Bug 244079 - QEMU / KVM Q35 USB Tablet (EVTouch) input device not captured by evdev
Summary: QEMU / KVM Q35 USB Tablet (EVTouch) input device not captured by evdev
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.1-STABLE
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-virtualization (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-12 20:25 UTC by John Hartley
Modified: 2020-05-15 01:36 UTC (History)
2 users (show)

See Also:


Attachments
devel/libudev-devd.patch (1.02 KB, patch)
2020-05-14 22:16 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 John Hartley 2020-02-12 20:25:42 UTC
BUG:

The QEMU EvTouch USB Graphics Tablet is not one of devices that is captured and available  via /dev/input/event*

The impact of this is that you cannot get X11 evadev pointer device support to work with FreeBSD 12.1 running on QEMU / KVM / Q35 .

TESTING:

Running FreeBSD 12.1 on:
QEMU / KVM / OVMF / Q35 VM with EvTouch USB Graphics Tablet connected.


Boot shows that devices is connected:


<<DMESG USB REPORT>>

# dmesg | grep USB
uhci0: <Intel 82801I (ICH9) USB controller> port 0xb0a0-0xb0bf irq 16 at device 29.0 on pci0
uhci1: <Intel 82801I (ICH9) USB controller> port 0xb080-0xb09f irq 17 at device 29.1 on pci0
uhci2: <Intel 82801I (ICH9) USB controller> port 0xb060-0xb07f irq 18 at device 29.2 on pci0
ehci0: <Intel 82801I (ICH9) USB 2.0 controller> mem 0xc8b83000-0xc8b83fff irq 19 at device 29.7 on pci0
usbus0: 12Mbps Full Speed USB v1.0
usbus2: usbus1: 12Mbps Full Speed USB v1.0
usbus3: 12Mbps Full Speed USB v1.0
480Mbps High Speed USB v2.0
ugen3.2: <QEMU QEMU USB Keyboard> at usbus3
ukbd0: <QEMU QEMU USB Keyboard, class 0/0, rev 2.00/0.00, addr 2> on usbus3
ugen3.3: <QEMU QEMU USB Mouse> at usbus3
ugen3.4: <QEMU QEMU USB Tablet> at usbus3
ums0: <QEMU QEMU USB Mouse, class 0/0, rev 2.00/0.00, addr 3> on usbus3
uhid0: <QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 4> on usbus3
<<DMESG USB REPORT>>


So QEMU USB Tablet is found and connected to device /dev/uhid0

However it does not appear in set of evdev captured devices


<<EVDEV DEVICE INFO>>

# python3.7 -m evdev.evtest
ID  Device               Name                                Phys                                Uniq
------------------------------------------------------------------------------------------------------------------------------------------
0   /dev/input/event0    System keyboard multiplexer         kbdmux0                                 
1   /dev/input/event1    System mouse                        sysmouse                                
2   /dev/input/event2    AT keyboard                         atkbd0                                  
3   /dev/input/event3    IntelliMouse Explorer               psm0                                    
4   /dev/input/event4    QEMU QEMU USB Keyboard, class 0/0, rev 2.00/0.00, addr 2 ukbd0                               68284-0000:00:1d.7-1
5   /dev/input/event5    QEMU QEMU USB Mouse, class 0/0, rev 2.00/0.00, addr 3 ums0                                89126-0000:00:1d.7-4

Select devices [0-5]:

<<END EVDEV DEVICE INFO>>

NOTE: Kernel build with netmap disabled kernel due to this bug:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241774) 


EXPECTED BEHAVIOUR:

QEMU USB Tablet should also be one of devices captured with input data available via /dev/input/event* device

Please let me know if you need additional testing to help with diagnosis.

I am reporting this as effecting many people as flow through to lack of EvTouch USB support much discussed issues when doing web search. This bug reports potential root cause fix.
Comment 1 Vladimir Kondratyev freebsd_committer 2020-02-16 00:54:11 UTC
uhid(4) does not support evdev now

