topology: UAPI updates for TLV and ops.
v2 cover topology: UAPI updates for TLV and ops.
This series updates the topology UAPI to allow easier addition of new TLV object types and generic operations for alsa-lib.
Mengdong Lin (2):
topology: update ABI to improve support for different TLV object
types.
topology: Add ops support to byte control objects.
include/sound/asoc.h | 28 +++++++++++++++++++--------- src/topology/ctl.c | 20 ++++++++------------ 2 files changed, 27 insertions(+), 21 deletions(-)
Signature · 1 line
2.1.4
PATCH v2 1/2 topology: update ABI to improve support for different TLV object types.
From: Mengdong Lin <[email protected]>
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.
--- include/sound/asoc.h | 19 +++++++++++++------ src/topology/ctl.c | 20 ++++++++------------ 2 files changed, 21 insertions(+), 18 deletions(-)
include/sound/asoc.h +13 -6
@@ -135,11 +135,19 @@ 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 { +__le32 data[SND_SOC_TPLG_TLV_SIZE ]; +struct snd_soc_tplg_tlv_dbscale scale; + }; } __attribute__((packed));/*
@@ -170,7 +178,7 @@ struct snd_soc_tplg_ctl_hdr {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_ctl_tlv tlv; } __attribute__((packed));/*
@@ -258,7 +266,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));
src/topology/ctl.c +8 -12
@@ -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); }
Signature · 1 line
2.1.4
PATCH v2 2/2 topology: Add ops support to byte control objects.
In reply to Liam GirdwoodFrom: Mengdong Lin <[email protected]>
Rename the control ops structure to make it more generic so we can use it with other objects like bytes controls. Add this structure to the byte control structure.
--- include/sound/asoc.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
include/sound/asoc.h +6 -3
@@ -161,9 +161,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;
@@ -177,7 +179,7 @@ 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; +struct snd_soc_tplg_io_ops ops;struct snd_soc_tplg_ctl_tlv tlv; } __attribute__((packed));
@@ -309,6 +311,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));
Signature · 1 line
2.1.4
Takashi Iwai
AppliedQuoted 8 lines · Liam Girdwood
This series updates the topology UAPI to allow easier addition of new TLV object types and generic operations for alsa-lib.
Mengdong Lin (2):
topology: update ABI to improve support for different TLV object
types.
topology: Add ops support to byte control objects.
Thanks, applied both now.
Takashi
Quoted 8 lines
include/sound/asoc.h | 28 +++++++++++++++++++--------- src/topology/ctl.c | 20 ++++++++------------ 2 files changed, 27 insertions(+), 21 deletions(-)Signature · 1 line
2.1.4