aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@enac.fr>2012-06-19 08:39:52 -0400
committerJiri Kosina <jkosina@suse.cz>2012-06-28 04:29:38 -0400
commit4aceed37e315e8eaa26cb4c8dfd619a32fa24669 (patch)
treec15e08a4f7d857375649a1313b215c84cfab9675
parent4380d8198845da88915c93a4b3f9cb2fa0f917be (diff)
HID: hid-multitouch: fix input mode feature command
Zytronic panels shows a new way of setting the Input Mode feature. This feature is put in the second usage in the HID feature, instead of the first, as the majority of the multitouch devices. This patch adds a detection step when the feature is presented to know where the feature is located in the report. We can then trigger the right command to the device. This removes the magic number "0" in the function mt_set_input_mode. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-multitouch.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 61cc4cbe0f3e..9a3891e00cdd 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -83,6 +83,7 @@ struct mt_device {
83 unsigned last_field_index; /* last field index of the report */ 83 unsigned last_field_index; /* last field index of the report */
84 unsigned last_slot_field; /* the last field of a slot */ 84 unsigned last_slot_field; /* the last field of a slot */
85 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ 85 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */
86 __s8 inputmode_index; /* InputMode HID feature index in the report */
86 __s8 maxcontact_report_id; /* Maximum Contact Number HID feature, 87 __s8 maxcontact_report_id; /* Maximum Contact Number HID feature,
87 -1 if non-existent */ 88 -1 if non-existent */
88 __u8 num_received; /* how many contacts we received */ 89 __u8 num_received; /* how many contacts we received */
@@ -260,10 +261,20 @@ static void mt_feature_mapping(struct hid_device *hdev,
260 struct hid_field *field, struct hid_usage *usage) 261 struct hid_field *field, struct hid_usage *usage)
261{ 262{
262 struct mt_device *td = hid_get_drvdata(hdev); 263 struct mt_device *td = hid_get_drvdata(hdev);
264 int i;
263 265
264 switch (usage->hid) { 266 switch (usage->hid) {
265 case HID_DG_INPUTMODE: 267 case HID_DG_INPUTMODE:
266 td->inputmode = field->report->id; 268 td->inputmode = field->report->id;
269 td->inputmode_index = 0; /* has to be updated below */
270
271 for (i=0; i < field->maxusage; i++) {
272 if (field->usage[i].hid == usage->hid) {
273 td->inputmode_index = i;
274 break;
275 }
276 }
277
267 break; 278 break;
268 case HID_DG_CONTACTMAX: 279 case HID_DG_CONTACTMAX:
269 td->maxcontact_report_id = field->report->id; 280 td->maxcontact_report_id = field->report->id;
@@ -618,7 +629,7 @@ static void mt_set_input_mode(struct hid_device *hdev)
618 re = &(hdev->report_enum[HID_FEATURE_REPORT]); 629 re = &(hdev->report_enum[HID_FEATURE_REPORT]);
619 r = re->report_id_hash[td->inputmode]; 630 r = re->report_id_hash[td->inputmode];
620 if (r) { 631 if (r) {
621 r->field[0]->value[0] = 0x02; 632 r->field[0]->value[td->inputmode_index] = 0x02;
622 usbhid_submit_report(hdev, r, USB_DIR_OUT); 633 usbhid_submit_report(hdev, r, USB_DIR_OUT);
623 } 634 }
624} 635}