Commit graph

152 commits

Author SHA1 Message Date
Jaroslav Kysela
6d830bf0f0 alsa-ucm: add support for master volume
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-06 10:05:44 +00:00
Jaroslav Kysela
1c240b7a12 alsa-mixer: improve alsa_id_decode() function
Accept those identifiers:

        Speaker,1
        'Speaker',1
        "Speaker",1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-06 10:05:44 +00:00
Jaroslav Kysela
7f4b8e1a7c alsa-mixer: handle the index for ALSA mixer element identifiers
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-06 10:05:44 +00:00
Arun Raghavan
eb912d3605 rtpoll: Separate out before/after/work callback userdata
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-11-08 17:39:03 +05:30
Olaf Hering
993d3fd89e alsa: Use correct header path
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-03-27 08:41:55 +00:00
scootergrisen
dee7674c7f Remove space in "Digital Passthrough (IEC958)" 2019-02-16 11:03:45 +00:00
Hongxu Jia
3d9deb1e56 build-sys: introduce a special build flag to explicitly disables running 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-12-11 16:15:32 +02:00
Tanu Kaskinen
3455d62e49 alsa-mixer: make the mono mapping a fallback only
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-21 06:30:25 +05:30
Bert Hekman
83675b3745 alsa-mixer: add support for SteelSeries Arctis 5 and renamed Arctis 7 files appropriately 2018-06-21 05:57:07 +05:30
Tanu Kaskinen
72fa468a45 alsa-mixer: autodetect the ELD device
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-13 21:33:52 +02:00
Tanu Kaskinen
67f11ff301 alsa-mixer: autodetect the HDMI jack PCM device
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-13 21:33:17 +02:00
Tanu Kaskinen
09ff3fca2f alsa-mixer: add hw_device_index to pa_alsa_mapping
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
2018-02-13 21:32:12 +02:00
Tanu Kaskinen
56b6e32535 alsa-mixer: add mixer handling to the fallback stereo case
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-18 18:49:34 +03:00
Johan Heikkilä
15386a710c alsa-mixer: add support for Steelseries Arctis 7 headset 2017-09-05 13:46:27 +03:00
Ian Ray
739a4b3d23 alsa-mixer: round, not truncate, in to_alsa_dB
to_alsa_dB() returns a result rounded to two decimal places (instead of
using integer truncation) to avoid small errors when converting between
dB and volume.

Consider playback at -22 dB (which is supported by ALSA) but results in
the higher level of -21 dB plus software attenuation.

    pa_sw_volume_from_dB(-22) = 28172
    pa_sw_volume_to_dB(28172) = -21.9997351
    to_alsa_dB(-21.9997351)   = -2199

    ALSA value 106 = -2200
    ALSA value 107 = -2100
    ...

    rounding = +1  /* "accurate or first above" */
    snd_mixer_selem_ask_playback_dB_vol(me, -2199, rounding, &alsa_val)
    alsa_val = -2100

Signed-off-by: Ian Ray <ian.ray@ge.com>
2017-09-05 13:46:27 +03:00
Tanu Kaskinen
ea3ebd09d1 alsa: don't assume that hw:x is an analog output
Previously, if front:x didn't work, we would try to use hw:x for analog
stereo output. There's no guarantee that hw:x is an analog output,
however. For example, the Intel HDMI LPE driver uses hw:x for HDMI
output, and PulseAudio incorrectly created analog profiles for that
card, because front:x doesn't work but hw:x does.

This patch changes things so that the analog stereo mapping doesn't any
more use hw:x as a fallback. A separate "unknown stereo" fallback
mapping is added to handle the rare case where hw:x is the only PCM
device that works.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=100488
2017-05-02 14:23:56 +03:00
Arun Raghavan
b793f68f2e alsa: Use pa_device_port->impl_free() for freeing port data
This allows us to clean up ucm port data associated with a port during
port clean up, instead of having to track this separately using a
dynarray.
2016-06-22 21:04:47 +05:30
David Henningsson
c87917cf0d alsa-mixer: refactor element_probe and fix >2 channel bug
By refactoring volume probing into its own function, we can reduce
indentation a lot. Also, if an error occurs during the volume probe,
that volume element is now always skipped (instead of taking down
the entire path with it).

Also, a bug for elements with more than two channels is fixed, as
previously, the volume parsing code was continuing, potentially
referencing somewhere outside the array (which has max two channels).

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2016-03-08 08:37:57 +01:00
Tanu Kaskinen
1d7ce90139 conf-parser: add support for .d directories
This allows a configuration scheme where after loading configuration
from "somefile", the parser loads configuration from files in
directory "somefile.d". This feature needs to be enabled on a per-file
basis, though, and this patch doesn't yet enable the feature for any
files.
2015-12-14 13:45:39 +01:00
Juho Hämäläinen
f61a16b8b1 alsa-mixer: Have valid proplist for synthesized path as well.
When synthesized alsa path is freed there is an assert from NULL
proplist. Create empty proplist for the path to fix.

