* [PATCH 01/13] topology: Use snd_config_get_bool to simplify boolean flag parsing
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
@ 2016-11-06 5:11 ` mengdong.lin
2016-11-06 5:11 ` [PATCH 02/13] topology: Merge an element's be & cc pointer to one link pointer mengdong.lin
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:11 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
The link flags in the text conf file are boolean, so this patch uses
snd_config_get_bool() to simplify the code.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 3f54e94..b7a2df7 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -400,13 +400,14 @@ static int tplg_parse_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
static int parse_flag(snd_config_t *n, unsigned int mask_in,
unsigned int *mask, unsigned int *flags)
{
- const char *val = NULL;
+ int ret;
- if (snd_config_get_string(n, &val) < 0)
- return -EINVAL;
+ ret = snd_config_get_bool(n);
+ if (ret < 0)
+ return ret;
*mask |= mask_in;
- if (strcmp(val, "true") == 0)
+ if (ret)
*flags |= mask_in;
else
*flags &= ~mask_in;
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/13] topology: Merge an element's be & cc pointer to one link pointer
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
2016-11-06 5:11 ` [PATCH 01/13] topology: Use snd_config_get_bool to simplify boolean flag parsing mengdong.lin
@ 2016-11-06 5:11 ` mengdong.lin
2016-11-06 5:12 ` [PATCH 03/13] topology: Define a function to build a single physical DAI link mengdong.lin
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:11 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index b7a2df7..64fd78f 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -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)
@@ -528,7 +524,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);
@@ -588,7 +584,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);
@@ -742,14 +738,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;
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index 7b30b84..3aa51ee 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -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;
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/13] topology: Define a function to build a single physical DAI link
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
2016-11-06 5:11 ` [PATCH 01/13] topology: Use snd_config_get_bool to simplify boolean flag parsing mengdong.lin
2016-11-06 5:11 ` [PATCH 02/13] topology: Merge an element's be & cc pointer to one link pointer mengdong.lin
@ 2016-11-06 5:12 ` mengdong.lin
2016-11-06 5:12 ` [PATCH 04/13] topology: ABI - Define DAI physical PCM data formats mengdong.lin
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:12 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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).
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/src/topology/parser.c b/src/topology/parser.c
index 7b2c879..ded2eb7 100644
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -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;
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 64fd78f..d8dd96a 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -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;
}
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index 3aa51ee..548f42d 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -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);
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/13] topology: ABI - Define DAI physical PCM data formats
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (2 preceding siblings ...)
2016-11-06 5:12 ` [PATCH 03/13] topology: Define a function to build a single physical DAI link mengdong.lin
@ 2016-11-06 5:12 ` mengdong.lin
2016-11-06 5:13 ` [PATCH 05/13] topology: ABI - Update physical DAI link configurations to ABI v5 mengdong.lin
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:12 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/sound/asoc.h b/include/sound/asoc.h
index 1f2c230..d55ce8c 100644
--- a/include/sound/asoc.h
+++ b/include/sound/asoc.h
@@ -115,6 +115,21 @@
#define SND_SOC_TPLG_TUPLE_TYPE_WORD 4
#define SND_SOC_TPLG_TUPLE_TYPE_SHORT 5
+/* 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
+
/* DAI link flags */
#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES (1 << 0)
#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS (1 << 1)
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/13] topology: ABI - Update physical DAI link configurations to ABI v5
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (3 preceding siblings ...)
2016-11-06 5:12 ` [PATCH 04/13] topology: ABI - Define DAI physical PCM data formats mengdong.lin
@ 2016-11-06 5:13 ` mengdong.lin
2016-11-06 5:13 ` [PATCH 06/13] topology: Rename varaibles for add physical links by C API mengdong.lin
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:13 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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 physical 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'.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/sound/asoc.h b/include/sound/asoc.h
index d55ce8c..039ef3e 100644
--- a/include/sound/asoc.h
+++ b/include/sound/asoc.h
@@ -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
@@ -278,6 +283,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
@@ -450,9 +484,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 |
* +-----------------------------------+-----+
@@ -462,7 +496,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
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/13] topology: Rename varaibles for add physical links by C API
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (4 preceding siblings ...)
2016-11-06 5:13 ` [PATCH 05/13] topology: ABI - Update physical DAI link configurations to ABI v5 mengdong.lin
@ 2016-11-06 5:13 ` mengdong.lin
2016-11-06 5:13 ` [PATCH 07/13] topology: Define new type and section name to configure physical links mengdong.lin
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:13 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index d8dd96a..fe8af45 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -740,10 +740,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;
@@ -751,22 +752,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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/13] topology: Define new type and section name to configure physical links
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (5 preceding siblings ...)
2016-11-06 5:13 ` [PATCH 06/13] topology: Rename varaibles for add physical links by C API mengdong.lin
@ 2016-11-06 5:13 ` mengdong.lin
2016-11-06 5:13 ` [PATCH 08/13] topology: Parse HW configurations of physical DAI links defined by C API mengdong.lin
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:13 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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 use SND_TPLG_TYPE_LINK and SectionLink to configure
backend links for DPCM cases, because BE links are also physical links.
The parsing is same and we rename the function from tplg_parse_be to
tplg_parse_link.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/topology.h b/include/topology.h
index dbd18b3..1fbaeb8 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -617,6 +617,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
@@ -687,6 +705,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 */
};
/**
diff --git a/src/topology/parser.c b/src/topology/parser.c
index ded2eb7..ed5da87 100644
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -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;
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index fe8af45..96a64e7 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -527,7 +527,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;
@@ -544,7 +545,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) {
@@ -748,7 +749,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. */
@@ -756,10 +758,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;
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index 548f42d..947f27e 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -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,
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/13] topology: Parse HW configurations of physical DAI links defined by C API
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (6 preceding siblings ...)
2016-11-06 5:13 ` [PATCH 07/13] topology: Define new type and section name to configure physical links mengdong.lin
@ 2016-11-06 5:13 ` mengdong.lin
2016-11-06 5:14 ` [PATCH 09/13] topology: Parse HW configurations of physical DAI links in text conf file mengdong.lin
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:13 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
Add HW configurations to C API template of physical link configuration.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/topology.h b/include/topology.h
index 1fbaeb8..0978ccf 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -927,6 +927,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.
*/
@@ -934,7 +961,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
diff --git a/src/topology/elem.c b/src/topology/elem.c
index 724bf26..f7ff070 100644
--- a/src/topology/elem.c
+++ b/src/topology/elem.c
@@ -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;
diff --git a/src/topology/parser.c b/src/topology/parser.c
index ed5da87..238943c 100644
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -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);
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 96a64e7..7b67d91 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -168,7 +168,7 @@ static int build_link(snd_tplg_t *tplg, struct tplg_elem *elem)
return 0;
}
-/* build BE/CC DAI link configurations */
+/* build physical DAI link configurations */
int tplg_build_links(snd_tplg_t *tplg, unsigned int type)
{
struct list_head *base, *pos;
@@ -176,6 +176,7 @@ int tplg_build_links(snd_tplg_t *tplg, unsigned int type)
int err = 0;
switch (type) {
+ case SND_TPLG_TYPE_LINK:
case SND_TPLG_TYPE_BE:
base = &tplg->be_list;
break;
@@ -189,11 +190,6 @@ int tplg_build_links(snd_tplg_t *tplg, unsigned int type)
list_for_each(pos, base) {
elem = list_entry(pos, struct tplg_elem, list);
- if (elem->type != type) {
- SNDERR("error: invalid elem '%s'\n", elem->id);
- return -EINVAL;
- }
-
err = build_link(tplg, elem);
if (err < 0)
return err;
@@ -741,6 +737,47 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
return 0;
}
+/* Set link HW config from C API template */
+static int set_link_hw_config(struct snd_soc_tplg_hw_config *cfg,
+ struct snd_tplg_hw_config_template *tpl)
+{
+ int i;
+
+ cfg->size = sizeof(*cfg);
+ cfg->id = tpl->id;
+
+ cfg->fmt = tpl->fmt;
+ cfg->clock_gated = tpl->clock_gated;
+ cfg->invert_bclk = tpl->invert_bclk;
+ cfg->invert_fsync = tpl->invert_fsync;
+ cfg->bclk_master = tpl->bclk_master;
+ cfg->fsync_master = tpl->fsync_master;
+ cfg->mclk_direction = tpl->mclk_direction;
+ cfg->reserved = tpl->reserved;
+ cfg->mclk_rate = tpl->mclk_rate;
+ cfg->bclk_rate = tpl->bclk_rate;
+ cfg->fsync_rate = tpl->fsync_rate;
+
+ cfg->tdm_slots = tpl->tdm_slots;
+ cfg->tdm_slot_width = tpl->tdm_slot_width;
+ cfg->tx_slots = tpl->tx_slots;
+ cfg->rx_slots = tpl->rx_slots;
+
+ if (cfg->tx_channels > SND_SOC_TPLG_MAX_CHAN
+ || cfg->rx_channels > SND_SOC_TPLG_MAX_CHAN)
+ return -EINVAL;
+
+ cfg->tx_channels = tpl->tx_channels;
+ for (i = 0; i < cfg->tx_channels; i++)
+ cfg->tx_chanmap[i] = tpl->tx_chanmap[i];
+
+ cfg->rx_channels = tpl->rx_channels;
+ for (i = 0; i < cfg->rx_channels; i++)
+ cfg->rx_chanmap[i] = tpl->rx_chanmap[i];
+
+ 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)
{
@@ -771,5 +808,12 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
for (i = 0; i < link->num_streams; i++)
tplg_add_stream_object(&link->stream[i], &link_tpl->stream[i]);
+ /* HW configs */
+ if (link_tpl->num_hw_configs > SND_SOC_TPLG_HW_CONFIG_MAX)
+ return -EINVAL;
+ link->num_hw_configs = link_tpl->num_hw_configs;
+ link->default_hw_config_id = link_tpl->default_hw_config_id;
+ for (i = 0; i < link->num_hw_configs; i++)
+ set_link_hw_config(&link->hw_config[i], &link_tpl->hw_config[i]);
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/13] topology: Parse HW configurations of physical DAI links in text conf file
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (7 preceding siblings ...)
2016-11-06 5:13 ` [PATCH 08/13] topology: Parse HW configurations of physical DAI links defined by C API mengdong.lin
@ 2016-11-06 5:14 ` mengdong.lin
2016-11-06 5:14 ` [PATCH 10/13] topology: Parse link flags of physical DAI links mengdong.lin
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:14 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/topology.h b/include/topology.h
index 0978ccf..85818ac 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -631,10 +631,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
@@ -706,6 +727,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 */
};
/**
diff --git a/src/topology/elem.c b/src/topology/elem.c
index f7ff070..01dce1f 100644
--- a/src/topology/elem.c
+++ b/src/topology/elem.c
@@ -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;
diff --git a/src/topology/parser.c b/src/topology/parser.c
index 238943c..7d0486c 100644
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -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);
}
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 7b67d91..e92d2b9 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -162,6 +162,34 @@ static int build_link(snd_tplg_t *tplg, struct tplg_elem *elem)
if (err < 0)
return err;
+ /* hw configs */
+ base = &elem->ref_list;
+ list_for_each(pos, base) {
+
+ ref = list_entry(pos, struct tplg_ref, list);
+
+ switch (ref->type) {
+ case SND_TPLG_TYPE_HW_CONFIG:
+ ref->elem = tplg_elem_lookup(&tplg->hw_cfg_list,
+ ref->id, SND_TPLG_TYPE_HW_CONFIG);
+ if (!ref->elem) {
+ SNDERR("error: cannot find HW config '%s'"
+ " referenced by link '%s'\n",
+ ref->id, elem->id);
+ return -EINVAL;
+ }
+
+ memcpy(&link->hw_config[num_hw_configs],
+ ref->elem->hw_cfg,
+ sizeof(struct snd_soc_tplg_hw_config));
+ num_hw_configs++;
+ break;
+
+ default:
+ break;
+ }
+ }
+
/* add link to manifest */
tplg->manifest.dai_link_elems++;
@@ -523,6 +551,54 @@ int tplg_parse_pcm(snd_tplg_t *tplg,
return 0;
}
+/* parse physical link runtime supported HW configs in text conf file */
+static int parse_hw_config_refs(snd_tplg_t *tplg, snd_config_t *cfg,
+ struct tplg_elem *elem)
+{
+ struct snd_soc_tplg_link_config *link = elem->link;
+ snd_config_type_t type;
+ snd_config_iterator_t i, next;
+ snd_config_t *n;
+ const char *id, *val = NULL;
+
+ if (snd_config_get_id(cfg, &id) < 0)
+ return -EINVAL;
+ type = snd_config_get_type(cfg);
+
+ /* refer to a single HW config */
+ if (type == SND_CONFIG_TYPE_STRING) {
+ if (snd_config_get_string(cfg, &val) < 0)
+ return -EINVAL;
+
+ link->num_hw_configs = 1;
+ return tplg_ref_add(elem, SND_TPLG_TYPE_HW_CONFIG, val);
+ }
+
+ if (type != SND_CONFIG_TYPE_COMPOUND) {
+ SNDERR("error: compound type expected for %s", id);
+ return -EINVAL;
+ }
+
+ /* refer to a list of HW configs */
+ snd_config_for_each(i, next, cfg) {
+ const char *val;
+
+ n = snd_config_iterator_entry(i);
+ if (snd_config_get_string(n, &val) < 0)
+ continue;
+
+ if (link->num_hw_configs >= SND_SOC_TPLG_HW_CONFIG_MAX) {
+ SNDERR("error: exceed max hw configs for link %s", id);
+ return -EINVAL;
+ }
+
+ link->num_hw_configs++;
+ return tplg_ref_add(elem, SND_TPLG_TYPE_HW_CONFIG, val);
+ }
+
+ return 0;
+}
+
/* 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)
@@ -573,6 +649,21 @@ int tplg_parse_link(snd_tplg_t *tplg,
continue;
}
+ if (strcmp(id, "hw_configs") == 0) {
+ err = parse_hw_config_refs(tplg, n, elem);
+ if (err < 0)
+ return err;
+ continue;
+ }
+
+ if (strcmp(id, "default_hw_conf_id") == 0) {
+ if (snd_config_get_string(n, &val) < 0)
+ return -EINVAL;
+
+ link->default_hw_config_id = atoi(val);
+ continue;
+ }
+
if (strcmp(id, "data") == 0) {
err = tplg_parse_data_refs(n, elem);
if (err < 0)
@@ -638,6 +729,110 @@ int tplg_parse_cc(snd_tplg_t *tplg,
return 0;
}
+static int get_audio_hw_format(const char *val)
+{
+ if (!strlen(val))
+ return -EINVAL;
+
+ if (!strcmp(val, "I2S"))
+ return SND_SOC_DAI_FORMAT_I2S;
+
+ if (!strcmp(val, "RIGHT_J"))
+ return SND_SOC_DAI_FORMAT_RIGHT_J;
+
+ if (!strcmp(val, "LEFT_J"))
+ return SND_SOC_DAI_FORMAT_LEFT_J;
+
+ if (!strcmp(val, "DSP_A"))
+ return SND_SOC_DAI_FORMAT_DSP_A;
+
+ if (!strcmp(val, "LEFT_B"))
+ return SND_SOC_DAI_FORMAT_DSP_B;
+
+ if (!strcmp(val, "AC97"))
+ return SND_SOC_DAI_FORMAT_AC97;
+
+ if (!strcmp(val, "PDM"))
+ return SND_SOC_DAI_FORMAT_PDM;
+
+ SNDERR("error: invalid audio HW format %s\n", val);
+ return -EINVAL;
+}
+
+int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
+ void *private ATTRIBUTE_UNUSED)
+{
+
+ struct snd_soc_tplg_hw_config *hw_cfg;
+ struct tplg_elem *elem;
+ snd_config_iterator_t i, next;
+ snd_config_t *n;
+ const char *id, *val = NULL;
+ int ret;
+
+ elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_HW_CONFIG);
+ if (!elem)
+ return -ENOMEM;
+
+ hw_cfg = elem->hw_cfg;
+ hw_cfg->size = elem->size;
+
+ tplg_dbg(" Link HW config: %s\n", elem->id);
+
+ snd_config_for_each(i, next, cfg) {
+
+ n = snd_config_iterator_entry(i);
+ if (snd_config_get_id(n, &id) < 0)
+ continue;
+
+ /* skip comments */
+ if (strcmp(id, "comment") == 0)
+ continue;
+ if (id[0] == '#')
+ continue;
+
+ if (strcmp(id, "id") == 0) {
+ if (snd_config_get_string(n, &val) < 0)
+ return -EINVAL;
+
+ hw_cfg->id = atoi(val);
+ tplg_dbg("\t%s: %d\n", id, hw_cfg->id);
+ continue;
+ }
+
+ if (strcmp(id, "format") == 0) {
+ if (snd_config_get_string(n, &val) < 0)
+ return -EINVAL;
+
+ ret = get_audio_hw_format(val);
+ if (ret < 0)
+ return ret;
+ hw_cfg->fmt = ret;
+ continue;
+ }
+
+ if (strcmp(id, "bclk") == 0) {
+ if (snd_config_get_string(n, &val) < 0)
+ return -EINVAL;
+
+ if (!strcmp(val, "master"))
+ hw_cfg->bclk_master = true;
+ continue;
+ }
+
+ if (strcmp(id, "fsync") == 0) {
+ if (snd_config_get_string(n, &val) < 0)
+ return -EINVAL;
+
+ if (!strcmp(val, "master"))
+ hw_cfg->fsync_master = true;
+ continue;
+ }
+ }
+
+ return 0;
+}
+
/* copy stream object */
static void tplg_add_stream_object(struct snd_soc_tplg_stream *strm,
struct snd_tplg_stream_template *strm_tpl)
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index 947f27e..9e67bf8 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -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);
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/13] topology: Parse link flags of physical DAI links
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (8 preceding siblings ...)
2016-11-06 5:14 ` [PATCH 09/13] topology: Parse HW configurations of physical DAI links in text conf file mengdong.lin
@ 2016-11-06 5:14 ` mengdong.lin
2016-11-06 5:14 ` [PATCH 11/13] topology: Parse and build private data of physical links mengdong.lin
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:14 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
Parse physical DAI link flags defined by text conf file or C API.
The flag mask and flags are added to C API template for physical DAI
links.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/topology.h b/include/topology.h
index 85818ac..3692da4 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -639,6 +639,11 @@ extern "C" {
*
* default_hw_conf_id "1" #default HW config ID for init
*
+ * # Optional boolean flags
+ * symmetric_rates "true"
+ * symmetric_channels "false"
+ * symmetric_sample_bits "true"
+ *
* data "name" # optional private data
* }
* </pre>
@@ -988,6 +993,9 @@ 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_tplg_obj_template
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index e92d2b9..a751851 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -664,6 +664,35 @@ int tplg_parse_link(snd_tplg_t *tplg,
continue;
}
+ /* flags */
+ if (strcmp(id, "symmetric_rates") == 0) {
+ err = parse_flag(n,
+ SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES,
+ &link->flag_mask, &link->flags);
+ if (err < 0)
+ return err;
+ continue;
+ }
+
+ if (strcmp(id, "symmetric_channels") == 0) {
+ err = parse_flag(n,
+ SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS,
+ &link->flag_mask, &link->flags);
+ if (err < 0)
+ return err;
+ continue;
+ }
+
+ if (strcmp(id, "symmetric_sample_bits") == 0) {
+ err = parse_flag(n,
+ SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS,
+ &link->flag_mask, &link->flags);
+ if (err < 0)
+ return err;
+ continue;
+ }
+
+ /* private data */
if (strcmp(id, "data") == 0) {
err = tplg_parse_data_refs(n, elem);
if (err < 0)
@@ -1010,5 +1039,9 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
link->default_hw_config_id = link_tpl->default_hw_config_id;
for (i = 0; i < link->num_hw_configs; i++)
set_link_hw_config(&link->hw_config[i], &link_tpl->hw_config[i]);
+
+ /* flags */
+ link->flag_mask = link_tpl->flag_mask;
+ link->flags = link_tpl->flags;
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/13] topology: Parse and build private data of physical links
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (9 preceding siblings ...)
2016-11-06 5:14 ` [PATCH 10/13] topology: Parse link flags of physical DAI links mengdong.lin
@ 2016-11-06 5:14 ` mengdong.lin
2016-11-06 5:14 ` [PATCH 12/13] topology: Parse name and stream name of physical DAI links mengdong.lin
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:14 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
Users can define private data for physical links by C API or text conf
file. Private data pointer is added to C API template for physical links.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/topology.h b/include/topology.h
index 3692da4..ad84c15 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -996,6 +996,7 @@ struct snd_tplg_link_template {
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
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index a751851..1d70396 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;
}
@@ -1043,5 +1049,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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 12/13] topology: Parse name and stream name of physical DAI links
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (10 preceding siblings ...)
2016-11-06 5:14 ` [PATCH 11/13] topology: Parse and build private data of physical links mengdong.lin
@ 2016-11-06 5:14 ` mengdong.lin
2016-11-06 5:14 ` [PATCH 13/13] topology: Remove BE or CC in comments of physical links C API template mengdong.lin
2016-11-14 16:23 ` [PATCH 00/13] topology: Update physical link support for ABI v5 Takashi Iwai
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:14 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
Parse name and stream name of physical links defined by text conf file
or C API. Add name and stream name to C API template of physical DAI
links.
These two fields will help topology kernel driver to find an existing
physical link to configure, since the id of links are often the default
value ZERO and useless for match.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/topology.h b/include/topology.h
index ad84c15..66dd084 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -631,6 +631,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"
@@ -985,8 +987,10 @@ struct snd_tplg_hw_config_template {
* \brief Template type for BE and CC DAI Links.
*/
struct snd_tplg_link_template {
- const char *name; /*!< link name */
+ const char *name; /*!< link name, used to match */
int id; /*!< unique ID - used to match with existing BE and CC links */
+ const char *stream_name; /*!< link stream name, used to match */
+
int num_streams; /*!< number of configs */
struct snd_tplg_stream_template *stream; /*!< supported configs */
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 1d70396..a9d3277 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -622,6 +622,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);
@@ -655,6 +656,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)
@@ -1030,7 +1041,15 @@ 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;
+ if (link->name)
+ elem_copy_text(link->name, link_tpl->name,
+ SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+ if (link->stream_name)
+ 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;
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 13/13] topology: Remove BE or CC in comments of physical links C API template
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (11 preceding siblings ...)
2016-11-06 5:14 ` [PATCH 12/13] topology: Parse name and stream name of physical DAI links mengdong.lin
@ 2016-11-06 5:14 ` mengdong.lin
2016-11-14 16:23 ` [PATCH 00/13] topology: Update physical link support for ABI v5 Takashi Iwai
13 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-11-06 5:14 UTC (permalink / raw)
To: alsa-devel
Cc: Mengdong Lin, tiwai, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, vinod.koul, broonie, mengdong.lin
From: Mengdong Lin <mengdong.lin@linux.intel.com>
No longer use BE or CC in comments of C API template for physical links.
This template can be used by Backend or Codec-to-Codec DAI links but not
only for them.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/include/topology.h b/include/topology.h
index 66dd084..c52c580 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -988,7 +988,7 @@ struct snd_tplg_hw_config_template {
*/
struct snd_tplg_link_template {
const char *name; /*!< link name, used to match */
- int id; /*!< unique ID - used to match with existing BE and CC links */
+ int id; /*!< unique ID - used to match with existing physical links */
const char *stream_name; /*!< link stream name, used to match */
int num_streams; /*!< number of configs */
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 00/13] topology: Update physical link support for ABI v5
2016-11-06 5:10 [PATCH 00/13] topology: Update physical link support for ABI v5 mengdong.lin
` (12 preceding siblings ...)
2016-11-06 5:14 ` [PATCH 13/13] topology: Remove BE or CC in comments of physical links C API template mengdong.lin
@ 2016-11-14 16:23 ` Takashi Iwai
13 siblings, 0 replies; 15+ messages in thread
From: Takashi Iwai @ 2016-11-14 16:23 UTC (permalink / raw)
To: mengdong.lin
Cc: alsa-devel, vinod.koul, hardik.t.shah, guneshwor.o.singh,
liam.r.girdwood, broonie, mengdong.lin
On Sun, 06 Nov 2016 06:10:06 +0100,
mengdong.lin@linux.intel.com wrote:
>
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
>
> This series completes support for physical DAI links of ABI v5, including
> ABI updates and code refactoring. The kernel can support the ABI updates
> in a backward compatible way.
>
> There will be another small series for the remaining user space patches.
>
> Mengdong Lin (13):
> topology: Use snd_config_get_bool to simplify boolean flag parsing
> 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: Remove BE or CC in comments of physical links C API template
Now merged all patches. Thanks.
Takashi
^ permalink raw reply [flat|nested] 15+ messages in thread