diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2006-03-31 05:31:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-31 15:19:00 -0500 |
commit | 2c0f5fb08e8ad59f396b1bda41ccd93cbb00a09f (patch) | |
tree | 9b53b4ffd3b118561d5210ca3962c592a428d7cd /drivers/video/backlight | |
parent | 5f27a27bd77fcfd4b90ed33668940bc3cf72768b (diff) |
[PATCH] backlight: corgi_bl: Generalise to support other Sharp SL hardware
Generalise the Corgi backlight driver by moving the default intensity and
limit mask settings into the platform specific data structure. This enables
the driver to support other Zaurus hardware, specifically the SL-6000x (Tosa)
model.
Also change the spinlock to a mutex (the spinlock is overkill).
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r-- | drivers/video/backlight/Kconfig | 4 | ||||
-rw-r--r-- | drivers/video/backlight/corgi_bl.c | 31 |
2 files changed, 15 insertions, 20 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 9d996f2c10d5..b895eaaa73fd 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -43,11 +43,11 @@ config LCD_DEVICE | |||
43 | default y | 43 | default y |
44 | 44 | ||
45 | config BACKLIGHT_CORGI | 45 | config BACKLIGHT_CORGI |
46 | tristate "Sharp Corgi Backlight Driver (SL-C7xx Series)" | 46 | tristate "Sharp Corgi Backlight Driver (SL Series)" |
47 | depends on BACKLIGHT_DEVICE && PXA_SHARPSL | 47 | depends on BACKLIGHT_DEVICE && PXA_SHARPSL |
48 | default y | 48 | default y |
49 | help | 49 | help |
50 | If you have a Sharp Zaurus SL-C7xx, say y to enable the | 50 | If you have a Sharp Zaurus SL-C7xx, SL-Cxx00 or SL-6000x say y to enable the |
51 | backlight driver. | 51 | backlight driver. |
52 | 52 | ||
53 | config BACKLIGHT_HP680 | 53 | config BACKLIGHT_HP680 |
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c index f86213b4a8fb..2ebbfd95145f 100644 --- a/drivers/video/backlight/corgi_bl.c +++ b/drivers/video/backlight/corgi_bl.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Backlight Driver for Sharp Corgi | 2 | * Backlight Driver for Sharp Zaurus Handhelds (various models) |
3 | * | 3 | * |
4 | * Copyright (c) 2004-2005 Richard Purdie | 4 | * Copyright (c) 2004-2006 Richard Purdie |
5 | * | 5 | * |
6 | * Based on Sharp's 2.4 Backlight Driver | 6 | * Based on Sharp's 2.4 Backlight Driver |
7 | * | 7 | * |
@@ -15,21 +15,17 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/spinlock.h> | 18 | #include <linux/mutex.h> |
19 | #include <linux/fb.h> | 19 | #include <linux/fb.h> |
20 | #include <linux/backlight.h> | 20 | #include <linux/backlight.h> |
21 | |||
22 | #include <asm/arch/sharpsl.h> | 21 | #include <asm/arch/sharpsl.h> |
23 | #include <asm/hardware/sharpsl_pm.h> | 22 | #include <asm/hardware/sharpsl_pm.h> |
24 | 23 | ||
25 | #define CORGI_DEFAULT_INTENSITY 0x1f | ||
26 | #define CORGI_LIMIT_MASK 0x0b | ||
27 | |||
28 | static int corgibl_intensity; | 24 | static int corgibl_intensity; |
29 | static void (*corgibl_mach_set_intensity)(int intensity); | 25 | static DEFINE_MUTEX(bl_mutex); |
30 | static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED; | ||
31 | static struct backlight_properties corgibl_data; | 26 | static struct backlight_properties corgibl_data; |
32 | static struct backlight_device *corgi_backlight_device; | 27 | static struct backlight_device *corgi_backlight_device; |
28 | static struct corgibl_machinfo *bl_machinfo; | ||
33 | 29 | ||
34 | static unsigned long corgibl_flags; | 30 | static unsigned long corgibl_flags; |
35 | #define CORGIBL_SUSPENDED 0x01 | 31 | #define CORGIBL_SUSPENDED 0x01 |
@@ -37,7 +33,6 @@ static unsigned long corgibl_flags; | |||
37 | 33 | ||
38 | static int corgibl_send_intensity(struct backlight_device *bd) | 34 | static int corgibl_send_intensity(struct backlight_device *bd) |
39 | { | 35 | { |
40 | unsigned long flags; | ||
41 | void (*corgi_kick_batt)(void); | 36 | void (*corgi_kick_batt)(void); |
42 | int intensity = bd->props->brightness; | 37 | int intensity = bd->props->brightness; |
43 | 38 | ||
@@ -48,13 +43,11 @@ static int corgibl_send_intensity(struct backlight_device *bd) | |||
48 | if (corgibl_flags & CORGIBL_SUSPENDED) | 43 | if (corgibl_flags & CORGIBL_SUSPENDED) |
49 | intensity = 0; | 44 | intensity = 0; |
50 | if (corgibl_flags & CORGIBL_BATTLOW) | 45 | if (corgibl_flags & CORGIBL_BATTLOW) |
51 | intensity &= CORGI_LIMIT_MASK; | 46 | intensity &= bl_machinfo->limit_mask; |
52 | |||
53 | spin_lock_irqsave(&bl_lock, flags); | ||
54 | |||
55 | corgibl_mach_set_intensity(intensity); | ||
56 | 47 | ||
57 | spin_unlock_irqrestore(&bl_lock, flags); | 48 | mutex_lock(&bl_mutex); |
49 | bl_machinfo->set_bl_intensity(intensity); | ||
50 | mutex_unlock(&bl_mutex); | ||
58 | 51 | ||
59 | corgibl_intensity = intensity; | 52 | corgibl_intensity = intensity; |
60 | 53 | ||
@@ -122,8 +115,10 @@ static int __init corgibl_probe(struct platform_device *pdev) | |||
122 | { | 115 | { |
123 | struct corgibl_machinfo *machinfo = pdev->dev.platform_data; | 116 | struct corgibl_machinfo *machinfo = pdev->dev.platform_data; |
124 | 117 | ||
118 | bl_machinfo = machinfo; | ||
125 | corgibl_data.max_brightness = machinfo->max_intensity; | 119 | corgibl_data.max_brightness = machinfo->max_intensity; |
126 | corgibl_mach_set_intensity = machinfo->set_bl_intensity; | 120 | if (!machinfo->limit_mask) |
121 | machinfo->limit_mask = -1; | ||
127 | 122 | ||
128 | corgi_backlight_device = backlight_device_register ("corgi-bl", | 123 | corgi_backlight_device = backlight_device_register ("corgi-bl", |
129 | NULL, &corgibl_data); | 124 | NULL, &corgibl_data); |
@@ -131,7 +126,7 @@ static int __init corgibl_probe(struct platform_device *pdev) | |||
131 | return PTR_ERR (corgi_backlight_device); | 126 | return PTR_ERR (corgi_backlight_device); |
132 | 127 | ||
133 | corgibl_data.power = FB_BLANK_UNBLANK; | 128 | corgibl_data.power = FB_BLANK_UNBLANK; |
134 | corgibl_data.brightness = CORGI_DEFAULT_INTENSITY; | 129 | corgibl_data.brightness = machinfo->default_intensity; |
135 | corgibl_send_intensity(corgi_backlight_device); | 130 | corgibl_send_intensity(corgi_backlight_device); |
136 | 131 | ||
137 | printk("Corgi Backlight Driver Initialized.\n"); | 132 | printk("Corgi Backlight Driver Initialized.\n"); |