Signed-off-by: Juho Hämäläinen <juho.hamalainen@nomovok.com>
2015-12-11 10:05:41 +01:00
David Henningsson
2a71fd7597 alsa-mixer: Fill in input and output names
Fill in input_name and output_name to make routing easier for
routing modules.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2015-11-22 04:59:21 +02:00
David Henningsson
107dfa8e01 alsa-mixer: Return early in case of no mixer poll descriptors
We encountered an alsa plugin a while ago (not sure if the source
can be shared) which had mixer controls, but no descriptors to
poll for changes.

Quit early to avoid latter assertion failures.

BugLink: https://bugs.launchpad.net/bugs/1092377
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2015-11-17 09:30:58 +01:00
David Henningsson
fcbbe34e00 alsa-mixer: Ignore volume with unexpected number of channels
We currently only support one and two channels for volumes, and
bail out otherwise. This makes Xonar users unhappy because they
have a volume with eight channels, and bailing out means they
don't have a path/port at all.

This way they will at least have a port, which will in turn make
the gnome/unity UI behave better.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=84983
BugLink: https://bugzilla.gnome.org/show_bug.cgi?id=745017
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2015-10-23 14:40:55 +03:00
Deepak Srivastava
2d5eec2d2c Rename functions with "tostring" in the name to one with "to_string" to conform with the convention.
component: core

<EP-E358F00C1D9A449EAE69225B9D2530F8>
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=88833

Signed-off-by: Deepak Srivastava <srivastava.d@samsung.com>
2015-09-25 17:29:02 +05:30
Arun Raghavan
5071960bf3 alsa-mixer: Drop redundant conditional frees
The dynarrays are allocated unconditionally, so the free need not be
conditional.
2015-08-25 19:27:58 +05:30
Tanu Kaskinen
38e81f4c3d ucm: Add support for "JackHWMute"
JackHWMute is used to list devices that get forcibly muted by
a particular jack. We mark ports unavailable based on that
information.
2015-08-21 14:33:11 +03:00
Tanu Kaskinen
d2bed5332a ucm: Create only one jack object per kcontrol
Previously the UCM code created one jack object per device name (which
is not the same thing as creating one jack object per device, because
the UCM device namespace is scoped on per-verb basis, so devices in
different verbs may have the same name). I think it's conceptually
cleaner to create one jack object per alsa kcontrol. I plan to do
similar refactoring on the traditional mixer code later.
2015-08-21 14:33:11 +03:00
Tanu Kaskinen
c9557e6969 alsa: Move UCM port availability updating to the mixer code
Previously module-alsa-card assigned to pa_alsa_jack.plugged_in
directly, and then did the port availability updating manually. The
idea of pa_alsa_jack_set_plugged_in() is to move the availability
updating to the mixer infrastructure, where it really belongs.

Similarly, pa_alsa_jack.has_control was previously modified directly
from several places. The has_control field affects the port
availability, and pa_alsa_jack_set_has_control() takes care of
updating the availability.

For now, pa_alsa_jack_set_plugged_in() and
pa_alsa_jack_set_has_control() only update the port availability
when using UCM. My plan is to adapt the traditional mixer code later.
2015-08-21 14:33:11 +03:00
Tanu Kaskinen
40714b6bcc alsa: Add associations between jacks, UCM devices and UCM ports
These associations will be used by subsequent UCM jack detection
refactoring work.
2015-08-21 14:33:10 +03:00
Tanu Kaskinen
f5fecff0b4 alsa: Add pa_alsa_jack_new() and pa_alsa_jack_free()
This reduces code duplication in alsa-mixer.c and alsa-ucm.c. No
functional changes.
2015-08-21 14:33:10 +03:00
Tanu Kaskinen
74b0fb45e5 alsa-mixer: Add descriptions for analog-stereo-input and analog-stereo-output mappings
These mapping names are used in sb-omni-surround-5.1.conf, which needs
to use separate mappings for input and output, since they are
associated with different alsa devices.
2015-08-21 11:25:26 +03:00
David Henningsson
6db74fc3c7 alsa-mixer: Add paths/ports for multichannel profile
This makes the GUIs (e g gnome/unity-control-center) look more consistent
with other inputs/outputs that also have ports.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2015-04-10 16:08:24 +02:00
David Henningsson
02dc6d84ed alsa-mixer: Use separate profiles for Multichannel Input/Output
This works around bug 80850: a mapping can only have one channel map,
and in case of a 6-out 10-in device, the mapping will be adjusted to
have both 10 and 6 channels, which does not work.

Reported-by: Benjamin Tegge <benjaminosm@googlemail.com>
Suggested-by: Raymond Yau <superquad.vortex2@gmail.com>
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=80850
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2015-04-10 16:08:24 +02:00
Ondrej Holecek
5effc83479 update FSF addresses to FSF web page
FSF addresses used in PA sources are no longer valid and rpmlint
generates numerous warnings during packaging because of this.
This patch changes all FSF addresses to FSF web page according to
the GPL how-to: https://www.gnu.org/licenses/gpl-howto.en.html

