]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/hid-logitech-hidpp-use-rap-instead-of-fap-to-get-the.patch
drop drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch from 4.4.y and 4.9.y
[thirdparty/kernel/stable-queue.git] / queue-4.4 / hid-logitech-hidpp-use-rap-instead-of-fap-to-get-the.patch
1 From cdc790dc8e568d3478cdf4bc3146b40ca66258ac Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Sat, 20 Apr 2019 13:22:10 +0200
4 Subject: HID: logitech-hidpp: use RAP instead of FAP to get the protocol
5 version
6
7 [ Upstream commit 096377525cdb8251e4656085efc988bdf733fb4c ]
8
9 According to the logitech_hidpp_2.0_specification_draft_2012-06-04.pdf doc:
10 https://lekensteyn.nl/files/logitech/logitech_hidpp_2.0_specification_draft_2012-06-04.pdf
11
12 We should use a register-access-protocol request using the short input /
13 output report ids. This is necessary because 27MHz HID++ receivers have
14 a max-packetsize on their HIP++ endpoint of 8, so they cannot support
15 long reports. Using a feature-access-protocol request (which is always
16 long or very-long) with these will cause a timeout error, followed by
17 the hidpp driver treating the device as not being HID++ capable.
18
19 This commit fixes this by switching to using a rap request to get the
20 protocol version.
21
22 Besides being tested with a (046d:c517) 27MHz receiver with various
23 27MHz keyboards and mice, this has also been tested to not cause
24 regressions on a non-unifying dual-HID++ nano receiver (046d:c534) with
25 k270 and m185 HID++-2.0 devices connected and on a unifying/dj receiver
26 (046d:c52b) with a HID++-2.0 Logitech Rechargeable Touchpad T650.
27
28 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
29 Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
30 Signed-off-by: Sasha Levin <sashal@kernel.org>
31 ---
32 drivers/hid/hid-logitech-hidpp.c | 17 +++++++++++++----
33 1 file changed, 13 insertions(+), 4 deletions(-)
34
35 diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
36 index 5fd97860aec4d..3666e5064d0d3 100644
37 --- a/drivers/hid/hid-logitech-hidpp.c
38 +++ b/drivers/hid/hid-logitech-hidpp.c
39 @@ -414,13 +414,16 @@ static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature,
40
41 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
42 {
43 + const u8 ping_byte = 0x5a;
44 + u8 ping_data[3] = { 0, 0, ping_byte };
45 struct hidpp_report response;
46 int ret;
47
48 - ret = hidpp_send_fap_command_sync(hidpp,
49 + ret = hidpp_send_rap_command_sync(hidpp,
50 + REPORT_ID_HIDPP_SHORT,
51 HIDPP_PAGE_ROOT_IDX,
52 CMD_ROOT_GET_PROTOCOL_VERSION,
53 - NULL, 0, &response);
54 + ping_data, sizeof(ping_data), &response);
55
56 if (ret == HIDPP_ERROR_INVALID_SUBID) {
57 hidpp->protocol_major = 1;
58 @@ -440,8 +443,14 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
59 if (ret)
60 return ret;
61
62 - hidpp->protocol_major = response.fap.params[0];
63 - hidpp->protocol_minor = response.fap.params[1];
64 + if (response.rap.params[2] != ping_byte) {
65 + hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n",
66 + __func__, response.rap.params[2], ping_byte);
67 + return -EPROTO;
68 + }
69 +
70 + hidpp->protocol_major = response.rap.params[0];
71 + hidpp->protocol_minor = response.rap.params[1];
72
73 return ret;
74 }
75 --
76 2.20.1
77