Commit graph

980 commits

Author SHA1 Message Date
Jaroslav Kysela
c051036e17 Change snd_dlopen() function to return the error string
The dlopen() function might fail also for another reason than
a missing file, thus return the error string from dlerror().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2017-11-27 21:48:20 +01:00
Jaroslav Kysela
5b9041bced Change FSF address (Franklin Street)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2017-11-14 14:29:26 +01:00
Natanael Copa
adab355f35 cleanup: Use uint*_t instead of u_int*_t everythwere
Use the standard uint{8,16,32,64}_t everywhere instead of the
non-standard u_int{8,16,32,64}_t.

This changes the types in the public headers and removes the u_int*_t
defines. This may break things. However, indentifiers ending with _t are
reserved by POSIX[1]; defining those can lead to undefined behavior.

So if you rely on alsa-lib defining those for you, then you want the
compiler to error so things can be fixed properly.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02_02

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-07-15 09:50:17 +02:00
Natanael Copa
885c64bcc4 cleanup: fix poll.h includes
According POSIX[1] and linux manpage[2] the include is poll.h, not
sys/poll.h.

This fixes the he following compiler warning when build with musl libc:

  /usr/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
   #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
    ^~~~~~~

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-07-12 12:05:37 +02:00
Liam Girdwood
84beecc71e topology: Add support for new widget types
Add topology support for new DSP widget types. This allows the new
widgets to be added to the driver and firmware DAPM graphs.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-06-30 16:32:53 +02:00
Takashi Iwai
8ef3805f1b pcm: hw: Call USER_PVERSION ioctl at open
Up from the new PCM protocol 2.0.14, user-space can inform the
protocol version it supports to kernel, so that the kernel may switch
its behavior depending on it.  Add this ioctl call in the PCM hw
plugin at opening.

