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)
Wed, Mar 27, 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
Unknown Object (File)
Nov 16 2023, 8:49 AM
Unknown Object (File)
Oct 15 2023, 7:46 AM
Unknown Object (File)
Oct 3 2023, 4:28 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 44644
Build 41532: arc lint + arc unit

Event Timeline

sys/dev/hid/bcm5974.c
168

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

175

ditto

371

Size member should be 0 for pressure

768

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

775

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
168

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

175

The second bitfield piece is one byte.

371

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

sys/dev/hid/bcm5974.c
175

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.