Skip to content

HID: let hid-generic take Apple internal interfaces no driver wants - #2262

Draft
RyanTheTide wants to merge 1 commit into
integration/aurorafrom
drvgap/hid-generic-special-match
Draft

RyanTheTide wants to merge 1 commit into
integration/aurorafrom
drvgap/hid-generic-special-match

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

The internal keyboard controllers on Apple laptops (SPI and DockChannel) give every interface the controller's vendor and product ID. hid-apple, hid-magicmouse and hid-apple-mtp-haptic list that ID with HID_ANY_ID and return -ENODEV from probe for the interfaces they don't drive. hid-generic refuses those interfaces as well, because __check_hid_generic() only checks the other drivers' ID tables. Those interfaces end up with no driver.

Seen on current fleet kernels (read-only sysfs and dmesg):

  • M2 MacBook Air (J413, 7.3.0-aurora-fleet74): 0019:05AC:0351.0005 "Apple MTP tp_accel" has no driver. dmesg shows hid-generic binding it at 2.54 s as hidraw4. It loses the binding when hid_apple/hid_magicmouse load and the bus reprobes it.
  • M4 Pro MacBook Pro (J616s, 7.3.0-aurora-fleet75): 0019:05AC:035A.0005 "tp-accel" and .0006 "mtp" never bind.

Change

  • __check_hid_generic() now asks a driver's .match callback, if it has one, before handing a device over to it.
  • hid-apple and hid-magicmouse get .match callbacks. For Apple SPI/host-bus devices they accept only the keyboard and trackpad interface types (HID_TYPE_SPI_KEYBOARD / HID_TYPE_SPI_MOUSE, set by spi-hid-apple and dockchannel-hid). Every other device matches as before. hid-apple-mtp-haptic already has a .match.

The extra interfaces then bind to hid-generic as hidraw nodes. That is the state the M2 already reaches during boot before the reprobe drops it.

Testing

  • Compile check (arm64, LLVM, W=1) of hid-generic.o, hid-apple.o, hid-magicmouse.o and hid-apple-mtp-haptic.o on integration 0abc2f3: no warnings. checkpatch: clean.

Still to run

  • M2 and J616s boot: tp_accel/tp-accel/mtp bound to hid-generic (hidraw only, no new input device). Keyboard, trackpad and haptics still bind to apple/magicmouse/hid-apple-mtp-haptic, the Fn keys and force click still work, and s2idle comes back with all of them bound.
  • M1 Pro (SPI HID): no change in bindings.
Details
  • hid_check_device_match() already calls hdrv->match when it decides whether a driver may probe. This patch only brings the hid-generic veto in line with it. The only drivers in the tree with a .match are hid-generic and hid-apple-mtp-haptic, plus the two added here.
  • The new callbacks keep the old hid_ignore_special_drivers / HID_QUIRK_IGNORE_SPECIAL_DRIVER behaviour, because a driver's .match replaces that check in hid_check_device_match().
  • Open HID: apple-mtp-kiwi: the K114c touch screen (needs #1568) #1605 (hid-apple-mtp-kiwi) also lists BUS_HOST Apple with HID_ANY_ID. Once it lands it would claim these interfaces again unless it gets a .match like the two above.
  • Why the M2 binding is lost: when a HID driver registers, __hid_bus_reprobe_drivers() reprobes every device that hid-generic holds but no longer matches. The new driver then turns the device down, and it is left with nothing.

Assisted-by: LLM (Claude:Opus 5.5)

The internal keyboard controllers on Apple laptops (SPI and DockChannel)
give every interface the same vendor and product ID. hid-apple,
hid-magicmouse and hid-apple-mtp-haptic list that ID with HID_ANY_ID,
and each probe returns -ENODEV for the interfaces it does not drive.
hid-generic then refuses them too, because __check_hid_generic() only
looks at the other drivers' ID tables.

So the extra interfaces stay unbound. On the M2 MacBook Air the
DockChannel "tp_accel" interface binds to hid-generic during boot
(hidraw4) and is unbound again once hid_apple and hid_magicmouse load
and the bus reprobes it. On the M4 Pro MacBook Pro "tp-accel" and "mtp"
never bind at all.

Make __check_hid_generic() ask a driver's match callback, so a driver
can decline a device its table covers. Give hid-apple and hid-magicmouse
callbacks that keep only the keyboard and trackpad interface types of
these controllers; hid-apple-mtp-haptic already has one. Every other
device matches as before.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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.

1 participant