Lines Matching +full:touchscreen +full:- +full:fuzz +full:- +full:pressure
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"
120 unsigned int mt_flags; /* flags to pass to input-mt */
146 __s32 sn_pressure; /* Signal/noise ratio for pressure events */
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()
415 return sprintf(buf, "%u\n", td->mtclass.quirks); in mt_show_quirks()
429 return -EINVAL; in mt_set_quirks()
431 td->mtclass.quirks = val; in mt_set_quirks()
433 list_for_each_entry(application, &td->applications, list) { in mt_set_quirks()
434 application->quirks = val; in mt_set_quirks()
435 if (!application->have_contact_count) in mt_set_quirks()
436 application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_set_quirks()
461 * marked as non-capable. in mt_get_feature()
463 if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) in mt_get_feature()
470 ret = hid_hw_raw_request(hdev, report->id, buf, size, in mt_get_feature()
473 dev_warn(&hdev->dev, "failed to fetch feature %d\n", in mt_get_feature()
474 report->id); in mt_get_feature()
479 dev_warn(&hdev->dev, "failed to report feature\n"); in mt_get_feature()
490 switch (usage->hid) { in mt_feature_mapping()
492 mt_get_feature(hdev, field->report); in mt_feature_mapping()
494 td->maxcontacts = field->value[0]; in mt_feature_mapping()
495 if (!td->maxcontacts && in mt_feature_mapping()
496 field->logical_maximum <= MT_MAX_MAXCONTACT) in mt_feature_mapping()
497 td->maxcontacts = field->logical_maximum; in mt_feature_mapping()
498 if (td->mtclass.maxcontacts) in mt_feature_mapping()
500 td->maxcontacts = td->mtclass.maxcontacts; in mt_feature_mapping()
504 if (usage->usage_index >= field->report_count) { in mt_feature_mapping()
505 dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); in mt_feature_mapping()
509 mt_get_feature(hdev, field->report); in mt_feature_mapping()
510 if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) in mt_feature_mapping()
511 td->is_buttonpad = true; in mt_feature_mapping()
516 if (usage->usage_index == 0) in mt_feature_mapping()
517 mt_get_feature(hdev, field->report); in mt_feature_mapping()
525 int fmin = field->logical_minimum; in set_abs()
526 int fmax = field->logical_maximum; in set_abs()
527 int fuzz = snratio ? (fmax - fmin) / snratio : 0; in set_abs() local
528 input_set_abs_params(input, code, fmin, fmax, fuzz, 0); in set_abs()
537 usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); in mt_allocate_usage()
542 usage->x = DEFAULT_ZERO; in mt_allocate_usage()
543 usage->y = DEFAULT_ZERO; in mt_allocate_usage()
544 usage->cx = DEFAULT_ZERO; in mt_allocate_usage()
545 usage->cy = DEFAULT_ZERO; in mt_allocate_usage()
546 usage->p = DEFAULT_ZERO; in mt_allocate_usage()
547 usage->w = DEFAULT_ZERO; in mt_allocate_usage()
548 usage->h = DEFAULT_ZERO; in mt_allocate_usage()
549 usage->a = DEFAULT_ZERO; in mt_allocate_usage()
550 usage->contactid = DEFAULT_ZERO; in mt_allocate_usage()
551 usage->tip_state = DEFAULT_FALSE; in mt_allocate_usage()
552 usage->inrange_state = DEFAULT_FALSE; in mt_allocate_usage()
553 usage->confidence_state = DEFAULT_TRUE; in mt_allocate_usage()
555 list_add_tail(&usage->list, &application->mt_usages); in mt_allocate_usage()
563 unsigned int application = report->application; in mt_allocate_application()
566 mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), in mt_allocate_application()
571 mt_application->application = application; in mt_allocate_application()
572 INIT_LIST_HEAD(&mt_application->mt_usages); in mt_allocate_application()
575 mt_application->mt_flags |= INPUT_MT_DIRECT; in mt_allocate_application()
581 mt_application->mt_flags |= INPUT_MT_POINTER; in mt_allocate_application()
582 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_allocate_application()
585 mt_application->scantime = DEFAULT_ZERO; in mt_allocate_application()
586 mt_application->raw_cc = DEFAULT_ZERO; in mt_allocate_application()
587 mt_application->quirks = td->mtclass.quirks; in mt_allocate_application()
588 mt_application->report_id = report->id; in mt_allocate_application()
590 list_add_tail(&mt_application->list, &td->applications); in mt_allocate_application()
598 unsigned int application = report->application; in mt_find_application()
601 list_for_each_entry(tmp, &td->applications, list) { in mt_find_application()
602 if (application == tmp->application) { in mt_find_application()
603 if (!(td->mtclass.quirks & MT_QUIRK_SEPARATE_APP_REPORT) || in mt_find_application()
604 tmp->report_id == report->id) { in mt_find_application()
624 rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); in mt_allocate_report_data()
628 rdata->report = report; in mt_allocate_report_data()
629 rdata->application = mt_find_application(td, report); in mt_allocate_report_data()
631 if (!rdata->application) { in mt_allocate_report_data()
632 devm_kfree(&td->hdev->dev, rdata); in mt_allocate_report_data()
636 for (r = 0; r < report->maxfield; r++) { in mt_allocate_report_data()
637 field = report->field[r]; in mt_allocate_report_data()
639 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_allocate_report_data()
642 if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { in mt_allocate_report_data()
643 for (n = 0; n < field->report_count; n++) { in mt_allocate_report_data()
644 if (field->usage[n].hid == HID_DG_CONTACTID) { in mt_allocate_report_data()
645 rdata->is_mt_collection = true; in mt_allocate_report_data()
652 list_add_tail(&rdata->list, &td->reports); in mt_allocate_report_data()
662 list_for_each_entry(tmp, &td->reports, list) { in mt_find_report_data()
663 if (report == tmp->report) { in mt_find_report_data()
683 if (list_empty(&application->mt_usages)) in mt_store_field()
686 usage = list_last_entry(&application->mt_usages, in mt_store_field()
699 if (usage->contactid == DEFAULT_ZERO || in mt_store_field()
700 usage->x == DEFAULT_ZERO || in mt_store_field()
701 usage->y == DEFAULT_ZERO) { in mt_store_field()
718 &field->value[usage->usage_index], \
726 struct mt_class *cls = &td->mtclass; in mt_touch_input_mapping()
733 if (field->application == HID_DG_TOUCHSCREEN && in mt_touch_input_mapping()
734 (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { in mt_touch_input_mapping()
735 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_mapping()
736 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_touch_input_mapping()
740 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) in mt_touch_input_mapping()
741 app->buttons_count++; in mt_touch_input_mapping()
743 if (usage->usage_index) in mt_touch_input_mapping()
744 prev_usage = &field->usage[usage->usage_index - 1]; in mt_touch_input_mapping()
746 switch (usage->hid & HID_USAGE_PAGE) { in mt_touch_input_mapping()
749 switch (usage->hid) { in mt_touch_input_mapping()
751 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
759 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
762 * A system multi-axis that exports X and Y has a high in mt_touch_input_mapping()
765 if (field->application == HID_GD_SYSTEM_MULTIAXIS) { in mt_touch_input_mapping()
767 hi->input->propbit); in mt_touch_input_mapping()
768 input_set_abs_params(hi->input, in mt_touch_input_mapping()
776 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
784 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
791 switch (usage->hid) { in mt_touch_input_mapping()
793 if (app->quirks & MT_QUIRK_HOVERING) { in mt_touch_input_mapping()
794 input_set_abs_params(hi->input, in mt_touch_input_mapping()
800 if ((cls->name == MT_CLS_WIN_8 || in mt_touch_input_mapping()
801 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || in mt_touch_input_mapping()
802 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU || in mt_touch_input_mapping()
803 cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP) && in mt_touch_input_mapping()
804 (field->application == HID_DG_TOUCHPAD || in mt_touch_input_mapping()
805 field->application == HID_DG_TOUCHSCREEN)) in mt_touch_input_mapping()
806 app->quirks |= MT_QUIRK_CONFIDENCE; in mt_touch_input_mapping()
808 if (app->quirks & MT_QUIRK_CONFIDENCE) in mt_touch_input_mapping()
809 input_set_abs_params(hi->input, in mt_touch_input_mapping()
817 if (field->application != HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
818 input_set_capability(hi->input, in mt_touch_input_mapping()
824 app->touches_by_report++; in mt_touch_input_mapping()
827 if (!(app->quirks & MT_QUIRK_NO_AREA)) in mt_touch_input_mapping()
828 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, in mt_touch_input_mapping()
829 cls->sn_width); in mt_touch_input_mapping()
833 if (!(app->quirks & MT_QUIRK_NO_AREA)) { in mt_touch_input_mapping()
834 set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, in mt_touch_input_mapping()
835 cls->sn_height); in mt_touch_input_mapping()
842 hi->input->absbit)) in mt_touch_input_mapping()
843 input_set_abs_params(hi->input, in mt_touch_input_mapping()
849 set_abs(hi->input, ABS_MT_PRESSURE, field, in mt_touch_input_mapping()
850 cls->sn_pressure); in mt_touch_input_mapping()
854 input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); in mt_touch_input_mapping()
855 app->scantime = &field->value[usage->usage_index]; in mt_touch_input_mapping()
856 app->scantime_logical_max = field->logical_maximum; in mt_touch_input_mapping()
859 app->have_contact_count = true; in mt_touch_input_mapping()
860 app->raw_cc = &field->value[usage->usage_index]; in mt_touch_input_mapping()
868 input_set_abs_params(hi->input, ABS_MT_ORIENTATION, in mt_touch_input_mapping()
869 -field->logical_maximum / 4, in mt_touch_input_mapping()
870 field->logical_maximum / 4, in mt_touch_input_mapping()
871 cls->sn_move ? in mt_touch_input_mapping()
872 field->logical_maximum / cls->sn_move : 0, 0); in mt_touch_input_mapping()
877 return -1; in mt_touch_input_mapping()
881 return -1; in mt_touch_input_mapping()
883 /* let hid-input decide for the others */ in mt_touch_input_mapping()
887 code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
892 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_input_mapping()
893 field->application == HID_DG_TOUCHPAD && in mt_touch_input_mapping()
894 (usage->hid & HID_USAGE) > 1) in mt_touch_input_mapping()
895 code--; in mt_touch_input_mapping()
897 if (field->application == HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
898 code = BTN_0 + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
902 return -1; in mt_touch_input_mapping()
903 input_set_capability(hi->input, EV_KEY, code); in mt_touch_input_mapping()
907 /* we do not want to map these: no input-oriented meaning */ in mt_touch_input_mapping()
908 return -1; in mt_touch_input_mapping()
918 __s32 quirks = app->quirks; in mt_compute_slot()
921 return *slot->contactid; in mt_compute_slot()
927 return app->num_received; in mt_compute_slot()
930 return *slot->contactid - 1; in mt_compute_slot()
932 return input_mt_get_slot_by_key(input, *slot->contactid); in mt_compute_slot()
942 for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { in mt_release_pending_palms()
943 clear_bit(slotnum, app->pending_palm_slots); in mt_release_pending_palms()
964 if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) in mt_sync_frame()
965 input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); in mt_sync_frame()
968 input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); in mt_sync_frame()
973 app->num_received = 0; in mt_sync_frame()
974 app->left_button_state = 0; in mt_sync_frame()
976 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) in mt_sync_frame()
977 set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
979 clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
980 clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_sync_frame()
985 long delta = value - app->prev_scantime; in mt_compute_timestamp()
986 unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); in mt_compute_timestamp()
988 app->jiffies = jiffies; in mt_compute_timestamp()
991 delta += app->scantime_logical_max; in mt_compute_timestamp()
1000 return app->timestamp + delta; in mt_compute_timestamp()
1007 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) in mt_touch_event()
1008 hid->hiddev_hid_event(hid, field, usage, value); in mt_touch_event()
1017 struct input_mt *mt = input->mt; in mt_process_slot()
1018 struct hid_device *hdev = td->hdev; in mt_process_slot()
1019 __s32 quirks = app->quirks; in mt_process_slot()
1028 return -EINVAL; in mt_process_slot()
1031 app->num_received >= app->num_expected) in mt_process_slot()
1032 return -EAGAIN; in mt_process_slot()
1036 valid = *slot->inrange_state; in mt_process_slot()
1038 valid = *slot->tip_state; in mt_process_slot()
1040 valid = *slot->confidence_state; in mt_process_slot()
1047 if (slotnum < 0 || slotnum >= td->maxcontacts) in mt_process_slot()
1051 struct input_mt_slot *i_slot = &mt->slots[slotnum]; in mt_process_slot()
1055 return -EAGAIN; in mt_process_slot()
1059 confidence_state = *slot->confidence_state; in mt_process_slot()
1062 inrange_state = *slot->inrange_state; in mt_process_slot()
1064 active = *slot->tip_state || inrange_state; in mt_process_slot()
1066 if (app->application == HID_GD_SYSTEM_MULTIAXIS) in mt_process_slot()
1071 input_mt_is_active(&mt->slots[slotnum])) { in mt_process_slot()
1073 * The non-confidence was reported for in mt_process_slot()
1076 * lift-off as userspace will not be aware in mt_process_slot()
1077 * of non-confidence, so we need to split in mt_process_slot()
1082 set_bit(slotnum, app->pending_palm_slots); in mt_process_slot()
1090 int wide = (*slot->w > *slot->h); in mt_process_slot()
1091 int major = max(*slot->w, *slot->h); in mt_process_slot()
1092 int minor = min(*slot->w, *slot->h); in mt_process_slot()
1101 if (slot->a != DEFAULT_ZERO) { in mt_process_slot()
1103 * Azimuth is counter-clockwise and ranges from [0, MAX) in mt_process_slot()
1105 * [-MAX/2, MAX/2]. in mt_process_slot()
1108 * the limit of [-MAX/4, MAX/4], but the value can go in mt_process_slot()
1109 * out of range to [-MAX/2, MAX/2] to report an upside in mt_process_slot()
1112 azimuth = *slot->a; in mt_process_slot()
1116 azimuth -= max_azimuth * 4; in mt_process_slot()
1117 orientation = -azimuth; in mt_process_slot()
1119 orientation = -orientation; in mt_process_slot()
1132 x = hdev->quirks & HID_QUIRK_X_INVERT ? in mt_process_slot()
1133 input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->x : in mt_process_slot()
1134 *slot->x; in mt_process_slot()
1135 y = hdev->quirks & HID_QUIRK_Y_INVERT ? in mt_process_slot()
1136 input_abs_get_max(input, ABS_MT_POSITION_Y) - *slot->y : in mt_process_slot()
1137 *slot->y; in mt_process_slot()
1138 cx = hdev->quirks & HID_QUIRK_X_INVERT ? in mt_process_slot()
1139 input_abs_get_max(input, ABS_MT_POSITION_X) - *slot->cx : in mt_process_slot()
1140 *slot->cx; in mt_process_slot()
1141 cy = hdev->quirks & HID_QUIRK_Y_INVERT ? in mt_process_slot()
1142 input_abs_get_max(input, ABS_MT_POSITION_Y) - *slot->cy : in mt_process_slot()
1143 *slot->cy; in mt_process_slot()
1149 input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); in mt_process_slot()
1151 input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); in mt_process_slot()
1155 set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_process_slot()
1168 __s32 quirks = app->quirks; in mt_process_mt_event()
1169 struct input_dev *input = field->hidinput->input; in mt_process_mt_event()
1171 if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) in mt_process_mt_event()
1179 * (possible) multi-packet frame. in mt_process_mt_event()
1191 if (usage->type == EV_KEY && usage->code == BTN_LEFT) { in mt_process_mt_event()
1192 app->left_button_state |= value; in mt_process_mt_event()
1197 input_event(input, usage->type, usage->code, value); in mt_process_mt_event()
1204 struct hid_report *report = rdata->report; in mt_touch_report()
1205 struct mt_application *app = rdata->application; in mt_touch_report()
1213 int contact_count = -1; in mt_touch_report()
1216 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_touch_report()
1219 scantime = *app->scantime; in mt_touch_report()
1220 app->timestamp = mt_compute_timestamp(app, scantime); in mt_touch_report()
1221 if (app->raw_cc != DEFAULT_ZERO) in mt_touch_report()
1222 contact_count = *app->raw_cc; in mt_touch_report()
1225 * Includes multi-packet support where subsequent in mt_touch_report()
1230 * For Win8 PTPs the first packet (td->num_received == 0) may in mt_touch_report()
1233 * of a possible multi-packet frame be checking that the in mt_touch_report()
1236 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_report()
1237 app->num_received == 0 && in mt_touch_report()
1238 app->prev_scantime != scantime) in mt_touch_report()
1239 app->num_expected = contact_count; in mt_touch_report()
1242 app->num_expected = contact_count; in mt_touch_report()
1244 app->prev_scantime = scantime; in mt_touch_report()
1246 first_packet = app->num_received == 0; in mt_touch_report()
1248 input = report->field[0]->hidinput->input; in mt_touch_report()
1250 list_for_each_entry(slot, &app->mt_usages, list) { in mt_touch_report()
1252 app->num_received++; in mt_touch_report()
1255 for (r = 0; r < report->maxfield; r++) { in mt_touch_report()
1256 field = report->field[r]; in mt_touch_report()
1257 count = field->report_count; in mt_touch_report()
1259 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_touch_report()
1264 &field->usage[n], field->value[n], in mt_touch_report()
1268 if (app->num_received >= app->num_expected) in mt_touch_report()
1273 * - once a contact has been reported, it has to be reported in each in mt_touch_report()
1275 * - the report rate when fingers are present has to be at least in mt_touch_report()
1279 * at least 60 Hz for a touchscreen to be certified. in mt_touch_report()
1281 * something wrong happens, either the touchscreen forgets to send in mt_touch_report()
1289 if (app->quirks & MT_QUIRK_STICKY_FINGERS) { in mt_touch_report()
1290 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_touch_report()
1291 mod_timer(&td->release_timer, in mt_touch_report()
1294 del_timer(&td->release_timer); in mt_touch_report()
1297 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_touch_report()
1305 struct mt_class *cls = &td->mtclass; in mt_touch_input_configured()
1306 struct input_dev *input = hi->input; in mt_touch_input_configured()
1309 if (!td->maxcontacts) in mt_touch_input_configured()
1310 td->maxcontacts = MT_DEFAULT_MAXCONTACT; in mt_touch_input_configured()
1313 if (td->serial_maybe) in mt_touch_input_configured()
1316 if (cls->is_indirect) in mt_touch_input_configured()
1317 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_configured()
1319 if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) in mt_touch_input_configured()
1320 app->mt_flags |= INPUT_MT_DROP_UNUSED; in mt_touch_input_configured()
1323 if ((app->mt_flags & INPUT_MT_POINTER) && in mt_touch_input_configured()
1324 (app->buttons_count == 1)) in mt_touch_input_configured()
1325 td->is_buttonpad = true; in mt_touch_input_configured()
1327 if (td->is_buttonpad) in mt_touch_input_configured()
1328 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); in mt_touch_input_configured()
1330 app->pending_palm_slots = devm_kcalloc(&hi->input->dev, in mt_touch_input_configured()
1331 BITS_TO_LONGS(td->maxcontacts), in mt_touch_input_configured()
1334 if (!app->pending_palm_slots) in mt_touch_input_configured()
1335 return -ENOMEM; in mt_touch_input_configured()
1337 ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); in mt_touch_input_configured()
1341 app->mt_flags = 0; in mt_touch_input_configured()
1355 rdata = mt_find_report_data(td, field->report); in mt_input_mapping()
1361 application = rdata->application; in mt_input_mapping()
1365 * TouchScreen or TouchPad collections. We need to ignore fields in mt_input_mapping()
1369 if (!td->mtclass.export_all_inputs && in mt_input_mapping()
1370 field->application != HID_DG_TOUCHSCREEN && in mt_input_mapping()
1371 field->application != HID_DG_PEN && in mt_input_mapping()
1372 field->application != HID_DG_TOUCHPAD && in mt_input_mapping()
1373 field->application != HID_GD_KEYBOARD && in mt_input_mapping()
1374 field->application != HID_GD_SYSTEM_CONTROL && in mt_input_mapping()
1375 field->application != HID_CP_CONSUMER_CONTROL && in mt_input_mapping()
1376 field->application != HID_GD_WIRELESS_RADIO_CTLS && in mt_input_mapping()
1377 field->application != HID_GD_SYSTEM_MULTIAXIS && in mt_input_mapping()
1378 !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1379 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) in mt_input_mapping()
1380 return -1; in mt_input_mapping()
1387 if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1388 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && in mt_input_mapping()
1389 (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { in mt_input_mapping()
1390 set_bit(EV_REP, hi->input->evbit); in mt_input_mapping()
1391 if (field->flags & HID_MAIN_ITEM_VARIABLE) in mt_input_mapping()
1392 field->flags &= ~HID_MAIN_ITEM_VARIABLE; in mt_input_mapping()
1393 switch (usage->hid & HID_USAGE) { in mt_input_mapping()
1400 return -1; in mt_input_mapping()
1405 if (rdata->is_mt_collection) in mt_input_mapping()
1413 if (field->physical == HID_DG_STYLUS) in mt_input_mapping()
1414 hi->application = HID_DG_STYLUS; in mt_input_mapping()
1416 /* let hid-core decide for the others */ in mt_input_mapping()
1427 rdata = mt_find_report_data(td, field->report); in mt_input_mapped()
1428 if (rdata && rdata->is_mt_collection) { in mt_input_mapped()
1429 /* We own these mappings, tell hid-input to ignore them */ in mt_input_mapped()
1430 return -1; in mt_input_mapped()
1433 /* let hid-core decide for the others */ in mt_input_mapped()
1443 rdata = mt_find_report_data(td, field->report); in mt_event()
1444 if (rdata && rdata->is_mt_collection) in mt_event()
1453 if (hdev->vendor == I2C_VENDOR_ID_GOODIX && in mt_report_fixup()
1454 (hdev->product == I2C_DEVICE_ID_GOODIX_01E8 || in mt_report_fixup()
1455 hdev->product == I2C_DEVICE_ID_GOODIX_01E9 || in mt_report_fixup()
1456 hdev->product == I2C_DEVICE_ID_GOODIX_01E0)) { in mt_report_fixup()
1460 &hdev->dev, in mt_report_fixup()
1464 &hdev->dev, in mt_report_fixup()
1478 struct hid_field *field = report->field[0]; in mt_report()
1481 if (!(hid->claimed & HID_CLAIMED_INPUT)) in mt_report()
1485 if (rdata && rdata->is_mt_collection) in mt_report()
1488 if (field && field->hidinput && field->hidinput->input) in mt_report()
1489 input_sync(field->hidinput->input); in mt_report()
1501 struct mt_class *cls = &td->mtclass; in mt_need_to_apply_feature()
1502 struct hid_report *report = field->report; in mt_need_to_apply_feature()
1503 unsigned int index = usage->usage_index; in mt_need_to_apply_feature()
1508 switch (usage->hid) { in mt_need_to_apply_feature()
1518 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { in mt_need_to_apply_feature()
1526 hid_hw_raw_request(hdev, report->id, buf, report_len, in mt_need_to_apply_feature()
1532 field->value[index] = td->inputmode_value; in mt_need_to_apply_feature()
1537 if (cls->maxcontacts) { in mt_need_to_apply_feature()
1538 max = min_t(int, field->logical_maximum, in mt_need_to_apply_feature()
1539 cls->maxcontacts); in mt_need_to_apply_feature()
1540 if (field->value[index] != max) { in mt_need_to_apply_feature()
1541 field->value[index] = max; in mt_need_to_apply_feature()
1548 field->value[index] = latency; in mt_need_to_apply_feature()
1552 field->value[index] = surface_switch; in mt_need_to_apply_feature()
1556 field->value[index] = button_switch; in mt_need_to_apply_feature()
1573 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in mt_set_modes()
1574 list_for_each_entry(rep, &rep_enum->report_list, list) { in mt_set_modes()
1577 for (i = 0; i < rep->maxfield; i++) { in mt_set_modes()
1579 if (rep->field[i]->report_count < 1) in mt_set_modes()
1582 for (j = 0; j < rep->field[i]->maxusage; j++) { in mt_set_modes()
1583 usage = &rep->field[i]->usage[j]; in mt_set_modes()
1586 rep->field[i], in mt_set_modes()
1604 __s32 quirks = app->quirks; in mt_post_parse_default_settings()
1607 if (list_is_singular(&app->mt_usages)) { in mt_post_parse_default_settings()
1615 app->quirks = quirks; in mt_post_parse_default_settings()
1620 if (!app->have_contact_count) in mt_post_parse()
1621 app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_post_parse()
1633 list_for_each_entry(report, &hi->reports, hidinput_list) { in mt_input_configured()
1637 return -ENOMEM; in mt_input_configured()
1640 mt_application = rdata->application; in mt_input_configured()
1642 if (rdata->is_mt_collection) { in mt_input_configured()
1650 switch (hi->application) { in mt_input_configured()
1662 /* we do not set suffix = "Touchscreen" */ in mt_input_configured()
1663 hi->input->name = hdev->name; in mt_input_configured()
1670 __set_bit(BTN_STYLUS, hi->input->keybit); in mt_input_configured()
1678 hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, in mt_input_configured()
1679 "%s %s", hdev->name, suffix); in mt_input_configured()
1686 if (field->usage[0].hid != usage || in mt_fix_const_field()
1687 !(field->flags & HID_MAIN_ITEM_CONSTANT)) in mt_fix_const_field()
1690 field->flags &= ~HID_MAIN_ITEM_CONSTANT; in mt_fix_const_field()
1691 field->flags |= HID_MAIN_ITEM_VARIABLE; in mt_fix_const_field()
1700 &hdev->report_enum[HID_INPUT_REPORT].report_list, in mt_fix_const_fields()
1703 if (!report->maxfield) in mt_fix_const_fields()
1706 for (i = 0; i < report->maxfield; i++) in mt_fix_const_fields()
1707 if (report->field[i]->maxusage >= 1) in mt_fix_const_fields()
1708 mt_fix_const_field(report->field[i], usage); in mt_fix_const_fields()
1718 list_for_each_entry(hidinput, &hid->inputs, list) { in mt_release_contacts()
1719 struct input_dev *input_dev = hidinput->input; in mt_release_contacts()
1720 struct input_mt *mt = input_dev->mt; in mt_release_contacts()
1724 for (i = 0; i < mt->num_slots; i++) { in mt_release_contacts()
1733 list_for_each_entry(application, &td->applications, list) { in mt_release_contacts()
1734 application->num_received = 0; in mt_release_contacts()
1741 struct hid_device *hdev = td->hdev; in mt_expired_timeout()
1747 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_expired_timeout()
1749 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_expired_timeout()
1751 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_expired_timeout()
1761 if (id->driver_data == mt_classes[i].name) { in mt_probe()
1767 td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); in mt_probe()
1769 dev_err(&hdev->dev, "cannot allocate multitouch data\n"); in mt_probe()
1770 return -ENOMEM; in mt_probe()
1772 td->hdev = hdev; in mt_probe()
1773 td->mtclass = *mtclass; in mt_probe()
1774 td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; in mt_probe()
1777 INIT_LIST_HEAD(&td->applications); in mt_probe()
1778 INIT_LIST_HEAD(&td->reports); in mt_probe()
1780 if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) in mt_probe()
1781 td->serial_maybe = true; in mt_probe()
1787 if (hdev->quirks & (HID_QUIRK_X_INVERT | HID_QUIRK_Y_INVERT) && in mt_probe()
1788 !((hdev->quirks & HID_QUIRK_X_INVERT) in mt_probe()
1789 && (hdev->quirks & HID_QUIRK_Y_INVERT))) in mt_probe()
1790 td->mtclass.quirks = MT_QUIRK_ORIENTATION_INVERT; in mt_probe()
1795 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; in mt_probe()
1802 hdev->quirks |= HID_QUIRK_INPUT_PER_APP; in mt_probe()
1804 if (id->group != HID_GROUP_MULTITOUCH_WIN_8) in mt_probe()
1805 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1807 if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) { in mt_probe()
1808 hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP; in mt_probe()
1809 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1812 timer_setup(&td->release_timer, mt_expired_timeout, 0); in mt_probe()
1818 if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) in mt_probe()
1821 if (hdev->vendor == USB_VENDOR_ID_SIS_TOUCH) in mt_probe()
1822 hdev->quirks |= HID_QUIRK_NOGET; in mt_probe()
1828 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); in mt_probe()
1830 dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", in mt_probe()
1831 hdev->name); in mt_probe()
1843 if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || in mt_suspend()
1876 del_timer_sync(&td->release_timer); in mt_remove()
1878 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); in mt_remove()
1884 * - VID/PID of products not working with the default multitouch handling
1885 * - 2 generic rules.
2097 /* HONOR GLO-GXXX panel */
2194 /* PixCir-based panels */
2199 /* Quanta-based panels */
2328 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
2332 .name = "hid-multitouch",