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
50 #include "hid-ids.h"
110 bool *tip_state; /* is the touch valid? */
112 bool *confidence_state; /* is the touch made by a finger? */
128 unsigned int mt_flags; /* flags to pass to input-mt */
238 * these device-dependent functions determine what slot corresponds
245 if (*slot->contactid != 0 || application->num_received == 0) in cypress_compute_slot()
246 return *slot->contactid; in cypress_compute_slot()
248 return -1; in cypress_compute_slot()
423 return sprintf(buf, "%u\n", td->mtclass.quirks); in mt_show_quirks()
437 return -EINVAL; in mt_set_quirks()
439 td->mtclass.quirks = val; in mt_set_quirks()
441 list_for_each_entry(application, &td->applications, list) { in mt_set_quirks()
442 application->quirks = val; in mt_set_quirks()
443 if (!application->have_contact_count) in mt_set_quirks()
444 application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_set_quirks()
469 * marked as non-capable. in mt_get_feature()
471 if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) in mt_get_feature()
478 ret = hid_hw_raw_request(hdev, report->id, buf, size, in mt_get_feature()
481 dev_warn(&hdev->dev, "failed to fetch feature %d\n", in mt_get_feature()
482 report->id); in mt_get_feature()
487 dev_warn(&hdev->dev, "failed to report feature\n"); in mt_get_feature()
498 switch (usage->hid) { in mt_feature_mapping()
500 mt_get_feature(hdev, field->report); in mt_feature_mapping()
502 td->maxcontacts = field->value[0]; in mt_feature_mapping()
503 if (!td->maxcontacts && in mt_feature_mapping()
504 field->logical_maximum <= MT_MAX_MAXCONTACT) in mt_feature_mapping()
505 td->maxcontacts = field->logical_maximum; in mt_feature_mapping()
506 if (td->mtclass.maxcontacts) in mt_feature_mapping()
508 td->maxcontacts = td->mtclass.maxcontacts; in mt_feature_mapping()
512 if (usage->usage_index >= field->report_count) { in mt_feature_mapping()
513 dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); in mt_feature_mapping()
517 mt_get_feature(hdev, field->report); in mt_feature_mapping()
518 if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) in mt_feature_mapping()
519 td->is_buttonpad = true; in mt_feature_mapping()
524 if (usage->usage_index == 0) in mt_feature_mapping()
525 mt_get_feature(hdev, field->report); in mt_feature_mapping()
533 int fmin = field->logical_minimum; in set_abs()
534 int fmax = field->logical_maximum; in set_abs()
535 int fuzz = snratio ? (fmax - fmin) / snratio : 0; in set_abs()
545 usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); in mt_allocate_usage()
550 usage->x = DEFAULT_ZERO; in mt_allocate_usage()
551 usage->y = DEFAULT_ZERO; in mt_allocate_usage()
552 usage->cx = DEFAULT_ZERO; in mt_allocate_usage()
553 usage->cy = DEFAULT_ZERO; in mt_allocate_usage()
554 usage->p = DEFAULT_ZERO; in mt_allocate_usage()
555 usage->w = DEFAULT_ZERO; in mt_allocate_usage()
556 usage->h = DEFAULT_ZERO; in mt_allocate_usage()
557 usage->a = DEFAULT_ZERO; in mt_allocate_usage()
558 usage->contactid = DEFAULT_ZERO; in mt_allocate_usage()
559 usage->tip_state = DEFAULT_FALSE; in mt_allocate_usage()
560 usage->inrange_state = DEFAULT_FALSE; in mt_allocate_usage()
561 usage->confidence_state = DEFAULT_TRUE; in mt_allocate_usage()
563 list_add_tail(&usage->list, &application->mt_usages); in mt_allocate_usage()
571 unsigned int application = report->application; in mt_allocate_application()
574 mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), in mt_allocate_application()
579 mt_application->application = application; in mt_allocate_application()
580 INIT_LIST_HEAD(&mt_application->mt_usages); in mt_allocate_application()
583 mt_application->mt_flags |= INPUT_MT_DIRECT; in mt_allocate_application()
589 mt_application->mt_flags |= INPUT_MT_POINTER; in mt_allocate_application()
590 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_allocate_application()
593 mt_application->scantime = DEFAULT_ZERO; in mt_allocate_application()
594 mt_application->raw_cc = DEFAULT_ZERO; in mt_allocate_application()
595 mt_application->quirks = td->mtclass.quirks; in mt_allocate_application()
596 mt_application->report_id = report->id; in mt_allocate_application()
598 list_add_tail(&mt_application->list, &td->applications); in mt_allocate_application()
606 unsigned int application = report->application; in mt_find_application()
609 list_for_each_entry(tmp, &td->applications, list) { in mt_find_application()
610 if (application == tmp->application) { in mt_find_application()
611 if (!(td->mtclass.quirks & MT_QUIRK_SEPARATE_APP_REPORT) || in mt_find_application()
612 tmp->report_id == report->id) { in mt_find_application()
632 rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); in mt_allocate_report_data()
636 rdata->report = report; in mt_allocate_report_data()
637 rdata->application = mt_find_application(td, report); in mt_allocate_report_data()
639 if (!rdata->application) { in mt_allocate_report_data()
640 devm_kfree(&td->hdev->dev, rdata); in mt_allocate_report_data()
644 for (r = 0; r < report->maxfield; r++) { in mt_allocate_report_data()
645 field = report->field[r]; in mt_allocate_report_data()
647 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_allocate_report_data()
650 if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { in mt_allocate_report_data()
651 for (n = 0; n < field->report_count; n++) { in mt_allocate_report_data()
652 if (field->usage[n].hid == HID_DG_CONTACTID) { in mt_allocate_report_data()
653 rdata->is_mt_collection = true; in mt_allocate_report_data()
660 list_add_tail(&rdata->list, &td->reports); in mt_allocate_report_data()
670 list_for_each_entry(tmp, &td->reports, list) { in mt_find_report_data()
671 if (report == tmp->report) { in mt_find_report_data()
691 if (list_empty(&application->mt_usages)) in mt_store_field()
694 usage = list_last_entry(&application->mt_usages, in mt_store_field()
707 if (usage->contactid == DEFAULT_ZERO || in mt_store_field()
708 usage->x == DEFAULT_ZERO || in mt_store_field()
709 usage->y == DEFAULT_ZERO) { in mt_store_field()
726 &field->value[usage->usage_index], \
734 struct mt_class *cls = &td->mtclass; in mt_touch_input_mapping()
741 if (field->application == HID_DG_TOUCHSCREEN && in mt_touch_input_mapping()
742 (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { in mt_touch_input_mapping()
743 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_mapping()
744 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_touch_input_mapping()
748 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) in mt_touch_input_mapping()
749 app->buttons_count++; in mt_touch_input_mapping()
751 if (usage->usage_index) in mt_touch_input_mapping()
752 prev_usage = &field->usage[usage->usage_index - 1]; in mt_touch_input_mapping()
754 switch (usage->hid & HID_USAGE_PAGE) { in mt_touch_input_mapping()
757 switch (usage->hid) { in mt_touch_input_mapping()
759 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
767 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
770 * A system multi-axis that exports X and Y has a high in mt_touch_input_mapping()
773 if (field->application == HID_GD_SYSTEM_MULTIAXIS) { in mt_touch_input_mapping()
775 hi->input->propbit); in mt_touch_input_mapping()
776 input_set_abs_params(hi->input, in mt_touch_input_mapping()
784 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
792 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
799 switch (usage->hid) { in mt_touch_input_mapping()
801 if (app->quirks & MT_QUIRK_HOVERING) { in mt_touch_input_mapping()
802 input_set_abs_params(hi->input, in mt_touch_input_mapping()
808 if ((cls->name == MT_CLS_WIN_8 || in mt_touch_input_mapping()
809 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || in mt_touch_input_mapping()
810 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU || in mt_touch_input_mapping()
811 cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP) && in mt_touch_input_mapping()
812 (field->application == HID_DG_TOUCHPAD || in mt_touch_input_mapping()
813 field->application == HID_DG_TOUCHSCREEN)) in mt_touch_input_mapping()
814 app->quirks |= MT_QUIRK_CONFIDENCE; in mt_touch_input_mapping()
816 if (app->quirks & MT_QUIRK_CONFIDENCE) in mt_touch_input_mapping()
817 input_set_abs_params(hi->input, in mt_touch_input_mapping()
825 if (field->application != HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
826 input_set_capability(hi->input, in mt_touch_input_mapping()
832 app->touches_by_report++; in mt_touch_input_mapping()
835 if (!(app->quirks & MT_QUIRK_NO_AREA)) in mt_touch_input_mapping()
836 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, in mt_touch_input_mapping()
837 cls->sn_width); in mt_touch_input_mapping()
841 if (!(app->quirks & MT_QUIRK_NO_AREA)) { in mt_touch_input_mapping()
842 set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, in mt_touch_input_mapping()
843 cls->sn_height); in mt_touch_input_mapping()
850 hi->input->absbit)) in mt_touch_input_mapping()
851 input_set_abs_params(hi->input, in mt_touch_input_mapping()
857 set_abs(hi->input, ABS_MT_PRESSURE, field, in mt_touch_input_mapping()
858 cls->sn_pressure); in mt_touch_input_mapping()
862 input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); in mt_touch_input_mapping()
863 app->scantime = &field->value[usage->usage_index]; in mt_touch_input_mapping()
864 app->scantime_logical_max = field->logical_maximum; in mt_touch_input_mapping()
867 app->have_contact_count = true; in mt_touch_input_mapping()
868 app->raw_cc = &field->value[usage->usage_index]; in mt_touch_input_mapping()
876 input_set_abs_params(hi->input, ABS_MT_ORIENTATION, in mt_touch_input_mapping()
877 -field->logical_maximum / 4, in mt_touch_input_mapping()
878 field->logical_maximum / 4, in mt_touch_input_mapping()
879 cls->sn_move ? in mt_touch_input_mapping()
880 field->logical_maximum / cls->sn_move : 0, 0); in mt_touch_input_mapping()
885 return -1; in mt_touch_input_mapping()
887 /* Legacy devices use TIPSWITCH and not TOUCH. in mt_touch_input_mapping()
889 return -1; in mt_touch_input_mapping()
891 /* let hid-input decide for the others */ in mt_touch_input_mapping()
895 code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
897 * MS PTP spec says that external buttons left and right have in mt_touch_input_mapping()
900 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_input_mapping()
901 field->application == HID_DG_TOUCHPAD && in mt_touch_input_mapping()
902 (usage->hid & HID_USAGE) > 1) in mt_touch_input_mapping()
903 code--; in mt_touch_input_mapping()
905 if (field->application == HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
906 code = BTN_0 + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
910 return -1; in mt_touch_input_mapping()
911 input_set_capability(hi->input, EV_KEY, code); in mt_touch_input_mapping()
915 /* we do not want to map these: no input-oriented meaning */ in mt_touch_input_mapping()
916 return -1; in mt_touch_input_mapping()
926 __s32 quirks = app->quirks; in mt_compute_slot()
929 return *slot->contactid; in mt_compute_slot()
935 return app->num_received; in mt_compute_slot()
938 return *slot->contactid - 1; in mt_compute_slot()
940 return input_mt_get_slot_by_key(input, *slot->contactid); in mt_compute_slot()
950 for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { in mt_release_pending_palms()
951 clear_bit(slotnum, app->pending_palm_slots); in mt_release_pending_palms()
972 if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) in mt_sync_frame()
973 input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); in mt_sync_frame()
976 input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); in mt_sync_frame()
981 app->num_received = 0; in mt_sync_frame()
982 app->left_button_state = 0; in mt_sync_frame()
984 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) in mt_sync_frame()
985 set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
987 clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
988 clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_sync_frame()
993 long delta = value - app->prev_scantime; in mt_compute_timestamp()
994 unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); in mt_compute_timestamp()
996 app->jiffies = jiffies; in mt_compute_timestamp()
999 delta += app->scantime_logical_max; in mt_compute_timestamp()
1008 return app->timestamp + delta; in mt_compute_timestamp()
1015 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) in mt_touch_event()
1016 hid->hiddev_hid_event(hid, field, usage, value); in mt_touch_event()
1025 struct input_mt *mt = input->mt; in mt_process_slot()
1026 struct hid_device *hdev = td->hdev; in mt_process_slot()
1027 __s32 quirks = app->quirks; in mt_process_slot()
1036 return -EINVAL; in mt_process_slot()
1039 app->num_received >= app->num_expected) in mt_process_slot()
1040 return -EAGAIN; in mt_process_slot()
1044 valid = *slot->inrange_state; in mt_process_slot()
1046 valid = *slot->tip_state; in mt_process_slot()
1048 valid = *slot->confidence_state; in mt_process_slot()
1055 if (slotnum < 0 || slotnum >= td->maxcontacts) in mt_process_slot()
1059 struct input_mt_slot *i_slot = &mt->slots[slotnum]; in mt_process_slot()
1063 return -EAGAIN; in mt_process_slot()
1067 confidence_state = *slot->confidence_state; in mt_process_slot()
1070 inrange_state = *slot->inrange_state; in mt_process_slot()
1072 active = *slot->tip_state || inrange_state; in mt_process_slot()
1074 if (app->application == HID_GD_SYSTEM_MULTIAXIS) in mt_process_slot()
1079 input_mt_is_active(&mt->slots[slotnum])) { in mt_process_slot()
1081 * The non-confidence was reported for in mt_process_slot()
1084 * lift-off as userspace will not be aware in mt_process_slot()
1085 * of non-confidence, so we need to split in mt_process_slot()
1090 set_bit(slotnum, app->pending_palm_slots); in mt_process_slot()
1098 int wide = (*slot->w > *slot->h); in mt_process_slot()
1099 int major = max(*slot->w, *slot->h); in mt_process_slot()
1100 int minor = min(*slot->w, *slot->h); in mt_process_slot()
1109 if (slot->a != DEFAULT_ZERO) { in mt_process_slot()
1111 * Azimuth is counter-clockwise and ranges from [0, MAX) in mt_process_slot()
1113 * [-MAX/2, MAX/2]. in mt_process_slot()
1116 * the limit of [-MAX/4, MAX/4], but the value can go in mt_process_slot()
1117 * out of range to [-MAX/2, MAX/2] to report an upside in mt_process_slot()
1120 azimuth = *slot->a; in mt_process_slot()
1124 azimuth -= max_azimuth * 4; in mt_process_slot()
1125 orientation = -azimuth; in mt_process_slot()
1127 orientation = -orientation; in mt_process_slot()
1133 * divided by two to match visual scale of touch in mt_process_slot()
1140 x = hdev->quirks & HID_QUIRK_X_INVERT ? in mt_process_slot()
1141 input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->x : in mt_process_slot()
1142 *slot->x; in mt_process_slot()
1143 y = hdev->quirks & HID_QUIRK_Y_INVERT ? in mt_process_slot()
1144 input_abs_get_max(input, ABS_MT_POSITION_Y) - *slot->y : in mt_process_slot()
1145 *slot->y; in mt_process_slot()
1146 cx = hdev->quirks & HID_QUIRK_X_INVERT ? in mt_process_slot()
1147 input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->cx : in mt_process_slot()
1148 *slot->cx; in mt_process_slot()
1149 cy = hdev->quirks & HID_QUIRK_Y_INVERT ? in mt_process_slot()
1150 input_abs_get_max(input, ABS_MT_POSITION_Y) - *slot->cy : in mt_process_slot()
1151 *slot->cy; in mt_process_slot()
1157 input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); in mt_process_slot()
1159 input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); in mt_process_slot()
1163 set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_process_slot()
1176 __s32 quirks = app->quirks; in mt_process_mt_event()
1177 struct input_dev *input = field->hidinput->input; in mt_process_mt_event()
1179 if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) in mt_process_mt_event()
1186 * non finger/touch events in the first_packet of a in mt_process_mt_event()
1187 * (possible) multi-packet frame. in mt_process_mt_event()
1199 if (usage->type == EV_KEY && usage->code == BTN_LEFT) { in mt_process_mt_event()
1200 app->left_button_state |= value; in mt_process_mt_event()
1205 input_event(input, usage->type, usage->code, value); in mt_process_mt_event()
1212 struct hid_report *report = rdata->report; in mt_touch_report()
1213 struct mt_application *app = rdata->application; in mt_touch_report()
1221 int contact_count = -1; in mt_touch_report()
1224 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_touch_report()
1227 scantime = *app->scantime; in mt_touch_report()
1228 app->timestamp = mt_compute_timestamp(app, scantime); in mt_touch_report()
1229 if (app->raw_cc != DEFAULT_ZERO) in mt_touch_report()
1230 contact_count = *app->raw_cc; in mt_touch_report()
1233 * Includes multi-packet support where subsequent in mt_touch_report()
1238 * For Win8 PTPs the first packet (td->num_received == 0) may in mt_touch_report()
1241 * of a possible multi-packet frame be checking that the in mt_touch_report()
1244 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_report()
1245 app->num_received == 0 && in mt_touch_report()
1246 app->prev_scantime != scantime) in mt_touch_report()
1247 app->num_expected = contact_count; in mt_touch_report()
1250 app->num_expected = contact_count; in mt_touch_report()
1252 app->prev_scantime = scantime; in mt_touch_report()
1254 first_packet = app->num_received == 0; in mt_touch_report()
1256 input = report->field[0]->hidinput->input; in mt_touch_report()
1258 list_for_each_entry(slot, &app->mt_usages, list) { in mt_touch_report()
1260 app->num_received++; in mt_touch_report()
1263 for (r = 0; r < report->maxfield; r++) { in mt_touch_report()
1264 field = report->field[r]; in mt_touch_report()
1265 count = field->report_count; in mt_touch_report()
1267 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_touch_report()
1272 &field->usage[n], field->value[n], in mt_touch_report()
1276 if (app->num_received >= app->num_expected) in mt_touch_report()
1281 * - once a contact has been reported, it has to be reported in each in mt_touch_report()
1283 * - the report rate when fingers are present has to be at least in mt_touch_report()
1284 * the refresh rate of the screen, 60 or 120 Hz in mt_touch_report()
1286 * I interprete this that the specification forces a report rate of in mt_touch_report()
1288 * Which means that if we do not get a report whithin 16 ms, either in mt_touch_report()
1297 if (app->quirks & MT_QUIRK_STICKY_FINGERS) { in mt_touch_report()
1298 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_touch_report()
1299 mod_timer(&td->release_timer, in mt_touch_report()
1302 del_timer(&td->release_timer); in mt_touch_report()
1305 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_touch_report()
1313 struct mt_class *cls = &td->mtclass; in mt_touch_input_configured()
1314 struct input_dev *input = hi->input; in mt_touch_input_configured()
1317 if (!td->maxcontacts) in mt_touch_input_configured()
1318 td->maxcontacts = MT_DEFAULT_MAXCONTACT; in mt_touch_input_configured()
1321 if (td->serial_maybe) in mt_touch_input_configured()
1324 if (cls->is_indirect) in mt_touch_input_configured()
1325 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_configured()
1327 if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) in mt_touch_input_configured()
1328 app->mt_flags |= INPUT_MT_DROP_UNUSED; in mt_touch_input_configured()
1331 if ((app->mt_flags & INPUT_MT_POINTER) && in mt_touch_input_configured()
1332 (app->buttons_count == 1)) in mt_touch_input_configured()
1333 td->is_buttonpad = true; in mt_touch_input_configured()
1335 if (td->is_buttonpad) in mt_touch_input_configured()
1336 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); in mt_touch_input_configured()
1338 app->pending_palm_slots = devm_kcalloc(&hi->input->dev, in mt_touch_input_configured()
1339 BITS_TO_LONGS(td->maxcontacts), in mt_touch_input_configured()
1342 if (!app->pending_palm_slots) in mt_touch_input_configured()
1343 return -ENOMEM; in mt_touch_input_configured()
1345 ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); in mt_touch_input_configured()
1349 app->mt_flags = 0; in mt_touch_input_configured()
1363 rdata = mt_find_report_data(td, field->report); in mt_input_mapping()
1369 application = rdata->application; in mt_input_mapping()
1377 if (!td->mtclass.export_all_inputs && in mt_input_mapping()
1378 field->application != HID_DG_TOUCHSCREEN && in mt_input_mapping()
1379 field->application != HID_DG_PEN && in mt_input_mapping()
1380 field->application != HID_DG_TOUCHPAD && in mt_input_mapping()
1381 field->application != HID_GD_KEYBOARD && in mt_input_mapping()
1382 field->application != HID_GD_SYSTEM_CONTROL && in mt_input_mapping()
1383 field->application != HID_CP_CONSUMER_CONTROL && in mt_input_mapping()
1384 field->application != HID_GD_WIRELESS_RADIO_CTLS && in mt_input_mapping()
1385 field->application != HID_GD_SYSTEM_MULTIAXIS && in mt_input_mapping()
1386 !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1387 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) in mt_input_mapping()
1388 return -1; in mt_input_mapping()
1395 if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1396 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && in mt_input_mapping()
1397 (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { in mt_input_mapping()
1398 set_bit(EV_REP, hi->input->evbit); in mt_input_mapping()
1399 if (field->flags & HID_MAIN_ITEM_VARIABLE) in mt_input_mapping()
1400 field->flags &= ~HID_MAIN_ITEM_VARIABLE; in mt_input_mapping()
1401 switch (usage->hid & HID_USAGE) { in mt_input_mapping()
1408 return -1; in mt_input_mapping()
1413 if (rdata->is_mt_collection) in mt_input_mapping()
1421 if (field->physical == HID_DG_STYLUS) in mt_input_mapping()
1422 hi->application = HID_DG_STYLUS; in mt_input_mapping()
1424 /* let hid-core decide for the others */ in mt_input_mapping()
1435 rdata = mt_find_report_data(td, field->report); in mt_input_mapped()
1436 if (rdata && rdata->is_mt_collection) { in mt_input_mapped()
1437 /* We own these mappings, tell hid-input to ignore them */ in mt_input_mapped()
1438 return -1; in mt_input_mapped()
1441 /* let hid-core decide for the others */ in mt_input_mapped()
1451 rdata = mt_find_report_data(td, field->report); in mt_event()
1452 if (rdata && rdata->is_mt_collection) in mt_event()
1461 if (hdev->vendor == I2C_VENDOR_ID_GOODIX && in mt_report_fixup()
1462 (hdev->product == I2C_DEVICE_ID_GOODIX_01E8 || in mt_report_fixup()
1463 hdev->product == I2C_DEVICE_ID_GOODIX_01E9)) { in mt_report_fixup()
1467 &hdev->dev, in mt_report_fixup()
1471 &hdev->dev, in mt_report_fixup()
1485 struct hid_field *field = report->field[0]; in mt_report()
1488 if (!(hid->claimed & HID_CLAIMED_INPUT)) in mt_report()
1492 if (rdata && rdata->is_mt_collection) in mt_report()
1495 if (field && field->hidinput && field->hidinput->input) in mt_report()
1496 input_sync(field->hidinput->input); in mt_report()
1507 struct mt_class *cls = &td->mtclass; in mt_need_to_apply_feature()
1508 struct hid_report *report = field->report; in mt_need_to_apply_feature()
1509 unsigned int index = usage->usage_index; in mt_need_to_apply_feature()
1514 switch (usage->hid) { in mt_need_to_apply_feature()
1524 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { in mt_need_to_apply_feature()
1532 hid_hw_raw_request(hdev, report->id, buf, report_len, in mt_need_to_apply_feature()
1538 field->value[index] = td->inputmode_value; in mt_need_to_apply_feature()
1543 if (cls->maxcontacts) { in mt_need_to_apply_feature()
1544 max = min_t(int, field->logical_maximum, in mt_need_to_apply_feature()
1545 cls->maxcontacts); in mt_need_to_apply_feature()
1546 if (field->value[index] != max) { in mt_need_to_apply_feature()
1547 field->value[index] = max; in mt_need_to_apply_feature()
1554 field->value[index] = latency; in mt_need_to_apply_feature()
1558 field->value[index] = !!(report_mode & TOUCHPAD_REPORT_CONTACTS); in mt_need_to_apply_feature()
1562 field->value[index] = !!(report_mode & TOUCHPAD_REPORT_BUTTONS); in mt_need_to_apply_feature()
1579 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in mt_set_modes()
1580 list_for_each_entry(rep, &rep_enum->report_list, list) { in mt_set_modes()
1583 for (i = 0; i < rep->maxfield; i++) { in mt_set_modes()
1585 if (rep->field[i]->report_count < 1) in mt_set_modes()
1588 for (j = 0; j < rep->field[i]->maxusage; j++) { in mt_set_modes()
1589 usage = &rep->field[i]->usage[j]; in mt_set_modes()
1592 rep->field[i], in mt_set_modes()
1609 __s32 quirks = app->quirks; in mt_post_parse_default_settings()
1612 if (list_is_singular(&app->mt_usages)) { in mt_post_parse_default_settings()
1620 app->quirks = quirks; in mt_post_parse_default_settings()
1625 if (!app->have_contact_count) in mt_post_parse()
1626 app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_post_parse()
1638 list_for_each_entry(report, &hi->reports, hidinput_list) { in mt_input_configured()
1642 return -ENOMEM; in mt_input_configured()
1645 mt_application = rdata->application; in mt_input_configured()
1647 if (rdata->is_mt_collection) { in mt_input_configured()
1655 switch (hi->application) { in mt_input_configured()
1668 hi->input->name = hdev->name; in mt_input_configured()
1675 __set_bit(BTN_STYLUS, hi->input->keybit); in mt_input_configured()
1683 hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, in mt_input_configured()
1684 "%s %s", hdev->name, suffix); in mt_input_configured()
1685 if (!hi->input->name) in mt_input_configured()
1686 return -ENOMEM; in mt_input_configured()
1694 if (field->usage[0].hid != usage || in mt_fix_const_field()
1695 !(field->flags & HID_MAIN_ITEM_CONSTANT)) in mt_fix_const_field()
1698 field->flags &= ~HID_MAIN_ITEM_CONSTANT; in mt_fix_const_field()
1699 field->flags |= HID_MAIN_ITEM_VARIABLE; in mt_fix_const_field()
1708 &hdev->report_enum[HID_INPUT_REPORT].report_list, in mt_fix_const_fields()
1711 if (!report->maxfield) in mt_fix_const_fields()
1714 for (i = 0; i < report->maxfield; i++) in mt_fix_const_fields()
1715 if (report->field[i]->maxusage >= 1) in mt_fix_const_fields()
1716 mt_fix_const_field(report->field[i], usage); in mt_fix_const_fields()
1726 list_for_each_entry(hidinput, &hid->inputs, list) { in mt_release_contacts()
1727 struct input_dev *input_dev = hidinput->input; in mt_release_contacts()
1728 struct input_mt *mt = input_dev->mt; in mt_release_contacts()
1732 for (i = 0; i < mt->num_slots; i++) { in mt_release_contacts()
1741 list_for_each_entry(application, &td->applications, list) { in mt_release_contacts()
1742 application->num_received = 0; in mt_release_contacts()
1749 struct hid_device *hdev = td->hdev; in mt_expired_timeout()
1755 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_expired_timeout()
1757 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_expired_timeout()
1759 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_expired_timeout()
1769 if (id->driver_data == mt_classes[i].name) { in mt_probe()
1775 td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); in mt_probe()
1777 dev_err(&hdev->dev, "cannot allocate multitouch data\n"); in mt_probe()
1778 return -ENOMEM; in mt_probe()
1780 td->hdev = hdev; in mt_probe()
1781 td->mtclass = *mtclass; in mt_probe()
1782 td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; in mt_probe()
1785 INIT_LIST_HEAD(&td->applications); in mt_probe()
1786 INIT_LIST_HEAD(&td->reports); in mt_probe()
1788 if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) in mt_probe()
1789 td->serial_maybe = true; in mt_probe()
1795 if (hdev->quirks & (HID_QUIRK_X_INVERT | HID_QUIRK_Y_INVERT) && in mt_probe()
1796 !((hdev->quirks & HID_QUIRK_X_INVERT) in mt_probe()
1797 && (hdev->quirks & HID_QUIRK_Y_INVERT))) in mt_probe()
1798 td->mtclass.quirks = MT_QUIRK_ORIENTATION_INVERT; in mt_probe()
1803 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; in mt_probe()
1810 hdev->quirks |= HID_QUIRK_INPUT_PER_APP; in mt_probe()
1812 if (id->group != HID_GROUP_MULTITOUCH_WIN_8) in mt_probe()
1813 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1815 if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) { in mt_probe()
1816 hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP; in mt_probe()
1817 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1820 timer_setup(&td->release_timer, mt_expired_timeout, 0); in mt_probe()
1826 if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) in mt_probe()
1829 if (hdev->vendor == USB_VENDOR_ID_SIS_TOUCH) in mt_probe()
1830 hdev->quirks |= HID_QUIRK_NOGET; in mt_probe()
1836 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); in mt_probe()
1838 dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", in mt_probe()
1839 hdev->name); in mt_probe()
1851 if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || in mt_suspend()
1884 del_timer_sync(&td->release_timer); in mt_remove()
1886 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); in mt_remove()
1892 * - VID/PID of products not working with the default multitouch handling
1893 * - 2 generic rules.
1944 /* Chunghwa Telecom touch panels */
2102 /* HONOR GLO-GXXX panel */
2112 /* Ilitek dual touch panel */
2188 /* PixArt optical touch screen */
2199 /* PixCir-based panels */
2204 /* Quanta-based panels */
2245 /* Touch International panels */
2338 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
2342 .name = "hid-multitouch",