Lines Matching +full:rate +full:- +full:touch +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr>
6 * Copyright (c) 2010-2013 Benjamin Tissoires <benjamin.tissoires@gmail.com>
7 * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France
8 * Copyright (c) 2012-2013 Red Hat, Inc
10 * This code is partly based on hid-egalax.c:
16 * This code is partly based on hid-3m-pct.c:
18 * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
27 * This driver is regularly tested thanks to the test suite in hid-tools[1].
31 * [1] https://gitlab.freedesktop.org/libevdev/hid-tools
49 #include "hid-ids.h"
102 bool *tip_state; /* is the touch valid? */
104 bool *confidence_state; /* is the touch made by a finger? */
120 unsigned int mt_flags; /* flags to pass to input-mt */
230 * these device-dependent functions determine what slot corresponds
237 if (*slot->contactid != 0 || application->num_received == 0) in cypress_compute_slot()
238 return *slot->contactid; in cypress_compute_slot()
240 return -1; in cypress_compute_slot()
410 return sprintf(buf, "%u\n", td->mtclass.quirks); in mt_show_quirks()
424 return -EINVAL; in mt_set_quirks()
426 td->mtclass.quirks = val; in mt_set_quirks()
428 list_for_each_entry(application, &td->applications, list) { in mt_set_quirks()
429 application->quirks = val; in mt_set_quirks()
430 if (!application->have_contact_count) in mt_set_quirks()
431 application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_set_quirks()
456 * marked as non-capable. in mt_get_feature()
458 if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) in mt_get_feature()
465 ret = hid_hw_raw_request(hdev, report->id, buf, size, in mt_get_feature()
468 dev_warn(&hdev->dev, "failed to fetch feature %d\n", in mt_get_feature()
469 report->id); in mt_get_feature()
474 dev_warn(&hdev->dev, "failed to report feature\n"); in mt_get_feature()
485 switch (usage->hid) { in mt_feature_mapping()
487 mt_get_feature(hdev, field->report); in mt_feature_mapping()
489 td->maxcontacts = field->value[0]; in mt_feature_mapping()
490 if (!td->maxcontacts && in mt_feature_mapping()
491 field->logical_maximum <= MT_MAX_MAXCONTACT) in mt_feature_mapping()
492 td->maxcontacts = field->logical_maximum; in mt_feature_mapping()
493 if (td->mtclass.maxcontacts) in mt_feature_mapping()
495 td->maxcontacts = td->mtclass.maxcontacts; in mt_feature_mapping()
499 if (usage->usage_index >= field->report_count) { in mt_feature_mapping()
500 dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); in mt_feature_mapping()
504 mt_get_feature(hdev, field->report); in mt_feature_mapping()
505 if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) in mt_feature_mapping()
506 td->is_buttonpad = true; in mt_feature_mapping()
511 if (usage->usage_index == 0) in mt_feature_mapping()
512 mt_get_feature(hdev, field->report); in mt_feature_mapping()
520 int fmin = field->logical_minimum; in set_abs()
521 int fmax = field->logical_maximum; in set_abs()
522 int fuzz = snratio ? (fmax - fmin) / snratio : 0; in set_abs()
532 usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); in mt_allocate_usage()
537 usage->x = DEFAULT_ZERO; in mt_allocate_usage()
538 usage->y = DEFAULT_ZERO; in mt_allocate_usage()
539 usage->cx = DEFAULT_ZERO; in mt_allocate_usage()
540 usage->cy = DEFAULT_ZERO; in mt_allocate_usage()
541 usage->p = DEFAULT_ZERO; in mt_allocate_usage()
542 usage->w = DEFAULT_ZERO; in mt_allocate_usage()
543 usage->h = DEFAULT_ZERO; in mt_allocate_usage()
544 usage->a = DEFAULT_ZERO; in mt_allocate_usage()
545 usage->contactid = DEFAULT_ZERO; in mt_allocate_usage()
546 usage->tip_state = DEFAULT_FALSE; in mt_allocate_usage()
547 usage->inrange_state = DEFAULT_FALSE; in mt_allocate_usage()
548 usage->confidence_state = DEFAULT_TRUE; in mt_allocate_usage()
550 list_add_tail(&usage->list, &application->mt_usages); in mt_allocate_usage()
558 unsigned int application = report->application; in mt_allocate_application()
561 mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), in mt_allocate_application()
566 mt_application->application = application; in mt_allocate_application()
567 INIT_LIST_HEAD(&mt_application->mt_usages); in mt_allocate_application()
570 mt_application->mt_flags |= INPUT_MT_DIRECT; in mt_allocate_application()
576 mt_application->mt_flags |= INPUT_MT_POINTER; in mt_allocate_application()
577 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_allocate_application()
580 mt_application->scantime = DEFAULT_ZERO; in mt_allocate_application()
581 mt_application->raw_cc = DEFAULT_ZERO; in mt_allocate_application()
582 mt_application->quirks = td->mtclass.quirks; in mt_allocate_application()
583 mt_application->report_id = report->id; in mt_allocate_application()
585 list_add_tail(&mt_application->list, &td->applications); in mt_allocate_application()
593 unsigned int application = report->application; in mt_find_application()
596 list_for_each_entry(tmp, &td->applications, list) { in mt_find_application()
597 if (application == tmp->application) { in mt_find_application()
598 if (!(td->mtclass.quirks & MT_QUIRK_SEPARATE_APP_REPORT) || in mt_find_application()
599 tmp->report_id == report->id) { in mt_find_application()
619 rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); in mt_allocate_report_data()
623 rdata->report = report; in mt_allocate_report_data()
624 rdata->application = mt_find_application(td, report); in mt_allocate_report_data()
626 if (!rdata->application) { in mt_allocate_report_data()
627 devm_kfree(&td->hdev->dev, rdata); in mt_allocate_report_data()
631 for (r = 0; r < report->maxfield; r++) { in mt_allocate_report_data()
632 field = report->field[r]; in mt_allocate_report_data()
634 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_allocate_report_data()
637 if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { in mt_allocate_report_data()
638 for (n = 0; n < field->report_count; n++) { in mt_allocate_report_data()
639 if (field->usage[n].hid == HID_DG_CONTACTID) { in mt_allocate_report_data()
640 rdata->is_mt_collection = true; in mt_allocate_report_data()
647 list_add_tail(&rdata->list, &td->reports); in mt_allocate_report_data()
657 list_for_each_entry(tmp, &td->reports, list) { in mt_find_report_data()
658 if (report == tmp->report) { in mt_find_report_data()
678 if (list_empty(&application->mt_usages)) in mt_store_field()
681 usage = list_last_entry(&application->mt_usages, in mt_store_field()
694 if (usage->contactid == DEFAULT_ZERO || in mt_store_field()
695 usage->x == DEFAULT_ZERO || in mt_store_field()
696 usage->y == DEFAULT_ZERO) { in mt_store_field()
713 &field->value[usage->usage_index], \
721 struct mt_class *cls = &td->mtclass; in mt_touch_input_mapping()
728 if (field->application == HID_DG_TOUCHSCREEN && in mt_touch_input_mapping()
729 (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { in mt_touch_input_mapping()
730 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_mapping()
731 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_touch_input_mapping()
735 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) in mt_touch_input_mapping()
736 app->buttons_count++; in mt_touch_input_mapping()
738 if (usage->usage_index) in mt_touch_input_mapping()
739 prev_usage = &field->usage[usage->usage_index - 1]; in mt_touch_input_mapping()
741 switch (usage->hid & HID_USAGE_PAGE) { in mt_touch_input_mapping()
744 switch (usage->hid) { in mt_touch_input_mapping()
746 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
754 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
757 * A system multi-axis that exports X and Y has a high in mt_touch_input_mapping()
760 if (field->application == HID_GD_SYSTEM_MULTIAXIS) { in mt_touch_input_mapping()
762 hi->input->propbit); in mt_touch_input_mapping()
763 input_set_abs_params(hi->input, in mt_touch_input_mapping()
771 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
779 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
786 switch (usage->hid) { in mt_touch_input_mapping()
788 if (app->quirks & MT_QUIRK_HOVERING) { in mt_touch_input_mapping()
789 input_set_abs_params(hi->input, in mt_touch_input_mapping()
795 if ((cls->name == MT_CLS_WIN_8 || in mt_touch_input_mapping()
796 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || in mt_touch_input_mapping()
797 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU || in mt_touch_input_mapping()
798 cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP) && in mt_touch_input_mapping()
799 (field->application == HID_DG_TOUCHPAD || in mt_touch_input_mapping()
800 field->application == HID_DG_TOUCHSCREEN)) in mt_touch_input_mapping()
801 app->quirks |= MT_QUIRK_CONFIDENCE; in mt_touch_input_mapping()
803 if (app->quirks & MT_QUIRK_CONFIDENCE) in mt_touch_input_mapping()
804 input_set_abs_params(hi->input, in mt_touch_input_mapping()
812 if (field->application != HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
813 input_set_capability(hi->input, in mt_touch_input_mapping()
819 app->touches_by_report++; in mt_touch_input_mapping()
822 if (!(app->quirks & MT_QUIRK_NO_AREA)) in mt_touch_input_mapping()
823 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, in mt_touch_input_mapping()
824 cls->sn_width); in mt_touch_input_mapping()
828 if (!(app->quirks & MT_QUIRK_NO_AREA)) { in mt_touch_input_mapping()
829 set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, in mt_touch_input_mapping()
830 cls->sn_height); in mt_touch_input_mapping()
837 hi->input->absbit)) in mt_touch_input_mapping()
838 input_set_abs_params(hi->input, in mt_touch_input_mapping()
844 set_abs(hi->input, ABS_MT_PRESSURE, field, in mt_touch_input_mapping()
845 cls->sn_pressure); in mt_touch_input_mapping()
849 input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); in mt_touch_input_mapping()
850 app->scantime = &field->value[usage->usage_index]; in mt_touch_input_mapping()
851 app->scantime_logical_max = field->logical_maximum; in mt_touch_input_mapping()
854 app->have_contact_count = true; in mt_touch_input_mapping()
855 app->raw_cc = &field->value[usage->usage_index]; in mt_touch_input_mapping()
863 input_set_abs_params(hi->input, ABS_MT_ORIENTATION, in mt_touch_input_mapping()
864 -field->logical_maximum / 4, in mt_touch_input_mapping()
865 field->logical_maximum / 4, in mt_touch_input_mapping()
866 cls->sn_move ? in mt_touch_input_mapping()
867 field->logical_maximum / cls->sn_move : 0, 0); in mt_touch_input_mapping()
872 return -1; in mt_touch_input_mapping()
874 /* Legacy devices use TIPSWITCH and not TOUCH. in mt_touch_input_mapping()
876 return -1; in mt_touch_input_mapping()
878 /* let hid-input decide for the others */ in mt_touch_input_mapping()
882 code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
884 * MS PTP spec says that external buttons left and right have in mt_touch_input_mapping()
887 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_input_mapping()
888 field->application == HID_DG_TOUCHPAD && in mt_touch_input_mapping()
889 (usage->hid & HID_USAGE) > 1) in mt_touch_input_mapping()
890 code--; in mt_touch_input_mapping()
892 if (field->application == HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
893 code = BTN_0 + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
897 return -1; in mt_touch_input_mapping()
898 input_set_capability(hi->input, EV_KEY, code); in mt_touch_input_mapping()
902 /* we do not want to map these: no input-oriented meaning */ in mt_touch_input_mapping()
903 return -1; in mt_touch_input_mapping()
913 __s32 quirks = app->quirks; in mt_compute_slot()
916 return *slot->contactid; in mt_compute_slot()
922 return app->num_received; in mt_compute_slot()
925 return *slot->contactid - 1; in mt_compute_slot()
927 return input_mt_get_slot_by_key(input, *slot->contactid); in mt_compute_slot()
937 for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { in mt_release_pending_palms()
938 clear_bit(slotnum, app->pending_palm_slots); in mt_release_pending_palms()
959 if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) in mt_sync_frame()
960 input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); in mt_sync_frame()
963 input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); in mt_sync_frame()
968 app->num_received = 0; in mt_sync_frame()
969 app->left_button_state = 0; in mt_sync_frame()
971 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) in mt_sync_frame()
972 set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
974 clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
975 clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_sync_frame()
980 long delta = value - app->prev_scantime; in mt_compute_timestamp()
981 unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); in mt_compute_timestamp()
983 app->jiffies = jiffies; in mt_compute_timestamp()
986 delta += app->scantime_logical_max; in mt_compute_timestamp()
995 return app->timestamp + delta; in mt_compute_timestamp()
1002 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) in mt_touch_event()
1003 hid->hiddev_hid_event(hid, field, usage, value); in mt_touch_event()
1012 struct input_mt *mt = input->mt; in mt_process_slot()
1013 struct hid_device *hdev = td->hdev; in mt_process_slot()
1014 __s32 quirks = app->quirks; in mt_process_slot()
1023 return -EINVAL; in mt_process_slot()
1026 app->num_received >= app->num_expected) in mt_process_slot()
1027 return -EAGAIN; in mt_process_slot()
1031 valid = *slot->inrange_state; in mt_process_slot()
1033 valid = *slot->tip_state; in mt_process_slot()
1035 valid = *slot->confidence_state; in mt_process_slot()
1042 if (slotnum < 0 || slotnum >= td->maxcontacts) in mt_process_slot()
1046 struct input_mt_slot *i_slot = &mt->slots[slotnum]; in mt_process_slot()
1050 return -EAGAIN; in mt_process_slot()
1054 confidence_state = *slot->confidence_state; in mt_process_slot()
1057 inrange_state = *slot->inrange_state; in mt_process_slot()
1059 active = *slot->tip_state || inrange_state; in mt_process_slot()
1061 if (app->application == HID_GD_SYSTEM_MULTIAXIS) in mt_process_slot()
1066 input_mt_is_active(&mt->slots[slotnum])) { in mt_process_slot()
1068 * The non-confidence was reported for in mt_process_slot()
1071 * lift-off as userspace will not be aware in mt_process_slot()
1072 * of non-confidence, so we need to split in mt_process_slot()
1077 set_bit(slotnum, app->pending_palm_slots); in mt_process_slot()
1085 int wide = (*slot->w > *slot->h); in mt_process_slot()
1086 int major = max(*slot->w, *slot->h); in mt_process_slot()
1087 int minor = min(*slot->w, *slot->h); in mt_process_slot()
1096 if (slot->a != DEFAULT_ZERO) { in mt_process_slot()
1098 * Azimuth is counter-clockwise and ranges from [0, MAX) in mt_process_slot()
1100 * [-MAX/2, MAX/2]. in mt_process_slot()
1103 * the limit of [-MAX/4, MAX/4], but the value can go in mt_process_slot()
1104 * out of range to [-MAX/2, MAX/2] to report an upside in mt_process_slot()
1107 azimuth = *slot->a; in mt_process_slot()
1111 azimuth -= max_azimuth * 4; in mt_process_slot()
1112 orientation = -azimuth; in mt_process_slot()
1114 orientation = -orientation; in mt_process_slot()
1120 * divided by two to match visual scale of touch in mt_process_slot()
1127 x = hdev->quirks & HID_QUIRK_X_INVERT ? in mt_process_slot()
1128 input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->x : in mt_process_slot()
1129 *slot->x; in mt_process_slot()
1130 y = hdev->quirks & HID_QUIRK_Y_INVERT ? in mt_process_slot()
1131 input_abs_get_max(input, ABS_MT_POSITION_Y) - *slot->y : in mt_process_slot()
1132 *slot->y; in mt_process_slot()
1133 cx = hdev->quirks & HID_QUIRK_X_INVERT ? in mt_process_slot()
1134 input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->cx : in mt_process_slot()
1135 *slot->cx; in mt_process_slot()
1136 cy = hdev->quirks & HID_QUIRK_Y_INVERT ? in mt_process_slot()
1137 input_abs_get_max(input, ABS_MT_POSITION_Y) - *slot->cy : in mt_process_slot()
1138 *slot->cy; in mt_process_slot()
1144 input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); in mt_process_slot()
1146 input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); in mt_process_slot()
1150 set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_process_slot()
1163 __s32 quirks = app->quirks; in mt_process_mt_event()
1164 struct input_dev *input = field->hidinput->input; in mt_process_mt_event()
1166 if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) in mt_process_mt_event()
1173 * non finger/touch events in the first_packet of a in mt_process_mt_event()
1174 * (possible) multi-packet frame. in mt_process_mt_event()
1186 if (usage->type == EV_KEY && usage->code == BTN_LEFT) { in mt_process_mt_event()
1187 app->left_button_state |= value; in mt_process_mt_event()
1192 input_event(input, usage->type, usage->code, value); in mt_process_mt_event()
1199 struct hid_report *report = rdata->report; in mt_touch_report()
1200 struct mt_application *app = rdata->application; in mt_touch_report()
1208 int contact_count = -1; in mt_touch_report()
1211 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_touch_report()
1214 scantime = *app->scantime; in mt_touch_report()
1215 app->timestamp = mt_compute_timestamp(app, scantime); in mt_touch_report()
1216 if (app->raw_cc != DEFAULT_ZERO) in mt_touch_report()
1217 contact_count = *app->raw_cc; in mt_touch_report()
1220 * Includes multi-packet support where subsequent in mt_touch_report()
1225 * For Win8 PTPs the first packet (td->num_received == 0) may in mt_touch_report()
1228 * of a possible multi-packet frame be checking that the in mt_touch_report()
1231 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_report()
1232 app->num_received == 0 && in mt_touch_report()
1233 app->prev_scantime != scantime) in mt_touch_report()
1234 app->num_expected = contact_count; in mt_touch_report()
1237 app->num_expected = contact_count; in mt_touch_report()
1239 app->prev_scantime = scantime; in mt_touch_report()
1241 first_packet = app->num_received == 0; in mt_touch_report()
1243 input = report->field[0]->hidinput->input; in mt_touch_report()
1245 list_for_each_entry(slot, &app->mt_usages, list) { in mt_touch_report()
1247 app->num_received++; in mt_touch_report()
1250 for (r = 0; r < report->maxfield; r++) { in mt_touch_report()
1251 field = report->field[r]; in mt_touch_report()
1252 count = field->report_count; in mt_touch_report()
1254 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_touch_report()
1259 &field->usage[n], field->value[n], in mt_touch_report()
1263 if (app->num_received >= app->num_expected) in mt_touch_report()
1268 * - once a contact has been reported, it has to be reported in each in mt_touch_report()
1270 * - the report rate when fingers are present has to be at least in mt_touch_report()
1271 * the refresh rate of the screen, 60 or 120 Hz in mt_touch_report()
1273 * I interprete this that the specification forces a report rate of in mt_touch_report()
1275 * Which means that if we do not get a report whithin 16 ms, either in mt_touch_report()
1284 if (app->quirks & MT_QUIRK_STICKY_FINGERS) { in mt_touch_report()
1285 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_touch_report()
1286 mod_timer(&td->release_timer, in mt_touch_report()
1289 del_timer(&td->release_timer); in mt_touch_report()
1292 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_touch_report()
1300 struct mt_class *cls = &td->mtclass; in mt_touch_input_configured()
1301 struct input_dev *input = hi->input; in mt_touch_input_configured()
1304 if (!td->maxcontacts) in mt_touch_input_configured()
1305 td->maxcontacts = MT_DEFAULT_MAXCONTACT; in mt_touch_input_configured()
1308 if (td->serial_maybe) in mt_touch_input_configured()
1311 if (cls->is_indirect) in mt_touch_input_configured()
1312 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_configured()
1314 if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) in mt_touch_input_configured()
1315 app->mt_flags |= INPUT_MT_DROP_UNUSED; in mt_touch_input_configured()
1318 if ((app->mt_flags & INPUT_MT_POINTER) && in mt_touch_input_configured()
1319 (app->buttons_count == 1)) in mt_touch_input_configured()
1320 td->is_buttonpad = true; in mt_touch_input_configured()
1322 if (td->is_buttonpad) in mt_touch_input_configured()
1323 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); in mt_touch_input_configured()
1325 app->pending_palm_slots = devm_kcalloc(&hi->input->dev, in mt_touch_input_configured()
1326 BITS_TO_LONGS(td->maxcontacts), in mt_touch_input_configured()
1329 if (!app->pending_palm_slots) in mt_touch_input_configured()
1330 return -ENOMEM; in mt_touch_input_configured()
1332 ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); in mt_touch_input_configured()
1336 app->mt_flags = 0; in mt_touch_input_configured()
1350 rdata = mt_find_report_data(td, field->report); in mt_input_mapping()
1356 application = rdata->application; in mt_input_mapping()
1364 if (!td->mtclass.export_all_inputs && in mt_input_mapping()
1365 field->application != HID_DG_TOUCHSCREEN && in mt_input_mapping()
1366 field->application != HID_DG_PEN && in mt_input_mapping()
1367 field->application != HID_DG_TOUCHPAD && in mt_input_mapping()
1368 field->application != HID_GD_KEYBOARD && in mt_input_mapping()
1369 field->application != HID_GD_SYSTEM_CONTROL && in mt_input_mapping()
1370 field->application != HID_CP_CONSUMER_CONTROL && in mt_input_mapping()
1371 field->application != HID_GD_WIRELESS_RADIO_CTLS && in mt_input_mapping()
1372 field->application != HID_GD_SYSTEM_MULTIAXIS && in mt_input_mapping()
1373 !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1374 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) in mt_input_mapping()
1375 return -1; in mt_input_mapping()
1382 if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1383 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && in mt_input_mapping()
1384 (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { in mt_input_mapping()
1385 set_bit(EV_REP, hi->input->evbit); in mt_input_mapping()
1386 if (field->flags & HID_MAIN_ITEM_VARIABLE) in mt_input_mapping()
1387 field->flags &= ~HID_MAIN_ITEM_VARIABLE; in mt_input_mapping()
1388 switch (usage->hid & HID_USAGE) { in mt_input_mapping()
1395 return -1; in mt_input_mapping()
1400 if (rdata->is_mt_collection) in mt_input_mapping()
1408 if (field->physical == HID_DG_STYLUS) in mt_input_mapping()
1409 hi->application = HID_DG_STYLUS; in mt_input_mapping()
1411 /* let hid-core decide for the others */ in mt_input_mapping()
1422 rdata = mt_find_report_data(td, field->report); in mt_input_mapped()
1423 if (rdata && rdata->is_mt_collection) { in mt_input_mapped()
1424 /* We own these mappings, tell hid-input to ignore them */ in mt_input_mapped()
1425 return -1; in mt_input_mapped()
1428 /* let hid-core decide for the others */ in mt_input_mapped()
1438 rdata = mt_find_report_data(td, field->report); in mt_event()
1439 if (rdata && rdata->is_mt_collection) in mt_event()
1448 if (hdev->vendor == I2C_VENDOR_ID_GOODIX && in mt_report_fixup()
1449 (hdev->product == I2C_DEVICE_ID_GOODIX_01E8 || in mt_report_fixup()
1450 hdev->product == I2C_DEVICE_ID_GOODIX_01E9 || in mt_report_fixup()
1451 hdev->product == I2C_DEVICE_ID_GOODIX_01E0)) { in mt_report_fixup()
1455 &hdev->dev, in mt_report_fixup()
1459 &hdev->dev, in mt_report_fixup()
1473 struct hid_field *field = report->field[0]; in mt_report()
1476 if (!(hid->claimed & HID_CLAIMED_INPUT)) in mt_report()
1480 if (rdata && rdata->is_mt_collection) in mt_report()
1483 if (field && field->hidinput && field->hidinput->input) in mt_report()
1484 input_sync(field->hidinput->input); in mt_report()
1496 struct mt_class *cls = &td->mtclass; in mt_need_to_apply_feature()
1497 struct hid_report *report = field->report; in mt_need_to_apply_feature()
1498 unsigned int index = usage->usage_index; in mt_need_to_apply_feature()
1503 switch (usage->hid) { in mt_need_to_apply_feature()
1513 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { in mt_need_to_apply_feature()
1521 hid_hw_raw_request(hdev, report->id, buf, report_len, in mt_need_to_apply_feature()
1527 field->value[index] = td->inputmode_value; in mt_need_to_apply_feature()
1532 if (cls->maxcontacts) { in mt_need_to_apply_feature()
1533 max = min_t(int, field->logical_maximum, in mt_need_to_apply_feature()
1534 cls->maxcontacts); in mt_need_to_apply_feature()
1535 if (field->value[index] != max) { in mt_need_to_apply_feature()
1536 field->value[index] = max; in mt_need_to_apply_feature()
1543 field->value[index] = latency; in mt_need_to_apply_feature()
1547 field->value[index] = surface_switch; in mt_need_to_apply_feature()
1551 field->value[index] = button_switch; in mt_need_to_apply_feature()
1568 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in mt_set_modes()
1569 list_for_each_entry(rep, &rep_enum->report_list, list) { in mt_set_modes()
1572 for (i = 0; i < rep->maxfield; i++) { in mt_set_modes()
1574 if (rep->field[i]->report_count < 1) in mt_set_modes()
1577 for (j = 0; j < rep->field[i]->maxusage; j++) { in mt_set_modes()
1578 usage = &rep->field[i]->usage[j]; in mt_set_modes()
1581 rep->field[i], in mt_set_modes()
1599 __s32 quirks = app->quirks; in mt_post_parse_default_settings()
1602 if (list_is_singular(&app->mt_usages)) { in mt_post_parse_default_settings()
1610 app->quirks = quirks; in mt_post_parse_default_settings()
1615 if (!app->have_contact_count) in mt_post_parse()
1616 app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_post_parse()
1628 list_for_each_entry(report, &hi->reports, hidinput_list) { in mt_input_configured()
1632 return -ENOMEM; in mt_input_configured()
1635 mt_application = rdata->application; in mt_input_configured()
1637 if (rdata->is_mt_collection) { in mt_input_configured()
1645 switch (hi->application) { in mt_input_configured()
1658 hi->input->name = hdev->name; in mt_input_configured()
1665 __set_bit(BTN_STYLUS, hi->input->keybit); in mt_input_configured()
1673 hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, in mt_input_configured()
1674 "%s %s", hdev->name, suffix); in mt_input_configured()
1681 if (field->usage[0].hid != usage || in mt_fix_const_field()
1682 !(field->flags & HID_MAIN_ITEM_CONSTANT)) in mt_fix_const_field()
1685 field->flags &= ~HID_MAIN_ITEM_CONSTANT; in mt_fix_const_field()
1686 field->flags |= HID_MAIN_ITEM_VARIABLE; in mt_fix_const_field()
1695 &hdev->report_enum[HID_INPUT_REPORT].report_list, in mt_fix_const_fields()
1698 if (!report->maxfield) in mt_fix_const_fields()
1701 for (i = 0; i < report->maxfield; i++) in mt_fix_const_fields()
1702 if (report->field[i]->maxusage >= 1) in mt_fix_const_fields()
1703 mt_fix_const_field(report->field[i], usage); in mt_fix_const_fields()
1713 list_for_each_entry(hidinput, &hid->inputs, list) { in mt_release_contacts()
1714 struct input_dev *input_dev = hidinput->input; in mt_release_contacts()
1715 struct input_mt *mt = input_dev->mt; in mt_release_contacts()
1719 for (i = 0; i < mt->num_slots; i++) { in mt_release_contacts()
1728 list_for_each_entry(application, &td->applications, list) { in mt_release_contacts()
1729 application->num_received = 0; in mt_release_contacts()
1736 struct hid_device *hdev = td->hdev; in mt_expired_timeout()
1742 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_expired_timeout()
1744 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_expired_timeout()
1746 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_expired_timeout()
1756 if (id->driver_data == mt_classes[i].name) { in mt_probe()
1762 td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); in mt_probe()
1764 dev_err(&hdev->dev, "cannot allocate multitouch data\n"); in mt_probe()
1765 return -ENOMEM; in mt_probe()
1767 td->hdev = hdev; in mt_probe()
1768 td->mtclass = *mtclass; in mt_probe()
1769 td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; in mt_probe()
1772 INIT_LIST_HEAD(&td->applications); in mt_probe()
1773 INIT_LIST_HEAD(&td->reports); in mt_probe()
1775 if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) in mt_probe()
1776 td->serial_maybe = true; in mt_probe()
1782 if (hdev->quirks & (HID_QUIRK_X_INVERT | HID_QUIRK_Y_INVERT) && in mt_probe()
1783 !((hdev->quirks & HID_QUIRK_X_INVERT) in mt_probe()
1784 && (hdev->quirks & HID_QUIRK_Y_INVERT))) in mt_probe()
1785 td->mtclass.quirks = MT_QUIRK_ORIENTATION_INVERT; in mt_probe()
1790 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; in mt_probe()
1797 hdev->quirks |= HID_QUIRK_INPUT_PER_APP; in mt_probe()
1799 if (id->group != HID_GROUP_MULTITOUCH_WIN_8) in mt_probe()
1800 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1802 if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) { in mt_probe()
1803 hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP; in mt_probe()
1804 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1807 timer_setup(&td->release_timer, mt_expired_timeout, 0); in mt_probe()
1813 if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) in mt_probe()
1820 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); in mt_probe()
1822 dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", in mt_probe()
1823 hdev->name); in mt_probe()
1836 if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || in mt_suspend()
1870 del_timer_sync(&td->release_timer); in mt_remove()
1872 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); in mt_remove()
1878 * - VID/PID of products not working with the default multitouch handling
1879 * - 2 generic rules.
1930 /* Chunghwa Telecom touch panels */
2091 /* HONOR GLO-GXXX panel */
2101 /* Ilitek dual touch panel */
2177 /* PixArt optical touch screen */
2188 /* PixCir-based panels */
2193 /* Quanta-based panels */
2234 /* Touch International panels */
2317 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
2321 .name = "hid-multitouch",