Bug 204967

Summary: Elantech Touchpad edge scroll shifted left since kernel 5.3.*
Product: Drivers Reporter: Paul (paul.up7)
Component: Input DevicesAssignee: drivers_input-devices
Status: NEW ---    
Severity: normal CC: arr8, glaubersm, gpohl+kbz, kernel, krivorot.oleg, m.lukacka, straube.linux
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 5.3.1 Subsystem:
Regression: No Bisected commit-id:
Attachments: log clippings, comparison
illustrated photo
tar archive with logs
dmesg from 5.4-rc3
bisect log

Description Paul 2019-09-23 18:15:17 UTC
Created attachment 285117 [details]
log clippings, comparison

Notebook: E1-571G/EA50_HC_HR

Elantech Touchpad edge scroll shifted left since kernel 5.3.* by 60% of the total area. Checked out libinput list-devices output between 5.2.14 and 5.3.1 kernels and see different sizes of touchpad area. 5.3.1 output gave size 40x17mm instead of 81x34mm (5.2.14).

Please, let me know if you need more additional information.
Comment 1 Paul 2019-09-23 18:27:47 UTC
Created attachment 285119 [details]
illustrated photo
Comment 2 Paul 2019-10-07 03:38:56 UTC
Created attachment 285373 [details]
tar archive with logs

Since kernel 5.3.4 was released - nothing changed.
Additional info:
libinput 1.14.1
linux-firmware-20190923

In attachment tar archive with logs: dmesg, xorg, hw spec & etc.
Comment 3 Michael Straube 2019-10-18 19:07:14 UTC
Same issue on Lenovo ideapad 110s since 5.3, still present in 5.4-rc3.

Sizes reported by `libinput list-devices`

5.2
Size:             79x34mm

5.4-rc3
Size:             39x17mm

Looks like this was introduced with following commit, since that's the first bad commit I got from git bisect.
 
37548659bb22 ("Input: elantech - query the min/max information beforehand too")
Comment 4 Michael Straube 2019-10-18 19:09:14 UTC
Created attachment 285551 [details]
dmesg from 5.4-rc3
Comment 5 Michael Straube 2019-10-18 19:10:17 UTC
Created attachment 285553 [details]
bisect log
Comment 6 galago3000 2019-11-04 09:05:10 UTC
I can confirm this too on an Acer Aspire.
Comment 7 oleg_krv 2020-01-19 21:39:44 UTC
I can confirm this too on Lenovo G580
Comment 8 oleg_krv 2020-01-19 22:12:08 UTC
libinput list-devices:

Device:           ETPS/2 Elantech Touchpad
Kernel:           /dev/input/event5
Group:            10
Seat:             seat0, default
Size:             47x20mm
Capabilities:     pointer 
Tap-to-click:     disabled
Tap-and-drag:     enabled
Tap drag lock:    disabled
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   *two-finger edge 
Click methods:    none
Disable-w-typing: enabled
Accel profiles:   none
Rotation:         n/a

dmesg | grep elantech:

[    8.427778] psmouse serio1: elantech: assuming hardware version 3 (with firmware version 0x450f02)
[    8.453827] psmouse serio1: elantech: Synaptics capabilities query result 0x78, 0x17, 0x0b.
[    8.480052] psmouse serio1: elantech: Elan sample query result 04, 3d, 85

xinput list-props "ETPS/2 Elantech Touchpad":

Device 'ETPS/2 Elantech Touchpad':
	Device Enabled (163):	1
	Coordinate Transformation Matrix (165):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
	Device Accel Profile (292):	1
	Device Accel Constant Deceleration (293):	2.500000
	Device Accel Adaptive Deceleration (294):	1.000000
	Device Accel Velocity Scaling (295):	12.500000
	Synaptics Edges (296):	58, 1412, 34, 596
	Synaptics Finger (297):	1, 1, 0
	Synaptics Tap Time (298):	180
	Synaptics Tap Move (299):	70
	Synaptics Tap Durations (300):	180, 180, 100
	Synaptics ClickPad (301):	0
	Synaptics Middle Button Timeout (302):	75
	Synaptics Two-Finger Pressure (303):	282
	Synaptics Two-Finger Width (304):	7
	Synaptics Scrolling Distance (305):	31, 31
	Synaptics Edge Scrolling (306):	0, 0, 0
	Synaptics Two-Finger Scrolling (307):	1, 1
	Synaptics Move Speed (308):	1.000000, 1.750000, 0.125078, 0.000000
	Synaptics Off (309):	0
	Synaptics Locked Drags (310):	0
	Synaptics Locked Drags Timeout (311):	5000
	Synaptics Tap Action (312):	2, 3, 0, 0, 1, 3, 2
	Synaptics Click Action (313):	1, 1, 0
	Synaptics Circular Scrolling (314):	0
	Synaptics Circular Scrolling Distance (315):	0.100000
	Synaptics Circular Scrolling Trigger (316):	0
	Synaptics Circular Pad (317):	0
	Synaptics Palm Detection (318):	0
	Synaptics Palm Dimensions (319):	10, 200
	Synaptics Coasting Speed (320):	20.000000, 50.000000
	Synaptics Pressure Motion (321):	30, 160
	Synaptics Pressure Motion Factor (322):	1.000000, 1.000000
	Synaptics Resolution Detect (323):	1
	Synaptics Grab Event Device (324):	0
	Synaptics Gestures (325):	1
	Synaptics Capabilities (326):	1, 0, 1, 1, 1, 1, 1
	Synaptics Pad Resolution (327):	31, 31
	Synaptics Area (328):	0, 0, 0, 0
	Synaptics Noise Cancellation (329):	7, 7
	Device Product ID (289):	2, 14
	Device Node (288):	"/dev/input/event5"
