Skip to content

Commit

Permalink
Merge tag 'hid-for-linus-2025021001' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/hid/hid

Pull HID fixes from Jiri Kosina:

 - build/dependency fixes for hid-lenovo and hid-intel-thc (Arnd
   Bergmann)

 - functional fixes for hid-corsair-void (Stuart Hayhurst)

 - workqueue handling and ordering fix for hid-steam (Vicki Pfau)

 - Gamepad mode vs. Lizard mode fix for hid-steam (Vicki Pfau)

 - OOB read fix for hid-thrustmaster (Tulio Fernandes)

 - fix for very long timeout on certain firmware in intel-ish-hid (Zhang
   Lixu)

 - other assorted small code fixes and device ID additions

* tag 'hid-for-linus-2025021001' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
  HID: hid-steam: Don't use cancel_delayed_work_sync in IRQ context
  HID: hid-steam: Move hidraw input (un)registering to work
  HID: hid-thrustmaster: fix stack-out-of-bounds read in usb_check_int_endpoints()
  HID: apple: fix up the F6 key on the Omoton KB066 keyboard
  HID: hid-apple: Apple Magic Keyboard a3203 USB-C support
  samples/hid: fix broken vmlinux path for VMLINUX_BTF
  samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS
  HID: topre: Fix n-key rollover on Realforce R3S TKL boards
  HID: intel-ish-hid: ipc: Add Panther Lake PCI device IDs
  HID: multitouch: Add NULL check in mt_input_configured
  HID: winwing: Add NULL check in winwing_init_led()
  HID: hid-steam: Fix issues with disabling both gamepad mode and lizard mode
  HID: ignore non-functional sensor in HP 5MP Camera
  HID: intel-thc: fix CONFIG_HID dependency
  HID: lenovo: select CONFIG_ACPI_PLATFORM_PROFILE
  HID: intel-ish-hid: Send clock sync message immediately after reset
  HID: intel-ish-hid: fix the length of MNG_SYNC_FW_CLOCK in doorbell
  HID: corsair-void: Initialise memory for psy_cfg
  HID: corsair-void: Add missing delayed work cancel for headset status
  • Loading branch information
torvalds committed Feb 10, 2025
2 parents c581f8c + b051ffa commit 58c9bf3
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 47 deletions.
15 changes: 10 additions & 5 deletions drivers/hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ config HID_LED

config HID_LENOVO
tristate "Lenovo / Thinkpad devices"
depends on ACPI
select ACPI_PLATFORM_PROFILE
select NEW_LEDS
select LEDS_CLASS
help
Expand Down Expand Up @@ -1167,7 +1169,8 @@ config HID_TOPRE
tristate "Topre REALFORCE keyboards"
depends on HID
help
Say Y for N-key rollover support on Topre REALFORCE R2 108/87 key keyboards.
Say Y for N-key rollover support on Topre REALFORCE R2 108/87 key and
Topre REALFORCE R3S 87 key keyboards.

config HID_THINGM
tristate "ThingM blink(1) USB RGB LED"
Expand Down Expand Up @@ -1374,10 +1377,6 @@ endmenu

source "drivers/hid/bpf/Kconfig"

endif # HID

source "drivers/hid/usbhid/Kconfig"

source "drivers/hid/i2c-hid/Kconfig"

source "drivers/hid/intel-ish-hid/Kconfig"
Expand All @@ -1388,4 +1387,10 @@ source "drivers/hid/surface-hid/Kconfig"

source "drivers/hid/intel-thc-hid/Kconfig"

endif # HID

# USB support may be used with HID disabled

source "drivers/hid/usbhid/Kconfig"

endif # HID_SUPPORT
1 change: 0 additions & 1 deletion drivers/hid/amd-sfh-hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ menu "AMD SFH HID Support"

config AMD_SFH_HID
tristate "AMD Sensor Fusion Hub"
depends on HID
depends on X86
help
If you say yes to this option, support will be included for the
Expand Down
8 changes: 8 additions & 0 deletions drivers/hid/hid-apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
hid->product == 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)
table = apple2021_fn_keys;
Expand Down Expand Up @@ -545,6 +546,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
}
}

if (usage->hid == 0xc0301) /* Omoton KB066 quirk */
code = KEY_F6;

