From patchwork Fri May 5 07:57:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fuweix.tang@intel.com X-Patchwork-Id: 9713119 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 685BE60362 for ; Fri, 5 May 2017 07:57:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 511EB28698 for ; Fri, 5 May 2017 07:57:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4476D28646; Fri, 5 May 2017 07:57:51 +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 732A128646 for ; Fri, 5 May 2017 07:57:49 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 28BC5266F30; Fri, 5 May 2017 09:57:48 +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 8342B266F36; Fri, 5 May 2017 09:57:46 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by alsa0.perex.cz (Postfix) with ESMTP id D73EB26687D for ; Fri, 5 May 2017 09:57:43 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP; 05 May 2017 00:57:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,291,1491289200"; d="scan'208";a="83923861" Received: from tangfw-thinkpad-x230.sh.intel.com ([10.239.47.124]) by orsmga004.jf.intel.com with ESMTP; 05 May 2017 00:57:40 -0700 From: fuweix.tang@intel.com To: alsa-devel@alsa-project.org Date: Fri, 5 May 2017 15:57:20 +0800 Message-Id: <1493971040-15628-1-git-send-email-fuweix.tang@intel.com> X-Mailer: git-send-email 2.7.4 Cc: tiwai@suse.de, liam.r.girdwood@linux.intel.com, Fuwei Tang , mengdong.lin@intel.com Subject: [alsa-devel] [PATCH v2] topology: Fix issue in parsing routes when generating topology binary 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: Fuwei Tang We missed parsing the index value, which is used as a use case indicator, when processing the route objects. This patch fixes the bug. Signed-off-by: Fuwei Tang Tested-by: Subhransu S. Prusty --- src/topology/dapm.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/topology/dapm.c b/src/topology/dapm.c index 13aa1c4..6af750b 100644 --- a/src/topology/dapm.c +++ b/src/topology/dapm.c @@ -381,7 +381,7 @@ done: } -static int tplg_parse_routes(snd_tplg_t *tplg, snd_config_t *cfg) +static int tplg_parse_routes(snd_tplg_t *tplg, snd_config_t *cfg, int index) { snd_config_iterator_t i, next; snd_config_t *n; @@ -399,7 +399,7 @@ static int tplg_parse_routes(snd_tplg_t *tplg, snd_config_t *cfg) elem = tplg_elem_new_route(tplg); if (!elem) return -ENOMEM; - + elem->index = index; line = elem->route; err = tplg_parse_line(val, line); @@ -419,7 +419,8 @@ int tplg_parse_dapm_graph(snd_tplg_t *tplg, snd_config_t *cfg, snd_config_iterator_t i, next; snd_config_t *n; int err; - const char *graph_id; + const char *graph_id, *val = NULL; + int index; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { SNDERR("error: compound is expected for dapm graph definition\n"); @@ -436,8 +437,14 @@ int tplg_parse_dapm_graph(snd_tplg_t *tplg, snd_config_t *cfg, continue; } + if (strcmp(id, "index") == 0) { + if (snd_config_get_string(n, &val) < 0) + return -EINVAL; + index = atoi(val); + } + if (strcmp(id, "lines") == 0) { - err = tplg_parse_routes(tplg, n); + err = tplg_parse_routes(tplg, n, index); if (err < 0) { SNDERR("error: failed to parse dapm graph %s\n", graph_id);