]> git.alsa-project.org Git - alsa-utils.git/log
alsa-utils.git
3 years agospeaker-test: remove sample_map.csv from Makefile
Jaroslav Kysela [Thu, 27 Jan 2022 17:29:05 +0000 (18:29 +0100)]
speaker-test: remove sample_map.csv from Makefile

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: rename function free_pre_preprocessor to free_pre_processor
Jaroslav Kysela [Thu, 27 Jan 2022 14:01:50 +0000 (15:01 +0100)]
topology: rename function free_pre_preprocessor to free_pre_processor

Line up this name with others.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: optimization for pre_processor_defs parsing
Jaroslav Kysela [Thu, 27 Jan 2022 13:58:55 +0000 (14:58 +0100)]
topology: optimization for pre_processor_defs parsing

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>
3 years agotopology: merge the pre-processor call to one function
Jaroslav Kysela [Thu, 27 Jan 2022 13:33:20 +0000 (14:33 +0100)]
topology: merge the pre-processor call to one function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: fix the command line define merge for new includes
Jaroslav Kysela [Thu, 27 Jan 2022 13:11:45 +0000 (14:11 +0100)]
topology: fix the command line define merge for new includes

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>
3 years agoalsactl: flush stdout for monitor command
Alex Xu (Hello71) [Tue, 24 Aug 2021 14:39:12 +0000 (10:39 -0400)]
alsactl: flush stdout for monitor command

It may be useful to pipe the output to another program.

Fixes: https://github.com/alsa-project/alsa-utils/pull/109
Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsactl: fix typo in comment in 00main
Jaroslav Kysela [Thu, 27 Jan 2022 12:19:32 +0000 (13:19 +0100)]
alsactl: fix typo in comment in 00main

Fixes: https://github.com/alsa-project/alsa-utils/issues/132
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agospeaker-test: remove sample_map.csv
Jaroslav Kysela [Thu, 27 Jan 2022 12:15:46 +0000 (13:15 +0100)]
speaker-test: remove sample_map.csv

The CSV file is not used. The .wav file names are fixed
in the source code, but the directory may be specified
using --wavdir. Remove this file until there's a demand
for the more precise .wav file mapping.

Fixes: https://github.com/alsa-project/alsa-utils/issues/133
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: don't allow to mix verbose level and output to stdout
Jaroslav Kysela [Thu, 27 Jan 2022 12:03:36 +0000 (13:03 +0100)]
topology: don't allow to mix verbose level and output to stdout

Fixes: https://github.com/alsa-project/alsa-utils/issues/131
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsamixer: Fix regression in color setup
Takashi Iwai [Thu, 20 Jan 2022 07:49:17 +0000 (08:49 +0100)]
alsamixer: Fix regression in color setup

The recent change to add the background config broke the color setup
via the config file due.  Fix the regression by restoring the
initialization order back again, and changing the logic for the
default background color to be re-initializing color pairs instead.

Link: https://github.com/alsa-project/alsa-utils/issues/137
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoalsactl: fix the error path in set_controls()
Jaroslav Kysela [Mon, 3 Jan 2022 15:14:31 +0000 (16:14 +0100)]
alsactl: fix the error path in set_controls()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: pre-processor: Move the call to expand variables
Ranjani Sridharan [Sat, 11 Dec 2021 18:45:43 +0000 (10:45 -0800)]
topology: pre-processor: Move the call to expand variables

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>
3 years agotopology: fix the file permissions for the generated files
Jaroslav Kysela [Sun, 12 Dec 2021 18:57:38 +0000 (19:57 +0100)]
topology: fix the file permissions for the generated files

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>
3 years agotopology: define -I option only for alsa-lib 1.2.6+
Jaroslav Kysela [Wed, 8 Dec 2021 08:55:44 +0000 (09:55 +0100)]
topology: define -I option only for alsa-lib 1.2.6+

Link: https://github.com/alsa-project/alsa-utils/pull/125
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: Add option to pass include path for conditional includes
Ranjani Sridharan [Wed, 8 Dec 2021 05:06:29 +0000 (21:06 -0800)]
topology: Add option to pass include path for conditional includes

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>
3 years agotopology: fix the include path parsing
Jaroslav Kysela [Tue, 7 Dec 2021 08:39:12 +0000 (09:39 +0100)]
topology: fix the include path parsing

When the last '/' is not found use '.' as the source path.

Fixes: https://github.com/alsa-project/alsa-utils/issues/123
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoRelease v1.2.6 v1.2.6
Jaroslav Kysela [Mon, 6 Dec 2021 10:17:28 +0000 (11:17 +0100)]
Release v1.2.6

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoamidi: remove unused variable
Jaroslav Kysela [Mon, 6 Dec 2021 10:02:10 +0000 (11:02 +0100)]
amidi: remove unused variable

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: fix compilation for older alsa-lib
Jaroslav Kysela [Mon, 6 Dec 2021 10:00:02 +0000 (11:00 +0100)]
topology: fix compilation for older alsa-lib

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: change include path
Jaroslav Kysela [Mon, 6 Dec 2021 09:13:22 +0000 (10:13 +0100)]
topology: change include path

Add support for relative (based on the path from the parsed
configuration file) and absolute include path without
ALSA_CONFIG_DIR environment variable usage. The dependency
on the alsa-lib config tree may be added on demand.

Link: https://github.com/alsa-project/alsa-utils/pull/117
Link: https://github.com/alsa-project/alsa-utils/issues/118
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotopology: pre-processor: Add support for conditional includes
Ranjani Sridharan [Mon, 6 Dec 2021 05:10:46 +0000 (21:10 -0800)]
topology: pre-processor: Add support for conditional includes

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>
3 years agotopology: Add option to pass pre-processor definitions
Ranjani Sridharan [Thu, 4 Nov 2021 19:17:24 +0000 (12:17 -0700)]
topology: Add option to pass pre-processor definitions

