From patchwork Wed Aug 5 10:10:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Girdwood X-Patchwork-Id: 6947701 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E8610C05AC for ; Wed, 5 Aug 2015 10:12:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E679820495 for ; Wed, 5 Aug 2015 10:12:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2EA6D203AC for ; Wed, 5 Aug 2015 10:12:03 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EADAE265DAC; Wed, 5 Aug 2015 12:12:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 76C98265D8A; Wed, 5 Aug 2015 12:11:29 +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 B6AD4265D8B; Wed, 5 Aug 2015 12:11:26 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id 8DBDA2614D6 for ; Wed, 5 Aug 2015 12:10:54 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 05 Aug 2015 03:10:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,615,1432623600"; d="scan'208";a="742573590" Received: from unknown (HELO loki.ger.corp.intel.com) ([10.252.23.69]) by orsmga001.jf.intel.com with ESMTP; 05 Aug 2015 03:10:50 -0700 From: Liam Girdwood To: Date: Wed, 5 Aug 2015 11:10:42 +0100 Message-Id: <1438769442-18681-1-git-send-email-liam.r.girdwood@linux.intel.com> X-Mailer: git-send-email 1.9.1 Cc: Takashi Iwai , Mengdong Lin , Mark Brown , Liam Girdwood Subject: [alsa-devel] [PATCH] topology: Update ABI to improve TLV, operations and private data support. 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 This is the alsa-lib patch - a corresponding kernel patch has also been sent. This patch updates the topology ABI version and adds support for private data types, specfic structures for each TLV data type and refactors the operations mapping structure to be generic (so that it can be used by other types). This code is only used within Intel atm and is not in an official alsa-lib release so impact should be minimal for the ABI update. Currently the TLV topology structure is targeted at only supporting the DB scale data. This patch extends support for the other TLV types so they can be easily added at a later stage. TLV structure is moved to common topology control header since it's a common field for controls and can be processed in a general way. Users must set a proper access flag for a control since it's used to decide if the TLV field is valid and if a TLV callback is needed. Removed the following fields from topology TLV struct: - size/count: type can decide the size. - numid: not needed to initialize TLV for kcontrol. - data: replaced by the type specific struct. Added TLV structure to generic control header and removed TLV structure from mixer control. Added generic ops to geneic control header. Signed-off-by: Mengdong Lin Signed-off-by: Liam Girdwood --- include/sound/asoc.h | 27 ++++++++++++++++++--------- src/topology/ctl.c | 20 ++++++++------------ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/include/sound/asoc.h b/include/sound/asoc.h index bb6dcf3..61b8473 100644 --- a/include/sound/asoc.h +++ b/include/sound/asoc.h @@ -135,11 +135,18 @@ struct snd_soc_tplg_private { /* * Kcontrol TLV data. */ +struct snd_soc_tplg_tlv_dbscale { + __le32 min; + __le32 step; + __le32 mute; +} __attribute__((packed)); + struct snd_soc_tplg_ctl_tlv { - __le32 size; /* in bytes aligned to 4 */ - __le32 numid; /* control element numeric identification */ - __le32 count; /* number of elem in data array */ - __le32 data[SND_SOC_TPLG_TLV_SIZE]; + __le32 size; /* in bytes of this structure */ + __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */ + union { + struct snd_soc_tplg_tlv_dbscale scale; + }; } __attribute__((packed)); /* @@ -153,9 +160,11 @@ struct snd_soc_tplg_channel { } __attribute__((packed)); /* - * Kcontrol Operations IDs + * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops + * Kcontrol ops need get/put/info. + * Bytes ext ops need get/put. */ -struct snd_soc_tplg_kcontrol_ops_id { +struct snd_soc_tplg_io_ops { __le32 get; __le32 put; __le32 info; @@ -169,8 +178,8 @@ struct snd_soc_tplg_ctl_hdr { __le32 type; char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; __le32 access; - struct snd_soc_tplg_kcontrol_ops_id ops; - __le32 tlv_size; /* non zero means control has TLV data */ + struct snd_soc_tplg_io_ops ops; + struct snd_soc_tplg_ctl_tlv tlv; } __attribute__((packed)); /* @@ -258,7 +267,6 @@ struct snd_soc_tplg_mixer_control { __le32 invert; __le32 num_channels; struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN]; - struct snd_soc_tplg_ctl_tlv tlv; struct snd_soc_tplg_private priv; } __attribute__((packed)); @@ -302,6 +310,7 @@ struct snd_soc_tplg_bytes_control { __le32 mask; __le32 base; __le32 num_regs; + struct snd_soc_tplg_io_ops ext_ops; struct snd_soc_tplg_private priv; } __attribute__((packed)); diff --git a/src/topology/ctl.c b/src/topology/ctl.c index aa06ff6..930b508 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -28,10 +28,7 @@ static int copy_tlv(struct tplg_elem *elem, struct tplg_elem *ref) tplg_dbg("TLV '%s' used by '%s\n", ref->id, elem->id); /* TLV has a fixed size */ - mixer_ctrl->tlv = *tlv; - - /* set size of TLV data */ - mixer_ctrl->hdr.tlv_size = tlv->count * sizeof(uint32_t); + mixer_ctrl->hdr.tlv = *tlv; return 0; } @@ -209,20 +206,19 @@ static int tplg_parse_tlv_dbscale(snd_config_t *cfg, struct tplg_elem *elem) snd_config_iterator_t i, next; snd_config_t *n; struct snd_soc_tplg_ctl_tlv *tplg_tlv; + struct snd_soc_tplg_tlv_dbscale *scale; const char *id = NULL, *value = NULL; - int *data; tplg_dbg(" scale: %s\n", elem->id); tplg_tlv = calloc(1, sizeof(*tplg_tlv)); if (!tplg_tlv) return -ENOMEM; - data = (int*)(tplg_tlv->data); elem->tlv = tplg_tlv; - tplg_tlv->numid = SNDRV_CTL_TLVT_DB_SCALE; - tplg_tlv->count = 8; - tplg_tlv->size = sizeof(*tplg_tlv); + tplg_tlv->size = sizeof(struct snd_soc_tplg_ctl_tlv); + tplg_tlv->type = SNDRV_CTL_TLVT_DB_SCALE; + scale = &tplg_tlv->scale; snd_config_for_each(i, next, cfg) { @@ -242,11 +238,11 @@ static int tplg_parse_tlv_dbscale(snd_config_t *cfg, struct tplg_elem *elem) /* get TLV data */ if (strcmp(id, "min") == 0) - data[0] = atoi(value); + scale->min = atoi(value); else if (strcmp(id, "step") == 0) - data[1] = atoi(value); + scale->step = atoi(value); else if (strcmp(id, "mute") == 0) - data[2] = atoi(value); + scale->mute = atoi(value); else SNDERR("error: unknown key %s\n", id); }