Commit graph

3794 commits

Author SHA1 Message Date
Hans de Goede
86c449d231 ucm: Fix opening of master-configs by the card's longname
Prior to commit aba2260ae7 ("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 aba2260ae7
_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: aba2260ae7 ("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>
2019-11-19 12:25:19 +01:00
Jaroslav Kysela
c28618353b conf: check for include path duplicates
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-19 10:55:29 +01:00
Jaroslav Kysela
39fda8a69a conf: fix the include paths support
I omitted to use parent paths and the proper error code
when no paths are defined.

Fixes: f600310954 ("conf: improve the include paths code")

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-18 19:03:06 +01:00
Jaroslav Kysela
6a76c01a01 ucm: fix memory leaks detected by the coverity checker
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-15 12:52:36 +01:00
Jaroslav Kysela
6fbf87c402 pcm: add braces to condition (coverity)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-15 12:44:28 +01:00
Jaroslav Kysela
8006a8e03c Release v1.2.1
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 18:02:27 +01:00
Jaroslav Kysela
a0b00a954e 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>
2019-11-14 17:21:20 +01:00
Jaroslav Kysela
4c021697f1 conf: implement snd_config_add_before() and snd_config_add_after()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 16:56:05 +01:00
Jaroslav Kysela
4724158c0a ucm: change the If block parsing
- evaluate always If before the other blocks
2019-11-14 15:13:38 +01:00
Jaroslav Kysela
cdc8aacbb5 topology: remove configuration files (moved to alsa-topology-conf repository)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:01:16 +01:00
Jaroslav Kysela
75d393a563 create separated libatopology library with the topology routines
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:01:12 +01:00
Jaroslav Kysela
1f37ba2a2b ucm: remove configuration files (moved to alsa-ucm-conf repository)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:54 +01:00
Curtis Malainey
35e737f2ec 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>
2019-11-14 15:00:40 +01:00
Curtis Malainey
eab3835c36 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>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
e6fbc84c16 use-case header file: add more references to correct ASCII ID parsers for CTL/mixer IDs
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
5c88b18371 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>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
4ce38a5ff4 mixer: simple - add snd_mixer_selem_id_parse() from amixer
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
1b14643384 ucm: add If.Condition.RegexMatch
If.1 {
	Condition {
		Type RegexMatch
		String "something to match"
		Regex ".*(thing)"
	}
	...
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
900638ff4d ucm: add ${CardComponents} substitution to the value string processing
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
7ccaa08693 ucm: evaluate nested If blocks also in True/False blocks
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
b7d74c6977 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>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
cd4b07ffbd ucm: add snd_use_case_parse_ctl_elem_id()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
530e8ea4c6 ucm: add PlaybackCTL and CaptureCTL default values when they are not set
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
c01e3d30b8 ucm: small cosmetic uc_error change in execute_sequence()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
8a36e38dc4 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>
2019-11-14 15:00:37 +01:00
Jaroslav Kysela
b9b2247943 ucm: do not cache all control devices in get_card_long_name()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 14:57:01 +01:00
Jaroslav Kysela
27f97ab585 ucm: parser - use less memory for integer/real values in parse_value()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:12:21 +01:00
Jaroslav Kysela
d8dfe4dac7 ucm: save the whole ctl info to the ctl_list structure
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:12:21 +01:00
Jaroslav Kysela
0dd89f3892 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>
2019-11-10 13:12:21 +01:00
Jaroslav Kysela
40aef87f1e ucm: fix memory leaks for cdev, bin-file and tlv elements
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:12:21 +01:00
Jaroslav Kysela
86643bc9a9 ucm: do not report failure when long name configuration does not exist
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:12:20 +01:00
Jaroslav Kysela
32ff0ba7a3 ucm: add support for multiple control devices, more aggresive caching
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:11:35 +01:00
Jaroslav Kysela
be6deb927f 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>
2019-11-10 13:10:43 +01:00
Jaroslav Kysela
aba2260ae7 ucm: switch to ucm2 directory and v2 format, keep backward compatibility
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:10:33 +01:00
Jaroslav Kysela
f600310954 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>
2019-11-10 13:05:53 +01:00
Jaroslav Kysela
6598e38856 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>
2019-11-02 08:57:53 +01:00
Jaroslav Kysela
e61913f94c ucm: fix uc_mgr_scan_master_configs() - skip correctly component directories
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-02 08:36:46 +01:00
Jaroslav Kysela
63ffd41d5f pcm: the maximal rate is 768000Hz, fix the remain code
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-25 13:43:31 +02:00
Jaroslav Kysela
33afdc6745 ucm: cosmetic fix in get_card_long_name()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-25 13:42:41 +02:00
Jaroslav Kysela
7a345a5c20 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>
2019-10-14 09:35:08 +02:00
Takashi Iwai
df483d3fe5 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: 54931e5a54 ("pcm: Add thread-safety to PCM API")
Reported-by: Ben Russell <thematrixeatsyou@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-09-24 13:55:16 +02:00
Takashi Iwai
0732e47e6b 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: d20e24e5d1 ("chmap: Always succeed setting the map to what it already is")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-09-24 13:48:37 +02:00
Marcin Pietraszko
1d7a131f78 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>
2019-08-27 09:37:32 +02:00
Keyon Jie
66a2d53f42 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>
2019-08-06 12:50:59 +02:00
Adam Miartus
845243bcc2 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>
2019-07-24 15:18:05 +02:00
Adam Miartus
3bf780dcc3 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>
2019-07-24 15:16:32 +02:00
Adam Miartus
d7ee2a9a30 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>
2019-07-05 17:00:15 +02:00
Adam Miartus
de1a9b2e81 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>
2019-07-03 14:23:03 +02:00
Adam Miartus
61b0f8f3f2 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>
2019-07-03 14:22:43 +02:00
Adam Miartus
053b430980 pcm_file: return errno in case of a failed write operation
allows correct error code propagation for snd_pcm_file_write_bytes caller

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-06-24 14:24:04 +02:00