Commit graph

4256 commits

Author SHA1 Message Date
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
bb646ecb47 pcm: empty plugin - fix the docs
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-07 16:22:34 +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
3cfbacdc34 ucm: add ctl-remove sequence command to delete controls from UCM
Syntax:

   ctl-remove "name='ABCD'"

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-29 11:31:08 +02:00
Jaroslav Kysela
02423dc970 ucm: add cset-new sequence command to create new controls from UCM
This command create a new control using ID, description and value.

Syntax:

    cset-new "name='ABCD',index=2 type=boolean,count=2 on,on"
    cset-new "name='Enum' type=enum,labels='L1;L2;L3' 'L2'"

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-29 11:00:25 +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
2f57b404b1 ucm: add Path condition type
Check for a file presence and mode.

Modes: exists, read, write, exec

Example:

	If.0 {
		Condition {
			Type Path
			Mode read
			Path "/etc/alsa/something"
			True {
				...
			}
		}
	}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-23 17:16:14 +01:00
Jaroslav Kysela
0afa61e8f0 ucm: rename sysset to sysw
Fixes: 1c6fb202 ("ucm: implement sysset sequence command")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-23 11:40:30 +01:00
Takashi Iwai
7bf1dd543b conf: Fix invalid free at parse_args()
The previous fix for memory leaks introduced a few regression.
The major one is the assert hit in the error path reaching with NULL
or uninitialized sub object.  Also, in other code paths, it's possible
that an already released sub object gets freed again.

Fix those bugs by initializing the sub object properly and add a NULL
check before calling snd_config_delete().

Fixes: ad5f255b47 ("conf: fix memory leak on the error path in parse_args()")
Reported-and-tested-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-03-18 17:43:58 +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
ad5f255b47 conf: fix memory leak on the error path in parse_args()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-11 09:26:07 +01:00
Jaroslav Kysela
56c11293e3 ucm: warn about unknown sequence commands
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-11 09:26:07 +01:00
Jaroslav Kysela
1c6fb20232 ucm: implement sysset sequence command
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-11 09:26:07 +01:00
Jaroslav Kysela
2b418648cf ucm: ucm_main.c - cosmetic tab cleanups
This file is problematic for the git's tab checker.
The unexpand tool is used to convert initial spaces
to tabs.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-11 09:26:07 +01:00
Jaroslav Kysela
9c194a0ba7 ucm: add _fboot / FixedBootSequence
Actually, the BootSequence is executed only when the driver controls
(identifiers or value types) are changed. It may be handy to have
also a sequence which is executed at _each_ boot without any condition.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-11 09:25:52 +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
8bd9e7897d conf: snd_config_save() - print arrays as [] not the internal representation
The internal represention of an array is:

{
	0 value1
	1 value2
	2 value2
	...
}

which is identicatal to shorter:

[
	value1
	value2
	value3
]

Always print the short format. It's more optimized and readable.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-07 21:02:20 +01:00
Jaroslav Kysela
5766e54fbe conf: improve the tabulator level prints
Do not use per char loop, but compose a string.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-07 20:57:28 +01:00
Jaroslav Kysela
829fbf5065 mixer: simple - use for loop in base_len()
... reduce the code a bit

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-07 20:28:03 +01:00
Hans de Goede
86b9c67774 mixer: simple - Unify simple_none: base_len() exception handling
Unify simple_none: base_len() exception handling:

1. In the "Input Source" and "3D Control" cases the base-name is the same
   as the full-name and base_len() simply returns strlen(name).
   Instead of returning 0 when the type is unknown, set the type to
   CTL_SINGLE and return strlen(name). This allows removing the special
   case for base_len() returning 0 in simple_event_add().

2. Move the special handling for "Capture Volume" and "Capture Switch"
   from simple_event_add() to base_len(), so that we handle all exceptions
   inside base_len(). Instead of handling some special cases in base_len()
   and other special cases in simple_event_add().

[jk - moved the "Capture Volume" and "Capture Switch" to "Input Source"
exceptions]

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-05 21:11:19 +01:00
Jaroslav Kysela
33ddf2e1c7 configure: bumb version to 1.2.5pre1 (for CI tests)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-05 18:36:01 +01:00
Jaroslav Kysela
058299bff3 pcm: softvol - improve TLV data check for new configs
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-26 21:10:59 +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
1d1062d920 pcm: fix snd_pcm_plugin_status()
The appl_ptr difference must be computed before
the appl_ptr in the status structure is updated.

