Lines Matching +full:counter +full:- +full:clockwise

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"
119 unsigned int mt_flags; /* flags to pass to input-mt */
227 * these device-dependent functions determine what slot corresponds
234 if (*slot->contactid != 0 || application->num_received == 0) in cypress_compute_slot()
235 return *slot->contactid; in cypress_compute_slot()
237 return -1; in cypress_compute_slot()
391 return sprintf(buf, "%u\n", td->mtclass.quirks); in mt_show_quirks()
405 return -EINVAL; in mt_set_quirks()
407 td->mtclass.quirks = val; in mt_set_quirks()
409 list_for_each_entry(application, &td->applications, list) { in mt_set_quirks()
410 application->quirks = val; in mt_set_quirks()
411 if (!application->have_contact_count) in mt_set_quirks()
412 application->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_set_quirks()
437 * marked as non-capable. in mt_get_feature()
439 if (hdev->quirks & HID_QUIRK_NO_INIT_REPORTS) in mt_get_feature()
446 ret = hid_hw_raw_request(hdev, report->id, buf, size, in mt_get_feature()
449 dev_warn(&hdev->dev, "failed to fetch feature %d\n", in mt_get_feature()
450 report->id); in mt_get_feature()
455 dev_warn(&hdev->dev, "failed to report feature\n"); in mt_get_feature()
466 switch (usage->hid) { in mt_feature_mapping()
468 mt_get_feature(hdev, field->report); in mt_feature_mapping()
470 td->maxcontacts = field->value[0]; in mt_feature_mapping()
471 if (!td->maxcontacts && in mt_feature_mapping()
472 field->logical_maximum <= MT_MAX_MAXCONTACT) in mt_feature_mapping()
473 td->maxcontacts = field->logical_maximum; in mt_feature_mapping()
474 if (td->mtclass.maxcontacts) in mt_feature_mapping()
476 td->maxcontacts = td->mtclass.maxcontacts; in mt_feature_mapping()
480 if (usage->usage_index >= field->report_count) { in mt_feature_mapping()
481 dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); in mt_feature_mapping()
485 mt_get_feature(hdev, field->report); in mt_feature_mapping()
486 if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD) in mt_feature_mapping()
487 td->is_buttonpad = true; in mt_feature_mapping()
492 if (usage->usage_index == 0) in mt_feature_mapping()
493 mt_get_feature(hdev, field->report); in mt_feature_mapping()
501 int fmin = field->logical_minimum; in set_abs()
502 int fmax = field->logical_maximum; in set_abs()
503 int fuzz = snratio ? (fmax - fmin) / snratio : 0; in set_abs()
513 usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL); in mt_allocate_usage()
518 usage->x = DEFAULT_ZERO; in mt_allocate_usage()
519 usage->y = DEFAULT_ZERO; in mt_allocate_usage()
520 usage->cx = DEFAULT_ZERO; in mt_allocate_usage()
521 usage->cy = DEFAULT_ZERO; in mt_allocate_usage()
522 usage->p = DEFAULT_ZERO; in mt_allocate_usage()
523 usage->w = DEFAULT_ZERO; in mt_allocate_usage()
524 usage->h = DEFAULT_ZERO; in mt_allocate_usage()
525 usage->a = DEFAULT_ZERO; in mt_allocate_usage()
526 usage->contactid = DEFAULT_ZERO; in mt_allocate_usage()
527 usage->tip_state = DEFAULT_FALSE; in mt_allocate_usage()
528 usage->inrange_state = DEFAULT_FALSE; in mt_allocate_usage()
529 usage->confidence_state = DEFAULT_TRUE; in mt_allocate_usage()
531 list_add_tail(&usage->list, &application->mt_usages); in mt_allocate_usage()
539 unsigned int application = report->application; in mt_allocate_application()
542 mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application), in mt_allocate_application()
547 mt_application->application = application; in mt_allocate_application()
548 INIT_LIST_HEAD(&mt_application->mt_usages); in mt_allocate_application()
551 mt_application->mt_flags |= INPUT_MT_DIRECT; in mt_allocate_application()
557 mt_application->mt_flags |= INPUT_MT_POINTER; in mt_allocate_application()
558 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_allocate_application()
561 mt_application->scantime = DEFAULT_ZERO; in mt_allocate_application()
562 mt_application->raw_cc = DEFAULT_ZERO; in mt_allocate_application()
563 mt_application->quirks = td->mtclass.quirks; in mt_allocate_application()
564 mt_application->report_id = report->id; in mt_allocate_application()
566 list_add_tail(&mt_application->list, &td->applications); in mt_allocate_application()
574 unsigned int application = report->application; in mt_find_application()
577 list_for_each_entry(tmp, &td->applications, list) { in mt_find_application()
578 if (application == tmp->application) { in mt_find_application()
579 if (!(td->mtclass.quirks & MT_QUIRK_SEPARATE_APP_REPORT) || in mt_find_application()
580 tmp->report_id == report->id) { in mt_find_application()
600 rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL); in mt_allocate_report_data()
604 rdata->report = report; in mt_allocate_report_data()
605 rdata->application = mt_find_application(td, report); in mt_allocate_report_data()
607 if (!rdata->application) { in mt_allocate_report_data()
608 devm_kfree(&td->hdev->dev, rdata); in mt_allocate_report_data()
612 for (r = 0; r < report->maxfield; r++) { in mt_allocate_report_data()
613 field = report->field[r]; in mt_allocate_report_data()
615 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_allocate_report_data()
618 if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { in mt_allocate_report_data()
619 for (n = 0; n < field->report_count; n++) { in mt_allocate_report_data()
620 if (field->usage[n].hid == HID_DG_CONTACTID) { in mt_allocate_report_data()
621 rdata->is_mt_collection = true; in mt_allocate_report_data()
628 list_add_tail(&rdata->list, &td->reports); in mt_allocate_report_data()
638 list_for_each_entry(tmp, &td->reports, list) { in mt_find_report_data()
639 if (report == tmp->report) { in mt_find_report_data()
659 if (list_empty(&application->mt_usages)) in mt_store_field()
662 usage = list_last_entry(&application->mt_usages, in mt_store_field()
675 if (usage->contactid == DEFAULT_ZERO || in mt_store_field()
676 usage->x == DEFAULT_ZERO || in mt_store_field()
677 usage->y == DEFAULT_ZERO) { in mt_store_field()
694 &field->value[usage->usage_index], \
702 struct mt_class *cls = &td->mtclass; in mt_touch_input_mapping()
709 if (field->application == HID_DG_TOUCHSCREEN && in mt_touch_input_mapping()
710 (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) { in mt_touch_input_mapping()
711 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_mapping()
712 td->inputmode_value = MT_INPUTMODE_TOUCHPAD; in mt_touch_input_mapping()
716 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) in mt_touch_input_mapping()
717 app->buttons_count++; in mt_touch_input_mapping()
719 if (usage->usage_index) in mt_touch_input_mapping()
720 prev_usage = &field->usage[usage->usage_index - 1]; in mt_touch_input_mapping()
722 switch (usage->hid & HID_USAGE_PAGE) { in mt_touch_input_mapping()
725 switch (usage->hid) { in mt_touch_input_mapping()
727 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
735 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
738 * A system multi-axis that exports X and Y has a high in mt_touch_input_mapping()
741 if (field->application == HID_GD_SYSTEM_MULTIAXIS) { in mt_touch_input_mapping()
743 hi->input->propbit); in mt_touch_input_mapping()
744 input_set_abs_params(hi->input, in mt_touch_input_mapping()
752 if (prev_usage && (prev_usage->hid == usage->hid)) { in mt_touch_input_mapping()
760 set_abs(hi->input, code, field, cls->sn_move); in mt_touch_input_mapping()
767 switch (usage->hid) { in mt_touch_input_mapping()
769 if (app->quirks & MT_QUIRK_HOVERING) { in mt_touch_input_mapping()
770 input_set_abs_params(hi->input, in mt_touch_input_mapping()
776 if ((cls->name == MT_CLS_WIN_8 || in mt_touch_input_mapping()
777 cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || in mt_touch_input_mapping()
778 cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP) && in mt_touch_input_mapping()
779 (field->application == HID_DG_TOUCHPAD || in mt_touch_input_mapping()
780 field->application == HID_DG_TOUCHSCREEN)) in mt_touch_input_mapping()
781 app->quirks |= MT_QUIRK_CONFIDENCE; in mt_touch_input_mapping()
783 if (app->quirks & MT_QUIRK_CONFIDENCE) in mt_touch_input_mapping()
784 input_set_abs_params(hi->input, in mt_touch_input_mapping()
792 if (field->application != HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
793 input_set_capability(hi->input, in mt_touch_input_mapping()
799 app->touches_by_report++; in mt_touch_input_mapping()
802 if (!(app->quirks & MT_QUIRK_NO_AREA)) in mt_touch_input_mapping()
803 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, in mt_touch_input_mapping()
804 cls->sn_width); in mt_touch_input_mapping()
808 if (!(app->quirks & MT_QUIRK_NO_AREA)) { in mt_touch_input_mapping()
809 set_abs(hi->input, ABS_MT_TOUCH_MINOR, field, in mt_touch_input_mapping()
810 cls->sn_height); in mt_touch_input_mapping()
817 hi->input->absbit)) in mt_touch_input_mapping()
818 input_set_abs_params(hi->input, in mt_touch_input_mapping()
824 set_abs(hi->input, ABS_MT_PRESSURE, field, in mt_touch_input_mapping()
825 cls->sn_pressure); in mt_touch_input_mapping()
829 input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); in mt_touch_input_mapping()
830 app->scantime = &field->value[usage->usage_index]; in mt_touch_input_mapping()
831 app->scantime_logical_max = field->logical_maximum; in mt_touch_input_mapping()
834 app->have_contact_count = true; in mt_touch_input_mapping()
835 app->raw_cc = &field->value[usage->usage_index]; in mt_touch_input_mapping()
843 input_set_abs_params(hi->input, ABS_MT_ORIENTATION, in mt_touch_input_mapping()
844 -field->logical_maximum / 4, in mt_touch_input_mapping()
845 field->logical_maximum / 4, in mt_touch_input_mapping()
846 cls->sn_move ? in mt_touch_input_mapping()
847 field->logical_maximum / cls->sn_move : 0, 0); in mt_touch_input_mapping()
852 return -1; in mt_touch_input_mapping()
856 return -1; in mt_touch_input_mapping()
858 /* let hid-input decide for the others */ in mt_touch_input_mapping()
862 code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
867 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_input_mapping()
868 field->application == HID_DG_TOUCHPAD && in mt_touch_input_mapping()
869 (usage->hid & HID_USAGE) > 1) in mt_touch_input_mapping()
870 code--; in mt_touch_input_mapping()
872 if (field->application == HID_GD_SYSTEM_MULTIAXIS) in mt_touch_input_mapping()
873 code = BTN_0 + ((usage->hid - 1) & HID_USAGE); in mt_touch_input_mapping()
877 return -1; in mt_touch_input_mapping()
878 input_set_capability(hi->input, EV_KEY, code); in mt_touch_input_mapping()
882 /* we do not want to map these: no input-oriented meaning */ in mt_touch_input_mapping()
883 return -1; in mt_touch_input_mapping()
893 __s32 quirks = app->quirks; in mt_compute_slot()
896 return *slot->contactid; in mt_compute_slot()
902 return app->num_received; in mt_compute_slot()
905 return *slot->contactid - 1; in mt_compute_slot()
907 return input_mt_get_slot_by_key(input, *slot->contactid); in mt_compute_slot()
917 for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { in mt_release_pending_palms()
918 clear_bit(slotnum, app->pending_palm_slots); in mt_release_pending_palms()
939 if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) in mt_sync_frame()
940 input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); in mt_sync_frame()
943 input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); in mt_sync_frame()
948 app->num_received = 0; in mt_sync_frame()
949 app->left_button_state = 0; in mt_sync_frame()
951 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) in mt_sync_frame()
952 set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
954 clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); in mt_sync_frame()
955 clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_sync_frame()
960 long delta = value - app->prev_scantime; in mt_compute_timestamp()
961 unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies); in mt_compute_timestamp()
963 app->jiffies = jiffies; in mt_compute_timestamp()
966 delta += app->scantime_logical_max; in mt_compute_timestamp()
975 return app->timestamp + delta; in mt_compute_timestamp()
982 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) in mt_touch_event()
983 hid->hiddev_hid_event(hid, field, usage, value); in mt_touch_event()
992 struct input_mt *mt = input->mt; in mt_process_slot()
993 __s32 quirks = app->quirks; in mt_process_slot()
1002 return -EINVAL; in mt_process_slot()
1005 app->num_received >= app->num_expected) in mt_process_slot()
1006 return -EAGAIN; in mt_process_slot()
1010 valid = *slot->inrange_state; in mt_process_slot()
1012 valid = *slot->tip_state; in mt_process_slot()
1014 valid = *slot->confidence_state; in mt_process_slot()
1021 if (slotnum < 0 || slotnum >= td->maxcontacts) in mt_process_slot()
1025 struct input_mt_slot *i_slot = &mt->slots[slotnum]; in mt_process_slot()
1029 return -EAGAIN; in mt_process_slot()
1033 confidence_state = *slot->confidence_state; in mt_process_slot()
1036 inrange_state = *slot->inrange_state; in mt_process_slot()
1038 active = *slot->tip_state || inrange_state; in mt_process_slot()
1040 if (app->application == HID_GD_SYSTEM_MULTIAXIS) in mt_process_slot()
1045 input_mt_is_active(&mt->slots[slotnum])) { in mt_process_slot()
1047 * The non-confidence was reported for in mt_process_slot()
1050 * lift-off as userspace will not be aware in mt_process_slot()
1051 * of non-confidence, so we need to split in mt_process_slot()
1056 set_bit(slotnum, app->pending_palm_slots); in mt_process_slot()
1064 int wide = (*slot->w > *slot->h); in mt_process_slot()
1065 int major = max(*slot->w, *slot->h); in mt_process_slot()
1066 int minor = min(*slot->w, *slot->h); in mt_process_slot()
1071 if (slot->a != DEFAULT_ZERO) { in mt_process_slot()
1073 * Azimuth is counter-clockwise and ranges from [0, MAX) in mt_process_slot()
1074 * (a full revolution). Convert it to clockwise ranging in mt_process_slot()
1075 * [-MAX/2, MAX/2]. in mt_process_slot()
1078 * the limit of [-MAX/4, MAX/4], but the value can go in mt_process_slot()
1079 * out of range to [-MAX/2, MAX/2] to report an upside in mt_process_slot()
1082 azimuth = *slot->a; in mt_process_slot()
1086 azimuth -= max_azimuth * 4; in mt_process_slot()
1087 orientation = -azimuth; in mt_process_slot()
1099 input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); in mt_process_slot()
1100 input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); in mt_process_slot()
1101 input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx); in mt_process_slot()
1102 input_event(input, EV_ABS, ABS_MT_TOOL_Y, *slot->cy); in mt_process_slot()
1103 input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); in mt_process_slot()
1105 input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); in mt_process_slot()
1109 set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); in mt_process_slot()
1122 __s32 quirks = app->quirks; in mt_process_mt_event()
1123 struct input_dev *input = field->hidinput->input; in mt_process_mt_event()
1125 if (!usage->type || !(hid->claimed & HID_CLAIMED_INPUT)) in mt_process_mt_event()
1133 * (possible) multi-packet frame. in mt_process_mt_event()
1145 if (usage->type == EV_KEY && usage->code == BTN_LEFT) { in mt_process_mt_event()
1146 app->left_button_state |= value; in mt_process_mt_event()
1151 input_event(input, usage->type, usage->code, value); in mt_process_mt_event()
1158 struct hid_report *report = rdata->report; in mt_touch_report()
1159 struct mt_application *app = rdata->application; in mt_touch_report()
1167 int contact_count = -1; in mt_touch_report()
1170 if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_touch_report()
1173 scantime = *app->scantime; in mt_touch_report()
1174 app->timestamp = mt_compute_timestamp(app, scantime); in mt_touch_report()
1175 if (app->raw_cc != DEFAULT_ZERO) in mt_touch_report()
1176 contact_count = *app->raw_cc; in mt_touch_report()
1179 * Includes multi-packet support where subsequent in mt_touch_report()
1184 * For Win8 PTPs the first packet (td->num_received == 0) may in mt_touch_report()
1187 * of a possible multi-packet frame be checking that the in mt_touch_report()
1190 if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) && in mt_touch_report()
1191 app->num_received == 0 && in mt_touch_report()
1192 app->prev_scantime != scantime) in mt_touch_report()
1193 app->num_expected = contact_count; in mt_touch_report()
1196 app->num_expected = contact_count; in mt_touch_report()
1198 app->prev_scantime = scantime; in mt_touch_report()
1200 first_packet = app->num_received == 0; in mt_touch_report()
1202 input = report->field[0]->hidinput->input; in mt_touch_report()
1204 list_for_each_entry(slot, &app->mt_usages, list) { in mt_touch_report()
1206 app->num_received++; in mt_touch_report()
1209 for (r = 0; r < report->maxfield; r++) { in mt_touch_report()
1210 field = report->field[r]; in mt_touch_report()
1211 count = field->report_count; in mt_touch_report()
1213 if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) in mt_touch_report()
1218 &field->usage[n], field->value[n], in mt_touch_report()
1222 if (app->num_received >= app->num_expected) in mt_touch_report()
1227 * - once a contact has been reported, it has to be reported in each in mt_touch_report()
1229 * - the report rate when fingers are present has to be at least in mt_touch_report()
1243 if (app->quirks & MT_QUIRK_STICKY_FINGERS) { in mt_touch_report()
1244 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_touch_report()
1245 mod_timer(&td->release_timer, in mt_touch_report()
1248 del_timer(&td->release_timer); in mt_touch_report()
1251 clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_touch_report()
1259 struct mt_class *cls = &td->mtclass; in mt_touch_input_configured()
1260 struct input_dev *input = hi->input; in mt_touch_input_configured()
1263 if (!td->maxcontacts) in mt_touch_input_configured()
1264 td->maxcontacts = MT_DEFAULT_MAXCONTACT; in mt_touch_input_configured()
1267 if (td->serial_maybe) in mt_touch_input_configured()
1270 if (cls->is_indirect) in mt_touch_input_configured()
1271 app->mt_flags |= INPUT_MT_POINTER; in mt_touch_input_configured()
1273 if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) in mt_touch_input_configured()
1274 app->mt_flags |= INPUT_MT_DROP_UNUSED; in mt_touch_input_configured()
1277 if ((app->mt_flags & INPUT_MT_POINTER) && in mt_touch_input_configured()
1278 (app->buttons_count == 1)) in mt_touch_input_configured()
1279 td->is_buttonpad = true; in mt_touch_input_configured()
1281 if (td->is_buttonpad) in mt_touch_input_configured()
1282 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); in mt_touch_input_configured()
1284 app->pending_palm_slots = devm_kcalloc(&hi->input->dev, in mt_touch_input_configured()
1285 BITS_TO_LONGS(td->maxcontacts), in mt_touch_input_configured()
1288 if (!app->pending_palm_slots) in mt_touch_input_configured()
1289 return -ENOMEM; in mt_touch_input_configured()
1291 ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); in mt_touch_input_configured()
1295 app->mt_flags = 0; in mt_touch_input_configured()
1309 rdata = mt_find_report_data(td, field->report); in mt_input_mapping()
1315 application = rdata->application; in mt_input_mapping()
1323 if (!td->mtclass.export_all_inputs && in mt_input_mapping()
1324 field->application != HID_DG_TOUCHSCREEN && in mt_input_mapping()
1325 field->application != HID_DG_PEN && in mt_input_mapping()
1326 field->application != HID_DG_TOUCHPAD && in mt_input_mapping()
1327 field->application != HID_GD_KEYBOARD && in mt_input_mapping()
1328 field->application != HID_GD_SYSTEM_CONTROL && in mt_input_mapping()
1329 field->application != HID_CP_CONSUMER_CONTROL && in mt_input_mapping()
1330 field->application != HID_GD_WIRELESS_RADIO_CTLS && in mt_input_mapping()
1331 field->application != HID_GD_SYSTEM_MULTIAXIS && in mt_input_mapping()
1332 !(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1333 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP)) in mt_input_mapping()
1334 return -1; in mt_input_mapping()
1341 if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS && in mt_input_mapping()
1342 application->quirks & MT_QUIRK_ASUS_CUSTOM_UP && in mt_input_mapping()
1343 (usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) { in mt_input_mapping()
1344 set_bit(EV_REP, hi->input->evbit); in mt_input_mapping()
1345 if (field->flags & HID_MAIN_ITEM_VARIABLE) in mt_input_mapping()
1346 field->flags &= ~HID_MAIN_ITEM_VARIABLE; in mt_input_mapping()
1347 switch (usage->hid & HID_USAGE) { in mt_input_mapping()
1354 return -1; in mt_input_mapping()
1359 if (rdata->is_mt_collection) in mt_input_mapping()
1367 if (field->physical == HID_DG_STYLUS) in mt_input_mapping()
1368 hi->application = HID_DG_STYLUS; in mt_input_mapping()
1370 /* let hid-core decide for the others */ in mt_input_mapping()
1381 rdata = mt_find_report_data(td, field->report); in mt_input_mapped()
1382 if (rdata && rdata->is_mt_collection) { in mt_input_mapped()
1383 /* We own these mappings, tell hid-input to ignore them */ in mt_input_mapped()
1384 return -1; in mt_input_mapped()
1387 /* let hid-core decide for the others */ in mt_input_mapped()
1397 rdata = mt_find_report_data(td, field->report); in mt_event()
1398 if (rdata && rdata->is_mt_collection) in mt_event()
1407 struct hid_field *field = report->field[0]; in mt_report()
1410 if (!(hid->claimed & HID_CLAIMED_INPUT)) in mt_report()
1414 if (rdata && rdata->is_mt_collection) in mt_report()
1417 if (field && field->hidinput && field->hidinput->input) in mt_report()
1418 input_sync(field->hidinput->input); in mt_report()
1430 struct mt_class *cls = &td->mtclass; in mt_need_to_apply_feature()
1431 struct hid_report *report = field->report; in mt_need_to_apply_feature()
1432 unsigned int index = usage->usage_index; in mt_need_to_apply_feature()
1437 switch (usage->hid) { in mt_need_to_apply_feature()
1447 if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { in mt_need_to_apply_feature()
1455 hid_hw_raw_request(hdev, report->id, buf, report_len, in mt_need_to_apply_feature()
1461 field->value[index] = td->inputmode_value; in mt_need_to_apply_feature()
1466 if (cls->maxcontacts) { in mt_need_to_apply_feature()
1467 max = min_t(int, field->logical_maximum, in mt_need_to_apply_feature()
1468 cls->maxcontacts); in mt_need_to_apply_feature()
1469 if (field->value[index] != max) { in mt_need_to_apply_feature()
1470 field->value[index] = max; in mt_need_to_apply_feature()
1477 field->value[index] = latency; in mt_need_to_apply_feature()
1481 field->value[index] = surface_switch; in mt_need_to_apply_feature()
1485 field->value[index] = button_switch; in mt_need_to_apply_feature()
1502 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in mt_set_modes()
1503 list_for_each_entry(rep, &rep_enum->report_list, list) { in mt_set_modes()
1506 for (i = 0; i < rep->maxfield; i++) { in mt_set_modes()
1508 if (rep->field[i]->report_count < 1) in mt_set_modes()
1511 for (j = 0; j < rep->field[i]->maxusage; j++) { in mt_set_modes()
1512 usage = &rep->field[i]->usage[j]; in mt_set_modes()
1515 rep->field[i], in mt_set_modes()
1533 __s32 quirks = app->quirks; in mt_post_parse_default_settings()
1536 if (list_is_singular(&app->mt_usages)) { in mt_post_parse_default_settings()
1544 app->quirks = quirks; in mt_post_parse_default_settings()
1549 if (!app->have_contact_count) in mt_post_parse()
1550 app->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; in mt_post_parse()
1563 list_for_each_entry(report, &hi->reports, hidinput_list) { in mt_input_configured()
1567 return -ENOMEM; in mt_input_configured()
1570 mt_application = rdata->application; in mt_input_configured()
1572 if (rdata->is_mt_collection) { in mt_input_configured()
1580 switch (hi->application) { in mt_input_configured()
1593 hi->input->name = hdev->name; in mt_input_configured()
1600 __set_bit(BTN_STYLUS, hi->input->keybit); in mt_input_configured()
1611 name = devm_kzalloc(&hi->input->dev, in mt_input_configured()
1612 strlen(hdev->name) + strlen(suffix) + 2, in mt_input_configured()
1615 sprintf(name, "%s %s", hdev->name, suffix); in mt_input_configured()
1616 hi->input->name = name; in mt_input_configured()
1625 if (field->usage[0].hid != usage || in mt_fix_const_field()
1626 !(field->flags & HID_MAIN_ITEM_CONSTANT)) in mt_fix_const_field()
1629 field->flags &= ~HID_MAIN_ITEM_CONSTANT; in mt_fix_const_field()
1630 field->flags |= HID_MAIN_ITEM_VARIABLE; in mt_fix_const_field()
1639 &hdev->report_enum[HID_INPUT_REPORT].report_list, in mt_fix_const_fields()
1642 if (!report->maxfield) in mt_fix_const_fields()
1645 for (i = 0; i < report->maxfield; i++) in mt_fix_const_fields()
1646 if (report->field[i]->maxusage >= 1) in mt_fix_const_fields()
1647 mt_fix_const_field(report->field[i], usage); in mt_fix_const_fields()
1657 list_for_each_entry(hidinput, &hid->inputs, list) { in mt_release_contacts()
1658 struct input_dev *input_dev = hidinput->input; in mt_release_contacts()
1659 struct input_mt *mt = input_dev->mt; in mt_release_contacts()
1663 for (i = 0; i < mt->num_slots; i++) { in mt_release_contacts()
1672 list_for_each_entry(application, &td->applications, list) { in mt_release_contacts()
1673 application->num_received = 0; in mt_release_contacts()
1680 struct hid_device *hdev = td->hdev; in mt_expired_timeout()
1686 if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) in mt_expired_timeout()
1688 if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) in mt_expired_timeout()
1690 clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); in mt_expired_timeout()
1700 if (id->driver_data == mt_classes[i].name) { in mt_probe()
1706 td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); in mt_probe()
1708 dev_err(&hdev->dev, "cannot allocate multitouch data\n"); in mt_probe()
1709 return -ENOMEM; in mt_probe()
1711 td->hdev = hdev; in mt_probe()
1712 td->mtclass = *mtclass; in mt_probe()
1713 td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; in mt_probe()
1716 INIT_LIST_HEAD(&td->applications); in mt_probe()
1717 INIT_LIST_HEAD(&td->reports); in mt_probe()
1719 if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID) in mt_probe()
1720 td->serial_maybe = true; in mt_probe()
1725 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; in mt_probe()
1732 hdev->quirks |= HID_QUIRK_INPUT_PER_APP; in mt_probe()
1734 if (id->group != HID_GROUP_MULTITOUCH_WIN_8) in mt_probe()
1735 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1737 if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) { in mt_probe()
1738 hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP; in mt_probe()
1739 hdev->quirks |= HID_QUIRK_MULTI_INPUT; in mt_probe()
1742 timer_setup(&td->release_timer, mt_expired_timeout, 0); in mt_probe()
1748 if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) in mt_probe()
1755 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group); in mt_probe()
1757 dev_warn(&hdev->dev, "Cannot allocate sysfs group for %s\n", in mt_probe()
1758 hdev->name); in mt_probe()
1771 if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || in mt_suspend()
1805 del_timer_sync(&td->release_timer); in mt_remove()
1807 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); in mt_remove()
1813 * - VID/PID of products not working with the default multitouch handling
1814 * - 2 generic rules.
2067 /* PixCir-based panels */
2072 /* Quanta-based panels */
2180 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
2184 .name = "hid-multitouch",