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>
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>
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>
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>
It is useful to run all disable sequences for all
UCM devices in a verb to ensure the valid, expected
initial state.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Continue the work in commit ba86ac55 ("conf: Use LFS calls when reading
config files") and fix the UCM code, too.
Fixes: https://github.com/alsa-project/alsa-lib/pull/223
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It may be useful to call the sequences from devices from
the verb sequences or another device sequences.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It is useful to pass information like application capabilities
to the UCM configuration parser. Those variables are prefixed
with '@' for the configuration files.
An example:
"<<<v1='a b c',x=12>>>hw:1"
Variables can substituted in the configuration:
"${var:@v1}" -> "a b c"
"${var:@x}" -> 12
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The arguments are set as temporary variables as /MACRO_NAME/_/ARGUMENT_NAME/.
Example:
# define new macro MyMacro with arguments ctl_name and ctl_value
DefineMacro.MyMacro {
BootSequence [
cset "name='${var:MyMacro_ctl_name}' ${var:MyMacro_ctl_value}"
]
}
# instantiate macro for Speaker control (short version)
Macro.headphone.MyMacro "ctl_name='Speaker Switch',ctl_value=off"
# instantiate macro for Mic control (second version)
Macro.mic.MyMacro {
ctl_name "Mic Switch"
ctl_value "off"
}
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It seems that users are confused when the UCM configuration
is not ready for the particular hardware. Actually, we don't
allow a fine grained message classification in alsa-lib and
UCM API. Allow suppression of this specific type of messages
on the application request (typically alsactl).
BugLink: https://github.com/alsa-project/alsa-utils/issues/111
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/ucm/main.c:788:8: error: implicit declaration of function 'WIFSIGNALED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (WIFSIGNALED(err)) {
^
src/ucm/main.c:790:10: error: implicit declaration of function 'WIFEXITED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
} if (WIFEXITED(err)) {
^
src/ucm/main.c:791:34: error: implicit declaration of function 'WEXITSTATUS' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (ignore_error == false && WEXITSTATUS(err) != 0) {
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The leading '+' in the keys specification add the key prefix
(sub-tree root identification) to the saved configuration.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Allow to save whole (or partial) local UCM alsa library configuration
to a file.
Syntax (saves key1.key2 sub-tree):
Sequence [
cfg-save "/tmp/my-file.conf:key1.key2"
]
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This change renames the original exec command to shell which
is more appropriate. Implement a light version of the exec
command which calls directly the specified executable without
the shell interaction (man 3 system).
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
When the user requests to ignore sysfs write errors by prefixing
the path with a '-' then we need to skip the '-' when building the
actual path otherwise the write will never work.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The application should know, that there is no special
initialization sequence. It's counterpart for
"ucm: return error if boot_list is empty".
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
If bootlist is empty, that means there is no BootSequence defined
in the ucm for this sound card, let set_boot_user() return error,
then alsactl could have chance to use non-ucm ways to initialize the
sound card.
BugLink: https://github.com/alsa-project/alsa-lib/pull/94
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit allows to define private alsa-lib's configuration. When
the configuration is present, the device values ("PlaybackCTL",
"CaptureCTL", "PlaybackMixer", "CaptureMixer", "CapturePCM")
are prefixed with '_ucmHEXA.' string where HEXA is replaced by the
unique hexadecimal number identifying the opened ucm manager handle.
Syntax 4
LibraryConfig.a_label.SubstiConfig {
# substituted library configuration like:
usr_share_dir "${ConfLibDir}"
}
LibraryConfig.b_label.Config {
# non-substituted library configuration like:
usr_share_dir "/usr/share/alsa"
}
The File counterparts:
LibraryConfig.c_label.SubstiFile "/some/path"
LibraryConfig.d_label.File "/some/path"
Note that for files the contents is substituted on the request,
but the file name is always substituted (useful for ${ConfDir} etc.).
The private configuration is not saved or preserved. It's life time
belongs to the opened ucm manager handle.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This command create a new control using ID, description and value.
Syntax:
cset-new "name='ABCD',index=2 type=boolean,count=2 on,on"
cset-new "name='Enum' type=enum,labels='L1;L2;L3' 'L2'"
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This file is problematic for the git's tab checker.
The unexpand tool is used to convert initial spaces
to tabs.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Actually, the BootSequence is executed only when the driver controls
(identifiers or value types) are changed. It may be handy to have
also a sequence which is executed at _each_ boot without any condition.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>