提交 94f99c87 编写于 作者: L Lars-Peter Clausen 提交者: Mark Brown

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: NLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 7171511e
...@@ -682,6 +682,7 @@ struct snd_soc_component_driver { ...@@ -682,6 +682,7 @@ struct snd_soc_component_driver {
struct snd_soc_component { struct snd_soc_component {
const char *name; const char *name;
int id; int id;
const char *name_prefix;
struct device *dev; struct device *dev;
unsigned int active; unsigned int active;
...@@ -710,7 +711,6 @@ struct snd_soc_component { ...@@ -710,7 +711,6 @@ struct snd_soc_component {
/* SoC Audio Codec device */ /* SoC Audio Codec device */
struct snd_soc_codec { struct snd_soc_codec {
const char *name; const char *name;
const char *name_prefix;
int id; int id;
struct device *dev; struct device *dev;
const struct snd_soc_codec_driver *driver; const struct snd_soc_codec_driver *driver;
......
...@@ -1108,7 +1108,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card) ...@@ -1108,7 +1108,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card)
} }
static void soc_set_name_prefix(struct snd_soc_card *card, static void soc_set_name_prefix(struct snd_soc_card *card,
struct snd_soc_codec *codec) struct snd_soc_component *component)
{ {
int i; int i;
...@@ -1117,11 +1117,11 @@ static void soc_set_name_prefix(struct snd_soc_card *card, ...@@ -1117,11 +1117,11 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
for (i = 0; i < card->num_configs; i++) { for (i = 0; i < card->num_configs; i++) {
struct snd_soc_codec_conf *map = &card->codec_conf[i]; struct snd_soc_codec_conf *map = &card->codec_conf[i];
if (map->of_node && codec->dev->of_node != map->of_node) if (map->of_node && component->dev->of_node != map->of_node)
continue; continue;
if (map->dev_name && strcmp(codec->name, map->dev_name)) if (map->dev_name && strcmp(component->name, map->dev_name))
continue; continue;
codec->name_prefix = map->name_prefix; component->name_prefix = map->name_prefix;
break; break;
} }
} }
...@@ -1135,7 +1135,7 @@ static int soc_probe_codec(struct snd_soc_card *card, ...@@ -1135,7 +1135,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
codec->card = card; codec->card = card;
codec->dapm.card = card; codec->dapm.card = card;
soc_set_name_prefix(card, codec); soc_set_name_prefix(card, &codec->component);
if (!try_module_get(codec->dev->driver->owner)) if (!try_module_get(codec->dev->driver->owner))
return -ENODEV; return -ENODEV;
...@@ -2403,7 +2403,7 @@ int snd_soc_add_codec_controls(struct snd_soc_codec *codec, ...@@ -2403,7 +2403,7 @@ int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
struct snd_card *card = codec->card->snd_card; struct snd_card *card = codec->card->snd_card;
return snd_soc_add_controls(card, codec->dev, controls, num_controls, return snd_soc_add_controls(card, codec->dev, controls, num_controls,
codec->name_prefix, &codec->component); codec->component.name_prefix, &codec->component);
} }
EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls);
......
...@@ -375,6 +375,13 @@ static void dapm_reset(struct snd_soc_card *card) ...@@ -375,6 +375,13 @@ static void dapm_reset(struct snd_soc_card *card)
} }
} }
static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm)
{
if (!dapm->component)
return NULL;
return dapm->component->name_prefix;
}
static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg, static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg,
unsigned int *value) unsigned int *value)
{ {
...@@ -570,11 +577,7 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, ...@@ -570,11 +577,7 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w,
const char *name; const char *name;
int ret; int ret;
if (dapm->codec) prefix = soc_dapm_prefix(dapm);
prefix = dapm->codec->name_prefix;
else
prefix = NULL;
if (prefix) if (prefix)
prefix_len = strlen(prefix) + 1; prefix_len = strlen(prefix) + 1;
else else
...@@ -2371,14 +2374,16 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, ...@@ -2371,14 +2374,16 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
const char *source; const char *source;
char prefixed_sink[80]; char prefixed_sink[80];
char prefixed_source[80]; char prefixed_source[80];
const char *prefix;
int ret; int ret;
if (dapm->codec && dapm->codec->name_prefix) { prefix = soc_dapm_prefix(dapm);
if (prefix) {
snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
dapm->codec->name_prefix, route->sink); prefix, route->sink);
sink = prefixed_sink; sink = prefixed_sink;
snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
dapm->codec->name_prefix, route->source); prefix, route->source);
source = prefixed_source; source = prefixed_source;
} else { } else {
sink = route->sink; sink = route->sink;
...@@ -2439,6 +2444,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, ...@@ -2439,6 +2444,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm,
const char *source; const char *source;
char prefixed_sink[80]; char prefixed_sink[80];
char prefixed_source[80]; char prefixed_source[80];
const char *prefix;
if (route->control) { if (route->control) {
dev_err(dapm->dev, dev_err(dapm->dev,
...@@ -2446,12 +2452,13 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, ...@@ -2446,12 +2452,13 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm,
return -EINVAL; return -EINVAL;
} }
if (dapm->codec && dapm->codec->name_prefix) { prefix = soc_dapm_prefix(dapm);
if (prefix) {
snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s",
dapm->codec->name_prefix, route->sink); prefix, route->sink);
sink = prefixed_sink; sink = prefixed_sink;
snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", snprintf(prefixed_source, sizeof(prefixed_source), "%s %s",
dapm->codec->name_prefix, route->source); prefix, route->source);
source = prefixed_source; source = prefixed_source;
} else { } else {
sink = route->sink; sink = route->sink;
...@@ -2968,6 +2975,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, ...@@ -2968,6 +2975,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_widget *widget) const struct snd_soc_dapm_widget *widget)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
const char *prefix;
int ret; int ret;
if ((w = dapm_cnew_widget(widget)) == NULL) if ((w = dapm_cnew_widget(widget)) == NULL)
...@@ -3008,9 +3016,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, ...@@ -3008,9 +3016,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
break; break;
} }
if (dapm->codec && dapm->codec->name_prefix) prefix = soc_dapm_prefix(dapm);
w->name = kasprintf(GFP_KERNEL, "%s %s", if (prefix)
dapm->codec->name_prefix, widget->name); w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
else else
w->name = kasprintf(GFP_KERNEL, "%s", widget->name); w->name = kasprintf(GFP_KERNEL, "%s", widget->name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册