Commit 64691959 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

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: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 166973e5
...@@ -78,21 +78,6 @@ static int cdv_backlight_combination_mode(struct drm_device *dev) ...@@ -78,21 +78,6 @@ static int cdv_backlight_combination_mode(struct drm_device *dev)
return REG_READ(BLC_PWM_CTL2) & PWM_LEGACY_MODE; 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) static u32 cdv_get_max_backlight(struct drm_device *dev)
{ {
u32 max = REG_READ(BLC_PWM_CTL); u32 max = REG_READ(BLC_PWM_CTL);
...@@ -110,6 +95,22 @@ static u32 cdv_get_max_backlight(struct drm_device *dev) ...@@ -110,6 +95,22 @@ static u32 cdv_get_max_backlight(struct drm_device *dev)
return max; 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) static int cdv_set_brightness(struct backlight_device *bd)
{ {
struct drm_device *dev = bl_get_data(bd); struct drm_device *dev = bl_get_data(bd);
...@@ -120,6 +121,9 @@ static int cdv_set_brightness(struct backlight_device *bd) ...@@ -120,6 +121,9 @@ static int cdv_set_brightness(struct backlight_device *bd)
if (level < 1) if (level < 1)
level = 1; level = 1;
level *= cdv_get_max_backlight(dev);
level /= 100;
if (cdv_backlight_combination_mode(dev)) { if (cdv_backlight_combination_mode(dev)) {
u32 max = cdv_get_max_backlight(dev); u32 max = cdv_get_max_backlight(dev);
u8 lbpc; u8 lbpc;
...@@ -157,7 +161,6 @@ static int cdv_backlight_init(struct drm_device *dev) ...@@ -157,7 +161,6 @@ static int cdv_backlight_init(struct drm_device *dev)
cdv_backlight_device->props.brightness = cdv_backlight_device->props.brightness =
cdv_get_brightness(cdv_backlight_device); cdv_get_brightness(cdv_backlight_device);
cdv_backlight_device->props.max_brightness = cdv_get_max_backlight(dev);
backlight_update_status(cdv_backlight_device); backlight_update_status(cdv_backlight_device);
dev_priv->backlight_device = cdv_backlight_device; dev_priv->backlight_device = cdv_backlight_device;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment