Commit Graph

3216 Commits

Author SHA1 Message Date
crescent
74627ea541 modify audio part name
Signed-off-by: crescent <sunhehe@huawei.com>
2022-06-22 06:24:02 +00:00
zenglifeng
6878fd2cde Porting the third-party library alsa-lib, add head file
Signed-off-by: zenglifeng <zenglifeng2@huawei.com>
2022-06-05 19:16:33 +08:00
zenglifeng
39280c6f22 Porting the third-party library alsa-lib
Signed-off-by: zenglifeng <zenglifeng2@huawei.com>
2022-05-18 11:17:05 +08:00
Jaroslav Kysela
2623e4bb76 ucm: add initial doxygen documenation
This is an attempt to explain the UCM in a more verbose way.

BugLink: https://github.com/alsa-project/alsa-ucm-conf/issues/103
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-12-01 10:33:44 +01:00
Jaroslav Kysela
ebb8a6c7a1 conf: introduce snd_config_load_string()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-12-01 10:18:58 +01:00
Jaroslav Kysela
a95942f1af conf: confeval - fix _to_integer error code
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-30 14:42:12 +01:00
Jaroslav Kysela
9b53b1f0fb conf: improve simple integer math expressions - brackets
Add brackets to the simple math expressions like:

  $[($a+($val+100))/2]

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-30 14:35:58 +01:00
Jaroslav Kysela
7b6da9ee6d ucm: add ${eval:EXPR} substitution (Syntax 5)
It is useful to do simple integer math in UCM configurations, too.
Use snd_config_evaluate_string() string for this job.

Example:

    ${eval:1+1}
    ${eval:100*$var1}
    ${eval:$[$var2+1]/5}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-30 14:22:39 +01:00
Jaroslav Kysela
bf528b9066 conf: add possibility to evaluate simple integer math expressions
It is useful to use the math expressions for the values in configuration.
This patch adds a simple expression evaluation routines (integer only).
The syntax is simplified unix shell (bash) style.

Examples:

	$[1 + 1]
	$[$[2 + 2] / $var1]
	$[0xa0 | 0x05]

As a bonus, the variable substitutions were more abstracted.
The function snd_config_expand_custom() was introduced to be used
for example in the topology pre-precessor.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-30 11:33:35 +01:00
Jaroslav Kysela
32d332b786 conf: add safe_strtoll_base() like safe_strtol_base()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-29 15:01:32 +01:00
Jaroslav Kysela
7ffe3d4162 ucm: fix parsing of the internal hexadecimal card identifier (2)
I forgot to change the passed variable name.

Fixes: 050f18c5 ("ucm: fix parsing of the internal hexadecimal card identifier")
Fixes: https://github.com/alsa-project/alsa-lib/issues/188
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-12 17:27:39 +01:00
Jaroslav Kysela
050f18c525 ucm: fix parsing of the internal hexadecimal card identifier
Too many code was removed.

Fixes: f547b2e3 ("conf: introduce safe_strtol_base()")
Fixes: https://github.com/alsa-project/alsa-lib/issues/188
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-12 16:00:59 +01:00
Jaroslav Kysela
ea5481296f ucm: fix DeviceModifier parser
The bellow commit caused regression for the SectionModifier parser. Revert
the single line change.

Fixes: 251bc204 ("ucm: implement RenameDevice and RemoveDevice verb management")

Fixes: https://github.com/alsa-project/alsa-lib/issues/167
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-07 18:41:43 +01:00
Jaroslav Kysela
faee7f678d pcm: softvol - mark _snd_pcm_parse_control_id as static
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-02 11:04:43 +01:00
Jaroslav Kysela
f0d540f851 pcm: partially revert "pcm: softvol - make snd_pcm_parse_control_id private"
This reverts partially commit b9a4997e92.

It seems that we have have some users for this very specific function.
Mark it deprecated and keep the softvol implementation separate,
so we can remove this function easily in future.

Fixes: https://github.com/alsa-project/alsa-lib/issues/186
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-02 11:00:35 +01:00
Jaroslav Kysela
5fab157a59 topology: do not call strtol directly
Introduce safe_strtol_base() function and redirects all
strtol calls there. Also, improve error and value handling
in callers.

BugLink: https://github.com/alsa-project/alsa-lib/issues/187
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-02 10:45:51 +01:00
Jaroslav Kysela
f547b2e35f conf: introduce safe_strtol_base()
It is useful to parse hexadecimal strings, too.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-11-02 10:41:11 +01:00
Jaroslav Kysela
23198a72cd ucm: suppress the no device (no UCM card) errors on request
It seems that users are confused when the UCM configuration
is not ready for the particular hardware. Actually, we don't
allow a fine grained message classification in alsa-lib and
UCM API. Allow suppression of this specific type of messages
on the application request (typically alsactl).

