Lines Matching +full:touchscreen +full:- +full:fuzz +full:- +full:x
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"
99 __s32 *x, *y, *cx, *cy, *p, *w, *h, *a; member
119 unsigned int mt_flags; /* flags to pass to input-mt */
229 * these device-dependent functions determine what slot corresponds
236 if (*slot->contactid != 0 || application->num_received == 0) in cypress_compute_slot()
237 return *slot->contactid; in cypress_compute_slot()
239 return -1; in cypress_compute_slot()
409 return sprintf(buf, "%u\n", td->mtclass.quirks); in mt_show_quirks()
423 return -EINVAL; in mt_set_quirks()
425 td->mtclass.quirks = val; in mt_set_quirks()
427 list_for_each_entry(application, &td->applications, list) { in mt_set_quirks()
428 application->quirks = val; in mt_set_quirks()
429 if (!application->have_contact_count) in mt_set_quirks()
430 application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_set_quirks()
455 * marked as non-capable. in mt_get_feature()
457 if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) in mt_get_feature()
464 ret = hid_hw_raw_request(hdev, report->id, buf, size, in mt_get_feature()
467 dev_warn(&hdev->dev, "failed to fetch feature %d\n", in mt_get_feature()
468 report->id); in mt_get_feature()
473 dev_warn(&hdev->dev, "failed to report feature\n"); in mt_get_feature()
484 switch (usage->hid) { in mt_feature_mapping()
486 mt_get_feature(hdev, field->report); in mt_feature_mapping()
488 td->maxcontacts = field->value[0]; in mt_feature_mapping()
489 if (!td->maxcontacts && in mt_feature_mapping()
490 field->logical_maximum <= MT_MAX_MAXCONTACT) in mt_feature_mapping()
491 td->maxcontacts = field->logical_maximum; in mt_feature_mapping()
492 if (td->mtclass.maxcontacts) in mt_feature_mapping()
494 td->maxcontacts = td->mtclass.maxcontacts; in mt_feature_mapping()
498 if (usage->usage_index >= field->report_count) { in mt_feature_mapping()
499 dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); in mt_feature_mapping()
503 mt_get_feature(hdev, field->report); in mt_feature_mapping()
504 if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) in mt_feature_mapping()
505 td->is_buttonpad = true; in mt_feature_mapping()
510 if (usage->usage_index == 0) in mt_feature_mapping()
511 mt_get_feature(hdev, field->report); in mt_feature_mapping()
519 int fmin = field->logical_minimum; in set_abs()
520 int fmax = field->logical_maximum; in set_abs()
521 int fuzz = snratio ? (fmax - fmin) / snratio : 0; in set_abs() local
522 input_set_abs_params(input, code, fmin, fmax, fuzz, 0); in set_abs()
531 usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); in mt_allocate_usage()
536 usage->x = DEFAULT_ZERO; in mt_allocate_usage()
537 usage->y = DEFAULT_ZERO; in mt_allocate_usage()
538 usage->cx = DEFAULT_ZERO; in mt_allocate_usage()
539 usage->cy = DEFAULT_ZERO; in mt_allocate_usage()
540 usage->p = DEFAULT_ZERO; in mt_allocate_usage()
541 usage->w = DEFAULT_ZERO; in mt_allocate_usage()
542 usage->h = DEFAULT_ZERO; in mt_allocate_usage()
543 usage->a = DEFAULT_ZERO; in mt_allocate_usage()
544 usage->contactid = DEFAULT_ZERO; in mt_allocate_usage()
545 usage->tip_state = DEFAULT_FALSE; in mt_allocate_usage()
546 usage->inrange_state = DEFAULT_FALSE; in mt_allocate_usage()
547 usage->confidence_state = DEFAULT_TRUE; in mt_allocate_usage()
549 list_add_tail(&usage->list, &application->mt_usages); in mt_allocate_usage()
557 unsigned int application = report->application; in mt_allocate_application()
560 mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), in mt_allocate_application()
565 mt_application->application = application; in mt_allocate_application()
566 INIT_LIST_HEAD(&mt_application->mt_usages); in mt_allocate_application()
569 mt_application->mt_flags |= INPUT_MT_DIRECT; in mt_allocate_application()
575 mt_application->mt_flags |= INPUT_MT_POINTER; in mt_allocate_application()
576 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_allocate_application()
579 mt_application->scantime = DEFAULT_ZERO; in mt_allocate_application()
580 mt_application->raw_cc = DEFAULT_ZERO; in mt_allocate_application()
581 mt_application->quirks = td->mtclass.quirks; in mt_allocate_application()
582 mt_application->report_id = report->id; in mt_allocate_application()
584 list_add_tail(&mt_application->list, &td->applications); in mt_allocate_application()
592 unsigned int application = report->application; in mt_find_application()
595 list_for_each_entry(tmp, &td->applications, list) { in mt_find_application()
596 if (application == tmp->application) { in mt_find_application()
597 if (!(td->mtclass.quirks & MT_QUIRK_SEPARATE_APP_REPORT) || in mt_find_application()
598 tmp->report_id == report->id) { in mt_find_application()
618 rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); in mt_allocate_report_data()
622 rdata->report = report; in mt_allocate_report_data()
623 rdata->application = mt_find_application(td, report); in mt_allocate_report_data()
625 if (!rdata->application) { in mt_allocate_report_data()
626 devm_kfree(&td->hdev->dev, rdata); in mt_allocate_report_data()
630 for (r = 0; r < report->maxfield; r++) { in mt_allocate_report_data()
631 field = report->field[r]; in mt_allocate_report_data()
633 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_allocate_report_data()
636 if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { in mt_allocate_report_data()
637 for (n = 0; n < field->report_count; n++) { in mt_allocate_report_data()
638 if (field->usage[n].hid == HID_DG_CONTACTID) { in mt_allocate_report_data()
639 rdata->is_mt_collection = true; in mt_allocate_report_data()
646 list_add_tail(&rdata->list, &td->reports); in mt_allocate_report_data()
656 list_for_each_entry(tmp, &td->reports, list) { in mt_find_report_data()
657 if (report == tmp->report) { in mt_find_report_data()
677 if (list_empty(&application->mt_usages)) in mt_store_field()
680 usage = list_last_entry(&application->mt_usages, in mt_store_field()
693 if (usage->contactid == DEFAULT_ZERO || in mt_store_field()
694 usage->x == DEFAULT_ZERO || in mt_store_field()
695 usage->y == DEFAULT_ZERO) { in mt_store_field()
712 &field->value[usage->usage_index], \
720 struct mt_class *cls = &td->mtclass; in mt_touch_input_mapping()
727 if (field->application == HID_DG_TOUCHSCREEN && in mt_touch_input_mapping()
728 (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { in mt_touch_input_mapping()
729 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_mapping()
730 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_touch_input_mapping()
734 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) in mt_touch_input_mapping()
735 app->buttons_count++; in mt_touch_input_mapping()
737 if (usage->usage_index) in mt_touch_input_mapping()
738 prev_usage = &field->usage[usage->usage_index - 1]; in mt_touch_input_mapping()
740 switch (usage->hid & HID_USAGE_PAGE) { in mt_touch_input_mapping()
743 switch (usage->hid) { in mt_touch_input_mapping()
745 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
750 MT_STORE_FIELD(x); in mt_touch_input_mapping()
753 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
756 * A system multi-axis that exports X and Y has a high in mt_touch_input_mapping()
759 if (field->application == HID_GD_SYSTEM_MULTIAXIS) { in mt_touch_input_mapping()
761 hi->input->propbit); in mt_touch_input_mapping()
762 input_set_abs_params(hi->input, in mt_touch_input_mapping()
770 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
778 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
785 switch (usage->hid) { in mt_touch_input_mapping()
787 if (app->quirks & MT_QUIRK_HOVERING) { in mt_touch_input_mapping()
788 input_set_abs_params(hi->input, in mt_touch_input_mapping()
794 if ((cls->name == MT_CLS_WIN_8 || in mt_touch_input_mapping()
795 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || in mt_touch_input_mapping()
796 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU || in mt_touch_input_mapping()
797 cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP) && in mt_touch_input_mapping()
798 (field->application == HID_DG_TOUCHPAD || in mt_touch_input_mapping()
799 field->application == HID_DG_TOUCHSCREEN)) in mt_touch_input_mapping()
800 app->quirks |= MT_QUIRK_CONFIDENCE; in mt_touch_input_mapping()
802 if (app->quirks & MT_QUIRK_CONFIDENCE) in mt_touch_input_mapping()
803 input_set_abs_params(hi->input, in mt_touch_input_mapping()
811 if (field->application != HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
812 input_set_capability(hi->input, in mt_touch_input_mapping()
818 app->touches_by_report++; in mt_touch_input_mapping()
821 if (!(app->quirks & MT_QUIRK_NO_AREA)) in mt_touch_input_mapping()
822 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, in mt_touch_input_mapping()
823 cls->sn_width); 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_MINOR, field, in mt_touch_input_mapping()
829 cls->sn_height); in mt_touch_input_mapping()
836 hi->input->absbit)) in mt_touch_input_mapping()
837 input_set_abs_params(hi->input, in mt_touch_input_mapping()
843 set_abs(hi->input, ABS_MT_PRESSURE, field, in mt_touch_input_mapping()
844 cls->sn_pressure); in mt_touch_input_mapping()
848 input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); in mt_touch_input_mapping()
849 app->scantime = &field->value[usage->usage_index]; in mt_touch_input_mapping()
850 app->scantime_logical_max = field->logical_maximum; in mt_touch_input_mapping()
853 app->have_contact_count = true; in mt_touch_input_mapping()
854 app->raw_cc = &field->value[usage->usage_index]; in mt_touch_input_mapping()
862 input_set_abs_params(hi->input, ABS_MT_ORIENTATION, in mt_touch_input_mapping()
863 -field->logical_maximum / 4, in mt_touch_input_mapping()
864 field->logical_maximum / 4, in mt_touch_input_mapping()
865 cls->sn_move ? in mt_touch_input_mapping()
866 field->logical_maximum / cls->sn_move : 0, 0); in mt_touch_input_mapping()
871 return -1; in mt_touch_input_mapping()
875 return -1; in mt_touch_input_mapping()
877 /* let hid-input decide for the others */ in mt_touch_input_mapping()
881 code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
886 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_input_mapping()
887 field->application == HID_DG_TOUCHPAD && in mt_touch_input_mapping()
888 (usage->hid & HID_USAGE) > 1) in mt_touch_input_mapping()
889 code--; in mt_touch_input_mapping()
891 if (field->application == HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
892 code = BTN_0 + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
896 return -1; in mt_touch_input_mapping()
897 input_set_capability(hi->input, EV_KEY, code); in mt_touch_input_mapping()
901 /* we do not want to map these: no input-oriented meaning */ in mt_touch_input_mapping()
902 return -1; in mt_touch_input_mapping()
912 __s32 quirks = app->quirks; in mt_compute_slot()
915 return *slot->contactid; in mt_compute_slot()
921 return app->num_received; in mt_compute_slot()
924 return *slot->contactid - 1; in mt_compute_slot()
926 return input_mt_get_slot_by_key(input, *slot->contactid); in mt_compute_slot()
936 for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { in mt_release_pending_palms()
937 clear_bit(slotnum, app->pending_palm_slots); in mt_release_pending_palms()
958 if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) in mt_sync_frame()
959 input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); in mt_sync_frame()
962 input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); in mt_sync_frame()
967 app->num_received = 0; in mt_sync_frame()
968 app->left_button_state = 0; in mt_sync_frame()
970 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) in mt_sync_frame()
971 set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
973 clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
974 clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_sync_frame()
979 long delta = value - app->prev_scantime; in mt_compute_timestamp()
980 unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); in mt_compute_timestamp()
982 app->jiffies = jiffies; in mt_compute_timestamp()
985 delta += app->scantime_logical_max; in mt_compute_timestamp()
994 return app->timestamp + delta; in mt_compute_timestamp()
1001 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) in mt_touch_event()
1002 hid->hiddev_hid_event(hid, field, usage, value); in mt_touch_event()
1011 struct input_mt *mt = input->mt; in mt_process_slot()
1012 __s32 quirks = app->quirks; in mt_process_slot()
1021 return -EINVAL; in mt_process_slot()
1024 app->num_received >= app->num_expected) in mt_process_slot()
1025 return -EAGAIN; in mt_process_slot()
1029 valid = *slot->inrange_state; in mt_process_slot()
1031 valid = *slot->tip_state; in mt_process_slot()
1033 valid = *slot->confidence_state; in mt_process_slot()
1040 if (slotnum < 0 || slotnum >= td->maxcontacts) in mt_process_slot()
1044 struct input_mt_slot *i_slot = &mt->slots[slotnum]; in mt_process_slot()
1048 return -EAGAIN; in mt_process_slot()
1052 confidence_state = *slot->confidence_state; in mt_process_slot()
1055 inrange_state = *slot->inrange_state; in mt_process_slot()
1057 active = *slot->tip_state || inrange_state; in mt_process_slot()
1059 if (app->application == HID_GD_SYSTEM_MULTIAXIS) in mt_process_slot()
1064 input_mt_is_active(&mt->slots[slotnum])) { in mt_process_slot()
1066 * The non-confidence was reported for in mt_process_slot()
1069 * lift-off as userspace will not be aware in mt_process_slot()
1070 * of non-confidence, so we need to split in mt_process_slot()
1075 set_bit(slotnum, app->pending_palm_slots); in mt_process_slot()
1083 int wide = (*slot->w > *slot->h); in mt_process_slot()
1084 int major = max(*slot->w, *slot->h); in mt_process_slot()
1085 int minor = min(*slot->w, *slot->h); in mt_process_slot()
1090 if (slot->a != DEFAULT_ZERO) { in mt_process_slot()
1092 * Azimuth is counter-clockwise and ranges from [0, MAX) in mt_process_slot()
1094 * [-MAX/2, MAX/2]. in mt_process_slot()
1097 * the limit of [-MAX/4, MAX/4], but the value can go in mt_process_slot()
1098 * out of range to [-MAX/2, MAX/2] to report an upside in mt_process_slot()
1101 azimuth = *slot->a; in mt_process_slot()
1105 azimuth -= max_azimuth * 4; in mt_process_slot()
1106 orientation = -azimuth; in mt_process_slot()
1118 input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); in mt_process_slot()
1119 input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); in mt_process_slot()
1120 input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx); in mt_process_slot()
1121 input_event(input, EV_ABS, ABS_MT_TOOL_Y, *slot->cy); in mt_process_slot()
1122 input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); in mt_process_slot()
1124 input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); in mt_process_slot()
1128 set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_process_slot()
1141 __s32 quirks = app->quirks; in mt_process_mt_event()
1142 struct input_dev *input = field->hidinput->input; in mt_process_mt_event()
1144 if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) in mt_process_mt_event()
1152 * (possible) multi-packet frame. in mt_process_mt_event()
1164 if (usage->type == EV_KEY && usage->code == BTN_LEFT) { in mt_process_mt_event()
1165 app->left_button_state |= value; in mt_process_mt_event()
1170 input_event(input, usage->type, usage->code, value); in mt_process_mt_event()
1177 struct hid_report *report = rdata->report; in mt_touch_report()
1178 struct mt_application *app = rdata->application; in mt_touch_report()
1186 int contact_count = -1; in mt_touch_report()
1189 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_touch_report()
1192 scantime = *app->scantime; in mt_touch_report()
1193 app->timestamp = mt_compute_timestamp(app, scantime); in mt_touch_report()
1194 if (app->raw_cc != DEFAULT_ZERO) in mt_touch_report()
1195 contact_count = *app->raw_cc; in mt_touch_report()
1198 * Includes multi-packet support where subsequent in mt_touch_report()
1203 * For Win8 PTPs the first packet (td->num_received == 0) may in mt_touch_report()
1206 * of a possible multi-packet frame be checking that the in mt_touch_report()
1209 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_report()
1210 app->num_received == 0 && in mt_touch_report()
1211 app->prev_scantime != scantime) in mt_touch_report()
1212 app->num_expected = contact_count; in mt_touch_report()
1215 app->num_expected = contact_count; in mt_touch_report()
1217 app->prev_scantime = scantime; in mt_touch_report()
1219 first_packet = app->num_received == 0; in mt_touch_report()
1221 input = report->field[0]->hidinput->input; in mt_touch_report()
1223 list_for_each_entry(slot, &app->mt_usages, list) { in mt_touch_report()
1225 app->num_received++; in mt_touch_report()
1228 for (r = 0; r < report->maxfield; r++) { in mt_touch_report()
1229 field = report->field[r]; in mt_touch_report()
1230 count = field->report_count; in mt_touch_report()
1232 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_touch_report()
1237 &field->usage[n], field->value[n], in mt_touch_report()
1241 if (app->num_received >= app->num_expected) in mt_touch_report()
1246 * - once a contact has been reported, it has to be reported in each in mt_touch_report()
1248 * - the report rate when fingers are present has to be at least in mt_touch_report()
1252 * at least 60 Hz for a touchscreen to be certified. in mt_touch_report()
1254 * something wrong happens, either the touchscreen forgets to send in mt_touch_report()
1262 if (app->quirks & MT_QUIRK_STICKY_FINGERS) { in mt_touch_report()
1263 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_touch_report()
1264 mod_timer(&td->release_timer, in mt_touch_report()
1267 del_timer(&td->release_timer); in mt_touch_report()
1270 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_touch_report()
1278 struct mt_class *cls = &td->mtclass; in mt_touch_input_configured()
1279 struct input_dev *input = hi->input; in mt_touch_input_configured()
1282 if (!td->maxcontacts) in mt_touch_input_configured()
1283 td->maxcontacts = MT_DEFAULT_MAXCONTACT; in mt_touch_input_configured()
1286 if (td->serial_maybe) in mt_touch_input_configured()
1289 if (cls->is_indirect) in mt_touch_input_configured()
1290 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_configured()
1292 if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) in mt_touch_input_configured()
1293 app->mt_flags |= INPUT_MT_DROP_UNUSED; in mt_touch_input_configured()
1296 if ((app->mt_flags & INPUT_MT_POINTER) && in mt_touch_input_configured()
1297 (app->buttons_count == 1)) in mt_touch_input_configured()
1298 td->is_buttonpad = true; in mt_touch_input_configured()
1300 if (td->is_buttonpad) in mt_touch_input_configured()
1301 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); in mt_touch_input_configured()
1303 app->pending_palm_slots = devm_kcalloc(&hi->input->dev, in mt_touch_input_configured()
1304 BITS_TO_LONGS(td->maxcontacts), in mt_touch_input_configured()
1307 if (!app->pending_palm_slots) in mt_touch_input_configured()
1308 return -ENOMEM; in mt_touch_input_configured()
1310 ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); in mt_touch_input_configured()
1314 app->mt_flags = 0; in mt_touch_input_configured()
1328 rdata = mt_find_report_data(td, field->report); in mt_input_mapping()
1334 application = rdata->application; in mt_input_mapping()
1338 * TouchScreen or TouchPad collections. We need to ignore fields in mt_input_mapping()
1342 if (!td->mtclass.export_all_inputs && in mt_input_mapping()
1343 field->application != HID_DG_TOUCHSCREEN && in mt_input_mapping()
1344 field->application != HID_DG_PEN && in mt_input_mapping()
1345 field->application != HID_DG_TOUCHPAD && in mt_input_mapping()
1346 field->application != HID_GD_KEYBOARD && in mt_input_mapping()
1347 field->application != HID_GD_SYSTEM_CONTROL && in mt_input_mapping()
1348 field->application != HID_CP_CONSUMER_CONTROL && in mt_input_mapping()
1349 field->application != HID_GD_WIRELESS_RADIO_CTLS && in mt_input_mapping()
1350 field->application != HID_GD_SYSTEM_MULTIAXIS && in mt_input_mapping()
1351 !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1352 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) in mt_input_mapping()
1353 return -1; in mt_input_mapping()
1360 if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1361 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && in mt_input_mapping()
1362 (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { in mt_input_mapping()
1363 set_bit(EV_REP, hi->input->evbit); in mt_input_mapping()
1364 if (field->flags & HID_MAIN_ITEM_VARIABLE) in mt_input_mapping()
1365 field->flags &= ~HID_MAIN_ITEM_VARIABLE; in mt_input_mapping()
1366 switch (usage->hid & HID_USAGE) { in mt_input_mapping()
1373 return -1; in mt_input_mapping()
1378 if (rdata->is_mt_collection) in mt_input_mapping()
1386 if (field->physical == HID_DG_STYLUS) in mt_input_mapping()
1387 hi->application = HID_DG_STYLUS; in mt_input_mapping()
1389 /* let hid-core decide for the others */ in mt_input_mapping()
1400 rdata = mt_find_report_data(td, field->report); in mt_input_mapped()
1401 if (rdata && rdata->is_mt_collection) { in mt_input_mapped()
1402 /* We own these mappings, tell hid-input to ignore them */ in mt_input_mapped()
1403 return -1; in mt_input_mapped()
1406 /* let hid-core decide for the others */ in mt_input_mapped()
1416 rdata = mt_find_report_data(td, field->report); in mt_event()
1417 if (rdata && rdata->is_mt_collection) in mt_event()
1426 struct hid_field *field = report->field[0]; in mt_report()
1429 if (!(hid->claimed & HID_CLAIMED_INPUT)) in mt_report()
1433 if (rdata && rdata->is_mt_collection) in mt_report()
1436 if (field && field->hidinput && field->hidinput->input) in mt_report()
1437 input_sync(field->hidinput->input); in mt_report()
1449 struct mt_class *cls = &td->mtclass; in mt_need_to_apply_feature()
1450 struct hid_report *report = field->report; in mt_need_to_apply_feature()
1451 unsigned int index = usage->usage_index; in mt_need_to_apply_feature()
1456 switch (usage->hid) { in mt_need_to_apply_feature()
1466 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { in mt_need_to_apply_feature()
1474 hid_hw_raw_request(hdev, report->id, buf, report_len, in mt_need_to_apply_feature()
1480 field->value[index] = td->inputmode_value; in mt_need_to_apply_feature()
1485 if (cls->maxcontacts) { in mt_need_to_apply_feature()
1486 max = min_t(int, field->logical_maximum, in mt_need_to_apply_feature()
1487 cls->maxcontacts); in mt_need_to_apply_feature()
1488 if (field->value[index] != max) { in mt_need_to_apply_feature()
1489 field->value[index] = max; in mt_need_to_apply_feature()
1496 field->value[index] = latency; in mt_need_to_apply_feature()
1500 field->value[index] = surface_switch; in mt_need_to_apply_feature()
1504 field->value[index] = button_switch; in mt_need_to_apply_feature()
1521 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in mt_set_modes()
1522 list_for_each_entry(rep, &rep_enum->report_list, list) { in mt_set_modes()
1525 for (i = 0; i < rep->maxfield; i++) { in mt_set_modes()
1527 if (rep->field[i]->report_count < 1) in mt_set_modes()
1530 for (j = 0; j < rep->field[i]->maxusage; j++) { in mt_set_modes()
1531 usage = &rep->field[i]->usage[j]; in mt_set_modes()
1534 rep->field[i], in mt_set_modes()
1552 __s32 quirks = app->quirks; in mt_post_parse_default_settings()
1555 if (list_is_singular(&app->mt_usages)) { in mt_post_parse_default_settings()
1563 app->quirks = quirks; in mt_post_parse_default_settings()
1568 if (!app->have_contact_count) in mt_post_parse()
1569 app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_post_parse()
1582 list_for_each_entry(report, &hi->reports, hidinput_list) { in mt_input_configured()
1586 return -ENOMEM; in mt_input_configured()
1589 mt_application = rdata->application; in mt_input_configured()
1591 if (rdata->is_mt_collection) { in mt_input_configured()
1599 switch (hi->application) { in mt_input_configured()
1611 /* we do not set suffix = "Touchscreen" */ in mt_input_configured()
1612 hi->input->name = hdev->name; in mt_input_configured()
1619 __set_bit(BTN_STYLUS, hi->input->keybit); in mt_input_configured()
1627 name = devm_kzalloc(&hi->input->dev, in mt_input_configured()
1628 strlen(hdev->name) + strlen(suffix) + 2, in mt_input_configured()
1631 sprintf(name, "%s %s", hdev->name, suffix); in mt_input_configured()
1632 hi->input->name = name; in mt_input_configured()
1641 if (field->usage[0].hid != usage || in mt_fix_const_field()
1642 !(field->flags & HID_MAIN_ITEM_CONSTANT)) in mt_fix_const_field()
1645 field->flags &= ~HID_MAIN_ITEM_CONSTANT; in mt_fix_const_field()
1646 field->flags |= HID_MAIN_ITEM_VARIABLE; in mt_fix_const_field()
1655 &hdev->report_enum[HID_INPUT_REPORT].report_list, in mt_fix_const_fields()
1658 if (!report->maxfield) in mt_fix_const_fields()
1661 for (i = 0; i < report->maxfield; i++) in mt_fix_const_fields()
1662 if (report->field[i]->maxusage >= 1) in mt_fix_const_fields()
1663 mt_fix_const_field(report->field[i], usage); in mt_fix_const_fields()
1673 list_for_each_entry(hidinput, &hid->inputs, list) { in mt_release_contacts()
1674 struct input_dev *input_dev = hidinput->input; in mt_release_contacts()
1675 struct input_mt *mt = input_dev->mt; in mt_release_contacts()
1679 for (i = 0; i < mt->num_slots; i++) { in mt_release_contacts()
1688 list_for_each_entry(application, &td->applications, list) { in mt_release_contacts()
1689 application->num_received = 0; in mt_release_contacts()
1696 struct hid_device *hdev = td->hdev; in mt_expired_timeout()
1702 if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_expired_timeout()
1704 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_expired_timeout()
1706 clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_expired_timeout()
1716 if (id->driver_data == mt_classes[i].name) { in mt_probe()
1722 td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); in mt_probe()
1724 dev_err(&hdev->dev, "cannot allocate multitouch data\n"); in mt_probe()
1725 return -ENOMEM; in mt_probe()
1727 td->hdev = hdev; in mt_probe()
1728 td->mtclass = *mtclass; in mt_probe()
1729 td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; in mt_probe()
1732 INIT_LIST_HEAD(&td->applications); in mt_probe()
1733 INIT_LIST_HEAD(&td->reports); in mt_probe()
1735 if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) in mt_probe()
1736 td->serial_maybe = true; in mt_probe()
1741 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; in mt_probe()
1748 hdev->quirks |= HID_QUIRK_INPUT_PER_APP; in mt_probe()
1750 if (id->group != HID_GROUP_MULTITOUCH_WIN_8) in mt_probe()
1751 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1753 if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) { in mt_probe()
1754 hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP; in mt_probe()
1755 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1758 timer_setup(&td->release_timer, mt_expired_timeout, 0); in mt_probe()
1764 if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) in mt_probe()
1771 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); in mt_probe()
1773 dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", in mt_probe()
1774 hdev->name); in mt_probe()
1787 if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || in mt_suspend()
1821 del_timer_sync(&td->release_timer); in mt_remove()
1823 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); in mt_remove()
1829 * - VID/PID of products not working with the default multitouch handling
1830 * - 2 generic rules.
2094 /* PixCir-based panels */
2099 /* Quanta-based panels */
2215 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
2219 .name = "hid-multitouch",