Bug 205690 - [psm] [patch]: Add support for Elantech trackpads
Summary: [psm] [patch]: Add support for Elantech trackpads
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Many People
Assignee: Oleksandr Tymoshenko
URL:
Keywords: feature, needs-qa, patch
Depends on:
Blocks:
 
Reported: 2015-12-29 10:39 UTC by Raphael 'kena' Poss
Modified: 2016-11-04 17:50 UTC (History)
20 users (show)

See Also:
knz: mfc-stable11?
koobs: mfc-stable10?


Attachments
Patch to add Elantech support to 10-STABLE (r292841) (97.49 KB, patch)
2015-12-29 10:39 UTC, Raphael 'kena' Poss
no flags Details | Diff
Patch updated to apply cleanly against 11-current (r301929) (64.88 KB, patch)
2016-06-15 23:45 UTC, Ben Woods
no flags Details | Diff
Patch updated to apply cleanly against 11-current (r301929) (65.68 KB, patch)
2016-06-16 10:35 UTC, Ben Woods
no flags Details | Diff
elantech.diff (11-CURRENT) (67.00 KB, patch)
2016-06-16 22:26 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (11-CURRENT) (67.37 KB, patch)
2016-06-19 13:28 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (11-CURRENT) (67.45 KB, patch)
2016-06-19 14:29 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (11-CURRENT) (88.83 KB, patch)
2016-06-23 23:08 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (11-CURRENT) (88.92 KB, patch)
2016-07-18 21:29 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (11-CURRENT) (89.09 KB, patch)
2016-07-19 08:47 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (12-CURRENT) (94.22 KB, patch)
2016-09-06 23:56 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (12-CURRENT) (94.90 KB, patch)
2016-09-24 16:50 UTC, Vladimir Kondratyev
no flags Details | Diff
patch-w_axis (920 bytes, patch)
2016-09-24 17:42 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (12-CURRENT) (94.95 KB, patch)
2016-09-24 21:09 UTC, Vladimir Kondratyev
no flags Details | Diff
elantech.diff (12-CURRENT) (94.96 KB, patch)
2016-09-25 11:57 UTC, Vladimir Kondratyev
no flags Details | Diff
extbuttons.diff (3.63 KB, patch)
2016-10-01 18:59 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 Raphael 'kena' Poss 2015-12-29 10:39:10 UTC
Created attachment 164815 [details]
Patch to add Elantech support to 10-STABLE (r292841)

Elantech trackpads are found in some laptops like the Asus UX31E. They are "synaptics compatible" but use a slightly different protocol. They are well supported on OpenBSD and NetBSD, but not in FreeBSD.

See previous discussions of issues:

https://lists.freebsd.org/pipermail/freebsd-x11/2012-August/012326.html

https://forums.freebsd.org/threads/touchpad-not-recognized-generic-ps-2-mouse-instead.50318/

A patch to support Elantech trackpads was proposed against 11-CURRENT by Vladimir Kondratyev in September 2015 on the freebsd-mobile mailing list:

https://lists.freebsd.org/pipermail/freebsd-mobile/2015-September/013327.html

I hereby confirm as independent observer that this patch indeed works as intended; moreover the Elantech trackpad is supported in 10-STABLE as well by back-porting the patched psm driver from 11-CURRENT.

The attachment provides a combined patch against 10-STABLE revision 292841.
Comment 1 Renic Gunderson 2016-06-09 03:03:11 UTC
I implemented this patch against releng/10.3 so that I could use it on my laptop.  It seems to work without incident.

I don't know how to make a unified diff, so I will link the github repo where I stored the changes.

https://github.com/renic/freebsd-elantech
Comment 2 Ben Woods freebsd_committer freebsd_triage 2016-06-15 23:45:39 UTC
Created attachment 171472 [details]
Patch updated to apply cleanly against 11-current (r301929)

Hi Raphael, thank you very much for your work on this!

I have gone through this patch line by line and modified it to apply cleanly to 11-current as of r301929.

I will rebuild my kernel+world now and do some testing.
Comment 3 Ben Woods freebsd_committer freebsd_triage 2016-06-16 08:20:26 UTC
I can confirm that this patch against 11-current compiles and allows my Elantech trackpad to work if I add the following line to /boot/loader.conf and reboot:
hw.psm.elantech_support="1"

Two-finger scrolling works perfectly by default.

One interesting behaviour is click+drag does not work as expected. If I click in the bottom left of the trackpad with one finger, and use a different finger to drag on the track pad, I expect it to select the text from the start to finish of the drag motion. Instead the cursor remains still on the screen and it enables scroll action as I drag. I can still click+drag successfully using another technique: double tap (touch) and drag with the one finger.
Comment 4 Ben Woods freebsd_committer freebsd_triage 2016-06-16 10:35:40 UTC
Created attachment 171478 [details]
Patch updated to apply cleanly against 11-current (r301929)

Updated patch to match original patch from Vladimir Kondratiev <wulf@cicgroup.ru>.

The only differences to Vladimir's original patch are those required to make it apply cleanly to 11-current (r301929).
Comment 5 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-16 22:26:36 UTC
Created attachment 171497 [details]
elantech.diff (11-CURRENT)
Comment 6 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-16 22:26:57 UTC
Hi, all

