The documentation specifies three different rounding modes, but this
is wrong, because they all end up calling snd_tlv_convert_from_dB,
which only has two rounding modes.
Signed-off-by: David Henningsson <diwic@ubuntu.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
DB410c board has support for both Digital and Analog audio. Digital
audio is over HDMI and analog is over codec chip integrated inside the
APQ8016 SOC.
It can support:
- 3 Microphones: Primary Mic(Handset mic), Headset Mic and Secondary
- 2 Digital Microphones.
- Earpiece.
- Headset.
- Loud Speaker.
- HDMI.
[Riku: squashed Srinivas's patches together and converted spaces to tabs]
Mengdong Lin [Fri, 22 Jul 2016 05:12:54 +0000 (13:12 +0800)]
topology: Fix the missing referenced elem ptr when merging private data
tplg_copy_data() should set the valid referenced data element pointer
on success. The caller will double check this pointer for all kinds of
references, including controls and data.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
ctl: use condition statements instead of assert() for new APIs to add an element set
Usage of assert() is not better practice of programming as shared library
APIs. They should return appropriate error code to promote applications to
handle error state.
This commit applies condition statements with return value of -EINVAL,
instead of assert(). As a backward compatibility for existent applications,
old APIs still call assert().
Mengdong Lin [Wed, 20 Jul 2016 01:53:12 +0000 (09:53 +0800)]
topology: Check address and length before string copy
elem_copy_text() is widely used for string copy in topology. Because some
name fields are not mandatory for users, sometimes the source can be
invalid and we should not do the copy. So we add check here.
Mengdong Lin [Wed, 20 Jul 2016 01:53:03 +0000 (09:53 +0800)]
topology: Add ATTRIBUTE_UNUSED for unused parameters to fix compiler warning
This commit adds ATTRIBUTE_UNUSED to the unused parameter 'tplg' for
function tplg_parse_streams() and tplg_parse_fe_dai(). These two functions
need to keep 'tplg' as ops for tplg_parse_compound().
The compiler warnings below are fixed:
pcm.c: In function 'tplg_parse_streams':
pcm.c:262:43: warning: unused parameter 'tplg' [-Wunused-parameter]
static int tplg_parse_streams(snd_tplg_t *tplg, snd_config_t *cfg,
^
pcm.c: In function 'tplg_parse_fe_dai':
pcm.c:324:42: warning: unused parameter 'tplg' [-Wunused-parameter]
static int tplg_parse_fe_dai(snd_tplg_t *tplg, snd_config_t *cfg,
Mengdong Lin [Wed, 20 Jul 2016 01:52:52 +0000 (09:52 +0800)]
topology: Remove support for control flag SNDRV_CTL_ELEM_ACCESS_USER
This access flag is used to add controls from user space by ioctl.
But topology only configures controls in user space and these controls
will eventually be created by ASoC in kernel, so topology should not
support this flag.
ctl: rename APIs to add an element set so that their names are appropriate
In this development period, some APIs have already been added. Most of
them are to add an element set, while their names are not so appropriate
against their feature. This is due to following to names of old APIs.
Mengdong Lin [Fri, 15 Jul 2016 12:19:58 +0000 (20:19 +0800)]
topology: Tuple type can have an extenstion
After the type specific string ("uuid", "string", "byte", "short" and
"word"), users may append a string, like "uuidxxx". The topology parser
will check the first few characters to get the tuple type.
This can allow users to put multiple tuples of the same type into one
vendor tuple section (SectionVendorTuples), e.g. parameters of multiple
firmware modules.
Mengdong Lin [Fri, 15 Jul 2016 12:18:59 +0000 (20:18 +0800)]
topology: Change uuid value to 16 separate characters in text conf file
Previously in text conf file, the uuid value of vendor tuples is a
16-characer string. Now change it to 16 characters separated by commas,
easier for users to edit it manually.
Mengdong Lin [Fri, 15 Jul 2016 12:17:43 +0000 (20:17 +0800)]
topology: An element can refer to multipe data sections in text conf file
Previously in text conf file, an element can only refer to one data
section (SectionData). Now it can also refer to a list of data sections.
Thus users can split groups of firmware parameters to multiple data
sections, and put them all in the reference list.
Finally, data of these data sections will be merged, in the same order as
they are in the reference list, as the element's private data for kernel.
We still support the original syntax of reference to a single data
section. The doc is updated for the syntax extension.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
mixer: remove alloca() from elem_write_switch_constant()
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keep storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
mixer: include library local header to find layout of structures
Inner this library, implementation of each features can find actual layout
of structures by including local header. Although, mixer feature is written
without the header and as the same way for applications. This brings some
inefficiencies such as usage of alloca() to keep memory objects for the
structures.
This commit includes the header for further improvements in mixer
feature.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
conf: remove alloca() from snd_func_private_pcm_subdevice()
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
conf: remove alloca() from snd_func_pcm_args_by_class()
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
pcm: remove alloca() from snd_pcm_query_chmaps_from_hw()
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
pcm: remove alloca() from snd_pcm_hw_change_timer()
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
pcm: remove alloca() from _snd_pcm_hook_ctl_elems_install()
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
pcm: remove alloca() from snd_pcm_direct_set_timer_params
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
pcm: remove alloca() from snd_pcm_direct_initialize_poll_fd()
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
pcm: remove alloca() from snd_pcm_direct_initialize_slave
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
Both of alloca() and automatic variables keeps storages on stack, while
the former generates more instructions than the latter. It's better to use
the latter if the size of storage is computable at pre-compile or compile
time; i.e. just for structures.
This commit obsolete usages of alloca() with automatic variables.
ctl: add compatibility information for snd_ctl_elem_info_set_dimension()
I forgot it when committing to the API.
Fixes: 16812b70daeb('ctl: add an API to set dimension levels to element information') Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
For making the debugging with any deadlocks by the newly introduced
thread-safety feature, add a check with LIBASOUND_THREAD_SAFE
environment variable. When this variable is set to "0", alsa-lib PCM
forcibly disables the whole thread-safe pthread mutex calls.
Takashi Iwai [Thu, 30 Jun 2016 15:24:42 +0000 (17:24 +0200)]
pcm: Remove home brew atomic operations
We've had a few home brew atomic operations in a couple of places in
the PCM code. This was for supporting the concurrent accesses, but in
practice, it couldn't cover the race properly by itself alone.
Since we have a wider concurrency protection via mutex now, we can get
rid of these atomic codes, which worsens the portability
significantly.
Takashi Iwai [Thu, 30 Jun 2016 13:32:40 +0000 (15:32 +0200)]
pcm: Add thread-safety to PCM API
Traditionally, many of ALSA library functions are supposed to be
thread-unsafe, and applications are required to take care of thread
safety by themselves. However, people never be careful enough, and
almost all applications fail in this regard.
This patch is an attempt to harden the thread safety in exported PCM
functions in a simplistic way: just wrap some of exported functions
with the pthread mutex of each PCM object. Not all API functions are
wrapped by the mutex since it doesn't make sense. Instead, the
patchset covers only the functions that may be likely called
concurrently. The supposedly thread-safe API functions are marked in
the document.
For achieving the feature, two new fields are added snd_pcm_t when the
option is enabled: thread_safe and lock. The former indicates that
the plugin is thread-safe that doesn't need this workaround and the
latter is the pthread mutex. Currently only hw plugin have
thread_safe=1. So, the most of real-time sensitive apps won't be
influenced by this patchset.
Although the patch covers most of PCM ops, a few snd_pcm_fast_ops are
left without the extra mutex locking: namely, the ones that may have
blocking behavior, i.e. resume, drain, readi, writei, readn and
writen. These are supposed to handle own locking in the callbacks.
Also, if anyone wants to disable this new thread-safe API feature, it
can be still turned off via --disable-thread-safety configure option.
pcm_direct.c: In function ‘snd1_pcm_direct_prepare’:
pcm_direct.c:821:2: warning: enumeration value ‘SND_PCM_STATE_PREPARED’ not handled in switch [-Wswitch]
switch (snd_pcm_state(dmix->spcm)) {
^
pcm_hw.c: In function ‘_snd_pcm_hw_open’:
pcm_hw.c:1816:16: warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]
return err;
^
In file included from ../../include/local.h:165:0,
from tplg_local.h:17,
from data.c:20:
data.c: In function ‘tplg_parse_tuples’:
../../include/error.h:64:21: warning: ‘id’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, __VA_ARGS__) /**< Shows a sound error message. */
^
data.c:576:14: note: ‘id’ was declared here
const char *id;
^
topology: apply the same type to compared two variables
This commit fixes below compiler warnings.
data.c: In function ‘get_token_value’:
data.c:262:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < tokens->num_tokens; i++) {
^
data.c: In function ‘copy_tuples’:
data.c:351:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < tuples->num_sets ; i++) {
^
data.c:378:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 0; j < tuple_set->num_tuples; j++) {
^
data.c: In function ‘tplg_free_tuples’:
data.c:723:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < tuples->num_sets; i++)
^
data.c: In function ‘get_tokens’:
data.c:276:6: warning: unused variable ‘err’ [-Wunused-variable]
int err = 0;
^
data.c: In function ‘has_tuples’:
data.c:302:6: warning: unused variable ‘err’ [-Wunused-variable]
int err = 0;
^
hctl: remove assertion from element event handler because removal event overwrites all of queued events
In ALSA control core, when several events occurs for an element, they're
represented bit mask (struct snd_ctl_event.data.elem.mask). Thus userspace
applications can handles these events separately in one I/O operation.
There's an exception; removal event. This is represented by all of bits in
the mask. Therefore, when a removal event occurs for an element, all of
queued events for the element are overwritten.
This works worse for a combination of applications which add/remove control
elements and applications which keep a cache of elements. For example,
let's assume a case that:
1.some elements are added by ioctl(SNDRV_CTL_IOCTL_ELEM_ADD).
2.ALSA control core handles the request and queues 'add' event.
3.applications don't read the event yet.
4.the elements are removed by ioctl(SNDRV_CTL_IOCTL_ELEM_REMOVE)
5.ALSA control core handles the request and queues 'removal' event by
overwriting queued events.
6.applications read the event at last.
7.the applications cannot find removed elements in their cache data.
Especially, when applications use hctl interface of ALSA userspace library,
this situation occurs because the interface is designed to keep element
cache implicitly inner the library. PulseAudio is such an application. When
executing a test program of ALSA library (test/user-ctl-element-set.c),
pulseaudio process aborts due to assertion at calls of
snd_hctl_handle_events().
The rule to represent events is in ALSA kernel/userspace interfaces
(UAPI header) and it's difficult to improve the rule. Therefore,
developers should pay enough attention to the fact that userspace
applications can receive removal events for elements which are not
notified with 'add' event.
For this reason, this commit removes assertion from event handler of ALSA
hctl API.
ctl: improve documentation of APIs to add an element set
Currently, documentation of APIs to add an element set describes causes of
errors partly. But it gives an opinion to describe them thoroughly. This
is not good for users.
This commit changes the documentation so that it partly describes the
causes.
test: add linker flag with pthread for pcm-multi-thread stress test
This test program is a pthread application, while Makefile has no flags
for linker about pthread library. This can cause below error.
$ make pcm-multi-thread
CCLD pcm-multi-thread
/usr/bin/ld: pcm-multi-thread.o: undefined reference to symbol 'pthread_cancel@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:523: recipe for target 'pcm-multi-thread' failed
make: *** [pcm-multi-thread] Error 1
This commit fixes the bug by adding a corresponding flag.
Linux 4.7 or former have no validator of dimension information. This can
causes an issue related to user-defined element set. For example, When
calculated total members in multi-dimensional matrix is larger than actual
capacity of snd_ctl_elem_value_t, processes to handle the element can
cause buffer-over-run.
For backward portability of this userspace library, this commit adds a
validator of dimension information. When userspace applications give
invalid dimension information to APIs to add element set, they receive
-EINVAL.
A simple multi-thread stress test for PCM is added to test
subdirectory. It can perform various PCM update function in the
worker threads while reading/writing the data in the main thread.
It can help catching the unexpected error or blockage. For example,
running the capture test with a softvol plugin will lead to the assert
due to the races.