Commit graph

4359 commits

Author SHA1 Message Date
Dan Cross
b7389e2e2e pcm: hw: fix minor bug in sw_params ioctl
Some checks failed
Build alsa-lib / fedora_latest_build (push) Has been cancelled
Build alsa-lib / ubuntu_last_build (push) Has been cancelled
Commit 2115cdb added a new call to the `SNDRV_PCM_IOCTL_SW_PARAMS`
ioctl on line 675 of src/pcm/pcm_hw.c, but passed the `sw_params`
argument by value; this should be passed by pointer.

I ran across this in the context of the direwolf software modem
for amateur radio; debugging details are in
https://groups.io/g/direwolf/message/8286

Fixes: https://github.com/alsa-project/alsa-lib/pull/330

Signed-off-by: Dan Cross <cross@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-06-15 07:51:11 +02:00
Takashi Iwai
77247f51c4 seq: Add UMP 1.1 features
Add APIs for groupless message filtering.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-12 10:14:23 +02:00
Takashi Iwai
80e20a1052 ump: Add UMP 1.1 features
Add a few new features for UMP 1.1:
- New attributes in UMP Endpoint and Block info
- Static block bit flag for EP info

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-12 10:14:20 +02:00
Takashi Iwai
517957a24b uapi: Update rawmidi API to 2.0.4
Sync with the kernel change of rawmidi API for supporting UMP 1.1
features.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-12 10:14:17 +02:00
Takashi Iwai
2aefb5c41c seq: Add UMP support
This patch adds the basic support of UMP on ALSA sequencer API.
An extended event type, snd_seq_ump_event_t, is defined.  It's
compatible with the existing type, snd_seq_event_t, but it has a
larger payload of 16 bytes instead of 12 bytes, for holding the full
128bit UMP packet.

The new snd_seq_ump_event_t must have the bit SND_SEQ_EVENT_UMP in the
event flags.

A few new API functions have been added such as
snd_seq_ump_event_output() and snd_seq_ump_event_input() for
reading/writing this new event object.

The support of UMP in the sequencer client is switched by the function
snd_seq_client_set_midi_version().  It can switch from the default
legacy MIDI to UMP MIDI 1.0 or 2.0 on the fly.

The automatic event conversion among UMP and legacy clients can be
suppressed via snd_seq_client_set_ump_conversion().

The inquiry of the associated UMP Endpoints and UMP Blocks can be done
via snd_seq_get_ump_endpoint_info() and snd_seq_get_ump_block_info().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
c40dc19a57 uapi: Update asequencer.h definitions for 1.0.3
Updated from kernel for supporting UMP on sequencer API.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
e80ee6ae75 ump: Add helpers for handling SysEx data
Yet a few more helpers for handling SysEx data with UMP packets.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
040356ecf0 ump: Add helpers to parse / set UMP packet data
This patch defines the structs / unions that can be used for encoding
and decoding UMP packets, as well as inline helper functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
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
Takashi Iwai
f47763d2c1 ump: Add initial support
This patch adds the initial support for UMP rawmidi access.
It's merely the wrapper for the standard rawmidi to access to the UMP
rawmidi device.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
6627953de0 rawmidi: Add UMP ioctl support
Just implement internal callbacks for two new ioctls for UMP
(ump_endpoint_info and ump_block_info).  No public API functions are
added yet here.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
a034b84705 uapi: Update control API to 2.0.9
Copied from the kernel uapi header for control API.
A few new ioctls have been added for the support of UMP next device
and inquiries of UMP Endpoint and Block info.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-06 15:13:27 +02:00
Takashi Iwai
c86a4f5cf6 uapi: Update rawmidi API to 2.0.3
Copied from the kernel uapi header for rawmidi API.
A few new structs and constants for UMP are defined in addition to a
few new ioctls.

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
325210acc8 usecase: add CaptureMicInfoFile field to documentation
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-16 15:57:15 +02:00
Jaroslav Kysela
55cdf2fd63 include: fix SND_DLSYM_BUILD_VERSION() for static build
Correct the dlsym_name string for nested macros. See Fixes:.

Fixes: https://github.com/alsa-project/alsa-lib/issues/316
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-16 09:16:12 +02:00
Jaroslav Kysela
3661bdae35 pcm: hw - prevent divide by zero for broken apps
Fixes: https://github.com/alsa-project/alsa-lib/issues/318
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-16 08:59:20 +02:00
Jaroslav Kysela
904f0f7e7a Release v1.2.9
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-04 09:16:16 +02:00
Jaroslav Kysela
58077e2f0d pcm: hw: fix the silence size setup in drain
The silence size cannot exceed the silence threshold. Move the check
from the manual condition to the common code. This may happen for
small ring buffers (where the 1/10th second is too large).

