[alsa-devel] [PATCH 17/22] topology: Parse name and stream name of physical DAI links

mengdong.lin at linux.intel.com mengdong.lin at linux.intel.com
Thu Oct 27 09:14:24 CEST 2016


From: Mengdong Lin <mengdong.lin at linux.intel.com>

Add name and stream name to C API template of physical DAI links.

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

diff --git a/include/topology.h b/include/topology.h
index d7971b7..f7ab7fe 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -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 */
 
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index c4857ba..67d647b 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -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;
-- 
2.5.0



More information about the Alsa-devel mailing list