ASoC: SOF: topology: use new sound control LED layer
Subsystems (3)
Jaroslav Kysela
maintainerPATCH v2 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").
-----
v2:
- add Mark to Cc:
- add snd_ctl_led_request() call
--- sound/soc/sof/control.c | 33 --------------------------------- sound/soc/sof/sof-priv.h | 1 + sound/soc/sof/topology.c | 16 ++++++++++++++++ 3 files changed, 17 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/sof-priv.h +1 -0
@@ -473,6 +473,7 @@ struct snd_sof_dev {struct list_head route_list;struct snd_soc_component *component;u32 enabled_cores_mask;/* keep track of enabled cores */ +bool led_present;/* FW configuration */ struct sof_ipc_window *info_window;
sound/soc/sof/topology.c +16 -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,16 @@ 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; + sdev->led_present = true; + } +dev_dbg (scomp->dev,"tplg: load kcontrol index %d chans %d\n" , scontrol->comp_id, scontrol->num_channels);
@@ -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) { +struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);const struct firmware *fw;int ret;
@@ -2049,6 +2061,10 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) }release_firmware (fw); + +if (ret >=0 && sdev->led_present) + ret =snd_ctl_led_request (); +return ret; }EXPORT_SYMBOL (snd_sof_load_topology);
Signature · 1 line
2.34.1
Quoted 122 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").Signed-off-by Jaroslav Kysela <[email protected]>Cc Mark Brown <[email protected]>Cc Ranjani Sridharan <[email protected]>Cc Bard Liao <[email protected]>Cc Péter Ujfalusi <[email protected]>Cc Pierre-Louis Bossart <[email protected]>-----
v2:
- add Mark to Cc:
- addsnd_ctl_led_request()call--- sound/soc/sof/control.c | 33 --------------------------------- sound/soc/sof/sof-priv.h | 1 + sound/soc/sof/topology.c | 16 ++++++++++++++++ 3 files changed, 17 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/sof-priv.h +1
-0@@ -473,6 +473,7 @@ struct snd_sof_dev {struct list_head route_list;struct snd_soc_component *component;u32 enabled_cores_mask;/* keep track of enabled cores */ +bool led_present;/* FW configuration */ struct sof_ipc_window *info_window;sound/soc/sof/topology.c +12
-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,16 @@ 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; + sdev->led_present = true; + } +dev_dbg (scomp->dev,"tplg: load kcontrol index %d chans %d\n" , scontrol->comp_id, scontrol->num_channels);@@ -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) { +struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);const struct firmware *fw;int ret;
sound/soc/sof/topology.c int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) · line 2061
Quoted 1 line
sound/soc/sof/topology.c +0
-0@@ -2049,6 +2061,10 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) }
Nitpick, but I would probably done:
- }
+ } else if (sdev->led_present) {
+ ret = snd_ctl_led_request();
+ }
Quoted 9 lines
sound/soc/sof/topology.c +4
-0release_firmware (fw); + +if (ret >=0 && sdev->led_present) + ret =snd_ctl_led_request (); +return ret; }EXPORT_SYMBOL (snd_sof_load_topology);
Signature · 1 line
Péter
Quoted 13 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").Signed-off-by Jaroslav Kysela <[email protected]>Cc Mark Brown <[email protected]>Cc Ranjani Sridharan <[email protected]>Cc Bard Liao <[email protected]>Cc Péter Ujfalusi <[email protected]>Cc Pierre-Louis Bossart <[email protected]>
Quoted 4 lines
-----
v2:
- add Mark to Cc:
- addsnd_ctl_led_request()call
Looks good. Thanks, Jaroslav.
Mark Brown
maintainerQuoted 4 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").
Quoted 8 lines
Signed-off-by Jaroslav Kysela <[email protected]>Cc Mark Brown <[email protected]>Cc Ranjani Sridharan <[email protected]>Cc Bard Liao <[email protected]>Cc Péter Ujfalusi <[email protected]>Cc Pierre-Louis Bossart <[email protected]>[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: SOF: topology: use new sound control LED layer
commit: 9b014266ef8ad0159b39920a752f191bcd6f356c
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
Quoted 10 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").Signed-off-by Jaroslav Kysela <[email protected]>Cc Mark Brown <[email protected]>Cc Ranjani Sridharan <[email protected]>Cc Bard Liao <[email protected]>Cc Péter Ujfalusi <[email protected]>Cc Pierre-Louis Bossart <[email protected]>
LGTM - how many engineers does it take to turn on a LED :-)
Quoted 122 lines
-----
v2:
- add Mark to Cc:
- addsnd_ctl_led_request()call--- sound/soc/sof/control.c | 33 --------------------------------- sound/soc/sof/sof-priv.h | 1 + sound/soc/sof/topology.c | 16 ++++++++++++++++ 3 files changed, 17 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/sof-priv.h +1
-0@@ -473,6 +473,7 @@ struct snd_sof_dev {struct list_head route_list;struct snd_soc_component *component;u32 enabled_cores_mask;/* keep track of enabled cores */ +bool led_present;/* FW configuration */ struct sof_ipc_window *info_window;sound/soc/sof/topology.c +16
-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,16 @@ 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; + sdev->led_present = true; + } +dev_dbg (scomp->dev,"tplg: load kcontrol index %d chans %d\n" , scontrol->comp_id, scontrol->num_channels);@@ -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) { +struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);const struct firmware *fw;int ret;@@ -2049,6 +2061,10 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) }release_firmware (fw); + +if (ret >=0 && sdev->led_present) + ret =snd_ctl_led_request (); +return ret; }EXPORT_SYMBOL (snd_sof_load_topology);