diff options
author | Michael Hanselmann <linux-kernel@hansmi.ch> | 2006-07-10 04:44:45 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-10 13:24:20 -0700 |
commit | e01af0384f54023b4548b7742952da2ffcafd4cd (patch) | |
tree | 6ffd14821a0a1fedbf4430c5df7fa60822f4809f /drivers/video/riva | |
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')
-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 baf494cecc1..33dddbae542 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c @@ -277,9 +277,11 @@ static const struct riva_regs reg_template = { */ #define MIN_LEVEL 0x158 #define MAX_LEVEL 0x534 +#define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX) static struct backlight_properties riva_bl_data; +/* Call with fb_info->bl_mutex held */ static int riva_bl_get_level_brightness(struct riva_par *par, int level) { @@ -287,9 +289,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par, int nlevel; /* Get and convert the value */ - mutex_lock(&info->bl_mutex); - nlevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; - mutex_unlock(&info->bl_mutex); + nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; if (nlevel < 0) nlevel = 0; @@ -301,7 +301,8 @@ static int riva_bl_get_level_brightness(struct riva_par *par, return nlevel; } -static int riva_bl_update_status(struct backlight_device *bd) +/* Call with fb_info->bl_mutex held */ +static int __riva_bl_update_status(struct backlight_device *bd) { struct riva_par *par = class_get_devdata(&bd->class_dev); U032 tmp_pcrt, tmp_pmc; @@ -326,6 +327,19 @@ static int riva_bl_update_status(struct backlight_device *bd) return 0; } +static int riva_bl_update_status(struct backlight_device *bd) +{ + struct riva_par *par = class_get_devdata(&bd->class_dev); + struct fb_info *info = pci_get_drvdata(par->pdev); + int ret; + + mutex_lock(&info->bl_mutex); + ret = __riva_bl_update_status(bd); + mutex_unlock(&info->bl_mutex); + + return ret; +} + static int riva_bl_get_brightness(struct backlight_device *bd) { return bd->props->brightness; @@ -338,6 +352,16 @@ static struct backlight_properties riva_bl_data = { .max_brightness = (FB_BACKLIGHT_LEVELS - 1), }; +static void riva_bl_set_power(struct fb_info *info, int power) +{ + mutex_lock(&info->bl_mutex); + up(&info->bl_dev->sem); + info->bl_dev->props->power = power; + __riva_bl_update_status(info->bl_dev); + down(&info->bl_dev->sem); + mutex_unlock(&info->bl_mutex); +} + static void riva_bl_init(struct riva_par *par) { struct fb_info *info = pci_get_drvdata(par->pdev); @@ -418,6 +442,7 @@ static void riva_bl_exit(struct riva_par *par) #else static inline void riva_bl_init(struct riva_par *par) {} static inline void riva_bl_exit(struct riva_par *par) {} +static inline void riva_bl_set_power(struct fb_info *info, int power) {} #endif /* CONFIG_FB_RIVA_BACKLIGHT */ /* ------------------------------------------------------------------------- * @@ -1336,16 +1361,7 @@ static int rivafb_blank(int blank, struct fb_info *info) SEQout(par, 0x01, tmp); CRTCout(par, 0x1a, vesa); -#ifdef CONFIG_FB_RIVA_BACKLIGHT - mutex_lock(&info->bl_mutex); - if (info->bl_dev) { - down(&info->bl_dev->sem); - info->bl_dev->props->power = blank; - info->bl_dev->props->update_status(info->bl_dev); - up(&info->bl_dev->sem); - } - mutex_unlock(&info->bl_mutex); -#endif + riva_bl_set_power(info, blank); NVTRACE_LEAVE(); |