diff options
author | Lukas Hejtmanek <xhejtman@ics.muni.cz> | 2008-06-16 02:49:41 +0800 |
---|---|---|
committer | root <root@debian-hp.(none)> | 2008-06-16 02:49:41 +0800 |
commit | 4c4ef27779aebf4df90b6233de05be2bb972de4c (patch) | |
tree | 4211119c474e8d8f35c272a040aa18d078d6c1df /src/i830_lvds.c | |
parent | 79f94ee3c4652019395b9c329d94f7779c558571 (diff) |
Fix maximum backlight issue
Diffstat (limited to 'src/i830_lvds.c')
-rw-r--r-- | src/i830_lvds.c | 28 |
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); |