Skip to content

Commit be896bd

Browse files
Phoenix Huangdtor
authored andcommitted
Input: elantench - fix misreporting trackpoint coordinates
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 <[email protected]> Tested-by: Yufei Du <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 6e48604 commit be896bd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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)