Commit graph

40 commits

Author SHA1 Message Date
David Härdeman
f33e1bc8c3 spa: alsa: autodetect supported iec958 codecs via ELD info
The alsa/acp code already supports getting a user-friendly monitor name
using the EDID-Like Data (ELD) information available from cards that follow
the Intel HDA specification.

This patch adds support for also parsing the SAD fields of the ELD, and
exposing the results as a "iec958.codecs.detected" property on the
corresponding node, which should make it possible to provide more
user-friendly configuration UIs and defaults.

The default value will take effect if the session manager does not set a
different value.

Brief example:
test@test:~/checkouts/pipewire$ pw-dump | grep -E "(iec958.codecs.detected|iec958.codecs)\":"
        "iec958.codecs": "[\"PCM\",\"AC3\",\"EAC3\",\"TrueHD\"]",
        "iec958.codecs.detected": "[\"PCM\",\"AC3\",\"EAC3\",\"TrueHD\"]",

<after powering on my receiver>

test@test:~/checkouts/pipewire$ pw-dump | grep -E "(iec958.codecs.detected|iec958.codecs)\":"
        "iec958.codecs": "[\"PCM\",\"DTS\",\"AC3\",\"EAC3\",\"TrueHD\",\"DTS-HD\"]",
        "iec958.codecs.detected": "[\"PCM\",\"DTS\",\"AC3\",\"EAC3\",\"TrueHD\",\"DTS-HD\"]",

Big thanks to Pauli Virtanen <pav@iki.fi>, who also wrote large paths of the
code for this patch.
2024-11-28 09:18:07 +01:00
Barnabás Pőcze
1a549c02a5 acp: do not overwrite properties of PCM with that of the card
The properties of the card might overwrite those of the PCM.
For example, the cards's `alsa.id` will be set on the PCM too
since 37a51533e0 ("acp: add more properties for the card").

To avoid that, call `pa_alsa_init_proplist_card()` first
in `pa_alsa_init_proplist_pcm_info()` instead of last.

See #4135
2024-10-01 22:50:12 +02:00
Diego Viola
7410755c03 Fix typos
found them with codespell.

Signed-off-by: Diego Viola <diego.viola@gmail.com>
2024-05-22 09:19:34 +02:00
Wim Taymans
44f2ed7579 alsa: add sync.id in acp properties 2024-04-30 10:14:30 +02:00
Wim Taymans
37a51533e0 acp: add more properties for the card
Use snd_ctl_card_info to set some more card properties such as the
alsa.id, alsa.mixer_name and alsa.components.

alsa.id is interesting because it is possible to use udev rules to set a
custom id, which is handy when you have two identical cards in the
system and want to assign unique ids to them.

See #3912
2024-03-18 10:59:23 +01:00
Wim Taymans
9fa559948e acp: also install a local error handler 2024-02-13 17:20:18 +01:00
Igor V. Kovalenko
3e45464603 alsa-util: Fix pa_alsa_get_supported_formats fallback.
Looks like original intention was to scan over sample formats supported by PA,
but code does the scan by list of alsa formats. Reverse the map and adjust
fallback case which now can use the same map.

Link: 5ab2b9cb0e
2023-12-04 15:34:48 +00:00
Igor V. Kovalenko
082680d8a2 alsa-util: Perform format and rate detection before setting HW params
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
Link: aed52c507f
[Wim: Apply to acp add_pro_profile(), enable pa_alsa_supported_*()]
2023-12-04 15:34:48 +00:00
Igor V. Kovalenko
79ee2fac73 alsa-util: Dump probed rates
Link: 8152f39603
2023-12-04 15:34:48 +00:00
Igor V. Kovalenko
ceb1c38ee9 alsa-util: Add more standard sample rates
Link: 86c5fbab57
2023-12-04 15:34:48 +00:00
Jaroslav Kysela
84120e1167 alsa-mixer: extend pa_alsa_mixer_find with the subdevice check
The full identifier check must be executed for the new melem
creation, otherwise the duplicate control element code check
is reached.

Example (using the snd-aloop driver):

numid=56,iface=PCM,name='PCM Notify',device=1,subdevice=1
numid=62,iface=PCM,name='PCM Notify',device=1,subdevice=2

Link: 81a051089f
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-12-04 15:34:48 +00:00
Jaroslav Kysela
4066bbaf09 alsa-mixer: fix the re-attach code for the mixer control element
The new helem must be tracked and old helem must be cleared
to make the code work properly. Introduce the pointer to helem
as the private value for melem and add the necessary code.

