OSDN Git Service

android-x86/external-alsa-lib.git
3 years agoconf: print quoted string more wisely
Jaroslav Kysela [Tue, 18 May 2021 11:02:56 +0000 (13:02 +0200)]
conf: print quoted string more wisely

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: cfg-save - allow to save the sub-tree including root keys
Jaroslav Kysela [Tue, 18 May 2021 10:22:46 +0000 (12:22 +0200)]
ucm: cfg-save - allow to save the sub-tree including root keys

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>
3 years agoucm: libconfig - merge not override items
Jaroslav Kysela [Tue, 18 May 2021 09:20:56 +0000 (11:20 +0200)]
ucm: libconfig - merge not override items

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: libconfig parser - fix memory leaks
Jaroslav Kysela [Tue, 18 May 2021 09:20:18 +0000 (11:20 +0200)]
ucm: libconfig parser - fix memory leaks

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: fix snd_config_merge() - merge schema
Jaroslav Kysela [Tue, 18 May 2021 08:57:17 +0000 (10:57 +0200)]
conf: fix snd_config_merge() - merge schema

All child compounds must be traversed and merged.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: remap - add no-op when the remapping is not active
Jaroslav Kysela [Mon, 17 May 2021 15:03:37 +0000 (17:03 +0200)]
control: remap - add no-op when the remapping is not active

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add cfg-save command
Jaroslav Kysela [Fri, 14 May 2021 10:20:18 +0000 (12:20 +0200)]
ucm: add cfg-save command

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>
3 years agoucm: fix memory leak in execute_cset()
Jaroslav Kysela [Fri, 14 May 2021 10:49:03 +0000 (12:49 +0200)]
ucm: fix memory leak in execute_cset()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: parse LibraryConfig also in the toplevel file
Jaroslav Kysela [Thu, 13 May 2021 16:28:20 +0000 (18:28 +0200)]
ucm: parse LibraryConfig also in the toplevel file

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: load the card specific configurations to the config sub-tree
Jaroslav Kysela [Thu, 13 May 2021 09:04:14 +0000 (11:04 +0200)]
conf: load the card specific configurations to the config sub-tree

The /var/lib/alsa/card<CARDNO>.conf.d configurations are loaded
to the cards.<CARDNO> tree only (overwrite mode).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add snd_config_make_path() function
Jaroslav Kysela [Thu, 13 May 2021 09:02:41 +0000 (11:02 +0200)]
conf: add snd_config_make_path() function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add snd_config_is_empty() function
Jaroslav Kysela [Thu, 13 May 2021 08:59:43 +0000 (10:59 +0200)]
conf: add snd_config_is_empty() function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: fix open in direct plugins - wrong pointer assignment
Jaroslav Kysela [Thu, 13 May 2021 08:18:27 +0000 (10:18 +0200)]
pcm: fix open in direct plugins - wrong pointer assignment

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: _snd_config_evaluate - remove 'delete compound members' call
Jaroslav Kysela [Wed, 12 May 2021 10:12:57 +0000 (12:12 +0200)]
conf: _snd_config_evaluate - remove 'delete compound members' call

With the recent snd_config_substitute() fix, remove the duplicate
code.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: fix snd_config_substitute() - memory leak
Jaroslav Kysela [Wed, 12 May 2021 09:39:05 +0000 (11:39 +0200)]
conf: fix snd_config_substitute() - memory leak

There's an issue with the current code: It says append for compounds,
but it does overwrite without the proper members delete from
the overwritten (destination) compound node.

Don't change the behaviour, just fix the comment and memory leak.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: fix snd_config_merge() - double free in overwrite mode
Jaroslav Kysela [Wed, 12 May 2021 08:07:12 +0000 (10:07 +0200)]
conf: fix snd_config_merge() - double free in overwrite mode

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix regexec() REG_NOMATCH state handling for define regex
Jaroslav Kysela [Wed, 12 May 2021 07:53:18 +0000 (09:53 +0200)]
ucm: fix regexec() REG_NOMATCH state handling for define regex

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add exec sequence command
Jaroslav Kysela [Tue, 11 May 2021 12:48:16 +0000 (14:48 +0200)]
ucm: add exec sequence command

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>
3 years agoalsa: conf - use card number roots for device redirects
Jaroslav Kysela [Tue, 4 May 2021 18:48:52 +0000 (20:48 +0200)]
alsa: conf - use card number roots for device redirects

