Commit Graph

21 Commits

Author SHA1 Message Date
Chris Wilson b24e7581bd backlight: Factor known names into preferred interfaces
Since the /sys/device/backlight never turned up we face an issue with
disambiguating the backlight on multi-GPU devices. Both intel_backlight
and nv_backlight are presented are raw interfaces, and on modern systems
the ACPI interface is defunct, so we need a way to distinguish them. So,
we fallback to our priority table of known interfaces and rank them
accordingly, first by class (platform, native, raw) and then by priority.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-06-17 17:58:28 +01:00
Olivier Fourdan e7016d30f3 backlight: Do not hang forever if helper pid is -1
Backlight helper PID is set to -1 by default, if for some reason it's
not set, we may end up with waitpid(-1, ...) which will hang forever.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90230
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2015-04-29 10:33:19 +01:00
Chris Wilson aa40f99014 Use AC_HEADER_MAJOR to find how to include major()
We need to include <sys/mkdev.h> on Solaris.

Reported-by: Richard Palo <richard@netbsd.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89763
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-03-25 14:14:30 +00:00
Patrick Welche ac90648ec7 backlight.c: test for features
Signed-off-by: Patrick Welche <prlw1@cam.ac.uk>
2015-01-26 12:46:07 +00:00
Chris Wilson 7ecc778691 backlight: bl_power uses 0 for on and 4 for off
The backlight/bl_power file didn't obey the obvious semantics, but
instead operates using some interesting framebuffer API. Oh well.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-11-04 10:37:48 +00:00
Chris Wilson 49376ba3bd backlight: Open bl_power using WRONLY for writing.
Jan spotted that we open the bl_power file using O_RDONLY and then attempt
to write the new power state into it. This fails...

Reported-by: Jan Steffens
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-10-11 21:36:11 +01:00
Chris Wilson 08921e4bda backlight: Expose interface to switch backlight on/off entirely
A feature in recent kernels is to disambiguate between the meaning of
brightness=0, between disabling the the backlight entirely or setting
the lowest valid brightness. As such, we now have an extra knob in sysfs
to explicitly request that the backlight be turned off.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-09-11 08:09:39 +01:00
Chris Wilson 61ec162dc9 backlight: Move the fd out of the select range
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-08-21 07:56:44 +01:00
Edward Sheldrake ebd1907304 backlight: Fix regression
The backlight xrandr property is missing unless the backlight level
was 0 on starting X, regression introduced in

commit f9e7ac7db7
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Jul 23 21:53:31 2014 +0100

    backlight: Set structure to safe values when not initialised

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82146
2014-08-04 20:20:41 +01:00
Chris Wilson f9e7ac7db7 backlight: Set structure to safe values when not initialised
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-23 21:58:05 +01:00
Hans de Goede 40bd45fb80 backlight: Fix compiler error
/usr/include/xorg/os.h around line 579 reads:

extern _X_EXPORT char *
strndup(const char *str, size_t n);

However strndup is already defined by glibc, and this redefine causes a
compile error.

This gets triggered because backlight.c does:

Without first doing:

Causing HAVE_STRNDUP to not be defined.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-06-18 14:11:05 +01:00
Chris Wilson 0b92b1285c backlight: Make search routine for device specific backlight common
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-02-20 19:22:03 +00:00
Mark Kettenis c91af569ee backlight: Build fixes for OpenBSD
Chris would like to humbly apologise for making these changes to the
OpenBSD code blind, and to thank Mark and Jonathan for their support
and understanding.
2014-02-18 19:04:09 +00:00
Hans de Goede b5229c6e15 backlight: Drop rights before executing pkexec
Event though we've failed to open the backlight normally, we may still be
running under a suid-root xserver, so drop any elevated rights before
executing what we hope will be pkxec.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-02-17 18:38:54 +00:00
Hans de Goede 27a9dc4ce8 backlight: Use System instead of system when checking for pkexec
Even though we've failed to open the backlight normally, we may still be
running under a suid-root xserver, so use the servers build in System instead
of system so as to properly drop root rights.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-02-17 18:38:45 +00:00
Hans de Goede 06066b7269 backlight: Explain better why we support both pkexec and suid root for the helper
Update the comment about trying suid-root first with some explanations of
why pkexec may be preferable in some cases.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2014-02-17 17:02:01 +00:00
Chris Wilson 6b5c2b4515 backlight: tidy use of BACKLIGHT_CLASS
Use string concantenation to simply the sprintf slightly.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-02-15 21:03:49 +00:00
Chris Wilson eb7d2b19e2 backlight: Reject user overrides on OpenBSD
We only handle the singular wscons OpenBSD interface for backlight, so
explicitly reject any user requests for something else.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-02-15 21:02:11 +00:00
Chris Wilson 268842a47f backlight: Amalgamate hardcoded priority tables
Our fallback path for finding the backlight interface uses a hardcoded
table of known backlight controllers in proirity order. Rather than
maintain this table twice in the midst of the KMS logic, push it to the
new set of common backlight routines.

This incorporates bugfixes from SNA to handle unknown backlights, but
usable, gracefully.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-02-15 20:56:24 +00:00
Jan Alexander Steffens (heftig) b71f3d8bd4 Backlight helper build fixes
Don't hardcode $(prefix)/libexec

Fix install hook when DESTDIR is set

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75028
2014-02-15 17:39:01 +00:00
Chris Wilson 3d629c91cf intel: Add a helper for setting backlight without root rights
Once the xserver stops running as root on kms capabable systems, we will need
some other way to access the backlight.

The approach taken in this patch moves most of the heavy lifting to a
helper that runs with root privileges and pipes our requested brightness
into the sysfs backlight interface. Where required, we use pkexec to
launch the helper with the elevated privilege.

v2: Amalgamate much more of the duplicate code.
    Keep the daemon and pipe alive for the lifetime of the backlight interface.
    Provide an alternative for systems without PolicyKit.

Signed-off-by: Hans de Goede <hdegoede@redhat.com> [v1]
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-02-15 15:33:47 +00:00