Bug 238291 - [patch] Elantech touchpad device is not recognized on Thinkpad t480s (error: unknown touchpad firmware (firmware v.0x7f3001))
Summary: [patch] Elantech touchpad device is not recognized on Thinkpad t480s (error: ...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.0-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Vladimir Kondratyev
URL: https://lists.freebsd.org/pipermail/f...
Keywords: feature, needs-qa
Depends on:
Blocks:
 
Reported: 2019-06-02 14:43 UTC by Andrey Kosachenko
Modified: 2019-09-09 07:28 UTC (History)
2 users (show)

See Also:
koobs: mfc-stable12?
koobs: mfc-stable11?


Attachments
enables proper t480s touchpad fw version recognition (293 bytes, application/gzip)
2019-06-02 14:43 UTC, Andrey Kosachenko
no flags Details
t480s-elantech-unknown-fw.patch (502 bytes, patch)
2019-06-02 14:58 UTC, Andrey Kosachenko
no flags Details | Diff
dmesg buffer output (89.46 KB, text/plain)
2019-06-03 20:31 UTC, Andrey Kosachenko
no flags Details
fix trackpoint coord sign checking (2.77 KB, patch)
2019-06-03 21:32 UTC, Vladimir Kondratyev
no flags Details | Diff
dmesg after 6bdaa610 (50.41 KB, text/plain)
2019-06-04 19:03 UTC, Andrey Kosachenko
no flags Details
fix trackpoint coord sign bits checking (2.79 KB, patch)
2019-06-04 21:37 UTC, Vladimir Kondratyev
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Kosachenko 2019-06-02 14:43:39 UTC
Created attachment 204782 [details]
enables proper t480s touchpad fw version recognition

Hi,
originally was reported in freebsd-drivers (https://lists.freebsd.org/pipermail/freebsd-drivers/2019-May/002183.html)
Further was suggested to submit a PR.


Recently I've replaced my t410 with t480s model.
Before ordering the device I found positive feedback in terms of FreeBSD 
compatibility (pages like https://wiki.freebsd.org/Laptops/Thinkpad_T480)

Apparently device is equipped with newer clickpad+trackpoint device 
which is not recognized by 12R properly:

FreeBSD beastie.intra 12.0-RELEASE-p3 FreeBSD 12.0-RELEASE-p3 #2 
r347114M: Sun May 12 00:08:31 EEST 2019 
root at beastie.intra:/usr/obj/usr/src/amd64.amd64/sys/BEASTIE-EVDEV  amd64

Attempts to enable hw.psm.synaptics_support or(and) 
hw.psm.elantech_support didn't help either. Though  trackpoint works 
just fine after enabling hw.psm.trackpoint_support

instead touchpad is recognized as generic PS/2 mouse (relevant strings 
from dmesg)

===
May 11 22:39:41 beastie kernel: atkbd0: [GIANT-LOCKED]
May 11 22:39:41 beastie kernel:   Unknown touchpad hardware (firmware 
v.0x7f3001)
May 11 22:39:41 beastie kernel: psm0: <PS/2 Mouse> irq 12 on atkbdc0
May 11 22:39:41 beastie kernel: psm0: [GIANT-LOCKED]
May 11 22:39:41 beastie kernel: psm0: model Generic PS/2 mouse, device ID 0
===

I was pretty much happy working with the device in general and with the 
tuouchpad in particular (as a simple mouse). Even got accustomed to the 
absence of double-finger scroll capability (which I could simulate via 
holding mid-button+swipe on touchpad) and triple-finger-tap as a 
midle-button-click). The only thing that I failed to workaround was 
accidental palm touches which is really painful and makes keyboard usage 
unbearable. Eventually I tried to seek for normal solution.

Lenovo site sujests for t480s devices "ELAN UltraNav Driver for Windows 
10 64-bit - ThinkPad T480s (Type 20L7, 20L8)" driver. Which made me 
think it is elantech (not synaptics). Looking through the psm sources 
quickly led me to the point where a very simple modification and 
recompilation of the kernel helped to recognize touchpad properly:
===
[silent at beastie][/usr/src]dmesg | egrep psm
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Elantech Touchpad, device ID 0
===


Additionally I found relevant topic in openbsd lists 
http://openbsd-archive.7691.n7.nabble.com/ThinkPad-T480s-Elantech-v4-clickpad-configuration-td342242.html. 
Eventually I narrow down it to the following changes: 
https://github.com/openbsd/src/commit/8e9e9c10431cb45d93e2c0d81f668ff9575f8015#diff-ff06b79b08490ebbfa34b15aa4ebf370 



Also in the freebsd-drivers  Vladimir Kondratyev commented the following (https://lists.freebsd.org/pipermail/freebsd-drivers/2019-May/002189.html):
===
The patch looks good to me. Linux guys did exactly the same recently:
https://github.com/torvalds/linux/commit/10d900303f1c3a821eb0bef4e7b7ece16768fba4#diff-e91bc4802c6797fe9acbdca0ed240be9
===


PS:
Please note there are 3 issues described in the mentioned thread of mailing lists:
1) proper touchpad firmware recognition
2) trackpoint issue;
3) yet unknown error reported in Xorg log

