Skip to content

Commit f8ec894

Browse files
rydbergdtor
authored andcommitted
Input: MT - make slot cleanup callable outside mt_sync_frame()
Some semi-mt drivers use the slots in a manual way, but may still want to call parts of the frame synchronization logic. This patch makes input_mt_drop_unused callable from those drivers. Signed-off-by: Henrik Rydberg <rydberg@euromail.se> Reviewed-by: Benson Leung <bleung@chromium.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 437d4f3 commit f8ec894

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

drivers/input/input-mt.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,31 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
236236
}
237237
EXPORT_SYMBOL(input_mt_report_pointer_emulation);
238238

239+
/**
240+
* input_mt_drop_unused() - Inactivate slots not seen in this frame
241+
* @dev: input device with allocated MT slots
242+
*
243+
* Lift all slots not seen since the last call to this function.
244+
*/
245+
void input_mt_drop_unused(struct input_dev *dev)
246+
{
247+
struct input_mt *mt = dev->mt;
248+
int i;
249+
250+
if (!mt)
251+
return;
252+
253+
for (i = 0; i < mt->num_slots; i++) {
254+
if (!input_mt_is_used(mt, &mt->slots[i])) {
255+
input_mt_slot(dev, i);
256+
input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
257+
}
258+
}
259+
260+
mt->frame++;
261+
}
262+
EXPORT_SYMBOL(input_mt_drop_unused);
263+
239264
/**
240265
* input_mt_sync_frame() - synchronize mt frame
241266
* @dev: input device with allocated MT slots
@@ -247,27 +272,18 @@ EXPORT_SYMBOL(input_mt_report_pointer_emulation);
247272
void input_mt_sync_frame(struct input_dev *dev)
248273
{
249274
struct input_mt *mt = dev->mt;
250-
struct input_mt_slot *s;
251275
bool use_count = false;
252276

253277
if (!mt)
254278
return;
255279

256-
if (mt->flags & INPUT_MT_DROP_UNUSED) {
257-
for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
258-
if (input_mt_is_used(mt, s))
259-
continue;
260-
input_mt_slot(dev, s - mt->slots);
261-
input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
262-
}
263-
}
280+
if (mt->flags & INPUT_MT_DROP_UNUSED)
281+
input_mt_drop_unused(dev);
264282

265283
if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT))
266284
use_count = true;
267285

268286
input_mt_report_pointer_emulation(dev, use_count);
269-
270-
mt->frame++;
271287
}
272288
EXPORT_SYMBOL(input_mt_sync_frame);
273289

include/linux/input/mt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void input_mt_report_slot_state(struct input_dev *dev,
105105

106106
void input_mt_report_finger_count(struct input_dev *dev, int count);
107107
void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
108+
void input_mt_drop_unused(struct input_dev *dev);
108109

109110
void input_mt_sync_frame(struct input_dev *dev);
110111

0 commit comments

Comments
 (0)