1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * HID driver for Keytouch devices not fully compliant with HID standard
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (c) 2011 Jiri Kosina
6*4882a593Smuzhiyun */
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun /*
9*4882a593Smuzhiyun */
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun #include <linux/device.h>
12*4882a593Smuzhiyun #include <linux/hid.h>
13*4882a593Smuzhiyun #include <linux/module.h>
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun #include "hid-ids.h"
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun /* Replace the broken report descriptor of this device with rather
18*4882a593Smuzhiyun * a default one */
19*4882a593Smuzhiyun static __u8 keytouch_fixed_rdesc[] = {
20*4882a593Smuzhiyun 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 0x29, 0xe7, 0x15,
21*4882a593Smuzhiyun 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x95, 0x01, 0x75, 0x08,
22*4882a593Smuzhiyun 0x81, 0x01, 0x95, 0x03, 0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91,
23*4882a593Smuzhiyun 0x02, 0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08, 0x15, 0x00,
24*4882a593Smuzhiyun 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a, 0xff, 0x00, 0x81, 0x00, 0xc0
25*4882a593Smuzhiyun };
26*4882a593Smuzhiyun
keytouch_report_fixup(struct hid_device * hdev,__u8 * rdesc,unsigned int * rsize)27*4882a593Smuzhiyun static __u8 *keytouch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
28*4882a593Smuzhiyun unsigned int *rsize)
29*4882a593Smuzhiyun {
30*4882a593Smuzhiyun hid_info(hdev, "fixing up Keytouch IEC report descriptor\n");
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun rdesc = keytouch_fixed_rdesc;
33*4882a593Smuzhiyun *rsize = sizeof(keytouch_fixed_rdesc);
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun return rdesc;
36*4882a593Smuzhiyun }
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun static const struct hid_device_id keytouch_devices[] = {
39*4882a593Smuzhiyun { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) },
40*4882a593Smuzhiyun { }
41*4882a593Smuzhiyun };
42*4882a593Smuzhiyun MODULE_DEVICE_TABLE(hid, keytouch_devices);
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun static struct hid_driver keytouch_driver = {
45*4882a593Smuzhiyun .name = "keytouch",
46*4882a593Smuzhiyun .id_table = keytouch_devices,
47*4882a593Smuzhiyun .report_fixup = keytouch_report_fixup,
48*4882a593Smuzhiyun };
49*4882a593Smuzhiyun module_hid_driver(keytouch_driver);
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun MODULE_LICENSE("GPL");
52*4882a593Smuzhiyun MODULE_AUTHOR("Jiri Kosina");
53