diff options
author | Jiri Kosina <jkosina@suse.cz> | 2013-04-30 04:17:48 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-04-30 04:17:48 -0400 |
commit | 72c16d9a5c303dce928a52a8861fe7a2a25f849a (patch) | |
tree | b38d03007abcfadf12619d422169a6d4d4000ce7 /drivers/hid | |
parent | 4f5a81042909fed6977881f22c024aa3582cfcca (diff) | |
parent | fb4d8d98dc24f66f7f98e6506fad63e1c320cd82 (diff) |
Merge branch 'for-3.10/mt-hybrid-finger-pen' into for-linus
Conflicts:
drivers/hid/hid-multitouch.c
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-input.c | 77 | ||||
-rw-r--r-- | drivers/hid/hid-multitouch.c | 237 |
2 files changed, 254 insertions, 60 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 21b196c394b1..945b8158ec4c 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -1198,6 +1198,67 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid) | |||
1198 | return hidinput; | 1198 | return hidinput; |
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | static bool hidinput_has_been_populated(struct hid_input *hidinput) | ||
1202 | { | ||
1203 | int i; | ||
1204 | unsigned long r = 0; | ||
1205 | |||
1206 | for (i = 0; i < BITS_TO_LONGS(EV_CNT); i++) | ||
1207 | r |= hidinput->input->evbit[i]; | ||
1208 | |||
1209 | for (i = 0; i < BITS_TO_LONGS(KEY_CNT); i++) | ||
1210 | r |= hidinput->input->keybit[i]; | ||
1211 | |||
1212 | for (i = 0; i < BITS_TO_LONGS(REL_CNT); i++) | ||
1213 | r |= hidinput->input->relbit[i]; | ||
1214 | |||
1215 | for (i = 0; i < BITS_TO_LONGS(ABS_CNT); i++) | ||
1216 | r |= hidinput->input->absbit[i]; | ||
1217 | |||
1218 | for (i = 0; i < BITS_TO_LONGS(MSC_CNT); i++) | ||
1219 | r |= hidinput->input->mscbit[i]; | ||
1220 | |||
1221 | for (i = 0; i < BITS_TO_LONGS(LED_CNT); i++) | ||
1222 | r |= hidinput->input->ledbit[i]; | ||
1223 | |||
1224 | for (i = 0; i < BITS_TO_LONGS(SND_CNT); i++) | ||
1225 | r |= hidinput->input->sndbit[i]; | ||
1226 | |||
1227 | for (i = 0; i < BITS_TO_LONGS(FF_CNT); i++) | ||
1228 | r |= hidinput->input->ffbit[i]; | ||
1229 | |||
1230 | for (i = 0; i < BITS_TO_LONGS(SW_CNT); i++) | ||
1231 | r |= hidinput->input->swbit[i]; | ||
1232 | |||
1233 | return !!r; | ||
1234 | } | ||
1235 | |||
1236 | static void hidinput_cleanup_hidinput(struct hid_device *hid, | ||
1237 | struct hid_input *hidinput) | ||
1238 | { | ||
1239 | struct hid_report *report; | ||
1240 | int i, k; | ||
1241 | |||
1242 | list_del(&hidinput->list); | ||
1243 | input_free_device(hidinput->input); | ||
1244 | |||
1245 | for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) { | ||
1246 | if (k == HID_OUTPUT_REPORT && | ||
1247 | hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) | ||
1248 | continue; | ||
1249 | |||
1250 | list_for_each_entry(report, &hid->report_enum[k].report_list, | ||
1251 | list) { | ||
1252 | |||
1253 | for (i = 0; i < report->maxfield; i++) | ||
1254 | if (report->field[i]->hidinput == hidinput) | ||
1255 | report->field[i]->hidinput = NULL; | ||
1256 | } | ||
1257 | } | ||
1258 | |||
1259 | kfree(hidinput); | ||
1260 | } | ||
1261 | |||
1201 | /* | 1262 | /* |
1202 | * Register the input device; print a message. | 1263 | * Register the input device; print a message. |
1203 | * Configure the input layer interface | 1264 | * Configure the input layer interface |
@@ -1249,6 +1310,10 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
1249 | hidinput_configure_usage(hidinput, report->field[i], | 1310 | hidinput_configure_usage(hidinput, report->field[i], |
1250 | report->field[i]->usage + j); | 1311 | report->field[i]->usage + j); |
1251 | 1312 | ||
1313 | if ((hid->quirks & HID_QUIRK_NO_EMPTY_INPUT) && | ||
1314 | !hidinput_has_been_populated(hidinput)) | ||
1315 | continue; | ||
1316 | |||
1252 | if (hid->quirks & HID_QUIRK_MULTI_INPUT) { | 1317 | if (hid->quirks & HID_QUIRK_MULTI_INPUT) { |
1253 | /* This will leave hidinput NULL, so that it | 1318 | /* This will leave hidinput NULL, so that it |
1254 | * allocates another one if we have more inputs on | 1319 | * allocates another one if we have more inputs on |
@@ -1265,6 +1330,18 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
1265 | } | 1330 | } |
1266 | } | 1331 | } |
1267 | 1332 | ||
1333 | if (hidinput && (hid->quirks & HID_QUIRK_NO_EMPTY_INPUT) && | ||
1334 | !hidinput_has_been_populated(hidinput)) { | ||
1335 | /* no need to register an input device not populated */ | ||
1336 | hidinput_cleanup_hidinput(hid, hidinput); | ||
1337 | hidinput = NULL; | ||
1338 | } | ||
1339 | |||
1340 | if (list_empty(&hid->inputs)) { | ||
1341 | hid_err(hid, "No inputs registered, leaving\n"); | ||
1342 | goto out_unwind; | ||
1343 | } | ||
1344 | |||
1268 | if (hidinput) { | 1345 | if (hidinput) { |
1269 | if (drv->input_configured) | 1346 | if (drv->input_configured) |
1270 | drv->input_configured(hid, hidinput); | 1347 | drv->input_configured(hid, hidinput); |
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index f19ec1586c5a..dc3ae5c56f56 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
45 | #include <linux/usb.h> | 45 | #include <linux/usb.h> |
46 | #include <linux/input/mt.h> | 46 | #include <linux/input/mt.h> |
47 | #include <linux/string.h> | ||
47 | 48 | ||
48 | 49 | ||
49 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); | 50 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); |
@@ -97,9 +98,9 @@ struct mt_device { | |||
97 | multitouch fields */ | 98 | multitouch fields */ |
98 | int cc_index; /* contact count field index in the report */ | 99 | int cc_index; /* contact count field index in the report */ |
99 | int cc_value_index; /* contact count value index in the field */ | 100 | int cc_value_index; /* contact count value index in the field */ |
100 | unsigned last_field_index; /* last field index of the report */ | ||
101 | unsigned last_slot_field; /* the last field of a slot */ | 101 | unsigned last_slot_field; /* the last field of a slot */ |
102 | unsigned mt_report_id; /* the report ID of the multitouch device */ | 102 | unsigned mt_report_id; /* the report ID of the multitouch device */ |
103 | unsigned pen_report_id; /* the report ID of the pen device */ | ||
103 | __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ | 104 | __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ |
104 | __s8 inputmode_index; /* InputMode HID feature index in the report */ | 105 | __s8 inputmode_index; /* InputMode HID feature index in the report */ |
105 | __s8 maxcontact_report_id; /* Maximum Contact Number HID feature, | 106 | __s8 maxcontact_report_id; /* Maximum Contact Number HID feature, |
@@ -115,6 +116,9 @@ struct mt_device { | |||
115 | unsigned mt_flags; /* flags to pass to input-mt */ | 116 | unsigned mt_flags; /* flags to pass to input-mt */ |
116 | }; | 117 | }; |
117 | 118 | ||
119 | static void mt_post_parse_default_settings(struct mt_device *td); | ||
120 | static void mt_post_parse(struct mt_device *td); | ||
121 | |||
118 | /* classes of device behavior */ | 122 | /* classes of device behavior */ |
119 | #define MT_CLS_DEFAULT 0x0001 | 123 | #define MT_CLS_DEFAULT 0x0001 |
120 | 124 | ||
@@ -257,6 +261,14 @@ static struct mt_class mt_classes[] = { | |||
257 | { } | 261 | { } |
258 | }; | 262 | }; |
259 | 263 | ||
264 | static void mt_free_input_name(struct hid_input *hi) | ||
265 | { | ||
266 | struct hid_device *hdev = hi->report->device; | ||
267 | |||
268 | if (hi->input->name != hdev->name) | ||
269 | kfree(hi->input->name); | ||
270 | } | ||
271 | |||
260 | static ssize_t mt_show_quirks(struct device *dev, | 272 | static ssize_t mt_show_quirks(struct device *dev, |
261 | struct device_attribute *attr, | 273 | struct device_attribute *attr, |
262 | char *buf) | 274 | char *buf) |
@@ -365,7 +377,53 @@ static void mt_store_field(struct hid_usage *usage, struct mt_device *td, | |||
365 | f->usages[f->length++] = usage->hid; | 377 | f->usages[f->length++] = usage->hid; |
366 | } | 378 | } |
367 | 379 | ||
368 | static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | 380 | static int mt_pen_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
381 | struct hid_field *field, struct hid_usage *usage, | ||
382 | unsigned long **bit, int *max) | ||
383 | { | ||
384 | struct mt_device *td = hid_get_drvdata(hdev); | ||
385 | |||
386 | td->pen_report_id = field->report->id; | ||
387 | |||
388 | return 0; | ||
389 | } | ||
390 | |||
391 | static int mt_pen_input_mapped(struct hid_device *hdev, struct hid_input *hi, | ||
392 | struct hid_field *field, struct hid_usage *usage, | ||
393 | unsigned long **bit, int *max) | ||
394 | { | ||
395 | return 0; | ||
396 | } | ||
397 | |||
398 | static int mt_pen_event(struct hid_device *hid, struct hid_field *field, | ||
399 | struct hid_usage *usage, __s32 value) | ||
400 | { | ||
401 | /* let hid-input handle it */ | ||
402 | return 0; | ||
403 | } | ||
404 | |||
405 | static void mt_pen_report(struct hid_device *hid, struct hid_report *report) | ||
406 | { | ||
407 | struct hid_field *field = report->field[0]; | ||
408 | |||
409 | input_sync(field->hidinput->input); | ||
410 | } | ||
411 | |||
412 | static void mt_pen_input_configured(struct hid_device *hdev, | ||
413 | struct hid_input *hi) | ||
414 | { | ||
415 | char *name = kzalloc(strlen(hi->input->name) + 5, GFP_KERNEL); | ||
416 | if (name) { | ||
417 | sprintf(name, "%s Pen", hi->input->name); | ||
418 | mt_free_input_name(hi); | ||
419 | hi->input->name = name; | ||
420 | } | ||
421 | |||
422 | /* force BTN_STYLUS to allow tablet matching in udev */ | ||
423 | __set_bit(BTN_STYLUS, hi->input->keybit); | ||
424 | } | ||
425 | |||
426 | static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
369 | struct hid_field *field, struct hid_usage *usage, | 427 | struct hid_field *field, struct hid_usage *usage, |
370 | unsigned long **bit, int *max) | 428 | unsigned long **bit, int *max) |
371 | { | 429 | { |
@@ -374,13 +432,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
374 | int code; | 432 | int code; |
375 | struct hid_usage *prev_usage = NULL; | 433 | struct hid_usage *prev_usage = NULL; |
376 | 434 | ||
377 | /* Only map fields from TouchScreen or TouchPad collections. | ||
378 | * We need to ignore fields that belong to other collections | ||
379 | * such as Mouse that might have the same GenericDesktop usages. */ | ||
380 | if (field->application == HID_DG_TOUCHSCREEN) | 435 | if (field->application == HID_DG_TOUCHSCREEN) |
381 | td->mt_flags |= INPUT_MT_DIRECT; | 436 | td->mt_flags |= INPUT_MT_DIRECT; |
382 | else if (field->application != HID_DG_TOUCHPAD) | ||
383 | return 0; | ||
384 | 437 | ||
385 | /* | 438 | /* |
386 | * Model touchscreens providing buttons as touchpads. | 439 | * Model touchscreens providing buttons as touchpads. |
@@ -389,12 +442,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
389 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) | 442 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) |
390 | td->mt_flags |= INPUT_MT_POINTER; | 443 | td->mt_flags |= INPUT_MT_POINTER; |
391 | 444 | ||
392 | /* eGalax devices provide a Digitizer.Stylus input which overrides | ||
393 | * the correct Digitizers.Finger X/Y ranges. | ||
394 | * Let's just ignore this input. */ | ||
395 | if (field->physical == HID_DG_STYLUS) | ||
396 | return -1; | ||
397 | |||
398 | if (usage->usage_index) | 445 | if (usage->usage_index) |
399 | prev_usage = &field->usage[usage->usage_index - 1]; | 446 | prev_usage = &field->usage[usage->usage_index - 1]; |
400 | 447 | ||
@@ -416,7 +463,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
416 | } | 463 | } |
417 | 464 | ||
418 | mt_store_field(usage, td, hi); | 465 | mt_store_field(usage, td, hi); |
419 | td->last_field_index = field->index; | ||
420 | return 1; | 466 | return 1; |
421 | case HID_GD_Y: | 467 | case HID_GD_Y: |
422 | if (prev_usage && (prev_usage->hid == usage->hid)) { | 468 | if (prev_usage && (prev_usage->hid == usage->hid)) { |
@@ -432,7 +478,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
432 | } | 478 | } |
433 | 479 | ||
434 | mt_store_field(usage, td, hi); | 480 | mt_store_field(usage, td, hi); |
435 | td->last_field_index = field->index; | ||
436 | return 1; | 481 | return 1; |
437 | } | 482 | } |
438 | return 0; | 483 | return 0; |
@@ -447,21 +492,17 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
447 | ABS_MT_DISTANCE, 0, 1, 0, 0); | 492 | ABS_MT_DISTANCE, 0, 1, 0, 0); |
448 | } | 493 | } |
449 | mt_store_field(usage, td, hi); | 494 | mt_store_field(usage, td, hi); |
450 | td->last_field_index = field->index; | ||
451 | return 1; | 495 | return 1; |
452 | case HID_DG_CONFIDENCE: | 496 | case HID_DG_CONFIDENCE: |
453 | mt_store_field(usage, td, hi); | 497 | mt_store_field(usage, td, hi); |
454 | td->last_field_index = field->index; | ||
455 | return 1; | 498 | return 1; |
456 | case HID_DG_TIPSWITCH: | 499 | case HID_DG_TIPSWITCH: |
457 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); | 500 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); |
458 | input_set_capability(hi->input, EV_KEY, BTN_TOUCH); | 501 | input_set_capability(hi->input, EV_KEY, BTN_TOUCH); |
459 | mt_store_field(usage, td, hi); | 502 | mt_store_field(usage, td, hi); |
460 | td->last_field_index = field->index; | ||
461 | return 1; | 503 | return 1; |
462 | case HID_DG_CONTACTID: | 504 | case HID_DG_CONTACTID: |
463 | mt_store_field(usage, td, hi); | 505 | mt_store_field(usage, td, hi); |
464 | td->last_field_index = field->index; | ||
465 | td->touches_by_report++; | 506 | td->touches_by_report++; |
466 | td->mt_report_id = field->report->id; | 507 | td->mt_report_id = field->report->id; |
467 | return 1; | 508 | return 1; |
@@ -472,7 +513,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
472 | set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, | 513 | set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, |
473 | cls->sn_width); | 514 | cls->sn_width); |
474 | mt_store_field(usage, td, hi); | 515 | mt_store_field(usage, td, hi); |
475 | td->last_field_index = field->index; | ||
476 | return 1; | 516 | return 1; |
477 | case HID_DG_HEIGHT: | 517 | case HID_DG_HEIGHT: |
478 | hid_map_usage(hi, usage, bit, max, | 518 | hid_map_usage(hi, usage, bit, max, |
@@ -484,7 +524,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
484 | ABS_MT_ORIENTATION, 0, 1, 0, 0); | 524 | ABS_MT_ORIENTATION, 0, 1, 0, 0); |
485 | } | 525 | } |
486 | mt_store_field(usage, td, hi); | 526 | mt_store_field(usage, td, hi); |
487 | td->last_field_index = field->index; | ||
488 | return 1; | 527 | return 1; |
489 | case HID_DG_TIPPRESSURE: | 528 | case HID_DG_TIPPRESSURE: |
490 | hid_map_usage(hi, usage, bit, max, | 529 | hid_map_usage(hi, usage, bit, max, |
@@ -492,17 +531,14 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
492 | set_abs(hi->input, ABS_MT_PRESSURE, field, | 531 | set_abs(hi->input, ABS_MT_PRESSURE, field, |
493 | cls->sn_pressure); | 532 | cls->sn_pressure); |
494 | mt_store_field(usage, td, hi); | 533 | mt_store_field(usage, td, hi); |
495 | td->last_field_index = field->index; | ||
496 | return 1; | 534 | return 1; |
497 | case HID_DG_CONTACTCOUNT: | 535 | case HID_DG_CONTACTCOUNT: |
498 | td->cc_index = field->index; | 536 | td->cc_index = field->index; |
499 | td->cc_value_index = usage->usage_index; | 537 | td->cc_value_index = usage->usage_index; |
500 | td->last_field_index = field->index; | ||
501 | return 1; | 538 | return 1; |
502 | case HID_DG_CONTACTMAX: | 539 | case HID_DG_CONTACTMAX: |
503 | /* we don't set td->last_slot_field as contactcount and | 540 | /* we don't set td->last_slot_field as contactcount and |
504 | * contact max are global to the report */ | 541 | * contact max are global to the report */ |
505 | td->last_field_index = field->index; | ||
506 | return -1; | 542 | return -1; |
507 | case HID_DG_TOUCH: | 543 | case HID_DG_TOUCH: |
508 | /* Legacy devices use TIPSWITCH and not TOUCH. | 544 | /* Legacy devices use TIPSWITCH and not TOUCH. |
@@ -526,7 +562,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
526 | return 0; | 562 | return 0; |
527 | } | 563 | } |
528 | 564 | ||
529 | static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, | 565 | static int mt_touch_input_mapped(struct hid_device *hdev, struct hid_input *hi, |
530 | struct hid_field *field, struct hid_usage *usage, | 566 | struct hid_field *field, struct hid_usage *usage, |
531 | unsigned long **bit, int *max) | 567 | unsigned long **bit, int *max) |
532 | { | 568 | { |
@@ -617,7 +653,7 @@ static void mt_sync_frame(struct mt_device *td, struct input_dev *input) | |||
617 | td->num_received = 0; | 653 | td->num_received = 0; |
618 | } | 654 | } |
619 | 655 | ||
620 | static int mt_event(struct hid_device *hid, struct hid_field *field, | 656 | static int mt_touch_event(struct hid_device *hid, struct hid_field *field, |
621 | struct hid_usage *usage, __s32 value) | 657 | struct hid_usage *usage, __s32 value) |
622 | { | 658 | { |
623 | /* we will handle the hidinput part later, now remains hiddev */ | 659 | /* we will handle the hidinput part later, now remains hiddev */ |
@@ -691,29 +727,19 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | |||
691 | if (usage->usage_index + 1 == field->report_count) { | 727 | if (usage->usage_index + 1 == field->report_count) { |
692 | /* we only take into account the last report. */ | 728 | /* we only take into account the last report. */ |
693 | if (usage->hid == td->last_slot_field) | 729 | if (usage->hid == td->last_slot_field) |
694 | mt_complete_slot(td, input); | 730 | mt_complete_slot(td, field->hidinput->input); |
695 | |||
696 | if (field->index == td->last_field_index | ||
697 | && td->num_received >= td->num_expected) | ||
698 | mt_sync_frame(td, field->hidinput->input); | ||
699 | } | 731 | } |
700 | 732 | ||
701 | } | 733 | } |
702 | } | 734 | } |
703 | 735 | ||
704 | static void mt_report(struct hid_device *hid, struct hid_report *report) | 736 | static void mt_touch_report(struct hid_device *hid, struct hid_report *report) |
705 | { | 737 | { |
706 | struct mt_device *td = hid_get_drvdata(hid); | 738 | struct mt_device *td = hid_get_drvdata(hid); |
707 | struct hid_field *field; | 739 | struct hid_field *field; |
708 | unsigned count; | 740 | unsigned count; |
709 | int r, n; | 741 | int r, n; |
710 | 742 | ||
711 | if (report->id != td->mt_report_id) | ||
712 | return; | ||
713 | |||
714 | if (!(hid->claimed & HID_CLAIMED_INPUT)) | ||
715 | return; | ||
716 | |||
717 | /* | 743 | /* |
718 | * Includes multi-packet support where subsequent | 744 | * Includes multi-packet support where subsequent |
719 | * packets are sent with zero contactcount. | 745 | * packets are sent with zero contactcount. |
@@ -736,6 +762,91 @@ static void mt_report(struct hid_device *hid, struct hid_report *report) | |||
736 | mt_process_mt_event(hid, field, &field->usage[n], | 762 | mt_process_mt_event(hid, field, &field->usage[n], |
737 | field->value[n]); | 763 | field->value[n]); |
738 | } | 764 | } |
765 | |||
766 | if (td->num_received >= td->num_expected) | ||
767 | mt_sync_frame(td, report->field[0]->hidinput->input); | ||
768 | } | ||
769 | |||
770 | static void mt_touch_input_configured(struct hid_device *hdev, | ||
771 | struct hid_input *hi) | ||
772 | { | ||
773 | struct mt_device *td = hid_get_drvdata(hdev); | ||
774 | struct mt_class *cls = &td->mtclass; | ||
775 | struct input_dev *input = hi->input; | ||
776 | |||
777 | if (!td->maxcontacts) | ||
778 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; | ||
779 | |||
780 | mt_post_parse(td); | ||
781 | if (td->serial_maybe) | ||
782 | mt_post_parse_default_settings(td); | ||
783 | |||
784 | if (cls->is_indirect) | ||
785 | td->mt_flags |= INPUT_MT_POINTER; | ||
786 | |||
787 | if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) | ||
788 | td->mt_flags |= INPUT_MT_DROP_UNUSED; | ||
789 | |||
790 | input_mt_init_slots(input, td->maxcontacts, td->mt_flags); | ||
791 | |||
792 | td->mt_flags = 0; | ||
793 | } | ||
794 | |||
795 | static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
796 | struct hid_field *field, struct hid_usage *usage, | ||
797 | unsigned long **bit, int *max) | ||
798 | { | ||
799 | /* Only map fields from TouchScreen or TouchPad collections. | ||
800 | * We need to ignore fields that belong to other collections | ||
801 | * such as Mouse that might have the same GenericDesktop usages. */ | ||
802 | if (field->application != HID_DG_TOUCHSCREEN && | ||
803 | field->application != HID_DG_PEN && | ||
804 | field->application != HID_DG_TOUCHPAD) | ||
805 | return -1; | ||
806 | |||
807 | if (field->physical == HID_DG_STYLUS) | ||
808 | return mt_pen_input_mapping(hdev, hi, field, usage, bit, max); | ||
809 | |||
810 | return mt_touch_input_mapping(hdev, hi, field, usage, bit, max); | ||
811 | } | ||
812 | |||
813 | static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, | ||
814 | struct hid_field *field, struct hid_usage *usage, | ||
815 | unsigned long **bit, int *max) | ||
816 | { | ||
817 | if (field->physical == HID_DG_STYLUS) | ||
818 | return mt_pen_input_mapped(hdev, hi, field, usage, bit, max); | ||
819 | |||
820 | return mt_touch_input_mapped(hdev, hi, field, usage, bit, max); | ||
821 | } | ||
822 | |||
823 | static int mt_event(struct hid_device *hid, struct hid_field *field, | ||
824 | struct hid_usage *usage, __s32 value) | ||
825 | { | ||
826 | struct mt_device *td = hid_get_drvdata(hid); | ||
827 | |||
828 | if (field->report->id == td->mt_report_id) | ||
829 | return mt_touch_event(hid, field, usage, value); | ||
830 | |||
831 | if (field->report->id == td->pen_report_id) | ||
832 | return mt_pen_event(hid, field, usage, value); | ||
833 | |||
834 | /* ignore other reports */ | ||
835 | return 1; | ||
836 | } | ||
837 | |||
838 | static void mt_report(struct hid_device *hid, struct hid_report *report) | ||
839 | { | ||
840 | struct mt_device *td = hid_get_drvdata(hid); | ||
841 | |||
842 | if (!(hid->claimed & HID_CLAIMED_INPUT)) | ||
843 | return; | ||
844 | |||
845 | if (report->id == td->mt_report_id) | ||
846 | mt_touch_report(hid, report); | ||
847 | |||
848 | if (report->id == td->pen_report_id) | ||
849 | mt_pen_report(hid, report); | ||
739 | } | 850 | } |
740 | 851 | ||
741 | static void mt_set_input_mode(struct hid_device *hdev) | 852 | static void mt_set_input_mode(struct hid_device *hdev) |
@@ -812,32 +923,18 @@ static void mt_post_parse(struct mt_device *td) | |||
812 | } | 923 | } |
813 | 924 | ||
814 | static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi) | 925 | static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi) |
815 | |||
816 | { | 926 | { |
817 | struct mt_device *td = hid_get_drvdata(hdev); | 927 | struct mt_device *td = hid_get_drvdata(hdev); |
818 | struct mt_class *cls = &td->mtclass; | 928 | char *name = kstrdup(hdev->name, GFP_KERNEL); |
819 | struct input_dev *input = hi->input; | ||
820 | 929 | ||
821 | /* Only initialize slots for MT input devices */ | 930 | if (name) |
822 | if (!test_bit(ABS_MT_POSITION_X, input->absbit)) | 931 | hi->input->name = name; |
823 | return; | ||
824 | 932 | ||
825 | if (!td->maxcontacts) | 933 | if (hi->report->id == td->mt_report_id) |
826 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; | 934 | mt_touch_input_configured(hdev, hi); |
827 | 935 | ||
828 | mt_post_parse(td); | 936 | if (hi->report->id == td->pen_report_id) |
829 | if (td->serial_maybe) | 937 | mt_pen_input_configured(hdev, hi); |
830 | mt_post_parse_default_settings(td); | ||
831 | |||
832 | if (cls->is_indirect) | ||
833 | td->mt_flags |= INPUT_MT_POINTER; | ||
834 | |||
835 | if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) | ||
836 | td->mt_flags |= INPUT_MT_DROP_UNUSED; | ||
837 | |||
838 | input_mt_init_slots(input, td->maxcontacts, td->mt_flags); | ||
839 | |||
840 | td->mt_flags = 0; | ||
841 | } | 938 | } |
842 | 939 | ||
843 | static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | 940 | static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) |
@@ -845,6 +942,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
845 | int ret, i; | 942 | int ret, i; |
846 | struct mt_device *td; | 943 | struct mt_device *td; |
847 | struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ | 944 | struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */ |
945 | struct hid_input *hi; | ||
848 | 946 | ||
849 | for (i = 0; mt_classes[i].name ; i++) { | 947 | for (i = 0; mt_classes[i].name ; i++) { |
850 | if (id->driver_data == mt_classes[i].name) { | 948 | if (id->driver_data == mt_classes[i].name) { |
@@ -858,6 +956,14 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
858 | */ | 956 | */ |
859 | hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; | 957 | hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; |
860 | 958 | ||
959 | /* | ||
960 | * This allows the driver to handle different input sensors | ||
961 | * that emits events through different reports on the same HID | ||
962 | * device. | ||
963 | */ | ||
964 | hdev->quirks |= HID_QUIRK_MULTI_INPUT; | ||
965 | hdev->quirks |= HID_QUIRK_NO_EMPTY_INPUT; | ||
966 | |||
861 | td = kzalloc(sizeof(struct mt_device), GFP_KERNEL); | 967 | td = kzalloc(sizeof(struct mt_device), GFP_KERNEL); |
862 | if (!td) { | 968 | if (!td) { |
863 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); | 969 | dev_err(&hdev->dev, "cannot allocate multitouch data\n"); |
@@ -867,6 +973,8 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
867 | td->inputmode = -1; | 973 | td->inputmode = -1; |
868 | td->maxcontact_report_id = -1; | 974 | td->maxcontact_report_id = -1; |
869 | td->cc_index = -1; | 975 | td->cc_index = -1; |
976 | td->mt_report_id = -1; | ||
977 | td->pen_report_id = -1; | ||
870 | hid_set_drvdata(hdev, td); | 978 | hid_set_drvdata(hdev, td); |
871 | 979 | ||
872 | td->fields = kzalloc(sizeof(struct mt_fields), GFP_KERNEL); | 980 | td->fields = kzalloc(sizeof(struct mt_fields), GFP_KERNEL); |
@@ -885,7 +993,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
885 | 993 | ||
886 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 994 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
887 | if (ret) | 995 | if (ret) |
888 | goto fail; | 996 | goto hid_fail; |
889 | 997 | ||
890 | ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); | 998 | ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); |
891 | 999 | ||
@@ -897,6 +1005,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
897 | 1005 | ||
898 | return 0; | 1006 | return 0; |
899 | 1007 | ||
1008 | hid_fail: | ||
1009 | list_for_each_entry(hi, &hdev->inputs, list) | ||
1010 | mt_free_input_name(hi); | ||
900 | fail: | 1011 | fail: |
901 | kfree(td->fields); | 1012 | kfree(td->fields); |
902 | kfree(td); | 1013 | kfree(td); |
@@ -926,8 +1037,14 @@ static int mt_resume(struct hid_device *hdev) | |||
926 | static void mt_remove(struct hid_device *hdev) | 1037 | static void mt_remove(struct hid_device *hdev) |
927 | { | 1038 | { |
928 | struct mt_device *td = hid_get_drvdata(hdev); | 1039 | struct mt_device *td = hid_get_drvdata(hdev); |
1040 | struct hid_input *hi; | ||
1041 | |||
929 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); | 1042 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); |
930 | hid_hw_stop(hdev); | 1043 | hid_hw_stop(hdev); |
1044 | |||
1045 | list_for_each_entry(hi, &hdev->inputs, list) | ||
1046 | mt_free_input_name(hi); | ||
1047 | |||
931 | kfree(td); | 1048 | kfree(td); |
932 | hid_set_drvdata(hdev, NULL); | 1049 | hid_set_drvdata(hdev, NULL); |
933 | } | 1050 | } |