Skip to content

Commit 2043f9a

Browse files
committed
Merge tag 'for-linus-2022121301' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - iio support for the MCP2221 HID driver (Matt Ranostay) - support for more than one hinge sensor in hid-sensor-custom (Yauhen Kharuzhy) - PS DualShock 4 controller support (Roderick Colenbrander) - XP-PEN Deco LW support (José Expósito) - other assorted code cleanups and device ID/quirk addtions * tag 'for-linus-2022121301' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (51 commits) HID: logitech HID++: Send SwID in GetProtocolVersion HID: hid-elan: use default remove for hid device HID: hid-alps: use default remove for hid device HID: hid-sensor-custom: set fixed size for custom attributes HID: i2c: let RMI devices decide what constitutes wakeup event HID: playstation: fix DualShock4 bluetooth CRC endian issue. HID: playstation: fix DualShock4 bluetooth memory corruption bug. HID: apple: Swap Control and Command keys on Apple keyboards HID: intel-ish-hid: ishtp: remove variable rb_count HID: uclogic: Standardize test name prefix HID: hid-sensor-custom: Allow more than one hinge angle sensor HID: ft260: fix 'cast to restricted' kernel CI bot warnings HID: ft260: missed NACK from busy device HID: ft260: fix a NULL pointer dereference in ft260_i2c_write HID: ft260: wake up device from power saving mode HID: ft260: missed NACK from big i2c read HID: ft260: remove SMBus Quick command support HID: ft260: skip unexpected HID input reports HID: ft260: do not populate /dev/hidraw device HID: ft260: improve i2c large reads performance ...
2 parents 86a0b42 + f722052 commit 2043f9a

25 files changed

+2056
-295
lines changed

drivers/hid/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,8 @@ config HID_ALPS
12521252
config HID_MCP2221
12531253
tristate "Microchip MCP2221 HID USB-to-I2C/SMbus host support"
12541254
depends on USB_HID && I2C
1255-
depends on GPIOLIB
1255+
imply GPIOLIB
1256+
imply IIO
12561257
help
12571258
Provides I2C and SMBUS host adapter functionality over USB-HID
12581259
through MCP2221 device.

drivers/hid/hid-alps.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -820,11 +820,6 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id)
820820
return 0;
821821
}
822822

823-
static void alps_remove(struct hid_device *hdev)
824-
{
825-
hid_hw_stop(hdev);
826-
}
827-
828823
static const struct hid_device_id alps_id[] = {
829824
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY,
830825
USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) },
@@ -842,7 +837,6 @@ static struct hid_driver alps_driver = {
842837
.name = "hid-alps",
843838
.id_table = alps_id,
844839
.probe = alps_probe,
845-
.remove = alps_remove,
846840
.raw_event = alps_raw_event,
847841
.input_mapping = alps_input_mapping,
848842
.input_configured = alps_input_configured,

drivers/hid/hid-apple.c

Lines changed: 74 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\")
5959
"(For people who want to keep Windows PC keyboard muscle memory. "
6060
"[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");
6161

62+
static unsigned int swap_ctrl_cmd;
63+
module_param(swap_ctrl_cmd, uint, 0644);
64+
MODULE_PARM_DESC(swap_ctrl_cmd, "Swap the Control (\"Ctrl\") and Command (\"Flag\") keys. "
65+
"(For people who are used to Mac shortcuts involving Command instead of Control. "
66+
"[0] = No change. 1 = Swapped.)");
67+
6268
static unsigned int swap_fn_leftctrl;
6369
module_param(swap_fn_leftctrl, uint, 0644);
6470
MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. "
@@ -308,12 +314,21 @@ static const struct apple_key_translation swapped_option_cmd_keys[] = {
308314
{ KEY_LEFTALT, KEY_LEFTMETA },
309315
{ KEY_LEFTMETA, KEY_LEFTALT },
310316
{ KEY_RIGHTALT, KEY_RIGHTMETA },
311-
{ KEY_RIGHTMETA,KEY_RIGHTALT },
317+
{ KEY_RIGHTMETA, KEY_RIGHTALT },
318+
{ }
319+
};
320+
321+
static const struct apple_key_translation swapped_ctrl_cmd_keys[] = {
322+
{ KEY_LEFTCTRL, KEY_LEFTMETA },
323+
{ KEY_LEFTMETA, KEY_LEFTCTRL },
324+
{ KEY_RIGHTCTRL, KEY_RIGHTMETA },
325+
{ KEY_RIGHTMETA, KEY_RIGHTCTRL },
312326
{ }
313327
};
314328

