Commit graph

342 commits

Author SHA1 Message Date
Jaroslav Kysela
66dfd40e8f ucm: add ValueGlobals section to the top configuration file
BootCardGroup and BootCardSyncTime variables should not be listed
by default in _identifiers. Handle them differently using
ValueGlobals section.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-12-04 12:11:41 +01:00
Jaroslav Kysela
5ed27d8e89 ucm: fix the DefineRegex issue where multiple variables were set to empty string
It is not required to set variables in undefined groups to empty string.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-12-04 12:11:41 +01:00
Jaroslav Kysela
ae921dc1c9 ucm: Include directive - add optional behaviour
It may be useful to skip the include when the file does not exist
(make it optional).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-12-04 12:11:41 +01:00
Jaroslav Kysela
22f8716af9 ucm: complete dependency graphs for conflicting/supported device lists
Modify verb_dev_list_check() to ensure all devices in a conflicting or
supported group reference each other. Previously, the function only
ensured bidirectional relationships. Now it ensures all devices in
the same group have complete dependency lists.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-12-04 12:11:41 +01:00
Jaroslav Kysela
3149ca0f1c ucm: implement DeviceVariant configuration extension
It may be useful for the channel count specification for example.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-12-04 12:11:41 +01:00
Jaroslav Kysela
554efca497 ucm: implement ValueDefaults.BootCardGroup and define use
We need a boot synchronization for multiple UCM cards where linking
is expected like AMD ACP or Intel AVS drivers. This method is
using a timestamp file which can be created and modified during
the boot process (e.g. from the alsactl tool).

The goal is to return a valid UCM configuration for standard
applications combining multiple ALSA cards into one UCM configuration
and cover the time window when all cards have not been probed yet.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-12-04 12:11:26 +01:00
Jaroslav Kysela
5c4a683bd0 ucm: keep original device name for logs
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-12-01 14:28:52 +01:00
Jaroslav Kysela
b3e4b15583 ucm: sort devices by priority
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-12-01 14:28:43 +01:00
Jaroslav Kysela
fd719bb122 ucm: doc - add examples for device name with descriptors (colon)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-18 14:01:29 +01:00
Jaroslav Kysela
2da7e29c0c ucm: be more restrictive for device name with descriptor
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-18 14:00:48 +01:00
Jaroslav Kysela
e83fd7806f ucm: strip device index when the device type is present only one time
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-18 13:37:26 +01:00
Jaroslav Kysela
48c477569d ucm: add support for device names with colon (':')
The colon identifier means to automatically assign
a device index for this device.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-18 13:37:09 +01:00
Jaroslav Kysela
07532ae8a8 ucm: normalize device names
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-18 13:37:08 +01:00
Jaroslav Kysela
9e933a08ed ucm: add possibility to inline Verb configurations to the main configuration file
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-17 18:36:32 +01:00
Jaroslav Kysela
a8620e814b ucm: add Prepend and Append block handling for If conditions (syntax 8+)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-17 18:01:14 +01:00
Jaroslav Kysela
47f4f9b73b coverity.com fixes - initial round
This commit tries to fix a bunch of issues found
by coverity.com.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-12 15:36:29 +01:00
Jaroslav Kysela
a9465869a7 add missing return value changes for snd_config_get_string() calls
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
2025-11-12 15:36:29 +01:00
Jaroslav Kysela
ea0a075c40 ucm: add missing stdbool.h include to ucm_local.h
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-07 21:51:43 +01:00
Jaroslav Kysela
bd0ce670c2 ucm: fix variant issue where variables or macros are overwritten
It is necessary to reset the state logic before each verb variant
is parsed. So save the original variable list and macros and
restore them before each parser iteration.

BugLink: https://github.com/alsa-project/alsa-ucm-conf/pull/633
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-07 18:09:26 +01:00
Jaroslav Kysela
f6dce4f9d0 ucm: remove 'error: ' prefix from error messages (duplication)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-07 18:09:26 +01:00
Jaroslav Kysela
0432be98f9 ucm: remove uc_dbg macro and callers
Those debug prints are not much useful now.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-07 18:09:26 +01:00
Jaroslav Kysela
9ab488b86c ucm: replace uc_error with snd_error calls
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-07 18:09:26 +01:00
Jaroslav Kysela
11235095bf ucm: add a basic set of trace/debug log calls
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-07 18:09:26 +01:00
Jaroslav Kysela
66a3d542ac huge correction of tabulators and whitespaces
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-11-07 18:09:26 +01:00
Jochen Sprickerhof
782b0597c2 ucm: use close_range on _GNU_SOURCE
Closes: https://github.com/alsa-project/alsa-lib/pull/459
Signed-off-by: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-07-31 15:30:51 +02:00
wyjstrong
4ad4d9590a Force to use alphasort64() sorting function for Harmony OS
Closes: https://github.com/alsa-project/alsa-lib/pull/467
Signed-off-by: wyjstrong <wyjstrong@163.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-07-31 15:29:21 +02:00
Jaroslav Kysela
ee5a58f48e ucm: regex: fix the error message (missing argument)
Link: https://github.com/alsa-project/alsa-ucm-conf/pull/580
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-06-26 11:33:15 +02:00
Jaroslav Kysela
8ab0228f51 Revert "ucm: do not bump syntax version to 8"
This reverts commit e51cba0973.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-04-24 13:25:38 +02:00
Jaroslav Kysela
e51cba0973 ucm: do not bump syntax version to 8
The new code for syntax 8 is not widely tested. Postpone it for next
alsa-lib release.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-04-14 09:44:42 +02:00
Jaroslav Kysela
d8300e5cb7 ucm: add '${LibCaps}' substitution
It is a preparation for future checking of alsa-lib's extensions.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-03-21 11:41:09 +01:00
Jaroslav Kysela
70f4c95df5 ucm: remove @@LibraryVersion and @@SyntaxVersion variables
It seems that version checking is more complicated:

Syntax is one-way settlement from the configuration files.
It cannot be conditional.

The library version string is hard to check with regex.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-03-21 11:26:32 +01:00
Jaroslav Kysela
e9e3c01ff7 ucm: format @@SyntaxVersion to 4 digits
It is better for regex matching.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-03-19 12:20:27 +01:00
Jaroslav Kysela
8f6fef8b1a ucm: enhance documentation (sys-card + ranges + more)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-03-19 12:05:34 +01:00
Jaroslav Kysela
12f6790910 ucm: add @@LibraryVersion and @@SyntaxVersion variables
It may be useful to check the current syntax version (and maybe
library version) when new features are added.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-03-19 11:54:50 +01:00
Jaroslav Kysela
7fbd47ce79 ucm: add sys-card substitution
It may be useful to check additional sysfs parameters like USB descriptors
to determine the exact hardware capabilities.

Introduce 'sys-card' substitution and 'sys' substitution to allow data
fetching from given range. Also, add conversion to hexadecimal format
when the source file has binary contents.

Example - fetch bytes from positions 0x10..0x15 (6 bytes):

  Define.Bytes1 "${sys-card:[type=hex,pos=0x10,size=6]device/../descriptors}"

Example - fetch one byte from position 0x22:

  Define.Bytes2 "${sys-card:[type=hex,pos=0x22]device/../descriptors}"

Replace type=hex or omit this variable settings to work with ASCII
characters.

Link: https://github.com/alsa-project/alsa-ucm-conf/issues/444
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2025-03-13 18:28:05 +01:00
Jaroslav Kysela
291e727dfe ucm: doc - add Variant and Macro to the evaluation order
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-05-14 15:28:44 +02:00
Jaroslav Kysela
3864f7d95f ucm: define and describe Syntax 7
- for new macro argument substitution
- for new Path condition fields substitutions

Link: https://github.com/alsa-project/alsa-ucm-conf/pull/411
Link: https://github.com/alsa-project/alsa-lib/issues/395
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-04-24 15:36:05 +02:00
Jaroslav Kysela
c6cd83bd0a ucm: raise error when macro argument is already defined (used)
Link: https://github.com/alsa-project/alsa-ucm-conf/pull/411
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-04-24 15:19:24 +02:00
Jaroslav Kysela
99499a6ebc ucm: do argument value substitution for Macros
Link: https://github.com/alsa-project/alsa-ucm-conf/pull/411
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-04-24 15:18:36 +02:00
Jaroslav Kysela
3fd24db22d ucm: fix Path condition - substitute Path
Use the appropriate variable for access/eaccess call.

Fixes: https://github.com/alsa-project/alsa-lib/issues/395
Fixes: ef6463a2 ("ucm: fix Path condition - substitute Path and Mode fields")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-04-24 14:48:13 +02:00
Jaroslav Kysela
ef6463a209 ucm: fix Path condition - substitute Path and Mode fields
The Path and Mode fields should be also substituted for
the runtime evaluation. See Fixes.

Fixes: https://github.com/alsa-project/alsa-lib/issues/395
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-04-24 13:01:04 +02:00
Jaroslav Kysela
8883943995 ucm: main - remove cast to pointer from integer of different size warning
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-01 16:50:51 +02:00
Tony Wasserka
00da3feace ucm: mark internal functions static
From: Tony Wasserka /neobrain@github/
Fixes: https://github.com/alsa-project/alsa-lib/pull/335
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-01 16:40:56 +02:00
borine
cde0e819f7 doxygen: ucm: silence warnings
Removes duplicate documentation blocks and fixes 'not documented' warnings

From: borine@github
Link: https://github.com/alsa-project/alsa-lib/pull/340
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-01 16:12:10 +02:00
borine
e72c605179 doxygen: escape xml tags
From: borine@github
Link: https://github.com/alsa-project/alsa-lib/pull/340
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-01 16:11:09 +02:00
borine
9505cfdb46 doxygen: fix broken parameter name tags
From: borine@github
Link: https://github.com/alsa-project/alsa-lib/pull/340
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-01 16:10:55 +02:00
Maxython
b40fcda7fb compilation: fix ANDROID -> __ANDROID__ define detection
Fixes: https://github.com/alsa-project/alsa-lib/pull/301/
Signed-off-by: Maxython <mixython@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-02 14:52:27 +02:00
Jaroslav Kysela
496c4e031b ucm: fix geti() macro - return zero on success
Fixes: c083417b ("ucm: simplify and fix the previous patch (geti)")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-15 18:57:56 +01:00
Jaroslav Kysela
c083417b72 ucm: simplify and fix the previous patch (geti)
Use macro to maintain only one code. The status may be 0 or 1 - handle
both values correctly.

Also, fix the possible memory leak in snd_use_case_geti() - string
str should be freed even when the error is returned.

Fixes: 436cd5b6 ("ucm: add existence checks to geti calls")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-15 18:37:40 +01:00
Curtis Malainey
436cd5b6d0 ucm: add existence checks to geti calls
Right now in snd_use_case_geti you cannot tell if the item being queried
exists or not when being checked. This also means the only way to check
for the existence of something in the client of the library is to
iterate over the list of mods/devs even if we know exactly the name we
are looking for. We have functions that do exactly this internally so
lets return this information in a logical fashion through geti.

Also clean up some trailing white space nearby.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-15 17:57:13 +01:00