summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Hejtmanek <xhejtman@ics.muni.cz>2008-06-16 02:49:41 +0800
committerroot <root@debian-hp.(none)>2008-06-16 02:54:44 +0800
commit9036c94b28d4f1d65333bc318079f31bf56b3f99 (patch)
tree379fdf5a140b344eae86b5df037e0648ea4d7a89
parentdf0bbdc7cbb6ff357a81ed28d12e56c9c7d643f7 (diff)
Fix maximum backlight issue
(cherry picked from commit 4c4ef27779aebf4df90b6233de05be2bb972de4c)
-rw-r--r--src/i830_lvds.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/i830_lvds.c b/src/i830_lvds.c
index 899c6cbf..ecb41c91 100644
--- a/src/i830_lvds.c
+++ b/src/i830_lvds.c
@@ -63,6 +63,9 @@ struct i830_lvds_priv {
/* The panel needs dithering enabled */
Bool panel_wants_dither;
+ /* The panel is in DPMS off */
+ Bool dpmsoff;
+
/* restore backlight to this value */
int backlight_duty_cycle;
@@ -334,6 +337,7 @@ i830_lvds_get_backlight_kernel(xf86OutputPtr output)
return 0;
}
+ memset(val, 0, sizeof(val));
if (read(fd, val, BACKLIGHT_VALUE_LEN) == -1)
goto out_err;
@@ -388,6 +392,10 @@ i830SetLVDSPanelPower(xf86OutputPtr output, Bool on)
uint32_t pp_status;
if (on) {
+ /* if we're going from on->on, be aware to current level. */
+ if ((INREG(PP_CONTROL) & POWER_TARGET_ON) && !dev_priv->dpmsoff)
+ dev_priv->backlight_duty_cycle = dev_priv->get_backlight(output);
+
/*
* If we're going from off->on we may need to turn on the backlight.
* We should use the saved value whenever possible, but on some
@@ -405,12 +413,13 @@ i830SetLVDSPanelPower(xf86OutputPtr output, Bool on)
} while ((pp_status & PP_ON) == 0);
dev_priv->set_backlight(output, dev_priv->backlight_duty_cycle);
+ dev_priv->dpmsoff = FALSE;
} else {
/*
* Only save the current backlight value if we're going from
* on to off.
*/
- if (INREG(PP_CONTROL) & POWER_TARGET_ON)
+ if ((INREG(PP_CONTROL) & POWER_TARGET_ON) && !dev_priv->dpmsoff)
dev_priv->backlight_duty_cycle = dev_priv->get_backlight(output);
dev_priv->set_backlight(output, 0);
@@ -418,6 +427,8 @@ i830SetLVDSPanelPower(xf86OutputPtr output, Bool on)
do {
pp_status = INREG(PP_STATUS);
} while (pp_status & PP_ON);
+
+ dev_priv->dpmsoff = TRUE;
}
}
@@ -447,7 +458,8 @@ i830_lvds_save (xf86OutputPtr output)
pI830->savePP_CONTROL = INREG(PP_CONTROL);
pI830->savePP_CYCLE = INREG(PP_CYCLE);
pI830->saveBLC_PWM_CTL = INREG(BLC_PWM_CTL);
- dev_priv->backlight_duty_cycle = dev_priv->get_backlight(output);
+ if ((INREG(PP_CONTROL) & POWER_TARGET_ON) && !dev_priv->dpmsoff)
+ dev_priv->backlight_duty_cycle = dev_priv->get_backlight(output);
}
static void
@@ -1081,7 +1093,10 @@ i830_lvds_set_property(xf86OutputPtr output, Atom property,
"RRConfigureOutputProperty error, %d\n", ret);
}
/* Set the current value of the backlight property */
- data = dev_priv->get_backlight(output);
+ if ((INREG(PP_CONTROL) & POWER_TARGET_ON) && !dev_priv->dpmsoff)
+ data = dev_priv->get_backlight(output);
+ else
+ data = dev_priv->backlight_duty_cycle;
ret = RRChangeOutputProperty(output->randr_output, backlight_atom,
XA_INTEGER, 32, PropModeReplace, 1, &data,
FALSE, TRUE);
@@ -1140,8 +1155,11 @@ i830_lvds_get_property(xf86OutputPtr output, Atom property)
*/
if (property == backlight_atom) {
int val;
- val = dev_priv->get_backlight(output);
- dev_priv->backlight_duty_cycle = val;
+ if ((INREG(PP_CONTROL) & POWER_TARGET_ON) && !dev_priv->dpmsoff) {
+ val = dev_priv->get_backlight(output);
+ dev_priv->backlight_duty_cycle = val;
+ } else
+ val = dev_priv->backlight_duty_cycle;
ret = RRChangeOutputProperty(output->randr_output, backlight_atom,
XA_INTEGER, 32, PropModeReplace, 1, &val,
FALSE, TRUE);