Lines Matching full:mt
8 #include <linux/input/mt.h>
25 * input_mt_init_slots() - initialize MT input slots
26 * @dev: input device supporting MT events and finger tracking
28 * @flags: mt tasks to handle in core
30 * This function allocates all necessary memory for MT slot handling
45 if (dev->mt) in input_mt_init_slots()
46 return dev->mt->num_slots != num_slots ? -EINVAL : 0; in input_mt_init_slots()
52 struct input_mt *mt __free(kfree) = in input_mt_init_slots()
53 kzalloc(struct_size(mt, slots, num_slots), GFP_KERNEL); in input_mt_init_slots()
54 if (!mt) 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()
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 = no_free_ptr(mt); in input_mt_init_slots()
105 * input_mt_destroy_slots() - frees the MT slots of the input device
106 * @dev: input device with allocated MT slots
109 * automatically free the MT slots when the device is destroyed.
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()
123 * @dev: input device with allocated MT slots
138 struct input_mt *mt = dev->mt; in input_mt_report_slot_state() local
142 if (!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()
155 id = input_mt_new_trkid(mt); in input_mt_report_slot_state()
166 * @dev: input device with allocated MT slots
187 * @dev: input device with allocated MT slots
198 struct input_mt *mt = dev->mt; in input_mt_report_pointer_emulation() local
202 if (!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()
259 static void __input_mt_drop_unused(struct input_dev *dev, struct input_mt *mt) in __input_mt_drop_unused() argument
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()
276 * @dev: input device with allocated MT slots
282 struct input_mt *mt = dev->mt; in input_mt_drop_unused() local
284 if (mt) { in input_mt_drop_unused()
287 __input_mt_drop_unused(dev, mt); in input_mt_drop_unused()
288 mt->frame++; in input_mt_drop_unused()
295 * @dev: input device with allocated MT slots
301 struct input_mt *mt = dev->mt; in input_mt_release_slots() local
305 if (mt) { in input_mt_release_slots()
307 mt->frame++; in input_mt_release_slots()
309 __input_mt_drop_unused(dev, mt); in input_mt_release_slots()
314 mt->frame++; in input_mt_release_slots()
319 * input_mt_sync_frame() - synchronize mt frame
320 * @dev: input device with allocated MT slots
328 struct input_mt *mt = dev->mt; in input_mt_sync_frame() local
331 if (!mt) in input_mt_sync_frame()
334 if (mt->flags & INPUT_MT_DROP_UNUSED) { in input_mt_sync_frame()
336 __input_mt_drop_unused(dev, mt); 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()
396 static int input_mt_set_matrix(struct input_mt *mt, in input_mt_set_matrix() argument
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()
416 return w - mt->red; in input_mt_set_matrix()
419 static void input_mt_set_slots(struct input_mt *mt, in input_mt_set_slots() argument
423 int *w = mt->red, j; 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()
457 * @dev: input device with allocated MT slots
477 struct input_mt *mt = dev->mt; in input_mt_assign_slots() local
481 if (!mt || !mt->red) in input_mt_assign_slots()
483 if (num_pos > mt->num_slots) in input_mt_assign_slots()
488 nrc = input_mt_set_matrix(mt, pos, num_pos, mu); in input_mt_assign_slots()
489 find_reduced_matrix(mt->red, num_pos, nrc / num_pos, nrc, mu); in input_mt_assign_slots()
490 input_mt_set_slots(mt, slots, num_pos); in input_mt_assign_slots()
498 * @dev: input device with allocated MT slots
510 struct input_mt *mt = dev->mt; in input_mt_get_slot_by_key() local
513 if (!mt) 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()
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()
521 if (!input_mt_is_active(s) && !input_mt_is_used(mt, s)) { in input_mt_get_slot_by_key()
523 return s - mt->slots; in input_mt_get_slot_by_key()