lkml.org 
[lkml]   [2010]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 3/3] hid-picolcd: make use of new suspend/resume hooks
Make use of new suspend/resume hooks to disable backlight on suspend
and restore backlight on simple resume or backlight, contrast and
framebuffer content on reset-resume.

Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Cc: Nicu Pavel <npavel@ituner.com>
---
drivers/hid/hid-picolcd.c | 45 +++
1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
index e69de29..90f6be5 100644
--- a/drivers/hid/hid-picolcd.c
+++ b/drivers/hid/hid-picolcd.c
@@ -833,6 +833,46 @@
};


+#ifdef CONFIG_PM
+static int picolcd_suspend(struct hid_device *hdev)
+{
+ struct picolcd_data *data = hid_get_drvdata(hdev);
+ int bl_power = data->lcd_power;
+
+ data->backlight->props.power = FB_BLANK_POWERDOWN;
+ picolcd_set_brightness(data->backlight);
+ data->lcd_power = data->backlight->props.power = bl_power;
+ dbg_hid(PICOLCD_NAME " device ready for suspend, lcd_power=%d\n", bl_power);
+ return 0;
+}
+
+static int picolcd_resume(struct hid_device *hdev)
+{
+ struct picolcd_data *data = hid_get_drvdata(hdev);
+ int ret;
+ ret = picolcd_set_brightness(data->backlight);
+ if (ret)
+ dbg_hid(PICOLCD_NAME " restoring brightness failed: %d\n", ret);
+ ret = picolcd_set_contrast(data->lcd, data->lcd_contrast);
+ if (ret)
+ dbg_hid(PICOLCD_NAME " restoring contrast 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(hdev, 0);
+ if (ret)
+ dbg_hid(PICOLCD_NAME " restoring framebuffer content failed: %d\n", ret);
+ return 0;
+}
+#endif
+
+
static int picolcd_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
@@ -1057,6 +1097,11 @@
.probe = picolcd_probe,
.remove = picolcd_remove,
.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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2010-02-24 17:05    [W:6.481 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site