# Touchscreen Does Not Work After Sleep/Resume



## blackhaz (Sep 2, 2018)

Hi All,

Running FreeBSD 11.2-RELEASE-p2 on ThinkPad X1 Yoga.

rc.conf:

```
webcamd_enable="YES"
webcamd_0_flags="-N Chicony-Electronics-Co--Ltd--Integrated-Camera"
webcamd_1_flags="-N Wacom-Co--Ltd--Pen-and-multitouch-sensor"
```

xorg.conf:

```
Section "InputDevice"
        Identifier      "Touchscreen"
        Driver          "evdev"
        Option          "Device" "/dev/input/event0"
EndSection

Section "InputDevice"
        Identifier      "TouchscreenPen"
        Driver          "evdev"
        Option          "Device" "/dev/input/event1"
EndSection

Section "ServerLayout"
        Identifier      "MyLayout"
        InputDevice     "Touchscreen"
    InputDevice    "TouchscreenPen"
EndSection
```

Touchscreen is for finger events, TouchscreenPen is for pen events. Everything works great until I sleep and resume the laptop. After that, Xorg does not react on touchscreen events, although evemu-record shows both event0 and event1 as available, and also shows events when I touch screen. Does this look like a bug?


----------



## blackhaz (Sep 21, 2018)

I'll just update this thread. I've found that after sleep/resume xinput reports both touchscreen devices as disabled. If I enable them back they're back working, however, it looks like coordinate transformation matrices are wrong. As if all the device settings are dropped at suspend. Still trying to understand what happens...


----------



## tingo (Sep 25, 2018)

FWIW, "resume" (from suspend) is often different from "initialize", in my experience. But - all devices that require re-initialization after resume from suspend should be fixed, IMHO. So it would be good if  you can figure this out.


----------



## Sensucht94 (Sep 25, 2018)

I suggest you to give a shot to the new wmt(4) driver, coupled with evdev in place of `webcamd`


----------



## blackhaz (Sep 25, 2018)

I beg my pardon for ignorance but I couldn't find any configuration examples of wmt. Are there any HOWTOs?


----------



## puretone (Sep 25, 2018)

blackhaz said:


> I beg my pardon for ignorance but I couldn't find any configuration examples of wmt. Are there any HOWTOs?



Have you tried:
https://unrelenting.technology/articles/freebsd-on-the-thinkpad-x240 ?
or
https://github.com/wulf7/libudev-devd


----------



## blackhaz (Sep 25, 2018)

I don't see any wmt-related instructions there. Besides, wmt man page says it only supports touchscreens. My X1 Yoga has a pen, and I mostly use pen. (Fingerprints on the screen kinda suck.)


----------



## puretone (Sep 26, 2018)

blackhaz said:


> I don't see any wmt-related instructions there. Besides, wmt man page says it only supports touchscreens. My X1 Yoga has a pen, and I mostly use pen.



(this might be a bit dated now)
To enable psm(4) evdev support one should:
1. Add `device evdev` and `options EVDEV_SUPPORT` to kernel config file
2. Add hw.psm.elantech_support=1 or hw.psm.synaptics_support=1 to
   /boot/loader.conf for activation of absolute mode on touchpads
3. Add kern.evdev.rcpt_mask=12 to /etc/sysctl.conf to enable psm event
   sourcing and disable sysmouse

&


> the new wmt(4) kernel driver supports the touchscreen perfectly, without that issue!! Also, libinput  is better than evdev in Xorg.


Scroll down https://unrelenting.technology/articles/freebsd-on-the-thinkpad-x240 a bit to the section on multi-touch, wmt() suggests there's not much to configure. You'll have put on your life-preserver here and experiment a bit. I'll try it for myself on an older laptop i've got lying that had a pesky misbehaving touchscreen that didn't want to remain attached to anything...perhaps blowing the dust out of if & forcing it out of its induced retirement will persuade it to behave. wmt.ko wasn't around back in 10.(n)-RELEASE days.




blackhaz said:


> (Fingerprints on the screen kinda suck.)


Same ^^^ here, which is why I have turned off/disabled the touchscreen altogether; plus touchscreens tend to be battery power-hogs. Smudges on my phone irritate enough as is.


----------



## Sensucht94 (Sep 26, 2018)

blackhaz said:


> I beg my pardon for ignorance but I couldn't find any configuration examples of wmt. Are there any HOWTOs?



If it's supported it should just work providing the correct Option 'Device' has been path has been specified in the xorg conf together with the evdev Driver. Is your Touchscreen HID -compliant?


----------



## blackhaz (Sep 30, 2018)

Hi guys, 

Sorry for the delay. Got swamped with other stuff. I've tried disabling webcamd, however, it looks like the wmt driver does not create /dev/input/eventX device files, at least once webcamd is disabled, evemu-record doesn't see the event0 and event1 devices which are normally visible when the webcamd is enabled. From the wmt manual:

"wmt creates a pseudo-device file, /dev/input/eventX which presents the multi-touch device as an input event device." 

And yes, wmt.ko is loaded. In my dmesg I see this right after boot:

wmt0 on uhub0
wmt0: <Multitouch> on usbus0
wmt0: 16 contacts and [C]. Report range [0:0] - [12380:6964]
wmt0: at uhub0, port 10, addr 5 (disconnected)
wmt0: detached


----------



## ikbendeman (Nov 1, 2018)

Are you certain this isn't an issue with powerd or you video driver? Do you have any syslogs or XOrg logs that may indicate the nature of the problem? If you startx from tty rather than using a graphical login, it sometimes makes it easier as you can CTRL+ALT+F[n] back and ScrollLk to see if it gives indication of where the problem starts; you could always serial or ssh in, as well, to ensure you don't lose this information or have to do a hard-shutdown.


----------



## blackhaz (Nov 1, 2018)

I don't see anything unusual in the system logs or Xorg logs. I am always starting X from tty and don't see anything unusual. I don't know what I am looking for though. When I sleep, resume, then quit the X server and start it again, the touchscreen and pen work fine until the next sleep.


----------



## mvivirito (Sep 2, 2019)

blackhaz said:


> I don't see anything unusual in the system logs or Xorg logs. I am always starting X from tty and don't see anything unusual. I don't know what I am looking for though. When I sleep, resume, then quit the X server and start it again, the touchscreen and pen work fine until the next sleep.


I am experiencing the same issue. Has any progress been made in this regard. I would love to help out. I am on a 1st gen thinkpad x1 yoga running release 12.0 p10


----------

