topology: Remaining user space patches of ABI v5
cover topology: Remaining user space patches of ABI v5
From: Mengdong Lin <[email protected]>
This series has all remaining topology user space patches for ABI update of version 5.
Backward compatibility from ABI v4 is assured by the kernel series "ASoC: topology: Remaining kernel patches of ABI v5", submitted as well.
Guneshwor Singh (3):
topology: ABI - Define new types for physical DAI
topology: Support configuring physical DAIs by C API
topology: Export physical DAIs to the binary for kernel
Mengdong Lin (19):
topology: ABI - Update stream caps and PCM objects to ABI v5
topology: Parse sig_bits of stream caps
topology: Parse flags for PCM
topology: Define a function to build a single PCM element
topology: Parse and build private data for PCM
topology: tplg_elem_lookup() checks parameter before searching
topology: Merge an element's be & cc pointer to one link pointer
topology: Define a function to build a single physical DAI link
topology: ABI - Define DAI physical PCM data formats
topology: ABI - Update physical DAI link configurations to ABI v5
topology: Rename varaibles for add physical links by C API
topology: Define new type and section name to configure physical links
topology: Parse HW configurations of physical DAI links defined by C
API
topology: Parse HW configurations of physical DAI links in text conf
file
topology: Parse link flags of physical DAI links
topology: Parse and build private data of physical links
topology: Parse name and stream name of physical DAI links
topology: ABI - Update manifest to ABI v5
topology: Parse physical DAIs in text conf file
include/sound/asoc.h | 108 ++++++- include/topology.h | 149 ++++++++- src/topology/builder.c | 11 + src/topology/data.c | 4 + src/topology/elem.c | 12 + src/topology/parser.c | 38 ++- src/topology/pcm.c | 775 +++++++++++++++++++++++++++++++++++++++++++--- src/topology/tplg_local.h | 21 +- 8 files changed, 1064 insertions(+), 54 deletions(-)
Signature · 1 line
2.5.0
PATCH 1/22 topology: ABI - Update stream caps and PCM objects to ABI v5
From: Mengdong Lin <[email protected]>
Pump ABI version to 5, with the updates for PCM (Front DAI & DAI link) objects:
- add sig_bits to stream caps.
- add flags and private data to PCM.
The kernel can handle the ABI update in a backward compatible way with the patch "ASoC: topology: Make PCM backward compatible from ABI v4".
include/sound/asoc.h +11 -0
@@ -115,6 +115,13 @@#define SND_SOC_TPLG_TUPLE_TYPE_WORD 4#define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5 +/* DAI link flags */ +#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES (1 << 0) +#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS (1 << 1) +#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2) +#define SND_SOC_TPLG_LNK_FLGBIT_IGNORE_SUSPEND (1 << 3) +#define SND_SOC_TPLG_LNK_FLGBIT_IGNORE_POWERDOWN_TIME (1 << 4) +/* * Block Header. * This header precedes all object and object arrays below.
@@ -242,6 +249,7 @@ struct snd_soc_tplg_stream_caps {__le32 period_size_max;/* max period size bytes */ __le32 buffer_size_min;/* min buffer size bytes */ __le32 buffer_size_max;/* max buffer size bytes */ +__le32 sig_bits;/* number of bits of content */ } __attribute__((packed));/*
@@ -422,6 +430,9 @@ struct snd_soc_tplg_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 */ +__le32 flag_mask;/* bitmask of flags to configure */ +__le32 flags;/* SND_SOC_TPLG_LNK_FLGBIT_* flag value */ +struct snd_soc_tplg_private priv; } __attribute__((packed));
Signature · 1 line
2.5.0
PATCH 2/22 topology: Parse sig_bits of stream caps
In reply to [email protected]From: Mengdong Lin <[email protected]>
Add sig_bits to stream caps template of C API and parse it.
include/topology.h +1 -0
@@ -848,6 +848,7 @@ struct snd_tplg_stream_caps_template {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 */ +unsigned int sig_bits;/*!< number of bits of content */ };/** \struct snd_tplg_pcm_template
src/topology/pcm.c +1 -0
@@ -572,6 +572,7 @@ static void tplg_add_stream_caps(struct snd_soc_tplg_stream_caps *caps, caps->period_size_max = caps_tpl->period_size_max; caps->buffer_size_min = caps_tpl->buffer_size_min; caps->buffer_size_max = caps_tpl->buffer_size_max; + caps->sig_bits = caps_tpl->sig_bits; }int tplg_add_pcm_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t)
Signature · 1 line
2.5.0
PATCH 3/22 topology: Parse flags for PCM
In reply to [email protected]From: Mengdong Lin <[email protected]>
Users can define flags by both text conf file and C API. Add flags and flag_mask to C API template of PCM object.
include/topology.h +9 -0
@@ -606,6 +606,13 @@ extern "C" {* "config3" * ] * } +* +* # Optional flags, the default value is "false". +* symmetric_rates "true or false" +* symmetric_channels "true or false" +* symmetric_sample_bits "true or false" +* ignore_suspend "true or false" +* ignore_powerdown_time "true or false" * } * </pre> *
@@ -863,6 +870,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 */ int num_streams;/*!< number of supported configs */ struct snd_tplg_stream_template stream[0 ];/*!< supported configs */ };
src/topology/pcm.c +68 -0
86 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 4/22 topology: Define a function to build a single PCM element
In reply to [email protected]From: Mengdong Lin <[email protected]>
Code refactoring. Rename tplg_build_pcm() to tplg_build_pcms() to build all PCM (FE DAI & DAI link) elements. It will call a new function build_pcm() to build a single PCM elemement.
build_pcm() will be extended to handle more properties of a PCM.
src/topology/parser.c +1 -1
@@ -267,7 +267,7 @@ static int tplg_build_integ(snd_tplg_t *tplg)if (err <0 )return err; - err =tplg_build_pcm (tplg,SND_TPLG_TYPE_PCM ); + err =tplg_build_pcms (tplg,SND_TPLG_TYPE_PCM );if (err <0 )return err;
src/topology/pcm.c +15 -3
@@ -70,8 +70,20 @@ static int tplg_build_stream_caps(snd_tplg_t *tplg,return 0 ; } -/* build FE DAI/PCM configurations */ -int tplg_build_pcm (snd_tplg_t *tplg,unsigned int type) +/* build a PCM (FE DAI & DAI link) element */ +static int build_pcm (snd_tplg_t *tplg,struct tplg_elem *elem) +{ +int err; + + err =tplg_build_stream_caps (tplg, elem->id, elem->pcm->caps); +if (err <0 ) +return err; + +return 0 ; +} + +/* build all PCM (FE DAI & DAI link) elements */ +int tplg_build_pcms (snd_tplg_t *tplg,unsigned int type) {struct list_head *base, *pos;struct tplg_elem *elem;
@@ -86,7 +98,7 @@ int tplg_build_pcm(snd_tplg_t *tplg, unsigned int type)return -EINVAL ; } - err =tplg_build_stream_caps (tplg, elem->id, elem->pcm->caps); + err =build_pcm (tplg, elem);if (err <0 )return err;
src/topology/tplg_local.h +1 -1
@@ -284,7 +284,7 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl,int tplg_add_bytes (snd_tplg_t *tplg,struct snd_tplg_bytes_template *bytes_ctl,struct tplg_elem **e); -int tplg_build_pcm (snd_tplg_t *tplg,unsigned int type); +int tplg_build_pcms (snd_tplg_t *tplg,unsigned int type);int tplg_build_link_cfg (snd_tplg_t *tplg,unsigned int type);int tplg_add_link_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t);int tplg_add_pcm_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t);
Signature · 1 line
2.5.0
PATCH 5/22 topology: Parse and build private data for PCM
In reply to [email protected]From: Mengdong Lin <[email protected]>
Users can define private for PCM (FE DAI & DAI links) elements by both text conf file and C API:
- Text conf file may define multiple data blocks for a PCM and they will be merged in building phase;
- Add private data to C API template of PCM object.
include/topology.h +3 -0
@@ -613,6 +613,8 @@ extern "C" {* symmetric_sample_bits "true or false" * ignore_suspend "true or false" * ignore_powerdown_time "true or false" +* +* data "name" # optional private data * } * </pre> *
@@ -872,6 +874,7 @@ struct snd_tplg_pcm_template {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 */ +struct snd_soc_tplg_private *priv;/*!< private data */ int num_streams;/*!< number of supported configs */ struct snd_tplg_stream_template stream[0 ];/*!< supported configs */ };
src/topology/pcm.c +50 -2
97 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 6/22 topology: tplg_elem_lookup() checks parameter before searching
In reply to [email protected]From: Mengdong Lin <[email protected]>
Check the parameters at first in case of misuse.
src/topology/elem.c +3 -0
@@ -111,6 +111,9 @@ struct tplg_elem *tplg_elem_lookup(struct list_head *base, const char* id,struct list_head *pos;struct tplg_elem *elem; +if (!base || !id) +return NULL ; +list_for_each (pos, base) { elem = list_entry(pos, struct tplg_elem, list);
Signature · 1 line
2.5.0
PATCH 7/22 topology: Merge an element's be & cc pointer to one link pointer
In reply to [email protected]From: Mengdong Lin <[email protected]>
Code refactoring. Previously an element has two pointers, 'be' and 'cc', for BE (Back End) and CC (Codec-Codec) link respectively. But actually the topology tool processes BE and CC links in the same way, so these two pointers can be merged into one 'link' pointer, which can be used configure any physical links.
src/topology/pcm.c +6 -12
@@ -175,11 +175,7 @@ int tplg_build_link_cfg(snd_tplg_t *tplg, unsigned int type)return -EINVAL ; } -if (type ==SND_TPLG_TYPE_BE ) - link = elem->be; -else - link = elem->cc; - + link = elem->link; err =tplg_build_stream_cfg (tplg, link->stream, link->num_streams);if (err <0 )
@@ -546,7 +542,7 @@ int tplg_parse_be(snd_tplg_t *tplg,if (!elem)return -ENOMEM ; - link = elem->be; + link = elem->link; link->size = elem->size;tplg_dbg (" BE: %s\n" , elem->id);
@@ -606,7 +602,7 @@ int tplg_parse_cc(snd_tplg_t *tplg,if (!elem)return -ENOMEM ; - link = elem->cc; + link = elem->link; link->size = elem->size;tplg_dbg (" CC: %s\n" , elem->id);
@@ -760,14 +756,12 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)if (!elem)return -ENOMEM ; -if (t->type ==SND_TPLG_TYPE_BE ) { +if (t->type ==SND_TPLG_TYPE_BE )tplg_dbg ("BE Link: %s" , link->name); - lk = elem->be; - }else { +else tplg_dbg ("CC Link: %s" , link->name); - lk = elem->cc; - } + lk = elem->link; lk->size = elem->size; lk->id = link->id; lk->num_streams = link->num_streams;
src/topology/tplg_local.h +1 -2
@@ -144,8 +144,7 @@ struct tplg_elem {struct snd_soc_tplg_bytes_control *bytes_ext;struct snd_soc_tplg_dapm_widget *widget;struct snd_soc_tplg_pcm *pcm; -struct snd_soc_tplg_link_config *be; -struct snd_soc_tplg_link_config *cc; +struct snd_soc_tplg_link_config *link;/* physical link */ struct snd_soc_tplg_dapm_graph_elem *route;struct snd_soc_tplg_stream *stream_cfg;struct snd_soc_tplg_stream_caps *stream_caps;
Signature · 1 line
2.5.0
PATCH 8/22 topology: Define a function to build a single physical DAI link
In reply to [email protected]From: Mengdong Lin <[email protected]>
Code refactoring. Rename the function to build all physical links from tplg_build_link_config() to tplg_build_links(). And define a new function build_link() to build a single physical DAI link element.
The function build_link() will be extended to handle more properties of a physical DAI link (e.g. backend or codec-codec link).
src/topology/parser.c +2 -2
@@ -271,11 +271,11 @@ static int tplg_build_integ(snd_tplg_t *tplg)if (err <0 )return err; - err =tplg_build_link_cfg (tplg,SND_TPLG_TYPE_BE ); + err =tplg_build_links (tplg,SND_TPLG_TYPE_BE );if (err <0 )return err; - err =tplg_build_link_cfg (tplg,SND_TPLG_TYPE_CC ); + err =tplg_build_links (tplg,SND_TPLG_TYPE_CC );if (err <0 )return err;
src/topology/pcm.c +22 -5
@@ -148,12 +148,31 @@ static int tplg_build_stream_cfg(snd_tplg_t *tplg,return 0 ; } +static int build_link (snd_tplg_t *tplg,struct tplg_elem *elem) +{ +struct snd_soc_tplg_link_config *link = elem->link; +struct tplg_elem *ref_elem =NULL ; +struct snd_soc_tplg_link_cmpnt *codec, *cmpnt; +struct tplg_ref *ref; +struct list_head *base, *pos; +int i, num_hw_configs =0 , err =0 ; + + err =tplg_build_stream_cfg (tplg, link->stream, + link->num_streams); +if (err <0 ) +return err; + +/* add link to manifest */ + tplg->manifest.dai_link_elems++; + +return 0 ; +} +/* build BE/CC DAI link configurations */ -int tplg_build_link_cfg (snd_tplg_t *tplg,unsigned int type) +int tplg_build_links (snd_tplg_t *tplg,unsigned int type) {struct list_head *base, *pos;struct tplg_elem *elem; -struct snd_soc_tplg_link_config *link;int err =0 ;switch (type) {
@@ -175,9 +194,7 @@ int tplg_build_link_cfg(snd_tplg_t *tplg, unsigned int type)return -EINVAL ; } - link = elem->link; - err =tplg_build_stream_cfg (tplg, link->stream, - link->num_streams); + err =build_link (tplg, elem);if (err <0 )return err; }
src/topology/tplg_local.h +1 -1
@@ -284,6 +284,6 @@ int tplg_add_bytes(snd_tplg_t *tplg, struct snd_tplg_bytes_template *bytes_ctl, struct tplg_elem **e);int tplg_build_pcms (snd_tplg_t *tplg,unsigned int type); -int tplg_build_link_cfg (snd_tplg_t *tplg,unsigned int type); +int tplg_build_links (snd_tplg_t *tplg,unsigned int type);int tplg_add_link_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t);int tplg_add_pcm_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t);
Signature · 1 line
2.5.0
PATCH 9/22 topology: ABI - Define DAI physical PCM data formats
In reply to [email protected]From: Mengdong Lin <[email protected]>
Define DAI physical PCM data formats for user space, so users can specify the formats of backends by topology (e.g. the DAI format to set on backend link init).
The kernel will also refer to these formats.
include/sound/asoc.h +15 -0
@@ -122,6 +122,21 @@#define SND_SOC_TPLG_LNK_FLGBIT_IGNORE_SUSPEND (1 << 3)#define SND_SOC_TPLG_LNK_FLGBIT_IGNORE_POWERDOWN_TIME (1 << 4) +/* DAI physical PCM data formats. +* Add new formats to the end of the list. +*/ +#define SND_SOC_DAI_FORMAT_I2S 1/* I2S mode */ +#define SND_SOC_DAI_FORMAT_RIGHT_J 2/* Right Justified mode */ +#define SND_SOC_DAI_FORMAT_LEFT_J 3/* Left Justified mode */ +#define SND_SOC_DAI_FORMAT_DSP_A 4/* L data MSB after FRM LRC */ +#define SND_SOC_DAI_FORMAT_DSP_B 5/* L data MSB during FRM LRC */ +#define SND_SOC_DAI_FORMAT_AC97 6/* AC97 */ +#define SND_SOC_DAI_FORMAT_PDM 7/* Pulse density modulation */ + +/* left and right justified also known as MSB and LSB respectively */ +#define SND_SOC_DAI_FORMAT_MSB SND_SOC_DAI_FORMAT_LEFT_J +#define SND_SOC_DAI_FORMAT_LSB SND_SOC_DAI_FORMAT_RIGHT_J +/* * Block Header. * This header precedes all object and object arrays below.
Signature · 1 line
2.5.0
PATCH 10/22 topology: ABI - Update physical DAI link configurations to ABI v5
In reply to [email protected]From: Mengdong Lin <[email protected]>
This patch update physicals DAI link config to ABI v5:
- Define the types and ABI struct for runtime supported hardware configs e.g. audio hardware formats. The default HW config ID will help topology to find the DAI format to set on init. Topology provides this as a fallback if such HW settings are not available in ACPI or device tree, to avoid hard code in drivers. It's only for config items that can be programmed by SW or FW, not for physical things like link connections or GPIO used for HP etc.
- Add flags. The flags will be used to configure an existing physical links.
- Add private data. The private data is reserved for future extension.
- Add name and stream name to BE DAI links. Kernel can also use name and stream name to find an existing physical link and configure it.
Kernel can handle the ABI update in a backward compatible way via patch 'ASoC: topology: Add support to configure existing physical DAI links'.
include/sound/asoc.h +44 -2
@@ -30,6 +30,11 @@*/ #define SND_SOC_TPLG_STREAM_CONFIG_MAX 8 +/* +* Maximum number of physical link's hardware configs +*/ +#define SND_SOC_TPLG_HW_CONFIG_MAX 8 +/* individual kcontrol info types - can be mixed with other types */ #define SND_SOC_TPLG_CTL_VOLSW 1#define SND_SOC_TPLG_CTL_VOLSW_SX 2
@@ -280,6 +285,35 @@ struct snd_soc_tplg_stream {__le32 channels;/* channels */ } __attribute__((packed)); + +/* +* Describes a physical link's runtime supported hardware config, +* i.e. hardware audio formats. +*/ +struct snd_soc_tplg_hw_config { +__le32 size;/* in bytes of this structure */ +__le32 id;/* unique ID - - used to match */ +__le32 fmt;/* SND_SOC_DAI_FORMAT_ format value */ +__u8 clock_gated;/* 1 if clock can be gated to save power */ +__u8 invert_bclk;/* 1 for inverted BCLK, 0 for normal */ +__u8 invert_fsync;/* 1 for inverted frame clock, 0 for normal */ +__u8 bclk_master;/* 1 for master of BCLK, 0 for slave */ +__u8 fsync_master;/* 1 for master of FSYNC, 0 for slave */ +__u8 mclk_direction;/* 0 for input, 1 for output */ +__le16 reserved;/* for 32bit alignment */ +__le32 mclk_rate;/* MCLK or SYSCLK freqency in Hz */ +__le32 bclk_rate;/* BCLK freqency in Hz */ +__le32 fsync_rate;/* frame clock in Hz */ +__le32 tdm_slots;/* number of TDM slots in use */ +__le32 tdm_slot_width;/* width in bits for each slot */ +__le32 tx_slots;/* bit mask for active Tx slots */ +__le32 rx_slots;/* bit mask for active Rx slots */ +__le32 tx_channels;/* number of Tx channels */ +__le32 tx_chanmap[SND_SOC_TPLG_MAX_CHAN ];/* array of slot number */ +__le32 rx_channels;/* number of Rx channels */ +__le32 rx_chanmap[SND_SOC_TPLG_MAX_CHAN ];/* array of slot number */ +} __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
@@ -452,9 +486,9 @@ struct snd_soc_tplg_pcm {/* -* Describes the BE or CC link runtime supported configs or params +* Describes the physical link runtime supported configs or params * -* File block representation for BE/CC link config :- +* File block representation for physical link config :- * +-----------------------------------+-----+ * | struct snd_soc_tplg_hdr | 1 | * +-----------------------------------+-----+
@@ -464,7 +498,15 @@ struct snd_soc_tplg_pcm {struct snd_soc_tplg_link_config {__le32 size;/* in bytes of this structure */ __le32 id;/* unique ID - used to match */ +char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ];/* name - used to match */ +char stream_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ];/* stream name - 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 */ +struct snd_soc_tplg_hw_config hw_config[SND_SOC_TPLG_HW_CONFIG_MAX ];/* hw configs */ +__le32 num_hw_configs;/* number of hw configs */ +__le32 default_hw_config_id;/* default hw config ID for init */ +__le32 flag_mask;/* bitmask of flags to configure */ +__le32 flags;/* SND_SOC_TPLG_LNK_FLGBIT_* flag value */ +struct snd_soc_tplg_private priv; } __attribute__((packed));#endif
Signature · 1 line
2.5.0
PATCH 11/22 topology: Rename varaibles for add physical links by C API
In reply to [email protected]From: Mengdong Lin <[email protected]>
Code refactoring. When adding a physical link element from C API:
- Rename "link" to "link_tpl" for physical link config template for C API users.
- Rename "lk" to "link" for physical link elements created by topology internally.
src/topology/pcm.c +14 -10
@@ -758,10 +758,11 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)return 0 ; } +/* Add a physical DAI link element from C API */ int tplg_add_link_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t) { -struct snd_tplg_link_template *link = t->link; -struct snd_soc_tplg_link_config *lk; +struct snd_tplg_link_template *link_tpl = t->link; +struct snd_soc_tplg_link_config *link, *_link;struct tplg_elem *elem;int i;
@@ -769,22 +770,25 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)return -EINVAL ;/* here type can be either BE or CC. */ - elem =tplg_elem_new_common (tplg,NULL , link->name, t->type); + elem =tplg_elem_new_common (tplg,NULL , link_tpl->name, t->type);if (!elem)return -ENOMEM ;if (t->type ==SND_TPLG_TYPE_BE ) -tplg_dbg ("BE Link: %s" , link->name); +tplg_dbg ("BE Link: %s" , link_tpl->name);else -tplg_dbg ("CC Link: %s" , link->name); +tplg_dbg ("CC Link: %s" , link_tpl->name); - lk = elem->link; - lk->size = elem->size; - lk->id = link->id; - lk->num_streams = link->num_streams; + link = elem->link; + link->size = elem->size; + link->id = link_tpl->id; +/* stream configs */ +if (link_tpl->num_streams >SND_SOC_TPLG_STREAM_CONFIG_MAX ) +return -EINVAL ; + link->num_streams = link_tpl->num_streams;for (i =0 ; i < link->num_streams; i++) -tplg_add_stream_object (&lk->stream[i], &link->stream[i]); +tplg_add_stream_object (&link->stream[i], &link_tpl->stream[i]);return 0 ; }
Signature · 1 line
2.5.0
PATCH 12/22 topology: Define new type and section name to configure physical links
In reply to [email protected]From: Mengdong Lin <[email protected]>
Users may not use DPCM but still need to configure the physical links. So we should not only consider backend links for DPCM.
- SND_TPLG_TYPE_LINK is defined to configure physical links by C API. And SND_TPLG_TYPE_BE is still supported to configure Backend links for DPCM cases.
- SectionLink can be used to configure physical links in text conf file. And SectionBE is still supported to config Backend links for DPCM cases.
Actually, users can also use SND_TPLG_TYPE_LINK and SectionLink to configure backend links for DPCM cases, because BE links are physical links. So the parsing is same and we rename the function from tplg_parse_be to tplg_parse_link.
include/topology.h +19 -0
@@ -618,6 +618,24 @@ extern "C" {* } * </pre> * +* <h4>Physical DAI Link Configurations</h4> +* The runtime configurations of a physical DAI link can be defined by +* SectionLink. <br> Backend DAI links belong to physical links, and can +* be configured by either SectionLink or SectionBE, with same syntax. +* But SectionBE is deprecated atm since the internal processing is +* actually same. +* +* <pre> +* SectionLink."name" { +* +* index "1" # Index number +* +* id "0" # used for binding to the link +* +* data "name" # optional private data +* } +* </pre> +* * <h4>Manifest Private Data</h4> * Manfiest may have private data. Users need to define a manifest section * and add the references to 1 or multiple data sections. Please refer to
@@ -658,6 +676,7 @@ enum snd_tplg_type {SND_TPLG_TYPE_MANIFEST ,/*!< Topology manifest */ SND_TPLG_TYPE_TOKEN ,/*!< Vendor tokens */ SND_TPLG_TYPE_TUPLE ,/*!< Vendor tuples */ + SND_TPLG_TYPE_LINK, /*!< Physical DAI link */ };/**
src/topology/parser.c +3 -2
@@ -133,8 +133,9 @@ static int tplg_parse_config(snd_tplg_t *tplg, snd_config_t *cfg)continue ; } -if (strcmp (id,"SectionBE" ) ==0 ) { - err =tplg_parse_compound (tplg, n, tplg_parse_be, +if (strcmp (id,"SectionLink" ) ==0 + ||strcmp (id,"SectionBE" ) ==0 ) { + err =tplg_parse_compound (tplg, n, tplg_parse_link,NULL );if (err <0 )return err;
src/topology/pcm.c +6 -7
@@ -545,7 +545,8 @@ int tplg_parse_pcm(snd_tplg_t *tplg,return 0 ; } -int tplg_parse_be (snd_tplg_t *tplg, +/* Parse a physical link element in text conf file */ +int tplg_parse_link (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED) {struct snd_soc_tplg_link_config *link;
@@ -562,7 +563,7 @@ int tplg_parse_be(snd_tplg_t *tplg, link = elem->link; link->size = elem->size; -tplg_dbg (" BE: %s\n" , elem->id); +tplg_dbg (" Link: %s\n" , elem->id);snd_config_for_each (i, next, cfg) {
@@ -766,7 +767,8 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)struct tplg_elem *elem;int i; -if (t->type !=SND_TPLG_TYPE_BE && t->type !=SND_TPLG_TYPE_CC ) +if (t->type !=SND_TPLG_TYPE_LINK && t->type !=SND_TPLG_TYPE_BE + && t->type !=SND_TPLG_TYPE_CC )return -EINVAL ;/* here type can be either BE or CC. */
@@ -774,10 +776,7 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)if (!elem)return -ENOMEM ; -if (t->type ==SND_TPLG_TYPE_BE ) -tplg_dbg ("BE Link: %s" , link_tpl->name); -else -tplg_dbg ("CC Link: %s" , link_tpl->name); +tplg_dbg ("Link: %s" , link_tpl->name); link = elem->link; link->size = elem->size;
src/topology/tplg_local.h +1 -1
@@ -220,7 +220,7 @@ int tplg_parse_stream_caps(snd_tplg_t *tplg,int tplg_parse_pcm (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED); -int tplg_parse_be (snd_tplg_t *tplg, +int tplg_parse_link (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED); int tplg_parse_cc(snd_tplg_t *tplg,
Signature · 1 line
2.5.0
PATCH 13/22 topology: Parse HW configurations of physical DAI links defined by C API
In reply to [email protected]From: Mengdong Lin <[email protected]>
Add HW configurations to C API template of physical link configuration.
include/topology.h +32 -1
@@ -898,6 +898,33 @@ struct snd_tplg_pcm_template {struct snd_tplg_stream_template stream[0 ];/*!< supported configs */ }; +/** \struct snd_tplg_hw_config_template +* \brief Template type to describe a physical link runtime supported +* hardware config, i.e. hardware audio formats. +*/ +struct snd_tplg_hw_config_template { +int id;/* unique ID - - used to match */ +unsigned int fmt;/* SND_SOC_DAI_FORMAT_ format value */ +unsigned char clock_gated;/* 1 if clock can be gated to save power */ +unsigned char invert_bclk;/* 1 for inverted BCLK, 0 for normal */ +unsigned char invert_fsync;/* 1 for inverted frame clock, 0 for normal */ +unsigned char bclk_master;/* 1 for master of BCLK, 0 for slave */ +unsigned char fsync_master;/* 1 for master of FSYNC, 0 for slave */ +unsigned char mclk_direction;/* 0 for input, 1 for output */ +unsigned short reserved;/* for 32bit alignment */ +unsigned int mclk_rate;/* MCLK or SYSCLK freqency in Hz */ +unsigned int bclk_rate;/* BCLK freqency in Hz */ +unsigned int fsync_rate;/* frame clock in Hz */ +unsigned int tdm_slots;/* number of TDM slots in use */ +unsigned int tdm_slot_width;/* width in bits for each slot */ +unsigned int tx_slots;/* bit mask for active Tx slots */ +unsigned int rx_slots;/* bit mask for active Rx slots */ +unsigned int tx_channels;/* number of Tx channels */ +unsigned int *tx_chanmap;/* array of slot number */ +unsigned int rx_channels;/* number of Rx channels */ +unsigned int *rx_chanmap;/* array of slot number */ +}; +/** \struct snd_tplg_link_template * \brief Template type for BE and CC DAI Links. */
@@ -905,7 +932,11 @@ 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_stream_template *stream;/*!< supported configs */ + +struct snd_tplg_hw_config_template *hw_config;/*!< supported HW configs */ +int num_hw_configs;/* number of hw configs */ +int default_hw_config_id;/* default hw config ID for init */ };/** \struct snd_tplg_obj_template
src/topology/elem.c +1 -0
@@ -193,6 +193,7 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg, obj_size =sizeof (struct snd_soc_tplg_pcm );break ;case SND_TPLG_TYPE_BE : +case SND_TPLG_TYPE_LINK :list_add_tail (&elem->list, &tplg->be_list); obj_size =sizeof (struct snd_soc_tplg_link_config );break ;
src/topology/parser.c +1 -0
@@ -348,6 +348,7 @@ int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)return tplg_add_graph_object (tplg, t);case SND_TPLG_TYPE_PCM :return tplg_add_pcm_object (tplg, t); +case SND_TPLG_TYPE_LINK :case SND_TPLG_TYPE_BE :case SND_TPLG_TYPE_CC :return tplg_add_link_object (tplg, t);
src/topology/pcm.c +50 -6
85 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 14/22 topology: Parse HW configurations of physical DAI links in text conf file
In reply to [email protected]From: Mengdong Lin <[email protected]>
Users can configure the runtime supported HW configurations of a physical link by SectionHWConfig. A physical link can refer multiple HW config sections in SectionLink.
include/topology.h +22 -0
@@ -632,10 +632,31 @@ extern "C" {* * id "0" # used for binding to the link * +* hw_configs [ # runtime supported HW configurations, optional +* "config1" +* "config2" +* ... +* ] +* +* default_hw_conf_id "1" #default HW config ID for init +* * data "name" # optional private data * } * </pre> * +* A physical link can refer to multiple runtime supported hardware +* configurations, which is defined by SectionHWConfig. +* +* <pre> +* SectionHWConfig."name" { +* +* id "1" # used for binding to the config +* format "I2S" # physical audio format. +* bclk "master" # Platform is master of bit clock +* fsync "slave" # Platform is slave of fsync +* } +* </pre> +* * <h4>Manifest Private Data</h4> * Manfiest may have private data. Users need to define a manifest section * and add the references to 1 or multiple data sections. Please refer to
@@ -677,6 +698,7 @@ enum snd_tplg_type {SND_TPLG_TYPE_TOKEN ,/*!< Vendor tokens */ SND_TPLG_TYPE_TUPLE ,/*!< Vendor tuples */ SND_TPLG_TYPE_LINK ,/*!< Physical DAI link */ + SND_TPLG_TYPE_HW_CONFIG, /*!< Link HW config */ };/**
src/topology/elem.c +4 -0
@@ -208,6 +208,10 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,list_add_tail (&elem->list, &tplg->tuple_list); elem->free = tplg_free_tuples;break ; +case SND_TPLG_TYPE_HW_CONFIG : +list_add_tail (&elem->list, &tplg->hw_cfg_list); + obj_size =sizeof (struct snd_soc_tplg_hw_config ); +break ;default :free (elem);return NULL ;
src/topology/parser.c +10 -0
@@ -133,6 +133,14 @@ static int tplg_parse_config(snd_tplg_t *tplg, snd_config_t *cfg)continue ; } +if (strcmp (id,"SectionHWConfig" ) ==0 ) { + err =tplg_parse_compound (tplg, n, tplg_parse_hw_config, +NULL ); +if (err <0 ) +return err; +continue ; + } +if (strcmp (id,"SectionLink" ) ==0 ||strcmp (id,"SectionBE" ) ==0 ) { err = tplg_parse_compound(tplg, n, tplg_parse_link,
@@ -455,6 +463,7 @@ snd_tplg_t *snd_tplg_new(void)INIT_LIST_HEAD (&tplg->bytes_ext_list);INIT_LIST_HEAD (&tplg->token_list);INIT_LIST_HEAD (&tplg->tuple_list); +INIT_LIST_HEAD (&tplg->hw_cfg_list);return tplg; }
@@ -480,6 +489,7 @@ void snd_tplg_free(snd_tplg_t *tplg)tplg_elem_free_list (&tplg->bytes_ext_list);tplg_elem_free_list (&tplg->token_list);tplg_elem_free_list (&tplg->tuple_list); +tplg_elem_free_list (&tplg->hw_cfg_list);free (tplg); }
src/topology/pcm.c +195 -0
219 lines not on this page · raw message
src/topology/tplg_local.h +5 -0
@@ -74,6 +74,7 @@ struct snd_tplg {struct list_head manifest_list;struct list_head pcm_config_list;struct list_head pcm_caps_list; +struct list_head hw_cfg_list;/* type-specific control lists */ struct list_head mixer_list;
@@ -148,6 +149,7 @@ struct tplg_elem {struct snd_soc_tplg_dapm_graph_elem *route;struct snd_soc_tplg_stream *stream_cfg;struct snd_soc_tplg_stream_caps *stream_caps; +struct snd_soc_tplg_hw_config *hw_cfg;/* these do not map to UAPI structs but are internal only */ struct snd_soc_tplg_ctl_tlv *tlv;
@@ -226,6 +228,9 @@ int tplg_parse_link(snd_tplg_t *tplg,int tplg_parse_cc (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED); +int tplg_parse_hw_config (snd_tplg_t *tplg,snd_config_t *cfg, + void *private ATTRIBUTE_UNUSED); +int tplg_build_data (snd_tplg_t *tplg);int tplg_build_manifest_data (snd_tplg_t *tplg);int tplg_build_controls (snd_tplg_t *tplg);
Signature · 1 line
2.5.0
PATCH 15/22 topology: Parse link flags of physical DAI links
In reply to [email protected]From: Mengdong Lin <[email protected]>
Parse physical DAI link flags in both text conf file or C API template.
include/topology.h +11 -0
@@ -640,6 +640,13 @@ extern "C" {* * default_hw_conf_id "1" #default HW config ID for init * +* # Optional flags, the default value is "false". +* symmetric_rates "true or false" +* symmetric_channels "true or false" +* symmetric_sample_bits "true or false" +* ignore_suspend "true or false" +* ignore_powerdown_time "true or false" +* * data "name" # optional private data * } * </pre>
@@ -959,6 +966,10 @@ struct snd_tplg_link_template {struct snd_tplg_hw_config_template *hw_config;/*!< supported HW configs */ int num_hw_configs;/* number of hw configs */ int default_hw_config_id;/* default hw config ID for init */ + +unsigned int flag_mask;/* bitmask of flags to configure */ +unsigned int flags;/* SND_SOC_TPLG_LNK_FLGBIT_* flag value */ +struct snd_soc_tplg_private *priv;/*!< private data */ };/** \struct snd_tplg_obj_template
src/topology/pcm.c +51 -0
62 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 16/22 topology: Parse and build private data of physical links
In reply to [email protected]From: Mengdong Lin <[email protected]>
Users can define private data for physical links by C API or text conf file.
src/topology/pcm.c +26 -1
@@ -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 ; }
Signature · 1 line
2.5.0
PATCH 17/22 topology: Parse name and stream name of physical DAI links
In reply to [email protected]From: Mengdong Lin <[email protected]>
Add name and stream name to C API template of physical DAI links.
include/topology.h +4 -0
@@ -632,6 +632,8 @@ extern "C" {* * id "0" # used for binding to the link * +* stream_name "name" # used for binding to the link +* * hw_configs [ # runtime supported HW configurations, optional * "config1" * "config2"
@@ -960,6 +962,8 @@ struct snd_tplg_hw_config_template {struct snd_tplg_link_template {const char *name;/*!< link name */ int id;/*!< unique ID - used to match with existing BE and CC links */ +const char *stream_name;/*!< stream name of the link */ +int num_streams;/*!< number of configs */ struct snd_tplg_stream_template *stream;/*!< supported configs */
src/topology/pcm.c +17 -0
@@ -640,6 +640,7 @@ int tplg_parse_link(snd_tplg_t *tplg, link = elem->link; link->size = elem->size; +elem_copy_text (link->name, elem->id,SNDRV_CTL_ELEM_ID_NAME_MAXLEN );tplg_dbg (" Link: %s\n" , elem->id);
@@ -673,6 +674,16 @@ int tplg_parse_link(snd_tplg_t *tplg,continue ; } +if (strcmp (id,"stream_name" ) ==0 ) { +if (snd_config_get_string (n, &val) <0 ) +return -EINVAL ; + +elem_copy_text (link->stream_name, val, +SNDRV_CTL_ELEM_ID_NAME_MAXLEN ); +tplg_dbg ("\t%s: %s\n" , id, val); +continue ; + } +if (strcmp (id,"hw_configs" ) ==0 ) { err =parse_hw_config_refs (tplg, n, elem);if (err <0 )
@@ -1066,7 +1077,13 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) link = elem->link; link->size = elem->size; +/* ID and names */ link->id = link_tpl->id; +elem_copy_text (link->name, link_tpl->name, +SNDRV_CTL_ELEM_ID_NAME_MAXLEN ); +elem_copy_text (link->stream_name, link_tpl->stream_name, +SNDRV_CTL_ELEM_ID_NAME_MAXLEN ); +/* stream configs */ if (link_tpl->num_streams >SND_SOC_TPLG_STREAM_CONFIG_MAX )return -EINVAL ;
Signature · 1 line
2.5.0
PATCH 18/22 topology: ABI - Update manifest to ABI v5
In reply to [email protected]From: Mengdong Lin <[email protected]>
Add the following fields to manifest:
- a count of physical DAIs. Later patches will add new ABI types for physical DAIs.
- some reserved fields for future extenstion.
Pump ABI version to 5.
Kerel will handle this ABI update in a backward compatible way, via patch 'ASoC: topology: Make manifest backward compatible from ABI v4'.
include/sound/asoc.h +4 -1
@@ -79,7 +79,8 @@#define SND_SOC_TPLG_NUM_TEXTS 16/* ABI version */ -#define SND_SOC_TPLG_ABI_VERSION 0x4 +#define SND_SOC_TPLG_ABI_VERSION 0x5/* current version */ +#define SND_SOC_TPLG_ABI_VERSION_MIN 0x4/* oldest version supported */ /* Max size of TLV data */ #define SND_SOC_TPLG_TLV_SIZE 32
@@ -333,6 +334,8 @@ struct snd_soc_tplg_manifest {__le32 graph_elems;/* number of graph elements */ __le32 pcm_elems;/* number of PCM elements */ __le32 dai_link_elems;/* number of DAI link elements */ +__le32 dai_elems;/* number of physical DAI elements */ +__le32 reserved[20 ];/* reserved for new ABI element types */ struct snd_soc_tplg_private priv; } __attribute__((packed));
Signature · 1 line
2.5.0
PATCH 19/22 topology: ABI - Define new types for physical DAI
In reply to [email protected]From: Guneshwor Singh <[email protected]>
Define the type and ABI struct for physical DAIs (e.g. backend DAIs). They are new to ABI and so no backward compatibility risk.
include/sound/asoc.h +30 -1
@@ -102,7 +102,8 @@#define SND_SOC_TPLG_TYPE_CODEC_LINK 9#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 +#define SND_SOC_TPLG_TYPE_DAI 12 +#define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_DAI/* vendor block IDs - please add new vendor types to end */ #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000
@@ -121,6 +122,11 @@#define SND_SOC_TPLG_TUPLE_TYPE_WORD 4#define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5 +/* DAI flags */ +#define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_RATES (1 << 0) +#define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS (1 << 1) +#define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2) +/* DAI link flags */ #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES (1 << 0)#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS (1 << 1)
@@ -512,4 +518,27 @@ struct snd_soc_tplg_link_config {__le32 flags;/* SND_SOC_TPLG_LNK_FLGBIT_* flag value */ struct snd_soc_tplg_private priv; } __attribute__((packed)); + +/* +* Describes SW/FW specific features of physical DAI. +* It can be used to configure backend DAIs for DPCM. +* +* File block representation for physical DAI :- +* +-----------------------------------+-----+ +* | struct snd_soc_tplg_hdr | 1 | +* +-----------------------------------+-----+ +* | struct snd_soc_tplg_dai | N | +* +-----------------------------------+-----+ +*/ +struct snd_soc_tplg_dai { +__le32 size;/* in bytes of this structure */ +char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ];/* name - used to match */ +__le32 dai_id;/* unique ID - used to match */ +__le32 playback;/* supports playback mode */ +__le32 capture;/* supports capture mode */ +struct snd_soc_tplg_stream_caps caps[2 ];/* playback and capture for DAI */ +__le32 flag_mask;/* bitmask of flags to configure */ +__le32 flags;/* SND_SOC_TPLG_DAI_FLGBIT_* */ +struct snd_soc_tplg_private priv; +} __attribute__((packed));#endif
Signature · 1 line
2.5.0
PATCH 20/22 topology: Parse physical DAIs in text conf file
In reply to [email protected]From: Mengdong Lin <[email protected]>
Add support for parsing physical DAIs in the text configuration file. The syntax of physical DAIs is described in document in topology.h
include/topology.h +31 -0
@@ -666,6 +666,36 @@ extern "C" {* } * </pre> * +* <h4>Physical DAI</h4> +* A physical DAI (e.g. backend DAI for DPCM) is defined as a new section +* that can include a unique ID, playback and capture stream capabilities, +* optional flags, and private data. <br> +* Its PCM stream capablities are same as those for PCM objects, +* please refer to section 'PCM Capabilities'. +* +* <pre> +* SectionDAI."name" { +* +* index "1" # Index number +* +* id "0" # used for binding to the Backend DAI +* +* pcm."playback" { +* capabilities "capabilities1" # capabilities for playback +* } +* +* pcm."capture" { +* capabilities "capabilities2" # capabilities for capture +* } +* +* symmetric_rates "true" # optional flags +* symmetric_channels "true" +* symmetric_sample_bits "false" +* +* data "name" # optional private data +* } +* </pre> +* * <h4>Manifest Private Data</h4> * Manfiest may have private data. Users need to define a manifest section * and add the references to 1 or multiple data sections. Please refer to
@@ -708,6 +738,7 @@ enum snd_tplg_type {SND_TPLG_TYPE_TUPLE ,/*!< Vendor tuples */ SND_TPLG_TYPE_LINK ,/*!< Physical DAI link */ SND_TPLG_TYPE_HW_CONFIG ,/*!< Link HW config */ + SND_TPLG_TYPE_DAI, /*!< Physical DAI */ };/**
src/topology/data.c +4 -0
@@ -46,6 +46,10 @@ struct snd_soc_tplg_private *get_priv_data(struct tplg_elem *elem) priv = &elem->widget->priv;break ; +case SND_TPLG_TYPE_DAI : + priv = &elem->dai->priv; +break ; +default :SNDERR ("error: '%s': no support for private data for type %d\n" , elem->id, elem->type);
src/topology/elem.c +4 -0
@@ -192,6 +192,10 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,list_add_tail (&elem->list, &tplg->pcm_list); obj_size =sizeof (struct snd_soc_tplg_pcm );break ; +case SND_TPLG_TYPE_DAI : +list_add_tail (&elem->list, &tplg->dai_list); + obj_size =sizeof (struct snd_soc_tplg_dai ); +break ;case SND_TPLG_TYPE_BE :case SND_TPLG_TYPE_LINK :list_add_tail (&elem->list, &tplg->be_list);
src/topology/parser.c +10 -0
@@ -133,6 +133,14 @@ static int tplg_parse_config(snd_tplg_t *tplg, snd_config_t *cfg)continue ; } +if (strcmp (id,"SectionDAI" ) ==0 ) { + err =tplg_parse_compound (tplg, n, + tplg_parse_dai,NULL ); +if (err <0 ) +return err; +continue ; + } +if (strcmp (id,"SectionHWConfig" ) ==0 ) { err =tplg_parse_compound (tplg, n, tplg_parse_hw_config,NULL );
@@ -450,6 +458,7 @@ snd_tplg_t *snd_tplg_new(void)INIT_LIST_HEAD (&tplg->tlv_list);INIT_LIST_HEAD (&tplg->widget_list);INIT_LIST_HEAD (&tplg->pcm_list); +INIT_LIST_HEAD (&tplg->dai_list);INIT_LIST_HEAD (&tplg->be_list);INIT_LIST_HEAD (&tplg->cc_list);INIT_LIST_HEAD (&tplg->route_list);
@@ -476,6 +485,7 @@ void snd_tplg_free(snd_tplg_t *tplg)tplg_elem_free_list (&tplg->tlv_list);tplg_elem_free_list (&tplg->widget_list);tplg_elem_free_list (&tplg->pcm_list); +tplg_elem_free_list (&tplg->dai_list);tplg_elem_free_list (&tplg->be_list);tplg_elem_free_list (&tplg->cc_list);tplg_elem_free_list (&tplg->route_list);
src/topology/pcm.c +112 -0
130 lines not on this page · raw message
src/topology/tplg_local.h +5 -0
@@ -64,6 +64,7 @@ struct snd_tplg {struct list_head tlv_list;struct list_head widget_list;struct list_head pcm_list; +struct list_head dai_list;struct list_head be_list;struct list_head cc_list;struct list_head route_list;
@@ -145,6 +146,7 @@ struct tplg_elem {struct snd_soc_tplg_bytes_control *bytes_ext;struct snd_soc_tplg_dapm_widget *widget;struct snd_soc_tplg_pcm *pcm; +struct snd_soc_tplg_dai *dai;struct snd_soc_tplg_link_config *link;/* physical link */ struct snd_soc_tplg_dapm_graph_elem *route;struct snd_soc_tplg_stream *stream_cfg;
@@ -222,6 +224,9 @@ int tplg_parse_stream_caps(snd_tplg_t *tplg,int tplg_parse_pcm (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED); +int tplg_parse_dai (snd_tplg_t *tplg,snd_config_t *cfg, + void *private ATTRIBUTE_UNUSED); +int tplg_parse_link (snd_tplg_t *tplg, snd_config_t *cfg, void *private ATTRIBUTE_UNUSED);
Signature · 1 line
2.5.0
PATCH 21/22 topology: Support configuring physical DAIs by C API
In reply to [email protected]From: Guneshwor Singh <[email protected]>
In addition to text conf file, BE (Back End) DAI configurations can also be added by C API. This patch defines the template to add BE DAI configurations from C API.
include/topology.h +16 -0
@@ -987,6 +987,21 @@ struct snd_tplg_hw_config_template {unsigned int *rx_chanmap;/* array of slot number */ }; +/** \struct snd_tplg_be_dai_template +* \brief Template type for Back End DAI. +*/ +struct snd_tplg_be_dai_template { +const char *dai_name;/*!< DAI name */ +unsigned int dai_id;/*!< unique ID - used to match */ +unsigned int playback;/*!< supports playback mode */ +unsigned int capture;/*!< supports capture mode */ +struct snd_tplg_stream_caps_template *caps[2 ];/*!< playback & capture for DAI */ +unsigned int flag_mask;/*!< bitmask of flags to configure */ +unsigned int flags;/*!< SND_SOC_TPLG_DAI_FLGBIT_* */ +struct snd_soc_tplg_private *priv;/*!< private data */ + +}; +/** \struct snd_tplg_link_template * \brief Template type for BE and CC DAI Links. */
@@ -1023,6 +1038,7 @@ typedef struct snd_tplg_obj_template {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 */ +struct snd_tplg_be_dai_template *dai;/*!< Physical DAI */ }; } snd_tplg_obj_template_t;
src/topology/parser.c +2 -0
@@ -364,6 +364,8 @@ int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)return tplg_add_graph_object (tplg, t);case SND_TPLG_TYPE_PCM :return tplg_add_pcm_object (tplg, t); +case SND_TPLG_TYPE_DAI : +return tplg_add_dai_object (tplg, t);case SND_TPLG_TYPE_LINK :case SND_TPLG_TYPE_BE :case SND_TPLG_TYPE_CC :
src/topology/pcm.c +55 -0
58 lines not on this page · raw message
src/topology/tplg_local.h +1 -0
@@ -297,3 +297,4 @@ int tplg_build_pcms(snd_tplg_t *tplg, unsigned int type);int tplg_build_links (snd_tplg_t *tplg,unsigned int type);int tplg_add_link_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t);int tplg_add_pcm_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t); +int tplg_add_dai_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t);
Signature · 1 line
2.5.0
PATCH 22/22 topology: Export physical DAIs to the binary for kernel
In reply to [email protected]From: Guneshwor Singh <[email protected]>
Export the physical DAI objects to the binary output file for kernel. For physical DAIs defined by the text conf file, find and merge their stream capablities and private data before exporting.
src/topology/builder.c +11 -0
@@ -204,6 +204,9 @@ static int write_block(snd_tplg_t *tplg, struct list_head *base,case SND_TPLG_TYPE_DATA :return write_elem_block (tplg, base, size,SND_SOC_TPLG_TYPE_PDATA ,"data" ); +case SND_TPLG_TYPE_DAI : +return write_elem_block (tplg, base, size, +SND_SOC_TPLG_TYPE_DAI ,"dai" );default :return -EINVAL ; }
@@ -293,6 +296,14 @@ int tplg_write_data(snd_tplg_t *tplg)return ret; } +/* write physical dai elems */ + ret =write_block (tplg, &tplg->dai_list, +SND_TPLG_TYPE_DAI ); +if (ret <0 ) { +SNDERR ("failed to write physical dai elems %d\n" , ret); +return ret; + } +/* write be elems */ ret =write_block (tplg, &tplg->be_list,SND_TPLG_TYPE_BE );
src/topology/parser.c +4 -0
@@ -288,6 +288,10 @@ static int tplg_build_integ(snd_tplg_t *tplg)if (err <0 )return err; + err =tplg_build_dais (tplg,SND_TPLG_TYPE_DAI ); +if (err <0 ) +return err; + err =tplg_build_links (tplg,SND_TPLG_TYPE_BE );if (err <0 )return err;
src/topology/pcm.c +55 -0
61 lines not on this page · raw message
src/topology/tplg_local.h +1 -0
@@ -294,6 +294,7 @@ int tplg_add_bytes(snd_tplg_t *tplg, struct snd_tplg_bytes_template *bytes_ctl, struct tplg_elem **e);int tplg_build_pcms (snd_tplg_t *tplg,unsigned int type); +int tplg_build_dais (snd_tplg_t *tplg,unsigned int type);int tplg_build_links (snd_tplg_t *tplg,unsigned int type);int tplg_add_link_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t);int tplg_add_pcm_object (snd_tplg_t *tplg,snd_tplg_obj_template_t *t);
Signature · 1 line
2.5.0