Skip to contentSkip to conversation

HID: logitech-dj: add support for the new lightspeed receiver iteration

PATCH In review Filipe Laíns 3 participants 6 messages Jan 23, 2021 – Dec 13, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 HID: logitech-dj: add support for the new lightspeed receiver iteration

From: Filipe Laíns <[email protected]>

Tested with the G Pro X Superlight. libratbag sees the device, as expected, and input events are passing trough.

https://github.com/libratbag/libratbag/pull/1122

The receiver has a quirk where the moused interface doesn't have a report ID, I am not sure why, perhaps they forgot. All other interfaces have report IDs so I am left scratching my head.
Since this driver doesn't have a quirk system, I simply implemented it as a different receiver type, which is true, it just wouldn't be the prefered approach :P

---
 drivers/hid/hid-ids.h         |  1 +
 drivers/hid/hid-logitech-dj.c | 49 +++++++++++++++++++++++++----------
 2 files changed, 37 insertions(+), 13 deletions(-)
drivers/hid/hid-ids.h +1 -0
index 4c5f23640f9c..8eac3c93fa38 100644
@@ -803,6 +803,7 @@
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1	0xc539
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1	0xc53f
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_POWERPLAY	0xc53a
+#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2	0xc547
 #define USB_DEVICE_ID_SPACETRAVELLER	0xc623
 #define USB_DEVICE_ID_SPACENAVIGATOR	0xc626
 #define USB_DEVICE_ID_DINOVO_DESKTOP	0xc704
drivers/hid/hid-logitech-dj.c +36 -13

79 lines not on this page · raw message

Signature · 1 line
2.30.0
#1 lore raw

PATCH 2/2 HID: logitech-hidpp: add support for the G Pro X Superlight over USB

From: Filipe Laíns <[email protected]>

Tested and is working :)

---
 drivers/hid/hid-logitech-hidpp.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/hid/hid-logitech-hidpp.c +2 -0
index 291c6b4d26b7..54a289510a7d 100644
@@ -4268,6 +4268,8 @@ static const struct hid_device_id hidpp_devices[] = {
 		.driver_data = HIDPP_QUIRK_CLASS_G920 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS},
 	{ /* Logitech G Pro Gaming Mouse over USB */
 	  HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC088) },
+	{ /* Logitech G Pro X Superlight Gaming Mouse over USB */
+	  HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC094) },
 
 	{ /* MX5000 keyboard over Bluetooth */
 	  HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb305),
Signature · 1 line
2.30.0
maintainer
#2 lore raw
In reply to Filipe Laíns
Quoted 5 lines · Filipe Laíns

From: Filipe Laíns <[email protected]>

Tested with the G Pro X Superlight. libratbag sees the device, as expected, and input events are passing trough.

Quoted 8 lines

https://github.com/libratbag/libratbag/pull/1122

The receiver has a quirk where the moused interface doesn't have a report ID, I am not sure why, perhaps they forgot. All other interfaces have report IDs so I am left scratching my head.
Since this driver doesn't have a quirk system, I simply implemented it as a different receiver type, which is true, it just wouldn't be the prefered approach :P

Benjamin, do you have any other idea how to accomplish this without this kind of spaghetti-style conditions?
If not, I am tempted to apply the patch as is.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#3 lore raw
Quoted 16 lines · Jiri Kosina
Quoted 5 lines · Filipe Laíns

From: Filipe Laíns <[email protected]>

Tested with the G Pro X Superlight. libratbag sees the device, as expected, and input events are passing trough.

Quoted 8 lines

https://github.com/libratbag/libratbag/pull/1122

The receiver has a quirk where the moused interface doesn't have a report ID, I am not sure why, perhaps they forgot. All other interfaces have report IDs so I am left scratching my head.
Since this driver doesn't have a quirk system, I simply implemented it as a different receiver type, which is true, it just wouldn't be the prefered approach :P

Quoted 6 lines

Benjamin, do you have any other idea how to accomplish this without this kind of spaghetti-style conditions?
If not, I am tempted to apply the patch as is.

Thanks,

Hi Benjamin, Jiri,

Could we get an update on this?

Cheers,
Filipe Laíns

#4 lore raw
In reply to Filipe Laíns
Quoted 69 lines · Filipe Laíns

From: Filipe Laíns <[email protected]>

Tested with the G Pro X Superlight. libratbag sees the device, as expected, and input events are passing trough.

https://github.com/libratbag/libratbag/pull/1122

