Commit 7b35ab6f00edbf9a5a7f942100df5290b294cc66

Authored by Hans de Goede
Committed by Greg Kroah-Hartman
1 parent 98eb06b6ca

Input: alps - v7: sometimes a single touch is reported in mt[1]

commit 7091c443dda8c6c6d8e70e33452252f9ad3e7814 upstream.

The v7 proto differentiates between a primary touch (with high precision)
and a secondary touch (with lower precision). Normally when 2 fingers are
down and one is lifted the still present touch becomes the primary touch,
but some traces have shown that this does not happen always.

This commit deals with this by making alps_get_mt_count() not stop at the
first empty mt slot, and if a touch is present in mt[1] and not mt[0]
moving the data to mt[0] (for input_mt_assign_slots).

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=86338
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 14 additions and 4 deletions Side-by-side Diff

drivers/input/mouse/alps.c
... ... @@ -919,12 +919,14 @@
919 919  
920 920 static int alps_get_mt_count(struct input_mt_pos *mt)
921 921 {
922   - int i;
  922 + int i, fingers = 0;
923 923  
924   - for (i = 0; i < MAX_TOUCHES && mt[i].x != 0 && mt[i].y != 0; i++)
925   - /* empty */;
  924 + for (i = 0; i < MAX_TOUCHES; i++) {
  925 + if (mt[i].x != 0 || mt[i].y != 0)
  926 + fingers++;
  927 + }
926 928  
927   - return i;
  929 + return fingers;
928 930 }
929 931  
930 932 static int alps_decode_packet_v7(struct alps_fields *f,
... ... @@ -969,6 +971,14 @@
969 971 f->fingers = alps_get_mt_count(f->mt);
970 972 else /* pkt_id == V7_PACKET_ID_MULTI */
971 973 f->fingers = 3 + (p[5] & 0x03);
  974 +
  975 + /* Sometimes a single touch is reported in mt[1] rather then mt[0] */
  976 + if (f->fingers == 1 && f->mt[0].x == 0 && f->mt[0].y == 0) {
  977 + f->mt[0].x = f->mt[1].x;
  978 + f->mt[0].y = f->mt[1].y;
  979 + f->mt[1].x = 0;
  980 + f->mt[1].y = 0;
  981 + }
972 982  
973 983 return 0;
974 984 }