|
20 | 20 | #include <linux/input.h>
|
21 | 21 | #include <linux/hid.h>
|
22 | 22 | #include <linux/module.h>
|
| 23 | +#include <linux/usb.h> |
23 | 24 |
|
24 | 25 | #include "hid-ids.h"
|
25 | 26 |
|
@@ -57,17 +58,42 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
|
57 | 58 | return 1;
|
58 | 59 | }
|
59 | 60 |
|
| 61 | +static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 62 | + unsigned int *rsize) |
| 63 | +{ |
| 64 | + struct usb_interface *intf = to_usb_interface(hdev->dev.parent); |
| 65 | + |
| 66 | + if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { |
| 67 | + /* Change usage maximum and logical maximum from 0x7fff to |
| 68 | + * 0x2fff, so they don't exceed HID_MAX_USAGES */ |
| 69 | + switch (hdev->product) { |
| 70 | + case USB_DEVICE_ID_CHICONY_ACER_SWITCH12: |
| 71 | + if (*rsize >= 128 && rdesc[64] == 0xff && rdesc[65] == 0x7f |
| 72 | + && rdesc[69] == 0xff && rdesc[70] == 0x7f) { |
| 73 | + hid_info(hdev, "Fixing up report descriptor\n"); |
| 74 | + rdesc[65] = rdesc[70] = 0x2f; |
| 75 | + } |
| 76 | + break; |
| 77 | + } |
| 78 | + |
| 79 | + } |
| 80 | + return rdesc; |
| 81 | +} |
| 82 | + |
| 83 | + |
60 | 84 | static const struct hid_device_id ch_devices[] = {
|
61 | 85 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
|
62 | 86 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
|
63 | 87 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
|
| 88 | + { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) }, |
64 | 89 | { }
|
65 | 90 | };
|
66 | 91 | MODULE_DEVICE_TABLE(hid, ch_devices);
|
67 | 92 |
|
68 | 93 | static struct hid_driver ch_driver = {
|
69 | 94 | .name = "chicony",
|
70 | 95 | .id_table = ch_devices,
|
| 96 | + .report_fixup = ch_switch12_report_fixup, |
71 | 97 | .input_mapping = ch_input_mapping,
|
72 | 98 | };
|
73 | 99 | module_hid_driver(ch_driver);
|
|
0 commit comments