Commit graph

4153 commits

Author SHA1 Message Date
Jaroslav Kysela
22d5ca8b6b ucm: add a check for the empty configuration
Return an error if the UCM configuration is empty (no verbs
or no boot sequence).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-10-06 10:43:13 +02:00
Jaroslav Kysela
e80f35611d ucm: Handle 'Error' keyword in the master file
With the conditional blocks, it may be useful to terminate
the hardware detection from the configuration. Introduce
'Error' keyword for the master UCM configuration file.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-10-06 10:23:25 +02:00
Tanjeff-N. Moos
c1e72460de control: Add documentation for snd_ctl_elem_value_*.
Signed-off-by: Tanjeff-N. Moos <tanjeff@cccmz.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-09-03 09:12:41 +02:00
Tanjeff-N. Moos
84185b5c94 control: Improve general control interface documentation.
Signed-off-by: Tanjeff-N. Moos <tanjeff@cccmz.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-09-03 09:11:27 +02:00
Jaroslav Kysela
472ab5db67 topology: improve the printf buffer management
The commit d04e72c9a5 introduced
the dynamic printf buffer allocation for each tplg_save_printf()
call.

Introduce 'struct tplg_buf' which carries extra information about
the temporary printf buffer and the destination buffer to save allocation
requests.

The printf buffer is also allocated using 1024 bytes chunks.

A comparison between 'alloc everyting' and 'cache+chunk alloc' for the
random picked topology file:

  1: 18,620 allocs, 18,620 frees, 7,239,688 bytes allocated
  2: 12,490 allocs, 12,490 frees, 962,568 bytes allocated

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 19:51:49 +02:00
Jaroslav Kysela
ab73253924 topology: fix the unaligned access
Introduce unaligned_get32/put32 helpers to deal with the
packed structures.

Use the gcc __BYTE_ORDER__ defines for the endian checks.
It may be improved to support other compilation environment.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 14:27:30 +02:00
Jaroslav Kysela
84c6aeef5c topology: fix sort_config()
The temporary config array must be initialized for all compound types.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 14:26:02 +02:00
Jaroslav Kysela
6ca1ddfbcd topology: fix some gcc10 warnings (labs, signess)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:25:07 +02:00
Jaroslav Kysela
dc778bade6 topology: return correct value in tplg_save_printf()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:21:26 +02:00
Piotr Maziarz
d04e72c9a5 topology: Make buffer for saving dynamic size
Some fields can exceed size limit, e.g. private data has no size
restriction. Therefore it needs to be dynamically increased.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
6b0fb2bc7e topology: decode: Add DAI name printing
DAI name is a part of topology binary. Not printing makes data loss while
converting from binary to standard ALSA configuration file.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
d93b346299 topology: decode: Print sig_bits field in PCM capabilities section
Not printing this field makes data loss while converting from binary
to standard ALSA configuration file.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
acbb0e3b17 topology: decode: Fix decoding PCM formats and rates
Not checking _LAST format and rate, which are valid indexes in arrays,
makes data loss while converting binary to standard ALSA configuration
file.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
c32498603a topology: decode: Change declaration of enum decoding function
Size constraints are always checked before invoking
tplg_decode_control_enum1. There is no need to validate it twice.
Alos moved debug print about size to invoking function, since now it's it
responsibility to check size.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
56a096ca2c topology: decode: Fix printing texts section
Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
f1435207a2 topology: decode: Add enum control texts as separate element
Texts are separate sections that should referenced by enum control.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
11d4a5aa72 topology: decode: Remove decoding values for enum control
Values have no representation in standard ALSA configuration files,
therefore there is no need to populate them. Also memory for values
wasn't allocated which was causing undefined behaviour.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
346a5efa87 topology: decode: Fix infinite loop in decoding enum control
Accessing memory outside of allocated boundaries caused segmentation fault.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Piotr Maziarz
1ac965184e topology: decode: Fix channel map memory allocation
Memory allocated on the stack was referenced outside of the function scope
caused undefined behaviour.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-31 13:03:01 +02:00
Jaroslav Kysela
ed75249852 conf: quote also strings with '*' and '#' characters in string_print()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-18 16:53:35 +02:00
Tanjeff-N. Moos
e097dd491a control: Add documentation for snd_ctl_elem_list_*.
Signed-off-by: Tanjeff-N. Moos <tanjeff@cccmz.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-08-18 12:18:30 +02:00
Tanu Kaskinen
fece807386 README: add patch submission instructions
Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-08-16 09:36:01 +02:00
Vijay Palaniswamy
82cb27c165 pcm: dmix: fix access to sum-buffer in non-interleaved mixing mode
When dmix uses non-interleaved mixing mode the offset and step width
to sum_buffer was calculated by using the dmix channels instead of
the slave channels. This leads to audio distortions due to frame
corruption.

example:
- With below configuratio, Do aplay on both device in parallel for
audio distortion

pcm.dmix_2_channels {
        type dmix
        ipc_key 5678293
        ipc_perm 0660
        ipc_gid audio
        bindings [0 1]

        slave {
                pcm "hardware"
                channels 2
                periods  4
                period_time 40000
        }
}

