Skip to contentSkip to conversation

topology: Support widgets' stream name and file inclusion for text conf file

PATCH Superseded [email protected] 3 participants 7 messages Oct 17, 2016 – Oct 20, 2016

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover topology: Support widgets' stream name and file inclusion for text conf file

From: Mengdong Lin <[email protected]>

This series doesn't require or cause any ABI updates. It doesn't need the kernel patches that trying to udpate ABI from v4 or v5.

It just fix a missing feature and enhance text conf file to support including files to control the increasing size of text conf files.

Mengdong Lin (2):
topology: Fix missing stream name of widgets in text conf file
topology: Add support for included files

 include/topology.h        |  38 +++++
 src/topology/dapm.c       |  10 ++
 src/topology/parser.c     | 374 +++++++++++++++++++++++++++++++++++++++++++++-
 src/topology/tplg_local.h |  17 +++
 4 files changed, 434 insertions(+), 5 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/2 topology: Fix missing stream name of widgets in text conf file

From: Mengdong Lin <[email protected]>

User can define the stream name of an input/output widget in the text conf file, by setting "stream_name" of a SectionWidget.

Topology C API and kernel already have support for configuring a widget's stream name. This patch just adds the missing part of the text conf file.

include/topology.h +1 -0
index 0675b52..a0d018e 100644
@@ -483,6 +483,7 @@ extern "C" {
  *	index "1"			# Index number
  *
  *	type "aif_in"			# Widget type - detailed above
+ *	stream_name "name"		# Stream name
  *
  *	no_pm "true"			# No PM control bit.
  *	reg "20"			# PM bit register offset
src/topology/dapm.c +10 -0
index e3c90d8..9fa0aac 100644
@@ -507,6 +507,16 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg,
 			continue;
 		}
 