this PR is dedicated to issue #1 only from the list above

Thank you!
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2019-06-02 14:51:14 UTC
Thank you for the report, detail (commit references) and patch Andrey

Could you reattach the patch unzipped for us please
Comment 2 Andrey Kosachenko 2019-06-02 14:58:47 UTC
Created attachment 204783 [details]
t480s-elantech-unknown-fw.patch
Comment 3 commit-hook freebsd_committer 2019-06-02 22:28:28 UTC
A commit references this bug:

Author: wulf
Date: Sun Jun  2 22:27:27 UTC 2019
New revision: 348520
URL: https://svnweb.freebsd.org/changeset/base/348520

Log:
  psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops

  PR:		238291
  Submitted by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
  MFC after:	2 weeks

Changes:
  head/sys/dev/atkbdc/psm.c
Comment 4 Andrey Kosachenko 2019-06-03 20:31:16 UTC
Created attachment 204813 [details]
dmesg buffer output

Hi Vladimir,

as it was requested in the corresponding mailing list thread I'm attaching dmesg buffer output after setting debug.psm.loglevel="5" and rebooting the system.

just a few notes that might be useful to you:

- as you requested I performed two trackpoint manipulations: up-left and down-right movements;

- to mark boundaries in the dmesg buffer I intentionally performed two tree-fingers-tap gestures. In the output they can be identified as "fingers=3" strings. I.e.:
[silent@beastie][/tmp]egrep -n fingers=3 debug.psm.level.five.dmesg
1852:synaptics: zmax=30, dx=14, dy=10, delta=14, fingers=3, queue=6
2037:synaptics: zmax=35, dx=0, dy=0, delta=0, fingers=3, queue=8

which basically means:
- lines (0,1852] can probably be just skipped as irrelevant
- up-left movement traces can be found among lines [1853,2037);
- down-right movement traces can be found in lines [2038,$];

hope it will be useful 

thanks!
Comment 5 Vladimir Kondratyev freebsd_committer 2019-06-03 21:32:25 UTC
Created attachment 204814 [details]
fix trackpoint coord sign checking

Try this patch after my previous patch from mail list is reverted.
Comment 6 Andrey Kosachenko 2019-06-04 19:03:06 UTC
Created attachment 204823 [details]
dmesg after 6bdaa610

Hi Vladimir,

I've reverted the patch posted to mailing list, applied this one:

===
commit 6bdaa610f7c80ebbe858033d3dbf7b65396e1ca7
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
===

and rebuilt the kernel. 

As a result trackpoint issue is still observed but in a "mirrored" fashion :), i.e: now pointer can be moved by trackpoint along up-left/down-right directions however pointer can't be moved up-right/down-left (with previous patch it was vise versa: i.e. pointer could be moved up-right/down-left but not up-left/down-right)


