aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-06-16 12:13:01 -0400
committerMark Brown <broonie@linaro.org>2014-06-21 16:03:22 -0400
commit94f99c875c109e51decf0d8c25ec2c946db20c56 (patch)
tree29bdcf055b85588e64553eec9353bf47919100c0 /sound/soc/soc-dapm.c
parent7171511eaec5bf23fb06078f59784a3a0626b38f (diff)
ASoC: Move name_prefix from CODEC to component
Move the name_prefix from the CODEC struct to the component struct. This will eventually allow to specify prefixes for all types of components. It is also necessary to make the DAPM code component type independent (i.e. a DAPM context does not need to know whether it belongs to a CODEC or a platform or something else). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a74b9bf23d9f..2f29b289a333 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -375,6 +375,13 @@ static void dapm_reset(struct snd_soc_card *card)
375 } 375 }
376} 376}
377 377
378static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm)
379{
380 if (!dapm->component)
381 return NULL;
382 return dapm->component->name_prefix;
383}
384
378static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg, 385static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg,
379 unsigned int *value) 386 unsigned int *value)
380{ 387{
@@ -570,11 +577,7 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w,
570 const char *name; 577 const char *name;
571 int ret; 578 int ret;
572 579
573 if (dapm->codec) 580 prefix = soc_dapm_prefix(dapm);
574 prefix = dapm->codec->name_prefix;
575 else
576 prefix = NULL;
577
578 if (prefix) 581 if (prefix)
579 prefix_len = strlen(prefix) + 1; 582 prefix_len = strlen(prefix) + 1;
580 else 583 else
@@ -2371,14 +2374,16 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
2371 const char *source; 2374 const char *source;
2372 char prefixed_sink[80]; 2375 char prefixed_sink[80];
2373 char prefixed_source[80]; 2376 char prefixed_source[80];
2377 const char *prefix;
2374 int ret; 2378 int ret;
2375 2379
2376 if (dapm->codec && dapm->codec->name_prefix) { 2380 prefix = soc_dapm_prefix(dapm);
2381 if (prefix) {
2377 snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", 2382 snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
2378 dapm->codec->name_prefix, route->sink); 2383 prefix, route->sink);
2379 sink = prefixed_sink; 2384 sink = prefixed_sink;
2380 snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", 2385 snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
2381 dapm->codec->name_prefix, route->source); 2386 prefix, route->source);
2382 source = prefixed_source; 2387 source = prefixed_source;
2383 } else { 2388 } else {
2384 sink = route->sink; 2389 sink = route->sink;
@@ -2439,6 +2444,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm,
2439 const char *source; 2444 const char *source;
2440 char prefixed_sink[80]; 2445 char prefixed_sink[80];
2441 char prefixed_source[80]; 2446 char prefixed_source[80];
2447 const char *prefix;
2442 2448
2443 if (route->control) { 2449 if (route->control) {
2444 dev_err(dapm->dev, 2450 dev_err(dapm->dev,
@@ -2446,12 +2452,13 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm,
2446 return -EINVAL; 2452 return -EINVAL;
2447 } 2453 }
2448 2454
2449 if (dapm->codec && dapm->codec->name_prefix) { 2455 prefix = soc_dapm_prefix(dapm);
2456 if (prefix) {
2450 snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", 2457 snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
2451 dapm->codec->name_prefix, route->sink); 2458 prefix, route->sink);
2452 sink = prefixed_sink; 2459 sink = prefixed_sink;
2453 snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", 2460 snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
2454 dapm->codec->name_prefix, route->source); 2461 prefix, route->source);
2455 source = prefixed_source; 2462 source = prefixed_source;
2456 } else { 2463 } else {
2457 sink = route->sink; 2464 sink = route->sink;
@@ -2968,6 +2975,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
2968 const struct snd_soc_dapm_widget *widget) 2975 const struct snd_soc_dapm_widget *widget)
2969{ 2976{
2970 struct snd_soc_dapm_widget *w; 2977 struct snd_soc_dapm_widget *w;
2978 const char *prefix;
2971 int ret; 2979 int ret;
2972 2980
2973 if ((w = dapm_cnew_widget(widget)) == NULL) 2981 if ((w = dapm_cnew_widget(widget)) == NULL)
@@ -3008,9 +3016,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3008 break; 3016 break;
3009 } 3017 }
3010 3018
3011 if (dapm->codec && dapm->codec->name_prefix) 3019 prefix = soc_dapm_prefix(dapm);
3012 w->name = kasprintf(GFP_KERNEL, "%s %s", 3020 if (prefix)
3013 dapm->codec->name_prefix, widget->name); 3021 w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
3014 else 3022 else
3015 w->name = kasprintf(GFP_KERNEL, "%s", widget->name); 3023 w->name = kasprintf(GFP_KERNEL, "%s", widget->name);
3016 3024