alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] topology: Updates for PCM object in ABI v5
@ 2016-11-03 23:00 mengdong.lin
  2016-11-03 23:05 ` [PATCH 1/6] topology: ABI - Update stream caps and PCM objects to " mengdong.lin
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: mengdong.lin @ 2016-11-03 23:00 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>

These ABI updates for PCM have just been applied to ASoC kernel. And
kernel can handle the PCM ABI updates in a backward compatible way.

So we update the user space code for PCM now.

The updates for physical DAI link and DAIs will come later after
their kernel updates be applied at first.

Mengdong Lin (6):
  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

 include/sound/asoc.h      |   9 ++++
 include/topology.h        |  11 +++++
 src/topology/elem.c       |   3 ++
 src/topology/parser.c     |   2 +-
 src/topology/pcm.c        | 120 ++++++++++++++++++++++++++++++++++++++++++++--
 src/topology/tplg_local.h |   2 +-
 6 files changed, 140 insertions(+), 7 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/6] topology: ABI - Update stream caps and PCM objects to ABI v5
  2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
@ 2016-11-03 23:05 ` mengdong.lin
  2016-11-03 23:06 ` [PATCH 2/6] topology: Parse sig_bits of stream caps mengdong.lin
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: mengdong.lin @ 2016-11-03 23:05 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>

Here are the ABI 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".

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/sound/asoc.h b/include/sound/asoc.h
index abe49c5..1f2c230 100644
--- a/include/sound/asoc.h
+++ b/include/sound/asoc.h
@@ -115,6 +115,11 @@
 #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)
+
 /*
  * Block Header.
  * This header precedes all object and object arrays below.
@@ -242,6 +247,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 +428,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));
 
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/6] topology: Parse sig_bits of stream caps
  2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
  2016-11-03 23:05 ` [PATCH 1/6] topology: ABI - Update stream caps and PCM objects to " mengdong.lin
@ 2016-11-03 23:06 ` mengdong.lin
  2016-11-03 23:07 ` [PATCH 3/6] topology: Parse flags for PCM mengdong.lin
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: mengdong.lin @ 2016-11-03 23:06 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 sig_bits to stream caps template of C API and parse it.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/topology.h b/include/topology.h
index 0675b52..ccd8401 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -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
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 0a90cb9..6fdf047 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -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)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/6] topology: Parse flags for PCM
  2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
  2016-11-03 23:05 ` [PATCH 1/6] topology: ABI - Update stream caps and PCM objects to " mengdong.lin
  2016-11-03 23:06 ` [PATCH 2/6] topology: Parse sig_bits of stream caps mengdong.lin