The receiver has a quirk where the moused interface doesn't have a report ID, I am not sure why, perhaps they forgot. All other interfaces have report IDs so I am left scratching my head.
Since this driver doesn't have a quirk system, I simply implemented it as a different receiver type, which is true, it just wouldn't be the prefered approach :P

---
 drivers/hid/hid-ids.h         |  1 +
 drivers/hid/hid-logitech-dj.c | 49 +++++++++++++++++++++++++----------
 2 files changed, 37 insertions(+), 13 deletions(-)
drivers/hid/hid-ids.h +1 -0
index 4c5f23640f9c..8eac3c93fa38 100644
@@ -803,6 +803,7 @@
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1      0xc539
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1    0xc53f
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_POWERPLAY 0xc53a
+#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2    0xc547
 #define USB_DEVICE_ID_SPACETRAVELLER   0xc623
 #define USB_DEVICE_ID_SPACENAVIGATOR   0xc626
 #define USB_DEVICE_ID_DINOVO_DESKTOP   0xc704
drivers/hid/hid-logitech-dj.c +2 -12
index 1401ee2067ca..6596c81947a8 100644
@@ -114,6 +114,7 @@ enum recvr_type {
        recvr_type_dj,
        recvr_type_hidpp,
        recvr_type_gaming_hidpp,
+       recvr_type_gaming_hidpp_missing_mse_report_id,  /* lightspeed receiver missing the mouse report ID */
        recvr_type_mouse_only,
        recvr_type_27mhz,
        recvr_type_bluetooth,
@@ -1360,6 +1361,7 @@ static int logi_dj_ll_parse(struct hid_device *hid)
                dbg_hid("%s: sending a mouse descriptor, reports_supported: %llx\n",
                        __func__, djdev->reports_supported);
                if (djdev->dj_receiver_dev->type == recvr_type_gaming_hidpp ||
+                   djdev->dj_receiver_dev->type == recvr_type_gaming_hidpp_missing_mse_report_id ||
                    djdev->dj_receiver_dev->type == recvr_type_mouse_only)
                        rdcat(rdesc, &rsize, mse_high_res_descriptor,
                              sizeof(mse_high_res_descriptor));
@@ -1605,19 +1607,35 @@ static int logi_dj_raw_event(struct hid_device *hdev,
                        data[0] = data[1];
                        data[1] = 0;
                }
-               /*
-                * Mouse-only receivers send unnumbered mouse data. The 27 MHz
-                * receiver uses 6 byte packets, the nano receiver 8 bytes.
-                */
-               if (djrcv_dev->unnumbered_application == HID_GD_MOUSE &&
-                   size <= 8) {
-                       u8 mouse_report[9];
-
-                       /* Prepend report id */
-                       mouse_report[0] = REPORT_TYPE_MOUSE;
-                       memcpy(mouse_report + 1, data, size);
-                       logi_dj_recv_forward_input_report(hdev, mouse_report,

drivers/hid/hid-logitech-dj.c static int logi_dj_raw_event(struct hid_device *hdev, · line 1618

Quoted 10 lines
drivers/hid/hid-logitech-dj.c +9 -1
-                                                         size + 1);
+
+
+               if (djrcv_dev->unnumbered_application == HID_GD_MOUSE) {
+                       /*
+                        * Mouse-only receivers send unnumbered mouse data. The 27 MHz
+                        * receiver uses 6 byte packets, the nano receiver 8 bytes.
+                        */
+                       if (size <= 8) {
+                               u8 mouse_report[9];

Hmm, as stated above, the 27 MHz receiver already does the exact same thing.

Can't we just bump the array size and check above to the following:

if (size <= 16) {
u8 mouse_report[17];

The property "djrcv_dev->unnumbered_application" is based on the report descriptor entirely, and they are just following the HID norm here. So I think this should be enough.

Cheers,
Benjamin

Quoted 45 lines
drivers/hid/hid-logitech-dj.c +25 -1
+
+                               /* Prepend report id */
+                               mouse_report[0] = REPORT_TYPE_MOUSE;
+                               memcpy(mouse_report + 1, data, size);
+                               logi_dj_recv_forward_input_report(hdev, mouse_report,
+                                                                 size + 1);
+
+                       /*
+                        * A variant of the ligtpseed receivers is missing the mouse
+                        * report ID.
+                        */
+                       } else if (djrcv_dev->type == recvr_type_gaming_hidpp_missing_mse_report_id) {
+                               u8 mouse_report[17];
+
+                               /* Prepend report id */
+                               mouse_report[0] = REPORT_TYPE_MOUSE;
+                               memcpy(mouse_report + 1, data, size);
+                               logi_dj_recv_forward_input_report(hdev, mouse_report,
+                                                                 size + 1);
+                       }
                }
 
                return false;
@@ -1688,6 +1706,7 @@ static int logi_dj_probe(struct hid_device *hdev,
        case recvr_type_dj:             no_dj_interfaces = 3; break;
        case recvr_type_hidpp:          no_dj_interfaces = 2; break;
        case recvr_type_gaming_hidpp:   no_dj_interfaces = 3; break;
+       case recvr_type_gaming_hidpp_missing_mse_report_id: no_dj_interfaces = 3; break;
        case recvr_type_mouse_only:     no_dj_interfaces = 2; break;
        case recvr_type_27mhz:          no_dj_interfaces = 2; break;
        case recvr_type_bluetooth:      no_dj_interfaces = 2; break;
@@ -1886,6 +1905,10 @@ static const struct hid_device_id logi_dj_receivers[] = {
          HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
                USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1),
         .driver_data = recvr_type_gaming_hidpp},
+       { /* Logitech lightspeed receiver (0xc547) */
+         HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
+               USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2),
+        .driver_data = recvr_type_gaming_hidpp_missing_mse_report_id},
        { /* Logitech 27 MHz HID++ 1.0 receiver (0xc513) */
          HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),
         .driver_data = recvr_type_27mhz},
--

2.30.0

#5 lore raw

Hi Filipe,

Quoted 84 lines · Benjamin Tissoires
Quoted 69 lines · Filipe Laíns

From: Filipe Laíns <[email protected]>

Tested with the G Pro X Superlight. libratbag sees the device, as expected, and input events are passing trough.

https://github.com/libratbag/libratbag/pull/1122

The receiver has a quirk where the moused interface doesn't have a report ID, I am not sure why, perhaps they forgot. All other interfaces have report IDs so I am left scratching my head.
Since this driver doesn't have a quirk system, I simply implemented it as a different receiver type, which is true, it just wouldn't be the prefered approach :P

---
 drivers/hid/hid-ids.h         |  1 +
 drivers/hid/hid-logitech-dj.c | 49 +++++++++++++++++++++++++----------
 2 files changed, 37 insertions(+), 13 deletions(-)
drivers/hid/hid-ids.h +1 -0
index 4c5f23640f9c..8eac3c93fa38 100644
@@ -803,6 +803,7 @@
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1      0xc539
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1    0xc53f
 #define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_POWERPLAY 0xc53a
+#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2    0xc547
 #define USB_DEVICE_ID_SPACETRAVELLER   0xc623
 #define USB_DEVICE_ID_SPACENAVIGATOR   0xc626
 #define USB_DEVICE_ID_DINOVO_DESKTOP   0xc704
drivers/hid/hid-logitech-dj.c +2 -12
index 1401ee2067ca..6596c81947a8 100644
@@ -114,6 +114,7 @@ enum recvr_type {
        recvr_type_dj,
        recvr_type_hidpp,
        recvr_type_gaming_hidpp,
+       recvr_type_gaming_hidpp_missing_mse_report_id,  /* lightspeed receiver missing the mouse report ID */
        recvr_type_mouse_only,
        recvr_type_27mhz,
        recvr_type_bluetooth,
@@ -1360,6 +1361,7 @@ static int logi_dj_ll_parse(struct hid_device *hid)
                dbg_hid("%s: sending a mouse descriptor, reports_supported: %llx\n",
                        __func__, djdev->reports_supported);
                if (djdev->dj_receiver_dev->type == recvr_type_gaming_hidpp ||
+                   djdev->dj_receiver_dev->type == recvr_type_gaming_hidpp_missing_mse_report_id ||
                    djdev->dj_receiver_dev->type == recvr_type_mouse_only)
                        rdcat(rdesc, &rsize, mse_high_res_descriptor,
                              sizeof(mse_high_res_descriptor));
@@ -1605,19 +1607,35 @@ static int logi_dj_raw_event(struct hid_device *hdev,
                        data[0] = data[1];
                        data[1] = 0;
                }
-               /*
-                * Mouse-only receivers send unnumbered mouse data. The 27 MHz
-                * receiver uses 6 byte packets, the nano receiver 8 bytes.
-                */
-               if (djrcv_dev->unnumbered_application == HID_GD_MOUSE &&
-                   size <= 8) {
-                       u8 mouse_report[9];
-
-                       /* Prepend report id */
-                       mouse_report[0] = REPORT_TYPE_MOUSE;
-                       memcpy(mouse_report + 1, data, size);
-                       logi_dj_recv_forward_input_report(hdev, mouse_report,

drivers/hid/hid-logitech-dj.c static int logi_dj_raw_event(struct hid_device *hdev, · line 1618

Quoted 10 lines
drivers/hid/hid-logitech-dj.c +9 -1
-                                                         size + 1);
+
+
+               if (djrcv_dev->unnumbered_application == HID_GD_MOUSE) {
+                       /*
+                        * Mouse-only receivers send unnumbered mouse data. The 27 MHz
+                        * receiver uses 6 byte packets, the nano receiver 8 bytes.
+                        */
+                       if (size <= 8) {
+                               u8 mouse_report[9];

Hmm, as stated above, the 27 MHz receiver already does the exact same thing.

Quoted 8 lines

Can't we just bump the array size and check above to the following:

if (size <= 16) {
u8 mouse_report[17];

The property "djrcv_dev->unnumbered_application" is based on the report descriptor entirely, and they are just following the HID norm here. So I think this should be enough.

I've been pinged last week about the G Pro X superlight, and Peter found that this patch never got into upstream.

AFAICT, compared to upstream the following code change should have the same effect that what you proposed here:
---

drivers/hid/hid-logitech-dj.c +4 -3
index 7106b921b53c..f5cdfce272e7 100644
@@ -1691,11 +1691,12 @@ static int logi_dj_raw_event(struct hid_device *hdev,
                }
                /*
                 * Mouse-only receivers send unnumbered mouse data. The 27 MHz
-                * receiver uses 6 byte packets, the nano receiver 8 bytes.
+                * receiver uses 6 byte packets, the nano receiver 8 bytes and
+                * some gaming ones are using 16 bytes.
                 */
                if (djrcv_dev->unnumbered_application == HID_GD_MOUSE &&
-                   size <= 8) {
-                       u8 mouse_report[9];
+                   size <= 16) {
+                       u8 mouse_report[17];
 
                        /* Prepend report id */
                        mouse_report[0] = REPORT_TYPE_MOUSE;

---

Would you mind sending a v2 of the patch updated to the current for-next so we can schedule this for 5.17?

Cheers,
Benjamin

Quoted 49 lines

Cheers,
Benjamin

Quoted 45 lines
drivers/hid/hid-logitech-dj.c +25 -1
+
+                               /* Prepend report id */
+                               mouse_report[0] = REPORT_TYPE_MOUSE;
+                               memcpy(mouse_report + 1, data, size);
+                               logi_dj_recv_forward_input_report(hdev, mouse_report,
+                                                                 size + 1);
+
+                       /*
+                        * A variant of the ligtpseed receivers is missing the mouse
+                        * report ID.
+                        */
+                       } else if (djrcv_dev->type == recvr_type_gaming_hidpp_missing_mse_report_id) {
+                               u8 mouse_report[17];
+
+                               /* Prepend report id */
+                               mouse_report[0] = REPORT_TYPE_MOUSE;
+                               memcpy(mouse_report + 1, data, size);
+                               logi_dj_recv_forward_input_report(hdev, mouse_report,
+                                                                 size + 1);
+                       }
                }
 
                return false;
@@ -1688,6 +1706,7 @@ static int logi_dj_probe(struct hid_device *hdev,
        case recvr_type_dj:             no_dj_interfaces = 3; break;
        case recvr_type_hidpp:          no_dj_interfaces = 2; break;
        case recvr_type_gaming_hidpp:   no_dj_interfaces = 3; break;
+       case recvr_type_gaming_hidpp_missing_mse_report_id: no_dj_interfaces = 3; break;
        case recvr_type_mouse_only:     no_dj_interfaces = 2; break;
        case recvr_type_27mhz:          no_dj_interfaces = 2; break;
        case recvr_type_bluetooth:      no_dj_interfaces = 2; break;
@@ -1886,6 +1905,10 @@ static const struct hid_device_id logi_dj_receivers[] = {
          HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
                USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1),
         .driver_data = recvr_type_gaming_hidpp},
+       { /* Logitech lightspeed receiver (0xc547) */
+         HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
+               USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2),
+        .driver_data = recvr_type_gaming_hidpp_missing_mse_report_id},
        { /* Logitech 27 MHz HID++ 1.0 receiver (0xc513) */
          HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),
         .driver_data = recvr_type_27mhz},
--

2.30.0