Skip to contentSkip to conversation

ASoC: bind new DAI links after probing components.

RFC PATCH Superseded [email protected] 1 participant 1 message Aug 10, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 6/10 ASoC: bind new DAI links after probing components.

From: Mengdong Lin <[email protected]>

Probing components can bring new DAI or DAI links based on the topology info. This patch finds the unbound DAI links and bind them.

sound/soc/soc-core.c +29 -0
index f552fa0..2818709 100644
@@ -1169,6 +1169,19 @@ static void soc_remove_dai_links(struct snd_soc_card *card)
 	}
 }
 
+static bool soc_is_dai_link_bound(struct snd_soc_card *card,
+		struct snd_soc_dai_link *dai_link)
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	list_for_each_entry(rtd, &card->rtd_list, list) {
+		if (rtd->dai_link == dai_link)
+			return true;
+	}
+
+	return false;
+}
+
 static int snd_soc_init_multicodec(struct snd_soc_card *card,
 				   struct snd_soc_dai_link *dai_link)
 {
@@ -1763,6 +1776,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 {
 	struct snd_soc_codec *codec;
 	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai_link *dai_link;
 	int ret, i, order;
 
 	mutex_lock(&client_mutex);
@@ -1853,6 +1867,21 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	/* no longer need dummy runtimes */
 	soc_remove_dummy_pcm_runtimes(card);
 
+	/* Find new DAI links added during probing components and bind them.
+	 * Components with topology may bring new DAIs and DAI links.
+	 */
+	list_for_each_entry(dai_link, &card->dai_link_list, list) {
+		if (dai_link->dummy || soc_is_dai_link_bound(card, dai_link))
+			continue;
+
+		ret = soc_init_dai_link(card, dai_link);
+		if (ret)
+			goto probe_dai_err;
+		ret = soc_bind_dai_link(card, dai_link);
+		if (ret)
+			goto probe_dai_err;
+	}
+
 	/* probe all DAI links on this card */
 	for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
 			order++) {
Signature · 1 line
1.9.1