@ 2016-11-03 23:07 ` mengdong.lin
  2016-11-05 15:45   ` Takashi Iwai
  2016-11-03 23:07 ` [PATCH 4/6] topology: Define a function to build a single PCM element mengdong.lin
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: mengdong.lin @ 2016-11-03 23:07 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 flags by both text conf file and C API.
Add flags and flag_mask to C API template of PCM object.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/topology.h b/include/topology.h
index ccd8401..b6a6f19 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -606,6 +606,11 @@ extern "C" {
  *			"config3"
  *		]
  *	}
+ *
+ *	# Optional boolean flags
+ *	symmetric_rates			"true"
+ *	symmetric_channels		"true"
+ *	symmetric_sample_bits		"false"
  * }
  * </pre>
  *
@@ -863,6 +868,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 SND_SOC_TPLG_LNK_FLGBIT_* */
 	int num_streams;	/*!< number of supported configs */
 	struct snd_tplg_stream_template stream[0]; /*!< supported configs */
 };
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 6fdf047..bd70dc9 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -364,6 +364,24 @@ static int tplg_parse_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
 	return 0;
 }
 
+/* parse a flag bit of the given mask */
+static int parse_flag(snd_config_t *n, unsigned int mask_in,
+		      unsigned int *mask, unsigned int *flags)
+{
+	const char *val = NULL;
+
+	if (snd_config_get_string(n, &val) < 0)
+		return -EINVAL;
+
+	*mask |= mask_in;
+	if (strcmp(val, "true") == 0)
+		*flags |= mask_in;
+	else
+		*flags &= ~mask_in;
+
+	return 0;
+}
+
 /* Parse pcm (for front end DAI & DAI link) */
 int tplg_parse_pcm(snd_tplg_t *tplg,
 	snd_config_t *cfg, void *private ATTRIBUTE_UNUSED)
@@ -430,6 +448,34 @@ int tplg_parse_pcm(snd_tplg_t *tplg,
 				return err;
 			continue;
 		}
+
+		/* flags */
+		if (strcmp(id, "symmetric_rates") == 0) {
+			err = parse_flag(n,
+				SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES,
+				&pcm->flag_mask, &pcm->flags);
+			if (err < 0)
+				return err;
+			continue;
+		}
+
+		if (strcmp(id, "symmetric_channels") == 0) {
+			err = parse_flag(n,
+				SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS,
+				&pcm->flag_mask, &pcm->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,
+				&pcm->flag_mask, &pcm->flags);
+			if (err < 0)
+				return err;
+			continue;
+		}
 	}
 
 	return 0;
@@ -610,6 +656,9 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
 			tplg_add_stream_caps(&pcm->caps[i], pcm_tpl->caps[i]);
 	}
 
+	pcm->flag_mask = pcm_tpl->flag_mask;
+	pcm->flags = pcm_tpl->flags;
+
 	pcm->num_streams = pcm_tpl->num_streams;
 	for (i = 0; i < pcm_tpl->num_streams; i++)
 		tplg_add_stream_object(&pcm->stream[i], &pcm_tpl->stream[i]);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/6] topology: Define a function to build a single PCM element
  2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
                   ` (2 preceding siblings ...)
  2016-11-03 23:07 ` [PATCH 3/6] topology: Parse flags for PCM mengdong.lin
@ 2016-11-03 23:07 ` mengdong.lin
  2016-11-03 23:08 ` [PATCH 5/6] topology: Parse and build private data for PCM mengdong.lin
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: mengdong.lin @ 2016-11-03 23:07 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 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.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/src/topology/parser.c b/src/topology/parser.c
index 3ab64f4..7b2c879 100644
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -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;
 
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index bd70dc9..77b7605 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -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;
 
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index cfde4cc..7b30b84 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/6] topology: Parse and build private data for PCM
  2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
                   ` (3 preceding siblings ...)
  2016-11-03 23:07 ` [PATCH 4/6] topology: Define a function to build a single PCM element mengdong.lin
@ 2016-11-03 23:08 ` mengdong.lin
  2016-11-03 23:08 ` [PATCH 6/6] topology: tplg_elem_lookup() checks parameter before searching mengdong.lin
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: mengdong.lin @ 2016-11-03 23:08 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 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.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/topology.h b/include/topology.h
index b6a6f19..481b408 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -611,6 +611,8 @@ extern "C" {
  *	symmetric_rates			"true"
  *	symmetric_channels		"true"
  *	symmetric_sample_bits		"false"
+ *
+ *	data "name"			# optional private data
  * }
  * </pre>
  *
@@ -870,6 +872,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 SND_SOC_TPLG_LNK_FLGBIT_* */
+	struct snd_soc_tplg_private *priv;	/*!< private data */
 	int num_streams;	/*!< number of supported configs */
 	struct snd_tplg_stream_template stream[0]; /*!< supported configs */
 };
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 77b7605..3f54e94 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -73,12 +73,32 @@ static int tplg_build_stream_caps(snd_tplg_t *tplg,
 /* build a PCM (FE DAI & DAI link) element */
 static int build_pcm(snd_tplg_t *tplg, struct tplg_elem *elem)
 {
+	struct tplg_ref *ref;
+	struct list_head *base, *pos;
 	int err;
 
 	err = tplg_build_stream_caps(tplg, elem->id, elem->pcm->caps);
 		if (err < 0)
 			return err;
 
+	/* merge private data from the referenced data elements */
+	base = &elem->ref_list;
+	list_for_each(pos, base) {
+
+		ref = list_entry(pos, struct tplg_ref, list);
+		if (ref->type == SND_TPLG_TYPE_DATA) {
+			err = tplg_copy_data(tplg, elem, ref);
+			if (err < 0)
+				return err;
+		}
+		if (!ref->elem) {
+			SNDERR("error: cannot find '%s' referenced by"
+				" PCM '%s'\n", ref->id, elem->id);
+			return -EINVAL;
+		} else if (err < 0)
+			return err;
+	}
+
 	return 0;
 }
 
@@ -394,7 +414,7 @@ static int parse_flag(snd_config_t *n, unsigned int mask_in,
 	return 0;
 }
 
-/* Parse pcm (for front end DAI & DAI link) */
+/* Parse PCM (for front end DAI & DAI link) in text conf file */
 int tplg_parse_pcm(snd_tplg_t *tplg,
 	snd_config_t *cfg, void *private ATTRIBUTE_UNUSED)
 {
@@ -501,6 +521,7 @@ int tplg_parse_be(snd_tplg_t *tplg,
 	snd_config_iterator_t i, next;
 	snd_config_t *n;
 	const char *id, *val = NULL;
+	int err;
 
 	elem = tplg_elem_new_common(tplg, cfg, NULL, SND_TPLG_TYPE_BE);
 	if (!elem)
@@ -540,6 +561,13 @@ int tplg_parse_be(snd_tplg_t *tplg,
 			tplg_dbg("\t%s: %d\n", id, link->id);
 			continue;
 		}
+
+		if (strcmp(id, "data") == 0) {
+			err = tplg_parse_data_refs(n, elem);
+			if (err < 0)
+				return err;
+			continue;
+		}
 	}
 
 	return 0;
@@ -633,10 +661,11 @@ static void tplg_add_stream_caps(struct snd_soc_tplg_stream_caps *caps,
 	caps->sig_bits = caps_tpl->sig_bits;
 }
 
+/* Add a PCM element (FE DAI & DAI link) from C API */
 int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
 {
 	struct snd_tplg_pcm_template *pcm_tpl = t->pcm;
-	struct snd_soc_tplg_pcm *pcm;
+	struct snd_soc_tplg_pcm *pcm, *_pcm;
 	struct tplg_elem *elem;
 	int i;
 
@@ -675,6 +704,25 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
 	for (i = 0; i < pcm_tpl->num_streams; i++)
 		tplg_add_stream_object(&pcm->stream[i], &pcm_tpl->stream[i]);
 
+	/* private data */
+	if (pcm_tpl->priv != NULL && pcm_tpl->priv->size) {
+		tplg_dbg("\t priv data size %d\n", pcm_tpl->priv->size);
+		_pcm = realloc(pcm,
+			elem->size + pcm_tpl->priv->size);
+		if (!_pcm) {
+			tplg_elem_free(elem);
+			return -ENOMEM;
+		}
+
+		pcm = _pcm;
+		elem->pcm = pcm;
+		elem->size += pcm_tpl->priv->size;
+
+		memcpy(pcm->priv.data, pcm_tpl->priv->data,
+			pcm_tpl->priv->size);
+		pcm->priv.size = pcm_tpl->priv->size;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/6] topology: tplg_elem_lookup() checks parameter before searching
  2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
                   ` (4 preceding siblings ...)
  2016-11-03 23:08 ` [PATCH 5/6] topology: Parse and build private data for PCM mengdong.lin
@ 2016-11-03 23:08 ` mengdong.lin
  2016-11-03 23:09 ` [PATCH 0/6] topology: Updates for PCM object in ABI v5 Lin, Mengdong
  2016-11-05 15:45 ` Takashi Iwai
  7 siblings, 0 replies; 11+ messages in thread
