diff options
author | Ulf Brosziewski <bru@cvs.openbsd.org> | 2020-10-23 22:06:28 +0000 |
---|---|---|
committer | Ulf Brosziewski <bru@cvs.openbsd.org> | 2020-10-23 22:06:28 +0000 |
commit | c7cf77038cb666bd62d2f1861928b89fcb0fb554 (patch) | |
tree | 70875027c6fc7c92838f935810b5268926df9d29 | |
parent | c13f556db0f1bbb83eb80c5ae8226e7131e69928 (diff) |
1. Work around a firmware bug of some Elantech-v1 touchpads.
2. Remove obsolete code from the v1-/v2-packet handlers (coordinate
values are ignored if z is 0).
-rw-r--r-- | sys/dev/pckbc/pms.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/sys/dev/pckbc/pms.c b/sys/dev/pckbc/pms.c index 0ee104d6be2..360ec47115c 100644 --- a/sys/dev/pckbc/pms.c +++ b/sys/dev/pckbc/pms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pms.c,v 1.94 2020/08/10 21:55:59 mglocker Exp $ */ +/* $OpenBSD: pms.c,v 1.95 2020/10/23 22:06:27 bru Exp $ */ /* $NetBSD: psm.c,v 1.11 2000/06/05 22:20:57 sommerfeld Exp $ */ /*- @@ -142,6 +142,7 @@ struct elantech_softc { int max_x, max_y; int old_x, old_y; + int initial_pkt; }; #define ELANTECH_IS_CLICKPAD(sc) (((sc)->elantech->fw_version & 0x1000) != 0) @@ -2443,15 +2444,29 @@ pms_proc_elantech_v1(struct pms_softc *sc) else w = (sc->packet[0] & 0xc0) >> 6; + /* + * Firmwares 0x20022 and 0x20600 have a bug, position data in the + * first two reports for single-touch contacts may be corrupt. + */ + if (elantech->fw_version == 0x20022 || + elantech->fw_version == 0x20600) { + if (w == 1) { + if (elantech->initial_pkt < 2) { + elantech->initial_pkt++; + return; + } + } else if (elantech->initial_pkt) { + elantech->initial_pkt = 0; + } + } + /* Hardware version 1 doesn't report pressure. */ if (w) { x = ((sc->packet[1] & 0x0c) << 6) | sc->packet[2]; y = ((sc->packet[1] & 0x03) << 8) | sc->packet[3]; z = SYNAPTICS_PRESSURE; } else { - x = elantech->old_x; - y = elantech->old_y; - z = 0; + x = y = z = 0; } WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons, x, y, z, w); @@ -2488,9 +2503,7 @@ pms_proc_elantech_v2(struct pms_softc *sc) y = (((sc->packet[0] & 0x20) << 3) | sc->packet[2]) << 2; z = SYNAPTICS_PRESSURE; } else { - x = elantech->old_x; - y = elantech->old_y; - z = 0; + x = y = z = 0; } WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons, x, y, z, w); |