Fixes: da5b70d3f ("pcm: plugin - fix status code for capture")
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
b9a4997e92 pcm: softvol - make snd_pcm_parse_control_id private
The function is not used externally (it's not exported in headers).
Make it private.

Use snd_config_get_ctl_iface() for the interface value parsing.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-26 21:08:28 +01:00
Jaroslav Kysela
24db585dd1 pcm: softvol - do not set TLV access flags for the switch
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-26 21:08:25 +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
Hui Wang
dfbac0e769 conf: HDA-Intel: increase the max number of HDMI/DP output to 11
Intel TGL HDMI/DP codec provides 9 pins (Linux kernel, 9a11ba7388f16:
ALSA: hda: hdmi - add Tigerlake support), and with the DP MST enabled,
the linux kernel will build 11 output devices (3, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16), and current alsa-lib only maps the first 8 output
devices, if users plug the HDMI/DP monitor to the last 3 ports, the
users will not see the output device from pulseaudio or gnome.

We have experienced this issue on a dell TGL machine with a dock, we
plugged 2 HDMP/DP monitors on the dock, but we could only see 1
HDMI/DP output device from pulseaudio or gnome, through investigation,
we found one monitor is plugged in the 2nd port from last.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
BugLink: https://github.com/alsa-project/alsa-lib/pull/118
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-02-24 10:09:47 +01:00
Jaroslav Kysela
0d232d714a ucm: fix two error messages
- add missing argument to error msg in if_eval_regex_match()
- print correct error value in uc_mgr_config_load_file()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-03 11:57:49 +01:00
Jaroslav Kysela
296b067fc7 ucm: add ${find-card} and ${find-device} substitutions
It may be useful to find a correct card or device through
control API information fields.

Increase the syntax version to 4.

Examples:

  ${find-card:field=name,regex='HDA Intel'}
  ${find-device:type=pcm,field=id,regex='HDMI 1$'}
  ${find-device:ctl=hw:acp,type=pcm,field=id,regex=DMIC}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-02-03 11:42:56 +01:00
Jaroslav Kysela
00eafe98ee pcm: pcm_ioplug - fix the avail_update mmap capture copy issue
It seems that the commit "pcm: ioplug: Transfer all available data"
introduced new regressions (wrong memory access). The second issue
is that the avail_update in ioplug does not move appl_ptr nor hw_ptr,
so it's possible that the transfers may be repetitive.

This patch moves the transfer calls to mmap_begin callback where it
should be. The pointer wraps are handled by design now.

Fixes: 1714332719 ("pcm: ioplug: Transfer all available data")
BugLink: https://github.com/alsa-project/alsa-lib/pull/103
Tested-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-27 11:39:15 +01:00
Takashi Iwai
55d59821ff pcm: share: Pass appl_ptr and hw_ptr in snd_pcm_status()
This one also has the same problem as others; the appl_ptr and hw_ptr
of share plugin aren't updated in snd_pcm_status() call.  Fix it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-22 17:58:07 +01:00
Takashi Iwai
bcc762f99a pcm: null: Pass appl_ptr and hw_ptr in snd_pcm_status()
Just like the previous fix for ioplug, the null plugin also misses the
appl_ptr and hw_ptr updates for snd_pcm_status().  Fix it as well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-22 17:58:07 +01:00
Takashi Iwai
26fdcb98e6 pcm: ioplug: Pass appl_ptr and hw_ptr in snd_pcm_status()
The snd_pcm_status() of the ioplug doesn't return the current
positions of hw_ptr and appl_ptr as advertised.  Fix it by copying the
current values stored in the plugin data.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-22 17:58:07 +01:00
Takashi Iwai
f2c1a9f327 pcm: direct: Fix the missing appl_ptr update
A snd_pcm_status() call for the direct plugins receives the status
from the slave PCM, but this doesn't contain a valid appl_ptr, since
the slave PCM for the direct plugins is in a free-wheel mode, hence
the appl_ptr is always zero.  This result in the inconsistent
status->appl_ptr and pcm->appl.ptr, hitting the recently introduced
assert() call.

Fix it by transferring the plugin's appl_ptr to the upper caller.

BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1181194
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-22 17:58:07 +01:00
Jaroslav Kysela
ae7362c996 topology: fix 'parse_tuple_set() - remove dead condition code'
The whole SND_SOC_TPLG_TUPLE_TYPE_WORD condition part must be
commented out, otherwise the condition is always true.

Fixes: 51e1d486ce ("topology: parse_tuple_set() - remove dead condition code")
BugLink: https://github.com/alsa-project/alsa-lib/issues/114
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-20 17:05:01 +01:00
Jaroslav Kysela
0de72e63d7 pcm: dmix/dshare - delay calculation fixes and cleanups
Unfortunately, we cannot use status->avail from slave, because this value
does not wrap to the buffer size and it may even overflow slave boundary
(endless run). We can use only hw_ptr from slave.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-20 17:05:00 +01:00
Jaroslav Kysela
644514e85d pcm_plugin: set the initial hw_ptr/appl_ptr from the child pcm
The direct plugins (dmix & etc.) sets own initial
hw_ptr and appl_ptr. Use this initial settings
to export correct values in snd_pcm_status().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-20 17:04:49 +01:00
Jaroslav Kysela
93752fb4de conf: USB - add "Xonar U7 MKII" to USB-Audio.pcm.iec958_device
BugLink: https://github.com/alsa-project/alsa-lib/issues/100
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-07 17:49:27 +01:00
Jaroslav Kysela
45f503632a topology: sort_config() cleanups - use goto for the error path
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-07 17:45:27 +01:00
Jaroslav Kysela
3f63dc2644 ucm: uc_mgr_substitute_tree() fix use after free
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-07 17:41:38 +01:00
Jaroslav Kysela
51e1d486ce topology: parse_tuple_set() - remove dead condition code
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-01-07 17:40:42 +01:00