topology: Align ABI with kernel to version 4
cover topology: Align ABI with kernel to version 4
From: Mengdong Lin <[email protected]>
After this series is applied, the kernel and user space ABIs will be aligned to version 4.
It also adds C API support for PCM and BE/CC links.
Mengdong Lin (4):
topology: ABI - Remove tdm_slot & dai_fmt from snd_soc_tplg_stream
topology: ABI - Change stream formats to a bitwise flag
topology: ABI - Rename dai_elems to pcm_elems in manifest
topology: Add C API support for PCM
Vedang Patel (5):
topology: ABI - Add name element to snd_soc_tplg_stream
topology: ABI - Separate PCM & BE/CC link support and bump ABI version
to 4
topology: ABI - Remove unused struct snd_soc_tplg_stream_config
topology: ABI - Use __le32 instead of __u32 in
snd_soc_tplg_dapm_widget
topology: Add C API support for BE and CC Links.
include/sound/asoc.h | 78 +++++---- include/topology.h | 59 +++++++ src/topology/builder.c | 4 +- src/topology/elem.c | 8 +- src/topology/parser.c | 19 +- src/topology/pcm.c | 429 +++++++++++++++++++++------------------------- src/topology/tplg_local.h | 14 +- 7 files changed, 311 insertions(+), 300 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/9 topology: ABI - Add name element to snd_soc_tplg_stream
From: Vedang Patel <[email protected]>
For codec-codec links, this struct will be mapped to the DAI links's params, which is struct snd_soc_pcm_stream and it needs a stream name.
include/sound/asoc.h +1 -0
@@ -208,6 +208,7 @@ struct snd_soc_tplg_stream_caps {*/ struct snd_soc_tplg_stream {__le32 size;/* in bytes of this structure */ +char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ];/* Name of the stream */ __le64 format;/* SNDRV_PCM_FMTBIT_* */ __le32 rate;/* SNDRV_PCM_RATE_* */ __le32 period_bytes;/* size of period in bytes */
Signature · 1 line
1.9.1
PATCH 2/9 topology: ABI - Separate PCM & BE/CC link support and bump ABI version to 4
In reply to [email protected]From: Vedang Patel <[email protected]>
The struct snd_soc_tplg_pcm_dai is renamed to snd_soc_tplg_pcm. This struct will now be used to handle data related to PCMs (FE DAI & DAI links). It's not for BE, because BE DAI mappings will be provided by ACPI/FDT data.
Remove the unused struct snd_soc_tplg_pcm_cfg_caps. We are using snd_soc_tplg_stream and snd_soc_stream_caps instead.
Define the topology type for BE DAI link: SND_SOC_TPLG_TYPE_BACKEND_LINK.
Define struct snd_soc_tplg_link_config to configure BE & CC links.
Bump ABI version to 4.
include/sound/asoc.h +34 -17
@@ -74,7 +74,7 @@#define SND_SOC_TPLG_NUM_TEXTS 16/* ABI version */ -#define SND_SOC_TPLG_ABI_VERSION 0x3 +#define SND_SOC_TPLG_ABI_VERSION 0x4/* Max size of TLV data */ #define SND_SOC_TPLG_TLV_SIZE 32
@@ -94,7 +94,8 @@#define SND_SOC_TPLG_TYPE_PCM 7#define SND_SOC_TPLG_TYPE_MANIFEST 8#define SND_SOC_TPLG_TYPE_CODEC_LINK 9 -#define SND_SOC_TPLG_TYPE_PDATA 10 +#define SND_SOC_TPLG_TYPE_BACKEND_LINK 10 +#define SND_SOC_TPLG_TYPE_PDATA 11#define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_PDATA/* vendor block IDs - please add new vendor types to end */
@@ -370,30 +371,46 @@ struct snd_soc_tplg_dapm_widget {*/ } __attribute__((packed)); -struct snd_soc_tplg_pcm_cfg_caps { -struct snd_soc_tplg_stream_caps caps; -struct snd_soc_tplg_stream_config configs[SND_SOC_TPLG_STREAM_CONFIG_MAX ]; -__le32 num_configs;/* number of configs */ -} __attribute__((packed));/* -* Describes SW/FW specific features of PCM or DAI link. +* Describes SW/FW specific features of PCM (FE DAI & DAI link). * -* File block representation for PCM/DAI-Link :- +* File block representation for PCM :- * +-----------------------------------+-----+ * | struct snd_soc_tplg_hdr | 1 | * +-----------------------------------+-----+ -* | struct snd_soc_tplg_dapm_pcm_dai | N | +* | struct snd_soc_tplg_pcm | N | * +-----------------------------------+-----+ */ -struct snd_soc_tplg_pcm_dai { +struct snd_soc_tplg_pcm {__le32 size;/* in bytes of this structure */ -char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; -__le32 id;/* unique ID - used to match */ -__le32 playback;/* supports playback mode */ -__le32 capture;/* supports capture mode */ -__le32 compress;/* 1 = compressed; 0 = PCM */ -struct snd_soc_tplg_pcm_cfg_caps capconf[2 ];/* capabilities and configs */ +char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +__le32 pcm_id;/* unique ID - used to match */ +__le32 dai_id;/* unique ID - used to match */ +__le32 playback;/* supports playback mode */ +__le32 capture;/* supports capture mode */ +__le32 compress;/* 1 = compressed; 0 = PCM */ +struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX ];/* for DAI link */ +__le32 num_streams;/* number of streams */ +struct snd_soc_tplg_stream_caps caps[2 ];/* playback and capture for DAI */ } __attribute__((packed)); + +/* +* Describes the BE or CC link runtime supported configs or params +* +* File block representation for BE/CC link config :- +* +-----------------------------------+-----+ +* | struct snd_soc_tplg_hdr | 1 | +* +-----------------------------------+-----+ +* | struct snd_soc_tplg_link_config | N | +* +-----------------------------------+-----+ +*/ +struct snd_soc_tplg_link_config { +__le32 size;/* in bytes of this structure */ +__le32 id;/* unique ID - used to match */ +struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX ];/* supported configs playback and captrure */ +__le32 num_streams;/* number of streams */ +} __attribute__((packed));#endif
src/topology/elem.c +4 -4
@@ -171,7 +171,7 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,break ;case SND_TPLG_TYPE_STREAM_CONFIG :list_add_tail (&elem->list, &tplg->pcm_config_list); - obj_size =sizeof (struct snd_soc_tplg_stream_config ); + obj_size =sizeof (struct snd_soc_tplg_stream );break ;case SND_TPLG_TYPE_STREAM_CAPS :list_add_tail (&elem->list, &tplg->pcm_caps_list);
@@ -179,15 +179,15 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,break ;case SND_TPLG_TYPE_PCM :list_add_tail (&elem->list, &tplg->pcm_list); - obj_size =sizeof (struct snd_soc_tplg_pcm_dai ); + obj_size =sizeof (struct snd_soc_tplg_pcm );break ;case SND_TPLG_TYPE_BE :list_add_tail (&elem->list, &tplg->be_list); - obj_size =sizeof (struct snd_soc_tplg_pcm_dai ); + obj_size =sizeof (struct snd_soc_tplg_link_config );break ;case SND_TPLG_TYPE_CC :list_add_tail (&elem->list, &tplg->cc_list); - obj_size =sizeof (struct snd_soc_tplg_pcm_dai ); + obj_size =sizeof (struct snd_soc_tplg_link_config );break ;default :free (elem);
src/topology/parser.c +3 -11
@@ -116,14 +116,6 @@ static int tplg_parse_config(snd_tplg_t *tplg, snd_config_t *cfg)continue ; } -if (strcmp (id,"SectionPCMConfig" ) ==0 ) { - err =tplg_parse_compound (tplg, n, - tplg_parse_pcm_config,NULL ); -if (err <0 ) -return err; -continue ; - } -if (strcmp (id,"SectionPCMCapabilities" ) ==0 ) { err =tplg_parse_compound (tplg, n, tplg_parse_pcm_caps,NULL );
@@ -241,15 +233,15 @@ static int tplg_build_integ(snd_tplg_t *tplg)if (err <0 )return err; - err =tplg_build_pcm_dai (tplg,SND_TPLG_TYPE_PCM ); + err =tplg_build_pcm (tplg,SND_TPLG_TYPE_PCM );if (err <0 )return err; - err =tplg_build_pcm_dai (tplg,SND_TPLG_TYPE_BE ); + err =tplg_build_link_cfg (tplg,SND_TPLG_TYPE_BE );if (err <0 )return err; - err =tplg_build_pcm_dai (tplg,SND_TPLG_TYPE_CC ); + err =tplg_build_link_cfg (tplg,SND_TPLG_TYPE_CC );if (err <0 )return err;
src/topology/pcm.c +80 -236
480 lines not on this page · raw message
src/topology/tplg_local.h +4 -10
@@ -108,11 +108,11 @@ struct tplg_elem {struct snd_soc_tplg_enum_control *enum_ctrl;struct snd_soc_tplg_bytes_control *bytes_ext;struct snd_soc_tplg_dapm_widget *widget; -struct snd_soc_tplg_pcm_dai *pcm; -struct snd_soc_tplg_pcm_dai *be; -struct snd_soc_tplg_pcm_dai *cc; +struct snd_soc_tplg_pcm *pcm; +struct snd_soc_tplg_link_config *be; +struct snd_soc_tplg_link_config *cc;struct snd_soc_tplg_dapm_graph_elem *route; -struct snd_soc_tplg_stream_config *stream_cfg; +struct snd_soc_tplg_stream *stream_cfg;struct snd_soc_tplg_stream_caps *stream_caps;/* these do not map to UAPI structs but are internal only */
@@ -164,15 +164,9 @@ int tplg_parse_dapm_graph(snd_tplg_t *tplg, snd_config_t *cfg,int tplg_parse_dapm_widget (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED); -int tplg_parse_pcm_config (snd_tplg_t *tplg, - snd_config_t *cfg, void *private ATTRIBUTE_UNUSED); -int tplg_parse_pcm_caps (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED); -int tplg_parse_pcm_cap_cfg (snd_tplg_t *tplg,snd_config_t *cfg, -void *private); -int tplg_parse_pcm (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED);
Signature · 1 line
1.9.1
PATCH 3/9 topology: ABI - Remove tdm_slot & dai_fmt from snd_soc_tplg_stream
In reply to [email protected]From: Mengdong Lin <[email protected]>
These two fields are line parameters for BE/CC links and should not be from toplogy but from ACPI.
include/sound/asoc.h +0 -2
@@ -215,8 +215,6 @@ struct snd_soc_tplg_stream {__le32 period_bytes;/* size of period in bytes */ __le32 buffer_bytes;/* size of buffer in bytes */ __le32 channels;/* channels */ -__le32 tdm_slot;/* optional BE bitmask of supported TDM slots */ -__le32 dai_fmt;/* SND_SOC_DAIFMT_ */ } __attribute__((packed));/*
Signature · 1 line
1.9.1
PATCH 4/9 topology: ABI - Remove unused struct snd_soc_tplg_stream_config
In reply to [email protected]From: Vedang Patel <[email protected]>
The struct snd_soc_tplg_stream_config is no longer used in the ABI. We are using snd_soc_tplg_stream instead.
include/sound/asoc.h +0 -10
@@ -218,16 +218,6 @@ struct snd_soc_tplg_stream { } __attribute__((packed));/* -* Duplex stream configuration supported by SW/FW. -*/ -struct snd_soc_tplg_stream_config { -__le32 size;/* in bytes of this structure */ -char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; -struct snd_soc_tplg_stream playback; -struct snd_soc_tplg_stream capture; -} __attribute__((packed)); - -/* * Manifest. List totals for each payload type. Not used in parsing, but will * be passed to the component driver before any other objects in order for any * global component resource allocations.
Signature · 1 line
1.9.1
PATCH 5/9 topology: ABI - Use __le32 instead of __u32 in snd_soc_tplg_dapm_widget
In reply to [email protected]From: Vedang Patel <[email protected]>
This fixes the endianness of the ABI parameters in the struct. The field 'num_kcontrols' is also extended from 16 bits to 32 bits.
include/sound/asoc.h +5 -5
@@ -347,11 +347,11 @@ struct snd_soc_tplg_dapm_widget {__le32 shift;/* bits to shift */ __le32 mask;/* non-shifted mask */ __le32 subseq;/* sort within widget type */ -__u32 invert;/* invert the power bit */ -__u32 ignore_suspend;/* kept enabled over suspend */ -__u16 event_flags; -__u16 event_type; -__u16 num_kcontrols; +__le32 invert;/* invert the power bit */ +__le32 ignore_suspend;/* kept enabled over suspend */ +__le16 event_flags; +__le16 event_type; +__le32 num_kcontrols;struct snd_soc_tplg_private priv;/* * kcontrols that relate to this widget
Signature · 1 line
1.9.1
PATCH 6/9 topology: ABI - Change stream formats to a bitwise flag
In reply to [email protected]From: Mengdong Lin <[email protected]>
The toplogy user space tool will generate this bitwise flag by using SNDRV_PCM_FORMAT_* exposed by asound.h, and the topology core will copy this flag when generating DAI streams.
include/sound/asoc.h +1 -1
@@ -190,7 +190,7 @@ struct snd_soc_tplg_ctl_hdr {struct snd_soc_tplg_stream_caps {__le32 size;/* in bytes of this structure */ char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; -__le64 formats[SND_SOC_TPLG_MAX_FORMATS ];/* supported formats SNDRV_PCM_FMTBIT_* */ +__le64 formats;/* supported formats SNDRV_PCM_FMTBIT_* */ __le32 rates;/* supported rates SNDRV_PCM_RATE_* */ __le32 rate_min;/* min rate */ __le32 rate_max;/* max rate */
src/topology/pcm.c +1 -1
@@ -174,7 +174,7 @@ static int split_format(struct snd_soc_tplg_stream_caps *caps, char *str)return -EINVAL ; } - caps->formats[i] = format; + caps->formats |=1 << format; s =strtok (NULL ,", " ); i++; }
Signature · 1 line
1.9.1
PATCH 7/9 topology: ABI - Rename dai_elems to pcm_elems in manifest
In reply to [email protected]From: Mengdong Lin <[email protected]>
This field is the number of PCM objects (a pair of FE DAI and DAI link).
include/sound/asoc.h +1 -1
@@ -234,7 +234,7 @@ struct snd_soc_tplg_manifest {__le32 control_elems;/* number of control elements */ __le32 widget_elems;/* number of widget elements */ __le32 graph_elems;/* number of graph elements */ -__le32 dai_elems;/* number of DAI elements */ +__le32 pcm_elems;/* number of PCM elements */ __le32 dai_link_elems;/* number of DAI link elements */ struct snd_soc_tplg_private priv; } __attribute__((packed));
Signature · 1 line
1.9.1
PATCH 8/9 topology: Add C API support for BE and CC Links.
In reply to [email protected]From: Vedang Patel <[email protected]>
Adding BE and CC Link support for C API reference. This will be used to populate the .hw_params element for BE and .params for CC, enabling us to update already existing DAI Links created by the kernel.
include/topology.h +23 -0
@@ -648,6 +648,28 @@ struct snd_tplg_widget_template {struct snd_tplg_ctl_template *ctl[0 ];/*!< array of widget controls */ }; +/** \struct snd_tplg_stream_template +* \brief Stream configurations. +*/ +struct snd_tplg_stream_template { +const char *name;/*!< name of the stream config */ +int format;/*!< SNDRV_PCM_FMTBIT_* */ +int rate;/*!< SNDRV_PCM_RATE_* */ +int period_bytes;/*!< size of period in bytes */ +int buffer_bytes;/*!< size of buffer in bytes. */ +int channels;/*!< number of channels */ +}; + +/** \struct snd_tplg_link_template +* \brief Template type for BE and CC DAI Links. +*/ +struct snd_tplg_link_template { +const char *name;/*!< link name */ +int id;/*!< unique ID - used to match with existing BE and CC links */ +int num_streams;/*!< number of configs */ +struct snd_tplg_stream_template stream[0 ];/*!< supported configs */ +}; +/** \struct snd_tplg_obj_template * \brief Generic Template Object */
@@ -662,6 +684,7 @@ typedef struct snd_tplg_obj_template {struct snd_tplg_bytes_template *bytes_ctl;/*!< Bytes control */ struct snd_tplg_enum_template *enum_ctl;/*!< Enum control */ struct snd_tplg_graph_template *graph;/*!< Graph elements */ +struct snd_tplg_link_template *link;/*!< BE and CC Links */ }; } snd_tplg_obj_template_t;
src/topology/builder.c +2 -2
@@ -221,10 +221,10 @@ static int write_block(snd_tplg_t *tplg, struct list_head *base, SND_SOC_TPLG_TYPE_PCM, "pcm");case SND_TPLG_TYPE_BE :return write_elem_block (tplg, base, size, -SND_SOC_TPLG_TYPE_DAI_LINK ,"be" ); +SND_SOC_TPLG_TYPE_BACKEND_LINK ,"be" );case SND_TPLG_TYPE_CC :return write_elem_block (tplg, base, size, -SND_SOC_TPLG_TYPE_DAI_LINK ,"cc" ); +SND_SOC_TPLG_TYPE_CODEC_LINK ,"cc" );case SND_TPLG_TYPE_DATA :return write_elem_block (tplg, base, size,SND_SOC_TPLG_TYPE_PDATA ,"data" );
src/topology/parser.c +3 -0
@@ -311,6 +311,9 @@ int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)return tplg_add_widget_object (tplg, t);case SND_TPLG_TYPE_DAPM_GRAPH :return tplg_add_graph_object (tplg, t); +case SND_TPLG_TYPE_BE : +case SND_TPLG_TYPE_CC : +return tplg_add_link_object (tplg, t);default :SNDERR ("error: invalid object type %d\n" , t->type);return -EINVAL ;
src/topology/pcm.c +46 -0
49 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 9/9 topology: Add C API support for PCM
In reply to [email protected]From: Mengdong Lin <[email protected]>
PCM objects can be added by C API. And this is used to create FE DAIs and DAI links in kernel.
include/topology.h +36 -0
@@ -660,6 +660,41 @@ struct snd_tplg_stream_template {int channels;/*!< number of channels */ }; +/** \struct snd_tplg_stream_caps_template +* \brief Stream Capabilities. +*/ +struct snd_tplg_stream_caps_template { +const char *name;/*!< name of the stream caps */ +__le64 formats;/*!< supported formats SNDRV_PCM_FMTBIT_* */ +unsigned int rates;/*!< supported rates SNDRV_PCM_RATE_* */ +unsigned int rate_min;/*!< min rate */ +unsigned int rate_max;/*!< max rate */ +unsigned int channels_min;/*!< min channels */ +unsigned int channels_max;/*!< max channels */ +unsigned int periods_min;/*!< min number of periods */ +unsigned int periods_max;/*!< max number of periods */ +unsigned int period_size_min;/*!< min period size bytes */ +unsigned int period_size_max;/*!< max period size bytes */ +unsigned int buffer_size_min;/*!< min buffer size bytes */ +unsigned int buffer_size_max;/*!< max buffer size bytes */ +}; + +/** \struct snd_tplg_pcm_template +* \brief Template type for PCM (FE DAI & DAI links). +*/ +struct snd_tplg_pcm_template { +const char *pcm_name;/*!< PCM stream name */ +const char *dai_name;/*!< DAI name */ +unsigned int pcm_id;/*!< unique ID - used to match */ +unsigned int dai_id;/*!< unique ID - used to match */ +unsigned int playback;/*!< supports playback mode */ +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 */ +int num_streams;/*!< number of supported configs */ +struct snd_tplg_stream_template stream[0 ];/*!< supported configs */ +}; +/** \struct snd_tplg_link_template * \brief Template type for BE and CC DAI Links. */
@@ -684,6 +719,7 @@ typedef struct snd_tplg_obj_template {struct snd_tplg_bytes_template *bytes_ctl;/*!< Bytes control */ struct snd_tplg_enum_template *enum_ctl;/*!< Enum control */ struct snd_tplg_graph_template *graph;/*!< Graph elements */ +struct snd_tplg_pcm_template *pcm;/*!< PCM elements */ struct snd_tplg_link_template *link;/*!< BE and CC Links */ }; } snd_tplg_obj_template_t;
src/topology/parser.c +2 -0
@@ -311,6 +311,8 @@ int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)return tplg_add_widget_object (tplg, t);case SND_TPLG_TYPE_DAPM_GRAPH :return tplg_add_graph_object (tplg, t); +case SND_TPLG_TYPE_PCM : +return tplg_add_pcm_object (tplg, t);case SND_TPLG_TYPE_BE :case SND_TPLG_TYPE_CC :return tplg_add_link_object (tplg, t);
src/topology/pcm.c +65 -0
77 lines not on this page · raw message
Signature · 1 line
1.9.1