Commit cab267c6 authored by Michael Hanselmann's avatar Michael Hanselmann Committed by Linus Torvalds

[PATCH] powermac backlight fixes

Fix a erroneous calculation of the legacy brightness values as reported by
Paul Collins.  Additionally, it moves the calculation of the negative value
in the radeonfb driver after the value check.
Signed-off-by: default avatarMichael Hanselmann <linux-kernel@hansmi.ch>
Acked-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: default avatarPaul Collins <paul@briny.ondioline.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 96febe9f
...@@ -119,7 +119,14 @@ int pmac_backlight_set_legacy_brightness(int brightness) ...@@ -119,7 +119,14 @@ int pmac_backlight_set_legacy_brightness(int brightness)
down(&pmac_backlight->sem); down(&pmac_backlight->sem);
props = pmac_backlight->props; props = pmac_backlight->props;
props->brightness = brightness * props->brightness = brightness *
props->max_brightness / OLD_BACKLIGHT_MAX; (props->max_brightness + 1) /
(OLD_BACKLIGHT_MAX + 1);
if (props->brightness > props->max_brightness)
props->brightness = props->max_brightness;
else if (props->brightness < 0)
props->brightness = 0;
props->update_status(pmac_backlight); props->update_status(pmac_backlight);
up(&pmac_backlight->sem); up(&pmac_backlight->sem);
...@@ -140,8 +147,11 @@ int pmac_backlight_get_legacy_brightness() ...@@ -140,8 +147,11 @@ int pmac_backlight_get_legacy_brightness()
down(&pmac_backlight->sem); down(&pmac_backlight->sem);
props = pmac_backlight->props; props = pmac_backlight->props;
result = props->brightness * result = props->brightness *
OLD_BACKLIGHT_MAX / props->max_brightness; (OLD_BACKLIGHT_MAX + 1) /
(props->max_brightness + 1);
up(&pmac_backlight->sem); up(&pmac_backlight->sem);
} }
mutex_unlock(&pmac_backlight_mutex); mutex_unlock(&pmac_backlight_mutex);
......
...@@ -40,14 +40,14 @@ static int radeon_bl_get_level_brightness(struct radeon_bl_privdata *pdata, ...@@ -40,14 +40,14 @@ static int radeon_bl_get_level_brightness(struct radeon_bl_privdata *pdata,
mutex_unlock(&info->bl_mutex); mutex_unlock(&info->bl_mutex);
if (pdata->negative)
rlevel = MAX_RADEON_LEVEL - rlevel;
if (rlevel < 0) if (rlevel < 0)
rlevel = 0; rlevel = 0;
else if (rlevel > MAX_RADEON_LEVEL) else if (rlevel > MAX_RADEON_LEVEL)
rlevel = MAX_RADEON_LEVEL; rlevel = MAX_RADEON_LEVEL;
if (pdata->negative)
rlevel = MAX_RADEON_LEVEL - rlevel;
return rlevel; return rlevel;
} }
......
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