HID: apple: combine patch series for all patches recently sent upstream
v3 cover HID: apple: combine patch series for all patches recently sent upstream
Hi
This small patch series contains various pending patches for hid-apple in a single series.
The first patch moves the backlight report structs, that were incorrectly placed between the translation tables, to other related backlight structs.
The second patch makes use of switch case statements for the ever increasing lengthy device table for fn translation.
The third patch removes the unused APPLE_IGNORE_MOUSE quirk.
The last 2 patches add Apple Magic Keyboard A3118 and A3119 USB-C support.
v2: Add A3118 Keyboard
v3: Add A3119 Keyboard
Aditya Garg (4):
HID: apple: move backlight report structs to other backlight structs
HID: apple: use switch case to set fn translation table
HID: apple: remove unused APPLE_IGNORE_MOUSE quirk
HID: apple: Add Apple Magic Keyboard A3119 USB-C support
Grigorii Sokolik (1):
HID: apple: Add Apple Magic Keyboard A3118 USB-C support
drivers/hid/hid-apple.c | 126 +++++++++++++++++++++++----------------- drivers/hid/hid-ids.h | 10 ++-- 2 files changed, 78 insertions(+), 58 deletions(-)
Signature · 1 line
2.49.0
PATCH v3 1/5 HID: apple: move backlight report structs to other backlight structs
The apple_backlight_config_report and apple_backlight_set_report structs were incorrectly placed between the translation tables. Fix this.
--- drivers/hid/hid-apple.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/hid/hid-apple.c +13 -14
@@ -89,6 +89,19 @@ struct apple_sc_backlight {struct hid_device *hdev; }; +struct apple_backlight_config_report { +u8 report_id; +u8 version; +u16 backlight_off, backlight_on_min, backlight_on_max; +}; + +struct apple_backlight_set_report { +u8 report_id; +u8 version; +u16 backlight; +u16 rate; +}; +struct apple_magic_backlight {struct led_classdev cdev;struct hid_report *brightness;
@@ -152,20 +165,6 @@ static const struct apple_key_translation magic_keyboard_2015_fn_keys[] = { { } }; -struct apple_backlight_config_report { -u8 report_id; -u8 version; -u16 backlight_off, backlight_on_min, backlight_on_max; -}; - -struct apple_backlight_set_report { -u8 report_id; -u8 version; -u16 backlight; -u16 rate; -}; - -static const struct apple_key_translation apple2021_fn_keys[] = { {KEY_BACKSPACE ,KEY_DELETE }, {KEY_ENTER ,KEY_INSERT },
Signature · 1 line
2.49.0
PATCH v3 2/5 HID: apple: use switch case to set fn translation table
In reply to Aditya GargThere has been a continuous increase in the number of devices requiring hid-apple driver during the last few years. Moreover, unlike previous releases, the PIDs of the newer devices released cannot be combined in a specific range, thus filling up the if else if statements with individual device IDs. For such large table, its now more suitable to use switch case instead of if else if for improved readability.
--- drivers/hid/hid-apple.c | 73 +++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 32 deletions(-)
drivers/hid/hid-apple.c +41 -32
@@ -465,42 +465,51 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, asc->fn_on = !!value;if (real_fnmode) { -if (hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI || - hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO || - hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS || - hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI || - hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO || - hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS || - hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI || - hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO || - hid->product ==USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS ) +switch (hid->product) { +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI : +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO : +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS : +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI : +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO : +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS : +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI : +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO : +case USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS : table = magic_keyboard_alu_fn_keys; -else if (hid->product ==USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 || - hid->product ==USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015 ) +break ; +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 : +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015 : table = magic_keyboard_2015_fn_keys; -else if (hid->product ==USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 || - hid->product ==USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 || - hid->product ==USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 || - hid->product ==USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 ) +break ; +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 : +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 : +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 : +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 : table = apple2021_fn_keys; -else if (hid->product ==USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 || - hid->product ==USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 || - hid->product ==USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 ) - table = macbookpro_no_esc_fn_keys; -else if (hid->product ==USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K || - hid->product ==USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 || - hid->product ==USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F ) - table = macbookpro_dedicated_esc_fn_keys; -else if (hid->product ==USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K || - hid->product ==USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K ) - table = apple_fn_keys; -else 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 <0x21d || hid->product >=0x300 ) - table = powerbook_fn_keys; -else +break ; +case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 : +case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 : +case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 : + table = macbookpro_no_esc_fn_keys; +break ; +case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F : +case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K : +case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 : + table = macbookpro_dedicated_esc_fn_keys; +break ; +case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K : +case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K : table = apple_fn_keys; +break ; +default : +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 <0x21d || hid->product >=0x300 ) + table = powerbook_fn_keys; +else + table = apple_fn_keys; + } trans =apple_find_translation (table, code);
Signature · 1 line
2.49.0
PATCH v3 3/5 HID: apple: remove unused APPLE_IGNORE_MOUSE quirk
In reply to Aditya GargThe APPLE_IGNORE_MOUSE quirk was not used anywhere in this driver, so can be removed.
--- drivers/hid/hid-apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-apple.c +1 -1
@@ -30,7 +30,7 @@#include "hid-ids.h" #define APPLE_RDESC_JIS BIT(0) -#define APPLE_IGNORE_MOUSE BIT(1) +/* BIT(1) reserved, was: APPLE_IGNORE_MOUSE */ #define APPLE_HAS_FN BIT(2)/* BIT(3) reserved, was: APPLE_HIDDEV */ #define APPLE_ISO_TILDE_QUIRK BIT(4)
Signature · 1 line
2.49.0
PATCH v3 4/5 HID: apple: Add Apple Magic Keyboard A3118 USB-C support
In reply to Aditya GargFrom: Grigorii Sokolik <[email protected]>
Add Apple Magic Keyboard 2024 with Touch ID device ID (05ac:0321) to those recognized by the hid-apple driver. Keyboard is otherwise compatible with the existing implementation for its earlier 2021 model.
--- drivers/hid/hid-apple.c | 21 +++++++++++++-------- drivers/hid/hid-ids.h | 9 +++++---- 2 files changed, 18 insertions(+), 12 deletions(-)
drivers/hid/hid-apple.c +13 -8
@@ -165,7 +165,7 @@ static const struct apple_key_translation magic_keyboard_2015_fn_keys[] = { { } }; -static const struct apple_key_translation apple2021_fn_keys[] = { +static const struct apple_key_translation magic_keyboard_2021_and_2024_fn_keys[] = { {KEY_BACKSPACE ,KEY_DELETE }, {KEY_ENTER ,KEY_INSERT }, {KEY_F1 ,KEY_BRIGHTNESSDOWN ,APPLE_FLAG_FKEY },
@@ -482,10 +482,11 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, table = magic_keyboard_2015_fn_keys;break ;case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 : -case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 :case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 :case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 : - table = apple2021_fn_keys; +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 : +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024 : + table = magic_keyboard_2021_and_2024_fn_keys;break ;case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 :case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 :
@@ -690,7 +691,7 @@ static void apple_setup_input(struct input_dev *input)apple_setup_key_translation (input, apple_iso_keyboard);apple_setup_key_translation (input, magic_keyboard_alu_fn_keys);apple_setup_key_translation (input, magic_keyboard_2015_fn_keys); -apple_setup_key_translation (input, apple2021_fn_keys); +apple_setup_key_translation (input, magic_keyboard_2021_and_2024_fn_keys);apple_setup_key_translation (input, macbookpro_no_esc_fn_keys);apple_setup_key_translation (input, macbookpro_dedicated_esc_fn_keys); }
@@ -1165,10 +1166,6 @@ static const struct hid_device_id apple_devices[] = { .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021), .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, - { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024), - .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, - { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024), - .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021), .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021),
@@ -1177,6 +1174,14 @@ static const struct hid_device_id apple_devices[] = { .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021), .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024), + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024), + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024), + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024), + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT), .driver_data = APPLE_MAGIC_BACKLIGHT },
drivers/hid/hid-ids.h +5 -4
@@ -162,6 +162,11 @@#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 0x0267#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015 0x026c +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 0x029c +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 0x029a +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 0x029f +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 0x0320 +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024 0x0321#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
@@ -183,10 +188,6 @@#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_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 0x0320 -#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 0x029a -#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 0x029f#define USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT 0x8102#define USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY 0x8302
Signature · 1 line
2.49.0
PATCH v3 5/5 HID: apple: Add Apple Magic Keyboard A3119 USB-C support
In reply to Aditya GargAdd Apple Magic Keyboard 2024 with Touch ID and Numeric Keypad device ID (05ac:0322) to those recognized by the hid-apple driver. Keyboard is otherwise compatible with the existing implementation for its earlier 2021 model.
--- drivers/hid/hid-apple.c | 5 +++++ drivers/hid/hid-ids.h | 1 + 2 files changed, 6 insertions(+)
drivers/hid/hid-apple.c +5 -0
@@ -486,6 +486,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 :case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 :case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024 : +case USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2024 : table = magic_keyboard_2021_and_2024_fn_keys;break ;case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 :
@@ -1182,6 +1183,10 @@ static const struct hid_device_id apple_devices[] = { .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024), .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2024), + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY }, + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2024), + .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT), .driver_data = APPLE_MAGIC_BACKLIGHT },
drivers/hid/hid-ids.h +1 -0
@@ -167,6 +167,7 @@#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 0x029f#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 0x0320#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024 0x0321 +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2024 0x0322#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
Signature · 1 line
2.49.0