From cc84094218a73238fbc517663f949f3a852f26cf Mon Sep 17 00:00:00 2001 From: "Alexander F. Lent" Date: Thu, 16 Sep 2021 15:38:40 -0400 Subject: HID: apple: Eliminate obsolete IR receiver quirks This code has been dead since 2013, when the appleir driver was added by commit 9a4a5574ce42 ("HID: appleir: add support for Apple ir devices"), removing Apple IR receivers from this driver. No other Apple devices use these quirks, so drop them. Signed-off-by: Alexander F. Lent Signed-off-by: Jiri Kosina --- drivers/hid/hid-apple.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'drivers/hid/hid-apple.c') diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 833fcf07ff35..1cb15f880c41 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -24,11 +24,11 @@ #define APPLE_RDESC_JIS 0x0001 #define APPLE_IGNORE_MOUSE 0x0002 #define APPLE_HAS_FN 0x0004 -#define APPLE_HIDDEV 0x0008 +/* 0x0008 reserved, was: APPLE_HIDDEV */ /* 0x0010 reserved, was: APPLE_ISO_KEYBOARD */ #define APPLE_MIGHTYMOUSE 0x0020 #define APPLE_INVERT_HWHEEL 0x0040 -#define APPLE_IGNORE_HIDINPUT 0x0080 +/* 0x0080 reserved, was: APPLE_IGNORE_HIDINPUT */ #define APPLE_NUMLOCK_EMULATION 0x0100 #define APPLE_FLAG_FKEY 0x01 @@ -433,7 +433,6 @@ static int apple_probe(struct hid_device *hdev, { unsigned long quirks = id->driver_data; struct apple_sc *asc; - unsigned int connect_mask = HID_CONNECT_DEFAULT; int ret; asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL); @@ -452,12 +451,7 @@ static int apple_probe(struct hid_device *hdev, return ret; } - if (quirks & APPLE_HIDDEV) - connect_mask |= HID_CONNECT_HIDDEV_FORCE; - if (quirks & APPLE_IGNORE_HIDINPUT) - connect_mask &= ~HID_CONNECT_HIDINPUT; - - ret = hid_hw_start(hdev, connect_mask); + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); if (ret) { hid_err(hdev, "hw start failed\n"); return ret; -- cgit v1.2.3-59-g8ed1b From 371a9dcee70e87fad44cf02112595b5a33774b7b Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Fri, 8 Oct 2021 01:37:00 -0600 Subject: HID: apple: Rename MAGIC_KEYBOARD_ANSI to MAGIC_KEYBOARD_2015 The ANSI, ISO, and JIS variants of this keyboard all have the same product ID. Signed-off-by: Alex Henrie Signed-off-by: Jiri Kosina --- drivers/hid/hid-apple.c | 8 ++++---- drivers/hid/hid-ids.h | 4 ++-- drivers/hid/hid-quirks.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/hid/hid-apple.c') diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 1cb15f880c41..ff9715f96502 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -531,13 +531,13 @@ static const struct hid_device_id apple_devices[] = { .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, - { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015), .driver_data = APPLE_HAS_FN }, - { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015), .driver_data = APPLE_HAS_FN }, - { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI), + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015), .driver_data = APPLE_HAS_FN }, - { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI), + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015), .driver_data = APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), .driver_data = APPLE_HAS_FN }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 29564b370341..c84ff8e4038f 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -159,8 +159,8 @@ #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI 0x0255 #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256 #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257 -#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI 0x0267 -#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI 0x026c +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 0x0267 +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015 0x026c #define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291 #define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292 diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 2e104682c22b..256bf42f9629 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -299,7 +299,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS) }, - { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015) }, { 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) }, #endif -- cgit v1.2.3-59-g8ed1b From 0cd3be51733febb4f8acb92bcf55b75fe824dd05 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Fri, 8 Oct 2021 01:37:01 -0600 Subject: HID: apple: Add support for the 2021 Magic Keyboard Signed-off-by: Alex Henrie Signed-off-by: Jiri Kosina --- drivers/hid/hid-apple.c | 4 ++++ drivers/hid/hid-ids.h | 1 + drivers/hid/hid-quirks.c | 1 + 3 files changed, 6 insertions(+) (limited to 'drivers/hid/hid-apple.c') diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index ff9715f96502..f79fc12a9d21 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -627,6 +627,10 @@ static const struct hid_device_id apple_devices[] = { .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021), + .driver_data = APPLE_HAS_FN }, + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021), + .driver_data = APPLE_HAS_FN }, { } }; diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index c84ff8e4038f..8995350d5fd9 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -174,6 +174,7 @@ #define USB_DEVICE_ID_APPLE_IRCONTROL3 0x8241 #define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242 #define USB_DEVICE_ID_APPLE_IRCONTROL5 0x8243 +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 0x029c #define USB_VENDOR_ID_ASUS 0x0486 #define USB_DEVICE_ID_ASUS_T91MT 0x0185 diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 256bf42f9629..06b7908c874c 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -302,6 +302,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015) }, { 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) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) }, #endif #if IS_ENABLED(CONFIG_HID_APPLEIR) { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) }, -- cgit v1.2.3-59-g8ed1b From d58cf34a594d34de1a6843f576f82fae40adc0c2 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Tue, 19 Oct 2021 01:12:32 -0600 Subject: HID: apple: Bring back flag for Apple tilde key quirk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some Apple ISO keyboards have a quirk where the backtick/tilde key is swapped with the less-than/greater-than key. Unfortunately, there is no perfectly reliable way to detect whether a keyboard has the quirk or not, but the quirk appears to only be present on models that support Bluetooth, and the affected keyboards usually report country code 13 in the HID descriptor. Therefore, the best we can do is to change /sys/module/hid_apple/parameters/iso_layout to a ternary: 0 = Not ISO or ISO and not quirky 1 = ISO and quirky -1 = Guess based on product ID and country code Table of keyboards that José, Julian and I have tested: Product Model Shape Labels Bus Country Quirky ========================================================= 05ac:0201 M2452 ANSI Usonian USB 0 No 05ac:020b A1048 ANSI Usonian USB 0 No 05ac:020c A1048 ISO Québécois USB 13 No 05ac:0221 A1243 ISO Norwegian USB 13 No 05ac:0221 A1243 ISO Portuguese USB 13 No 05ac:0221 A1243 ISO Swedish USB 13 No 05ac:0221 A1243 ISO Swiss USB 13 No 05ac:022c A1255 ANSI Usonian BT 33 No 05ac:022d A1255 ISO Hebrew BT 13 Yes 05ac:022d A1255 ISO Québécois BT 13 Yes 05ac:022d A1255 ISO Spanish BT 13 Yes 05ac:023a A1314 ISO Russian BT 13 Yes 05ac:023a A1314 ISO Swiss BT 13 Yes 05ac:024f A1243 ANSI Usonian USB 0 No 05ac:0250 A1243 ISO British USB 13 No 05ac:0250 A1243 ISO German USB 13 No 05ac:0250 A1243 ISO Italian USB 13 No 05ac:0250 A1243 ISO Québécois USB 13 No 05ac:0251 A1243 JIS Japanese USB 15 No 05ac:0255 A1314 ANSI Usonian BT 33 No 05ac:0255 A1314 ANSI Taiwanese BT 33 No 05ac:0255 A1314 ANSI Thai BT 33 No 05ac:0256 A1314 ISO Arabic BT 13 Yes 05ac:0256 A1314 ISO French BT 13 Yes 05ac:0256 A1314 ISO German BT 13 Yes 05ac:0256 A1314 ISO Norwegian BT 13 Yes 05ac:0256 A1314 ISO Spanish BT 13 Yes 05ac:0256 A1314 ISO Swiss BT 13 Yes 05ac:0257 A1314 JIS Japanese BT 15 No 05ac:0267 A1644 ANSI Usonian USB 33 No 004c:0267 A1644 ANSI Usonian BT 0 No 05ac:0267 A1644 ISO British USB 13 Yes 004c:0267 A1644 ISO British BT 0 Yes 05ac:0267 A1644 ISO Finnish USB 13 Yes 004c:0267 A1644 ISO Finnish BT 0 Yes 05ac:0267 A1644 ISO Québécois USB 13 Yes 004c:0267 A1644 ISO Québécois BT 0 Yes 05ac:0267 A1644 ISO Spanish USB 13 Yes 004c:0267 A1644 ISO Spanish BT 0 Yes 05ac:0267 A1644 ISO Swiss USB 13 Yes 004c:0267 A1644 ISO Swiss BT 0 Yes 05ac:0267 A1644 JIS Japanese USB 15 No 004c:0267 A1644 JIS Japanese BT 0 No 05ac:029c A2450 ANSI Usonian USB 33 No 004c:029c A2450 ANSI Usonian BT 0 No 05ac:029c A2450 ISO Spanish USB 13 Yes 004c:029c A2450 ISO Spanish BT 0 Yes 05ac:029c A2450 JIS Japanese USB 15 No 004c:029c A2450 JIS Japanese BT 0 No Reported-by: José Expósito Tested-by: José Expósito Tested-by: Julian Weigt Signed-off-by: Alex Henrie Signed-off-by: Jiri Kosina --- drivers/hid/hid-apple.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'drivers/hid/hid-apple.c') diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index f79fc12a9d21..b97119507cf7 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -25,7 +25,7 @@ #define APPLE_IGNORE_MOUSE 0x0002 #define APPLE_HAS_FN 0x0004 /* 0x0008 reserved, was: APPLE_HIDDEV */ -/* 0x0010 reserved, was: APPLE_ISO_KEYBOARD */ +#define APPLE_ISO_TILDE_QUIRK 0x0010 #define APPLE_MIGHTYMOUSE 0x0020 #define APPLE_INVERT_HWHEEL 0x0040 /* 0x0080 reserved, was: APPLE_IGNORE_HIDINPUT */ @@ -40,10 +40,10 @@ module_param(fnmode, uint, 0644); MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, " "[1] = fkeyslast, 2 = fkeysfirst)"); -static unsigned int iso_layout = 1; -module_param(iso_layout, uint, 0644); -MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. " - "(0 = disabled, [1] = enabled)"); +static int iso_layout = -1; +module_param(iso_layout, int, 0644); +MODULE_PARM_DESC(iso_layout, "Swap the backtick/tilde and greater-than/less-than keys. " + "([-1] = auto, 0 = disabled, 1 = enabled)"); static unsigned int swap_opt_cmd; module_param(swap_opt_cmd, uint, 0644); @@ -277,14 +277,13 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, } } - if (iso_layout) { - if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) { - trans = apple_find_translation(apple_iso_keyboard, usage->code); - if (trans) { - input_event_with_scancode(input, usage->type, - trans->to, usage->hid, value); - return 1; - } + if (iso_layout > 0 || (iso_layout < 0 && (asc->quirks & APPLE_ISO_TILDE_QUIRK) && + hid->country == HID_COUNTRY_INTERNATIONAL_ISO)) { + trans = apple_find_translation(apple_iso_keyboard, usage->code); + if (trans) { + input_event_with_scancode(input, usage->type, + trans->to, usage->hid, value); + return 1; } } @@ -520,9 +519,11 @@ static const struct hid_device_id apple_devices[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO), - .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, + .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | + APPLE_ISO_TILDE_QUIRK }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO), - .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, + .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | + APPLE_ISO_TILDE_QUIRK }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, @@ -532,13 +533,13 @@ static const struct hid_device_id apple_devices[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), .driver_data = APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO), @@ -620,7 +621,8 @@ static const struct hid_device_id apple_devices[] = { { 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), - .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, + .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | + APPLE_ISO_TILDE_QUIRK }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), @@ -628,9 +630,9 @@ static const struct hid_device_id apple_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021), - .driver_data = APPLE_HAS_FN }, + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { } }; -- cgit v1.2.3-59-g8ed1b