summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2012-02-15 17:50:00 +0000
committerBastien Nocera <hadess@hadess.net>2013-10-28 17:02:52 +0100
commita6e830cd652a086161f04b049c84283e0573881b (patch)
tree5b93d582fc841b4d25084211c966d3b1d35c4484
parentb8fe9902f3c6c50ca6a23e24fcea99582beebc65 (diff)
linux: Detect docked docking stations correctly0.9
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
-rw-r--r--src/linux/up-dock.c38
1 files 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",