1 From 0136b73158f60d5dc630ae348b18df3b59a2a5c2 Mon Sep 17 00:00:00 2001
2 From: Tanu Kaskinen <tanuk@iki.fi>
3 Date: Fri, 23 Oct 2015 13:37:11 +0300
4 Subject: [PATCH 4/4] alsa: set availability for (some) unavailable profiles
6 The alsa card hasn't so far set any availability for profiles. That
7 caused an issue with some HDMI hardware: the sound card has two HDMI
8 outputs, but only the second of them is actually usable. The
9 unavailable port is marked as unavailable and the available port is
10 marked as available, but this information isn't propagated to the
11 profile availability. Without profile availability information, the
12 initial profile policy picks the unavailable one, since it has a
13 higher priority value.
15 This patch adds simple logic for marking some profiles unavailable:
16 if the profile only contains unavailable ports, the profile is
17 unavailable too. This can be improved in the future so that if a
18 profile contains sinks or sources that only contain unavailable ports,
19 the profile should be marked as unavailable. Implementing that
20 requires adding more information about the sinks and sources to
21 pa_card_profile, however.
23 BugLink: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8448
25 Upstream-Status: Submitted [http://lists.freedesktop.org/archives/pulseaudio-discuss/2015-October/024614.html]
26 Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
28 src/modules/alsa/module-alsa-card.c | 24 ++++++++++++++++++++++++
29 1 file changed, 24 insertions(+)
31 diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
32 index 5b39654..73a846c 100644
33 --- a/src/modules/alsa/module-alsa-card.c
34 +++ b/src/modules/alsa/module-alsa-card.c
35 @@ -366,6 +366,7 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
39 + pa_card_profile *profile;
43 @@ -396,6 +397,29 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
45 report_port_state(port, u);
48 + /* Update profile availabilities. The logic could be improved; for now we
49 + * only set obviously unavailable profiles (those that contain only
50 + * unavailable ports) to PA_AVAILABLE_NO and all others to
51 + * PA_AVAILABLE_UNKNOWN. */
52 + PA_HASHMAP_FOREACH(profile, u->card->profiles, state) {
54 + pa_available_t available = PA_AVAILABLE_NO;
56 + /* Don't touch the "off" profile. */
57 + if (pa_hashmap_size(profile->ports) == 0)
60 + PA_HASHMAP_FOREACH(port, profile->ports, state2) {
61 + if (port->available != PA_AVAILABLE_NO) {
62 + available = PA_AVAILABLE_UNKNOWN;
67 + pa_card_profile_set_available(profile, available);