Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] HID: lenovo: Fix middle-button behaviour for system suspend
@ 2023-09-21  9:21 Martin Kepplinger
  2023-09-24  8:11 ` Jamie Lentin
  0 siblings, 1 reply; 9+ messages in thread
From: Martin Kepplinger @ 2023-09-21  9:21 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jm, linux-kernel
  Cc: linux-input, Martin Kepplinger

After system suspend the middle-button mode is being reset to
compatibility mode which simply breaks functionality for the devices
where native mode is configured during probe().

Fix this by setting native mode in reset_resume() for the appropriate
devices.

Fixes: 94eefa271323 ("HID: lenovo: Use native middle-button mode for compact keyboards")
Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
 drivers/hid/hid-lenovo.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 44763c0da444..d20562b9eca6 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -1344,6 +1344,28 @@ static int lenovo_input_configured(struct hid_device *hdev,
 	return 0;
 }
 
+static int __maybe_unused lenovo_resume(struct hid_device *hdev)
+{
+	int ret;
+
+	switch (hdev->product) {
+	case USB_DEVICE_ID_LENOVO_CUSBKBD:
+	case USB_DEVICE_ID_LENOVO_CBTKBD:
+	case USB_DEVICE_ID_LENOVO_TPIIUSBKBD:
+	case USB_DEVICE_ID_LENOVO_TPIIBTKBD:
+		/* Switch middle button to native mode again */
+		ret = lenovo_send_cmd_cptkbd(hdev, 0x09, 0x01);
+		if (ret)
+			hid_warn(hdev, "Failed to switch middle button: %d\n",
+				 ret);
+		break;
+	default:
+		ret = 0;
+		break;
+	}
+
+	return ret;
+}
 
 static const struct hid_device_id lenovo_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) },
@@ -1380,6 +1402,9 @@ static struct hid_driver lenovo_driver = {
 	.raw_event = lenovo_raw_event,
 	.event = lenovo_event,
 	.report_fixup = lenovo_report_fixup,
+#ifdef CONFIG_PM
+	.reset_resume = lenovo_resume,
+#endif
 };
 module_hid_driver(lenovo_driver);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-30  9:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-21  9:21 [PATCH] HID: lenovo: Fix middle-button behaviour for system suspend Martin Kepplinger
2023-09-24  8:11 ` Jamie Lentin
2023-09-25 10:23   ` [RFC PATCH 1/2] hid: lenovo: Resend all settings on reset_resume for compact keyboards Martin Kepplinger
2023-09-25 10:23     ` [RFC PATCH 2/2] hid: lenovo: move type checks to lenovo_features_set_cptkbd() Martin Kepplinger
2023-09-27  8:19       ` Jamie Lentin
2023-09-27 11:20         ` Martin Kepplinger
2023-09-28 21:06           ` Jamie Lentin
2023-09-30  9:26             ` Martin Kepplinger
2023-09-30  9:58               ` Jamie Lentin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox