[pulseaudio-discuss] [PATCH v2 3/3] alsa-mixer: autodetect the ELD device

Tanu Kaskinen tanuk at iki.fi
Sun Oct 8 16:48:26 UTC 2017


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
---
 src/modules/alsa/alsa-mixer.c                      | 28 ++++++++++++++++++++--
 src/modules/alsa/alsa-mixer.h                      |  1 +
 .../alsa/mixer/paths/analog-output.conf.common     |  8 +++++--
 src/modules/alsa/mixer/paths/hdmi-output-0.conf    |  2 +-
 src/modules/alsa/mixer/paths/hdmi-output-1.conf    |  2 +-
 src/modules/alsa/mixer/paths/hdmi-output-2.conf    |  2 +-
 src/modules/alsa/mixer/paths/hdmi-output-3.conf    |  2 +-
 src/modules/alsa/mixer/paths/hdmi-output-4.conf    |  2 +-
 src/modules/alsa/mixer/paths/hdmi-output-5.conf    |  2 +-
 src/modules/alsa/mixer/paths/hdmi-output-6.conf    |  2 +-
 src/modules/alsa/mixer/paths/hdmi-output-7.conf    |  2 +-
 11 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index eaee7ea0a..a524d6d64 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -2051,6 +2051,28 @@ static int element_parse_enumeration(pa_config_parser_state *state) {
     return 0;
 }
 
