Commit 9d71ea05 authored by Bruno Prémont's avatar Bruno Prémont Committed by Jiri Kosina

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: default avatarBruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent d6d53cbc
...@@ -763,7 +763,7 @@ static inline int picolcd_init_framebuffer(struct picolcd_data *data) ...@@ -763,7 +763,7 @@ static inline int picolcd_init_framebuffer(struct picolcd_data *data)
{ {
return 0; return 0;
} }
static void picolcd_exit_framebuffer(struct picolcd_data *data) static inline void picolcd_exit_framebuffer(struct picolcd_data *data)
{ {
} }
#define picolcd_fbinfo(d) NULL #define picolcd_fbinfo(d) NULL
...@@ -852,6 +852,18 @@ static inline int picolcd_resume_backlight(struct picolcd_data *data) ...@@ -852,6 +852,18 @@ static inline int picolcd_resume_backlight(struct picolcd_data *data)
return picolcd_set_brightness(data->backlight); return picolcd_set_brightness(data->backlight);
} }
#ifdef CONFIG_PM
static void picolcd_suspend_backlight(struct picolcd_data *data)
{
int bl_power = data->lcd_power;
if (!data->backlight)
return;
data->backlight->props.power = FB_BLANK_POWERDOWN;
picolcd_set_brightness(data->backlight);
data->lcd_power = data->backlight->props.power = bl_power;
}
#endif /* CONFIG_PM */
#else #else
static inline int picolcd_init_backlight(struct picolcd_data *data, static inline int picolcd_init_backlight(struct picolcd_data *data,
struct hid_report *report) struct hid_report *report)
...@@ -865,6 +877,9 @@ static inline int picolcd_resume_backlight(struct picolcd_data *data) ...@@ -865,6 +877,9 @@ static inline int picolcd_resume_backlight(struct picolcd_data *data)
{ {
return 0; return 0;
} }
static inline void picolcd_suspend_backlight(struct picolcd_data *data)
{
}
#endif /* CONFIG_HID_PICOLCD_BACKLIGHT */ #endif /* CONFIG_HID_PICOLCD_BACKLIGHT */
#ifdef CONFIG_HID_PICOLCD_LCD #ifdef CONFIG_HID_PICOLCD_LCD
...@@ -1098,7 +1113,7 @@ static inline int picolcd_init_leds(struct picolcd_data *data, ...@@ -1098,7 +1113,7 @@ static inline int picolcd_init_leds(struct picolcd_data *data,
{ {
return 0; return 0;
} }
static void picolcd_exit_leds(struct picolcd_data *data) static inline void picolcd_exit_leds(struct picolcd_data *data)
{ {
} }
static inline int picolcd_leds_set(struct picolcd_data *data) static inline int picolcd_leds_set(struct picolcd_data *data)
...@@ -2214,9 +2229,18 @@ static void picolcd_exit_devfs(struct picolcd_data *data) ...@@ -2214,9 +2229,18 @@ static void picolcd_exit_devfs(struct picolcd_data *data)
mutex_destroy(&data->mutex_flash); mutex_destroy(&data->mutex_flash);
} }
#else #else
#define picolcd_debug_raw_event(data, hdev, report, raw_data, size) static inline void picolcd_debug_raw_event(struct picolcd_data *data,
#define picolcd_init_devfs(data, eeprom_r, eeprom_w, flash_r, flash_w, reset) struct hid_device *hdev, struct hid_report *report,
static void picolcd_exit_devfs(struct picolcd_data *data) u8 *raw_data, int size)
{
}
static inline void picolcd_init_devfs(struct picolcd_data *data,
struct hid_report *eeprom_r, struct hid_report *eeprom_w,
struct hid_report *flash_r, struct hid_report *flash_w,
struct hid_report *reset)
{
}
static inline void picolcd_exit_devfs(struct picolcd_data *data)
{ {
} }
#endif /* CONFIG_DEBUG_FS */ #endif /* CONFIG_DEBUG_FS */
...@@ -2259,6 +2283,46 @@ static int picolcd_raw_event(struct hid_device *hdev, ...@@ -2259,6 +2283,46 @@ static int picolcd_raw_event(struct hid_device *hdev,
return 1; return 1;
} }
#ifdef CONFIG_PM
static int picolcd_suspend(struct hid_device *hdev, pm_message_t message)
{
if (message.event & PM_EVENT_AUTO)
return 0;
picolcd_suspend_backlight(hid_get_drvdata(hdev));
dbg_hid(PICOLCD_NAME " device ready for suspend\n");
return 0;
}
static int picolcd_resume(struct hid_device *hdev)
{
int ret;
ret = picolcd_resume_backlight(hid_get_drvdata(hdev));
if (ret)
dbg_hid(PICOLCD_NAME " restoring backlight failed: %d\n", ret);
return 0;
}
static int picolcd_reset_resume(struct hid_device *hdev)
{
int ret;
ret = picolcd_reset(hdev);
if (ret)
dbg_hid(PICOLCD_NAME " resetting our device failed: %d\n", ret);
ret = picolcd_fb_reset(hid_get_drvdata(hdev), 0);
if (ret)
dbg_hid(PICOLCD_NAME " restoring framebuffer content failed: %d\n", ret);
ret = picolcd_resume_lcd(hid_get_drvdata(hdev));
if (ret)
dbg_hid(PICOLCD_NAME " restoring lcd failed: %d\n", ret);
ret = picolcd_resume_backlight(hid_get_drvdata(hdev));
if (ret)
dbg_hid(PICOLCD_NAME " restoring backlight failed: %d\n", ret);
picolcd_leds_set(hid_get_drvdata(hdev));
return 0;
}
#endif
/* initialize keypad input device */ /* initialize keypad input device */
static int picolcd_init_keys(struct picolcd_data *data, static int picolcd_init_keys(struct picolcd_data *data,
struct hid_report *report) struct hid_report *report)
...@@ -2544,6 +2608,11 @@ static struct hid_driver picolcd_driver = { ...@@ -2544,6 +2608,11 @@ static struct hid_driver picolcd_driver = {
.probe = picolcd_probe, .probe = picolcd_probe,
.remove = picolcd_remove, .remove = picolcd_remove,
.raw_event = picolcd_raw_event, .raw_event = picolcd_raw_event,
#ifdef CONFIG_PM
.suspend = picolcd_suspend,
.resume = picolcd_resume,
.reset_resume = picolcd_reset_resume,
#endif
}; };
static int __init picolcd_init(void) static int __init picolcd_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment