Skip to content

Commit 73e8a8e

Browse files
bentissdtor
authored andcommitted
Input: MT - make slot assignment work for overcovered solutions
The recent inclusion of a deassignment cost in the slot assignment algorithm did not properly account for the corner cases where the solutions are overcovered. This change makes sure the resulting assignment is unique, allocating new slots when necessary. Signed-off-by: Henrik Rydberg <rydberg@bitmath.org> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 6112559 commit 73e8a8e

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

‎drivers/input/input-mt.c‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -365,27 +365,35 @@ static void input_mt_set_slots(struct input_mt *mt,
365365
int *slots, int num_pos)
366366
{
367367
struct input_mt_slot *s;
368-
int *w = mt->red, *p;
368+
int *w = mt->red, j;
369369

370-
for (p = slots; p != slots + num_pos; p++)
371-
*p = -1;
370+
for (j = 0; j != num_pos; j++)
371+
slots[j] = -1;
372372

373373
for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
374374
if (!input_mt_is_active(s))
375375
continue;
376-
for (p = slots; p != slots + num_pos; p++)
377-
if (*w++ < 0)
378-
*p = s - mt->slots;
376+
377+
for (j = 0; j != num_pos; j++) {
378+
if (w[j] < 0) {
379+
slots[j] = s - mt->slots;
380+
break;
381+
}
382+
}
383+
384+
w += num_pos;
379385
}
380386

381387
for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
382388
if (input_mt_is_active(s))
383389
continue;
384-
for (p = slots; p != slots + num_pos; p++)
385-
if (*p < 0) {
386-
*p = s - mt->slots;
390+
391+
for (j = 0; j != num_pos; j++) {
392+
if (slots[j] < 0) {
393+
slots[j] = s - mt->slots;
387394
break;
388395
}
396+
}
389397
}
390398
}
391399

0 commit comments

Comments
 (0)