diff options
author | Michael Hanselmann <linux-kernel@hansmi.ch> | 2006-06-28 07:26:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-28 17:59:06 -0400 |
commit | cab267c65f44337974e4f1eae490b21dce0e9811 (patch) | |
tree | d752bda111449ae7e9b7c85988f2993a9a068128 | |
parent | 96febe9fb7b04f2a078882d08bd6a997dee7cfa3 (diff) |
[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: Michael Hanselmann <linux-kernel@hansmi.ch>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Paul Collins <paul@briny.ondioline.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/powerpc/platforms/powermac/backlight.c | 14 | ||||
-rw-r--r-- | drivers/video/aty/radeon_backlight.c | 6 |
2 files changed, 15 insertions, 5 deletions
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c index 498b042e1837..c7a27eddca6d 100644 --- a/arch/powerpc/platforms/powermac/backlight.c +++ b/arch/powerpc/platforms/powermac/backlight.c | |||
@@ -119,7 +119,14 @@ int pmac_backlight_set_legacy_brightness(int brightness) | |||
119 | down(&pmac_backlight->sem); | 119 | down(&pmac_backlight->sem); |
120 | props = pmac_backlight->props; | 120 | props = pmac_backlight->props; |
121 | props->brightness = brightness * | 121 | props->brightness = brightness * |
122 | props->max_brightness / OLD_BACKLIGHT_MAX; | 122 | (props->max_brightness + 1) / |
123 | (OLD_BACKLIGHT_MAX + 1); | ||
124 | |||
125 | if (props->brightness > props->max_brightness) | ||
126 | props->brightness = props->max_brightness; | ||
127 | else if (props->brightness < 0) | ||
128 | props->brightness = 0; | ||
129 | |||
123 | props->update_status(pmac_backlight); | 130 | props->update_status(pmac_backlight); |
124 | up(&pmac_backlight->sem); | 131 | up(&pmac_backlight->sem); |
125 | 132 | ||
@@ -140,8 +147,11 @@ int pmac_backlight_get_legacy_brightness() | |||
140 | 147 | ||
141 | down(&pmac_backlight->sem); | 148 | down(&pmac_backlight->sem); |
142 | props = pmac_backlight->props; | 149 | props = pmac_backlight->props; |
150 | |||
143 | result = props->brightness * | 151 | result = props->brightness * |
144 | OLD_BACKLIGHT_MAX / props->max_brightness; | 152 | (OLD_BACKLIGHT_MAX + 1) / |
153 | (props->max_brightness + 1); | ||
154 | |||
145 | up(&pmac_backlight->sem); | 155 | up(&pmac_backlight->sem); |
146 | } | 156 | } |
147 | mutex_unlock(&pmac_backlight_mutex); | 157 | mutex_unlock(&pmac_backlight_mutex); |
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c index 7de66b855d4e..1755dddf1899 100644 --- a/drivers/video/aty/radeon_backlight.c +++ b/drivers/video/aty/radeon_backlight.c | |||
@@ -40,14 +40,14 @@ static int radeon_bl_get_level_brightness(struct radeon_bl_privdata *pdata, | |||
40 | 40 | ||
41 | mutex_unlock(&info->bl_mutex); | 41 | mutex_unlock(&info->bl_mutex); |
42 | 42 | ||
43 | if (pdata->negative) | ||
44 | rlevel = MAX_RADEON_LEVEL - rlevel; | ||
45 | |||
46 | if (rlevel < 0) | 43 | if (rlevel < 0) |
47 | rlevel = 0; | 44 | rlevel = 0; |
48 | else if (rlevel > MAX_RADEON_LEVEL) | 45 | else if (rlevel > MAX_RADEON_LEVEL) |
49 | rlevel = MAX_RADEON_LEVEL; | 46 | rlevel = MAX_RADEON_LEVEL; |
50 | 47 | ||
48 | if (pdata->negative) | ||
49 | rlevel = MAX_RADEON_LEVEL - rlevel; | ||
50 | |||
51 | return rlevel; | 51 | return rlevel; |
52 | } | 52 | } |
53 | 53 | ||