diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2007-09-02 19:27:00 -0400 |
---|---|---|
committer | Richard Purdie <rpurdie@rpsys.net> | 2007-10-11 17:24:13 -0400 |
commit | c3f8f65046127f471d0b6193a1923185b354c011 (patch) | |
tree | 69e9178d13f9c1e02387f33fbff38fff612eb12e | |
parent | 18f65c793a5106b9f99822ef248e71582db03386 (diff) |
backlight: Convert corgi backlight driver into a more generic driver
Convert the corgi backlight driver to a more generic version
so it can be reused by other code rather than being Zaurus/PXA
specific.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
-rw-r--r-- | arch/arm/mach-pxa/corgi.c | 18 | ||||
-rw-r--r-- | arch/arm/mach-pxa/spitz.c | 18 | ||||
-rw-r--r-- | drivers/video/backlight/Kconfig | 11 | ||||
-rw-r--r-- | drivers/video/backlight/corgi_bl.c | 22 | ||||
-rw-r--r-- | include/asm-arm/arch-pxa/sharpsl.h | 6 | ||||
-rw-r--r-- | include/linux/backlight.h | 9 |
6 files changed, 57 insertions, 27 deletions
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index aab27297b3c6..2363cc64fe07 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/mmc/host.h> | 21 | #include <linux/mmc/host.h> |
22 | #include <linux/pm.h> | 22 | #include <linux/pm.h> |
23 | #include <linux/backlight.h> | ||
23 | 24 | ||
24 | #include <asm/setup.h> | 25 | #include <asm/setup.h> |
25 | #include <asm/memory.h> | 26 | #include <asm/memory.h> |
@@ -142,15 +143,28 @@ struct corgissp_machinfo corgi_ssp_machinfo = { | |||
142 | /* | 143 | /* |
143 | * Corgi Backlight Device | 144 | * Corgi Backlight Device |
144 | */ | 145 | */ |
145 | static struct corgibl_machinfo corgi_bl_machinfo = { | 146 | static void corgi_bl_kick_battery(void) |
147 | { | ||
148 | void (*kick_batt)(void); | ||
149 | |||
150 | kick_batt = symbol_get(sharpsl_battery_kick); | ||
151 | if (kick_batt) { | ||
152 | kick_batt(); | ||
153 | symbol_put(sharpsl_battery_kick); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | static struct generic_bl_info corgi_bl_machinfo = { | ||
158 | .name = "corgi-bl", | ||
146 | .max_intensity = 0x2f, | 159 | .max_intensity = 0x2f, |
147 | .default_intensity = 0x1f, | 160 | .default_intensity = 0x1f, |
148 | .limit_mask = 0x0b, | 161 | .limit_mask = 0x0b, |
149 | .set_bl_intensity = corgi_bl_set_intensity, | 162 | .set_bl_intensity = corgi_bl_set_intensity, |
163 | .kick_battery = corgi_bl_kick_battery, | ||
150 | }; | 164 | }; |
151 | 165 | ||
152 | static struct platform_device corgibl_device = { | 166 | static struct platform_device corgibl_device = { |
153 | .name = "corgi-bl", | 167 | .name = "generic-bl", |
154 | .dev = { | 168 | .dev = { |
155 | .parent = &corgifb_device.dev, | 169 | .parent = &corgifb_device.dev, |
156 | .platform_data = &corgi_bl_machinfo, | 170 | .platform_data = &corgi_bl_machinfo, |
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index bae47e145de8..2d78199d24af 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/mmc/host.h> | 22 | #include <linux/mmc/host.h> |
23 | #include <linux/pm.h> | 23 | #include <linux/pm.h> |
24 | #include <linux/backlight.h> | ||
24 | 25 | ||
25 | #include <asm/setup.h> | 26 | #include <asm/setup.h> |
26 | #include <asm/memory.h> | 27 | #include <asm/memory.h> |
@@ -222,14 +223,27 @@ struct corgissp_machinfo spitz_ssp_machinfo = { | |||
222 | /* | 223 | /* |
223 | * Spitz Backlight Device | 224 | * Spitz Backlight Device |
224 | */ | 225 | */ |
225 | static struct corgibl_machinfo spitz_bl_machinfo = { | 226 | static void spitz_bl_kick_battery(void) |
227 | { | ||
228 | void (*kick_batt)(void); | ||
229 | |||
230 | kick_batt = symbol_get(sharpsl_battery_kick); | ||
231 | if (kick_batt) { | ||
232 | kick_batt(); | ||
233 | symbol_put(sharpsl_battery_kick); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | static struct generic_bl_info spitz_bl_machinfo = { | ||
238 | .name = "corgi-bl", | ||
226 | .default_intensity = 0x1f, | 239 | .default_intensity = 0x1f, |
227 | .limit_mask = 0x0b, | 240 | .limit_mask = 0x0b, |
228 | .max_intensity = 0x2f, | 241 | .max_intensity = 0x2f, |
242 | .kick_battery = spitz_bl_kick_battery, | ||
229 | }; | 243 | }; |
230 | 244 | ||
231 | static struct platform_device spitzbl_device = { | 245 | static struct platform_device spitzbl_device = { |
232 | .name = "corgi-bl", | 246 | .name = "generic-bl", |
233 | .dev = { | 247 | .dev = { |
234 | .platform_data = &spitz_bl_machinfo, | 248 | .platform_data = &spitz_bl_machinfo, |
235 | }, | 249 | }, |
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index b6f936a09185..9609a6c676be 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -51,12 +51,13 @@ config BACKLIGHT_CLASS_DEVICE | |||
51 | select the proper drivers which depend on this option. | 51 | select the proper drivers which depend on this option. |
52 | 52 | ||
53 | config BACKLIGHT_CORGI | 53 | config BACKLIGHT_CORGI |
54 | tristate "Sharp Corgi Backlight Driver (SL Series)" | 54 | tristate "Generic (aka Sharp Corgi) Backlight Driver" |
55 | depends on BACKLIGHT_CLASS_DEVICE && PXA_SHARPSL | 55 | depends on BACKLIGHT_CLASS_DEVICE |
56 | default y | 56 | default n |
57 | help | 57 | help |
58 | If you have a Sharp Zaurus SL-C7xx, SL-Cxx00 or SL-6000x say y to enable the | 58 | Say y to enable the generic platform backlight driver previously |
59 | backlight driver. | 59 | known as the Corgi backlight driver. If you have a Sharp Zaurus |
60 | SL-C7xx, SL-Cxx00 or SL-6000x say y. Most users can say n. | ||
60 | 61 | ||
61 | config BACKLIGHT_LOCOMO | 62 | config BACKLIGHT_LOCOMO |
62 | tristate "Sharp LOCOMO LCD/Backlight Driver" | 63 | tristate "Sharp LOCOMO LCD/Backlight Driver" |
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c index ce00e18a4e5d..4d4d037e3ec9 100644 --- a/drivers/video/backlight/corgi_bl.c +++ b/drivers/video/backlight/corgi_bl.c | |||
@@ -18,13 +18,11 @@ | |||
18 | #include <linux/mutex.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 | #include <asm/arch/sharpsl.h> | ||
22 | #include <asm/hardware/sharpsl_pm.h> | ||
23 | 21 | ||
24 | static int corgibl_intensity; | 22 | static int corgibl_intensity; |
25 | static struct backlight_properties corgibl_data; | 23 | static struct backlight_properties corgibl_data; |
26 | static struct backlight_device *corgi_backlight_device; | 24 | static struct backlight_device *corgi_backlight_device; |
27 | static struct corgibl_machinfo *bl_machinfo; | 25 | static struct generic_bl_info *bl_machinfo; |
28 | 26 | ||
29 | static unsigned long corgibl_flags; | 27 | static unsigned long corgibl_flags; |
30 | #define CORGIBL_SUSPENDED 0x01 | 28 | #define CORGIBL_SUSPENDED 0x01 |
@@ -32,7 +30,6 @@ static unsigned long corgibl_flags; | |||
32 | 30 | ||
33 | static int corgibl_send_intensity(struct backlight_device *bd) | 31 | static int corgibl_send_intensity(struct backlight_device *bd) |
34 | { | 32 | { |
35 | void (*corgi_kick_batt)(void); | ||
36 | int intensity = bd->props.brightness; | 33 | int intensity = bd->props.brightness; |
37 | 34 | ||
38 | if (bd->props.power != FB_BLANK_UNBLANK) | 35 | if (bd->props.power != FB_BLANK_UNBLANK) |
@@ -48,11 +45,8 @@ static int corgibl_send_intensity(struct backlight_device *bd) | |||
48 | 45 | ||
49 | corgibl_intensity = intensity; | 46 | corgibl_intensity = intensity; |
50 | 47 | ||
51 | corgi_kick_batt = symbol_get(sharpsl_battery_kick); | 48 | if (bl_machinfo->kick_battery) |
52 | if (corgi_kick_batt) { | 49 | bl_machinfo->kick_battery(); |
53 | corgi_kick_batt(); | ||
54 | symbol_put(sharpsl_battery_kick); | ||
55 | } | ||
56 | 50 | ||
57 | return 0; | 51 | return 0; |
58 | } | 52 | } |
@@ -107,13 +101,17 @@ static struct backlight_ops corgibl_ops = { | |||
107 | 101 | ||
108 | static int corgibl_probe(struct platform_device *pdev) | 102 | static int corgibl_probe(struct platform_device *pdev) |
109 | { | 103 | { |
110 | struct corgibl_machinfo *machinfo = pdev->dev.platform_data; | 104 | struct generic_bl_info *machinfo = pdev->dev.platform_data; |
105 | const char *name = "generic-bl"; | ||
111 | 106 | ||
112 | bl_machinfo = machinfo; | 107 | bl_machinfo = machinfo; |
113 | if (!machinfo->limit_mask) | 108 | if (!machinfo->limit_mask) |
114 | machinfo->limit_mask = -1; | 109 | machinfo->limit_mask = -1; |
115 | 110 | ||
116 | corgi_backlight_device = backlight_device_register ("corgi-bl", | 111 | if (machinfo->name) |
112 | name = machinfo->name; | ||
113 | |||
114 | corgi_backlight_device = backlight_device_register (name, | ||
117 | &pdev->dev, NULL, &corgibl_ops); | 115 | &pdev->dev, NULL, &corgibl_ops); |
118 | if (IS_ERR (corgi_backlight_device)) | 116 | if (IS_ERR (corgi_backlight_device)) |
119 | return PTR_ERR (corgi_backlight_device); | 117 | return PTR_ERR (corgi_backlight_device); |
@@ -149,7 +147,7 @@ static struct platform_driver corgibl_driver = { | |||
149 | .suspend = corgibl_suspend, | 147 | .suspend = corgibl_suspend, |
150 | .resume = corgibl_resume, | 148 | .resume = corgibl_resume, |
151 | .driver = { | 149 | .driver = { |
152 | .name = "corgi-bl", | 150 | .name = "generic-bl", |
153 | }, | 151 | }, |
154 | }; | 152 | }; |
155 | 153 | ||
diff --git a/include/asm-arm/arch-pxa/sharpsl.h b/include/asm-arm/arch-pxa/sharpsl.h index 94cb4982af82..2b0fe773213a 100644 --- a/include/asm-arm/arch-pxa/sharpsl.h +++ b/include/asm-arm/arch-pxa/sharpsl.h | |||
@@ -25,12 +25,6 @@ struct corgits_machinfo { | |||
25 | /* | 25 | /* |
26 | * SharpSL Backlight | 26 | * SharpSL Backlight |
27 | */ | 27 | */ |
28 | struct corgibl_machinfo { | ||
29 | int max_intensity; | ||
30 | int default_intensity; | ||
31 | int limit_mask; | ||
32 | void (*set_bl_intensity)(int intensity); | ||
33 | }; | ||
34 | extern void corgibl_limit_intensity(int limit); | 28 | extern void corgibl_limit_intensity(int limit); |
35 | 29 | ||
36 | 30 | ||
diff --git a/include/linux/backlight.h b/include/linux/backlight.h index c897c7b03858..1ee9488ca2e4 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h | |||
@@ -92,4 +92,13 @@ static inline void * bl_get_data(struct backlight_device *bl_dev) | |||
92 | return dev_get_drvdata(&bl_dev->dev); | 92 | return dev_get_drvdata(&bl_dev->dev); |
93 | } | 93 | } |
94 | 94 | ||
95 | struct generic_bl_info { | ||
96 | const char *name; | ||
97 | int max_intensity; | ||
98 | int default_intensity; | ||
99 | int limit_mask; | ||
100 | void (*set_bl_intensity)(int intensity); | ||
101 | void (*kick_battery)(void); | ||
102 | }; | ||
103 | |||
95 | #endif | 104 | #endif |