From: mengdong.lin @ 2016-11-03 23:08 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>

Check the parameters at first in case of misuse.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/src/topology/elem.c b/src/topology/elem.c
index 029c9ab..724bf26 100644
--- a/src/topology/elem.c
+++ b/src/topology/elem.c
@@ -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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/6] topology: Updates for PCM object in ABI v5
  2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
                   ` (5 preceding siblings ...)
  2016-11-03 23:08 ` [PATCH 6/6] topology: tplg_elem_lookup() checks parameter before searching mengdong.lin
@ 2016-11-03 23:09 ` Lin, Mengdong
  2016-11-05 15:45 ` Takashi Iwai
  7 siblings, 0 replies; 11+ messages in thread
From: Lin, Mengdong @ 2016-11-03 23:09 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

I'm so sorry, please overlook the duplicated cover letters. I sent them out by mistake.

Thanks
Mengdong

> -----Original Message-----
> From: mengdong.lin@linux.intel.com [mailto:mengdong.lin@linux.intel.com]
> Sent: Friday, November 4, 2016 7:00 AM
> To: alsa-devel@alsa-project.org
> Cc: tiwai@suse.de; broonie@kernel.org; perex@perex.cz;
> liam.r.girdwood@linux.intel.com; Shah, Hardik T <hardik.t.shah@intel.com>;
> Singh, Guneshwor O <guneshwor.o.singh@intel.com>; Koul, Vinod
> <vinod.koul@intel.com>; Lin, Mengdong <mengdong.lin@intel.com>;
> Mengdong Lin <mengdong.lin@linux.intel.com>
> Subject: [PATCH 0/6] topology: Updates for PCM object in ABI v5
> 
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> These ABI updates for PCM have just been applied to ASoC kernel. And
> kernel can handle the PCM ABI updates in a backward compatible way.
> 
> So we update the user space code for PCM now.
> 
> The updates for physical DAI link and DAIs will come later after their kernel
> updates be applied at first.
> 
> Mengdong Lin (6):
>   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
> 
>  include/sound/asoc.h      |   9 ++++
>  include/topology.h        |  11 +++++
>  src/topology/elem.c       |   3 ++
>  src/topology/parser.c     |   2 +-
>  src/topology/pcm.c        | 120
> ++++++++++++++++++++++++++++++++++++++++++++--
>  src/topology/tplg_local.h |   2 +-
>  6 files changed, 140 insertions(+), 7 deletions(-)
> 
> --
> 2.7.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/6] topology: Updates for PCM object in ABI v5
  2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
                   ` (6 preceding siblings ...)
  2016-11-03 23:09 ` [PATCH 0/6] topology: Updates for PCM object in ABI v5 Lin, Mengdong
