blob: e2c7465df69f3ae74c2cb1979c531b02e2934089 [file] [log] [blame]
Richard Nauber64b386e2010-06-28 18:54:25 +02001/*
Diego Elio Pettenò0bb7a372017-04-26 17:37:04 +01002 * HID driver for ELECOM devices.
Richard Nauber64b386e2010-06-28 18:54:25 +02003 * Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com>
Diego Elio Pettenò0bb7a372017-04-26 17:37:04 +01004 * Copyright (c) 2016 Yuxuan Shui <yshuiv7@gmail.com>
5 * Copyright (c) 2017 Diego Elio Pettenò <flameeyes@flameeyes.eu>
Richard Nauber64b386e2010-06-28 18:54:25 +02006 */
7
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.
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18
19#include "hid-ids.h"
20
Nikolai Kondrashov73e40082010-08-06 23:03:06 +040021static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
22 unsigned int *rsize)
Richard Nauber64b386e2010-06-28 18:54:25 +020023{
Diego Elio Pettenò0bb7a372017-04-26 17:37:04 +010024 switch (hdev->product) {
25 case USB_DEVICE_ID_ELECOM_BM084:
26 /* The BM084 Bluetooth mouse includes a non-existing horizontal
27 * wheel in the HID descriptor. */
28 if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) {
29 hid_info(hdev, "Fixing up Elecom BM084 report descriptor\n");
30 rdesc[47] = 0x00;
31 }
32 break;
33 case USB_DEVICE_ID_ELECOM_DEFT_WIRED:
34 case USB_DEVICE_ID_ELECOM_DEFT_WIRELESS:
35 /* The DEFT trackball has eight buttons, but its descriptor only
36 * reports five, disabling the three Fn buttons on the top of
37 * the mouse.
38 *
39 * Apply the following diff to the descriptor:
40 *
41 * Collection (Physical), Collection (Physical),
42 * Report ID (1), Report ID (1),
43 * Report Count (5), -> Report Count (8),
44 * Report Size (1), Report Size (1),
45 * Usage Page (Button), Usage Page (Button),
46 * Usage Minimum (01h), Usage Minimum (01h),
47 * Usage Maximum (05h), -> Usage Maximum (08h),
48 * Logical Minimum (0), Logical Minimum (0),
49 * Logical Maximum (1), Logical Maximum (1),
50 * Input (Variable), Input (Variable),
51 * Report Count (1), -> Report Count (0),
52 * Report Size (3), Report Size (3),
53 * Input (Constant), Input (Constant),
54 * Report Size (16), Report Size (16),
55 * Report Count (2), Report Count (2),
56 * Usage Page (Desktop), Usage Page (Desktop),
57 * Usage (X), Usage (X),
58 * Usage (Y), Usage (Y),
59 * Logical Minimum (-32768), Logical Minimum (-32768),
60 * Logical Maximum (32767), Logical Maximum (32767),
61 * Input (Variable, Relative), Input (Variable, Relative),
62 * End Collection, End Collection,
63 */
64 if (*rsize == 213 && rdesc[13] == 5 && rdesc[21] == 5) {
65 hid_info(hdev, "Fixing up Elecom DEFT Fn buttons\n");
66 rdesc[13] = 8; /* Button/Variable Report Count */
67 rdesc[21] = 8; /* Button/Variable Usage Maximum */
68 rdesc[29] = 0; /* Button/Constant Report Count */
69 }
70 break;
Richard Nauber64b386e2010-06-28 18:54:25 +020071 }
Jiri Slaby636a89d2015-10-11 16:18:22 +020072 return rdesc;
Richard Nauber64b386e2010-06-28 18:54:25 +020073}
74
75static const struct hid_device_id elecom_devices[] = {
Diego Elio Pettenò0bb7a372017-04-26 17:37:04 +010076 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
77 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) },
78 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) },
Richard Nauber64b386e2010-06-28 18:54:25 +020079 { }
80};
81MODULE_DEVICE_TABLE(hid, elecom_devices);
82
83static struct hid_driver elecom_driver = {
84 .name = "elecom",
85 .id_table = elecom_devices,
86 .report_fixup = elecom_report_fixup
87};
H Hartley Sweetenf4254582012-12-17 15:28:26 -070088module_hid_driver(elecom_driver);
Richard Nauber64b386e2010-06-28 18:54:25 +020089
Richard Nauber64b386e2010-06-28 18:54:25 +020090MODULE_LICENSE("GPL");