blob: e0efa70f3244edd682779985bdcfc40f2770e85a [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001From 690d567e298f6687b61c82660b051df5b25482ee Mon Sep 17 00:00:00 2001
Patrick Williamsf1e5d692016-03-30 15:21:19 -05002From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Fri, 23 Oct 2015 13:37:11 +0300
4Subject: [PATCH 4/4] alsa: set availability for (some) unavailable profiles
5
6The alsa card hasn't so far set any availability for profiles. That
7caused an issue with some HDMI hardware: the sound card has two HDMI
8outputs, but only the second of them is actually usable. The
9unavailable port is marked as unavailable and the available port is
10marked as available, but this information isn't propagated to the
11profile availability. Without profile availability information, the
12initial profile policy picks the unavailable one, since it has a
13higher priority value.
14
15This patch adds simple logic for marking some profiles unavailable:
16if the profile only contains unavailable ports, the profile is
17unavailable too. This can be improved in the future so that if a
18profile contains sinks or sources that only contain unavailable ports,
19the profile should be marked as unavailable. Implementing that
20requires adding more information about the sinks and sources to
21pa_card_profile, however.
22
23BugLink: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8448
24
Patrick Williamsf1e5d692016-03-30 15:21:19 -050025Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050026
27Rebased on 8.0.
28
29Upstream-Status: Denied [The patch set needs some work to be accepted.
30The review thread:
31http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/24301]
32
33Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
Patrick Williamsf1e5d692016-03-30 15:21:19 -050034---
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050035 src/modules/alsa/module-alsa-card.c | 25 +++++++++++++++++++++++++
36 1 file changed, 25 insertions(+)
Patrick Williamsf1e5d692016-03-30 15:21:19 -050037
38diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039index fe240f0..bdbdc12 100644
Patrick Williamsf1e5d692016-03-30 15:21:19 -050040--- a/src/modules/alsa/module-alsa-card.c
41+++ b/src/modules/alsa/module-alsa-card.c
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050042@@ -366,6 +366,8 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
Patrick Williamsf1e5d692016-03-30 15:21:19 -050043 void *state;
44 pa_alsa_jack *jack;
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050045 struct temp_port_avail *tp, *tports;
46+ pa_device_port *port;
Patrick Williamsf1e5d692016-03-30 15:21:19 -050047+ pa_card_profile *profile;
48
49 pa_assert(u);
50
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050051@@ -412,6 +414,29 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
52 pa_device_port_set_available(tp->port, tp->avail);
53
54 pa_xfree(tports);
Patrick Williamsf1e5d692016-03-30 15:21:19 -050055+
56+ /* Update profile availabilities. The logic could be improved; for now we
57+ * only set obviously unavailable profiles (those that contain only
58+ * unavailable ports) to PA_AVAILABLE_NO and all others to
59+ * PA_AVAILABLE_UNKNOWN. */
60+ PA_HASHMAP_FOREACH(profile, u->card->profiles, state) {
61+ void *state2;
62+ pa_available_t available = PA_AVAILABLE_NO;
63+
64+ /* Don't touch the "off" profile. */
65+ if (pa_hashmap_size(profile->ports) == 0)
66+ continue;
67+
68+ PA_HASHMAP_FOREACH(port, profile->ports, state2) {
69+ if (port->available != PA_AVAILABLE_NO) {
70+ available = PA_AVAILABLE_UNKNOWN;
71+ break;
72+ }
73+ }
74+
75+ pa_card_profile_set_available(profile, available);
76+ }
77+
78 return 0;
79 }
80
81--
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500822.7.0
Patrick Williamsf1e5d692016-03-30 15:21:19 -050083