Skip to contentSkip to conversation

topology: Add support for included files

PATCH In review [email protected] 3 participants 4 messages Sep 19, 2016 – Sep 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 topology: Add support for included files

From: Mengdong Lin <[email protected]>

There is no ABI change in this file, but only an enhancement for topology user space library. It will let a text configuration file include other files, so that some common cofigurations can be shared and we can reduce the total sizes of files.

Mengdong Lin (1):
topology: Add support for included files

 include/topology.h        |  37 +++++
 src/topology/parser.c     | 374 +++++++++++++++++++++++++++++++++++++++++++++-
 src/topology/tplg_local.h |  17 +++
 3 files changed, 423 insertions(+), 5 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/1 topology: Add support for included files

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 0675b52..86520df 100644
@@ -623,6 +623,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
#2 lore raw
In reply to [email protected]
Quoted 6 lines · On Mon, Sep 19, 2016 at 01:34:44PM +0800, [email protected] wrote:

From: Mengdong Lin <[email protected]>

There is no ABI change in this file, but only an enhancement for topology user space library. It will let a text configuration file include other files, so that some common cofigurations can be shared and we can reduce the total sizes of files.

Please don't send cover letters for single patches, if there is anything that needs saying put it in the changelog of the patch or after the --- if it's administrative stuff. This reduces mail volume and ensures that any important information is recorded in the changelog rather than being lost.

#3 lore raw

Okay, I will follow the rule.

For this patch, I only want to clarify there is no ABI change and there is nothing else important.

Thanks
Mengdong

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Monday, September 19, 2016 5:09 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Lin, Mengdong <[email protected]>
Subject: Re: [PATCH] topology: Add support for included files

Quoted 6 lines · On Mon, Sep 19, 2016 at 01:34:44PM +0800, [email protected] wrote:

From: Mengdong Lin <[email protected]>

There is no ABI change in this file, but only an enhancement for topology user space library. It will let a text configuration file include other files, so that some common cofigurations can be shared and we can reduce the total sizes of files.

Please don't send cover letters for single patches, if there is anything that needs saying put it in the changelog of the patch or after the --- if it's administrative stuff. This reduces mail volume and ensures that any important information is recorded in the changelog rather than being lost.