Comment 9 oleg_krv 2020-01-20 16:51:59 UTC
libinput list-devices (kernel 5.0.0-37-generic):
Device:           ETPS/2 Elantech Touchpad
Kernel:           /dev/input/event5
Group:            10
Seat:             seat0, default
Size:             95x41mm
Capabilities:     pointer 
Tap-to-click:     disabled
Tap-and-drag:     enabled
Tap drag lock:    disabled
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   *two-finger edge 
Click methods:    none
Disable-w-typing: enabled
Accel profiles:   none
Rotation:         n/a

difference between the core 5.3 * and 5.0. *:
5.0.*: Size:             95x41mm
5.3.*: Size:             47x20mm

options psmouse
elantech_smbus=0 synaptics_intertouch=0
do not help
Comment 10 oleg_krv 2020-01-22 22:43:06 UTC
testing kernel 5.4.13 - this bug is present
Comment 11 oleg_krv 2020-02-14 00:32:22 UTC
file elantech.c

function :
elantech_query_info

change from:

case 3:
  if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
			return -EINVAL;
  info->x_max = (0x0f & param[0]) << 8 | param[1];
  info->y_max = (0xf0 & param[0]) << 4 | param[2];

to:

case 3:
  if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
			return -EINVAL;

  info->x_max = ((0x0f & param[0]) << 8 | param[1]) * 2;
  info->y_max = ((0xf0 & param[0]) << 4 | param[2]) * 2;

and recompile module psmouse returned normal device functionality

I could not find the cause of the error, in the old version (kernel 5.0) there is no multiplication and everything works fine.
Comment 12 oleg_krv 2020-02-14 08:14:01 UTC
new driwer kernel 5.3: cat /var/log/Xorg.0.log | grep synaptics
    54.102] (II) synaptics: ETPS/2 Elantech Touchpad: ignoring touch events for semi-multitouch device
[    54.102] (--) synaptics: ETPS/2 Elantech Touchpad: x-axis range 0 - 1470 (res 31)
[    54.102] (--) synaptics: ETPS/2 Elantech Touchpad: y-axis range 0 - 630 (res 31)
[    54.102] (--) synaptics: ETPS/2 Elantech Touchpad: pressure range 0 - 255
[    54.102] (--) synaptics: ETPS/2 Elantech Touchpad: finger width range 0 - 15
[    54.102] (--) synaptics: ETPS/2 Elantech Touchpad: buttons: left right double triple
[    54.102] (--) synaptics: ETPS/2 Elantech Touchpad: Vendor 0x2 Product 0xe
[    54.102] (--) synaptics: ETPS/2 Elantech Touchpad: touchpad found
[    54.134] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) MinSpeed is now constant deceleration 2.5
[    54.134] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) MaxSpeed is now 1.75
[    54.134] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) AccelFactor is now 0.125
[    54.134] (--) synaptics: ETPS/2 Elantech Touchpad: touchpad found


--------------
old kernel 5.0:
[ 16938.135] (II) synaptics: ETPS/2 Elantech Touchpad: ignoring touch events for semi-multitouch device
[ 16938.135] (--) synaptics: ETPS/2 Elantech Touchpad: x-axis range 0 - 2940 (res 31)
[ 16938.135] (--) synaptics: ETPS/2 Elantech Touchpad: y-axis range 0 - 1260 (res 31)
[ 16938.135] (--) synaptics: ETPS/2 Elantech Touchpad: pressure range 0 - 255
[ 16938.135] (--) synaptics: ETPS/2 Elantech Touchpad: finger width range 0 - 15
[ 16938.135] (--) synaptics: ETPS/2 Elantech Touchpad: buttons: left right double triple
[ 16938.135] (--) synaptics: ETPS/2 Elantech Touchpad: Vendor 0x2 Product 0xe
[ 16938.135] (--) synaptics: ETPS/2 Elantech Touchpad: touchpad found
[ 16938.175] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) MinSpeed is now constant deceleration 2.5
[ 16938.175] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) MaxSpeed is now 1.75
[ 16938.175] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) AccelFactor is now 0.063
[ 16938.175] (--) synaptics: ETPS/2 Elantech Touchpad: touchpad found
Comment 13 kernel@bernd-stark.de 2020-02-19 23:23:03 UTC
Hi there, the same commit mentioned above causes the problem I encountered on my good old Samsung RF710 with ETPS/2 Elantech Touchpad HW version 3:

