Skip to content

Commit

Permalink
Add new T2 compatible devices
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeeq committed Sep 6, 2019
1 parent ceb30ea commit a597622
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Travis kernel publish status - <http://fedora-mbp-repo.herokuapp.com/> :
#### Not working

- Microphone
- Dynamic audio outputs change (on connecting/disconnecting headphones jack)
- Dynamic audio input/output change (on connecting/disconnecting headphones jack)
- Suspend/Resume (sleep mode)
- TouchID - (@MCMrARM is working on it - https://github.com/Dunedan/mbp-2016-linux/issues/71#issuecomment-528545490)

#### Working with upstream stable kernel 5.1

Expand Down
38 changes: 20 additions & 18 deletions patches/hid-apple-mod.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ index 1cb4199..3f30d04 100644
* Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
+ * Copyright (c) 2019 Paul Pawlowski <paul@mrarm.io>
*/

/*
@@ -33,6 +34,7 @@
#define APPLE_INVERT_HWHEEL 0x0040
#define APPLE_IGNORE_HIDINPUT 0x0080
#define APPLE_NUMLOCK_EMULATION 0x0100
+#define APPLE_BACKLIGHT_CTL 0x0200

#define APPLE_FLAG_FKEY 0x01

@@ -54,11 +56,31 @@
"(For people who want to keep Windows PC keyboard muscle memory. "
"[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");

+static unsigned int swap_fn_leftctrl;
+module_param(swap_fn_leftctrl, uint, 0644);
+MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. "
Expand All @@ -51,12 +51,12 @@ index 1cb4199..3f30d04 100644
+ struct hid_device *hdev;
+ unsigned short backlight_off, backlight_on_min, backlight_on_max;
};

struct apple_key_translation {
@@ -166,6 +188,16 @@
{ }
};

+static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
+ { KEY_FN, KEY_LEFTCTRL },
+ { }
Expand All @@ -73,7 +73,7 @@ index 1cb4199..3f30d04 100644
@@ -185,9 +217,11 @@
struct apple_sc *asc = hid_get_drvdata(hid);
const struct apple_key_translation *trans, *table;

- if (usage->code == KEY_FN) {
+ u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN);
+
Expand All @@ -83,11 +83,11 @@ index 1cb4199..3f30d04 100644
+ input_event(input, usage->type, KEY_FN, value);
return 1;
}

@@ -266,6 +300,22 @@
}
}

+ if (rightalt_as_rightctrl) {
+ trans = apple_find_translation(rightalt_as_rightctrl_keys, usage->code);
+ if (trans) {
Expand All @@ -106,9 +106,9 @@ index 1cb4199..3f30d04 100644
+
return 0;
}

@@ -329,6 +379,17 @@

for (trans = apple_iso_keyboard; trans->from; trans++)
set_bit(trans->to, input->keybit);
+
Expand All @@ -123,12 +123,12 @@ index 1cb4199..3f30d04 100644
+ }
+
}

static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -366,6 +427,11 @@
return 0;
}

+static int apple_init_backlight(struct hid_device *hdev);
+static int apple_set_backlight(struct hid_device *hdev, u16 value, u16 rate);
+static int apple_led_set_backlight(struct led_classdev *led_cdev,
Expand All @@ -140,13 +140,13 @@ index 1cb4199..3f30d04 100644
@@ -401,9 +467,106 @@
return ret;
}

+ if (quirks & APPLE_BACKLIGHT_CTL)
+ apple_init_backlight(hdev);
+
return 0;
}

+struct apple_backlight_config_report {
+ u8 report_id;
+ u8 version;
Expand Down Expand Up @@ -244,13 +244,15 @@ index 1cb4199..3f30d04 100644
static const struct hid_device_id apple_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
.driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
@@ -557,6 +720,10 @@
@@ -557,6 +720,12 @@
.driver_data = APPLE_HAS_FN },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MBA8_1),
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_A),
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_B),
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MBP15_X),
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_C),
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
Expand Down
25 changes: 14 additions & 11 deletions patches/keyboard.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@ From: fedora kernel <fedora@kernel.org>
Subject: patch keyboard

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index adce58f24..1ee41d05c 100644
index b032d3899fa3..4af2f7eb12af 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -170,6 +170,8 @@
@@ -168,6 +168,9 @@
#define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI 0x0272
#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273
#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
+#define USB_DEVICE_ID_APPLE_MBA8_1 0x027a
+#define USB_DEVICE_ID_APPLE_MBP15_X 0x027b
+#define USB_DEVICE_ID_APPLE_WELLSPRING10_T2_A 0x027a
+#define USB_DEVICE_ID_APPLE_WELLSPRING10_T2_B 0x027b
+#define USB_DEVICE_ID_APPLE_WELLSPRING10_T2_C 0x027c
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 77ffba48c..3853d11d3 100644
index 671a285724f9..d8d7232b65e2 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -269,6 +269,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
@@ -267,6 +267,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MBA8_1) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MBP15_X) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_A) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_B) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_C) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
@@ -916,6 +918,8 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
@@ -908,6 +911,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MBA8_1) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MBP15_X) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_A) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_B) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING10_T2_C) },
{ 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) },
{ }
Expand Down
42 changes: 31 additions & 11 deletions patches/touchpad.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,42 @@ From: fedora kernel <fedora@kernel.org>
Subject: patch touchpad

diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index d0122134f..da9162306 100644
index 59a14505b9cd..5df8baa58e00 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -96,6 +96,8 @@
@@ -82,6 +82,13 @@
#define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI 0x0272
#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273
#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
+/* MacbookAir8,1 (2018) */
+#define USB_DEVICE_ID_APPLE_MBA81 0x027a
+/* T2-Attached Devices */
+/* MacbookAir8,1 (2019) */
+#define USB_DEVICE_ID_APPLE_WELLSPRING10_T2_A 0x027a
+/* MacbookPro15,2 (2018) */
+#define USB_DEVICE_ID_APPLE_WELLSPRING10_T2_B 0x027b
+/* MacbookPro15,1 (2018) */
+#define USB_DEVICE_ID_APPLE_WELLSPRING10_T2_C 0x027c

#define BCM5974_DEVICE(prod) { \
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
@@ -161,6 +163,10 @@ static const struct usb_device_id bcm5974_table[] = {
@@ -147,6 +154,12 @@ static const struct usb_device_id bcm5974_table[] = {
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
+ /* MacbookAir8,1 */
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_MBA81),
+ /* MacbookPro15 */
+ BCM5974_DEVICE(0x027b),
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING10_T2_A),
+ /* MacbookPro15,2 */
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING10_T2_B),
+ /* MacbookPro15,1 */
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING10_T2_C),
/* Terminating entry */
{}
};
@@ -497,6 +503,32 @@ static const struct bcm5974_config bcm5974_config_table[] = {
@@ -483,6 +496,45 @@ static const struct bcm5974_config bcm5974_config_table[] = {
{ SN_COORD, -203, 6803 },
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
},
+ {
+ USB_DEVICE_ID_APPLE_MBA81,
+ USB_DEVICE_ID_APPLE_WELLSPRING10_T2_A,
+ 0,
+ 0,
+ HAS_INTEGRATED_BUTTON,
Expand All @@ -43,7 +50,20 @@ index d0122134f..da9162306 100644
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
+ },
+ {
+ 0x027b,
+ USB_DEVICE_ID_APPLE_WELLSPRING10_T2_B,
+ 0,
+ 0,
+ HAS_INTEGRATED_BUTTON,
+ 0, sizeof(struct bt_data),
+ 0x83, DATAFORMAT(TYPE4),
+ { SN_PRESSURE, 0, 300 },
+ { SN_WIDTH, 0, 2048 },
+ { SN_COORD, -6243, 6749 },
+ { SN_COORD, -170, 7685 },
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
+ },
+ {
+ USB_DEVICE_ID_APPLE_WELLSPRING10_T2_C,
+ 0,
+ 0,
+ HAS_INTEGRATED_BUTTON,
Expand Down

0 comments on commit a597622

Please sign in to comment.