BugLink: https://github.com/alsa-project/alsa-utils/issues/111
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 11:52:08 +02:00
Jaroslav Kysela
a6a22d82a0 rawmidi: allocate the read buffer in the params call
It is better to allocate the read buffer for the framing stream
in the params setup call.

Suggested-by: David Henningsson <coding@diwic.se>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Jaroslav Kysela
392d5b06f8 rawmidi: free framing read bufffer when the framing mode becomes inactive
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Jaroslav Kysela
c932c1e7ab rawmidi: add support for SNDRV_RAWMIDI_IOCTL_USER_PVERSION
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Jaroslav Kysela
c578e80d6f rawmidi: return ENOTSUP when timestamp reads are not supported by plugins
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Jaroslav Kysela
5ac6198376 rawmidi: allow timestamp reads only for the appropriate read mode
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Jaroslav Kysela
11f54c2774 rawmidi: doc - fix the framing / read mode section
Follow the previous changes and describe the current API.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Jaroslav Kysela
d3c5e9e009 rawmidi: rename enum snd_rawmidi_framing to snd_rawmidi_read_mode
We hide the internal data transfers using the data frames. Rename
the snd_rawmidi_framing enum to snd_rawmidi_read_mode to make
API more straight and understandable.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Jaroslav Kysela
5a5c2953ea rawmidi: define more abstract API for the timestamp reads
The frame structure is a bit internal thing for the kernel
data transfer implementation. Introduce snd_rawmidi_tread()
function which is straight for the application usage and hides
the framing data transfers (kernel space API).

The current code implements the read cache and does the merging
of the frame reads with the similar timestamps (opposite
to the kernel data split for big chunks).

If the application wants to use super-duper-lighting-fast reads,
the snd_rawmidi_read() may be used, but the structure must be
defined on it's own, because this mechanism is not preferred
and unsupported.

BugLink: https://github.com/alsa-project/alsa-lib/issues/172
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-28 08:40:20 +02:00
Johan Adolfsson
42eeb5eca0 dlmisc.c: Avoid double unlock in snd_dlobj_cache_get0()
Remove call to snd_dlobj_unlock() in snd_dlobj_cache_get0()
All lock/unlock is done by callers of the function.

Buglink: https://github.com/alsa-project/alsa-lib/issues/181
Fixes: https://github.com/alsa-project/alsa-lib/pull/182
Signed-off-by: Johan Adolfsson <johana@axis.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-10-07 16:52:56 +02:00
Jaroslav Kysela
a1e91720cc rawmidi: initialize the reserved space in snd_rawmidi_params_default()
BugLink: https://github.com/alsa-project/alsa-lib/issues/178
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-09-19 21:04:21 +02:00
Sava Jakovljev
1aeea94ce8 pcm: multi plugin - adjust appl_ptr on rewind/forward operations
When doing rewind or forward operations, application pointer needs to
be properly adjusted, in the same way when doing commit/write
operations.

Fixes: https://github.com/alsa-project/alsa-lib/pull/161
Signed-off-by: Sava Jakovljev <sava.jakovljev@teufel.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-09-03 08:54:56 +02:00
Henrik Enquist
c4972cb154 pcm: add a note about return values of snd_pcm_state()
Fixes: https://github.com/alsa-project/alsa-lib/pull/162
Signed-off-by: Henrik Enquist <henrik.enquist@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-09-03 08:41:40 +02:00
Jaroslav Kysela
aa04023565 ucm: substitute the before/after identifiers
This allows to handle correctly declarations like:
  Before.SectionDevice "${var:DeviceMic}"

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-09-01 11:05:51 +02:00
Jaroslav Kysela
4a52ae4c32 ucm: fix the parsing of the hexadecimal prefix
The safe_strtol() function use strtol() which expects
to have the '0x' prefix for the hexadecimal number (when
base argument is zero).

BugLink: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1553
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-31 09:42:02 +02:00
Jaroslav Kysela
7d40a76ef5 ucm: avoid zero card instance number
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-31 09:25:12 +02:00
David Henningsson
95eb312fad rawmidi: Add rawmidi framing API
Optionally, incoming rawmidi bytes can be put inside a frame of type
snd_rawmidi_framing_tstamp_t.
The main current benefit is that can enable in-kernel timestamping of
incoming bytes, and that timestamp is likely to be more precise than
what userspace can offer.

