Page MenuHomeFreeBSD

bcm5974: add Magic Trackpad 2 (USB only for now) support
ClosedPublic

Authored by val_packett.cool on Mar 3 2022, 11:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 27, 1:32 AM
Unknown Object (File)
Fri, Apr 26, 10:20 PM
Unknown Object (File)
Mon, Apr 22, 6:40 AM
Unknown Object (File)
Mar 27 2024, 2:59 PM
Unknown Object (File)
Feb 12 2024, 9:56 AM
Unknown Object (File)
Jan 26 2024, 9:11 AM
Unknown Object (File)
Jan 23 2024, 1:58 PM
Unknown Object (File)
Dec 23 2023, 12:15 AM

Details

Summary

The MT2 uses a compact report format, but otherwise is similar in many ways to the internal trackpads, it even uses the same mode switching commands. (With an extra byte via bluetooth for some reason :/ but exactly the same via USB) I'm not sure if handling it in the same driver is the correct way to go, but it was easy to add here.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/dev/hid/bcm5974.c
192

AFAIK bitfields are not endian-safe. Replace this block with single uint32_t and use shifts with bitmasks

199

ditto

380

Size member should be 0 for pressure

781

No need to set EVDEV_FLAG_MT_TRACK flag while initializing evdev if device already exports good tracking id

788

Just do not declare ABS_MT_WIDTH_MAJOR/ABS_MT_WIDTH_MAJOR events during initialization instead of setting them to 0 here.

Endian convert the initial 32 bit field, use given IDs, do not report width major/minor

val_packett.cool added inline comments.
sys/dev/hid/bcm5974.c
192

Reading a *signed* 13 bit number with shifts and bitmasks sounds complicated, I used a union to read from an endian-converted uint32_t.

199

The second bitfield piece is one byte.

380

Just like wellspring9 this is truly force sensitive so resolution should be non-zero.

sys/dev/hid/bcm5974.c
199

The second bitfield piece is one byte.

On BE archs not bytes are stored in opposite order as compared to LE, but structure members. See e.g. https://github.com/freebsd/freebsd-src/blob/main/sys/dev/usb/usbdi.h#L273 . So shifts/masks should be used here too. Alternatively, usbdi.h trick with reversing of member order can be used. It looks better than shifts/masks but just now I have no access BE arch to test it especially for members which crosses byte boundaries.

This revision was not accepted when it landed; it landed in state Needs Review.Apr 25 2023, 9:22 AM
This revision was automatically updated to reflect the committed changes.