Sorry to bring back this thread but I'm having some trouble getting both the newer and older screens fully working on i386 (all testing before was on amd64).

Attached is the final diff against releng/13.0 I used to build on both amd64 and i386. On amd64 everything works as it did before. Using the same patch on i386 we get as far as evemu-record hearing events, X adding the input device, but the pointer doesn't actually move inside X or with xinput --test.

Can you think of anything that would need to be done differently for i386 or spot anything I might have missed here? I tried 2 clean i386 installs with the same results. Quarterly packages from official repo and configs are the same on both amd64/i386 machines:

/etc/rc.conf:
devmatch_blacklist="uep.ko uhid.ko wmt.ko"

/boot/loader.conf:
hw.usb.usbhid.enable=1
usbhid_load="YES"
hidraw_load="YES"

/usr/local/share/libinput/90-egalax.quirks:
[eGalax]
MatchUdevType=tablet
MatchVendor=0x0EEF
MatchProduct=0x0001
AttrResolutionHint=26x43

This output is from a 2014 screen that doesn't require setrdesc.c:

# evemu-record
Available devices:
/dev/input/event0:      System mouse
/dev/input/event1:      System keyboard multiplexer
/dev/input/event2:      Power Button
/dev/input/event3:      AT keyboard
/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 Tablet
/dev/input/event6:      eGalax Inc. USB TouchController Pen
/dev/input/event7:      eGalax Inc. USB TouchController TouchScreen
/dev/input/event8: Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control /dev/input/event9: Lite-On Technology Corp. USB Multimedia Keyboard System Control
Select the device event number [0-9]: 5
# EVEMU 1.3
# Kernel: 13.0-RELEASE-p4
# Input device name: "eGalax Inc. USB TouchController Tablet"
# Input device ID: bus 0x03 vendor 0xeef product 0x01 version 0x100
# 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 272 (BTN_LEFT)
#     Event code 273 (BTN_RIGHT)
#   Event type 3 (EV_ABS)
#     Event code 0 (ABS_X)
#       Value     1712
#       Min          0
#       Max       4095
#       Fuzz         0
#       Flat         0
#       Resolution   0
#     Event code 1 (ABS_Y)
#       Value     2362
#       Min          0
#       Max       4095
#       Fuzz         0
#       Flat         0
#       Resolution   0
# Properties:
#   Property  type 1 (INPUT_PROP_DIRECT)
N: eGalax Inc. USB TouchController Tablet
I: 0003 0eef 0001 0100
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 03 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: 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 4095 0 0 0
A: 01 0 4095 0 0 0
################################
#      Waiting for events      #
################################
E: 0.000001 0003 0000 2510      # EV_ABS / ABS_X                2510
E: 0.000001 0003 0001 2360      # EV_ABS / ABS_Y                2360
E: 0.000001 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +0ms
E: 0.002005 0001 0110 0001      # EV_KEY / BTN_LEFT             1
E: 0.002005 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +2ms
E: 0.007999 0003 0000 2506      # EV_ABS / ABS_X                2506
E: 0.007999 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +5ms
E: 0.013990 0003 0000 2502      # EV_ABS / ABS_X                2502
E: 0.013990 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.020008 0003 0000 2498      # EV_ABS / ABS_X                2498
E: 0.020008 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +7ms
E: 0.027994 0003 0000 2494      # EV_ABS / ABS_X                2494
E: 0.027994 0003 0001 2358      # EV_ABS / ABS_Y                2358
E: 0.027994 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +7ms
E: 0.033998 0003 0000 2492      # EV_ABS / ABS_X                2492
E: 0.033998 0003 0001 2354      # EV_ABS / ABS_Y                2354
E: 0.033998 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.039999 0003 0001 2352      # EV_ABS / ABS_Y                2352
E: 0.039999 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.045985 0003 0001 2350      # EV_ABS / ABS_Y                2350
E: 0.045985 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.051988 0003 0001 2348      # EV_ABS / ABS_Y                2348
E: 0.051988 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.057993 0003 0001 2346      # EV_ABS / ABS_Y                2346
E: 0.057993 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.063997 0003 0000 2494      # EV_ABS / ABS_X                2494
E: 0.063997 0003 0001 2344      # EV_ABS / ABS_Y                2344
E: 0.063997 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.077981 0003 0001 2342      # EV_ABS / ABS_Y                2342
E: 0.077981 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +14ms
E: 0.083987 0003 0001 2340      # EV_ABS / ABS_Y                2340
E: 0.083987 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.089994 0003 0001 2338      # EV_ABS / ABS_Y                2338
E: 0.089994 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.095989 0003 0001 2336      # EV_ABS / ABS_Y                2336
E: 0.095989 0000 0000 0001 # ------------ SYN_REPORT (1) ---------- +6ms
E: 0.101995 0003 0001 2334      # EV_ABS / ABS_Y                2334

(only event5 hears events)

$ xinput
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ System mouse id=6 [slave pointer (2)] ⎜ ↳ eGalax Inc. USB TouchController Tablet id=11 [slave pointer (2)] ⎜ ↳ eGalax Inc. USB TouchController TouchScreen id=13 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ System keyboard multiplexer id=7 [slave keyboard (3)] ↳ Power Button id=8 [slave keyboard (3)] ↳ AT keyboard id=9 [slave keyboard (3)] ↳ Lite-On Technology Corp. USB Multimedia Keyboard id=10 [slave keyboard (3)] ↳ eGalax Inc. USB TouchController Pen id=12 [slave keyboard (3)] ↳ Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control id=14 [slave keyboard (3)] ↳ Lite-On Technology Corp. USB Multimedia Keyboard System Control id=15 [slave keyboard (3)]
$ xinput --test 11
(no output)
^C
$ xinput --test 13
(no output)
^C
$

[ 108.675] (II) config/udev: Adding input device eGalax Inc. USB TouchController Tablet (/dev/input/event5) [ 108.675] (**) eGalax Inc. USB TouchController Tablet: Applying InputClass "libinput touchscreen catchall" [ 108.675] (II) Using input driver 'libinput' for 'eGalax Inc. USB TouchController Tablet' [ 108.675] (**) eGalax Inc. USB TouchController Tablet: always reports core events
[   108.676] (**) Option "Device" "/dev/input/event5"
[   108.676] (**) Option "_source" "server/udev"
[ 108.697] (II) event5 - eGalax Inc. USB TouchController Tablet: is tagged by udev as: Touchscreen [ 108.705] (II) event5 - eGalax Inc. USB TouchController Tablet: device is a touch device [ 108.712] (II) event5 - eGalax Inc. USB TouchController Tablet: device removed
[   108.715] (**) Option "config_info" "udev:/dev/input/event5"
[ 108.715] (II) XINPUT: Adding extended input device "eGalax Inc. USB TouchController Tablet" (type: TOUCHSCREEN, id 11)
[   108.716] (**) Option "AccelerationScheme" "none"
[ 108.716] (**) eGalax Inc. USB TouchController Tablet: (accel) selected scheme none/0 [ 108.716] (**) eGalax Inc. USB TouchController Tablet: (accel) acceleration factor: 2.000 [ 108.716] (**) eGalax Inc. USB TouchController Tablet: (accel) acceleration threshold: 4 [ 108.737] (II) event5 - eGalax Inc. USB TouchController Tablet: is tagged by udev as: Touchscreen [ 108.745] (II) event5 - eGalax Inc. USB TouchController Tablet: device is a touch device [ 108.753] (II) config/udev: Adding input device eGalax Inc. USB TouchController Pen (/dev/input/event6) [ 108.753] (**) eGalax Inc. USB TouchController Pen: Applying InputClass "libinput tablet catchall" [ 108.753] (II) Using input driver 'libinput' for 'eGalax Inc. USB TouchController Pen' [ 108.753] (**) eGalax Inc. USB TouchController Pen: always reports core events
[   108.754] (**) Option "Device" "/dev/input/event6"
[   108.754] (**) Option "_source" "server/udev"
[ 108.774] (II) event6 - eGalax Inc. USB TouchController Pen: is tagged by udev as: Tablet [ 109.142] (II) event6 - eGalax Inc. USB TouchController Pen: tablet 'eGalax Inc. USB TouchController Pen' unknown to libwacom [ 109.142] (II) event6 - eGalax Inc. USB TouchController Pen: device is a tablet [ 109.144] (II) event6 - eGalax Inc. USB TouchController Pen: device removed
[   109.144] (**) Option "config_info" "udev:/dev/input/event6"
[ 109.144] (II) XINPUT: Adding extended input device "eGalax Inc. USB TouchController Pen" (type: TABLET, id 12) [ 109.164] (II) event6 - eGalax Inc. USB TouchController Pen: is tagged by udev as: Tablet [ 109.169] (II) event6 - eGalax Inc. USB TouchController Pen: tablet 'eGalax Inc. USB TouchController Pen' unknown to libwacom [ 109.170] (II) event6 - eGalax Inc. USB TouchController Pen: device is a tablet [ 109.172] (II) config/udev: Adding input device eGalax Inc. USB TouchController TouchScreen (/dev/input/event7) [ 109.172] (**) eGalax Inc. USB TouchController TouchScreen: Applying InputClass "libinput touchscreen catchall" [ 109.172] (II) Using input driver 'libinput' for 'eGalax Inc. USB TouchController TouchScreen' [ 109.172] (**) eGalax Inc. USB TouchController TouchScreen: always reports core events
[   109.172] (**) Option "Device" "/dev/input/event7"
[   109.173] (**) Option "_source" "server/udev"
[ 109.196] (II) event7 - eGalax Inc. USB TouchController TouchScreen: is tagged by udev as: Touchscreen [ 109.199] (II) event7 - eGalax Inc. USB TouchController TouchScreen: device is a touch device [ 109.206] (II) event7 - eGalax Inc. USB TouchController TouchScreen: device removed
[   109.207] (**) Option "config_info" "udev:/dev/input/event7"
[ 109.207] (II) XINPUT: Adding extended input device "eGalax Inc. USB TouchController TouchScreen" (type: TOUCHSCREEN, id 13)
[   109.207] (**) Option "AccelerationScheme" "none"
[ 109.208] (**) eGalax Inc. USB TouchController TouchScreen: (accel) selected scheme none/0 [ 109.208] (**) eGalax Inc. USB TouchController TouchScreen: (accel) acceleration factor: 2.000 [ 109.208] (**) eGalax Inc. USB TouchController TouchScreen: (accel) acceleration threshold: 4 [ 109.231] (II) event7 - eGalax Inc. USB TouchController TouchScreen: is tagged by udev as: Touchscreen [ 109.234] (II) event7 - eGalax Inc. USB TouchController TouchScreen: device is a touch device [ 109.242] (II) config/udev: Adding input device Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control (/dev/input/event8) [ 109.242] (**) Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control: Applying InputClass "Evdev keyboard" [ 109.243] (**) Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control: Applying InputClass "libinput keyboard catchall" [ 109.243] (II) Using input driver 'libinput' for 'Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control' [ 109.243] (**) Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control: always reports core events
[   109.243] (**) Option "Device" "/dev/input/event8"
[   109.243] (**) Option "_source" "server/udev"
[ 109.274] (II) event8 - Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control: is tagged by udev as: Keyboard [ 109.279] (II) event8 - Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control: device is a keyboard [ 109.288] (II) event8 - Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control: device removed
[   109.292] (**) Option "config_info" "udev:/dev/input/event8"
[ 109.292] (II) XINPUT: Adding extended input device "Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control" (type: KEYBOARD, id 14)
[   109.292] (**) Option "xkb_rules" "evdev"
[ 109.325] (II) event8 - Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control: is tagged by udev as: Keyboard [ 109.329] (II) event8 - Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control: device is a keyboard [ 109.339] (II) config/udev: Adding input device Lite-On Technology Corp. USB Multimedia Keyboard System Control (/dev/input/event9) [ 109.339] (**) Lite-On Technology Corp. USB Multimedia Keyboard System Control: Applying InputClass "Evdev keyboard" [ 109.340] (**) Lite-On Technology Corp. USB Multimedia Keyboard System Control: Applying InputClass "libinput keyboard catchall" [ 109.340] (II) Using input driver 'libinput' for 'Lite-On Technology Corp. USB Multimedia Keyboard System Control' [ 109.340] (**) Lite-On Technology Corp. USB Multimedia Keyboard System Control: always reports core events
[   109.340] (**) Option "Device" "/dev/input/event9"
[   109.340] (**) Option "_source" "server/udev"
[ 109.371] (II) event9 - Lite-On Technology Corp. USB Multimedia Keyboard System Control: is tagged by udev as: Keyboard [ 109.375] (II) event9 - Lite-On Technology Corp. USB Multimedia Keyboard System Control: device is a keyboard [ 109.384] (II) event9 - Lite-On Technology Corp. USB Multimedia Keyboard System Control: device removed
[   109.385] (**) Option "config_info" "udev:/dev/input/event9"
[ 109.385] (II) XINPUT: Adding extended input device "Lite-On Technology Corp. USB Multimedia Keyboard System Control" (type: KEYBOARD, id 15)
[   109.385] (**) Option "xkb_rules" "evdev"
[ 109.422] (II) event9 - Lite-On Technology Corp. USB Multimedia Keyboard System Control: is tagged by udev as: Keyboard [ 109.426] (II) event9 - Lite-On Technology Corp. USB Multimedia Keyboard System Control: device is a keyboard [ 379.577] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 379.890] (EE) client bug: timer event5 debounce: scheduled expiry is in the past (-16ms), your system is too slow [ 379.891] (EE) client bug: timer event5 debounce short: scheduled expiry is in the past (-29ms), your system is too slow [ 379.891] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 380.183] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 380.311] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 380.559] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 380.662] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 380.949] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 381.079] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1815.177] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1815.477] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1815.679] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1815.871] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1820.643] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1821.049] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1821.349] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1821.653] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1850.460] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1850.879] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1851.136] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1851.474] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1851.720] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1851.938] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1857.580] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1857.860] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1858.190] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1858.340] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1863.131] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1863.456] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1863.903] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1864.097] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1864.613] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet" [ 1864.843] (EE) libinput bug: Event for missing capability CAP_POINTER on device "eGalax Inc. USB TouchController Tablet"


