ASoC: Fix dapm_is_shared_kcontrol so everything isn't shared
PATCH 1/1 ASoC: Fix dapm_is_shared_kcontrol so everything isn't shared
Commit af46800 ("ASoC: Implement mux control sharing") introduced function dapm_is_shared_kcontrol.
When this function returns true, the naming of DAPM controls is derived from the kcontrol_new. Otherwise, the name comes from the widget (and possibly a widget's naming prefix).
A bug in the implementation of dapm_is_shared_kcontrol made it return 1 in all cases. Hence, that commit caused a change in control naming for all controls instead of just shared controls.
Specifically, a control is always considered shared because it is always compared against itself. Solve this by never comparing against the widget containing the control being created.
Equally, controls should never be shared between DAPM contexts; when the same codec is instantiated multiple times, the same kcontrol_new will be used. However, the control should no be shared between the multiple instances.
I tested that with the Tegra WM8903 driver:
* Shared is now mostly 0 as expected, and sometimes 1.
* The expected controls are still generated after this change.
However, I don't have any systems that have a widget/control naming prefix, so I can't test that aspect.
Thanks for Jarkko Nikula for pointing out how to fix this.
v2:
* Don't share across DAPM contexts.
* Changed to Tested-by tag below for Jarkko.
--- sound/soc/soc-dapm.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
sound/soc/soc-dapm.c +4 -1
@@ -325,6 +325,7 @@ static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm, }static int dapm_is_shared_kcontrol (struct snd_soc_dapm_context *dapm, +struct snd_soc_dapm_widget *kcontrolw,const struct snd_kcontrol_new *kcontrol_new,struct snd_kcontrol **kcontrol) {
@@ -334,6 +335,8 @@ static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, *kcontrol =NULL ;list_for_each_entry (w, &dapm->card->widgets, list) { +if (w == kcontrolw || w->dapm != kcontrolw->dapm) +continue ;for (i =0 ; i < w->num_kcontrols; i++) {if (&w->kcontrol_news[i] == kcontrol_new) {if (w->kcontrols)
@@ -468,7 +471,7 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm,return -EINVAL ; } - shared =dapm_is_shared_kcontrol (dapm, &w->kcontrol_news[0 ], + shared =dapm_is_shared_kcontrol (dapm, w, &w->kcontrol_news[0 ], &kcontrol);if (kcontrol) { wlist = kcontrol->private_data;
Signature · 1 line
1.7.0.4
Quoted 33 lines · On Thu, 26 May 2011 09:57:33 -0600 Stephen Warren <[email protected]> wrote:
Commit af46800 ("ASoC: Implement mux control sharing") introduced function
dapm_is_shared_kcontrol.When this function returns true, the naming of DAPM controls is derived from the
kcontrol_new. Otherwise, the name comes from the widget (and possibly a widget's naming prefix).A bug in the implementation of
dapm_is_shared_kcontrolmade it return 1 in all cases. Hence, that commit caused a change in control naming for all controls instead of just shared controls.Specifically, a control is always considered shared because it is always compared against itself. Solve this by never comparing against the widget containing the control being created.
Equally, controls should never be shared between DAPM contexts; when the same codec is instantiated multiple times, the same
kcontrol_newwill be used. However, the control should no be shared between the multiple instances.I tested that with the Tegra WM8903 driver:
* Shared is now mostly 0 as expected, and sometimes 1.
* The expected controls are still generated after this change.However, I don't have any systems that have a widget/control naming prefix, so I can't test that aspect.
Thanks for Jarkko Nikula for pointing out how to fix this.
v2:
* Don't share across DAPM contexts.
* Changed to Tested-by tag below for Jarkko.
Quoted 7 lines
Reported-by Liam Girdwood <[email protected]>Tested-by Jarkko Nikula <[email protected]>Signed-off-by Stephen Warren <[email protected]>--- sound/soc/soc-dapm.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
Tested-by confirmation :-)
Signature · 1 line
Jarkko
Quoted 29 lines · Stephen Warren
Commit af46800 ("ASoC: Implement mux control sharing") introduced function
dapm_is_shared_kcontrol.When this function returns true, the naming of DAPM controls is derived from the
kcontrol_new. Otherwise, the name comes from the widget (and possibly a widget's naming prefix).A bug in the implementation of
dapm_is_shared_kcontrolmade it return 1 in all cases. Hence, that commit caused a change in control naming for all controls instead of just shared controls.Specifically, a control is always considered shared because it is always compared against itself. Solve this by never comparing against the widget containing the control being created.
Equally, controls should never be shared between DAPM contexts; when the same codec is instantiated multiple times, the same
kcontrol_newwill be used. However, the control should no be shared between the multiple instances.I tested that with the Tegra WM8903 driver:
* Shared is now mostly 0 as expected, and sometimes 1.
* The expected controls are still generated after this change.However, I don't have any systems that have a widget/control naming prefix, so I can't test that aspect.
Thanks for Jarkko Nikula for pointing out how to fix this.
Quoted 8 lines
v2:
* Don't share across DAPM contexts.
* Changed to Tested-by tag below for Jarkko.Reported-by Liam Girdwood <[email protected]>Tested-by Jarkko Nikula <[email protected]>Signed-off-by Stephen Warren <[email protected]>---
Mark Brown
AppliedQuoted 6 lines · Stephen Warren
Commit af46800 ("ASoC: Implement mux control sharing") introduced function
dapm_is_shared_kcontrol.When this function returns true, the naming of DAPM controls is derived from the
kcontrol_new. Otherwise, the name comes from the widget (and possibly a widget's naming prefix).
Applied, thanks.