aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight/lcd.c
diff options
context:
space:
mode:
authorJames Simmons <jsimmons@infradead.org>2006-12-08 05:40:47 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:29:07 -0500
commit3d5eeaddad9338f39d25ee0c6c2ab1eda1ed2ef6 (patch)
treedfb85035f7cc4732e0bf407ec43ff8229ac25dba /drivers/video/backlight/lcd.c
parentb5bd1cec8999624fa2b32833ba9707eb4966df17 (diff)
[PATCH] backlight: lcd: Remove dependenct from the framebuffer layer
The backlight layer should be independent from the framebuffer layer. It can use the services offered by the framebuffer, but its absence should not prevent the backlight/lcd layer from functioning. [akpm@osdl.org: cleanups] Signed-off-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/backlight/lcd.c')
-rw-r--r--drivers/video/backlight/lcd.c78
1 files changed, 49 insertions, 29 deletions
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 58c37d489107..f6e041627edb 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -14,6 +14,53 @@
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/fb.h> 15#include <linux/fb.h>
16 16
17#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
18 defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
19/* This callback gets called when something important happens inside a
20 * framebuffer driver. We're looking if that important event is blanking,
21 * and if it is, we're switching lcd power as well ...
22 */
23static int fb_notifier_callback(struct notifier_block *self,
24 unsigned long event, void *data)
25{
26 struct lcd_device *ld;
27 struct fb_event *evdata = data;
28
29 /* If we aren't interested in this event, skip it immediately ... */
30 if (event != FB_EVENT_BLANK)
31 return 0;
32
33 ld = container_of(self, struct lcd_device, fb_notif);
34 down(&ld->sem);
35 if (ld->props)
36 if (!ld->props->check_fb || ld->props->check_fb(evdata->info))
37 ld->props->set_power(ld, *(int *)evdata->data);
38 up(&ld->sem);
39 return 0;
40}
41
42static int lcd_register_fb(struct lcd_device *ld)
43{
44 memset(&ld->fb_notif, 0, sizeof(&ld->fb_notif));
45 ld->fb_notif.notifier_call = fb_notifier_callback;
46 return fb_register_client(&ld->fb_notif);
47}
48
49static void lcd_unregister_fb(struct lcd_device *ld)
50{
51 fb_unregister_client(&ld->fb_notif);
52}
53#else
54static int lcd_register_fb(struct lcd_device *ld)
55{
56 return 0;
57}
58
59static inline void lcd_unregister_fb(struct lcd_device *ld)
60{
61}
62#endif /* CONFIG_FB */
63
17static ssize_t lcd_show_power(struct class_device *cdev, char *buf) 64static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
18{ 65{
19 int rc; 66 int rc;
@@ -127,29 +174,6 @@ static const struct class_device_attribute lcd_class_device_attributes[] = {
127 DECLARE_ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL), 174 DECLARE_ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
128}; 175};
129 176
130/* This callback gets called when something important happens inside a
131 * framebuffer driver. We're looking if that important event is blanking,
132 * and if it is, we're switching lcd power as well ...
133 */
134static int fb_notifier_callback(struct notifier_block *self,
135 unsigned long event, void *data)
136{
137 struct lcd_device *ld;
138 struct fb_event *evdata =(struct fb_event *)data;
139
140 /* If we aren't interested in this event, skip it immediately ... */
141 if (event != FB_EVENT_BLANK)
142 return 0;
143
144 ld = container_of(self, struct lcd_device, fb_notif);
145 down(&ld->sem);
146 if (ld->props)
147 if (!ld->props->check_fb || ld->props->check_fb(evdata->info))
148 ld->props->set_power(ld, *(int *)evdata->data);
149 up(&ld->sem);
150 return 0;
151}
152
153/** 177/**
154 * lcd_device_register - register a new object of lcd_device class. 178 * lcd_device_register - register a new object of lcd_device class.
155 * @name: the name of the new object(must be the same as the name of the 179 * @name: the name of the new object(must be the same as the name of the
@@ -186,10 +210,8 @@ error: kfree(new_ld);
186 return ERR_PTR(rc); 210 return ERR_PTR(rc);
187 } 211 }
188 212
189 memset(&new_ld->fb_notif, 0, sizeof(new_ld->fb_notif)); 213 rc = lcd_register_fb(new_ld);
190 new_ld->fb_notif.notifier_call = fb_notifier_callback;
191 214
192 rc = fb_register_client(&new_ld->fb_notif);
193 if (unlikely(rc)) 215 if (unlikely(rc))
194 goto error; 216 goto error;
195 217
@@ -232,9 +254,7 @@ void lcd_device_unregister(struct lcd_device *ld)
232 down(&ld->sem); 254 down(&ld->sem);
233 ld->props = NULL; 255 ld->props = NULL;
234 up(&ld->sem); 256 up(&ld->sem);
235 257 lcd_unregister_fb(ld);
236 fb_unregister_client(&ld->fb_notif);
237
238 class_device_unregister(&ld->class_dev); 258 class_device_unregister(&ld->class_dev);
239} 259}
240EXPORT_SYMBOL(lcd_device_unregister); 260EXPORT_SYMBOL(lcd_device_unregister);