Try misc/utouch-kmod driver from the ports tree
Comment 2 John Hartley 2020-02-18 07:06:55 UTC
Hi Vladimir,

thank you very much for response.

I have done as suggested:

<<DMESG WITH UTOUCH>>

# dmesg | grep USB
uhci0: <Intel 82801I (ICH9) USB controller> port 0xb0a0-0xb0bf irq 16 at device 29.0 on pci0
uhci1: <Intel 82801I (ICH9) USB controller> port 0xb080-0xb09f irq 17 at device 29.1 on pci0
uhci2: <Intel 82801I (ICH9) USB controller> port 0xb060-0xb07f irq 18 at device 29.2 on pci0
ehci0: <Intel 82801I (ICH9) USB 2.0 controller> mem 0xc8b83000-0xc8b83fff irq 19 at device 29.7 on pci0
usbus0: 12Mbps Full Speed USB v1.0
usbus2: 12Mbps Full Speed USB v1.0
usbus3: 480Mbps High Speed USB v2.0
usbus1: 12Mbps Full Speed USB v1.0
ugen3.2: <QEMU QEMU USB Keyboard> at usbus3
ukbd0: <QEMU QEMU USB Keyboard, class 0/0, rev 2.00/0.00, addr 2> on usbus3
ugen3.3: <QEMU QEMU USB Mouse> at usbus3
ugen3.4: <QEMU QEMU USB Tablet> at usbus3
utouch0: <QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 4> on usbus3
ums0: <QEMU QEMU USB Mouse, class 0/0, rev 2.00/0.00, addr 3> on usbus3

<<END DMESG WITH UTOUCH>>

<<EVTEST>>

# python3.7 -m evdev.evtest
ID  Device               Name                                Phys                                Uniq
------------------------------------------------------------------------------------------------------------------------------------------
0   /dev/input/event0    System keyboard multiplexer         kbdmux0                                 
1   /dev/input/event1    System mouse                        sysmouse                                
2   /dev/input/event2    AT keyboard                         atkbd0                                  
3   /dev/input/event3    IntelliMouse Explorer               psm0                                    
4   /dev/input/event4    QEMU QEMU USB Keyboard, class 0/0, rev 2.00/0.00, addr 2 ukbd0                               68284-0000:00:1d.7-1
5   /dev/input/event5    QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 4 utouch0                             28754-0000:00:1d.7-5
6   /dev/input/event6    QEMU QEMU USB Mouse, class 0/0, rev 2.00/0.00, addr 3 ums0                                89126-0000:00:1d.7-4

