diff options
Diffstat (limited to 'drivers/video/backlight/corgi_bl.c')
-rw-r--r-- | drivers/video/backlight/corgi_bl.c | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c index 4d4d037e3ec..c6abf51ee3e 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; | |||
24 | static struct backlight_device *corgi_backlight_device; | 24 | static struct backlight_device *corgi_backlight_device; |
25 | static struct generic_bl_info *bl_machinfo; | 25 | static struct generic_bl_info *bl_machinfo; |
26 | 26 | ||
27 | static 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 | ||
31 | static int corgibl_send_intensity(struct backlight_device *bd) | 30 | static 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 | ||
55 | static 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 | |||
64 | static 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 | |||
77 | static int corgibl_get_intensity(struct backlight_device *bd) | 53 | static 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 | */ |
86 | void corgibl_limit_intensity(int limit) | 62 | void 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 | } |
94 | EXPORT_SYMBOL(corgibl_limit_intensity); | 74 | EXPORT_SYMBOL(corgibl_limit_intensity); |
95 | 75 | ||
96 | 76 | ||
97 | static struct backlight_ops corgibl_ops = { | 77 | static 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) | |||
144 | static struct platform_driver corgibl_driver = { | 125 | static 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 | }, |