xf86-video-intel: 2 commits - src/intel_display.c src/sna/sna_display.c
Chris Wilson
ickle at kemper.freedesktop.org
Fri Mar 22 04:30:32 PDT 2013
src/intel_display.c | 73 +++++++++++++++++++++++++++++++++++++++++++++-----
src/sna/sna_display.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 140 insertions(+), 6 deletions(-)
New commits:
commit ccd6b7e402e731c73163b132a80ae29ae2911613
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Mar 22 11:28:01 2013 +0000
sna: Add backlight control implementation
Based on the previous patch by Mark Kettenis <kettenis at openbsd.org>
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 9068df9..7891c8d 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -192,6 +192,78 @@ static void gem_close(int fd, uint32_t handle)
(void)drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &close);
}
+#ifdef __OpenBSD__
+
+#include <dev/wscons/wsconsio.h>
+#include <xf86Priv.h>
+
+static void
+sna_output_backlight_set(xf86OutputPtr output, int level)
+{
+ struct sna_output *sna_output = output->driver_private;
+ struct wsdisplay_param param;
+
+ DBG(("%s: level=%d, max=%d\n", __FUNCTION__,
+ level, sna_output->backlight_max));
+
+ if (!sna_output->backlight_iface)
+ return;
+
+ if ((unsigned)level > sna_output->backlight_max)
+ level = sna_output->backlight_max;
+
+ VG_CLEAR(param);
+ 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
+sna_output_backlight_get(xf86OutputPtr output)
+{
+ struct wsdisplay_param param;
+
+ VG_CLEAR(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;
+ }
+
+ DBG(("%s: level=%d (max=%d)\n", __FUNCTION__, param.curval, param.max));
+
+ return param.curval;
+}
+
+static void
+sna_output_backlight_init(xf86OutputPtr output)
+{
+ struct sna_output *sna_output = output->driver_private;
+ struct wsdisplay_param param;
+
+ VG_CLEAR(param);
+ param.param = WSDISPLAYIO_PARAM_BRIGHTNESS;
+
+ if (ioctl(xf86Info.consoleFd, WSDISPLAYIO_GETPARAM, ¶m) == -1)
+ return;
+
+ DBG(("%s: found 'wscons'\n", __FUNCTION__));
+
+ intel_output->backlight_iface = "wscons";
+ intel_output->backlight_max = param.max;
+ intel_output->backlight_active_level = param.curval;
+}
+
+#else
+
static void
sna_output_backlight_set(xf86OutputPtr output, int level)
{
@@ -532,6 +604,7 @@ done:
"found backlight control interface %s (type '%s')\n",
sna_output->backlight_iface, best_iface);
}
+#endif
static void
mode_from_kmode(ScrnInfoPtr scrn,
commit 364e02c7998813643bc81f25ba077a764872d49e
Author: Mark Kettenis <kettenis at openbsd.org>
Date: Fri Mar 22 11:23:11 2013 +0100
uxa: Add OpenBSD backlight control implementation
Signed-off-by: Mark Kettenis <kettenis at openbsd.org>
diff --git a/src/intel_display.c b/src/intel_display.c
index 5ee955e..2197183 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,
More information about the xorg-commit
mailing list