From patchwork Sun Nov 6 05:14:34 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: 9413887 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 DBE806022E for ; Sun, 6 Nov 2016 08:46:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4F3728E12 for ; Sun, 6 Nov 2016 08:46:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7B9B28FD2; Sun, 6 Nov 2016 08:46:45 +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 ECB8828E12 for ; Sun, 6 Nov 2016 08:46:44 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 25409266D1A; Sun, 6 Nov 2016 09:46:43 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id CB38E266C41; Sun, 6 Nov 2016 09:44:17 +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 946D72665CC; Sun, 6 Nov 2016 06:13:10 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id C1E182665B0 for ; Sun, 6 Nov 2016 06:13:04 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 05 Nov 2016 22:13:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,599,1473145200"; d="scan'208";a="188195466" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga004.fm.intel.com with ESMTP; 05 Nov 2016 22:13:01 -0700 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org Date: Sun, 6 Nov 2016 13:14:34 +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 12/13] topology: Parse name and stream name of physical DAI links 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 Parse name and stream name of physical links defined by text conf file or C API. Add name and stream name to C API template of physical DAI links. These two fields will help topology kernel driver to find an existing physical link to configure, since the id of links are often the default value ZERO and useless for match. Signed-off-by: Mengdong Lin diff --git a/include/topology.h b/include/topology.h index ad84c15..66dd084 100644 --- a/include/topology.h +++ b/include/topology.h @@ -631,6 +631,8 @@ extern "C" { * * id "0" # used for binding to the link * + * stream_name "name" # used for binding to the link + * * hw_configs [ # runtime supported HW configurations, optional * "config1" * "config2" @@ -985,8 +987,10 @@ struct snd_tplg_hw_config_template { * \brief Template type for BE and CC DAI Links. */ struct snd_tplg_link_template { - const char *name; /*!< link name */ + const char *name; /*!< link name, used to match */ int id; /*!< unique ID - used to match with existing BE and CC links */ + const char *stream_name; /*!< link stream name, used to match */ + int num_streams; /*!< number of configs */ struct snd_tplg_stream_template *stream; /*!< supported configs */ diff --git a/src/topology/pcm.c b/src/topology/pcm.c index 1d70396..a9d3277 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -622,6 +622,7 @@ int tplg_parse_link(snd_tplg_t *tplg, link = elem->link; link->size = elem->size; + elem_copy_text(link->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); tplg_dbg(" Link: %s\n", elem->id); @@ -655,6 +656,16 @@ int tplg_parse_link(snd_tplg_t *tplg, continue; } + if (strcmp(id, "stream_name") == 0) { + if (snd_config_get_string(n, &val) < 0) + return -EINVAL; + + elem_copy_text(link->stream_name, val, + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); + tplg_dbg("\t%s: %s\n", id, val); + continue; + } + if (strcmp(id, "hw_configs") == 0) { err = parse_hw_config_refs(tplg, n, elem); if (err < 0) @@ -1030,7 +1041,15 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) link = elem->link; link->size = elem->size; + /* ID and names */ link->id = link_tpl->id; + if (link->name) + elem_copy_text(link->name, link_tpl->name, + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); + if (link->stream_name) + elem_copy_text(link->stream_name, link_tpl->stream_name, + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); + /* stream configs */ if (link_tpl->num_streams > SND_SOC_TPLG_STREAM_CONFIG_MAX) return -EINVAL;