aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--include/sound/soc.h2
-rw-r--r--sound/soc/soc-core.c12
-rw-r--r--sound/soc/soc-dapm.c36
3 files changed, 29 insertions, 21 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index ed9e2d7e5fdc..e1cce0042f8a 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -682,6 +682,7 @@ struct snd_soc_component_driver {
682struct snd_soc_component { 682struct snd_soc_component {
683 const char *name; 683 const char *name;
684 int id; 684 int id;
685 const char *name_prefix;
685 struct device *dev; 686 struct device *dev;
686 687
687 unsigned int active; 688 unsigned int active;
@@ -710,7 +711,6 @@ struct snd_soc_component {
710/* SoC Audio Codec device */ 711/* SoC Audio Codec device */
711struct snd_soc_codec { 712struct snd_soc_codec {
712 const char *name; 713 const char *name;
713 const char *name_prefix;
714 int id; 714 int id;
715 struct device *dev; 715 struct device *dev;
716 const struct snd_soc_codec_driver *driver; 716 const struct snd_soc_codec_driver *driver;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b87d7d882e6d..ba822e927187 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1108,7 +1108,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card)
1108} 1108}
1109 1109
1110static void soc_set_name_prefix(struct snd_soc_card *card, 1110static void soc_set_name_prefix(struct snd_soc_card *card,
1111 struct snd_soc_codec *codec) 1111 struct snd_soc_component *component)
1112{ 1112{
1113 int i; 1113 int i;
1114 1114
@@ -1117,11 +1117,11 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
1117 1117
1118 for (i = 0; i < card->num_configs; i++) { 1118 for (i = 0; i < card->num_configs; i++) {
1119 struct snd_soc_codec_conf *map = &card->codec_conf[i]; 1119 struct snd_soc_codec_conf *map = &card->codec_conf[i];
1120 if (map->of_node && codec->dev->of_node != map->of_node) 1120 if (map->of_node && component->dev->of_node != map->of_node)
1121 continue; 1121 continue;
1122 if (map->dev_name && strcmp(codec->name, map->dev_name)) 1122 if (map->dev_name && strcmp(component->name, map->dev_name))
1123 continue; 1123 continue;
1124 codec->name_prefix = map->name_prefix; 1124 component->name_prefix = map->name_prefix;
1125 break; 1125 break;
1126 } 1126 }
1127} 1127}
@@ -1135,7 +1135,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
1135 1135
1136 codec->card = card; 1136 codec->card = card;
1137 codec->dapm.card = card; 1137 codec->dapm.card = card;
1138 soc_set_name_prefix(card, codec); 1138 soc_set_name_prefix(card, &codec->component);
1139 1139
1140 if (!try_module_get(codec->dev->driver->owner)) 1140 if (!try_module_get(codec->dev->driver->owner))
1141 return -ENODEV; 1141 return -ENODEV;
@@ -2403,7 +2403,7 @@ int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
2403 struct snd_card *card = codec->card->snd_card; 2403 struct snd_card *card = codec->card->snd_card;
2404 2404
2405 return snd_soc_add_controls(card, codec->dev, controls, num_controls, 2405 return snd_soc_add_controls(card, codec->dev, controls, num_controls,
2406 codec->name_prefix, &codec->component); 2406 codec->component.name_prefix, &codec->component);
2407} 2407}
2408EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); 2408EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls);
2409 2409
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