[PATCH 1/2] Input: MT - Make slot cleanup callable outsidemt_sync_frame()

From: Henrik Rydberg
Date: Wed Feb 20 2013 - 16:36:52 EST


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@xxxxxxxxxxx>
---
drivers/input/input-mt.c | 38 +++++++++++++++++++++++++++-----------
include/linux/input/mt.h | 1 +
2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index 1b7f4d4..a22094d 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -235,6 +235,31 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
EXPORT_SYMBOL(input_mt_report_pointer_emulation);

/**
+ * input_mt_drop_unused() - Inactivate slots not seen in this frame
+ * @dev: input device with allocated MT slots
+ *
+ * Lift all slots not seen since the last call to this function.
+ */
+void input_mt_drop_unused(struct input_dev *dev)
+{
+ struct input_mt *mt = dev->mt;
+ struct input_mt_slot *s;
+
+ if (!mt)
+ return;
+
+ for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
+ if (s->frame == mt->frame)
+ continue;
+ input_mt_slot(dev, s - mt->slots);
+ input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
+ }
+
+ mt->frame++;
+}
+EXPORT_SYMBOL(input_mt_drop_unused);
+
+/**
* input_mt_sync_frame() - synchronize mt frame
* @dev: input device with allocated MT slots
*
@@ -245,23 +270,14 @@ EXPORT_SYMBOL(input_mt_report_pointer_emulation);
void input_mt_sync_frame(struct input_dev *dev)
{
struct input_mt *mt = dev->mt;
- struct input_mt_slot *s;

if (!mt)
return;

- if (mt->flags & INPUT_MT_DROP_UNUSED) {
- for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
- if (s->frame == mt->frame)
- continue;
- input_mt_slot(dev, s - mt->slots);
- input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
- }
- }
+ if (mt->flags & INPUT_MT_DROP_UNUSED)
+ input_mt_drop_unused(dev);

input_mt_report_pointer_emulation(dev, (mt->flags & INPUT_MT_POINTER));
-
- mt->frame++;
}
EXPORT_SYMBOL(input_mt_sync_frame);

diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index cc5cca7..5766be1 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -98,6 +98,7 @@ void input_mt_report_slot_state(struct input_dev *dev,

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

void input_mt_sync_frame(struct input_dev *dev);

--
1.8.1.3