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, Dec 7, 2:13 PM
Unknown Object (File)
Nov 14 2024, 3:54 PM
Unknown Object (File)
Oct 13 2024, 3:33 PM
Unknown Object (File)
Sep 29 2024, 8:27 AM
Unknown Object (File)
Sep 29 2024, 8:21 AM
Unknown Object (File)
Sep 29 2024, 8:18 AM
Unknown Object (File)
Sep 29 2024, 6:25 AM
Unknown Object (File)
Sep 26 2024, 4:19 PM

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
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

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.

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.

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.