---<<BOOT>>---
Copyright (c) 1992-2021 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 13.0-RELEASE-p4 #0 releng/13.0-n244760-940681634ee-dirty: Fri Sep 3 12:26:04 CDT 2021
    root@i386build:/usr/obj/usr/src/i386.i386/sys/GENERIC i386
FreeBSD clang version 11.0.1 ([email protected]:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe)
VT(vga): resolution 640x480
CPU: Intel(R) Atom(TM) CPU N270   @ 1.60GHz (1600.09-MHz 686-class CPU)
  Origin="GenuineIntel"  Id=0x106c2  Family=0x6  Model=0x1c  Stepping=2
Features=0xbfe9fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Features2=0x40c39d<SSE3,DTES64,MON,DS_CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE>
  AMD Features=0x100000<NX>
  AMD Features2=0x1<LAHF>
  TSC: P-state invariant, performance statistics
real memory  = 1073741824 (1024 MB)
avail memory = 1008582656 (961 MB)
Event timer "LAPIC" quality 100
ACPI APIC Table: <IntelR AWRDACPI>
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
FreeBSD/SMP: 1 package(s) x 1 core(s) x 2 hardware threads
random: unblocking device.
Firmware Warning (ACPI): 32/64X length mismatch in FADT/Pm1aEventBlock: 32/8 (20201113/tbfadt-748) Firmware Warning (ACPI): 32/64X length mismatch in FADT/Pm1aControlBlock: 16/8 (20201113/tbfadt-748) Firmware Warning (ACPI): 32/64X length mismatch in FADT/PmTimerBlock: 32/8 (20201113/tbfadt-748) Firmware Warning (ACPI): 32/64X length mismatch in FADT/Gpe0Block: 64/8 (20201113/tbfadt-748) Firmware Warning (ACPI): Invalid length for FADT/Pm1aEventBlock: 8, using default 32 (20201113/tbfadt-850) Firmware Warning (ACPI): Invalid length for FADT/Pm1aControlBlock: 8, using default 16 (20201113/tbfadt-850) Firmware Warning (ACPI): Invalid length for FADT/PmTimerBlock: 8, using default 32 (20201113/tbfadt-850)
ioapic0: MADT APIC ID 2 != hw id 0
ioapic0 <Version 2.0> irqs 0-23
Launching APs: 1
Timecounter "TSC" frequency 1600093704 Hz quality 1000
random: entropy device external interface
[ath_hal] loaded
WARNING: Device "kbd" is Giant locked and may be deleted before FreeBSD 14.0.
kbd1 at kbdmux0
nexus0
vtvga0: <VT VGA driver>
cryptosoft0: <software crypto>
aesni0: No AES or SHA support.
acpi0: <IntelR AWRDACPI>
acpi0: Power Button (fixed)
cpu0: <ACPI CPU> on acpi0
attimer0: <AT timer> port 0x40-0x43 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
atrtc0: <AT realtime clock> port 0x70-0x73 irq 8 on acpi0
atrtc0: registered as a time-of-day clock, resolution 1.000000s
Event timer "RTC" frequency 32768 Hz quality 0
Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
acpi_button0: <Power Button> on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
vgapci0: <VGA-compatible display> port 0xff00-0xff07 mem 0xfde80000-0xfdefffff,0xd0000000-0xdfffffff,0xfdf80000-0xfdfbffff irq 16 at device 2.0 on pci0
agp0: <Intel 945GME SVGA controller> on vgapci0
WARNING: Device "agp" is Giant locked and may be deleted before FreeBSD 14.0.
agp0: aperture size is 256M, detected 7932k stolen memory
vgapci0: Boot video device
vgapci1: <VGA-compatible display> mem 0xfdf00000-0xfdf7ffff at device 2.1 on pci0 hdac0: <Intel 82801G HDA Controller> mem 0xfdff8000-0xfdffbfff irq 16 at device 27.0 on pci0
pcib1: <ACPI PCI-PCI bridge> irq 16 at device 28.0 on pci0
pcib2: <ACPI PCI-PCI bridge> irq 19 at device 28.5 on pci0
pci1: <ACPI PCI bus> on pcib2
re0: <RealTek 8168/8111 B/C/CP/D/DP/E/F/G PCIe Gigabit Ethernet> port 0xee00-0xeeff mem 0xfddff000-0xfddfffff,0xfdcf0000-0xfdcfffff irq 17 at device 0.0 on pci1
re0: Using 1 MSI-X message
re0: Chip rev. 0x3c000000
re0: MAC rev. 0x00400000
miibus0: <MII bus> on re0
rgephy0: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus0 rgephy0: none, 10baseT, 10baseT-FDX, 10baseT-FDX-flow, 100baseTX, 100baseTX-FDX, 100baseTX-FDX-flow, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, 1000baseT-FDX-flow, 1000baseT-FDX-flow-master, auto, auto-flow
re0: Using defaults for TSO: 65518/35/2048
re0: Ethernet address: 00:10:f3:5c:97:2e
uhci0: <Intel 82801G (ICH7) USB controller USB-A> port 0xfe00-0xfe1f irq 23 at device 29.0 on pci0
uhci0: LegSup = 0x2f00
usbus0 on uhci0
usbus0: 12Mbps Full Speed USB v1.0
uhci1: <Intel 82801G (ICH7) USB controller USB-B> port 0xfd00-0xfd1f irq 19 at device 29.1 on pci0
uhci1: LegSup = 0x2f00
usbus1 on uhci1
usbus1: 12Mbps Full Speed USB v1.0
uhci2: <Intel 82801G (ICH7) USB controller USB-C> port 0xfc00-0xfc1f irq 18 at device 29.2 on pci0
uhci2: LegSup = 0x2f00
usbus2 on uhci2
usbus2: 12Mbps Full Speed USB v1.0
uhci3: <Intel 82801G (ICH7) USB controller USB-D> port 0xfb00-0xfb1f irq 16 at device 29.3 on pci0
uhci3: LegSup = 0x2f00
usbus3 on uhci3
usbus3: 12Mbps Full Speed USB v1.0
ehci0: <Intel 82801GB/R (ICH7) USB 2.0 controller> mem 0xfdfff000-0xfdfff3ff irq 23 at device 29.7 on pci0
usbus4: EHCI version 1.0
usbus4 on ehci0
usbus4: 480Mbps High Speed USB v2.0
pcib3: <ACPI PCI-PCI bridge> at device 30.0 on pci0
pci2: <ACPI PCI bus> on pcib3
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel ICH7 UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xfa00-0xfa0f at device 31.1 on pci0
ata0: <ATA channel> at channel 0 on atapci0
atapci1: <Intel ICH7M SATA150 controller> port 0xf900-0xf907,0xf800-0xf803,0xf700-0xf707,0xf600-0xf603,0xf500-0xf50f mem 0xfdffe000-0xfdffe3ff irq 19 at device 31.2 on pci0
ata2: <ATA channel> at channel 0 on atapci1
ata3: <ATA channel> at channel 1 on atapci1
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart1: <16550 or compatible> port 0x2f8-0x2ff irq 3 on acpi0
uart2: <16550 or compatible> port 0x3e8-0x3ef irq 5 on acpi0
uart3: <16550 or compatible> port 0x2e8-0x2ef irq 7 on acpi0
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
orm0: <ISA Option ROM> at iomem 0xef000-0xeffff pnpid ORM0000 on isa0
ppc0: parallel port not found.
est0: <Enhanced SpeedStep Frequency Control> on cpu0
Timecounters tick every 1.000 msec
hdacc0: <Realtek ALC888 HDA CODEC> at cad 0 on hdac0
hdaa0: <Realtek ALC888 Audio Function Group> at nid 1 on hdacc0
pcm0: <Realtek ALC888 (Analog 2.0+HP/2.0)> at nid 20,21 and 24,26 on hdaa0
ugen1.1: <Intel UHCI root HUB> at usbus1
ugen4.1: <Intel EHCI root HUB> at usbus4
uhub0 on usbus1
uhub0: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus1
uhub1 on usbus4
uhub1: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus4
ugen0.1: <Intel UHCI root HUB> at usbus0
ugen3.1: <Intel UHCI root HUB> at usbus3
uhub2 on usbus0
uhub2: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
Trying to mount root from ufs:/dev/ada0s1a [rw]...
Root mount waiting for: usbus0 usbus1 usbus2 usbus3 usbus4 CAM
uhub3 on usbus3
uhub3: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus3
ugen2.1: <Intel UHCI root HUB> at usbus2
uhub4 on usbus2
uhub4: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus2
uhub0: 2 ports with 2 removable, self powered
uhub2: 2 ports with 2 removable, self powered
uhub3: 2 ports with 2 removable, self powered
uhub4: 2 ports with 2 removable, self powered
Root mount waiting for: usbus4 CAM
ada0 at ata2 bus 0 scbus1 target 0 lun 0
ada0: <KINGSTON SUV400S37120G 0C3J96R9> ACS-4 ATA SATA 3.x device
ada0: Serial Number 50026B767603A50C
ada0: 150.000MB/s transfers (SATA 1.x, UDMA5, PIO 8192bytes)
ada0: 114473MB (234441648 512 byte sectors)
Root mount waiting for: usbus4
uhub1: 8 ports with 8 removable, self powered
Root mount waiting for: usbus4
mountroot: waiting for device /dev/ada0s1a...
warning: total configured swap (3090798 pages) exceeds maximum recommended amount (2009952 pages).
warning: increase kern.maxswzone or reduce amount of swap.
ugen0.2: <eGalax Inc. USB TouchController> at usbus0
usbhid0 on uhub2
usbhid0: <eGalax Inc. USB TouchController, class 0/0, rev 1.10/1.00, addr 2> on usbus0
hidbus0: <HID bus> on usbhid0
hidraw0: <eGalax Inc. USB TouchController Raw HID Device> on hidbus0
ugen0.3: <Lite-On Technology Corp. USB Multimedia Keyboard> at usbus0
ukbd0 on uhub2
ukbd0: <Lite-On Technology Corp. USB Multimedia Keyboard, class 0/0, rev 1.10/1.09, addr 3> on usbus0
kbd2 at ukbd0
usbhid1 on uhub2
usbhid1: <Lite-On Technology Corp. USB Multimedia Keyboard, class 0/0, rev 1.10/1.09, addr 3> on usbus0
hidbus1: <HID bus> on usbhid1
hidraw1: <Lite-On Technology Corp. USB Multimedia Keyboard Raw HID Device> on hidbus1 ichsmb0: <Intel 82801GB (ICH7) SMBus controller> port 0x500-0x51f irq 19 at device 31.3 on pci0
smbus0: <System Management Bus> on ichsmb0
hms0: <eGalax Inc. USB TouchController Tablet> on hidbus0
hms0: 2 buttons and [XY] coordinates ID=1
hpen0: <eGalax Inc. USB TouchController Pen> on hidbus0
hmt0: <eGalax Inc. USB TouchController TouchScreen> on hidbus0
hmt0: Multitouch touchscreen with 0 external buttons
hmt0: 1 contacts with [RC] properties. Report range [0:0] - [4095:4095]
hconf0: <eGalax Inc. USB TouchController Configuration> on hidbus0
drmn0: <drmn> on vgapci0
vgapci0: child drmn0 requested pci_enable_io
vgapci0: child drmn0 requested pci_enable_io
[drm] Unable to create a private tmpfs mount, hugepage support will be disabled(-19).
Successfully added WC MTRR for [0xd0000000-0xdfffffff]: 0;
[drm] Got stolen memory base 0x0, size 0x0
[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[drm] Driver supports precise vblank timestamp query.
[drm] Connector LVDS-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.LVDS-1
[drm]   - kern.vt.fb.default_mode
[drm] Connector VGA-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.VGA-1
[drm]   - kern.vt.fb.default_mode
[drm] Connector DVI-D-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.DVI-D-1
[drm]   - kern.vt.fb.default_mode
[drm] RC6 disabled, disabling runtime PM support
[drm] Initialized overlay support.
sysctl_warn_reuse: can't re-use a leaf (hw.dri.debug)!
[drm] Initialized i915 1.6.0 20190822 for drmn0 on minor 0
WARNING: Device "fb" is Giant locked and may be deleted before FreeBSD 14.0.
VT: Replacing driver "vga" with new "fb".
start FB_INFO:
type=11 height=600 width=800 depth=32
cmsize=16 size=3145728
pbase=0xd0009000 vbase=0x1ae09000
name=drmn0 flags=0x0 stride=4096 bpp=32
cmap[0]=0 cmap[1]=7f0000 cmap[2]=7f00 cmap[3]=c4a000
end FB_INFO
drmn0: fb0: i915drmfb frame buffer device
lo0: link state changed to UP
re0: link state changed to DOWN
re0: link state changed to UP
hcons0: <Lite-On Technology Corp. USB Multimedia Keyboard Consumer Control> on hidbus1 hsctrl0: <Lite-On Technology Corp. USB Multimedia Keyboard System Control> on hidbus1
diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c
index 086ee36333d..bc28ae0734f 100644
--- a/sys/dev/evdev/evdev.c
+++ b/sys/dev/evdev/evdev.c
@@ -316,8 +316,7 @@ evdev_register_common(struct evdev_dev *evdev)
 	}
 
 	/* Initialize multitouch protocol type B states */
