From: Mengdong Lin mengdong.lin@linux.intel.com
Machine drivers can set the name of one or more auxiliary components. And the ASoC core will find and probe the auxiliary components.
Machine drivers can use this to specify the components with topology. Then when the components are probed, topology info will be loaded to the core.
Signed-off-by: Mengdong Lin mengdong.lin@linux.intel.com
diff --git a/include/sound/soc.h b/include/sound/soc.h index 9a0e0e8..13e1409 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1070,6 +1070,11 @@ struct snd_soc_aux_dev { int (*init)(struct snd_soc_component *component); };
+struct snd_soc_aux_component { + const char *name; + struct snd_soc_component *comp; +}; + /* SoC card */ struct snd_soc_card { const char *name; @@ -1114,6 +1119,10 @@ struct snd_soc_card { struct list_head dai_link_list; /* all links */ int num_dai_links;
+ /* auxiliary components, e.g. topology */ + struct snd_soc_aux_component *aux_components; + int num_aux_components; + struct list_head rtd_list; int num_rtd;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index cb49a31..23d067ae 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1767,6 +1767,18 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) goto base_error; }
+ /* find auxiliary components */ + for (i = 0; i < card->num_aux_components; i++) { + card->aux_components[i].comp = + soc_find_component(NULL, card->aux_components[i].name); + if (!card->aux_components[i].comp) { + dev_err(card->dev, "ASoC: Aux component %s not registered\n", + card->aux_components[i].name); + ret = -EPROBE_DEFER; + goto base_error; + } + } + /* add predefined DAI links to the list */ for (i = 0; i < card->num_links; i++) snd_soc_add_dai_link(card, card->dai_link+i); @@ -1821,6 +1833,21 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) goto card_probe_error; }
+ /* probe auxiliary components */ + for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; + order++) { + for (i = 0; i < card->num_aux_components; i++) { + ret = soc_probe_component(card, + card->aux_components[i].comp); + if (ret < 0) { + dev_err(card->dev, + "ASoC: failed to probe aux component %s %d\n", + card->aux_components[i].name, ret); + goto probe_dai_err; + } + } + } + /* probe all components used by DAI links on this card */ for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; order++) {