Commit 9b014266 authored by Jaroslav Kysela's avatar Jaroslav Kysela Committed by Mark Brown

ASoC: SOF: topology: use new sound control LED layer

Use the new sound control LED layer instead the direct ledtrig_audio_set()
call - see 22d8de62 ("ALSA: control - add generic LED trigger module
as the new control layer").
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220329120039.2394138-1-perex@perex.czSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 31231092
...@@ -15,36 +15,6 @@ ...@@ -15,36 +15,6 @@
#include "sof-priv.h" #include "sof-priv.h"
#include "sof-audio.h" #include "sof-audio.h"
static void update_mute_led(struct snd_sof_control *scontrol,
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int temp = 0;
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 IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO)
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);
#endif
}
int snd_sof_volume_get(struct snd_kcontrol *kcontrol, int snd_sof_volume_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
...@@ -121,9 +91,6 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol, ...@@ -121,9 +91,6 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg; const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg;
if (scontrol->led_ctl.use_led)
update_mute_led(scontrol, kcontrol, ucontrol);
if (tplg_ops->control->switch_put) if (tplg_ops->control->switch_put)
return tplg_ops->control->switch_put(scontrol, ucontrol); return tplg_ops->control->switch_put(scontrol, ucontrol);
......
...@@ -473,6 +473,7 @@ struct snd_sof_dev { ...@@ -473,6 +473,7 @@ struct snd_sof_dev {
struct list_head route_list; struct list_head route_list;
struct snd_soc_component *component; struct snd_soc_component *component;
u32 enabled_cores_mask; /* keep track of enabled cores */ u32 enabled_cores_mask; /* keep track of enabled cores */
bool led_present;
/* FW configuration */ /* FW configuration */
struct sof_ipc_window *info_window; struct sof_ipc_window *info_window;
......
...@@ -773,6 +773,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, ...@@ -773,6 +773,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,
struct snd_soc_tplg_mixer_control *mc = struct snd_soc_tplg_mixer_control *mc =
container_of(hdr, struct snd_soc_tplg_mixer_control, hdr); container_of(hdr, struct snd_soc_tplg_mixer_control, hdr);
int tlv[TLV_ITEMS]; int tlv[TLV_ITEMS];
unsigned int mask;
int ret; int ret;
/* validate topology data */ /* validate topology data */
...@@ -821,6 +822,16 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, ...@@ -821,6 +822,16 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,
goto err; goto err;
} }
if (scontrol->led_ctl.use_led) {
mask = scontrol->led_ctl.direction ? SNDRV_CTL_ELEM_ACCESS_MIC_LED :
SNDRV_CTL_ELEM_ACCESS_SPK_LED;
scontrol->access &= ~SNDRV_CTL_ELEM_ACCESS_LED_MASK;
scontrol->access |= mask;
kc->access &= ~SNDRV_CTL_ELEM_ACCESS_LED_MASK;
kc->access |= mask;
sdev->led_present = true;
}
dev_dbg(scomp->dev, "tplg: load kcontrol index %d chans %d\n", dev_dbg(scomp->dev, "tplg: load kcontrol index %d chans %d\n",
scontrol->comp_id, scontrol->num_channels); scontrol->comp_id, scontrol->num_channels);
...@@ -2027,6 +2038,7 @@ static struct snd_soc_tplg_ops sof_tplg_ops = { ...@@ -2027,6 +2038,7 @@ static struct snd_soc_tplg_ops sof_tplg_ops = {
int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
{ {
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
const struct firmware *fw; const struct firmware *fw;
int ret; int ret;
...@@ -2049,6 +2061,10 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) ...@@ -2049,6 +2061,10 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
} }
release_firmware(fw); release_firmware(fw);
if (ret >= 0 && sdev->led_present)
ret = snd_ctl_led_request();
return ret; return ret;
} }
EXPORT_SYMBOL(snd_sof_load_topology); EXPORT_SYMBOL(snd_sof_load_topology);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment