Skip to content

HID: MacBookPro15,4 reporting 05ac:0277 — add WELLSPRINGT2_J223_ALT for keyboard backlight and trackpad #25

Description

@c0deAbra

Summary

On this MacBookPro15,4 (board Mac-53FDB3D8DB8CA971, i.e. J223) the internal
keyboard/trackpad enumerates as 05ac:0277 instead of 0x027f. That product
id appears in no kernel table, so hid-generic claims all five interfaces:

  • no keyboard backlight LED is registered at all, and
  • the trackpad degrades to a plain 3-button relative mouse — EV=17 ABS=0 REL=3 PROP=0,
    i.e. not even a scroll axis — so libinput has nothing to build two-finger scroll
    or gestures from.

The hardware is otherwise an ordinary J223. Adding the id as WELLSPRINGT2_J223_ALT,
mirroring the existing J680_ALT (0x0278) precedent where Apple likewise ships an
alternate product id for one board, makes both work fully.

Environment

Model MacBookPro15,4 / Mac-53FDB3D8DB8CA971
Kernel 7.1.8-arch1-...-t2 (Arch linux-t2 7.1.8.arch1-3)
Patch series linux-t2-patches @ 79ed04627b (KVER=7.1.4)
usb 5-5: New USB device found, idVendor=05ac, idProduct=0277, bcdDevice= 8.96
usb 5-5: Product: Apple Internal Keyboard / Trackpad

Interface layout is the usual T2 one: iface 0/3/4 vendor collections, iface 1
the keyboard (vendor usage ff00.000f present), iface 2 the HID_TYPE_USBMOUSE
trackpad.

Evidence that it really is a J223

Keyboard backlight. Interface 1 answers the 0xBF backlight config feature
report with a valid structure:

$ HIDIOCGFEATURE(0xBF) on the iface-1 hidraw node
bf 01 00 00 20 00 00 02
   ^^ version=1  ^^^^^ on_min=32  ^^^^^ on_max=512

Binding hid-apple to interface 1 with the J223 quirks (via the HID bus new_id
interface, plus APPLE_BACKLIGHT_CTL) registers apple::kbd_backlight with
max_brightness = 512, and it works — including the Touch Bar's
XF86KbdBrightnessUp/Down keys.

Trackpad. Building hid-magicmouse with 0x0277 added alongside J223
(same geometry: X -6046..6536, Y -164..7439) turns it into a real clickpad:

before:  EV=17  ABS=0                 REL=3  PROP=0
after:   EV=1b  ABS=67f800001000003   REL=0  PROP=5   (POINTER|BUTTONPAD)

with the full multitouch stack — ABS_MT_SLOT, ABS_MT_POSITION_X/Y,
ABS_MT_TRACKING_ID, ABS_MT_PRESSURE, ABS_MT_TOUCH_MAJOR/MINOR,
ABS_MT_ORIENTATION. Pointing, two-finger scroll and gestures all behave
correctly, so the J223 geometry is right for this unit.

Note on APPLE_BACKLIGHT_CTL

The current J223 entry in hid-apple has no APPLE_BACKLIGHT_CTL, yet this
unit answers the backlight reports and drives the LED correctly. The proposed
entry includes the quirk; the plain J223 entry may deserve it too, but I have
no 0x027f machine to confirm that on.

Why new_id is not enough

hid-apple is quirk-driven, so the keyboard side can be handled at runtime with
new_id. hid-magicmouse cannot: it selects trackpad geometry and the
multitouch-enable feature report with switch (id->product), and new_id only
supplies driver_data. An unlisted id falls through every case, so the id has to
be compiled in — hence this request rather than a local workaround.

Patch

Against the tree with 4001/4003/4004/4005 applied. I have been running it
(as a DKMS build of hid-magicmouse plus new_id for hid-apple) with both
devices fully working.

--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@
 #define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223		0x027f
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223_ALT	0x0277
 #define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K		0x0280

--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223),
 		.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_DISABLE_FKEYS |
 				APPLE_IGNORE_MOUSE },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223_ALT),
+		.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK |
+				APPLE_DISABLE_FKEYS | APPLE_IGNORE_MOUSE },

--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -195,6 +195,15 @@
 #define J223_TP_RES_Y \
 	((J223_TP_MAX_Y - J223_TP_MIN_Y) / (J223_TP_DIMENSION_Y / 100))
 
+#define J223_ALT_TP_DIMENSION_X J223_TP_DIMENSION_X
+#define J223_ALT_TP_MIN_X J223_TP_MIN_X
+#define J223_ALT_TP_MAX_X J223_TP_MAX_X
+#define J223_ALT_TP_RES_X J223_TP_RES_X
+#define J223_ALT_TP_DIMENSION_Y J223_TP_DIMENSION_Y
+#define J223_ALT_TP_MIN_Y J223_TP_MIN_Y
+#define J223_ALT_TP_MAX_Y J223_TP_MAX_Y
+#define J223_ALT_TP_RES_Y J223_TP_RES_Y
+
 #define J230K_TP_DIMENSION_X (float)12100
 #define J230K_TP_MIN_X -5318
 #define J230K_TP_MAX_X 5787
@@ -1169,6 +1178,7 @@
 	T2_TOUCHPAD_ENTRY(J213),
 	T2_TOUCHPAD_ENTRY(J214K),
 	T2_TOUCHPAD_ENTRY(J223),
+	T2_TOUCHPAD_ENTRY(J223_ALT),
 	T2_TOUCHPAD_ENTRY(J230K),
 	T2_TOUCHPAD_ENTRY(J152F),
 };
@@ -1387,6 +1397,7 @@
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223:
+	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223_ALT:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F:
 		feature_size = sizeof(feature_mt_trackpad2_usb);
@@ -1498,6 +1509,7 @@
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223:
+	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223_ALT:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F:
 		if (hdev->type != HID_TYPE_USBMOUSE)
@@ -1531,6 +1543,7 @@
 		case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213:
 		case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K:
 		case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223:
+		case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223_ALT:
 		case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K:
 		case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F:
 			msc->input_ops.raw_event = magicmouse_raw_event_t2;
@@ -1607,6 +1620,7 @@
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223:
+	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223_ALT:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K:
 	case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F:
 		report = hid_register_report(hdev, HID_INPUT_REPORT,
@@ -1733,6 +1747,8 @@
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
 		USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223), .driver_data = 0 },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
+		USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223_ALT), .driver_data = 0 },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
 		USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K), .driver_data = 0 },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
 		USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F), .driver_data = 0 },

Happy to turn this into a PR in the series' numbering scheme if that is preferred,
and to run any test you want on the hardware.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions