NetBSD Problem Report #58435
From mccd@bsd.lt Wed Jul 17 14:40:41 2024
Return-Path: <mccd@bsd.lt>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id B6EC11A9239
for <gnats-bugs@gnats.NetBSD.org>; Wed, 17 Jul 2024 14:40:41 +0000 (UTC)
Message-Id: <20240716164437.94D9D1020F93@bsd.lt>
Date: Tue, 16 Jul 2024 11:44:37 -0500 (-05)
From: marc@mccd.space
Reply-To: marc@mccd.space
To: gnats-bugs@NetBSD.org
Subject: kern/58435: synaptics_aux_mid_button_scroll not working
X-Send-Pr-Version: 3.95
>Number: 58435
>Category: kern
>Synopsis: synaptics_aux_mid_button_scroll not working
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jul 17 14:45:00 +0000 2024
>Last-Modified: Fri Jul 19 04:55:01 +0000 2024
>Originator: marc@mccd.space
>Release: NetBSD 10.0
>Organization:
>Environment:
System: NetBSD bsd.lt 10.0 NetBSD 10.0 (COOLBSD) #0: Mon Jul 15 20:32:46 -05 2024 mccd@bsd.lt:/root/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
On my laptop I recently replaced my elantech touchpad with
a synaptics touchpad.
Everything works and I can see Synpatics touchpad being
registered in dmesg:
mccd dmesg | grep -i pms
[ 1.033021] pms0 at pckbc1 (aux slot)
[ 1.033021] pms0: Synaptics touchpad version 8.2
[ 1.033021] pms0: Extended W mode, Passthrough, Palm detect, One button click pad, Multi-finger Report, Multi-finger, Reports max, Reports min
[ 1.033021] pms0: Probed max coordinates right: 5678, top: 4720
[ 1.033021] pms0: Probed min coordinates left: 1264, bottom: 1132
[ 1.033021] wsmouse0 at pms0 mux 0
[ 1.033176] pms0 at pckbc1 (aux slot)
[ 1.033176] pms0: Synaptics touchpad version 8.2
[ 1.033176] pms0: Extended W mode, Passthrough, Palm detect, One button click pad, Multi-finger Report, Multi-finger, Reports max, Reports min
[ 1.033176] pms0: Probed max coordinates right: 5678, top: 4720
[ 1.033176] pms0: Probed min coordinates left: 1264, bottom: 1132
[ 1.033176] wsmouse0 at pms0 mux 0
and pc keyboard is detected as well
mccd dmesg | grep -i pckbd0
[ 1.033021] pckbd0 at pckbc1 (kbd slot)
[ 1.033021] wskbd0 at pckbd0: console keyboard
[ 1.033176] pckbd0 at pckbc1 (kbd slot)
[ 1.033176] wskbd0 at pckbd0: console keyboard
The laptop I have is a thinkpad T480s
However, I can not get middle-click scroll to work.
I can see that there is an option to enable it in
pms and I have made sure it is enabled in sysctl like
so:
hw.synaptics.aux_mid_button_scroll=1
Yet middle click scroll does not work, I noticed that
the if case is:
if (synaptics_aux_mid_button_scroll &&
dy && (psc->buttons & 0x2)) {
wsmouse_precision_scroll(psc->sc_wsmousedev, dx, dy);
} else {
buttons = (psc->buttons & 0x1f) | ((psc->buttons >> 5) & 0x7);
wsmouse_input(psc->sc_wsmousedev,
buttons, dx, dy, dz, 0,
WSMOUSE_INPUT_DELTA);
}
Maybe the if case is incorrect and the code
should be something different?
>How-To-Repeat:
This happens on a thinkpad T480s with the
touchpad replaced to a synaptics touchpad.
>Fix:
Temporary solution is to enable autoscroll in
webbrowser but this does not solve the problem
in general
>Release-Note:
>Audit-Trail:
From: "Marc Coquand" <marc@mccd.space>
To: <gnats-bugs@netbsd.org>
Cc:
Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
Date: Wed, 17 Jul 2024 19:27:06 -0500
Hi!
Not sure what happened with the title, sorry for that.
Since reporting this issue, I managed to create a fix that works on my
computer.
It seems the button code was wrong for my computer, not sure if there
is a generic solution to the issue.
I was able to figure out the correct code through debug statements.
diff --git a/sys/dev/pckbport/synaptics.c.old b/sys/dev/pckbport/synaptics.=
c
index 76582c9..3bd763a 100644
--- a/sys/dev/pckbport/synaptics.c.old
+++ b/sys/dev/pckbport/synaptics.c
@@ -1688,7 +1688,7 @@ pms_synaptics_passthrough(struct pms_softc *psc)
* scrolling.
*/
if (synaptics_aux_mid_button_scroll &&
- dy && (psc->buttons & 0x2)) {
+ dy && (psc->buttons & 0x40)) {
wsmouse_precision_scroll(psc->sc_wsmousedev, dx, dy=
);
} else {
buttons =3D (psc->buttons & 0x1f) | ((psc->buttons =
>> 5) & 0x7);
Sincerely,
Marc
From: Robert Elz <kre@munnari.OZ.AU>
To: "Marc Coquand" <marc@mccd.space>
Cc: gnats-bugs@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
Date: Thu, 18 Jul 2024 14:59:38 +0700
Date: Thu, 18 Jul 2024 00:30:03 +0000 (UTC)
From: "Marc Coquand" <marc@mccd.space>
Message-ID: <20240718003003.CD1F81A923A@mollari.NetBSD.org>
| Since reporting this issue, I managed to create a fix that works on my
| computer.
|
| It seems the button code was wrong for my computer, not sure if there
| is a generic solution to the issue.
To me, your change makes it look like as if the following change might
be a better one -- but I don't have any kind of (working) synatpics
touchpad at the minute to test this.
I believe this will work for you, but I can't tell if it might break
things for anyone else.
kre
Index: synaptics.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pckbport/synaptics.c,v
retrieving revision 1.83
diff -u -r1.83 synaptics.c
--- synaptics.c 18 Apr 2024 17:35:53 -0000 1.83
+++ synaptics.c 18 Jul 2024 07:52:59 -0000
@@ -1700,11 +1700,11 @@
* If the middle button is held, interpret movement as
* scrolling.
*/
+ buttons = (psc->buttons & 0x1f) | ((psc->buttons >> 5) & 0x7);
if (synaptics_aux_mid_button_scroll &&
- dy && (psc->buttons & 0x2)) {
+ dy && (buttons & 0x2)) {
wsmouse_precision_scroll(psc->sc_wsmousedev, dx, dy);
} else {
- buttons = (psc->buttons & 0x1f) | ((psc->buttons >> 5) & 0x7);
wsmouse_input(psc->sc_wsmousedev,
buttons, dx, dy, dz, 0,
WSMOUSE_INPUT_DELTA);
From: "Marc Coquand" <marc@mccd.space>
To: <gnats-bugs@netbsd.org>, <kern-bug-people@netbsd.org>,
<gnats-admin@netbsd.org>, <netbsd-bugs@netbsd.org>
Cc:
Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
Date: Thu, 18 Jul 2024 10:11:19 -0500
Hi Robert,
I tested your changes and they also work! Thank you.
I am very new to kernel development and trying to learn more, could I
ask how you came to your solution?
-- Marc
On Thu Jul 18, 2024 at 3:00 AM -05, Robert Elz wrote:
> The following reply was made to PR kern/58435; it has been noted by GNATS=
.
>
> From: Robert Elz <kre@munnari.OZ.AU>
> To: "Marc Coquand" <marc@mccd.space>
> Cc: gnats-bugs@netbsd.org, netbsd-bugs@netbsd.org
> Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
> Date: Thu, 18 Jul 2024 14:59:38 +0700
>
> Date: Thu, 18 Jul 2024 00:30:03 +0000 (UTC)
> From: "Marc Coquand" <marc@mccd.space>
> Message-ID: <20240718003003.CD1F81A923A@mollari.NetBSD.org>
> =20
> | Since reporting this issue, I managed to create a fix that works on=
my
> | computer.
> | =20
> | It seems the button code was wrong for my computer, not sure if the=
re
> | is a generic solution to the issue.
> =20
> To me, your change makes it look like as if the following change might
> be a better one -- but I don't have any kind of (working) synatpics
> touchpad at the minute to test this.
> =20
> I believe this will work for you, but I can't tell if it might break
> things for anyone else.
> =20
> kre
> =20
> Index: synaptics.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/src/sys/dev/pckbport/synaptics.c,v
> retrieving revision 1.83
> diff -u -r1.83 synaptics.c
> --- synaptics.c 18 Apr 2024 17:35:53 -0000 1.83
> +++ synaptics.c 18 Jul 2024 07:52:59 -0000
> @@ -1700,11 +1700,11 @@
> * If the middle button is held, interpret movement as
> * scrolling.
> */
> + buttons =3D (psc->buttons & 0x1f) | ((psc->buttons >> 5) & 0x7);
> if (synaptics_aux_mid_button_scroll &&
> - dy && (psc->buttons & 0x2)) {
> + dy && (buttons & 0x2)) {
> wsmouse_precision_scroll(psc->sc_wsmousedev, dx, dy);
> } else {
> - buttons =3D (psc->buttons & 0x1f) | ((psc->buttons >> 5) & 0x7);
> wsmouse_input(psc->sc_wsmousedev,
> buttons, dx, dy, dz, 0,
> WSMOUSE_INPUT_DELTA);
> =20
> =20
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
Date: Thu, 18 Jul 2024 19:27:42 +0300
I'd _guess_ - from a quick glance - that in your case the middle
button "belongs" to the pass-through device (the stick, or whatever),
so it's mapped by the driver's code to 0x40, while whoever wrote that
code had their middle button belong to the main device, so it would
have been mapped to 0x02. The code in the else branch merged the two
sets of buttons, but the scrolling code didn't and only tested the
main device bits (and your kludge was to test the pass-through device
bits). So kre's fix is to always merge the buttons, and the scrolling
code should now react to both the primary and the pass-through middle
buttons.
-uwe
From: Robert Elz <kre@munnari.OZ.AU>
To: "Marc Coquand" <marc@mccd.space>
Cc: gnats-bugs@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
Date: Fri, 19 Jul 2024 00:21:28 +0700
Date: Thu, 18 Jul 2024 10:11:19 -0500
From: "Marc Coquand" <marc@mccd.space>
Message-ID: <D2SREUPAW7DX.2069PCA6P3T4Q@mccd.space>
| I tested your changes and they also work!
That's good.
| I am very new to kernel development and trying to learn more, could I
| ask how you came to your solution?
Reading the code, and guesswork... along with the solution that you provided.
The button= line that was a little later, in combination with your changed
value, suggested that the 5 button bits are in some way duplicated in
the struct - the code for the 2nd case was treating them the same (what
that line does) but the scrolling code you had a problem with wasn't.
Your change swapped use of the lower bits (or one of them anyway) for the
equivalent bit in the other set ((0x40 >> 5) == 0x2) - so it seemed likely
to me that combining the bits for the scrolling case would work if it does
for the other case (and this is right at the end of the function, so what
is left in the "buttons" variable cannot matter).
But someone with synaptics knowledge should check this, or at least someone
with access to some kind of documentation.
kre
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
Date: Thu, 18 Jul 2024 23:49:42 -0000 (UTC)
kre@munnari.OZ.AU (Robert Elz) writes:
>- dy && (psc->buttons & 0x2)) {
>+ dy && (buttons & 0x2)) {
You could just use (psc->buttons & 0x42) to see if main or
aux "middle button" are pressed. Ideally you would have
names for the "magic" numbers too.
This would leave the idiom:
# merge main and aux button state into wsmouse button mask
buttons = ..
# create input event for wsmouse
wsmouse_input(...
as is.
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
Date: Fri, 19 Jul 2024 09:17:16 +0700
Date: Thu, 18 Jul 2024 23:55:01 +0000 (UTC)
From: mlelstv@serpens.de (Michael van Elst)
Message-ID: <20240718235501.D362B1A923A@mollari.NetBSD.org>
| You could just use (psc->buttons & 0x42) to see if main or
| aux "middle button" are pressed.
Yes, I considered that version, but it just seemed too obtuse.
| Ideally you would have names for the "magic" numbers too.
Ideally ... something for someone who has one of these they can
use for testing, and to commit something.
kre
From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/58435 CVS commit: src/sys/dev/pckbport
Date: Fri, 19 Jul 2024 04:48:13 +0000
Module Name: src
Committed By: mlelstv
Date: Fri Jul 19 04:48:13 UTC 2024
Modified Files:
src/sys/dev/pckbport: synaptics.c
Log Message:
hw.synaptics.aux_mid_button_scroll translates vertical movements
of an aux device (like a trackpoint) into a scroll event when
the middle mouse button is pressed.
Make this work with either the middle mouse button of the main
device (buttonmask 0x02) or the middle mouse button of the aux
device (buttonmask 0x40).
Fixes PR 58435.
To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/pckbport/synaptics.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/58435: synaptics_aux_mid_button_scroll not working
Date: Fri, 19 Jul 2024 04:52:05 -0000 (UTC)
kre@munnari.OZ.AU (Robert Elz) writes:
> | You could just use (psc->buttons & 0x42) to see if main or
> | aux "middle button" are pressed.
>
> Yes, I considered that version, but it just seemed too obtuse.
Just committed.
> | Ideally you would have names for the "magic" numbers too.
>
> Ideally ... something for someone who has one of these they can
> use for testing, and to commit something.
Maybe next time :)
Saying that, I miss more a click-and-drag gesture.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.