diff options
author | Hans de Goede <hdegoede@redhat.com> | 2017-05-08 15:07:18 +0200 |
---|---|---|
committer | Rui Matos <tiagomatos@gmail.com> | 2017-05-09 18:16:06 +0200 |
commit | f9a41defd0693368f4b9489a8e8e9a684955dbbe (patch) | |
tree | 5036d0b7f91ffea6ecc4b50576e93ea038b2f3b0 | |
parent | 00d1a8a3c283b44849ac98c709af2a70bc9ff278 (diff) | |
download | gnome-settings-daemon-f9a41defd0693368f4b9489a8e8e9a684955dbbe.tar.gz |
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
-rw-r--r-- | 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 54d6f9dc..27b56ae9 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; |