]> git.alsa-project.org Git - alsa-lib.git/log
alsa-lib.git
5 years agotopology: dapm - merge identical index blocks like for other elems
Jaroslav Kysela [Fri, 13 Dec 2019 20:56:58 +0000 (21:56 +0100)]
topology: dapm - merge identical index blocks like for other elems

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agotopology: dapm - coding fixes
Jaroslav Kysela [Fri, 13 Dec 2019 20:52:13 +0000 (21:52 +0100)]
topology: dapm - coding fixes

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agotopology: use list_insert() macro in tplg_elem_insert()
Jaroslav Kysela [Fri, 13 Dec 2019 20:23:52 +0000 (21:23 +0100)]
topology: use list_insert() macro in tplg_elem_insert()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agotopology: make vebose output more nice
Jaroslav Kysela [Fri, 13 Dec 2019 17:53:41 +0000 (18:53 +0100)]
topology: make vebose output more nice

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agotopology: merge write_block to tplg_write_data
Jaroslav Kysela [Fri, 13 Dec 2019 17:49:29 +0000 (18:49 +0100)]
topology: merge write_block to tplg_write_data

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agotopology: use size_t for calc_block_size()
Jaroslav Kysela [Fri, 13 Dec 2019 17:26:20 +0000 (18:26 +0100)]
topology: use size_t for calc_block_size()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agotopology: use an array describing blocks for the main build loop
Jaroslav Kysela [Fri, 13 Dec 2019 17:24:55 +0000 (18:24 +0100)]
topology: use an array describing blocks for the main build loop

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agotopology: file position and size cleanups
Jaroslav Kysela [Fri, 13 Dec 2019 16:01:03 +0000 (17:01 +0100)]
topology: file position and size cleanups

- try to use size_t/ssize_t
- track the position in own variable, do not use lseek

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agotopology: remove vendor_fd/name from snd_tplg structure - not used
Jaroslav Kysela [Fri, 13 Dec 2019 15:09:35 +0000 (16:09 +0100)]
topology: remove vendor_fd/name from snd_tplg structure - not used

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoalsa-lib: fix the array parser (unique compound keys)
Jaroslav Kysela [Thu, 12 Dec 2019 17:42:33 +0000 (18:42 +0100)]
alsa-lib: fix the array parser (unique compound keys)

The code from the old import may merge arrays wrongly and
the result is a compound with same keys like:

Input:

        lines [
                "SSP0.OUT, , BUF1.3"
        ]
        lines [
                "BUF2.0, , SSP0.IN"
        ]

Parsed contents:

        lines {
                0 'SSP0.OUT, , BUF1.3'
                0 'BUF2.0, , SSP0.IN'
        }

Proper parsed contents (create+merge mode):

        lines {
                0 'SSP0.OUT, , BUF1.3'
                1 'BUF2.0, , SSP0.IN'
        }

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: setup conf_format after getting ALSA_CONFIG_UCM_VAR successfully
Libin Yang [Wed, 11 Dec 2019 06:07:19 +0000 (14:07 +0800)]
ucm: setup conf_format after getting ALSA_CONFIG_UCM_VAR successfully

Set the conf_format to 1 after getting ALSA_CONFIG_UCM_VAR successfully.
Otherwise, the conf_format is not set in this scenario.

Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs - remove MixerCopy values, add Priority for verb, improve priority docs
Jaroslav Kysela [Tue, 10 Dec 2019 10:48:06 +0000 (11:48 +0100)]
ucm: docs - remove MixerCopy values, add Priority for verb, improve priority docs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs - add note about the sequences and device split
Jaroslav Kysela [Fri, 6 Dec 2019 10:11:54 +0000 (11:11 +0100)]
ucm: docs - add note about the sequences and device split

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs - change the Mic description to simple Microphone Device
Jaroslav Kysela [Thu, 5 Dec 2019 16:19:06 +0000 (17:19 +0100)]
ucm: docs - change the Mic description to simple Microphone Device

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs - remove DigitalMic, it does not have sense
Jaroslav Kysela [Thu, 5 Dec 2019 16:01:31 +0000 (17:01 +0100)]
ucm: docs - remove DigitalMic, it does not have sense

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs - add Mic/DigitalMic and multiple devices comments
Jaroslav Kysela [Thu, 5 Dec 2019 15:59:05 +0000 (16:59 +0100)]
ucm: docs - add Mic/DigitalMic and multiple devices comments

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoalsa.m4: another try to fix the libatopology detection
Jaroslav Kysela [Wed, 4 Dec 2019 08:49:40 +0000 (09:49 +0100)]
alsa.m4: another try to fix the libatopology detection

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agosrc/ucm/main.c: fix build without mixer
Fabrice Fontaine [Tue, 3 Dec 2019 17:56:40 +0000 (18:56 +0100)]
src/ucm/main.c: fix build without mixer

Commit 4ce38a5ff466d18039b2606938f866ea3a6c9f3c breaks the build without
mixer on:

  CCLD     libasound.la
/home/buildroot/autobuild/instance-1/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/8.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: ucm/.libs/libucm.a(main.o): in function `snd_use_case_set':
main.c:(.text+0x185c): undefined reference to `snd_mixer_selem_id_parse'

Fixes: http://autobuild.buildroot.org/results/4d91c9f82a2a61c50c457a851073b85cc09ea345
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: Do not fail to parse configs on cards with an empty CardComponents lists
Hans de Goede [Tue, 3 Dec 2019 17:27:39 +0000 (18:27 +0100)]
ucm: Do not fail to parse configs on cards with an empty CardComponents lists

Since the UCM profiles for all Bay- and Cherry-Trail SST cards have been
moved over to UCM2, parsing them fails with:

ALSA lib ucm_subs.c:220:(uc_mgr_get_substituted_value) variable '${CardComponents}' is not defined in this context!

This completely breaks audio support on all Bay- and Cherry-Trail devices.

This is caused by these non-SOF ASoC using cards having an empty
CardComponents list. Which in itself is fine, but is rejected by
the ucm_subs.c code. This commit changes the ucm_subs code to accept
an empty string as a valid value for CardComponents restoring audio
functionality on these boards.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs - add JackCTL, rearrange JackControl and JackDev
Jaroslav Kysela [Tue, 3 Dec 2019 14:01:04 +0000 (15:01 +0100)]
ucm: docs - add JackCTL, rearrange JackControl and JackDev

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agouse-case: docs - add PlaybackMixerCopy and CaptureMixerCopy
Jaroslav Kysela [Mon, 2 Dec 2019 10:57:18 +0000 (11:57 +0100)]
use-case: docs - add PlaybackMixerCopy and CaptureMixerCopy

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs - allow spaces in device names for JackHWMute
Jaroslav Kysela [Mon, 2 Dec 2019 10:56:30 +0000 (11:56 +0100)]
ucm: docs - allow spaces in device names for JackHWMute

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agonamehint: improve the previous patch (check the returned value)
Jaroslav Kysela [Sun, 1 Dec 2019 13:30:54 +0000 (14:30 +0100)]
namehint: improve the previous patch (check the returned value)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agonamehint: correct the @args check
Jaroslav Kysela [Sun, 1 Dec 2019 13:26:40 +0000 (14:26 +0100)]
namehint: correct the @args check

BugLink: https://github.com/alsa-project/alsa-plugins/issues/3
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add _identifiers list
Jaroslav Kysela [Sat, 30 Nov 2019 19:31:55 +0000 (20:31 +0100)]
ucm: add _identifiers list

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: return always at least NULL if no list is available in snd_use_case_get_list()
Jaroslav Kysela [Fri, 29 Nov 2019 21:28:26 +0000 (22:28 +0100)]
ucm: return always at least NULL if no list is available in snd_use_case_get_list()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: Use strncmp to avoid access-out-of-boundary
paulhsia [Fri, 29 Nov 2019 19:35:30 +0000 (03:35 +0800)]
ucm: Use strncmp to avoid access-out-of-boundary

If the length of the identifier is less than the length of the prefix,
access-out-of-boundary will occur in memcmp().

Signed-off-by: paulhsia <paulhsia@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoRelease v1.2.1.2 v1.2.1.2
Jaroslav Kysela [Fri, 29 Nov 2019 15:35:31 +0000 (16:35 +0100)]
Release v1.2.1.2

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add support for ControlEnum in ControlExists condition
Jaroslav Kysela [Fri, 29 Nov 2019 08:33:50 +0000 (09:33 +0100)]
ucm: add support for ControlEnum in ControlExists condition

