Skip to content

Commit b80a75c

Browse files
committed
Merge tag 'hid-for-linus-2025073101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - hardening of HID core parser against conversion to 0 bits in s32ton() by buggy/malicious devices (Alan Stern) - fix for potential NULL pointer dereference in hid-apple that could be caused by malicious device with APPLE_MAGIC_BACKLIGHT quirk present triggering overflow in data field (Qasim Ijaz) - support for Wake-on-touch in intel-thc (Even Xu) - support for "Input max input size control" and "Input interrupt delay" I2C features in order to improve compatibility of THC devices with legacy HIDI2C touch devices (Even Xu) - support for Touch Bars on x86 MacBook Pros (Kerem Karabay) - support for XP-PEN Artist 22R Pro (Joshua Goins) - third party trackpart support for MacBookPro15,1 (Aditya Garg) - Apple Magic Keyboard A311[89] USB-C support (Aditya Garg, Grigorii Sokoli) - support for operating modes in amd-sfh (Basavaraj Natikar) - avoid setting up battery timer for Apple and Magicmouse devices without battery (Aditya Garg) - fix for behavior of the hid-mcp2221 driver for !CONFIG_IIO cases (Heiko Schocher) - other assorted fixups and device ID additions * tag 'hid-for-linus-2025073101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (54 commits) HID: core: Harden s32ton() against conversion to 0 bits HID: apple: validate feature-report field count to prevent NULL pointer dereference HID: core: Improve the kerneldoc for hid_report_len() selftests/hid: sync python tests to hid-tools 0.10 selftests/hid: sync the python tests to hid-tools 0.8 selftests/hid: run ruff format on the python part HID: magicmouse: use secs_to_jiffies() for battery timeout HID: apple: use secs_to_jiffies() for battery timeout HID: magicmouse: avoid setting up battery timer when not needed HID: apple: avoid setting up battery timer for devices without battery HID: amd_sfh: Enable operating mode HID: uclogic: Add support for XP-PEN Artist 22R Pro HID: rate-limit hid_warn to prevent log flooding HID: replace scnprintf() with sysfs_emit() HID: uclogic: make read-only array reconnect_event static const HID: mcp-2221: Replace manual comparison with min() macro HID: intel-thc-hid: Separate max input size control conditional list HID: mcp2221: set gpio pin mode HID: multitouch: add device ID for Apple Touch Bar HID: multitouch: specify that Apple Touch Bar is direct ...
2 parents db68e4c + c62f87e commit b80a75c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1669
-478
lines changed

Documentation/hid/intel-thc-hid.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,34 @@ Control register.
188188
Reset line is controlled by BIOS (or EFI) through ACPI _RST method, driver needs to call this
189189
device ACPI _RST method to reset touch IC during initialization.
190190

191+
2.3 Max input size control
192+
--------------------------
193+
194+
This is a new feature introduced in Panther Lake platform, THC hardware allows driver to set
195+
a max input size for RxDMA. After this max size gets set and enabled, for every input report
196+
packet reading, THC hardware sequencer will first read incoming input packet size, then compare
197+
input packet size with the given max size:
198+
199+
- if input packet size <= max size, THC continues using input packet size to finish the reading
200+
- if input packet size > max size, there is potential input data crash risk during
201+
transferring, THC will use max size instead of input packet size for reading
202+
203+
This feature is used to avoid data corruption which will cause RxDMA buffer overrun issue for
204+
I2C bus, and enhance whole system stability.
205+
206+
2.4 Interrupt delay
207+
-------------------
208+
209+
Because of MCU performance limitation, some touch devices cannot de-assert interrupt pin
210+
immediately after input data is transferred, which cause an interrupt toggle delay. But THC
211+
always detects next interrupt immediately after last input interrupt is handled. In this
212+
case, the delayed interrupt de-assertion will be recognized as a new interrupt signal by THC,
213+
and causes THC to start an input report reading spuriously.
214+
215+
In order to avoid this situation, THC introduced interrupt delay new feature in Panther Lake
216+
platform, where THC allows driver to set an interrupt delay. After this feature is enabled,
217+
THC will delay this given time for next interrupt detection.
218+
191219
3. High level concept
192220
=====================
193221

