Re: Thinkpad t480s elantech touchpad device is not recognized: unknown touchpad firmware (firmware v.0x7f3001)

Vladimir Kondratyev <[email protected]>
Newsgroups gmane.os.freebsd.devel.x11
Message-ID <[email protected]>
On 30.05.2019 01:17, Vladimir Kondratyev wrote:
> I.e. after that simple modification system started to recognize fw
>>> version:
>>>
>>> ===
>>> [silent@beastie][/usr/src]dmesg | egrep psm
>>> psm0: <PS/2 Mouse> irq 12 on atkbdc0
>>> psm0: [GIANT-LOCKED]
>>> psm0: model Elantech Touchpad, device ID 0
>>> ===
>>>
>>> and all expected touchpad features (multi-tap gestures and scrolling,
>>> whatsoever) started to function properly under xorg+evdev. I'm happy
>>> with a touchpad now however trackpoint stopped to work. In particular
>>> attempt to use trackpoint causes strange flickering of the mice
>>> cursor (which lasts few fractions of the second) after which cursor
>>> jumps to the left-upper corner of the screen and it's impossible to
>>> move it (via trackpoint) anymore (though swiping touchpad surface
>>> moves cursor as expected). Also I found in Xorg.log messages emerging
>>> when a palm touches the surface of a touchpad:
> Andrey, please fill bugzilla PR and send me link to it. I believe
> Elantech's trackpoint support has never been tested yet.
>
Hi Andrey,

Could you try attached patch? It is only compile-tested.

_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-x11
To unsubscribe, send any mail to "[email protected]"
psm.diff (text/x-patch, 2.3 KB)
commit 3260a1a8ffc4af7a70296496860940436a93e9c4
Author: Vladimir Kondratyev <[email protected]>
Date:   Sun Jun 2 12:37:43 2019 +0300

    psm(4): Add extra sanity checks to Elantech trackpoint support

diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c
index 5da0c3f666d4..1f253c15d156 100644
--- a/sys/dev/atkbdc/psm.c
+++ b/sys/dev/atkbdc/psm.c
@@ -4640,22 +4640,34 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, mousestatus_t *ms,
 		 * over 9 bits with SX/SY the relative top bit and
 		 * X7..X0 and Y7..Y0 the lower bits.
 		 */
-		*x = (pb->ipacket[0] & 0x20) ?
-		    pb->ipacket[4] - 256 : pb->ipacket[4];
-		*y = (pb->ipacket[0] & 0x10) ?
-		    pb->ipacket[5] - 256 : pb->ipacket[5];
 
-		trackpoint_button =
-		    ((pb->ipacket[0] & 0x01) ? MOUSE_BUTTON1DOWN : 0) |
-		    ((pb->ipacket[0] & 0x02) ? MOUSE_BUTTON3DOWN : 0) |
-		    ((pb->ipacket[0] & 0x04) ? MOUSE_BUTTON2DOWN : 0);
+		/* Check zeros for presence and sign bits for equality */
+		if (!(pb->ipacket[0] & 0xC8) && !(pb->ipacket[1] & 0x7F) &&
+		    !(pb->ipacket[2] & 0x7F) && !(pb->ipacket[3] & 0xC9) &&
+		    !(pb->ipacket[0] & 0x20) != !(pb->ipacket[1] & 0x80) &&
+		    !(pb->ipacket[0] & 0x20) != !(pb->ipacket[3] & 0x10) &&
+		    !(pb->ipacket[0] & 0x10) != !(pb->ipacket[2] & 0x80) &&
+		    !(pb->ipacket[0] & 0x10) != !(pb->ipacket[3] & 0x20)) {
+
+			*x = (pb->ipacket[0] & 0x20) ?
+			    pb->ipacket[4] - 256 : pb->ipacket[4];
+			*y = (pb->ipacket[0] & 0x10) ?
+			    pb->ipacket[5] - 256 : pb->ipacket[5];
+
+			trackpoint_button =
+			    ((pb->ipacket[0] & 0x01) ? MOUSE_BUTTON1DOWN : 0) |
+			    ((pb->ipacket[0] & 0x02) ? MOUSE_BUTTON3DOWN : 0) |
+			    ((pb->ipacket[0] & 0x04) ? MOUSE_BUTTON2DOWN : 0);
 #ifdef EVDEV_SUPPORT
-		evdev_push_rel(sc->evdev_r, REL_X, *x);
-		evdev_push_rel(sc->evdev_r, REL_Y, -*y);
-		evdev_push_mouse_btn(sc->evdev_r, trackpoint_button);
-		evdev_sync(sc->evdev_r);
+			evdev_push_rel(sc->evdev_r, REL_X, *x);
+			evdev_push_rel(sc->evdev_r, REL_Y, -*y);
+			evdev_push_mouse_btn(sc->evdev_r, trackpoint_button);
+			evdev_sync(sc->evdev_r);
 #endif
-		ms->button = touchpad_button | trackpoint_button;
+			ms->button = touchpad_button | trackpoint_button;
+		} else
+			VLOG(3, (LOG_DEBUG, "elantech: "
+			    "unexpected trackpoint packet skipped\n"));
 		return (0);
 
 	case ELANTECH_PKT_NOP:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.