diff options
author | Mark Kettenis <kettenis@openbsd.org> | 2013-03-22 11:23:11 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-03-22 11:27:43 +0000 |
commit | 364e02c7998813643bc81f25ba077a764872d49e (patch) | |
tree | 32bdc14f2bb57cf1bc6bb1305f6aa9d35b6e45fa | |
parent | 8d75b2ece1de1c95047c5dc5a569348abd0e6325 (diff) |
uxa: Add OpenBSD backlight control implementation
Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
-rw-r--r-- | src/intel_display.c | 73 |
1 files changed, 67 insertions, 6 deletions
diff --git a/src/intel_display.c b/src/intel_display.c index 5ee955ee..21971835 100644 --- a/src/intel_display.c +++ b/src/intel_display.c @@ -127,6 +127,72 @@ intel_output_dpms(xf86OutputPtr output, int mode); static void intel_output_dpms_backlight(xf86OutputPtr output, int oldmode, int mode); +static inline int +crtc_id(struct intel_crtc *crtc) +{ + return crtc->mode_crtc->crtc_id; +} + +#ifdef __OpenBSD__ + +#include <dev/wscons/wsconsio.h> +#include "xf86Priv.h" + +static void +intel_output_backlight_set(xf86OutputPtr output, int level) +{ + struct intel_output *intel_output = output->driver_private; + struct wsdisplay_param param; + + if (level > intel_output->backlight_max) + level = intel_output->backlight_max; + if (! intel_output->backlight_iface || level < 0) + return; + + param.param = WSDISPLAYIO_PARAM_BRIGHTNESS; + param.curval = level; + if (ioctl(xf86Info.consoleFd, WSDISPLAYIO_SETPARAM, ¶m) == -1) { + xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, + "Failed to set backlight level: %s\n", + strerror(errno)); + } +} + +static int +intel_output_backlight_get(xf86OutputPtr output) +{ + struct wsdisplay_param param; + + param.param = WSDISPLAYIO_PARAM_BRIGHTNESS; + if (ioctl(xf86Info.consoleFd, WSDISPLAYIO_GETPARAM, ¶m) == -1) { + xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, + "Failed to get backlight level: %s\n", + strerror(errno)); + return -1; + } + + return param.curval; +} + +static void +intel_output_backlight_init(xf86OutputPtr output) +{ + struct intel_output *intel_output = output->driver_private; + struct wsdisplay_param param; + + param.param = WSDISPLAYIO_PARAM_BRIGHTNESS; + if (ioctl(xf86Info.consoleFd, WSDISPLAYIO_GETPARAM, ¶m) == -1) { + intel_output->backlight_iface = NULL; + return; + } + + intel_output->backlight_iface = "wscons"; + intel_output->backlight_max = param.max; + intel_output->backlight_active_level = param.curval; +} + +#else + #define BACKLIGHT_CLASS "/sys/class/backlight" /* @@ -155,12 +221,6 @@ static const char *backlight_interfaces[] = { /* Enough for 10 digits of backlight + '\n' + '\0' */ #define BACKLIGHT_VALUE_LEN 12 -static inline int -crtc_id(struct intel_crtc *crtc) -{ - return crtc->mode_crtc->crtc_id; -} - static void intel_output_backlight_set(xf86OutputPtr output, int level) { @@ -297,6 +357,7 @@ intel_output_backlight_init(xf86OutputPtr output) intel_output->backlight_iface = NULL; } +#endif static void mode_from_kmode(ScrnInfoPtr scrn, |