ASoC: Fix prefixing of DAPM controls by factoring prefix into snd_soc_cnew()
PATCH 1/1 ASoC: Fix prefixing of DAPM controls by factoring prefix into snd_soc_cnew()
Currently will ignore prefixes when creating DAPM controls. Since currently all control creation goes through snd_soc_cnew() we can fix this by factoring the prefixing into that function.
--- include/sound/soc.h | 3 ++- sound/soc/soc-core.c | 45 +++++++++++++++++++++++++++++++-------------- sound/soc/soc-dapm.c | 16 ++++++++++++++-- 3 files changed, 47 insertions(+), 17 deletions(-)
include/sound/soc.h +2 -1
@@ -341,7 +341,8 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);*Controls */ struct snd_kcontrol *snd_soc_cnew (const struct snd_kcontrol_new *_template, -void *data,char *long_name); +void *data,char *long_name, +const char *prefix);int snd_soc_add_controls (struct snd_soc_codec *codec,const struct snd_kcontrol_new *controls,int num_controls); int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
sound/soc/soc-core.c +31 -14
75 lines not on this page · raw message
sound/soc/soc-dapm.c +14 -2
@@ -369,6 +369,12 @@ static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,size_t name_len;struct snd_soc_dapm_path *path;struct snd_card *card = dapm->card->snd_card; +const char *prefix; + +if (dapm->codec) + prefix = dapm->codec->name_prefix; +else + prefix =NULL ;/* add kcontrol */ for (i =0 ; i < w->num_kcontrols; i++) {
@@ -409,7 +415,7 @@ static int dapm_new_mixer(struct snd_soc_dapm_context *dapm, path->long_name[name_len -1 ] ='\0' ; path->kcontrol =snd_soc_cnew (&w->kcontrols[i], w, - path->long_name); + path->long_name, prefix); ret =snd_ctl_add (card, path->kcontrol);if (ret <0 ) { dev_err(dapm->dev,
@@ -431,6 +437,7 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm,struct snd_soc_dapm_path *path =NULL ;struct snd_kcontrol *kcontrol;struct snd_card *card = dapm->card->snd_card; +const char *prefix;int ret =0 ;if (!w->num_kcontrols) {
@@ -438,7 +445,12 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm,return -EINVAL ; } - kcontrol =snd_soc_cnew (&w->kcontrols[0 ], w, w->name); +if (dapm->codec) + prefix = dapm->codec->name_prefix; +else + prefix =NULL ; + + kcontrol =snd_soc_cnew (&w->kcontrols[0 ], w, w->name, prefix); ret =snd_ctl_add (card, kcontrol);if (ret <0 )
Signature · 1 line
1.7.2.3
Quoted 5 lines · Mark Brown
Currently will ignore prefixes when creating DAPM controls. Since currently all control creation goes through
snd_soc_cnew()we can fix this by factoring the prefixing into that function.Signed-off-by Mark Brown <[email protected]>
Quoted 9 lines · On Tue, 08 Mar 2011 18:01:21 +0000 Liam Girdwood <[email protected]> wrote:
Quoted 5 lines · Mark Brown
Currently will ignore prefixes when creating DAPM controls. Since currently all control creation goes through
snd_soc_cnew()we can fix this by factoring the prefixing into that function.Signed-off-by Mark Brown <[email protected]>Acked-by Liam Girdwood <[email protected]>
Unfortunately this leads to double prefixing to mixer and mux controls on Nokia RX-51/N900 in today's head. Reason there is that the snd_soc_dapm_new_control has already added the prefix to widget name and the dapm_new_mixer/mux takes this prefixed w->name and prefixes it again.
codec driver or soc_probe_codec
-> snd_soc_dapm_new_controls
-> snd_soc_dapm_new_control: prefix added to w->name
soc_post_component_init
-> snd_soc_dapm_new_widgets
-> dapm_new_mixer/mux: prefix added again to w->name
Signature · 1 line
Jarkko
Quoted 5 lines · Jarkko Nikula
Unfortunately this leads to double prefixing to mixer and mux controls on Nokia RX-51/N900 in today's head. Reason there is that the
snd_soc_dapm_new_controlhas already added the prefix to widget name and the dapm_new_mixer/mux takes this prefixedw->nameand prefixes it again.
The system I'm using isn't affected as there's no unnamed mixers in it. I rather suspect this means that the old code is broken for named mixers. Working on a fix just now.
Quoted 11 lines · On Wed, 9 Mar 2011 11:03:14 +0000 Mark Brown…
Quoted 5 lines · Jarkko Nikula
Unfortunately this leads to double prefixing to mixer and mux controls on Nokia RX-51/N900 in today's head. Reason there is that the
snd_soc_dapm_new_controlhas already added the prefix to widget name and the dapm_new_mixer/mux takes this prefixedw->nameand prefixes it again.The system I'm using isn't affected as there's no unnamed mixers in it. I rather suspect this means that the old code is broken for named mixers. Working on a fix just now.
Yeah, just realized the prefixing indeed was broken originally for named mixers in sound/soc/soc-dapm.c: dapm_new_mixer as only w->name carried the prefix and which is not included for snd_soc_dapm_mixer_named_ctl case. My bad...
switch (w->id) {
default:
snprintf(path->long_name, name_len, "%s %s", w->name, w->kcontrols[i].name); break; case snd_soc_dapm_mixer_named_ctl: snprintf(path->long_name, name_len, "%s", w->kcontrols[i].name); break; }
Signature · 1 line
Jarkko