Commit graph

385 commits

Author SHA1 Message Date
Takashi Iwai
81b0cf46d1 control: Add UMP Endpoint and Block info query support
Add functions to query the UMP Endpoint and Block info via control
interface.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
8bc10c83b1 control: Add UMP device query support
Add a function to query the next available UMP device via control
interface, just like the existing one for rawmidi.  As the UMP rawmidi
is compatible with the standard rawmidi, no extra helper for the
rawmidi_info is present.  Ditto for the preferred subdevice, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Jaroslav Kysela
cbdb428ab9 remove extra trailing new line in SNDMSG and SNDERR calls
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-06-06 13:47:41 +02:00
Jaroslav Kysela
507d906abb pcm: add SND_CTL_EINTR open mode
Add possibility to return -EINTR instead waiting for the event. The
applications may want to handle -EINTR condition themselves.

BugLink: https://github.com/alsa-project/alsa-lib/issues/228
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 15:59:15 +02:00
Jaroslav Kysela
7e678d70c2 control: namehint - do not support 'card' devices
The card: devices do not exist. Do not return -ENOENT,
but -EINVAL in this case.

Fixes: https://github.com/alsa-project/alsa-lib/issues/277
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-10-24 10:02:54 +02:00
Jaroslav Kysela
4633d35171 control: eld - skip trailing spaces
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-10-18 15:53:52 +02:00
Jaroslav Kysela
89ee619147 control: eld - fix the decoding for older hw
It seems that the monitor name is not always present in the
ELD structure. Add asterisk suffix to notify user about
the monitor present for this case.

Thanks goes to Bernhard Rosenkränzer <bero@lindev.ch> for the report.

Fixes: https://github.com/alsa-project/alsa-lib/pull/233
Fixes: https://github.com/alsa-project/alsa-lib/pull/234
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-06-06 12:14:24 +02:00
Jaroslav Kysela
9b279d11a4 control: eld - add missing ctype.h header inclusion
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-20 08:47:07 +02:00
Jaroslav Kysela
f1fa7ea077 control: shm - initialize write buffer
ccontrol_shm.c: In function ‘snd_ctl_shm_action’:
  control_shm.c:54:23: error: invalid initializer
     54 |         char buf[1] = 0;
        |                       ^

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-05 14:38:09 +02:00
Jaroslav Kysela
859448f010 control: decode HDMI device name from ELD
The HDMI drivers set an uniform PCM names. Use ELD (EDID) to obtain
the HDMI device name and send this string to applications for a better
user experience.

Example (aplay -l):

  card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
    Subdevices: 1/1

  vs improved:

  card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [Philips 272P4]
    Subdevices: 1/1

Fixes: https://github.com/alsa-project/alsa-lib/issues/209
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-05-05 14:31:45 +02:00
Jaroslav Kysela
23a191a82c control: remap - assign right name to the child handle for no-op (2nd case)
Fixes: https://github.com/alsa-project/alsa-utils/issues/100
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-29 19:31:35 +02:00
Jaroslav Kysela
e47c11822d control: remap - assign right name to the child handle for no-op
Fixes: https://github.com/alsa-project/alsa-utils/issues/100
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-29 18:02:30 +02:00
Tanjeff-N. Moos
7ba3f888d0 control: Minor documentation fixes.
Signed-off-by: Tanjeff-N. Moos <tanjeff@cccmz.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-21 17:13:26 +02:00
Tanjeff-N. Moos
ccc14ae897 control: Add documentation for snd_ctl_card_* and friends.
In this patch series, I added a description about control interface
handling and how control interfaces are identified.

In addition, I added/improved Doxygen documentation for the
snd_ctl_card_info_t type and related corresponding functions,
e.g. snd_ctl_card_info(). I also documented other card-related like
snd_card_next().

Along the way I did minor documentation improvements.

Signed-off-by: Tanjeff-N. Moos <tanjeff@cccmz.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-21 17:12:53 +02:00
Jaroslav Kysela
81e7923fbf control: empty - fix the static build
Reported-by: Jan Palus <atler@pld-linux.org>
Fixes: https://github.com/alsa-project/alsa-lib/issues/157
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-15 23:24:26 +02:00
Chih-Wei Huang
f4c061f349 control: remap - fix an infinite recursive call in the async callback
The function snd_ctl_remap_async will call itself infinitely. Looks like
a typo.

Fixes: a64391a42 ("control: remap plugin - initial version")
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-14 10:14:40 +02:00
Jaroslav Kysela
013ec607db control: remap - fix uninitialized value in parse_map_vindex()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 19:28:32 +02:00
Jaroslav Kysela
d6f9e9f590 control: remap - add no-op when the remapping is not active
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-17 17:03:39 +02:00
Jaroslav Kysela
3e731ff51e control: remap - don't allow I/O on renamed IDs
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-23 21:11:25 +02:00
Jaroslav Kysela
8f5779eb3f ucm: add LibraryConfig support
This commit allows to define private alsa-lib's configuration. When
the configuration is present, the device values ("PlaybackCTL",
"CaptureCTL", "PlaybackMixer", "CaptureMixer", "CapturePCM")
are prefixed with '_ucmHEXA.' string where HEXA is replaced by the
unique hexadecimal number identifying the opened ucm manager handle.

    Syntax 4

    LibraryConfig.a_label.SubstiConfig {
            # substituted library configuration like:
            usr_share_dir "${ConfLibDir}"
    }

    LibraryConfig.b_label.Config {
            # non-substituted library configuration like:
            usr_share_dir "/usr/share/alsa"
    }

    The File counterparts:

    LibraryConfig.c_label.SubstiFile "/some/path"
    LibraryConfig.d_label.File "/some/path"