@ 2016-11-05 15:45 ` Takashi Iwai
  7 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2016-11-05 15:45 UTC (permalink / raw)
  To: mengdong.lin
  Cc: alsa-devel, vinod.koul, hardik.t.shah, guneshwor.o.singh,
	liam.r.girdwood, broonie, mengdong.lin

On Fri, 04 Nov 2016 00:00:19 +0100,
mengdong.lin@linux.intel.com wrote:
> 
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> These ABI updates for PCM have just been applied to ASoC kernel. And
> kernel can handle the PCM ABI updates in a backward compatible way.
> 
> So we update the user space code for PCM now.
> 
> The updates for physical DAI link and DAIs will come later after
> their kernel updates be applied at first.
> 
> Mengdong Lin (6):
>   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

Applied all patches now.
There was a minor issue, but we can address it later.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/6] topology: Parse flags for PCM
  2016-11-03 23:07 ` [PATCH 3/6] topology: Parse flags for PCM mengdong.lin
@ 2016-11-05 15:45   ` Takashi Iwai
  2016-11-05 16:54     ` Lin, Mengdong
  0 siblings, 1 reply; 11+ messages in thread
From: Takashi Iwai @ 2016-11-05 15:45 UTC (permalink / raw)
  To: mengdong.lin
  Cc: alsa-devel, vinod.koul, hardik.t.shah, guneshwor.o.singh,
	liam.r.girdwood, broonie, mengdong.lin

