Mengdong Lin [Thu, 7 Apr 2016 07:29:49 +0000 (15:29 +0800)]
topology: Build data objects with tuples
For data objects with tuples, the parser will bind the vendor tuples
and tokens, copy the tuples to the private buffer of its parent data
object. Then later the builder will export the vendor tuples as private
binary data for the control or widgets objects.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Mengdong Lin [Thu, 7 Apr 2016 07:29:36 +0000 (15:29 +0800)]
topology: Add support for vendor tokens
Vendor can define a token list in SectionVendorTokens. Each token element
is a pair of string ID and integer value. And both the ID and value are
vendor-specific.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Mengdong Lin [Thu, 7 Apr 2016 07:29:27 +0000 (15:29 +0800)]
topology: ABI - Define types for vendor tuples
Tuples, a pair of token and value, can be used to define vendor specific
data, for controls and widgets. This can avoid importing binary data blob
from other files.
Vendor specific tuple arrays will be embeded in the private data buffer
of a control or widget object. To be backward compatible, union is used
to define the tuple arrays in the existing private data ABI object
'struct snd_soc_tplg_private'.
Vendors need to make sure the token values defined by the topology conf
file match those defined by their driver.
Now supported tuple types are uuid, string, bool, byte, short and word.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Shengjiu Wang [Wed, 6 Apr 2016 11:02:12 +0000 (19:02 +0800)]
pcm_plugin: fix appl pointer not correct when mmap_commit() return error
When snd_pcm_mmap_commit() return error, the appl pointer is also updated.
which cause the avail_update()'s result wrong.
This patch move the snd_pcm_mmap_appl_forward() to the place when
snd_pcm_mmap_commit() is successfully returned.
Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Qing Cai [Thu, 10 Mar 2016 12:40:51 +0000 (07:40 -0500)]
pcm: fix 'unable to create IPC shm instance' caused by fork from a thread
As stated in manpage SHMCTL(2), shm_nattch is "No. of current attaches"
(i.e., number of processes attached to the shared memeory). If an
application uses alsa-lib and invokes fork() from a thread of the
application, there may be the following execution sequence:
1. execute the following statement:
pcm_direct.c:110: dmix->shmptr = shmat(dmix->shmid, 0, 0)
(shm_nattch becomes 1)
2. invoke fork() in some thread.
(shm_nattch becomes 2)
3. execute the following statement:
pcm_direct.c:122: if (buf.shm_nattch == 1)
4. execute the following statement:
pcm_direct.c:131: if (dmix->shmptr->magic != SND_PCM_DIRECT_MAGIC)
(As stated in manpage SHMGET(2), "When a new shared memory segment
is created, its contents are initialized to zero values", so
dmix->shmptr->magic is 0)
5. execute the following statements:
pcm_direct.c:132: snd_pcm_direct_shm_discard(dmix)
pcm_direct.c:133: return -EINVAL
The above execution sequence will cause the following error:
unable to create IPC shm instance
This error causes multimedia application has no sound. This error rarely
occurs, probability is about 1%.
More notes about this patch:
this patch tries to address the race above by changing the condition
to identify "the first user". Until now, the first user was
identified by checking shm_nattch. But this is racy, as stated in the
above.
In this version, we try to assign a shm at first without IPC_CREAT.
If this succeeds, we are not alone, so we must not be the first user.
Only when this fails, try to get a shmem with IPC_CREAT and IPC_EXCL.
If this succeeds, we are the first user. And, one more notable point
is that the race of this function call itself is protected by
semaphore in the caller side. The only point to avoid is the race
after shmget() and the first initialization, and this method should
work around that.
Signed-off-by: Qing Cai <bsiice@msn.com> Signed-off-by: Qing Cai <caiqing@neusoft.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Martin Koegler [Thu, 3 Mar 2016 21:39:37 +0000 (22:39 +0100)]
seq: Provide sequencer sound card number / PID via alsa-lib
rawmidi devices expose the card number via IOCTLs, which allows to
find the corresponding device in sysfs.
The sequencer provides no identifing data. Chromium works around this
issue by scanning rawmidi as well as sequencer devices and matching
them by using assumtions, how the kernel register sequencer devices.
This changes adds support for exposing the card number for kernel clients
as well as the PID for user client.
It supports kernels with and without the required support.
Signed-off-by: Martin Koegler <martin.koegler@chello.at> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Sakamoto [Mon, 22 Feb 2016 13:13:31 +0000 (22:13 +0900)]
control: keep consistent usage of assertion
In most codes for control APIs, assertions are used to check given
arguments from applications. If the arguments are not expected, the
application is forced to abort. When NDEBUG is defined in the beginning
of the codes, no checks are performed.
Although, in snd_ctl_elem_set_bytes(), assertion is used with condition
statement. There's an intention to check the arguments regardless of
NDEBUG. However, this is not the same fashion in the codes.
This commit applies the same fashion to the function, to keep consistent
usage of assertion.
Takashi Sakamoto [Sun, 21 Feb 2016 16:54:28 +0000 (01:54 +0900)]
control: initialize element channel values according to identification number at adding a new element
In ALSA control core, there're two ways to identify elements. One is by
numid. Another is by name/index. The former way is lighter than the latter
way.
In control API, after adding elements by snd_ctl_elem_add_integer() and
snd_ctl_elem_add_integer64(), these functions initialize value of each
channel. When executing this operation, used ID information is still given
by applications. Although, in this time, the element can be identified
according to numid.
This commit uses the numid instead of name/index pair.
Takashi Sakamoto [Sun, 21 Feb 2016 16:54:19 +0000 (01:54 +0900)]
control: fulfill a description about element type with integer64
In UAPI of asound.h, there're 6 types of control element; boolean, integer,
enumerated, bytes, iec958 and integer64 (The none type seems to be added to
start the value at non-zero). Although, current description in alsa-lib
has a lack of integer64 type.
Mengdong Lin [Thu, 19 Nov 2015 08:33:12 +0000 (03:33 -0500)]
topology: Quit and show error message on big-endian machines
This tool can only support little-endian machines atm.
Many codes directly refer to __le32/__le64 variables of ABI objects,
so will be broken on big-endian machines.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Mengdong Lin [Thu, 19 Nov 2015 08:33:05 +0000 (03:33 -0500)]
topology: Not compare a for loop iterator with ABI __le32 variables
The iterator 'i' in a loop is a usually a integer. But ABI variables use
type _le32, which is converted to host unsigned integer. Comparing them
can cause gcc warning: comparison between signed and unsigned integer
expressions[-Wsign-compare].
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Mon, 9 Nov 2015 12:37:26 +0000 (13:37 +0100)]
topology: Add missing include sys/stat.h
Necessary for proper definitions of S_IRUSR & co. Otherwise it
results in compile errors with old glibc:
parser.c: In function 'snd_tplg_build_file':
parser.c:262: error: 'S_IRUSR' undeclared (first use in this function)
parser.c:262: error: (Each undeclared identifier is reported only once
parser.c:262: error: for each function it appears in.)
Vedang Patel [Thu, 5 Nov 2015 12:49:23 +0000 (20:49 +0800)]
topology: Add C API support for BE and CC Links.
Adding BE and CC Link support for C API reference. This will be used
to populate the .hw_params element for BE and .params for CC, enabling
us to update already existing DAI Links created by the kernel.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Mengdong Lin [Thu, 5 Nov 2015 12:49:02 +0000 (20:49 +0800)]
topology: ABI - Change stream formats to a bitwise flag
The toplogy user space tool will generate this bitwise flag by using
SNDRV_PCM_FORMAT_* exposed by asound.h, and the topology core will copy
this flag when generating DAI streams.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Vedang Patel [Thu, 5 Nov 2015 12:48:30 +0000 (20:48 +0800)]
topology: ABI - Separate PCM & BE/CC link support and bump ABI version to 4
The struct snd_soc_tplg_pcm_dai is renamed to snd_soc_tplg_pcm.
This struct will now be used to handle data related to PCMs
(FE DAI & DAI links). It's not for BE, because BE DAI mappings will be
provided by ACPI/FDT data.
Remove the unused struct snd_soc_tplg_pcm_cfg_caps. We are using
snd_soc_tplg_stream and snd_soc_stream_caps instead.
Define the topology type for BE DAI link: SND_SOC_TPLG_TYPE_BACKEND_LINK.
Define struct snd_soc_tplg_link_config to configure BE & CC links.
Bump ABI version to 4.
Signed-off-by: Vedang Patel <vedang.patel@intel.com> Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Mike Frysinger [Tue, 27 Oct 2015 21:28:04 +0000 (17:28 -0400)]
support building w/out System V shared memory
Some systems, like Android/Bionic, do not support SysV at all.
Let the configure script detect if the header is available, and
if not, automatically disable the pieces that require it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Mike Frysinger [Tue, 27 Oct 2015 21:28:03 +0000 (17:28 -0400)]
pcm: drop unused sys/shm.h inclusion
This header isn't used in these files, so stop trying to include it.
This helps builds on systems that don't provide the header (such as
Android/Bionic).
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Mike Frysinger [Tue, 27 Oct 2015 21:27:55 +0000 (17:27 -0400)]
move page helpers to common code
If you build with --disable-pcm, the rawmidi code fails to link because
it uses the page_size helper declared in local.h, but the page_* funcs
are in the pcm mmap module. Move these funcs into conf.c so that they
are always available to the rest of the system.
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai [Fri, 30 Oct 2015 16:13:50 +0000 (17:13 +0100)]
pcm: dmix: Handle slave PCM xrun and unexpected states properly
Currently, dmix & co plugins ignore the XRUN state of the slave PCM.
It's (supposedly) because dmix deals with the PCM in a free-wheel
mode, which is equivalent with XRUN. But, this difference (whether
the correct freewheel or XRUN) should be done by the kernel, and we
may have an XRUN state indeed (e.g. via xrun injection).
This patch fixes this lack of behavior, to handle PCM xrun and does
prepare when the slave PCM is in such a state.
Also, the patch consolidates the prepare callback for all dmix, dsnoop
and dshare plugins, and fix/cleanup a bit for dshare/dsnoop codes to
align with dsnoop code.
Mike Frysinger [Fri, 9 Oct 2015 21:47:40 +0000 (17:47 -0400)]
fix _GNU_SOURCE handling & header inclusion
The configure script blindly adds -D_GNU_SOURCE to all build settings,
even on non-GNU systems. This isn't too much of a big deal (even if
it uses the wrong variable -- CFLAGS instead of CPPFLAGS), except that
the alsa-lib source itself determines whether to use GNU features when
this is defined (such as versionsort). So when we build on non-glibc
systems, we get build failures like:
src/ucm/parser.c:1268:18: error: 'versionsort' undeclared (first use in this function)
#define SORTFUNC versionsort
^
src/ucm/parser.c:1272:54: note: in expansion of macro 'SORTFUNC'
err = scandir(filename, &namelist, filename_filter, SORTFUNC);
^
The correct way to add these flags is to use the autoconf helper
AC_USE_SYSTEM_EXTENSIONS. Unfortunately, that triggers some more
bugs in the alsa build. This macro adds defines to config.h and
not directly to CPPFLAGS, so it relies on files correctly including
config.h before anything else. A number of alsa files do not do
this leading to build failures. The fix there is to shuffle the
includes around so that the local ones come first.
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Linux 4.4 newly support these drivers. Their hardware dependent interfaces
give functionalities to get hardware information, to lock/unlock kernel
streaming and to receive lock status event.
Takashi Iwai [Fri, 2 Oct 2015 09:55:36 +0000 (11:55 +0200)]
pcm: ladspa: Fix segfault due to a wrong channel reference
Because of a typo in referencing the input array in
snd_pcm_ladspa_allocate_memory(), ladpsa PCM plugin may cause a
segfault at prepare when input and and output channels are different:
#0 0x00007ffff78623ef in snd_pcm_ladspa_allocate_memory (pcm=0x626fa0, pcm=0x626fa0, pcm=0x626fa0, ladspa=0x621ad0) at pcm_ladspa.c:753
#1 snd_pcm_ladspa_init (pcm=0x626fa0) at pcm_ladspa.c:834
#2 0x00007ffff7842946 in snd_pcm_plugin_prepare (pcm=0x626fa0) at pcm_plugin.c:171
#3 0x00007ffff784290f in snd_pcm_plugin_prepare (pcm=0x62c760) at pcm_plugin.c:162
#4 0x000000000040256a in ?? ()
#5 0x00007ffff7222ec5 in __libc_start_main (main=0x401d80,a argc=4, argv=0x7fffffffde28, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffde18) at libc-start.c:287
#6 0x0000000000402fdd in ?? ()
This patch corrects the wrong reference.
Reported-and-tested-by: Andreas Hartmann <mail@andreashartmann.eu> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Mengdong Lin [Wed, 16 Sep 2015 09:07:13 +0000 (17:07 +0800)]
topology: Add API to set a vendor specific version number
This vendor-specific version number is optional. It will be written to
the 'version' field of each block header of the binary toplogy data file.
The vendor driver can check this number for further processing in kernel.
The topology ABI version number is still stored in the 'abi' field of
block headers.
cross compilers are passed via path may not be a gcc based cross
compiler in such cases this check fails and try's to force gcc based
cross compiler detection, This code is a convenience that limits the
build system
Fix gcc warnings:
pcm.c: In function ‘tplg_parse_stream_cfg’:
pcm.c:160:6: warning: unused variable ‘ret’ [-Wunused-variable]
int ret;
^
pcm.c: In function ‘split_format’:
pcm.c:267:13: warning: unused variable ‘ret’ [-Wunused-variable]
int i = 0, ret;
^
topology: parser: Add missing return value to snd_tplg_set_manifest_data()
Spotted by gcc warning:
parser.c: In function ‘snd_tplg_set_manifest_data’:
parser.c:361:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
topology: data: Fix wrong size check in tplg_parse_data_hex()
A wrong, uninitialized variable is referred as the size to check in
tplg_parse_data_hex(). Spotted by gcc warning:
data.c: In function ‘tplg_parse_data_hex’:
data.c:228:5: warning: ‘esize’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (esize > TPLG_MAX_PRIV_SIZE) {
^
data.c:211:12: note: ‘esize’ was declared here
int size, esize, off, num;
^
Fix the wrong bit-and check by adding parentheses properly:
ctl.c: In function ‘tplg_add_bytes’:
ctl.c:868:22: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
if (be->hdr.access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE
^
topology: builder: Fix possibly uninitialized variable in write_elem_block()
When an empty list is passed to write_elem_block(), it may leave
vendor_type uninitialized.
builder.c: In function ‘write_elem_block’:
builder.c:127:8: warning: ‘vendor_type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
ret = write_block_header(tplg, tplg_type, vendor_type,
^
builder.c:114:33: note: ‘vendor_type’ was declared here
int ret, wsize = 0, count = 0, vendor_type;
^
Add an immediate return for count = 0 for avoiding it, and simplify
the code initializing vendor_type without using a one-shot loop.
pcm: route: Remove bogus ! in snd_config_get_id() checks
There are strange "!" added before snd_config_get_id() return value
checks in a couple of places in pcm_route.c. This essentially makes
the result always positive, making checks bogus.
Mengdong Lin [Tue, 11 Aug 2015 17:23:16 +0000 (18:23 +0100)]
topology: Add C templates structure for building topology from C programs
Define structures that can be used by applications to directly build topology
data instead of using text files. The application will build up the topology
data by populating the template structures for each object type and then
registering the template with the topology core.
Mengdong Lin [Wed, 5 Aug 2015 13:41:51 +0000 (14:41 +0100)]
topology: Add ops support to byte control objects.
Rename the control ops structure to make it more generic so we can use it
with other objects like bytes controls. Add this structure to the byte
control structure.
Mengdong Lin [Wed, 5 Aug 2015 13:41:50 +0000 (14:41 +0100)]
topology: update ABI to improve support for different TLV object types.
Currently the TLV topology structure is targeted at only supporting the
DB scale data. This patch extends support for the other TLV types so they
can be easily added at a later stage.
TLV structure is moved to common topology control header since it's a
common field for controls and can be processed in a general way.
Users must set a proper access flag for a control since it's used to decide
if the TLV field is valid and if a TLV callback is needed.
Removed the following fields from topology TLV struct:
- size/count: type can decide the size.
- numid: not needed to initialize TLV for kcontrol.
- data: replaced by the type specific struct.
Added TLV structure to generic control header and removed TLV structure from
mixer control.
Jin Yao [Tue, 4 Aug 2015 17:09:12 +0000 (18:09 +0100)]
topology: Add element ID so we can look up references by name.
Add support to lookup elements by name. This is in preparation for adding
some new API calls that will allow building topology data using a C API. This
will allow applications to build their own topology data directly.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com> Signed-off-by: Mengdong Lin <mengdong.lin@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Parse PCM configurations and capabilities. These can then be used to define
the capabilities and config for FE DAI links, PCM devices and
codec <-> codec style links.
The topology core parses the high level topology file and calls the
individual object parsers when any new object element is detected at
the high level.
We copied include/list.h from Linux kernel, and it's of course in
GPLv2. This has raised concerns to many people, as it's not clear
whether such a code is considered to be completely trivial, thus it
might be seen as a derivative work, which takes effect in GPL, as
suggested by Clemens.
For clearing the situation, this patch replaces the existing list.h
implementation from a new version. The API is kept to be compatible,
but the codes were written from full scratch under LGPL, to be aligned
with other alsa-lib codes.
Reported-by: Clemens Lang <clemens.lang@bmw-carit.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Martin Geier [Fri, 24 Jul 2015 07:30:57 +0000 (09:30 +0200)]
pcm: restore hw params on set latency failed
When method snd_pcm_set_params sets sample rate to 22050 and latency to 50000
to davinci soc driver method snd_pcm_hw_params_set_buffer_time_near fails
and variable params is already changed in the method so the next method
snd_pcm_hw_params_set_period_time_near fails also.
Signed-off-by: Martin Geier <martin.geier@streamunlimited.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>