Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jun 2019 12:49:18 +0300
From:      Vladimir Kondratyev <vladimir@kondratyev.su>
To:        Andrey Kosachenko <andrey.kosachenko@gmail.com>
Cc:        freebsd-drivers@freebsd.org, FreeBSD X11 mailing list <freebsd-x11@freebsd.org>
Subject:   Re: Thinkpad t480s elantech touchpad device is not recognized: unknown touchpad firmware (firmware v.0x7f3001)
Message-ID:  <de2f55b6-fd86-194a-f431-8b2b775f1b11@kondratyev.su>
In-Reply-To: <279a4144-43d3-6921-2047-e7877bfd721d@kondratyev.su>
References:  <5f4e1f25-8c87-5fa5-1d7f-edbde63fde6e@gmail.com> <a179dbc9-3907-8c3d-c369-dd829896393b@gjunka.com> <279a4144-43d3-6921-2047-e7877bfd721d@kondratyev.su>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------CC899A5BF3F64DC5C00BA818
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

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.



--------------CC899A5BF3F64DC5C00BA818
Content-Type: text/x-patch;
 name="psm.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="psm.diff"

commit 3260a1a8ffc4af7a70296496860940436a93e9c4
Author: Vladimir Kondratyev <vladimir@kondratyev.su>
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:

--------------CC899A5BF3F64DC5C00BA818--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?de2f55b6-fd86-194a-f431-8b2b775f1b11>