Repository navigation
HID: let hid-generic take Apple internal interfaces no driver wants - #2262
Draft
RyanTheTide wants to merge 1 commit into
Draft
RyanTheTide wants to merge 1 commit into
RyanTheTide wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_IDand return-ENODEVfrom 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):
0019:05AC:0351.0005 "Apple MTP tp_accel"has no driver. dmesg shows hid-generic binding it at 2.54 s ashidraw4. It loses the binding when hid_apple/hid_magicmouse load and the bus reprobes it.0019:05AC:035A.0005 "tp-accel"and.0006 "mtp"never bind.Change
__check_hid_generic()now asks a driver's.matchcallback, if it has one, before handing a device over to it..matchcallbacks. 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
Still to run
tp_accel/tp-accel/mtpbound 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.Details
hid_check_device_match()already callshdrv->matchwhen 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.matchare hid-generic and hid-apple-mtp-haptic, plus the two added here.hid_ignore_special_drivers/HID_QUIRK_IGNORE_SPECIAL_DRIVERbehaviour, because a driver's.matchreplaces that check inhid_check_device_match().BUS_HOSTApple withHID_ANY_ID. Once it lands it would claim these interfaces again unless it gets a.matchlike the two above.__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)