[gnome-settings-daemon/gnome-3-24] power: Choose correct backlight device on laptops with hybrid graphics
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-24] power: Choose correct backlight device on laptops with hybrid graphics
- Date: Tue, 9 May 2017 16:27:46 +0000 (UTC)
commit f9a41defd0693368f4b9489a8e8e9a684955dbbe
Author: Hans de Goede <hdegoede redhat com>
Date: Mon May 8 15:07:18 2017 +0200
power: Choose correct backlight device on laptops with hybrid graphics
On laptops with hybrid graphics the LCD panel may be connected to
a mux so that it can be driven by either GPU. In this case both
GPU drivers will register a raw backlight interface for their
LCD panel connector and g-s-d needs to pick the one for the enabled
connector rather then just picking the first one.
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1683445
https://bugzilla.gnome.org/show_bug.cgi?id=782211
plugins/power/gsd-backlight-linux.c | 36 ++++++++++++++++++++++++++++++++++-
1 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/plugins/power/gsd-backlight-linux.c b/plugins/power/gsd-backlight-linux.c
index 54d6f9d..27b56ae 100644
--- a/plugins/power/gsd-backlight-linux.c
+++ b/plugins/power/gsd-backlight-linux.c
@@ -43,6 +43,40 @@ gsd_backlight_helper_get_type (GList *devices, const gchar *type)
}
return NULL;
}
+
+/*
+ * Search for a raw backlight interface, raw backlight interfaces registered
+ * by the drm driver will have the drm-connector as their parent, check the
+ * drm-connector's enabled sysfs attribute so that we pick the right LCD-panel
+ * connector on laptops with hybrid-gfx. Fall back to just picking the first
+ * raw backlight interface if no enabled interface is found.
+ */
+static gchar *
+gsd_backlight_helper_get_raw (GList *devices)
+{
+ GUdevDevice *parent;
+ const gchar *attr;
+ GList *d;
+
+ for (d = devices; d != NULL; d = d->next) {
+ attr = g_udev_device_get_sysfs_attr (d->data, "type");
+ if (g_strcmp0 (attr, "raw") != 0)
+ continue;
+
+ parent = g_udev_device_get_parent (d->data);
+ if (!parent)
+ continue;
+
+ attr = g_udev_device_get_sysfs_attr (parent, "enabled");
+ if (!attr || g_strcmp0 (attr, "enabled") != 0)
+ continue;
+
+ return g_strdup (g_udev_device_get_sysfs_path (d->data));
+ }
+
+ return gsd_backlight_helper_get_type (devices, "raw");
+}
+
#endif /* HAVE_GUDEV */
char *
@@ -72,7 +106,7 @@ gsd_backlight_helper_get_best_backlight (GsdBacklightType *type)
*type = GSD_BACKLIGHT_TYPE_PLATFORM;
goto out;
}
- path = gsd_backlight_helper_get_type (devices, "raw");
+ path = gsd_backlight_helper_get_raw (devices);
if (path != NULL) {
if (type)
*type = GSD_BACKLIGHT_TYPE_RAW;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]