Commit graph

127 commits

Author SHA1 Message Date
Jyri Sarha
906a56f9ff topology: nhlt: Intel: Improve all error prints
Many error prints had obsolete function name written in them, use
__func__ everywhere and add problematic value to the print if its
available.

Closes: https://github.com/alsa-project/alsa-utils/pull/254
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-03-16 19:01:11 +01:00
Seppo Ingalsuo
19a75d0ebc topology: nhlt: Intel: Clear DMIC BFTH bits for version
The former Burst Fifo ThresHold bits 20-23 in output register are
specified as reserved bits starting from driver version 4.

Closes: https://github.com/alsa-project/alsa-utils/pull/254
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-03-16 19:01:11 +01:00
Seppo Ingalsuo
9efbf459fb topology: nhlt: Intel: Add check for DMIC version
Error if the version passed from topology is not known. Also fix the
dmic_set_params() error prints for to show the correct function name.

Closes: https://github.com/alsa-project/alsa-utils/pull/254
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-03-16 19:01:11 +01:00
Jyri Sarha
6da3737bd4 topology: Fix one character typo in code comments
Closes: https://github.com/alsa-project/alsa-utils/pull/250
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-01-24 18:39:16 +01:00
Jyri Sarha
0029ab7cc7 topology: Expand attribute references inside $[] expressions
Properly expand referred object attributes inside $[] expression. This
allows for example this simplified case:

Define {
       CHANNELS 2
       BIT_DEPTH 16
}

Object.Base.foo {
	channels	$CHANNELS
	sample_bits	$BIT_DEPTH
	frame_bits	"$[$channels * $sample_bits]"
}

Closes: https://github.com/alsa-project/alsa-utils/pull/250
Reported-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-01-24 18:38:03 +01:00
Jyri Sarha
6eb1eb5047 topology: nhlt: Fix dmic configuration blob building
The dmic configuration functions are called for each dmic DAI (or
FIFO) separately, and each dmic DAI is configured in their own
configuration rounds. However, the later configured dmic FIFO may
change the common clock divider and thus affect the FIR configuration
of the first configured DAI. However, the first configured FIR blob is
not touched after it is configured for the first time.

To overcome this problem always check the both FIR configurations, no
matter which DAI we are configuring.

Closes: https://github.com/alsa-project/alsa-utils/pull/250
Suggested-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-01-24 18:34:22 +01:00
Jaroslav Kysela
e7a02f3872 topology: nhlt: fix simple memory leak
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-01-17 17:38:29 +01:00
Tianyi Liu
edff9652c0 misc: fix incorrect usages of strerror
`strerror` takes the `errno` directly as its argument,
negating it will result in an "Unknown error".

This fixes such usages across multiple modules.

Fixes: https://github.com/alsa-project/alsa-utils/pull/245
Signed-off-by: Tianyi Liu <i.pear@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-12-08 20:01:04 +01:00
Andy Ross
8f3d84ba19 nhlt: Revert SSP_ANALOG device_type field
This partially reverts commit 3a47ef2487 ("topology: nhlt: intel:
support more device types and directions"), which changed the default
device_type in the endpoint descriptor from zero to SSP_ANALOG.

This change breaks the Linux kernel NHLT parser (which AFAICT doesn't
recognize SSP_ANALOG at all), producing errors like:

  [56458.583812] sof-audio-pci-intel-mtl 0000:00:1f.3: no matching blob for sample rate: 48000 sample width: 32 channels: 2
  [56458.583833] sof-audio-pci-intel-mtl 0000:00:1f.3: failed to prepare widget dai-copier.SSP.SSP0-Codec.playback
  [56458.583840] sof-audio-pci-intel-mtl 0000:00:1f.3: Failed to prepare connected widgets
  [56458.583847] sof-audio-pci-intel-mtl 0000:00:1f.3: error: failed widget list set up for pcm 1 dir 0
  [56458.583853] sof-audio-pci-intel-mtl 0000:00:1f.3: ASoC: error at snd_soc_pcm_component_hw_params on 0000:00:1f.3: -22

Revert for compatibility.

Fixes: https://github.com/alsa-project/alsa-utils/pull/248
Signed-off-by: Andy Ross <andyross@google.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-12-08 19:46:58 +01:00
Sam James
d272c5d935 topology: add include for ENABLE_NLS on musl
Needed for setlocale().

(After rebasing to pick up 8c229270f6, just
move it to be guarded as the include now exists.)

Closes: https://github.com/alsa-project/alsa-utils/pull/234
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-10-17 13:44:54 +02:00
Ranjani Sridharan
68dd54784a topology: pre-processor: Add support for enum controls
Add support for adding enum controls in the topology pre-processor.

Closes: https://github.com/alsa-project/alsa-utils/pull/236
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-10-17 13:24:11 +02:00
Michael Opdenacker
8c229270f6 topology: include locale.h
This solves an issue compiling with the musl libc.

Fixes: https://github.com/alsa-project/alsa-utils/issues/239
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-19 14:36:38 +02:00
Jaroslav Kysela
dfe1c7143a topology: use ATTRIBUTE_UNUSED instead remove argument name
We need to support older compilers than GCC 11.

Link: https://github.com/alsa-project/alsa-utils/issues/233
Fixes: 153d185 ("topology: fix the verbose compilation warnings for latest gcc")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-04 17:11:29 +02:00
Jaroslav Kysela
feb9c4cdec reshuffle included files to include config.h as first
config.h may contain defines like _FILE_OFFSET_BITS which influence
the system wide include files (off_t types, open -> open64 function
usage etc.).

Related: https://github.com/alsa-project/alsa-utils/pull/223
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-30 18:48:23 +02:00
Jaroslav Kysela
153d185822 topology: fix the verbose compilation warnings for latest gcc
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-30 12:33:19 +02:00
Jaska Uimonen
096920264e topology: plugins: nhlt: remove dmic error print
Remove "fs not set" print from dmic processing. The message is printed out
when pdm is enabled but not configured. Many sof topologies enable all
pdms even if not used as it is a requirement for some Intel firmware
versions to work correctly.

Fixes: https://github.com/alsa-project/alsa-utils/pull/218
Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-01 09:46:47 +02:00
Seppo Ingalsuo
a4c25e4710 Topology: NHLT: Intel: Update DMIC FIR coefficients
The previous version contained some hand edit mistakes those
impacted the filter frequency response. The used generator script
is found from directory:

https://github.com/thesofproject/sof/tree/main/tools/tune/dmic .

Use command "dmic_batch.h" to generate these and copy new version
to alsa-utils.

Fixes: https://github.com/alsa-project/alsa-utils/pull/218
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-01 09:46:33 +02:00
Brent Lu
3a47ef2487 topology: nhlt: intel: support more device types and directions
In current NHLT table the device type of all SSP endpoints are set to
BT Sideband(0) instead of SSP Analog Codec(4) and the direction only
supports Render(0) and Capture(1).

Here we introduce two new quirks from topology to set the device type
correctly and support two more directions: Render with loopback(2)
and Feedback for render(3) for speakers with echo reference or IV
sense feedback.

Fixes: https://github.com/alsa-project/alsa-utils/pull/226
Signed-off-by: Brent Lu <brent.lu@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-01 09:43:17 +02:00
Ranjani Sridharan
9d058fff27 topology: pre-processor: Add support for CombineArrays
Introduce a new keyword, "CombineArrays" to instantiate multiple nodes
of the type specified. For example:

CombineArrays.Object.Base.input_audio_format [
	{
		in_rate [
			8000
			16000
			48000
		]
		in_bit_depth [
			32
		]
		in_valid_bit_depth [
			24
			32
		]
	}
]

This would be expanded into 6 objects with the rate, bit_depth and
valid_bit_depth combinations of the arrays of values above.

Object.Base.input_audio_format [
	{
		in_rate 8000
		in_bit_depth 32
		in_valid_bit_depth 32
	}
	{
		in_rate 16000
		in_bit_depth 32
		in_valid_bit_depth 32
	}
	{
		in_rate 48000
		in_bit_depth 32
		in_valid_bit_depth 32
	}
	{
		in_rate 8000
		in_bit_depth 32
		in_valid_bit_depth 24
	}
	{
		in_rate 16000
		in_bit_depth 32
		in_valid_bit_depth 24
	}
	{
		in_rate 48000
		in_bit_depth 32
		in_valid_bit_depth 24
	}
]

The CombineArrays definition is an array so that multiple combinations can
be specified in order to deal with only valid combinations. For example,
16-bit bit_depth is only valid with 16-bit valid_bit_depth. So if we
also want to add those combinations with the multiple rates, the
definition would look like:

CombineArrays.Object.Base.input_audio_format [
        {
                in_rate [
                        8000
                        16000
                        48000
                ]
                in_bit_depth [
                        32
                ]
                in_valid_bit_depth [
                        24
                        32
                ]
        }
        {
                in_rate [
                        8000
                        16000
                        48000
                ]
                in_bit_depth [
                        16
                ]
                in_valid_bit_depth [
                        16
                ]
        }
]

Fixes: https://github.com/alsa-project/alsa-utils/pull/216
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-01 09:40:51 +02:00
Jaska Uimonen
5cdb598f59 topology: plugins: nhlt: set dmic stereo mode only in hw version 1
Dmic stereo mode should be set only in hw version 1. In later hw
versions this bit is reserved.

Fixes: https://github.com/alsa-project/alsa-utils/pull/222
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.ntel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-08-01 09:34:19 +02:00
Chao Song
52f6fb7f33 topology: pre-processor: fix regular expression flags
The REG_ICASE flag is a compile-time flag (cflags), it
should be used with regcomp() instead of regexec(). Also
add the REG_EXTENDED flag in this patch to make patterns
like 'tgl|adl' work.

Fixes: https://github.com/alsa-project/alsa-utils/pull/195
Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 16:25:15 +02:00
Jyri Sarha
cf25cf6767 topology: pre-process-object: Expand definitions within strings
Expand the pre-processor to allow for expanding the definitions,
object attribute references and arithmetic expressions within strings.

With this extension its possible to embedded definitions or attribute
references into topology string objects. For example:

Define {
       PCM_NUMBER	1
}

Object.Pipeline {
	pcm-playback.0 {

	Object.Widget {
		copier.1 {
			copier_type	"host"
		}
		gain.1 {
			Object.Control.mixer.1 {
				name 'hw:$[$PCM_NUMBER - 1] Playback Volume'
		}
	}

	Object.Base {
		route.1 {
			source	copier.host.$index.1
			sink	gain.$index.1
		}
	}
}

In the example the $[$PCM_NUMBER - 1] would be replaced with the
result of arithmetic expression '1 - 1' in other words '0' , and
$index in all occurrences with index attribute found from pipeline
object. Any non alpha numeric or '_' character are treated as
delimiters for variable names if $[]-notation is not used.

Fixes: https://github.com/alsa-project/alsa-utils/pull/189
Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-06 15:49:14 +01:00
Jyri Sarha
4d7275d7f8 topology: pre-process-object: Remove all trailing white space
Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-06 15:48:20 +01:00
Chao Song
1350900246 topology: pre-processor: support to include conf block with IncludeByKey
Currently, The IncludeByKey mechanism only supports conditionally
including a topology conf file. Even if we only
want to conditionally include a small conf block, we have
to use a conf file and in the end we will have a lot of
trivial conf files that only contain a single conf blocks.

This patch extends the use of IncludeByKey ito support including conf
blocks conditionally. For example, the block below will include the route
conditionally based on the variable definition COPIER_ROUTE.

Define {
	COPIER_ROUTE	1
}

IncludeByKey.COPIER_ROUTE {
       	"1" {
		Object.Base.route.11 {
			source	copier.module.8.2
			sink	copier.module.17.2
		}
	    }
}

Fixes: https://github.com/alsa-project/alsa-utils/pull/187
Signed-off-by: Chao Song <chao.song@linux.intel.com>
Co-authored-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-24 09:45:45 +01:00
Jaska Uimonen
df3da091cc topology: nhlt: intel: add support for ssp blob ver 1.5
Ssp plugin had already a definition for newer nhlt blob version 1.5.
Add support to generate that instead of legacy blob. Never blob can be
generated by adding "version" field in SSP dai topology2 definition and
setting it to lower 16 bits of SSP_BLOB_VER_1_5 (0xee000105) -> 0x105
i.e 8 bits for major and 8 bits for minor version.

SSP."0" {
	id              0
	dai_index       0
	direction       "duplex"
	name            NoCodec-0
	version         0x105
}

Fixes: https://github.com/alsa-project/alsa-utils/pull/184
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-24 09:43:52 +01:00
Jaska Uimonen
1ad140f641 topology: plugins: nhlt: add ssp aux controls
Intel ssp blob can have auxiliary controls catenated as tlv array at the
end of its "normal" data blob. These are needed in some platforms for
example to enable hardware clocks earlier than streaming starts.

In topology the auxiliary data classes are embedded into hw_config and
can be instantiated like:

Object.Base.hw_config."SSP0_0" {
	id              0
	mclk_freq       38400000
	bclk_freq       256000
	tdm_slot_width  16
	format          "DSP_A"
	bclk            "codec_provider"
	fsync           "codec_provider"
	fsync_freq      16000

	Object.Base.mn_config."MN_0" {
		m_div   100
		n_div   200
	}

	Object.Base.clk_config."CLK_0" {
		clock_warm_up          1
		mclk                   2
		warm_up_ovr            3
		clock_stop_delay       4
		keep_running           5
		clock_stop_ovr         6
	}
}

Fixes: https://github.com/alsa-project/alsa-utils/pull/184
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-24 09:42:40 +01:00
Chao Song
deaa1635cc topology: propagate nhlt plugin error to main program
Let's propagate nhlt plugin error to main program,
so that we don't generate a wrong nhlt blob silently.

Fixes: https://github.com/alsa-project/alsa-utils/pull/181
Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-23 19:02:23 +01:00
Jaska Uimonen
8871d51aa1 topology: plugins: nhlt: fix ssp debug
Nhlt ssp plugin debug feature was broken due to recent change in ssp
indexing, thus fix it.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-23 19:00:58 +01:00
Pierre-Louis Bossart
f67b3ed002 topology: nhlt: intel: ssp: fix obvious typo for 'codec_provider'
Looks like a bad search and replace?

Fixes: https://github.com/alsa-project/alsa-utils/pull/174
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-23 18:54:22 +01:00
Jaska Uimonen
c57391dd26 topology: plugins: nhlt: fix ssp dai index
There was a conceptual error in handling the separate ssp dais, so fix
it.

Fixes: https://github.com/alsa-project/alsa-utils/pull/164
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-04 22:04:40 +01:00
Jaska Uimonen
e13a7d3cf6 topology: plugins: nhlt: add dmic dai index
Dmic might have multiple configurations for the same hw, so add them to
nhlt blob. The configurations are separated by dai_index.

Fixes: https://github.com/alsa-project/alsa-utils/pull/164
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-04 22:04:29 +01:00
Yong Zhi
038ed518e9 topology: plugins: fix off by 1 mem allocation error
Fix valgrind memcheck error:

==1337389== Invalid write of size 1
==1337389==    at 0x4A4AFAB: __vsnprintf_internal (vsnprintf.c:117)
==1337389==    by 0x4AECF40: __snprintf_chk (snprintf_chk.c:38)
==1337389==    by 0x484B870: snprintf (stdio2.h:67)
==1337389==    by 0x484B870: print_as_hex_bytes (nhlt-processor.c:112)
==1337389==    by 0x484B870: merge_manifest_data (nhlt-processor.c:154)
==1337389==    by 0x484B870: do_nhlt (nhlt-processor.c:420)
==1337389==    by 0x484B870: _snd_topology_nhlt_process (nhlt-processor.c:484)

The consecutive snprintf overwrites always the previous terminator until
it hits the very last call of:

snprintf(dst, ALSA_BYTE_CHARS + 1, "0x%02x,", *nhlt_buffer);

when the size n given to snprintf is 1 more than allocated.

Fixes: https://github.com/alsa-project/alsa-utils/pull/162
Signed-off-by: Yong Zhi <yong.zhi@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-04 22:03:35 +01:00
Jaroslav Kysela
265dda7715 configure: use AC_DISABLE_STATIC (for topology modules)
Fixes: https://github.com/alsa-project/alsa-utils/issues/152
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-06-02 08:25:51 +02:00
Jaroslav Kysela
65841efdf5 topology: nhlt plugin: second attempt to fix the .so linking
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-31 18:23:59 +02:00
Jaroslav Kysela
cae9b71589 topology: nhlt plugin: fix the .so linking
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-31 18:11:50 +02:00
Jaska Uimonen
96ddc346e0 topology: plugins: nhlt: fix intel dmic mode calculation
Dmic find_modes function was used with same sampling rate for both fifo
a and b parameter calculations. This bug was found in testing two
simultaneous dmic dais in topology. Fix this by introducing a sampling
rate argument for find_modes.

Fixes: https://github.com/alsa-project/alsa-utils/pull/148
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-31 14:10:25 +02:00
Jaroslav Kysela
904bc1dfd4 topology: add missing nhlt headers to Makefile.am
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-03 14:16:43 +02:00
Jaroslav Kysela
3862452e4e topology: add missing pre-process-external.h to Makefile.am
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-03 14:06:13 +02:00
Jaroslav Kysela
42010cfeba topology: do not pass pre_processor_defs to pre_process_plugins()
This parameter is not used.

Link: https://github.com/alsa-project/alsa-utils/pull/129
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-03 13:24:36 +02:00
Jaska Uimonen
f9e6010d5e topology: plugins - add Intel nhlt encoder plugin
Add Intel nhlt acpi table encoder plugin into topology2.0 processing.
Nhlt internal structure is defined in:
https://01.org/sites/default/files/595976_intel_sst_nhlt.pdf
Nhlt acpi table contain vendor specific binary data blobs that are used
in some Intel dsp platforms for configuring the dmic and ssp hardware.

The function of this code is mainly to generate the vendor specific
binary blobs, but as there is existing nhlt parser code and header in
kernel there's no point of re-inventing the container: just use the
existing nhlt acpi table format. Basically this code is creating similar
nhlt acpi table that you would get from: cat
/sys/firmware/acpi/tables/NHLT

This code will have implementation for dmic and ssp endpoints. Thus the
code will translate the topology dai tokens into vendor specific binary
blobs and pack them into nhlt acpi table. Ssp and dmic code is lifted
from Sound Open Firmware (sof) code base, thus it will have BSD-3
license.

This plugin can be enabled from command line with:

alsatplg -DPREPROCESS_PLUGINS="nhlt" -c foo.conf -p -o bar.tplg

You can also dump the nhlt binary into a file with additional define:

-DNHLT_BIN="nhlt.bin"

Link: https://github.com/alsa-project/alsa-utils/pull/129
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-03 13:24:03 +02:00
Jaska Uimonen
44d3e8aa44 topology: add simple topology plugin mechanism
Add a simple plugin interface for processing the topology tree. There
can be cases where parts of the topology need to be translated from the
original format into something else. For example one could calculate
some kind of filter coefficients from filter parameters or some other
binary interface parameters from plain text topology tokens.

Mechanism is similar as in alsa-plugins and in the plugin there should
be only 1 function exported of the form:

int _snd_topology_##pluginname##_process (snd_config_t *input, snd_config_t *output)

Input and output parameters are snd_config tree before and after topology2
pre-processing. So the plugin can modify both if needed. There are cases
where the plugin may need to get information from input tree, but make
modifications to the output.

The plugins to be used can be defined in command line with:

alsatplg -DPREPROCESS_PLUGINS="foobar" -c topology.conf -p -o topology.tplg

Multiple plugins should be separated by ":".

Plugins to be used can also be defined with "Define" clause inside the
topology file (but command line takes precedence):

Define {
       PREPROCESS_PLUGINS "foobar"
}

Link: https://github.com/alsa-project/alsa-utils/pull/129
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-03 13:23:36 +02:00
Ranjani Sridharan
ed36ce25a7 topology: pre-processor: fix seg fault when there no command line defines
In case there are not command line definitions, there is nothing to
merge or delete.

Fixes: https://github.com/alsa-project/alsa-utils/pull/141
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-28 22:39:45 +01:00
Jaroslav Kysela
b5748d329b topology: use a copy of the command line defines
Fixes: a9b3525 ("topology: don't fail when Define section is missing in the included file")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-28 18:53:52 +01:00
Jaroslav Kysela
a9b35252b4 topology: don't fail when Define section is missing in the included file
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-28 18:07:46 +01:00
Jaroslav Kysela
31d4afd8ca topology: create Define subtree for command line defines only
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-28 18:03:08 +01:00
Jaroslav Kysela
3afa353c0a topology: the includes should be deleted not removed
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-28 18:03:07 +01:00
Jaroslav Kysela
7245f63b2e topology: use cached Define subtree in pre_process_includes()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-28 10:04:07 +01:00
Jaroslav Kysela
123eecf7fa topology: fix the define section merge from the included files
The bellow commit assumed that the merge of the included file
is to the main configuration tree, but it's for the subtree.
The Define compound from the included file must be handled
separately.

Link: https://github.com/alsa-project/alsa-utils/pull/140
Fixes: e1a0711 ("topology: fix the command line define merge for new includes")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-28 09:45:42 +01:00
Jaroslav Kysela
329cc772af topology: fix the comment for improved -D option
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-28 09:29:34 +01:00
Jaroslav Kysela
16f9311174 topology: add support for multiple -D arguments
It may be useful in the makefile rules for example.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-27 18:48:20 +01:00