Skip to content

Commit 9a1d78a

Browse files
nkudriavtsevJiri Kosina
authored andcommitted
HID: chicony: Add support for Acer Aspire Switch 12
Acer Aspire Switch 12 keyboard Chicony's controller reports too big usage index on the 1st interface. The patch fixes the report. The work based on solution from drivers/hid/hid-holtek-mouse.c Bug report: https://bugzilla.kernel.org/show_bug.cgi?id=101721 Signed-off-by: Nicholas Kudriavtsev <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 874bf9e commit 9a1d78a

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

drivers/hid/hid-chicony.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/input.h>
2121
#include <linux/hid.h>
2222
#include <linux/module.h>
23+
#include <linux/usb.h>
2324

2425
#include "hid-ids.h"
2526

@@ -57,17 +58,42 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
5758
return 1;
5859
}
5960

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+
6084
static const struct hid_device_id ch_devices[] = {
6185
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
6286
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
6387
{ 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) },
6489
{ }
6590
};
6691
MODULE_DEVICE_TABLE(hid, ch_devices);
6792

6893
static struct hid_driver ch_driver = {
6994
.name = "chicony",
7095
.id_table = ch_devices,
96+
.report_fixup = ch_switch12_report_fixup,
7197
.input_mapping = ch_input_mapping,
7298
};
7399
module_hid_driver(ch_driver);

drivers/hid/hid-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
18041804
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) },
18051805
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
18061806
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
1807+
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
18071808
{ HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
18081809
{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) },
18091810
{ HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
#define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE 0x1053
231231
#define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123
232232
#define USB_DEVICE_ID_CHICONY_AK1D 0x1125
233+
#define USB_DEVICE_ID_CHICONY_ACER_SWITCH12 0x1421
233234

234235
#define USB_VENDOR_ID_CHUNGHWAT 0x2247
235236
#define USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH 0x0001

0 commit comments

Comments
 (0)