-	if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT) &&
-	    evdev->ev_absinfo != NULL && MAXIMAL_MT_SLOT(evdev) > 0)
+	if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT))
 		evdev_mt_init(evdev);
 
 	/* Estimate maximum report size */
diff --git a/sys/dev/hid/hid.c b/sys/dev/hid/hid.c
index 699bfa4a8bb..fbbd998b5bf 100644
--- a/sys/dev/hid/hid.c
+++ b/sys/dev/hid/hid.c
@@ -856,6 +856,7 @@ hid_item_resolution(struct hid_item *hi)
 		divisor = 10;
 		break;
 	case HUM_INCH:
+	case HUM_INCH + 0x20:
 		multiplier = 10;
 		divisor = 254;
 		break;
diff --git a/sys/dev/hid/hidbus.c b/sys/dev/hid/hidbus.c
index be356484298..646e88e7884 100644
--- a/sys/dev/hid/hidbus.c
+++ b/sys/dev/hid/hidbus.c
@@ -171,6 +171,25 @@ hidbus_locate(const void *desc, hid_size_t size, int32_t u, enum hid_kind k,
 	return (0);
 }
 
+bool
+hidbus_is_collection(const void *desc, hid_size_t size, int32_t usage,
+    uint8_t tlc_index)
+{
+	struct hid_data *d;
+	struct hid_item h;
+	bool ret = false;
+
+	d = hid_start_parse(desc, size, 0);
+	HIDBUS_FOREACH_ITEM(d, &h, tlc_index) {
+		if (h.kind == hid_collection && h.usage == usage) {
+			ret = true;
+			break;
+		}
+	}
+	hid_end_parse(d);
+	return (ret);
+}
+
 static device_t
 hidbus_add_child(device_t dev, u_int order, const char *name, int unit)
 {
diff --git a/sys/dev/hid/hidbus.h b/sys/dev/hid/hidbus.h
index 05911fff573..d4324a2dc39 100644
--- a/sys/dev/hid/hidbus.h
+++ b/sys/dev/hid/hidbus.h
@@ -152,6 +152,7 @@ int	hidbus_locate(const void *desc, hid_size_t size, int32_t u,
 	    enum hid_kind k, uint8_t tlc_index, uint8_t index,
 	    struct hid_location *loc, uint32_t *flags, uint8_t *id,
 	    struct hid_absinfo *ai);
+bool	hidbus_is_collection(const void *, hid_size_t, int32_t, uint8_t);
 
 const struct hid_device_id *hidbus_lookup_id(device_t,
 		    const struct hid_device_id *, int);
diff --git a/sys/dev/hid/hidmap.c b/sys/dev/hid/hidmap.c
index 46e789fa7ce..d787b298b41 100644
--- a/sys/dev/hid/hidmap.c
+++ b/sys/dev/hid/hidmap.c
@@ -451,7 +451,8 @@ hidmap_probe_hid_descr(void *d_ptr, hid_size_t d_len, uint8_t tlc_index,
 	bool do_free = false;
 
 	if (caps == NULL) {
-		caps = malloc(HIDMAP_CAPS_SZ(nitems_map), M_DEVBUF, M_WAITOK);
+		caps = malloc(HIDMAP_CAPS_SZ(nitems_map), M_DEVBUF,
+		    M_WAITOK | M_ZERO);
 		do_free = true;
 	} else
 		bzero (caps, HIDMAP_CAPS_SZ(nitems_map));
@@ -481,7 +482,10 @@ hidmap_probe_hid_descr(void *d_ptr, hid_size_t d_len, uint8_t tlc_index,
 	/* Check that all mandatory usages are present in report descriptor */
 	if (items != 0) {
 		for (i = 0; i < nitems_map; i++) {
-			if (map[i].required && isclr(caps, i)) {
+			KASSERT(!(map[i].required && map[i].forbidden),
+			    ("both required & forbidden item flags are set"));
+			if ((map[i].required && isclr(caps, i)) ||
+			    (map[i].forbidden && isset(caps, i))) {
 				items = 0;
 				break;
 			}
diff --git a/sys/dev/hid/hidmap.h b/sys/dev/hid/hidmap.h
index 6ac23b3dc4e..62888109263 100644
--- a/sys/dev/hid/hidmap.h
+++ b/sys/dev/hid/hidmap.h
@@ -62,6 +62,8 @@ typedef int hidmap_cb_t(HIDMAP_CB_ARGS);
 /* These helpers can be used at any stage of any callbacks */
 #define	HIDMAP_CB_GET_STATE(...)					\
 	((hm == NULL) ? HIDMAP_CB_IS_PROBING : hm->cb_state)
+#define	HIDMAP_CB_GET_DEV(...)						\
+	(hm == NULL ? NULL : hm->dev)
 #define	HIDMAP_CB_GET_SOFTC(...)					\
 	(hm == NULL ? NULL : device_get_softc(hm->dev))
 #define	HIDMAP_CB_GET_EVDEV(...)					\
@@ -98,7 +100,8 @@ struct hidmap_item {
 	bool			has_cb:1;
 	bool			final_cb:1;
 	bool			invert_value:1;
-	u_int			reserved:10;
+	bool			forbidden:1;	/* Forbidden by driver */
+	u_int			reserved:9;
 };
 
 #define	HIDMAP_ANY(_page, _usage, _type, _code)				\
diff --git a/sys/dev/hid/hms.c b/sys/dev/hid/hms.c
index 94267b3fcd5..0f60eec86a4 100644
--- a/sys/dev/hid/hms.c
+++ b/sys/dev/hid/hms.c
@@ -109,6 +109,7 @@ static const struct hidmap_item hms_map_wheel_rev[] = {
 
 /* A match on these entries will load hms */
 static const struct hid_device_id hms_devs[] = {
+	{ HID_TLC(HUP_GENERIC_DESKTOP, HUG_POINTER) },
 	{ HID_TLC(HUP_GENERIC_DESKTOP, HUG_MOUSE) },
 };
 
diff --git a/sys/dev/hid/hmt.c b/sys/dev/hid/hmt.c
index fd50ea4de82..39063f2c822 100644
--- a/sys/dev/hid/hmt.c
+++ b/sys/dev/hid/hmt.c
@@ -207,6 +207,8 @@ struct hmt_softc {
 	uint8_t			report_id;
 	uint32_t		max_button;
 	bool			has_int_button;
+	bool			has_cont_count;
+	bool			has_scan_time;
 	bool			is_clickpad;
 	bool			do_timestamps;
 #ifdef IICHID_SAMPLING
@@ -374,7 +376,8 @@ hmt_attach(device_t dev)
 		sc->ai[HMT_SLOT].max = MAX_MT_SLOTS - 1;
 	}
 
-	if (hid_test_quirk(hw, HQ_MT_TIMESTAMP) || hmt_timestamps)
+	if (sc->has_scan_time &&
+	    (hid_test_quirk(hw, HQ_MT_TIMESTAMP) || hmt_timestamps))
 		sc->do_timestamps = true;
 #ifdef IICHID_SAMPLING
 	if (hid_test_quirk(hw, HQ_IICHID_SAMPLING))
@@ -517,6 +520,12 @@ hmt_intr(void *context, void *buf, hid_size_t len)
 	}
 
 	/*
+	 * "In serial mode, each packet contains information that describes a
+	 * single physical contact point. Multiple contacts are streamed
+	 * serially. In this mode, devices report all contact information in a
+	 * series of packets. The device sends a separate packet for each
+	 * concurrent contact."
+	 *
 	 * "In Parallel mode, devices report all contact information in a
 	 * single packet. Each physical contact is represented by a logical
 	 * collection that is embedded in the top-level collection."
@@ -525,7 +534,10 @@ hmt_intr(void *context, void *buf, hid_size_t len)
 	 * report with contactid=0 but contactids are zero-based, find
 	 * contactcount first.
 	 */
-	cont_count = hid_get_udata(buf, len, &sc->cont_count_loc);
+	if (sc->has_cont_count)
+		cont_count = hid_get_udata(buf, len, &sc->cont_count_loc);
+	else
+		cont_count = 1;
 	/*
 	 * "In Hybrid mode, the number of contacts that can be reported in one
 	 * report is less than the maximum number of contacts that the device
@@ -764,7 +776,6 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 				sc->cont_count_loc = hi.loc;
 				break;
 			}
-			/* Scan time is required but clobbered by evdev */
 			if (hi.collevel == 1 && hi.usage ==
 			    HID_USAGE2(HUP_DIGITIZERS, HUD_SCAN_TIME)) {
 				scan_time_found = true;
@@ -815,7 +826,7 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 	hid_end_parse(hd);
 
 	/* Check for required HID Usages */
-	if (!cont_count_found || !scan_time_found || cont == 0)
+	if ((!cont_count_found && cont != 1) || cont == 0)
 		return (HMT_TYPE_UNSUPPORTED);
 	for (i = 0; i < HMT_N_USAGES; i++) {
 		if (hmt_hid_map[i].required && isclr(sc->caps, i))
@@ -859,6 +870,8 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 	sc->report_id = report_id;
 	sc->nconts_per_report = cont;
 	sc->has_int_button = has_int_button;
+	sc->has_cont_count = cont_count_found;
+	sc->has_scan_time = scan_time_found;
 
 	return (type);
 }
diff --git a/sys/dev/hid/hpen.c b/sys/dev/hid/hpen.c
index 1d505e14089..8a86b95b102 100644
--- a/sys/dev/hid/hpen.c
+++ b/sys/dev/hid/hpen.c
@@ -72,44 +72,43 @@ static hidmap_cb_t	hpen_final_pen_cb;
 	HIDMAP_ABS_CB(HUP_DIGITIZERS, HUD_##usage, &cb)
 
 /* Generic map digitizer page map according to hut1_12v2.pdf */
-static const struct hidmap_item hpen_map_digi[] = {
+static const struct hidmap_item hpen_map_pen[] = {
     { HPEN_MAP_ABS_GD(X,		ABS_X),		  .required = true },
     { HPEN_MAP_ABS_GD(Y,		ABS_Y),		  .required = true },
     { HPEN_MAP_ABS(   TIP_PRESSURE,	ABS_PRESSURE) },
     { HPEN_MAP_ABS(   X_TILT,		ABS_TILT_X) },
     { HPEN_MAP_ABS(   Y_TILT,		ABS_TILT_Y) },
+    { HPEN_MAP_ABS(   CONTACTID,	0), 		  .forbidden = true },
+    { HPEN_MAP_ABS(   CONTACTCOUNT,	0), 		  .forbidden = true },
     { HPEN_MAP_ABS_CB(BATTERY_STRENGTH,	hpen_battery_strenght_cb) },
     { HPEN_MAP_BUT(   TOUCH,		BTN_TOUCH) },
     { HPEN_MAP_BUT(   TIP_SWITCH,	BTN_TOUCH) },
     { HPEN_MAP_BUT(   SEC_TIP_SWITCH,	BTN_TOUCH) },
-    { HPEN_MAP_BUT(   IN_RANGE,		BTN_TOOL_PEN) },
     { HPEN_MAP_BUT(   BARREL_SWITCH,	BTN_STYLUS) },
     { HPEN_MAP_BUT(   INVERT,		BTN_TOOL_RUBBER) },
     { HPEN_MAP_BUT(   ERASER,		BTN_TOUCH) },
     { HPEN_MAP_BUT(   TABLET_PICK,	BTN_STYLUS2) },
     { HPEN_MAP_BUT(   SEC_BARREL_SWITCH,BTN_STYLUS2) },
-    { HIDMAP_FINAL_CB(			&hpen_final_digi_cb) },
+    { HIDMAP_FINAL_CB(			&hpen_final_pen_cb) },
 };
 
-/* Microsoft-standardized pen support */
-static const struct hidmap_item hpen_map_pen[] = {
-    { HPEN_MAP_ABS_GD(X,		ABS_X),		  .required = true },
-    { HPEN_MAP_ABS_GD(Y,		ABS_Y),		  .required = true },
-    { HPEN_MAP_ABS(   TIP_PRESSURE,	ABS_PRESSURE),	  .required = true },
-    { HPEN_MAP_ABS(   X_TILT,		ABS_TILT_X) },
-    { HPEN_MAP_ABS(   Y_TILT,		ABS_TILT_Y) },
-    { HPEN_MAP_ABS_CB(BATTERY_STRENGTH,	hpen_battery_strenght_cb) },
-    { HPEN_MAP_BUT(   TIP_SWITCH,	BTN_TOUCH),	  .required = true },
-    { HPEN_MAP_BUT(   IN_RANGE,		BTN_TOOL_PEN),	  .required = true },
-    { HPEN_MAP_BUT(   BARREL_SWITCH,	BTN_STYLUS) },
-    { HPEN_MAP_BUT(   INVERT,		BTN_TOOL_RUBBER), .required = true },
-    { HPEN_MAP_BUT(   ERASER,		BTN_TOUCH),	  .required = true },
-    { HIDMAP_FINAL_CB(			&hpen_final_pen_cb) },
+static const struct hidmap_item hpen_map_stylus[] = {
+    { HPEN_MAP_BUT(   IN_RANGE,		BTN_TOOL_PEN) },
+};
+static const struct hidmap_item hpen_map_finger[] = {
+    { HPEN_MAP_BUT(   IN_RANGE,		BTN_TOOL_FINGER) },
 };
 
 static const struct hid_device_id hpen_devs[] = {
 	{ HID_TLC(HUP_DIGITIZERS, HUD_DIGITIZER) },
 	{ HID_TLC(HUP_DIGITIZERS, HUD_PEN) },
+	{ HID_TLC(HUP_DIGITIZERS, HUD_TOUCHSCREEN),
+	  HID_BVP(BUS_USB, USB_VENDOR_EGALAX, USB_PRODUCT_EGALAX_TPANEL) },
+};
+
+/* Do not autoload legacy pen driver for all touchscreen */
+static const struct hid_device_id hpen_devs_no_load[] = {
+	{ HID_TLC(HUP_DIGITIZERS, HUD_TOUCHSCREEN) },
 };
 
 static int
@@ -134,25 +133,18 @@ hpen_battery_strenght_cb(HIDMAP_CB_ARGS)
 	return (0);
 }
 
-static int
-hpen_final_digi_cb(HIDMAP_CB_ARGS)
-{
-	struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV();
-
-	if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING)
-		evdev_support_prop(evdev, INPUT_PROP_POINTER);
-
-	/* Do not execute callback at interrupt handler and detach */
-	return (ENOSYS);
-}
-
 static int
 hpen_final_pen_cb(HIDMAP_CB_ARGS)
 {
 	struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV();
 
-	if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING)
-		evdev_support_prop(evdev, INPUT_PROP_DIRECT);
+	if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) {
+		if (hidbus_get_usage(HIDMAP_CB_GET_DEV()) ==
+		    HID_USAGE2(HUP_DIGITIZERS, HUD_DIGITIZER))
+			evdev_support_prop(evdev, INPUT_PROP_POINTER);
+		else
+			evdev_support_prop(evdev, INPUT_PROP_DIRECT);
+	}
 
 	/* Do not execute callback at interrupt handler and detach */
 	return (ENOSYS);
@@ -185,24 +177,39 @@ static int
 hpen_probe(device_t dev)
 {
 	struct hidmap *hm = device_get_softc(dev);
+	const char *desc;
+	void *d_ptr;
+	hid_size_t d_len;
 	int error;
-	bool is_pen;
 
-	error = HIDBUS_LOOKUP_DRIVER_INFO(dev, hpen_devs);
-	if (error != 0)
-		return (error);
+	if (HIDBUS_LOOKUP_DRIVER_INFO(dev, hpen_devs_no_load) != 0) {
+		error = HIDBUS_LOOKUP_DRIVER_INFO(dev, hpen_devs);
+		if (error != 0)
+			return (error);
+	}
 
 	hidmap_set_dev(hm, dev);
 
-	/* Check if report descriptor belongs to a HID tablet device */
-	is_pen = hidbus_get_usage(dev) == HID_USAGE2(HUP_DIGITIZERS, HUD_PEN);
-	error = is_pen
-	    ? HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL)
-	    : HIDMAP_ADD_MAP(hm, hpen_map_digi, NULL);
+	/* Check if report descriptor belongs to a HID pen device */
+	error = HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL);
 	if (error != 0)
 		return (error);
 
-	hidbus_set_desc(dev, is_pen ? "Pen" : "Digitizer");
+	if (hid_get_report_descr(dev, &d_ptr, &d_len) != 0)
+		return (ENXIO);
+
+	if (hidbus_is_collection(d_ptr, d_len,
+	    HID_USAGE2(HUP_DIGITIZERS, HUD_FINGER), hidbus_get_index(dev))) {
+		HIDMAP_ADD_MAP(hm, hpen_map_finger, NULL);
+		desc = "TouchScreen";
+	} else {
+		HIDMAP_ADD_MAP(hm, hpen_map_stylus, NULL);
+		desc = "Pen";
+	}
+	if (hidbus_get_usage(dev) == HID_USAGE2(HUP_DIGITIZERS, HUD_DIGITIZER))
+		desc = "Digitizer";
+
+	hidbus_set_desc(dev, desc);
 
 	return (BUS_PROBE_DEFAULT);
 }

Reply via email to