Note that for files the contents is substituted on the request,
but the file name is always substituted (useful for ${ConfDir} etc.).

The private configuration is not saved or preserved. It's life time
belongs to the opened ucm manager handle.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-13 17:14:28 +02:00
Jaroslav Kysela
adce5f7b65 control: add empty plugin
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-07 16:24:20 +02:00
Jaroslav Kysela
493a41bcad control: remap plugin - add docs
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-07 16:24:09 +02:00
Jaroslav Kysela
7371ac9aad control: doc - create controls plugin page
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-07 16:24:05 +02:00
Jaroslav Kysela
a64391a428 control: remap plugin - initial version
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-07 16:22:50 +02:00
Jaroslav Kysela
7db7e18bbb control: add _snd_ctl_open_child()
To support internal plugins, add internal _snd_ctl_open_child()
function like _snd_pcm_open_slave().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-07 16:22:45 +02:00
Jaroslav Kysela
10e2490023 control: shm - add missing continue to _snd_ctl_shm_open()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-29 11:41:26 +02:00
Jaroslav Kysela
b0b9e4b88d ucm: move __snd_ctl_ascii_elem_id_parse prototype to control_local.h
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-25 20:40:22 +01:00
Jaroslav Kysela
03cb988179 control: add __snd_ctl_add_elem_set() helper
It simplifies the add_elem_set functions and we need it for UCM.
It's an internal function.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-25 20:36:39 +01:00
Jaroslav Kysela
83e4c1ab77 control: add snd_ctl_elem_id_compare_numid() function
Idea for the function prototype by Takashi Sakamoto.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-23 17:48:30 +01:00
Jaroslav Kysela
6f4b96ecc9 control: rename snd_ctl_elem_id_compare() to snd_ctl_elem_id_compare_set()
- add asserts to check if the unsigned integers are in the valid range
- replace tuple with set in the id description
- add const prefix for id1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-23 17:31:30 +01:00
Jaroslav Kysela
74422643ee control: fix the subdevice fields comparison in snd_ctl_elem_id_compare() 2021-03-18 12:33:16 +01:00
Jaroslav Kysela
266618088a control: better docs for snd_ctl_elem_id_compare()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-08 15:24:31 +01:00
Jaroslav Kysela
2cfe6addae control: add snd_ctl_elem_id_compare() function
Compare two control element identifiers like strcmp().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-26 21:08:28 +01:00
Jaroslav Kysela
7a1402cddc control: snd_ctl_ascii_elem_id_get() - do not show unset numid
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-26 21:08:28 +01:00
Jaroslav Kysela
19ad9bdc49 conf: introduce snd_config_get_card() function
It's helper for the "card" entries parsing. It reduces
the code in most of open_hw functions.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-26 21:08:28 +01:00
Jaroslav Kysela
174592280d control: improve snd_ctl_add_*_elem_set functions (access flags)
The access flags are useful for the user space elements
with the custom access flags.

Introduce snd_ctl_elem_info_set_*() functions to set those flags
in the info structure.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-26 20:32:20 +01:00
Jaroslav Kysela
7da208173f control: fix iformation -> information typos
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-24 11:06:25 +01: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
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
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
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
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
John Keeping
198eb642bc control: ctlparse - use type-specific bound on element count
Using a fixed bound of 128 means that too many values may be set for an
INTEGER64 type and that any elements past 128 are out of reach for BYTE
type controls.

Derive the maximum number of elements from the type so that the full
range is parsed for all types.

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-16 21:29:20 +02:00
Jaroslav Kysela
d54fde85db tlv: implement nearest rounding in snd_tlv_convert_from_dB() for xdir == 0
We should round-up values to nearest to get more precise results.

BugLink: https://github.com/alsa-project/alsa-utils/issues/35
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-05 17:57:06 +02:00
Jaroslav Kysela
d39f5acd9b control: use more precise rounding in snd_ctl_ascii_value_parse()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-05 17:04:18 +02:00
Jaroslav Kysela
b2a4272ecb snd_dlopen: do not use absolute plugin path for snd_dlopen() calls
In commit b906db19ef, the snd_dlopen()
implements the automatic lookup to the ALSA_PLUGIN_DIR directory.
It is not necessary to add the absolute paths in callers now.

The plugin names are also searched in ld.so.conf paths as the fallback now,
but it should not be a big problem.

BugLink: https://github.com/alsa-project/alsa-lib/issues/34
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-04 19:09:50 +02:00
Jaroslav Kysela
d434638a68 namehint: remember the direction from the upper levels
The current code resets the direction info for each level.
Simply remove this code.

Fixes: https://github.com/alsa-project/alsa-lib/issues/39

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-03-27 11:59:55 +01:00
Jaroslav Kysela
09e78da4ca conf: namehint - add omit_noargs to the hint section
Do not list simple surround devices in the namehint function by default.

Fixes: https://github.com/alsa-project/alsa-lib/issues/27

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-03-02 09:45:55 +01:00