Skip to content

Commit 8c341d1

Browse files
Phoenix Huanggregkh
authored andcommitted
Input: elantench - fix misreporting trackpoint coordinates
commit be896bd upstream. Some firmwares occasionally report bogus data from trackpoint, with X or Y displacement being too large (outside of [-127, 127] range). Let's drop such packets so that we do not generate jumps. Signed-off-by: Phoenix Huang <phoenix@emc.com.tw> Tested-by: Yufei Du <yufeidu@cs.unc.edu> Link: https://lore.kernel.org/r/20210729010940.5752-1-phoenix@emc.com.tw Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d1eb42d commit 8c341d1

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎drivers/input/mouse/elantech.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,19 @@ static void elantech_report_trackpoint(struct psmouse *psmouse,
517517
case 0x16008020U:
518518
case 0x26800010U:
519519
case 0x36808000U:
520+
521+
/*
522+
* This firmware misreport coordinates for trackpoint
523+
* occasionally. Discard packets outside of [-127, 127] range
524+
* to prevent cursor jumps.
525+
*/
526+
if (packet[4] == 0x80 || packet[5] == 0x80 ||
527+
packet[1] >> 7 == packet[4] >> 7 ||
528+
packet[2] >> 7 == packet[5] >> 7) {
529+
elantech_debug("discarding packet [%6ph]\n", packet);
530+
break;
531+
532+
}
520533
x = packet[4] - (int)((packet[1]^0x80) << 1);
521534
y = (int)((packet[2]^0x80) << 1) - packet[5];
522535

0 commit comments

Comments
 (0)