aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-03-09 06:33:09 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-03-09 07:36:14 -0500
commit3e5ff4dfa5a0a5627235a245665035597f050d86 (patch)
tree17c33ba548a997b23d2360b0aea948662868e98e /sound/soc
parent378a90f4540cc113e6ef36861ae914b0c63700a0 (diff)
ASoC: Fix double addition of prefixes due to widget prefixing
We're not only prefixing all controls, we're also prefixing the widget names in the runtime data. This causes us to add the prefix twice - once when using the widget name to generate the control name and once when adding the control. Really we shouldn't be prefixing the widget names at all, the matching code should be handing this as we always know which DAPM context a widget came from and always display the widget name in terms of a DAPM context. However, we're quite close to the merge window and that's relatively invasive. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reported-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/soc-dapm.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a6fb85d46416..e981a8339f88 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -366,7 +366,7 @@ static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,
366 struct snd_soc_dapm_widget *w) 366 struct snd_soc_dapm_widget *w)
367{ 367{
368 int i, ret = 0; 368 int i, ret = 0;
369 size_t name_len; 369 size_t name_len, prefix_len;
370 struct snd_soc_dapm_path *path; 370 struct snd_soc_dapm_path *path;
371 struct snd_card *card = dapm->card->snd_card; 371 struct snd_card *card = dapm->card->snd_card;
372 const char *prefix; 372 const char *prefix;
@@ -376,6 +376,11 @@ static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,
376 else 376 else
377 prefix = NULL; 377 prefix = NULL;
378 378
379 if (prefix)
380 prefix_len = strlen(prefix) + 1;
381 else
382 prefix_len = 0;
383
379 /* add kcontrol */ 384 /* add kcontrol */
380 for (i = 0; i < w->num_kcontrols; i++) { 385 for (i = 0; i < w->num_kcontrols; i++) {
381 386
@@ -403,8 +408,15 @@ static int dapm_new_mixer(struct snd_soc_dapm_context *dapm,
403 408
404 switch (w->id) { 409 switch (w->id) {
405 default: 410 default:
411 /* The control will get a prefix from
412 * the control creation process but
413 * we're also using the same prefix
414 * for widgets so cut the prefix off
415 * the front of the widget name.
416 */
406 snprintf(path->long_name, name_len, "%s %s", 417 snprintf(path->long_name, name_len, "%s %s",
407 w->name, w->kcontrols[i].name); 418 w->name + prefix_len,
419 w->kcontrols[i].name);
408 break; 420 break;
409 case snd_soc_dapm_mixer_named_ctl: 421 case snd_soc_dapm_mixer_named_ctl:
410 snprintf(path->long_name, name_len, "%s", 422 snprintf(path->long_name, name_len, "%s",
@@ -438,6 +450,7 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm,
438 struct snd_kcontrol *kcontrol; 450 struct snd_kcontrol *kcontrol;
439 struct snd_card *card = dapm->card->snd_card; 451 struct snd_card *card = dapm->card->snd_card;
440 const char *prefix; 452 const char *prefix;
453 size_t prefix_len;
441 int ret = 0; 454 int ret = 0;
442 455
443 if (!w->num_kcontrols) { 456 if (!w->num_kcontrols) {
@@ -450,7 +463,17 @@ static int dapm_new_mux(struct snd_soc_dapm_context *dapm,
450 else 463 else
451 prefix = NULL; 464 prefix = NULL;
452 465
453 kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name, prefix); 466 if (prefix)
467 prefix_len = strlen(prefix) + 1;
468 else
469 prefix_len = 0;
470
471 /* The control will get a prefix from the control creation
472 * process but we're also using the same prefix for widgets so
473 * cut the prefix off the front of the widget name.
474 */
475 kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name + prefix_len,
476 prefix);
454 ret = snd_ctl_add(card, kcontrol); 477 ret = snd_ctl_add(card, kcontrol);
455 478
456 if (ret < 0) 479 if (ret < 0)