aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-01-06 16:00:19 -0500
committerRichard Purdie <rpurdie@linux.intel.com>2009-01-08 10:37:43 -0500
commitc835ee7f4154992e6cf0674d7ee136f5d36247a4 (patch)
treee886aecbf4ce1389ca649a20891315499ff9054d /drivers/video/backlight
parent9be1df98bca44dbe3769cd22f4ab8122b76c5313 (diff)
backlight: Add suspend/resume support to the backlight core
Add suspend/resume support to the backlight core and enable use of it by appropriate drivers. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r--drivers/video/backlight/backlight.c34
-rw-r--r--drivers/video/backlight/corgi_bl.c45
-rw-r--r--drivers/video/backlight/mbp_nvidia_bl.c1
3 files changed, 47 insertions, 33 deletions
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index a9c013bb9f20..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);
@@ -165,6 +169,34 @@ static ssize_t backlight_show_actual_brightness(struct device *dev,
165 169
166static struct class *backlight_class; 170static struct class *backlight_class;
167 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
168static void bl_device_release(struct device *dev) 200static void bl_device_release(struct device *dev)
169{ 201{
170 struct backlight_device *bd = to_backlight_device(dev); 202 struct backlight_device *bd = to_backlight_device(dev);
@@ -281,6 +313,8 @@ static int __init backlight_class_init(void)
281 } 313 }
282 314
283 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;
284 return 0; 318 return 0;
285} 319}
286 320
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index 4d4d037e3ec9..c6abf51ee3e0 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -24,9 +24,8 @@ static struct backlight_properties corgibl_data;
24static struct backlight_device *corgi_backlight_device; 24static struct backlight_device *corgi_backlight_device;
25static struct generic_bl_info *bl_machinfo; 25static struct generic_bl_info *bl_machinfo;
26 26
27static unsigned long corgibl_flags; 27/* Flag to signal when the battery is low */
28#define CORGIBL_SUSPENDED 0x01 28#define CORGIBL_BATTLOW BL_CORE_DRIVER1
29#define CORGIBL_BATTLOW 0x02
30 29
31static int corgibl_send_intensity(struct backlight_device *bd) 30static int corgibl_send_intensity(struct backlight_device *bd)
32{ 31{
@@ -34,11 +33,11 @@ static int corgibl_send_intensity(struct backlight_device *bd)
34 33
35 if (bd->props.power != FB_BLANK_UNBLANK) 34 if (bd->props.power != FB_BLANK_UNBLANK)
36 intensity = 0; 35 intensity = 0;
37 if (bd->props.fb_blank != FB_BLANK_UNBLANK) 36 if (bd->props.state & BL_CORE_FBBLANK)
38 intensity = 0; 37 intensity = 0;
39 if (corgibl_flags & CORGIBL_SUSPENDED) 38 if (bd->props.state & BL_CORE_SUSPENDED)
40 intensity = 0; 39 intensity = 0;
41 if (corgibl_flags & CORGIBL_BATTLOW) 40 if (bd->props.state & CORGIBL_BATTLOW)
42 intensity &= bl_machinfo->limit_mask; 41 intensity &= bl_machinfo->limit_mask;
43 42
44 bl_machinfo->set_bl_intensity(intensity); 43 bl_machinfo->set_bl_intensity(intensity);
@@ -51,29 +50,6 @@ static int corgibl_send_intensity(struct backlight_device *bd)
51 return 0; 50 return 0;
52} 51}
53 52
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) 53static int corgibl_get_intensity(struct backlight_device *bd)
78{ 54{
79 return corgibl_intensity; 55 return corgibl_intensity;
@@ -85,16 +61,21 @@ static int corgibl_get_intensity(struct backlight_device *bd)
85 */ 61 */
86void corgibl_limit_intensity(int limit) 62void corgibl_limit_intensity(int limit)
87{ 63{
64 struct backlight_device *bd = corgi_backlight_device;
65
66 mutex_lock(&bd->ops_lock);
88 if (limit) 67 if (limit)
89 corgibl_flags |= CORGIBL_BATTLOW; 68 bd->props.state |= CORGIBL_BATTLOW;
90 else 69 else
91 corgibl_flags &= ~CORGIBL_BATTLOW; 70 bd->props.state &= ~CORGIBL_BATTLOW;
92 backlight_update_status(corgi_backlight_device); 71 backlight_update_status(corgi_backlight_device);
72 mutex_unlock(&bd->ops_lock);
93} 73}
94EXPORT_SYMBOL(corgibl_limit_intensity); 74EXPORT_SYMBOL(corgibl_limit_intensity);
95 75
96 76
97static struct backlight_ops corgibl_ops = { 77static struct backlight_ops corgibl_ops = {
78 .options = BL_CORE_SUSPENDRESUME,
98 .get_brightness = corgibl_get_intensity, 79 .get_brightness = corgibl_get_intensity,
99 .update_status = corgibl_send_intensity, 80 .update_status = corgibl_send_intensity,
100}; 81};
@@ -144,8 +125,6 @@ static int corgibl_remove(struct platform_device *pdev)
144static struct platform_driver corgibl_driver = { 125static struct platform_driver corgibl_driver = {
145 .probe = corgibl_probe, 126 .probe = corgibl_probe,
146 .remove = corgibl_remove, 127 .remove = corgibl_remove,
147 .suspend = corgibl_suspend,
148 .resume = corgibl_resume,
149 .driver = { 128 .driver = {
150 .name = "generic-bl", 129 .name = "generic-bl",
151 }, 130 },
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};