alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org,
	Mark Brown <broonie@kernel.org>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [alsa-devel] Applied "ASoC: SOF: acpi led support for switch controls" to the asoc tree
Date: Thu, 10 Oct 2019 15:22:31 +0100 (BST)	[thread overview]
Message-ID: <20191010142231.2B252D0003C@fitzroy.sirena.org.uk> (raw)
In-Reply-To: <20191008164443.1358-10-pierre-louis.bossart@linux.intel.com>

The patch

   ASoC: SOF: acpi led support for switch controls

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 5d43001ae43606dc525f55c482c545afba01bb55 Mon Sep 17 00:00:00 2001
From: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Date: Tue, 8 Oct 2019 11:44:43 -0500
Subject: [PATCH] ASoC: SOF: acpi led support for switch controls

Currently sof doesn't support acpi leds with mute switches. So implement
acpi leds following quite shamelessly existing HDA implementation by
Takashi Iwai.

Mute leds can be enabled in topology by adding led and direction token
in switch control private data.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191008164443.1358-10-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/uapi/sound/sof/tokens.h |  4 ++++
 sound/soc/sof/control.c         | 32 ++++++++++++++++++++++++++++++++
 sound/soc/sof/sof-priv.h        |  9 +++++++++
 sound/soc/sof/topology.c        | 13 +++++++++++++
 4 files changed, 58 insertions(+)

diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h
index da18c9de1056..d65406f34361 100644
--- a/include/uapi/sound/sof/tokens.h
+++ b/include/uapi/sound/sof/tokens.h
@@ -113,4 +113,8 @@
 /* ESAI */
 #define SOF_TKN_IMX_ESAI_MCLK_ID		1100
 
+/* Led control for mute switches */
+#define SOF_TKN_MUTE_LED_USE			1300
+#define SOF_TKN_MUTE_LED_DIRECTION		1301
+
 #endif
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index a4983f90ff5b..41551e8f6ac3 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -11,8 +11,37 @@
 /* Mixer Controls */
 
 #include <linux/pm_runtime.h>
+#include <linux/leds.h>
 #include "sof-priv.h"
 
+static void update_mute_led(struct snd_sof_control *scontrol,
+			    struct snd_kcontrol *kcontrol,
+			    struct snd_ctl_elem_value *ucontrol)
+{
+	unsigned int temp = 0;
+	unsigned int mask;
+	int i;
+
+	mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+
+	for (i = 0; i < scontrol->num_channels; i++) {
+		if (ucontrol->value.integer.value[i]) {
+			temp |= mask;
+			break;
+		}
+	}
+
+	if (temp == scontrol->led_ctl.led_value)
+		return;
+
+	scontrol->led_ctl.led_value = temp;
+
+	if (!scontrol->led_ctl.direction)
+		ledtrig_audio_set(LED_AUDIO_MUTE, temp ? LED_OFF : LED_ON);
+	else
+		ledtrig_audio_set(LED_AUDIO_MICMUTE, temp ? LED_OFF : LED_ON);
+}
+
 static inline u32 mixer_to_ipc(unsigned int value, u32 *volume_map, int size)
 {
 	if (value >= size)
@@ -112,6 +141,9 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
 		cdata->chanv[i].channel = i;
 	}
 
+	if (scontrol->led_ctl.use_led)
+		update_mute_led(scontrol, kcontrol, ucontrol);
+
 	/* notify DSP of mixer updates */
 	if (pm_runtime_active(sdev->dev))
 		snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
index 44f789bf7fb0..5a11a8517fa5 100644
--- a/sound/soc/sof/sof-priv.h
+++ b/sound/soc/sof/sof-priv.h
@@ -15,6 +15,7 @@
 
 #include <sound/hdaudio.h>
 #include <sound/soc.h>
+#include <sound/control.h>
 
 #include <sound/sof.h>
 #include <sound/sof/stream.h> /* needs to be included before control.h */
@@ -310,6 +311,12 @@ struct snd_sof_pcm {
 	bool prepared[2]; /* PCM_PARAMS set successfully */
 };
 