On Fri, 04 Nov 2016 00:07:06 +0100,
mengdong.lin@linux.intel.com wrote:
> 
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> Users can define flags by both text conf file and C API.
> Add flags and flag_mask to C API template of PCM object.
> 
> Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> diff --git a/include/topology.h b/include/topology.h
> index ccd8401..b6a6f19 100644
> --- a/include/topology.h
> +++ b/include/topology.h
> @@ -606,6 +606,11 @@ extern "C" {
>   *			"config3"
>   *		]
>   *	}
> + *
> + *	# Optional boolean flags
> + *	symmetric_rates			"true"
> + *	symmetric_channels		"true"
> + *	symmetric_sample_bits		"false"
>   * }
>   * </pre>
>   *
> @@ -863,6 +868,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 SND_SOC_TPLG_LNK_FLGBIT_* */
>  	int num_streams;	/*!< number of supported configs */
>  	struct snd_tplg_stream_template stream[0]; /*!< supported configs */
>  };
> diff --git a/src/topology/pcm.c b/src/topology/pcm.c
> index 6fdf047..bd70dc9 100644
> --- a/src/topology/pcm.c
> +++ b/src/topology/pcm.c
> @@ -364,6 +364,24 @@ static int tplg_parse_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
>  	return 0;
>  }
>  
> +/* parse a flag bit of the given mask */
> +static int parse_flag(snd_config_t *n, unsigned int mask_in,
> +		      unsigned int *mask, unsigned int *flags)
> +{
> +	const char *val = NULL;
> +
> +	if (snd_config_get_string(n, &val) < 0)
> +		return -EINVAL;
> +
> +	*mask |= mask_in;
> +	if (strcmp(val, "true") == 0)
> +		*flags |= mask_in;
> +	else
> +		*flags &= ~mask_in;

This can be simplified with snd_config_get_bool().


thanks,

Takashi

> +
> +	return 0;
> +}
> +
>  /* Parse pcm (for front end DAI & DAI link) */
>  int tplg_parse_pcm(snd_tplg_t *tplg,
>  	snd_config_t *cfg, void *private ATTRIBUTE_UNUSED)
> @@ -430,6 +448,34 @@ int tplg_parse_pcm(snd_tplg_t *tplg,
>  				return err;
>  			continue;
>  		}
> +
> +		/* flags */
> +		if (strcmp(id, "symmetric_rates") == 0) {
> +			err = parse_flag(n,
> +				SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES,
> +				&pcm->flag_mask, &pcm->flags);
> +			if (err < 0)
> +				return err;
> +			continue;
> +		}
> +
> +		if (strcmp(id, "symmetric_channels") == 0) {
> +			err = parse_flag(n,
> +				SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS,
> +				&pcm->flag_mask, &pcm->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,
> +				&pcm->flag_mask, &pcm->flags);
> +			if (err < 0)
> +				return err;
> +			continue;
> +		}
>  	}
>  
>  	return 0;
> @@ -610,6 +656,9 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
>  			tplg_add_stream_caps(&pcm->caps[i], pcm_tpl->caps[i]);
>  	}
>  
> +	pcm->flag_mask = pcm_tpl->flag_mask;
> +	pcm->flags = pcm_tpl->flags;
> +
>  	pcm->num_streams = pcm_tpl->num_streams;
>  	for (i = 0; i < pcm_tpl->num_streams; i++)
>  		tplg_add_stream_object(&pcm->stream[i], &pcm_tpl->stream[i]);
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/6] topology: Parse flags for PCM
  2016-11-05 15:45   ` Takashi Iwai
@ 2016-11-05 16:54     ` Lin, Mengdong
  0 siblings, 0 replies; 11+ messages in thread
From: Lin, Mengdong @ 2016-11-05 16:54 UTC (permalink / raw)
  To: Takashi Iwai, mengdong.lin@linux.intel.com
  Cc: alsa-devel@alsa-project.org, Koul, Vinod, Shah, Hardik T,
	Singh, Guneshwor O, liam.r.girdwood@linux.intel.com,
	broonie@kernel.org

> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de]
> Sent: Saturday, November 5, 2016 11:46 PM
> >
> > +/* parse a flag bit of the given mask */ static int
> > +parse_flag(snd_config_t *n, unsigned int mask_in,
> > +		      unsigned int *mask, unsigned int *flags) {
> > +	const char *val = NULL;
> > +
> > +	if (snd_config_get_string(n, &val) < 0)
> > +		return -EINVAL;
> > +
> > +	*mask |= mask_in;
> > +	if (strcmp(val, "true") == 0)
> > +		*flags |= mask_in;
> > +	else
> > +		*flags &= ~mask_in;
> 
> This can be simplified with snd_config_get_bool().

Okay, I'll fix it in my later patches. Thank you so much for the review!

There will be ~15 patches left for topology user space. I'll split into 2 series.

Regards
Mengdong

> 
> 
> thanks,
> 
> Takashi
> 
> > +
> > +	return 0;
> > +}
> > +
> >  /* Parse pcm (for front end DAI & DAI link) */  int
> > tplg_parse_pcm(snd_tplg_t *tplg,
> >  	snd_config_t *cfg, void *private ATTRIBUTE_UNUSED) @@ -430,6
> +448,34
> > @@ int tplg_parse_pcm(snd_tplg_t *tplg,
> >  				return err;
> >  			continue;
> >  		}
> > +
> > +		/* flags */
> > +		if (strcmp(id, "symmetric_rates") == 0) {
> > +			err = parse_flag(n,
> > +
> 	SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES,
> > +				&pcm->flag_mask, &pcm->flags);
> > +			if (err < 0)
> > +				return err;
> > +			continue;
> > +		}
> > +
> > +		if (strcmp(id, "symmetric_channels") == 0) {
> > +			err = parse_flag(n,
> > +
> 	SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS,
> > +				&pcm->flag_mask, &pcm->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,
> > +				&pcm->flag_mask, &pcm->flags);
> > +			if (err < 0)
> > +				return err;
> > +			continue;
> > +		}
> >  	}
> >
> >  	return 0;
> > @@ -610,6 +656,9 @@ int tplg_add_pcm_object(snd_tplg_t *tplg,
> snd_tplg_obj_template_t *t)
> >  			tplg_add_stream_caps(&pcm->caps[i], pcm_tpl-
> >caps[i]);
> >  	}
> >
> > +	pcm->flag_mask = pcm_tpl->flag_mask;
> > +	pcm->flags = pcm_tpl->flags;
> > +
> >  	pcm->num_streams = pcm_tpl->num_streams;
> >  	for (i = 0; i < pcm_tpl->num_streams; i++)
> >  		tplg_add_stream_object(&pcm->stream[i], &pcm_tpl-
> >stream[i]);
> > --
> > 2.7.4
> >

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-11-05 16:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-03 23:00 [PATCH 0/6] topology: Updates for PCM object in ABI v5 mengdong.lin
2016-11-03 23:05 ` [PATCH 1/6] topology: ABI - Update stream caps and PCM objects to " mengdong.lin
2016-11-03 23:06 ` [PATCH 2/6] topology: Parse sig_bits of stream caps mengdong.lin
2016-11-03 23:07 ` [PATCH 3/6] topology: Parse flags for PCM mengdong.lin
2016-11-05 15:45   ` Takashi Iwai
2016-11-05 16:54     ` Lin, Mengdong
2016-11-03 23:07 ` [PATCH 4/6] topology: Define a function to build a single PCM element mengdong.lin
2016-11-03 23:08 ` [PATCH 5/6] topology: Parse and build private data for PCM mengdong.lin
2016-11-03 23:08 ` [PATCH 6/6] topology: tplg_elem_lookup() checks parameter before searching mengdong.lin
2016-11-03 23:09 ` [PATCH 0/6] topology: Updates for PCM object in ABI v5 Lin, Mengdong
2016-11-05 15:45 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).