+static int parse_eld_device(pa_config_parser_state *state) {
+    pa_alsa_path *path;
+    uint32_t eld_device;
+
+    path = state->userdata;
+
+    if (pa_atou(state->rvalue, &eld_device) >= 0) {
+        path->autodetect_eld_device = false;
+        path->eld_device = eld_device;
+        return 0;
+    }
+
+    if (pa_streq(state->rvalue, "auto")) {
+        path->autodetect_eld_device = true;
+        path->eld_device = -1;
+        return 0;
+    }
+
+    pa_log("[%s:%u] Invalid value for option 'eld-device': %s", state->filename, state->lineno, state->rvalue);
+    return -1;
+}
+
 static int option_parse_priority(pa_config_parser_state *state) {
     pa_alsa_path *p;
     pa_alsa_option *o;
@@ -2568,7 +2590,7 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
         { "description-key",     pa_config_parse_string,            NULL, "General" },
         { "description",         pa_config_parse_string,            NULL, "General" },
         { "mute-during-activation", pa_config_parse_bool,           NULL, "General" },
-        { "eld-device",          pa_config_parse_int,               NULL, "General" },
+        { "eld-device",          parse_eld_device,                  NULL, "General" },
 
         /* [Option ...] */
         { "priority",            option_parse_priority,             NULL, NULL },
@@ -2608,7 +2630,6 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
     items[1].data = &p->description_key;
     items[2].data = &p->description;
     items[3].data = &mute_during_activation;
-    items[4].data = &p->eld_device;
 
     if (!paths_dir)
         paths_dir = get_default_paths_dir();
@@ -4012,6 +4033,9 @@ static void mapping_paths_probe(pa_alsa_mapping *m, pa_alsa_profile *profile,
     }
 
     PA_HASHMAP_FOREACH(p, ps->paths, state) {
+        if (p->autodetect_eld_device)
+            p->eld_device = m->hw_device_index;
+
         if (pa_alsa_path_probe(p, m, mixer_handle, m->profile_set->ignore_dB) < 0)
             pa_hashmap_remove(ps->paths, p);
     }
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index 7ae40511c..15615a615 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -193,6 +193,7 @@ struct pa_alsa_path {
     char *description_key;
     char *description;
     unsigned priority;
+    bool autodetect_eld_device;
     int eld_device;
     pa_proplist *proplist;
 
diff --git a/src/modules/alsa/mixer/paths/analog-output.conf.common b/src/modules/alsa/mixer/paths/analog-output.conf.common
index baf37660e..e52830d99 100644
--- a/src/modules/alsa/mixer/paths/analog-output.conf.common
+++ b/src/modules/alsa/mixer/paths/analog-output.conf.common
@@ -64,8 +64,12 @@
 ; mute-during-activation = yes | no      # If this path supports hardware mute, should the hw mute be used while activating this
 ;                                        # path? In some cases this can reduce extra noises during port switching, while in other
 ;                                        # cases this can increase such noises. Default: no.
-; eld-device = ...                       # If this is an HDMI port, here's where to specify the device number for the ELD mixer
-;                                        # control. The default is to not make use of ELD information.
+; eld-device = ...                       # If this is an HDMI port, set to "auto" so that PulseAudio will try to read
+;                                        # the monitor ELD information from the ALSA mixer. By default the ELD information
+;                                        # is not read, because it's only applicable with HDMI. Earlier the "auto" option
+;                                        # didn't exist, and the hw device index had to be manually configured. For
+;                                        # backwards compatibility, it's still possible to manually configure the device
+;                                        # index using this option.
 ;
 ; [Properties]                           # Property list for this path. The list is merged into the port property list.
 ; <key> = <value>                        # Each property is defined on its own line.
diff --git a/src/modules/alsa/mixer/paths/hdmi-output-0.conf b/src/modules/alsa/mixer/paths/hdmi-output-0.conf
index a87205cea..95b1342e9 100644
--- a/src/modules/alsa/mixer/paths/hdmi-output-0.conf
+++ b/src/modules/alsa/mixer/paths/hdmi-output-0.conf
@@ -1,7 +1,7 @@
 [General]
 description = HDMI / DisplayPort
 priority = 59
-eld-device = 3
+eld-device = auto
 
 [Properties]
 device.icon_name = video-display
diff --git a/src/modules/alsa/mixer/paths/hdmi-output-1.conf b/src/modules/alsa/mixer/paths/hdmi-output-1.conf
index b513ffd70..37b945204 100644
--- a/src/modules/alsa/mixer/paths/hdmi-output-1.conf
+++ b/src/modules/alsa/mixer/paths/hdmi-output-1.conf
@@ -1,7 +1,7 @@
 [General]
 description = HDMI / DisplayPort 2
 priority = 58
-eld-device = 7
+eld-device = auto
 
 [Properties]
 device.icon_name = video-display
diff --git a/src/modules/alsa/mixer/paths/hdmi-output-2.conf b/src/modules/alsa/mixer/paths/hdmi-output-2.conf
index a2386650e..19c38f2e8 100644
--- a/src/modules/alsa/mixer/paths/hdmi-output-2.conf
+++ b/src/modules/alsa/mixer/paths/hdmi-output-2.conf
@@ -1,7 +1,7 @@
 [General]
 description = HDMI / DisplayPort 3
 priority = 57
-eld-device = 8
+eld-device = auto
 
 [Properties]
 device.icon_name = video-display
diff --git a/src/modules/alsa/mixer/paths/hdmi-output-3.conf b/src/modules/alsa/mixer/paths/hdmi-output-3.conf
index edceb36e1..8551570ac 100644
--- a/src/modules/alsa/mixer/paths/hdmi-output-3.conf
+++ b/src/modules/alsa/mixer/paths/hdmi-output-3.conf
@@ -1,7 +1,7 @@
 [General]
 description = HDMI / DisplayPort 4
 priority = 56
-eld-device = 9
+eld-device = auto
 
 [Properties]
 device.icon_name = video-display
diff --git a/src/modules/alsa/mixer/paths/hdmi-output-4.conf b/src/modules/alsa/mixer/paths/hdmi-output-4.conf
index 0d1401eef..e36128921 100644
--- a/src/modules/alsa/mixer/paths/hdmi-output-4.conf
+++ b/src/modules/alsa/mixer/paths/hdmi-output-4.conf
@@ -1,7 +1,7 @@
 [General]
 description = HDMI / DisplayPort 5
 priority = 55
-eld-device = 10
+eld-device = auto
 
 [Properties]
 device.icon_name = video-display
diff --git a/src/modules/alsa/mixer/paths/hdmi-output-5.conf b/src/modules/alsa/mixer/paths/hdmi-output-5.conf
index 883cccc20..82dc3be79 100644
--- a/src/modules/alsa/mixer/paths/hdmi-output-5.conf
+++ b/src/modules/alsa/mixer/paths/hdmi-output-5.conf
@@ -1,7 +1,7 @@
 [General]
 description = HDMI / DisplayPort 6
 priority = 54
-eld-device = 11
+eld-device = auto
 
 [Properties]
 device.icon_name = video-display
diff --git a/src/modules/alsa/mixer/paths/hdmi-output-6.conf b/src/modules/alsa/mixer/paths/hdmi-output-6.conf
index d8ac2f55c..92e8fd1e2 100644
--- a/src/modules/alsa/mixer/paths/hdmi-output-6.conf
+++ b/src/modules/alsa/mixer/paths/hdmi-output-6.conf
@@ -1,7 +1,7 @@
 [General]
 description = HDMI / DisplayPort 7
 priority = 53
-eld-device = 12
+eld-device = auto
 
 [Properties]
 device.icon_name = video-display
diff --git a/src/modules/alsa/mixer/paths/hdmi-output-7.conf b/src/modules/alsa/mixer/paths/hdmi-output-7.conf
index dd090855f..abe2b60e6 100644
--- a/src/modules/alsa/mixer/paths/hdmi-output-7.conf
+++ b/src/modules/alsa/mixer/paths/hdmi-output-7.conf
@@ -1,7 +1,7 @@
 [General]
 description = HDMI / DisplayPort 8
 priority = 52
-eld-device = 13
+eld-device = auto
 
 [Properties]
 device.icon_name = video-display
-- 
2.14.2



More information about the pulseaudio-discuss mailing list