@@ -109,6 +109,12 @@ static char *backlight_interfaces[] = {
/* Enough for 10 digits of backlight + '\n' + '\0' */
#define BACKLIGHT_VALUE_LEN 12
+/* Constants from include/linux/fb.h */
+enum {
+ FB_BLANK_UNBLANK = 0,
+ FB_BLANK_POWERDOWN = 4
+};
+
static void
drmmode_backlight_set(xf86OutputPtr output, int level)
{
@@ -121,22 +127,37 @@ drmmode_backlight_set(xf86OutputPtr output, int level)
if (! drmmode_output->backlight_iface || level < 0)
return;
- len = snprintf(val, BACKLIGHT_VALUE_LEN, "%d\n", level);
sprintf(path, "%s/%s/brightness",
BACKLIGHT_CLASS, drmmode_output->backlight_iface);
+ len = snprintf(val, BACKLIGHT_VALUE_LEN, "%d\n", level);
fd = open(path, O_RDWR);
if (fd == -1) {
xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, "failed to open %s for backlight "
"control: %s\n", path, strerror(errno));
return;
}
-
ret = write(fd, val, len);
if (ret == -1) {
xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, "write to %s for backlight "
"control failed: %s\n", path, strerror(errno));
}
+ close(fd);
+ sprintf(path, "%s/%s/bl_power",
+ BACKLIGHT_CLASS, drmmode_output->backlight_iface);
+ len = snprintf(val, BACKLIGHT_VALUE_LEN, "%d\n",
+ level > 0 ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN);
+ fd = open(path, O_RDWR);
+ if (fd == -1) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, "failed to open %s for backlight "
+ "control: %s\n", path, strerror(errno));
+ return;
+ }
+ ret = write(fd, val, len);
+ if (ret == -1) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_ERROR, "write to %s for backlight "
+ "control failed: %s\n", path, strerror(errno));
+ }
close(fd);
}