[PATCH] HID: hid-logitech-hidpp: Implement support for some Bluetooth HID++ devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds support the MX Anywhere 2, MX Anywhere 2S, MX Master, and MX Master 2S over Bluetooth to the hid-logitech-hidpp module. This patch also implements a foundation for other Bluetooth devices to be added to the module.

Changes include:
1) Adding the device IDs for the aforementioned mice over Bluetooth (these IDs have been copied from the libratbag device database). Their quirks have been based on their DJ device counterparts.
2) Adding an additional HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID as these devices do not support Short HID++ reports. This quirk causes short reports to be sent as long reports to the device and overrides the device validation to only check if the long report descriptor exists. Without this quirk, these devices will fail the HID++ device validation.

Note about these changes: I only own an MX Master (b01e) so I have not been able to test this patch on other devices. However, I have also noticed that the MX Master 2S over Bluetooth does not pass the original HID++ report descriptor tests which leads me to believe all MX Bluetooth LE devices are missing short report descriptors. Further testing with the other devices may be required.

Signed-off-by: Mazin Rezk <mnrzk@xxxxxxxxxxxxxx>
---
 drivers/hid/hid-logitech-hidpp.c | 39 ++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 0179f7ed77e5..a80c4486756c 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -72,6 +72,9 @@ MODULE_PARM_DESC(disable_tap_to_click,
 #define HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS	BIT(30)
 #define HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS	BIT(31)

+/* This is required to fix report ids on some bluetooth devices */
+#define HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID	BIT(32)
+
 /* These are just aliases for now */
 #define HIDPP_QUIRK_KBD_SCROLL_WHEEL HIDPP_QUIRK_HIDPP_WHEELS
 #define HIDPP_QUIRK_KBD_ZOOM_WHEEL   HIDPP_QUIRK_HIDPP_WHEELS
@@ -340,6 +343,11 @@ static int hidpp_send_rap_command_sync(struct hidpp_device *hidpp_dev,
 	struct hidpp_report *message;
 	int ret, max_count;

+	/* Force long reports on devices that do not support short reports */
+	if (hidpp_dev-&gt;quirks &amp; HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID &amp;&amp;
+	    report_id == REPORT_ID_HIDPP_SHORT)
+		report_id = REPORT_ID_HIDPP_LONG;
+
 	switch (report_id) {
 	case REPORT_ID_HIDPP_SHORT:
 		max_count = HIDPP_REPORT_SHORT_LENGTH - 4;
@@ -3482,6 +3490,12 @@ static bool hidpp_validate_report(struct hid_device *hdev, int id,

 static bool hidpp_validate_device(struct hid_device *hdev)
 {
+	struct hidpp_device *hidpp = hid_get_drvdata(hdev);
+	/* Skip the short report check if the device does not support it */
+	if (hidpp-&gt;quirks &amp; HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID)
+		return hidpp_validate_report(hdev, REPORT_ID_HIDPP_LONG,
+					     HIDPP_REPORT_LONG_LENGTH, false);
+
 	return hidpp_validate_report(hdev, REPORT_ID_HIDPP_SHORT,
 				     HIDPP_REPORT_SHORT_LENGTH, false) &amp;&amp;
 	       hidpp_validate_report(hdev, REPORT_ID_HIDPP_LONG,
@@ -3773,6 +3787,31 @@ static const struct hid_device_id hidpp_devices[] = {
 	{ /* MX5500 keyboard over Bluetooth */
 	  HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb30b),
 	  .driver_data = HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS },
+	{ /* MX Anywhere 2 mouse over Bluetooth */
+	  HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb013),
+	  .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 |
+			 HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb018),
+	  .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 |
+			 HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID },
+	{ /* MX Anywhere 2S mouse over Bluetooth */
+	  HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01a),
+	  .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 |
+			 HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID },
+	{ /* MX Master mouse over Bluetooth */
+	  HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb012),
+	  .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 |
+			 HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb017),
+	  .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 |
+			 HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01e),
+	  .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 |
+			 HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID },
+	{ /* MX Master 2S mouse over Bluetooth */
+	  HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb019),
+	  .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 |
+			 HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID },
 	{}
 };

--
2.23.0





[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux