xref: /linux/drivers/hid/hid-ortek.c (revision 9d262f35b1155d6f56b6fd1dc054ec218e42696b)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2cd9ec30dSJohnathon Harris /*
3d586dca0SJiri Kosina  *  HID driver for various devices which are apparently based on the same chipset
4d586dca0SJiri Kosina  *  from certain vendor which produces chips that contain wrong LogicalMaximum
5d586dca0SJiri Kosina  *  value in their HID report descriptor. Currently supported devices are:
6d586dca0SJiri Kosina  *
7d586dca0SJiri Kosina  *    Ortek PKB-1700
8d586dca0SJiri Kosina  *    Ortek WKB-2000
9c228352dSBenjamin Tissoires  *    iHome IMAC-A210S
10d586dca0SJiri Kosina  *    Skycable wireless presenter
11cd9ec30dSJohnathon Harris  *
12cd9ec30dSJohnathon Harris  *  Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com>
13d586dca0SJiri Kosina  *  Copyright (c) 2011 Jiri Kosina
14cd9ec30dSJohnathon Harris  */
15cd9ec30dSJohnathon Harris 
16cd9ec30dSJohnathon Harris /*
17cd9ec30dSJohnathon Harris  */
18cd9ec30dSJohnathon Harris 
19cd9ec30dSJohnathon Harris #include <linux/device.h>
20cd9ec30dSJohnathon Harris #include <linux/hid.h>
21cd9ec30dSJohnathon Harris #include <linux/module.h>
22cd9ec30dSJohnathon Harris 
23cd9ec30dSJohnathon Harris #include "hid-ids.h"
24cd9ec30dSJohnathon Harris 
2573e4008dSNikolai Kondrashov static __u8 *ortek_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2673e4008dSNikolai Kondrashov 		unsigned int *rsize)
27cd9ec30dSJohnathon Harris {
2873e4008dSNikolai Kondrashov 	if (*rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x01) {
29c228352dSBenjamin Tissoires 		hid_info(hdev, "Fixing up logical maximum in report descriptor (Ortek)\n");
30cd9ec30dSJohnathon Harris 		rdesc[55] = 0x92;
31d586dca0SJiri Kosina 	} else if (*rsize >= 54 && rdesc[52] == 0x25 && rdesc[53] == 0x01) {
32c228352dSBenjamin Tissoires 		hid_info(hdev, "Fixing up logical maximum in report descriptor (Skycable)\n");
33d586dca0SJiri Kosina 		rdesc[53] = 0x65;
34cd9ec30dSJohnathon Harris 	}
3573e4008dSNikolai Kondrashov 	return rdesc;
36cd9ec30dSJohnathon Harris }
37cd9ec30dSJohnathon Harris 
38cd9ec30dSJohnathon Harris static const struct hid_device_id ortek_devices[] = {
39270fdc07SHerton Ronaldo Krzesinski 	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) },
40cd9ec30dSJohnathon Harris 	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
41c228352dSBenjamin Tissoires 	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_IHOME_IMAC_A210S) },
42d586dca0SJiri Kosina 	{ HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
43cd9ec30dSJohnathon Harris 	{ }
44cd9ec30dSJohnathon Harris };
45cd9ec30dSJohnathon Harris MODULE_DEVICE_TABLE(hid, ortek_devices);
46cd9ec30dSJohnathon Harris 
47cd9ec30dSJohnathon Harris static struct hid_driver ortek_driver = {
48cd9ec30dSJohnathon Harris 	.name = "ortek",
49cd9ec30dSJohnathon Harris 	.id_table = ortek_devices,
50cd9ec30dSJohnathon Harris 	.report_fixup = ortek_report_fixup
51cd9ec30dSJohnathon Harris };
52f425458eSH Hartley Sweeten module_hid_driver(ortek_driver);
53cd9ec30dSJohnathon Harris 
54*9d262f35SJeff Johnson MODULE_DESCRIPTION("HID driver for Ortek PKB-1700/WKB-2000/Skycable wireless keyboard and mouse trackpad");
55cd9ec30dSJohnathon Harris MODULE_LICENSE("GPL");
56