aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/pulseaudio/pulseaudio/0004-alsa-set-availability-for-some-unavailable-profiles.patch
blob: e0efa70f3244edd682779985bdcfc40f2770e85a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From 690d567e298f6687b61c82660b051df5b25482ee Mon Sep 17 00:00:00 2001
From: Tanu Kaskinen <tanuk@iki.fi>
Date: Fri, 23 Oct 2015 13:37:11 +0300
Subject: [PATCH 4/4] alsa: set availability for (some) unavailable profiles

The alsa card hasn't so far set any availability for profiles. That
caused an issue with some HDMI hardware: the sound card has two HDMI
outputs, but only the second of them is actually usable. The
unavailable port is marked as unavailable and the available port is
marked as available, but this information isn't propagated to the
profile availability. Without profile availability information, the
initial profile policy picks the unavailable one, since it has a
higher priority value.

This patch adds simple logic for marking some profiles unavailable:
if the profile only contains unavailable ports, the profile is
unavailable too. This can be improved in the future so that if a
profile contains sinks or sources that only contain unavailable ports,
the profile should be marked as unavailable. Implementing that
requires adding more information about the sinks and sources to
pa_card_profile, however.

BugLink: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8448

Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>

Rebased on 8.0.

Upstream-Status: Denied [The patch set needs some work to be accepted.
The review thread:
http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/24301]

Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
---
 src/modules/alsa/module-alsa-card.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index fe240f0..bdbdc12 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -366,6 +366,8 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
     void *state;
     pa_alsa_jack *jack;
     struct temp_port_avail *tp, *tports;
+    pa_device_port *port;
+    pa_card_profile *profile;
 
     pa_assert(u);
 
@@ -412,6 +414,29 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
            pa_device_port_set_available(tp->port, tp->avail);
 
     pa_xfree(tports);
+
+    /* Update profile availabilities. The logic could be improved; for now we
+     * only set obviously unavailable profiles (those that contain only
+     * unavailable ports) to PA_AVAILABLE_NO and all others to
+     * PA_AVAILABLE_UNKNOWN. */
+    PA_HASHMAP_FOREACH(profile, u->card->profiles, state) {
+        void *state2;
+        pa_available_t available = PA_AVAILABLE_NO;
+
+        /* Don't touch the "off" profile. */
+        if (pa_hashmap_size(profile->ports) == 0)
+            continue;
+
+        PA_HASHMAP_FOREACH(port, profile->ports, state2) {
+            if (port->available != PA_AVAILABLE_NO) {
+                available = PA_AVAILABLE_UNKNOWN;
+                break;
+            }
+        }
+
+        pa_card_profile_set_available(profile, available);
+    }
+
     return 0;
 }
 
-- 
2.7.0