Skip to content

Commit e30bfdb

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 6aa9e80 commit e30bfdb

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
@@ -473,6 +473,18 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
473473
asc->fn_on = !!value;
474474

475475
if (real_fnmode) {
476+
switch (hid->bus) {
477+
case BUS_SPI:
478+
switch (hid->product) {
479+
case SPI_DEVICE_ID_APPLE_MACBOOK_PRO13_2020:
480+
table = macbookpro_dedicated_esc_fn_keys;
481+
break;
482+
default:
483+
table = magic_keyboard_2021_and_2024_fn_keys;
484+
break;
485+
}
486+
break;
487+
default:
476488
switch (hid->product) {
477489
case USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI:
478490
case USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO:
@@ -521,6 +533,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
521533
else
522534
table = apple_fn_keys;
523535
}
536+
}
524537

525538
trans = apple_find_translation(table, code);
526539

@@ -938,6 +951,10 @@ static int apple_probe(struct hid_device *hdev,
938951
struct apple_sc *asc;
939952
int ret;
940953

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

0 commit comments

Comments
 (0)