ASoC: SOF: topology: use new sound control LED layer
Subsystems (3)
Jaroslav Kysela
maintainerPATCH 1/1 ASoC: SOF: topology: use new sound control LED layer
Use the new sound control LED layer instead the direct ledtrig_audio_set() call - see 22d8de62f11b ("ALSA: control - add generic LED trigger module as the new control layer").
--- sound/soc/sof/control.c | 33 --------------------------------- sound/soc/sof/topology.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 33 deletions(-)
sound/soc/sof/control.c +0 -33
@@ -15,36 +15,6 @@#include "sof-priv.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,struct snd_ctl_elem_value *ucontrol) {
@@ -121,9 +91,6 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);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)return tplg_ops->control->switch_put (scontrol, ucontrol);
sound/soc/sof/topology.c +10 -0
@@ -773,6 +773,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,struct snd_soc_tplg_mixer_control *mc = container_of(hdr, struct snd_soc_tplg_mixer_control, hdr);int tlv[TLV_ITEMS ]; +unsigned int mask;int ret;/* validate topology data */
@@ -821,6 +822,15 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, 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; + } +dev_dbg (scomp->dev,"tplg: load kcontrol index %d chans %d\n" , scontrol->comp_id, scontrol->num_channels);
Signature · 1 line
2.34.1
Péter Ujfalusi
maintainerHi Jaroslav,
Quoted 3 lines · Jaroslav Kysela
Use the new sound control LED layer instead the direct
ledtrig_audio_set()call - see22d8de62f11b("ALSA: control - add generic LED trigger module as the new control layer").
Don't we need to select SND_CTL_LED from SOF to make sure that the LED trigger module is available?
Quoted 89 lines
Signed-off-by Jaroslav Kysela <[email protected]>Cc Ranjani Sridharan <[email protected]>Cc Bard Liao <[email protected]>Cc Péter Ujfalusi <[email protected]>Cc Pierre-Louis Bossart <[email protected]>--- sound/soc/sof/control.c | 33 --------------------------------- sound/soc/sof/topology.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 33 deletions(-)sound/soc/sof/control.c +0
-33@@ -15,36 +15,6 @@#include "sof-priv.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,struct snd_ctl_elem_value *ucontrol) {@@ -121,9 +91,6 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);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)return tplg_ops->control->switch_put (scontrol, ucontrol);sound/soc/sof/topology.c +10
-0@@ -773,6 +773,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,struct snd_soc_tplg_mixer_control *mc = container_of(hdr, struct snd_soc_tplg_mixer_control, hdr);int tlv[TLV_ITEMS ]; +unsigned int mask;int ret;/* validate topology data */ @@ -821,6 +822,15 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, 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; + } +dev_dbg (scomp->dev,"tplg: load kcontrol index %d chans %d\n" , scontrol->comp_id, scontrol->num_channels);
Signature · 1 line
Péter
Jaroslav Kysela
maintainerQuoted 9 lines · Péter Ujfalusi
Hi Jaroslav,
Quoted 3 lines · Jaroslav Kysela
Use the new sound control LED layer instead the direct
ledtrig_audio_set()call - see22d8de62f11b("ALSA: control - add generic LED trigger module as the new control layer").Don't we need to select
SND_CTL_LEDfrom SOF to make sure that the LED trigger module is available?
This feature is optional and the current code does not even forcefully select the LEDS_TRIGGERS and LEDS_TRIGGER_AUDIO, too. There was IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO) condition. I think that this change should be handled separately (if required).
Unfortunately, I forgot to call snd_ctl_led_request() to load the LED trigger module when available. I will send v2 ASAP.
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.