Commit 1f243e302cea1561ac881eb5d27041c5342beba4

Authored by Jiri Slaby
Committed by Jiri Kosina
1 parent 3b239cd739

HID: move ezkey quirks

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Showing 8 changed files with 107 additions and 40 deletions Side-by-side Diff

... ... @@ -117,6 +117,13 @@
117 117 ---help---
118 118 Support for Cypress mouse and barcodes.
119 119  
  120 +config HID_EZKEY
  121 + tristate "Ezkey"
  122 + default m
  123 + depends on USB_HID
  124 + ---help---
  125 + Support for Ezkey mouse and barcodes.
  126 +
120 127 config HID_LOGITECH
121 128 tristate "Logitech"
122 129 default m
drivers/hid/Makefile
... ... @@ -16,6 +16,7 @@
16 16 obj-$(CONFIG_HID_APPLE) += hid-apple.o
17 17 obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
18 18 obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
  19 +obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
19 20 obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
20 21 obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
21 22 obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
drivers/hid/hid-core.c
... ... @@ -1168,6 +1168,7 @@
1168 1168 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
1169 1169 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
1170 1170 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
  1171 + { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
1171 1172 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
1172 1173 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
1173 1174 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
drivers/hid/hid-dummy.c
... ... @@ -16,6 +16,9 @@
16 16 #ifdef CONFIG_HID_CYPRESS_MODULE
17 17 HID_COMPAT_CALL_DRIVER(cypress);
18 18 #endif
  19 +#ifdef CONFIG_HID_EZKEY_MODULE
  20 + HID_COMPAT_CALL_DRIVER(ezkey);
  21 +#endif
19 22 #ifdef CONFIG_HID_LOGITECH_MODULE
20 23 HID_COMPAT_CALL_DRIVER(logitech);
21 24 #endif
drivers/hid/hid-ezkey.c
  1 +/*
  2 + * HID driver for some ezkey "special" devices
  3 + *
  4 + * Copyright (c) 1999 Andreas Gal
  5 + * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
  6 + * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
  7 + * Copyright (c) 2006-2007 Jiri Kosina
  8 + * Copyright (c) 2007 Paul Walmsley
  9 + * Copyright (c) 2008 Jiri Slaby
  10 + */
  11 +
  12 +/*
  13 + * This program is free software; you can redistribute it and/or modify it
  14 + * under the terms of the GNU General Public License as published by the Free
  15 + * Software Foundation; either version 2 of the License, or (at your option)
  16 + * any later version.
  17 + */
  18 +
  19 +#include <linux/device.h>
  20 +#include <linux/input.h>
  21 +#include <linux/hid.h>
  22 +#include <linux/module.h>
  23 +
  24 +#include "hid-ids.h"
  25 +
  26 +#define ez_map_rel(c) hid_map_usage(hi, usage, bit, max, EV_REL, (c))
  27 +#define ez_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c))
  28 +
  29 +static int ez_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  30 + struct hid_field *field, struct hid_usage *usage,
  31 + unsigned long **bit, int *max)
  32 +{
  33 + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
  34 + return 0;
  35 +
  36 + switch (usage->hid & HID_USAGE) {
  37 + case 0x230: ez_map_key(BTN_MOUSE); break;
  38 + case 0x231: ez_map_rel(REL_WHEEL); break;
  39 + /*
  40 + * this keyboard has a scrollwheel implemented in
  41 + * totally broken way. We map this usage temporarily
  42 + * to HWHEEL and handle it in the event quirk handler
  43 + */
  44 + case 0x232: ez_map_rel(REL_HWHEEL); break;
  45 + default:
  46 + return 0;
  47 + }
  48 + return 1;
  49 +}
  50 +
  51 +static int ez_event(struct hid_device *hdev, struct hid_field *field,
  52 + struct hid_usage *usage, __s32 value)
  53 +{
  54 + if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
  55 + !usage->type)
  56 + return 0;
  57 +
  58 + /* handle the temporary quirky mapping to HWHEEL */
  59 + if (usage->type == EV_REL && usage->code == REL_HWHEEL) {
  60 + struct input_dev *input = field->hidinput->input;
  61 + input_event(input, usage->type, REL_WHEEL, -value);
  62 + return 1;
  63 + }
  64 +
  65 + return 0;
  66 +}
  67 +
  68 +static const struct hid_device_id ez_devices[] = {
  69 + { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
  70 + { }
  71 +};
  72 +MODULE_DEVICE_TABLE(hid, ez_devices);
  73 +
  74 +static struct hid_driver ez_driver = {
  75 + .name = "ezkey",
  76 + .id_table = ez_devices,
  77 + .input_mapping = ez_input_mapping,
  78 + .event = ez_event,
  79 +};
  80 +
  81 +static int ez_init(void)
  82 +{
  83 + return hid_register_driver(&ez_driver);
  84 +}
  85 +
  86 +static void ez_exit(void)
  87 +{
  88 + hid_unregister_driver(&ez_driver);
  89 +}
  90 +
  91 +module_init(ez_init);
  92 +module_exit(ez_exit);
  93 +MODULE_LICENSE("GPL");
  94 +
  95 +HID_COMPAT_LOAD_DRIVER(ezkey);
drivers/hid/hid-input-quirks.c
... ... @@ -16,9 +16,6 @@
16 16 #include <linux/input.h>
17 17 #include <linux/hid.h>
18 18  
19   -#define map_rel(c) hid_map_usage(hidinput, usage, bit, max, EV_REL, (c))
20   -#define map_key(c) hid_map_usage(hidinput, usage, bit, max, EV_KEY, (c))
21   -
22 19 #define map_key_clear(c) hid_map_usage_clear(hidinput, usage, bit, \
23 20 max, EV_KEY, (c))
24 21  
25 22  
... ... @@ -132,37 +129,12 @@
132 129 return 1;
133 130 }
134 131  
135   -static int quirk_btc_8193(struct hid_usage *usage, struct hid_input *hidinput,
136   - unsigned long **bit, int *max)
137   -{
138   - if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
139   - return 0;
140   -
141   - switch (usage->hid & HID_USAGE) {
142   - case 0x230: map_key(BTN_MOUSE); break;
143   - case 0x231: map_rel(REL_WHEEL); break;
144   - /*
145   - * this keyboard has a scrollwheel implemented in
146   - * totally broken way. We map this usage temporarily
147   - * to HWHEEL and handle it in the event quirk handler
148   - */
149   - case 0x232: map_rel(REL_HWHEEL); break;
150   -
151   - default:
152   - return 0;
153   - }
154   - return 1;
155   -}
156   -
157 132 #define VENDOR_ID_BELKIN 0x1020
158 133 #define DEVICE_ID_BELKIN_WIRELESS_KEYBOARD 0x0006
159 134  
160 135 #define VENDOR_ID_CHICONY 0x04f2
161 136 #define DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418
162 137  
163   -#define VENDOR_ID_EZKEY 0x0518
164   -#define DEVICE_ID_BTC_8193 0x0002
165   -
166 138 #define VENDOR_ID_GYRATION 0x0c16
167 139 #define DEVICE_ID_GYRATION_REMOTE 0x0002
168 140  
... ... @@ -182,8 +154,6 @@
182 154  
183 155 { VENDOR_ID_CHICONY, DEVICE_ID_CHICONY_TACTICAL_PAD, quirk_chicony_tactical_pad },
184 156  
185   - { VENDOR_ID_EZKEY, DEVICE_ID_BTC_8193, quirk_btc_8193 },
186   -
187 157 { VENDOR_ID_GYRATION, DEVICE_ID_GYRATION_REMOTE, quirk_gyration_remote },
188 158  
189 159 { VENDOR_ID_MONTEREY, DEVICE_ID_GENIUS_KB29E, quirk_cherry_genius_29e },
... ... @@ -214,13 +184,6 @@
214 184 struct input_dev *input;
215 185  
216 186 input = field->hidinput->input;
217   -
218   - /* handle the temporary quirky mapping to HWHEEL */
219   - if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT &&
220   - usage->type == EV_REL && usage->code == REL_HWHEEL) {
221   - input_event(input, usage->type, REL_WHEEL, -value);
222   - return 1;
223   - }
224 187  
225 188 /* Gyration MCE remote "Sleep" key */
226 189 if (hid->vendor == VENDOR_ID_GYRATION &&
drivers/hid/usbhid/hid-quirks.c
... ... @@ -46,8 +46,6 @@
46 46 { USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM, HID_QUIRK_HIDDEV },
47 47 { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_HIDDEV | HID_QUIRK_IGNORE_HIDINPUT },
48 48  
49   - { USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193, HID_QUIRK_HWHEEL_WHEEL_INVERT },
50   -
51 49 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
52 50 { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
53 51  
... ... @@ -266,7 +266,6 @@
266 266 #define HID_QUIRK_RESET_LEDS 0x00100000
267 267 #define HID_QUIRK_HIDINPUT 0x00200000
268 268 #define HID_QUIRK_IGNORE_HIDINPUT 0x01000000
269   -#define HID_QUIRK_HWHEEL_WHEEL_INVERT 0x04000000
270 269 #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000
271 270  
272 271 /*