if (usage->code != code) {
input_event_with_scancode(input, usage->type, code, usage->hid, value);

Expand Down Expand Up @@ -1150,6 +1154,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_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),
Expand Down
3 changes: 2 additions & 1 deletion drivers/hid/hid-corsair-void.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static void corsair_void_battery_remove_work_handler(struct work_struct *work)
static void corsair_void_battery_add_work_handler(struct work_struct *work)
{
struct corsair_void_drvdata *drvdata;
struct power_supply_config psy_cfg;
struct power_supply_config psy_cfg = {};
struct power_supply *new_supply;

drvdata = container_of(work, struct corsair_void_drvdata,
Expand Down Expand Up @@ -726,6 +726,7 @@ static void corsair_void_remove(struct hid_device *hid_dev)
if (drvdata->battery)
power_supply_unregister(drvdata->battery);

cancel_delayed_work_sync(&drvdata->delayed_status_work);
cancel_delayed_work_sync(&drvdata->delayed_firmware_work);
sysfs_remove_group(&hid_dev->dev.kobj, &corsair_void_attr_group);
}
Expand Down
3 changes: 3 additions & 0 deletions drivers/hid/hid-ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
#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
Expand Down Expand Up @@ -1095,6 +1096,7 @@
#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001 0x3001
#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3003 0x3003
#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008 0x3008
#define USB_DEVICE_ID_QUANTA_HP_5MP_CAMERA_5473 0x5473

#define I2C_VENDOR_ID_RAYDIUM 0x2386
#define I2C_PRODUCT_ID_RAYDIUM_4B33 0x4b33
Expand Down Expand Up @@ -1301,6 +1303,7 @@
#define USB_VENDOR_ID_TOPRE 0x0853
#define USB_DEVICE_ID_TOPRE_REALFORCE_R2_108 0x0148
#define USB_DEVICE_ID_TOPRE_REALFORCE_R2_87 0x0146
#define USB_DEVICE_ID_TOPRE_REALFORCE_R3S_87 0x0313

#define USB_VENDOR_ID_TOPSEED 0x0766
#define USB_DEVICE_ID_TOPSEED_CYBERLINK 0x0204
Expand Down
7 changes: 1 addition & 6 deletions drivers/hid/hid-lenovo.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
#include <linux/leds.h>
#include <linux/workqueue.h>

#if IS_ENABLED(CONFIG_ACPI_PLATFORM_PROFILE)
#include <linux/platform_profile.h>
#endif /* CONFIG_ACPI_PLATFORM_PROFILE */

#include "hid-ids.h"

Expand Down Expand Up @@ -730,13 +728,10 @@ static int lenovo_raw_event_TP_X12_tab(struct hid_device *hdev, u32 raw_data)
if (hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB) {
report_key_event(input, KEY_RFKILL);
return 1;
}
#if IS_ENABLED(CONFIG_ACPI_PLATFORM_PROFILE)
else {
} else {
platform_profile_cycle();
return 1;
}
#endif /* CONFIG_ACPI_PLATFORM_PROFILE */
return 0;
case TP_X12_RAW_HOTKEY_FN_F10:
/* TAB1 has PICKUP Phone and TAB2 use Snipping tool*/
Expand Down
5 changes: 4 additions & 1 deletion drivers/hid/hid-multitouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1679,9 +1679,12 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
break;
}

if (suffix)
if (suffix) {
hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
"%s %s", hdev->name, suffix);
if (!hi->input->name)
return -ENOMEM;
}

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/hid/hid-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ static const struct hid_device_id hid_ignore_list[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) },
#endif
{ HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
{ HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_HP_5MP_CAMERA_5473) },
{ }
};

Expand Down
46 changes: 35 additions & 11 deletions drivers/hid/hid-steam.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ struct steam_device {
u16 rumble_left;
u16 rumble_right;
unsigned int sensor_timestamp_us;
struct work_struct unregister_work;
};

static int steam_recv_report(struct steam_device *steam,
Expand Down Expand Up @@ -1050,10 +1051,10 @@ static void steam_mode_switch_cb(struct work_struct *work)
struct steam_device, mode_switch);
unsigned long flags;
bool client_opened;
steam->gamepad_mode = !steam->gamepad_mode;
if (!lizard_mode)
return;

steam->gamepad_mode = !steam->gamepad_mode;
if (steam->gamepad_mode)
steam_set_lizard_mode(steam, false);
else {
Expand All @@ -1072,6 +1073,31 @@ static void steam_mode_switch_cb(struct work_struct *work)
}
}