I'm attaching dmesg output again with debug.psm.loglevel="5". Few comments:
===
[silent@beastie][/tmp]egrep -n 'fingers=3' dmesg.out
552:synaptics: zmax=34, dx=22, dy=12, delta=22, fingers=3, queue=6
748:synaptics: zmax=32, dx=3, dy=19, delta=19, fingers=3, queue=8
1010:synaptics: zmax=33, dx=9, dy=20, delta=20, fingers=3, queue=7
1250:synaptics: zmax=35, dx=9, dy=21, delta=21, fingers=3, queue=9
===

1) up-left movement: lines 553-747;
2) up-right movement: lines 749-1009;
3) down-right movement: lines 1011-1249;
4) down-left movement: lines 1251-eof;

hope it will help to tackle the issue.
Comment 7 Vladimir Kondratyev freebsd_committer 2019-06-04 21:37:25 UTC
Created attachment 204827 [details]
fix trackpoint coord sign bits checking

Hopefully, it should fix trackpoint.
Comment 8 Andrey Kosachenko 2019-06-06 17:34:16 UTC
(In reply to Vladimir Kondratyev from comment #7)

Hi Vladimir,

I confirm that the last patch makes trackpoint work as expected

thank you!
Comment 9 commit-hook freebsd_committer 2019-06-08 21:34:25 UTC
A commit references this bug:

Author: wulf
Date: Sat Jun  8 21:33:34 UTC 2019
New revision: 348817
URL: https://svnweb.freebsd.org/changeset/base/348817

Log:
  psm(4): Fix Elantech trackpoint support.

  Sign bits for X and Y motion data were taken from wrong places.

  PR:		238291
  Reported by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
  MFC after:	2 weeks

Changes:
  head/sys/dev/atkbdc/psm.c
Comment 10 commit-hook freebsd_committer 2019-06-29 12:50:32 UTC
A commit references this bug:

Author: wulf
Date: Sat Jun 29 12:49:53 UTC 2019
New revision: 349540
URL: https://svnweb.freebsd.org/changeset/base/349540

Log:
  MFC r346455-r346458, r348520, r348529, r348817, r348818

  r346455:
  psm(4): Add support for 4 and 5 finger touches in synaptics driver

  While 4-th and 5-th finger positions are not exported through PS/2
  interface, total number of touches is reported by MT trackpads.

  r346456:
  psm(4): do not process gestures when palm is present

  Ignoring of gesture processing when the palm is detected helps to reduce
  some of the erratic pointer behavior.

  This fixes regression introduced in r317814

  Reported by:	Ben LeMasurier <ben@crypt.ly>

  r346457:
  psm(4): respect tap_disabled configuration with enabled Extended support

  This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps
  were processed.
  tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1).
  To respect PR kern/139272, taps are ignored only when explicity disabled.

  Submitted by:	Ben LeMasurier <ben@crypt.ly> (initial version)

  r346458:
  psm(4): give names to synaptics commands

  Submitted by:	Ben LeMasurier <ben@crypt.ly>

  r348520:
  psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops

  PR:		238291
  Submitted by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

  r348529:
  psm(4): Add natural scrolling support to sysmouse protocol

  This change enables natural scrolling with two finger scroll enabled
  and when user is using a trackpad (mouse and trackpoint are not affected).
  Depending on trackpad model it can be activated with setting of
  hw.psm.synaptics.natural_scroll or hw.psm.elantech.natural_scroll sysctl
  values to 1.

  Evdev protocol is not affected by this change too. Tune userland client
  e.g. libinput to enable natural scrolling in that case.

  Submitted by:	nyan_myuji.xyz
  Reviewed by:	wulf
  Differential Revision:	https://reviews.freebsd.org/D20447

  r348817:
  psm(4): Fix Elantech trackpoint support.

  Sign bits for X and Y motion data were taken from wrong places.

  PR:		238291
  Reported by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

  r348818:
  psm(4): Add extra sanity checks to Elantech trackpoint packet parser.

  Add strict checks for unused bit states in Elantech trackpoint packet
  parser to filter out spurious events produces by some hardware which
  are detected as trackpoint packets. See comment on r328191 for example.

  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