Suggested-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 22:27:40 +02:00
Oswald Buddenhagen
798f387fe9 conf/emu10k1: remove compat with two decades old drivers
There really isn't much of a point to clutter the files with this.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 18:01:40 +02:00
Oswald Buddenhagen
3da32ca4db pcm: remove duplicate SND_PCM_HW_PARAM_{FIRST,LAST}_* #defines
Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 17:59:49 +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
d6d5982d3a pcm: add SND_PCM_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
e2d9e41174 pcm: improve handling for snd_pcm_wait()
The snd_pcm_wait() function is called also internally from
the various plugins to wait for the drain with -1 and from i/o
routines in pcm.c.

Define two special negative timeout values to distinguish the
drain and i/o wait and calculate the maximal timeout according
the wait place.

Fixes: 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
1de6f99c7d pcm: add new symbols to Versions.in
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 15:58:57 +02:00
Jaroslav Kysela
264d6c43ee pcm: hw: introduce SNDRV_PCM_HW_PARAMS_DRAIN_SILENCE
The application may not require to touch the playback
sample stream for the drain operation at all. In this case,
the application is responsible to setup a silencing mechanism
for the playback or another graceful stop (like using the
rewind operation).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 15:58:56 +02:00
Jaroslav Kysela
90e25887d2 pcm: hw: introduce SNDRV_PCM_INFO_PERFECT_DRAIN
Handle the driver informing us that it is not necessary to set up
silencing upon playback draining. This will be the case for drivers
which are guaranteed to not read any samples beyond the application
pointer.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 14:00:57 +02:00
Jaroslav Kysela
dd9cb31a90 pcm: hw: add drain_silence configuration keyword
# Add silence in drain (-1 = auto /default/, 0 = off, > 0 milliseconds)
  [drain_silence INT]

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 13:56:19 +02:00
Jaroslav Kysela
2115cdb4dc pcm: hw: setup explicit silencing for snd_pcm_drain by default
Some applications may not alignt transfers to the period size
and also the driver developers may not follow the consequeces of the
access beyond valid samples in the playback DMA buffer.

To avoid clicks, fill a little silence at the end of the playback
ring buffer when snd_pcm_drain() is called.

Related: https://lore.kernel.org/alsa-devel/20230420113324.877164-2-oswald.buddenhagen@gmx.de/
Related: https://lore.kernel.org/alsa-devel/20230405201219.2197789-2-oswald.buddenhagen@gmx.de/
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 13:50:56 +02:00
Maxython
b40fcda7fb compilation: fix ANDROID -> __ANDROID__ define detection
Fixes: https://github.com/alsa-project/alsa-lib/pull/301/
Signed-off-by: Maxython <mixython@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-02 14:52:27 +02:00
Jaroslav Kysela
a8afb0449c pcm: avoid endless loop in snd_pcm_sw_params_default()
BugLink: https://lore.kernel.org/alsa-devel/167734349294.22.1388671545195719262@mailman-web.alsa-project.org/
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-25 18:03:46 +01:00
SASANO Takayoshi
44705e3a20 test: BSD-like fixes
- rename devname -> pcmdev, it conflicts *BSD <stdlib.h> function
- replace <values.h> -> <limits.h> and fix K&R style related warning
- use config.h to determine include <malloc.h>
- add OpenBSD support and fix printf() warning
- fix warning

Fixes: https://github.com/alsa-project/alsa-lib/pull/298
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-03 13:22:04 +01:00
SASANO Takayoshi
3b4cdbdf19 type_compat.h: use ESPIPE instead of EPIPE when ESTRPIPE not defined
Fixes: https://github.com/alsa-project/alsa-lib/pull/298
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-02-03 13:21:54 +01:00
SASANO Takayoshi
fea9fc2298 configure: avoid libdl detecion on *BSD
NetBSD and OpenBSD has no libdl
FreeBSD and DragonFlyBSD has libdl but dummy

These OSes are no need to use -ldl to use dlopen()

Fixes: https://github.com/alsa-project/alsa-lib/pull/290
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-29 19:00:59 +01:00
Gunnar Dibbern
2f9bbefb8d pcm: hw - fix return code checking in snd_pcm_hw_hw_refine
The isse was introduced in commit 7f2d6c3