Add a -D switch to be able to pass pre-processor definitions that will
be used to expand arguments in the input config file. This will be
useful to generate multiple topology binaries from the same input config
file with different argument values.

For example: if we had a pipeline config as follows:

Object.Pipeline {
volume-playback.1 {
dynamic_pipeline $DYNAMIC_PIPELINE
}
}

We can define the variable for DYNAMIC_PIPELINE as:

Define {
DYNAMIC_PIPELINE 0
}

And when pre-processing the conf file pass "-D DYNAMIC_PIPELINE=1" to
override the default value for dynamic_pipeline attribute in the input
conf file.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsamixer: fix typo in man page (and/of -> and/or)
Jaroslav Kysela [Fri, 3 Dec 2021 13:55:03 +0000 (14:55 +0100)]
alsamixer: fix typo in man page (and/of -> and/or)

Fixes: https://github.com/alsa-project/alsa-utils/issues/110
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsa-info.sh: Fix alsa-usbstream.tmp test
Jaroslav Kysela [Fri, 3 Dec 2021 13:52:52 +0000 (14:52 +0100)]
alsa-info.sh: Fix alsa-usbstream.tmp test

Fixes: https://github.com/alsa-project/alsa-utils/issues/115
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsactl: fix the check for additional elements
Jaroslav Kysela [Fri, 3 Dec 2021 10:09:54 +0000 (11:09 +0100)]
alsactl: fix the check for additional elements

The driver may export only write-only elements. The previous
heuristics code do not handle this use case correctly.
Iterate through all elements and skip the write-only ones.

Fixes: https://github.com/alsa-project/alsa-utils/issues/122
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsaloop: Support "Playback Pitch 1000000" rate shift
Pavel Hofman [Sun, 24 Oct 2021 08:31:55 +0000 (10:31 +0200)]
alsaloop: Support "Playback Pitch 1000000" rate shift

Linux 5.15 will introduce a new control element "Playback Pitch 1000000"
(commit 6fec018 ("usb: gadget: u_audio.c: Adding Playback Pitch ctl for
sync playback") which provides feedback mechanism for playback direction
of USB Audio Gadget. The control operates in the same way as the
existing control element "Capture Pitch 1000000".

This patch adds support for this feature.

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsaloop: Renamed field capt_pitch to ctl_pitch
Pavel Hofman [Sun, 24 Oct 2021 08:31:54 +0000 (10:31 +0200)]
alsaloop: Renamed field capt_pitch to ctl_pitch

Renaming capt_pitch to ctl_pitch to respect the naming style of
snd_ctl_elem_value_t fields in loopback_handle. Also making the variable
name suitable for planned support of playback pitch.

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsactl: suppress no device 'errors' for UCM
Jaroslav Kysela [Thu, 28 Oct 2021 10:07:10 +0000 (12:07 +0200)]
alsactl: suppress no device 'errors' for UCM

This patch adds --ucm-nodev (or -X) option to get those
messages back. The code works only with library 1.2.6+.

By default, these messages are suppressed:

  alsactl[xxx]: alsa-lib parser.c:242:(error_node) UCM is not supported for this HDA model (HDA Intel PCH...)
  alsactl[xxx]: alsa-lib main.c:1405:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -6

Fixes: https://github.com/alsa-project/alsa-utils/issues/111
Link: https://lore.kernel.org/alsa-devel/20211027144008.27002-1-tiwai@suse.de/
Link: https://github.com/alsa-project/alsa-lib/commit/23198a72cd4f8f8759e650362b4adb485fc9fb12
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsamixer: Allow setting the default background color in config
Takashi Iwai [Wed, 20 Oct 2021 15:13:35 +0000 (17:13 +0200)]
alsamixer: Allow setting the default background color in config

The recent commit c867aa8a84a7 ("alsamixer: use background color
instead of COLOR_BLACK") changed the behavior of alsamixer to take the
system default background color instead of black.  This caused
problems on the terminal setups that have bright background colors,
e.g. yellow is very hard to read.

It could be "fixed" by setting up the color configurations in
~/.config/alsamixer.rc, but this needs to change the all colors in
every element, which is pretty cumbersome.  Instead, this patch
extends the config set command to allow user to specify the default
background color.  A user like me can create their own
~/.config/alsamixer.rc file containing the line

  set background black

and the old good black background is back again.

Note that, for achieving the above, we also had to shuffle the
function call order, to parse the config at first, then initialize
curses.  This shouldn't matter for other behavior.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoalsamixer: Check the availability of mouse
Takashi Iwai [Wed, 20 Oct 2021 13:39:13 +0000 (15:39 +0200)]
alsamixer: Check the availability of mouse

Let's check the availiabiy via has_mouse().  Otherwise the program
aborts unexpectedly just focusing on my rxvt terminal :-(

Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoalsaloop: fixed parsing value 'auto' of option 'sync'
Pavel Hofman [Wed, 13 Oct 2021 12:00:49 +0000 (14:00 +0200)]
alsaloop: fixed parsing value 'auto' of option 'sync'

The value 'auto' was not checked which resulted in using
SYNC_TYPE_NONE instead of SYNC_TYPE_AUTO.

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsaloop: added option prateshift for PLAYSHIFT ctl elem used in PLAYSHIFT
Pavel Hofman [Wed, 13 Oct 2021 10:33:43 +0000 (12:33 +0200)]
alsaloop: added option prateshift for PLAYSHIFT ctl elem used in PLAYSHIFT

If snd-aloop device is on playback side, the required sync mode is
PLAYSHIFT. That means Loopback ctl elem "PCM Rate Shift 100000" of the
corresponding capture side of the Loopback pipe must be controlled (by
a reciprocal).

ASCII name of the playback rate shift ctl elem is specified with newly
added option -x/--prateshift, e.g.:
  -P hw:Loopback,0 -S playshift \
  -x iface=PCM,name='PCM Rate Shift 100000',device=1

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoalsaloop: Adding openctl_elem debug log
Pavel Hofman [Fri, 1 Oct 2021 08:00:28 +0000 (10:00 +0200)]
alsaloop: Adding openctl_elem debug log

When debugging what ctl elem was found and opened (if any) a debug log is
helpful.

Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoamixer: print help and add doc for 'sevents' and 'events' commands
Jaroslav Kysela [Mon, 4 Oct 2021 08:40:07 +0000 (10:40 +0200)]
amixer: print help and add doc for 'sevents' and 'events' commands

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsatplg: use standard include/asoundlib.h instead direct headers
Jaroslav Kysela [Fri, 3 Sep 2021 06:49:01 +0000 (08:49 +0200)]
alsatplg: use standard include/asoundlib.h instead direct headers

BugLink: https://github.com/alsa-project/alsa-lib/pull/169
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoamidi: add timestamp option for dump
folkert van heusden [Tue, 24 Aug 2021 09:49:43 +0000 (11:49 +0200)]
amidi: add timestamp option for dump

Added -T / --timestamp option (with parameter "realtime", "monotonic" or "raw") which prints
a timestamp before each received message when using the --dump mode.

Fixes: https://github.com/alsa-project/alsa-utils/pull/108
Signed-off-by: Folkert van Heusden <mail@vanheusden.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoaplay: Fix out-of-bound access in stereo VU meter drawing
Takashi Iwai [Tue, 24 Aug 2021 08:06:05 +0000 (10:06 +0200)]
aplay: Fix out-of-bound access in stereo VU meter drawing

The left channel drawing of a stereo VU meter has a bug where it may
access a negative array index.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoaplay: Handle upper bound in peak calculations
Takashi Iwai [Tue, 24 Aug 2021 08:00:26 +0000 (10:00 +0200)]
aplay: Handle upper bound in peak calculations

Make sure that the calculated max_peak[] won't go beyond the sample
max resolution.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoaplay: Don't pass most negative integer to abs() in peak calculations
Takashi Iwai [Tue, 24 Aug 2021 07:58:29 +0000 (09:58 +0200)]
aplay: Don't pass most negative integer to abs() in peak calculations

The return value from abs() for the most negative integer is
undefined.  Cap it properly for the 32bit sample handling.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoaplay: Handle 16bit sample negative overflow in peak calculations
Takashi Iwai [Tue, 24 Aug 2021 07:36:33 +0000 (09:36 +0200)]
aplay: Handle 16bit sample negative overflow in peak calculations

The handling of 16bit samples in the peak calculations has a bug when
a sample with 0x8000 is passed.  As abs() treats 32bit int, it returns
0x8000.  And yet the code stores back into 16bit value again.

To fix that overflow, use 32bit value (i.e. val instead of sval) for
the further calculations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoaplay: Fix conversion of unsigned samples in peak calculation
Takashi Iwai [Tue, 24 Aug 2021 07:00:40 +0000 (09:00 +0200)]
aplay: Fix conversion of unsigned samples in peak calculation

The XOR with the mask has to be applied before calculating abs value.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
4 years agoalsaloop: Support "Capture Pitch 1000000" rate shift
Yunhao Tian [Tue, 27 Jul 2021 15:52:30 +0000 (23:52 +0800)]
alsaloop: Support "Capture Pitch 1000000" rate shift

In Linux 5.14, a new feedback mechanism for USB Audio
Gadget is introduced (commit e89bb428), along with a
new control element "Capture Pitch 1000000". This patch
adds support for this feature. Note that this property
seems to be the reverse of PCM Rate Shift, so we have
to take reciprocal of pitch.

Signed-off-by: Yunhao Tian <t123yh@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoAdded configuration information to manual page
braph [Wed, 7 Jul 2021 19:48:06 +0000 (21:48 +0200)]
Added configuration information to manual page

Added sections FILES and CONFIGURATION.
Removed section BUGS, because the described terminal issues have been fixed.

Signed-off-by: braph <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology:pre-process-object: merge object config with parent object config
Ranjani Sridharan [Tue, 15 Jun 2021 23:38:32 +0000 (16:38 -0700)]
topology:pre-process-object: merge object config with parent object config

An object can be declared within a class definition as follows:

Class.Pipeline.volume-playback {
Object.Widget.pga.0 {
ramp_step_ms 250
}
}

While instantiating the volume-pipeline class, the pga object
could be modified as follows:

Object.Pipeline.volume-playback.0 {
Object.Widget.pga.0 {
format "s24le"
}
}

When building the pga.0 object in the class definition, merge
the attributes declared in the volume-playback.0 object to create
a new config as follows to make sure that all attributes are
set for the pga object.

Object.Widget.pga.0 {
ramp_step_ms 250
                format "s24le"
        }

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopre-process-object: set tlv name if config exists already
Ranjani Sridharan [Tue, 15 Jun 2021 23:25:11 +0000 (16:25 -0700)]
pre-process-object: set tlv name if config exists already

Do not create TLV config if it exists already. Just
set the string value with the name name.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopre-process-dapm: add data section for kcontrols
Ranjani Sridharan [Tue, 15 Jun 2021 23:15:06 +0000 (16:15 -0700)]
pre-process-dapm: add data section for kcontrols

Allow support for adding data section for kcontrols.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-processor: fix typo in pre_process_config()
Ranjani Sridharan [Sun, 13 Jun 2021 19:58:35 +0000 (12:58 -0700)]
topology: pre-processor: fix typo in pre_process_config()

Fix typo in config variable name. Should be n2 instead of n.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: dont create if section already exists
Ranjani Sridharan [Sun, 13 Jun 2021 16:18:39 +0000 (09:18 -0700)]
topology: pre-process-object: dont create if section already exists

Skip creating section when it exists already.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopre-process-object: skip parent update if parent is NULL
Ranjani Sridharan [Sun, 13 Jun 2021 03:27:19 +0000 (20:27 -0700)]
pre-process-object: skip parent update if parent is NULL

Nothing to do for top-level objects with no parent.
Also, add access to the bytes control template.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agopre-process-dapm: fix source and sink for DAPM routes
Ranjani Sridharan [Sun, 13 Jun 2021 03:24:15 +0000 (20:24 -0700)]
pre-process-dapm: fix source and sink for DAPM routes

Switch source and sink widgets in the DAPM route.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: Add support for pre-process objects with no builder
Ranjani Sridharan [Fri, 11 Jun 2021 06:51:58 +0000 (23:51 -0700)]
topology: pre-process-object: Add support for pre-process objects with no builder

Some objects just need tobe processed to add their attributes
to the private data section of their parent objects.
An example of this would be the pdm_config objects for
DMIC DAI's. Each pdm_config object's attributes need
to be added as separate arrays in the DAI object's
private data.

Modify the signature of tplg_add_object_data() to pass
the array_name parameter when multiple objects of the
same type in the same parent are processed.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dapm: update automatic attributes for buffer
Chao Song [Wed, 2 Jun 2021 05:59:53 +0000 (13:59 +0800)]
topology: pre-process-dapm: update automatic attributes for buffer

Add the function to compute the value for the
"size" automatic attribute in the buffer objects.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: add support for updating automatic attributes
Chao Song [Wed, 2 Jun 2021 05:20:49 +0000 (13:20 +0800)]
topology: pre-process-object: add support for updating automatic attributes

Classes definitions in Topology2.0 can have attributes
qualified with the "automatic" constraint. Values for
these attributes will be calculated by the compiler.
This patch provides a generic method for defining automatic
attributes computation logic for different classes.

To update automatic attributes for a class, add an item
in object_build_map with auto_attr_updater defined, and then
add updating logic in the custom auto_attr_updater function.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoaseqnet: add ipv6 support
Jaroslav Kysela [Mon, 9 Aug 2021 18:24:44 +0000 (20:24 +0200)]
aseqnet: add ipv6 support

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoaseqnet: use getaddrinfo() instead obsolete gethostbyname()
Jaroslav Kysela [Mon, 9 Aug 2021 16:10:56 +0000 (18:10 +0200)]
aseqnet: use getaddrinfo() instead obsolete gethostbyname()

- modernize code (preparation for IPv6)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsatplg: do not do NULL check for string arrays
Jaroslav Kysela [Fri, 18 Jun 2021 08:15:46 +0000 (10:15 +0200)]
alsatplg: do not do NULL check for string arrays

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsatplg: fix memory-leak in tplg_construct_object_name()
Jaroslav Kysela [Fri, 18 Jun 2021 08:11:34 +0000 (10:11 +0200)]
alsatplg: fix memory-leak in tplg_construct_object_name()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoRelease v1.2.5.1 v1.2.5.1
Jaroslav Kysela [Mon, 14 Jun 2021 10:28:46 +0000 (12:28 +0200)]
Release v1.2.5.1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoarecord: Inform users when 8-bit sampling is used on tty
Jaroslav Kysela [Mon, 14 Jun 2021 10:22:08 +0000 (12:22 +0200)]
arecord: Inform users when 8-bit sampling is used on tty

When we reverted 0c5948e ("aplay: try to use 16-bit format to
increase capture quality"), we should also handle the original
problem somehow. This code shows a warning with a hint to
the right parameter.

Fixes: https://github.com/alsa-project/alsa-utils/issues/96
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoRevert "aplay: try to use 16-bit format to increase capture quality"
Jaroslav Kysela [Mon, 14 Jun 2021 10:02:35 +0000 (12:02 +0200)]
Revert "aplay: try to use 16-bit format to increase capture quality"

This reverts commit 0c5948e98a6a8535c89b7bcab13017d7732181c6.

Link: https://github.com/alsa-project/alsa-utils/issues/96
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoadded an option to aseqnet to optionally set the midi process name
Andrea Piras [Fri, 29 Nov 2019 02:13:21 +0000 (03:13 +0100)]
added an option to aseqnet to optionally set the midi process name

This option allows to run multiple instances of aseqnet without having
to double check the assigned port number, since each one can get spawned
with a unique name.

Fixes: https://github.com/alsa-project/alsa-utils/pull/95
Signed-off-by: Andrea Piras <andrea.piras.85@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoutils.c: Include limits.h explicitly to fix build on musl
Andreas Müller [Thu, 3 Jun 2021 14:07:10 +0000 (16:07 +0200)]
utils.c: Include limits.h explicitly to fix build on musl

Fixes:
| ../../alsa-utils-1.2.5/alsactl/utils.c: In function 'snd_card_clean_cfgdir':
| ../../alsa-utils-1.2.5/alsactl/utils.c:309:19: error: 'PATH_MAX' undeclared (first use in this function)
|   309 |         char path[PATH_MAX];
|       |                   ^~~~~~~~
| ../../alsa-utils-1.2.5/alsactl/utils.c:309:19: note: each undeclared identifier is reported only once for each function it appears in

Fixes: https://github.com/alsa-project/alsa-utils/pull/92
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsactl: load_state: Only delete config if one was loaded
Sören Tempel [Sun, 6 Jun 2021 01:14:19 +0000 (03:14 +0200)]
alsactl: load_state: Only delete config if one was loaded

If load_configuration fails with open_failed == true, load_state will
jump to the out label without config being initialized and pass this
uninitialized config value to snd_config_delete. This commit fixes this
issue by initializing config with NULL and checking if it is non-null
before invoking snd_config_delete.

Fixes: https://github.com/alsa-project/alsa-utils/pull/94
Fixes: f138117 ("alsactl: load_state() - initialize config variable for the open_failed case")
BugLink: https://github.com/alsa-project/alsa-utils/issues/93
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsactl: load_state() - initialize config variable for the open_failed case
Jaroslav Kysela [Mon, 7 Jun 2021 15:21:56 +0000 (17:21 +0200)]
alsactl: load_state() - initialize config variable for the open_failed case

Fixes: https://github.com/alsa-project/alsa-utils/issues/93
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: fix few coverity detected defects
Jaroslav Kysela [Fri, 4 Jun 2021 08:19:22 +0000 (10:19 +0200)]
topology: fix few coverity detected defects

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoaxfer: fix wrong calloc() item size in allocate_containers()
Jaroslav Kysela [Fri, 4 Jun 2021 08:12:06 +0000 (10:12 +0200)]
axfer: fix wrong calloc() item size in allocate_containers()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsactl: fix lock_fd unlock in load_configuration() - error path
Jaroslav Kysela [Fri, 4 Jun 2021 08:08:18 +0000 (10:08 +0200)]
alsactl: fix lock_fd unlock in load_configuration() - error path

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsactl: state - fix ‘item’ may be used uninitialized gcc warning
Jaroslav Kysela [Fri, 4 Jun 2021 08:04:50 +0000 (10:04 +0200)]
alsactl: state - fix â€˜item’ may be used uninitialized gcc warning

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsactl: check for error values from snd_config_get...()
Jaroslav Kysela [Fri, 4 Jun 2021 07:58:46 +0000 (09:58 +0200)]
alsactl: check for error values from snd_config_get...()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsactl: init() - return error value from snd_card_iterator_sinit() call
Jaroslav Kysela [Fri, 4 Jun 2021 07:56:20 +0000 (09:56 +0200)]
alsactl: init() - return error value from snd_card_iterator_sinit() call

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsactl: return error value in dump_config_tree()
Jaroslav Kysela [Fri, 4 Jun 2021 07:53:56 +0000 (09:53 +0200)]
alsactl: return error value in dump_config_tree()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: fix potential null pointer from strchr
Chao Song [Mon, 31 May 2021 02:29:57 +0000 (10:29 +0800)]
topology: fix potential null pointer from strchr

This patch adds check to the return pointer from strchr,
because it may be null and cause segment fault, if component
is not properly constructed.

Fixes: https://github.com/alsa-project/alsa-utils/pull/91
Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoalsactl: fix the nested iteration
Jaroslav Kysela [Tue, 1 Jun 2021 15:47:42 +0000 (17:47 +0200)]
alsactl: fix the nested iteration

There may be nested iterations for hw: card names.
Handle this card name in snd_card_iterator_sinit().

BugLink: https://github.com/alsa-project/alsa-lib/issues/142
Fixes: eefc2c6 ("alsactl: use card iterator functions for all card loops")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoRelease v1.2.5 v1.2.5
Jaroslav Kysela [Thu, 27 May 2021 17:18:36 +0000 (19:18 +0200)]
Release v1.2.5

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoamixer: Makefile - add volume_mapping.h to noinst_HEADERS
Jaroslav Kysela [Tue, 25 May 2021 16:58:34 +0000 (18:58 +0200)]
amixer: Makefile - add volume_mapping.h to noinst_HEADERS

Fixes: dc20c4b ("amixer: add the volume_mapping.h link")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agoamixer: add the volume_mapping.h link
Jaroslav Kysela [Tue, 25 May 2021 16:47:57 +0000 (18:47 +0200)]
amixer: add the volume_mapping.h link

Fixes: 75e644d ("amixer: link volume_mapping.c from alsamixer to amixer")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: some whitespace fixups
Jaroslav Kysela [Tue, 25 May 2021 16:28:00 +0000 (18:28 +0200)]
topology: some whitespace fixups

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: add support for prepocessing child objects
Ranjani Sridharan [Wed, 21 Apr 2021 18:18:04 +0000 (11:18 -0700)]
topology: pre-process-object: add support for prepocessing child objects

Add support for processing object instances embedded
within objects and classes. For example:
Object.Control.mixer."0" {
#Channel register and shift for Front Left/Right
Object.Base.channel."fl" {
shift 0
}
Object.Base.channel."fr" {
}

Object.Base.tlv."vtlv_m64s2" {
Object.Base.scale."m64s2" {
mute 1
}
}

Object.Base.ops."ctl" {
info  "volsw"
#256 binds the mixer control to volume get/put handlers
get  256
put  256
}
}

and pga class embeds the mixer objects as follows:
Class.Widget."pga" {
...
Object.Control {
mixer."0" {...}
mixer."1" {...}
}

The pre-processor starts with the top-pevel PGA widget object
and processes the mixer objects in the class definition.
This will recursively pre-processes its child objects to add the channels,
tlv and ops.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dai: add support for pcm_caps objects
Ranjani Sridharan [Mon, 26 Apr 2021 20:34:26 +0000 (13:34 -0700)]
topology: pre-process-dai: add support for pcm_caps objects

Add support for processing pcm_caps objects.
For ex:

Object.PCM.pcm."0" {
name "Port0"
direction "duplex"
Object.Base.fe_dai."Port 0" {}
Object.PCM.pcm_caps."playback" {
name "Port0 Playback"
}
Object.PCM.pcm_caps."capture" {
name "Port0 Capture"
}
}

Would convert into:
SectionPCMCapabilities {
        'Port0 Playback' {
                formats 'S32_LE,S24_LE,S16_LE'
                rate_min 48000
                rate_max 48000
                channels_min 2
                channels_max 2
                periods_min 2
                periods_max 16
                period_size_min 192
                period_size_max 16384
                buffer_size_min 65536
                buffer_size_max 65536
        }
        'Port0 Capture' {
                formats 'S32_LE,S24_LE,S16_LE'
                rate_min 48000
                rate_max 48000
                channels_min 2
                channels_max 2
                periods_min 2
                periods_max 16
                period_size_min 192
                period_size_max 16384
                buffer_size_min 65536
                buffer_size_max 65536
        }
}

and the SectionPCM updated as follows:
SectionPCM {
        Port0 {
                id 0
                dai {
                        'Port 0' {
                                id 0
                        }
                }
                pcm {
                        playback {
                                capabilities 'Port0 Playback'
                        }
                        capture {
                                capabilities 'Port0 Capture'
                        }
                }
        }
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dai: add support for fe_dai objects
Ranjani Sridharan [Mon, 26 Apr 2021 20:31:00 +0000 (13:31 -0700)]
topology: pre-process-dai: add support for fe_dai objects

Add support for fe_dai objects:

For ex:

Object.PCM.pcm."0" {
name "Port0"
direction "duplex"
Object.Base.fe_dai."Port 0" {}
}

will be converted to update the SectionPCM as follows:

SectionPCM {
        Port0 {
                id 0
                dai {
                        'Port 0' {
id 0
}
                }
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dai: add support for hwcfg objects
Ranjani Sridharan [Mon, 26 Apr 2021 20:26:08 +0000 (13:26 -0700)]
topology: pre-process-dai: add support for hwcfg objects

Add supprt for hwcfg objects:
For ex:
Object.Base.hw_config."SSP0 hw_config 0" {
id 0
mclk_freq 24000000
bclk_freq 4800000
tdm_slot_width 25
}

would get converted to:

SectionHWConfig {
        'SSP0 hw_config 0' {
                id 0
                format I2S
                bclk codec_consumer
                bclk_freq 4800000
                fsync codec_consumer
                fsync_freq 48000
                mclk codec_mclk_in
                mclk_freq 24000000
                tdm_slots 2
                tdm_slot_width 25
                tx_slots 3
                rx_slots 3
        }
}

and the corresponding SectionBE will be updated with the hwcfgs reference as:

hw_configs [
'SSP0 hw_config 0'
        ]

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dai: add support for PCM and BE DAI objects
Ranjani Sridharan [Mon, 26 Apr 2021 20:12:43 +0000 (13:12 -0700)]
topology: pre-process-dai: add support for PCM and BE DAI objects

Add support for pre-processing PCM and BE DAI objects:

Object.PCM.pcm."0" {
name "Port0"
direction "duplex"
}

will be converted to:

SectionPCM.'Port0' {}

The capabilities and dai configs will be added those objects are pre-processed.

An ex of DAI object would be:
Object.Dai.SSP."0" {
direction "duplex"
stream_name "NoCodec-0"
id  0
default_hw_conf_id 0
format "s24le"
quirks "lbm_mode"
sample_bits 24
}

converted to:
SectionBE {
        'SSP.0.duplex' {
                id 0
                stream_name NoCodec-0
                default_hw_conf_id 0
                data [
                        'SSP.0.duplex.sof_tkn_intel_ssp.word'
                        'SSP.0.duplex.sof_tkn_dai.word'
                        'SSP.0.duplex.sof_tkn_dai.string'
                        'SSP.0.duplex.sof_tkn_intel_ssp.short'
                ]
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dapm: add support for route objects
Ranjani Sridharan [Mon, 26 Apr 2021 20:07:00 +0000 (13:07 -0700)]
topology: pre-process-dapm: add support for route objects

DAPM route objects such as:
Object.Base.route."1" {
source "dai.SSP.0.dai.capture"
sink "buffer.2.1"
}

will be converted to:

SectionGraph."Endpoint.route.1" {
index 0
lines [
"dai.SSP.0.capture, , buffer.2.1"
]
}

If the source/sink names are references to objects within a parent pipeline
object, the index attribute value can be skipped and it will be
populated when the object is pre-processed

Object.Pipeline.volume-capture."1" {
Object.Base.route."1" {
source "pga..0"
sink "buffer..0"
}
}

The reference pga..0 will need to be resolved to
get the widget name pga.1.0 and buffer..0 will
be resolved to buffer.1.0 before creating the SectionGraph as follows:

SectionGraph."volume-capture.1.route.1" {
index 2
lines [
"pga.1.0, , buffer.1.0"
]
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dapm: add support for widget control objects
Ranjani Sridharan [Mon, 26 Apr 2021 20:03:57 +0000 (13:03 -0700)]
topology: pre-process-dapm: add support for widget control objects

Add support for pre-processing mixer and byte control objects.
For ex: a pga widget with a mixer control as follows:

Object.pga"0" {
...
mixer.0 {
index 2
max 32
name "2 MasterPlaybackControl"
Object.Base.channel."fl" {
shift 0
}
Object.Base.channel."fr" {
}

Object.Base.tlv."vtlv_m64s2" {
Object.Base.scale."m64s2" {
mute 1
}
}

Object.Base.ops."ctl" {
info  "volsw"
#256 binds the mixer control to volume get/put handlers
get  256
put  256
}

access [
read_write
tlv_read
]
}
}

Would be converted to:

SectionControlMixer.'2 Master Playback Volume' {
index 2
max 32
channel {
fl {
reg 1
}
fr {
reg 1
shift 1
}
}
tlv "vtlv_m64s2"
ops.0 {
info volsw
get 256
put 256
}
access [
read_write
tlv_read
]
}

and the SectionWidget for pga.2.0 would be updated to add the mixer references as follows:
SectionWidget.'pga.2.0' {
...
mixer [
"2 Master Playback Volume"
]
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dapm: add support for scale/ops/channel objects
Ranjani Sridharan [Mon, 26 Apr 2021 19:55:26 +0000 (12:55 -0700)]
topology: pre-process-dapm: add support for scale/ops/channel objects

Add support for pre-processing scale/ops/channel objects
and adding the converted config to the relevant sections.

For ex:
Object.Base.channel."fl" {
shift 0
reg 1
}
Object.Base.channel."fr" {
reg 1
shift 1
}

Will be converted to:

channel {
fl {
reg 1
shift 0
}
fr {
reg 1
shift 1
}
}

And added to the SectionControlMixer that this object belongs to.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dapm: Add support for tlv objects
Ranjani Sridharan [Mon, 26 Apr 2021 19:49:51 +0000 (12:49 -0700)]
topology: pre-process-dapm: Add support for tlv objects

Add support for pre-processing TLV objects
For example:

Object.Base.tlv."vtlv_m64s2" {}

will be converted to:

SectionTLV.'vtlv_m64s2' {}

And the mixer controle section will be updated to add
the reference to the tlv object.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-dapm: Add support for DAPM Widget objects
Ranjani Sridharan [Mon, 26 Apr 2021 19:45:01 +0000 (12:45 -0700)]
topology: pre-process-dapm: Add support for DAPM Widget objects

Add support for pre-processing DAPM widget opbects.
For ex:

Object.Widget.pga."0" {
        pipeline_id     1
no_pm true
type pga
}

will be converted to:

SectionWidget.'pga.0' {
index 1
type pga
no_pm 1
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-base: add support for VendorToken objects
Ranjani Sridharan [Mon, 26 Apr 2021 18:55:22 +0000 (11:55 -0700)]
topology: pre-process-base: add support for VendorToken objects

Add support for pre-processing VendorToken objects.
For ex:
Object.Base.VendorToken."sof_tkn_dai" {
dmac_config 153
dai_type 154
index 155
direction 156
}

would be converted to:

SectionVendorTokens."sof_tkn_dai" {
dmac_config 153
dai_type 154
index 155
direction 156
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: Add support for data objects
Ranjani Sridharan [Mon, 26 Apr 2021 18:48:43 +0000 (11:48 -0700)]
topology: pre-process-object: Add support for data objects

Pre-process data objects, create the SectionData and update
the parent object with the reference to the object.
For example, the following object instance:

Object.Base.data."SOF_ABI" {
bytes "0x03,0x12,0x01"
}

would update the SectionManifest as follows:
SectionManifest."sof_manifest" {
data [
"SOF_ABI"
]
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-obejct: add helper function to get the section config
Ranjani Sridharan [Mon, 26 Apr 2021 18:33:12 +0000 (11:33 -0700)]
topology: pre-process-obejct: add helper function to get the section config

Add a helper function to retrieve the config node
pointing to the section name for a given object.
For ex: for the object, Object.Widget.pga.1{},
the function returns the config with id, "SectionWidget"
in the output config.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: add data section for attributes with token reference
Ranjani Sridharan [Mon, 26 Apr 2021 18:30:07 +0000 (11:30 -0700)]
topology: pre-process-object: add data section for attributes with token reference

Objects that have attributes with token_ref need
to have separate SectionData and SectionVendorTuples
for each unique token_ref based on the attribute_sets
in the object's attribute_set_list.

Add the tplg_pp_add_object_data()
function to add the data[] refs in the object and also
the respective SectionData and SectionVendorTuples.

For example for the pga object:

Object.Widget.pga."0" {
pipeline_id 2
format s24le
type pga
no_pm 1
uuid    "7e:67:7e:b7:f4:5f:88:41:af:14:fb:a8:bd:bf:8"
period_sink_count 2
period_source_count 2
ramp_step_ms 250
        ramp_step_type "linear"
mixer.0 {
....
}
mixer.0.name "2 Master Playback Volume"
}

The following sections will be added:
SectionWidget.'pga.2.0' {
index 2
type pga
no_pm 1
mixer [
"2 Master Playback Volume"
]
bytes [
]
data [
"pga.2.0.sof_tkn_comp.word"
"pga.2.0.sof_tkn_comp.string"
"pga.2.0.sof_tkn_comp.uuid"
"pga.2.0.sof_tkn_volume.word"
]
}

SectionData."pga.2.0.sof_tkn_comp.word" {
tuples "pga.2.0.sof_tkn_comp.word"
}

SectionData."pga.2.0.sof_tkn_comp.string" {
tuples "pga.2.0.sof_tkn_comp.string"
}

SectionData."pga.2.0.sof_tkn_comp.uuid" {
tuples "pga.2.0.sof_tkn_comp.uuid"
}

SectionData."pga.2.0.sof_tkn_volume.word" {
tuples "pga.2.0.sof_tkn_volume.word"
}

SectionVendorTuples."pga.2.0.sof_tkn_comp.word" {
tokens "sof_tkn_comp"
tuples."word" {
period_source_count "2"
period_sink_count "2"
}
}

SectionVendorTuples."pga.2.0.sof_tkn_comp.string" {
tokens "sof_tkn_comp"
tuples."string" {
format "s24le"
}
}

SectionVendorTuples."pga.2.0.sof_tkn_comp.uuid" {
tokens "sof_tkn_comp"
tuples."uuid" {
uuid "7e:67:7e:b7:f4:5f:88:41:af:14:fb:a8:bd:bf:8"
}
}

SectionVendorTuples."pga.2.0.sof_tkn_volume.word" {
tokens "sof_tkn_volume"
tuples."word" {
ramp_step_ms "250"
ramp_step_type "0"
}
}

Note that the ramp_step_type of "linear" is converted
to the tuple value 0.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: Add support for processing Manifest object
Ranjani Sridharan [Mon, 26 Apr 2021 18:19:31 +0000 (11:19 -0700)]
topology: pre-process-object: Add support for processing Manifest object

The pre-processor converts the Topology2.0 objects into
the relevant sections by looking for attributes defined
in the template config for the section and reading the
attribute values from the object instance config.

The structure struct build_function_map contains the
mapping of the build function to use for each object
based on the type and name for the class that the object
belongs to. The manifest object is the simplest with
no attributes. So, the build function simply creates
a new Section called SectionManifest which will be
populated with the data section in the following patches.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: construct object name from its constructor attributes
Ranjani Sridharan [Mon, 26 Apr 2021 17:10:03 +0000 (10:10 -0700)]
topology: pre-process-object: construct object name from its constructor attributes

An object's name is derived from its constructor attribute
values separated by '.'. For example, the name for the
host widget objects is derived from its index and direction
attribute values as follows:
Object.Widget.host."playback" {
index 2
}

The name for the host widget object would be host.2.playback.

Alternatively, if the object has a name attribute, the class
definition may skip the constructor attributes and the name attribute
value will be used instead.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: check attribute validity
Ranjani Sridharan [Mon, 26 Apr 2021 17:04:54 +0000 (10:04 -0700)]
topology: pre-process-object: check attribute validity

Attributes can have constraints set for valid values, min
or max values. If the attribute value is set in an object,
the value must be validated against the set constraints.

An example for attribute constraint would be:
DefineAttribute."direction" {
constraints {
valid_values [
"playback"
"capture"
]
tuple_values [
0
1
]
}
}

where the tuple_values array would translate the valid_values of
playback as 0 and capture as 1.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology/pre-process-object: update object config with attributes
Ranjani Sridharan [Mon, 26 Apr 2021 16:58:44 +0000 (09:58 -0700)]
topology/pre-process-object: update object config with attributes

Object attributes can be set in multiple places. Search for
the attribute value in the following order:
1. Value set in object instance
2. Default value set in the object's class definition
3. Inherited value from the parent object
4. Value set in the object instance embedded in the parent object
5. Value set in the object instance embedded in the parent class definition

Mandatory attributes must be found in one of the above, resulting
in an error if not found.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-object: Add support for pre-processing Objects
Ranjani Sridharan [Mon, 26 Apr 2021 16:34:48 +0000 (09:34 -0700)]
topology: pre-process-object: Add support for pre-processing Objects

Add support for pre-processing object instances in the input
config. An object's attributes can be set in multiple places
such as, within the object instance, default values in the class
defnition, inherited from a parent object or explicitly set
in a parent object. Before converting the object config into
the relevant section in the existing syntax, all the attribute
values must be consolidated into one place so that it is easy
to verify if all mandatory attributes are set.
Also, the name of the object will be constructed from the
attributes defined in the attributes.constructor[] config
in the class definition and the unique attribute's value
must be set from the value passed in the object instance.

This patch create a temporary config for each object instance
and populates its unique attribute value. The rest of the steps
will be added in the following patches.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-class: add function to convert valid attribute values to intege...
Ranjani Sridharan [Fri, 23 Apr 2021 20:46:24 +0000 (13:46 -0700)]
topology: pre-process-class: add function to convert valid attribute values to integer tuple values

Some attributes have valid values that need to be converted
to integer tuple values before it is appended to the
object's private data:

For ex, the buffer widget object's "caps" attribute has the
following definition:
DefineAttribute."caps" {
type "string"
# Token reference and type
token_ref "sof_tkn_buffer.word"
constraints {
value_ref "sof_tkn_mem"
valid_values [
"dai"
"host"
"pass"
"comp"
]
tuple_values [
113
113
113
65
]
}
}

Depending on the user input, the value string values for "caps"
will be converted to the appropriate tuple values.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-class: add function to look up token_ref for an attribute in...
Ranjani Sridharan [Fri, 23 Apr 2021 20:41:45 +0000 (13:41 -0700)]
topology: pre-process-class: add function to look up token_ref for an attribute in class

Some attributes may have the token_ref set which is
used to look up the token value for the tuple data
that is appended to the object's private data.

For example, in the buffer widget object:
DefineAttribute."size" {
# Token reference and type
token_ref "sof_tkn_buffer.word"
}

The token_ref must include the reference to the vendor
token object name followed by the type of the tuple.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-class: function to get attribute type
Ranjani Sridharan [Fri, 23 Apr 2021 20:36:48 +0000 (13:36 -0700)]
topology: pre-process-class: function to get attribute type

Add a helper function to get attribute type from the
attribute definition and convert them to SND_CONFIG_TYPE_*
values. When no type if provided for an attribute, type
defaults to integer.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
4 years agotopology: pre-process-class: add funcion to get the name of the unique attribute...
Ranjani Sridharan [Fri, 23 Apr 2021 20:32:26 +0000 (13:32 -0700)]
topology: pre-process-class: add funcion to get the name of the unique attribute in a class

Every class must have a unique attribute that will be used
to instantiate the object. The value provided for this
attribute must be unique within the same alsaconf node for
objects of the same class. Add a helper function to get the
name of the attribute that must have a unique value in the
object instance.

For example, when instantiating 2 buffer widgets within a pipeline,
they must be given unique instance attribute values as:
Object.Widget.buffer.0{} and Object.Widget.buffer.1{}.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>