Select devices [0-6]: 5
Listening for events (press ctrl-c to exit) ...
time 1582007519.619301 --------- SYN_DROPPED --------
time 1582007519.619301 --------- SYN_REPORT --------
time 1582007519.638179 type 3 (EV_ABS), code 0    (ABS_X), value 22015
time 1582007519.638179 type 3 (EV_ABS), code 1    (ABS_Y), value 26495
time 1582007519.638179 --------- SYN_REPORT --------
time 1582007519.642895 type 3 (EV_ABS), code 0    (ABS_X), value 21663
time 1582007519.642895 type 3 (EV_ABS), code 1    (ABS_Y), value 27348
time 1582007519.642895 --------- SYN_REPORT --------
time 1582007519.65342 type 3 (EV_ABS), code 0    (ABS_X), value 21215
time 1582007519.65342 type 3 (EV_ABS), code 1    (ABS_Y), value 28585
time 1582007519.65342 --------- SYN_REPORT --------
time 1582007519.66421 type 3 (EV_ABS), code 0    (ABS_X), value 20863
time 1582007519.66421 type 3 (EV_ABS), code 1    (ABS_Y), value 29823
time 1582007519.66421 --------- SYN_REPORT --------
time 1582007519.677026 type 3 (EV_ABS), code 0    (ABS_X), value 20607
time 1582007519.677026 type 3 (EV_ABS), code 1    (ABS_Y), value 31060
time 1582007519.677026 --------- SYN_REPORT --------
time 1582007519.686741 type 3 (EV_ABS), code 0    (ABS_X), value 20415
time 1582007519.686741 type 3 (EV_ABS), code 1    (ABS_Y), value 32297
time 1582007519.686741 --------- SYN_REPORT --------
time 1582007536.383169 type 3 (EV_ABS), code 0    (ABS_X), value 12031
time 1582007536.383169 type 3 (EV_ABS), code 1    (ABS_Y), value 17108
time 1582007536.383169 --------- SYN_REPORT --------
time 1582007536.449228 type 3 (EV_ABS), code 0    (ABS_X), value 12063
time 1582007536.449228 --------- SYN_REPORT --------
time 1582007536.744538 type 3 (EV_ABS), code 1    (ABS_Y), value 17066
time 1582007536.744538 --------- SYN_REPORT --------
time 1582007536.754257 type 3 (EV_ABS), code 0    (ABS_X), value 12095
time 1582007536.754257 type 3 (EV_ABS), code 1    (ABS_Y), value 17023
time 1582007536.754257 --------- SYN_REPORT --------
time 1582007536.765432 type 3 (EV_ABS), code 0    (ABS_X), value 12127
time 1582007536.765432 type 3 (EV_ABS), code 1    (ABS_Y), value 16980
time 1582007536.765432 --------- SYN_REPORT --------
time 1582007536.779227 type 3 (EV_ABS), code 0    (ABS_X), value 12159
time 1582007536.779227 type 3 (EV_ABS), code 1    (ABS_Y), value 16938
time 1582007536.779227 --------- SYN_REPORT --------
time 1582007536.786433 type 3 (EV_ABS), code 0    (ABS_X), value 12223
time 1582007536.786433 type 3 (EV_ABS), code 1    (ABS_Y), value 16895
time 1582007536.786433 --------- SYN_REPORT --------
time 1582007536.805982 type 3 (EV_ABS), code 0    (ABS_X), value 12255
time 1582007536.805982 type 3 (EV_ABS), code 1    (ABS_Y), value 16852
time 1582007536.805982 --------- SYN_REPORT --------
time 1582007536.809289 type 3 (EV_ABS), code 0    (ABS_X), value 12319
time 1582007536.809289 type 3 (EV_ABS), code 1    (ABS_Y), value 16810
time 1582007536.809289 --------- SYN_REPORT --------
time 1582007536.822264 type 3 (EV_ABS), code 0    (ABS_X), value 12351
time 1582007536.822264 type 3 (EV_ABS), code 1    (ABS_Y), value 16767
time 1582007536.822264 --------- SYN_REPORT --------
time 1582007536.831691 type 3 (EV_ABS), code 0    (ABS_X), value 12383
time 1582007536.831691 type 3 (EV_ABS), code 1    (ABS_Y), value 16724
time 1582007536.831691 --------- SYN_REPORT --------
time 1582007536.854654 type 3 (EV_ABS), code 0    (ABS_X), value 12415
time 1582007536.854654 type 3 (EV_ABS), code 1    (ABS_Y), value 16682
time 1582007536.854654 --------- SYN_REPORT --------
time 1582007537.103654 type 1 (EV_KEY), code 272  (['BTN_LEFT', 'BTN_MOUSE']), value 1
time 1582007537.103654 --------- SYN_REPORT --------
time 1582007537.236717 type 3 (EV_ABS), code 0    (ABS_X), value 12479
time 1582007537.236717 --------- SYN_REPORT --------
time 1582007537.2603  type 3 (EV_ABS), code 0    (ABS_X), value 12511
time 1582007537.2603  --------- SYN_REPORT --------
time 1582007537.279146 type 1 (EV_KEY), code 272  (['BTN_LEFT', 'BTN_MOUSE']), value 0
time 1582007537.279146 --------- SYN_REPORT --------
time 1582007537.280155 type 3 (EV_ABS), code 0    (ABS_X), value 12543
time 1582007537.280155 type 3 (EV_ABS), code 1    (ABS_Y), value 16724
time 1582007537.280155 --------- SYN_REPORT --------
time 1582007537.282278 type 3 (EV_ABS), code 0    (ABS_X), value 12607
time 1582007537.282278 --------- SYN_REPORT --------
time 1582007537.292983 type 3 (EV_ABS), code 0    (ABS_X), value 12671
time 1582007537.292983 type 3 (EV_ABS), code 1    (ABS_Y), value 16767
time 1582007537.292983 --------- SYN_REPORT --------
time 1582007537.313748 type 3 (EV_ABS), code 0    (ABS_X), value 12735
time 1582007537.313748 --------- SYN_REPORT --------
time 1582007537.315358 type 3 (EV_ABS), code 0    (ABS_X), value 12895
...
...
...