Condition {
  Type ControlExists
  Control "name='Capture Input'"
  ControlEnum "Headphone Mic"
}

The result is true if the control exists, it is the enumerated
type and has the item with the ControlEnum text (name).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: conditions - fix the wrong string/substring match
Jaroslav Kysela [Thu, 28 Nov 2019 18:25:03 +0000 (19:25 +0100)]
ucm: conditions - fix the wrong string/substring match

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agouse-case: add priority values from pulseaudio
Jaroslav Kysela [Thu, 28 Nov 2019 17:10:43 +0000 (18:10 +0100)]
use-case: add priority values from pulseaudio

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agocontrol: ctlparse - accept enum values in '' or ""
Jaroslav Kysela [Wed, 27 Nov 2019 13:59:17 +0000 (14:59 +0100)]
control: ctlparse - accept enum values in '' or ""

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agouse-case: improve comment for mixer elements
Jaroslav Kysela [Thu, 28 Nov 2019 13:58:36 +0000 (14:58 +0100)]
use-case: improve comment for mixer elements

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: rename mixer element identifiers
Jaroslav Kysela [Wed, 27 Nov 2019 13:59:17 +0000 (14:59 +0100)]
ucm: rename mixer element identifiers

To my knowledge, no software is using the mixer element identifiers.
Rename them to be more consistent with the mixer API and add
Master element identifier and type.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoalsa.m4: Fix the detection of topology library availability
Takashi Iwai [Wed, 27 Nov 2019 09:19:26 +0000 (10:19 +0100)]
alsa.m4: Fix the detection of topology library availability

The header file alsa/topology.h is mandatory and needs to be checked,
too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agoucm: fix the cdev initialization sequence
Jaroslav Kysela [Tue, 26 Nov 2019 16:35:15 +0000 (17:35 +0100)]
ucm: fix the cdev initialization sequence

The default values must be set before the defaults
UCM sequence is executed.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: remove the new-line for uc_error() calls
Jaroslav Kysela [Mon, 25 Nov 2019 18:50:47 +0000 (19:50 +0100)]
ucm: remove the new-line for uc_error() calls

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoinclude/sound/Makefile.am: remove asoundef.h
Jaroslav Kysela [Mon, 25 Nov 2019 15:16:13 +0000 (16:16 +0100)]
include/sound/Makefile.am: remove asoundef.h

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agolocal.h: remove sound/asoundef.h dependency
Jaroslav Kysela [Mon, 25 Nov 2019 09:36:32 +0000 (10:36 +0100)]
local.h: remove sound/asoundef.h dependency

5 years agoasoundef.h: add CEA861_AUDIO_INFOFRAME defines
Jaroslav Kysela [Mon, 25 Nov 2019 09:36:05 +0000 (10:36 +0100)]
asoundef.h: add CEA861_AUDIO_INFOFRAME defines

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoinclude/sound: sync with the kernel v5.4
Jaroslav Kysela [Mon, 25 Nov 2019 09:14:43 +0000 (10:14 +0100)]
include/sound: sync with the kernel v5.4

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: use-case.h - add <alsa/asoundlib.h> include
Jaroslav Kysela [Sat, 23 Nov 2019 14:38:35 +0000 (15:38 +0100)]
ucm: use-case.h - add <alsa/asoundlib.h> include

It is required for snd_ctl_elem_id_t and snd_mixer_selem_id_t.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agopcm_file: fix pipe stall when pclose() is called too early
Jaroslav Kysela [Thu, 21 Nov 2019 23:57:19 +0000 (00:57 +0100)]
pcm_file: fix pipe stall when pclose() is called too early

BugLink: https://github.com/alsa-project/alsa-lib/issues/14
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add ${CardDriver} substitution
Jaroslav Kysela [Thu, 21 Nov 2019 07:15:23 +0000 (08:15 +0100)]
ucm: add ${CardDriver} substitution

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: implement ${sys:sysfs/path} substitution
Jaroslav Kysela [Wed, 20 Nov 2019 12:43:39 +0000 (13:43 +0100)]
ucm: implement ${sys:sysfs/path} substitution

Example:

