aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2017-04-26 12:37:04 -0400
committerJiri Kosina <jkosina@suse.cz>2017-05-11 04:49:14 -0400
commit0bb7a37f8d15e5fb5d21776875f9fbc74e10753a (patch)
tree68f9e3d71650c0f4c48d039c83e3baa4e278deed
parentf4b65b9563216b3e01a5cc844c3ba68901d9b195 (diff)
HID: elecom: extend to fix the descriptor for DEFT trackballs
The ELECOM DEFT trackballs report only five buttons, when the device actually has 8. Change the descriptor so that the HID driver can see all of them. For completeness and future reference, I included a side-by-side diff of the part of the descriptor that is being edited. Cc: Jiri Kosina <jikos@kernel.org> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com> Cc: Yuxuan Shui <yshuiv7@gmail.com> Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/Kconfig6
-rw-r--r--drivers/hid/hid-core.c2
-rw-r--r--drivers/hid/hid-elecom.c62
-rw-r--r--drivers/hid/hid-ids.h2
4 files changed, 61 insertions, 11 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index fe40e5e499dd..687705c50794 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -275,10 +275,12 @@ config HID_EMS_FF
275 - Trio Linker Plus II 275 - Trio Linker Plus II
276 276
277config HID_ELECOM 277config HID_ELECOM
278 tristate "ELECOM BM084 bluetooth mouse" 278 tristate "ELECOM HID devices"
279 depends on HID 279 depends on HID
280 ---help--- 280 ---help---
281 Support for the ELECOM BM084 (bluetooth mouse). 281 Support for ELECOM devices:
282 - BM084 Bluetooth Mouse
283 - DEFT Trackball (Wired and wireless)
282 284
283config HID_ELO 285config HID_ELO
284 tristate "ELO USB 4000/4500 touchscreen" 286 tristate "ELO USB 4000/4500 touchscreen"
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 37084b645785..38d041510e1d 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1891,6 +1891,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
1891 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_WN) }, 1891 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_WN) },
1892 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_FA) }, 1892 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_FA) },
1893 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 1893 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
1894 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) },
1895 { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) },
1894 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) }, 1896 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) },
1895 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0030) }, 1897 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0030) },
1896 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) }, 1898 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },
diff --git a/drivers/hid/hid-elecom.c b/drivers/hid/hid-elecom.c
index 6e3848a8d8dd..e2c7465df69f 100644
--- a/drivers/hid/hid-elecom.c
+++ b/drivers/hid/hid-elecom.c
@@ -1,10 +1,8 @@
1/* 1/*
2 * HID driver for Elecom BM084 (bluetooth mouse). 2 * HID driver for ELECOM devices.
3 * Removes a non-existing horizontal wheel from
4 * the HID descriptor.
5 * (This module is based on "hid-ortek".)
6 *
7 * Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com> 3 * Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com>
4 * Copyright (c) 2016 Yuxuan Shui <yshuiv7@gmail.com>
5 * Copyright (c) 2017 Diego Elio Pettenò <flameeyes@flameeyes.eu>
8 */ 6 */
9 7
10/* 8/*
@@ -23,15 +21,61 @@
23static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc, 21static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
24 unsigned int *rsize) 22 unsigned int *rsize)
25{ 23{
26 if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) { 24 switch (hdev->product) {
27 hid_info(hdev, "Fixing up Elecom BM084 report descriptor\n"); 25 case USB_DEVICE_ID_ELECOM_BM084:
28 rdesc[47] = 0x00; 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;
29 } 71 }
30 return rdesc; 72 return rdesc;
31} 73}
32 74
33static const struct hid_device_id elecom_devices[] = { 75static const struct hid_device_id elecom_devices[] = {
34 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084)}, 76 { 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) },
35 { } 79 { }
36}; 80};
37MODULE_DEVICE_TABLE(hid, elecom_devices); 81MODULE_DEVICE_TABLE(hid, elecom_devices);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 643390ba749d..8e8a1baee090 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -358,6 +358,8 @@
358 358
359#define USB_VENDOR_ID_ELECOM 0x056e 359#define USB_VENDOR_ID_ELECOM 0x056e
360#define USB_DEVICE_ID_ELECOM_BM084 0x0061 360#define USB_DEVICE_ID_ELECOM_BM084 0x0061
361#define USB_DEVICE_ID_ELECOM_DEFT_WIRED 0x00fe
362#define USB_DEVICE_ID_ELECOM_DEFT_WIRELESS 0x00ff
361 363
362#define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34 364#define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34
363#define USB_DEVICE_ID_DREAM_CHEEKY_WN 0x0004 365#define USB_DEVICE_ID_DREAM_CHEEKY_WN 0x0004