ARM: dts: sirf: add missed chhifbg node in prima2 and atlas6 dts
[linux-2.6.git] / drivers / hid / hid-holtek-mouse.c
blob7e6db3cf46f9eb39746fcc4ac4b4e29296caa569
1 /*
2 * HID driver for Holtek gaming mice
3 * Copyright (c) 2013 Christian Ohm
4 * Heavily inspired by various other HID drivers that adjust the report
5 * descriptor.
6 */
8 /*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
15 #include <linux/hid.h>
16 #include <linux/module.h>
17 #include <linux/usb.h>
19 #include "hid-ids.h"
22 * The report descriptor of some Holtek based gaming mice specifies an
23 * excessively large number of consumer usages (2^15), which is more than
24 * HID_MAX_USAGES. This prevents proper parsing of the report descriptor.
26 * This driver fixes the report descriptor for:
27 * - USB ID 04d9:a067, sold as Sharkoon Drakonia and Perixx MX-2000
28 * - USB ID 04d9:a04a, sold as Tracer Sniper TRM-503, NOVA Gaming Slider X200
29 * and Zalman ZM-GM1
32 static __u8 *holtek_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
33 unsigned int *rsize)
35 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
37 if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
38 /* Change usage maximum and logical maximum from 0x7fff to
39 * 0x2fff, so they don't exceed HID_MAX_USAGES */
40 switch (hdev->product) {
41 case USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067:
42 if (*rsize >= 122 && rdesc[115] == 0xff && rdesc[116] == 0x7f
43 && rdesc[120] == 0xff && rdesc[121] == 0x7f) {
44 hid_info(hdev, "Fixing up report descriptor\n");
45 rdesc[116] = rdesc[121] = 0x2f;
47 break;
48 case USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A:
49 if (*rsize >= 113 && rdesc[106] == 0xff && rdesc[107] == 0x7f
50 && rdesc[111] == 0xff && rdesc[112] == 0x7f) {
51 hid_info(hdev, "Fixing up report descriptor\n");
52 rdesc[107] = rdesc[112] = 0x2f;
54 break;
58 return rdesc;
61 static const struct hid_device_id holtek_mouse_devices[] = {
62 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT,
63 USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067) },
64 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT,
65 USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A) },
66 { }
68 MODULE_DEVICE_TABLE(hid, holtek_mouse_devices);
70 static struct hid_driver holtek_mouse_driver = {
71 .name = "holtek_mouse",
72 .id_table = holtek_mouse_devices,
73 .report_fixup = holtek_mouse_report_fixup,
76 module_hid_driver(holtek_mouse_driver);
77 MODULE_LICENSE("GPL");