hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/hid/hid-lg.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * HID driver for some logitech "special" devices
34 *
....@@ -10,10 +11,6 @@
1011 */
1112
1213 /*
13
- * This program is free software; you can redistribute it and/or modify it
14
- * under the terms of the GNU General Public License as published by the Free
15
- * Software Foundation; either version 2 of the License, or (at your option)
16
- * any later version.
1714 */
1815
1916 #include <linux/device.h>
....@@ -50,6 +47,7 @@
5047 #define MOMO_RDESC_ORIG_SIZE 87
5148 #define MOMO2_RDESC_ORIG_SIZE 87
5249 #define FFG_RDESC_ORIG_SIZE 85
50
+#define FG_RDESC_ORIG_SIZE 82
5351
5452 /* Fixed report descriptors for Logitech Driving Force (and Pro)
5553 * wheel controllers
....@@ -381,6 +379,49 @@
381379 0xC0 /* End Collection */
382380 };
383381
382
+static __u8 fg_rdesc_fixed[] = {
383
+0x05, 0x01, /* Usage Page (Desktop), */
384
+0x09, 0x04, /* Usage (Joystik), */
385
+0xA1, 0x01, /* Collection (Application), */
386
+0xA1, 0x02, /* Collection (Logical), */
387
+0x15, 0x00, /* Logical Minimum (0), */
388
+0x26, 0xFF, 0x00, /* Logical Maximum (255), */
389
+0x35, 0x00, /* Physical Minimum (0), */
390
+0x46, 0xFF, 0x00, /* Physical Maximum (255), */
391
+0x75, 0x08, /* Report Size (8), */
392
+0x95, 0x01, /* Report Count (1), */
393
+0x09, 0x30, /* Usage (X), */
394
+0x81, 0x02, /* Input (Variable), */
395
+0xA4, /* Push, */
396
+0x25, 0x01, /* Logical Maximum (1), */
397
+0x45, 0x01, /* Physical Maximum (1), */
398
+0x75, 0x01, /* Report Size (1), */
399
+0x95, 0x02, /* Report Count (2), */
400
+0x81, 0x01, /* Input (Constant), */
401
+0x95, 0x06, /* Report Count (6), */
402
+0x05, 0x09, /* Usage Page (Button), */
403
+0x19, 0x01, /* Usage Minimum (01h), */
404
+0x29, 0x06, /* Usage Maximum (06h), */
405
+0x81, 0x02, /* Input (Variable), */
406
+0x05, 0x01, /* Usage Page (Desktop), */
407
+0xB4, /* Pop, */
408
+0x81, 0x02, /* Input (Constant), */
409
+0x09, 0x31, /* Usage (Y), */
410
+0x81, 0x02, /* Input (Variable), */
411
+0x09, 0x32, /* Usage (Z), */
412
+0x81, 0x02, /* Input (Variable), */
413
+0xC0, /* End Collection, */
414
+0xA1, 0x02, /* Collection (Logical), */
415
+0x26, 0xFF, 0x00, /* Logical Maximum (255), */
416
+0x46, 0xFF, 0x00, /* Physical Maximum (255), */
417
+0x75, 0x08, /* Report Size (8), */
418
+0x95, 0x04, /* Report Count (4), */
419
+0x09, 0x02, /* Usage (02h), */
420
+0xB1, 0x02, /* Feature (Variable), */
421
+0xC0, /* End Collection, */
422
+0xC0 /* End Collection, */
423
+};
424
+
384425 /*
385426 * Certain Logitech keyboards send in report #3 keys which are far
386427 * above the logical maximum described in descriptor. This extends
....@@ -407,6 +448,19 @@
407448 }
408449
409450 switch (hdev->product) {
451
+
452
+ case USB_DEVICE_ID_LOGITECH_WINGMAN_FG:
453
+ if (*rsize == FG_RDESC_ORIG_SIZE) {
454
+ hid_info(hdev,
455
+ "fixing up Logitech Wingman Formula GP report descriptor\n");
456
+ rdesc = fg_rdesc_fixed;
457
+ *rsize = sizeof(fg_rdesc_fixed);
458
+ } else {
459
+ hid_info(hdev,
460
+ "rdesc size test failed for formula gp\n");
461
+ }
462
+ break;
463
+
410464
411465 case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
412466 if (*rsize == FFG_RDESC_ORIG_SIZE) {
....@@ -664,6 +718,7 @@
664718 usage->code == ABS_RZ)) {
665719 switch (hdev->product) {
666720 case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
721
+ case USB_DEVICE_ID_LOGITECH_WINGMAN_FG:
667722 case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
668723 case USB_DEVICE_ID_LOGITECH_WHEEL:
669724 case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
....@@ -822,11 +877,7 @@
822877 }
823878
824879 static const struct hid_device_id lg_devices[] = {
825
- { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),
826
- .driver_data = LG_RDESC | LG_WIRELESS },
827880 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER),
828
- .driver_data = LG_RDESC | LG_WIRELESS },
829
- { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2),
830881 .driver_data = LG_RDESC | LG_WIRELESS },
831882
832883 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER),
....@@ -879,6 +930,8 @@
879930 .driver_data = LG_NOGET | LG_FF4 },
880931 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL),
881932 .driver_data = LG_FF4 },
933
+ { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FG),
934
+ .driver_data = LG_NOGET },
882935 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG),
883936 .driver_data = LG_NOGET | LG_FF4 },
884937 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2),