Major symptom:
expected behavior: tapping at any position on the touchpad results in a left button click

observed behavior: 
- tap in left half --> left button click (OK)
- tap in upper right quadrant --> middle button click (not OK)
- tap in lower right quadrant --> right button click (not OK)

Minor symptom: Very high mouse cursor speed (factor 2 of normal speed)

Here is what I found out:
- By this commit (37548659bb22) the query for x_max / y_max was moved from elantech_set_range() to elantech_query_info()

- elantech_query_info() is executed earlier than elantech_set_range() in the driver init sequence, especially before setting the touchpad to absolute mode (elantech_set_absolute_mode()).

- I inserted some debug code that queries x_min/x_max and dumps it (values increase by factor 2):

[   47.395457] psmouse serio1: elantech: assuming hardware version 3 (with firmware version 0x450f00)
[   47.410731] psmouse serio1: elantech: Synaptics capabilities query result 0x08, 0x15, 0x0c.
[   47.426318] psmouse serio1: elantech: Elan sample query result 09, 05, 00
...
[   47.472421] psmouse serio1: elantech: debug_xy_max() - before set_absolute_mode(): x_max: 1254, y_max: 660
[   47.564383] psmouse serio1: elantech: debug_xy_max() - after set_absolute_mode():  x_max: 2508, y_max: 1320
...
[   47.611757] input: ETPS/2 Elantech Touchpad as /devices/platform/i8042/serio1/input/input16


Conclusion: Querying of x_min / x_max has to be done AFTER setting the touchpad to absolute mode.

Just reverting this single commit would fix the problem for my Samsung RF710 / ETPS/2 Elantech Touchpad and probably for most of you, but maybe Dimitry will find a solution retaining the intention of the commit in question (forward min/max to SMBus).

If I can help testing, just contact me.
Comment 14 kernel@bernd-stark.de 2020-02-27 18:56:40 UTC
> 
> Conclusion: Querying of x_min / x_max has to be done AFTER setting the
> touchpad to absolute mode.
> 

Sorry, "x_max / y_max" is correct.
Comment 15 Marian Lukacka 2021-01-06 15:17:26 UTC
Hi folks,
I have successfully got rid of this issue on my Acer Aspire using
touchpad-edge-detector from libevdev to create /etc/udev/hwdb.d/61-evdev-local.hwdb with correct size of the touchpad...
Comment 16 galago3000 2021-01-06 21:47:00 UTC
(In reply to Marian Lukacka from comment #15)

I can confirm that using touchpad-edge-detector fixes the issue for me too.
Thanks Marian!
Comment 17 gpohl 2021-01-19 14:54:20 UTC
I have the same issue on a hw version 3 pad, though only y_max is affected in my case. Another workaround is to reload the driver via 

\# echo -n rescan > /sys/devices/i8042/serio2/drvctl" 

(replace serio2 as applicable)
Comment 18 gpohl 2021-01-20 01:08:54 UTC
(In reply to gpohl from comment #17)

Uh, sorry, I meant /sys/devices/**platform**/i8042/serio2/drvctl

One advantage of doing it this way is that it makes the elantech driver actually get the correct y_min,y_max,... values, whereas touchpad-edge-detector only adjusts what evdev thinks is the edge of the pad, so that evdev still reports negative values for part of the pad. This is a nuisance because with synaptics parameters such as TopEdge can't be negative.
Comment 19 Marian Lukacka 2021-01-26 16:10:11 UTC
(In reply to gpohl from comment #18)

For me, this method doesn't work. After issuing rescan, driver just switches to two-finger scroll mode...
Comment 20 Patrick Silva 2021-11-25 00:31:32 UTC
Same problem on Arch Linux installed on Lenovo G400S Touch laptop.

$uname -r
5.15.4-arch1-1

$sudo libinput list-devices
Device:           ETPS/2 Elantech Touchpad
Kernel:           /dev/input/event12
Group:            9
Seat:             seat0, default
Size:             39x17mm
Capabilities:     pointer 
Tap-to-click:     disabled
Tap-and-drag:     enabled
Tap drag lock:    disabled
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   *two-finger edge 
Click methods:    none
Disable-w-typing: enabled
Accel profiles:   flat *adaptive
Rotation:         n/a