Changes:
_U  stable/12/
  stable/12/share/man/man4/psm.4
  stable/12/sys/dev/atkbdc/psm.c
Comment 11 commit-hook freebsd_committer 2019-06-29 12:50:34 UTC
A commit references this bug:

Author: wulf
Date: Sat Jun 29 12:49:53 UTC 2019
New revision: 349540
URL: https://svnweb.freebsd.org/changeset/base/349540

Log:
  MFC r346455-r346458, r348520, r348529, r348817, r348818

  r346455:
  psm(4): Add support for 4 and 5 finger touches in synaptics driver

  While 4-th and 5-th finger positions are not exported through PS/2
  interface, total number of touches is reported by MT trackpads.

  r346456:
  psm(4): do not process gestures when palm is present

  Ignoring of gesture processing when the palm is detected helps to reduce
  some of the erratic pointer behavior.

  This fixes regression introduced in r317814

  Reported by:	Ben LeMasurier <ben@crypt.ly>

  r346457:
  psm(4): respect tap_disabled configuration with enabled Extended support

  This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps
  were processed.
  tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1).
  To respect PR kern/139272, taps are ignored only when explicity disabled.

  Submitted by:	Ben LeMasurier <ben@crypt.ly> (initial version)

  r346458:
  psm(4): give names to synaptics commands

  Submitted by:	Ben LeMasurier <ben@crypt.ly>

  r348520:
  psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops

  PR:		238291
  Submitted by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

  r348529:
  psm(4): Add natural scrolling support to sysmouse protocol

  This change enables natural scrolling with two finger scroll enabled
  and when user is using a trackpad (mouse and trackpoint are not affected).
  Depending on trackpad model it can be activated with setting of
  hw.psm.synaptics.natural_scroll or hw.psm.elantech.natural_scroll sysctl
  values to 1.

  Evdev protocol is not affected by this change too. Tune userland client
  e.g. libinput to enable natural scrolling in that case.

  Submitted by:	nyan_myuji.xyz
  Reviewed by:	wulf
  Differential Revision:	https://reviews.freebsd.org/D20447

  r348817:
  psm(4): Fix Elantech trackpoint support.

  Sign bits for X and Y motion data were taken from wrong places.

  PR:		238291
  Reported by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

  r348818:
  psm(4): Add extra sanity checks to Elantech trackpoint packet parser.

  Add strict checks for unused bit states in Elantech trackpoint packet
  parser to filter out spurious events produces by some hardware which
  are detected as trackpoint packets. See comment on r328191 for example.

  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

Changes:
_U  stable/12/
  stable/12/share/man/man4/psm.4
  stable/12/sys/dev/atkbdc/psm.c
Comment 12 commit-hook freebsd_committer 2019-06-29 12:54:39 UTC
A commit references this bug:

Author: wulf
Date: Sat Jun 29 12:54:28 UTC 2019
New revision: 349541
URL: https://svnweb.freebsd.org/changeset/base/349541

