summaryrefslogtreecommitdiff
path: root/src/modules/alsa/alsa-mixer.c
AgeCommit message (Collapse)AuthorFilesLines
2023-08-12alsa-mixer: Respect XDG base directory spec when loading profile setsSimonP1-29/+33
Try $XDG_DATA_HOME, then $XDG_DATA_DIRS, and finally fall back to old behaviour. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/311>
2023-02-25alsa-util: Perform format and rate detection before setting HW paramsIgor V. Kovalenko1-1/+1
Perform detection of supported sample format and rates just after device is opened, before `snd_pcm_hw_params()` is called for the first time. This fixes a problem where device restricts available sample rates after HW params are set preventing sample rate detection (seen with UAC2 devices and kernel 6.1.9) Bug: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1414 Bug: https://github.com/alsa-project/alsa-lib/issues/119 Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/782>
2022-06-23fix translation error of pulseaudiopeijiankang1-1/+1
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/726>
2021-06-01alsa-mixer: prevent double-free on decibel fixes object keyIgor V. Kovalenko1-0/+1
When decibel fixes object is cloned, there is only a shallow copy of `key` string member of original object. This may lead to double-free crash reported in pipewire tracker https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1125 Fix this by doing a deep copy of `key` string to maintain correct ownership. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/569>
2021-04-19alsa-mixer: Allow selected fallback mappings in all profile setsIgor V. Kovalenko1-3/+15
When fallback mapping is selected all subsequent profile sets containing selected mapping are ignored. When there are only e.g. fallback input mappings available, admitted profile set will only contain one profile with selected first input fallback mapping and no outputs, and rest of profiles will only contain outputs and no inputs. When there are only fallback input and output mappings, there will be no profiles admitted at all. Fix this by making sure that selected first fallback input or output mapping is actually allowed to exist in all probed profile sets. Note while this change allows selected fallback mappings to be found in duplex configuraitons, probing fallbacks still can fail if there is more than one input fallback and first one (selected) does not work in duplex configurations. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/539>
2021-01-18alsa-mixer: Accept negative max_dB when using decibel fixesTanu Kaskinen1-1/+1
Sometimes decibel fixes are used as a trick to set a maximum hardware volume, and in these cases max_dB may be negative yet still valid. Here's an example: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/292#note_671300 Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/447>
2021-01-18alsa-mixer: disable has_dB if max_dB is negativeBenjamin Valentin1-0/+8
Volume scaling in dB mode is broken if max dB is negative. I have a Nobsound USB amplifier (1908:2220) that reports a dB range of -127.07 dB to -128 dB in Alsa. While this is likely a driver/device bug, in my naive imagination userspace wouldn't bother too much with the absolute values and just set out_dB(percent) = min_dB + (max_dB - min_dB) * percent However, this is not what PulseAudio is doing, instead max_dB is used as base_volume with which the desired software volume is multiplied while min_dB does not seem to be taken into account. The result is that with this device only a tiny portion of the volume slider is usable. Setting it to 97% already reaches min_dB which effectively turns any (software) audio knob to an on/off switch. To work around this, simply set the has_dB flag to false if max_dB is negative. This falls back to using raw Alsa values (ranging from 0 - 255), now the settings in pavucontrol perfectly mirror those in alsamixer. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/447>
2020-12-30alsa-mixer: Use unambiguous descriptions with dual headphone outputsTanu Kaskinen1-0/+1
Previously both paths had description "Headphones", which I assume can cause confusion with users who see two ports with identical names. I don't have this kind of hardware myself nor have I heard complaints from users, this is just something I noticed while reading the configuration files. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/272>
2020-12-30alsa-mixer: Handle the index for ALSA mixer jack identifiersKai-Heng Feng1-49/+60
Some systems have two jacks with same name but different index, we need to take index into consideration to use both jacks. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/272>
2020-12-21alsa: mixer - add support up 8 mixer channelsJaroslav Kysela1-19/+99
We have at least one USB hardware which supports the 8 channels in one mixer element: https://github.com/alsa-project/alsa-ucm-conf/pull/25 POSITION_MASK_CHANNELS define was added for the future extensions. The override_map variable was changed from bool to mask (unsigned int). The channel map override settings is handled for channels up to eight now. Also added missing override-map.3 .. override-map.8 to the configuration parser array. The driver channel position was added to the override mask arguments (syntax is driver:pulseaudio like left:all-left). If ommited, the ALSA's channel positions are guessed by index. Link: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/292 Signed-off-by: Jaroslav Kysela <perex@perex.cz> Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/389>
2020-12-21alsa: mixer - use safe dB range values when the override mask is unsetJaroslav Kysela1-3/+16
Use safe values for the min_dB and max_dB fields when the position mask is unset to avoid breakage for the upper levels. If the range is incorrect, the volume range shown in pavucontrol shows strange values. (Thanks to Wim Taymans for the idea.) Signed-off-by: Jaroslav Kysela <perex@perex.cz> Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/389>
2020-12-14alsa-mixer: Pick at most one fallback mappingTanu Kaskinen1-2/+2
The old behaviour was such that if none of the normal mappings worked, we would probe ALL fallbacks. I don't think that makes sense, and it caused concrete issues: let's say we have a regular stereo mic device, but there's no "front" PCM defined for it. In this situation we would probe the stereo-fallback mapping (which uses "hw" instead of "front"), and it would work, but then we'd also probe the "multichannel-input" mapping, which would also work, so we end up with two mappings that don't have any difference in behaviour. I think it's better to simply pick the first working fallback and ignore the rest. Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/901 (issue is marked as confidential due to unreleased hardware) Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/304>
2020-12-14alsa-mixer: Respect XDG base directory spec when loading path configsSimonP1-8/+60
Try $XDG_DATA_HOME, then $XDG_DATA_DIRS, and finally fall back to old behaviour (prefix-defined directory). core-util: Ignore non-absolute XDG base dirs These are invalid per the spec. Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/862 Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/293>
2020-12-09alsa-mixer: add support for Sennheiser GSX 1000 gaming DACPatrick McLean1-0/+4
This same profile should also work for the GSX 1200, but I don't know the USB id for that. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/257>
2020-11-23alsa-mixer: Add support for HP Thunderbolt DockKai-Heng Feng1-0/+4
The HP Thunderbolt Dock [1] has two separate USB cards, a headset jack and an optional module which is a speakerphone. This patch adds new description for them, and mark the intended-roles as phone for the speakerphone module. [1] https://store.hp.com/us/en/pdp/hp-thunderbolt-dock-120w-g2-with-audio
2020-11-23alsa-mixer: add mono input support for Behringer UMC22Nazar Mokrynskyi1-0/+2
2020-10-30alsa-mixer: Fix jack name comparisonv13.99.3Tanu Kaskinen1-1/+1
HDMI jacks are configured like this: [Jack HDMI/DP] append-pcm-to-name = yes The pa_alsa_jack.name field is then "HDMI/DP" and pa_alsa_jack.alsa_name is set to "HDMI/DP,pcm=3 Jack" or similar. If we compare the name fields of HDMI paths, they appear to use the same jack element even though they are different in reality, so all HDMI ports got incorrectly assigned to the same availability group.
2020-10-30alsa-mixer: Set availability groups once per cardTanu Kaskinen1-11/+27
Previously they were set once per mapping, which caused the numbering to restart from 1 for every mapping, so ports were incorrectly assigned to the same group.
2020-10-13Revert "alsa-mixer: support up to 8 channels per mixer element"Arun Raghavan1-15/+9
This reverts commit e0ab9fa4a478a79fac5fa25a957daff4947d5133. The change broke some Xonar cards, and we probably don't want to hold up the 14.0 release for this. Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1009
2020-10-13alsa-mixer: support up to 8 channels per mixer elementJaroslav Kysela1-9/+15
We have at least one USB hardware which supports the 8 channels in one mixer element: https://github.com/alsa-project/alsa-ucm-conf/pull/25 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-10-04alsa: fix analog-input-microphone-headset device typeJaroslav Kysela1-1/+1
From: Hui Wang <hui.wang@canonical.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-10-04alsa: mixer - reorder the type field in path parserJaroslav Kysela1-1/+1
The items array is assigned later and the order of fields is important. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-08-10alsa-mixer: Fix indentationTanu Kaskinen1-24/+24
2020-08-10Rename "available group" to "availability group"Tanu Kaskinen1-6/+6
"Availability group" is more clear about what the field is about. Credits to Arun Raghavan for coming up with the better name.
2020-08-10alsa-mixer: Fix mapping_group_available() logicTanu Kaskinen1-3/+3
There were three bugs: 1) j->state_plugged was set to PA_AVAILABLE_UNKNOWN too early. It must be set only after we have found that the jack is shared by two ports. The result of setting it too early was that no jack ever could have the PA_AVAILABLE_YES status. 2) The inner jack loop iterated through p->jacks instead of p2->jacks, so the code didn't compare jacks between two ports at all. As a result all ports were put in the same availability group. 3) The inner jack loop checked j->state_plugged instead of j2->state_plugged. The result was that the speaker port, which uses the Headphone jack to toggle between unknown and unavailable, was put in the same group with the headphone port.
2020-07-26alsa-mixer: add support for Astro A50 gaming headsetTomasz Kontusz1-0/+2
2020-07-26alsa-mixer: add description-key to Mappings and ProfilesTomasz Kontusz1-2/+31
2020-07-26alsa-mixer: Remove unused iec958-passthrough* descriptionsTomasz Kontusz1-2/+0
They were unused since 20f1fa17bebe086cb9cff09a5157dc7ca009ba61.
2020-07-26alsa-mixer: Fix well-known descriptions for steelseries game/chat outputsTomasz Kontusz1-2/+2
2020-06-17alsa: legacy card - implement device port type parser and assignmentJaroslav Kysela1-30/+100
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17alsa: legacy card - set available_groupJaroslav Kysela1-0/+49
Create automatically the groups per paths where the similar jacks are used. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-10alsa-mixer: store the ucm_device with the order of their priorityHui Wang1-1/+14
There is some case that multiple ucm devices share an amixer Jack like "Headphones", "Headset" and "Mic2" share the "Headphone Mic Jack", When the Jack state is changed, the module-switch-on-port-available will process them in the order they are in the jack->ucm_devices, and the last device will decide the final setting. But usually users put priority for those devices and expect the final setting is based on the highest priority device if there is no other policies like manual selection. So here do some change to store the ucm_devices according to their priority (from low to high). For example, we have ucm devices definition like below (ucm2): SectionDevice."Mic2" { Comment "Headphones Stereo Microphone" ... Value { CapturePriority 200 ... } SectionDevice."Headset" { Comment "Headset Mono Microphone" ... Value { CapturePriority 300 ... } } Without this patch, the final setting is based on Mic2, after applying this patch, the final setting is based on the Headset (with higher priority than Mic2). Signed-off-by: Hui Wang <hui.wang@canonical.com>
2019-12-23alsa-mixer: improve check for the empty path set for sink/sourceJaroslav Kysela1-0/+6
The unused mixer instances are created without this code. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-23alsa: rewrite mixer open/close, cache mixer accesses in probeJaroslav Kysela1-9/+10
The ALSA mixer can be opened multiple times (especially for UCM in the probe). This adds a simple mixer cache to prevent multiple open calls. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-23alsa-mixer: Add the ability to pass the intended-role to the mappingLaurent Bigonville1-0/+19
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/640
2019-12-18alsa-mixer: handle interface type (CARD,PCM) for mixer element lookupsJaroslav Kysela1-1/+1
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-06alsa-ucm: add support for master volumeJaroslav Kysela1-10/+10
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-06alsa-mixer: improve alsa_id_decode() functionJaroslav Kysela1-3/+16
Accept those identifiers: Speaker,1 'Speaker',1 "Speaker",1 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-06alsa-mixer: handle the index for ALSA mixer element identifiersJaroslav Kysela1-80/+206
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-08rtpoll: Separate out before/after/work callback userdataArun Raghavan1-3/+2
It is possible that we might want to have a separate userdata to be used for these callbacks, so let's split them out. This is particularly needed when using an pa_rtpoll_item around pa_fdsem since that uses its own before/after callback but will essentially have whatever is using the fdsem set up the work callback appropriately (and thus at least the work callback's userdata needs to be separated from the before/after callback -- we might as well then just separate all three). Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2019-03-27alsa: Use correct header pathOlaf Hering1-1/+1
Consumers are expected to use <alsa/asoundlib.h> instead of <asoundlib.h>. This is in preparation of an change to pkgconfig(alsa) to not pollute CFLAGS with -I/usr/include/alsa anymore. Signed-off-by: Olaf Hering <olaf@aepfle.de>
2019-02-16Remove space in "Digital Passthrough (IEC958)"scootergrisen1-1/+1
2018-12-11build-sys: introduce a special build flag to explicitly disables running ↵Hongxu Jia1-0/+4
from build tree It is helpful to improve reproducibility build [1] since PA_SRCDIR/PA_BUILDDIR contains build path, --disable-running-from-build-tree could drop these macros at precompilation. [1] https://reproducible-builds.org/ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2018-06-21alsa-mixer: make the mono mapping a fallback onlyTanu Kaskinen1-0/+1
If a sound card doesn't have the "front" device defined for it, we have to use the "hw" device for stereo. Not so long ago, the analog-stereo mapping had "hw:%f" in its device-strings and everything worked great, except that it caused trouble with the Intel HDMI LPE driver that uses the first "hw" device for HDMI, and we were incorrectly detecting it as an analog device. That problem was fixed in commit ea3ebd09, which removed "hw:%f" from analog-stereo and added a new stereo fallback mapping for "hw". Now the problem is that if a sound card doesn't have the "front" device defined for it, and it supports both mono and stereo, only the mono mapping is used, because the stereo mapping is only a fallback. This patch makes the mono mapping a fallback too, so the mono mapping is used only if there's absolutely nothing else that works. This can cause trouble at least in theory. Maybe someone actually wants to use mono output on a card that supports both mono and stereo. But that seems quite unlikely.
2018-06-21alsa-mixer: add support for SteelSeries Arctis 5 and renamed Arctis 7 files ↵Bert Hekman1-0/+2
appropriately
2018-02-13alsa-mixer: autodetect the ELD deviceTanu Kaskinen1-2/+26
This removes the need to hardcode the ELD device index in the path configuration. The hardcoded values don't work with the Intel HDMI LPE driver. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=100488
2018-02-13alsa-mixer: autodetect the HDMI jack PCM deviceTanu Kaskinen1-5/+48
This removes the need to hardcode the PCM device index in the HDMI jack names. The hardcoded values don't work with the Intel HDMI LPE driver. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=100488
2018-02-13alsa-mixer: add hw_device_index to pa_alsa_mappingTanu Kaskinen1-0/+26
We have so far assumed that HDMI always uses device indexes 3, 7, 8, 9, 10, 11, 12 and 13. These values are hardcoded in the path configuration. The Intel HDMI LPE driver, however, uses different device numbering scheme. Since the indexes aren't always the same, we need to query the hw device index from ALSA. Later patches will use the queried index for HDMI jack detection and ELD information reading. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=100488
2017-09-18alsa-mixer: add mixer handling to the fallback stereo caseTanu Kaskinen1-1/+1
Some sound cards don't have any alsa-lib configuration, but they used to work well enough up to PulseAudio 10. PulseAudio 11 stopped using "hw:0" for the analog-stereo mapping, and instead defined it as a fallback mapping without any mixer handling. As a result, switching between headphones and speakers stopped working without changing the mixer settings manually at least on Toshiba Chromebook 2. This patch adds the mixer handling back to the fallback mapping. I also renamed "unknown-stereo" to "stereo-fallback", because I like that name more. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=102560
2017-09-05alsa-mixer: add support for Steelseries Arctis 7 headsetJohan Heikkilä1-0/+1