diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2012-09-15 09:15:58 -0400 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2012-09-19 13:50:17 -0400 |
commit | 8d18fba282120a4a8e4416d1202522ffae8cad58 (patch) | |
tree | 22e3ddabba314c9ad544b9fefe004194205c2940 /drivers/input/input-mt.c | |
parent | 4cbe5a555fa58a79b6ecbb6c531b8bab0650778d (diff) |
Input: Break out MT data
Move all MT-related things to a separate place. This saves some
bytes for non-mt input devices, and prepares for new MT features.
Reviewed-and-tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Tested-by: Ping Cheng <pingc@wacom.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'drivers/input/input-mt.c')
-rw-r--r-- | drivers/input/input-mt.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index 70a16c7da8cc..37ee1f925d23 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c | |||
@@ -27,26 +27,28 @@ | |||
27 | */ | 27 | */ |
28 | int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots) | 28 | int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots) |
29 | { | 29 | { |
30 | struct input_mt *mt = dev->mt; | ||
30 | int i; | 31 | int i; |
31 | 32 | ||
32 | if (!num_slots) | 33 | if (!num_slots) |
33 | return 0; | 34 | return 0; |
34 | if (dev->mt) | 35 | if (mt) |
35 | return dev->mtsize != num_slots ? -EINVAL : 0; | 36 | return mt->num_slots != num_slots ? -EINVAL : 0; |
36 | 37 | ||
37 | dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL); | 38 | mt = kzalloc(sizeof(*mt) + num_slots * sizeof(*mt->slots), GFP_KERNEL); |
38 | if (!dev->mt) | 39 | if (!mt) |
39 | return -ENOMEM; | 40 | return -ENOMEM; |
40 | 41 | ||
41 | dev->mtsize = num_slots; | 42 | mt->num_slots = num_slots; |
42 | input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0); | 43 | input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0); |
43 | input_set_abs_params(dev, ABS_MT_TRACKING_ID, 0, TRKID_MAX, 0, 0); | 44 | input_set_abs_params(dev, ABS_MT_TRACKING_ID, 0, TRKID_MAX, 0, 0); |
44 | input_set_events_per_packet(dev, 6 * num_slots); | 45 | input_set_events_per_packet(dev, 6 * num_slots); |
45 | 46 | ||
46 | /* Mark slots as 'unused' */ | 47 | /* Mark slots as 'unused' */ |
47 | for (i = 0; i < num_slots; i++) | 48 | for (i = 0; i < num_slots; i++) |
48 | input_mt_set_value(&dev->mt[i], ABS_MT_TRACKING_ID, -1); | 49 | input_mt_set_value(&mt->slots[i], ABS_MT_TRACKING_ID, -1); |
49 | 50 | ||
51 | dev->mt = mt; | ||
50 | return 0; | 52 | return 0; |
51 | } | 53 | } |
52 | EXPORT_SYMBOL(input_mt_init_slots); | 54 | EXPORT_SYMBOL(input_mt_init_slots); |
@@ -62,9 +64,6 @@ void input_mt_destroy_slots(struct input_dev *dev) | |||
62 | { | 64 | { |
63 | kfree(dev->mt); | 65 | kfree(dev->mt); |
64 | dev->mt = NULL; | 66 | dev->mt = NULL; |
65 | dev->mtsize = 0; | ||
66 | dev->slot = 0; | ||
67 | dev->trkid = 0; | ||
68 | } | 67 | } |
69 | EXPORT_SYMBOL(input_mt_destroy_slots); | 68 | EXPORT_SYMBOL(input_mt_destroy_slots); |
70 | 69 | ||
@@ -83,18 +82,19 @@ EXPORT_SYMBOL(input_mt_destroy_slots); | |||
83 | void input_mt_report_slot_state(struct input_dev *dev, | 82 | void input_mt_report_slot_state(struct input_dev *dev, |
84 | unsigned int tool_type, bool active) | 83 | unsigned int tool_type, bool active) |
85 | { | 84 | { |
86 | struct input_mt_slot *mt; | 85 | struct input_mt *mt = dev->mt; |
86 | struct input_mt_slot *slot; | ||
87 | int id; | 87 | int id; |
88 | 88 | ||
89 | if (!dev->mt || !active) { | 89 | if (!mt || !active) { |
90 | input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); | 90 | input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); |
91 | return; | 91 | return; |
92 | } | 92 | } |
93 | 93 | ||
94 | mt = &dev->mt[dev->slot]; | 94 | slot = &mt->slots[mt->slot]; |
95 | id = input_mt_get_value(mt, ABS_MT_TRACKING_ID); | 95 | id = input_mt_get_value(slot, ABS_MT_TRACKING_ID); |
96 | if (id < 0 || input_mt_get_value(mt, ABS_MT_TOOL_TYPE) != tool_type) | 96 | if (id < 0 || input_mt_get_value(slot, ABS_MT_TOOL_TYPE) != tool_type) |
97 | id = input_mt_new_trkid(dev); | 97 | id = input_mt_new_trkid(mt); |
98 | 98 | ||
99 | input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id); | 99 | input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id); |
100 | input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type); | 100 | input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type); |
@@ -135,13 +135,19 @@ EXPORT_SYMBOL(input_mt_report_finger_count); | |||
135 | */ | 135 | */ |
136 | void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) | 136 | void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) |
137 | { | 137 | { |
138 | struct input_mt_slot *oldest = NULL; | 138 | struct input_mt *mt = dev->mt; |
139 | int oldid = dev->trkid; | 139 | struct input_mt_slot *oldest; |
140 | int count = 0; | 140 | int oldid, count, i; |
141 | int i; | 141 | |
142 | if (!mt) | ||
143 | return; | ||
144 | |||
145 | oldest = 0; | ||
146 | oldid = mt->trkid; | ||
147 | count = 0; | ||
142 | 148 | ||
143 | for (i = 0; i < dev->mtsize; ++i) { | 149 | for (i = 0; i < mt->num_slots; ++i) { |
144 | struct input_mt_slot *ps = &dev->mt[i]; | 150 | struct input_mt_slot *ps = &mt->slots[i]; |
145 | int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID); | 151 | int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID); |
146 | 152 | ||
147 | if (id < 0) | 153 | if (id < 0) |