Log:
  MFC r346455-r346458, r348520, r348529, r348817, r348818

  r346455:
  psm(4): Add support for 4 and 5 finger touches in synaptics driver

  While 4-th and 5-th finger positions are not exported through PS/2
  interface, total number of touches is reported by MT trackpads.

  r346456:
  psm(4): do not process gestures when palm is present

  Ignoring of gesture processing when the palm is detected helps to reduce
  some of the erratic pointer behavior.

  This fixes regression introduced in r317814

  Reported by:	Ben LeMasurier <ben@crypt.ly>

  r346457:
  psm(4): respect tap_disabled configuration with enabled Extended support

  This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps
  were processed.
  tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1).
  To respect PR kern/139272, taps are ignored only when explicity disabled.

  Submitted by:	Ben LeMasurier <ben@crypt.ly> (initial version)

  r346458:
  psm(4): give names to synaptics commands

  Submitted by:	Ben LeMasurier <ben@crypt.ly>

  r348520:
  psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops

  PR:		238291
  Submitted by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

  r348529:
  psm(4): Add natural scrolling support to sysmouse protocol

  This change enables natural scrolling with two finger scroll enabled
  and when user is using a trackpad (mouse and trackpoint are not affected).
  Depending on trackpad model it can be activated with setting of
  hw.psm.synaptics.natural_scroll or hw.psm.elantech.natural_scroll sysctl
  values to 1.

  Evdev protocol is not affected by this change too. Tune userland client
  e.g. libinput to enable natural scrolling in that case.

  Submitted by:	nyan_myuji.xyz
  Reviewed by:	wulf
  Differential Revision:	https://reviews.freebsd.org/D20447

  r348817:
  psm(4): Fix Elantech trackpoint support.

  Sign bits for X and Y motion data were taken from wrong places.

  PR:		238291
  Reported by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

  r348818:
  psm(4): Add extra sanity checks to Elantech trackpoint packet parser.

  Add strict checks for unused bit states in Elantech trackpoint packet
  parser to filter out spurious events produces by some hardware which
  are detected as trackpoint packets. See comment on r328191 for example.

  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

Changes:
_U  stable/11/
  stable/11/share/man/man4/psm.4
  stable/11/sys/dev/atkbdc/psm.c
Comment 13 commit-hook freebsd_committer 2019-06-29 12:54:41 UTC
A commit references this bug:

Author: wulf
Date: Sat Jun 29 12:54:28 UTC 2019
New revision: 349541
URL: https://svnweb.freebsd.org/changeset/base/349541

Log:
  MFC r346455-r346458, r348520, r348529, r348817, r348818

  r346455:
  psm(4): Add support for 4 and 5 finger touches in synaptics driver

  While 4-th and 5-th finger positions are not exported through PS/2
  interface, total number of touches is reported by MT trackpads.

  r346456:
  psm(4): do not process gestures when palm is present

  Ignoring of gesture processing when the palm is detected helps to reduce
  some of the erratic pointer behavior.

  This fixes regression introduced in r317814

  Reported by:	Ben LeMasurier <ben@crypt.ly>

  r346457:
  psm(4): respect tap_disabled configuration with enabled Extended support

  This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps
  were processed.
  tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1).
  To respect PR kern/139272, taps are ignored only when explicity disabled.

  Submitted by:	Ben LeMasurier <ben@crypt.ly> (initial version)

  r346458:
  psm(4): give names to synaptics commands

  Submitted by:	Ben LeMasurier <ben@crypt.ly>

  r348520:
  psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops

  PR:		238291
  Submitted by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

  r348529:
  psm(4): Add natural scrolling support to sysmouse protocol

  This change enables natural scrolling with two finger scroll enabled
  and when user is using a trackpad (mouse and trackpoint are not affected).
  Depending on trackpad model it can be activated with setting of
  hw.psm.synaptics.natural_scroll or hw.psm.elantech.natural_scroll sysctl
  values to 1.

  Evdev protocol is not affected by this change too. Tune userland client
  e.g. libinput to enable natural scrolling in that case.

  Submitted by:	nyan_myuji.xyz
  Reviewed by:	wulf
  Differential Revision:	https://reviews.freebsd.org/D20447

  r348817:
  psm(4): Fix Elantech trackpoint support.

  Sign bits for X and Y motion data were taken from wrong places.

  PR:		238291
  Reported by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

  r348818:
  psm(4): Add extra sanity checks to Elantech trackpoint packet parser.

  Add strict checks for unused bit states in Elantech trackpoint packet
  parser to filter out spurious events produces by some hardware which
  are detected as trackpoint packets. See comment on r328191 for example.

  Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>

Changes:
_U  stable/11/
  stable/11/share/man/man4/psm.4
  stable/11/sys/dev/atkbdc/psm.c