From: David Herrmann <dh.herrmann@googlemail.com>
To: linux-input@vger.kernel.org
Cc: jkosina@suse.cz, David Herrmann <dh.herrmann@googlemail.com>
Subject: [PATCH v2 12/15] HID: wiimote: Initialize IR cam on request
Date: Tue, 6 Sep 2011 13:50:37 +0200 [thread overview]
Message-ID: <1315309840-4664-13-git-send-email-dh.herrmann@googlemail.com> (raw)
In-Reply-To: <1315309840-4664-1-git-send-email-dh.herrmann@googlemail.com>
Initialize the IR cam if the related input device is opened by userspace. Stop
IR cam again if userspace is no longer interested in its data events.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
drivers/hid/hid-wiimote.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c
index 35dc293..6658398 100644
--- a/drivers/hid/hid-wiimote.c
+++ b/drivers/hid/hid-wiimote.c
@@ -668,6 +668,32 @@ static void wiimote_accel_close(struct input_dev *dev)
hid_hw_close(wdata->hdev);
}
+static int wiimote_ir_open(struct input_dev *dev)
+{
+ struct wiimote_data *wdata = input_get_drvdata(dev);
+ int ret;
+
+ ret = hid_hw_open(wdata->hdev);
+ if (ret)
+ return ret;
+
+ ret = wiimote_init_ir(wdata, WIIPROTO_FLAG_IR_BASIC);
+ if (ret) {
+ hid_hw_close(wdata->hdev);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void wiimote_ir_close(struct input_dev *dev)
+{
+ struct wiimote_data *wdata = input_get_drvdata(dev);
+
+ wiimote_init_ir(wdata, 0);
+ hid_hw_close(wdata->hdev);
+}
+
static void handler_keys(struct wiimote_data *wdata, const __u8 *payload)
{
input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_LEFT],
@@ -1062,6 +1088,8 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
goto err_ir;
input_set_drvdata(wdata->ir, wdata);
+ wdata->ir->open = wiimote_ir_open;
+ wdata->ir->close = wiimote_ir_close;
wdata->ir->dev.parent = &wdata->hdev->dev;
wdata->ir->id.bustype = wdata->hdev->bus;
wdata->ir->id.vendor = wdata->hdev->vendor;
--
1.7.6.1
next prev parent reply other threads:[~2011-09-06 11:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-06 11:50 [PATCH v2 00/15] Extended Wiimote Support David Herrmann
2011-09-06 11:50 ` [PATCH v2 01/15] HID: wiimote: Support rumble device David Herrmann
2011-09-06 11:50 ` [PATCH v2 02/15] HID: wiimote: Add force-feedback support David Herrmann
2011-09-06 11:50 ` [PATCH v2 03/15] HID: wiimote: Add accelerometer input device David Herrmann
2011-09-06 11:50 ` [PATCH v2 04/15] HID: wiimote: Parse accelerometer data David Herrmann
2011-09-06 11:50 ` [PATCH v2 05/15] HID: wiimote: Add IR input device David Herrmann
2011-09-06 11:50 ` [PATCH v2 06/15] HID: wiimote: Parse IR data David Herrmann
2011-09-06 11:50 ` [PATCH v2 07/15] HID: wiimote: Add missing extension DRM handlers David Herrmann
2011-09-06 11:50 ` [PATCH v2 08/15] HID: wiimote: Add register/eeprom memory support David Herrmann
2011-09-06 11:50 ` [PATCH v2 09/15] HID: wiimote: Helper functions for synchronous requests David Herrmann
2011-09-06 11:50 ` [PATCH v2 10/15] HID: wiimote: Add write-register helpers David Herrmann
2011-09-06 11:50 ` [PATCH v2 11/15] HID: wiimote: Add IR initializer David Herrmann
2011-09-06 11:50 ` David Herrmann [this message]
2011-09-06 11:50 ` [PATCH v2 13/15] HID: wiimote: Add status request David Herrmann
2011-09-06 11:50 ` [PATCH v2 14/15] HID: wiimote: Read wiimote battery charge level David Herrmann
2011-09-06 11:50 ` [PATCH v2 15/15] HID: wiimote: Add MAINTAINERS entry David Herrmann
2011-09-07 11:29 ` [PATCH v2 00/15] Extended Wiimote Support 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=1315309840-4664-13-git-send-email-dh.herrmann@googlemail.com \
--to=dh.herrmann@googlemail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
/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).