alsa-utils/topology
Ranjani Sridharan ffc63f76de topology: pre-processor: Introduce a new feature for subtree copies
Introduce a new kyword "SubTreeCopy" for extneding existing conf nodes
with additional nodes. This feature is useful for extending previous
pipeline class definitions with the addition of one or more widgets
without having to duplicate everything in the new class definition.

For example: Consider a pipeline class definition as below. Note that
only the widgets & routes are shown here.

Class.Pipeline.mixout-gain-dai-copier-playback {
	Object.Widget {
		mixout."1" {}
		dai-copier."1" {}
		gain."1" {}
		pipeline."1" {}
	}

	Object.Base {
		!route [
			{
				source mixout.$index.1
				sink	gain.$index.1
			}
		]
	}
}

If we want to extend this pipeline with the addition of an eqiir/eqfir,
we can create a SubTreeCopy node with type extend as follows:

Class.Pipeline.mixout-gain-eqiir-eqfir-dai-copier-playback {
	SubTreeCopy.baseclass {
		source "Class.Pipeline.mixout-gain-dai-copier-playback"
		type extend

                tree {
			Object.Widget {
				eqiir.1 {}
				eqfir.1 {}
			}

			Object.Base {
				!route [
					{
						source gain.$index.1
						sink   eqiir.$index.1
					}
					{
						source eqiir.$index.1
						sink   eqfir.$index.1
					}
				]
			}
		}
	}
}

Note that the target is left undefined, which means that the newly
created subtree will be merged to the parent node that contains the
"SubTreeCopy" node i.e. in this case
Class.Pipeline.mixout-gain-eqiir-eqfir-dai-copier-playback".

But if we want to modify an existing pipeline class while modifying the
order of widgets and/or inserting new widgets, we should use the type
"override" instead. This allows for adding new widgets to the list of
widgets in the base class definition while also allowing overriding the
routes to allow inserting the new widgets and reordering the widgets in
the base class. For example, if we want to add a drc widget between the
gain and the eqiir modules in the above class, we can do the following:

Class.Pipeline.mixout-efx-dai-copier-playback {
	# This copy will override all widgets/routes in the base class
	SubTreeCopy.baseclass {
		source "Class.Pipeline.mixout-gain-eqiir-eqfir-dai-copier-playback"
		target "Class.Pipeline"
		type override

		tree {
			Object.Widget {
				drc.1 {}
			}

			Object.Base {
				!route [
					{
						source mixout.$index.1
						sink	gain.$index.1
					}
					{
						source gain.$index.1
						sink	drc.$index.1
					}
					{
						source	drc.$index.1
						sink	eqiir.$index.1
					}
					{
						source	eqiir.$index.1
						sink	eqfir.$index.1
					}
				]
			}
		}
	}

	# Explicitly copy the widgets from the base class now
	SubTreeCopy.widgets {
		source "Class.Pipeline.mixout-gain-eqiir-eqfir-dai-copier-playback.Object.Widget"
		target "Class.Pipeline.mixout-efx-dai-copier-playback.Object.Widget"
	}
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2024-07-12 10:25:21 -07:00
..
nhlt topology: nhlt: Intel: Improve all error prints 2024-03-16 19:01:11 +01:00
alsatplg.rst alsatplg: add decode command 2020-02-09 20:52:30 +01:00
Makefile.am topology: add missing pre-process-external.h to Makefile.am 2022-05-03 14:06:13 +02:00
pre-process-class.c topology: use ATTRIBUTE_UNUSED instead remove argument name 2023-09-04 17:11:29 +02:00
pre-process-dai.c reshuffle included files to include config.h as first 2023-08-30 18:48:23 +02:00
pre-process-dapm.c topology: pre-processor: Add support for enum controls 2023-10-17 13:24:11 +02:00
pre-process-external.h topology: add simple topology plugin mechanism 2022-05-03 13:23:36 +02:00
pre-process-object.c topology: Fix one character typo in code comments 2024-01-24 18:39:16 +01:00
pre-processor.c topology: pre-processor: Introduce a new feature for subtree copies 2024-07-12 10:25:21 -07:00
pre-processor.h topology: pre-processor: Add support for enum controls 2023-10-17 13:24:11 +02:00
topology.c misc: fix incorrect usages of strerror 2023-12-08 20:01:04 +01:00
topology.h topology: rename function free_pre_preprocessor to free_pre_processor 2022-01-27 15:02:02 +01:00