[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <GOPSiaLYzQc3Hi9-MvdMQOmiF6O9whCeVYWavirKdm-9VHGb37VtawOPII8FEdYAOWZYFvk3oSQcHkPGazJKZNx8DEwBO7JfrRjLjWA84UI=@protonmail.com>
Date: Fri, 11 Oct 2019 00:57:56 +0000
From: Mazin Rezk <mnrzk@...tonmail.com>
To: "linux-input@...r.kernel.org" <linux-input@...r.kernel.org>
Cc: "benjamin.tissoires@...hat.com" <benjamin.tissoires@...hat.com>,
"jikos@...nel.org" <jikos@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Filipe LaĆns <lains@...hlinux.org>,
"mnrzk@...tonmail.com" <mnrzk@...tonmail.com>
Subject: [PATCH v4 4/4] HID: logitech: Support WirelessDeviceStatus connect events
On Saturday, October 5, 2019 9:05 PM, Mazin Rezk <mnrzk@...tonmail.com> wrote:
> This patch makes WirelessDeviceStatus (0x1d4b) events get detected as
> connection events on devices with HIDPP_QUIRK_WIRELESS_DEVICE_STATUS.
>
> This quirk is currently an alias for HIDPP_QUIRK_CLASS_BLUETOOTH since
> the added Bluetooth devices do not support regular connect events.
No changes have been made to this patch in v4.
Signed-off-by: Mazin Rezk <mnrzk@...tonmail.com>
---
drivers/hid/hid-logitech-hidpp.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 2062be922c08..b2b5fe2c74db 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -84,6 +84,7 @@ MODULE_PARM_DESC(disable_tap_to_click,
/* Just an alias for now, may possibly be a catch-all in the future */
#define HIDPP_QUIRK_MISSING_SHORT_REPORTS HIDPP_QUIRK_CLASS_BLUETOOTH
+#define HIDPP_QUIRK_WIRELESS_DEVICE_STATUS HIDPP_QUIRK_CLASS_BLUETOOTH
#define HIDPP_QUIRK_DELAYED_INIT HIDPP_QUIRK_NO_HIDINPUT
@@ -406,9 +407,22 @@ static inline bool hidpp_match_error(struct hidpp_report *question,
(answer->fap.params[0] == question->fap.funcindex_clientid);
}
-static inline bool hidpp_report_is_connect_event(struct hidpp_report *report)
+#define HIDPP_PAGE_WIRELESS_DEVICE_STATUS 0x1d4b
+
+static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp,
+ struct hidpp_report *report)
{
- return (report->report_id == REPORT_ID_HIDPP_SHORT) &&
+ if (hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS) {
+ /* If feature is invalid, skip array check */
+ if (report->fap.feature_index > hidpp->feature_count)
+ return false;
+
+ return (hidpp->features[report->fap.feature_index] ==
+ HIDPP_PAGE_WIRELESS_DEVICE_STATUS);
+ }
+
+ return ((report->report_id == REPORT_ID_HIDPP_SHORT) ||
+ (hidpp->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS)) &&
(report->rap.sub_id == 0x41);
}
@@ -3157,7 +3171,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
}
}
- if (unlikely(hidpp_report_is_connect_event(report))) {
+ if (unlikely(hidpp_report_is_connect_event(hidpp, report))) {
atomic_set(&hidpp->connected,
!(report->rap.params[0] & (1 << 6)));
if (schedule_work(&hidpp->work) == 0)
--
2.23.0
Powered by blists - more mailing lists