From patchwork Mon Aug 10 06:13:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Mengdong" X-Patchwork-Id: 6979451 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 868E2C05AC for ; Mon, 10 Aug 2015 06:02:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A246A2074B for ; Mon, 10 Aug 2015 06:02:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 72E0820738 for ; Mon, 10 Aug 2015 06:02:07 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6AEC226548B; Mon, 10 Aug 2015 08:02:06 +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, 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 DB4A62652E6; Mon, 10 Aug 2015 08:00:30 +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 E4CDD265361; Mon, 10 Aug 2015 08:00:28 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id 0A81B265327 for ; Mon, 10 Aug 2015 08:00:02 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 09 Aug 2015 22:59:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,643,1432623600"; d="scan'208";a="765414054" Received: from amanda-hsw-pc.sh.intel.com ([10.239.159.75]) by fmsmga001.fm.intel.com with ESMTP; 09 Aug 2015 22:59:50 -0700 From: mengdong.lin@intel.com To: alsa-devel@alsa-project.org Date: Mon, 10 Aug 2015 14:13:09 +0800 Message-Id: <1439187189-1101-1-git-send-email-mengdong.lin@intel.com> X-Mailer: git-send-email 1.9.1 Cc: tiwai@suse.de, Mengdong Lin , broonie@kernel.org, liam.r.girdwood@intel.com Subject: [alsa-devel] [RFC PATCH 04/10] ASoC: implement DAI links in a list. 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 Implement a dai link list for the soc card. And API snd_soc_add_dai_link() is defined for machine drivers to add DAI links dynamically based on topology. Signed-off-by: Mengdong Lin diff --git a/include/sound/soc.h b/include/sound/soc.h index e2b7b0f..79891e2 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1011,6 +1011,8 @@ struct snd_soc_dai_link { /* pmdown_time is ignored at stop */ unsigned int ignore_pmdown_time:1; + + struct list_head list; /* dai link list of the soc card */ }; struct snd_soc_codec_conf { @@ -1078,8 +1080,11 @@ struct snd_soc_card { long pmdown_time; /* CPU <--> Codec DAI links */ - struct snd_soc_dai_link *dai_link; - int num_links; + struct snd_soc_dai_link *dai_link; /* predefined links only */ + int num_links; /* predefined links only */ + struct list_head dai_link_list; /* all links except the dummy ones */ + int num_dai_links; + struct list_head rtd_list; int num_rtd; @@ -1619,6 +1624,9 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev, struct device_node *of_node, struct snd_soc_dai_link *dai_link); +void snd_soc_add_dai_link(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link); + #include #ifdef CONFIG_DEBUG_FS diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index ddfdd1d..58eac57 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1235,6 +1235,27 @@ static int soc_init_dai_link(struct snd_soc_card *card, return 0; } +/** + * snd_soc_add_dai_link - Add a DAI link dynamically + * @card: The ASoC card to which the DAI link is added + * @dai_link: The new DAI link to add + * + * This function adds a DAI link to the ASoC card, and creates a ASoC + * runtime for the link. + * + * Note: For adding DAI links dynamically by machine drivers based on + * the topology info when probing the platform component. And machine + * drivers can still define static DAI links in dai_link array. + */ +void snd_soc_add_dai_link(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) +{ + lockdep_assert_held(&client_mutex); + list_add_tail(&dai_link->list, &card->dai_link_list); + card->num_dai_links++; +} +EXPORT_SYMBOL_GPL(snd_soc_add_dai_link); + static void soc_set_name_prefix(struct snd_soc_card *card, struct snd_soc_component *component) { @@ -1729,6 +1750,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) goto base_error; } + /* all predefined resources are ready, store non-dummy links */ + for (i = 0; i < card->num_links; i++) + snd_soc_add_dai_link(card, card->dai_link+i); + /* initialize the register cache for each available codec */ list_for_each_entry(codec, &codec_list, list) { if (codec->cache_init) @@ -2486,6 +2511,9 @@ int snd_soc_register_card(struct snd_soc_card *card) snd_soc_initialize_card_lists(card); + INIT_LIST_HEAD(&card->dai_link_list); + card->num_dai_links = 0; + INIT_LIST_HEAD(&card->rtd_list); card->num_rtd = 0;