summaryrefslogtreecommitdiffstats
path: root/source/a/upower/patches/linux-Detect-docked-docking-stations-correctly.patch
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/upower/patches/linux-Detect-docked-docking-stations-correctly.patch')
-rw-r--r--source/a/upower/patches/linux-Detect-docked-docking-stations-correctly.patch84
1 files changed, 84 insertions, 0 deletions
diff --git a/source/a/upower/patches/linux-Detect-docked-docking-stations-correctly.patch b/source/a/upower/patches/linux-Detect-docked-docking-stations-correctly.patch
new file mode 100644
index 000000000..bed83d8e6
--- /dev/null
+++ b/source/a/upower/patches/linux-Detect-docked-docking-stations-correctly.patch
@@ -0,0 +1,84 @@
+From a6e830cd652a086161f04b049c84283e0573881b Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@hadess.net>
+Date: Wed, 15 Feb 2012 17:50:00 +0000
+Subject: [PATCH 3/3] linux: Detect docked docking stations correctly
+
+Instead of counting the number of graphics outputs, check
+all the devices the platform/dock_station subsystem that
+export a "dock_station" type.
+
+Based on patch by Armando Di Cianno <armando@goodship.net>
+
+https://bugs.freedesktop.org/show_bug.cgi?id=36818
+---
+ src/linux/up-dock.c | 38 +++++++++++++++++++-------------------
+ 1 file changed, 19 insertions(+), 19 deletions(-)
+
+diff --git a/src/linux/up-dock.c b/src/linux/up-dock.c
+index f9a7c67..4fe904e 100644
+--- a/src/linux/up-dock.c
++++ b/src/linux/up-dock.c
+@@ -46,22 +46,23 @@ G_DEFINE_TYPE (UpDock, up_dock, G_TYPE_OBJECT)
+ * up_dock_device_check:
+ **/
+ static gboolean
+-up_dock_device_check (GUdevDevice *d)
++up_dock_device_check (GUdevDevice *device)
+ {
+- const gchar *status;
+- gboolean ret = FALSE;
+-
+- /* Get the boolean state from the kernel -- note that ideally
+- * the property value would be "1" or "true" but now it's
+- * set in stone as ABI. Urgh. */
+- status = g_udev_device_get_sysfs_attr (d, "status");
+- if (status == NULL)
+- goto out;
+- ret = (g_strcmp0 (status, "connected") == 0);
+- g_debug ("graphics device %s is %s",
+- g_udev_device_get_sysfs_path (d),
+- ret ? "on" : "off");
+-out:
++ gint docked;
++ gboolean ret;
++
++ /* Is it a docking station? */
++ if (g_strcmp0 (g_udev_device_get_sysfs_attr (device, "dock_type"), "dock_station") != 0)
++ return FALSE;
++
++ /* Get the boolean state from the kernel */
++ if (g_udev_device_get_sysfs_attr (device, "docked") == NULL)
++ return FALSE;
++
++ docked = g_udev_device_get_sysfs_attr_as_int (device, "docked");
++ ret = (docked == 1);
++ g_debug ("dock_station %s is %s", g_udev_device_get_sysfs_path (device), ret ? "docked" : "undocked");
++
+ return ret;
+ }
+
+@@ -76,10 +77,9 @@ up_dock_refresh (UpDock *dock)
+ GUdevDevice *native;
+ guint count = 0;
+
+- /* the metric we're using here is that a machine is docked when
+- * there is more than one active output */
++ /* check to see if there are any docking stations, and if they are docked */
+ devices = g_udev_client_query_by_subsystem (dock->priv->gudev_client,
+- "drm");
++ "platform/dock_station");
+ for (l = devices; l != NULL; l = l->next) {
+ native = l->data;
+ count += up_dock_device_check (native);
+@@ -163,7 +163,7 @@ up_dock_uevent_signal_handler_cb (GUdevClient *client, const gchar *action,
+ static void
+ up_dock_init (UpDock *dock)
+ {
+- const gchar *subsystems[] = { "drm", NULL};
++ const gchar *subsystems[] = { "platform/dock_station", NULL};
+ dock->priv = UP_DOCK_GET_PRIVATE (dock);
+ dock->priv->gudev_client = g_udev_client_new (subsystems);
+ g_signal_connect (dock->priv->gudev_client, "uevent",
+--
+2.6.4
+