Condition {
Type String
String1 "${sys:class/dmi/id/board_vendor}"
String2 "LENOVO"
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoRelease v1.2.1.1 v1.2.1.1
Jaroslav Kysela [Tue, 19 Nov 2019 13:16:27 +0000 (14:16 +0100)]
Release v1.2.1.1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: quick fix for the previous commit when ALSA_CONFIG_UCM_VAR is set
Jaroslav Kysela [Tue, 19 Nov 2019 13:15:00 +0000 (14:15 +0100)]
ucm: quick fix for the previous commit when ALSA_CONFIG_UCM_VAR is set

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: fix again the long name configuration filename lookup
Jaroslav Kysela [Tue, 19 Nov 2019 12:10:19 +0000 (13:10 +0100)]
ucm: fix again the long name configuration filename lookup

The fix in commit 77119d83a1f4 assumes that both ucm1 / ucm2 directories
have the configurations for the long name in the same directory. For v2
we changed the location to card_name/card_long_name aka
driver_name/driver_long_name to make the directory layout more structured.

Fixes: 77119d83a1f4 ("ucm: Fix opening of master-configs by the card's longname")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: parser: Fix snprintf usage
Hans de Goede [Tue, 19 Nov 2019 10:48:22 +0000 (11:48 +0100)]
ucm: parser: Fix snprintf usage

There is no need to manually 0 terminate the buffer with snprintf,
only strncpy has the very unfortunate behavior of not guaranteeing 0
termination.

Likewise there is no need to substract one from the buffer size of
the buffer passed to snprintf.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: Only look in ucm[1] or ucm2 dir once we've found a config file in one
Hans de Goede [Tue, 19 Nov 2019 10:48:21 +0000 (11:48 +0100)]
ucm: Only look in ucm[1] or ucm2 dir once we've found a config file in one

Unless environment variables are set, then configuration_filename()
when initially called by load_master_config() will first try to find
the requested master-config under <prefix>/alsa/ucm2 and then under
<prefix>/alsa/ucm.

Once a master-config is found this way, we should set conf_format to
match, so that subsequent lookups only look under the same directory
as where the master-config was found.

This fixes 2 problems:
1. uc_mgr_config_load() looking under <prefix>/alsa/ucm for includes for
   UCM2 profiles because it is called with uc_mgr->conf_format as format
   and before this commit that would stay 0 when autodetecion is used.

2. parse_verb_file() possibly loading an UCM2 verb-file for an UCM1 profile,
   the chance of this happening is small as this means that even though
   there is no UCM2 master-config there is an UCM2 profile dir matching
   uc_mgr->conf_file_name, which would be weird.

Fixes: aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format, keep backward compatibility")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: Fix fallback to card_name (shortname) config for ucm1 profiles
Hans de Goede [Tue, 19 Nov 2019 10:48:20 +0000 (11:48 +0100)]
ucm: Fix fallback to card_name (shortname) config for ucm1 profiles

uc_mgr_import_master_config() first calls load_master_config()
with the card's longname and if that fails then calls it again with the
card_name.

Before this commit configuration_filename() would force conf_format to 2
when it the access(fn, R_OK) test failed for the ucm1 longname
master-config filename.

This would cause configuration_filename() to blindly return a filename
under <prefix>/ucm2 without seeing if that is actually there and without
trying to fallback to the old profiles under <prefix>/ucm, breaking the
loading of UCM1 profiles by card_name.

This commit fixes this by modifying configuration_filename() to not set
conf_format when checking for the UCM1 config filename fails.
Instead, to make sure that any errors about opening the file still report
the new path, configuration_filename() now resets the filename to the UCM2
path if the access() check has failed for both the UCM2 and UCM1 paths,
without touching conf_format.

Fixes: aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format, keep backward compatibility")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: Fix opening of master-configs by the card's longname
Hans de Goede [Tue, 19 Nov 2019 10:48:19 +0000 (11:48 +0100)]
ucm: Fix opening of master-configs by the card's longname

Prior to commit aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format,
keep backward compatibility").

The filename build in parse_verb_file() was build like this:
<prefix>/<uc_mgr->conf_file_name>/<file>

Where uc_mgr->conf_file_name would contain either the card_name or the
card's longname depending on the detection of a longname based config in
uc_mgr_import_master_config().

While the filename used in load_master_config() was build like this:
<prefix>/<card_name>/<card_name>.conf

And uc_mgr_import_master_config() first calls load_master_config()
with the card's longname and if that succeeds it overwrites
uc_mgr->conf_file_name with the longname so that the subsequent uses
of uc_mgr->conf_file_name in parse_verb_file() correctly use the longname.

But the new configuration_filename() helper added in commit aba2260ae7b5
_always_ builds the filename like this:
<prefix>/<uc_mgr->conf_file_name>/<file><suffix>

This breaks the loading of the master-config by its longname, as when
the longname is tried uc_mgr->conf_file_name still contains the card_name.

This commit fixes this by adding a dir parameter to configuration_filename()
and restoring the old behavior by passing card_name as dir in
load_master_config().

Fixes: aba2260ae7b5 ("ucm: switch to ucm2 directory and v2 format, keep backward compatibility")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoconf: check for include path duplicates
Jaroslav Kysela [Tue, 19 Nov 2019 09:55:29 +0000 (10:55 +0100)]
conf: check for include path duplicates

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoconf: fix the include paths support
Jaroslav Kysela [Mon, 18 Nov 2019 18:01:45 +0000 (19:01 +0100)]
conf: fix the include paths support

I omitted to use parent paths and the proper error code
when no paths are defined.

Fixes: f600310954e7 ("conf: improve the include paths code")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: fix memory leaks detected by the coverity checker
Jaroslav Kysela [Fri, 15 Nov 2019 11:52:36 +0000 (12:52 +0100)]
ucm: fix memory leaks detected by the coverity checker

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agopcm: add braces to condition (coverity)
Jaroslav Kysela [Fri, 15 Nov 2019 11:44:28 +0000 (12:44 +0100)]
pcm: add braces to condition (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoRelease v1.2.1 v1.2.1
Jaroslav Kysela [Thu, 14 Nov 2019 17:02:27 +0000 (18:02 +0100)]
Release v1.2.1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add possibility to keep order of childs for If blocks
Jaroslav Kysela [Thu, 14 Nov 2019 15:57:22 +0000 (16:57 +0100)]
ucm: add possibility to keep order of childs for If blocks

Because of the nature of the structured parser, it is not guaranteed
that the order of the parsed tree is equal to the lines in the source.

Add possibility to insert the If results before or after the selected
identifier like:

SectionDevice."Speaker" {
  ...
}

If.1 {
Condition { ... }
Before.SectionDevice "Speaker"
True { ... }
}
If.2 {
Condition { ... }
After.SectionDevice "Speaker"
True { ... }
}

If the "After" or "Before" identifiers are not found, the result is added
after the last entry in the block.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoconf: implement snd_config_add_before() and snd_config_add_after()
Jaroslav Kysela [Thu, 14 Nov 2019 15:56:05 +0000 (16:56 +0100)]
conf: implement snd_config_add_before() and snd_config_add_after()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: change the If block parsing
Jaroslav Kysela [Thu, 14 Nov 2019 14:13:36 +0000 (15:13 +0100)]
ucm: change the If block parsing

- evaluate always If before the other blocks

5 years agotopology: remove configuration files (moved to alsa-topology-conf repository)
Jaroslav Kysela [Wed, 13 Nov 2019 10:28:44 +0000 (11:28 +0100)]
topology: remove configuration files (moved to alsa-topology-conf repository)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agocreate separated libatopology library with the topology routines
Jaroslav Kysela [Tue, 12 Nov 2019 18:30:36 +0000 (19:30 +0100)]
create separated libatopology library with the topology routines

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: remove configuration files (moved to alsa-ucm-conf repository)
Jaroslav Kysela [Mon, 11 Nov 2019 16:03:26 +0000 (17:03 +0100)]
ucm: remove configuration files (moved to alsa-ucm-conf repository)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs: Add MinBufferLevel value
Curtis Malainey [Thu, 7 Nov 2019 01:58:02 +0000 (17:58 -0800)]
ucm: docs: Add MinBufferLevel value

Allows ucm to override minimum buffer level for platforms that
incorrectly report their buffer level.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: docs: Add EDID File value
Curtis Malainey [Thu, 7 Nov 2019 01:58:01 +0000 (17:58 -0800)]
ucm: docs: Add EDID File value

Add a sys path to the EDID file for the corresponding HDMI device so
userspace can use if needed

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agouse-case header file: add more references to correct ASCII ID parsers for CTL/mixer IDs
Jaroslav Kysela [Mon, 11 Nov 2019 13:35:02 +0000 (14:35 +0100)]
use-case header file: add more references to correct ASCII ID parsers for CTL/mixer IDs

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add snd_use_case_parse_selem_id()
Jaroslav Kysela [Mon, 11 Nov 2019 13:22:36 +0000 (14:22 +0100)]
ucm: add snd_use_case_parse_selem_id()

and add strict ucm_id checks to snd_use_case_parse_ctl_elem_id()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agomixer: simple - add snd_mixer_selem_id_parse() from amixer
Jaroslav Kysela [Mon, 11 Nov 2019 13:22:11 +0000 (14:22 +0100)]
mixer: simple - add snd_mixer_selem_id_parse() from amixer

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add If.Condition.RegexMatch
Jaroslav Kysela [Wed, 6 Nov 2019 09:44:29 +0000 (10:44 +0100)]
ucm: add If.Condition.RegexMatch

If.1 {
Condition {
Type RegexMatch
String "something to match"
Regex ".*(thing)"
}
...
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add ${CardComponents} substitution to the value string processing
Jaroslav Kysela [Wed, 6 Nov 2019 09:21:40 +0000 (10:21 +0100)]
ucm: add ${CardComponents} substitution to the value string processing

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: evaluate nested If blocks also in True/False blocks
Jaroslav Kysela [Wed, 6 Nov 2019 09:19:57 +0000 (10:19 +0100)]
ucm: evaluate nested If blocks also in True/False blocks

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add If.Condition.String to match strings and substrings
Jaroslav Kysela [Wed, 6 Nov 2019 08:51:47 +0000 (09:51 +0100)]
ucm: add If.Condition.String to match strings and substrings

Case insensitive string match:

If.1 {
Condition {
Type String
String1 "aa"
String2 "bb"
}
True {
...
}
}

Substring is present (case sensitive):

If.1 {
Condition {
Type String
Haystack "White Horse"
Needle "Horse"
}
True {
...
}
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add snd_use_case_parse_ctl_elem_id()
Jaroslav Kysela [Tue, 5 Nov 2019 19:04:54 +0000 (20:04 +0100)]
ucm: add snd_use_case_parse_ctl_elem_id()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add PlaybackCTL and CaptureCTL default values when they are not set
Jaroslav Kysela [Tue, 5 Nov 2019 13:21:07 +0000 (14:21 +0100)]
ucm: add PlaybackCTL and CaptureCTL default values when they are not set

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: small cosmetic uc_error change in execute_sequence()
Jaroslav Kysela [Tue, 5 Nov 2019 13:07:26 +0000 (14:07 +0100)]
ucm: small cosmetic uc_error change in execute_sequence()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add If condition block
Jaroslav Kysela [Tue, 5 Nov 2019 12:02:41 +0000 (13:02 +0100)]
ucm: add If condition block

The syntax is simple:

If./any-if-identificator/ {
  Condition {
    Type /type_here/
    /optional defines/
  }
  True {
    /block used when condition is evaluated as true/
  }
  False {
    /block used when condition is evaluated as false/
  }
}

The Type "ControlExists" is implemented:

Condition {
  Type ControlExists
  Device "hw:${CardId}"
  Control "iface=CARD,name='Headphone Jack'"
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: do not cache all control devices in get_card_long_name()
Jaroslav Kysela [Tue, 5 Nov 2019 09:21:36 +0000 (10:21 +0100)]
ucm: do not cache all control devices in get_card_long_name()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: parser - use less memory for integer/real values in parse_value()
Jaroslav Kysela [Tue, 5 Nov 2019 09:14:44 +0000 (10:14 +0100)]
ucm: parser - use less memory for integer/real values in parse_value()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: save the whole ctl info to the ctl_list structure
Jaroslav Kysela [Tue, 5 Nov 2019 09:06:37 +0000 (10:06 +0100)]
ucm: save the whole ctl info to the ctl_list structure

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add the run-time variable substitution
Jaroslav Kysela [Mon, 4 Nov 2019 15:18:07 +0000 (16:18 +0100)]
ucm: add the run-time variable substitution

Those two variables are supported:

  ${ConfName}      - configuration file name
  ${CardId}        - card identification string (like PCH)
  ${CardName}      - card name (driver)
  ${CardLongName}  - card long name (driver)
  ${env:ENV_NAME}  - returns the environment variable ENV_NAME

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: fix memory leaks for cdev, bin-file and tlv elements
Jaroslav Kysela [Mon, 4 Nov 2019 17:44:00 +0000 (18:44 +0100)]
ucm: fix memory leaks for cdev, bin-file and tlv elements

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: do not report failure when long name configuration does not exist
Jaroslav Kysela [Mon, 4 Nov 2019 16:14:40 +0000 (17:14 +0100)]
ucm: do not report failure when long name configuration does not exist

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: add support for multiple control devices, more aggresive caching
Jaroslav Kysela [Mon, 4 Nov 2019 13:42:45 +0000 (14:42 +0100)]
ucm: add support for multiple control devices, more aggresive caching

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: extend snd_use_case_mgr_open() to address the sound card directly
Jaroslav Kysela [Sun, 3 Nov 2019 18:05:54 +0000 (19:05 +0100)]
ucm: extend snd_use_case_mgr_open() to address the sound card directly

Some clients like pulseaudio wants to access the multiple instances
of sound cards. This patch adds prefixes like "hw:" to the card_name
argument to handle this. The card index (value) or card identification
(string) can be used for this prefix.

Also the prefix "strict:" was added to avoid the driver name and
driver long name matching. It might be useable for use case
configurations which are not bound to the one sound card.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: switch to ucm2 directory and v2 format, keep backward compatibility
Jaroslav Kysela [Sat, 9 Nov 2019 10:53:32 +0000 (11:53 +0100)]
ucm: switch to ucm2 directory and v2 format, keep backward compatibility

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoconf: improve the include paths code
Jaroslav Kysela [Sun, 10 Nov 2019 12:00:59 +0000 (13:00 +0100)]
conf: improve the include paths code

- various cleanups (more straight code and allocations)
- do not add the base config path /usr/share/alsa to the
  explicit include list of directories
  (it's not wanted for ucm configs)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: parse_verb_file() - remove folder_name variable and extra logic
Jaroslav Kysela [Sat, 2 Nov 2019 07:57:51 +0000 (08:57 +0100)]
ucm: parse_verb_file() - remove folder_name variable and extra logic

The member uc_mgr->conf_file_name already contains the used directory
name.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: fix uc_mgr_scan_master_configs() - skip correctly component directories
Jaroslav Kysela [Sat, 2 Nov 2019 07:36:46 +0000 (08:36 +0100)]
ucm: fix uc_mgr_scan_master_configs() - skip correctly component directories

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agopcm: the maximal rate is 768000Hz, fix the remain code
Jaroslav Kysela [Fri, 25 Oct 2019 11:43:31 +0000 (13:43 +0200)]
pcm: the maximal rate is 768000Hz, fix the remain code

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agoucm: cosmetic fix in get_card_long_name()
Jaroslav Kysela [Fri, 25 Oct 2019 11:42:41 +0000 (13:42 +0200)]
ucm: cosmetic fix in get_card_long_name()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agopcm: fix the period_size for direct plugins (dmix, dsnoop, dshare)
Jaroslav Kysela [Mon, 14 Oct 2019 07:34:35 +0000 (09:34 +0200)]
pcm: fix the period_size for direct plugins (dmix, dsnoop, dshare)

BugLink: https://github.com/alsa-project/alsa-lib/issues/8
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
5 years agopcm: Fix the wrong PCM object passed for locking/unlocking
Takashi Iwai [Tue, 24 Sep 2019 10:10:41 +0000 (12:10 +0200)]
pcm: Fix the wrong PCM object passed for locking/unlocking

Most of PCM API functions have snd_pcm_lock()/unlock() wraps for the
actual calls of ops, and some plugins try to unlock/relock internally
for the given PCM object.  This, unfortunately, causes a problem in
some configurations and leads to the unexpected behavior or deadlock.

The main problem is that we call snd_pcm_lock() with the given PCM
object, while calling the ops with pcm->op_arg or pcm->fast_op_arg as
the slave PCM object.  Meanwhile the plugin code assumes that the
passed PCM object is already locked, and calls snd_pcm_unlock().
This bug doesn't hit always because in most cases pcm->op_arg and
fast_op_arg are identical with pcm itself.  But in some configurations
they have different values, so the problem surfaces.

This patch is an attempt to resolve these inconsistencies.  It
replaces most of snd_pcm_lock()/unlock() calls with either pcm->op_arg
or pcm->fast_op_arg, depending on the call pattern, so that the plugin
code can safely run snd_pcm_unlock() to the given PCM object.

Fixes: 54931e5a5455 ("pcm: Add thread-safety to PCM API")
Reported-by: Ben Russell <thematrixeatsyou@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
5 years agopcm: chmap: Fix memory leak at snd_pcm_set_chmap()
Takashi Iwai [Tue, 24 Sep 2019 11:48:37 +0000 (13:48 +0200)]
pcm: chmap: Fix memory leak at snd_pcm_set_chmap()

snd_pcm_set_chmap() leaks the memory returned from snd_pcm_get_chmap()
without releasing.  Add the missing free() call as well as a slight
code refactoring.

Reported-by: Conrad Jones
BugLink: https://github.com/alsa-project/alsa-lib/pull/11
Fixes: d20e24e5d161 ("chmap: Always succeed setting the map to what it already is")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotopology: Fix variable overflow in split_format
Marcin Pietraszko [Mon, 26 Aug 2019 11:51:41 +0000 (13:51 +0200)]
topology: Fix variable overflow in split_format

The 1 which was 32-bit long, when left-shifted by more than 31 caused
an overflow, which resulted in some of the formats being not supported.

Signed-off-by: Marcin Pietraszko <marcin.pietraszko@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotopology: add support to parse private data for pcm
Keyon Jie [Thu, 1 Aug 2019 09:15:06 +0000 (17:15 +0800)]
topology: add support to parse private data for pcm

We have private data section in struct snd_soc_tplg_pcm, but alsatplg
doesn't support handling it yet, here add handling in tplg_parse_pcm()
to enable it.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: dshare: allow missing bindings
Adam Miartus [Wed, 24 Jul 2019 10:13:00 +0000 (12:13 +0200)]
pcm: dshare: allow missing bindings

allow opening the device and start the audio clock without blocking
any channel

this is required if the audio clock has to be available all the time,
even when application is not streaming audio data

Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: return -ENOSYS when ops or fast_ops callback is NULL
Adam Miartus [Wed, 24 Jul 2019 10:12:59 +0000 (12:12 +0200)]
pcm: return -ENOSYS when ops or fast_ops callback is NULL

function is allowed to continue until it checks for error variable, as to
not conflict with original implementation flow

for simple functions involving only one line, return error immediately in
case callback is NULL

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: improve error checking in write_wav_header function
Adam Miartus [Fri, 5 Jul 2019 14:40:48 +0000 (16:40 +0200)]
pcm_file: improve error checking in write_wav_header function

previously errno would be returned even for cases where it may have
not been populated, for example one of the write functions failing,
or writing only partial buffer,

now progress through write operations separately and report errno when
appropriate

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: in case of failed write clear file buffer variables
Adam Miartus [Mon, 1 Jul 2019 13:25:18 +0000 (15:25 +0200)]
pcm_file: in case of failed write clear file buffer variables

previously, in case of failed write to output file, error is returned
from snd_pcm_writei/read APIs, user could run pcm_drain as fallback and
encounter an assert, since drain would try to write remaining file
buffer to a file

if failed to write to output file in first place, it makes sense to clear
current internal pmc_file file buffer variables

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm_file: use EIO instead of EPIPE when failing to write output file
Adam Miartus [Mon, 1 Jul 2019 13:25:16 +0000 (15:25 +0200)]
pcm_file: use EIO instead of EPIPE when failing to write output file

EPIPE is defined as XRUN which is not entirely correct in this condition

failing to write to a file in pcm_file plugin can not be simply recovered
by a retry as user of the api might be led to believe when receiving EPIPE

use EIO instead to indicate a different kid of error that may not be
recoverable by retry

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>