time 1582007545.415462 --------- SYN_REPORT --------

<<END EVTEST>>

So I am now getting Absolute X/Y (which is what I want) but when I do startx the mouse is not working correctly.

NOTE: I have following enabled via /etc/rc.conf:

dbus_enable="YES"

All other mouse/pointer related items are commented out (ie disabled):

#moused_enable="YES"
#hald_enable="YES"

The xinput indicates that the evdev driver has not loaded and Xorg is defaulting to mouse_drv:

<<XINPUT>>
# cat xinput-01.txt 
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ sysmouse                                	id=7	[slave  pointer  (2)]
⎜   ↳ Mouse                                   	id=8	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ kbdmux                                  	id=6	[slave  keyboard (3)]
<<END XINPUT>>

So issue is now how to get evdev input device connected to xorg...

can you provide any tip / link on this ?

Thank you.

Cheers,


John Hartley.
Comment 3 Vladimir Kondratyev freebsd_committer 2020-02-20 21:55:27 UTC
(In reply to John Hartley from comment #2)
> can you provide any tip / link on this ?
Please, upgrade Xorg-server port to at least r526589. It enables autodetection of evdev devices by default.
Comment 4 John Hartley 2020-03-02 07:26:26 UTC
(In reply to Vladimir Kondratyev from comment #3)

Thanks again Vladimir, I did some additional manual configuration and now working.
I have documented my configuration here to help others....

https://tips.graphica.com.au/freebsd-gnome-on-qemu/

Cheers,

John.
Comment 5 John Hartley 2020-05-10 11:59:19 UTC
(In reply to Vladimir Kondratyev from comment #3)

Hi Vladimir,

I have not touch this for a while, as I have spent considerable time on next FreeBSD hurdle, which is to get: bhyve / qemu / libvirt / virt-manager running with FreeBSD Gnome Desktop.

I have now got bhyve running, but in doing update to 12.1 and installed packages, I am having EvTouch Tablet issues again.

I have removed all my prior configuration and am relying auto detection as per your original suggestion.

I have KVM / QEMU FreeBSD VM with USB Keyboard and EvTouch USB Tablet.

I now get the follow error when I do mouse click, from lib input:
libinput bug: Event for missing capability CAP_POINTER on device "QEMU QEMU USB Tablet"

Here is snippet from:  /var/log/X11.0.log

<<X11.0.log>>
...
...
[    11.694] (II) config/udev: Adding input device QEMU QEMU USB Tablet (/dev/input/event5)
[    11.694] (**) QEMU QEMU USB Tablet: Applying InputClass "evdev touchscreen catchall"
[    11.694] (**) QEMU QEMU USB Tablet: Applying InputClass "libinput touchscreen catchall"
[    11.694] (II) Using input driver 'libinput' for 'QEMU QEMU USB Tablet'
[    11.694] (**) QEMU QEMU USB Tablet: always reports core events
[    11.694] (**) Option "Device" "/dev/input/event5"
[    11.694] (**) Option "_source" "server/udev"
[    11.694] (II) event5  - QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 3: is tagged by udev as: Touchscreen
[    11.695] (II) event5  - QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 3: device is a touch device
[    11.695] (II) event5  - QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 3: device removed
[    11.695] (**) Option "config_info" "udev:/dev/input/event5"
[    11.695] (II) XINPUT: Adding extended input device "QEMU QEMU USB Tablet" (type: TOUCHSCREEN, id 11)
[    11.695] (**) Option "AccelerationScheme" "none"
[    11.695] (**) QEMU QEMU USB Tablet: (accel) selected scheme none/0
[    11.695] (**) QEMU QEMU USB Tablet: (accel) acceleration factor: 2.000
[    11.695] (**) QEMU QEMU USB Tablet: (accel) acceleration threshold: 4
[    11.696] (II) event5  - QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 3: is tagged by udev as: Touchscreen
[    11.696] (II) event5  - QEMU QEMU USB Tablet, class 0/0, rev 2.00/0.00, addr 3: device is a touch device
[    13.944] qxl_surface_create: Bad bpp: 1 (1)
[    20.773] (EE) libinput bug: Event for missing capability CAP_POINTER on device "QEMU QEMU USB Tablet, class 0/0, rev 2.00/
0.00, addr 3"
[    20.920] (EE) libinput bug: Event for missing capability CAP_POINTER on device "QEMU QEMU USB Tablet, class 0/0, rev 2.00/
0.00, addr 3"
[    22.394] (EE) libinput bug: Event for missing capability CAP_POINTER on device "QEMU QEMU USB Tablet, class 0/0, rev 2.00/
0.00, addr 3"
[    22.526] (EE) libinput bug: Event for missing capability CAP_POINTER on device "QEMU QEMU USB Tablet, class 0/0, rev 2.00/
0.00, addr 3"
[    27.770] (EE) libinput bug: Event for missing capability CAP_POINTER on device "QEMU QEMU USB Tablet, class 0/0, rev 2.00/
...
...
<<END>>

Is this because libinput has broken the utouch interface ?

Cheers,


John Hartley.
Comment 6 John Hartley 2020-05-10 13:16:05 UTC
Hi Vladamir,

I did some extra ferreting around and found cause of problem.

When I did update on installed 12.1 pkg I pull in new version of xorg which has moved to udev based device discovery and defaults to using libinput for all found devices (as per log I submitted)

To get KVM EvTouch I need to ensure I am using evdev driver as that is that your utouch fix hooks into.

So to fix issue I just added overriding configuration to into: /usr/local/etc/X11/xorg.conf.d
 
<<UTOUCH OVERRIDE>>
$ cat /usr/local/etc/X11/xorg.conf.d/99-qemu-input.conf 
#
# Overide libinput
#
Section "InputClass"
        Identifier "evdev touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection
<<END UTOUCH OVERRIDE>>

So now have FreeBSD Desktop back and up running and with much much simpler overall configuration.

Cheers,


John Hartley
Comment 7 Vladimir Kondratyev freebsd_committer 2020-05-12 15:50:17 UTC
(In reply to John Hartley from comment #6)
> Is this because libinput has broken the utouch interface

That is strange AFAIR libinput handles utouch devices. Or at least handled sometime ago. I'll try to reproduce it with virtualbox USB tablet when get some spare cycles.
May be it is udev shim who does something wrongly.
Comment 8 Vladimir Kondratyev freebsd_committer 2020-05-14 22:16:05 UTC
Created attachment 214507 [details]
devel/libudev-devd.patch

It is appeared as libudev shim issue.

Device type auto-detection code based on xf86-input-evdev claimed pointer device as touchscreen (absolute VM mouses behave like touchscreens really) while libinput expected it to be a mouse.

If you are familiar with FreeBSD ports system, you can rebuild devel/libudev-devd port after applying of enclosed patch and test libinput with utouch once again.
Comment 9 John Hartley 2020-05-15 01:36:26 UTC
Thanks Vladimir,

glad you found issue and have a fix.

I am ok with simple config change for time being, but having fix will make sure it all works better in future for others, which is what we need.

Cheers,


John Hartley.