From: "Bruno Prémont" <bonbons@linux-vserver.org>
To: Oliver Neukum <oliver@neukum.org>, Jiri Kosina <jkosina@suse.cz>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Nicu Pavel <npavel@ituner.com>,
Jaya Kumar <jayakumar.lkml@gmail.com>,
"Rick L. Vinyard Jr." <rvinyard@cs.nmsu.edu>
Subject: [PATCH 2/2] hid: add PM support to PicoLCD device
Date: Sun, 25 Apr 2010 21:43:06 +0200 [thread overview]
Message-ID: <20100425214306.5d7be049@neptune.home> (raw)
In-Reply-To: <20100425214003.7e87c6a3@neptune.home>
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>
---
drivers/hid/hid-picolcd.c | 61 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
index aa6f2e1..c652390 100644
--- a/drivers/hid/hid-picolcd.c
+++ b/drivers/hid/hid-picolcd.c
@@ -852,6 +852,20 @@ static inline int picolcd_resume_backlight(struct picolcd_data *data)
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;
+}
+#else
+#define picolcd_suspend_backlight(a)
+#endif /* CONFIG_PM */
#else
static inline int picolcd_init_backlight(struct picolcd_data *data,
struct hid_report *report)
@@ -865,6 +879,7 @@ static inline int picolcd_resume_backlight(struct picolcd_data *data)
{
return 0;
}
+#define picolcd_suspend_backlight(a)
#endif /* CONFIG_HID_PICOLCD_BACKLIGHT */
#ifdef CONFIG_HID_PICOLCD_LCD
@@ -2259,6 +2274,46 @@ static int picolcd_raw_event(struct hid_device *hdev,
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 */
static int picolcd_init_keys(struct picolcd_data *data,
struct hid_report *report)
@@ -2544,6 +2599,11 @@ static struct hid_driver picolcd_driver = {
.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)
--
1.6.4.4
next prev parent reply other threads:[~2010-04-25 19:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-25 19:40 [PATCH 1/2] hid: add suspend/resume hooks for hid drivers Bruno Prémont
2010-04-25 19:43 ` Bruno Prémont [this message]
2010-04-27 13:28 ` [PATCH 2/2] hid: add PM support to PicoLCD device Jiri Kosina
2010-04-27 20:16 ` Bruno Prémont
2010-04-27 20:57 ` Jiri Kosina
2010-05-02 14:05 ` Bruno Prémont
[not found] ` <20100502160505.4acc9f1c-hY15tx4IgV39zxVx7UNMDg@public.gmane.org>
2010-05-03 13:28 ` Jiri Kosina
[not found] ` <20100425214003.7e87c6a3-hY15tx4IgV39zxVx7UNMDg@public.gmane.org>
2010-04-27 13:25 ` [PATCH 1/2] hid: add suspend/resume hooks for hid drivers Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100425214306.5d7be049@neptune.home \
--to=bonbons@linux-vserver.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jayakumar.lkml@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=npavel@ituner.com \
--cc=oliver@neukum.org \
--cc=rvinyard@cs.nmsu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).