pcm.dmix_1_channels {
        type dmix
        ipc_key 5678293
        ipc_perm 0660
        ipc_gid audio
        bindings [0]

        slave {
                pcm "hardware"
                channels 1
                periods  4
                period_time 40000
        }
}

pcm.hardware {
        type hw
        card 0
        channels 2
        rate 48000
        format S16_LE
}

Signed-off-by: Vijay Palaniswamy <vijay.palaniswamy@in.bosch.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-08-13 16:19:30 +02:00
Kai-Heng Feng
464c2f8b61 conf: USB-Audio: Disable IEC958 on Lenovo ThinkStation P620
Both USB audio cards on Lenovo ThinkStation P620 don't support IEC958,
so disable IEC958 accordingly.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-08-11 13:17:15 +02:00
Jaroslav Kysela
a3ca4803cb control: ctlparse - fix enum values in '' or ""
This comit fixes the enum value string parser
(fixes aaf3a081bf).

BugLink: https://github.com/alsa-project/alsa-ucm-conf/pull/40
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-27 18:29:09 +02:00
omar
a80606d1ab conf: pcm - USB - Added S/PDIF fix for Asus Xonar SE
Resolves #70
From: omar <odzinic@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-27 11:46:53 +02:00
Matthias Reichl
36e4b296d2 pcm: iec958: set channel status bits according to rate and format
This mimics snd_pcm_create_iec958_consumer in the kernel.

The rate and wordlength bits will only be modified if they are
set to "not indicated", which is now the default if no status
option is used.

This allows applications to override parameters determined from
the stream or implement channel status bits extensions without
needing to change pcm_iec958 code.

Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-07-14 12:52:07 +02:00
Matthias Reichl
8defc5c2a6 pcm: iec958: implement HDMI HBR audio formatting
High bitrate compressed audio data like DTS HD or MAT is usually
packed into 8-channel data. The HDMI specs state this has to be
formatted as a single IEC958 stream, compared to normal multi-
channel PCM data which has to be formatted as parallel IEC958 streams.

As this single-stream formatting mode may break existing setups that
expect non-PCM multichannel data to be formatted as parallel IEC958
streams it needs to be explicitly selected by setting the hdmi_mode
option to true.

The single-stream formatting implementation is prepared to cope with
arbitrary channel counts but only limited testing was done for channel
counts other than 8.

Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-07-14 12:51:33 +02:00
Takashi Iwai
d824b461ae pcm: dmix: Fix semaphore usage with lockless operation
As Maarten Baert recently reported, the current dmix code applies the
semaphore unnecessarily around mixing streams even when the lockless
mix operation is used on x86.  This was rather introduced mistakenly
at the commit 267d7c7281 ("Add support of little-endian on
i386/x86_64 dmix") where the generic dmix code was included on x86,
too.

For achieving the original performance back, this patch changes the
semaphore handling to be checked at run time instead of statically at
compile time.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-07-07 11:57:03 +02:00
Takashi Iwai
4759865c86 pcm: dmix: make lockless operation optional
The recently reported (but a long-standing) bug about the
unconditional semaphore usage in the dmix implies that basically we've
had no problem with the locking in the practical usages over years.
Although the lockless operation has a clear merit, it's a much higher
CPU usage (especially on some uncached pages), and it might lead to a
potential deadlock in theory (which is hard to reproduce at will,
though).

This patch introduces a new configure option "--enable-lockless-dmix"
or "--disable-lockless-dmix" to let user choose the default dmix
operation mode.  The usage of the lockless mixing has been already
conditionally enabled via asoundrc and card config
"direct_memory_access", so we just need to set the default value based
on it.

In this patch, the default is set off to the lockless mixing, i.e. the
generic mixing is chosen.  It makes more sense from the performance
POV.  For any users who still require the lockless operation, it can
be enabled either via configure option or the asoundrc.

The magic number used in the shmem is also changed depending on the
operation mode.  It's just for safety, not to conflict both operation
modes with each other.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-07-07 11:56:41 +02:00
Takashi Sakamoto
877bdf95fd ctl: improve documentation for identifier of control element
In documentation, there're two ways relevant to the identifier of control
element. However, the case of combination has the lack of parameters.

This commit improves documentation in this point.

Fixes: f3c24de8c0 ("ctl: add an overview for design of ALSA control interface")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-06 16:41:48 +02:00
Jaroslav Kysela
32addac948 ucm: substitute the merged tree completely
We need to define the common shared configuration like for multiple
HDMI devices or so. Substitute the whole merged configuration tree
including identifiers.

Fixes: https://github.com/alsa-project/alsa-lib/issues/67
Fixes: dcef48f13d
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-06 16:34:35 +02:00
Jaroslav Kysela
30d12e930c ucm: fix parse_get_safe_name() - safe name must be checked after substitution
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-03 14:48:18 +02:00
Jaroslav Kysela
485930ea5d ucm: substitution - remove duplicate allow_empty assignment
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-30 09:22:12 +02:00
Jaroslav Kysela
cac5a62dcf Release v1.2.3.2
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-29 12:51:08 +02:00
Hans de Goede
f4e48d0d15 ucm: Allow empty strings in "${var:...}" substitutions
Recent ucm-conf changes introduce checks like this one in various places:

If.mspk {
        Condition {
                Type String
                Empty "${var:MonoSpeaker}"
        }
        True ...
        False ...
}

The 'Empty "${var:MonoSpeaker}"' part can only every succeed if we do:

Define.MonoSpeaker ""

But so far that would result in an error like this one:

ALSA lib ucm_subs.c:367:(uc_mgr_get_substituted_value) variable '${var:MonoSpeaker}' is not defined in this context!
ALSA lib main.c:983:(snd_use_case_mgr_open) error: failed to import cht-bsw-rt5672 use case configuration -22
alsaucm: error failed to open sound card cht-bsw-rt5672: Invalid argument

This commit fixes this by allowing empty values for "${var:...}"
substitutions.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-28 17:51:46 +02:00
Jaroslav Kysela
eb94bf0280 alsa.conf: load /etc/asound.conf or /usr/etc/asound.conf not both
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-24 19:28:35 +02:00
Jaroslav Kysela
7c9f0fa436 ucm: implement AlwaysTrue Condition.Type
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-24 19:27:05 +02:00
Mark Hills
676e2f0811 pcm: Annotate the _avail functions
I took time to understand these functions in the context of the
rest of the code, which would have been a lot quicker with a comment
like this.

Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 13:01:13 +02:00
Mark Hills
46c65dd490 dsnoop: Make use of the (previously unused) function
Match the equivalent funciton for playback. This is on the assumption
that values should be capped at zero, which is what _rewindable()
implements.

Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 13:00:32 +02:00
Mark Hills
ad0684089e dsnoop: Another bug where the empty, not full, part of the ringbuffer was observed
This looks like a simple mistake dating back to 2003 (commit 7470a5b9)
where code originated from dmix.

Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 12:59:51 +02:00
Mark Hills
19c7de16fd dsnoop: The stop threshold was not implemented correctly
The previous implementation would mean that stop_threshold behaved
erratically. The intent is to detect that the buffer is too full,
and stop.

In practice, I don't think this was a bug in practice for applications
which don't adjust the stop_threshold. The line above catches those cases.

Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 12:59:00 +02:00
Mark Hills
243105769b pcm: Annotate the _delay functions based on findings from the previous bug
Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 12:58:25 +02:00
Mark Hills
1a169c21af dsnoop: The delay presented to snd_pcm_status_delay() was incorrect
This was the original bug that caused me to start looking at the
ring buffer functions.

In the API this is documented as:

  "Delay is distance between current application frame position and
   sound frame position. It's positive and less than buffer size in
   normal situation, negative on playback underrun and greater than
   buffer size on capture overrun. "

Because dsnoop was returning the buffer space available to the hardware
the return value was always quite large, and moved in the wrong
direction.

With this patch, dsnoop now gives results which are comparable to using
the "hw" device directly. My test case was with snd-echo3g (Layla3G).

Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 12:57:08 +02:00
Mark Hills
a510754af2 control: Fix a bug that prevented namehint behaviour
Looks like the documented behaviour was broken in commit 1ba513f9 in
2006, with the introduction of multiple fields.

I've chosen to match the described behaviour. Prior to this patch,
using namehint could be made to work by exploiting the lack of escaping
of the "name", populating the other fields:

  "plug:front|DESCDo all conversions for front speakers"

rather than that which is documented and presumed to be the intention
for asoundrc files:

  "plug:front|Do all conversions for front speakers"

Everything seems to strongly suggest nobody is using this feature; I can
find no working examples through a web search and probably someone
would have hit this bug. It's not documented in configuration, only in
the snd_device_name_hint() call. So it would probably clutter things to
provide compatibility for the old behaviour.

I have found it to be very useful since working in Chromium, where it is
the only way to expose chosen ALSA devices to web applications.

A temporary buffer is required to null-terminate the string.  I see no
use of alloca() in the code, presumably to avoid unbounded stack size.
So memory is allocated on the heap.

Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 12:49:36 +02:00
Mark Hills
6be096eed9 control: Fix typos in the namehint example
Ths "namehint" is a list, and there doesn't seem to have been any
history where the separator would be a colon.

Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 12:48:38 +02:00
Takashi Iwai
2c93faaf80 conf: Add /usr/etc to the default search paths
There's been some recent action to move the distribution-default setup
from /etc to /usr/etc, and we should follow that, too.

This patch adds /usr/etc/alsa.conf.d and /usr/etc/alsa.conf to the
default search paths.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-06-23 12:47:23 +02:00
Jaroslav Kysela
730481ec2f ucm: simplify get_by_card() in parser.c
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-22 09:05:24 +02:00
Jaroslav Kysela
089bb8762f ucm: fix the possible buffer overflow (substitution)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-22 09:05:05 +02:00
Jaroslav Kysela
b13b911605 Release v1.2.3.1
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-18 19:24:32 +02:00