From: Shan Rizvi <shan@rizvi.nu>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Jonathan Cameron <jic23@kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
Chia-Lin Kao <acelan.kao@canonical.com>,
Shan Rizvi <shan@rizvi.nu>,
stable@vger.kernel.org
Subject: [PATCH] HID: sensor-hub: Fix report 17 interval size on Chicony 04f2:b872
Date: Thu, 3 Dec 2026 10:38:42 -0500 [thread overview]
Message-ID: <20261203153842.565409-1-shan@rizvi.nu> (raw)
On the Chicony HP 5MP Camera sensor hub (04f2:b872, bcdDevice 0x1020,
HP OmniBook X Flip 16 8EA2, BIOS F.07), probing the secondary proximity
sensor (feature report 17) via iio_info or iio-sensor-proxy stalls
runtime PM resume for hours.
All byte offsets below include the leading report ID at byte 0. Report
17 declares Report Interval (usage 0x030e) and Minimum Report Interval
(usage 0x0304) as 32-bit fields for a 122-byte report. On the wire,
GET_REPORT returns 120 bytes: a 16-bit Report Interval at bytes 6..7
followed immediately by the 32-bit Minimum Report Interval (100 ms) at
bytes 8..11 and the remaining fields, shifting every subsequent field
left by two bytes (including Friendly Name and Persistent Unique ID):
parsed at declared offsets (bytes 26..57): "P AI SENSOR"
actual wire layout (bytes 24..55): "HP AI SENSOR"
Because hid-sensor-hub parses Report Interval as 32 bits, the default
wire bytes (d0 07 64 00) decode as 6,555,600 ms instead of 2000 ms,
causing in_proximity0_sampling_frequency to read 0.000100 and stalling
hid-sensor-trigger's runtime PM resume in
msleep_interruptible(poll_value * 2) for ~3.64 hours. On the write path,
hid-sensor-hub likewise constructs a 122-byte SET_REPORT with every
field after Report Interval shifted right by two bytes. Because this
device exposes working ALS (report 10) and primary proximity (report 1)
sensors, adding 04f2:b872 to hid_ignore_list would regress working
sensors.
Fix report 17's Report Size (32 -> 16) and Logical Maximum
(0x7fffffff -> 0x0000ffff) in-place in sensor_hub_report_fixup(),
matching the 1846-byte descriptor and the 18-byte item sequence at
offset 1553.
Tested on kernel 7.2.15 with stock hid-sensor-trigger:
in_proximity0_sampling_frequency reads 0.500000 and round-trips across
10, 1, and 0.5 Hz; raw HIDIOCGFEATURE dumps confirm SET_REPORT updates
bytes 6..7 without altering trailing fields; warm reads of
in_proximity0_raw return a live value (~212 ms) without stalling
runtime PM resume. After runtime autosuspend, a raw read can still hit
the pre-existing 5 s completion timeout in
sensor_hub_input_attr_get_raw_value() (returning 0), which is a
separate issue not addressed by this patch. Primary proximity and ALS
continue working.
Link: https://lore.kernel.org/r/179591783777.39.15448655394533903125@rizvi.nu
Cc: stable@vger.kernel.org
Signed-off-by: Shan Rizvi <shan@rizvi.nu>
---
Notes:
- Based on hid.git for-next; runtime-tested on 7.2.15 against stock
hid-sensor-trigger.
- In the linked thread, Srinivas noted he plans to send a generic
hid-sensor-trigger poll-interval clamp. Even with trigger-side
clamping, report 17 still needs this descriptor fixup so GET_REPORT
and SET_REPORT field offsets align.
- Kept in-kernel in sensor_hub_report_fixup() rather than HID-BPF
because probing this sensor can stall runtime PM resume for hours on
systems without udev-hid-bpf installed.
drivers/hid/hid-ids.h | 1 +
drivers/hid/hid-sensor-hub.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index f841667..a6d84a7 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -349,6 +349,7 @@
#define USB_DEVICE_ID_CHICONY_HP_5MP_CAMERA 0xb824
#define USB_DEVICE_ID_CHICONY_HP_5MP_CAMERA2 0xb82c
#define USB_DEVICE_ID_CHICONY_HP_5MP_CAMERA3 0xb882
+#define USB_DEVICE_ID_CHICONY_HP_5MP_CAMERA4 0xb872
#define USB_VENDOR_ID_CHUNGHWAT 0x2247
#define USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH 0x0001
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 2a7f247..8fdee5a 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -674,6 +674,34 @@ static const __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc,
rdesc[917] = rdesc[938] = rdesc[959] = 0xff;
}
+ /*
+ * Chicony HP 5MP Camera (04f2:b872) declares report 17's Report
+ * Interval (usage 0x030e) as 32-bit, but firmware sends and expects
+ * 16 bits (119-byte feature payload instead of 121). Fix Report Size
+ * and Logical Maximum so report 17 matches the wire layout.
+ */
+ if (hdev->vendor == USB_VENDOR_ID_CHICONY &&
+ hdev->product == USB_DEVICE_ID_CHICONY_HP_5MP_CAMERA4 &&
+ *rsize == 1846) {
+ static const __u8 report17_interval[] = {
+ 0x0a, 0x0e, 0x03, /* Usage (Report Interval) */
+ 0x15, 0x00, /* Logical Minimum (0) */
+ 0x27, 0xff, 0xff, 0xff, 0x7f, /* Logical Maximum (0x7fffffff) */
+ 0x75, 0x20, /* Report Size (32) */
+ 0x95, 0x01, /* Report Count (1) */
+ 0x55, 0x00, /* Unit Exponent (0) */
+ 0xb1, 0x02, /* Feature (Data,Var,Abs) */
+ };
+
+ if (!memcmp(&rdesc[1553], report17_interval,
+ sizeof(report17_interval))) {
+ hid_info(hdev, "fixing up Chicony HP 5MP Camera report 17 interval size\n");
+ rdesc[1561] = 0x00;
+ rdesc[1562] = 0x00;
+ rdesc[1564] = 0x10;
+ }
+ }
+
return rdesc;
}
base-commit: 47d0d5ce3cfca63a04eabcbeef7086d06240ff97
--
2.56.0
reply other threads:[~2026-12-03 15:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203153842.565409-1-shan@rizvi.nu \
--to=shan@rizvi.nu \
--cc=acelan.kao@canonical.com \
--cc=bentiss@kernel.org \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox