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"
118 unsigned int mt_flags; /* flags to pass to input-mt */
145 __s32 sn_pressure; /* Signal/noise ratio for pressure events */
225 * these device-dependent functions determine what slot corresponds
232 if (*slot->contactid != 0 || application->num_received == 0) in cypress_compute_slot()
233 return *slot->contactid; in cypress_compute_slot()
235 return -1; in cypress_compute_slot()
380 return sprintf(buf, "%u\n", td->mtclass.quirks); in mt_show_quirks()
394 return -EINVAL; in mt_set_quirks()
396 td->mtclass.quirks = val; in mt_set_quirks()
398 list_for_each_entry(application, &td->applications, list) { in mt_set_quirks()
399 application->quirks = val; in mt_set_quirks()
400 if (!application->have_contact_count) in mt_set_quirks()
401 application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_set_quirks()
426 * marked as non-capable. in mt_get_feature()
428 if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) in mt_get_feature()
435 ret = hid_hw_raw_request(hdev, report->id, buf, size, in mt_get_feature()
438 dev_warn(&hdev->dev, "failed to fetch feature %d\n", in mt_get_feature()
439 report->id); in mt_get_feature()
444 dev_warn(&hdev->dev, "failed to report feature\n"); in mt_get_feature()
455 switch (usage->hid) { in mt_feature_mapping()
457 mt_get_feature(hdev, field->report); in mt_feature_mapping()
459 td->maxcontacts = field->value[0]; in mt_feature_mapping()
460 if (!td->maxcontacts && in mt_feature_mapping()
461 field->logical_maximum <= MT_MAX_MAXCONTACT) in mt_feature_mapping()
462 td->maxcontacts = field->logical_maximum; in mt_feature_mapping()
463 if (td->mtclass.maxcontacts) in mt_feature_mapping()
465 td->maxcontacts = td->mtclass.maxcontacts; in mt_feature_mapping()
469 if (usage->usage_index >= field->report_count) { in mt_feature_mapping()
470 dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); in mt_feature_mapping()
474 mt_get_feature(hdev, field->report); in mt_feature_mapping()
475 if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) in mt_feature_mapping()
476 td->is_buttonpad = true; in mt_feature_mapping()
481 if (usage->usage_index == 0) in mt_feature_mapping()
482 mt_get_feature(hdev, field->report); in mt_feature_mapping()
490 int fmin = field->logical_minimum; in set_abs()
491 int fmax = field->logical_maximum; in set_abs()
492 int fuzz = snratio ? (fmax - fmin) / snratio : 0; in set_abs() local
493 input_set_abs_params(input, code, fmin, fmax, fuzz, 0); in set_abs()
502 usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); in mt_allocate_usage()
507 usage->x = DEFAULT_ZERO; in mt_allocate_usage()
508 usage->y = DEFAULT_ZERO; in mt_allocate_usage()
509 usage->cx = DEFAULT_ZERO; in mt_allocate_usage()
510 usage->cy = DEFAULT_ZERO; in mt_allocate_usage()
511 usage->p = DEFAULT_ZERO; in mt_allocate_usage()
512 usage->w = DEFAULT_ZERO; in mt_allocate_usage()
513 usage->h = DEFAULT_ZERO; in mt_allocate_usage()
514 usage->a = DEFAULT_ZERO; in mt_allocate_usage()
515 usage->contactid = DEFAULT_ZERO; in mt_allocate_usage()
516 usage->tip_state = DEFAULT_FALSE; in mt_allocate_usage()
517 usage->inrange_state = DEFAULT_FALSE; in mt_allocate_usage()
518 usage->confidence_state = DEFAULT_TRUE; in mt_allocate_usage()
520 list_add_tail(&usage->list, &application->mt_usages); in mt_allocate_usage()
528 unsigned int application = report->application; in mt_allocate_application()
531 mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), in mt_allocate_application()
536 mt_application->application = application; in mt_allocate_application()
537 INIT_LIST_HEAD(&mt_application->mt_usages); in mt_allocate_application()
540 mt_application->mt_flags |= INPUT_MT_DIRECT; in mt_allocate_application()
546 mt_application->mt_flags |= INPUT_MT_POINTER; in mt_allocate_application()
547 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_allocate_application()
550 mt_application->scantime = DEFAULT_ZERO; in mt_allocate_application()
551 mt_application->raw_cc = DEFAULT_ZERO; in mt_allocate_application()
552 mt_application->quirks = td->mtclass.quirks; in mt_allocate_application()
553 mt_application->report_id = report->id; in mt_allocate_application()
555 list_add_tail(&mt_application->list, &td->applications); in mt_allocate_application()
563 unsigned int application = report->application; in mt_find_application()
566 list_for_each_entry(tmp, &td->applications, list) { in mt_find_application()
567 if (application == tmp->application) { in mt_find_application()
568 if (!(td->mtclass.quirks & MT_QUIRK_SEPARATE_APP_REPORT) || in mt_find_application()
569 tmp->report_id == report->id) { in mt_find_application()
589 rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); in mt_allocate_report_data()
593 rdata->report = report; in mt_allocate_report_data()
594 rdata->application = mt_find_application(td, report); in mt_allocate_report_data()
596 if (!rdata->application) { in mt_allocate_report_data()
597 devm_kfree(&td->hdev->dev, rdata); in mt_allocate_report_data()
601 for (r = 0; r < report->maxfield; r++) { in mt_allocate_report_data()
602 field = report->field[r]; in mt_allocate_report_data()
604 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_allocate_report_data()
607 for (n = 0; n < field->report_count; n++) { in mt_allocate_report_data()
608 if (field->usage[n].hid == HID_DG_CONTACTID) in mt_allocate_report_data()
609 rdata->is_mt_collection = true; in mt_allocate_report_data()
613 list_add_tail(&rdata->list, &td->reports); in mt_allocate_report_data()
623 list_for_each_entry(tmp, &td->reports, list) { in mt_find_report_data()
624 if (report == tmp->report) { in mt_find_report_data()
644 if (list_empty(&application->mt_usages)) in mt_store_field()
647 usage = list_last_entry(&application->mt_usages, in mt_store_field()
660 if (usage->contactid == DEFAULT_ZERO || in mt_store_field()
661 usage->x == DEFAULT_ZERO || in mt_store_field()
662 usage->y == DEFAULT_ZERO) { in mt_store_field()
679 &field->value[usage->usage_index], \
687 struct mt_class *cls = &td->mtclass; in mt_touch_input_mapping()
694 if (field->application == HID_DG_TOUCHSCREEN && in mt_touch_input_mapping()
695 (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { in mt_touch_input_mapping()
696 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_mapping()
697 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_touch_input_mapping()
701 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) in mt_touch_input_mapping()
702 app->buttons_count++; in mt_touch_input_mapping()
704 if (usage->usage_index) in mt_touch_input_mapping()
705 prev_usage = &field->usage[usage->usage_index - 1]; in mt_touch_input_mapping()
707 switch (usage->hid & HID_USAGE_PAGE) { in mt_touch_input_mapping()
710 switch (usage->hid) { in mt_touch_input_mapping()
712 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
720 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
723 * A system multi-axis that exports X and Y has a high in mt_touch_input_mapping()
726 if (field->application == HID_GD_SYSTEM_MULTIAXIS) { in mt_touch_input_mapping()
728 hi->input->propbit); in mt_touch_input_mapping()
729 input_set_abs_params(hi->input, in mt_touch_input_mapping()
737 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
745 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
752 switch (usage->hid) { in mt_touch_input_mapping()
754 if (app->quirks & MT_QUIRK_HOVERING) { in mt_touch_input_mapping()
755 input_set_abs_params(hi->input, in mt_touch_input_mapping()
761 if (cls->name == MT_CLS_WIN_8 && in mt_touch_input_mapping()
762 (field->application == HID_DG_TOUCHPAD || in mt_touch_input_mapping()
763 field->application == HID_DG_TOUCHSCREEN)) in mt_touch_input_mapping()
764 app->quirks |= MT_QUIRK_CONFIDENCE; in mt_touch_input_mapping()
766 if (app->quirks & MT_QUIRK_CONFIDENCE) in mt_touch_input_mapping()
767 input_set_abs_params(hi->input, in mt_touch_input_mapping()
775 if (field->application != HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
776 input_set_capability(hi->input, in mt_touch_input_mapping()
782 app->touches_by_report++; in mt_touch_input_mapping()
785 if (!(app->quirks & MT_QUIRK_NO_AREA)) in mt_touch_input_mapping()
786 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, in mt_touch_input_mapping()
787 cls->sn_width); in mt_touch_input_mapping()
791 if (!(app->quirks & MT_QUIRK_NO_AREA)) { in mt_touch_input_mapping()
792 set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, in mt_touch_input_mapping()
793 cls->sn_height); in mt_touch_input_mapping()
800 hi->input->absbit)) in mt_touch_input_mapping()
801 input_set_abs_params(hi->input, in mt_touch_input_mapping()
807 set_abs(hi->input, ABS_MT_PRESSURE, field, in mt_touch_input_mapping()
808 cls->sn_pressure); in mt_touch_input_mapping()
812 input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); in mt_touch_input_mapping()
813 app->scantime = &field->value[usage->usage_index]; in mt_touch_input_mapping()
814 app->scantime_logical_max = field->logical_maximum; in mt_touch_input_mapping()
817 app->have_contact_count = true; in mt_touch_input_mapping()
818 app->raw_cc = &field->value[usage->usage_index]; in mt_touch_input_mapping()
826 input_set_abs_params(hi->input, ABS_MT_ORIENTATION, in mt_touch_input_mapping()
827 -field->logical_maximum / 4, in mt_touch_input_mapping()
828 field->logical_maximum / 4, in mt_touch_input_mapping()
829 cls->sn_move ? in mt_touch_input_mapping()
830 field->logical_maximum / cls->sn_move : 0, 0); in mt_touch_input_mapping()
835 return -1; in mt_touch_input_mapping()
839 return -1; in mt_touch_input_mapping()
841 /* let hid-input decide for the others */ in mt_touch_input_mapping()
845 code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
850 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_input_mapping()
851 field->application == HID_DG_TOUCHPAD && in mt_touch_input_mapping()
852 (usage->hid & HID_USAGE) > 1) in mt_touch_input_mapping()
853 code--; in mt_touch_input_mapping()
855 if (field->application == HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
856 code = BTN_0 + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
860 return -1; in mt_touch_input_mapping()
861 input_set_capability(hi->input, EV_KEY, code); in mt_touch_input_mapping()
865 /* we do not want to map these: no input-oriented meaning */ in mt_touch_input_mapping()
866 return -1; in mt_touch_input_mapping()
876 __s32 quirks = app->quirks; in mt_compute_slot()
879 return *slot->contactid; in mt_compute_slot()
885 return app->num_received; in mt_compute_slot()
888 return *slot->contactid - 1; in mt_compute_slot()
890 return input_mt_get_slot_by_key(input, *slot->contactid); in mt_compute_slot()
900 for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { in mt_release_pending_palms()
901 clear_bit(slotnum, app->pending_palm_slots); in mt_release_pending_palms()
922 if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) in mt_sync_frame()
923 input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); in mt_sync_frame()
926 input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); in mt_sync_frame()
931 app->num_received = 0; in mt_sync_frame()
932 app->left_button_state = 0; in mt_sync_frame()
934 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) in mt_sync_frame()
935 set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
937 clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
938 clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_sync_frame()
943 long delta = value - app->prev_scantime; in mt_compute_timestamp()
944 unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); in mt_compute_timestamp()
946 app->jiffies = jiffies; in mt_compute_timestamp()
949 delta += app->scantime_logical_max; in mt_compute_timestamp()
958 return app->timestamp + delta; in mt_compute_timestamp()
965 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) in mt_touch_event()
966 hid->hiddev_hid_event(hid, field, usage, value); in mt_touch_event()
975 struct input_mt *mt = input->mt; in mt_process_slot()
976 __s32 quirks = app->quirks; in mt_process_slot()
985 return -EINVAL; in mt_process_slot()
988 app->num_received >= app->num_expected) in mt_process_slot()
989 return -EAGAIN; in mt_process_slot()
993 valid = *slot->inrange_state; in mt_process_slot()
995 valid = *slot->tip_state; in mt_process_slot()
997 valid = *slot->confidence_state; in mt_process_slot()
1004 if (slotnum < 0 || slotnum >= td->maxcontacts) in mt_process_slot()
1008 struct input_mt_slot *i_slot = &mt->slots[slotnum]; in mt_process_slot()
1012 return -EAGAIN; in mt_process_slot()
1016 confidence_state = *slot->confidence_state; in mt_process_slot()
1019 inrange_state = *slot->inrange_state; in mt_process_slot()
1021 active = *slot->tip_state || inrange_state; in mt_process_slot()
1023 if (app->application == HID_GD_SYSTEM_MULTIAXIS) in mt_process_slot()
1028 input_mt_is_active(&mt->slots[slotnum])) { in mt_process_slot()
1030 * The non-confidence was reported for in mt_process_slot()
1033 * lift-off as userspace will not be aware in mt_process_slot()
1034 * of non-confidence, so we need to split in mt_process_slot()
1039 set_bit(slotnum, app->pending_palm_slots); in mt_process_slot()
1047 int wide = (*slot->w > *slot->h); in mt_process_slot()
1048 int major = max(*slot->w, *slot->h); in mt_process_slot()
1049 int minor = min(*slot->w, *slot->h); in mt_process_slot()
1054 if (slot->a != DEFAULT_ZERO) { in mt_process_slot()
1056 * Azimuth is counter-clockwise and ranges from [0, MAX) in mt_process_slot()
1058 * [-MAX/2, MAX/2]. in mt_process_slot()
1061 * the limit of [-MAX/4, MAX/4], but the value can go in mt_process_slot()
1062 * out of range to [-MAX/2, MAX/2] to report an upside in mt_process_slot()
1065 azimuth = *slot->a; in mt_process_slot()
1069 azimuth -= max_azimuth * 4; in mt_process_slot()
1070 orientation = -azimuth; in mt_process_slot()
1082 input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); in mt_process_slot()
1083 input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); in mt_process_slot()
1084 input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx); in mt_process_slot()
1085 input_event(input, EV_ABS, ABS_MT_TOOL_Y, *slot->cy); in mt_process_slot()
1086 input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); in mt_process_slot()
1088 input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); in mt_process_slot()
1092 set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_process_slot()
1105 __s32 quirks = app->quirks; in mt_process_mt_event()
1106 struct input_dev *input = field->hidinput->input; in mt_process_mt_event()
1108 if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) in mt_process_mt_event()
1116 * (possible) multi-packet frame. in mt_process_mt_event()
1128 if (usage->type == EV_KEY && usage->code == BTN_LEFT) { in mt_process_mt_event()
1129 app->left_button_state |= value; in mt_process_mt_event()
1134 input_event(input, usage->type, usage->code, value); in mt_process_mt_event()
1141 struct hid_report *report = rdata->report; in mt_touch_report()
1142 struct mt_application *app = rdata->application; in mt_touch_report()
1150 int contact_count = -1; in mt_touch_report()
1153 if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_touch_report()
1156 scantime = *app->scantime; in mt_touch_report()
1157 app->timestamp = mt_compute_timestamp(app, scantime); in mt_touch_report()
1158 if (app->raw_cc != DEFAULT_ZERO) in mt_touch_report()
1159 contact_count = *app->raw_cc; in mt_touch_report()
1162 * Includes multi-packet support where subsequent in mt_touch_report()
1167 * For Win8 PTPs the first packet (td->num_received == 0) may in mt_touch_report()
1170 * of a possible multi-packet frame be checking that the in mt_touch_report()
1173 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_report()
1174 app->num_received == 0 && in mt_touch_report()
1175 app->prev_scantime != scantime) in mt_touch_report()
1176 app->num_expected = contact_count; in mt_touch_report()
1179 app->num_expected = contact_count; in mt_touch_report()
1181 app->prev_scantime = scantime; in mt_touch_report()
1183 first_packet = app->num_received == 0; in mt_touch_report()
1185 input = report->field[0]->hidinput->input; in mt_touch_report()
1187 list_for_each_entry(slot, &app->mt_usages, list) { in mt_touch_report()
1189 app->num_received++; in mt_touch_report()
1192 for (r = 0; r < report->maxfield; r++) { in mt_touch_report()
1193 field = report->field[r]; in mt_touch_report()
1194 count = field->report_count; in mt_touch_report()
1196 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_touch_report()
1201 &field->usage[n], field->value[n], in mt_touch_report()
1205 if (app->num_received >= app->num_expected) in mt_touch_report()
1210 * - once a contact has been reported, it has to be reported in each in mt_touch_report()
1212 * - the report rate when fingers are present has to be at least in mt_touch_report()
1216 * at least 60 Hz for a touchscreen to be certified. in mt_touch_report()
1218 * something wrong happens, either the touchscreen forgets to send in mt_touch_report()
1226 if (app->quirks & MT_QUIRK_STICKY_FINGERS) { in mt_touch_report()
1227 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_touch_report()
1228 mod_timer(&td->release_timer, in mt_touch_report()
1231 del_timer(&td->release_timer); in mt_touch_report()
1234 clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_touch_report()
1242 struct mt_class *cls = &td->mtclass; in mt_touch_input_configured()
1243 struct input_dev *input = hi->input; in mt_touch_input_configured()
1246 if (!td->maxcontacts) in mt_touch_input_configured()
1247 td->maxcontacts = MT_DEFAULT_MAXCONTACT; in mt_touch_input_configured()
1250 if (td->serial_maybe) in mt_touch_input_configured()
1253 if (cls->is_indirect) in mt_touch_input_configured()
1254 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_configured()
1256 if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) in mt_touch_input_configured()
1257 app->mt_flags |= INPUT_MT_DROP_UNUSED; in mt_touch_input_configured()
1260 if ((app->mt_flags & INPUT_MT_POINTER) && in mt_touch_input_configured()
1261 (app->buttons_count == 1)) in mt_touch_input_configured()
1262 td->is_buttonpad = true; in mt_touch_input_configured()
1264 if (td->is_buttonpad) in mt_touch_input_configured()
1265 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); in mt_touch_input_configured()
1267 app->pending_palm_slots = devm_kcalloc(&hi->input->dev, in mt_touch_input_configured()
1268 BITS_TO_LONGS(td->maxcontacts), in mt_touch_input_configured()
1271 if (!app->pending_palm_slots) in mt_touch_input_configured()
1272 return -ENOMEM; in mt_touch_input_configured()
1274 ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); in mt_touch_input_configured()
1278 app->mt_flags = 0; in mt_touch_input_configured()
1292 rdata = mt_find_report_data(td, field->report); in mt_input_mapping()
1298 application = rdata->application; in mt_input_mapping()
1302 * TouchScreen or TouchPad collections. We need to ignore fields in mt_input_mapping()
1306 if (!td->mtclass.export_all_inputs && in mt_input_mapping()
1307 field->application != HID_DG_TOUCHSCREEN && in mt_input_mapping()
1308 field->application != HID_DG_PEN && in mt_input_mapping()
1309 field->application != HID_DG_TOUCHPAD && in mt_input_mapping()
1310 field->application != HID_GD_KEYBOARD && in mt_input_mapping()
1311 field->application != HID_GD_SYSTEM_CONTROL && in mt_input_mapping()
1312 field->application != HID_CP_CONSUMER_CONTROL && in mt_input_mapping()
1313 field->application != HID_GD_WIRELESS_RADIO_CTLS && in mt_input_mapping()
1314 field->application != HID_GD_SYSTEM_MULTIAXIS && in mt_input_mapping()
1315 !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1316 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) in mt_input_mapping()
1317 return -1; in mt_input_mapping()
1324 if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1325 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && in mt_input_mapping()
1326 (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { in mt_input_mapping()
1327 set_bit(EV_REP, hi->input->evbit); in mt_input_mapping()
1328 if (field->flags & HID_MAIN_ITEM_VARIABLE) in mt_input_mapping()
1329 field->flags &= ~HID_MAIN_ITEM_VARIABLE; in mt_input_mapping()
1330 switch (usage->hid & HID_USAGE) { in mt_input_mapping()
1337 return -1; in mt_input_mapping()
1342 if (rdata->is_mt_collection) in mt_input_mapping()
1350 if (field->physical == HID_DG_STYLUS) in mt_input_mapping()
1351 hi->application = HID_DG_STYLUS; in mt_input_mapping()
1353 /* let hid-core decide for the others */ in mt_input_mapping()
1364 rdata = mt_find_report_data(td, field->report); in mt_input_mapped()
1365 if (rdata && rdata->is_mt_collection) { in mt_input_mapped()
1366 /* We own these mappings, tell hid-input to ignore them */ in mt_input_mapped()
1367 return -1; in mt_input_mapped()
1370 /* let hid-core decide for the others */ in mt_input_mapped()
1380 rdata = mt_find_report_data(td, field->report); in mt_event()
1381 if (rdata && rdata->is_mt_collection) in mt_event()
1390 struct hid_field *field = report->field[0]; in mt_report()
1393 if (!(hid->claimed & HID_CLAIMED_INPUT)) in mt_report()
1397 if (rdata && rdata->is_mt_collection) in mt_report()
1400 if (field && field->hidinput && field->hidinput->input) in mt_report()
1401 input_sync(field->hidinput->input); in mt_report()
1413 struct mt_class *cls = &td->mtclass; in mt_need_to_apply_feature()
1414 struct hid_report *report = field->report; in mt_need_to_apply_feature()
1415 unsigned int index = usage->usage_index; in mt_need_to_apply_feature()
1420 switch (usage->hid) { in mt_need_to_apply_feature()
1430 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { in mt_need_to_apply_feature()
1438 hid_hw_raw_request(hdev, report->id, buf, report_len, in mt_need_to_apply_feature()
1444 field->value[index] = td->inputmode_value; in mt_need_to_apply_feature()
1449 if (cls->maxcontacts) { in mt_need_to_apply_feature()
1450 max = min_t(int, field->logical_maximum, in mt_need_to_apply_feature()
1451 cls->maxcontacts); in mt_need_to_apply_feature()
1452 if (field->value[index] != max) { in mt_need_to_apply_feature()
1453 field->value[index] = max; in mt_need_to_apply_feature()
1460 field->value[index] = latency; in mt_need_to_apply_feature()
1464 field->value[index] = surface_switch; in mt_need_to_apply_feature()
1468 field->value[index] = button_switch; in mt_need_to_apply_feature()
1485 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in mt_set_modes()
1486 list_for_each_entry(rep, &rep_enum->report_list, list) { in mt_set_modes()
1489 for (i = 0; i < rep->maxfield; i++) { in mt_set_modes()
1491 if (rep->field[i]->report_count < 1) in mt_set_modes()
1494 for (j = 0; j < rep->field[i]->maxusage; j++) { in mt_set_modes()
1495 usage = &rep->field[i]->usage[j]; in mt_set_modes()
1498 rep->field[i], in mt_set_modes()
1516 __s32 quirks = app->quirks; in mt_post_parse_default_settings()
1519 if (list_is_singular(&app->mt_usages)) { in mt_post_parse_default_settings()
1527 app->quirks = quirks; in mt_post_parse_default_settings()
1532 if (!app->have_contact_count) in mt_post_parse()
1533 app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_post_parse()
1546 list_for_each_entry(report, &hi->reports, hidinput_list) { in mt_input_configured()
1550 return -ENOMEM; in mt_input_configured()
1553 mt_application = rdata->application; in mt_input_configured()
1555 if (rdata->is_mt_collection) { in mt_input_configured()
1563 switch (hi->application) { in mt_input_configured()
1575 /* we do not set suffix = "Touchscreen" */ in mt_input_configured()
1576 hi->input->name = hdev->name; in mt_input_configured()
1580 __set_bit(BTN_STYLUS, hi->input->keybit); in mt_input_configured()
1594 name = devm_kzalloc(&hi->input->dev, in mt_input_configured()
1595 strlen(hdev->name) + strlen(suffix) + 2, in mt_input_configured()
1598 sprintf(name, "%s %s", hdev->name, suffix); in mt_input_configured()
1599 hi->input->name = name; in mt_input_configured()
1608 if (field->usage[0].hid != usage || in mt_fix_const_field()
1609 !(field->flags & HID_MAIN_ITEM_CONSTANT)) in mt_fix_const_field()
1612 field->flags &= ~HID_MAIN_ITEM_CONSTANT; in mt_fix_const_field()
1613 field->flags |= HID_MAIN_ITEM_VARIABLE; in mt_fix_const_field()
1622 &hdev->report_enum[HID_INPUT_REPORT].report_list, in mt_fix_const_fields()
1625 if (!report->maxfield) in mt_fix_const_fields()
1628 for (i = 0; i < report->maxfield; i++) in mt_fix_const_fields()
1629 if (report->field[i]->maxusage >= 1) in mt_fix_const_fields()
1630 mt_fix_const_field(report->field[i], usage); in mt_fix_const_fields()
1640 list_for_each_entry(hidinput, &hid->inputs, list) { in mt_release_contacts()
1641 struct input_dev *input_dev = hidinput->input; in mt_release_contacts()
1642 struct input_mt *mt = input_dev->mt; in mt_release_contacts()
1646 for (i = 0; i < mt->num_slots; i++) { in mt_release_contacts()
1655 list_for_each_entry(application, &td->applications, list) { in mt_release_contacts()
1656 application->num_received = 0; in mt_release_contacts()
1663 struct hid_device *hdev = td->hdev; in mt_expired_timeout()
1669 if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_expired_timeout()
1671 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_expired_timeout()
1673 clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_expired_timeout()
1683 if (id->driver_data == mt_classes[i].name) { in mt_probe()
1689 td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); in mt_probe()
1691 dev_err(&hdev->dev, "cannot allocate multitouch data\n"); in mt_probe()
1692 return -ENOMEM; in mt_probe()
1694 td->hdev = hdev; in mt_probe()
1695 td->mtclass = *mtclass; in mt_probe()
1696 td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; in mt_probe()
1699 INIT_LIST_HEAD(&td->applications); in mt_probe()
1700 INIT_LIST_HEAD(&td->reports); in mt_probe()
1702 if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) in mt_probe()
1703 td->serial_maybe = true; in mt_probe()
1708 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; in mt_probe()
1715 hdev->quirks |= HID_QUIRK_INPUT_PER_APP; in mt_probe()
1717 if (id->group != HID_GROUP_MULTITOUCH_WIN_8) in mt_probe()
1718 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1720 if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) { in mt_probe()
1721 hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP; in mt_probe()
1722 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1725 timer_setup(&td->release_timer, mt_expired_timeout, 0); in mt_probe()
1731 if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) in mt_probe()
1738 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); in mt_probe()
1740 dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", in mt_probe()
1741 hdev->name); in mt_probe()
1772 del_timer_sync(&td->release_timer); in mt_remove()
1774 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); in mt_remove()
1780 * - VID/PID of products not working with the default multitouch handling
1781 * - 2 generic rules.
2028 /* PixCir-based panels */
2033 /* Quanta-based panels */
2137 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
2141 .name = "hid-multitouch",