Skip to content

Commit d87f3fb

Browse files
committed
HID: apple: Bind Apple silicon SPI devices
Apple MacBook keyboards started using HID over SPI in 2015. With the addition of the SPI HID transport they can be supported by this driver. Support all product ids over with the Apple SPI vendor id for now. The Macbook Pro (M1, 13-inch, 2020) uses the same function key mapping as other Macbook Pros with touchbar and dedicated ESC key. Apple silicon Macbooks use the same function key mapping as the 2021 and later Magic Keyboards. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent aa26c21 commit d87f3fb

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

drivers/hid/hid-apple.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,18 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
472472
asc->fn_on = !!value;
473473

474474
if (real_fnmode) {
475+
switch (hid->bus) {
476+
case BUS_SPI:
477+
switch (hid->product) {
478+
case SPI_DEVICE_ID_APPLE_MACBOOK_PRO13_2020:
479+
table = macbookpro_dedicated_esc_fn_keys;
480+
break;
481+
default:
482+
table = magic_keyboard_2021_and_2024_fn_keys;
483+
break;
484+
}
485+
break;
486+
default:
475487
switch (hid->product) {
476488
case USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI:
477489
case USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO:
@@ -520,6 +532,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
520532
else
521533
table = apple_fn_keys;
522534
}
535+
}
523536

524537
trans = apple_find_translation(table, code);
525538

@@ -937,6 +950,10 @@ static int apple_probe(struct hid_device *hdev,
937950
struct apple_sc *asc;
938951
int ret;
939952

953+
if (id->bus == BUS_SPI && id->vendor == SPI_VENDOR_ID_APPLE &&
954+
hdev->type != HID_TYPE_SPI_KEYBOARD)
955+
return -ENODEV;
956+
940957
asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
941958
if (asc == NULL) {
942959
hid_err(hdev, "can't alloc apple descriptor\n");
@@ -1191,6 +1208,8 @@ static const struct hid_device_id apple_devices[] = {
11911208
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
11921209
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
11931210
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
1211+
{ HID_SPI_DEVICE(SPI_VENDOR_ID_APPLE, HID_ANY_ID),
1212+
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
11941213
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
11951214
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY },
11961215
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),

0 commit comments

Comments
 (0)