Commit graph

1779 commits

Author SHA1 Message Date
Ranjani Sridharan
c47188f258 topology: pre-process-object: expand variables before validating attributes
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>
2022-01-27 18:32:06 +01:00
Jaroslav Kysela
1f1cbab235 speaker-test: remove sample_map.csv from Makefile
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-27 18:29:05 +01:00
Jaroslav Kysela
5a7ffd5171 topology: rename function free_pre_preprocessor to free_pre_processor
Line up this name with others.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-27 15:02:02 +01:00
Jaroslav Kysela
3c665532e0 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>
2022-01-27 14:58:58 +01:00
Jaroslav Kysela
6723b5d413 topology: merge the pre-processor call to one function
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-27 14:33:20 +01:00
Jaroslav Kysela
e1a0711329 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>
2022-01-27 14:16:38 +01:00
Alex Xu (Hello71)
d05ac4a078 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>
2022-01-27 13:22:38 +01:00
Jaroslav Kysela
8adbb2c275 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>
2022-01-27 13:19:36 +01:00
Jaroslav Kysela
90e1fd964b 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>
2022-01-27 13:16:37 +01:00
Jaroslav Kysela
84173ff9e3 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>
2022-01-27 13:04:01 +01:00
Takashi Iwai
40202a522a 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>
2022-01-20 08:58:48 +01:00
Jaroslav Kysela
fca9d89bbc alsactl: fix the error path in set_controls()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-01-03 16:14:31 +01:00
Ranjani Sridharan
90f5967178 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>
2021-12-19 20:32:38 +01:00
Jaroslav Kysela
8e71fba810 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>
2021-12-12 19:58:54 +01:00
Jaroslav Kysela
c8c348e28a 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>
2021-12-08 09:56:38 +01:00
Ranjani Sridharan
79f8ae46b6 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>
2021-12-08 09:56:25 +01:00
Jaroslav Kysela
7692cfa0c5 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>
2021-12-07 09:39:28 +01:00
Jaroslav Kysela
e18913110b Release v1.2.6
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-12-06 11:17:28 +01:00
Jaroslav Kysela
52f5bea5e9 amidi: remove unused variable
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-12-06 11:02:10 +01:00
Jaroslav Kysela
15a5a16eb7 topology: fix compilation for older alsa-lib
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-12-06 11:00:02 +01:00
Jaroslav Kysela
66693b1a77 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>
2021-12-06 10:21:41 +01:00
Ranjani Sridharan
ef3a96367e 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>
2021-12-06 09:19:20 +01:00
Ranjani Sridharan
da8f90c424 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>
2021-12-06 09:19:20 +01:00
Jaroslav Kysela
c4e43384fc 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>
2021-12-03 14:55:07 +01:00
Jaroslav Kysela
c6a9e53ca0 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>
2021-12-03 14:52:52 +01:00
Jaroslav Kysela
257f3063fa 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>
2021-12-03 11:09:57 +01:00
Pavel Hofman
3b1b6863e7 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>
2021-10-28 12:32:37 +02:00
Pavel Hofman
59464effec 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>
2021-10-28 12:32:22 +02:00
Jaroslav Kysela
af62c72e2d 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: 23198a72cd
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 12:16:11 +02:00
Takashi Iwai
5d4442b2cf alsamixer: Allow setting the default background color in config
The recent commit c867aa8a84 ("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>
2021-10-20 17:24:35 +02:00
Takashi Iwai
31820c5f23 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>
2021-10-20 17:24:30 +02:00
Pavel Hofman
0fd3022e82 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>
2021-10-13 14:05:02 +02:00
Pavel Hofman
138e53aabb 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>
2021-10-13 13:52:12 +02:00
Pavel Hofman
e2b167c490 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>
2021-10-04 10:44:46 +02:00
Jaroslav Kysela
68473a41c6 amixer: print help and add doc for 'sevents' and 'events' commands
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-04 10:40:14 +02:00
Jaroslav Kysela
1a32420577 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>
2021-09-03 08:49:03 +02:00
folkert van heusden
9a8fcec5aa 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>
2021-08-24 12:05:52 +02:00
Takashi Iwai
dea51861a8 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>
2021-08-24 10:06:05 +02:00
Takashi Iwai
2efe124c31 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>
2021-08-24 10:00:26 +02:00
Takashi Iwai
d9b3133815 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>
2021-08-24 09:58:29 +02:00
Takashi Iwai
5c4bf63a94 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>
2021-08-24 09:53:53 +02:00
Takashi Iwai
0ea7bfea83 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>
2021-08-24 09:51:39 +02:00
Yunhao Tian
ce05208085 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>
2021-08-23 16:55:36 +02:00
braph
2b9bfacca7 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>
2021-08-23 16:50:47 +02:00
Ranjani Sridharan
a1c2275090 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>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
814dc3b19e 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>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
b13a940618 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>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
3d55a99ccd 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>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
c1f0ec46b4 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>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
3c81766242 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>
2021-08-23 16:49:56 +02:00