aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2015-04-05 16:41:35 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-04-06 12:37:33 -0400
commit73e8a8e777d8dde6a67df1cf4b18371e27d080d8 (patch)
tree542890fc7998f5592a6e7f6cb32fa613e53786d6
parent61125591e1de23992279938eebf8c54f47d7e0a9 (diff)
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>
-rw-r--r--drivers/input/input-mt.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index cb150a1dbaff..b097af269e00 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -365,27 +365,35 @@ static void input_mt_set_slots(struct input_mt *mt,
365 int *slots, int num_pos) 365 int *slots, int num_pos)
366{ 366{
367 struct input_mt_slot *s; 367 struct input_mt_slot *s;
368 int *w = mt->red, *p; 368 int *w = mt->red, j;
369 369
370 for (p = slots; p != slots + num_pos; p++) 370 for (j = 0; j != num_pos; j++)
371 *p = -1; 371 slots[j] = -1;
372 372
373 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { 373 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
374 if (!input_mt_is_active(s)) 374 if (!input_mt_is_active(s))
375 continue; 375 continue;
376 for (p = slots; p != slots + num_pos; p++) 376
377 if (*w++ < 0) 377 for (j = 0; j != num_pos; j++) {
378 *p = s - mt->slots; 378 if (w[j] < 0) {
379 slots[j] = s - mt->slots;
380 break;
381 }
382 }
383
384 w += num_pos;
379 } 385 }
380 386
381 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { 387 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
382 if (input_mt_is_active(s)) 388 if (input_mt_is_active(s))
383 continue; 389 continue;
384 for (p = slots; p != slots + num_pos; p++) 390
385 if (*p < 0) { 391 for (j = 0; j != num_pos; j++) {
386 *p = s - mt->slots; 392 if (slots[j] < 0) {
393 slots[j] = s - mt->slots;
387 break; 394 break;
388 } 395 }
396 }
389 } 397 }
390} 398}
391 399