diff options
author | Michael Hanselmann <linux-kernel@hansmi.ch> | 2006-07-10 07:44:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-10 16:24:20 -0400 |
commit | e01af0384f54023b4548b7742952da2ffcafd4cd (patch) | |
tree | 6ffd14821a0a1fedbf4430c5df7fa60822f4809f /drivers/video/riva/fbdev.c | |
parent | 58d383a6222d66be9483598c51bae34e7d3c2c37 (diff) |
[PATCH] powermac: Combined fixes for backlight code
This patch fixes several problems:
- pmac_backlight_key() is called under interrupt context, and therefore
can't use mutexes or semaphores, so defer the backlight level for
later, as it's not critical (original code by Aristeu S. Rozanski F.
<aris@valeta.org>).
- Add exports for functions that might be called from modules
- Fix Kconfig depdencies on PMAC_BACKLIGHT.
- Fix locking issues on calls from inside the driver (reported by
Aristeu S. Rozanski F., too)
- Fix wrong calculation of backlight values in some of the drivers
- Replace pmac_backlight_key_up/down by inline functions
[akpm@osdl.org: fix function prototypes]
Signed-off-by: Michael Hanselmann <linux-kernel@hansmi.ch>
Acked-by: Aristeu S. Rozanski F. <aris@valeta.org>
Acked-by: Rene Nussbaumer <linux-kernel@killerfox.forkbomb.ch>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/riva/fbdev.c')
-rw-r--r-- | drivers/video/riva/fbdev.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index baf494cecc10..33dddbae5420 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c | |||
@@ -277,9 +277,11 @@ static const struct riva_regs reg_template = { | |||
277 | */ | 277 | */ |
278 | #define MIN_LEVEL 0x158 | 278 | #define MIN_LEVEL 0x158 |
279 | #define MAX_LEVEL 0x534 | 279 | #define MAX_LEVEL 0x534 |
280 | #define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX) | ||
280 | 281 | ||
281 | static struct backlight_properties riva_bl_data; | 282 | static struct backlight_properties riva_bl_data; |
282 | 283 | ||
284 | /* Call with fb_info->bl_mutex held */ | ||
283 | static int riva_bl_get_level_brightness(struct riva_par *par, | 285 | static int riva_bl_get_level_brightness(struct riva_par *par, |
284 | int level) | 286 | int level) |
285 | { | 287 | { |
@@ -287,9 +289,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par, | |||
287 | int nlevel; | 289 | int nlevel; |
288 | 290 | ||
289 | /* Get and convert the value */ | 291 | /* Get and convert the value */ |
290 | mutex_lock(&info->bl_mutex); | 292 | nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; |
291 | nlevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; | ||
292 | mutex_unlock(&info->bl_mutex); | ||
293 | 293 | ||
294 | if (nlevel < 0) | 294 | if (nlevel < 0) |
295 | nlevel = 0; | 295 | nlevel = 0; |
@@ -301,7 +301,8 @@ static int riva_bl_get_level_brightness(struct riva_par *par, | |||
301 | return nlevel; | 301 | return nlevel; |
302 | } | 302 | } |
303 | 303 | ||
304 | static int riva_bl_update_status(struct backlight_device *bd) | 304 | /* Call with fb_info->bl_mutex held */ |
305 | static int __riva_bl_update_status(struct backlight_device *bd) | ||
305 | { | 306 | { |
306 | struct riva_par *par = class_get_devdata(&bd->class_dev); | 307 | struct riva_par *par = class_get_devdata(&bd->class_dev); |
307 | U032 tmp_pcrt, tmp_pmc; | 308 | U032 tmp_pcrt, tmp_pmc; |
@@ -326,6 +327,19 @@ static int riva_bl_update_status(struct backlight_device *bd) | |||
326 | return 0; | 327 | return 0; |
327 | } | 328 | } |
328 | 329 | ||
330 | static int riva_bl_update_status(struct backlight_device *bd) | ||
331 | { | ||
332 | struct riva_par *par = class_get_devdata(&bd->class_dev); | ||
333 | struct fb_info *info = pci_get_drvdata(par->pdev); | ||
334 | int ret; | ||
335 | |||
336 | mutex_lock(&info->bl_mutex); | ||
337 | ret = __riva_bl_update_status(bd); | ||
338 | mutex_unlock(&info->bl_mutex); | ||
339 | |||
340 | return ret; | ||
341 | } | ||
342 | |||
329 | static int riva_bl_get_brightness(struct backlight_device *bd) | 343 | static int riva_bl_get_brightness(struct backlight_device *bd) |
330 | { | 344 | { |
331 | return bd->props->brightness; | 345 | return bd->props->brightness; |
@@ -338,6 +352,16 @@ static struct backlight_properties riva_bl_data = { | |||
338 | .max_brightness = (FB_BACKLIGHT_LEVELS - 1), | 352 | .max_brightness = (FB_BACKLIGHT_LEVELS - 1), |
339 | }; | 353 | }; |
340 | 354 | ||
355 | static void riva_bl_set_power(struct fb_info *info, int power) | ||
356 | { | ||
357 | mutex_lock(&info->bl_mutex); | ||
358 | up(&info->bl_dev->sem); | ||
359 | info->bl_dev->props->power = power; | ||
360 | __riva_bl_update_status(info->bl_dev); | ||
361 | down(&info->bl_dev->sem); | ||
362 | mutex_unlock(&info->bl_mutex); | ||
363 | } | ||
364 | |||
341 | static void riva_bl_init(struct riva_par *par) | 365 | static void riva_bl_init(struct riva_par *par) |
342 | { | 366 | { |
343 | struct fb_info *info = pci_get_drvdata(par->pdev); | 367 | struct fb_info *info = pci_get_drvdata(par->pdev); |
@@ -418,6 +442,7 @@ static void riva_bl_exit(struct riva_par *par) | |||
418 | #else | 442 | #else |
419 | static inline void riva_bl_init(struct riva_par *par) {} | 443 | static inline void riva_bl_init(struct riva_par *par) {} |
420 | static inline void riva_bl_exit(struct riva_par *par) {} | 444 | static inline void riva_bl_exit(struct riva_par *par) {} |
445 | static inline void riva_bl_set_power(struct fb_info *info, int power) {} | ||
421 | #endif /* CONFIG_FB_RIVA_BACKLIGHT */ | 446 | #endif /* CONFIG_FB_RIVA_BACKLIGHT */ |
422 | 447 | ||
423 | /* ------------------------------------------------------------------------- * | 448 | /* ------------------------------------------------------------------------- * |
@@ -1336,16 +1361,7 @@ static int rivafb_blank(int blank, struct fb_info *info) | |||
1336 | SEQout(par, 0x01, tmp); | 1361 | SEQout(par, 0x01, tmp); |
1337 | CRTCout(par, 0x1a, vesa); | 1362 | CRTCout(par, 0x1a, vesa); |
1338 | 1363 | ||
1339 | #ifdef CONFIG_FB_RIVA_BACKLIGHT | 1364 | riva_bl_set_power(info, blank); |
1340 | mutex_lock(&info->bl_mutex); | ||
1341 | if (info->bl_dev) { | ||
1342 | down(&info->bl_dev->sem); | ||
1343 | info->bl_dev->props->power = blank; | ||
1344 | info->bl_dev->props->update_status(info->bl_dev); | ||
1345 | up(&info->bl_dev->sem); | ||
1346 | } | ||
1347 | mutex_unlock(&info->bl_mutex); | ||
1348 | #endif | ||
1349 | 1365 | ||
1350 | NVTRACE_LEAVE(); | 1366 | NVTRACE_LEAVE(); |
1351 | 1367 | ||