diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-01-08 15:52:37 -0500 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-01-08 15:52:37 -0500 |
commit | d00ba726725c6f41e43df00f83e484ba8f9fac5c (patch) | |
tree | 1f8db4a4091da667c7fa8d328d2ad0d9fb9a89ab /drivers/video | |
parent | f4f6bda00fc6bf995a35d8246db45aacaa9b3f09 (diff) |
backlight: Rename the corgi backlight driver to generic
The corgi backlight driver is really generic code. This rename makes
this a lot clearer and completes the partial rename made a while ago.
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/Kconfig | 11 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 2 | ||||
-rw-r--r-- | drivers/video/backlight/corgi_bl.c | 148 | ||||
-rw-r--r-- | drivers/video/backlight/generic_bl.c | 147 |
4 files changed, 152 insertions, 156 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 7ee2313ed6b8..72facb9eb7db 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -123,17 +123,14 @@ config BACKLIGHT_ATMEL_PWM | |||
123 | To compile this driver as a module, choose M here: the module will be | 123 | To compile this driver as a module, choose M here: the module will be |
124 | called atmel-pwm-bl. | 124 | called atmel-pwm-bl. |
125 | 125 | ||
126 | config BACKLIGHT_CORGI | 126 | config BACKLIGHT_GENERIC |
127 | tristate "Generic (aka Sharp Corgi) Backlight Driver (DEPRECATED)" | 127 | tristate "Generic (aka Sharp Corgi) Backlight Driver" |
128 | depends on BACKLIGHT_CLASS_DEVICE | 128 | depends on BACKLIGHT_CLASS_DEVICE |
129 | default n | 129 | default y |
130 | help | 130 | help |
131 | Say y to enable the generic platform backlight driver previously | 131 | Say y to enable the generic platform backlight driver previously |
132 | known as the Corgi backlight driver. If you have a Sharp Zaurus | 132 | known as the Corgi backlight driver. If you have a Sharp Zaurus |
133 | SL-C7xx, SL-Cxx00 or SL-6000x say y. Most users can say n. | 133 | SL-C7xx, SL-Cxx00 or SL-6000x say y. |
134 | |||
135 | Note: this driver is marked as deprecated, try enable SPI and | ||
136 | use the new corgi_lcd driver with integrated backlight control | ||
137 | 134 | ||
138 | config BACKLIGHT_LOCOMO | 135 | config BACKLIGHT_LOCOMO |
139 | tristate "Sharp LOCOMO LCD/Backlight Driver" | 136 | tristate "Sharp LOCOMO LCD/Backlight Driver" |
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 103427de6703..363b3cb2f01b 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -11,7 +11,7 @@ obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o | |||
11 | 11 | ||
12 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o | 12 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o |
13 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o | 13 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o |
14 | obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o | 14 | obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o |
15 | obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o | 15 | obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o |
16 | obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o | 16 | obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o |
17 | obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o | 17 | obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o |
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c deleted file mode 100644 index c6abf51ee3e0..000000000000 --- a/drivers/video/backlight/corgi_bl.c +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | /* | ||
2 | * Backlight Driver for Sharp Zaurus Handhelds (various models) | ||
3 | * | ||
4 | * Copyright (c) 2004-2006 Richard Purdie | ||
5 | * | ||
6 | * Based on Sharp's 2.4 Backlight Driver | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/mutex.h> | ||
19 | #include <linux/fb.h> | ||
20 | #include <linux/backlight.h> | ||
21 | |||
22 | static int corgibl_intensity; | ||
23 | static struct backlight_properties corgibl_data; | ||
24 | static struct backlight_device *corgi_backlight_device; | ||
25 | static struct generic_bl_info *bl_machinfo; | ||
26 | |||
27 | /* Flag to signal when the battery is low */ | ||
28 | #define CORGIBL_BATTLOW BL_CORE_DRIVER1 | ||
29 | |||
30 | static int corgibl_send_intensity(struct backlight_device *bd) | ||
31 | { | ||
32 | int intensity = bd->props.brightness; | ||
33 | |||
34 | if (bd->props.power != FB_BLANK_UNBLANK) | ||
35 | intensity = 0; | ||
36 | if (bd->props.state & BL_CORE_FBBLANK) | ||
37 | intensity = 0; | ||
38 | if (bd->props.state & BL_CORE_SUSPENDED) | ||
39 | intensity = 0; | ||
40 | if (bd->props.state & CORGIBL_BATTLOW) | ||
41 | intensity &= bl_machinfo->limit_mask; | ||
42 | |||
43 | bl_machinfo->set_bl_intensity(intensity); | ||
44 | |||
45 | corgibl_intensity = intensity; | ||
46 | |||
47 | if (bl_machinfo->kick_battery) | ||
48 | bl_machinfo->kick_battery(); | ||
49 | |||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static int corgibl_get_intensity(struct backlight_device *bd) | ||
54 | { | ||
55 | return corgibl_intensity; | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | * Called when the battery is low to limit the backlight intensity. | ||
60 | * If limit==0 clear any limit, otherwise limit the intensity | ||
61 | */ | ||
62 | void corgibl_limit_intensity(int limit) | ||
63 | { | ||
64 | struct backlight_device *bd = corgi_backlight_device; | ||
65 | |||
66 | mutex_lock(&bd->ops_lock); | ||
67 | if (limit) | ||
68 | bd->props.state |= CORGIBL_BATTLOW; | ||
69 | else | ||
70 | bd->props.state &= ~CORGIBL_BATTLOW; | ||
71 | backlight_update_status(corgi_backlight_device); | ||
72 | mutex_unlock(&bd->ops_lock); | ||
73 | } | ||
74 | EXPORT_SYMBOL(corgibl_limit_intensity); | ||
75 | |||
76 | |||
77 | static struct backlight_ops corgibl_ops = { | ||
78 | .options = BL_CORE_SUSPENDRESUME, | ||
79 | .get_brightness = corgibl_get_intensity, | ||
80 | .update_status = corgibl_send_intensity, | ||
81 | }; | ||
82 | |||
83 | static int corgibl_probe(struct platform_device *pdev) | ||
84 | { | ||
85 | struct generic_bl_info *machinfo = pdev->dev.platform_data; | ||
86 | const char *name = "generic-bl"; | ||
87 | |||
88 | bl_machinfo = machinfo; | ||
89 | if (!machinfo->limit_mask) | ||
90 | machinfo->limit_mask = -1; | ||
91 | |||
92 | if (machinfo->name) | ||
93 | name = machinfo->name; | ||
94 | |||
95 | corgi_backlight_device = backlight_device_register (name, | ||
96 | &pdev->dev, NULL, &corgibl_ops); | ||
97 | if (IS_ERR (corgi_backlight_device)) | ||
98 | return PTR_ERR (corgi_backlight_device); | ||
99 | |||
100 | platform_set_drvdata(pdev, corgi_backlight_device); | ||
101 | |||
102 | corgi_backlight_device->props.max_brightness = machinfo->max_intensity; | ||
103 | corgi_backlight_device->props.power = FB_BLANK_UNBLANK; | ||
104 | corgi_backlight_device->props.brightness = machinfo->default_intensity; | ||
105 | backlight_update_status(corgi_backlight_device); | ||
106 | |||
107 | printk("Corgi Backlight Driver Initialized.\n"); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static int corgibl_remove(struct platform_device *pdev) | ||
112 | { | ||
113 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
114 | |||
115 | corgibl_data.power = 0; | ||
116 | corgibl_data.brightness = 0; | ||
117 | backlight_update_status(bd); | ||
118 | |||
119 | backlight_device_unregister(bd); | ||
120 | |||
121 | printk("Corgi Backlight Driver Unloaded\n"); | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | static struct platform_driver corgibl_driver = { | ||
126 | .probe = corgibl_probe, | ||
127 | .remove = corgibl_remove, | ||
128 | .driver = { | ||
129 | .name = "generic-bl", | ||
130 | }, | ||
131 | }; | ||
132 | |||
133 | static int __init corgibl_init(void) | ||
134 | { | ||
135 | return platform_driver_register(&corgibl_driver); | ||
136 | } | ||
137 | |||
138 | static void __exit corgibl_exit(void) | ||
139 | { | ||
140 | platform_driver_unregister(&corgibl_driver); | ||
141 | } | ||
142 | |||
143 | module_init(corgibl_init); | ||
144 | module_exit(corgibl_exit); | ||
145 | |||
146 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | ||
147 | MODULE_DESCRIPTION("Corgi Backlight Driver"); | ||
148 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c new file mode 100644 index 000000000000..6d27f62fdcd0 --- /dev/null +++ b/drivers/video/backlight/generic_bl.c | |||
@@ -0,0 +1,147 @@ | |||
1 | /* | ||
2 | * Generic Backlight Driver | ||
3 | * | ||
4 | * Copyright (c) 2004-2008 Richard Purdie | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/mutex.h> | ||
17 | #include <linux/fb.h> | ||
18 | #include <linux/backlight.h> | ||
19 | |||
20 | static int genericbl_intensity; | ||
21 | static struct backlight_device *generic_backlight_device; | ||
22 | static struct generic_bl_info *bl_machinfo; | ||
23 | |||
24 | /* Flag to signal when the battery is low */ | ||
25 | #define GENERICBL_BATTLOW BL_CORE_DRIVER1 | ||
26 | |||
27 | static int genericbl_send_intensity(struct backlight_device *bd) | ||
28 | { | ||
29 | int intensity = bd->props.brightness; | ||
30 | |||
31 | if (bd->props.power != FB_BLANK_UNBLANK) | ||
32 | intensity = 0; | ||
33 | if (bd->props.state & BL_CORE_FBBLANK) | ||
34 | intensity = 0; | ||
35 | if (bd->props.state & BL_CORE_SUSPENDED) | ||
36 | intensity = 0; | ||
37 | if (bd->props.state & GENERICBL_BATTLOW) | ||
38 | intensity &= bl_machinfo->limit_mask; | ||
39 | |||
40 | bl_machinfo->set_bl_intensity(intensity); | ||
41 | |||
42 | genericbl_intensity = intensity; | ||
43 | |||
44 | if (bl_machinfo->kick_battery) | ||
45 | bl_machinfo->kick_battery(); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static int genericbl_get_intensity(struct backlight_device *bd) | ||
51 | { | ||
52 | return genericbl_intensity; | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * Called when the battery is low to limit the backlight intensity. | ||
57 | * If limit==0 clear any limit, otherwise limit the intensity | ||
58 | */ | ||
59 | void corgibl_limit_intensity(int limit) | ||
60 | { | ||
61 | struct backlight_device *bd = generic_backlight_device; | ||
62 | |||
63 | mutex_lock(&bd->ops_lock); | ||
64 | if (limit) | ||
65 | bd->props.state |= GENERICBL_BATTLOW; | ||
66 | else | ||
67 | bd->props.state &= ~GENERICBL_BATTLOW; | ||
68 | backlight_update_status(generic_backlight_device); | ||
69 | mutex_unlock(&bd->ops_lock); | ||
70 | } | ||
71 | EXPORT_SYMBOL(corgibl_limit_intensity); | ||
72 | |||
73 | static struct backlight_ops genericbl_ops = { | ||
74 | .options = BL_CORE_SUSPENDRESUME, | ||
75 | .get_brightness = genericbl_get_intensity, | ||
76 | .update_status = genericbl_send_intensity, | ||
77 | }; | ||
78 | |||
79 | static int genericbl_probe(struct platform_device *pdev) | ||
80 | { | ||
81 | struct generic_bl_info *machinfo = pdev->dev.platform_data; | ||
82 | const char *name = "generic-bl"; | ||
83 | struct backlight_device *bd; | ||
84 | |||
85 | bl_machinfo = machinfo; | ||
86 | if (!machinfo->limit_mask) | ||
87 | machinfo->limit_mask = -1; | ||
88 | |||
89 | if (machinfo->name) | ||
90 | name = machinfo->name; | ||
91 | |||
92 | bd = backlight_device_register (name, | ||
93 | &pdev->dev, NULL, &genericbl_ops); | ||
94 | if (IS_ERR (bd)) | ||
95 | return PTR_ERR (bd); | ||
96 | |||
97 | platform_set_drvdata(pdev, bd); | ||
98 | |||
99 | bd->props.max_brightness = machinfo->max_intensity; | ||
100 | bd->props.power = FB_BLANK_UNBLANK; | ||
101 | bd->props.brightness = machinfo->default_intensity; | ||
102 | backlight_update_status(bd); | ||
103 | |||
104 | generic_backlight_device = bd; | ||
105 | |||
106 | printk("Generic Backlight Driver Initialized.\n"); | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static int genericbl_remove(struct platform_device *pdev) | ||
111 | { | ||
112 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
113 | |||
114 | bd->props.power = 0; | ||
115 | bd->props.brightness = 0; | ||
116 | backlight_update_status(bd); | ||
117 | |||
118 | backlight_device_unregister(bd); | ||
119 | |||
120 | printk("Generic Backlight Driver Unloaded\n"); | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static struct platform_driver genericbl_driver = { | ||
125 | .probe = genericbl_probe, | ||
126 | .remove = genericbl_remove, | ||
127 | .driver = { | ||
128 | .name = "generic-bl", | ||
129 | }, | ||
130 | }; | ||
131 | |||
132 | static int __init genericbl_init(void) | ||
133 | { | ||
134 | return platform_driver_register(&genericbl_driver); | ||
135 | } | ||
136 | |||
137 | static void __exit genericbl_exit(void) | ||
138 | { | ||
139 | platform_driver_unregister(&genericbl_driver); | ||
140 | } | ||
141 | |||
142 | module_init(genericbl_init); | ||
143 | module_exit(genericbl_exit); | ||
144 | |||
145 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | ||
146 | MODULE_DESCRIPTION("Generic Backlight Driver"); | ||
147 | MODULE_LICENSE("GPL"); | ||