315329
static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
316330
{ KEY_FN, KEY_LEFTCTRL },
331+
{ KEY_LEFTCTRL, KEY_FN },
317332
{ }
318333
};
319334

@@ -375,24 +390,47 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
375390
struct apple_sc *asc = hid_get_drvdata(hid);
376391
const struct apple_key_translation *trans, *table;
377392
bool do_translate;
378-
u16 code = 0;
393+
u16 code = usage->code;
379394
unsigned int real_fnmode;
380395

381-
u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN);
382-
383-
if (usage->code == fn_keycode) {
384-
asc->fn_on = !!value;
385-
input_event_with_scancode(input, usage->type, KEY_FN,
386-
usage->hid, value);
387-
return 1;
388-
}
389-
390396
if (fnmode == 3) {
391397
real_fnmode = (asc->quirks & APPLE_IS_NON_APPLE) ? 2 : 1;
392398
} else {
393399
real_fnmode = fnmode;
394400
}
395401

402+
if (swap_fn_leftctrl) {
403+
trans = apple_find_translation(swapped_fn_leftctrl_keys, code);
404+
405+
if (trans)
406+
code = trans->to;
407+
}
408+
409+
if (iso_layout > 0 || (iso_layout < 0 && (asc->quirks & APPLE_ISO_TILDE_QUIRK) &&
410+
hid->country == HID_COUNTRY_INTERNATIONAL_ISO)) {
411+
trans = apple_find_translation(apple_iso_keyboard, code);
412+
413+
if (trans)
414+
code = trans->to;
415+
}
416+
417+
if (swap_opt_cmd) {
418+
trans = apple_find_translation(swapped_option_cmd_keys, code);
419+
420+
if (trans)
421+
code = trans->to;
422+
}
423+
424+
if (swap_ctrl_cmd) {
425+
trans = apple_find_translation(swapped_ctrl_cmd_keys, code);
426+
427+
if (trans)
428+
code = trans->to;
429+
}
430+
431+
if (code == KEY_FN)
432+
asc->fn_on = !!value;
433+
396434
if (real_fnmode) {
397435
if (hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI ||
398436
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO ||
@@ -430,15 +468,18 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
430468
else
431469
table = apple_fn_keys;
432470

433-
trans = apple_find_translation (table, usage->code);
471+
trans = apple_find_translation(table, code);
434472

435473
if (trans) {
436-
if (test_bit(trans->from, input->key))
474+
bool from_is_set = test_bit(trans->from, input->key);
475+
bool to_is_set = test_bit(trans->to, input->key);
476+
477+
if (from_is_set)
437478
code = trans->from;
438-
else if (test_bit(trans->to, input->key))
479+
else if (to_is_set)
439480
code = trans->to;
440481

441-
if (!code) {
482+
if (!(from_is_set || to_is_set)) {
442483
if (trans->flags & APPLE_FLAG_FKEY) {
443484
switch (real_fnmode) {
444485
case 1:
@@ -455,62 +496,31 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
455496
do_translate = asc->fn_on;
456497
}
457498

458-
code = do_translate ? trans->to : trans->from;
499+
if (do_translate)
500+
code = trans->to;
459501
}
460-
461-
input_event_with_scancode(input, usage->type, code,
462-
usage->hid, value);
463-
return 1;
464502
}
465503

466504
if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
467-
(test_bit(usage->code, asc->pressed_numlock) ||
505+
(test_bit(code, asc->pressed_numlock) ||
468506
test_bit(LED_NUML, input->led))) {
469-
trans = apple_find_translation(powerbook_numlock_keys,
470-
usage->code);
507+
trans = apple_find_translation(powerbook_numlock_keys, code);
471508

472509
if (trans) {
473510
if (value)
474-
set_bit(usage->code,
475-
asc->pressed_numlock);
511+
set_bit(code, asc->pressed_numlock);
476512
else
477-
clear_bit(usage->code,
478-
asc->pressed_numlock);
513+
clear_bit(code, asc->pressed_numlock);
479514

480-
input_event_with_scancode(input, usage->type,
481-
trans->to, usage->hid, value);
515+
code = trans->to;
482516
}
483-
484-
return 1;
485-
}
486-
}
487-
488-
if (iso_layout > 0 || (iso_layout < 0 && (asc->quirks & APPLE_ISO_TILDE_QUIRK) &&
489-
hid->country == HID_COUNTRY_INTERNATIONAL_ISO)) {
490-
trans = apple_find_translation(apple_iso_keyboard, usage->code);
491-
if (trans) {
492-
input_event_with_scancode(input, usage->type,
493-
trans->to, usage->hid, value);
494-
return 1;
495517
}
496518
}
497519

498-
if (swap_opt_cmd) {
499-
trans = apple_find_translation(swapped_option_cmd_keys, usage->code);
500-
if (trans) {
501-
input_event_with_scancode(input, usage->type,
502-
trans->to, usage->hid, value);
503-
return 1;
504-
}
505-
}
520+
if (usage->code != code) {
521+
input_event_with_scancode(input, usage->type, code, usage->hid, value);
506522

507-
if (swap_fn_leftctrl) {
508-
trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code);
509-
if (trans) {
510-
input_event_with_scancode(input, usage->type,
511-
trans->to, usage->hid, value);
512-
return 1;
513-
}
523+
return 1;
514524
}
515525

516526
return 0;
@@ -640,9 +650,6 @@ static void apple_setup_input(struct input_dev *input)
640650
apple_setup_key_translation(input, apple2021_fn_keys);
641651
apple_setup_key_translation(input, macbookpro_no_esc_fn_keys);
642652
apple_setup_key_translation(input, macbookpro_dedicated_esc_fn_keys);
643-
644-
if (swap_fn_leftctrl)
645-
apple_setup_key_translation(input, swapped_fn_leftctrl_keys);
646653
}
647654

648655
static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -1011,21 +1018,21 @@ static const struct hid_device_id apple_devices[] = {
10111018
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
10121019
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
10131020
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K),
1014-
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
1021+
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
10151022
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132),
1016-
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
1023+
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
10171024
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680),
1018-
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
1025+
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
10191026
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213),
1020-
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
1027+
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
10211028
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
1022-
.driver_data = APPLE_HAS_FN },
1029+
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
10231030
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223),
1024-
.driver_data = APPLE_HAS_FN },
1031+
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
10251032
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K),
1026-
.driver_data = APPLE_HAS_FN },
1033+
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
10271034
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F),
1028-
.driver_data = APPLE_HAS_FN },
1035+
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
10291036
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
10301037
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
10311038
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),

drivers/hid/hid-elan.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,6 @@ static int elan_probe(struct hid_device *hdev, const struct hid_device_id *id)
507507
return ret;
508508
}
509509

510-
static void elan_remove(struct hid_device *hdev)
511-
{
512-
hid_hw_stop(hdev);
513-
}
514-
515510
static const struct hid_device_id elan_devices[] = {
516511
{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_HP_X2),
517512
.driver_data = ELAN_HAS_LED },
@@ -529,7 +524,6 @@ static struct hid_driver elan_driver = {
529524
.input_configured = elan_input_configured,
530525
.raw_event = elan_raw_event,
531526
.probe = elan_probe,
532-
.remove = elan_remove,
533527
};
534528

535529
module_hid_driver(elan_driver);

0 commit comments

Comments
 (0)