Skip to contentSkip to conversation

Add MacBookAir4,1 keyboard support

PATCH In review Pieter-Augustijn Van Malleghem 2 participants 3 messages Sep 7, 2011 – Sep 16, 2011 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add MacBookAir4,1 keyboard support

This patch adds support for the Apple MacBookAir4,1 released in July 2011. It was inspired by Joshua Dillon's patch for the MacBookAir4,2 posted on http://www.almostsure.com/mba42/hid-apple-dkms.patch.

drivers/hid/hid-apple.c +9 -0
diff -uNr linux/drivers/hid/hid-apple.c patched/drivers/hid/hid-apple.c
@@ -183,6 +183,9 @@
 		if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
 				hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
 			table = macbookair_fn_keys;
+		else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI &&
+				hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS)
+			table = macbookair_fn_keys;
 		else if (hid->product < 0x21d || hid->product >= 0x300)
 			table = powerbook_fn_keys;
 		else
@@ -493,6 +499,12 @@
 		.driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
 		.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
+		.driver_data = APPLE_HAS_FN },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
+		.driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
+		.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
 		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
drivers/hid/hid-core.c +6 -0
diff -uNr linux/drivers/hid/hid-core.c patched/drivers/hid/hid-core.c
@@ -1340,6 +1340,9 @@
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) },
@@ -1892,6 +1895,9 @@
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
 	{ }
drivers/hid/hid-ids.h +3 -0
diff -uNr linux/drivers/hid/hid-ids.h patched/drivers/hid/hid-ids.h
@@ -109,6 +109,9 @@
 #define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI	0x0245
 #define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO	0x0246
 #define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS	0x0247
+#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI	0x0249
+#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO	0x024a
+#define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS	0x024b
 #define USB_DEVICE_ID_APPLE_ALU_REVB_ANSI	0x024f
 #define USB_DEVICE_ID_APPLE_ALU_REVB_ISO	0x0250
 #define USB_DEVICE_ID_APPLE_ALU_REVB_JIS	0x0251
#1 lore raw
Quoted 9 lines · Pieter-Augustijn Van Malleghem

This patch adds support for the Apple MacBookAir4,1 released in July 2011. It was inspired by Joshua Dillon's patch for the MacBookAir4,2 posted on http://www.almostsure.com/mba42/hid-apple-dkms.patch.

diff -uNr linux/drivers/hid/hid-apple.c patched/drivers/hid/hid-apple.c

drivers/hid/hid-apple.c line 191

Quoted 9 lines
drivers/hid/hid-apple.c +3 -0
@@ -183,6 +183,9 @@
 		if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
 				hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
 			table = macbookair_fn_keys;
+		else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI &&
+				hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS)
+			table = macbookair_fn_keys;
 		else if (hid->product < 0x21d || hid->product >= 0x300)
 			table = powerbook_fn_keys;
 		else

This is broken, the macbookair_fn_keys above are for earlier revisions of the MacBook Air. MacBookAir4,1 and 4,1 don't have an eject button anymore, so should use the apple_fn_keys[] translation table.

Cheers

Tested-by
#2 lore raw
Quoted 15 lines · Bastien Nocera
Quoted 14 lines · Pieter-Augustijn Van Malleghem

This patch adds support for the Apple MacBookAir4,1 released in July 2011. It was inspired by Joshua Dillon's patch for the MacBookAir4,2 posted on http://www.almostsure.com/mba42/hid-apple-dkms.patch.

diff -uNr linux/drivers/hid/hid-apple.c patched/drivers/hid/hid-apple.c

drivers/hid/hid-apple.c +2 -0
@@ -183,6 +183,9 @@
 		if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
 				hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
 			table = macbookair_fn_keys;
+		else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI &&
+				hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS)
Quoted 8 lines

drivers/hid/hid-apple.c line 191

Quoted 4 lines
drivers/hid/hid-apple.c +1 -0
+			table = macbookair_fn_keys;
 		else if (hid->product < 0x21d || hid->product >= 0x300)
 			table = powerbook_fn_keys;
 		else

This is broken, the macbookair_fn_keys above are for earlier revisions of the MacBook Air. MacBookAir4,1 and 4,1 don't have an eject button anymore, so should use the apple_fn_keys[] translation table.

Works with this patch applied on top of yours:
@@ -59,7 +59,7 @@ diff -uNr linux/drivers/hid/hid-apple.c patched/drivers/hid/hid-apple.c

                        table = macbookair_fn_keys;
 +              else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI &&
 +                              hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS)
-+                      table = macbookair_fn_keys;
++                      table = apple_fn_keys;
                else if (hid->product < 0x21d || hid->product >= 0x300)
                        table = powerbook_fn_keys;
                else