static void steam_work_unregister_cb(struct work_struct *work)
{
struct steam_device *steam = container_of(work, struct steam_device,
unregister_work);
unsigned long flags;
bool connected;
bool opened;

spin_lock_irqsave(&steam->lock, flags);
opened = steam->client_opened;
connected = steam->connected;
spin_unlock_irqrestore(&steam->lock, flags);

if (connected) {
if (opened) {
steam_sensors_unregister(steam);
steam_input_unregister(steam);
} else {
steam_set_lizard_mode(steam, lizard_mode);
steam_input_register(steam);
steam_sensors_register(steam);
}
}
}

static bool steam_is_valve_interface(struct hid_device *hdev)
{
struct hid_report_enum *rep_enum;
Expand Down Expand Up @@ -1117,8 +1143,7 @@ static int steam_client_ll_open(struct hid_device *hdev)
steam->client_opened++;
spin_unlock_irqrestore(&steam->lock, flags);

steam_sensors_unregister(steam);
steam_input_unregister(steam);
schedule_work(&steam->unregister_work);

return 0;
}
Expand All @@ -1135,11 +1160,7 @@ static void steam_client_ll_close(struct hid_device *hdev)
connected = steam->connected && !steam->client_opened;
spin_unlock_irqrestore(&steam->lock, flags);

if (connected) {
steam_set_lizard_mode(steam, lizard_mode);
steam_input_register(steam);
steam_sensors_register(steam);
}
schedule_work(&steam->unregister_work);
}

static int steam_client_ll_raw_request(struct hid_device *hdev,
Expand Down Expand Up @@ -1231,6 +1252,7 @@ static int steam_probe(struct hid_device *hdev,
INIT_LIST_HEAD(&steam->list);
INIT_WORK(&steam->rumble_work, steam_haptic_rumble_cb);
steam->sensor_timestamp_us = 0;
INIT_WORK(&steam->unregister_work, steam_work_unregister_cb);

/*
* With the real steam controller interface, do not connect hidraw.
Expand Down Expand Up @@ -1291,6 +1313,7 @@ static int steam_probe(struct hid_device *hdev,
cancel_work_sync(&steam->work_connect);
cancel_delayed_work_sync(&steam->mode_switch);
cancel_work_sync(&steam->rumble_work);
cancel_work_sync(&steam->unregister_work);

return ret;
}
Expand All @@ -1307,6 +1330,7 @@ static void steam_remove(struct hid_device *hdev)
cancel_delayed_work_sync(&steam->mode_switch);
cancel_work_sync(&steam->work_connect);
cancel_work_sync(&steam->rumble_work);
cancel_work_sync(&steam->unregister_work);
hid_destroy_device(steam->client_hdev);
steam->client_hdev = NULL;
steam->client_opened = 0;
Expand Down Expand Up @@ -1593,13 +1617,13 @@ static void steam_do_deck_input_event(struct steam_device *steam,

if (!(b9 & BIT(6)) && steam->did_mode_switch) {
steam->did_mode_switch = false;
cancel_delayed_work_sync(&steam->mode_switch);
cancel_delayed_work(&steam->mode_switch);
} else if (!steam->client_opened && (b9 & BIT(6)) && !steam->did_mode_switch) {
steam->did_mode_switch = true;
schedule_delayed_work(&steam->mode_switch, 45 * HZ / 100);
}

if (!steam->gamepad_mode)
if (!steam->gamepad_mode && lizard_mode)
return;

lpad_touched = b10 & BIT(3);
Expand Down Expand Up @@ -1669,7 +1693,7 @@ static void steam_do_deck_sensors_event(struct steam_device *steam,
*/
steam->sensor_timestamp_us += 4000;

if (!steam->gamepad_mode)
if (!steam->gamepad_mode && lizard_mode)
return;

input_event(sensors, EV_MSC, MSC_TIMESTAMP, steam->sensor_timestamp_us);
Expand Down
2 changes: 1 addition & 1 deletion drivers/hid/hid-thrustmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static void thrustmaster_interrupts(struct hid_device *hdev)
b_ep = ep->desc.bEndpointAddress;

/* Are the expected endpoints present? */
u8 ep_addr[1] = {b_ep};
u8 ep_addr[2] = {b_ep, 0};

if (!usb_check_int_endpoints(usbif, ep_addr)) {
hid_err(hdev, "Unexpected non-int endpoint\n");
Expand Down
7 changes: 7 additions & 0 deletions drivers/hid/hid-topre.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ static const __u8 *topre_report_fixup(struct hid_device *hdev, __u8 *rdesc,
hid_info(hdev,
"fixing up Topre REALFORCE keyboard report descriptor\n");
rdesc[72] = 0x02;
} else if (*rsize >= 106 && rdesc[28] == 0x29 && rdesc[29] == 0xe7 &&
rdesc[30] == 0x81 && rdesc[31] == 0x00) {
hid_info(hdev,
"fixing up Topre REALFORCE keyboard report descriptor\n");
rdesc[31] = 0x02;
}
return rdesc;
}
Expand All @@ -38,6 +43,8 @@ static const struct hid_device_id topre_id_table[] = {
USB_DEVICE_ID_TOPRE_REALFORCE_R2_108) },
{ HID_USB_DEVICE(USB_VENDOR_ID_TOPRE,
USB_DEVICE_ID_TOPRE_REALFORCE_R2_87) },
{ HID_USB_DEVICE(USB_VENDOR_ID_TOPRE,
USB_DEVICE_ID_TOPRE_REALFORCE_R3S_87) },
{ }
};
MODULE_DEVICE_TABLE(hid, topre_id_table);
Expand Down
2 changes: 2 additions & 0 deletions drivers/hid/hid-winwing.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ static int winwing_init_led(struct hid_device *hdev,
"%s::%s",
dev_name(&input->dev),
info->led_name);
if (!led->cdev.name)
return -ENOMEM;

