[alsa-devel] [PATCH 06/13] ASoC: topology: Add FE DAIs only if not already added

mengdong.lin at linux.intel.com mengdong.lin at linux.intel.com
Fri Aug 19 12:13:25 CEST 2016


From: Guneshwor Singh <guneshwor.o.singh at intel.com>

Topology will check with ASoC if the FE DAI already exists by
checking its name. If not, topology will create a new one.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh at intel.com>
Signed-off-by: Mengdong Lin <mengdong.lin at linux.intel.com>

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index b71abad..6a1a9c2 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1683,13 +1683,25 @@ static int soc_tplg_link_create(struct soc_tplg *tplg,
 static int soc_tplg_pcm_create(struct soc_tplg *tplg,
 	struct snd_soc_tplg_pcm *pcm)
 {
+	struct snd_soc_dai_link_component dai_component = {0};
+	struct snd_soc_dai *dai;
 	int ret;
 
-	ret = soc_tplg_dai_create(tplg, pcm);
-	if (ret < 0)
-		return ret;
+	if (!strlen(pcm->dai_name)) {
+		dev_err(tplg->dev, "ASoC: Invalid FE DAI name %s\n",
+			pcm->dai_name);
+		return -EINVAL;
+	}
+
+	dai_component.dai_name = pcm->dai_name;
+	dai = snd_soc_find_dai(&dai_component);
+	if (!dai) { /* FE DAI doesn't exist, create it */
+		ret = soc_tplg_dai_create(tplg, pcm);
+		if (ret < 0)
+			return ret;
+	}
 
-	return  soc_tplg_link_create(tplg, pcm);
+	return soc_tplg_link_create(tplg, pcm);
 }
 
 static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
-- 
2.5.0



More information about the Alsa-devel mailing list