Also, add a check for the duplicate mixer elements. The duplicate
mixer element invokes the abort check in alsa-lib. Print a warning
instead and handle the exit gracefully.

Link: d1675df0cd
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-12-04 15:34:48 +00:00
Jaroslav Kysela
3177f41cb4 alsa-mixer: allow to re-attach the mixer control element
It may be possible that the ALSA control element appears
again. Allow this combination by checking, if the pulseaudio
mixer element already exists. Do not create the duplicate
mixer element in this case.

Link: def8eb074e
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-12-04 15:34:48 +00:00
Wim Taymans
916f1cdfbf Revert "alsa-mixer: allow to re-attach the mixer control element"
This reverts commit b554fc20e9.
2023-04-14 16:32:18 +02:00
Wim Taymans
a66d5b90f9 Revert "alsa: UCM conflicting devices changes"
If needs some more work

This reverts commit aae770f18b.
This reverts commit 2216956e05.
This reverts commit 1d3c4501ef.
This reverts commit c7ca024607.
This reverts commit 8e4a5f5d5e.
This reverts commit 8b20675ad1.
This reverts commit ebe6f8b51a.
This reverts commit 4b97da1277.
This reverts commit 7c46a656c7.
This reverts commit 96ed03e1fc.
This reverts commit 43770c533c.
This reverts commit ccb2fce054.
This reverts commit 93d0ddc8b3.
This reverts commit 815e8c8fa0.
This reverts commit 97b99a0f7c.
This reverts commit 7e4d87402b.
This reverts commit 168b3ee22c.
This reverts commit 5128cdba31.
This reverts commit 31cde774c5.
This reverts commit b02c8ba153.
This reverts commit 68ac72d098.
This reverts commit 96cfc9bc1a.
This reverts commit e2d642a20b.
This reverts commit 80fc80c343.
This reverts commit 3a68905c7c.
This reverts commit 7e64680a65.
This reverts commit 8d1e38a281.
This reverts commit 591188195c.
This reverts commit 973fe0cb79.
This reverts commit 4d08c9ad60.
This reverts commit 3dce92e580.
This reverts commit 6b5e232c5c.
This reverts commit b1286c62c9.
2023-04-12 13:05:08 +02:00
Wim Taymans
2216956e05 alsa: fixup after merge 2023-03-21 10:07:39 +01:00
Wim Taymans
7c46a656c7 alsa-util: Fix pa_alsa_get_supported_formats fallback.
Looks like original intention was to scan over sample formats supported by PA,
but code does the scan by list of alsa formats. Reverse the map and adjust
fallback case which now can use the same map.
2023-03-20 18:24:20 +01:00
Wim Taymans
96ed03e1fc alsa-util: Perform format and rate detection before setting HW params
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)
2023-03-20 18:22:09 +01:00
Wim Taymans
ccb2fce054 alsa-util: Add more standard sample rates.
Dump probed rates
2023-03-20 17:54:54 +01:00
Wim Taymans
93d0ddc8b3 alsa-mixer: extend pa_alsa_mixer_find with the subdevice check
The full identifier check must be executed for the new melem
creation, otherwise the duplicate control element code check
is reached.

Example (using the snd-aloop driver):

numid=56,iface=PCM,name='PCM Notify',device=1,subdevice=1
numid=62,iface=PCM,name='PCM Notify',device=1,subdevice=2

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-03-20 17:50:17 +01:00
Wim Taymans
815e8c8fa0 alsa-mixer: fix the re-attach code for the mixer control element
The new helem must be tracked and old helem must be cleared
to make the code work properly. Introduce the pointer to helem
as the private value for melem and add the necessary code.

Also, add a check for the duplicate mixer elements. The duplicate
mixer element invokes the abort check in alsa-lib. Print a warning
instead and handle the exit gracefully.

Fixes: def8eb074 ("alsa-mixer: allow to re-attach the mixer control element")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-03-20 17:47:52 +01:00
Wim Taymans
b554fc20e9 alsa-mixer: allow to re-attach the mixer control element
It may be possible that the ALSA control element appears
again. Allow this combination by checking, if the pulseaudio
mixer element already exists. Do not create the duplicate
mixer element in this case.
2023-03-20 13:19:51 +01:00
Wim Taymans
a9ced45d4b acp: add debug for open and close
Debug open and close calls.
Make pa_alsa_close to close the device.
2022-08-05 12:31:28 +02:00
Wim Taymans
bc1789c3ea Revert "acp: sync with pulseaudio"
This reverts commit 57f0fdf746.

