Skip to content

Commit

Permalink
Merge tag 'for-linus-2022121301' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/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
  ...
  • Loading branch information
Linus Torvalds committed Dec 13, 2022
2 parents 86a0b42 + f722052 commit 2043f9a
Show file tree
Hide file tree
Showing 25 changed files with 2,056 additions and 295 deletions.
3 changes: 2 additions & 1 deletion drivers/hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,8 @@ config HID_ALPS
config HID_MCP2221
tristate "Microchip MCP2221 HID USB-to-I2C/SMbus host support"
depends on USB_HID && I2C
depends on GPIOLIB
imply GPIOLIB
imply IIO
help
Provides I2C and SMBUS host adapter functionality over USB-HID
through MCP2221 device.
Expand Down
6 changes: 0 additions & 6 deletions drivers/hid/hid-alps.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,11 +820,6 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id)
return 0;
}

static void alps_remove(struct hid_device *hdev)
{
hid_hw_stop(hdev);
}

static const struct hid_device_id alps_id[] = {
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY,
USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) },
Expand All @@ -842,7 +837,6 @@ static struct hid_driver alps_driver = {
.name = "hid-alps",
.id_table = alps_id,
.probe = alps_probe,
.remove = alps_remove,
.raw_event = alps_raw_event,
.input_mapping = alps_input_mapping,
.input_configured = alps_input_configured,
Expand Down
141 changes: 74 additions & 67 deletions drivers/hid/hid-apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\")
"(For people who want to keep Windows PC keyboard muscle memory. "
"[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");

static unsigned int swap_ctrl_cmd;
module_param(swap_ctrl_cmd, uint, 0644);
MODULE_PARM_DESC(swap_ctrl_cmd, "Swap the Control (\"Ctrl\") and Command (\"Flag\") keys. "
"(For people who are used to Mac shortcuts involving Command instead of Control. "
"[0] = No change. 1 = Swapped.)");

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 Down Expand Up @@ -308,12 +314,21 @@ static const struct apple_key_translation swapped_option_cmd_keys[] = {
{ KEY_LEFTALT, KEY_LEFTMETA },
{ KEY_LEFTMETA, KEY_LEFTALT },
{ KEY_RIGHTALT, KEY_RIGHTMETA },
{ KEY_RIGHTMETA,KEY_RIGHTALT },
{ KEY_RIGHTMETA, KEY_RIGHTALT },
{ }
};

static const struct apple_key_translation swapped_ctrl_cmd_keys[] = {
{ KEY_LEFTCTRL, KEY_LEFTMETA },
{ KEY_LEFTMETA, KEY_LEFTCTRL },
{ KEY_RIGHTCTRL, KEY_RIGHTMETA },
{ KEY_RIGHTMETA, KEY_RIGHTCTRL },
{ }
};

static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
{ KEY_FN, KEY_LEFTCTRL },
{ KEY_LEFTCTRL, KEY_FN },
{ }
};

Expand Down Expand Up @@ -375,24 +390,47 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
struct apple_sc *asc = hid_get_drvdata(hid);
const struct apple_key_translation *trans, *table;
bool do_translate;
u16 code = 0;
u16 code = usage->code;
unsigned int real_fnmode;

u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN);

if (usage->code == fn_keycode) {
asc->fn_on = !!value;
input_event_with_scancode(input, usage->type, KEY_FN,
usage->hid, value);
return 1;
}

if (fnmode == 3) {
real_fnmode = (asc->quirks & APPLE_IS_NON_APPLE) ? 2 : 1;
} else {
real_fnmode = fnmode;
}

if (swap_fn_leftctrl) {
trans = apple_find_translation(swapped_fn_leftctrl_keys, code);

if (trans)
code = trans->to;
}

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, code);

if (trans)
code = trans->to;
}

if (swap_opt_cmd) {
trans = apple_find_translation(swapped_option_cmd_keys, code);

if (trans)
code = trans->to;
}

if (swap_ctrl_cmd) {
trans = apple_find_translation(swapped_ctrl_cmd_keys, code);

if (trans)
code = trans->to;
}

if (code == KEY_FN)
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 ||
Expand Down Expand Up @@ -430,15 +468,18 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
else
table = apple_fn_keys;

trans = apple_find_translation (table, usage->code);
trans = apple_find_translation(table, code);

if (trans) {
if (test_bit(trans->from, input->key))
bool from_is_set = test_bit(trans->from, input->key);
bool to_is_set = test_bit(trans->to, input->key);

if (from_is_set)
code = trans->from;
else if (test_bit(trans->to, input->key))
else if (to_is_set)
code = trans->to;

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

code = do_translate ? trans->to : trans->from;
if (do_translate)
code = trans->to;
}

input_event_with_scancode(input, usage->type, code,
usage->hid, value);
return 1;
}

if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
(test_bit(usage->code, asc->pressed_numlock) ||
(test_bit(code, asc->pressed_numlock) ||
test_bit(LED_NUML, input->led))) {
trans = apple_find_translation(powerbook_numlock_keys,
usage->code);
trans = apple_find_translation(powerbook_numlock_keys, code);

if (trans) {
if (value)
set_bit(usage->code,
asc->pressed_numlock);
set_bit(code, asc->pressed_numlock);
else
clear_bit(usage->code,
asc->pressed_numlock);
clear_bit(code, asc->pressed_numlock);

input_event_with_scancode(input, usage->type,
trans->to, usage->hid, value);
code = trans->to;
}

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;
}
}

if (swap_opt_cmd) {
trans = apple_find_translation(swapped_option_cmd_keys, usage->code);
if (trans) {
input_event_with_scancode(input, usage->type,
trans->to, usage->hid, value);
return 1;
}
}
if (usage->code != code) {
input_event_with_scancode(input, usage->type, code, usage->hid, value);

if (swap_fn_leftctrl) {
trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code);
if (trans) {
input_event_with_scancode(input, usage->type,
trans->to, usage->hid, value);
return 1;
}
return 1;
}

return 0;
Expand Down Expand Up @@ -640,9 +650,6 @@ static void apple_setup_input(struct input_dev *input)
apple_setup_key_translation(input, apple2021_fn_keys);
apple_setup_key_translation(input, macbookpro_no_esc_fn_keys);
apple_setup_key_translation(input, macbookpro_dedicated_esc_fn_keys);

if (swap_fn_leftctrl)
apple_setup_key_translation(input, swapped_fn_leftctrl_keys);
}

static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
Expand Down Expand Up @@ -1011,21 +1018,21 @@ static const struct hid_device_id apple_devices[] = {
{ 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_WELLSPRINGT2_J140K),
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132),
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680),
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213),
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
.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_WELLSPRINGT2_J223),
.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_WELLSPRINGT2_J230K),
.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_WELLSPRINGT2_J152F),
.driver_data = APPLE_HAS_FN },
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
{ 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),
Expand Down
6 changes: 0 additions & 6 deletions drivers/hid/hid-elan.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,6 @@ static int elan_probe(struct hid_device *hdev, const struct hid_device_id *id)
return ret;
}

static void elan_remove(struct hid_device *hdev)
{
hid_hw_stop(hdev);
}

static const struct hid_device_id elan_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_HP_X2),
.driver_data = ELAN_HAS_LED },
Expand All @@ -529,7 +524,6 @@ static struct hid_driver elan_driver = {
.input_configured = elan_input_configured,
.raw_event = elan_raw_event,
.probe = elan_probe,
.remove = elan_remove,
};

module_hid_driver(elan_driver);
Expand Down
Loading

0 comments on commit 2043f9a

Please sign in to comment.