Lines Matching +full:active +full:- +full:distance
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
45 if (dev->mt) in input_mt_init_slots()
46 return dev->mt->num_slots != num_slots ? -EINVAL : 0; in input_mt_init_slots()
50 return -EINVAL; in input_mt_init_slots()
55 return -ENOMEM; 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()
89 return -ENOMEM; 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 = no_free_ptr(mt); in input_mt_init_slots()
105 * input_mt_destroy_slots() - frees the MT slots of the input device
113 if (dev->mt) { in input_mt_destroy_slots()
114 kfree(dev->mt->red); in input_mt_destroy_slots()
115 kfree(dev->mt); in input_mt_destroy_slots()
117 dev->mt = NULL; in input_mt_destroy_slots()
122 * input_mt_report_slot_state() - report contact state
125 * @active: true if contact is active, false otherwise
128 * ABS_MT_TOOL_TYPE. If active is true and the slot is currently
133 * Returns true if contact is active.
136 unsigned int tool_type, bool active) in input_mt_report_slot_state() argument
138 struct input_mt *mt = dev->mt; in input_mt_report_slot_state()
145 slot = &mt->slots[mt->slot]; in input_mt_report_slot_state()
146 slot->frame = mt->frame; in input_mt_report_slot_state()
148 if (!active) { in input_mt_report_slot_state()
149 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); in input_mt_report_slot_state()
165 * input_mt_report_finger_count() - report contact count
186 * input_mt_report_pointer_emulation() - common pointer emulation
188 * @use_count: report number of active contacts as finger count
198 struct input_mt *mt = dev->mt; in input_mt_report_pointer_emulation()
206 oldid = mt->trkid; in input_mt_report_pointer_emulation()
209 for (i = 0; i < mt->num_slots; ++i) { in input_mt_report_pointer_emulation()
210 struct input_mt_slot *ps = &mt->slots[i]; in input_mt_report_pointer_emulation()
215 if ((id - oldid) & TRKID_SGN) { in input_mt_report_pointer_emulation()
226 !test_bit(ABS_MT_DISTANCE, dev->absbit) && in input_mt_report_pointer_emulation()
227 test_bit(ABS_DISTANCE, dev->absbit) && in input_mt_report_pointer_emulation()
231 * only report general hover (and not per-contact in input_mt_report_pointer_emulation()
232 * distance) when contact is in proximity but not in input_mt_report_pointer_emulation()
248 if (test_bit(ABS_MT_PRESSURE, dev->absbit)) { in input_mt_report_pointer_emulation()
253 if (test_bit(ABS_MT_PRESSURE, dev->absbit)) in input_mt_report_pointer_emulation()
263 lockdep_assert_held(&dev->event_lock); in __input_mt_drop_unused()
265 for (i = 0; i < mt->num_slots; i++) { in __input_mt_drop_unused()
266 if (input_mt_is_active(&mt->slots[i]) && in __input_mt_drop_unused()
267 !input_mt_is_used(mt, &mt->slots[i])) { in __input_mt_drop_unused()
269 input_handle_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); in __input_mt_drop_unused()
275 * input_mt_drop_unused() - Inactivate slots not seen in this frame
282 struct input_mt *mt = dev->mt; in input_mt_drop_unused()
285 guard(spinlock_irqsave)(&dev->event_lock); in input_mt_drop_unused()
288 mt->frame++; in input_mt_drop_unused()
294 * input_mt_release_slots() - Deactivate all slots
297 * Lift all active slots.
301 struct input_mt *mt = dev->mt; in input_mt_release_slots()
303 lockdep_assert_held(&dev->event_lock); in input_mt_release_slots()
307 mt->frame++; in input_mt_release_slots()
311 if (test_bit(ABS_PRESSURE, dev->absbit)) in input_mt_release_slots()
314 mt->frame++; in input_mt_release_slots()
319 * input_mt_sync_frame() - synchronize mt frame
328 struct input_mt *mt = dev->mt; in input_mt_sync_frame()
334 if (mt->flags & INPUT_MT_DROP_UNUSED) { in input_mt_sync_frame()
335 guard(spinlock_irqsave)(&dev->event_lock); in input_mt_sync_frame()
339 if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT)) in input_mt_sync_frame()
344 mt->frame++; in input_mt_sync_frame()
376 *p -= c; in adjust_dual()
402 int *w = mt->red; in input_mt_set_matrix()
405 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { in input_mt_set_matrix()
411 int dx = x - p->x, dy = y - p->y; in input_mt_set_matrix()
412 *w++ = dx * dx + dy * dy - mu; in input_mt_set_matrix()
416 return w - mt->red; in input_mt_set_matrix()
423 int *w = mt->red, j; in input_mt_set_slots()
426 slots[j] = -1; in input_mt_set_slots()
428 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { in input_mt_set_slots()
434 slots[j] = s - mt->slots; in input_mt_set_slots()
442 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { in input_mt_set_slots()
448 slots[j] = s - mt->slots; in input_mt_set_slots()
456 * input_mt_assign_slots() - perform a best-match assignment
468 * below the euclidian distance dmax. If no such assignment can be found,
477 struct input_mt *mt = dev->mt; in input_mt_assign_slots()
481 if (!mt || !mt->red) in input_mt_assign_slots()
482 return -ENXIO; in input_mt_assign_slots()
483 if (num_pos > mt->num_slots) in input_mt_assign_slots()
484 return -EINVAL; in input_mt_assign_slots()
489 find_reduced_matrix(mt->red, num_pos, nrc / num_pos, nrc, mu); in input_mt_assign_slots()
497 * input_mt_get_slot_by_key() - return slot matching key
504 * If no available slot can be found, -1 is returned.
510 struct input_mt *mt = dev->mt; in input_mt_get_slot_by_key()
514 return -1; in input_mt_get_slot_by_key()
516 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) in input_mt_get_slot_by_key()
517 if (input_mt_is_active(s) && s->key == key) in input_mt_get_slot_by_key()
518 return s - mt->slots; in input_mt_get_slot_by_key()
520 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) in input_mt_get_slot_by_key()
522 s->key = key; in input_mt_get_slot_by_key()
523 return s - mt->slots; in input_mt_get_slot_by_key()
526 return -1; in input_mt_get_slot_by_key()