Bug 213757 - [psm] generic psm0 device does not support tapping on synaptics touchpad without enabling full extended support (Thinkpad T400)
Summary: [psm] generic psm0 device does not support tapping on synaptics touchpad with...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 11.0-STABLE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Oleksandr Tymoshenko
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2016-10-24 20:43 UTC by jakub_lach
Modified: 2016-11-14 21:27 UTC (History)
2 users (show)

See Also:


Attachments
Trackpoint.probing.respects.synapics.relative.mode.diff (2.53 KB, patch)
2016-10-26 00:08 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 jakub_lach 2016-10-24 20:43:36 UTC
After the r307576 the generic psm0 touchpad device no longer supports tapping (left click) on synaptics touchpad, tapping only works after the extended synaptics support is fully enabled. (hw.psm.synaptics_support: 1)
Comment 1 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-25 21:30:03 UTC
Could you post hw.psm.tap_enabled sysctl value here.
And after then try to boot with hw.psm.tap_enabled=1 line added to /boot/loader.conf, rather than /etc/sysctl.conf ?
Comment 2 jakub_lach 2016-10-25 21:42:23 UTC
(In reply to Vladimir Kondratyev from comment #1)

Default state:

$ sysctl hw.psm
hw.psm.elantech_support: 0
hw.psm.trackpoint_support: 0
hw.psm.synaptics_support: 0
hw.psm.tap_timeout: 125000
hw.psm.tap_threshold: 25
hw.psm.tap_enabled: -1

Tapping does not work. I do not compile/use 
evdev module by default but having done so, 
there was no difference.

After enabling tap_enabled

$ sysctl hw.psm
hw.psm.elantech_support: 0
hw.psm.trackpoint_support: 0
hw.psm.synaptics_support: 0
hw.psm.tap_timeout: 125000
hw.psm.tap_threshold: 25
hw.psm.tap_enabled: 1

In the second case, generic device
tapping works as usual.
Comment 3 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 00:08:33 UTC
Created attachment 176166 [details]
Trackpoint.probing.respects.synapics.relative.mode.diff

Could you try attached patch with different combinations of hw.psm.synaptics_support, hw.psm.trackpoint_support loader tunables? With and w/o synaptics xorg driver in psm mode
Comment 4 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 00:15:50 UTC
(In reply to Vladimir Kondratyev from comment #3)
Its unclear to me how synaptics in relative mode with guest trackpoint can coexist on pre r307576 kernel. Trackpoint probing switched synaptics device to absolute mode with different protocol.
Comment 5 jakub_lach 2016-10-26 05:40:37 UTC
I will report about the patch later. So far I did not use x11-drivers/xf86-input-synaptics at all, is there something I need to ensure is enabled? Iirc, turning on hw.psm.trackpoint_support made the touchpad non functional (I've tried that before synaptics_support).
Comment 6 jakub_lach 2016-10-26 10:39:11 UTC
(In reply to jakub_lach from comment #5)

After applying the patch, as far as I can tell, tapping works in all cases. hw.psm.synaptics_support: 0/1, hw.psm.trackpoint_support: 0/1, hw.psm.elantech_support: 0/1 (defaults to generic driver, but works still). If I need to test specific features (with or w/o xorg driver), please ask. I'm used to only use basic functionality and don't know what to check. Regardless, edge scrolling works with synaptics support enabled, as before.
Comment 7 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 13:11:46 UTC
(In reply to jakub_lach from comment #5)
> So far I did not use x11-drivers/xf86-input-synaptics at all,
> is there something I need to ensure is enabled?
You need something like http://stolarscy.com/dryobates/2014-02/synaptics-freebsd/ and check Xorg.log then if /dev/psm0 is handled with x11-drivers/xf86-input-synaptics. It gives you much better 2finger scroll and lot of tunables but disables console mouse support

> Iirc, turning on hw.psm.trackpoint_support made the touchpad non functional
It`s not a hardware restriction, so there are chances that it was fixed. Few commits touched that.

> After applying the patch, as far as I can tell, tapping works in all
> cases. hw.psm.synaptics_support: 0/1, hw.psm.trackpoint_support: 0/1
Thanks for testing! Don`t you forget to remove hw.psm.tap_enabled lines from /boot/loader.conf and /etc/sysctl.conf? as their presence workarounds the bug?

> If I need to test specific features (with or w/o xorg driver), please ask.
Did touchpad work for you as expected with hw.psm.synaptics_support loader tunable unset after r284585? 11.0-RELEASE is only containing this change

> Edge scrolling works with synaptics support enabled, as before.
Thanks for testing! I hope 2finger scroll works too
Comment 8 jakub_lach 2016-10-26 14:50:06 UTC
> (testing xorg driver)

Okay, I will need a bit more time on that though. Would never swap console input for a extended support in xorg, but that's just me :)

> It`s not a hardware restriction, so there are chances that it was fixed. Few commits touched that.

What I've meant, is that I've tried enabling trackpoint extended support while I was trying to regain tapping. I've lost cursor input in console then. Synaptics one worked. Now, after the patch, both of them work.

>Thanks for testing! Don`t you forget to remove hw.psm.tap_enabled lines from /boot/loader.conf and /etc/sysctl.conf? as their presence workarounds the bug?

Sure, I've commented out tapping enabled as a first thing. It's now at -1 (the default).

>Did touchpad work for you as expected with hw.psm.synaptics_support loader tunable unset after r284585? 11.0-RELEASE is only containing this change

I recompile -STABLE once every few days, I've only lost tapping after base r307755 update (21 Oct), so I'm pretty sure that's base r307576 is a culprit, so -RELEASE should be safe? I've never had hw.psm.synaptics_support enabled prior to me trying to regain tapping.
Comment 9 jakub_lach 2016-10-26 15:13:25 UTC
> Thanks for testing! I hope 2finger scroll works too

After setting hw.psm.synaptics.two_finger_scroll: 0 -> 1 neither edge scrolling nor two finger scroll works unfortunately (cursor jerks or does not move at all).
Comment 10 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 19:27:23 UTC
(In reply to jakub_lach from comment #8)
> I've only lost tapping after base r307755 update (21 Oct)
>  so I'm pretty sure that's base r307576 is a culprit,
> so -RELEASE should be safe?
r307576 enabled so called "Extended W Mode" bit in "Mode byte" for synaptics touchpad that gives multitouch support in absolute mode. That bit also disables tapping being set in relative mode. After r284585 mouse driver switches touchpad to absolute mode on trackpoint probing and initialization for reasons unknown for me (may be by bug), so absolute mode bits start leaking to relative mode. That did not hurt tapping till r307576, so -RELEASE should be tapping-safe, but other side effects due to other leaked bits are possible but not detected yet.

> After setting hw.psm.synaptics.two_finger_scroll: 0 -> 1
> neither edge scrolling nor two finger scroll works unfortunately
> (cursor jerks or does not move at all).
Did you try it before r307576 or this patch applied?
Could you set debug.psm.loglevel=5 in /boot/loader.conf and post here psm-related part of boot log and 2finger scroll gesture log?
Comment 11 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 19:49:56 UTC
(In reply to Vladimir Kondratyev from comment #10)
> Could you set debug.psm.loglevel=5 in /boot/loader.conf and post here
> psm-related part of boot log and 2finger scroll gesture log?

After googling its turned out that multifinger capabilities are not supported on some T400. E.g. Arch Linux wiki is not mentioned them on sample xf86-input-synaptics config: https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_T400
Comment 12 jakub_lach 2016-10-26 20:33:33 UTC
(In reply to Vladimir Kondratyev from comment #11)

I saw some reports of two finger scrolling on T400 (or attempts 
to have it), I've never used it before.

FreeBSD 11.0-STABLE #0 r307955M with patch applied,

 $ sysctl hw.psm
hw.psm.synaptics.touchpad_off: 0
hw.psm.synaptics.vscroll_div_max: 150
hw.psm.synaptics.vscroll_div_min: 100
hw.psm.synaptics.vscroll_min_delta: 50
hw.psm.synaptics.vscroll_ver_area: -600
hw.psm.synaptics.vscroll_hor_area: 0
hw.psm.synaptics.taphold_timeout: 125000
hw.psm.synaptics.tap_min_queue: 2
hw.psm.synaptics.tap_max_delta: 80
hw.psm.synaptics.div_len: 100
hw.psm.synaptics.div_max_na: 30
hw.psm.synaptics.div_max: 17
hw.psm.synaptics.div_min: 9
hw.psm.synaptics.weight_len_squared: 2000
hw.psm.synaptics.weight_previous_na: 20
hw.psm.synaptics.weight_previous: 6
hw.psm.synaptics.weight_current: 3
hw.psm.synaptics.multiplicator: 10000
hw.psm.synaptics.window_max: 10
hw.psm.synaptics.window_min: 4
hw.psm.synaptics.na_left: 1600
hw.psm.synaptics.na_bottom: 1408
hw.psm.synaptics.na_right: 563
hw.psm.synaptics.na_top: 1783
hw.psm.synaptics.margin_left: 200
hw.psm.synaptics.margin_bottom: 200
hw.psm.synaptics.margin_right: 200
hw.psm.synaptics.margin_top: 200
hw.psm.synaptics.max_width: 10
hw.psm.synaptics.max_pressure: 220
hw.psm.synaptics.min_pressure: 16
hw.psm.synaptics.two_finger_scroll: 1
hw.psm.synaptics.max_y: 6143
hw.psm.synaptics.max_x: 6143
hw.psm.synaptics.directional_scrolls: 0
hw.psm.elantech_support: 0
hw.psm.trackpoint_support: 0
hw.psm.synaptics_support: 1
hw.psm.tap_timeout: 125000
hw.psm.tap_threshold: 25
hw.psm.tap_enabled: -1

Boot log:

http://pastebin.com/aA6XqC7X
Comment 13 jakub_lach 2016-10-26 20:40:10 UTC
(In reply to jakub_lach from comment #12)

Attempt to two finger scroll:

http://pastebin.com/BKnZdnwN

Lots of the same, hard to spot anything.
Comment 14 jakub_lach 2016-10-26 20:45:34 UTC
(In reply to jakub_lach from comment #13)

I've experimented a bit with debug level 2, and the most I got 
after adding second finger was

Oct 26 22:43:57 Thinkpad kernel: synaptics: button RELEASE: 1
Oct 26 22:43:58 Thinkpad kernel: synaptics: button PRESS: 1
Oct 26 22:43:58 Thinkpad kernel: softintr: callout set: 126 ticks
Oct 26 22:43:58 Thinkpad kernel: synaptics: button RELEASE: 1
Oct 26 22:44:02 Thinkpad kernel: synaptics: palm detected! (11)
Oct 26 22:44:02 Thinkpad last message repeated 2 times

Usually the second finger is just ignored.
Comment 15 jakub_lach 2016-10-26 20:59:20 UTC
(In reply to jakub_lach from comment #14)

I've also enabled horizontal scrolling by hw.psm.synaptics.vscroll_hor_area=1300 though it scrolls vertically, the same as default vertical edge scrolling. I don't know if it's right.
Comment 16 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 21:13:03 UTC
(In reply to jakub_lach from comment #14)
According to boot log:

>    capMultiFinger: 0
your hardware does not support multifinger reporting

>    capPalmDetect: 1
But does support touch width reporting so multifinger touches are reported as single palm touch

In that case you can use "EmulateTwoFingerMinW" option of xf86-input-synaptics driver:
> Option "EmulateTwoFingerMinW" "integer"
>    Some touchpads report a two-finger touch as wide finger.
>    This sets the finger width threshold to emulate a two finger press.
>    This feature works best with (PalmDetect) off.
>    Property: "Synaptics Two-Finger Width" 
> (ftp://www.x.org/pub/X11R7.5/doc/man/man4/synaptics.4.html)
E.g. Option "EmulateTwoFingerMinW" "8"
but it does not supported by in-kernel driver, so it is usable only in xorg
Comment 17 jakub_lach 2016-10-26 21:16:50 UTC
(In reply to Vladimir Kondratyev from comment #16)

Just spotted the relevant bit in boot log as well, thanks 
for confirmation and explanation. Is there anything you would 
like me to test now without using xorg synaptics driver?
Comment 18 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 21:17:40 UTC
(In reply to jakub_lach from comment #15)

> I've also enabled horizontal scrolling by
> hw.psm.synaptics.vscroll_hor_area=1300 though it scrolls vertically,
> the same as default vertical edge scrolling. I don't know if it's right.

You should patch xf86-input-mouse driver to enable horizontal scrolling.
Patch can be found e.g. here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=205690 (patch_w-axis)
Comment 19 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 21:36:25 UTC
(In reply to jakub_lach from comment #17)
> Is there anything you would 
> like me to test now without using xorg synaptics driver?

Could you confirm that trackpoint is working for you in 2 following cases:

hw.psm.trackpoint_support=1
hw.psm.synaptics_support=0

hw.psm.trackpoint_support=1
hw.psm.synaptics_support=1

No need to post logs, just "yes"/"no"

I think several leaves should grow on hw.psm.trackpoint sysctl branch in both cases.
Comment 20 jakub_lach 2016-10-26 21:41:56 UTC
I see, I was under impression it might be not needed any more, as it dates back to 8-CURRENT/2008 at least (FreeBSD wiki/SynapticsTouchpad). Maybe a port option would be a good idea? In any way, this was just curiosity from my side. 
      
Can we define what is "works"? Is just moving a cursor by Trackpoint a OK? Are there any advanced gestures I need to check in either case?
Comment 21 jakub_lach 2016-10-26 21:49:24 UTC
(In reply to Vladimir Kondratyev from comment #19)

hw.psm.trackpoint_support: 0
hw.psm.synaptics_support: 1

Moving cursor by Trackpoint works.

hw.psm.trackpoint_support: 1
hw.psm.synaptics_support: 1

Moving cursor by Trackpoint works.
Comment 22 jakub_lach 2016-10-26 21:54:01 UTC
(In reply to jakub_lach from comment #21)

What I have just discovered, is that when hw.psm.synaptics_support: 1 is set (alone or in addition to trackpoint support), touchpad gets a lot more sensitive- I can get cursor to move by hoovering a finger just slightly above it's surface. I know the values are adjustable, just FYI.
Comment 23 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 22:00:38 UTC
(In reply to jakub_lach from comment #20)
> I see, I was under impression it might be not needed any more,
> as it dates back to 8-CURRENT/2008 at least (FreeBSD wiki/SynapticsTouchpad). 
I dont know. Maybe because usb mouses use different sysmouse protocol extension for scrolls. They map z_axis(usb)->z_axis(sysmouse) and w_axis(usb)->extra buttons(sysmouse), while PS/2 mouse drivers maps both z&w axises to z_axis of sysmouse reports.

> Maybe a port option would be a good idea?
Coming evdev work should solve this problem.
    
> Can we define what is "works"? Is just moving a cursor by Trackpoint a OK?
> Are there any advanced gestures I need to check in either case?
I have never used IBM/Lenovo trackpoints with FreeBSD so I am not sure.
I think moving cursor means that it working, and extra sysctls means that it was detected as trackpoint rather then generic mouse.
Comment 24 jakub_lach 2016-10-26 22:05:48 UTC
Trackpoint can be used as a button, there is some pressure 
detection sysctl for that I think. In Windows, it's also
used to scroll page if the third button is held, but 
I don't think FreeBSD ever tried to do have that? I need 
third button for pasting anyway.
Comment 25 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 22:06:52 UTC
(In reply to jakub_lach from comment #22)
> when hw.psm.synaptics_support: 1 is set (alone or in addition
> to trackpoint support), touchpad gets a lot more sensitive
FreeBSD uses very low pressure threshold to distinct touchs from hovers - 16, while Linux and, probably, hardware is using ~30, IIRC.
Comment 26 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 22:43:21 UTC
(In reply to jakub_lach from comment #21)
> hw.psm.trackpoint_support: 0
> hw.psm.synaptics_support: 1
>
> Moving cursor by Trackpoint works.
>
I asked to do test with trackpoint: 1 and synaptics: 0
Mouse should be recognized as "IBM/Lenovo trackpoint" in that case.

> hw.psm.trackpoint_support: 1
> hw.psm.synaptics_support: 1
>
> Moving cursor by Trackpoint works.

That is OK. Thanx
Comment 27 jakub_lach 2016-10-26 23:16:59 UTC
(In reply to Vladimir Kondratyev from comment #26)

Sory for the mixup, with synaptics 0 and trackpoint 1 moving a cursor 
with nub works too.
Comment 28 jakub_lach 2016-10-26 23:18:11 UTC
(In reply to jakub_lach from comment #27)

atkbd0: [GIANT-LOCKED]
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model IBM/Lenovo TrackPoint, device ID 0
Comment 29 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-26 23:43:45 UTC
(In reply to jakub_lach from comment #27)
Thank you for testing. Your touchpad is looking OK for me. I hope for you too.
Comment 30 jakub_lach 2016-10-28 09:14:56 UTC
(In reply to Vladimir Kondratyev from comment #29)

I'm glad I could help. I was able to use synaptics driver 
from ports (as verified in Xorg.0.log), though middle click 
paste doesn't work and the cursor is quite fast (accelerated)
- probably configuration thing.
Comment 31 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-10-28 16:20:26 UTC
Is attached patch a final version of the fix? Can it be committed?
Comment 32 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-28 21:32:25 UTC
(In reply to Oleksandr Tymoshenko from comment #31)
> Is attached patch a final version of the fix? Can it be committed?

Yes, it is a final version.
Comment 33 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-28 22:14:12 UTC
(In reply to jakub_lach from comment #30)
> I'm glad I could help.
Thanks!

> though middle click paste doesn't work
Your hardware advertised no support for middle button:
> capMiddle: 0
nor support for extended buttons:
> nExtendedButtons: 0
So, the only way for middle button press event to be reported is to come along with trackpoint events.
Can you confirm that trackpoint is working with synaptics driver?

> cursor is quite fast (accelerated) - probably configuration thing.
Kernel passes raw ps/2 packets to synaptics driver while it is enabled, so it is most probably a configuration issue.
Comment 34 jakub_lach 2016-10-28 22:50:16 UTC
(In reply to Vladimir Kondratyev from comment #33)

> (regarding trackpoint buttons)

Correct, there are two sets of buttons, 

http://www.notebookcheck.net/fileadmin/_migrated/pics/IOTouchpad_03.jpg

however, those (with the middle button) -

http://www.notebookcheck.net/fileadmin/_migrated/pics/IOTrackpoint01_03.jpg

are a part of keyboard/trackpoint. As it turns out, neither of which works
while synaptics xorg driver is loaded.
Comment 35 jakub_lach 2016-10-28 22:58:35 UTC
(In reply to jakub_lach from comment #34)

Which I think, was to be expected, as neither is a part of Synaptics device
and generic moused driver is not loaded?
Comment 36 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-29 09:48:34 UTC
(In reply to jakub_lach from comment #35)
After some looping over commit history of xf86-input-synaptics, its turned out that guest mouse support (trackpoint in your case) was dropped with following commit:
https://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics/commit/?id=b19e3782a77c171ca20fc962f95923495fdb7978
So the only way to use trackpoint with xf86-input-synaptics now is to use not raw psm but evdev protocol which is not available for psm driver yet.
Comment 37 commit-hook freebsd_committer freebsd_triage 2016-11-02 01:28:17 UTC
A commit references this bug:

Author: gonzo
Date: Wed Nov  2 01:27:20 UTC 2016
New revision: 308189
URL: https://svnweb.freebsd.org/changeset/base/308189

Log:
  [psm] Fix choosing wrong mode for synaptic device + trackpoint

  With guest trackpoint present trackpoint probing switched synaptics
  device to absolute mode with different protocol instead of keeping it
  in relative mode.

  PR:		213757
  Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>
  MFC after:	1 week

Changes:
  head/sys/dev/atkbdc/psm.c
Comment 38 commit-hook freebsd_committer freebsd_triage 2016-11-14 21:27:41 UTC
A commit references this bug:

Author: gonzo
Date: Mon Nov 14 21:27:18 UTC 2016
New revision: 308652
URL: https://svnweb.freebsd.org/changeset/base/308652

Log:
  MFC r308189:

  [psm] Fix choosing wrong mode for synaptic device + trackpoint

  With guest trackpoint present trackpoint probing switched synaptics
  device to absolute mode with different protocol instead of keeping it
  in relative mode.

  PR:		213757
  Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>
  MFC after:	1 week

Changes:
_U  stable/11/
  stable/11/sys/dev/atkbdc/psm.c