aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2011-09-06 07:50:37 -0400
committerJiri Kosina <jkosina@suse.cz>2011-09-07 07:25:17 -0400
commit0370d7cb30716b202b2412b9b2d4740fd3152d30 (patch)
treede22cc063955c3a4c49bf0988ef4c40783070b50
parentfc221cda3b1220bb3d356349bd843fabef3cf96f (diff)
HID: wiimote: Initialize IR cam on request
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> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-wiimote.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c
index 35dc293db40e..66583986bcdb 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)
668 hid_hw_close(wdata->hdev); 668 hid_hw_close(wdata->hdev);
669} 669}
670 670
671static int wiimote_ir_open(struct input_dev *dev)
672{
673 struct wiimote_data *wdata = input_get_drvdata(dev);
674 int ret;
675
676 ret = hid_hw_open(wdata->hdev);
677 if (ret)
678 return ret;
679
680 ret = wiimote_init_ir(wdata, WIIPROTO_FLAG_IR_BASIC);
681 if (ret) {
682 hid_hw_close(wdata->hdev);
683 return ret;
684 }
685
686 return 0;
687}
688
689static void wiimote_ir_close(struct input_dev *dev)
690{
691 struct wiimote_data *wdata = input_get_drvdata(dev);
692
693 wiimote_init_ir(wdata, 0);
694 hid_hw_close(wdata->hdev);
695}
696
671static void handler_keys(struct wiimote_data *wdata, const __u8 *payload) 697static void handler_keys(struct wiimote_data *wdata, const __u8 *payload)
672{ 698{
673 input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_LEFT], 699 input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_LEFT],
@@ -1062,6 +1088,8 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
1062 goto err_ir; 1088 goto err_ir;
1063 1089
1064 input_set_drvdata(wdata->ir, wdata); 1090 input_set_drvdata(wdata->ir, wdata);
1091 wdata->ir->open = wiimote_ir_open;
1092 wdata->ir->close = wiimote_ir_close;
1065 wdata->ir->dev.parent = &wdata->hdev->dev; 1093 wdata->ir->dev.parent = &wdata->hdev->dev;
1066 wdata->ir->id.bustype = wdata->hdev->bus; 1094 wdata->ir->id.bustype = wdata->hdev->bus;
1067 wdata->ir->id.vendor = wdata->hdev->vendor; 1095 wdata->ir->id.vendor = wdata->hdev->vendor;