Here is up to date version of patch from my private repository. It is simplified version of previous patch as I changed direction of development and now use evdev interface for direct reporting of absolute fingers position to libinput or xf86-synaptics driver (evdev part is not included here). So for most people this patch will not make life better as compared with previous version :-(

Most notable changes are:
1. Dirty "Multitouch" hack has been removed. For now only first finger position is accounted for 2 finger scroll
2. (Unested) Ver 2. Hardware initialization sequence changed to match OpenBSD not Linux (linux guys did not commit that part for unknown reason)
3. HW Ver 3 2finger touch is processed as single 12-byte packet not as 2 6-bytes packets. (Libinput wants this)
4. diff size has been reduced
5. Something else that I cant remember.

Not all of these changes  has been tested due to lack of hardware so regressions are possible.
Comment 7 Ben Woods freebsd_committer freebsd_triage 2016-06-18 08:59:01 UTC
(In reply to Vladimir Kondratyev from comment #6)
Hi Vladimir,

Thanks for the update. I have tested it and confirm that it still allows me to have working two-finger scrolling, even without the evdev work. I do still have a problem with click-and-drag.

Thanks for your work on this.
Comment 8 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-18 09:58:34 UTC
(In reply to Ben Woods from comment #7)
Thanks for testing, Ben!

Click and drag is not supported. It is a restriction of single-touch gesture processor dated back to 2008 and r183888. Single-double-triple tap and drag only.

It`s possible to add a hack to simulate this but i think it is a wrong way. IMO the right way is to move gesture processing to one of already existing userland library and leave current code path in its current state to vt & sc mouses only.
Comment 9 Ben Woods freebsd_committer freebsd_triage 2016-06-19 08:54:30 UTC
Hi Vladimir,
I am not convinced that click and drag only needs support in X, and therefore doesn't need to be in the psm(4) driver. In fact, if I disable the elantech support with this patch, click and drag is support with the moused generic 3 button mouse support. Enabling the elantech support breaks click and drag, but it would be handy to use in both the console and in X (for copying).
Comment 10 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-19 13:28:28 UTC
Created attachment 171570 [details]
elantech.diff (11-CURRENT)
Comment 11 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-19 13:36:17 UTC
(In reply to Ben Woods from comment #9)

Try updated patch. It forbids entering 2 finger scroll mode when any button is pressed
Comment 12 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-19 14:29:23 UTC
Created attachment 171573 [details]
elantech.diff (11-CURRENT)
Comment 13 Ben Woods freebsd_committer freebsd_triage 2016-06-20 09:54:53 UTC
(In reply to Vladimir Kondratyev from comment #11)
> Try updated patch. It forbids entering 2 finger scroll mode when any button is pressed

Hi Vladimir,
Thanks for that - it works very nicely! It works as long as I click before touching my other finger to the touchpad. However, if I happen to have my other finger already resting on the touchpad then it still doesn't work, and sometimes tries to scroll. Is it possible to make the click take precedence and cancel any current multitouch action?
Comment 14 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-20 20:35:12 UTC
(In reply to Ben Woods from comment #13)
This behaviour is expected. Gesture processor is single-touch only, so driver tries to predict which finger will move and sometimes does it wrong.
I tried to split current code on separate movement smoother and gesture processor parts to be able to use 2 instances of smoother and track both fingers at one time but some regressions appeared. I will post updated patch here if I fix them but can say nothing about timeframe
Comment 15 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-23 23:08:41 UTC
Created attachment 171726 [details]
elantech.diff (11-CURRENT)
Comment 16 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-23 23:10:30 UTC
Multitouch version attached. I hope it works
Comment 17 Ben Woods freebsd_committer freebsd_triage 2016-06-28 09:01:26 UTC
Adrian / Vladimir: what are your thoughts about whether this could make it into FreeBSD 11? Is it too late now that we are in code/ABI freeze?
Comment 18 Ben Woods freebsd_committer freebsd_triage 2016-06-28 09:03:02 UTC
Not sure if it helps to say that the majority of this code only take effect if the following sysctl is set at boot time:
hw.psm.elantech_support="1"
Comment 19 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-28 10:17:05 UTC
(In reply to Ben Woods from comment #17)

This patch requires regression testing on synaptics touchpads and I do not have such hardware.
Comment 20 Ben Woods freebsd_committer freebsd_triage 2016-06-28 17:00:09 UTC
(In reply to Vladimir Kondratyev from comment #16)
> Multitouch version attached. I hope it works

Yep - this is working fine for me. This is the best version yet - I have two finger scroll and click-and-drag both working, regardless of whether or not my drag finger was on the touchpad before I click or not. Thank you!
Comment 21 Anthony Jenkins 2016-06-28 19:29:03 UTC
(In reply to Ben Woods from comment #20)

I've been running an early version of this patch on my laptop with a Synaptics touchpad with no problem; I'll try the latest version.

Does the multitouch functionality extend to the Synaptics variant of psm(4)?
Comment 22 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-06-28 22:02:36 UTC
(In reply to Anthony Jenkins from comment #21)
> Does the multitouch functionality extend to the Synaptics variant of psm(4)?
No. Someone should implement "advanced gestures packets" parser in synaptics driver to enable multitouch functionality.
Comment 23 Ben Woods freebsd_committer freebsd_triage 2016-07-11 18:02:37 UTC
(In reply to Anthony Jenkins from comment #21)
Hi Anthony, how has your testing gone with this driver installed on a system with a synaptics touchpad for regression testing purposes?

Maybe we could now land this driver in 12-current?

Adrian: would you be willing to have a look, as previously mentioned?
Comment 24 Juan Ramón Molina Menor 2016-07-15 08:34:10 UTC
I have tested the patch on two Lenovo laptops which have Synaptics (ThinkPad S440) and Elantech (S20-30) trackpads. I already had Synaptics support with the psm(4) driver and the patch doesn’t seem to introduce regressions.

What I have tested, both on console and X:
 - Select / Copy / Paste with tap, drag and three-finger tap.
 - Two-finger scroll.
 - Normal button operation.

Hope it helps,
Juan
Comment 25 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-07-15 09:14:01 UTC
(In reply to Juan Ramón Molina Menor from comment #24)
Thank you, Juan!

Could you add debug.psm.loglevel=2 to /boot/loader.conf and provide us with some info about your touchpad hardware from "dmesg" and "sysctl hw.psm." commands output?

Following is what my laptop prints:

# dmesg
... skipped ...
Elantech touchpad hardware v.4 firmware v.0x461f02
... skipped ...
  Model information:
   MaxX:     2772
   MaxY:     1452
   DpmmX:    32
   DpmmY:    32
   TracesX:  21
   TracesY:  11
   SemiMT:   0
   Clickpad: 1
   Trackpad: 0
   CRC:      0
   Pressure: 1
psm0: found Elantech Touchpad

# sysctl hw.psm.elantech.
hw.psm.elantech.softbutton3_x: 1848
hw.psm.elantech.softbutton2_x: 924
hw.psm.elantech.softbuttons_y: 363
hw.psm.elantech.touchpad_off: 0
hw.psm.elantech.vscroll_div_max: 50
hw.psm.elantech.vscroll_div_min: 30
hw.psm.elantech.vscroll_min_delta: 15
hw.psm.elantech.vscroll_ver_area: 0
hw.psm.elantech.vscroll_hor_area: 0
hw.psm.elantech.taphold_timeout: 250000
hw.psm.elantech.tap_min_queue: 2
hw.psm.elantech.tap_max_delta: 25
hw.psm.elantech.div_len: 30
hw.psm.elantech.div_max_na: 10
hw.psm.elantech.div_max: 6
hw.psm.elantech.div_min: 3
hw.psm.elantech.weight_len_squared: 200
hw.psm.elantech.weight_previous_na: 20
hw.psm.elantech.weight_previous: 6
hw.psm.elantech.weight_current: 3
hw.psm.elantech.multiplicator: 10000
hw.psm.elantech.window_max: 10
hw.psm.elantech.window_min: 4
hw.psm.elantech.na_left: 0
hw.psm.elantech.na_bottom: 0
hw.psm.elantech.na_right: 0
hw.psm.elantech.na_top: 0
hw.psm.elantech.margin_left: 0
hw.psm.elantech.margin_bottom: 0
hw.psm.elantech.margin_right: 0
hw.psm.elantech.margin_top: 0
hw.psm.elantech.max_width: 10
hw.psm.elantech.max_pressure: 220
hw.psm.elantech.min_pressure: 1
hw.psm.elantech.two_finger_scroll: 1
hw.psm.elantech.directional_scrolls: 0
Comment 26 Juan Ramón Molina Menor 2016-07-15 10:18:39 UTC
# dmesg
...
Elantech touchpad hardware v.3 firmware v.0x350f00
...
  Model information:
   MaxX:     2436
   MaxY:     1044
   DpmmX:    32
   DpmmY:    32
   TracesX:  22
   TracesY:  10
   SemiMT:   1
   Clickpad: 0
   Trackpad: 0
   CRC:      0
   Pressure: 1
psm0: found Elantech Touchpad
...
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Elantech Touchpad, device ID 0-00, 3 buttons
psm0: config:00004000, flags:00000008, packet size:6
psm0: syncmask:04, syncbits:00

# sysctl hw.psm.elantech
hw.psm.elantech.touchpad_off: 0
hw.psm.elantech.vscroll_div_max: 50
hw.psm.elantech.vscroll_div_min: 30
hw.psm.elantech.vscroll_min_delta: 15
hw.psm.elantech.vscroll_ver_area: 0
hw.psm.elantech.vscroll_hor_area: 0
hw.psm.elantech.taphold_timeout: 125000
hw.psm.elantech.tap_min_queue: 2
hw.psm.elantech.tap_max_delta: 25
hw.psm.elantech.div_len: 30
hw.psm.elantech.div_max_na: 10
hw.psm.elantech.div_max: 6
hw.psm.elantech.div_min: 3
hw.psm.elantech.weight_len_squared: 200
hw.psm.elantech.weight_previous_na: 20
hw.psm.elantech.weight_previous: 6
hw.psm.elantech.weight_current: 3
hw.psm.elantech.multiplicator: 10000
hw.psm.elantech.window_max: 10
hw.psm.elantech.window_min: 4
hw.psm.elantech.na_left: 0
hw.psm.elantech.na_bottom: 0
hw.psm.elantech.na_right: 0
hw.psm.elantech.na_top: 0
hw.psm.elantech.margin_left: 0
hw.psm.elantech.margin_bottom: 0
hw.psm.elantech.margin_right: 0
hw.psm.elantech.margin_top: 0
hw.psm.elantech.max_width: 10
hw.psm.elantech.max_pressure: 220
hw.psm.elantech.min_pressure: 1
hw.psm.elantech.two_finger_scroll: 1
hw.psm.elantech.directional_scrolls: 0
Comment 27 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-07-15 11:22:18 UTC
(In reply to Juan Ramón Molina Menor from comment #26)
> Elantech touchpad hardware v.3 firmware v.0x350f00

HW version 3 can be considered as basicaly working. Thanks

>   SemiMT:   1

Here is harmless bug in driver. HWv3 is multitouch TP not semi-multitouch. I will fix that

Could you do following gestures and post results here:

Gest 1.
1. Put first finger on e.g. left bottom corner of TP
2. Do a short move so cursor moves too
3. Put second finger on opposite corner
4. Move both fingers to trigger 2finger scroll
5. Release first (left) finger but leave second on TP
6. Move second finger across TP

Gest 2.
1 - 4 is the same
5. Release second (right) finger but leave first on TP
6. Move first finger across TP


Does cursor jump on p.5?
What is happening on p.6? Cursor moving or scrolling?

Could you post synaptics "dmesg" and "sysctl hw.psm." output here too?
Comment 28 Juan Ramón Molina Menor 2016-07-15 18:54:20 UTC
Hi again.

> Could you do following gestures and post results here:
>
> Gest 1.
> 1. Put first finger on e.g. left bottom corner of TP
> 2. Do a short move so cursor moves too
> 3. Put second finger on opposite corner
> 4. Move both fingers to trigger 2finger scroll
> 5. Release first (left) finger but leave second on TP
> 6. Move second finger across TP
>
> Gest 2.
> 1 - 4 is the same
> 5. Release second (right) finger but leave first on TP
> 6. Move first finger across TP

Results:

--- Synaptics ---
Gest 1 and 2: Cursor does not jump on p. 5. Scroll stops in p. 6 and cursor resumes moving.

--- Elantech ---
Gest 1: Cursor jumps on p. 5. Scroll stops in p. 6. and cursor resumes moving.
Gest 2: Cursor does not jump on p. 5. Scroll stops in p. 6 and cursor resumes moving.


> Could you post synaptics "dmesg" and "sysctl hw.psm." output here too?

# dmesg
...
Synaptics Touchpad v8.1
...
  Model information:
   infoRot180: 0
   infoPortrait: 0
   infoSensor: 1
   infoHardware: 113
   infoNewAbs: 1
   capPen: 0
   infoSimplC: 1
   infoGeometry: 1
...
  Extended capabilities:
   capExtended: 1
   capMiddle: 0
   nExtendedQueries: 5
   capPassthrough: 1
   capLowPower: 0
   capMultiFingerReport: 1
   capSleep: 0
   capFourButtons: 0
   capBallistics: 0
   capMultiFinger: 1
   capPalmDetect: 1
   infoXupmm: 45
   infoYupmm: 52
...
  Extended model ID:
   verticalScroll: 0
   horizontalScroll: 0
   verticalWheel: 0
   nExtendedButtons: 0
   capEWmode: 1
...
  Continued capabilities:
   capClickPad: 1
   capDeluxeLEDs: 0
   noAbsoluteFilter: 0
   capReportsV: 1
   capUniformClickPad: 0
   capReportsMin: 1
   capInterTouch: 1
   capReportsMax: 1
   capClearPad: 0
   capAdvancedGestures: 0
   capCoveredPad: 0
   maximumXCoord: 5674
   maximumYCoord: 4684
   minimumXCoord: 1266
   minimumYCoord: 1170
  Additional Buttons: 1
...
psm0: found Synaptics Touchpad
...
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Synaptics Touchpad, device ID 0-00, 4 buttons
psm0: config:00004000, flags:00000008, packet size:6
psm0: syncmask:c0, syncbits:00

# sysctl hw.psm.synaptics
hw.psm.synaptics.softbutton3_x: 4700
hw.psm.synaptics.softbutton2_x: 3600
hw.psm.synaptics.softbuttons_y: 1700
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: -400
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: 0
hw.psm.synaptics.na_top: 1314
hw.psm.synaptics.margin_left: 200
hw.psm.synaptics.margin_bottom: 200
hw.psm.synaptics.margin_right: 0
hw.psm.synaptics.margin_top: 0
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.directional_scrolls: 0
Comment 29 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-07-18 21:29:01 UTC
Created attachment 172681 [details]
elantech.diff (11-CURRENT)

Changes:
1. (Hopefully) fixes cursor jump after releasing of one finger in "2finger scroll" on Hw v.3 touchpads
2. fixes staying in "2finger scroll" state after releasing of one finger on Hw v.4 touchpads
3. (Hopefully) fixes incorrect noise area sizing for Synaptics touchpads
Comment 30 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-07-18 21:56:18 UTC
(In reply to Juan Ramón Molina Menor from comment #28)
> --- Elantech ---
> Gest 1: Cursor jumps on p. 5. Scroll stops in p. 6. and cursor resumes moving.
New version should eliminate cursor jump

> # sysctl hw.psm.synaptics
> ....
> hw.psm.synaptics.na_right: 0
> hw.psm.synaptics.na_top: 1314
Ooops. I subtracted wrong axis here. Should be fixed now.

>  Continued capabilities:
>   capClickPad: 1
Is it synaptics clickpad?
If so, could you check proper softbuttons sizing? Pressing on to lower-right part of synaptics clickpad should produce middle or right mouse button events rather than left button event. Zones are tuned via hw.psm.synaptics.softbutton3_x, hw.psm.synaptics.softbutton2_x and hw.psm.synaptics.softbuttons_y sysctls and their default values was taken to match HP pavillion clickpad drawing. I wonder, if these values match your touchpad geometry?

Big thanx for testing, Juan!
Comment 31 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-07-19 08:47:39 UTC
Created attachment 172702 [details]
elantech.diff (11-CURRENT)

Fix regression appeared in previous patch

Driver produced extra taps when used with Elan Hw v.4 TP
Comment 32 Ben Woods freebsd_committer freebsd_triage 2016-07-26 15:06:46 UTC
Hi Vladimir,

Please see below the same details for my touchpad.

# dmesg
...
skipped
...
psm0: current command byte:0065
psm: ENABLE_DEV return code:00fa
psm: DISABLE_DEV return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 02 64
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SET_RESOLUTION (0) 00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 3c 03 00
psm: SET_RESOLUTION (3) 00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 3c 03 00
psm: SET_RESOLUTION (3) 00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 3c 03 00
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SEND_AUX_DEV_DATA return code:00fa
psm: data 00 00 ffffffff
psm: SET_SAMPLING_RATE (200) 00fa
psm: SET_SAMPLING_RATE (100) 00fa
psm: SET_SAMPLING_RATE (80) 00fa
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SET_SAMPLING_RATE (200) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: SET_SAMPLING_RATE (80) 00fa
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SET_SAMPLING_RATE (200) 00fa
psm: SET_SAMPLING_RATE (100) 00fa
psm: SET_SAMPLING_RATE (80) 00fa
psm: SET_SAMPLING_RATE (60) 00fa
psm: SET_SAMPLING_RATE (40) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 7a f0 1c
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 3c 03 00
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 46 1f 01
Elantech touchpad hardware v.4 firmware v.0x461f01
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 10 15 0e
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 06 66 04
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 7a f0 1c
  Model information:
   MaxX:     2800
   MaxY:     1820
   DpmmX:    33
   DpmmY:    33
   TracesX:  20
   TracesY:  13
   SemiMT:   0
   Clickpad: 1
   Trackpad: 0
   CRC:      0
   Pressure: 1
psm0: found Elantech Touchpad
psm: SET_RESOLUTION (2) 00fa
psm: SET_SAMPLING_RATE (100) 00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 02 64
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Elantech Touchpad, device ID 0-00, 1 buttons
psm0: config:00004000, flags:00000008, packet size:6
psm0: syncmask:04, syncbits:00
...
skipped
...
psm: ENABLE_DEV return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 20 02 64
psm: SET_SAMPLING_RATE (100) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 20 02 64


# sysctl hw.psm.elantech
hw.psm.elantech.softbutton3_x: 1400
hw.psm.elantech.softbutton2_x: 0
hw.psm.elantech.softbuttons_y: 455
hw.psm.elantech.touchpad_off: 0
hw.psm.elantech.vscroll_div_max: 50
hw.psm.elantech.vscroll_div_min: 30
hw.psm.elantech.vscroll_min_delta: 15
hw.psm.elantech.vscroll_ver_area: 0
hw.psm.elantech.vscroll_hor_area: 0
hw.psm.elantech.taphold_timeout: 125000
hw.psm.elantech.tap_min_queue: 2
hw.psm.elantech.tap_max_delta: 25
hw.psm.elantech.div_len: 30
hw.psm.elantech.div_max_na: 10
hw.psm.elantech.div_max: 6
hw.psm.elantech.div_min: 3
hw.psm.elantech.weight_len_squared: 200
hw.psm.elantech.weight_previous_na: 20
hw.psm.elantech.weight_previous: 6
hw.psm.elantech.weight_current: 3
hw.psm.elantech.multiplicator: 10000
hw.psm.elantech.window_max: 10
hw.psm.elantech.window_min: 4
hw.psm.elantech.na_left: 0
hw.psm.elantech.na_bottom: 0
hw.psm.elantech.na_right: 0
hw.psm.elantech.na_top: 0
hw.psm.elantech.margin_left: 0
hw.psm.elantech.margin_bottom: 0
hw.psm.elantech.margin_right: 0
hw.psm.elantech.margin_top: 0
hw.psm.elantech.max_width: 10
hw.psm.elantech.max_pressure: 220
hw.psm.elantech.min_pressure: 1
hw.psm.elantech.two_finger_scroll: 1
hw.psm.elantech.directional_scrolls: 0


# grep -i psm /boot/loader.conf
hw.psm.elantech_support="1"
debug.psm.loglevel="2"


# grep -i psm /etc/sysctl.conf
hw.psm.elantech.softbutton2_x=0		# Disable middle click in touchpad button area
hw.psm.elantech.softbutton3_x=1400	# Move touchpad right click button left axis to middle


I also performed the tests you requests (with two finger scroll and then releasing left or right finger before the other). In either case, the cursor movement on releasing the fingers was minimal... a few pixels either way, but that may be caused by the lifting of the finger off the touchpad.
Comment 33 Juan Ramón Molina Menor 2016-07-29 15:57:16 UTC
Hi Vladimir.

Sorry for not replying earlier.

Unfortunately, I’m having a graphics problem with the laptop with the Elantech touchpad: I’m testing the DRM 4.6 support and something has broken Xorg in a recent commit. I’m not seeing the 'jump' issues with the touchpad in the console, but there is no two-finger scroll to be tested…

Well, I have tested your new path in my Haswell laptop with a Synaptics touchpad and it works as before, so support do not seem to have regressed.

I’ll be back to you as soon as I have something. Thanks for your efforts.
Juan
Comment 34 Juan Ramón Molina Menor 2016-07-31 15:43:23 UTC
(In reply to Vladimir Kondratyev from comment #30)
>> Gest 1: Cursor jumps on p. 5. Scroll stops in p. 6. and cursor resumes moving.
>New version should eliminate cursor jump

Yes it does.

>>  Continued capabilities:
>>   capClickPad: 1
>Is it synaptics clickpad?
>If so, could you check proper softbuttons sizing? Pressing on to lower-right
>part of synaptics clickpad should produce middle or right mouse button events 
>rather than left button event. Zones are tuned via 
>hw.psm.synaptics.softbutton3_x, hw.psm.synaptics.softbutton2_x and 
>hw.psm.synaptics.softbuttons_y sysctls and their default values was taken to 
>match HP pavillion clickpad drawing. I wonder, if these values match your 
>touchpad geometry?

Thanks for pointing this, I didn’t know. Softbuttons are also working, but require fine-tuning their position with the sysctl values. They also require an actual click, tapping would not trigger them. All considered, I still prefer double and triple tapping.

Best regards,
Juan
Comment 35 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-06 23:56:39 UTC
Created attachment 174447 [details]
elantech.diff (12-CURRENT)

Finally, I had got laptop with synaptics touchpad to play with and wrote "Extended W mode" AKA "advanced gestures" packets parser to enable multitouch functionality on synaptcs.

Changes are:

1. Multitouch support to synaptics psm driver.
2. Some minor fixes.
3. Resize clickpad softbuttons. Now they relative sizes should be 42%-16%-42% (L-M-R). This change affects elans too.

Unfortunately, only semi-mt trackpads has been tested. Modern multitouch are not. Multitouch trackpad can be recognized by presence of enabled (set to 1) capReportsV property in "Continued capabilities" section of verbose boot log, i think. Set debug.psm.loglevel=2 in /boot/loader.conf to obtain this log.

Enjoy :-)

P.S. Thanks all for previous versions testing
Comment 36 Juan Ramón Molina Menor 2016-09-13 07:09:39 UTC
I have a ThinkPad with Synaptics multi-touch trackpad (capReportsV: 1, see above for details) and I’ve not found regressions with this new patch. Softbuttons, tapping, two-finger scroll, three-finger paste, etc. work as expected. Thanks!
Comment 37 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-13 12:44:19 UTC
(In reply to Juan Ramón Molina Menor from comment #36)
> I have a ThinkPad with Synaptics multi-touch trackpad (capReportsV: 1, see above for details) and I’ve not found regressions with this new patch.  Softbuttons, tapping, two-finger scroll, three-finger paste, etc. work as expected. Thanks!

Did you try multitouch gestures like clickpad Click-and-drag?

Place 2 fingers one by one on touchpad to trigger 2-finger scroll then click with one finger and move another one without releasing touch surface. You should see cursor moving with your finger with mouse button downed (drag). It should not depends on placing order and which finger is holding a click and which finger is moving.

It would be nice to check these gestures with x11-drivers/xf86-input-synaptics driver in psm mode. It seems that nonpatched driver do not initialize "advanced gesture mode" for xf86-input-synaptics for multitouch trackpads. This patch should fix that.
Comment 38 Juan Ramón Molina Menor 2016-09-13 13:47:39 UTC
(In reply to Vladimir Kondratyev from comment #37)
It is somewhat awkward, but yes, click-and-drag work as you describe, I can select text or move windows. I didn't know about these gestures, do you have others I could test?
Comment 39 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-13 15:18:00 UTC
(In reply to Juan Ramón Molina Menor from comment #38)
> It is somewhat awkward, but yes, click-and-drag work as you describe,
> I can select text or move windows. I didn't know about these gestures,
> do you have others I could test?

Thanks for testing, Juan

Click-and-drag is useful for long drags when touchpad`s edge restricts your finger movement length. click-drag-drag-drag is easier to do than tap-drag-tap-drag-tap-drag.
And it`s only supported multitouch gesture now. Other consequence of multitouch support is ability to do 2 finger scroll with moving of single finger not both but I don`t see it really helpful.
Comment 40 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-13 16:06:21 UTC
(In reply to Juan Ramón Molina Menor from comment #38)
Click-and-drag is really simple gesture. You click with one finger and then drag with another not releasing former. Some complications I wrote in previous post is for working around some synaptics firmware single touch trickery. See comments 13 and 14 from Ben Woods and me.
Comment 41 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-09-23 22:03:00 UTC
Hi Vladimir, could you confirm that you tested this change for two cases: with WITNESS+INVARIANTS enabled and without these options? I don't have hardware to test it myself so I'd like your help to make sure that it passes smoke test.
Comment 42 Guilherme Salazar 2016-09-24 07:04:35 UTC
(In reply to Oleksandr Tymoshenko from comment #41)

Oleksandr, could you elaborate on these options? I'd be happy to help.

By the way, thanks to whoever proposed the patch. What I have tested:

1) Two-finger scroll
2) Vertical and horizontal edge scroll

If we enable both, two-finger scroll seems to take precedence. Also, scroll continues after touch release; you have to touch the pad again to stop it.
Comment 43 Guilherme Salazar 2016-09-24 07:09:04 UTC
(In reply to Guilherme Salazar from comment #42)

Addendum: "scroll continues" behavior only applies to vscroll.
Comment 44 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-24 16:50:11 UTC
Created attachment 175131 [details]
elantech.diff (12-CURRENT)

1. Fix for "scroll continues" behavior on edgescroll.
2. Mention hw.psm.elantech_support loader tunable in psm(4) manpage
Comment 45 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-24 16:52:09 UTC
(In reply to Guilherme Salazar from comment #42)
Hi, Guilherme.

Could you test updated patch for edgescroll issue?
Comment 46 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-09-24 17:01:50 UTC
(In reply to Guilherme Salazar from comment #42)

Hi Guilherme,

WITNESS and INVARIANTS are two kernel options that add additional checks to detect problems with locking and some inconsistencies in internal subsystem states. These checks affect performance so they're not enabled in release kernels, only on -CURRENT. It's a good idea to test patches with WITNESS/INVARIANTS enabled to catch bugs like lock order reversal early instead of going through full debugging.
Comment 47 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-24 17:42:55 UTC
Created attachment 175134 [details]
patch-w_axis

As a bonus
Patch to enable horizontal scrolling in xf86-input-mouse driver. Just put this file onto /usr/ports/x11-drivers/xf86-input-mouse/files/ directory with name patch-w_axis, rebuild x11-drivers/xf86-input-mouse and restart X-server.
Don`t apply it if you do not use synaptics or elantech touchpad in native mode as it uses slightly different version of sysmouse protocol
Comment 48 Guilherme Salazar 2016-09-24 20:10:35 UTC
(In reply to Vladimir Kondratyev from comment #45)
Hi Vladimir,

I have tested the new patch and the issue persists. Noticed I had only compiled and installed the kernel; compiled and installed moused and mouse.h but the issue still persists.

Any clue?
Comment 49 Guilherme Salazar 2016-09-24 20:12:04 UTC
(In reply to Oleksandr Tymoshenko from comment #46)

Hi Oleksandr, did it; took a bit to figure out INVARIANTS requires INVARIANT_SUPPORT, but got it. I'm running the kernel with these options; any particular test I need to do?
Comment 50 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-09-24 20:24:16 UTC
(In reply to Guilherme Salazar from comment #49)

No, no particular tests. Just check dmesg output for lines with "lock order reversal". There might be some from other subsystems but if there is nothing with psm.c in it - it's OK. Also if kernel does not panic - it means there are no violations of INVARIANTS checks. 

Thanks for testing it.
Comment 51 Guilherme Salazar 2016-09-24 20:28:29 UTC
(In reply to Vladimir Kondratyev from comment #45)

Got some reversals, but they do seem to come from other places.

============
 $ dmesg | grep -C3 -i "lock order reversal" 
WARNING: attempt to domain_add(bluetooth) after domainfinalize()
WARNING: attempt to domain_add(netgraph) after domainfinalize()
re0: link state changed to UP
lock order reversal:
 1st 0xfffffe01e6e6c950 bufwait (bufwait) @ /usr/src/sys/kern/vfs_bio.c:3512
 2nd 0xfffff80008f97400 dirhash (dirhash) @ /usr/src/sys/ufs/ufs/ufs_dirhash.c:281
stack backtrace:
--
#7 0xffffffff80b025a8 at kern_mkdirat+0x208
#8 0xffffffff80e9d40b at amd64_syscall+0x2db
#9 0xffffffff80e7d7eb at Xfast_syscall+0xfb
lock order reversal:
 1st 0xfffff8012e05d5f0 ufs (ufs) @ /usr/src/sys/kern/vfs_subr.c:2523
 2nd 0xfffffe01e6f94b70 bufwait (bufwait) @ /usr/src/sys/ufs/ffs/ffs_vnops.c:263
 3rd 0xfffff8012e3fa9a0 ufs (ufs) @ /usr/src/sys/kern/vfs_subr.c:2523
--
#14 0xffffffff80b01dd0 at sys_fsync+0x170
#15 0xffffffff80e9d40b at amd64_syscall+0x2db
#16 0xffffffff80e7d7eb at Xfast_syscall+0xfb
lock order reversal:
 1st 0xfffffe01e7310ab0 bufwait (bufwait) @ /usr/src/sys/ufs/ffs/ffs_vnops.c:263
 2nd 0xfffff8005fd3a5b0 snaplk (snaplk) @ /usr/src/sys/ufs/ffs/ffs_snapshot.c:2298
stack backtrace:
--
#14 0xffffffff80aff298 at kern_unlinkat+0x208
#15 0xffffffff80e9d40b at amd64_syscall+0x2db
#16 0xffffffff80e7d7eb at Xfast_syscall+0xfb
lock order reversal:
 1st 0xfffff8005fd3a5b0 snaplk (snaplk) @ /usr/src/sys/kern/vfs_vnops.c:442
 2nd 0xfffff8012ed957c8 ufs (ufs) @ /usr/src/sys/ufs/ffs/ffs_snapshot.c:1629
stack backtrace:
============
Comment 52 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-09-24 20:35:47 UTC
(In reply to Guilherme Salazar from comment #51)

Great, no psm LORs. Thanks a lot for testing.
Comment 53 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-24 21:09:57 UTC
Created attachment 175144 [details]
elantech.diff (12-CURRENT)
Comment 54 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-24 21:17:19 UTC
(In reply to Guilherme Salazar from comment #48)
> I have tested the new patch and the issue persists.

That looks strange. I have tested it on both elan and synaptics touchpads and it fixes edgescroll bug for me.

Did you change some sysctls? E.g. hw.psm.<your touchpad>.window_min?
If so try new patch. It should fix edgescroll if window_min is set to 1.
Comment 55 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-24 21:21:53 UTC
(In reply to Oleksandr Tymoshenko from comment #41)
> Hi Vladimir, could you confirm that you tested this change for two cases: with WITNESS+INVARIANTS enabled and without these options?

I tested it with both touchpad types and found no psm.c-related witness messages.
Comment 56 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-09-24 21:42:37 UTC
(In reply to Vladimir Kondratyev from comment #55)

Thanks, Vladimir. Once the bug with vertical scroll is cleared (either fixed, or fix postponed until more information is available) I will commit the patch.
Comment 57 Guilherme Salazar 2016-09-24 22:59:30 UTC
(In reply to Vladimir Kondratyev from comment #54)

Tested it; same thing. I'm afraid I may be doing something wrong:

* I build and install a new kernel
* I build and install usr.sbin/moused
* I copy sys/sys/mouse.h header to include/sys/mouse.h

I set these options on /boot/loader.conf:

hw.psm.elantech_support=1
hw.psm.elantech.two_finger_scroll=1

and I have moused enabled in rc.conf.

To test vscroll, I do:

sysctl hw.psm.elantech.two_finger_scroll=0
sysctl hw.psm.elantech.vscroll_ver_area=-100

and I did also test setting

sysctl hw.psm.elantech.window_min=1

I'm running 11-RC3 btw.
Comment 58 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-24 23:57:15 UTC
(In reply to Guilherme Salazar from comment #57)

> Tested it; same thing. I'm afraid I may be doing something wrong:

> * I build and install a new kernel
> * I build and install usr.sbin/moused
> * I copy sys/sys/mouse.h header to include/sys/mouse.h

Build and install kernel is enough

> I set these options on /boot/loader.conf:

> hw.psm.elantech_support=1
> hw.psm.elantech.two_finger_scroll=1

hw.psm.elantech.two_finger_scroll is sysctl, not kernel tuneable. No need in setting it here. Other settings seem to be OK.

Could you add debug.psm.loglevel=5 to /boot/loader.conf and post here following parts of dmesg output (they can be found in /var/log/messages also):
1. PSM-related part of boot log. like described in post #25 in this thread.
2. Your 'buggy' gesture. Please do not long finger moves to keep log short.
Comment 59 Guilherme Salazar 2016-09-25 02:04:52 UTC
(In reply to Vladimir Kondratyev from comment #58)

PSM-related parts of dmesg and "sysctl hw.psm below; the gesture data I posted at http://pastebin.com/2WDATpGp. Please let me know if you need me to do it again.

$ dmesg
...
Elantech touchpad hardware v.3 firmware v.0x450f02
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 79 17 0c
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 0b 01 14
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 5b 7c 78
  Model information:
   MaxX:     2940
   MaxY:     1400
   DpmmX:    32
   DpmmY:    32
   TracesX:  22
   TracesY:  11
   SemiMT:   0
   Clickpad: 0
   Trackpad: 0
   CRC:      0
   Pressure: 1
elantech: END init
psm0: found Elantech Touchpad
...

$ sysctl hw.psm.
hw.psm.elantech.touchpad_off: 0
hw.psm.elantech.vscroll_div_max: 50
hw.psm.elantech.vscroll_div_min: 30
hw.psm.elantech.vscroll_min_delta: 15
hw.psm.elantech.vscroll_ver_area: 0
hw.psm.elantech.vscroll_hor_area: 0
hw.psm.elantech.taphold_timeout: 125000
hw.psm.elantech.tap_min_queue: 2
hw.psm.elantech.tap_max_delta: 25
hw.psm.elantech.div_len: 30
hw.psm.elantech.div_max_na: 10
hw.psm.elantech.div_max: 6
hw.psm.elantech.div_min: 3
hw.psm.elantech.weight_len_squared: 200
hw.psm.elantech.weight_previous_na: 20
hw.psm.elantech.weight_previous: 6
hw.psm.elantech.weight_current: 3
hw.psm.elantech.multiplicator: 10000
hw.psm.elantech.window_max: 10
hw.psm.elantech.window_min: 4
hw.psm.elantech.na_left: 0
hw.psm.elantech.na_bottom: 0
hw.psm.elantech.na_right: 0
hw.psm.elantech.na_top: 0
hw.psm.elantech.margin_left: 0
hw.psm.elantech.margin_bottom: 0
hw.psm.elantech.margin_right: 0
hw.psm.elantech.margin_top: 0
hw.psm.elantech.max_width: 10
hw.psm.elantech.max_pressure: 220
hw.psm.elantech.min_pressure: 1
hw.psm.elantech.two_finger_scroll: 1
hw.psm.elantech.max_y: 1400
hw.psm.elantech.max_x: 2940
hw.psm.elantech.directional_scrolls: 0
hw.psm.tap_timeout: 125000
hw.psm.tap_threshold: 25
hw.psm.tap_enabled: -1
Comment 60 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-25 09:10:59 UTC
(In reply to Guilherme Salazar from comment #59)
According to log, you did not apply last patch correctly.

See line 1374:

> synaptics: ----
> synaptics: virtual scrolling: NO (direction=0, dxp=97, dyp=212, fingers=1)

Appearance of this two lines together (except if window_min sysctl is set to 1) is consequence of edgescroll bug. But that codepath is clean and is fixed now. I do not understand how you did it.
Comment 61 Guilherme Salazar 2016-09-25 09:58:36 UTC
(In reply to Vladimir Kondratyev from comment #60)

> I do not understand how you did it.

Neither do I; checked out a clean src tree, applied the patch, and it worked. Very very sorry for the noise. Many thanks for your work on the patchset.

Will run the kernel with INVARIANTS+WITNESS until later today and post the results here.
Comment 62 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-25 11:57:45 UTC
Created attachment 175154 [details]
elantech.diff (12-CURRENT)

1. Rename Elantech guest device from trackpad to trackpoint (cosmetic change)
2. Apply changes similar to edgescroll bugfix to clickpad handling code.

Changes as compared with previous patch is mostly no-op, so no need to apply it if you use previous version. It was almost impossible to trigger bug conditions with clickpad
Comment 63 rkoberman 2016-09-25 15:58:59 UTC
RE: Comment #62 Item #2.

Please don't call the Elantach touchpad a "trackpoint". That term is already in use for the little eraser-like pointer device found on Lenovo and, historically, Dell and HP laptops. Using this term for other pointing devices will only cause confusion. This is particularly significant because the psm driver already has support for that trackpoint and the hw.psm.trackpoint OID tree for sysctls already exists. Also, the term is a trademark of Lenovo.
Comment 64 Guilherme Salazar 2016-09-25 22:46:10 UTC
Have been running a patched kernel with INVARIANTS, WITNESS, DIAGNOSTIC, and DEBUG_LOCKS on. It looks clean.
Comment 65 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-25 22:58:39 UTC
(In reply to rkoberman from comment #63)

"Trackpoint" is optional device, not touchpad itself.
Comment 66 commit-hook freebsd_committer freebsd_triage 2016-09-26 22:06:56 UTC
A commit references this bug:

Author: gonzo
Date: Mon Sep 26 22:06:19 UTC 2016
New revision: 306355
URL: https://svnweb.freebsd.org/changeset/base/306355

Log:
  Add Elantech trackpad support

  Elantech trackpads are found in some laptops like the Asus UX31E. They
  are "synaptics compatible" but use a slightly different protocol.

  Elantech hardware support is not enabled by default and just like
  Synaptic or TrackPoint devices it should be enabled by setting
  tunable, in this case hw.psm.elantech_support, to non-zero value

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

Changes:
  head/sys/dev/atkbdc/psm.c
  head/sys/sys/mouse.h
Comment 67 commit-hook freebsd_committer freebsd_triage 2016-09-26 22:08:02 UTC
A commit references this bug:

Author: gonzo
Date: Mon Sep 26 22:07:46 UTC 2016
New revision: 306356
URL: https://svnweb.freebsd.org/changeset/base/306356

Log:
  Add Elantech trackpad to the list of known models

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

Changes:
  head/usr.sbin/moused/moused.c
Comment 68 commit-hook freebsd_committer freebsd_triage 2016-09-26 22:09:06 UTC
A commit references this bug:

Author: gonzo
Date: Mon Sep 26 22:08:35 UTC 2016
New revision: 306357
URL: https://svnweb.freebsd.org/changeset/base/306357

Log:
  Document hw.psm.elantech_support in psm(4)

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

Changes:
  head/share/man/man4/psm.4
Comment 69 Guilherme Salazar 2016-09-26 22:52:28 UTC
Nice it got committed; too bad it won't be in 11 :(

Thanks again for your work, Vladimir; improved a lot my experience.
Comment 70 Ben Woods freebsd_committer freebsd_triage 2016-09-26 23:21:25 UTC
(In reply to Guilherme Salazar from comment #69)
I'll second that - thanks Vladimir for improving the FreeBSD experience on my laptop!

Can this bug report be closed now?
Comment 71 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2016-09-27 06:34:20 UTC
(In reply to Ben Woods from comment #70)

I'm planning on MFCing this change to 11 (and may be 10) so let's keep it open until then.
Comment 72 Jakob Alvermark 2016-09-30 11:18:41 UTC
Regression:

On a ThinkPad Yoga 12 (Broadwell) with ClickPad and TrackPoint.

After r306355 the hardware buttons does not work anymore.

ClickPad works, multifinger and all.
Comment 73 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-09-30 12:17:28 UTC
(In reply to Jakob Alvermark from comment #72)

> On a ThinkPad Yoga 12 (Broadwell) with ClickPad and TrackPoint.
> After r306355 the hardware buttons does not work anymore.
> ClickPad works, multifinger and all.

Is it Synaptics or Elan?

Could you add debug.psm.loglevel=5 to /boot/loader.conf and post here following parts of dmesg output (they can be found in /var/log/messages also):
1. PSM-related part of boot log. like described in post #25 in this thread.
2. Button press and release
Comment 74 Jakob Alvermark 2016-10-01 15:19:12 UTC
(In reply to Vladimir Kondratyev from comment #73)

I'm 100% sure, but I think it is synaptics.

/boot/loader.conf has:
hw.psm.synaptics_support=1
hw.psm.trackpoint_support=1

Boot dmesg (withdebug.psm.loglevel=5) :
psm0: current command byte:0047
psm: ENABLE_DEV return code:00fa
psm: DISABLE_DEV return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 02 64
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SET_RESOLUTION (0) 00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 00 64
psm: SET_RESOLUTION (3) 00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 03 64
psm: SET_RESOLUTION (3) 00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 03 64
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SEND_AUX_DEV_DATA return code:00fa
psm: data 08 00 00
psm: SET_SAMPLING_RATE (200) 00fa
psm: SET_SAMPLING_RATE (100) 00fa
psm: SET_SAMPLING_RATE (80) 00fa
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SET_SAMPLING_RATE (200) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: SET_SAMPLING_RATE (80) 00fa
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SET_SAMPLING_RATE (200) 00fa
psm: SET_SAMPLING_RATE (100) 00fa
psm: SET_SAMPLING_RATE (80) 00fa
psm: SET_SAMPLING_RATE (60) 00fa
psm: SET_SAMPLING_RATE (40) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
synaptics: BEGIN init
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 01 47 18
Synaptics Touchpad v8.1
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 01 e2 b1
  Model information:
   infoRot180: 0
   infoPortrait: 0
   infoSensor: 1
   infoHardware: 113
   infoNewAbs: 1
   capPen: 0
   infoSimplC: 1
   infoGeometry: 1
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status f0 02 a3
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 35 80 49
  Extended capabilities:
   capExtended: 1
   capMiddle: 0
   nExtendedQueries: 7
   capPassthrough: 1
   capLowPower: 0
   capMultiFingerReport: 1
   capSleep: 0
   capFourButtons: 0
   capBallistics: 0
   capMultiFinger: 1
   capPalmDetect: 1
   infoXupmm: 53
   infoYupmm: 73
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 94 33 00
  Extended model ID:
   verticalScroll: 0
   horizontalScroll: 0
   verticalWheel: 0
   nExtendedButtons: 3
   capEWmode: 1
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 12 e8 00
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status b2 68 95
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 26 98 21
  Continued capabilities:
   capClickPad: 1
   capDeluxeLEDs: 0
   noAbsoluteFilter: 0
   capReportsV: 1
   capUniformClickPad: 0
   capReportsMin: 1
   capInterTouch: 1
   capReportsMax: 1
   capClearPad: 0
   capAdvancedGestures: 0
   capCoveredPad: 0
   maximumXCoord: 5712
   maximumYCoord: 4780
   minimumXCoord: 1232
   minimumYCoord: 1074
  Additional Buttons: 4
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 33 03 40
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
psm: setting pass-through mode.
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (2) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: turning pass-through mode off.
psm: SET_SCALING21 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_RESOLUTION (1) 00fa
psm: SET_SAMPLING_RATE (20) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (0) 00fa
psm: SET_RESOLUTION (3) 00fa
psm: SET_SAMPLING_RATE (200) 00fa
synaptics: END init (7 buttons)
psm0: found Synaptics Touchpad
psm: SET_RESOLUTION (2) 00fa
psm: SET_SAMPLING_RATE (100) 00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 02 64
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Synaptics Touchpad, device ID 0-00, 7 buttons
psm0: config:00004000, flags:00000008, packet size:6
psm0: syncmask:c0, syncbits:00

------

Clicking the three hardware buttons (one by one, in order) produces this:
psm0: lost interrupt?
psmintr: 80 00 00 c2 01 00
psmintr: 80 00 00 c0 00 00
last message repeated 12 times
psmintr: 80 00 00 c2 00 00
psmintr: 80 00 00 c0 00 00
last message repeated 79 times
psmintr: 80 00 00 c2 02 00
psmintr: 80 00 00 c0 00 00
last message repeated 15 times
psmintr: 80 00 00 c2 00 00
psmintr: 80 00 00 c0 00 00
last message repeated 79 times
psmintr: 80 00 00 c2 00 01
psmintr: 80 00 00 c0 00 00
last message repeated 8 times
psmintr: 80 00 00 c2 00 00
psmintr: 80 00 00 c0 00 00

----

Even not touching the touchpad, button or trackpoint produces a lot of psm0: lost interrupt?

Even the keyboard starts acting funny, and eventually the trackpoint/touchpad stops functioning altogether, with the following messages:
psmintr: out of sync (0000 != 0080) 845 cmds since last error.
psmintr: discard a byte (1)
psmintr: b4 80 00 00 c0 00
psmintr: 00 84 18 00 c4 fe
psmintr: out of sync (0000 != 0080) 0 cmds since last error.
psmintr: reset the mouse.
psm0: current command byte: 0047 (reinitialize).
psm: DISABLE_DEV return code:00fa
psm0: failed to reset the aux device.
psm0: the aux device has gone! (reinitialize).
Comment 75 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-01 18:59:08 UTC
Created attachment 175339 [details]
extbuttons.diff

Fix for synaptics clickpad/extended buttons coexistence
Comment 76 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-01 19:22:34 UTC
(In reply to Jakob Alvermark from comment #74)
> I'm 100% sure, but I think it is synaptics.

>/boot/loader.conf has:
>hw.psm.synaptics_support=1
>hw.psm.trackpoint_support=1
-------------
> psm0: model Synaptics Touchpad, device ID 0-00, 7 buttons

It is certainly Synaptics.

Could you try attached patch - extbuttons.diff? I made extended buttons support codepath like pre-r306355.

> Even not touching the touchpad, button or trackpoint produces a lot of psm0: lost interrupt?

That is normal for mobile devices. They do not produce interrupts while inactive to reduce number of driver wakeups and power consumption then. Just ignore "lost interrupt" messages.

> Even the keyboard starts acting funny, and eventually the trackpoint/touchpad stops functioning altogether, with the following messages:
> psmintr: out of sync (0000 != 0080) 845 cmds since last error.
> psmintr: discard a byte (1)
> psmintr: b4 80 00 00 c0 00
> psmintr: 00 84 18 00 c4 fe
> psmintr: out of sync (0000 != 0080) 0 cmds since last error.
> psmintr: reset the mouse.

That is bad. You are really lost sync here - received packet is shifted by 1 byte. I cant help you in that case and have no clues. My code works after 6-bytes has been assembled in one packet. Did it happen before r306355?
Comment 77 Jakob Alvermark 2016-10-02 10:04:15 UTC
(In reply to Vladimir Kondratyev from comment #76)

> Could you try attached patch - extbuttons.diff? I made extended buttons
> support codepath like pre-r306355.

Yes, this restores the previous behavior, i.e. the buttons work again.

One other thing I would like to change though, setting hw.psm.synaptics.touchpad_off=1 disables the touchpad/clickpad as expected, but it also turns on the buttons.
This was also the case pre-r306355.
I almost exclusively use the trackpoint, so I would like to be able to turn the touchpad off, but keep the buttons working.



> > Even the keyboard starts acting funny, and eventually the trackpoint/touchpad stops functioning altogether, with the following messages:
> > psmintr: out of sync (0000 != 0080) 845 cmds since last error.
> > psmintr: discard a byte (1)
> > psmintr: b4 80 00 00 c0 00
> > psmintr: 00 84 18 00 c4 fe
> > psmintr: out of sync (0000 != 0080) 0 cmds since last error.
> > psmintr: reset the mouse.
> 
> That is bad. You are really lost sync here - received packet is shifted by 1
> byte. I cant help you in that case and have no clues. My code works after
> 6-bytes has been assembled in one packet. Did it happen before r306355?

Never had this problem before. I have been using this hardware for months, tracking HEAD. It seems to work now, with the patch applied and no debug on. I'll keep running it with this patch and see what happens.
Comment 78 Vladimir Kondratyev freebsd_committer freebsd_triage 2016-10-02 12:29:37 UTC
(In reply to Jakob Alvermark from comment #77)

> Yes, this restores the previous behavior, i.e. the buttons work again.

That is nice!

> One other thing I would like to change though, setting
> hw.psm.synaptics.touchpad_off=1 disables the touchpad/clickpad
> as expected, but it also turns on the buttons.
> This was also the case pre-r306355.
> I almost exclusively use the trackpoint, so I would like to be
> able to turn the touchpad off, but keep the buttons working.

Try following hack:
# sysctl hw.psm.synaptics.min_pressure=255

> Never had this problem before. I have been using this hardware for months,
> tracking HEAD. It seems to work now, with the patch applied and no debug on.
> I'll keep running it with this patch and see what happens.

psm driver reinitializes touchpad within few seconds if sync loss has been detected. So it is possible that you just did not notice this.
Comment 79 Jakob Alvermark 2016-10-02 13:14:40 UTC
(In reply to Vladimir Kondratyev from comment #78)
> (In reply to Jakob Alvermark from comment #77)
> 
> > Yes, this restores the previous behavior, i.e. the buttons work again.
> 
> That is nice!

Could we get this committed? It would be a POLA violation for ThinkPad users if we don't.


> > One other thing I would like to change though, setting
> > hw.psm.synaptics.touchpad_off=1 disables the touchpad/clickpad
> > as expected, but it also turns on the buttons.
> > This was also the case pre-r306355.
> > I almost exclusively use the trackpoint, so I would like to be
> > able to turn the touchpad off, but keep the buttons working.
> 
> Try following hack:
> # sysctl hw.psm.synaptics.min_pressure=255

That actually does what I want, thanks for the hint!


> > Never had this problem before. I have been using this hardware for months,
> > tracking HEAD. It seems to work now, with the patch applied and no debug on.
> > I'll keep running it with this patch and see what happens.
> 
> psm driver reinitializes touchpad within few seconds if sync loss has been
> detected. So it is possible that you just did not notice this.

I am quite sure I would have noticed if the mouse pointer would stop moving until I rebooted the machine.
Comment 80 commit-hook freebsd_committer freebsd_triage 2016-10-06 01:01:20 UTC
A commit references this bug:

Author: gonzo
Date: Thu Oct  6 01:01:00 UTC 2016
New revision: 306746
URL: https://svnweb.freebsd.org/changeset/base/306746

Log:
  Fix extended buttons support on synaptic clickpad

  Fix regression introduced by r306355 on synaptic clickpads with
  extended buttons (buttons stopped working)

  PR:		205690
  Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>

Changes:
  head/sys/dev/atkbdc/psm.c
Comment 81 commit-hook freebsd_committer freebsd_triage 2016-10-18 20:18:46 UTC
A commit references this bug:

Author: gonzo
Date: Tue Oct 18 20:17:57 UTC 2016
New revision: 307576
URL: https://svnweb.freebsd.org/changeset/base/307576

Log:
  MFC r306355, r306474, r306746:

  r306355:
  Add Elantech trackpad support

  Elantech trackpads are found in some laptops like the Asus UX31E. They
  are "synaptics compatible" but use a slightly different protocol.

  Elantech hardware support is not enabled by default and just like
  Synaptic or TrackPoint devices it should be enabled by setting
  tunable, in this case hw.psm.elantech_support, to non-zero value

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

  r306474:
  Replace explicit TUNABLE_INT to sysctl with CTLFLAG_TUN

  - Replace tunables-only hw.psm.synaptics_support, hw.psm.trackpoint_support,
      and hw.psm.elantech_support with respective sysctls declared with
      CTLFLAG_TUN. It simplifies checking them in userland, also makes them
      easier to get discovered by user
  - Get rid of debug.psm.loglevel and hw.psm.tap_enabled TUNABLE_INT
      declaration by adding CTLFLAG_TUN to read/write sysctls that were
      already declared for these tunables.

  Suggested by: jhb

  r306746:
  Fix extended buttons support on synaptic clickpad

  Fix regression introduced by r306355 on synaptic clickpads with
  extended buttons (buttons stopped working)

  PR:		205690
  Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>

Changes:
_U  stable/11/
  stable/11/sys/dev/atkbdc/psm.c
  stable/11/sys/sys/mouse.h
Comment 82 commit-hook freebsd_committer freebsd_triage 2016-10-18 20:18:53 UTC
A commit references this bug:

Author: gonzo
Date: Tue Oct 18 20:17:57 UTC 2016
New revision: 307576
URL: https://svnweb.freebsd.org/changeset/base/307576

Log:
  MFC r306355, r306474, r306746:

  r306355:
  Add Elantech trackpad support

  Elantech trackpads are found in some laptops like the Asus UX31E. They
  are "synaptics compatible" but use a slightly different protocol.

  Elantech hardware support is not enabled by default and just like
  Synaptic or TrackPoint devices it should be enabled by setting
  tunable, in this case hw.psm.elantech_support, to non-zero value

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

  r306474:
  Replace explicit TUNABLE_INT to sysctl with CTLFLAG_TUN

  - Replace tunables-only hw.psm.synaptics_support, hw.psm.trackpoint_support,
      and hw.psm.elantech_support with respective sysctls declared with
      CTLFLAG_TUN. It simplifies checking them in userland, also makes them
      easier to get discovered by user
  - Get rid of debug.psm.loglevel and hw.psm.tap_enabled TUNABLE_INT
      declaration by adding CTLFLAG_TUN to read/write sysctls that were
      already declared for these tunables.

  Suggested by: jhb

  r306746:
  Fix extended buttons support on synaptic clickpad

  Fix regression introduced by r306355 on synaptic clickpads with
  extended buttons (buttons stopped working)

  PR:		205690
  Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>

Changes:
_U  stable/11/
  stable/11/sys/dev/atkbdc/psm.c
  stable/11/sys/sys/mouse.h
Comment 83 commit-hook freebsd_committer freebsd_triage 2016-10-18 22:24:20 UTC
A commit references this bug:

Author: gonzo
Date: Tue Oct 18 22:24:03 UTC 2016
New revision: 307579
URL: https://svnweb.freebsd.org/changeset/base/307579

Log:
  MFC r306356:

  Add Elantech trackpad to the list of known models

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

Changes:
_U  stable/11/
  stable/11/usr.sbin/moused/moused.c
Comment 84 commit-hook freebsd_committer freebsd_triage 2016-10-18 22:27:27 UTC
A commit references this bug:

Author: gonzo
Date: Tue Oct 18 22:26:38 UTC 2016
New revision: 307580
URL: https://svnweb.freebsd.org/changeset/base/307580

Log:
  MFC r306357:

  Document hw.psm.elantech_support in psm(4)

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

Changes:
_U  stable/11/
  stable/11/share/man/man4/psm.4