This seems to cause problems and needs to mature a bit more in
pulseaudio it seems.
2022-07-11 10:03:01 +02:00
Wim Taymans
57f0fdf746 acp: sync with pulseaudio 2022-07-07 12:23:28 +02:00
Takashi Sakamoto
e3b6534872 acp: avoid assertion at alsa-lib mixer API when element removal
PipeWire v0.3.7 or later hits assertion at alsa-lib mixer API due to
wrong handling of removal event for mixer element.

wireplumber: mixer.c:149: hctl_elem_event_handler: Assertion `bag_empty(bag)' failed.

The removal event is defined as '~0U', thus it's not distinguished from
the other type of event just by bitwise operator.

At the removal event, class implementator for mixer API should detach
mixer element from hcontrol element in callback handler since alsa-lib
has assertion to check the list of mixer elements for a hcontrol element
is empty or not after calling all of handlers. In detail, please refer to
MR to alsa-lib:

 * https://github.com/alsa-project/alsa-lib/pull/244

This commit fixes the above two issues. The issue can be regenerated by
`samples/ctl` Python 3 script of alsa-gobject.

 * https://github.com/alsa-project/alsa-gobject/

It adds some user-defined elements into sound card 0. When terminated by
SIGINT signal, it removes the elements. Then PulseAudio dies due to the
assertion.

Fixes: 1612f5e4d2 ("alsa-acp: Add libacp based card device")
2022-06-27 10:17:30 +09:00
Wim Taymans
b63a6a1b66 acp: sync with pulseaudio 2022-01-03 17:21:28 +01:00
Peter Hutterer
5cf3c28fa4 config.h is a local header, not a system one
Change the #include accordingly, that's what we use in the rest of the tree
too.
2021-06-10 09:04:16 +10:00
Peter Hutterer
da339c286f meson.build: drop HAVE_CONFIG_H
This is an autotools leftover, with meson we're always guaranteed to have
the config.h file.
2021-06-10 09:04:16 +10:00
Wim Taymans
20eb61b882 alsa: sync with pulseaudio 2021-02-25 10:28:25 +01:00
Wim Taymans
62065ac263 acp: update to latest 2021-01-05 10:08:31 +01:00
Wim Taymans
e8dcd7f5f9 acp: sync
Remove >2 channel support until upstream
Fix availability groups
2020-12-17 11:03:31 +01:00
Wim Taymans
119678e8d1 Revert "alsa: sync to latest acp"
This reverts commit f611e34456.

There is something wrong with this
2020-11-26 12:40:44 +01:00
Wim Taymans
f611e34456 alsa: sync to latest acp 2020-11-26 11:16:31 +01:00
Jan Grulich
743cf58fb7 Define SPA_FALLTHROUGH to make fall-through annotations work for all compilers
This is needed for example for Clang compiler which uses different
annotations than GCC. It will make WebRTC to happily use PipeWire
since the spa library is header-only and WebRTC defaults to use
Clang with -Wimplicit-fallthrough.
2020-10-22 13:31:19 +02:00
Wim Taymans
41db0f35b3 acp: sync with latests 2020-09-30 12:56:05 +02:00
Wim Taymans
a67af43cad alsa: sync with latest pulseaudio
Move some things around to make it easier to merge in changes.
2020-08-18 12:41:34 +02:00
Emmanuel Gil Peyrot
14fdf07e8f Run codespell on the entire codebase
This tool detects and fixes common English spelling mistakes, with
generally very few mistakes.

Here is the command I used to generate this commit.  There were a few
changes that had to be done manually, and of course adding the ignore
file:
```shell
codespell -I .codespell-ignore -x .codespell-ignore -w
```

I didn’t add it to the CI, but this would be a good place for it.
2020-08-17 17:16:31 +00:00
Wim Taymans
a655e8f6df alsa-util: fix check for digit
Fix the check for a digit by checking if the value is between the
*character* '0' (not *value* 0) and '9'.
2020-08-03 10:10:04 +02:00
Wim Taymans
1612f5e4d2 alsa-acp: Add libacp based card device
libacp is a port and wrapper around the pulseaudio card profile code.
It uses a set of templates for construct a card profile and mixer port
settings. It also has support for UCM when available for the hardware.
2020-07-06 12:20:09 +02:00