From patchwork Thu Nov 3 23:07:06 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: 9412069 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 E957760722 for ; Fri, 4 Nov 2016 08:01:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAD8A2B0A1 for ; Fri, 4 Nov 2016 08:01:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF8892B0AC; Fri, 4 Nov 2016 08:01:39 +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 C180E2B0A1 for ; Fri, 4 Nov 2016 08:01:38 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3DDB326720A; Fri, 4 Nov 2016 09:01:37 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7CA40267198; Fri, 4 Nov 2016 08:59:18 +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 D18F126736C; Fri, 4 Nov 2016 00:05:47 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id 0C6E5266B8C for ; Fri, 4 Nov 2016 00:05:40 +0100 (CET) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP; 03 Nov 2016 16:05:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,440,1473145200"; d="scan'208";a="27175385" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga006.fm.intel.com with ESMTP; 03 Nov 2016 16:05:37 -0700 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org Date: Fri, 4 Nov 2016 07:07:06 +0800 Message-Id: <34d6902914df281d29cb4f01ccb5e8ffe1b78d8a.1478212626.git.mengdong.lin@linux.intel.com> 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 3/6] topology: Parse flags for PCM 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 Users can define flags by both text conf file and C API. Add flags and flag_mask to C API template of PCM object. Signed-off-by: Mengdong Lin diff --git a/include/topology.h b/include/topology.h index ccd8401..b6a6f19 100644 --- a/include/topology.h +++ b/include/topology.h @@ -606,6 +606,11 @@ extern "C" { * "config3" * ] * } + * + * # Optional boolean flags + * symmetric_rates "true" + * symmetric_channels "true" + * symmetric_sample_bits "false" * } * * @@ -863,6 +868,8 @@ struct snd_tplg_pcm_template { unsigned int capture; /*!< supports capture mode */ unsigned int compress; /*!< 1 = compressed; 0 = PCM */ struct snd_tplg_stream_caps_template *caps[2]; /*!< playback & capture for DAI */ + unsigned int flag_mask; /*!< bitmask of flags to configure */ + unsigned int flags; /*!< flag value SND_SOC_TPLG_LNK_FLGBIT_* */ int num_streams; /*!< number of supported configs */ struct snd_tplg_stream_template stream[0]; /*!< supported configs */ }; diff --git a/src/topology/pcm.c b/src/topology/pcm.c index 6fdf047..bd70dc9 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -364,6 +364,24 @@ static int tplg_parse_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED, return 0; } +/* parse a flag bit of the given mask */ +static int parse_flag(snd_config_t *n, unsigned int mask_in, + unsigned int *mask, unsigned int *flags) +{ + const char *val = NULL; + + if (snd_config_get_string(n, &val) < 0) + return -EINVAL; + + *mask |= mask_in; + if (strcmp(val, "true") == 0) + *flags |= mask_in; + else + *flags &= ~mask_in; + + return 0; +} + /* Parse pcm (for front end DAI & DAI link) */ int tplg_parse_pcm(snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED) @@ -430,6 +448,34 @@ int tplg_parse_pcm(snd_tplg_t *tplg, return err; continue; } + + /* flags */ + if (strcmp(id, "symmetric_rates") == 0) { + err = parse_flag(n, + SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES, + &pcm->flag_mask, &pcm->flags); + if (err < 0) + return err; + continue; + } + + if (strcmp(id, "symmetric_channels") == 0) { + err = parse_flag(n, + SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS, + &pcm->flag_mask, &pcm->flags); + if (err < 0) + return err; + continue; + } + + if (strcmp(id, "symmetric_sample_bits") == 0) { + err = parse_flag(n, + SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS, + &pcm->flag_mask, &pcm->flags); + if (err < 0) + return err; + continue; + } } return 0; @@ -610,6 +656,9 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) tplg_add_stream_caps(&pcm->caps[i], pcm_tpl->caps[i]); } + pcm->flag_mask = pcm_tpl->flag_mask; + pcm->flags = pcm_tpl->flags; + pcm->num_streams = pcm_tpl->num_streams; for (i = 0; i < pcm_tpl->num_streams; i++) tplg_add_stream_object(&pcm->stream[i], &pcm_tpl->stream[i]);