From patchwork Thu Oct 27 07:14:14 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: 9399297 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 A52B6600BA for ; Thu, 27 Oct 2016 13:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DBEA297CC for ; Thu, 27 Oct 2016 13:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71E392A287; Thu, 27 Oct 2016 13:15:56 +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 35570297CC for ; Thu, 27 Oct 2016 13:15:51 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 94A892673EE; Thu, 27 Oct 2016 15:15:50 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E31C12673C8; Thu, 27 Oct 2016 15:13:22 +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 18E2F267327; Thu, 27 Oct 2016 09:13:06 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by alsa0.perex.cz (Postfix) with ESMTP id 16C0D2672C7 for ; Thu, 27 Oct 2016 09:12:59 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP; 27 Oct 2016 00:12:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,404,1473145200"; d="scan'208";a="24251226" Received: from amanda-haswell-pc.sh.intel.com ([10.239.159.21]) by fmsmga005.fm.intel.com with ESMTP; 27 Oct 2016 00:12:56 -0700 From: mengdong.lin@linux.intel.com To: alsa-devel@alsa-project.org Date: Thu, 27 Oct 2016 15:14:14 +0800 Message-Id: <55d8c0b57916319b6d39d4ba578121b36aa46220.1477549962.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 16/22] topology: Parse and build private data of physical 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 Users can define private data for physical links by C API or text conf file. Signed-off-by: Mengdong Lin diff --git a/src/topology/pcm.c b/src/topology/pcm.c index daeb32e..c4857ba 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -162,7 +162,7 @@ static int build_link(snd_tplg_t *tplg, struct tplg_elem *elem) if (err < 0) return err; - /* hw configs */ + /* hw configs & private data */ base = &elem->ref_list; list_for_each(pos, base) { @@ -185,6 +185,12 @@ static int build_link(snd_tplg_t *tplg, struct tplg_elem *elem) num_hw_configs++; break; + case SND_TPLG_TYPE_DATA: /* merge private data */ + err = tplg_copy_data(tplg, elem, ref); + if (err < 0) + return err; + break; + default: break; } @@ -1079,5 +1085,24 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) /* flags */ link->flag_mask = link_tpl->flag_mask; link->flags = link_tpl->flags; + + /* private data */ + if (link_tpl->priv != NULL && link_tpl->priv->size) { + _link = realloc(link, + elem->size + link_tpl->priv->size); + if (!_link) { + tplg_elem_free(elem); + return -ENOMEM; + } + + link = _link; + elem->link = link; + elem->size += link_tpl->priv->size; + + memcpy(link->priv.data, link_tpl->priv->data, + link_tpl->priv->size); + link->priv.size = link_tpl->priv->size; + } + return 0; }