mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 06:40:04 +01:00
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
This commit is contained in:
parent
b8fe9902f3
commit
a6e830cd65
1 changed files with 18 additions and 18 deletions
|
|
@ -46,22 +46,23 @@ G_DEFINE_TYPE (UpDock, up_dock, G_TYPE_OBJECT)
|
||||||
* up_dock_device_check:
|
* up_dock_device_check:
|
||||||
**/
|
**/
|
||||||
static gboolean
|
static gboolean
|
||||||
up_dock_device_check (GUdevDevice *d)
|
up_dock_device_check (GUdevDevice *device)
|
||||||
{
|
{
|
||||||
const gchar *status;
|
gint docked;
|
||||||
gboolean ret = FALSE;
|
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");
|
||||||
|
|
||||||
/* 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:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,10 +77,9 @@ up_dock_refresh (UpDock *dock)
|
||||||
GUdevDevice *native;
|
GUdevDevice *native;
|
||||||
guint count = 0;
|
guint count = 0;
|
||||||
|
|
||||||
/* the metric we're using here is that a machine is docked when
|
/* check to see if there are any docking stations, and if they are docked */
|
||||||
* there is more than one active output */
|
|
||||||
devices = g_udev_client_query_by_subsystem (dock->priv->gudev_client,
|
devices = g_udev_client_query_by_subsystem (dock->priv->gudev_client,
|
||||||
"drm");
|
"platform/dock_station");
|
||||||
for (l = devices; l != NULL; l = l->next) {
|
for (l = devices; l != NULL; l = l->next) {
|
||||||
native = l->data;
|
native = l->data;
|
||||||
count += up_dock_device_check (native);
|
count += up_dock_device_check (native);
|
||||||
|
|
@ -163,7 +163,7 @@ up_dock_uevent_signal_handler_cb (GUdevClient *client, const gchar *action,
|
||||||
static void
|
static void
|
||||||
up_dock_init (UpDock *dock)
|
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 = UP_DOCK_GET_PRIVATE (dock);
|
||||||
dock->priv->gudev_client = g_udev_client_new (subsystems);
|
dock->priv->gudev_client = g_udev_client_new (subsystems);
|
||||||
g_signal_connect (dock->priv->gudev_client, "uevent",
|
g_signal_connect (dock->priv->gudev_client, "uevent",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue