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/nvidia/nv_backlight.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/nvidia/nv_backlight.c')
-rw-r--r-- | drivers/video/nvidia/nv_backlight.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c index 1c1c10c699c5..b45f577094ac 100644 --- a/drivers/video/nvidia/nv_backlight.c +++ b/drivers/video/nvidia/nv_backlight.c @@ -26,9 +26,11 @@ */ #define MIN_LEVEL 0x158 #define MAX_LEVEL 0x534 +#define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX) static struct backlight_properties nvidia_bl_data; +/* Call with fb_info->bl_mutex held */ static int nvidia_bl_get_level_brightness(struct nvidia_par *par, int level) { @@ -36,9 +38,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_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; @@ -50,7 +50,8 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par, return nlevel; } -static int nvidia_bl_update_status(struct backlight_device *bd) +/* Call with fb_info->bl_mutex held */ +static int __nvidia_bl_update_status(struct backlight_device *bd) { struct nvidia_par *par = class_get_devdata(&bd->class_dev); u32 tmp_pcrt, tmp_pmc, fpcontrol; @@ -84,6 +85,19 @@ static int nvidia_bl_update_status(struct backlight_device *bd) return 0; } +static int nvidia_bl_update_status(struct backlight_device *bd) +{ + struct nvidia_par *par = class_get_devdata(&bd->class_dev); + struct fb_info *info = pci_get_drvdata(par->pci_dev); + int ret; + + mutex_lock(&info->bl_mutex); + ret = __nvidia_bl_update_status(bd); + mutex_unlock(&info->bl_mutex); + + return ret; +} + static int nvidia_bl_get_brightness(struct backlight_device *bd) { return bd->props->brightness; @@ -96,6 +110,16 @@ static struct backlight_properties nvidia_bl_data = { .max_brightness = (FB_BACKLIGHT_LEVELS - 1), }; +void nvidia_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; + __nvidia_bl_update_status(info->bl_dev); + down(&info->bl_dev->sem); + mutex_unlock(&info->bl_mutex); +} + void nvidia_bl_init(struct nvidia_par *par) { struct fb_info *info = pci_get_drvdata(par->pci_dev); |