Page MenuHomeFreeBSD

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

Authored by greg_unrelenting.technology on Mar 3 2022, 11:32 PM.

Details

Reviewers
wulf
Group Reviewers
Contributor Reviews (base)
desktop
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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44655
Build 41543: arc lint + arc unit

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

374

Size member should be 0 for pressure

761

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

768

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

greg_unrelenting.technology 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.

374

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.