summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorRafi Rubin <rafi@seas.upenn.edu>2011-03-09 23:33:52 -0500
committerHenrik Rydberg <rydberg@euromail.se>2011-03-22 09:24:30 +0100
commitc9cc0925737666432e8e31794cb98a110eebfeae (patch)
tree2671ff2496883bd6589420fe23f78a1818f0f2f9 /usr/src
parented7f6d1740316b0777965a66cb13067c51a95928 (diff)
HID: hid-ntrig: init settle and mode check
Adding a wait before the wakeup signal. As a precautionary measure sanity check the current sensor mode. If needed reset it to "dual". When the device is responding poorly and needs the wakeup call, it was missing it. Giving it a chance to settle first improves the chances that signal gets through. Signed-off-by: Rafi Rubin <rafi@seas.upenn.edu> Tested-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/dkms_source_tree/hid-ntrig.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/usr/src/dkms_source_tree/hid-ntrig.c b/usr/src/dkms_source_tree/hid-ntrig.c
index bd292b3..63abd7b 100644
--- a/usr/src/dkms_source_tree/hid-ntrig.c
+++ b/usr/src/dkms_source_tree/hid-ntrig.c
@@ -75,6 +75,36 @@ static int ntrig_version_string(unsigned char *raw, char *buf)
75 return sprintf(buf, "%u.%u.%u.%u.%u", a, b, c, d, e); 75 return sprintf(buf, "%u.%u.%u.%u.%u", a, b, c, d, e);
76} 76}
77 77
78static inline int ntrig_get_mode(struct hid_device *hdev)
79{
80 struct hid_report *report = hdev->report_enum[HID_FEATURE_REPORT].
81 report_id_hash[0x0d];
82
83 if (!report)
84 return -EINVAL;
85
86 usbhid_submit_report(hdev, report, USB_DIR_IN);
87 usbhid_wait_io(hdev);
88 return (int)report->field[0]->value[0];
89}
90
91static inline void ntrig_set_mode(struct hid_device *hdev, const int mode)
92{
93 struct hid_report *report;
94 __u8 mode_commands[4] = { 0xe, 0xf, 0x1b, 0x10 };
95
96 if (mode < 0 || mode > 3)
97 return;
98
99 report = hdev->report_enum[HID_FEATURE_REPORT].
100 report_id_hash[mode_commands[mode]];
101
102 if (!report)
103 return;
104
105 usbhid_submit_report(hdev, report, USB_DIR_IN);
106}
107
78static void ntrig_report_version(struct hid_device *hdev) 108static void ntrig_report_version(struct hid_device *hdev)
79{ 109{
80 int ret; 110 int ret;
@@ -452,8 +482,19 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
452 482
453 /* This is needed for devices with more recent firmware versions */ 483 /* This is needed for devices with more recent firmware versions */
454 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a]; 484 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a];
455 if (report) 485 if (report) {
456 usbhid_submit_report(hdev, report, USB_DIR_OUT); 486 /* Let the device settle to ensure the wakeup message gets
487 * through */
488 usbhid_wait_io(hdev);
489 usbhid_submit_report(hdev, report, USB_DIR_IN);
490
491 /*
492 * Sanity check: if the current mode is invalid reset it to
493 * something reasonable.
494 */
495 if (ntrig_get_mode(hdev) >= 4)
496 ntrig_set_mode(hdev, 3);
497 }
457 498
458 ntrig_report_version(hdev); 499 ntrig_report_version(hdev);
459 500