Skip to content

Commit

Permalink
Input: fix used slots detection breakage
Browse files Browse the repository at this point in the history
Commit f8ec894 allowed external callers
use slot dropping logic, unfortunately it also broke external users of
input_mt_is_used() as we stopped incrementing frame count unless input
device was set up to automatically drop unused slots.

Fixes: f8ec894 ("Input: MT - make slot cleanup callable outside
mt_sync_frame()")
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=83081

Reported-by: Gabriele Mazzotta <[email protected]>
Tested-by: Gabriele Mazzotta <[email protected]>
Reviewed-by: Henrik Rydberg <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
dtor committed Aug 25, 2014
1 parent fb92be7 commit 8ff21f4
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions drivers/input/input-mt.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
}
EXPORT_SYMBOL(input_mt_report_pointer_emulation);

static void __input_mt_drop_unused(struct input_dev *dev, struct input_mt *mt)
{
int i;

for (i = 0; i < mt->num_slots; i++) {
if (!input_mt_is_used(mt, &mt->slots[i])) {
input_mt_slot(dev, i);
input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
}
}
}

/**
* input_mt_drop_unused() - Inactivate slots not seen in this frame
* @dev: input device with allocated MT slots
Expand All @@ -245,19 +257,11 @@ EXPORT_SYMBOL(input_mt_report_pointer_emulation);
void input_mt_drop_unused(struct input_dev *dev)
{
struct input_mt *mt = dev->mt;
int i;

if (!mt)
return;

for (i = 0; i < mt->num_slots; i++) {
if (!input_mt_is_used(mt, &mt->slots[i])) {
input_mt_slot(dev, i);
input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
}
if (mt) {
__input_mt_drop_unused(dev, mt);
mt->frame++;
}

mt->frame++;
}
EXPORT_SYMBOL(input_mt_drop_unused);

Expand All @@ -278,12 +282,14 @@ void input_mt_sync_frame(struct input_dev *dev)
return;

if (mt->flags & INPUT_MT_DROP_UNUSED)
input_mt_drop_unused(dev);
__input_mt_drop_unused(dev, mt);

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

input_mt_report_pointer_emulation(dev, use_count);

mt->frame++;
}
EXPORT_SYMBOL(input_mt_sync_frame);

Expand Down

0 comments on commit 8ff21f4

Please sign in to comment.