Fixes: 7f2d6c3a ("pcm: hw: change rate range syntax")
Fixes: https://github.com/alsa-project/alsa-lib/issues/271
Fixes: https://github.com/alsa-project/alsa-lib/pull/293
Signed-off-by: Gunnar Dibbern <gunnar.dibbern@lht.dlh.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-29 18:58:51 +01:00
Amadeusz Sławiński
e11ea20645 topology: Parse ignore_suspend property for dapm widget
snd_soc_tplg_dapm_widget has ignore_suspend field, but there is no way
to set value for it, because we don't parse topology field for it.
Fix this by adding parsing code.

Fixes: https://github.com/alsa-project/alsa-lib/pull/230
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-29 18:55:53 +01:00
Amadeusz Sławiński
e824f70d62 topology: Add decompilation support for ignore_suspend
Previous patch added build support for ignore_suspend, however it should
be also possible to decompile binary back to human readable form and not
lose data.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-29 18:55:29 +01:00
Cezary Rojewski
d72da154a3 topology: Parse ignore_suspend flag
XXX_VOICE_WAKEUP also known as 'ignore_suspend' is already processed by
kernel in soc-topology, but there is no way of setting it via topology
file like it's the case for other flags. Fix this by adding it to pcm,
dai and link parsing mechanism.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-29 18:55:29 +01:00
Sam James
1fc1c1b7dc utils/alsa.m4: include <stdlib.h> for exit()
Clang 16 makes -Wimplicit-function-declaration an error by default
and it's easier to just explicitly include <stdlib.h> rather
than hope the ALSA headers always have it.

Fixes: https://github.com/alsa-project/alsa-lib/pull/278
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-29 18:51:54 +01:00
Jaroslav Kysela
496c4e031b ucm: fix geti() macro - return zero on success
Fixes: c083417b ("ucm: simplify and fix the previous patch (geti)")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-15 18:57:56 +01:00
Jaroslav Kysela
c083417b72 ucm: simplify and fix the previous patch (geti)
Use macro to maintain only one code. The status may be 0 or 1 - handle
both values correctly.

Also, fix the possible memory leak in snd_use_case_geti() - string
str should be freed even when the error is returned.

Fixes: 436cd5b6 ("ucm: add existence checks to geti calls")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-15 18:37:40 +01:00
Curtis Malainey
436cd5b6d0 ucm: add existence checks to geti calls
Right now in snd_use_case_geti you cannot tell if the item being queried
exists or not when being checked. This also means the only way to check
for the existence of something in the client of the library is to
iterate over the list of mods/devs even if we know exactly the name we
are looking for. We have functions that do exactly this internally so
lets return this information in a logical fashion through geti.

Also clean up some trailing white space nearby.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-15 17:57:13 +01:00
Jaroslav Kysela
d25ddafaa7 ucm: fix possible memory leak in execute_sysw()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-01-05 15:42:31 +01:00
Alan Young
2e82060ebc pcm: rate: fix last_commit_ptr boundary wrapping
Wrap last_commit_ptr using boundary. Was just wrapped to 0, which is
correct only if the buffer size, and hence the boundary, is an integer
multiple of the period size.

Fixes: 467d69c5bc ("Fix CPU hog with combination of rate plugin")
Fixes: 29041c5220 ("fix infinite draining of the rate plugin in SND_PCM_NONBLOCK mode")
Link: https://lore.kernel.org/alsa-devel/20221230164814.901457-1-consult.awy@gmail.com/
Signed-off-by: Alan Young <consult.awy@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-12-30 20:12:42 +01:00
Jaroslav Kysela
9f2c68cef7 pcm: route/softvol use snd_config_get_ireal vs get_real to handle also integers
Link: https://lore.kernel.org/alsa-devel/f9a7ad6a256d4ad7a31642dcf875d436@axis.com/
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-12-13 10:31:35 +01:00
Jaroslav Kysela
13e31fb1ec alsa-lib: conf - fix possible use-after-free in get_char_skip_comments
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-12-07 14:54:30 +01:00
Jaroslav Kysela
e29413a220 ucm: execute_sysw - fix possible use-after-free
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-12-07 14:51:32 +01:00
Jaroslav Kysela
d28e8cb294 topology: ctl - remove the wrong (debug) code
This code was commited by mistake. It was used for testing
of ALSA_PCM_OLD_HW/SW_PARAMS_API.

BugLink: https://github.com/thesofproject/sof/issues/6667
Related-to: 78b20e3c ("test: latency - use snd_pcm_format_physical_width()")
Reported-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-29 19:43:52 +01:00
Jaroslav Kysela
75f8e2e73e test: latency - --policy option - allow using SCHED_OTHER
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2022-11-24 10:55:32 +01:00