diff options
author | Bruno Prémont <bonbons@linux-vserver.org> | 2010-05-02 10:05:05 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-05-03 09:25:52 -0400 |
commit | 9d71ea057bc4823058d8fe27d34e987eb9880457 (patch) | |
tree | 109b3fd4da4b2041fcf93ed6c5392e7913635a3d /drivers/hid/hid-picolcd.c | |
parent | d6d53cbc6b10d28646fb6184d1069f336ec76dc4 (diff) |
HID: add PM support to PicoLCD device
Add PM support in order to turn off backlight on suspend, restore
it on resume and especially restore complete state on reset-resume.
Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-picolcd.c')
-rw-r--r-- | drivers/hid/hid-picolcd.c | 79 |
1 files changed, 74 insertions, 5 deletions
diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c index aa6f2e18d4a6..95253b310541 100644 --- a/drivers/hid/hid-picolcd.c +++ b/drivers/hid/hid-picolcd.c | |||
@@ -763,7 +763,7 @@ static inline int picolcd_init_framebuffer(struct picolcd_data *data) | |||
763 | { | 763 | { |
764 | return 0; | 764 | return 0; |
765 | } | 765 | } |
766 | static void picolcd_exit_framebuffer(struct picolcd_data *data) | 766 | static inline void picolcd_exit_framebuffer(struct picolcd_data *data) |
767 | { | 767 | { |
768 | } | 768 | } |
769 | #define picolcd_fbinfo(d) NULL | 769 | #define picolcd_fbinfo(d) NULL |
@@ -852,6 +852,18 @@ static inline int picolcd_resume_backlight(struct picolcd_data *data) | |||
852 | return picolcd_set_brightness(data->backlight); | 852 | return picolcd_set_brightness(data->backlight); |
853 | } | 853 | } |
854 | 854 | ||
855 | #ifdef CONFIG_PM | ||
856 | static void picolcd_suspend_backlight(struct picolcd_data *data) | ||
857 | { | ||
858 | int bl_power = data->lcd_power; | ||
859 | if (!data->backlight) | ||
860 | return; | ||
861 | |||
862 | data->backlight->props.power = FB_BLANK_POWERDOWN; | ||
863 | picolcd_set_brightness(data->backlight); | ||
864 | data->lcd_power = data->backlight->props.power = bl_power; | ||
865 | } | ||
866 | #endif /* CONFIG_PM */ | ||
855 | #else | 867 | #else |
856 | static inline int picolcd_init_backlight(struct picolcd_data *data, | 868 | static inline int picolcd_init_backlight(struct picolcd_data *data, |
857 | struct hid_report *report) | 869 | struct hid_report *report) |
@@ -865,6 +877,9 @@ static inline int picolcd_resume_backlight(struct picolcd_data *data) | |||
865 | { | 877 | { |
866 | return 0; | 878 | return 0; |
867 | } | 879 | } |
880 | static inline void picolcd_suspend_backlight(struct picolcd_data *data) | ||
881 | { | ||
882 | } | ||
868 | #endif /* CONFIG_HID_PICOLCD_BACKLIGHT */ | 883 | #endif /* CONFIG_HID_PICOLCD_BACKLIGHT */ |
869 | 884 | ||
870 | #ifdef CONFIG_HID_PICOLCD_LCD | 885 | #ifdef CONFIG_HID_PICOLCD_LCD |
@@ -1098,7 +1113,7 @@ static inline int picolcd_init_leds(struct picolcd_data *data, | |||
1098 | { | 1113 | { |
1099 | return 0; | 1114 | return 0; |
1100 | } | 1115 | } |
1101 | static void picolcd_exit_leds(struct picolcd_data *data) | 1116 | static inline void picolcd_exit_leds(struct picolcd_data *data) |
1102 | { | 1117 | { |
1103 | } | 1118 | } |
1104 | static inline int picolcd_leds_set(struct picolcd_data *data) | 1119 | static inline int picolcd_leds_set(struct picolcd_data *data) |
@@ -2214,9 +2229,18 @@ static void picolcd_exit_devfs(struct picolcd_data *data) | |||
2214 | mutex_destroy(&data->mutex_flash); | 2229 | mutex_destroy(&data->mutex_flash); |
2215 | } | 2230 | } |
2216 | #else | 2231 | #else |
2217 | #define picolcd_debug_raw_event(data, hdev, report, raw_data, size) | 2232 | static inline void picolcd_debug_raw_event(struct picolcd_data *data, |
2218 | #define picolcd_init_devfs(data, eeprom_r, eeprom_w, flash_r, flash_w, reset) | 2233 | struct hid_device *hdev, struct hid_report *report, |
2219 | static void picolcd_exit_devfs(struct picolcd_data *data) | 2234 | u8 *raw_data, int size) |
2235 | { | ||
2236 | } | ||
2237 | static inline void picolcd_init_devfs(struct picolcd_data *data, | ||
2238 | struct hid_report *eeprom_r, struct hid_report *eeprom_w, | ||
2239 | struct hid_report *flash_r, struct hid_report *flash_w, | ||
2240 | struct hid_report *reset) | ||
2241 | { | ||
2242 | } | ||
2243 | static inline void picolcd_exit_devfs(struct picolcd_data *data) | ||
2220 | { | 2244 | { |
2221 | } | 2245 | } |
2222 | #endif /* CONFIG_DEBUG_FS */ | 2246 | #endif /* CONFIG_DEBUG_FS */ |
@@ -2259,6 +2283,46 @@ static int picolcd_raw_event(struct hid_device *hdev, | |||
2259 | return 1; | 2283 | return 1; |
2260 | } | 2284 | } |
2261 | 2285 | ||
2286 | #ifdef CONFIG_PM | ||
2287 | static int picolcd_suspend(struct hid_device *hdev, pm_message_t message) | ||
2288 | { | ||
2289 | if (message.event & PM_EVENT_AUTO) | ||
2290 | return 0; | ||
2291 | |||
2292 | picolcd_suspend_backlight(hid_get_drvdata(hdev)); | ||
2293 | dbg_hid(PICOLCD_NAME " device ready for suspend\n"); | ||
2294 | return 0; | ||
2295 | } | ||
2296 | |||
2297 | static int picolcd_resume(struct hid_device *hdev) | ||
2298 | { | ||
2299 | int ret; | ||
2300 | ret = picolcd_resume_backlight(hid_get_drvdata(hdev)); | ||
2301 | if (ret) | ||
2302 | dbg_hid(PICOLCD_NAME " restoring backlight failed: %d\n", ret); | ||
2303 | return 0; | ||
2304 | } | ||
2305 | |||
2306 | static int picolcd_reset_resume(struct hid_device *hdev) | ||
2307 | { | ||
2308 | int ret; | ||
2309 | ret = picolcd_reset(hdev); | ||
2310 | if (ret) | ||
2311 | dbg_hid(PICOLCD_NAME " resetting our device failed: %d\n", ret); | ||
2312 | ret = picolcd_fb_reset(hid_get_drvdata(hdev), 0); | ||
2313 | if (ret) | ||
2314 | dbg_hid(PICOLCD_NAME " restoring framebuffer content failed: %d\n", ret); | ||
2315 | ret = picolcd_resume_lcd(hid_get_drvdata(hdev)); | ||
2316 | if (ret) | ||
2317 | dbg_hid(PICOLCD_NAME " restoring lcd failed: %d\n", ret); | ||
2318 | ret = picolcd_resume_backlight(hid_get_drvdata(hdev)); | ||
2319 | if (ret) | ||
2320 | dbg_hid(PICOLCD_NAME " restoring backlight failed: %d\n", ret); | ||
2321 | picolcd_leds_set(hid_get_drvdata(hdev)); | ||
2322 | return 0; | ||
2323 | } | ||
2324 | #endif | ||
2325 | |||
2262 | /* initialize keypad input device */ | 2326 | /* initialize keypad input device */ |
2263 | static int picolcd_init_keys(struct picolcd_data *data, | 2327 | static int picolcd_init_keys(struct picolcd_data *data, |
2264 | struct hid_report *report) | 2328 | struct hid_report *report) |
@@ -2544,6 +2608,11 @@ static struct hid_driver picolcd_driver = { | |||
2544 | .probe = picolcd_probe, | 2608 | .probe = picolcd_probe, |
2545 | .remove = picolcd_remove, | 2609 | .remove = picolcd_remove, |
2546 | .raw_event = picolcd_raw_event, | 2610 | .raw_event = picolcd_raw_event, |
2611 | #ifdef CONFIG_PM | ||
2612 | .suspend = picolcd_suspend, | ||
2613 | .resume = picolcd_resume, | ||
2614 | .reset_resume = picolcd_reset_resume, | ||
2615 | #endif | ||
2547 | }; | 2616 | }; |
2548 | 2617 | ||
2549 | static int __init picolcd_init(void) | 2618 | static int __init picolcd_init(void) |