The change device definitions (pcm.front etc.) from the driver
roots (cards.<DRIVER_NAME>) to the card number roots (cards.<CARDNO>).

This will allow us to do custom overrides (like UCM) in
/var/lib/alsa/card<CARDNO>.conf.d.

For dmix and dsnoop default values, use the card ID instead
the card driver name. It's more flexible.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: extend load_for_all_cards hook (id/value table)
Jaroslav Kysela [Tue, 4 May 2021 18:27:45 +0000 (20:27 +0200)]
conf: extend load_for_all_cards hook (id/value table)

For the per-card configuration, add possibility to define
card number -> card driver link table.

Example:

  cards.0 'cards.USB-Audio'
  cards.1 'cards.USB-Audio'
  cards.2 'cards.HDA-Intel'
  cards.3 'cards.USB-Audio'

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agomixer: simple - Fix "Capture Volume" and "Capture Switch" being seen as global controls
Hans de Goede [Tue, 4 May 2021 15:58:30 +0000 (17:58 +0200)]
mixer: simple - Fix "Capture Volume" and "Capture Switch" being seen as global controls

Fix the "Capture Volume" and "Capture Switch" exceptions no longer
working after commit 86b9c67774bc ("mixer: simple - Unify simple_none:
base_len() exception handling") because they were moved to after the
suffix checking, so they would be treated as CTL_GLOBAL_VOLUME resp.
CTL_GLOBAL_SWITCH based on their suffix before the exception check
has a chance to check for a match.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: Fix sysw sequence command not working when requesting to ignore errors
Hans de Goede [Mon, 3 May 2021 20:52:44 +0000 (22:52 +0200)]
ucm: Fix sysw sequence command not working when requesting to ignore errors

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>
3 years agoucm: fix the local ucm control device name caching
Jaroslav Kysela [Fri, 23 Apr 2021 15:24:36 +0000 (17:24 +0200)]
ucm: fix the local ucm control device name caching

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: remap - don't allow I/O on renamed IDs
Jaroslav Kysela [Fri, 23 Apr 2021 14:35:26 +0000 (16:35 +0200)]
control: remap - don't allow I/O on renamed IDs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: add missing src/conf/ctl/Makefile.am
Jaroslav Kysela [Fri, 23 Apr 2021 10:28:33 +0000 (12:28 +0200)]
control: add missing src/conf/ctl/Makefile.am

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: limit the master config scan to conf.virt.d
Jaroslav Kysela [Thu, 22 Apr 2021 09:47:48 +0000 (11:47 +0200)]
ucm: limit the master config scan to conf.virt.d

The composition of the list of valid UCM cards is a bit
tricky. Scan only ucm2/conf.virt.d tree.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fixed find-device substitution (non-continuous PCM devices)
Jaroslav Kysela [Fri, 16 Apr 2021 12:48:08 +0000 (14:48 +0200)]
ucm: fixed find-device substitution (non-continuous PCM devices)

The PCM device numbers may be non-continous. Skip them when -ENOENT error
is returned.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: allow to escape the trailing variable substitution character
Jaroslav Kysela [Fri, 16 Apr 2021 10:34:29 +0000 (12:34 +0200)]
ucm: allow to escape the trailing variable substitution character

Example:

  ${find-device:ctl='hw:0',type=pcm,field=id,regex='USB A{1\\}'}

Unescaped find-device arguments:

  ctl='hw:0',type=pcm,field=id,regex='USB A{1}'

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: find-device / pcm - the ctl_list may be empty
Jaroslav Kysela [Fri, 16 Apr 2021 08:48:35 +0000 (10:48 +0200)]
ucm: find-device / pcm - the ctl_list may be empty

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add missing uc_mgr_card_close() call to snd_use_case_mgr_open()
Jaroslav Kysela [Thu, 15 Apr 2021 14:58:24 +0000 (16:58 +0200)]
ucm: add missing uc_mgr_card_close() call to snd_use_case_mgr_open()

Handle the error path correctly.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: cosmetic code reshuffle in rval_lookup_main()
Jaroslav Kysela [Thu, 15 Apr 2021 14:45:12 +0000 (16:45 +0200)]
ucm: cosmetic code reshuffle in rval_lookup_main()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: fix uc_mgr_has_local_config()
Jaroslav Kysela [Thu, 15 Apr 2021 09:49:32 +0000 (11:49 +0200)]
ucm: fix uc_mgr_has_local_config()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: rewrite device value only when the local config exists
Jaroslav Kysela [Thu, 15 Apr 2021 09:38:39 +0000 (11:38 +0200)]
ucm: rewrite device value only when the local config exists

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoutils/alsa.m4: another quick fix for the brackets
asavah [Tue, 13 Apr 2021 19:16:26 +0000 (22:16 +0300)]
utils/alsa.m4: another quick fix for the brackets

BugLink: https://github.com/alsa-project/alsa-lib/pull/133
From: asavah <asavah@avh.od.ua>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoutils/alsa.m4: a quick fix for missing end brackets
Jaroslav Kysela [Tue, 13 Apr 2021 18:30:07 +0000 (20:30 +0200)]
utils/alsa.m4: a quick fix for missing end brackets

Fixes: c6e0f24e ("utils/alsa.m4: update for newer autoconf.")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: usb - correct 'SB Omni Surround 5.1' iec958 device
Jaroslav Kysela [Tue, 13 Apr 2021 17:58:01 +0000 (19:58 +0200)]
conf: usb - correct 'SB Omni Surround 5.1' iec958 device

BugLink: https://github.com/alsa-project/alsa-lib/issues/101
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agotest: audio_time - fix timestamp2ns() and usage()
Jaroslav Kysela [Tue, 13 Apr 2021 17:49:44 +0000 (19:49 +0200)]
test: audio_time - fix timestamp2ns() and usage()

BugLink: https://github.com/alsa-project/alsa-lib/issues/132
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoutils/alsa.m4: update for newer autoconf.
Ozkan Sezer [Thu, 17 Dec 2020 11:11:28 +0000 (14:11 +0300)]
utils/alsa.m4: update for newer autoconf.

fixes autoconf-2.70 warnings. should be compatible down to autoconf-2.59.

BugLink: https://github.com/alsa-project/alsa-lib/pull/106
Signed-off-by: Ozkan Sezer <sezeroz@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: return error if fixedboot_list is empty
Jaroslav Kysela [Tue, 13 Apr 2021 17:13:20 +0000 (19:13 +0200)]
ucm: return error if fixedboot_list is empty

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>
3 years agoucm: return error if boot_list is empty
Hui Wang [Thu, 29 Oct 2020 06:51:30 +0000 (14:51 +0800)]
ucm: return error if boot_list is empty

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>
3 years agoconf: USB - add "Cmedia Audio" to USB-Audio.pcm.iec958_device
Hui Wang [Mon, 1 Mar 2021 05:51:54 +0000 (13:51 +0800)]
conf: USB - add "Cmedia Audio" to USB-Audio.pcm.iec958_device

Otherwise, there will be a "Digital Output(S/PDIF)-Cmedia Audio" from
Gnome UI, but there is no this physical interface on the card.

BugLink: https://github.com/alsa-project/alsa-lib/pull/122
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoRemove non-existent SPDIF output on Dell AE515
James [Wed, 3 Mar 2021 21:03:37 +0000 (21:03 +0000)]
Remove non-existent SPDIF output on Dell AE515

The Dell Professional Sound Bar AE515 shows up in GNOME Settings with
a digital output that doesn't physically exist. Add it to the list
to suppress this.

BugLink: https://github.com/alsa-project/alsa-lib/pull/124
From: drjhe
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: No SPDIF on Plantronics 3220 headset
James [Tue, 16 Mar 2021 17:41:48 +0000 (17:41 +0000)]
conf: No SPDIF on Plantronics 3220 headset

The Plantronics Blackwire 3220 Series headset (USB ID 047f:c056) shows up
in GNOME Settings with a non-existent digital output. Add it to the list
to suppress this.

BugLink: https://github.com/alsa-project/alsa-lib/pull/126
From: drjhe
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: direct - move the direct struct init to _snd_pcm_direct_new()
Jaroslav Kysela [Tue, 13 Apr 2021 16:55:37 +0000 (18:55 +0200)]
pcm: direct - move the direct struct init to _snd_pcm_direct_new()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: dshare - fix shared memory pointer check
Vanitha Channaiah [Sun, 21 Mar 2021 11:00:48 +0000 (16:30 +0530)]
pcm: dshare - fix shared memory pointer check

Currently shared memory pointer is initialized to 0 and set to -1
in some, but not in all error paths.
In cleanup path of open the shm pointer is only compared to be non-NULL
before dereferencing it which leads to SEGFAULT in case it was set to -1.

This patch initializes pointer to -1 to have a unique identification
for invalid pointer and also checks for pointer being not -1 on
access in cleanup path.

Signed-off-by: Vanitha Channaiah <vanitha.channaiah@in.bosch.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoinclude: fix SND_LIB_VER() macro
Jaroslav Kysela [Tue, 13 Apr 2021 16:01:09 +0000 (18:01 +0200)]
include: fix SND_LIB_VER() macro

Fixes: c132509a ("include: add SND_LIB_VER() macro")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: ucm_filename() - avoid double //
Jaroslav Kysela [Tue, 13 Apr 2021 15:19:54 +0000 (17:19 +0200)]
ucm: ucm_filename() - avoid double //

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: handle better the system() call
Jaroslav Kysela [Tue, 13 Apr 2021 07:52:35 +0000 (09:52 +0200)]
ucm: handle better the system() call

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add LibraryConfig support
Jaroslav Kysela [Mon, 12 Apr 2021 16:09:21 +0000 (18:09 +0200)]
ucm: add LibraryConfig support

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>
3 years agooutput: Add snd_output_buffer_steal() function
Jaroslav Kysela [Mon, 12 Apr 2021 14:47:58 +0000 (16:47 +0200)]
output: Add snd_output_buffer_steal() function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add snd_config_merge() function
Jaroslav Kysela [Fri, 9 Apr 2021 16:11:57 +0000 (18:11 +0200)]
conf: add snd_config_merge() function

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add ${ConfLibDir} substitution
Jaroslav Kysela [Thu, 8 Apr 2021 10:48:38 +0000 (12:48 +0200)]
ucm: add ${ConfLibDir} substitution

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add /var/lib/alsa/conf.d directory lookup
Jaroslav Kysela [Thu, 8 Apr 2021 10:31:47 +0000 (12:31 +0200)]
conf: add /var/lib/alsa/conf.d directory lookup

It may be handy to put the configurations or symlinks
to the global runtime directory.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: add /var/lib/alsa/card<NUMBER>.conf.d directory lookups
Jaroslav Kysela [Tue, 6 Apr 2021 19:05:31 +0000 (21:05 +0200)]
conf: add /var/lib/alsa/card<NUMBER>.conf.d directory lookups

It may be handy to put extra configurations or symlinks to
the global runtime directory. The configurations may be
created at boot / hotplug event by udev or other scripts.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: extend hook load_for_all_cards
Jaroslav Kysela [Tue, 6 Apr 2021 18:00:36 +0000 (20:00 +0200)]
conf: extend hook load_for_all_cards

Pass also card integer number.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoinclude: add SND_LIB_VER() macro
Jaroslav Kysela [Tue, 6 Apr 2021 16:32:57 +0000 (18:32 +0200)]
include: add SND_LIB_VER() macro

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: make ctl.default and sysdefault devices more universal
Jaroslav Kysela [Tue, 6 Apr 2021 16:19:48 +0000 (18:19 +0200)]
conf: make ctl.default and sysdefault devices more universal

It may be handy to add hw specific configs.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: add empty plugin
Jaroslav Kysela [Tue, 6 Apr 2021 18:34:18 +0000 (20:34 +0200)]
control: add empty plugin

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: remap plugin - add docs
Jaroslav Kysela [Tue, 6 Apr 2021 10:57:54 +0000 (12:57 +0200)]
control: remap plugin - add docs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: doc - create controls plugin page
Jaroslav Kysela [Tue, 6 Apr 2021 10:18:23 +0000 (12:18 +0200)]
control: doc - create controls plugin page

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: remap plugin - initial version
Jaroslav Kysela [Mon, 29 Mar 2021 10:36:21 +0000 (12:36 +0200)]
control: remap plugin - initial version

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: add _snd_ctl_open_child()
Jaroslav Kysela [Mon, 29 Mar 2021 10:19:21 +0000 (12:19 +0200)]
control: add _snd_ctl_open_child()

To support internal plugins, add internal _snd_ctl_open_child()
function like _snd_pcm_open_slave().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: empty plugin - fix the docs
Jaroslav Kysela [Tue, 6 Apr 2021 18:03:40 +0000 (20:03 +0200)]
pcm: empty plugin - fix the docs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: shm - add missing continue to _snd_ctl_shm_open()
Jaroslav Kysela [Mon, 29 Mar 2021 09:41:26 +0000 (11:41 +0200)]
control: shm - add missing continue to _snd_ctl_shm_open()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add ctl-remove sequence command to delete controls from UCM
Jaroslav Kysela [Mon, 29 Mar 2021 09:12:28 +0000 (11:12 +0200)]
ucm: add ctl-remove sequence command to delete controls from UCM

Syntax:

   ctl-remove "name='ABCD'"

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add cset-new sequence command to create new controls from UCM
Jaroslav Kysela [Thu, 25 Mar 2021 19:36:54 +0000 (20:36 +0100)]
ucm: add cset-new sequence command to create new controls from UCM

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>
3 years agoucm: move __snd_ctl_ascii_elem_id_parse prototype to control_local.h
Jaroslav Kysela [Thu, 25 Mar 2021 19:40:22 +0000 (20:40 +0100)]
ucm: move __snd_ctl_ascii_elem_id_parse prototype to control_local.h

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: add __snd_ctl_add_elem_set() helper
Jaroslav Kysela [Thu, 25 Mar 2021 19:27:44 +0000 (20:27 +0100)]
control: add __snd_ctl_add_elem_set() helper

It simplifies the add_elem_set functions and we need it for UCM.
It's an internal function.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: add snd_ctl_elem_id_compare_numid() function
Jaroslav Kysela [Tue, 23 Mar 2021 16:43:30 +0000 (17:43 +0100)]
control: add snd_ctl_elem_id_compare_numid() function

Idea for the function prototype by Takashi Sakamoto.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: rename snd_ctl_elem_id_compare() to snd_ctl_elem_id_compare_set()
Jaroslav Kysela [Tue, 23 Mar 2021 16:30:25 +0000 (17:30 +0100)]
control: rename snd_ctl_elem_id_compare() to snd_ctl_elem_id_compare_set()

- add asserts to check if the unsigned integers are in the valid range
- replace tuple with set in the id description
- add const prefix for id1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add Path condition type
Jaroslav Kysela [Tue, 23 Mar 2021 15:53:03 +0000 (16:53 +0100)]
ucm: add Path condition type

Check for a file presence and mode.

Modes: exists, read, write, exec

Example:

If.0 {
Condition {
Type Path
Mode read
Path "/etc/alsa/something"
True {
...
}
}
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: rename sysset to sysw
Jaroslav Kysela [Tue, 23 Mar 2021 10:40:30 +0000 (11:40 +0100)]
ucm: rename sysset to sysw

Fixes: 1c6fb202 ("ucm: implement sysset sequence command")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: Fix invalid free at parse_args()
Takashi Iwai [Thu, 18 Mar 2021 16:43:58 +0000 (17:43 +0100)]
conf: Fix invalid free at parse_args()

The previous fix for memory leaks introduced a few regression.
The major one is the assert hit in the error path reaching with NULL
or uninitialized sub object.  Also, in other code paths, it's possible
that an already released sub object gets freed again.

Fix those bugs by initializing the sub object properly and add a NULL
check before calling snd_config_delete().

Fixes: ad5f255b4767 ("conf: fix memory leak on the error path in parse_args()")
Reported-and-tested-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agocontrol: fix the subdevice fields comparison in snd_ctl_elem_id_compare()
Jaroslav Kysela [Thu, 18 Mar 2021 11:33:10 +0000 (12:33 +0100)]
control: fix the subdevice fields comparison in snd_ctl_elem_id_compare()

3 years agoconf: fix memory leak on the error path in parse_args()
Jaroslav Kysela [Wed, 10 Mar 2021 17:10:57 +0000 (18:10 +0100)]
conf: fix memory leak on the error path in parse_args()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: warn about unknown sequence commands
Jaroslav Kysela [Tue, 9 Mar 2021 19:02:57 +0000 (20:02 +0100)]
ucm: warn about unknown sequence commands

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: implement sysset sequence command
Jaroslav Kysela [Fri, 5 Mar 2021 18:55:06 +0000 (19:55 +0100)]
ucm: implement sysset sequence command

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: ucm_main.c - cosmetic tab cleanups
Jaroslav Kysela [Fri, 5 Mar 2021 18:35:03 +0000 (19:35 +0100)]
ucm: ucm_main.c - cosmetic tab cleanups

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>
3 years agoucm: add _fboot / FixedBootSequence
Jaroslav Kysela [Fri, 5 Mar 2021 17:50:02 +0000 (18:50 +0100)]
ucm: add _fboot / FixedBootSequence

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>
3 years agocontrol: better docs for snd_ctl_elem_id_compare()
Jaroslav Kysela [Mon, 8 Mar 2021 14:24:31 +0000 (15:24 +0100)]
control: better docs for snd_ctl_elem_id_compare()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: snd_config_save() - print arrays as [] not the internal representation
Jaroslav Kysela [Sun, 7 Mar 2021 19:58:45 +0000 (20:58 +0100)]
conf: snd_config_save() - print arrays as [] not the internal representation

The internal represention of an array is:

{
0 value1
1 value2
2 value2
...
}

which is identicatal to shorter:

[
value1
value2
value3
]

Always print the short format. It's more optimized and readable.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: improve the tabulator level prints
Jaroslav Kysela [Sun, 7 Mar 2021 19:47:21 +0000 (20:47 +0100)]
conf: improve the tabulator level prints

Do not use per char loop, but compose a string.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agomixer: simple - use for loop in base_len()
Jaroslav Kysela [Fri, 5 Mar 2021 20:11:41 +0000 (21:11 +0100)]
mixer: simple - use for loop in base_len()

... reduce the code a bit

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agomixer: simple - Unify simple_none: base_len() exception handling
Hans de Goede [Sun, 28 Feb 2021 16:13:02 +0000 (17:13 +0100)]
mixer: simple - Unify simple_none: base_len() exception handling

Unify simple_none: base_len() exception handling:

1. In the "Input Source" and "3D Control" cases the base-name is the same
   as the full-name and base_len() simply returns strlen(name).
   Instead of returning 0 when the type is unknown, set the type to
   CTL_SINGLE and return strlen(name). This allows removing the special
   case for base_len() returning 0 in simple_event_add().

2. Move the special handling for "Capture Volume" and "Capture Switch"
   from simple_event_add() to base_len(), so that we handle all exceptions
   inside base_len(). Instead of handling some special cases in base_len()
   and other special cases in simple_event_add().

[jk - moved the "Capture Volume" and "Capture Switch" to "Input Source"
exceptions]

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconfigure: bumb version to 1.2.5pre1 (for CI tests)
Jaroslav Kysela [Fri, 5 Mar 2021 17:36:01 +0000 (18:36 +0100)]
configure: bumb version to 1.2.5pre1 (for CI tests)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: softvol - improve TLV data check for new configs
Jaroslav Kysela [Fri, 26 Feb 2021 19:52:23 +0000 (20:52 +0100)]
pcm: softvol - improve TLV data check for new configs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: add snd_ctl_elem_id_compare() function
Jaroslav Kysela [Fri, 26 Feb 2021 19:30:58 +0000 (20:30 +0100)]
control: add snd_ctl_elem_id_compare() function

Compare two control element identifiers like strcmp().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: snd_ctl_ascii_elem_id_get() - do not show unset numid
Jaroslav Kysela [Fri, 26 Feb 2021 18:53:17 +0000 (19:53 +0100)]
control: snd_ctl_ascii_elem_id_get() - do not show unset numid

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: fix snd_pcm_plugin_status()
Jaroslav Kysela [Wed, 24 Feb 2021 20:03:29 +0000 (21:03 +0100)]
pcm: fix snd_pcm_plugin_status()

The appl_ptr difference must be computed before
the appl_ptr in the status structure is updated.

Fixes: da5b70d3f ("pcm: plugin - fix status code for capture")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: introduce snd_config_get_card() function
Jaroslav Kysela [Wed, 24 Feb 2021 18:20:15 +0000 (19:20 +0100)]
conf: introduce snd_config_get_card() function

It's helper for the "card" entries parsing. It reduces
the code in most of open_hw functions.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: softvol - make snd_pcm_parse_control_id private
Jaroslav Kysela [Mon, 22 Feb 2021 19:01:34 +0000 (20:01 +0100)]
pcm: softvol - make snd_pcm_parse_control_id private

The function is not used externally (it's not exported in headers).
Make it private.

Use snd_config_get_ctl_iface() for the interface value parsing.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: softvol - do not set TLV access flags for the switch
Jaroslav Kysela [Mon, 22 Feb 2021 12:08:30 +0000 (13:08 +0100)]
pcm: softvol - do not set TLV access flags for the switch

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: improve snd_ctl_add_*_elem_set functions (access flags)
Jaroslav Kysela [Mon, 22 Feb 2021 11:24:58 +0000 (12:24 +0100)]
control: improve snd_ctl_add_*_elem_set functions (access flags)

The access flags are useful for the user space elements
with the custom access flags.

Introduce snd_ctl_elem_info_set_*() functions to set those flags
in the info structure.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agocontrol: fix iformation -> information typos
Jaroslav Kysela [Mon, 22 Feb 2021 11:13:44 +0000 (12:13 +0100)]
control: fix iformation -> information typos

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoconf: HDA-Intel: increase the max number of HDMI/DP output to 11
Hui Wang [Tue, 2 Feb 2021 00:33:36 +0000 (08:33 +0800)]
conf: HDA-Intel: increase the max number of HDMI/DP output to 11

Intel TGL HDMI/DP codec provides 9 pins (Linux kernel, 9a11ba7388f16:
ALSA: hda: hdmi - add Tigerlake support), and with the DP MST enabled,
the linux kernel will build 11 output devices (3, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16), and current alsa-lib only maps the first 8 output
devices, if users plug the HDMI/DP monitor to the last 3 ports, the
users will not see the output device from pulseaudio or gnome.

We have experienced this issue on a dell TGL machine with a dock, we
plugged 2 HDMP/DP monitors on the dock, but we could only see 1
HDMI/DP output device from pulseaudio or gnome, through investigation,
we found one monitor is plugged in the 2nd port from last.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
BugLink: https://github.com/alsa-project/alsa-lib/pull/118
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoucm: fix two error messages
Jaroslav Kysela [Wed, 3 Feb 2021 10:55:53 +0000 (11:55 +0100)]
ucm: fix two error messages

- add missing argument to error msg in if_eval_regex_match()
- print correct error value in uc_mgr_config_load_file()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agoucm: add ${find-card} and ${find-device} substitutions
Jaroslav Kysela [Tue, 2 Feb 2021 18:26:24 +0000 (19:26 +0100)]
ucm: add ${find-card} and ${find-device} substitutions

It may be useful to find a correct card or device through
control API information fields.

Increase the syntax version to 4.

Examples:

  ${find-card:field=name,regex='HDA Intel'}
  ${find-device:type=pcm,field=id,regex='HDMI 1$'}
  ${find-device:ctl=hw:acp,type=pcm,field=id,regex=DMIC}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: pcm_ioplug - fix the avail_update mmap capture copy issue
Jaroslav Kysela [Thu, 21 Jan 2021 14:45:49 +0000 (15:45 +0100)]
pcm: pcm_ioplug - fix the avail_update mmap capture copy issue

It seems that the commit "pcm: ioplug: Transfer all available data"
introduced new regressions (wrong memory access). The second issue
is that the avail_update in ioplug does not move appl_ptr nor hw_ptr,
so it's possible that the transfers may be repetitive.

This patch moves the transfer calls to mmap_begin callback where it
should be. The pointer wraps are handled by design now.

Fixes: 1714332719 ("pcm: ioplug: Transfer all available data")
BugLink: https://github.com/alsa-project/alsa-lib/pull/103
Tested-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: share: Pass appl_ptr and hw_ptr in snd_pcm_status()
Takashi Iwai [Fri, 22 Jan 2021 14:48:42 +0000 (15:48 +0100)]
pcm: share: Pass appl_ptr and hw_ptr in snd_pcm_status()

This one also has the same problem as others; the appl_ptr and hw_ptr
of share plugin aren't updated in snd_pcm_status() call.  Fix it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
3 years agopcm: null: Pass appl_ptr and hw_ptr in snd_pcm_status()
Takashi Iwai [Fri, 22 Jan 2021 14:48:41 +0000 (15:48 +0100)]
pcm: null: Pass appl_ptr and hw_ptr in snd_pcm_status()

Just like the previous fix for ioplug, the null plugin also misses the
appl_ptr and hw_ptr updates for snd_pcm_status().  Fix it as well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>