ret = devm_led_classdev_register(&hdev->dev, &led->cdev);
if (ret)
Expand Down
2 changes: 1 addition & 1 deletion drivers/hid/i2c-hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
menuconfig I2C_HID
tristate "I2C HID support"
default y
depends on I2C && INPUT && HID
depends on I2C

if I2C_HID

Expand Down
1 change: 0 additions & 1 deletion drivers/hid/intel-ish-hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ config INTEL_ISH_HID
tristate "Intel Integrated Sensor Hub"
default n
depends on X86
depends on HID
help
The Integrated Sensor Hub (ISH) enables the ability to offload
sensor polling and algorithm processing to a dedicated low power
Expand Down
2 changes: 2 additions & 0 deletions drivers/hid/intel-ish-hid/ipc/hw-ish.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#define PCI_DEVICE_ID_INTEL_ISH_ARL_H 0x7745
#define PCI_DEVICE_ID_INTEL_ISH_ARL_S 0x7F78
#define PCI_DEVICE_ID_INTEL_ISH_LNL_M 0xA845
#define PCI_DEVICE_ID_INTEL_ISH_PTL_H 0xE345
#define PCI_DEVICE_ID_INTEL_ISH_PTL_P 0xE445

#define REVISION_ID_CHT_A0 0x6
#define REVISION_ID_CHT_Ax_SI 0x0
Expand Down
15 changes: 9 additions & 6 deletions drivers/hid/intel-ish-hid/ipc/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ static int ish_fw_reset_handler(struct ishtp_device *dev)
/* ISH FW is dead */
if (!ish_is_input_ready(dev))
return -EPIPE;

/* Send clock sync at once after reset */
ishtp_dev->prev_sync = 0;

/*
* Set HOST2ISH.ILUP. Apparently we need this BEFORE sending
* RESET_NOTIFY_ACK - FW will be checking for it
Expand Down Expand Up @@ -577,15 +581,14 @@ static void fw_reset_work_fn(struct work_struct *work)
*/
static void _ish_sync_fw_clock(struct ishtp_device *dev)
{
static unsigned long prev_sync;
uint64_t usec;
struct ipc_time_update_msg time = {};

if (prev_sync && time_before(jiffies, prev_sync + 20 * HZ))
if (dev->prev_sync && time_before(jiffies, dev->prev_sync + 20 * HZ))
return;

prev_sync = jiffies;
usec = ktime_to_us(ktime_get_boottime());
ipc_send_mng_msg(dev, MNG_SYNC_FW_CLOCK, &usec, sizeof(uint64_t));
dev->prev_sync = jiffies;
/* The fields of time would be updated while sending message */
ipc_send_mng_msg(dev, MNG_SYNC_FW_CLOCK, &time, sizeof(time));
}

/**
Expand Down
Loading

0 comments on commit 58c9bf3

Please sign in to comment.