Skip to content

HID: bring up the trackpad of the 14-inch M5 Max MacBook Pro - #1568

Draft
joshuaswarren wants to merge 4 commits into
aurora-silicon:integration/aurorafrom
joshuaswarren:w7c/up-k114c-trackpad
Draft

joshuaswarren wants to merge 4 commits into
aurora-silicon:integration/aurorafrom
joshuaswarren:w7c/up-k114c-trackpad

Conversation

@joshuaswarren

Copy link
Copy Markdown
Contributor

The trackpad of the 14-inch M5 Max MacBook Pro (K114c, T6050) did not register at all. This fixes it in four steps.

  1. dockchannel-hid clamps oversized Report Size items. The multi-touch interface declares its raw touch report as one Report Size item of 0x80000 bits. hid-core rejects anything above 16384 with invalid report_size 524288, so the device never came up even though the firmware, the interface and the keyboard did. A KUnit case covers the clamp.
  2. hid-magicmouse no longer marks the MTP trackpad as a direct device.
  3. hid-magicmouse drops the Generic Desktop mouse usages on dockchannel MTP devices.
  4. hid-magicmouse parses report 0x5a. This firmware does not send the 0x75 report magicmouse registers, so hid_input_report() returned -1 for every packet. The 0x75 path is unchanged.

Tested on the hardware: with the parser loaded the input device reported 929 frames, X from -5896 to 5875, four clicks and the two-finger tool bit. The report layout comes from kprobe captures with one, two and three fingers, documented in the commit message. The button bit and the phase rule are read from those captures. Three floats in the contact record are still unidentified.

Opened as a draft: the layout is verified on one board only, and the MTP interface on other T6050 boards is untested.

The multi-touch interface of the 14-inch M5 Max MacBook Pro (t6050)
declares its raw touch report as a single Report Size item of 0x80000
bits. hid-core rejects any Report Size above 16384 with "invalid
report_size 524288", so the trackpad never registered although the
firmware, the interface and the keyboard all came up.

hid-magicmouse consumes these reports in raw_event() and never uses the
parsed field layout. Clamp each Report Size item in the copied descriptor
to the hid-core limit before parsing, and log the clamp once per item.

A KUnit case feeds a descriptor with a long item whose data looks like a
Report Size prefix, a normal Report Size and the oversized one, and checks
that only the oversized item changes.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
The K114c multi-touch descriptor has a Digitizer-page field under a Mouse
application. hid-input reads that as a pen and sets INPUT_PROP_DIRECT, and
udev then tags the trackpad as a touchscreen instead of a touchpad. The
pad is an indirect pointing device: clear the property.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
The dockchannel MTP descriptor of the K114c opens with a Generic Desktop
Mouse collection next to the multi-touch part. hid-input maps its
buttons and axes, so the input device is a mouse and a multi-touch pad
at once, and libinput refuses that hybrid.

raw_event() drives every event of these devices. Ignore the usages of
the Mouse application on dockchannel MTP devices so the input device is
a plain touchpad. The keyboard interface is a GD Keyboard and is not
affected.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
The K114c MTP firmware (personality K2C1, "AppleMTPFirmwareMac-6320.86.1")
does not send the 0x75 report that magicmouse registers. It sends report
0x5a. hid_get_report() finds no report with that id, so hid_input_report()
returned -1 for every packet and the trackpad never produced an input
event, although the dockchannel interrupt fired on every touch.

Register 0x5a next to 0x75 and parse it on dockchannel devices. 0x75
devices keep the old parser.

Report layout. Offsets are bytes from the report id, little endian:

  0       report id, 0x5a
  1-47    firmware header: counter, timestamp. Not used.
  48      contact section tag, 0x02
  49      section header size, 8
  50      contact record size, 48
  51      section payload size, header size + count * record size
  53      number of contact records
  59      bit 4: physical button
  60      start of the first record
  total   113 + 48 * count bytes, so 113, 161, 209, 257 for 0 to 3 contacts

Contact record, 48 bytes:

  +1      tracking id, rolling
  +2      phase: 1 start, 2-3 approach, 4 touching, 5-7 lifting, 0 gone
  +5      f32 x, in micrometres
  +9      f32 y
  +13     f32 velocity x
  +17     f32 velocity y
  +21     f32 major axis
  +25     f32 minor axis
  +29     three f32 whose meaning is not known
  +41     f32 force, 0 to about 840 at a hard click
  +45     three bytes, not used

A contact counts in phases 3 and 4. The floats are converted by hand
because the kernel avoids the FPU. Positions and axes go out in tens of
micrometres, which fits the J314 ranges the input device already
advertises.

The layout was read from kprobe captures of hid_input_report() on a 14-inch
M5 Max MacBook Pro with one, two and three fingers and clicks. With the
parser loaded, the input device reported 929 frames, X -5896 to 5875, four
clicks and the two-finger tool bit. The button bit and the phase rule are
read from those captures, not from documentation.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks Joshua. Regression rows for the shared MTP path, kernel integration c6c15ac + this PR (with #1601/#1605/#1606), one boot each:

  • M2 (J413) and M4 Pro (J616s): dockchannel-hid 0 errors, every interface ready, libinput devices identical to the base kernel, s2idle 1/1. The one difference: the multi-touch input device no longer has EV_MSC/MSC_SCAN, from dropping the GD Mouse usages. Keys, axes and props are unchanged, and libinput classifies the pad the same.
  • Neo (T8140) and J714s rows are still to come; this merges once they're in.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Neo (J700, T8140) row: PASS, the same as the M2 and J616s. Kernel fleet64 base 1de767b + this PR (with #1601/#1605/#1606). dockchannel-hid 0 errors, GPIO state and libinput devices identical to the base, s2idle 1/1. The only input change is again the multi-touch device dropping EV_MSC/MSC_SCAN. The J714s row is the last one before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants