xref: /openbmc/linux/drivers/hid/hid-semitek.c (revision d47a97bd)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  HID driver for Semitek keyboards
4  *
5  *  Copyright (c) 2021 Benjamin Moody
6  */
7 
8 #include <linux/device.h>
9 #include <linux/hid.h>
10 #include <linux/module.h>
11 
12 #include "hid-ids.h"
13 
14 static __u8 *semitek_report_fixup(struct hid_device *hdev, __u8 *rdesc,
15                                   unsigned int *rsize)
16 {
17 	/* In the report descriptor for interface 2, fix the incorrect
18 	   description of report ID 0x04 (the report contains a
19 	   bitmask, not an array of keycodes.) */
20 	if (*rsize == 0xcb && rdesc[0x83] == 0x81 && rdesc[0x84] == 0x00) {
21 		hid_info(hdev, "fixing up Semitek report descriptor\n");
22 		rdesc[0x84] = 0x02;
23 	}
24 	return rdesc;
25 }
26 
27 static const struct hid_device_id semitek_devices[] = {
28 	{ HID_USB_DEVICE(USB_VENDOR_ID_SEMITEK, USB_DEVICE_ID_SEMITEK_KEYBOARD) },
29 	{ }
30 };
31 MODULE_DEVICE_TABLE(hid, semitek_devices);
32 
33 static struct hid_driver semitek_driver = {
34 	.name = "semitek",
35 	.id_table = semitek_devices,
36 	.report_fixup = semitek_report_fixup,
37 };
38 module_hid_driver(semitek_driver);
39 
40 MODULE_LICENSE("GPL");
41