drivers/hid/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ config HID_MULTITOUCH
771771
Say Y here if you have one of the following devices:
772772
- 3M PCT touch screens
773773
- ActionStar dual touch panels
774+
- Apple Touch Bar on x86 MacBook Pros
774775
- Atmel panels
775776
- Cando dual touch panels
776777
- Chunghwa panels

drivers/hid/amd-sfh-hid/amd_sfh_client.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ static const char *get_sensor_name(int idx)
146146
return "gyroscope";
147147
case mag_idx:
148148
return "magnetometer";
149+
case op_idx:
150+
return "operating-mode";
149151
case als_idx:
150152
case ACS_IDX: /* ambient color sensor */
151153
return "ALS";
@@ -243,6 +245,20 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
243245
rc = -ENOMEM;
244246
goto cleanup;
245247
}
248+
249+
if (cl_data->sensor_idx[i] == op_idx) {
250+
info.period = AMD_SFH_IDLE_LOOP;
251+
info.sensor_idx = cl_data->sensor_idx[i];
252+
info.dma_address = cl_data->sensor_dma_addr[i];
253+
mp2_ops->start(privdata, info);
254+
cl_data->sensor_sts[i] = amd_sfh_wait_for_response(privdata,
255+
cl_data->sensor_idx[i],
256+
SENSOR_ENABLED);
257+
if (cl_data->sensor_sts[i] == SENSOR_ENABLED)
258+
cl_data->is_any_sensor_enabled = true;
259+
continue;
260+
}
261+
246262
cl_data->sensor_sts[i] = SENSOR_DISABLED;
247263
cl_data->sensor_requested_cnt[i] = 0;
248264
cl_data->cur_hid_dev = i;
@@ -303,6 +319,13 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
303319

304320
for (i = 0; i < cl_data->num_hid_devices; i++) {
305321
cl_data->cur_hid_dev = i;
322+
if (cl_data->sensor_idx[i] == op_idx) {
323+
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
324+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
325+
cl_data->sensor_sts[i]);
326+
continue;
327+
}
328+
306329
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
307330
rc = amdtp_hid_probe(i, cl_data);
308331
if (rc)

drivers/hid/amd-sfh-hid/amd_sfh_hid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifndef AMDSFH_HID_H
1212
#define AMDSFH_HID_H
1313

14-
#define MAX_HID_DEVICES 6
14+
#define MAX_HID_DEVICES 7
1515
#define AMD_SFH_HID_VENDOR 0x1022
1616
#define AMD_SFH_HID_PRODUCT 0x0001
1717

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define ACEL_EN BIT(0)
3030
#define GYRO_EN BIT(1)
3131
#define MAGNO_EN BIT(2)
32+
#define OP_EN BIT(15)
3233
#define HPD_EN BIT(16)
3334
#define ALS_EN BIT(19)
3435
#define ACS_EN BIT(22)
@@ -232,6 +233,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
232233
if (MAGNO_EN & activestatus)
233234
sensor_id[num_of_sensors++] = mag_idx;
234235

236+
if (OP_EN & activestatus)
237+
sensor_id[num_of_sensors++] = op_idx;
238+
235239
if (ALS_EN & activestatus)
236240
sensor_id[num_of_sensors++] = als_idx;
237241

drivers/hid/amd-sfh-hid/amd_sfh_pcie.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ enum sensor_idx {
7979
accel_idx = 0,
8080
gyro_idx = 1,
8181
mag_idx = 2,
82+
op_idx = 15,
8283
als_idx = 19
8384
};
8485

0 commit comments

Comments
 (0)