Tstamp type framing requires a kernel >= 5.14 and a buffer size that
is a multiple of sizeof(snd_rawmidi_framing_tstamp_t). It is only
available on input streams.

Signed-off-by: David Henningsson <coding@diwic.se>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-08-20 08:46:26 +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
Jaroslav Kysela
1a1f0fb244 pcm: rate - fix some gcc warnings
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-28 12:13:56 +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
e0e0846590 pcm: direct plugins - fix bad memory access when channel bindings do not match hw
Fix and cleanup snd_pcm_direct_check_interleave() function.
Add requested / hardware channel check and use goto when the interleaved

Fixes: https://github.com/alsa-project/alsa-lib/issues/117
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-21 15:18:28 +02:00
Takashi Iwai
a5e11f9a81 pcm: Move snd_pcm_channel_area_addr() and _step() to public header
Used in the rate plugins commonly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-21 14:22:36 +02:00
Jaroslav Kysela
dd609ef968 pcm: direct plugins - fix hw_ptr in the status callback
The parent hw_ptr may be in another range (boundary limit).
Set the correct value for the caller.

BugLink: https://github.com/alsa-project/alsa-lib/issues/155
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-21 09:28:43 +02:00
Jaroslav Kysela
212c6c18c4 pcm: dmix - use pcm_frame_diff() in snd_pcm_dmix_sync_ptr0()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-21 09:23:02 +02:00
Jaroslav Kysela
3f737a2a2c pcm: improve docs for snd_pcm_sw_params_get_avail_min() and snd_pcm_status_get_avail_max()
Fixes: https://github.com/alsa-project/alsa-lib/issues/44
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-18 11:35:36 +02:00
Takashi Iwai
119d9c1678 pcm: rate: Improve the support multiple formats
This patch extends the PCM rate plugin for allowing its converter
plugin to deal with multiple formats.  Currently, the converter plugin
is allowed to take different formats only when convert callback is
defined.  And for this way (so far only the standard linear rate
plugin does), all linear formats have to be handled, and it's
cumbersome.

OTOH, most other rate plugins are implemented with convert_s16
callback, which accepts only S16 format.  This is often not ideal
because many converter engines can handle 32bit formats.  Also, the
target format is often 32bit format, hence this would require
additional conversion even if the converter engine can output 32bit
natively.

In this patch, for addressing the problems above, the rate plugin API
is extended in the following way:

- The new get_supported_formats callback is added; this stores the bit
  masks of the supported input and output formats, as well as the
  behavior flags.  Currently only linear formats are allowed.
- When the plugin accepts only the interleaved stream, set
  SND_PCM_RATE_FLAG_INTERLEAVED flag bit.  Otherwise the code has to
  handle snd_pcm_channel_area at each call.
- When both input and output formats have to be identical, pass
  SND_PCM_RATE_FLAG_SYNC_FORMATS flag bit.
- When the converter wants to process different formats, use convert
  callback instead of convert_s16.  You can put both in the ops for
  compatibility, too.
  The input and output formats are found in the info argument of init
  callback.
- Now the PCM rate plugin core will skip the temporary buffer
  allocation and conversions for pre- and post-process if not needed
  (i.e. matching with the requested input or output format).

The rate plugin API version is bumped to 0x010003.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-17 11:40:38 +02:00
Takashi Iwai
5089358aa9 pcm: rate: Refactoring temporary buffer allocations
Introduce common helpers to allocate and release the temporary buffers
and the associated snd_pcm_channel.  Now two allocated objects are
used instead of one malloc to be split.

Also, change the snd_pcm_channel set up to be in interleaved mode.
This will be necessary in the following change in the rate plugin.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-17 10:20:25 +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
Chih-Wei Huang
76d1aa0cd7 configure: check if eaccess() is available
To fix the build error on Android:
  src/ucm/parser.c:2521:7: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                if (eaccess(filename, R_OK))
                    ^
  src/ucm/parser.c:2521:7: note: did you mean 'access'?

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-14 10:10:58 +02:00
Chih-Wei Huang
01960fa856 ucm: include sys/wait.h to fix build on Android
src/ucm/main.c:788:8: error: implicit declaration of function 'WIFSIGNALED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        if (WIFSIGNALED(err)) {
                            ^
    src/ucm/main.c:790:10: error: implicit declaration of function 'WIFEXITED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        } if (WIFEXITED(err)) {
                              ^
    src/ucm/main.c:791:34: error: implicit declaration of function 'WEXITSTATUS' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                if (ignore_error == false && WEXITSTATUS(err) != 0) {

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-14 10:10:02 +02:00