Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB HID support for Linux |
| 3 | * |
| 4 | * Copyright (c) 1999 Andreas Gal |
Michael Haboustak | bf0964d | 2005-09-05 00:12:01 -0500 | [diff] [blame] | 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
| 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc |
Jiri Kosina | b55fd23 | 2007-02-21 19:27:49 +0100 | [diff] [blame] | 7 | * Copyright (c) 2006-2007 Jiri Kosina |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * This program is free software; you can redistribute it and/or modify it |
| 12 | * under the terms of the GNU General Public License as published by the Free |
| 13 | * Software Foundation; either version 2 of the License, or (at your option) |
| 14 | * any later version. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/list.h> |
| 22 | #include <linux/mm.h> |
| 23 | #include <linux/smp_lock.h> |
| 24 | #include <linux/spinlock.h> |
| 25 | #include <asm/unaligned.h> |
| 26 | #include <asm/byteorder.h> |
| 27 | #include <linux/input.h> |
| 28 | #include <linux/wait.h> |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/usb.h> |
| 31 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 32 | #include <linux/hid.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <linux/hiddev.h> |
Jiri Kosina | c080d89 | 2007-01-25 11:43:31 +0100 | [diff] [blame] | 34 | #include <linux/hid-debug.h> |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 35 | #include "usbhid.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * Version Information |
| 39 | */ |
| 40 | |
Michael Haboustak | bf0964d | 2005-09-05 00:12:01 -0500 | [diff] [blame] | 41 | #define DRIVER_VERSION "v2.6" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik" |
| 43 | #define DRIVER_DESC "USB HID core driver" |
| 44 | #define DRIVER_LICENSE "GPL" |
| 45 | |
| 46 | static char *hid_types[] = {"Device", "Pointer", "Mouse", "Device", "Joystick", |
| 47 | "Gamepad", "Keyboard", "Keypad", "Multi-Axis Controller"}; |
| 48 | /* |
| 49 | * Module parameters. |
| 50 | */ |
| 51 | |
| 52 | static unsigned int hid_mousepoll_interval; |
| 53 | module_param_named(mousepoll, hid_mousepoll_interval, uint, 0644); |
| 54 | MODULE_PARM_DESC(mousepoll, "Polling interval of mice"); |
| 55 | |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 56 | #define USB_VENDOR_ID_A4TECH 0x09da |
| 57 | #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 |
| 58 | |
| 59 | #define USB_VENDOR_ID_AASHIMA 0x06d6 |
| 60 | #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 |
| 61 | #define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026 |
| 62 | |
| 63 | #define USB_VENDOR_ID_ACECAD 0x0460 |
| 64 | #define USB_DEVICE_ID_ACECAD_FLAIR 0x0004 |
| 65 | #define USB_DEVICE_ID_ACECAD_302 0x0008 |
| 66 | |
| 67 | #define USB_VENDOR_ID_AIPTEK 0x08ca |
| 68 | #define USB_DEVICE_ID_AIPTEK_01 0x0001 |
| 69 | #define USB_DEVICE_ID_AIPTEK_10 0x0010 |
| 70 | #define USB_DEVICE_ID_AIPTEK_20 0x0020 |
| 71 | #define USB_DEVICE_ID_AIPTEK_21 0x0021 |
| 72 | #define USB_DEVICE_ID_AIPTEK_22 0x0022 |
| 73 | #define USB_DEVICE_ID_AIPTEK_23 0x0023 |
| 74 | #define USB_DEVICE_ID_AIPTEK_24 0x0024 |
| 75 | |
| 76 | #define USB_VENDOR_ID_AIRCABLE 0x16CA |
| 77 | #define USB_DEVICE_ID_AIRCABLE1 0x1502 |
| 78 | |
| 79 | #define USB_VENDOR_ID_ALCOR 0x058f |
| 80 | #define USB_DEVICE_ID_ALCOR_USBRS232 0x9720 |
| 81 | |
| 82 | #define USB_VENDOR_ID_ALPS 0x0433 |
| 83 | #define USB_DEVICE_ID_IBM_GAMEPAD 0x1101 |
| 84 | |
| 85 | #define USB_VENDOR_ID_APPLE 0x05ac |
| 86 | #define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 |
| 87 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e |
| 88 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f |
| 89 | #define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214 |
| 90 | #define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215 |
| 91 | #define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216 |
| 92 | #define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217 |
| 93 | #define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218 |
| 94 | #define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219 |
| 95 | #define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a |
| 96 | #define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b |
| 97 | #define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c |
| 98 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a |
| 99 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b |
| 100 | #define USB_DEVICE_ID_APPLE_IR 0x8240 |
| 101 | |
| 102 | #define USB_VENDOR_ID_ATEN 0x0557 |
| 103 | #define USB_DEVICE_ID_ATEN_UC100KM 0x2004 |
| 104 | #define USB_DEVICE_ID_ATEN_CS124U 0x2202 |
| 105 | #define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204 |
| 106 | #define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205 |
| 107 | #define USB_DEVICE_ID_ATEN_4PORTKVMC 0x2208 |
| 108 | |
Daniel P. Engel | 66df514 | 2007-04-03 23:43:46 +0200 | [diff] [blame] | 109 | #define USB_VENDOR_ID_BELKIN 0x050d |
| 110 | #define USB_DEVICE_ID_FLIP_KVM 0x3201 |
| 111 | |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 112 | #define USB_VENDOR_ID_BERKSHIRE 0x0c98 |
| 113 | #define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 |
| 114 | |
| 115 | #define USB_VENDOR_ID_CHERRY 0x046a |
| 116 | #define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 |
| 117 | |
| 118 | #define USB_VENDOR_ID_CHIC 0x05fe |
| 119 | #define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014 |
| 120 | |
| 121 | #define USB_VENDOR_ID_CIDC 0x1677 |
| 122 | |
| 123 | #define USB_VENDOR_ID_CODEMERCS 0x07c0 |
| 124 | #define USB_DEVICE_ID_CODEMERCS_IOW_FIRST 0x1500 |
| 125 | #define USB_DEVICE_ID_CODEMERCS_IOW_LAST 0x15ff |
| 126 | |
| 127 | #define USB_VENDOR_ID_CYPRESS 0x04b4 |
| 128 | #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 |
| 129 | #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 |
| 130 | #define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 |
| 131 | |
Pete Zaitcev | 713c8aa | 2007-04-06 14:33:18 +0200 | [diff] [blame^] | 132 | #define USB_VENDOR_ID_DELL 0x413c |
| 133 | #define USB_DEVICE_ID_DELL_W7658 0x2005 |
| 134 | |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 135 | #define USB_VENDOR_ID_DELORME 0x1163 |
| 136 | #define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 |
| 137 | #define USB_DEVICE_ID_DELORME_EM_LT20 0x0200 |
| 138 | |
| 139 | #define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f |
| 140 | #define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 |
| 141 | |
| 142 | #define USB_VENDOR_ID_GLAB 0x06c2 |
| 143 | #define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 |
| 144 | #define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 |
| 145 | #define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040 |
| 146 | #define USB_DEVICE_ID_0_16_16_IF_KIT 0x0044 |
| 147 | #define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045 |
| 148 | #define USB_DEVICE_ID_0_8_7_IF_KIT 0x0051 |
| 149 | #define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053 |
| 150 | #define USB_DEVICE_ID_PHIDGET_MOTORCONTROL 0x0058 |
| 151 | |
| 152 | #define USB_VENDOR_ID_GRIFFIN 0x077d |
| 153 | #define USB_DEVICE_ID_POWERMATE 0x0410 |
| 154 | #define USB_DEVICE_ID_SOUNDKNOB 0x04AA |
| 155 | |
| 156 | #define USB_VENDOR_ID_GTCO 0x078c |
| 157 | #define USB_DEVICE_ID_GTCO_90 0x0090 |
| 158 | #define USB_DEVICE_ID_GTCO_100 0x0100 |
| 159 | #define USB_DEVICE_ID_GTCO_101 0x0101 |
| 160 | #define USB_DEVICE_ID_GTCO_103 0x0103 |
| 161 | #define USB_DEVICE_ID_GTCO_104 0x0104 |
| 162 | #define USB_DEVICE_ID_GTCO_105 0x0105 |
| 163 | #define USB_DEVICE_ID_GTCO_106 0x0106 |
| 164 | #define USB_DEVICE_ID_GTCO_107 0x0107 |
| 165 | #define USB_DEVICE_ID_GTCO_108 0x0108 |
| 166 | #define USB_DEVICE_ID_GTCO_200 0x0200 |
| 167 | #define USB_DEVICE_ID_GTCO_201 0x0201 |
| 168 | #define USB_DEVICE_ID_GTCO_202 0x0202 |
| 169 | #define USB_DEVICE_ID_GTCO_203 0x0203 |
| 170 | #define USB_DEVICE_ID_GTCO_204 0x0204 |
| 171 | #define USB_DEVICE_ID_GTCO_205 0x0205 |
| 172 | #define USB_DEVICE_ID_GTCO_206 0x0206 |
| 173 | #define USB_DEVICE_ID_GTCO_207 0x0207 |
| 174 | #define USB_DEVICE_ID_GTCO_300 0x0300 |
| 175 | #define USB_DEVICE_ID_GTCO_301 0x0301 |
| 176 | #define USB_DEVICE_ID_GTCO_302 0x0302 |
| 177 | #define USB_DEVICE_ID_GTCO_303 0x0303 |
| 178 | #define USB_DEVICE_ID_GTCO_304 0x0304 |
| 179 | #define USB_DEVICE_ID_GTCO_305 0x0305 |
| 180 | #define USB_DEVICE_ID_GTCO_306 0x0306 |
| 181 | #define USB_DEVICE_ID_GTCO_307 0x0307 |
| 182 | #define USB_DEVICE_ID_GTCO_308 0x0308 |
| 183 | #define USB_DEVICE_ID_GTCO_309 0x0309 |
| 184 | #define USB_DEVICE_ID_GTCO_400 0x0400 |
| 185 | #define USB_DEVICE_ID_GTCO_401 0x0401 |
| 186 | #define USB_DEVICE_ID_GTCO_402 0x0402 |
| 187 | #define USB_DEVICE_ID_GTCO_403 0x0403 |
| 188 | #define USB_DEVICE_ID_GTCO_404 0x0404 |
| 189 | #define USB_DEVICE_ID_GTCO_405 0x0405 |
| 190 | #define USB_DEVICE_ID_GTCO_500 0x0500 |
| 191 | #define USB_DEVICE_ID_GTCO_501 0x0501 |
| 192 | #define USB_DEVICE_ID_GTCO_502 0x0502 |
| 193 | #define USB_DEVICE_ID_GTCO_503 0x0503 |
| 194 | #define USB_DEVICE_ID_GTCO_504 0x0504 |
| 195 | #define USB_DEVICE_ID_GTCO_1000 0x1000 |
| 196 | #define USB_DEVICE_ID_GTCO_1001 0x1001 |
| 197 | #define USB_DEVICE_ID_GTCO_1002 0x1002 |
| 198 | #define USB_DEVICE_ID_GTCO_1003 0x1003 |
| 199 | #define USB_DEVICE_ID_GTCO_1004 0x1004 |
| 200 | #define USB_DEVICE_ID_GTCO_1005 0x1005 |
| 201 | #define USB_DEVICE_ID_GTCO_1006 0x1006 |
| 202 | |
| 203 | #define USB_VENDOR_ID_HAPP 0x078b |
| 204 | #define USB_DEVICE_ID_UGCI_DRIVING 0x0010 |
| 205 | #define USB_DEVICE_ID_UGCI_FLYING 0x0020 |
| 206 | #define USB_DEVICE_ID_UGCI_FIGHTING 0x0030 |
| 207 | |
| 208 | #define USB_VENDOR_ID_IMATION 0x0718 |
| 209 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 |
| 210 | |
| 211 | #define USB_VENDOR_ID_KBGEAR 0x084e |
| 212 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 |
| 213 | |
| 214 | #define USB_VENDOR_ID_LD 0x0f11 |
| 215 | #define USB_DEVICE_ID_LD_CASSY 0x1000 |
| 216 | #define USB_DEVICE_ID_LD_POCKETCASSY 0x1010 |
| 217 | #define USB_DEVICE_ID_LD_MOBILECASSY 0x1020 |
| 218 | #define USB_DEVICE_ID_LD_JWM 0x1080 |
| 219 | #define USB_DEVICE_ID_LD_DMMP 0x1081 |
| 220 | #define USB_DEVICE_ID_LD_UMIP 0x1090 |
| 221 | #define USB_DEVICE_ID_LD_XRAY1 0x1100 |
| 222 | #define USB_DEVICE_ID_LD_XRAY2 0x1101 |
| 223 | #define USB_DEVICE_ID_LD_VIDEOCOM 0x1200 |
| 224 | #define USB_DEVICE_ID_LD_COM3LAB 0x2000 |
| 225 | #define USB_DEVICE_ID_LD_TELEPORT 0x2010 |
| 226 | #define USB_DEVICE_ID_LD_NETWORKANALYSER 0x2020 |
| 227 | #define USB_DEVICE_ID_LD_POWERCONTROL 0x2030 |
| 228 | #define USB_DEVICE_ID_LD_MACHINETEST 0x2040 |
| 229 | |
| 230 | #define USB_VENDOR_ID_LOGITECH 0x046d |
Jiri Kosina | 85cbea3 | 2007-04-05 12:23:09 +0200 | [diff] [blame] | 231 | #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 |
| 232 | #define USB_DEVICE_ID_S510_RECEIVER 0xc50c |
| 233 | #define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 |
| 234 | #define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 235 | #define USB_DEVICE_ID_DINOVO_EDGE 0xc714 |
| 236 | |
| 237 | #define USB_VENDOR_ID_MCC 0x09db |
| 238 | #define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 |
| 239 | #define USB_DEVICE_ID_MCC_PMD1208LS 0x007a |
| 240 | |
| 241 | #define USB_VENDOR_ID_MGE 0x0463 |
| 242 | #define USB_DEVICE_ID_MGE_UPS 0xffff |
| 243 | #define USB_DEVICE_ID_MGE_UPS1 0x0001 |
| 244 | |
| 245 | #define USB_VENDOR_ID_NEC 0x073e |
| 246 | #define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301 |
| 247 | |
| 248 | #define USB_VENDOR_ID_ONTRAK 0x0a07 |
| 249 | #define USB_DEVICE_ID_ONTRAK_ADU100 0x0064 |
| 250 | |
| 251 | #define USB_VENDOR_ID_PANJIT 0x134c |
| 252 | |
| 253 | #define USB_VENDOR_ID_PANTHERLORD 0x0810 |
| 254 | #define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK 0x0001 |
| 255 | |
| 256 | #define USB_VENDOR_ID_SAITEK 0x06a3 |
| 257 | #define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 |
| 258 | |
| 259 | #define USB_VENDOR_ID_SONY 0x054c |
| 260 | #define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 |
| 261 | |
| 262 | #define USB_VENDOR_ID_SUN 0x0430 |
| 263 | #define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab |
| 264 | |
| 265 | #define USB_VENDOR_ID_TOPMAX 0x0663 |
| 266 | #define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103 |
| 267 | |
| 268 | #define USB_VENDOR_ID_TURBOX 0x062a |
| 269 | #define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201 |
| 270 | |
| 271 | #define USB_VENDOR_ID_VERNIER 0x08f7 |
| 272 | #define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 |
| 273 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 |
| 274 | #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 |
| 275 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 |
| 276 | |
| 277 | #define USB_VENDOR_ID_WACOM 0x056a |
| 278 | |
| 279 | #define USB_VENDOR_ID_WISEGROUP 0x0925 |
| 280 | #define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101 |
| 281 | #define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104 |
| 282 | #define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201 |
| 283 | #define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866 |
| 284 | |
| 285 | #define USB_VENDOR_ID_WISEGROUP_LTD 0x6677 |
| 286 | #define USB_DEVICE_ID_SMARTJOY_DUAL_PLUS 0x8802 |
| 287 | |
| 288 | #define USB_VENDOR_ID_YEALINK 0x6993 |
| 289 | #define USB_DEVICE_ID_YEALINK_P1K_P4K_B2K 0xb001 |
| 290 | |
| 291 | /* |
| 292 | * Alphabetically sorted blacklist by quirk type. |
| 293 | */ |
| 294 | |
| 295 | static const struct hid_blacklist { |
| 296 | __u16 idVendor; |
| 297 | __u16 idProduct; |
Paul Walmsley | 4cbe7d2 | 2007-03-20 19:23:16 +0100 | [diff] [blame] | 298 | __u32 quirks; |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 299 | } hid_blacklist[] = { |
| 300 | |
| 301 | { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, |
| 302 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, |
| 303 | |
Jiri Kosina | 85cbea3 | 2007-04-05 12:23:09 +0200 | [diff] [blame] | 304 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER, HID_QUIRK_BAD_RELATIVE_KEYS }, |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 305 | |
| 306 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, |
| 307 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, |
| 308 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, |
| 309 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, |
| 310 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
| 311 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
| 312 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
| 313 | { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD }, |
| 314 | { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD }, |
| 315 | { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD }, |
| 316 | |
| 317 | { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION }, |
| 318 | |
| 319 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE, HID_QUIRK_DUPLICATE_USAGES }, |
| 320 | |
Daniel P. Engel | 66df514 | 2007-04-03 23:43:46 +0200 | [diff] [blame] | 321 | { USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM, HID_QUIRK_HIDDEV }, |
| 322 | |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 323 | { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01, HID_QUIRK_IGNORE }, |
| 324 | { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10, HID_QUIRK_IGNORE }, |
| 325 | { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20, HID_QUIRK_IGNORE }, |
| 326 | { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21, HID_QUIRK_IGNORE }, |
| 327 | { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE }, |
| 328 | { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE }, |
| 329 | { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE }, |
| 330 | { USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1, HID_QUIRK_IGNORE }, |
| 331 | { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE }, |
| 332 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IR, HID_QUIRK_IGNORE }, |
| 333 | { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE }, |
| 334 | { USB_VENDOR_ID_CIDC, 0x0103, HID_QUIRK_IGNORE }, |
| 335 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, |
| 336 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE, HID_QUIRK_IGNORE }, |
| 337 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, |
| 338 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, |
| 339 | { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, |
| 340 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, |
| 341 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, |
| 342 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT, HID_QUIRK_IGNORE }, |
| 343 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT, HID_QUIRK_IGNORE }, |
| 344 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT, HID_QUIRK_IGNORE }, |
| 345 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT, HID_QUIRK_IGNORE }, |
| 346 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT, HID_QUIRK_IGNORE }, |
| 347 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL, HID_QUIRK_IGNORE }, |
| 348 | { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE, HID_QUIRK_IGNORE }, |
| 349 | { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB, HID_QUIRK_IGNORE }, |
| 350 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90, HID_QUIRK_IGNORE }, |
| 351 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100, HID_QUIRK_IGNORE }, |
| 352 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101, HID_QUIRK_IGNORE }, |
| 353 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103, HID_QUIRK_IGNORE }, |
| 354 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104, HID_QUIRK_IGNORE }, |
| 355 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105, HID_QUIRK_IGNORE }, |
| 356 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106, HID_QUIRK_IGNORE }, |
| 357 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107, HID_QUIRK_IGNORE }, |
| 358 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108, HID_QUIRK_IGNORE }, |
| 359 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200, HID_QUIRK_IGNORE }, |
| 360 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201, HID_QUIRK_IGNORE }, |
| 361 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202, HID_QUIRK_IGNORE }, |
| 362 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203, HID_QUIRK_IGNORE }, |
| 363 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204, HID_QUIRK_IGNORE }, |
| 364 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205, HID_QUIRK_IGNORE }, |
| 365 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206, HID_QUIRK_IGNORE }, |
| 366 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207, HID_QUIRK_IGNORE }, |
| 367 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300, HID_QUIRK_IGNORE }, |
| 368 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301, HID_QUIRK_IGNORE }, |
| 369 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302, HID_QUIRK_IGNORE }, |
| 370 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303, HID_QUIRK_IGNORE }, |
| 371 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304, HID_QUIRK_IGNORE }, |
| 372 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305, HID_QUIRK_IGNORE }, |
| 373 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306, HID_QUIRK_IGNORE }, |
| 374 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307, HID_QUIRK_IGNORE }, |
| 375 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308, HID_QUIRK_IGNORE }, |
| 376 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309, HID_QUIRK_IGNORE }, |
| 377 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400, HID_QUIRK_IGNORE }, |
| 378 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401, HID_QUIRK_IGNORE }, |
| 379 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402, HID_QUIRK_IGNORE }, |
| 380 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403, HID_QUIRK_IGNORE }, |
| 381 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404, HID_QUIRK_IGNORE }, |
| 382 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405, HID_QUIRK_IGNORE }, |
| 383 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500, HID_QUIRK_IGNORE }, |
| 384 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501, HID_QUIRK_IGNORE }, |
| 385 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502, HID_QUIRK_IGNORE }, |
| 386 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503, HID_QUIRK_IGNORE }, |
| 387 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504, HID_QUIRK_IGNORE }, |
| 388 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000, HID_QUIRK_IGNORE }, |
| 389 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001, HID_QUIRK_IGNORE }, |
| 390 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002, HID_QUIRK_IGNORE }, |
| 391 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003, HID_QUIRK_IGNORE }, |
| 392 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004, HID_QUIRK_IGNORE }, |
| 393 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005, HID_QUIRK_IGNORE }, |
| 394 | { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006, HID_QUIRK_IGNORE }, |
| 395 | { USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA, HID_QUIRK_IGNORE }, |
| 396 | { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE }, |
| 397 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY, HID_QUIRK_IGNORE }, |
| 398 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY, HID_QUIRK_IGNORE }, |
| 399 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY, HID_QUIRK_IGNORE }, |
| 400 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM, HID_QUIRK_IGNORE }, |
| 401 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP, HID_QUIRK_IGNORE }, |
| 402 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP, HID_QUIRK_IGNORE }, |
| 403 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1, HID_QUIRK_IGNORE }, |
| 404 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2, HID_QUIRK_IGNORE }, |
| 405 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM, HID_QUIRK_IGNORE }, |
| 406 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB, HID_QUIRK_IGNORE }, |
| 407 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT, HID_QUIRK_IGNORE }, |
| 408 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER, HID_QUIRK_IGNORE }, |
| 409 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL, HID_QUIRK_IGNORE }, |
| 410 | { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST, HID_QUIRK_IGNORE }, |
| 411 | { USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS, HID_QUIRK_IGNORE }, |
| 412 | { USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS, HID_QUIRK_IGNORE }, |
| 413 | { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_IGNORE }, |
| 414 | { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_IGNORE }, |
| 415 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100, HID_QUIRK_IGNORE }, |
| 416 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20, HID_QUIRK_IGNORE }, |
| 417 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30, HID_QUIRK_IGNORE }, |
| 418 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100, HID_QUIRK_IGNORE }, |
| 419 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108, HID_QUIRK_IGNORE }, |
| 420 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118, HID_QUIRK_IGNORE }, |
| 421 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200, HID_QUIRK_IGNORE }, |
| 422 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE }, |
| 423 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE }, |
| 424 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE }, |
| 425 | { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE }, |
| 426 | { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE }, |
| 427 | { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE }, |
| 428 | { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE }, |
| 429 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO, HID_QUIRK_IGNORE }, |
| 430 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE }, |
| 431 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE }, |
| 432 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE }, |
| 433 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
| 434 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
| 435 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE }, |
| 436 | { USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K, HID_QUIRK_IGNORE }, |
| 437 | |
| 438 | { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE }, |
| 439 | { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302, HID_QUIRK_IGNORE }, |
| 440 | |
Jiri Kosina | 85cbea3 | 2007-04-05 12:23:09 +0200 | [diff] [blame] | 441 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER, HID_QUIRK_LOGITECH_DESCRIPTOR }, |
| 442 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER, HID_QUIRK_LOGITECH_DESCRIPTOR }, |
| 443 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2, HID_QUIRK_LOGITECH_DESCRIPTOR }, |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 444 | |
| 445 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL }, |
| 446 | |
| 447 | { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, |
| 448 | |
| 449 | { USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, HID_QUIRK_SONY_PS3_CONTROLLER }, |
| 450 | |
| 451 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, |
| 452 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, |
| 453 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, |
| 454 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, |
| 455 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, |
| 456 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, |
| 457 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, |
| 458 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
| 459 | { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
| 460 | |
| 461 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 462 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 463 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 464 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, |
| 465 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 466 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 467 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, |
| 468 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 469 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 470 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, |
| 471 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 472 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 473 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, |
| 474 | |
Pete Zaitcev | 713c8aa | 2007-04-06 14:33:18 +0200 | [diff] [blame^] | 475 | { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, |
| 476 | |
Jiri Kosina | 48b4554 | 2007-04-03 23:39:37 +0200 | [diff] [blame] | 477 | { 0, 0 } |
| 478 | }; |
| 479 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | /* |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 481 | * Input submission and I/O error handler. |
| 482 | */ |
| 483 | |
| 484 | static void hid_io_error(struct hid_device *hid); |
| 485 | |
| 486 | /* Start up the input URB */ |
| 487 | static int hid_start_in(struct hid_device *hid) |
| 488 | { |
| 489 | unsigned long flags; |
| 490 | int rc = 0; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 491 | struct usbhid_device *usbhid = hid->driver_data; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 492 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 493 | spin_lock_irqsave(&usbhid->inlock, flags); |
| 494 | if (hid->open > 0 && !test_bit(HID_SUSPENDED, &usbhid->iofl) && |
| 495 | !test_and_set_bit(HID_IN_RUNNING, &usbhid->iofl)) { |
| 496 | rc = usb_submit_urb(usbhid->urbin, GFP_ATOMIC); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 497 | if (rc != 0) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 498 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 499 | } |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 500 | spin_unlock_irqrestore(&usbhid->inlock, flags); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 501 | return rc; |
| 502 | } |
| 503 | |
| 504 | /* I/O retry timer routine */ |
| 505 | static void hid_retry_timeout(unsigned long _hid) |
| 506 | { |
| 507 | struct hid_device *hid = (struct hid_device *) _hid; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 508 | struct usbhid_device *usbhid = hid->driver_data; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 509 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 510 | dev_dbg(&usbhid->intf->dev, "retrying intr urb\n"); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 511 | if (hid_start_in(hid)) |
| 512 | hid_io_error(hid); |
| 513 | } |
| 514 | |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 515 | /* Workqueue routine to reset the device or clear a halt */ |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 516 | static void hid_reset(struct work_struct *work) |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 517 | { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 518 | struct usbhid_device *usbhid = |
| 519 | container_of(work, struct usbhid_device, reset_work); |
| 520 | struct hid_device *hid = usbhid->hid; |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 521 | int rc_lock, rc = 0; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 522 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 523 | if (test_bit(HID_CLEAR_HALT, &usbhid->iofl)) { |
| 524 | dev_dbg(&usbhid->intf->dev, "clear halt\n"); |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 525 | rc = usb_clear_halt(hid_to_usb_dev(hid), usbhid->urbin->pipe); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 526 | clear_bit(HID_CLEAR_HALT, &usbhid->iofl); |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 527 | hid_start_in(hid); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 528 | } |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 529 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 530 | else if (test_bit(HID_RESET_PENDING, &usbhid->iofl)) { |
| 531 | dev_dbg(&usbhid->intf->dev, "resetting device\n"); |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 532 | rc = rc_lock = usb_lock_device_for_reset(hid_to_usb_dev(hid), usbhid->intf); |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 533 | if (rc_lock >= 0) { |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 534 | rc = usb_reset_composite_device(hid_to_usb_dev(hid), usbhid->intf); |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 535 | if (rc_lock) |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 536 | usb_unlock_device(hid_to_usb_dev(hid)); |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 537 | } |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 538 | clear_bit(HID_RESET_PENDING, &usbhid->iofl); |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 539 | } |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 540 | |
Alan Stern | df9a1f4 | 2006-06-01 13:55:28 -0400 | [diff] [blame] | 541 | switch (rc) { |
| 542 | case 0: |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 543 | if (!test_bit(HID_IN_RUNNING, &usbhid->iofl)) |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 544 | hid_io_error(hid); |
Alan Stern | df9a1f4 | 2006-06-01 13:55:28 -0400 | [diff] [blame] | 545 | break; |
| 546 | default: |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 547 | err("can't reset device, %s-%s/input%d, status %d", |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 548 | hid_to_usb_dev(hid)->bus->bus_name, |
| 549 | hid_to_usb_dev(hid)->devpath, |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 550 | usbhid->ifnum, rc); |
Alan Stern | df9a1f4 | 2006-06-01 13:55:28 -0400 | [diff] [blame] | 551 | /* FALLTHROUGH */ |
| 552 | case -EHOSTUNREACH: |
| 553 | case -ENODEV: |
| 554 | case -EINTR: |
| 555 | break; |
| 556 | } |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | /* Main I/O error handler */ |
| 560 | static void hid_io_error(struct hid_device *hid) |
| 561 | { |
| 562 | unsigned long flags; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 563 | struct usbhid_device *usbhid = hid->driver_data; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 564 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 565 | spin_lock_irqsave(&usbhid->inlock, flags); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 566 | |
| 567 | /* Stop when disconnected */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 568 | if (usb_get_intfdata(usbhid->intf) == NULL) |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 569 | goto done; |
| 570 | |
Alan Stern | 5e2a55f | 2007-03-20 19:03:31 +0100 | [diff] [blame] | 571 | /* If it has been a while since the last error, we'll assume |
| 572 | * this a brand new error and reset the retry timeout. */ |
| 573 | if (time_after(jiffies, usbhid->stop_retry + HZ/2)) |
| 574 | usbhid->retry_delay = 0; |
| 575 | |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 576 | /* When an error occurs, retry at increasing intervals */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 577 | if (usbhid->retry_delay == 0) { |
| 578 | usbhid->retry_delay = 13; /* Then 26, 52, 104, 104, ... */ |
| 579 | usbhid->stop_retry = jiffies + msecs_to_jiffies(1000); |
| 580 | } else if (usbhid->retry_delay < 100) |
| 581 | usbhid->retry_delay *= 2; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 582 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 583 | if (time_after(jiffies, usbhid->stop_retry)) { |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 584 | |
| 585 | /* Retries failed, so do a port reset */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 586 | if (!test_and_set_bit(HID_RESET_PENDING, &usbhid->iofl)) { |
| 587 | schedule_work(&usbhid->reset_work); |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 588 | goto done; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 589 | } |
| 590 | } |
| 591 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 592 | mod_timer(&usbhid->io_retry, |
| 593 | jiffies + msecs_to_jiffies(usbhid->retry_delay)); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 594 | done: |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 595 | spin_unlock_irqrestore(&usbhid->inlock, flags); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | * Input interrupt completion handler. |
| 600 | */ |
| 601 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 602 | static void hid_irq_in(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | { |
| 604 | struct hid_device *hid = urb->context; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 605 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | int status; |
| 607 | |
| 608 | switch (urb->status) { |
| 609 | case 0: /* success */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 610 | usbhid->retry_delay = 0; |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 611 | hid_input_report(urb->context, HID_INPUT_REPORT, |
| 612 | urb->transfer_buffer, |
| 613 | urb->actual_length, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | break; |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 615 | case -EPIPE: /* stall */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 616 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
| 617 | set_bit(HID_CLEAR_HALT, &usbhid->iofl); |
| 618 | schedule_work(&usbhid->reset_work); |
Alan Stern | 6d8fc4d | 2006-10-18 12:35:24 -0400 | [diff] [blame] | 619 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | case -ECONNRESET: /* unlink */ |
| 621 | case -ENOENT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | case -ESHUTDOWN: /* unplug */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 623 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | return; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 625 | case -EILSEQ: /* protocol error or unplug */ |
| 626 | case -EPROTO: /* protocol error or unplug */ |
Pete Zaitcev | 38e2bfc | 2006-09-18 22:49:02 -0700 | [diff] [blame] | 627 | case -ETIME: /* protocol error or unplug */ |
| 628 | case -ETIMEDOUT: /* Should never happen, but... */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 629 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 630 | hid_io_error(hid); |
| 631 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | default: /* error */ |
| 633 | warn("input irq status %d received", urb->status); |
| 634 | } |
| 635 | |
Christoph Lameter | 54e6ecb | 2006-12-06 20:33:16 -0800 | [diff] [blame] | 636 | status = usb_submit_urb(urb, GFP_ATOMIC); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 637 | if (status) { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 638 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 639 | if (status != -EPERM) { |
| 640 | err("can't resubmit intr, %s-%s/input%d, status %d", |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 641 | hid_to_usb_dev(hid)->bus->bus_name, |
| 642 | hid_to_usb_dev(hid)->devpath, |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 643 | usbhid->ifnum, status); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 644 | hid_io_error(hid); |
| 645 | } |
| 646 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | } |
| 648 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | static int hid_submit_out(struct hid_device *hid) |
| 650 | { |
| 651 | struct hid_report *report; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 652 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 654 | report = usbhid->out[usbhid->outtail]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 656 | hid_output_report(report, usbhid->outbuf); |
| 657 | usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 658 | usbhid->urbout->dev = hid_to_usb_dev(hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
| 660 | dbg("submitting out urb"); |
| 661 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 662 | if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | err("usb_submit_urb(out) failed"); |
| 664 | return -1; |
| 665 | } |
| 666 | |
| 667 | return 0; |
| 668 | } |
| 669 | |
| 670 | static int hid_submit_ctrl(struct hid_device *hid) |
| 671 | { |
| 672 | struct hid_report *report; |
| 673 | unsigned char dir; |
| 674 | int len; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 675 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 677 | report = usbhid->ctrl[usbhid->ctrltail].report; |
| 678 | dir = usbhid->ctrl[usbhid->ctrltail].dir; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
| 680 | len = ((report->size - 1) >> 3) + 1 + (report->id > 0); |
| 681 | if (dir == USB_DIR_OUT) { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 682 | hid_output_report(report, usbhid->ctrlbuf); |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 683 | usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 684 | usbhid->urbctrl->transfer_buffer_length = len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | } else { |
| 686 | int maxpacket, padlen; |
| 687 | |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 688 | usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0); |
| 689 | maxpacket = usb_maxpacket(hid_to_usb_dev(hid), usbhid->urbctrl->pipe, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | if (maxpacket > 0) { |
| 691 | padlen = (len + maxpacket - 1) / maxpacket; |
| 692 | padlen *= maxpacket; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 693 | if (padlen > usbhid->bufsize) |
| 694 | padlen = usbhid->bufsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | } else |
| 696 | padlen = 0; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 697 | usbhid->urbctrl->transfer_buffer_length = padlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | } |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 699 | usbhid->urbctrl->dev = hid_to_usb_dev(hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 701 | usbhid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir; |
| 702 | usbhid->cr->bRequest = (dir == USB_DIR_OUT) ? HID_REQ_SET_REPORT : HID_REQ_GET_REPORT; |
| 703 | usbhid->cr->wValue = cpu_to_le16(((report->type + 1) << 8) | report->id); |
| 704 | usbhid->cr->wIndex = cpu_to_le16(usbhid->ifnum); |
| 705 | usbhid->cr->wLength = cpu_to_le16(len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | |
| 707 | dbg("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u", |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 708 | usbhid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report", |
| 709 | usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 711 | if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | err("usb_submit_urb(ctrl) failed"); |
| 713 | return -1; |
| 714 | } |
| 715 | |
| 716 | return 0; |
| 717 | } |
| 718 | |
| 719 | /* |
| 720 | * Output interrupt completion handler. |
| 721 | */ |
| 722 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 723 | static void hid_irq_out(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | { |
| 725 | struct hid_device *hid = urb->context; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 726 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | unsigned long flags; |
| 728 | int unplug = 0; |
| 729 | |
| 730 | switch (urb->status) { |
| 731 | case 0: /* success */ |
Vojtech Pavlik | c4786ca | 2005-09-05 00:13:03 -0500 | [diff] [blame] | 732 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | case -ESHUTDOWN: /* unplug */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | unplug = 1; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 735 | case -EILSEQ: /* protocol error or unplug */ |
| 736 | case -EPROTO: /* protocol error or unplug */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | case -ECONNRESET: /* unlink */ |
| 738 | case -ENOENT: |
| 739 | break; |
| 740 | default: /* error */ |
| 741 | warn("output irq status %d received", urb->status); |
| 742 | } |
| 743 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 744 | spin_lock_irqsave(&usbhid->outlock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | |
| 746 | if (unplug) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 747 | usbhid->outtail = usbhid->outhead; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | else |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 749 | usbhid->outtail = (usbhid->outtail + 1) & (HID_OUTPUT_FIFO_SIZE - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 751 | if (usbhid->outhead != usbhid->outtail) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | if (hid_submit_out(hid)) { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 753 | clear_bit(HID_OUT_RUNNING, &usbhid->iofl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | wake_up(&hid->wait); |
| 755 | } |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 756 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | return; |
| 758 | } |
| 759 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 760 | clear_bit(HID_OUT_RUNNING, &usbhid->iofl); |
| 761 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | wake_up(&hid->wait); |
| 763 | } |
| 764 | |
| 765 | /* |
| 766 | * Control pipe completion handler. |
| 767 | */ |
| 768 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 769 | static void hid_ctrl(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | { |
| 771 | struct hid_device *hid = urb->context; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 772 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | unsigned long flags; |
| 774 | int unplug = 0; |
| 775 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 776 | spin_lock_irqsave(&usbhid->ctrllock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | |
| 778 | switch (urb->status) { |
| 779 | case 0: /* success */ |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 780 | if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 781 | hid_input_report(urb->context, usbhid->ctrl[usbhid->ctrltail].report->type, |
| 782 | urb->transfer_buffer, urb->actual_length, 0); |
Vojtech Pavlik | c4786ca | 2005-09-05 00:13:03 -0500 | [diff] [blame] | 783 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | case -ESHUTDOWN: /* unplug */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | unplug = 1; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 786 | case -EILSEQ: /* protocol error or unplug */ |
| 787 | case -EPROTO: /* protocol error or unplug */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | case -ECONNRESET: /* unlink */ |
| 789 | case -ENOENT: |
| 790 | case -EPIPE: /* report not available */ |
| 791 | break; |
| 792 | default: /* error */ |
| 793 | warn("ctrl urb status %d received", urb->status); |
| 794 | } |
| 795 | |
| 796 | if (unplug) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 797 | usbhid->ctrltail = usbhid->ctrlhead; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | else |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 799 | usbhid->ctrltail = (usbhid->ctrltail + 1) & (HID_CONTROL_FIFO_SIZE - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 801 | if (usbhid->ctrlhead != usbhid->ctrltail) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | if (hid_submit_ctrl(hid)) { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 803 | clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | wake_up(&hid->wait); |
| 805 | } |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 806 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | return; |
| 808 | } |
| 809 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 810 | clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); |
| 811 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | wake_up(&hid->wait); |
| 813 | } |
| 814 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 815 | void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | { |
| 817 | int head; |
| 818 | unsigned long flags; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 819 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | |
| 821 | if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN) |
| 822 | return; |
| 823 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 824 | if (usbhid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 826 | spin_lock_irqsave(&usbhid->outlock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 828 | if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) { |
| 829 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | warn("output queue full"); |
| 831 | return; |
| 832 | } |
| 833 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 834 | usbhid->out[usbhid->outhead] = report; |
| 835 | usbhid->outhead = head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 837 | if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | if (hid_submit_out(hid)) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 839 | clear_bit(HID_OUT_RUNNING, &usbhid->iofl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 841 | spin_unlock_irqrestore(&usbhid->outlock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | return; |
| 843 | } |
| 844 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 845 | spin_lock_irqsave(&usbhid->ctrllock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 847 | if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) { |
| 848 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | warn("control queue full"); |
| 850 | return; |
| 851 | } |
| 852 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 853 | usbhid->ctrl[usbhid->ctrlhead].report = report; |
| 854 | usbhid->ctrl[usbhid->ctrlhead].dir = dir; |
| 855 | usbhid->ctrlhead = head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 857 | if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | if (hid_submit_ctrl(hid)) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 859 | clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 861 | spin_unlock_irqrestore(&usbhid->ctrllock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | } |
| 863 | |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 864 | static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 865 | { |
| 866 | struct hid_device *hid = dev->private; |
| 867 | struct hid_field *field; |
| 868 | int offset; |
| 869 | |
| 870 | if (type == EV_FF) |
| 871 | return input_ff_event(dev, type, code, value); |
| 872 | |
| 873 | if (type != EV_LED) |
| 874 | return -1; |
| 875 | |
| 876 | if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) { |
| 877 | warn("event field not found"); |
| 878 | return -1; |
| 879 | } |
| 880 | |
| 881 | hid_set_field(field, offset, value); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 882 | usbhid_submit_report(hid, field->report, USB_DIR_OUT); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 883 | |
| 884 | return 0; |
| 885 | } |
| 886 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 887 | int usbhid_wait_io(struct hid_device *hid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 889 | struct usbhid_device *usbhid = hid->driver_data; |
| 890 | |
| 891 | if (!wait_event_timeout(hid->wait, (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl) && |
| 892 | !test_bit(HID_OUT_RUNNING, &usbhid->iofl)), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | 10*HZ)) { |
| 894 | dbg("timeout waiting for ctrl or out queue to clear"); |
| 895 | return -1; |
| 896 | } |
| 897 | |
| 898 | return 0; |
| 899 | } |
| 900 | |
Vojtech Pavlik | 854561b | 2005-05-29 02:28:00 -0500 | [diff] [blame] | 901 | static int hid_set_idle(struct usb_device *dev, int ifnum, int report, int idle) |
| 902 | { |
Vojtech Pavlik | 71387bd | 2005-05-29 02:28:14 -0500 | [diff] [blame] | 903 | return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
Vojtech Pavlik | 854561b | 2005-05-29 02:28:00 -0500 | [diff] [blame] | 904 | HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, (idle << 8) | report, |
| 905 | ifnum, NULL, 0, USB_CTRL_SET_TIMEOUT); |
| 906 | } |
| 907 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, |
| 909 | unsigned char type, void *buf, int size) |
| 910 | { |
| 911 | int result, retries = 4; |
| 912 | |
Jiri Kosina | 43c7bf0 | 2007-01-26 12:58:24 +0100 | [diff] [blame] | 913 | memset(buf, 0, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | |
| 915 | do { |
| 916 | result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), |
| 917 | USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN, |
| 918 | (type << 8), ifnum, buf, size, USB_CTRL_GET_TIMEOUT); |
| 919 | retries--; |
| 920 | } while (result < size && retries); |
| 921 | return result; |
| 922 | } |
| 923 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 924 | int usbhid_open(struct hid_device *hid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | { |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 926 | ++hid->open; |
| 927 | if (hid_start_in(hid)) |
| 928 | hid_io_error(hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | return 0; |
| 930 | } |
| 931 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 932 | void usbhid_close(struct hid_device *hid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 934 | struct usbhid_device *usbhid = hid->driver_data; |
| 935 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | if (!--hid->open) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 937 | usb_kill_urb(usbhid->urbin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | /* |
| 941 | * Initialize all reports |
| 942 | */ |
| 943 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 944 | void usbhid_init_reports(struct hid_device *hid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | { |
| 946 | struct hid_report *report; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 947 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | int err, ret; |
| 949 | |
Michael Haboustak | bf0964d | 2005-09-05 00:12:01 -0500 | [diff] [blame] | 950 | list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 951 | usbhid_submit_report(hid, report, USB_DIR_IN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | |
| 953 | list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 954 | usbhid_submit_report(hid, report, USB_DIR_IN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
| 956 | err = 0; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 957 | ret = usbhid_wait_io(hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | while (ret) { |
| 959 | err |= ret; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 960 | if (test_bit(HID_CTRL_RUNNING, &usbhid->iofl)) |
| 961 | usb_kill_urb(usbhid->urbctrl); |
| 962 | if (test_bit(HID_OUT_RUNNING, &usbhid->iofl)) |
| 963 | usb_kill_urb(usbhid->urbout); |
| 964 | ret = usbhid_wait_io(hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | } |
| 966 | |
| 967 | if (err) |
Olaf Hering | de289fd | 2006-01-06 12:45:28 +0100 | [diff] [blame] | 968 | warn("timeout initializing reports"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | } |
| 970 | |
Michael Haboustak | bf0964d | 2005-09-05 00:12:01 -0500 | [diff] [blame] | 971 | /* |
Pete Zaitcev | 713c8aa | 2007-04-06 14:33:18 +0200 | [diff] [blame^] | 972 | * Reset LEDs which BIOS might have left on. For now, just NumLock (0x01). |
| 973 | */ |
| 974 | static int hid_find_field_early(struct hid_device *hid, unsigned int page, |
| 975 | unsigned int hid_code, struct hid_field **pfield) |
| 976 | { |
| 977 | struct hid_report *report; |
| 978 | struct hid_field *field; |
| 979 | struct hid_usage *usage; |
| 980 | int i, j; |
| 981 | |
| 982 | list_for_each_entry(report, &hid->report_enum[HID_OUTPUT_REPORT].report_list, list) { |
| 983 | for (i = 0; i < report->maxfield; i++) { |
| 984 | field = report->field[i]; |
| 985 | for (j = 0; j < field->maxusage; j++) { |
| 986 | usage = &field->usage[j]; |
| 987 | if ((usage->hid & HID_USAGE_PAGE) == page && |
| 988 | (usage->hid & 0xFFFF) == hid_code) { |
| 989 | *pfield = field; |
| 990 | return j; |
| 991 | } |
| 992 | } |
| 993 | } |
| 994 | } |
| 995 | return -1; |
| 996 | } |
| 997 | |
| 998 | static void usbhid_set_leds(struct hid_device *hid) |
| 999 | { |
| 1000 | struct hid_field *field; |
| 1001 | int offset; |
| 1002 | |
| 1003 | if ((offset = hid_find_field_early(hid, HID_UP_LED, 0x01, &field)) != -1) { |
| 1004 | hid_set_field(field, offset, 0); |
| 1005 | usbhid_submit_report(hid, field->report, USB_DIR_OUT); |
| 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | /* |
Michael Haboustak | bf0964d | 2005-09-05 00:12:01 -0500 | [diff] [blame] | 1010 | * Traverse the supplied list of reports and find the longest |
| 1011 | */ |
| 1012 | static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *max) |
| 1013 | { |
| 1014 | struct hid_report *report; |
| 1015 | int size; |
| 1016 | |
| 1017 | list_for_each_entry(report, &hid->report_enum[type].report_list, list) { |
| 1018 | size = ((report->size - 1) >> 3) + 1; |
| 1019 | if (type == HID_INPUT_REPORT && hid->report_enum[type].numbered) |
| 1020 | size++; |
| 1021 | if (*max < size) |
| 1022 | *max = size; |
| 1023 | } |
| 1024 | } |
| 1025 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) |
| 1027 | { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1028 | struct usbhid_device *usbhid = hid->driver_data; |
| 1029 | |
| 1030 | if (!(usbhid->inbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->inbuf_dma))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | return -1; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1032 | if (!(usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->outbuf_dma))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | return -1; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1034 | if (!(usbhid->cr = usb_buffer_alloc(dev, sizeof(*(usbhid->cr)), GFP_ATOMIC, &usbhid->cr_dma))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | return -1; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1036 | if (!(usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->ctrlbuf_dma))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | return -1; |
| 1038 | |
| 1039 | return 0; |
| 1040 | } |
| 1041 | |
| 1042 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) |
| 1043 | { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1044 | struct usbhid_device *usbhid = hid->driver_data; |
| 1045 | |
| 1046 | if (usbhid->inbuf) |
| 1047 | usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); |
| 1048 | if (usbhid->outbuf) |
| 1049 | usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); |
| 1050 | if (usbhid->cr) |
| 1051 | usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma); |
| 1052 | if (usbhid->ctrlbuf) |
| 1053 | usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | } |
| 1055 | |
Vojtech Pavlik | 940824b | 2006-01-14 00:25:39 -0500 | [diff] [blame] | 1056 | /* |
| 1057 | * Cherry Cymotion keyboard have an invalid HID report descriptor, |
| 1058 | * that needs fixing before we can parse it. |
| 1059 | */ |
| 1060 | |
| 1061 | static void hid_fixup_cymotion_descriptor(char *rdesc, int rsize) |
| 1062 | { |
| 1063 | if (rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) { |
| 1064 | info("Fixing up Cherry Cymotion report descriptor"); |
| 1065 | rdesc[11] = rdesc[16] = 0xff; |
| 1066 | rdesc[12] = rdesc[17] = 0x03; |
| 1067 | } |
| 1068 | } |
| 1069 | |
Geoff Levand | 4a1a4d8 | 2007-01-15 20:11:52 -0800 | [diff] [blame] | 1070 | /* |
| 1071 | * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller |
| 1072 | * to "operational". Without this, the ps3 controller will not report any |
| 1073 | * events. |
| 1074 | */ |
| 1075 | static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum) |
| 1076 | { |
| 1077 | int result; |
| 1078 | char *buf = kmalloc(18, GFP_KERNEL); |
| 1079 | |
| 1080 | if (!buf) |
| 1081 | return; |
| 1082 | |
| 1083 | result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), |
| 1084 | HID_REQ_GET_REPORT, |
| 1085 | USB_DIR_IN | USB_TYPE_CLASS | |
| 1086 | USB_RECIP_INTERFACE, |
| 1087 | (3 << 8) | 0xf2, ifnum, buf, 17, |
| 1088 | USB_CTRL_GET_TIMEOUT); |
| 1089 | |
| 1090 | if (result < 0) |
| 1091 | err("%s failed: %d\n", __func__, result); |
| 1092 | |
| 1093 | kfree(buf); |
| 1094 | } |
| 1095 | |
Jiri Kosina | b55fd23 | 2007-02-21 19:27:49 +0100 | [diff] [blame] | 1096 | /* |
Jiri Kosina | 85cbea3 | 2007-04-05 12:23:09 +0200 | [diff] [blame] | 1097 | * Certain Logitech keyboards send in report #3 keys which are far |
Jiri Kosina | b55fd23 | 2007-02-21 19:27:49 +0100 | [diff] [blame] | 1098 | * above the logical maximum described in descriptor. This extends |
| 1099 | * the original value of 0x28c of logical maximum to 0x104d |
| 1100 | */ |
Jiri Kosina | 85cbea3 | 2007-04-05 12:23:09 +0200 | [diff] [blame] | 1101 | static void hid_fixup_logitech_descriptor(unsigned char *rdesc, int rsize) |
Jiri Kosina | b55fd23 | 2007-02-21 19:27:49 +0100 | [diff] [blame] | 1102 | { |
| 1103 | if (rsize >= 90 && rdesc[83] == 0x26 |
| 1104 | && rdesc[84] == 0x8c |
| 1105 | && rdesc[85] == 0x02) { |
Jiri Kosina | 85cbea3 | 2007-04-05 12:23:09 +0200 | [diff] [blame] | 1106 | info("Fixing up Logitech keyboard report descriptor"); |
Jiri Kosina | b55fd23 | 2007-02-21 19:27:49 +0100 | [diff] [blame] | 1107 | rdesc[84] = rdesc[89] = 0x4d; |
| 1108 | rdesc[85] = rdesc[90] = 0x10; |
| 1109 | } |
| 1110 | } |
| 1111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) |
| 1113 | { |
| 1114 | struct usb_host_interface *interface = intf->cur_altsetting; |
| 1115 | struct usb_device *dev = interface_to_usbdev (intf); |
| 1116 | struct hid_descriptor *hdesc; |
| 1117 | struct hid_device *hid; |
Paul Walmsley | 4cbe7d2 | 2007-03-20 19:23:16 +0100 | [diff] [blame] | 1118 | __u32 quirks = 0; |
| 1119 | unsigned rsize = 0; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 1120 | char *rdesc; |
| 1121 | int n, len, insize = 0; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1122 | struct usbhid_device *usbhid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | |
Robert Marquardt | 5ddc322 | 2007-03-02 16:01:52 +0100 | [diff] [blame] | 1124 | /* Ignore all Wacom devices */ |
| 1125 | if (le16_to_cpu(dev->descriptor.idVendor) == USB_VENDOR_ID_WACOM) |
| 1126 | return NULL; |
| 1127 | /* ignore all Code Mercenaries IOWarrior devices */ |
| 1128 | if (le16_to_cpu(dev->descriptor.idVendor) == USB_VENDOR_ID_CODEMERCS) |
| 1129 | if (le16_to_cpu(dev->descriptor.idProduct) >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && |
| 1130 | le16_to_cpu(dev->descriptor.idProduct) <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) |
| 1131 | return NULL; |
Ping Cheng | ea18665 | 2006-07-14 16:50:04 -0700 | [diff] [blame] | 1132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | for (n = 0; hid_blacklist[n].idVendor; n++) |
| 1134 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && |
| 1135 | (hid_blacklist[n].idProduct == le16_to_cpu(dev->descriptor.idProduct))) |
| 1136 | quirks = hid_blacklist[n].quirks; |
| 1137 | |
Alan Stern | 0f28b55 | 2006-05-15 14:49:04 -0400 | [diff] [blame] | 1138 | /* Many keyboards and mice don't like to be polled for reports, |
| 1139 | * so we will always set the HID_QUIRK_NOGET flag for them. */ |
| 1140 | if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { |
| 1141 | if (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD || |
| 1142 | interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE) |
| 1143 | quirks |= HID_QUIRK_NOGET; |
| 1144 | } |
| 1145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | if (quirks & HID_QUIRK_IGNORE) |
| 1147 | return NULL; |
| 1148 | |
Soeren Sonnenburg | a417a21 | 2007-02-05 10:06:01 +0100 | [diff] [blame] | 1149 | if ((quirks & HID_QUIRK_IGNORE_MOUSE) && |
| 1150 | (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE)) |
| 1151 | return NULL; |
| 1152 | |
| 1153 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 1154 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && |
| 1155 | (!interface->desc.bNumEndpoints || |
| 1156 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { |
| 1157 | dbg("class descriptor not present\n"); |
| 1158 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | for (n = 0; n < hdesc->bNumDescriptors; n++) |
| 1162 | if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT) |
| 1163 | rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength); |
| 1164 | |
| 1165 | if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) { |
| 1166 | dbg("weird size of report descriptor (%u)", rsize); |
| 1167 | return NULL; |
| 1168 | } |
| 1169 | |
| 1170 | if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) { |
| 1171 | dbg("couldn't allocate rdesc memory"); |
| 1172 | return NULL; |
| 1173 | } |
| 1174 | |
Vojtech Pavlik | 854561b | 2005-05-29 02:28:00 -0500 | [diff] [blame] | 1175 | hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0); |
| 1176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { |
| 1178 | dbg("reading report descriptor failed"); |
| 1179 | kfree(rdesc); |
| 1180 | return NULL; |
| 1181 | } |
| 1182 | |
Vojtech Pavlik | 940824b | 2006-01-14 00:25:39 -0500 | [diff] [blame] | 1183 | if ((quirks & HID_QUIRK_CYMOTION)) |
| 1184 | hid_fixup_cymotion_descriptor(rdesc, rsize); |
| 1185 | |
Jiri Kosina | 85cbea3 | 2007-04-05 12:23:09 +0200 | [diff] [blame] | 1186 | if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR) |
| 1187 | hid_fixup_logitech_descriptor(rdesc, rsize); |
Jiri Kosina | b55fd23 | 2007-02-21 19:27:49 +0100 | [diff] [blame] | 1188 | |
Jiri Kosina | fdc9c56 | 2007-02-19 14:15:59 +0100 | [diff] [blame] | 1189 | #ifdef CONFIG_HID_DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n); |
| 1191 | for (n = 0; n < rsize; n++) |
| 1192 | printk(" %02x", (unsigned char) rdesc[n]); |
| 1193 | printk("\n"); |
| 1194 | #endif |
| 1195 | |
| 1196 | if (!(hid = hid_parse_report(rdesc, n))) { |
| 1197 | dbg("parsing report descriptor failed"); |
| 1198 | kfree(rdesc); |
| 1199 | return NULL; |
| 1200 | } |
| 1201 | |
| 1202 | kfree(rdesc); |
| 1203 | hid->quirks = quirks; |
| 1204 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1205 | if (!(usbhid = kzalloc(sizeof(struct usbhid_device), GFP_KERNEL))) |
| 1206 | goto fail; |
Michael Haboustak | bf0964d | 2005-09-05 00:12:01 -0500 | [diff] [blame] | 1207 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1208 | hid->driver_data = usbhid; |
| 1209 | usbhid->hid = hid; |
| 1210 | |
| 1211 | usbhid->bufsize = HID_MIN_BUFFER_SIZE; |
| 1212 | hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize); |
| 1213 | hid_find_max_report(hid, HID_OUTPUT_REPORT, &usbhid->bufsize); |
| 1214 | hid_find_max_report(hid, HID_FEATURE_REPORT, &usbhid->bufsize); |
| 1215 | |
| 1216 | if (usbhid->bufsize > HID_MAX_BUFFER_SIZE) |
| 1217 | usbhid->bufsize = HID_MAX_BUFFER_SIZE; |
Michael Haboustak | bf0964d | 2005-09-05 00:12:01 -0500 | [diff] [blame] | 1218 | |
| 1219 | hid_find_max_report(hid, HID_INPUT_REPORT, &insize); |
| 1220 | |
| 1221 | if (insize > HID_MAX_BUFFER_SIZE) |
| 1222 | insize = HID_MAX_BUFFER_SIZE; |
| 1223 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | if (hid_alloc_buffers(dev, hid)) { |
| 1225 | hid_free_buffers(dev, hid); |
| 1226 | goto fail; |
| 1227 | } |
| 1228 | |
| 1229 | for (n = 0; n < interface->desc.bNumEndpoints; n++) { |
| 1230 | |
| 1231 | struct usb_endpoint_descriptor *endpoint; |
| 1232 | int pipe; |
| 1233 | int interval; |
| 1234 | |
| 1235 | endpoint = &interface->endpoint[n].desc; |
| 1236 | if ((endpoint->bmAttributes & 3) != 3) /* Not an interrupt endpoint */ |
| 1237 | continue; |
| 1238 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | interval = endpoint->bInterval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | |
| 1241 | /* Change the polling interval of mice. */ |
| 1242 | if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) |
| 1243 | interval = hid_mousepoll_interval; |
Dmitry Torokhov | 05f091ab | 2005-05-29 02:29:01 -0500 | [diff] [blame] | 1244 | |
Luiz Fernando N. Capitulino | 0f12aa0 | 2006-10-26 13:02:51 -0300 | [diff] [blame] | 1245 | if (usb_endpoint_dir_in(endpoint)) { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1246 | if (usbhid->urbin) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | continue; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1248 | if (!(usbhid->urbin = usb_alloc_urb(0, GFP_KERNEL))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | goto fail; |
| 1250 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1251 | usb_fill_int_urb(usbhid->urbin, dev, pipe, usbhid->inbuf, insize, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | hid_irq_in, hid, interval); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1253 | usbhid->urbin->transfer_dma = usbhid->inbuf_dma; |
| 1254 | usbhid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | } else { |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1256 | if (usbhid->urbout) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | continue; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1258 | if (!(usbhid->urbout = usb_alloc_urb(0, GFP_KERNEL))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | goto fail; |
| 1260 | pipe = usb_sndintpipe(dev, endpoint->bEndpointAddress); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1261 | usb_fill_int_urb(usbhid->urbout, dev, pipe, usbhid->outbuf, 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | hid_irq_out, hid, interval); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1263 | usbhid->urbout->transfer_dma = usbhid->outbuf_dma; |
| 1264 | usbhid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | } |
| 1266 | } |
| 1267 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1268 | if (!usbhid->urbin) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | err("couldn't find an input interrupt endpoint"); |
| 1270 | goto fail; |
| 1271 | } |
| 1272 | |
| 1273 | init_waitqueue_head(&hid->wait); |
| 1274 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1275 | INIT_WORK(&usbhid->reset_work, hid_reset); |
| 1276 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 1277 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1278 | spin_lock_init(&usbhid->inlock); |
| 1279 | spin_lock_init(&usbhid->outlock); |
| 1280 | spin_lock_init(&usbhid->ctrllock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1281 | |
| 1282 | hid->version = le16_to_cpu(hdesc->bcdHID); |
| 1283 | hid->country = hdesc->bCountryCode; |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 1284 | hid->dev = &intf->dev; |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1285 | usbhid->intf = intf; |
| 1286 | usbhid->ifnum = interface->desc.bInterfaceNumber; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | |
| 1288 | hid->name[0] = 0; |
| 1289 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 1290 | if (dev->manufacturer) |
| 1291 | strlcpy(hid->name, dev->manufacturer, sizeof(hid->name)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 1293 | if (dev->product) { |
| 1294 | if (dev->manufacturer) |
| 1295 | strlcat(hid->name, " ", sizeof(hid->name)); |
| 1296 | strlcat(hid->name, dev->product, sizeof(hid->name)); |
| 1297 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 1299 | if (!strlen(hid->name)) |
| 1300 | snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x", |
| 1301 | le16_to_cpu(dev->descriptor.idVendor), |
| 1302 | le16_to_cpu(dev->descriptor.idProduct)); |
| 1303 | |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 1304 | hid->bus = BUS_USB; |
Julien BLACHE | 9fa2ad5f | 2007-02-11 18:20:25 +0100 | [diff] [blame] | 1305 | hid->vendor = le16_to_cpu(dev->descriptor.idVendor); |
| 1306 | hid->product = le16_to_cpu(dev->descriptor.idProduct); |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 1307 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 1308 | usb_make_path(dev, hid->phys, sizeof(hid->phys)); |
| 1309 | strlcat(hid->phys, "/input", sizeof(hid->phys)); |
| 1310 | len = strlen(hid->phys); |
| 1311 | if (len < sizeof(hid->phys) - 1) |
| 1312 | snprintf(hid->phys + len, sizeof(hid->phys) - len, |
| 1313 | "%d", intf->altsetting[0].desc.bInterfaceNumber); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | |
| 1315 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) |
| 1316 | hid->uniq[0] = 0; |
| 1317 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1318 | usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
| 1319 | if (!usbhid->urbctrl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | goto fail; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 1321 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1322 | usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr, |
| 1323 | usbhid->ctrlbuf, 1, hid_ctrl, hid); |
| 1324 | usbhid->urbctrl->setup_dma = usbhid->cr_dma; |
| 1325 | usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma; |
| 1326 | usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 1327 | hid->hidinput_input_event = usb_hidinput_input_event; |
Jiri Kosina | 7c37914 | 2007-01-24 11:54:19 +0100 | [diff] [blame] | 1328 | hid->hid_open = usbhid_open; |
| 1329 | hid->hid_close = usbhid_close; |
Jiri Kosina | aa938f7 | 2006-12-08 18:41:10 +0100 | [diff] [blame] | 1330 | #ifdef CONFIG_USB_HIDDEV |
| 1331 | hid->hiddev_hid_event = hiddev_hid_event; |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1332 | hid->hiddev_report_event = hiddev_report_event; |
Jiri Kosina | aa938f7 | 2006-12-08 18:41:10 +0100 | [diff] [blame] | 1333 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | return hid; |
| 1335 | |
| 1336 | fail: |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1337 | usb_free_urb(usbhid->urbin); |
| 1338 | usb_free_urb(usbhid->urbout); |
| 1339 | usb_free_urb(usbhid->urbctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | hid_free_buffers(dev, hid); |
| 1341 | hid_free_device(hid); |
| 1342 | |
| 1343 | return NULL; |
| 1344 | } |
| 1345 | |
| 1346 | static void hid_disconnect(struct usb_interface *intf) |
| 1347 | { |
| 1348 | struct hid_device *hid = usb_get_intfdata (intf); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1349 | struct usbhid_device *usbhid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | |
| 1351 | if (!hid) |
| 1352 | return; |
| 1353 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1354 | usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1356 | spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ |
| 1357 | usb_set_intfdata(intf, NULL); |
| 1358 | spin_unlock_irq(&usbhid->inlock); |
| 1359 | usb_kill_urb(usbhid->urbin); |
| 1360 | usb_kill_urb(usbhid->urbout); |
| 1361 | usb_kill_urb(usbhid->urbctrl); |
| 1362 | |
| 1363 | del_timer_sync(&usbhid->io_retry); |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 1364 | flush_scheduled_work(); |
| 1365 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1366 | if (hid->claimed & HID_CLAIMED_INPUT) |
| 1367 | hidinput_disconnect(hid); |
| 1368 | if (hid->claimed & HID_CLAIMED_HIDDEV) |
| 1369 | hiddev_disconnect(hid); |
| 1370 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1371 | usb_free_urb(usbhid->urbin); |
| 1372 | usb_free_urb(usbhid->urbctrl); |
| 1373 | usb_free_urb(usbhid->urbout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | |
Anssi Hannula | be82097 | 2007-01-19 19:28:17 +0200 | [diff] [blame] | 1375 | hid_free_buffers(hid_to_usb_dev(hid), hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1376 | hid_free_device(hid); |
| 1377 | } |
| 1378 | |
| 1379 | static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 1380 | { |
| 1381 | struct hid_device *hid; |
| 1382 | char path[64]; |
| 1383 | int i; |
| 1384 | char *c; |
| 1385 | |
| 1386 | dbg("HID probe called for ifnum %d", |
| 1387 | intf->altsetting->desc.bInterfaceNumber); |
| 1388 | |
| 1389 | if (!(hid = usb_hid_configure(intf))) |
Stelian Pop | 479f6ea | 2005-06-22 17:53:28 +0200 | [diff] [blame] | 1390 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1392 | usbhid_init_reports(hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | hid_dump_device(hid); |
Pete Zaitcev | 713c8aa | 2007-04-06 14:33:18 +0200 | [diff] [blame^] | 1394 | if (hid->quirks & HID_QUIRK_RESET_LEDS) |
| 1395 | usbhid_set_leds(hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1396 | |
| 1397 | if (!hidinput_connect(hid)) |
| 1398 | hid->claimed |= HID_CLAIMED_INPUT; |
| 1399 | if (!hiddev_connect(hid)) |
| 1400 | hid->claimed |= HID_CLAIMED_HIDDEV; |
| 1401 | |
| 1402 | usb_set_intfdata(intf, hid); |
| 1403 | |
| 1404 | if (!hid->claimed) { |
| 1405 | printk ("HID device not claimed by input or hiddev\n"); |
| 1406 | hid_disconnect(intf); |
Stelian Pop | 479f6ea | 2005-06-22 17:53:28 +0200 | [diff] [blame] | 1407 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | } |
| 1409 | |
Anssi Hannula | c414606 | 2007-01-11 16:51:16 +0200 | [diff] [blame] | 1410 | if ((hid->claimed & HID_CLAIMED_INPUT)) |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1411 | hid_ff_init(hid); |
| 1412 | |
Geoff Levand | 4a1a4d8 | 2007-01-15 20:11:52 -0800 | [diff] [blame] | 1413 | if (hid->quirks & HID_QUIRK_SONY_PS3_CONTROLLER) |
| 1414 | hid_fixup_sony_ps3_controller(interface_to_usbdev(intf), |
| 1415 | intf->cur_altsetting->desc.bInterfaceNumber); |
| 1416 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1417 | printk(KERN_INFO); |
| 1418 | |
| 1419 | if (hid->claimed & HID_CLAIMED_INPUT) |
| 1420 | printk("input"); |
| 1421 | if (hid->claimed == (HID_CLAIMED_INPUT | HID_CLAIMED_HIDDEV)) |
| 1422 | printk(","); |
| 1423 | if (hid->claimed & HID_CLAIMED_HIDDEV) |
| 1424 | printk("hiddev%d", hid->minor); |
| 1425 | |
| 1426 | c = "Device"; |
| 1427 | for (i = 0; i < hid->maxcollection; i++) { |
| 1428 | if (hid->collection[i].type == HID_COLLECTION_APPLICATION && |
| 1429 | (hid->collection[i].usage & HID_USAGE_PAGE) == HID_UP_GENDESK && |
| 1430 | (hid->collection[i].usage & 0xffff) < ARRAY_SIZE(hid_types)) { |
| 1431 | c = hid_types[hid->collection[i].usage & 0xffff]; |
| 1432 | break; |
| 1433 | } |
| 1434 | } |
| 1435 | |
| 1436 | usb_make_path(interface_to_usbdev(intf), path, 63); |
| 1437 | |
| 1438 | printk(": USB HID v%x.%02x %s [%s] on %s\n", |
| 1439 | hid->version >> 8, hid->version & 0xff, c, hid->name, path); |
| 1440 | |
| 1441 | return 0; |
| 1442 | } |
| 1443 | |
David Brownell | 27d72e8 | 2005-04-18 17:39:22 -0700 | [diff] [blame] | 1444 | static int hid_suspend(struct usb_interface *intf, pm_message_t message) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1445 | { |
| 1446 | struct hid_device *hid = usb_get_intfdata (intf); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1447 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1449 | spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ |
| 1450 | set_bit(HID_SUSPENDED, &usbhid->iofl); |
| 1451 | spin_unlock_irq(&usbhid->inlock); |
| 1452 | del_timer(&usbhid->io_retry); |
| 1453 | usb_kill_urb(usbhid->urbin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | dev_dbg(&intf->dev, "suspend\n"); |
| 1455 | return 0; |
| 1456 | } |
| 1457 | |
| 1458 | static int hid_resume(struct usb_interface *intf) |
| 1459 | { |
| 1460 | struct hid_device *hid = usb_get_intfdata (intf); |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1461 | struct usbhid_device *usbhid = hid->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | int status; |
| 1463 | |
Jiri Kosina | 4916b3a | 2006-12-08 18:41:03 +0100 | [diff] [blame] | 1464 | clear_bit(HID_SUSPENDED, &usbhid->iofl); |
| 1465 | usbhid->retry_delay = 0; |
Alan Stern | aef4e26 | 2006-01-31 12:58:38 -0500 | [diff] [blame] | 1466 | status = hid_start_in(hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | dev_dbg(&intf->dev, "resume status %d\n", status); |
| 1468 | return status; |
| 1469 | } |
| 1470 | |
Alan Stern | df9a1f4 | 2006-06-01 13:55:28 -0400 | [diff] [blame] | 1471 | /* Treat USB reset pretty much the same as suspend/resume */ |
| 1472 | static void hid_pre_reset(struct usb_interface *intf) |
| 1473 | { |
| 1474 | /* FIXME: What if the interface is already suspended? */ |
| 1475 | hid_suspend(intf, PMSG_ON); |
| 1476 | } |
| 1477 | |
| 1478 | static void hid_post_reset(struct usb_interface *intf) |
| 1479 | { |
| 1480 | struct usb_device *dev = interface_to_usbdev (intf); |
| 1481 | |
| 1482 | hid_set_idle(dev, intf->cur_altsetting->desc.bInterfaceNumber, 0, 0); |
| 1483 | /* FIXME: Any more reinitialization needed? */ |
| 1484 | |
| 1485 | hid_resume(intf); |
| 1486 | } |
| 1487 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | static struct usb_device_id hid_usb_ids [] = { |
| 1489 | { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, |
| 1490 | .bInterfaceClass = USB_INTERFACE_CLASS_HID }, |
| 1491 | { } /* Terminating entry */ |
| 1492 | }; |
| 1493 | |
| 1494 | MODULE_DEVICE_TABLE (usb, hid_usb_ids); |
| 1495 | |
| 1496 | static struct usb_driver hid_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | .name = "usbhid", |
| 1498 | .probe = hid_probe, |
| 1499 | .disconnect = hid_disconnect, |
| 1500 | .suspend = hid_suspend, |
| 1501 | .resume = hid_resume, |
Alan Stern | df9a1f4 | 2006-06-01 13:55:28 -0400 | [diff] [blame] | 1502 | .pre_reset = hid_pre_reset, |
| 1503 | .post_reset = hid_post_reset, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | .id_table = hid_usb_ids, |
| 1505 | }; |
| 1506 | |
| 1507 | static int __init hid_init(void) |
| 1508 | { |
| 1509 | int retval; |
| 1510 | retval = hiddev_init(); |
| 1511 | if (retval) |
| 1512 | goto hiddev_init_fail; |
| 1513 | retval = usb_register(&hid_driver); |
| 1514 | if (retval) |
| 1515 | goto usb_register_fail; |
| 1516 | info(DRIVER_VERSION ":" DRIVER_DESC); |
| 1517 | |
| 1518 | return 0; |
| 1519 | usb_register_fail: |
| 1520 | hiddev_exit(); |
| 1521 | hiddev_init_fail: |
| 1522 | return retval; |
| 1523 | } |
| 1524 | |
| 1525 | static void __exit hid_exit(void) |
| 1526 | { |
| 1527 | usb_deregister(&hid_driver); |
| 1528 | hiddev_exit(); |
| 1529 | } |
| 1530 | |
| 1531 | module_init(hid_init); |
| 1532 | module_exit(hid_exit); |
| 1533 | |
| 1534 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 1535 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 1536 | MODULE_LICENSE(DRIVER_LICENSE); |