summaryrefslogtreecommitdiff
path: root/usr/src/dkms_source_tree
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/dkms_source_tree')
-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