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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
With the introduction of variables in the topology files, validation of
attributes values must be done after they are expanded to their defined
values. Also, since valid values for attributes in the class definition
can also be variables, they need to be expanded as well. So, first expand
the attribute values and then check them against expanded valid values.
Fixes: https://github.com/alsa-project/alsa-utils/pull/138
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Parse the configuration tree only one time and then reuse
it for the merge.
Also, do not pass inc_path to all functions - add it
to the pre-processor structure.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The defines from the command line must overwrite the defines
from the included configuration files forcefully.
Link: https://github.com/alsa-project/alsa-utils/pull/129
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Remove the call to snd_config_expand_custom() to expand the top-level
input config. And replace it with calls to snd_config_evaluate_string()
for each non-compound config while processing individual objects. This
will allow retreving variable definitions from object attribute values
and global definitions.
Add a new field "current_obj_cfg" to hold the current object config
being pre-processed.
This will facilitate adding simple math expressions for computing
attribute values for objects based on other attributes. For ex: we can
set the expression for buffer size as follows:
buffer_size "$[($in_channels * 48) * 4]"
The buffer_size attribute value will be computed with the attribute
value "in_channels" based on the expression above. So if $in_channels =
2, buffer_size will be evaluated to 384.
Additionally this change also permits computing attribute values based
on previously computed values. For example:
buffer_size "$[($in_channels * 48) * 4]"
dma_buffer_size "$[$buffer_size * 2]"
dma_buffer_size will be computed as 768. Note that the order of
definitions for buffer_size and dma_buffer_size matters because the
evaluation for dma_buffer_size depends on the evaluation of buffer_size.
In order to conform to this, the tplg_object_copy_and_add_param() is
modified to add attribute configs from class config to an object using
snd_config_before() instead of snd_config_add().
With this change, we no longer need to set the auto_attr_updater for
buffer type widget objects. So remove it.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The owner r/w file permissions are too restrictive.
Let umask do it's work and set the r/w permissions to any.
Fixes: https://github.com/alsa-project/alsa-utils/issues/126
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The include path passed with -I option will override the relative
include path based on the source file.
Fixes: https://github.com/alsa-project/alsa-utils/pull/125
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Add a new keyword "IncludeByKey" that will be used to conditional
include configuration files based on the argument value supplied during
build time. For example:
IncludeByKey.DMIC_CH_COUNT {
"[1-4]" "include/platform/intel/dmic-generic.conf"
}
The above config will include the dmic-generic.conf file if the argument
value for DMIC_CH_COUNT is between 1 and 4.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>