aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-01-09 16:55:13 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-09 16:55:13 -0500
commitb64dc5a4842c3420d7a093bf5e8979c57ceb789c (patch)
tree48978026f68d6153716df66d77d4eccfadf5e2ee /drivers/video
parent73d59314e6ed268d6f322ae1bdd723b23fa5a4ed (diff)
parentd00ba726725c6f41e43df00f83e484ba8f9fac5c (diff)
Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight
* 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight: backlight: Rename the corgi backlight driver to generic backlight: add support for Toppoly TDO35S series to tdo24m lcd driver backlight: Add suspend/resume support to the backlight core bd->props.brightness doesn't reflect the actual backlight level. backlight: Support VGA/QVGA mode switching in tosa_lcd backlight: Catch invalid input in sysfs attributes backlight: Value of ILI9320_RGB_IF2 register should not be hardcoded backlight: crbllcd_bl - Use platform_device_register_simple() backlight: progear_bl - Use platform_device_register_simple() backlight: hp680_bl - Use platform_device_register_simple()
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/backlight/Kconfig15
-rw-r--r--drivers/video/backlight/Makefile2
-rw-r--r--drivers/video/backlight/backlight.c73
-rw-r--r--drivers/video/backlight/corgi_bl.c169
-rw-r--r--drivers/video/backlight/cr_bllcd.c18
-rw-r--r--drivers/video/backlight/generic_bl.c147
-rw-r--r--drivers/video/backlight/hp680_bl.c20
-rw-r--r--drivers/video/backlight/mbp_nvidia_bl.c1
-rw-r--r--drivers/video/backlight/progear_bl.c20
-rw-r--r--drivers/video/backlight/tdo24m.c94
-rw-r--r--drivers/video/backlight/tosa_lcd.c27
-rw-r--r--drivers/video/backlight/vgg2432a4.c2
12 files changed, 341 insertions, 247 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 4a4dd9adc328..72facb9eb7db 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -52,11 +52,11 @@ config LCD_ILI9320
52 then say y to include a power driver for it. 52 then say y to include a power driver for it.
53 53
54config LCD_TDO24M 54config LCD_TDO24M
55 tristate "Toppoly TDO24M LCD Panels support" 55 tristate "Toppoly TDO24M and TDO35S LCD Panels support"
56 depends on LCD_CLASS_DEVICE && SPI_MASTER 56 depends on LCD_CLASS_DEVICE && SPI_MASTER
57 default n 57 default n
58 help 58 help
59 If you have a Toppoly TDO24M series LCD panel, say y here to 59 If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to
60 include the support for it. 60 include the support for it.
61 61
62config LCD_VGG2432A4 62config LCD_VGG2432A4
@@ -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
126config BACKLIGHT_CORGI 126config 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
138config BACKLIGHT_LOCOMO 135config 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
12obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o 12obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
13obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o 13obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o
14obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o 14obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o
15obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o 15obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
16obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o 16obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
17obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o 17obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 0664fc032235..157057c79ca3 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -40,6 +40,10 @@ static int fb_notifier_callback(struct notifier_block *self,
40 if (!bd->ops->check_fb || 40 if (!bd->ops->check_fb ||
41 bd->ops->check_fb(evdata->info)) { 41 bd->ops->check_fb(evdata->info)) {
42 bd->props.fb_blank = *(int *)evdata->data; 42 bd->props.fb_blank = *(int *)evdata->data;
43 if (bd->props.fb_blank == FB_BLANK_UNBLANK)
44 bd->props.state &= ~BL_CORE_FBBLANK;
45 else
46 bd->props.state |= BL_CORE_FBBLANK;
43 backlight_update_status(bd); 47 backlight_update_status(bd);
44 } 48 }
45 mutex_unlock(&bd->ops_lock); 49 mutex_unlock(&bd->ops_lock);
@@ -80,20 +84,18 @@ static ssize_t backlight_show_power(struct device *dev,
80static ssize_t backlight_store_power(struct device *dev, 84static ssize_t backlight_store_power(struct device *dev,
81 struct device_attribute *attr, const char *buf, size_t count) 85 struct device_attribute *attr, const char *buf, size_t count)
82{ 86{
83 int rc = -ENXIO; 87 int rc;
84 char *endp;
85 struct backlight_device *bd = to_backlight_device(dev); 88 struct backlight_device *bd = to_backlight_device(dev);
86 int power = simple_strtoul(buf, &endp, 0); 89 unsigned long power;
87 size_t size = endp - buf;
88 90
89 if (*endp && isspace(*endp)) 91 rc = strict_strtoul(buf, 0, &power);
90 size++; 92 if (rc)
91 if (size != count) 93 return rc;
92 return -EINVAL;
93 94
95 rc = -ENXIO;
94 mutex_lock(&bd->ops_lock); 96 mutex_lock(&bd->ops_lock);
95 if (bd->ops) { 97 if (bd->ops) {
96 pr_debug("backlight: set power to %d\n", power); 98 pr_debug("backlight: set power to %lu\n", power);
97 if (bd->props.power != power) { 99 if (bd->props.power != power) {
98 bd->props.power = power; 100 bd->props.power = power;
99 backlight_update_status(bd); 101 backlight_update_status(bd);
@@ -116,28 +118,25 @@ static ssize_t backlight_show_brightness(struct device *dev,
116static ssize_t backlight_store_brightness(struct device *dev, 118static ssize_t backlight_store_brightness(struct device *dev,
117 struct device_attribute *attr, const char *buf, size_t count) 119 struct device_attribute *attr, const char *buf, size_t count)
118{ 120{
119 int rc = -ENXIO; 121 int rc;
120 char *endp;
121 struct backlight_device *bd = to_backlight_device(dev); 122 struct backlight_device *bd = to_backlight_device(dev);
122 int brightness = simple_strtoul(buf, &endp, 0); 123 unsigned long brightness;
123 size_t size = endp - buf; 124
125 rc = strict_strtoul(buf, 0, &brightness);
126 if (rc)
127 return rc;
124 128
125 if (*endp && isspace(*endp)) 129 rc = -ENXIO;
126 size++;
127 if (size != count)
128 return -EINVAL;
129 130
130 mutex_lock(&bd->ops_lock); 131 mutex_lock(&bd->ops_lock);
131 if (bd->ops) { 132 if (bd->ops) {
132 if (brightness > bd->props.max_brightness) 133 if (brightness > bd->props.max_brightness)
133 rc = -EINVAL; 134 rc = -EINVAL;
134 else { 135 else {
135 pr_debug("backlight: set brightness to %d\n", 136 pr_debug("backlight: set brightness to %lu\n",
136 brightness); 137 brightness);
137 if (bd->props.brightness != brightness) { 138 bd->props.brightness = brightness;
138 bd->props.brightness = brightness; 139 backlight_update_status(bd);
139 backlight_update_status(bd);
140 }
141 rc = count; 140 rc = count;
142 } 141 }
143 } 142 }
@@ -170,6 +169,34 @@ static ssize_t backlight_show_actual_brightness(struct device *dev,
170 169
171static struct class *backlight_class; 170static struct class *backlight_class;
172 171
172static int backlight_suspend(struct device *dev, pm_message_t state)
173{
174 struct backlight_device *bd = to_backlight_device(dev);
175
176 if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
177 mutex_lock(&bd->ops_lock);
178 bd->props.state |= BL_CORE_SUSPENDED;
179 backlight_update_status(bd);
180 mutex_unlock(&bd->ops_lock);
181 }
182
183 return 0;
184}
185
186static int backlight_resume(struct device *dev)
187{
188 struct backlight_device *bd = to_backlight_device(dev);
189
190 if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
191 mutex_lock(&bd->ops_lock);
192 bd->props.state &= ~BL_CORE_SUSPENDED;
193 backlight_update_status(bd);
194 mutex_unlock(&bd->ops_lock);
195 }
196
197 return 0;
198}
199
173static void bl_device_release(struct device *dev) 200static void bl_device_release(struct device *dev)
174{ 201{
175 struct backlight_device *bd = to_backlight_device(dev); 202 struct backlight_device *bd = to_backlight_device(dev);
@@ -286,6 +313,8 @@ static int __init backlight_class_init(void)
286 } 313 }
287 314
288 backlight_class->dev_attrs = bl_device_attributes; 315 backlight_class->dev_attrs = bl_device_attributes;
316 backlight_class->suspend = backlight_suspend;
317 backlight_class->resume = backlight_resume;
289 return 0; 318 return 0;
290} 319}
291 320
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
deleted file mode 100644
index 4d4d037e3ec9..000000000000
--- a/drivers/video/backlight/corgi_bl.c
+++ /dev/null
@@ -1,169 +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
22static int corgibl_intensity;
23static struct backlight_properties corgibl_data;
24static struct backlight_device *corgi_backlight_device;
25static struct generic_bl_info *bl_machinfo;
26
27static unsigned long corgibl_flags;
28#define CORGIBL_SUSPENDED 0x01
29#define CORGIBL_BATTLOW 0x02
30
31static int corgibl_send_intensity(struct backlight_device *bd)
32{
33 int intensity = bd->props.brightness;
34
35 if (bd->props.power != FB_BLANK_UNBLANK)
36 intensity = 0;
37 if (bd->props.fb_blank != FB_BLANK_UNBLANK)
38 intensity = 0;
39 if (corgibl_flags & CORGIBL_SUSPENDED)
40 intensity = 0;
41 if (corgibl_flags & CORGIBL_BATTLOW)
42 intensity &= bl_machinfo->limit_mask;
43
44 bl_machinfo->set_bl_intensity(intensity);
45
46 corgibl_intensity = intensity;
47
48 if (bl_machinfo->kick_battery)
49 bl_machinfo->kick_battery();
50
51 return 0;
52}
53
54#ifdef CONFIG_PM
55static int corgibl_suspend(struct platform_device *pdev, pm_message_t state)
56{
57 struct backlight_device *bd = platform_get_drvdata(pdev);
58
59 corgibl_flags |= CORGIBL_SUSPENDED;
60 backlight_update_status(bd);
61 return 0;
62}
63
64static int corgibl_resume(struct platform_device *pdev)
65{
66 struct backlight_device *bd = platform_get_drvdata(pdev);
67
68 corgibl_flags &= ~CORGIBL_SUSPENDED;
69 backlight_update_status(bd);
70 return 0;
71}
72#else
73#define corgibl_suspend NULL
74#define corgibl_resume NULL
75#endif
76
77static int corgibl_get_intensity(struct backlight_device *bd)
78{
79 return corgibl_intensity;
80}
81
82/*
83 * Called when the battery is low to limit the backlight intensity.
84 * If limit==0 clear any limit, otherwise limit the intensity
85 */
86void corgibl_limit_intensity(int limit)
87{
88 if (limit)
89 corgibl_flags |= CORGIBL_BATTLOW;
90 else
91 corgibl_flags &= ~CORGIBL_BATTLOW;
92 backlight_update_status(corgi_backlight_device);
93}
94EXPORT_SYMBOL(corgibl_limit_intensity);
95
96
97static struct backlight_ops corgibl_ops = {
98 .get_brightness = corgibl_get_intensity,
99 .update_status = corgibl_send_intensity,
100};
101
102static int corgibl_probe(struct platform_device *pdev)
103{
104 struct generic_bl_info *machinfo = pdev->dev.platform_data;
105 const char *name = "generic-bl";
106
107 bl_machinfo = machinfo;
108 if (!machinfo->limit_mask)
109 machinfo->limit_mask = -1;
110
111 if (machinfo->name)
112 name = machinfo->name;
113
114 corgi_backlight_device = backlight_device_register (name,
115 &pdev->dev, NULL, &corgibl_ops);
116 if (IS_ERR (corgi_backlight_device))
117 return PTR_ERR (corgi_backlight_device);
118
119 platform_set_drvdata(pdev, corgi_backlight_device);
120
121 corgi_backlight_device->props.max_brightness = machinfo->max_intensity;
122 corgi_backlight_device->props.power = FB_BLANK_UNBLANK;
123 corgi_backlight_device->props.brightness = machinfo->default_intensity;
124 backlight_update_status(corgi_backlight_device);
125
126 printk("Corgi Backlight Driver Initialized.\n");
127 return 0;
128}
129
130static int corgibl_remove(struct platform_device *pdev)
131{
132 struct backlight_device *bd = platform_get_drvdata(pdev);
133
134 corgibl_data.power = 0;
135 corgibl_data.brightness = 0;
136 backlight_update_status(bd);
137
138 backlight_device_unregister(bd);
139
140 printk("Corgi Backlight Driver Unloaded\n");
141 return 0;
142}
143
144static struct platform_driver corgibl_driver = {
145 .probe = corgibl_probe,
146 .remove = corgibl_remove,
147 .suspend = corgibl_suspend,
148 .resume = corgibl_resume,
149 .driver = {
150 .name = "generic-bl",
151 },
152};
153
154static int __init corgibl_init(void)
155{
156 return platform_driver_register(&corgibl_driver);
157}
158
159static void __exit corgibl_exit(void)
160{
161 platform_driver_unregister(&corgibl_driver);
162}
163
164module_init(corgibl_init);
165module_exit(corgibl_exit);
166
167MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
168MODULE_DESCRIPTION("Corgi Backlight Driver");
169MODULE_LICENSE("GPL");
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 26add8898605..b9fe62b475c6 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -259,22 +259,18 @@ static int __init cr_backlight_init(void)
259{ 259{
260 int ret = platform_driver_register(&cr_backlight_driver); 260 int ret = platform_driver_register(&cr_backlight_driver);
261 261
262 if (!ret) { 262 if (ret)
263 crp = platform_device_alloc("cr_backlight", -1); 263 return ret;
264 if (!crp)
265 return -ENOMEM;
266 264
267 ret = platform_device_add(crp); 265 crp = platform_device_register_simple("cr_backlight", -1, NULL, 0);
268 266 if (IS_ERR(crp)) {
269 if (ret) { 267 platform_driver_unregister(&cr_backlight_driver);
270 platform_device_put(crp); 268 return PTR_ERR(crp);
271 platform_driver_unregister(&cr_backlight_driver);
272 }
273 } 269 }
274 270
275 printk("Carillo Ranch Backlight Driver Initialized.\n"); 271 printk("Carillo Ranch Backlight Driver Initialized.\n");
276 272
277 return ret; 273 return 0;
278} 274}
279 275
280static void __exit cr_backlight_exit(void) 276static void __exit cr_backlight_exit(void)
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
20static int genericbl_intensity;
21static struct backlight_device *generic_backlight_device;
22static struct generic_bl_info *bl_machinfo;
23
24/* Flag to signal when the battery is low */
25#define GENERICBL_BATTLOW BL_CORE_DRIVER1
26
27static 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
50static 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 */
59void 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}
71EXPORT_SYMBOL(corgibl_limit_intensity);
72
73static struct backlight_ops genericbl_ops = {
74 .options = BL_CORE_SUSPENDRESUME,
75 .get_brightness = genericbl_get_intensity,
76 .update_status = genericbl_send_intensity,
77};
78
79static 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
110static 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
124static struct platform_driver genericbl_driver = {
125 .probe = genericbl_probe,
126 .remove = genericbl_remove,
127 .driver = {
128 .name = "generic-bl",
129 },
130};
131
132static int __init genericbl_init(void)
133{
134 return platform_driver_register(&genericbl_driver);
135}
136
137static void __exit genericbl_exit(void)
138{
139 platform_driver_unregister(&genericbl_driver);
140}
141
142module_init(genericbl_init);
143module_exit(genericbl_exit);
144
145MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
146MODULE_DESCRIPTION("Generic Backlight Driver");
147MODULE_LICENSE("GPL");
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index d4cfed0b26d5..5be55a20d8c7 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -151,19 +151,15 @@ static int __init hp680bl_init(void)
151 int ret; 151 int ret;
152 152
153 ret = platform_driver_register(&hp680bl_driver); 153 ret = platform_driver_register(&hp680bl_driver);
154 if (!ret) { 154 if (ret)
155 hp680bl_device = platform_device_alloc("hp680-bl", -1); 155 return ret;
156 if (!hp680bl_device) 156 hp680bl_device = platform_device_register_simple("hp680-bl", -1,
157 return -ENOMEM; 157 NULL, 0);
158 158 if (IS_ERR(hp680bl_device)) {
159 ret = platform_device_add(hp680bl_device); 159 platform_driver_unregister(&hp680bl_driver);
160 160 return PTR_ERR(hp680bl_device);
161 if (ret) {
162 platform_device_put(hp680bl_device);
163 platform_driver_unregister(&hp680bl_driver);
164 }
165 } 161 }
166 return ret; 162 return 0;
167} 163}
168 164
169static void __exit hp680bl_exit(void) 165static void __exit hp680bl_exit(void)
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c
index 06964af761c6..65864c500455 100644
--- a/drivers/video/backlight/mbp_nvidia_bl.c
+++ b/drivers/video/backlight/mbp_nvidia_bl.c
@@ -70,6 +70,7 @@ static int mbp_get_intensity(struct backlight_device *bd)
70} 70}
71 71
72static struct backlight_ops mbp_ops = { 72static struct backlight_ops mbp_ops = {
73 .options = BL_CORE_SUSPENDRESUME,
73 .get_brightness = mbp_get_intensity, 74 .get_brightness = mbp_get_intensity,
74 .update_status = mbp_send_intensity, 75 .update_status = mbp_send_intensity,
75}; 76};
diff --git a/drivers/video/backlight/progear_bl.c b/drivers/video/backlight/progear_bl.c
index 15fb4d58b5bc..9edaf24fd82d 100644
--- a/drivers/video/backlight/progear_bl.c
+++ b/drivers/video/backlight/progear_bl.c
@@ -119,20 +119,16 @@ static int __init progearbl_init(void)
119{ 119{
120 int ret = platform_driver_register(&progearbl_driver); 120 int ret = platform_driver_register(&progearbl_driver);
121 121
122 if (!ret) { 122 if (ret)
123 progearbl_device = platform_device_alloc("progear-bl", -1); 123 return ret;
124 if (!progearbl_device) 124 progearbl_device = platform_device_register_simple("progear-bl", -1,
125 return -ENOMEM; 125 NULL, 0);
126 126 if (IS_ERR(progearbl_device)) {
127 ret = platform_device_add(progearbl_device); 127 platform_driver_unregister(&progearbl_driver);
128 128 return PTR_ERR(progearbl_device);
129 if (ret) {
130 platform_device_put(progearbl_device);
131 platform_driver_unregister(&progearbl_driver);
132 }
133 } 129 }
134 130
135 return ret; 131 return 0;
136} 132}
137 133
138static void __exit progearbl_exit(void) 134static void __exit progearbl_exit(void)
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c
index 8427669162ea..1dae7f8f3c6b 100644
--- a/drivers/video/backlight/tdo24m.c
+++ b/drivers/video/backlight/tdo24m.c
@@ -14,6 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
17#include <linux/spi/tdo24m.h>
17#include <linux/fb.h> 18#include <linux/fb.h>
18#include <linux/lcd.h> 19#include <linux/lcd.h>
19 20
@@ -31,6 +32,9 @@ struct tdo24m {
31 struct spi_transfer xfer; 32 struct spi_transfer xfer;
32 uint8_t *buf; 33 uint8_t *buf;
33 34
35 int (*adj_mode)(struct tdo24m *lcd, int mode);
36 int color_invert;
37
34 int power; 38 int power;
35 int mode; 39 int mode;
36}; 40};
@@ -66,7 +70,7 @@ static uint32_t lcd_panel_off[] = {
66 CMD_NULL, 70 CMD_NULL,
67}; 71};
68 72
69static uint32_t lcd_vga_pass_through[] = { 73static uint32_t lcd_vga_pass_through_tdo24m[] = {
70 CMD1(0xB0, 0x16), 74 CMD1(0xB0, 0x16),
71 CMD1(0xBC, 0x80), 75 CMD1(0xBC, 0x80),
72 CMD1(0xE1, 0x00), 76 CMD1(0xE1, 0x00),
@@ -75,7 +79,7 @@ static uint32_t lcd_vga_pass_through[] = {
75 CMD_NULL, 79 CMD_NULL,
76}; 80};
77 81
78static uint32_t lcd_qvga_pass_through[] = { 82static uint32_t lcd_qvga_pass_through_tdo24m[] = {
79 CMD1(0xB0, 0x16), 83 CMD1(0xB0, 0x16),
80 CMD1(0xBC, 0x81), 84 CMD1(0xBC, 0x81),
81 CMD1(0xE1, 0x00), 85 CMD1(0xE1, 0x00),
@@ -84,7 +88,7 @@ static uint32_t lcd_qvga_pass_through[] = {
84 CMD_NULL, 88 CMD_NULL,
85}; 89};
86 90
87static uint32_t lcd_vga_transfer[] = { 91static uint32_t lcd_vga_transfer_tdo24m[] = {
88 CMD1(0xcf, 0x02), /* Blanking period control (1) */ 92 CMD1(0xcf, 0x02), /* Blanking period control (1) */
89 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */ 93 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
90 CMD1(0xd1, 0x01), /* CKV timing control on/off */ 94 CMD1(0xd1, 0x01), /* CKV timing control on/off */
@@ -110,6 +114,35 @@ static uint32_t lcd_qvga_transfer[] = {
110 CMD_NULL, 114 CMD_NULL,
111}; 115};
112 116
117static uint32_t lcd_vga_pass_through_tdo35s[] = {
118 CMD1(0xB0, 0x16),
119 CMD1(0xBC, 0x80),
120 CMD1(0xE1, 0x00),
121 CMD1(0x3B, 0x00),
122 CMD_NULL,
123};
124
125static uint32_t lcd_qvga_pass_through_tdo35s[] = {
126 CMD1(0xB0, 0x16),
127 CMD1(0xBC, 0x81),
128 CMD1(0xE1, 0x00),
129 CMD1(0x3B, 0x22),
130 CMD_NULL,
131};
132
133static uint32_t lcd_vga_transfer_tdo35s[] = {
134 CMD1(0xcf, 0x02), /* Blanking period control (1) */
135 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
136 CMD1(0xd1, 0x01), /* CKV timing control on/off */
137 CMD2(0xd2, 0x00, 0x1e), /* CKV 1,2 timing control */
138 CMD2(0xd3, 0x14, 0x28), /* OEV timing control */
139 CMD2(0xd4, 0x28, 0x64), /* ASW timing control (1) */
140 CMD1(0xd5, 0x28), /* ASW timing control (2) */
141 CMD0(0x21), /* Invert for normally black display */
142 CMD0(0x29), /* Display on */
143 CMD_NULL,
144};
145
113static uint32_t lcd_panel_config[] = { 146static uint32_t lcd_panel_config[] = {
114 CMD2(0xb8, 0xff, 0xf9), /* Output control */ 147 CMD2(0xb8, 0xff, 0xf9), /* Output control */
115 CMD0(0x11), /* sleep out */ 148 CMD0(0x11), /* sleep out */
@@ -148,6 +181,8 @@ static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array)
148 int nparams, err = 0; 181 int nparams, err = 0;
149 182
150 for (; *p != CMD_NULL; p++) { 183 for (; *p != CMD_NULL; p++) {
184 if (!lcd->color_invert && *p == CMD0(0x21))
185 continue;
151 186
152 nparams = (*p >> 30) & 0x3; 187 nparams = (*p >> 30) & 0x3;
153 188
@@ -184,12 +219,33 @@ static int tdo24m_adj_mode(struct tdo24m *lcd, int mode)
184{ 219{
185 switch (mode) { 220 switch (mode) {
186 case MODE_VGA: 221 case MODE_VGA:
187 tdo24m_writes(lcd, lcd_vga_pass_through); 222 tdo24m_writes(lcd, lcd_vga_pass_through_tdo24m);
188 tdo24m_writes(lcd, lcd_panel_config); 223 tdo24m_writes(lcd, lcd_panel_config);
189 tdo24m_writes(lcd, lcd_vga_transfer); 224 tdo24m_writes(lcd, lcd_vga_transfer_tdo24m);
190 break; 225 break;
191 case MODE_QVGA: 226 case MODE_QVGA:
192 tdo24m_writes(lcd, lcd_qvga_pass_through); 227 tdo24m_writes(lcd, lcd_qvga_pass_through_tdo24m);
228 tdo24m_writes(lcd, lcd_panel_config);
229 tdo24m_writes(lcd, lcd_qvga_transfer);
230 break;
231 default:
232 return -EINVAL;
233 }
234
235 lcd->mode = mode;
236 return 0;
237}
238
239static int tdo35s_adj_mode(struct tdo24m *lcd, int mode)
240{
241 switch (mode) {
242 case MODE_VGA:
243 tdo24m_writes(lcd, lcd_vga_pass_through_tdo35s);
244 tdo24m_writes(lcd, lcd_panel_config);
245 tdo24m_writes(lcd, lcd_vga_transfer_tdo35s);
246 break;
247 case MODE_QVGA:
248 tdo24m_writes(lcd, lcd_qvga_pass_through_tdo35s);
193 tdo24m_writes(lcd, lcd_panel_config); 249 tdo24m_writes(lcd, lcd_panel_config);
194 tdo24m_writes(lcd, lcd_qvga_transfer); 250 tdo24m_writes(lcd, lcd_qvga_transfer);
195 break; 251 break;
@@ -213,7 +269,7 @@ static int tdo24m_power_on(struct tdo24m *lcd)
213 if (err) 269 if (err)
214 goto out; 270 goto out;
215 271
216 err = tdo24m_adj_mode(lcd, lcd->mode); 272 err = lcd->adj_mode(lcd, lcd->mode);
217out: 273out:
218 return err; 274 return err;
219} 275}
@@ -262,7 +318,7 @@ static int tdo24m_set_mode(struct lcd_device *ld, struct fb_videomode *m)
262 if (lcd->mode == mode) 318 if (lcd->mode == mode)
263 return 0; 319 return 0;
264 320
265 return tdo24m_adj_mode(lcd, mode); 321 return lcd->adj_mode(lcd, mode);
266} 322}
267 323
268static struct lcd_ops tdo24m_ops = { 324static struct lcd_ops tdo24m_ops = {
@@ -276,8 +332,16 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
276 struct tdo24m *lcd; 332 struct tdo24m *lcd;
277 struct spi_message *m; 333 struct spi_message *m;
278 struct spi_transfer *x; 334 struct spi_transfer *x;
335 struct tdo24m_platform_data *pdata;
336 enum tdo24m_model model;
279 int err; 337 int err;
280 338
339 pdata = spi->dev.platform_data;
340 if (pdata)
341 model = pdata->model;
342 else
343 model = TDO24M;
344
281 spi->bits_per_word = 8; 345 spi->bits_per_word = 8;
282 spi->mode = SPI_MODE_3; 346 spi->mode = SPI_MODE_3;
283 err = spi_setup(spi); 347 err = spi_setup(spi);
@@ -306,6 +370,20 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
306 x->tx_buf = &lcd->buf[0]; 370 x->tx_buf = &lcd->buf[0];
307 spi_message_add_tail(x, m); 371 spi_message_add_tail(x, m);
308 372
373 switch (model) {
374 case TDO24M:
375 lcd->color_invert = 1;
376 lcd->adj_mode = tdo24m_adj_mode;
377 break;
378 case TDO35S:
379 lcd->adj_mode = tdo35s_adj_mode;
380 lcd->color_invert = 0;
381 break;
382 default:
383 dev_err(&spi->dev, "Unsupported model");
384 goto out_free;
385 }
386
309 lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, 387 lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev,
310 lcd, &tdo24m_ops); 388 lcd, &tdo24m_ops);
311 if (IS_ERR(lcd->lcd_dev)) { 389 if (IS_ERR(lcd->lcd_dev)) {
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c
index 57a26649f1a5..b7fbc75a62fc 100644
--- a/drivers/video/backlight/tosa_lcd.c
+++ b/drivers/video/backlight/tosa_lcd.c
@@ -39,6 +39,7 @@ struct tosa_lcd_data {
39 struct i2c_client *i2c; 39 struct i2c_client *i2c;
40 40
41 int lcd_power; 41 int lcd_power;
42 bool is_vga;
42}; 43};
43 44
44static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data) 45static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data)
@@ -81,8 +82,12 @@ static void tosa_lcd_tg_init(struct tosa_lcd_data *data)
81static void tosa_lcd_tg_on(struct tosa_lcd_data *data) 82static void tosa_lcd_tg_on(struct tosa_lcd_data *data)
82{ 83{
83 struct spi_device *spi = data->spi; 84 struct spi_device *spi = data->spi;
84 const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR; 85 int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR;
85 tosa_tg_send(spi, TG_PNLCTL, value | TG_REG0_VQV); /* this depends on mode */ 86
87 if (data->is_vga)
88 value |= TG_REG0_VQV;
89
90 tosa_tg_send(spi, TG_PNLCTL, value);
86 91
87 /* TG LCD pannel power up */ 92 /* TG LCD pannel power up */
88 tosa_tg_send(spi, TG_PINICTL,0x4); 93 tosa_tg_send(spi, TG_PINICTL,0x4);
@@ -142,9 +147,25 @@ static int tosa_lcd_get_power(struct lcd_device *lcd)
142 return data->lcd_power; 147 return data->lcd_power;
143} 148}
144 149
150static int tosa_lcd_set_mode(struct lcd_device *lcd, struct fb_videomode *mode)
151{
152 struct tosa_lcd_data *data = lcd_get_data(lcd);
153
154 if (mode->xres == 320 || mode->yres == 320)
155 data->is_vga = false;
156 else
157 data->is_vga = true;
158
159 if (POWER_IS_ON(data->lcd_power))
160 tosa_lcd_tg_on(data);
161
162 return 0;
163}
164
145static struct lcd_ops tosa_lcd_ops = { 165static struct lcd_ops tosa_lcd_ops = {
146 .set_power = tosa_lcd_set_power, 166 .set_power = tosa_lcd_set_power,
147 .get_power = tosa_lcd_get_power, 167 .get_power = tosa_lcd_get_power,
168 .set_mode = tosa_lcd_set_mode,
148}; 169};
149 170
150static int __devinit tosa_lcd_probe(struct spi_device *spi) 171static int __devinit tosa_lcd_probe(struct spi_device *spi)
@@ -156,6 +177,8 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
156 if (!data) 177 if (!data)
157 return -ENOMEM; 178 return -ENOMEM;
158 179
180 data->is_vga = true; /* defaut to VGA mode */
181
159 /* 182 /*
160 * bits_per_word cannot be configured in platform data 183 * bits_per_word cannot be configured in platform data
161 */ 184 */
diff --git a/drivers/video/backlight/vgg2432a4.c b/drivers/video/backlight/vgg2432a4.c
index 593c7687d54a..8e653b8a6f17 100644
--- a/drivers/video/backlight/vgg2432a4.c
+++ b/drivers/video/backlight/vgg2432a4.c
@@ -137,7 +137,7 @@ static int vgg2432a4_lcd_init(struct ili9320 *lcd,
137 137
138 ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1); 138 ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1);
139 ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0); 139 ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0);
140 ili9320_write(lcd, ILI9320_RGB_IF2, ILI9320_RGBIF2_DPL); 140 ili9320_write(lcd, ILI9320_RGB_IF2, cfg->rgb_if2);
141 141
142 ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1)); 142 ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1));
143 if (ret != 0) 143 if (ret != 0)