[PATCH 3/3] alsa-card: Make ELD monitor name a port property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If there is a proper monitor name, we expose this as a device.product.name
property on the port. This can be useful for UIs who might want to show
this name.

Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
 src/modules/alsa/module-alsa-card.c |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 366f4ba..76da3a9 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -309,6 +309,34 @@ static void init_profile(struct userdata *u) {
             am->source = pa_alsa_source_new(u->module, u->modargs, __FILE__, u->card, am);
 }
 
+static void reset_hdmi_eld_data(pa_device_port *p)
+{
+    /* Clear properties */
+    pa_proplist_unset(p->proplist, PA_PROP_DEVICE_PRODUCT_NAME);
+}
+
+static void update_hdmi_eld_data(pa_device_port *p, struct userdata *u)
+{
+    pa_alsa_port_data *data;
+    pa_hdmi_eld_t eld;
+    int device;
+
+    data = PA_DEVICE_PORT_DATA(p);
+    pa_assert(data->path);
+    device = data->path->eld_device;
+
+    if (device < 0)
+        return;
+
+    if (!pa_alsa_get_hdmi_eld(u->hctl_handle, device, &eld)) {
+        /* FIXME: Some devices don't seem to have ELD available until later,
+           we should try again in a second or two */
+        reset_hdmi_eld_data(p);
+    }
+    else
+        pa_proplist_sets(p->proplist, PA_PROP_DEVICE_PRODUCT_NAME, eld.monitor_name);
+}
+
 static void report_port_state(pa_device_port *p, struct userdata *u)
 {
     void *state;
@@ -344,6 +372,11 @@ static void report_port_state(pa_device_port *p, struct userdata *u)
             pa = cpa;
     }
 
+    if (pa == PA_PORT_AVAILABLE_YES)
+        update_hdmi_eld_data(p, u);
+    else if (pa == PA_PORT_AVAILABLE_NO)
+        reset_hdmi_eld_data(p);
+
     pa_device_port_set_available(p, pa);
 }
 
-- 
1.7.9.5



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux