Re: eGalax USB touchscreen issues

From: Mark Kane <mark_at_kane.mn>
Date: Tue, 10 Aug 2021 04:03:12 UTC
On 2021-08-07 05:56, Vladimir Kondratyev wrote:
> Try attached patch (on top of previous one)

The screen we've been testing works perfectly with this patch on top of 
previous one (with usbhid_load="YES" and hw.usb.usbhid.enable=1). Thanks 
very much for all of your work on this! :)

I have many of these egalax screens for an application being migrated 
from Linux to FreeBSD. Physically they all look identical but after 
trying a few others it seems that some are very different inside. Below 
is one that is not working with or without the patches. Is there any 
possibility of also supporting this variant on FreeBSD?

Screen #2 - With your 2 patches and usbhid/hidraw:

ugen0.3: <eGalax Inc. USB TouchController> at usbus0
usbhid0 on uhub1
usbhid0: <eGalax Inc. USB TouchController, class 0/0, rev 1.10/1.00, 
addr 3> on usbus0
hidbus0: <HID bus> on usbhid0
hidraw0: <eGalax Inc. USB TouchController Raw HID Device> on hidbus0
hidraw0: no report descriptor

# hid-decode /dev/hidraw0
(no output)
# usbhid-dump
000:003:000:DESCRIPTOR         1628551474.564813
  8D 0F 00 09 42 09 32 15 00 25 01 95 02 75 01 81
  02 95 06 75 01 81 03 05 01 09 30 75 10 95 01 A4
  55 00 65 00 36 00 00 46 00 00 16 1E 00 26 C8 0F
  81 02 09 31 16 3C 00 26

000:004:001:DESCRIPTOR         1628551474.567569
  05 0C 09 01 A1 01 85 01 19 00 2A 3C 02 15 00 26
  3C 02 95 01 75 10 81 00 C0 05 01 09 80 A1 01 85
  02 19 81 29 83 25 01 75 01 95 03 81 02 95 05 81
  01 C0

000:004:000:DESCRIPTOR         1628551474.570559
  05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
  95 08 75 01 81 02 95 08 75 01 81 01 05 08 19 01
  29 03 95 03 75 01 91 02 95 01 75 05 91 01 05 07
  19 00 2A FF 00 15 00 26 FF 00 95 06 75 08 81 00
  C0
#

Based on that and a lot of forums/bugzilla reading it seems that the 
vendor re-used hardware IDs that makes older non-HID touchscreens look 
the same as their newer HID screens. This "screen #2" was manufactured 
in 2012 compared to the 2018 unit that works with your patches now. So I 
suspect this may be one of the older non-HID screens that uep(4) should 
support (?).

With usbhid disabled uep(4) attaches in evdev mode and X gets the input 
device but no events are heard:

ugen0.3: <eGalax Inc. USB TouchController> at usbus0
uep0 on uhub1
uep0: <eGalax Inc. USB TouchController, class 0/0, rev 1.10/1.00, addr 
3> on usbus0

[    59.002] (II) config/udev: Adding input device eGalax Inc. USB 
TouchController (/dev/input/event5)
[    59.002] (**) eGalax Inc. USB TouchController: Applying InputClass 
"evdev touchscreen catchall"
[    59.002] (**) eGalax Inc. USB TouchController: Applying InputClass 
"libinput touchscreen catchall"
[    59.002] (II) Using input driver 'libinput' for 'eGalax Inc. USB 
TouchController'
[    59.002] (**) eGalax Inc. USB TouchController: always reports core 
events
[    59.002] (**) Option "Device" "/dev/input/event5"
[    59.002] (**) Option "_source" "server/udev"
[    59.005] (II) event5  - eGalax Inc. USB TouchController, class 0/0, 
rev 1.10/1.00, addr 3: is tagged by udev as: Touchscreen
[    59.006] (II) event5  - eGalax Inc. USB TouchController, class 0/0, 
rev 1.10/1.00, addr 3: device is a touch device
[    59.007] (II) event5  - eGalax Inc. USB TouchController, class 0/0, 
rev 1.10/1.00, addr 3: device removed
[    59.007] (**) Option "config_info" "udev:/dev/input/event5"
[    59.007] (II) XINPUT: Adding extended input device "eGalax Inc. USB 
TouchController" (type: TOUCHSCREEN, id 11)
[    59.007] (**) Option "AccelerationScheme" "none"
[    59.007] (**) eGalax Inc. USB TouchController: (accel) selected 
scheme none/0
[    59.007] (**) eGalax Inc. USB TouchController: (accel) acceleration 
factor: 2.000
[    59.007] (**) eGalax Inc. USB TouchController: (accel) acceleration 
threshold: 4
[    59.010] (II) event5  - eGalax Inc. USB TouchController, class 0/0, 
rev 1.10/1.00, addr 3: is tagged by udev as: Touchscreen
[    59.011] (II) event5  - eGalax Inc. USB TouchController, class 0/0, 
rev 1.10/1.00, addr 3: device is a touch device

