lördag 28 mars 2015

Laptop touchpad stops working after suspend

The MSI GE60 Laptop has an Elantech touchpad that has always had some problems working in Linux after suspending and resuming the laptop.

Edit: Found some notes. It seems to have worked fine in Fedora 18, but in Fedora 19 after a synaptics driver update (xorg-x11-drv-synaptics-1.7.1-3.fc19.x86_64) it went totally nuts. Edge scrolling stopped working and after suspend/resume, the touchpad notification icon was flashing over the GDM login prompt, alternating with the on and off icon image. The touchpad was also turned off after reboot and couldn't be turned on except for in the Gnome system settings. After a few updates, some of the problems were fixed, except for the problem that it is turned off after suspend/resume.

At least now with Fedora 20, which is currently installed on the laptop, the touchpad always stops working when resuming from suspend, and the hardware button to turn on doesn't affect its state.

It is using the psmouse kernel driver and synaptics in Xorg:

from dmesg:
[    1.961844] psmouse serio1: elantech: assuming hardware version 3 (with firmware version 0x550f00)
[    1.978787] psmouse serio1: elantech: Synaptics capabilities query result 0x79, 0x15, 0x0c.
[    2.064901] input: ETPS/2 Elantech Touchpad as /devices/platform/i8042/serio1/input/input5


from Xorg log:
[    30.565] (II) LoadModule: "synaptics"
[    30.565] (II) Loading /usr/lib64/xorg/modules/input/synaptics_drv.so
[    30.611] (II) Module synaptics: vendor="X.Org Foundation"
[    30.611] (II) Using input driver 'synaptics' for 'ETPS/2 Elantech Touchpad'
[    30.629] (--) synaptics: ETPS/2 Elantech Touchpad: x-axis range 0 - 2356 (res 0)
[    30.629] (--) synaptics: ETPS/2 Elantech Touchpad: y-axis range 0 - 1240 (res 0)
[    30.629] (--) synaptics: ETPS/2 Elantech Touchpad: pressure range 0 - 255
[    30.629] (--) synaptics: ETPS/2 Elantech Touchpad: finger width range 0 - 15
[    30.629] (--) synaptics: ETPS/2 Elantech Touchpad: buttons: left right double triple
[    30.629] (--) synaptics: ETPS/2 Elantech Touchpad: Vendor 0x2 Product 0xe
[    30.629] (--) synaptics: ETPS/2 Elantech Touchpad: touchpad found
[    30.644] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) MinSpeed is now constant deceleration 2.5
[    30.644] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) MaxSpeed is now 1.75
[    30.644] (**) synaptics: ETPS/2 Elantech Touchpad: (accel) AccelFactor is now 0.075



One way to turn the touchpad on again is to use the keyboard to navigate to computer settings (in Gnome) and turn off and on the touchpad. Another way is to reboot the computer.

To make it work with suspend, you can turn off the touchpad before suspending and turn it on afterwards. To do this automatically, create a file at /etc/pm/sleep.d/00-trackpad with the following content:
#!/bin/sh

declare -i ID
ID=`xinput list | grep -Eo 'ouchpad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'`
case "$1" in
  suspend|hibernate)
     xinput disable $ID ;;
  resume|thaw)
    xinput enable $ID ;;
esac
Edit: Don't forget to make the script executable with chmod +x.

There are some examples on the Internet with similar solutions (mostly for Ubuntu). However, they unload and load the psmouse kernel driver. This doesn't work in Fedora, because psmouse is built into the kernel.

To finally fix this, a bug report should be created for the synaptics driver, but it is not always easy to get obscure bugs fixed upstream.