slackware-current/source/a/upower/patches/linux-Detect-docked-docking-stations-correctly.patch
Patrick J Volkerding d31c50870d Slackware 14.2
Thu Jun 30 20:26:57 UTC 2016
Slackware 14.2 x86_64 stable is released!

The long development cycle (the Linux community has lately been living in
"interesting times", as they say) is finally behind us, and we're proud to
announce the release of Slackware 14.2.  The new release brings many updates
and modern tools, has switched from udev to eudev (no systemd), and adds
well over a hundred new packages to the system.  Thanks to the team, the
upstream developers, the dedicated Slackware community, and everyone else
who pitched in to help make this release a reality.

The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided
32-bit/64-bit x86/x86_64 DVD.  Please consider supporting the Slackware
project by picking up a copy from store.slackware.com.  We're taking
pre-orders now, and offer a discount if you sign up for a subscription.

Have fun!  :-)
2018-05-31 23:31:18 +02:00

84 lines
2.8 KiB
Diff

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