diff options
| author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2018-07-13 10:13:45 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2018-07-17 09:33:47 -0400 |
| commit | f146d1c4d7eafde96a33838e52ba7568d05bf1f7 (patch) | |
| tree | 96eb9c55d06267336ac2a4d2765790fb953672f9 /drivers/hid | |
| parent | cf6d15d7b1f386905616912b2d450c8d7092a0f0 (diff) | |
HID: multitouch: Store per collection multitouch data
Currently, hid-multitouch can only handle one multitouch collection at
a time. This is an issue for the Dell Canvas, as the Totem (a dial tool)
is also using a multitouch-like collection.
Factor out the multitouch collection data in their own struct.
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
| -rw-r--r-- | drivers/hid/hid-multitouch.c | 380 |
1 files changed, 230 insertions, 150 deletions
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 91624a2240ca..cd207e99d26a 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
| @@ -28,14 +28,11 @@ | |||
| 28 | */ | 28 | */ |
| 29 | 29 | ||
| 30 | /* | 30 | /* |
| 31 | * This driver is regularly tested thanks to the tool hid-test[1]. | 31 | * This driver is regularly tested thanks to the test suite in hid-tools[1]. |
| 32 | * This tool relies on hid-replay[2] and a database of hid devices[3]. | ||
| 33 | * Please run these regression tests before patching this module so that | 32 | * Please run these regression tests before patching this module so that |
| 34 | * your patch won't break existing known devices. | 33 | * your patch won't break existing known devices. |
| 35 | * | 34 | * |
| 36 | * [1] https://github.com/bentiss/hid-test | 35 | * [1] https://gitlab.freedesktop.org/libevdev/hid-tools |
| 37 | * [2] https://github.com/bentiss/hid-replay | ||
| 38 | * [3] https://github.com/bentiss/hid-devices | ||
| 39 | */ | 36 | */ |
| 40 | 37 | ||
| 41 | #include <linux/device.h> | 38 | #include <linux/device.h> |
| @@ -99,6 +96,37 @@ struct mt_slot { | |||
| 99 | bool has_azimuth; /* the contact reports azimuth */ | 96 | bool has_azimuth; /* the contact reports azimuth */ |
| 100 | }; | 97 | }; |
| 101 | 98 | ||
| 99 | struct mt_application { | ||
| 100 | struct list_head list; | ||
| 101 | unsigned int application; | ||
| 102 | struct mt_slot curdata; /* placeholder of incoming data */ | ||
| 103 | |||
| 104 | int cc_index; /* contact count field index in the report */ | ||
| 105 | int cc_value_index; /* contact count value index in the field */ | ||
| 106 | int scantime_index; /* scantime field index in the report */ | ||
| 107 | int scantime_val_index; /* scantime value index in the field */ | ||
| 108 | unsigned int last_slot_field; /* the last field of a slot */ | ||
| 109 | bool curvalid; /* is the current contact valid? */ | ||
| 110 | |||
| 111 | int left_button_state; /* left button state */ | ||
| 112 | unsigned int mt_flags; /* flags to pass to input-mt */ | ||
| 113 | |||
| 114 | __u8 num_received; /* how many contacts we received */ | ||
| 115 | __u8 num_expected; /* expected last contact index */ | ||
| 116 | __u8 buttons_count; /* number of physical buttons per touchpad */ | ||
| 117 | __u8 touches_by_report; /* how many touches are present in one report: | ||
| 118 | * 1 means we should use a serial protocol | ||
| 119 | * > 1 means hybrid (multitouch) protocol | ||
| 120 | */ | ||
| 121 | |||
| 122 | __s32 dev_time; /* the scan time provided by the device */ | ||
| 123 | unsigned long jiffies; /* the frame's jiffies */ | ||
| 124 | int timestamp; /* the timestamp to be sent */ | ||
| 125 | int prev_scantime; /* scantime reported previously */ | ||
| 126 | |||
| 127 | bool have_contact_count; | ||
| 128 | }; | ||
| 129 | |||
| 102 | struct mt_class { | 130 | struct mt_class { |
| 103 | __s32 name; /* MT_CLS */ | 131 | __s32 name; /* MT_CLS */ |
| 104 | __s32 quirks; | 132 | __s32 quirks; |
| @@ -117,40 +145,24 @@ struct mt_fields { | |||
| 117 | }; | 145 | }; |
| 118 | 146 | ||
| 119 | struct mt_device { | 147 | struct mt_device { |
| 120 | struct mt_slot curdata; /* placeholder of incoming data */ | ||
| 121 | struct mt_class mtclass; /* our mt device class */ | 148 | struct mt_class mtclass; /* our mt device class */ |
| 122 | struct timer_list release_timer; /* to release sticky fingers */ | 149 | struct timer_list release_timer; /* to release sticky fingers */ |
| 123 | struct hid_device *hdev; /* hid_device we're attached to */ | 150 | struct hid_device *hdev; /* hid_device we're attached to */ |
| 124 | struct mt_fields *fields; /* temporary placeholder for storing the | 151 | struct mt_fields *fields; /* temporary placeholder for storing the |
| 125 | multitouch fields */ | 152 | multitouch fields */ |
| 126 | unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ | 153 | unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ |
| 127 | int cc_index; /* contact count field index in the report */ | ||
| 128 | int cc_value_index; /* contact count value index in the field */ | ||
| 129 | int scantime_index; /* scantime field index in the report */ | ||
| 130 | int scantime_val_index; /* scantime value index in the field */ | ||
| 131 | int prev_scantime; /* scantime reported in the previous packet */ | ||
| 132 | int left_button_state; /* left button state */ | ||
| 133 | unsigned last_slot_field; /* the last field of a slot */ | ||
| 134 | unsigned mt_report_id; /* the report ID of the multitouch device */ | 154 | unsigned mt_report_id; /* the report ID of the multitouch device */ |
| 135 | __u8 inputmode_value; /* InputMode HID feature value */ | 155 | __u8 inputmode_value; /* InputMode HID feature value */ |
| 136 | __u8 num_received; /* how many contacts we received */ | ||
| 137 | __u8 num_expected; /* expected last contact index */ | ||
| 138 | __u8 maxcontacts; | 156 | __u8 maxcontacts; |
| 139 | __u8 touches_by_report; /* how many touches are present in one report: | ||
| 140 | * 1 means we should use a serial protocol | ||
| 141 | * > 1 means hybrid (multitouch) protocol */ | ||
| 142 | __u8 buttons_count; /* number of physical buttons per touchpad */ | ||
| 143 | bool is_buttonpad; /* is this device a button pad? */ | 157 | bool is_buttonpad; /* is this device a button pad? */ |
| 144 | bool serial_maybe; /* need to check for serial protocol */ | 158 | bool serial_maybe; /* need to check for serial protocol */ |
| 145 | bool curvalid; /* is the current contact valid? */ | 159 | |
| 146 | unsigned mt_flags; /* flags to pass to input-mt */ | 160 | struct list_head applications; |
| 147 | __s32 dev_time; /* the scan time provided by the device */ | ||
| 148 | unsigned long jiffies; /* the frame's jiffies */ | ||
| 149 | int timestamp; /* the timestamp to be sent */ | ||
| 150 | }; | 161 | }; |
| 151 | 162 | ||
| 152 | static void mt_post_parse_default_settings(struct mt_device *td); | 163 | static void mt_post_parse_default_settings(struct mt_device *td, |
| 153 | static void mt_post_parse(struct mt_device *td); | 164 | struct mt_application *app); |
| 165 | static void mt_post_parse(struct mt_device *td, struct mt_application *app); | ||
| 154 | 166 | ||
| 155 | /* classes of device behavior */ | 167 | /* classes of device behavior */ |
| 156 | #define MT_CLS_DEFAULT 0x0001 | 168 | #define MT_CLS_DEFAULT 0x0001 |
| @@ -203,10 +215,10 @@ static void mt_post_parse(struct mt_device *td); | |||
| 203 | * to a valid contact that was just read. | 215 | * to a valid contact that was just read. |
| 204 | */ | 216 | */ |
| 205 | 217 | ||
| 206 | static int cypress_compute_slot(struct mt_device *td) | 218 | static int cypress_compute_slot(struct mt_application *app) |
| 207 | { | 219 | { |
| 208 | if (td->curdata.contactid != 0 || td->num_received == 0) | 220 | if (app->curdata.contactid != 0 || app->num_received == 0) |
| 209 | return td->curdata.contactid; | 221 | return app->curdata.contactid; |
| 210 | else | 222 | else |
| 211 | return -1; | 223 | return -1; |
| 212 | } | 224 | } |
| @@ -353,15 +365,22 @@ static ssize_t mt_set_quirks(struct device *dev, | |||
| 353 | { | 365 | { |
| 354 | struct hid_device *hdev = to_hid_device(dev); | 366 | struct hid_device *hdev = to_hid_device(dev); |
| 355 | struct mt_device *td = hid_get_drvdata(hdev); | 367 | struct mt_device *td = hid_get_drvdata(hdev); |
| 368 | struct mt_application *application; | ||
| 356 | 369 | ||
| 357 | unsigned long val; | 370 | unsigned long val; |
| 371 | bool confidence_found = false; | ||
| 358 | 372 | ||
| 359 | if (kstrtoul(buf, 0, &val)) | 373 | if (kstrtoul(buf, 0, &val)) |
| 360 | return -EINVAL; | 374 | return -EINVAL; |
| 361 | 375 | ||
| 362 | td->mtclass.quirks = val; | 376 | td->mtclass.quirks = val; |
| 363 | 377 | ||
| 364 | if (td->cc_index < 0) | 378 | list_for_each_entry(application, &td->applications, list) { |
| 379 | if (application->have_contact_count) | ||
| 380 | confidence_found = true; | ||
| 381 | } | ||
| 382 | |||
| 383 | if (!confidence_found) | ||
| 365 | td->mtclass.quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; | 384 | td->mtclass.quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
| 366 | 385 | ||
| 367 | return count; | 386 | return count; |
| @@ -457,6 +476,55 @@ static void set_abs(struct input_dev *input, unsigned int code, | |||
| 457 | input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); | 476 | input_abs_set_res(input, code, hidinput_calc_abs_res(field, code)); |
| 458 | } | 477 | } |
| 459 | 478 | ||
| 479 | static struct mt_application *mt_allocate_application(struct mt_device *td, | ||
| 480 | unsigned int application) | ||
| 481 | { | ||
| 482 | struct mt_application *mt_application; | ||
| 483 | |||
| 484 | mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), | ||
| 485 | GFP_KERNEL); | ||
| 486 | if (!mt_application) | ||
| 487 | return NULL; | ||
| 488 | |||
| 489 | mt_application->application = application; | ||
| 490 | |||
| 491 | if (application == HID_DG_TOUCHSCREEN) | ||
| 492 | mt_application->mt_flags |= INPUT_MT_DIRECT; | ||
| 493 | |||
| 494 | /* | ||
| 495 | * Model touchscreens providing buttons as touchpads. | ||
| 496 | */ | ||
| 497 | if (application == HID_DG_TOUCHPAD) { | ||
| 498 | mt_application->mt_flags |= INPUT_MT_POINTER; | ||
| 499 | td->inputmode_value = MT_INPUTMODE_TOUCHPAD; | ||
| 500 | } | ||
| 501 | |||
| 502 | mt_application->cc_index = -1; | ||
| 503 | mt_application->scantime_index = -1; | ||
| 504 | |||
| 505 | list_add_tail(&mt_application->list, &td->applications); | ||
| 506 | |||
| 507 | return mt_application; | ||
| 508 | } | ||
| 509 | |||
| 510 | static struct mt_application *mt_find_application(struct mt_device *td, | ||
| 511 | unsigned int application) | ||
| 512 | { | ||
| 513 | struct mt_application *tmp, *mt_application = NULL; | ||
| 514 | |||
| 515 | list_for_each_entry(tmp, &td->applications, list) { | ||
| 516 | if (application == tmp->application) { | ||
| 517 | mt_application = tmp; | ||
| 518 | break; | ||
| 519 | } | ||
| 520 | } | ||
| 521 | |||
| 522 | if (!mt_application) | ||
| 523 | mt_application = mt_allocate_application(td, application); | ||
| 524 | |||
| 525 | return mt_application; | ||
| 526 | } | ||
| 527 | |||
| 460 | static void mt_store_field(struct hid_usage *usage, struct mt_device *td, | 528 | static void mt_store_field(struct hid_usage *usage, struct mt_device *td, |
| 461 | struct hid_input *hi) | 529 | struct hid_input *hi) |
| 462 | { | 530 | { |
| @@ -470,28 +538,24 @@ static void mt_store_field(struct hid_usage *usage, struct mt_device *td, | |||
| 470 | 538 | ||
| 471 | static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | 539 | static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 472 | struct hid_field *field, struct hid_usage *usage, | 540 | struct hid_field *field, struct hid_usage *usage, |
| 473 | unsigned long **bit, int *max) | 541 | unsigned long **bit, int *max, struct mt_application *app) |
| 474 | { | 542 | { |
| 475 | struct mt_device *td = hid_get_drvdata(hdev); | 543 | struct mt_device *td = hid_get_drvdata(hdev); |
| 476 | struct mt_class *cls = &td->mtclass; | 544 | struct mt_class *cls = &td->mtclass; |
| 477 | int code; | 545 | int code; |
| 478 | struct hid_usage *prev_usage = NULL; | 546 | struct hid_usage *prev_usage = NULL; |
| 479 | 547 | ||
| 480 | if (field->application == HID_DG_TOUCHSCREEN) | ||
| 481 | td->mt_flags |= INPUT_MT_DIRECT; | ||
| 482 | |||
| 483 | /* | 548 | /* |
| 484 | * Model touchscreens providing buttons as touchpads. | 549 | * Model touchscreens providing buttons as touchpads. |
| 485 | */ | 550 | */ |
| 486 | if (field->application == HID_DG_TOUCHPAD || | 551 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { |
| 487 | (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { | 552 | app->mt_flags |= INPUT_MT_POINTER; |
| 488 | td->mt_flags |= INPUT_MT_POINTER; | ||
| 489 | td->inputmode_value = MT_INPUTMODE_TOUCHPAD; | 553 | td->inputmode_value = MT_INPUTMODE_TOUCHPAD; |
| 490 | } | 554 | } |
| 491 | 555 | ||
| 492 | /* count the buttons on touchpads */ | 556 | /* count the buttons on touchpads */ |
| 493 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) | 557 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) |
| 494 | td->buttons_count++; | 558 | app->buttons_count++; |
| 495 | 559 | ||
| 496 | if (usage->usage_index) | 560 | if (usage->usage_index) |
| 497 | prev_usage = &field->usage[usage->usage_index - 1]; | 561 | prev_usage = &field->usage[usage->usage_index - 1]; |
| @@ -501,33 +565,23 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 501 | case HID_UP_GENDESK: | 565 | case HID_UP_GENDESK: |
| 502 | switch (usage->hid) { | 566 | switch (usage->hid) { |
| 503 | case HID_GD_X: | 567 | case HID_GD_X: |
| 504 | if (prev_usage && (prev_usage->hid == usage->hid)) { | 568 | if (prev_usage && (prev_usage->hid == usage->hid)) |
| 505 | hid_map_usage(hi, usage, bit, max, | 569 | code = ABS_MT_TOOL_X; |
| 506 | EV_ABS, ABS_MT_TOOL_X); | 570 | else |
| 507 | set_abs(hi->input, ABS_MT_TOOL_X, field, | 571 | code = ABS_MT_POSITION_X; |
| 508 | cls->sn_move); | ||
| 509 | } else { | ||
| 510 | hid_map_usage(hi, usage, bit, max, | ||
| 511 | EV_ABS, ABS_MT_POSITION_X); | ||
| 512 | set_abs(hi->input, ABS_MT_POSITION_X, field, | ||
| 513 | cls->sn_move); | ||
| 514 | } | ||
| 515 | 572 | ||
| 573 | hid_map_usage(hi, usage, bit, max, EV_ABS, code); | ||
| 574 | set_abs(hi->input, code, field, cls->sn_move); | ||
| 516 | mt_store_field(usage, td, hi); | 575 | mt_store_field(usage, td, hi); |
| 517 | return 1; | 576 | return 1; |
| 518 | case HID_GD_Y: | 577 | case HID_GD_Y: |
| 519 | if (prev_usage && (prev_usage->hid == usage->hid)) { | 578 | if (prev_usage && (prev_usage->hid == usage->hid)) |
| 520 | hid_map_usage(hi, usage, bit, max, | 579 | code = ABS_MT_TOOL_Y; |
| 521 | EV_ABS, ABS_MT_TOOL_Y); | 580 | else |
| 522 | set_abs(hi->input, ABS_MT_TOOL_Y, field, | 581 | code = ABS_MT_POSITION_Y; |
| 523 | cls->sn_move); | ||
| 524 | } else { | ||
| 525 | hid_map_usage(hi, usage, bit, max, | ||
| 526 | EV_ABS, ABS_MT_POSITION_Y); | ||
| 527 | set_abs(hi->input, ABS_MT_POSITION_Y, field, | ||
| 528 | cls->sn_move); | ||
| 529 | } | ||
| 530 | 582 | ||
| 583 | hid_map_usage(hi, usage, bit, max, EV_ABS, code); | ||
| 584 | set_abs(hi->input, code, field, cls->sn_move); | ||
| 531 | mt_store_field(usage, td, hi); | 585 | mt_store_field(usage, td, hi); |
| 532 | return 1; | 586 | return 1; |
| 533 | } | 587 | } |
| @@ -558,7 +612,7 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 558 | return 1; | 612 | return 1; |
| 559 | case HID_DG_CONTACTID: | 613 | case HID_DG_CONTACTID: |
| 560 | mt_store_field(usage, td, hi); | 614 | mt_store_field(usage, td, hi); |
| 561 | td->touches_by_report++; | 615 | app->touches_by_report++; |
| 562 | td->mt_report_id = field->report->id; | 616 | td->mt_report_id = field->report->id; |
| 563 | return 1; | 617 | return 1; |
| 564 | case HID_DG_WIDTH: | 618 | case HID_DG_WIDTH: |
| @@ -602,20 +656,16 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 602 | if (field->index >= field->report->maxfield || | 656 | if (field->index >= field->report->maxfield || |
| 603 | usage->usage_index >= field->report_count) | 657 | usage->usage_index >= field->report_count) |
| 604 | return 1; | 658 | return 1; |
| 605 | td->scantime_index = field->index; | 659 | app->scantime_index = field->index; |
| 606 | td->scantime_val_index = usage->usage_index; | 660 | app->scantime_val_index = usage->usage_index; |
| 607 | /* | ||
| 608 | * We don't set td->last_slot_field as scan time is | ||
| 609 | * global to the report. | ||
| 610 | */ | ||
| 611 | return 1; | 661 | return 1; |
| 612 | case HID_DG_CONTACTCOUNT: | 662 | case HID_DG_CONTACTCOUNT: |
| 613 | /* Ignore if indexes are out of bounds. */ | 663 | /* Ignore if indexes are out of bounds. */ |
| 614 | if (field->index >= field->report->maxfield || | 664 | if (field->index >= field->report->maxfield || |
| 615 | usage->usage_index >= field->report_count) | 665 | usage->usage_index >= field->report_count) |
| 616 | return 1; | 666 | return 1; |
| 617 | td->cc_index = field->index; | 667 | app->cc_index = field->index; |
| 618 | td->cc_value_index = usage->usage_index; | 668 | app->cc_value_index = usage->usage_index; |
| 619 | return 1; | 669 | return 1; |
| 620 | case HID_DG_AZIMUTH: | 670 | case HID_DG_AZIMUTH: |
| 621 | hid_map_usage(hi, usage, bit, max, | 671 | hid_map_usage(hi, usage, bit, max, |
| @@ -666,39 +716,41 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 666 | return 0; | 716 | return 0; |
| 667 | } | 717 | } |
| 668 | 718 | ||
| 669 | static int mt_compute_slot(struct mt_device *td, struct input_dev *input) | 719 | static int mt_compute_slot(struct mt_device *td, struct mt_application *app, |
| 720 | struct input_dev *input) | ||
| 670 | { | 721 | { |
| 671 | __s32 quirks = td->mtclass.quirks; | 722 | __s32 quirks = td->mtclass.quirks; |
| 672 | 723 | ||
| 673 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) | 724 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID) |
| 674 | return td->curdata.contactid; | 725 | return app->curdata.contactid; |
| 675 | 726 | ||
| 676 | if (quirks & MT_QUIRK_CYPRESS) | 727 | if (quirks & MT_QUIRK_CYPRESS) |
| 677 | return cypress_compute_slot(td); | 728 | return cypress_compute_slot(app); |
| 678 | 729 | ||
| 679 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) | 730 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER) |
| 680 | return td->num_received; | 731 | return app->num_received; |
| 681 | 732 | ||
| 682 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) | 733 | if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE) |
| 683 | return td->curdata.contactid - 1; | 734 | return app->curdata.contactid - 1; |
| 684 | 735 | ||
| 685 | return input_mt_get_slot_by_key(input, td->curdata.contactid); | 736 | return input_mt_get_slot_by_key(input, app->curdata.contactid); |
| 686 | } | 737 | } |
| 687 | 738 | ||
| 688 | /* | 739 | /* |
| 689 | * this function is called when a whole contact has been processed, | 740 | * this function is called when a whole contact has been processed, |
| 690 | * so that it can assign it to a slot and store the data there | 741 | * so that it can assign it to a slot and store the data there |
| 691 | */ | 742 | */ |
| 692 | static void mt_complete_slot(struct mt_device *td, struct input_dev *input) | 743 | static void mt_complete_slot(struct mt_device *td, struct mt_application *app, |
| 744 | struct input_dev *input) | ||
| 693 | { | 745 | { |
| 694 | if ((td->mtclass.quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && | 746 | if ((td->mtclass.quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && |
| 695 | td->num_received >= td->num_expected) | 747 | app->num_received >= app->num_expected) |
| 696 | return; | 748 | return; |
| 697 | 749 | ||
| 698 | if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { | 750 | if (app->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { |
| 699 | int active; | 751 | int active; |
| 700 | int slotnum = mt_compute_slot(td, input); | 752 | int slotnum = mt_compute_slot(td, app, input); |
| 701 | struct mt_slot *s = &td->curdata; | 753 | struct mt_slot *s = &app->curdata; |
| 702 | struct input_mt *mt = input->mt; | 754 | struct input_mt *mt = input->mt; |
| 703 | 755 | ||
| 704 | if (slotnum < 0 || slotnum >= td->maxcontacts) | 756 | if (slotnum < 0 || slotnum >= td->maxcontacts) |
| @@ -753,23 +805,25 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) | |||
| 753 | } | 805 | } |
| 754 | } | 806 | } |
| 755 | 807 | ||
| 756 | td->num_received++; | 808 | app->num_received++; |
| 757 | } | 809 | } |
| 758 | 810 | ||
| 759 | /* | 811 | /* |
| 760 | * this function is called when a whole packet has been received and processed, | 812 | * this function is called when a whole packet has been received and processed, |
| 761 | * so that it can decide what to send to the input layer. | 813 | * so that it can decide what to send to the input layer. |
| 762 | */ | 814 | */ |
| 763 | static void mt_sync_frame(struct mt_device *td, struct input_dev *input) | 815 | static void mt_sync_frame(struct mt_device *td, struct mt_application *app, |
| 816 | struct input_dev *input) | ||
| 764 | { | 817 | { |
| 765 | if (td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) | 818 | if (td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) |
| 766 | input_event(input, EV_KEY, BTN_LEFT, td->left_button_state); | 819 | input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); |
| 767 | 820 | ||
| 768 | input_mt_sync_frame(input); | 821 | input_mt_sync_frame(input); |
| 769 | input_event(input, EV_MSC, MSC_TIMESTAMP, td->timestamp); | 822 | input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); |
| 770 | input_sync(input); | 823 | input_sync(input); |
| 771 | td->num_received = 0; | 824 | app->num_received = 0; |
| 772 | td->left_button_state = 0; | 825 | app->left_button_state = 0; |
| 826 | |||
| 773 | if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) | 827 | if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) |
| 774 | set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); | 828 | set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); |
| 775 | else | 829 | else |
| @@ -777,14 +831,13 @@ static void mt_sync_frame(struct mt_device *td, struct input_dev *input) | |||
| 777 | clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); | 831 | clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); |
| 778 | } | 832 | } |
| 779 | 833 | ||
| 780 | static int mt_compute_timestamp(struct mt_device *td, struct hid_field *field, | 834 | static int mt_compute_timestamp(struct mt_application *app, |
| 781 | __s32 value) | 835 | struct hid_field *field, __s32 value) |
| 782 | { | 836 | { |
| 783 | long delta = value - td->dev_time; | 837 | long delta = value - app->prev_scantime; |
| 784 | unsigned long jdelta = jiffies_to_usecs(jiffies - td->jiffies); | 838 | unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); |
| 785 | 839 | ||
| 786 | td->jiffies = jiffies; | 840 | app->jiffies = jiffies; |
| 787 | td->dev_time = value; | ||
| 788 | 841 | ||
| 789 | if (delta < 0) | 842 | if (delta < 0) |
| 790 | delta += field->logical_maximum; | 843 | delta += field->logical_maximum; |
| @@ -796,7 +849,7 @@ static int mt_compute_timestamp(struct mt_device *td, struct hid_field *field, | |||
| 796 | /* No data received for a while, resync the timestamp. */ | 849 | /* No data received for a while, resync the timestamp. */ |
| 797 | return 0; | 850 | return 0; |
| 798 | else | 851 | else |
| 799 | return td->timestamp + delta; | 852 | return app->timestamp + delta; |
| 800 | } | 853 | } |
| 801 | 854 | ||
| 802 | static int mt_touch_event(struct hid_device *hid, struct hid_field *field, | 855 | static int mt_touch_event(struct hid_device *hid, struct hid_field *field, |
| @@ -811,7 +864,7 @@ static int mt_touch_event(struct hid_device *hid, struct hid_field *field, | |||
| 811 | 864 | ||
| 812 | static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | 865 | static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, |
| 813 | struct hid_usage *usage, __s32 value, | 866 | struct hid_usage *usage, __s32 value, |
| 814 | bool first_packet) | 867 | struct mt_application *app, bool first_packet) |
| 815 | { | 868 | { |
| 816 | struct mt_device *td = hid_get_drvdata(hid); | 869 | struct mt_device *td = hid_get_drvdata(hid); |
| 817 | __s32 quirks = td->mtclass.quirks; | 870 | __s32 quirks = td->mtclass.quirks; |
| @@ -821,47 +874,48 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | |||
| 821 | switch (usage->hid) { | 874 | switch (usage->hid) { |
| 822 | case HID_DG_INRANGE: | 875 | case HID_DG_INRANGE: |
| 823 | if (quirks & MT_QUIRK_VALID_IS_INRANGE) | 876 | if (quirks & MT_QUIRK_VALID_IS_INRANGE) |
| 824 | td->curvalid = value; | 877 | app->curvalid = value; |
| 825 | if (quirks & MT_QUIRK_HOVERING) | 878 | if (quirks & MT_QUIRK_HOVERING) |
| 826 | td->curdata.inrange_state = value; | 879 | app->curdata.inrange_state = value; |
| 827 | break; | 880 | break; |
| 828 | case HID_DG_TIPSWITCH: | 881 | case HID_DG_TIPSWITCH: |
| 829 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) | 882 | if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
| 830 | td->curvalid = value; | 883 | app->curvalid = value; |
| 831 | td->curdata.touch_state = value; | 884 | app->curdata.touch_state = value; |
| 832 | break; | 885 | break; |
| 833 | case HID_DG_CONFIDENCE: | 886 | case HID_DG_CONFIDENCE: |
| 834 | if (quirks & MT_QUIRK_CONFIDENCE) | 887 | if (quirks & MT_QUIRK_CONFIDENCE) |
| 835 | td->curdata.confidence_state = value; | 888 | app->curdata.confidence_state = value; |
| 836 | if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) | 889 | if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) |
| 837 | td->curvalid = value; | 890 | app->curvalid = value; |
| 838 | break; | 891 | break; |
| 839 | case HID_DG_CONTACTID: | 892 | case HID_DG_CONTACTID: |
| 840 | td->curdata.contactid = value; | 893 | app->curdata.contactid = value; |
| 841 | break; | 894 | break; |
| 842 | case HID_DG_TIPPRESSURE: | 895 | case HID_DG_TIPPRESSURE: |
| 843 | td->curdata.p = value; | 896 | app->curdata.p = value; |
| 844 | break; | 897 | break; |
| 845 | case HID_GD_X: | 898 | case HID_GD_X: |
| 846 | if (usage->code == ABS_MT_TOOL_X) | 899 | if (usage->code == ABS_MT_TOOL_X) |
| 847 | td->curdata.cx = value; | 900 | app->curdata.cx = value; |
| 848 | else | 901 | else |
| 849 | td->curdata.x = value; | 902 | app->curdata.x = value; |
| 850 | break; | 903 | break; |
| 851 | case HID_GD_Y: | 904 | case HID_GD_Y: |
| 852 | if (usage->code == ABS_MT_TOOL_Y) | 905 | if (usage->code == ABS_MT_TOOL_Y) |
| 853 | td->curdata.cy = value; | 906 | app->curdata.cy = value; |
| 854 | else | 907 | else |
| 855 | td->curdata.y = value; | 908 | app->curdata.y = value; |
| 856 | break; | 909 | break; |
| 857 | case HID_DG_WIDTH: | 910 | case HID_DG_WIDTH: |
| 858 | td->curdata.w = value; | 911 | app->curdata.w = value; |
| 859 | break; | 912 | break; |
| 860 | case HID_DG_HEIGHT: | 913 | case HID_DG_HEIGHT: |
| 861 | td->curdata.h = value; | 914 | app->curdata.h = value; |
| 862 | break; | 915 | break; |
| 863 | case HID_DG_SCANTIME: | 916 | case HID_DG_SCANTIME: |
| 864 | td->timestamp = mt_compute_timestamp(td, field, value); | 917 | app->timestamp = mt_compute_timestamp(app, field, |
| 918 | value); | ||
| 865 | break; | 919 | break; |
| 866 | case HID_DG_CONTACTCOUNT: | 920 | case HID_DG_CONTACTCOUNT: |
| 867 | break; | 921 | break; |
| @@ -878,8 +932,8 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | |||
| 878 | */ | 932 | */ |
| 879 | if (value > field->logical_maximum / 2) | 933 | if (value > field->logical_maximum / 2) |
| 880 | value -= field->logical_maximum; | 934 | value -= field->logical_maximum; |
| 881 | td->curdata.a = -value; | 935 | app->curdata.a = -value; |
| 882 | td->curdata.has_azimuth = true; | 936 | app->curdata.has_azimuth = true; |
| 883 | break; | 937 | break; |
| 884 | case HID_DG_TOUCH: | 938 | case HID_DG_TOUCH: |
| 885 | /* do nothing */ | 939 | /* do nothing */ |
| @@ -904,7 +958,7 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | |||
| 904 | */ | 958 | */ |
| 905 | if ((quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && | 959 | if ((quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && |
| 906 | usage->type == EV_KEY && usage->code == BTN_LEFT) { | 960 | usage->type == EV_KEY && usage->code == BTN_LEFT) { |
| 907 | td->left_button_state |= value; | 961 | app->left_button_state |= value; |
| 908 | return; | 962 | return; |
| 909 | } | 963 | } |
| 910 | 964 | ||
| @@ -916,8 +970,9 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | |||
| 916 | 970 | ||
| 917 | if (usage->usage_index + 1 == field->report_count) { | 971 | if (usage->usage_index + 1 == field->report_count) { |
| 918 | /* we only take into account the last report. */ | 972 | /* we only take into account the last report. */ |
| 919 | if (usage->hid == td->last_slot_field) | 973 | if (usage->hid == app->last_slot_field) |
| 920 | mt_complete_slot(td, field->hidinput->input); | 974 | mt_complete_slot(td, app, |
| 975 | field->hidinput->input); | ||
| 921 | } | 976 | } |
| 922 | 977 | ||
| 923 | } | 978 | } |
| @@ -926,26 +981,34 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, | |||
| 926 | static void mt_touch_report(struct hid_device *hid, struct hid_report *report) | 981 | static void mt_touch_report(struct hid_device *hid, struct hid_report *report) |
| 927 | { | 982 | { |
| 928 | struct mt_device *td = hid_get_drvdata(hid); | 983 | struct mt_device *td = hid_get_drvdata(hid); |
| 984 | struct mt_application *app; | ||
| 929 | struct hid_field *field; | 985 | struct hid_field *field; |
| 930 | bool first_packet; | 986 | bool first_packet; |
| 931 | unsigned count; | 987 | unsigned count; |
| 932 | int r, n, scantime = 0; | 988 | int r, n; |
| 989 | int scantime = 0; | ||
| 990 | int contact_count = -1; | ||
| 933 | 991 | ||
| 934 | /* sticky fingers release in progress, abort */ | 992 | /* sticky fingers release in progress, abort */ |
| 935 | if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) | 993 | if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) |
| 936 | return; | 994 | return; |
| 937 | 995 | ||
| 996 | app = mt_find_application(td, report->application); | ||
| 997 | |||
| 998 | if (!app) | ||
| 999 | return; | ||
| 1000 | |||
| 938 | /* | 1001 | /* |
| 939 | * Includes multi-packet support where subsequent | 1002 | * Includes multi-packet support where subsequent |
| 940 | * packets are sent with zero contactcount. | 1003 | * packets are sent with zero contactcount. |
| 941 | */ | 1004 | */ |
| 942 | if (td->scantime_index >= 0) { | 1005 | if (app->scantime_index >= 0) { |
| 943 | field = report->field[td->scantime_index]; | 1006 | field = report->field[app->scantime_index]; |
| 944 | scantime = field->value[td->scantime_val_index]; | 1007 | scantime = field->value[app->scantime_val_index]; |
| 945 | } | 1008 | } |
| 946 | if (td->cc_index >= 0) { | 1009 | if (app->cc_index >= 0) { |
| 947 | struct hid_field *field = report->field[td->cc_index]; | 1010 | field = report->field[app->cc_index]; |
| 948 | int value = field->value[td->cc_value_index]; | 1011 | contact_count = field->value[app->cc_value_index]; |
| 949 | 1012 | ||
| 950 | /* | 1013 | /* |
| 951 | * For Win8 PTPs the first packet (td->num_received == 0) may | 1014 | * For Win8 PTPs the first packet (td->num_received == 0) may |
| @@ -955,15 +1018,16 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report) | |||
| 955 | * timestamp has changed. | 1018 | * timestamp has changed. |
| 956 | */ | 1019 | */ |
| 957 | if ((td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && | 1020 | if ((td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && |
| 958 | td->num_received == 0 && td->prev_scantime != scantime) | 1021 | app->num_received == 0 && |
| 959 | td->num_expected = value; | 1022 | app->prev_scantime != scantime) |
| 1023 | app->num_expected = contact_count; | ||
| 960 | /* A non 0 contact count always indicates a first packet */ | 1024 | /* A non 0 contact count always indicates a first packet */ |
| 961 | else if (value) | 1025 | else if (contact_count) |
| 962 | td->num_expected = value; | 1026 | app->num_expected = contact_count; |
| 963 | } | 1027 | } |
| 964 | td->prev_scantime = scantime; | 1028 | app->prev_scantime = scantime; |
| 965 | 1029 | ||
| 966 | first_packet = td->num_received == 0; | 1030 | first_packet = app->num_received == 0; |
| 967 | for (r = 0; r < report->maxfield; r++) { | 1031 | for (r = 0; r < report->maxfield; r++) { |
| 968 | field = report->field[r]; | 1032 | field = report->field[r]; |
| 969 | count = field->report_count; | 1033 | count = field->report_count; |
| @@ -973,11 +1037,11 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report) | |||
| 973 | 1037 | ||
| 974 | for (n = 0; n < count; n++) | 1038 | for (n = 0; n < count; n++) |
| 975 | mt_process_mt_event(hid, field, &field->usage[n], | 1039 | mt_process_mt_event(hid, field, &field->usage[n], |
| 976 | field->value[n], first_packet); | 1040 | field->value[n], app, first_packet); |
| 977 | } | 1041 | } |
| 978 | 1042 | ||
| 979 | if (td->num_received >= td->num_expected) | 1043 | if (app->num_received >= app->num_expected) |
| 980 | mt_sync_frame(td, report->field[0]->hidinput->input); | 1044 | mt_sync_frame(td, app, report->field[0]->hidinput->input); |
| 981 | 1045 | ||
| 982 | /* | 1046 | /* |
| 983 | * Windows 8 specs says 2 things: | 1047 | * Windows 8 specs says 2 things: |
| @@ -1009,7 +1073,8 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report) | |||
| 1009 | } | 1073 | } |
| 1010 | 1074 | ||
| 1011 | static int mt_touch_input_configured(struct hid_device *hdev, | 1075 | static int mt_touch_input_configured(struct hid_device *hdev, |
| 1012 | struct hid_input *hi) | 1076 | struct hid_input *hi, |
| 1077 | struct mt_application *app) | ||
| 1013 | { | 1078 | { |
| 1014 | struct mt_device *td = hid_get_drvdata(hdev); | 1079 | struct mt_device *td = hid_get_drvdata(hdev); |
| 1015 | struct mt_class *cls = &td->mtclass; | 1080 | struct mt_class *cls = &td->mtclass; |
| @@ -1019,28 +1084,29 @@ static int mt_touch_input_configured(struct hid_device *hdev, | |||
| 1019 | if (!td->maxcontacts) | 1084 | if (!td->maxcontacts) |
| 1020 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; | 1085 | td->maxcontacts = MT_DEFAULT_MAXCONTACT; |
| 1021 | 1086 | ||
| 1022 | mt_post_parse(td); | 1087 | mt_post_parse(td, app); |
| 1023 | if (td->serial_maybe) | 1088 | if (td->serial_maybe) |
| 1024 | mt_post_parse_default_settings(td); | 1089 | mt_post_parse_default_settings(td, app); |
| 1025 | 1090 | ||
| 1026 | if (cls->is_indirect) | 1091 | if (cls->is_indirect) |
| 1027 | td->mt_flags |= INPUT_MT_POINTER; | 1092 | app->mt_flags |= INPUT_MT_POINTER; |
| 1028 | 1093 | ||
| 1029 | if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) | 1094 | if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) |
| 1030 | td->mt_flags |= INPUT_MT_DROP_UNUSED; | 1095 | app->mt_flags |= INPUT_MT_DROP_UNUSED; |
| 1031 | 1096 | ||
| 1032 | /* check for clickpads */ | 1097 | /* check for clickpads */ |
| 1033 | if ((td->mt_flags & INPUT_MT_POINTER) && (td->buttons_count == 1)) | 1098 | if ((app->mt_flags & INPUT_MT_POINTER) && |
| 1099 | (app->buttons_count == 1)) | ||
| 1034 | td->is_buttonpad = true; | 1100 | td->is_buttonpad = true; |
| 1035 | 1101 | ||
| 1036 | if (td->is_buttonpad) | 1102 | if (td->is_buttonpad) |
| 1037 | __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); | 1103 | __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); |
| 1038 | 1104 | ||
| 1039 | ret = input_mt_init_slots(input, td->maxcontacts, td->mt_flags); | 1105 | ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); |
| 1040 | if (ret) | 1106 | if (ret) |
| 1041 | return ret; | 1107 | return ret; |
| 1042 | 1108 | ||
| 1043 | td->mt_flags = 0; | 1109 | app->mt_flags = 0; |
| 1044 | return 0; | 1110 | return 0; |
| 1045 | } | 1111 | } |
| 1046 | 1112 | ||
| @@ -1051,6 +1117,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 1051 | unsigned long **bit, int *max) | 1117 | unsigned long **bit, int *max) |
| 1052 | { | 1118 | { |
| 1053 | struct mt_device *td = hid_get_drvdata(hdev); | 1119 | struct mt_device *td = hid_get_drvdata(hdev); |
| 1120 | struct mt_application *application; | ||
| 1054 | 1121 | ||
| 1055 | /* | 1122 | /* |
| 1056 | * If mtclass.export_all_inputs is not set, only map fields from | 1123 | * If mtclass.export_all_inputs is not set, only map fields from |
| @@ -1093,6 +1160,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 1093 | return 1; | 1160 | return 1; |
| 1094 | } | 1161 | } |
| 1095 | 1162 | ||
| 1163 | application = mt_find_application(td, field->application); | ||
| 1164 | |||
| 1096 | /* | 1165 | /* |
| 1097 | * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" | 1166 | * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" |
| 1098 | * for the stylus. | 1167 | * for the stylus. |
| @@ -1109,7 +1178,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 1109 | 1178 | ||
| 1110 | if (field->application == HID_DG_TOUCHSCREEN || | 1179 | if (field->application == HID_DG_TOUCHSCREEN || |
| 1111 | field->application == HID_DG_TOUCHPAD) | 1180 | field->application == HID_DG_TOUCHPAD) |
| 1112 | return mt_touch_input_mapping(hdev, hi, field, usage, bit, max); | 1181 | return mt_touch_input_mapping(hdev, hi, field, usage, bit, max, |
| 1182 | application); | ||
| 1113 | 1183 | ||
| 1114 | /* let hid-core decide for the others */ | 1184 | /* let hid-core decide for the others */ |
| 1115 | return 0; | 1185 | return 0; |
| @@ -1259,12 +1329,13 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency, | |||
| 1259 | } | 1329 | } |
| 1260 | } | 1330 | } |
| 1261 | 1331 | ||
| 1262 | static void mt_post_parse_default_settings(struct mt_device *td) | 1332 | static void mt_post_parse_default_settings(struct mt_device *td, |
| 1333 | struct mt_application *app) | ||
| 1263 | { | 1334 | { |
| 1264 | __s32 quirks = td->mtclass.quirks; | 1335 | __s32 quirks = td->mtclass.quirks; |
| 1265 | 1336 | ||
| 1266 | /* unknown serial device needs special quirks */ | 1337 | /* unknown serial device needs special quirks */ |
| 1267 | if (td->touches_by_report == 1) { | 1338 | if (app->touches_by_report == 1) { |
| 1268 | quirks |= MT_QUIRK_ALWAYS_VALID; | 1339 | quirks |= MT_QUIRK_ALWAYS_VALID; |
| 1269 | quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; | 1340 | quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP; |
| 1270 | quirks &= ~MT_QUIRK_VALID_IS_INRANGE; | 1341 | quirks &= ~MT_QUIRK_VALID_IS_INRANGE; |
| @@ -1275,17 +1346,19 @@ static void mt_post_parse_default_settings(struct mt_device *td) | |||
| 1275 | td->mtclass.quirks = quirks; | 1346 | td->mtclass.quirks = quirks; |
| 1276 | } | 1347 | } |
| 1277 | 1348 | ||
| 1278 | static void mt_post_parse(struct mt_device *td) | 1349 | static void mt_post_parse(struct mt_device *td, struct mt_application *app) |
| 1279 | { | 1350 | { |
| 1280 | struct mt_fields *f = td->fields; | 1351 | struct mt_fields *f = td->fields; |
| 1281 | struct mt_class *cls = &td->mtclass; | 1352 | struct mt_class *cls = &td->mtclass; |
| 1282 | 1353 | ||
| 1283 | if (td->touches_by_report > 0) { | 1354 | if (app->touches_by_report > 0) { |
| 1284 | int field_count_per_touch = f->length / td->touches_by_report; | 1355 | int field_count_per_touch; |
| 1285 | td->last_slot_field = f->usages[field_count_per_touch - 1]; | 1356 | |
| 1357 | field_count_per_touch = f->length / app->touches_by_report; | ||
| 1358 | app->last_slot_field = f->usages[field_count_per_touch - 1]; | ||
| 1286 | } | 1359 | } |
| 1287 | 1360 | ||
| 1288 | if (td->cc_index < 0) | 1361 | if (app->cc_index < 0) |
| 1289 | cls->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; | 1362 | cls->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; |
| 1290 | } | 1363 | } |
| 1291 | 1364 | ||
| @@ -1295,13 +1368,17 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) | |||
| 1295 | char *name; | 1368 | char *name; |
| 1296 | const char *suffix = NULL; | 1369 | const char *suffix = NULL; |
| 1297 | unsigned int application = 0; | 1370 | unsigned int application = 0; |
| 1371 | struct mt_application *mt_application = NULL; | ||
| 1298 | struct hid_report *report; | 1372 | struct hid_report *report; |
| 1299 | int ret; | 1373 | int ret; |
| 1300 | 1374 | ||
| 1301 | list_for_each_entry(report, &hi->reports, hidinput_list) { | 1375 | list_for_each_entry(report, &hi->reports, hidinput_list) { |
| 1302 | application = report->application; | 1376 | application = report->application; |
| 1377 | mt_application = mt_find_application(td, application); | ||
| 1378 | |||
| 1303 | if (report->id == td->mt_report_id) { | 1379 | if (report->id == td->mt_report_id) { |
| 1304 | ret = mt_touch_input_configured(hdev, hi); | 1380 | ret = mt_touch_input_configured(hdev, hi, |
| 1381 | mt_application); | ||
| 1305 | if (ret) | 1382 | if (ret) |
| 1306 | return ret; | 1383 | return ret; |
| 1307 | } | 1384 | } |
| @@ -1390,6 +1467,7 @@ static void mt_fix_const_fields(struct hid_device *hdev, unsigned int usage) | |||
| 1390 | static void mt_release_contacts(struct hid_device *hid) | 1467 | static void mt_release_contacts(struct hid_device *hid) |
| 1391 | { | 1468 | { |
| 1392 | struct hid_input *hidinput; | 1469 | struct hid_input *hidinput; |
| 1470 | struct mt_application *application; | ||
| 1393 | struct mt_device *td = hid_get_drvdata(hid); | 1471 | struct mt_device *td = hid_get_drvdata(hid); |
| 1394 | 1472 | ||
| 1395 | list_for_each_entry(hidinput, &hid->inputs, list) { | 1473 | list_for_each_entry(hidinput, &hid->inputs, list) { |
| @@ -1409,7 +1487,9 @@ static void mt_release_contacts(struct hid_device *hid) | |||
| 1409 | } | 1487 | } |
| 1410 | } | 1488 | } |
| 1411 | 1489 | ||
| 1412 | td->num_received = 0; | 1490 | list_for_each_entry(application, &td->applications, list) { |
| 1491 | application->num_received = 0; | ||
| 1492 | } | ||
| 1413 | } | 1493 | } |
| 1414 | 1494 | ||
| 1415 | static void mt_expired_timeout(struct timer_list *t) | 1495 | static void mt_expired_timeout(struct timer_list *t) |
| @@ -1449,11 +1529,11 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1449 | td->hdev = hdev; | 1529 | td->hdev = hdev; |
| 1450 | td->mtclass = *mtclass; | 1530 | td->mtclass = *mtclass; |
| 1451 | td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; | 1531 | td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; |
| 1452 | td->cc_index = -1; | ||
| 1453 | td->scantime_index = -1; | ||
| 1454 | td->mt_report_id = -1; | 1532 | td->mt_report_id = -1; |
| 1455 | hid_set_drvdata(hdev, td); | 1533 | hid_set_drvdata(hdev, td); |
| 1456 | 1534 | ||
| 1535 | INIT_LIST_HEAD(&td->applications); | ||
| 1536 | |||
| 1457 | td->fields = devm_kzalloc(&hdev->dev, sizeof(struct mt_fields), | 1537 | td->fields = devm_kzalloc(&hdev->dev, sizeof(struct mt_fields), |
| 1458 | GFP_KERNEL); | 1538 | GFP_KERNEL); |
| 1459 | if (!td->fields) { | 1539 | if (!td->fields) { |
