summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@neko.keithp.com>2007-06-21 23:59:38 +0100
committerKeith Packard <keithp@neko.keithp.com>2007-06-21 23:59:38 +0100
commita67c2965385001bcb8987265f698ff0f5809cd11 (patch)
tree880a2c8095a605f11838c655b1bcbe9d2b393d20
parentd6e46f67ab3af1ad3bfa72acb0efd9fe79dbf1dc (diff)
Follow BIOS configuration for Legacy Backlight Brightness.
The backlight control in the LVDS controller can either operate in 'normal' mode or 'legacy' mode. In legacy mode, it uses the PCI config space register 0xf4 which can range from 0 to 0xff. In normal mode, it reads the range and current value from the BLC_PWM_CTL register.
-rw-r--r--src/i810_reg.h8
-rw-r--r--src/i830_lvds.c34
2 files changed, 36 insertions, 6 deletions
diff --git a/src/i810_reg.h b/src/i810_reg.h
index 6001297e..248df049 100644
--- a/src/i810_reg.h
+++ b/src/i810_reg.h
@@ -1056,6 +1056,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define RENCLK_GATE_D2 0x6208
#define RAMCLK_GATE_D 0x6210 /* CRL only */
+/*
+ * This is a PCI config space register to manipulate backlight brightness
+ * It is used when the BLM_LEGACY_MODE is turned on. When enabled, the first
+ * byte of this config register sets brightness within the range from
+ * 0 to 0xff
+ */
+#define LEGACY_BACKLIGHT_BRIGHTNESS 0xf4
+
#define BLC_PWM_CTL 0x61254
#define BACKLIGHT_MODULATION_FREQ_SHIFT (17)
/**
diff --git a/src/i830_lvds.c b/src/i830_lvds.c
index ee278aa4..d4698151 100644
--- a/src/i830_lvds.c
+++ b/src/i830_lvds.c
@@ -59,8 +59,18 @@ i830_lvds_set_backlight(xf86OutputPtr output, int level)
I830Ptr pI830 = I830PTR(pScrn);
CARD32 blc_pwm_ctl;
- blc_pwm_ctl = INREG(BLC_PWM_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK;
- OUTREG(BLC_PWM_CTL, blc_pwm_ctl | (level << BACKLIGHT_DUTY_CYCLE_SHIFT));
+ blc_pwm_ctl = INREG(BLC_PWM_CTL);
+ if (blc_pwm_ctl & BLM_LEGACY_MODE)
+ {
+ pciWriteByte (pI830->PciTag,
+ LEGACY_BACKLIGHT_BRIGHTNESS,
+ level & 0xff);
+ }
+ else
+ {
+ blc_pwm_ctl &= ~BACKLIGHT_DUTY_CYCLE_MASK;
+ OUTREG(BLC_PWM_CTL, blc_pwm_ctl | (level << BACKLIGHT_DUTY_CYCLE_SHIFT));
+ }
}
/**
@@ -71,9 +81,13 @@ i830_lvds_get_max_backlight(xf86OutputPtr output)
{
ScrnInfoPtr pScrn = output->scrn;
I830Ptr pI830 = I830PTR(pScrn);
+ CARD32 pwm_ctl = INREG(BLC_PWM_CTL);
- return ((INREG(BLC_PWM_CTL) & BACKLIGHT_MODULATION_FREQ_MASK) >>
- BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
+ if (pwm_ctl & BLM_LEGACY_MODE)
+ return 0xff;
+ else
+ return ((pwm_ctl & BACKLIGHT_MODULATION_FREQ_MASK) >>
+ BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
}
/**
@@ -129,8 +143,16 @@ 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 = (pI830->saveBLC_PWM_CTL &
- BACKLIGHT_DUTY_CYCLE_MASK);
+ if (pI830->saveBLC_PWM_CTL & BLM_LEGACY_MODE)
+ {
+ dev_priv->backlight_duty_cycle = pciReadByte (pI830->PciTag,
+ LEGACY_BACKLIGHT_BRIGHTNESS);
+ }
+ else
+ {
+ dev_priv->backlight_duty_cycle = (pI830->saveBLC_PWM_CTL &
+ BACKLIGHT_DUTY_CYCLE_MASK);
+ }
/*
* If the light is off at server startup, just make it full brightness