Done automatically by sed-ing through sources.
2015-01-14 22:20:40 +02:00
Peter Meerwald
275ffb3657 alsa-mixer: Use pa_assert_not_reached()
get rid of the following warning when compiling with NDEBUG:

modules/alsa/alsa-mixer.c: In function 'element_is_subset':
modules/alsa/alsa-mixer.c:3125:18: warning: 'a_limit' may be used uninitialized in this function [-Wmaybe-uninitialized]
             long a_limit;

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2014-11-17 13:25:15 +01:00
David Henningsson
300a5e3ed7 alsa: Remove unnecessary hctl handles being passed around
Now that we have switched to using the mixer handle only,
there is no use for sending hctl handles around.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-09-16 09:33:04 +02:00
David Henningsson
f2120fc2b6 alsa-mixer/card: Move to use the new mixer interface
Use the new mixer API to get callbacks, instead of using the hctl
API. Using the hctl API caused a memory leak, because alsa-lib itself
used the hctl callbacks, which we were previously overriding.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-09-16 09:33:04 +02:00
David Henningsson
b8656afe4a alsa-mixer: Improve workaround for Valgrind's false warnings
Valgrind is not correctly handling ALSA TLV syscalls, which leads
to false warnings, looking like this:
 "Conditional jump or move depends on uninitialised value(s)"

Unfortunately, alsa-lib itself also uses these values which valgrind
falsely believe are uninitialized, so not all warnings are removed,
but this is what we can do from PA until the valgrind bug is fixed.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-09-08 13:05:10 +02:00
David Henningsson
2575b102b9 alsa: Remove four channel input profile
With the new multichannel profile, we can remove this one and
handle the four channel input as a generic multichannel fallback.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-08-23 15:54:13 +02:00
Tanu Kaskinen
facfd3a664 alsa-mixer: Fix path subset detection
The old logic assumed that if path A was a subset of path B, the
element list in B would have all elements of A in the beginning of
B's list, in the same order as A. This assumption was invalid, causing
some subset cases to not get detected. We need to search through the
full element list of B every time before we can conclude that B
doesn't have the element that we're inspecting.
2014-08-18 13:44:44 +03:00
David Henningsson
48edd0a00f alsa: Add a multichannel fallback mapping
In case all other profiles fail, try this fallback mapping as well.
It allows the device to specify the channel count, so it can be used
for devices that only supports being opened in multichannel mode.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-08-01 18:05:49 +02:00
David Henningsson
c15107eaf6 alsa: Allow "fallback" configuration for mappings and profiles
A fallback mapping or profile will only be considered for probing
if all non-fallback profiles fail.

If auto-profiles are used, a profile made up of one non-fallback
mapping and one fallback mapping will be considered a fallback profile.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-08-01 18:05:49 +02:00
David Henningsson
be8311417c alsa: Add "exact-channels" mapping configurability
Allow a mapping to relax the exact channel restriction:

exact-channels = yes | no # If no, and the exact number of channels is not supported,
                          # allow device to be opened with another channel count

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-08-01 18:05:49 +02:00
Tanu Kaskinen
eca082a93f Use pa_hashmap_remove_and_free() where appropriate 2014-04-17 10:06:23 +03:00
Tanu Kaskinen
9271c11e68 alsa: Remove a redundant check
If mixer_handle is not NULL, then hctl_handle won't be NULL either.
The redundant check was confusing, because it looked like we would
leak the mixer_handle if mixer_handle is non-NULL and hctl_handle is
NULL.
2014-03-03 18:06:21 +02:00
poljar (Damir Jelić)
c307093cf0 alsa-mixer: Free the description key in alsa_path_free(). 2014-01-03 13:17:08 +02:00
Tanu Kaskinen
d1fd31d50f idxset: Allow deep copying with pa_idxset_copy() 2013-11-29 07:14:39 +02:00
David Henningsson
798525bf16 alsa-mixer: Drop all unused paths, not only unsupported paths
This is a cleaner solution, because it also removes paths that are
being removed because they are subsets of other paths.

Otherwise, the lingering paths could cause jack detection related
assertion failures.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=69676
Reported-and-tested-by: Kalev Lember <kalevlember@gmail.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-10-03 16:19:52 +02:00
Arun Raghavan
6a6ee8fd22 alsa: Allow sample spec override in mappings
This allows mappings to override some or all of the sample_spec used to
open the ALSA device. The intention, to start with, is to use this for
devices in UCM that need to be opened at a specific rate (like modem
devices). This can be extended to allow overrides in profile-sets as
well.
2013-09-17 18:31:03 +05:30
Arun Raghavan
6825df8cec hashmap: Add the ability to free keys
Since the hashmap stores a pointer to the key provided at pa_hashmap_put()
time, it make sense to allow the hashmap to be given ownership of the key and
have it free it at pa_hashmap_remove/free time.

To do this cleanly, we now provide the key and value free functions at hashmap
creation time with a pa_hashmap_new_full. With this, we do away with the free
function that was provided at remove/free time for freeing the value.
2013-09-17 18:01:22 +05:30