forked from luck/tmp_suning_uos_patched
gma500,cdv: Fix the brightness base
Some desktop environments carefully save and restore the brightness settings from the previous boot. Unfortunately they don't all check to see if the range has changed. The end result is that they restore a brightness of 100/lots not 100/100. As the old driver and the non-free GMA36xx driver both use 0-100 we thus need to go back doing the same thing to avoid users getting a mysterious black screen after boot. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
166973e506
commit
6469195940
|
@ -78,21 +78,6 @@ static int cdv_backlight_combination_mode(struct drm_device *dev)
|
|||
return REG_READ(BLC_PWM_CTL2) & PWM_LEGACY_MODE;
|
||||
}
|
||||
|
||||
static int cdv_get_brightness(struct backlight_device *bd)
|
||||
{
|
||||
struct drm_device *dev = bl_get_data(bd);
|
||||
u32 val = REG_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
|
||||
|
||||
if (cdv_backlight_combination_mode(dev)) {
|
||||
u8 lbpc;
|
||||
|
||||
val &= ~1;
|
||||
pci_read_config_byte(dev->pdev, 0xF4, &lbpc);
|
||||
val *= lbpc;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
static u32 cdv_get_max_backlight(struct drm_device *dev)
|
||||
{
|
||||
u32 max = REG_READ(BLC_PWM_CTL);
|
||||
|
@ -110,6 +95,22 @@ static u32 cdv_get_max_backlight(struct drm_device *dev)
|
|||
return max;
|
||||
}
|
||||
|
||||
static int cdv_get_brightness(struct backlight_device *bd)
|
||||
{
|
||||
struct drm_device *dev = bl_get_data(bd);
|
||||
u32 val = REG_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
|
||||
|
||||
if (cdv_backlight_combination_mode(dev)) {
|
||||
u8 lbpc;
|
||||
|
||||
val &= ~1;
|
||||
pci_read_config_byte(dev->pdev, 0xF4, &lbpc);
|
||||
val *= lbpc;
|
||||
}
|
||||
return (val * 100)/cdv_get_max_backlight(dev);
|
||||
|
||||
}
|
||||
|
||||
static int cdv_set_brightness(struct backlight_device *bd)
|
||||
{
|
||||
struct drm_device *dev = bl_get_data(bd);
|
||||
|
@ -120,6 +121,9 @@ static int cdv_set_brightness(struct backlight_device *bd)
|
|||
if (level < 1)
|
||||
level = 1;
|
||||
|
||||
level *= cdv_get_max_backlight(dev);
|
||||
level /= 100;
|
||||
|
||||
if (cdv_backlight_combination_mode(dev)) {
|
||||
u32 max = cdv_get_max_backlight(dev);
|
||||
u8 lbpc;
|
||||
|
@ -157,7 +161,6 @@ static int cdv_backlight_init(struct drm_device *dev)
|
|||
|
||||
cdv_backlight_device->props.brightness =
|
||||
cdv_get_brightness(cdv_backlight_device);
|
||||
cdv_backlight_device->props.max_brightness = cdv_get_max_backlight(dev);
|
||||
backlight_update_status(cdv_backlight_device);
|
||||
dev_priv->backlight_device = cdv_backlight_device;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user