From patchwork Thu Nov 3 23:07:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mengdong.lin@linux.intel.com X-Patchwork-Id: 9412071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BC520601C2 for ; Fri, 4 Nov 2016 08:18:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA6C22ADEC for ; Fri, 4 Nov 2016 08:18:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D8B12AE9C; Fri, 4 Nov 2016 08:18:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140062ADEC for ; Fri, 4 Nov 2016 08:18:57 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8D2532673CD; Fri, 4 Nov 2016 09:18:56 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2945626720A; Fri, 4 Nov 2016 09:16:31 +0100 (CET) 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 E4EC426736C; Fri, 4 Nov 2016 00:06:35 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by alsa0.perex.cz (Postfix) with ESMTP id 69EF0266B8C for ; Fri, 4 Nov 2016 00:06:32 +0100 (CET) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP; 03 Nov 2016 16:06:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,440,1473145200"; d="scan'208";a="27250754" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga005.fm.intel.com with ESMTP; 03 Nov 2016 16:06:29 -0700 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org Date: Fri, 4 Nov 2016 07:07:58 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: Cc: Mengdong Lin , tiwai@suse.de, hardik.t.shah@intel.com, guneshwor.o.singh@intel.com, liam.r.girdwood@linux.intel.com, vinod.koul@intel.com, broonie@kernel.org, mengdong.lin@intel.com Subject: [alsa-devel] [PATCH 4/6] topology: Define a function to build a single PCM element 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 Code refactoring. Rename tplg_build_pcm() to tplg_build_pcms() to build all PCM (FE DAI & DAI link) elements. It will call a new function build_pcm() to build a single PCM elemement. build_pcm() will be extended to handle more properties of a PCM. Signed-off-by: Mengdong Lin diff --git a/src/topology/parser.c b/src/topology/parser.c index 3ab64f4..7b2c879 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -267,7 +267,7 @@ static int tplg_build_integ(snd_tplg_t *tplg) if (err < 0) return err; - err = tplg_build_pcm(tplg, SND_TPLG_TYPE_PCM); + err = tplg_build_pcms(tplg, SND_TPLG_TYPE_PCM); if (err < 0) return err; diff --git a/src/topology/pcm.c b/src/topology/pcm.c index bd70dc9..77b7605 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -70,8 +70,20 @@ static int tplg_build_stream_caps(snd_tplg_t *tplg, return 0; } -/* build FE DAI/PCM configurations */ -int tplg_build_pcm(snd_tplg_t *tplg, unsigned int type) +/* build a PCM (FE DAI & DAI link) element */ +static int build_pcm(snd_tplg_t *tplg, struct tplg_elem *elem) +{ + int err; + + err = tplg_build_stream_caps(tplg, elem->id, elem->pcm->caps); + if (err < 0) + return err; + + return 0; +} + +/* build all PCM (FE DAI & DAI link) elements */ +int tplg_build_pcms(snd_tplg_t *tplg, unsigned int type) { struct list_head *base, *pos; struct tplg_elem *elem; @@ -86,7 +98,7 @@ int tplg_build_pcm(snd_tplg_t *tplg, unsigned int type) return -EINVAL; } - err = tplg_build_stream_caps(tplg, elem->id, elem->pcm->caps); + err = build_pcm(tplg, elem); if (err < 0) return err; diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index cfde4cc..7b30b84 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -284,7 +284,7 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl, int tplg_add_bytes(snd_tplg_t *tplg, struct snd_tplg_bytes_template *bytes_ctl, struct tplg_elem **e); -int tplg_build_pcm(snd_tplg_t *tplg, unsigned int type); +int tplg_build_pcms(snd_tplg_t *tplg, unsigned int type); int tplg_build_link_cfg(snd_tplg_t *tplg, unsigned int type); int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t); int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t);