Lines Matching +full:abs +full:- +full:fuzz
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2008-2010 Henrik Rydberg
11 #include "input-core-private.h"
17 if (dev->absinfo && test_bit(src, dev->absbit)) { in copy_abs()
18 dev->absinfo[dst] = dev->absinfo[src]; in copy_abs()
19 dev->absinfo[dst].fuzz = 0; in copy_abs()
20 __set_bit(dst, dev->absbit); in copy_abs()
25 * input_mt_init_slots() - initialize MT input slots
36 * May be called repeatedly. Returns -EINVAL if attempting to
42 struct input_mt *mt = dev->mt; in input_mt_init_slots()
48 return mt->num_slots != num_slots ? -EINVAL : 0; in input_mt_init_slots()
51 return -EINVAL; in input_mt_init_slots()
57 mt->num_slots = num_slots; in input_mt_init_slots()
58 mt->flags = flags; in input_mt_init_slots()
59 input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0); in input_mt_init_slots()
63 __set_bit(EV_KEY, dev->evbit); in input_mt_init_slots()
64 __set_bit(BTN_TOUCH, dev->keybit); in input_mt_init_slots()
71 __set_bit(BTN_TOOL_FINGER, dev->keybit); in input_mt_init_slots()
72 __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit); in input_mt_init_slots()
74 __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit); in input_mt_init_slots()
76 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); in input_mt_init_slots()
78 __set_bit(BTN_TOOL_QUINTTAP, dev->keybit); in input_mt_init_slots()
79 __set_bit(INPUT_PROP_POINTER, dev->propbit); in input_mt_init_slots()
82 __set_bit(INPUT_PROP_DIRECT, dev->propbit); in input_mt_init_slots()
84 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); in input_mt_init_slots()
87 mt->red = kcalloc(n2, sizeof(*mt->red), GFP_KERNEL); in input_mt_init_slots()
88 if (!mt->red) in input_mt_init_slots()
94 input_mt_set_value(&mt->slots[i], ABS_MT_TRACKING_ID, -1); in input_mt_init_slots()
97 mt->frame = 1; in input_mt_init_slots()
99 dev->mt = mt; in input_mt_init_slots()
103 return -ENOMEM; in input_mt_init_slots()
108 * input_mt_destroy_slots() - frees the MT slots of the input device
116 if (dev->mt) { in input_mt_destroy_slots()
117 kfree(dev->mt->red); in input_mt_destroy_slots()
118 kfree(dev->mt); in input_mt_destroy_slots()
120 dev->mt = NULL; in input_mt_destroy_slots()
125 * input_mt_report_slot_state() - report contact state
141 struct input_mt *mt = dev->mt; in input_mt_report_slot_state()
148 slot = &mt->slots[mt->slot]; in input_mt_report_slot_state()
149 slot->frame = mt->frame; in input_mt_report_slot_state()
152 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); in input_mt_report_slot_state()
168 * input_mt_report_finger_count() - report contact count
189 * input_mt_report_pointer_emulation() - common pointer emulation
196 * The input core ensures only the KEY and ABS axes already setup for
201 struct input_mt *mt = dev->mt; in input_mt_report_pointer_emulation()
209 oldid = mt->trkid; in input_mt_report_pointer_emulation()
212 for (i = 0; i < mt->num_slots; ++i) { in input_mt_report_pointer_emulation()
213 struct input_mt_slot *ps = &mt->slots[i]; in input_mt_report_pointer_emulation()
218 if ((id - oldid) & TRKID_SGN) { in input_mt_report_pointer_emulation()
229 !test_bit(ABS_MT_DISTANCE, dev->absbit) && in input_mt_report_pointer_emulation()
230 test_bit(ABS_DISTANCE, dev->absbit) && in input_mt_report_pointer_emulation()
234 * only report general hover (and not per-contact in input_mt_report_pointer_emulation()
251 if (test_bit(ABS_MT_PRESSURE, dev->absbit)) { in input_mt_report_pointer_emulation()
256 if (test_bit(ABS_MT_PRESSURE, dev->absbit)) in input_mt_report_pointer_emulation()
266 lockdep_assert_held(&dev->event_lock); in __input_mt_drop_unused()
268 for (i = 0; i < mt->num_slots; i++) { in __input_mt_drop_unused()
269 if (input_mt_is_active(&mt->slots[i]) && in __input_mt_drop_unused()
270 !input_mt_is_used(mt, &mt->slots[i])) { in __input_mt_drop_unused()
272 input_handle_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); in __input_mt_drop_unused()
278 * input_mt_drop_unused() - Inactivate slots not seen in this frame
285 struct input_mt *mt = dev->mt; in input_mt_drop_unused()
290 spin_lock_irqsave(&dev->event_lock, flags); in input_mt_drop_unused()
293 mt->frame++; in input_mt_drop_unused()
295 spin_unlock_irqrestore(&dev->event_lock, flags); in input_mt_drop_unused()
301 * input_mt_release_slots() - Deactivate all slots
308 struct input_mt *mt = dev->mt; in input_mt_release_slots()
310 lockdep_assert_held(&dev->event_lock); in input_mt_release_slots()
314 mt->frame++; in input_mt_release_slots()
318 if (test_bit(ABS_PRESSURE, dev->absbit)) in input_mt_release_slots()
321 mt->frame++; in input_mt_release_slots()
326 * input_mt_sync_frame() - synchronize mt frame
335 struct input_mt *mt = dev->mt; in input_mt_sync_frame()
341 if (mt->flags & INPUT_MT_DROP_UNUSED) { in input_mt_sync_frame()
344 spin_lock_irqsave(&dev->event_lock, flags); in input_mt_sync_frame()
346 spin_unlock_irqrestore(&dev->event_lock, flags); in input_mt_sync_frame()
349 if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT)) in input_mt_sync_frame()
354 mt->frame++; in input_mt_sync_frame()
386 *p -= c; in adjust_dual()
412 int *w = mt->red; in input_mt_set_matrix()
415 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { in input_mt_set_matrix()
421 int dx = x - p->x, dy = y - p->y; in input_mt_set_matrix()
422 *w++ = dx * dx + dy * dy - mu; in input_mt_set_matrix()
426 return w - mt->red; in input_mt_set_matrix()
433 int *w = mt->red, j; in input_mt_set_slots()
436 slots[j] = -1; in input_mt_set_slots()
438 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { in input_mt_set_slots()
444 slots[j] = s - mt->slots; in input_mt_set_slots()
452 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { in input_mt_set_slots()
458 slots[j] = s - mt->slots; in input_mt_set_slots()
466 * input_mt_assign_slots() - perform a best-match assignment
487 struct input_mt *mt = dev->mt; in input_mt_assign_slots()
491 if (!mt || !mt->red) in input_mt_assign_slots()
492 return -ENXIO; in input_mt_assign_slots()
493 if (num_pos > mt->num_slots) in input_mt_assign_slots()
494 return -EINVAL; in input_mt_assign_slots()
499 find_reduced_matrix(mt->red, num_pos, nrc / num_pos, nrc, mu); in input_mt_assign_slots()
507 * input_mt_get_slot_by_key() - return slot matching key
514 * If no available slot can be found, -1 is returned.
520 struct input_mt *mt = dev->mt; in input_mt_get_slot_by_key()
524 return -1; in input_mt_get_slot_by_key()
526 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) in input_mt_get_slot_by_key()
527 if (input_mt_is_active(s) && s->key == key) in input_mt_get_slot_by_key()
528 return s - mt->slots; in input_mt_get_slot_by_key()
530 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) in input_mt_get_slot_by_key()
532 s->key = key; in input_mt_get_slot_by_key()
533 return s - mt->slots; in input_mt_get_slot_by_key()
536 return -1; in input_mt_get_slot_by_key()