Bug 232040 - wmt driver fails to attach to Synaptics Touchscreen
Summary: wmt driver fails to attach to Synaptics Touchscreen
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Some People
Assignee: Vladimir Kondratyev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-07 18:11 UTC by Sergei Akhmatdinov
Modified: 2019-11-24 12:16 UTC (History)
3 users (show)

See Also:


Attachments
usbconfig -d ugen0.2 dump_all_desc (1.92 KB, text/plain)
2019-04-23 05:51 UTC, Kubilay Kocak
no flags Details
Output of usbhid-dump (12.28 KB, text/plain)
2019-10-09 18:36 UTC, Sergei Akhmatdinov
no flags Details
Treat_padding_as_data_for_CCMax.patch (539 bytes, patch)
2019-11-11 10:27 UTC, Vladimir Kondratyev
no flags Details | Diff
Output of evemu-record (3.37 KB, text/plain)
2019-11-18 19:10 UTC, Sergei Akhmatdinov
no flags Details
Fix_report_descriptor.patch (18.75 KB, patch)
2019-11-24 12:05 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 Sergei Akhmatdinov 2018-10-07 18:11:24 UTC
I have a Lenovo YOGA 12 Thinkpad with a Synaptics Touchscreen. 

It gets detected as 

ugen0.2: <SYNAPTICS Synaptics Touch Digitizer V04> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (400mA)

by usbconfig and I get a corresponding /dev/uhid0 device.

usbconfig -d ugen0.2 dump_all_desc:
https://ghostbin.com/paste/3fq7o

I can get the touchscreen working through webcamd, but the touch screen has issues detecting ButtonRelease when configured that way.

Trying to hook /dev/uhid0 up as a mouse through xorg.conf gives me a segfault when launching X.

I also have a usb_quirk setup to make the touchscreen get ignored by UMS, since moused likes to attach itself to it every time in the console. It does not seem to function as ums0, however.

Synaptics driver doesn't work with it either.
Comment 1 Sergei Akhmatdinov 2018-10-07 18:16:25 UTC
Forgot to mention that I am tracking head, updated world and kernel today.
Comment 2 Vladimir Kondratyev freebsd_committer 2018-10-09 20:52:34 UTC
Hi Sergei,

Could you attach HID descriptor of your touchscreen.

usbhid-dump (sysutils/usbhid-dump) can help you obtain it.
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2019-04-23 05:51:11 UTC
Created attachment 203907 [details]
usbconfig -d ugen0.2 dump_all_desc

Attach output of `usbconfig -d ugen0.2 dump_all_desc` mentioned in comment 0 just in case pastebin goes away.

@Vladimir Is this sufficient information or is usbhid-dump output still needed?
Comment 4 Vladimir Kondratyev freebsd_committer 2019-04-23 12:05:02 UTC
(In reply to Kubilay Kocak from comment #3)
> @Vladimir Is this sufficient information or is usbhid-dump output still needed?

usbhid-dump output is still needed. Unlike mices and keyboards, touchscreens do not have boot protocol records in USB interface descriptor so their detection is based on content of HID descriptor.
Comment 5 Sergei Akhmatdinov 2019-10-09 18:36:50 UTC
Created attachment 208210 [details]
Output of usbhid-dump

My apologies for not responding to this bug sooner.

Please find the output of usbhid-dump attached. The device is now detected as ugen0.3, I was not sure which descriptor corresponds to the device itself.
Comment 6 Vladimir Kondratyev freebsd_committer 2019-11-11 10:26:14 UTC
(In reply to Sergei Akhmatdinov from comment #5)
HID report descriptor appeared to be broken. It declares 'Contact Count Maximum' as padding bits:

0x85, 0x08,        //   Report ID (8)
0x09, 0x55,        //   Usage (0x55)
0xB1, 0x03,        //   Feature (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)

Try the attached patch. It is a quick and dirty hack, not a real solution. Right way is to substitute broken descriptor with fixed one, but wmt(4) driver can not do that yet.
Comment 7 Vladimir Kondratyev freebsd_committer 2019-11-11 10:27:44 UTC
Created attachment 209051 [details]
Treat_padding_as_data_for_CCMax.patch
Comment 8 Sergei Akhmatdinov 2019-11-13 15:00:29 UTC
(In reply to Vladimir Kondratyev from comment #6)

Thank you, Vladimir.

The patch seems to work, wmt attaches now:

# dmesg | grep wmt
wmt0 on uhub1
wmt0: <SYNAPTICS Synaptics Touch Digitizer V04, class 0/0, rev 2.00/0.05, addr 2> on usbus0
wmt0: 15 contacts and []. Report range [0:0] - [2786:1579]
wmt0: 10 feature report contactsugen1.2: <vendor 0x8087 product 0x8001> at usbus1
wmt0: at uhub1, port 5, addr 2 (disconnected)
wmt0: detached
wmt0 on uhub1
wmt0: <SYNAPTICS Synaptics Touch Digitizer V04, class 0/0, rev 2.00/0.05, addr 5> on usbus0
wmt0: 15 contacts and []. Report range [0:0] - [2786:1579]
wmt0: 10 feature report contacts

I seem to get a device as /dev/input/event0. 

However, X fails to make use of it. I do not see anything mention /dev/input/event0 in Xorg.0.log. xf86-input-evdev and xf86-input-libinput are both installed.

Libinput seems to see the device, however:
# libinput list-devices
Device:           SYNAPTICS Synaptics Touch Digitizer V04, class 0/0, rev 2.00/0.05, addr 5
Kernel:           /dev/input/event0
Group:            1
Seat:             seat0, default
Size:             279x158mm
Capabilities:     touch
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      n/a
Nat.scrolling:    n/a
Middle emulation: n/a
Calibration:      identity matrix
Scroll methods:   none
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   n/a
Rotation:         n/a

I don't know if libinput is interfering or not. 
I have made an entry in Xorg.conf.d to try and force evdev, but Xorg seems to ignore it.

# 40-touch.conf
Section "InputDevice"
        Identifier      "Touchscreen"
        Driver          "evdev"
        Option          "Device" "/dev/input/event0"
EndSection
Comment 9 Vladimir Kondratyev freebsd_committer 2019-11-13 22:02:33 UTC
(In reply to Sergei Akhmatdinov from comment #8)
You should start with evemu-record (devel/evemu) and find out if your device produces any events
Comment 10 Sergei Akhmatdinov 2019-11-18 19:10:46 UTC
Created attachment 209233 [details]
Output of evemu-record

Seems like I am getting events, here is the output of 

# evemu-record /dev/input/event0

after touching the screen once and releasing.
Comment 11 Vladimir Kondratyev freebsd_committer 2019-11-24 12:05:32 UTC
Created attachment 209381 [details]
Fix_report_descriptor.patch
Comment 12 Vladimir Kondratyev freebsd_committer 2019-11-24 12:16:23 UTC
(In reply to Sergei Akhmatdinov from comment #10)
> Seems like I am getting events, here is the output of 
> # evemu-record /dev/input/event0
> after touching the screen once and releasing.

Events look good for single touch. So you need to configure Xorg properly.
On one of my laptops I found following line in "ServerLayout" section:

InputDevice    "TouchScreen" "SendCoreEvents"

May be that is what you need.

The other option is to use evdev-awared input device autoconfiguration backend.

See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196678

P.S. I updated patch with proper fix for your touchscreen. Please test it after reverting of previous one.