aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/input
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2012-08-12 14:47:05 -0400
committerHenrik Rydberg <rydberg@euromail.se>2012-09-19 13:50:19 -0400
commit7c1a87897c75139dec258eb03e1a24fb73385b73 (patch)
tree0cc927c32fea65d1938881fd499aba6be9f8a6c3 /include/linux/input
parent55e49089f4589908eb688742d2d7eff33b74ac78 (diff)
Input: MT - Add in-kernel tracking
With the INPUT_MT_TRACK flag set, the function input_mt_assign_slots() can be used to match a new set of contacts against the currently used slots. The algorithm used is based on Lagrange relaxation, and performs very well in practice; slower than mtdev for a few corner cases, but faster in most commonly occuring cases. Tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'include/linux/input')
-rw-r--r--include/linux/input/mt.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index 94989189878d..6b6f7c8e95bf 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -18,6 +18,8 @@
18#define INPUT_MT_POINTER 0x0001 /* pointer device, e.g. trackpad */ 18#define INPUT_MT_POINTER 0x0001 /* pointer device, e.g. trackpad */
19#define INPUT_MT_DIRECT 0x0002 /* direct device, e.g. touchscreen */ 19#define INPUT_MT_DIRECT 0x0002 /* direct device, e.g. touchscreen */
20#define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */ 20#define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */
21#define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */
22
21/** 23/**
22 * struct input_mt_slot - represents the state of an input MT slot 24 * struct input_mt_slot - represents the state of an input MT slot
23 * @abs: holds current values of ABS_MT axes for this slot 25 * @abs: holds current values of ABS_MT axes for this slot
@@ -35,6 +37,7 @@ struct input_mt_slot {
35 * @slot: MT slot currently being transmitted 37 * @slot: MT slot currently being transmitted
36 * @flags: input_mt operation flags 38 * @flags: input_mt operation flags
37 * @frame: increases every time input_mt_sync_frame() is called 39 * @frame: increases every time input_mt_sync_frame() is called
40 * @red: reduced cost matrix for in-kernel tracking
38 * @slots: array of slots holding current values of tracked contacts 41 * @slots: array of slots holding current values of tracked contacts
39 */ 42 */
40struct input_mt { 43struct input_mt {
@@ -43,6 +46,7 @@ struct input_mt {
43 int slot; 46 int slot;
44 unsigned int flags; 47 unsigned int flags;
45 unsigned int frame; 48 unsigned int frame;
49 int *red;
46 struct input_mt_slot slots[]; 50 struct input_mt_slot slots[];
47}; 51};
48 52
@@ -58,6 +62,11 @@ static inline int input_mt_get_value(const struct input_mt_slot *slot,
58 return slot->abs[code - ABS_MT_FIRST]; 62 return slot->abs[code - ABS_MT_FIRST];
59} 63}
60 64
65static inline bool input_mt_is_active(const struct input_mt_slot *slot)
66{
67 return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0;
68}
69
61int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, 70int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots,
62 unsigned int flags); 71 unsigned int flags);
63void input_mt_destroy_slots(struct input_dev *dev); 72void input_mt_destroy_slots(struct input_dev *dev);
@@ -90,4 +99,16 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
90 99
91void input_mt_sync_frame(struct input_dev *dev); 100void input_mt_sync_frame(struct input_dev *dev);
92 101
102/**
103 * struct input_mt_pos - contact position
104 * @x: horizontal coordinate
105 * @y: vertical coordinate
106 */
107struct input_mt_pos {
108 s16 x, y;
109};
110
111int input_mt_assign_slots(struct input_dev *dev, int *slots,
112 const struct input_mt_pos *pos, int num_pos);
113
93#endif 114#endif