From patchwork Mon Aug 10 14:47:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Mengdong" X-Patchwork-Id: 6985161 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7AE7A9F358 for ; Mon, 10 Aug 2015 14:37:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 85E19205FC for ; Mon, 10 Aug 2015 14:37:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3564B205FA for ; Mon, 10 Aug 2015 14:37:19 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 635C82659E5; Mon, 10 Aug 2015 16:37:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 2A289265938; Mon, 10 Aug 2015 16:35:57 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C85F52659A4; Mon, 10 Aug 2015 16:35:55 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id 4556B265938 for ; Mon, 10 Aug 2015 16:34:34 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 10 Aug 2015 07:34:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,645,1432623600"; d="scan'208";a="539155373" Received: from amanda-hsw-pc.sh.intel.com ([10.239.159.75]) by FMSMGA003.fm.intel.com with ESMTP; 10 Aug 2015 07:34:28 -0700 From: mengdong.lin@intel.com To: alsa-devel@alsa-project.org Date: Mon, 10 Aug 2015 22:47:47 +0800 Message-Id: <0364569ce2898a20d08243ba59a92973b2dc4735.1439217448.git.mengdong.lin@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Cc: tiwai@suse.de, Mengdong Lin , broonie@kernel.org, liam.r.girdwood@intel.com Subject: [alsa-devel] [PATCH v2 05/10] ASoC: Add support for dummy DAI links and PCM runtimes X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mengdong Lin Add dummy flag to a DAI link and PCM runtime. A dummy link will create a dummy PCM runtime. A machine driver can define dummy dai links to specify the expected platform and codec. And its dummy runtime is used to probe the platform and codec components, which can bring real DAI/DAI links based on topology. After components probing, all dummy PCM runtimes will be removed. Only non-dummy PCM runtimes will be assigned a valid number and create PCM streams. The ASoC core will find the platform for a dummy DAI link, assuming the cpu DAI can be dummy but the platform can bring the topology info. Signed-off-by: Mengdong Lin diff --git a/include/sound/soc.h b/include/sound/soc.h index 79891e2..7e04ec0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -970,6 +970,11 @@ struct snd_soc_dai_link { enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */ + /* This DAI link is dummy. Machine drivers can define static dummy + * links to specify platform/codec with topology. + */ + bool dummy; + /* codec/machine specific init - e.g. add machine controls */ int (*init)(struct snd_soc_pcm_runtime *rtd); @@ -1087,6 +1092,7 @@ struct snd_soc_card { struct list_head rtd_list; int num_rtd; + int num_rtd_dev; /* monotonic increase and exclude dummy ones */ /* optional codec specific configuration */ struct snd_soc_codec_conf *codec_conf; @@ -1181,6 +1187,7 @@ struct snd_soc_pcm_runtime { struct dentry *debugfs_dpcm_state; #endif + bool dummy; unsigned int num; /* 0-based and monotonic increasing */ struct list_head list; /* rtd list of the soc card */ }; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 58eac57..f552fa0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -561,6 +561,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( rtd->card = card; rtd->dai_link = dai_link; + rtd->dummy = dai_link->dummy; rtd->codec_dais = devm_kzalloc(card->dev, sizeof(struct snd_soc_dai *) * dai_link->num_codecs, @@ -583,10 +584,28 @@ static void soc_add_pcm_runtime(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd) { list_add_tail(&rtd->list, &card->rtd_list); - rtd->num = card->num_rtd; + + if (!rtd->dummy) { + rtd->num = card->num_rtd_dev; + card->num_rtd_dev++; + } + card->num_rtd++; } +static void soc_remove_dummy_pcm_runtimes(struct snd_soc_card *card) +{ + struct snd_soc_pcm_runtime *rtd, *_rtd; + + list_for_each_entry_safe(rtd, _rtd, &card->rtd_list, list) { + if (rtd->dummy) { + list_del(&rtd->list); + soc_free_pcm_runtime(card, rtd); + card->num_rtd--; + } + } +} + static void soc_remove_pcm_runtimes(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd, *_rtd; @@ -1007,6 +1026,15 @@ static int soc_bind_dai_link(struct snd_soc_card *card, } } + /* Dummy link can use dummy cpu DAI but set platform to get topology */ + if (dai_link->dummy && dai_link->platform_name) { + if (!soc_find_component(NULL, dai_link->platform_name)) { + dev_err(card->dev, "ASoC: Platform %s not registered\n", + dai_link->platform_name); + goto _err_defer; + } + } + /* Single codec links expect codec and codec_dai in runtime data */ rtd->codec_dai = codec_dais[0]; rtd->codec = rtd->codec_dai->codec; @@ -1250,6 +1278,10 @@ static int soc_init_dai_link(struct snd_soc_card *card, void snd_soc_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { + /* Dummy links should be static, so overlook them */ + if (dai_link->dummy) + return; + lockdep_assert_held(&client_mutex); list_add_tail(&dai_link->list, &card->dai_link_list); card->num_dai_links++; @@ -1818,6 +1850,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) } } + /* no longer need dummy runtimes */ + soc_remove_dummy_pcm_runtimes(card); + /* probe all DAI links on this card */ for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; order++) { @@ -2516,6 +2551,7 @@ int snd_soc_register_card(struct snd_soc_card *card) INIT_LIST_HEAD(&card->rtd_list); card->num_rtd = 0; + card->num_rtd_dev = 0; card->rtd_aux = devm_kzalloc(card->dev, sizeof(struct snd_soc_pcm_runtime) *