12 #include <linux/export.h>
13 #include <linux/slab.h>
15 #define TRKID_SGN ((TRKID_MAX + 1) >> 1)
17 static void copy_abs(
struct input_dev *
dev,
unsigned int dst,
unsigned int src)
19 if (dev->absinfo &&
test_bit(src, dev->absbit)) {
20 dev->absinfo[
dst] = dev->absinfo[
src];
57 input_set_abs_params(dev,
ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
130 unsigned int tool_type,
bool active)
149 id = input_mt_new_trkid(mt);
267 static int adjust_dual(
int *begin,
int step,
int *
end,
int eq)
276 s = p == end ? f + 1 : *
p;
285 if (c == 0 || (c > 0 && !eq))
290 for (p = begin; p !=
end; p +=
step)
293 return (c < s && s <= 0) || (f >= 0 && f <
c);
296 static void find_reduced_matrix(
int *
w,
int nr,
int nc,
int nrc)
300 for (k = 0; k < nrc; k++) {
301 for (i = 0; i <
nr; i++)
302 adjust_dual(w + i, nr, w + i + nrc, nr <= nc);
304 for (i = 0; i < nrc; i +=
nr)
305 sum += adjust_dual(w + i, 1, w + i + nr, nc <= nr);
311 static int input_mt_set_matrix(
struct input_mt *mt,
320 if (!input_mt_is_active(s))
324 for (p = pos; p != pos + num_pos; p++) {
325 int dx = x - p->
x, dy = y - p->
y;
326 *w++ = dx * dx + dy * dy;
333 static void input_mt_set_slots(
struct input_mt *mt,
334 int *
slots,
int num_pos)
337 int *w = mt->
red, *
p;
339 for (p = slots; p != slots + num_pos; p++)
343 if (!input_mt_is_active(s))
345 for (p = slots; p != slots + num_pos; p++)
351 if (input_mt_is_active(s))
353 for (p = slots; p != slots + num_pos; p++)
387 nrc = input_mt_set_matrix(mt, pos, num_pos);
388 find_reduced_matrix(mt->
red, num_pos, nrc / num_pos, nrc);
389 input_mt_set_slots(mt, slots, num_pos);
414 if (input_mt_is_active(s) && s->
key == key)
415 return s - mt->
slots;
418 if (!input_mt_is_active(s)) {
420 return s - mt->
slots;