projects/linux·tree master · refs

Files

ModeNameSize
040000../--
100644FR-TEC__Raptor-Mach-2.bpf.c10.2 KiB
100644Generic__touchpad.bpf.c1.9 KiB
100644HP__Elite-Presenter.bpf.c1.6 KiB
100644Huion__Dial-2.bpf.c23.0 KiB
100644Huion__Inspiroy-2-M.bpf.c18.8 KiB
100644Huion__Inspiroy-2-S.bpf.c19.2 KiB
100644Huion__Inspiroy-Frego-M.bpf.c2.4 KiB
100644Huion__Kamvas-Pro-19.bpf.c20.2 KiB
100644Huion__Kamvas13Gen3.bpf.c66.3 KiB
100644Huion__Kamvas16Gen3.bpf.c34.7 KiB
100644Huion__KeydialK20-Bluetooth.bpf.c24.9 KiB
100644Huion__KeydialK20.bpf.c22.3 KiB
100644IOGEAR__Kaliber-MMOmentum.bpf.c1.5 KiB
100644Logitech__SpaceNavigator.bpf.c2.5 KiB
100644Makefile2.6 KiB
100644Microsoft__Xbox-Elite-2.bpf.c5.7 KiB
100644Mistel__MD770.bpf.c7.4 KiB
100644README3.1 KiB
100644Rapoo__M50-Plus-Silent.bpf.c6.9 KiB
100644TUXEDO__Sirius-16-Gen1-and-Gen2.bpf.c1.1 KiB
100644Thrustmaster__TCA-Yoke-Boeing.bpf.c7.5 KiB
100644Trust__Philips-SPK6327.bpf.c1.1 KiB
100644WALTOP__Batteryless-Tablet.bpf.c13.3 KiB
100644Wacom__ArtPen.bpf.c4.5 KiB
100644XPPen__ACK05.bpf.c11.6 KiB
100644XPPen__Artist24.bpf.c9.0 KiB
100644XPPen__ArtistPro16Gen2.bpf.c13.6 KiB
100644XPPen__Deco01V3.bpf.c14.2 KiB
100644XPPen__Deco02.bpf.c14.1 KiB
100644XPPen__DecoMini4.bpf.c9.5 KiB
100644hid_bpf.h565 B
100644hid_bpf_async.h5.2 KiB
100644hid_bpf_helpers.h17.7 KiB
100644hid_report_descriptor_helpers.h2.3 KiB
100644hid_report_helpers.h199.0 KiB
100644hid_usages.h173.4 KiB

drivers/hid/bpf/progs/README

# HID-BPF programs

This directory contains various fixes for devices. They add new features or
fix some behaviors without being entirely mandatory. It is better to load them
when you have such a device, but they should not be a requirement for a device
to be working during the boot stage.

The .bpf.c files provided here are not automatically compiled in the kernel.
They should be loaded in the kernel by `udev-hid-bpf`:

https://gitlab.freedesktop.org/libevdev/udev-hid-bpf

The main reasons for these fixes to be here is to have a central place to
"upstream" them, but also this way we can test them thanks to the HID
selftests.

Once a .bpf.c file is accepted here, it is duplicated in `udev-hid-bpf`
in the `src/bpf/stable` directory, and distributions are encouraged to
only ship those bpf objects. So adding a file here should eventually
land in distributions when they update `udev-hid-bpf`

## Compilation

Just run `make`

## Installation

### Automated way

Just run `sudo udev-hid-bpf install ./my-awesome-fix.bpf.o`

### Manual way

- copy the `.bpf.o` you want in `/etc/udev-hid-bpf/`
- create a new udev rule to automatically load it

The following should do the trick (assuming udev-hid-bpf is available in
/usr/bin):

```
$> cp xppen-ArtistPro16Gen2.bpf.o /etc/udev-hid-bpf/
$> udev-hid-bpf inspect xppen-ArtistPro16Gen2.bpf.o
[
  {
    "name": "xppen-ArtistPro16Gen2.bpf.o",
    "devices": [
      {
        "bus": "0x0003",
        "group": "0x0001",
        "vid": "0x28BD",
        "pid": "0x095A"
      },
      {
        "bus": "0x0003",
        "group": "0x0001",
        "vid": "0x28BD",
        "pid": "0x095B"
      }
    ],
...
$> cat <EOF > /etc/udev/rules.d/99-load-hid-bpf-xppen-ArtistPro16Gen2.rules
ACTION!="add|remove", GOTO="hid_bpf_end"
SUBSYSTEM!="hid", GOTO="hid_bpf_end"

# xppen-ArtistPro16Gen2.bpf.o
ACTION=="add",ENV{MODALIAS}=="hid:b0003g0001v000028BDp0000095A", RUN{program}+="/usr/local/bin/udev-hid-bpf add $sys$devpath /etc/udev-hid-bpf/xppen-ArtistPro16Gen2.bpf.o"
ACTION=="remove",ENV{MODALIAS}=="hid:b0003g0001v000028BDp0000095A", RUN{program}+="/usr/local/bin/udev-hid-bpf remove $sys$devpath "
# xppen-ArtistPro16Gen2.bpf.o
ACTION=="add",ENV{MODALIAS}=="hid:b0003g0001v000028BDp0000095B", RUN{program}+="/usr/local/bin/udev-hid-bpf add $sys$devpath /etc/udev-hid-bpf/xppen-ArtistPro16Gen2.bpf.o"
ACTION=="remove",ENV{MODALIAS}=="hid:b0003g0001v000028BDp0000095B", RUN{program}+="/usr/local/bin/udev-hid-bpf remove $sys$devpath "

LABEL="hid_bpf_end"
EOF
$> udevadm control --reload
```

Then unplug and replug the device.

## Checks

### udev rule

You can check that the udev rule is correctly working by issuing

```
$> udevadm test /sys/bus/hid/devices/0003:28BD:095B*
...
run: '/usr/local/bin/udev-hid-bpf add /sys/devices/virtual/misc/uhid/0003:28BD:095B.0E57 /etc/udev-hid-bpf/xppen-ArtistPro16Gen2.bpf.o'
```

### program loaded

You can check that the program has been properly loaded with `bpftool`

```
$> bpftool prog
...
247: tracing  name xppen_16_fix_eraser tag 18d389353ed2ef07  gpl
	loaded_at 2024-03-28T16:02:28+0100  uid 0
	xlated 120B  jited 77B  memlock 4096B
	btf_id 487
```