From mboxrd@z Thu Jan 1 00:00:00 1970 From: mengdong.lin@linux.intel.com Subject: [PATCH 06/13] ASoC: topology: Add FE DAIs only if not already added Date: Fri, 19 Aug 2016 18:13:25 +0800 Message-ID: <1e43f6028e16478ab41b7b99b183cf0fb493cf51.1471599648.git.mengdong.lin@linux.intel.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id CC1BB266C80 for ; Fri, 19 Aug 2016 12:07:34 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: Mengdong Lin , tiwai@suse.de, mengdong.lin@intel.com, guneshwor.o.singh@intel.com, liam.r.girdwood@linux.intel.com, vinod.koul@intel.com, hardik.t.shah@intel.com List-Id: alsa-devel@alsa-project.org From: Guneshwor Singh 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 Signed-off-by: Mengdong Lin 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