+		if (strcmp(id, "stream_name") == 0) {
+			if (snd_config_get_string(n, &val) < 0)
+				return -EINVAL;
+
+			elem_copy_text(widget->sname, val,
+				       SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+			tplg_dbg("\t%s: %s\n", id, val);
+			continue;
+		}
+
 		if (strcmp(id, "no_pm") == 0) {
 			if (snd_config_get_string(n, &val) < 0)
 				return -EINVAL;
Signature · 1 line
2.5.0
#2 lore raw

PATCH 2/2 topology: Add support for included files

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Users can include a list of files by SectionInclude in the text config file. This allows user to define common info in separate files (e.g. vendor tokens, tuples) and share them for different platforms, by including them. This can save the total size of files. Users can also specifiy a list of directories relative to "usr/share/alsa/topology" to search the included files.

The topology library will search and open an included file in the following order of priority:
1. directly open the file by its name;
2. search for the file name in the directory containing current file;
3. search for the file name in "usr/share/alsa/topology";
4. search for the file name in user specified subdirectories under "usr/share/alsa/topology".

The order of the included files need not to be same as their dependencies, because the toplogy library will load all of them before parsing their dependencies.

include/topology.h +37 -0
index a0d018e..324f123 100644
@@ -624,6 +624,43 @@ extern "C" {
  *	data "name"			# optional private data
  * }
  * </pre>
+ *
+ * <h4>Include other files</h4>
+ * Users can include a list of files by SectionInclude in the text config
+ * file. This allows user to define common info in separate files (e.g.
+ * vendor tokens, tuples) and share them for different platforms, by
+ * including them. This can save the total size of files. <br><br>
+ * Users can also specifiy a list of subdirectories under
+ * "usr/share/alsa/topology", the installation directory of toplogy
+ * configuration files, to search the included files. <br><br>
+ *
+ * The topology library will search and open an included file in the
+ * following order of priority:
+ *  1. directly open the file by its name;
+ *  2. search for the file name in the directory containing current file;
+ *  3. search for the file name in "usr/share/alsa/topology";
+ *  4. search for the file name in user specified subdirectories under
+ *     "usr/share/alsa/topology".
+ *
+ * The order of the included files need not to be same as their
+ * dependencies, since the tool will load them all before parsing their
+ * dependencies.
+ *
+ * <pre>
+ * SectionInclude."name" {
+ *	path [		# Optional subdirectories to search included files
+ *		"1st subdirectory"
+ *		"2nd subdirectory"
+ *		...
+ *	]
+ *
+ *	include [	# Name of included files, use relative path
+ *		"name of 1st included file"
+ *		"name of 2nd included file"
+ *		...
+ *	]
+ * }
+ * </pre>
  */
 
 /** Maximum number of channels supported in one control */
src/topology/parser.c +369 -5

441 lines not on this page · raw message

src/topology/tplg_local.h +17 -0
index cfde4cc..ce8f4b3 100644
@@ -48,6 +48,11 @@ struct snd_tplg {
 	/* out file */
 	int out_fd;
 
+	/* user specified paths to search included files */
+	struct list_head include_paths;
+	/* child configs of included files */
+	struct list_head child_cfg_list;
+
 	int verbose;
 	unsigned int version;
 
@@ -169,6 +174,18 @@ struct tplg_elem {
 	void (*free)(void *obj);
 };
 
+/* child topology config from an included file */
+struct tplg_config {
+	snd_config_t *cfg;
+	struct list_head list; /* list of all child configs */
+};
+
+/* path to search included files */
+struct tplg_path {
+	char *dir;
+	struct list_head list; /* list of all include paths */
+};
+
 struct map_elem {
 	const char *name;
 	int id;
Signature · 1 line
2.5.0
#3 lore raw
In reply to [email protected]
Quoted 8 lines · On Mon, 17 Oct 2016 07:55:21 +0200, [email protected] wrote:

From: Mengdong Lin <[email protected]>

This series doesn't require or cause any ABI updates. It doesn't need the kernel patches that trying to udpate ABI from v4 or v5.

It just fix a missing feature and enhance text conf file to support including files to control the increasing size of text conf files.

The inclusion of a file can be done in alsaconf syntax via <xxx>, too. We may extend it if needed instead?

The patches themselves look OK, so I'm not strongly against merging them, but just to make sure our standpoint.

thanks,

Takashi

Quoted 14 lines

Mengdong Lin (2):
topology: Fix missing stream name of widgets in text conf file
topology: Add support for included files

 include/topology.h        |  38 +++++
 src/topology/dapm.c       |  10 ++
 src/topology/parser.c     | 374 +++++++++++++++++++++++++++++++++++++++++++++-
 src/topology/tplg_local.h |  17 +++
 4 files changed, 434 insertions(+), 5 deletions(-)
Signature · 1 line
2.5.0
#4 lore raw
Quoted 5 lines · Takashi Iwai
Quoted 3 lines · On Mon, 17 Oct 2016 07:55:21 +0200, [email protected] wrote:

From: Mengdong Lin <[email protected]>

Quoted 8 lines
Quoted 5 lines

This series doesn't require or cause any ABI updates. It doesn't need the kernel patches that trying to udpate ABI from v4 or v5.

It just fix a missing feature and enhance text conf file to support including files to control the increasing size of text conf files.

The inclusion of a file can be done in alsaconf syntax via <xxx>, too. We may extend it if needed instead?

Ah that's interesting... Am fine either way.

Quoted 2 lines

The patches themselves look OK, so I'm not strongly against merging them, but just to make sure our standpoint.

The last SKL conf became a bit bigger, so for readability we though we can have different files, one for module instances, one for tuples and then finally one including these two which has the graph..

Signature · 1 line
~Vinod
#6 lore raw
In reply to Takashi Iwai
Quoted 5 lines · Takashi Iwai
Quoted 3 lines · On Mon, 17 Oct 2016 07:55:21 +0200, [email protected] wrote:

From: Mengdong Lin <[email protected]>

Quoted 8 lines
Quoted 5 lines

This series doesn't require or cause any ABI updates. It doesn't need the kernel patches that trying to udpate ABI from v4 or v5.

It just fix a missing feature and enhance text conf file to support including files to control the increasing size of text conf files.

The inclusion of a file can be done in alsaconf syntax via <xxx>, too. We may extend it if needed instead?

Thanks for your review and advice!

It seems etter to extend and reuse alsaconf syntax, instead of adding topology specific code. This can also benefit UCM if users want to split common codec or SOC settings to other files.

alsaconf already support using absolute path to include a file. But it seems we cannot give a relative path (e.g. just a file name) and a configuration directory by <confdir:xxx>. I'll try to extend alsaconf.

The other patch is a bug fixing, if it's okay, could it be merged first?

Thanks
Mengdong

Quoted 24 lines

The patches themselves look OK, so I'm not strongly against merging them, but just to make sure our standpoint.

thanks,

Takashi

Quoted 14 lines

Mengdong Lin (2):
topology: Fix missing stream name of widgets in text conf file
topology: Add support for included files

  include/topology.h        |  38 +++++
  src/topology/dapm.c       |  10 ++
  src/topology/parser.c     | 374 +++++++++++++++++++++++++++++++++++++++++++++-
  src/topology/tplg_local.h |  17 +++
  4 files changed, 434 insertions(+), 5 deletions(-)

--
2.5.0

#5 lore raw
In reply to Vinod Koul
Quoted 9 lines · Vinod Koul
Quoted 8 lines · Takashi Iwai
Quoted 6 lines · On Mon, 17 Oct 2016 07:55:21 +0200, [email protected] wrote:

From: Mengdong Lin <[email protected]>

This series doesn't require or cause any ABI updates. It doesn't need the kernel patches that trying to udpate ABI from v4 or v5.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

It just fix a missing feature and enhance text conf file to support including files to control the increasing size of text conf files.

The inclusion of a file can be done in alsaconf syntax via <xxx>, too. We may extend it if needed instead?

Ah that's interesting... Am fine either way.

That saves a lot of code as well :-)

I sent out the v2 series which extends alsaconf and now topology does not need any code change. Please review.

Thanks
Mengdong

Quoted 8 lines
Quoted 3 lines

The patches themselves look OK, so I'm not strongly against merging them, but just to make sure our standpoint.

The last SKL conf became a bit bigger, so for readability we though we can have different files, one for module instances, one for tuples and then finally one including these two which has the graph..