+struct snd_sof_led_control {
+	unsigned int use_led;
+	unsigned int direction;
+	unsigned int led_value;
+};
+
 /* ALSA SOF Kcontrol device */
 struct snd_sof_control {
 	struct snd_sof_dev *sdev;
@@ -324,6 +331,8 @@ struct snd_sof_control {
 	u32 *volume_table; /* volume table computed from tlv data*/
 
 	struct list_head list;	/* list in sdev control list */
+
+	struct snd_sof_led_control led_ctl;
 };
 
 /* ASoC SOF DAPM widget */
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 3918301c573b..2e5fab1cfbb4 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -682,6 +682,14 @@ static const struct sof_topology_token dmic_pdm_tokens[] = {
 static const struct sof_topology_token hda_tokens[] = {
 };
 
+/* Leds */
+static const struct sof_topology_token led_tokens[] = {
+	{SOF_TKN_MUTE_LED_USE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
+	 offsetof(struct snd_sof_led_control, use_led), 0},
+	{SOF_TKN_MUTE_LED_DIRECTION, SND_SOC_TPLG_TUPLE_TYPE_WORD,
+	 get_token_u32, offsetof(struct snd_sof_led_control, direction), 0},
+};
+
 static void sof_parse_uuid_tokens(struct snd_soc_component *scomp,
 				  void *object,
 				  const struct sof_topology_token *tokens,
@@ -944,6 +952,11 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,
 	}
 
 out:
+	/* set up possible led control from mixer private data */
+	ret = sof_parse_tokens(scomp, &scontrol->led_ctl, led_tokens,
+			       ARRAY_SIZE(led_tokens), mc->priv.array,
+			       le32_to_cpu(mc->priv.size));
+
 	dev_dbg(sdev->dev, "tplg: load kcontrol index %d chans %d\n",
 		scontrol->comp_id, scontrol->num_channels);
 
-- 
2.20.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

      reply	other threads:[~2019-10-10 14:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 16:44 [alsa-devel] [PATCH 0/9] ASoC: SOF updates for Intel/i.MX Pierre-Louis Bossart
2019-10-08 16:44 ` [alsa-devel] [PATCH 1/9] ASoC: SOF: enable sync_write in hdac_bus Pierre-Louis Bossart
2019-10-10 14:22   ` [alsa-devel] Applied "ASoC: SOF: enable sync_write in hdac_bus" to the asoc tree Mark Brown
2019-10-08 16:44 ` [alsa-devel] [PATCH 2/9] Revert "ASoC: SOF: Force polling mode on CFL and CNL" Pierre-Louis Bossart
2019-10-10 14:08   ` Mark Brown
2019-10-10 15:41     ` Pierre-Louis Bossart
2019-10-10 14:22   ` [alsa-devel] Applied "Revert "ASoC: SOF: Force polling mode on CFL and CNL"" to the asoc tree Mark Brown
2019-10-08 16:44 ` [alsa-devel] [PATCH 3/9] ASoC: SOF: acpi: add debug module param Pierre-Louis Bossart
2019-10-10 14:22   ` [alsa-devel] Applied "ASoC: SOF: acpi: add debug module param" to the asoc tree Mark Brown
2019-10-08 16:44 ` [alsa-devel] [PATCH 4/9] ASoC: SOF: pci: add debug module param Pierre-Louis Bossart
2019-10-10 14:22   ` [alsa-devel] Applied "ASoC: SOF: pci: add debug module param" to the asoc tree Mark Brown
2019-10-08 16:44 ` [alsa-devel] [PATCH 5/9] ASoC: SOF: imx: Describe ESAI parameters to be sent to DSP Pierre-Louis Bossart
2019-10-10 14:22   ` [alsa-devel] Applied "ASoC: SOF: imx: Describe ESAI parameters to be sent to DSP" to the asoc tree Mark Brown
2019-10-08 16:44 ` [alsa-devel] [PATCH 6/9] ASoC: SOF: imx: Read ESAI parameters and send them to DSP Pierre-Louis Bossart
2019-10-10 14:22   ` [alsa-devel] Applied "ASoC: SOF: imx: Read ESAI parameters and send them to DSP" to the asoc tree Mark Brown
2019-10-08 16:44 ` [alsa-devel] [PATCH 7/9] ASoC: SOF: enable dual control for pga Pierre-Louis Bossart
2019-10-10 14:22   ` [alsa-devel] Applied "ASoC: SOF: enable dual control for pga" to the asoc tree Mark Brown
2019-10-08 16:44 ` [alsa-devel] [PATCH 8/9] AsoC: SOF: refactor control load code Pierre-Louis Bossart
2019-10-10 14:22   ` [alsa-devel] Applied "AsoC: SOF: refactor control load code" to the asoc tree Mark Brown
2019-10-08 16:44 ` [alsa-devel] [PATCH 9/9] ASoC: SOF: acpi led support for switch controls Pierre-Louis Bossart
2019-10-10 14:22   ` Mark Brown [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191010142231.2B252D0003C@fitzroy.sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=jaska.uimonen@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).