The patch contains also the addition of SNDRV_PCM_INFO_SYNC_APPLPTR
carried from the upstream kernel commit 42f945970af9 ("ALSA: pcm: Add
the explicit appl_ptr sync support"), as well as the trivial change
(an addition of comma) to sync with the kernel asound.h.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-06-27 11:45:22 +02:00
Guneshwor Singh
c550a421a3 topology: Add parsing for rates from conf
In alsa-lib topology parser, rate_min and rate_max are parsed currently.
Add support to parse rates also.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-06-20 08:10:36 +02:00
Takashi Iwai
516bf057b0 conf: Allow dynamic top-level config directory
Currently the top-level config directory is specified only via
configure script option, and is fixed after that.  It's inconvenient
when the library is moved to another base directory, or if you want to
use a library code (e.g. with $LD_PRELOAD) with the incompatible
config setups.

This patch allows user to override the top-level config path via the
environment varialbe, $ALSA_CONFIG_DIR.  For that, a new helper
function, snd_config_topdir(), was introduced, and the codes referring
to the top config dir have been modified to handle it dynamically.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-05-03 09:54:16 +02:00
Mengdong Lin
0b8b6bb7d8 topology: Allow a data section to contain multiple tuples objects
It's easy to use a vendor tuples object to define a C structure instance as
vendor specific parameter for kernel drivers. And sometimes the kernel drivers
may want a group of structures. So this patch will allow user to define multiple
vendor tuples objects in a data section, to avoid defining multiple data
sections and each data section only has 1 vendor tuples object.

There is no ABI change in this patch.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Fuwei Tang <fuweix.tang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-27 08:48:45 +02:00
Takashi Sakamoto
fbc18ec771 hwdep: add support for MOTU FireWire series and RME Fireface series
Drivers for MOTU FireWire series and RME Fireface series were newly added
to v4.12 kernel. Like the other drivers in ALSA firewire stack, they also
support HwDep interface.

This commit add entries for the drivers.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-21 17:57:57 +02:00
Takashi Sakamoto
9307575d14 hwdep: add Line6 USB series support
Drivers for Line6 USB series was firstly added to staging directory at
development period of v2.6.30 kernel. At v4.9 kernel development, they
were moved to sound directory. The drivers include HwDep interface, while
header in user space library has never been updated for an entry
corresponding to the drivers.

This commit adds the entry.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-21 17:57:56 +02:00
Takashi Sakamoto
d1777a503d timer: obsolete legacy rtctimer instance
At v4.7 development, ALSA timer interface dropped device instance based on
legacy rtctimer implementation. User space applications should not use the
device instance.

This commit adds comments to notify a corresponding macro should not be
used anymore.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-21 17:57:56 +02:00
Fuwei Tang
a3b4bd2c8c topology: Look up references for an object based on its index
We can distinguish different use cases by the object index value, the default
value is 0, meaning applicable for all use cases, defined by macro "SND_TOLG_INDEX_ALL".
An element can only refer to other elements for "all" use cases or the same use
cases, i.e. it can only refer to elements with index value "SND_TOLG_INDEX_ALL"
or the same index value as itself.
The object list has been sorted in ascending order of index, so when we look up
a reference for an object, we traverse the object list it depends on, if we have
not found the reference until index of the object list is greater than index of
the object, we give up and return an error.

Signed-off-by: Fuwei Tang <fuweix.tang@intel.com>
Reviewed-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-21 12:57:48 +02:00
Breno Leitao
3bad0a21b4 Drop ppc64-specific workaround for versioned symbols
Currently aserver fails to build when using parameter
--without-versioned, due to an workaround for ppc64
(06221f86d2).  This workaround is
not required anymore on the ppc64 ABI v2, and, in fact is breaking the
compilation. Reverting this commit

Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-23 12:37:47 +01:00
Alan Young
97be19cf6f pcm: rate: Add capability to pass configuration node to plugins
If a rate plugin uses a node (compound) instead of a plain string for
its "converter", and that compound is not a simple string array, then
the compound will be passed as an additional parameter to the new plugin
open() function (SND_PCM_RATE_PLUGIN_CONF_ENTRY(XXX)). The previous
open() function (SND_PCM_RATE_PLUGIN_ENTRY(XXX)) will be called if the
CONF version is not found. It is up to the plugin to determine whether
the presence of the conf parameter is mandatory.

Signed-off-by: Alan Young <consult.awy@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-21 22:29:44 +01:00
Mengdong Lin
e93d93a8cd ucm: Add command 'get _file' to get the config file name of the opened card
After opening a card, this command can show the name of the actually
loaded configuration file, either matches the card name or card long name.
So developers can check if there is a device-sepcific configuration file
available for a given card.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-01-18 11:55:25 +01:00
Rene Rebe
2544b6cd55 pcm: fix get_stop_threshold alsa-lib 0.9 alias
resurrecting some decade old code I got some crashes and noticed a typo in
an old 0.9 legacy symver alias.

Signed-off-by: René Rebe <rene@exactcode.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-12-15 22:47:02 +01:00
Mengdong Lin
fa7a52e636 topology: Revise document and comments for ABI v5
Revise the obsolete content in document and comments.

Here are the major changes in implementation from early phase design:
- PCM object is used to configure front end DAI & DAI links, not used by
  physical DAI or DAI links.
- No longer use separate object for backend or codec<->codec links, but
  use physical links to cover them.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-22 07:50:30 +01:00
Mengdong Lin
75626fec50 topology: ABI - Add voice wake up flag for DAI links
Add a new flag bit SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP to link flags.
If a link is used for voice wake up, users can set this flag bit and
topology will set the link's 'ignore_suspend' to true.

This ABI update is backward compatible and applied in kernel. We may
rename this flag when we find a better name for this.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-22 07:50:29 +01:00
Guneshwor Singh
9117715371 topology: Support configuring physical DAIs by C API
In addition to text conf file, physical DAIs can also be configured
by C API. This patch defines the template to add physical DAI
configurations from C API.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-22 07:50:27 +01:00
Mengdong Lin
0b6bd6c19a topology: Parse physical DAIs in text conf file
Add support for parsing physical DAIs in the text configuration file.
The syntax of physical DAIs is described in document in topology.h

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-22 07:50:26 +01:00
Guneshwor Singh
50c77cdc7f topology: ABI - Define new types for physical DAI
Define the type and ABI struct for physical DAIs (e.g. backend DAIs).
They are new to ABI and so no backward compatibility risk.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-22 07:50:25 +01:00
Mengdong Lin
527c8a1b19 topology: ABI - Update manifest and pump ABI version to 5
Pump ABI version to 5.

To support physical DAIs and furture extension, add the following fields
to manifest:
- the count of physical DAIs. Later patches will add new ABI types for
  physical DAIs.
- some reserved fields for new ABI objects in the future.

Kerel will handle this ABI update in a backward compatible way, via patch
'ASoC: topology: Make manifest backward compatible from ABI v4'.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-22 07:50:25 +01:00
Mengdong Lin
4597577750 topology: Remove BE or CC in comments of physical links C API template
No longer use BE or CC in comments of C API template for physical links.
This template can be used by Backend or Codec-to-Codec DAI links but not
only for them.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:22 +01:00
Mengdong Lin
a182ab29c6 topology: Parse name and stream name of physical DAI links
Parse name and stream name of physical links defined by text conf file
or C API. Add name and stream name to C API template of physical DAI
links.

These two fields will help topology kernel driver to find an existing
physical link to configure, since the id of links are often the default
value ZERO and useless for match.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:22 +01:00
Mengdong Lin
c33b3a0ea2 topology: Parse and build private data of physical links
Users can define private data for physical links by C API or text conf
file. Private data pointer is added to C API template for physical links.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:21 +01:00
Mengdong Lin
2894c31816 topology: Parse link flags of physical DAI links
Parse physical DAI link flags defined by text conf file or C API.
The flag mask and flags are added to C API template for physical DAI
links.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:21 +01:00
Mengdong Lin
f7bf8b0cc8 topology: Parse HW configurations of physical DAI links in text conf file
Users can configure the runtime supported HW configurations of a physical
link by SectionHWConfig. A physical link can refer multiple HW config
sections in SectionLink.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:20 +01:00
Mengdong Lin
6b4d775b97 topology: Parse HW configurations of physical DAI links defined by C API
Add HW configurations to C API template of physical link configuration.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:19 +01:00
Mengdong Lin
f5b275b24c topology: Define new type and section name to configure physical links
Users may not use DPCM but still need to configure the physical links.
So we should not only consider backend links for DPCM.

- SND_TPLG_TYPE_LINK is defined to configure physical links by C API.
  And SND_TPLG_TYPE_BE is still supported to configure Backend links for
  DPCM cases.

- SectionLink can be used to configure physical links in text conf file.
  And SectionBE is still supported to config Backend links for DPCM cases.

Actually, users can use SND_TPLG_TYPE_LINK and SectionLink to configure
backend links for DPCM cases, because BE links are also physical links.
The parsing is same and we rename the function from tplg_parse_be to
tplg_parse_link.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:18 +01:00
Mengdong Lin
50e7190d35 topology: ABI - Update physical DAI link configurations to ABI v5
This patch update physicals DAI link config to ABI v5:

- Define the types and ABI struct for runtime supported hardware configs
  e.g. audio hardware formats. The default HW config ID will help topology
  to find the DAI format to set on init. Topology provides this as a
  fallback if such HW settings are not available in ACPI or device tree,
  to avoid hard code in drivers. It's only for config items that can be
  programmed by SW or FW, not for physical things like link connections
  or GPIO used for HP etc.

- Add flags. The flags will be used to configure an existing physical
  links.

- Add private data. The private data is reserved for future extension.

- Add name and stream name to physical DAI links. Kernel can also use name
  and stream name to find an existing physical link and configure it.

Kernel can handle the ABI update in a backward compatible way via patch
'ASoC: topology: Add support to configure existing physical DAI links'.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:17 +01:00
Mengdong Lin
3b4e53624d topology: ABI - Define DAI physical PCM data formats
Define DAI physical PCM data formats for user space, so users can specify
the formats of backends by topology (e.g. the DAI format to set on backend
link init).

The kernel will also refer to these formats.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-08 16:33:17 +01:00
Mengdong Lin
4136d98606 topology: Parse and build private data for PCM
Users can define private for PCM (FE DAI & DAI links) elements by both
text conf file and C API:

- Text conf file may define multiple data blocks for a PCM and they will
  be merged in building phase;

- Add private data to C API template of PCM object.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-05 16:41:55 +01:00
Mengdong Lin
b398ed4058 topology: Parse flags for PCM
Users can define flags by both text conf file and C API.
Add flags and flag_mask to C API template of PCM object.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-05 16:41:53 +01:00
Mengdong Lin
f94ed5cf75 topology: Parse sig_bits of stream caps
Add sig_bits to stream caps template of C API and parse it.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-05 16:41:52 +01:00
Mengdong Lin
6945156a67 topology: ABI - Update stream caps and PCM objects to ABI v5
Here are the ABI updates for PCM (Front DAI & DAI link) objects:

- add sig_bits to stream caps.
- add flags and private data to PCM.

The kernel can handle the ABI update in a backward compatible way with
the patch "ASoC: topology: Make PCM backward compatible from ABI v4".

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-11-05 16:41:52 +01:00
Mengdong Lin
3a5341e2ac topology: Add doc for including other files in the text conf file
This patch adds document about how to include other files in the text
configuration files, by alsaconf syntax <xxx> and <searchdir:xxx>.

Users may define common info in separate files (e.g. vendor tokens,
tuples) and share them for different platforms, by including them via
syntax <path/to/configuration-file>. This can save the total size of
files. Users can also specifiy additional configuraiton directories
relative to "/usr/share/alsa/" to search the included files, via syntax
<searchdir:relative-path/to/usr/share/alsa>.

The alsaconf will search and open an included file in the following order
of priority:
1. directly open the file by its name;
2. search for the file name in "/usr/share/alsa";
3. search for the file name in user specified subdirectories under
   "/usr/share/alsa".

The order of the included files need not to be same as their dependencies,
because the toplogy library will load all of them before parsing their
dependencies.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-10-25 09:26:24 +02:00
Mengdong Lin
adb9866b70 topology: Fix missing stream name of widgets in text conf file
User can define the stream name of an input/output widget in the text conf
file, by setting "stream_name" of a SectionWidget.

Topology C API and kernel already have support for configuring a widget's
stream name. This patch just adds the missing part of the text conf file.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-10-25 09:24:28 +02:00
Takashi Sakamoto
21dcb000c8 Update include/sound/tlv.h from 4.9-pre kernel uapi
The UAPI header in 4.9-pre kernel newly includes existent macros related
to tlv operation, mainly for layout of TLV packet payload.

This commit updates corresponding backport header in this library.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-09-30 17:12:30 +02:00
Antonio Ospite
64481b3c72 ucm: docs: typeset lists of identifiers explicitly
Doxygen doesn't preserve formatting that relies only on indentation,
typeset lists of identifiers explicitly.

This makes the HTML docs a lot more readable.

This change comes along the lines of commit 72aa0f8332 ("ucm: reformat
snd_use_case_get() doc").

Some TABs has been added too in order to preserve the aligned look when
reading the source code.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-09-29 09:56:02 +02:00
Takashi Sakamoto
7bebd4c980 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.

This commit renames them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-17 10:01:25 +02:00
Mengdong Lin
962d006c28 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.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-17 10:00:28 +02:00
Mengdong Lin
a3683a2ba0 topology: Parse vendor private data for manifest
In text conf file, user can define a manifest section and let it refer
to private data sections, in the same syntax as other element types.

The text conf file can have at most 1 manifest section.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-17 10:00:17 +02:00
Mengdong Lin
62c180981b 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.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-17 10:00:04 +02:00
Mengdong Lin
bb03d929e8 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.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-17 09:59:21 +02:00
Takashi Iwai
7a8a1d1552 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-11 15:25:30 +02:00
Takashi Iwai
54931e5a54 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-07-11 15:25:30 +02:00
Takashi Sakamoto
16812b70da ctl: add an API to set dimension levels to element information
In a former commit, 'struct snd_ctl_elem_info' is used as a 'container' to
transfer extra fields of element information for APIs to add an element
set. The extra fields should be filled in advance of call of the APIs.
Currently, dimension level is in the extra fields and no APIs to set it.

This commit adds an API to set dimension level to the information
structure. This API is expected to be used in advance of usage of APIs
to add an element set, for nothing others. When the information structure
is extended in future, then the similar APIs shall be added for the new
feature.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-30 08:42:17 +02:00
Takashi Sakamoto
f9e6011255 ctl: support extra information to user-defined element set
In ALSA control feature, information of an element includes extra fields
to type-specific parameters; i.e. dimension. The fields can be extended in
future.

Meanwhile, current APIs to add user-defined element set can not support
such an extended fields. This may cause inconveniences in future.

This commit supports the fields, by changing APIs for element set.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-30 08:42:17 +02:00
Takashi Sakamoto
7117d22cf2 ctl: use consistent name for second argument of snd_ctl_elem_read/write
Second argument of these functions has three different names in
documentation/header/code (obj/control/value). This easily causes users'
confusion.

This commit applies consistent names for the arguments.

Fixes: 90020c05f8 ('ctl: improve comments for handling element data')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-29 11:50:26 +02:00