# evemu-record
Available devices:
/dev/input/event0:	System mouse
/dev/input/event1:	System keyboard multiplexer
/dev/input/event2:	Power Button
/dev/input/event3:	Sleep Button
/dev/input/event4:	Lite-On Technology Corp. USB Multimedia Keyboard, 
class 0/0, rev 1.10/1.09, add
/dev/input/event5:	eGalax Inc. USB TouchController, class 0/0, rev 
1.10/1.00, addr 3
Select the device event number [0-5]: 5
# EVEMU 1.3
# Kernel: 13.0-RELEASE-p3
# Input device name: "eGalax Inc. USB TouchController, class 0/0, rev 
1.10/1.00, addr 3"
# Input device ID: bus 0x03 vendor 0xeef product 0x01 version 0000
# Supported events:
#   Event type 0 (EV_SYN)
#     Event code 0 (SYN_REPORT)
#     Event code 1 (SYN_CONFIG)
#     Event code 2 (SYN_MT_REPORT)
#     Event code 3 (SYN_DROPPED)
#     Event code 4 ((null))
#     Event code 5 ((null))
#     Event code 6 ((null))
#     Event code 7 ((null))
#     Event code 8 ((null))
#     Event code 9 ((null))
#     Event code 10 ((null))
#     Event code 11 ((null))
#     Event code 12 ((null))
#     Event code 13 ((null))
#     Event code 14 ((null))
#     Event code 15 (SYN_MAX)
#   Event type 1 (EV_KEY)
#     Event code 330 (BTN_TOUCH)
#   Event type 3 (EV_ABS)
#     Event code 0 (ABS_X)
#       Value        0
#       Min          0
#       Max       2047
#       Fuzz         0
#       Flat         0
#       Resolution   0
#     Event code 1 (ABS_Y)
#       Value        0
#       Min          0
#       Max       2047
#       Fuzz         0
#       Flat         0
#       Resolution   0
# Properties:
#   Property  type 1 (INPUT_PROP_DIRECT)
N: eGalax Inc. USB TouchController, class 0/0, rev 1.10/1.00, addr 3
I: 0003 0eef 0001 0000
P: 02 00 00 00 00 00 00 00
B: 00 0b 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 04 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 02 00 00 00 00 00 00 00 00
B: 03 03 00 00 00 00 00 00 00
B: 04 00 00 00 00 00 00 00 00
B: 05 00 00 00 00 00 00 00 00
B: 11 00 00 00 00 00 00 00 00
B: 12 00 00 00 00 00 00 00 00
B: 14 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
A: 00 0 2047 0 0 0
A: 01 0 2047 0 0 0
################################
#      Waiting for events      #
################################

[...no events...]

Trying uep(4) in native mode with xf86-input-egalax also had the same, 
uep(4) attached but no events when testing with xinput.

# usbconfig -d ugen0.3 dump_all_desc
ugen0.3: <eGalax Inc. USB TouchController> at usbus0, cfg=0 md=HOST 
spd=FULL (12Mbps) pwr=ON (100mA)

   bLength = 0x0012
   bDescriptorType = 0x0001
   bcdUSB = 0x0110
   bDeviceClass = 0x0000  <Probed by interface class>
   bDeviceSubClass = 0x0000
   bDeviceProtocol = 0x0000
   bMaxPacketSize0 = 0x0040
   idVendor = 0x0eef
   idProduct = 0x0001
   bcdDevice = 0x0100
   iManufacturer = 0x0001  <eGalax Inc.>
   iProduct = 0x0002  <USB TouchController>
   iSerialNumber = 0x0000  <no string>
   bNumConfigurations = 0x0001

  Configuration index 0

     bLength = 0x0009
     bDescriptorType = 0x0002
     wTotalLength = 0x0022
     bNumInterfaces = 0x0001
     bConfigurationValue = 0x0001
     iConfiguration = 0x0001  <eGalax Inc.>
     bmAttributes = 0x00a0
     bMaxPower = 0x0032

     Interface 0
       bLength = 0x0009
       bDescriptorType = 0x0004
       bInterfaceNumber = 0x0000
       bAlternateSetting = 0x0000
       bNumEndpoints = 0x0001
       bInterfaceClass = 0x0003  <HID device>
       bInterfaceSubClass = 0x0000
       bInterfaceProtocol = 0x0000
       iInterface = 0x0000  <no string>

       Additional Descriptor

       bLength = 0x09
       bDescriptorType = 0x21
       bDescriptorSubType = 0x10
        RAW dump:
        0x00 | 0x09, 0x21, 0x10, 0x02, 0x00, 0x01, 0x22, 0x8d,
        0x08 | 0x00

      Endpoint 0
         bLength = 0x0007
         bDescriptorType = 0x0005
         bEndpointAddress = 0x0081  <IN>
         bmAttributes = 0x0003  <INTERRUPT>
         wMaxPacketSize = 0x0008
         bInterval = 0x0003
         bRefresh = 0x0000
         bSynchAddress = 0x0000
#