1 /* 2 * HID driver for Kye/Genius devices not fully compliant with HID standard 3 * 4 * Copyright (c) 2009 Jiri Kosina 5 * Copyright (c) 2009 Tomas Hanak 6 * Copyright (c) 2012 Nikolai Kondrashov 7 */ 8 9 /* 10 * This program is free software; you can redistribute it and/or modify it 11 * under the terms of the GNU General Public License as published by the Free 12 * Software Foundation; either version 2 of the License, or (at your option) 13 * any later version. 14 */ 15 16 #include <linux/device.h> 17 #include <linux/hid.h> 18 #include <linux/module.h> 19 20 #include "hid-ids.h" 21 22 /* Original EasyPen i405X report descriptor size */ 23 #define EASYPEN_I405X_RDESC_ORIG_SIZE 476 24 25 /* Fixed EasyPen i405X report descriptor */ 26 static __u8 easypen_i405x_rdesc_fixed[] = { 27 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 28 0x09, 0x01, /* Usage (01h), */ 29 0xA1, 0x01, /* Collection (Application), */ 30 0x85, 0x05, /* Report ID (5), */ 31 0x09, 0x01, /* Usage (01h), */ 32 0x15, 0x80, /* Logical Minimum (-128), */ 33 0x25, 0x7F, /* Logical Maximum (127), */ 34 0x75, 0x08, /* Report Size (8), */ 35 0x95, 0x07, /* Report Count (7), */ 36 0xB1, 0x02, /* Feature (Variable), */ 37 0xC0, /* End Collection, */ 38 0x05, 0x0D, /* Usage Page (Digitizer), */ 39 0x09, 0x02, /* Usage (Pen), */ 40 0xA1, 0x01, /* Collection (Application), */ 41 0x85, 0x10, /* Report ID (16), */ 42 0x09, 0x20, /* Usage (Stylus), */ 43 0xA0, /* Collection (Physical), */ 44 0x14, /* Logical Minimum (0), */ 45 0x25, 0x01, /* Logical Maximum (1), */ 46 0x75, 0x01, /* Report Size (1), */ 47 0x09, 0x42, /* Usage (Tip Switch), */ 48 0x09, 0x44, /* Usage (Barrel Switch), */ 49 0x09, 0x46, /* Usage (Tablet Pick), */ 50 0x95, 0x03, /* Report Count (3), */ 51 0x81, 0x02, /* Input (Variable), */ 52 0x95, 0x04, /* Report Count (4), */ 53 0x81, 0x03, /* Input (Constant, Variable), */ 54 0x09, 0x32, /* Usage (In Range), */ 55 0x95, 0x01, /* Report Count (1), */ 56 0x81, 0x02, /* Input (Variable), */ 57 0x75, 0x10, /* Report Size (16), */ 58 0x95, 0x01, /* Report Count (1), */ 59 0xA4, /* Push, */ 60 0x05, 0x01, /* Usage Page (Desktop), */ 61 0x55, 0xFD, /* Unit Exponent (-3), */ 62 0x65, 0x13, /* Unit (Inch), */ 63 0x34, /* Physical Minimum (0), */ 64 0x09, 0x30, /* Usage (X), */ 65 0x46, 0x7C, 0x15, /* Physical Maximum (5500), */ 66 0x26, 0x00, 0x37, /* Logical Maximum (14080), */ 67 0x81, 0x02, /* Input (Variable), */ 68 0x09, 0x31, /* Usage (Y), */ 69 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */ 70 0x26, 0x00, 0x28, /* Logical Maximum (10240), */ 71 0x81, 0x02, /* Input (Variable), */ 72 0xB4, /* Pop, */ 73 0x09, 0x30, /* Usage (Tip Pressure), */ 74 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ 75 0x81, 0x02, /* Input (Variable), */ 76 0xC0, /* End Collection, */ 77 0xC0 /* End Collection */ 78 }; 79 80 /* Original MousePen i608X report descriptor size */ 81 #define MOUSEPEN_I608X_RDESC_ORIG_SIZE 476 82 83 /* Fixed MousePen i608X report descriptor */ 84 static __u8 mousepen_i608x_rdesc_fixed[] = { 85 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 86 0x09, 0x01, /* Usage (01h), */ 87 0xA1, 0x01, /* Collection (Application), */ 88 0x85, 0x05, /* Report ID (5), */ 89 0x09, 0x01, /* Usage (01h), */ 90 0x15, 0x80, /* Logical Minimum (-128), */ 91 0x25, 0x7F, /* Logical Maximum (127), */ 92 0x75, 0x08, /* Report Size (8), */ 93 0x95, 0x07, /* Report Count (7), */ 94 0xB1, 0x02, /* Feature (Variable), */ 95 0xC0, /* End Collection, */ 96 0x05, 0x0D, /* Usage Page (Digitizer), */ 97 0x09, 0x02, /* Usage (Pen), */ 98 0xA1, 0x01, /* Collection (Application), */ 99 0x85, 0x10, /* Report ID (16), */ 100 0x09, 0x20, /* Usage (Stylus), */ 101 0xA0, /* Collection (Physical), */ 102 0x14, /* Logical Minimum (0), */ 103 0x25, 0x01, /* Logical Maximum (1), */ 104 0x75, 0x01, /* Report Size (1), */ 105 0x09, 0x42, /* Usage (Tip Switch), */ 106 0x09, 0x44, /* Usage (Barrel Switch), */ 107 0x09, 0x46, /* Usage (Tablet Pick), */ 108 0x95, 0x03, /* Report Count (3), */ 109 0x81, 0x02, /* Input (Variable), */ 110 0x95, 0x04, /* Report Count (4), */ 111 0x81, 0x03, /* Input (Constant, Variable), */ 112 0x09, 0x32, /* Usage (In Range), */ 113 0x95, 0x01, /* Report Count (1), */ 114 0x81, 0x02, /* Input (Variable), */ 115 0x75, 0x10, /* Report Size (16), */ 116 0x95, 0x01, /* Report Count (1), */ 117 0xA4, /* Push, */ 118 0x05, 0x01, /* Usage Page (Desktop), */ 119 0x55, 0xFD, /* Unit Exponent (-3), */ 120 0x65, 0x13, /* Unit (Inch), */ 121 0x34, /* Physical Minimum (0), */ 122 0x09, 0x30, /* Usage (X), */ 123 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */ 124 0x26, 0x00, 0x50, /* Logical Maximum (20480), */ 125 0x81, 0x02, /* Input (Variable), */ 126 0x09, 0x31, /* Usage (Y), */ 127 0x46, 0x70, 0x17, /* Physical Maximum (6000), */ 128 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */ 129 0x81, 0x02, /* Input (Variable), */ 130 0xB4, /* Pop, */ 131 0x09, 0x30, /* Usage (Tip Pressure), */ 132 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ 133 0x81, 0x02, /* Input (Variable), */ 134 0xC0, /* End Collection, */ 135 0xC0, /* End Collection, */ 136 0x05, 0x01, /* Usage Page (Desktop), */ 137 0x09, 0x02, /* Usage (Mouse), */ 138 0xA1, 0x01, /* Collection (Application), */ 139 0x85, 0x11, /* Report ID (17), */ 140 0x09, 0x01, /* Usage (Pointer), */ 141 0xA0, /* Collection (Physical), */ 142 0x14, /* Logical Minimum (0), */ 143 0xA4, /* Push, */ 144 0x05, 0x09, /* Usage Page (Button), */ 145 0x75, 0x01, /* Report Size (1), */ 146 0x19, 0x01, /* Usage Minimum (01h), */ 147 0x29, 0x03, /* Usage Maximum (03h), */ 148 0x25, 0x01, /* Logical Maximum (1), */ 149 0x95, 0x03, /* Report Count (3), */ 150 0x81, 0x02, /* Input (Variable), */ 151 0x95, 0x05, /* Report Count (5), */ 152 0x81, 0x01, /* Input (Constant), */ 153 0xB4, /* Pop, */ 154 0x95, 0x01, /* Report Count (1), */ 155 0xA4, /* Push, */ 156 0x55, 0xFD, /* Unit Exponent (-3), */ 157 0x65, 0x13, /* Unit (Inch), */ 158 0x34, /* Physical Minimum (0), */ 159 0x75, 0x10, /* Report Size (16), */ 160 0x09, 0x30, /* Usage (X), */ 161 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */ 162 0x26, 0x00, 0x50, /* Logical Maximum (20480), */ 163 0x81, 0x02, /* Input (Variable), */ 164 0x09, 0x31, /* Usage (Y), */ 165 0x46, 0x70, 0x17, /* Physical Maximum (6000), */ 166 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */ 167 0x81, 0x02, /* Input (Variable), */ 168 0xB4, /* Pop, */ 169 0x75, 0x08, /* Report Size (8), */ 170 0x09, 0x38, /* Usage (Wheel), */ 171 0x15, 0xFF, /* Logical Minimum (-1), */ 172 0x25, 0x01, /* Logical Maximum (1), */ 173 0x81, 0x06, /* Input (Variable, Relative), */ 174 0x81, 0x01, /* Input (Constant), */ 175 0xC0, /* End Collection, */ 176 0xC0 /* End Collection */ 177 }; 178 179 /* Original MousePen i608X v2 report descriptor size */ 180 #define MOUSEPEN_I608X_V2_RDESC_ORIG_SIZE 482 181 182 /* Fixed MousePen i608X v2 report descriptor */ 183 static __u8 mousepen_i608x_v2_rdesc_fixed[] = { 184 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 185 0x09, 0x01, /* Usage (01h), */ 186 0xA1, 0x01, /* Collection (Application), */ 187 0x85, 0x05, /* Report ID (5), */ 188 0x09, 0x01, /* Usage (01h), */ 189 0x15, 0x80, /* Logical Minimum (-128), */ 190 0x25, 0x7F, /* Logical Maximum (127), */ 191 0x75, 0x08, /* Report Size (8), */ 192 0x95, 0x07, /* Report Count (7), */ 193 0xB1, 0x02, /* Feature (Variable), */ 194 0xC0, /* End Collection, */ 195 0x05, 0x0D, /* Usage Page (Digitizer), */ 196 0x09, 0x02, /* Usage (Pen), */ 197 0xA1, 0x01, /* Collection (Application), */ 198 0x85, 0x10, /* Report ID (16), */ 199 0x09, 0x20, /* Usage (Stylus), */ 200 0xA0, /* Collection (Physical), */ 201 0x14, /* Logical Minimum (0), */ 202 0x25, 0x01, /* Logical Maximum (1), */ 203 0x75, 0x01, /* Report Size (1), */ 204 0x09, 0x42, /* Usage (Tip Switch), */ 205 0x09, 0x44, /* Usage (Barrel Switch), */ 206 0x09, 0x46, /* Usage (Tablet Pick), */ 207 0x95, 0x03, /* Report Count (3), */ 208 0x81, 0x02, /* Input (Variable), */ 209 0x95, 0x04, /* Report Count (4), */ 210 0x81, 0x03, /* Input (Constant, Variable), */ 211 0x09, 0x32, /* Usage (In Range), */ 212 0x95, 0x01, /* Report Count (1), */ 213 0x81, 0x02, /* Input (Variable), */ 214 0x75, 0x10, /* Report Size (16), */ 215 0x95, 0x01, /* Report Count (1), */ 216 0xA4, /* Push, */ 217 0x05, 0x01, /* Usage Page (Desktop), */ 218 0x55, 0xFD, /* Unit Exponent (-3), */ 219 0x65, 0x13, /* Unit (Inch), */ 220 0x34, /* Physical Minimum (0), */ 221 0x09, 0x30, /* Usage (X), */ 222 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */ 223 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */ 224 0x81, 0x02, /* Input (Variable), */ 225 0x09, 0x31, /* Usage (Y), */ 226 0x46, 0x70, 0x17, /* Physical Maximum (6000), */ 227 0x26, 0x00, 0x78, /* Logical Maximum (30720), */ 228 0x81, 0x02, /* Input (Variable), */ 229 0xB4, /* Pop, */ 230 0x09, 0x30, /* Usage (Tip Pressure), */ 231 0x26, 0xFF, 0x07, /* Logical Maximum (2047), */ 232 0x81, 0x02, /* Input (Variable), */ 233 0xC0, /* End Collection, */ 234 0xC0, /* End Collection, */ 235 0x05, 0x01, /* Usage Page (Desktop), */ 236 0x09, 0x02, /* Usage (Mouse), */ 237 0xA1, 0x01, /* Collection (Application), */ 238 0x85, 0x11, /* Report ID (17), */ 239 0x09, 0x01, /* Usage (Pointer), */ 240 0xA0, /* Collection (Physical), */ 241 0x14, /* Logical Minimum (0), */ 242 0xA4, /* Push, */ 243 0x05, 0x09, /* Usage Page (Button), */ 244 0x75, 0x01, /* Report Size (1), */ 245 0x19, 0x01, /* Usage Minimum (01h), */ 246 0x29, 0x03, /* Usage Maximum (03h), */ 247 0x25, 0x01, /* Logical Maximum (1), */ 248 0x95, 0x03, /* Report Count (3), */ 249 0x81, 0x02, /* Input (Variable), */ 250 0x95, 0x05, /* Report Count (5), */ 251 0x81, 0x01, /* Input (Constant), */ 252 0xB4, /* Pop, */ 253 0x95, 0x01, /* Report Count (1), */ 254 0xA4, /* Push, */ 255 0x55, 0xFD, /* Unit Exponent (-3), */ 256 0x65, 0x13, /* Unit (Inch), */ 257 0x34, /* Physical Minimum (0), */ 258 0x75, 0x10, /* Report Size (16), */ 259 0x09, 0x30, /* Usage (X), */ 260 0x46, 0x40, 0x1F, /* Physical Maximum (8000), */ 261 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */ 262 0x81, 0x02, /* Input (Variable), */ 263 0x09, 0x31, /* Usage (Y), */ 264 0x46, 0x70, 0x17, /* Physical Maximum (6000), */ 265 0x26, 0x00, 0x78, /* Logical Maximum (30720), */ 266 0x81, 0x02, /* Input (Variable), */ 267 0xB4, /* Pop, */ 268 0x75, 0x08, /* Report Size (8), */ 269 0x09, 0x38, /* Usage (Wheel), */ 270 0x15, 0xFF, /* Logical Minimum (-1), */ 271 0x25, 0x01, /* Logical Maximum (1), */ 272 0x81, 0x06, /* Input (Variable, Relative), */ 273 0x81, 0x01, /* Input (Constant), */ 274 0xC0, /* End Collection, */ 275 0xC0 /* End Collection */ 276 }; 277 278 /* Original EasyPen M610X report descriptor size */ 279 #define EASYPEN_M610X_RDESC_ORIG_SIZE 476 280 281 /* Fixed EasyPen M610X report descriptor */ 282 static __u8 easypen_m610x_rdesc_fixed[] = { 283 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 284 0x09, 0x01, /* Usage (01h), */ 285 0xA1, 0x01, /* Collection (Application), */ 286 0x85, 0x05, /* Report ID (5), */ 287 0x09, 0x01, /* Usage (01h), */ 288 0x15, 0x80, /* Logical Minimum (-128), */ 289 0x25, 0x7F, /* Logical Maximum (127), */ 290 0x75, 0x08, /* Report Size (8), */ 291 0x95, 0x07, /* Report Count (7), */ 292 0xB1, 0x02, /* Feature (Variable), */ 293 0xC0, /* End Collection, */ 294 0x05, 0x0D, /* Usage Page (Digitizer), */ 295 0x09, 0x02, /* Usage (Pen), */ 296 0xA1, 0x01, /* Collection (Application), */ 297 0x85, 0x10, /* Report ID (16), */ 298 0x09, 0x20, /* Usage (Stylus), */ 299 0xA0, /* Collection (Physical), */ 300 0x14, /* Logical Minimum (0), */ 301 0x25, 0x01, /* Logical Maximum (1), */ 302 0x75, 0x01, /* Report Size (1), */ 303 0x09, 0x42, /* Usage (Tip Switch), */ 304 0x09, 0x44, /* Usage (Barrel Switch), */ 305 0x09, 0x46, /* Usage (Tablet Pick), */ 306 0x95, 0x03, /* Report Count (3), */ 307 0x81, 0x02, /* Input (Variable), */ 308 0x95, 0x04, /* Report Count (4), */ 309 0x81, 0x03, /* Input (Constant, Variable), */ 310 0x09, 0x32, /* Usage (In Range), */ 311 0x95, 0x01, /* Report Count (1), */ 312 0x81, 0x02, /* Input (Variable), */ 313 0x75, 0x10, /* Report Size (16), */ 314 0x95, 0x01, /* Report Count (1), */ 315 0xA4, /* Push, */ 316 0x05, 0x01, /* Usage Page (Desktop), */ 317 0x55, 0xFD, /* Unit Exponent (-3), */ 318 0x65, 0x13, /* Unit (Inch), */ 319 0x34, /* Physical Minimum (0), */ 320 0x09, 0x30, /* Usage (X), */ 321 0x46, 0x10, 0x27, /* Physical Maximum (10000), */ 322 0x27, 0x00, 0xA0, 0x00, 0x00, /* Logical Maximum (40960), */ 323 0x81, 0x02, /* Input (Variable), */ 324 0x09, 0x31, /* Usage (Y), */ 325 0x46, 0x6A, 0x18, /* Physical Maximum (6250), */ 326 0x26, 0x00, 0x64, /* Logical Maximum (25600), */ 327 0x81, 0x02, /* Input (Variable), */ 328 0xB4, /* Pop, */ 329 0x09, 0x30, /* Usage (Tip Pressure), */ 330 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ 331 0x81, 0x02, /* Input (Variable), */ 332 0xC0, /* End Collection, */ 333 0xC0, /* End Collection, */ 334 0x05, 0x0C, /* Usage Page (Consumer), */ 335 0x09, 0x01, /* Usage (Consumer Control), */ 336 0xA1, 0x01, /* Collection (Application), */ 337 0x85, 0x12, /* Report ID (18), */ 338 0x14, /* Logical Minimum (0), */ 339 0x25, 0x01, /* Logical Maximum (1), */ 340 0x75, 0x01, /* Report Size (1), */ 341 0x95, 0x04, /* Report Count (4), */ 342 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */ 343 0x0A, 0x79, 0x02, /* Usage (AC Redo Or Repeat), */ 344 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */ 345 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */ 346 0x81, 0x02, /* Input (Variable), */ 347 0x95, 0x01, /* Report Count (1), */ 348 0x75, 0x14, /* Report Size (20), */ 349 0x81, 0x03, /* Input (Constant, Variable), */ 350 0x75, 0x20, /* Report Size (32), */ 351 0x81, 0x03, /* Input (Constant, Variable), */ 352 0xC0 /* End Collection */ 353 }; 354 355 356 /* Original PenSketch M912 report descriptor size */ 357 #define PENSKETCH_M912_RDESC_ORIG_SIZE 482 358 359 /* Fixed PenSketch M912 report descriptor */ 360 static __u8 pensketch_m912_rdesc_fixed[] = { 361 0x05, 0x01, /* Usage Page (Desktop), */ 362 0x08, /* Usage (00h), */ 363 0xA1, 0x01, /* Collection (Application), */ 364 0x85, 0x05, /* Report ID (5), */ 365 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 366 0x09, 0x01, /* Usage (01h), */ 367 0x15, 0x81, /* Logical Minimum (-127), */ 368 0x25, 0x7F, /* Logical Maximum (127), */ 369 0x75, 0x08, /* Report Size (8), */ 370 0x95, 0x07, /* Report Count (7), */ 371 0xB1, 0x02, /* Feature (Variable), */ 372 0xC0, /* End Collection, */ 373 0x05, 0x0D, /* Usage Page (Digitizer), */ 374 0x09, 0x02, /* Usage (Pen), */ 375 0xA1, 0x01, /* Collection (Application), */ 376 0x85, 0x10, /* Report ID (16), */ 377 0x09, 0x20, /* Usage (Stylus), */ 378 0xA0, /* Collection (Physical), */ 379 0x09, 0x42, /* Usage (Tip Switch), */ 380 0x09, 0x44, /* Usage (Barrel Switch), */ 381 0x09, 0x46, /* Usage (Tablet Pick), */ 382 0x14, /* Logical Minimum (0), */ 383 0x25, 0x01, /* Logical Maximum (1), */ 384 0x75, 0x01, /* Report Size (1), */ 385 0x95, 0x03, /* Report Count (3), */ 386 0x81, 0x02, /* Input (Variable), */ 387 0x95, 0x04, /* Report Count (4), */ 388 0x81, 0x03, /* Input (Constant, Variable), */ 389 0x09, 0x32, /* Usage (In Range), */ 390 0x95, 0x01, /* Report Count (1), */ 391 0x81, 0x02, /* Input (Variable), */ 392 0x75, 0x10, /* Report Size (16), */ 393 0x95, 0x01, /* Report Count (1), */ 394 0xA4, /* Push, */ 395 0x05, 0x01, /* Usage Page (Desktop), */ 396 0x55, 0xFD, /* Unit Exponent (-3), */ 397 0x65, 0x13, /* Unit (Inch), */ 398 0x14, /* Logical Minimum (0), */ 399 0x34, /* Physical Minimum (0), */ 400 0x09, 0x30, /* Usage (X), */ 401 0x27, 0x00, 0xF0, 0x00, 0x00, /* Logical Maximum (61440), */ 402 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */ 403 0x81, 0x02, /* Input (Variable), */ 404 0x09, 0x31, /* Usage (Y), */ 405 0x27, 0x00, 0xB4, 0x00, 0x00, /* Logical Maximum (46080), */ 406 0x46, 0x28, 0x23, /* Physical Maximum (9000), */ 407 0x81, 0x02, /* Input (Variable), */ 408 0xB4, /* Pop, */ 409 0x09, 0x30, /* Usage (Tip Pressure), */ 410 0x14, /* Logical Minimum (0), */ 411 0x26, 0xFF, 0x07, /* Logical Maximum (2047), */ 412 0x81, 0x02, /* Input (Variable), */ 413 0xC0, /* End Collection, */ 414 0xC0, /* End Collection, */ 415 0x05, 0x0D, /* Usage Page (Digitizer), */ 416 0x09, 0x21, /* Usage (Puck), */ 417 0xA1, 0x01, /* Collection (Application), */ 418 0x85, 0x11, /* Report ID (17), */ 419 0x09, 0x21, /* Usage (Puck), */ 420 0xA0, /* Collection (Physical), */ 421 0x05, 0x09, /* Usage Page (Button), */ 422 0x75, 0x01, /* Report Size (1), */ 423 0x19, 0x01, /* Usage Minimum (01h), */ 424 0x29, 0x03, /* Usage Maximum (03h), */ 425 0x14, /* Logical Minimum (0), */ 426 0x25, 0x01, /* Logical Maximum (1), */ 427 0x95, 0x03, /* Report Count (3), */ 428 0x81, 0x02, /* Input (Variable), */ 429 0x95, 0x04, /* Report Count (4), */ 430 0x81, 0x01, /* Input (Constant), */ 431 0x95, 0x01, /* Report Count (1), */ 432 0x0B, 0x32, 0x00, 0x0D, 0x00, /* Usage (Digitizer In Range), */ 433 0x14, /* Logical Minimum (0), */ 434 0x25, 0x01, /* Logical Maximum (1), */ 435 0x81, 0x02, /* Input (Variable), */ 436 0xA4, /* Push, */ 437 0x05, 0x01, /* Usage Page (Desktop), */ 438 0x75, 0x10, /* Report Size (16), */ 439 0x95, 0x01, /* Report Count (1), */ 440 0x55, 0xFD, /* Unit Exponent (-3), */ 441 0x65, 0x13, /* Unit (Inch), */ 442 0x14, /* Logical Minimum (0), */ 443 0x34, /* Physical Minimum (0), */ 444 0x09, 0x30, /* Usage (X), */ 445 0x27, 0x00, 0xF0, 0x00, 0x00, /* Logical Maximum (61440), */ 446 0x46, 0xE0, 0x2E, /* Physical Maximum (12000), */ 447 0x81, 0x02, /* Input (Variable), */ 448 0x09, 0x31, /* Usage (Y), */ 449 0x27, 0x00, 0xB4, 0x00, 0x00, /* Logical Maximum (46080), */ 450 0x46, 0x28, 0x23, /* Physical Maximum (9000), */ 451 0x81, 0x02, /* Input (Variable), */ 452 0x09, 0x38, /* Usage (Wheel), */ 453 0x75, 0x08, /* Report Size (8), */ 454 0x95, 0x01, /* Report Count (1), */ 455 0x15, 0xFF, /* Logical Minimum (-1), */ 456 0x25, 0x01, /* Logical Maximum (1), */ 457 0x34, /* Physical Minimum (0), */ 458 0x44, /* Physical Maximum (0), */ 459 0x81, 0x06, /* Input (Variable, Relative), */ 460 0xB4, /* Pop, */ 461 0xC0, /* End Collection, */ 462 0xC0, /* End Collection, */ 463 0x05, 0x0C, /* Usage Page (Consumer), */ 464 0x09, 0x01, /* Usage (Consumer Control), */ 465 0xA1, 0x01, /* Collection (Application), */ 466 0x85, 0x12, /* Report ID (18), */ 467 0x14, /* Logical Minimum (0), */ 468 0x25, 0x01, /* Logical Maximum (1), */ 469 0x75, 0x01, /* Report Size (1), */ 470 0x95, 0x08, /* Report Count (8), */ 471 0x05, 0x0C, /* Usage Page (Consumer), */ 472 0x0A, 0x6A, 0x02, /* Usage (AC Delete), */ 473 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */ 474 0x0A, 0x01, 0x02, /* Usage (AC New), */ 475 0x0A, 0x2F, 0x02, /* Usage (AC Zoom), */ 476 0x0A, 0x25, 0x02, /* Usage (AC Forward), */ 477 0x0A, 0x24, 0x02, /* Usage (AC Back), */ 478 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */ 479 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */ 480 0x81, 0x02, /* Input (Variable), */ 481 0x95, 0x30, /* Report Count (48), */ 482 0x81, 0x03, /* Input (Constant, Variable), */ 483 0xC0 /* End Collection */ 484 }; 485 486 /* Original EasyPen M406XE report descriptor size */ 487 #define EASYPEN_M406XE_RDESC_ORIG_SIZE 476 488 489 /* Fixed EasyPen M406XE report descriptor */ 490 static __u8 easypen_m406xe_rdesc_fixed[] = { 491 0x05, 0x01, /* Usage Page (Desktop), */ 492 0x09, 0x01, /* Usage (01h), */ 493 0xA1, 0x01, /* Collection (Application), */ 494 0x85, 0x05, /* Report ID (5), */ 495 0x09, 0x01, /* Usage (01h), */ 496 0x15, 0x80, /* Logical Minimum (-128), */ 497 0x25, 0x7F, /* Logical Maximum (127), */ 498 0x75, 0x08, /* Report Size (8), */ 499 0x95, 0x07, /* Report Count (7), */ 500 0xB1, 0x02, /* Feature (Variable), */ 501 0xC0, /* End Collection, */ 502 0x05, 0x0D, /* Usage Page (Digitizer), */ 503 0x09, 0x02, /* Usage (Pen), */ 504 0xA1, 0x01, /* Collection (Application), */ 505 0x85, 0x10, /* Report ID (16), */ 506 0x09, 0x20, /* Usage (Stylus), */ 507 0xA0, /* Collection (Physical), */ 508 0x14, /* Logical Minimum (0), */ 509 0x25, 0x01, /* Logical Maximum (1), */ 510 0x75, 0x01, /* Report Size (1), */ 511 0x09, 0x42, /* Usage (Tip Switch), */ 512 0x09, 0x44, /* Usage (Barrel Switch), */ 513 0x09, 0x46, /* Usage (Tablet Pick), */ 514 0x95, 0x03, /* Report Count (3), */ 515 0x81, 0x02, /* Input (Variable), */ 516 0x95, 0x04, /* Report Count (4), */ 517 0x81, 0x03, /* Input (Constant, Variable), */ 518 0x09, 0x32, /* Usage (In Range), */ 519 0x95, 0x01, /* Report Count (1), */ 520 0x81, 0x02, /* Input (Variable), */ 521 0x75, 0x10, /* Report Size (16), */ 522 0x95, 0x01, /* Report Count (1), */ 523 0xA4, /* Push, */ 524 0x05, 0x01, /* Usage Page (Desktop), */ 525 0x55, 0xFD, /* Unit Exponent (-3), */ 526 0x65, 0x13, /* Unit (Inch), */ 527 0x34, /* Physical Minimum (0), */ 528 0x09, 0x30, /* Usage (X), */ 529 0x46, 0x70, 0x17, /* Physical Maximum (6000), */ 530 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */ 531 0x81, 0x02, /* Input (Variable), */ 532 0x09, 0x31, /* Usage (Y), */ 533 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */ 534 0x26, 0x00, 0x28, /* Logical Maximum (10240), */ 535 0x81, 0x02, /* Input (Variable), */ 536 0xB4, /* Pop, */ 537 0x09, 0x30, /* Usage (Tip Pressure), */ 538 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ 539 0x81, 0x02, /* Input (Variable), */ 540 0xC0, /* End Collection, */ 541 0xC0, /* End Collection */ 542 0x05, 0x0C, /* Usage Page (Consumer), */ 543 0x09, 0x01, /* Usage (Consumer Control), */ 544 0xA1, 0x01, /* Collection (Application), */ 545 0x85, 0x12, /* Report ID (18), */ 546 0x14, /* Logical Minimum (0), */ 547 0x25, 0x01, /* Logical Maximum (1), */ 548 0x75, 0x01, /* Report Size (1), */ 549 0x95, 0x04, /* Report Count (4), */ 550 0x0A, 0x79, 0x02, /* Usage (AC Redo Or Repeat), */ 551 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */ 552 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */ 553 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */ 554 0x81, 0x02, /* Input (Variable), */ 555 0x95, 0x34, /* Report Count (52), */ 556 0x81, 0x03, /* Input (Constant, Variable), */ 557 0xC0 /* End Collection */ 558 }; 559 560 static __u8 *kye_consumer_control_fixup(struct hid_device *hdev, __u8 *rdesc, 561 unsigned int *rsize, int offset, const char *device_name) { 562 /* 563 * the fixup that need to be done: 564 * - change Usage Maximum in the Consumer Control 565 * (report ID 3) to a reasonable value 566 */ 567 if (*rsize >= offset + 31 && 568 /* Usage Page (Consumer Devices) */ 569 rdesc[offset] == 0x05 && rdesc[offset + 1] == 0x0c && 570 /* Usage (Consumer Control) */ 571 rdesc[offset + 2] == 0x09 && rdesc[offset + 3] == 0x01 && 572 /* Usage Maximum > 12287 */ 573 rdesc[offset + 10] == 0x2a && rdesc[offset + 12] > 0x2f) { 574 hid_info(hdev, "fixing up %s report descriptor\n", device_name); 575 rdesc[offset + 12] = 0x2f; 576 } 577 return rdesc; 578 } 579 580 static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc, 581 unsigned int *rsize) 582 { 583 switch (hdev->product) { 584 case USB_DEVICE_ID_KYE_ERGO_525V: 585 /* the fixups that need to be done: 586 * - change led usage page to button for extra buttons 587 * - report size 8 count 1 must be size 1 count 8 for button 588 * bitfield 589 * - change the button usage range to 4-7 for the extra 590 * buttons 591 */ 592 if (*rsize >= 75 && 593 rdesc[61] == 0x05 && rdesc[62] == 0x08 && 594 rdesc[63] == 0x19 && rdesc[64] == 0x08 && 595 rdesc[65] == 0x29 && rdesc[66] == 0x0f && 596 rdesc[71] == 0x75 && rdesc[72] == 0x08 && 597 rdesc[73] == 0x95 && rdesc[74] == 0x01) { 598 hid_info(hdev, 599 "fixing up Kye/Genius Ergo Mouse " 600 "report descriptor\n"); 601 rdesc[62] = 0x09; 602 rdesc[64] = 0x04; 603 rdesc[66] = 0x07; 604 rdesc[72] = 0x01; 605 rdesc[74] = 0x08; 606 } 607 break; 608 case USB_DEVICE_ID_KYE_EASYPEN_I405X: 609 if (*rsize == EASYPEN_I405X_RDESC_ORIG_SIZE) { 610 rdesc = easypen_i405x_rdesc_fixed; 611 *rsize = sizeof(easypen_i405x_rdesc_fixed); 612 } 613 break; 614 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: 615 if (*rsize == MOUSEPEN_I608X_RDESC_ORIG_SIZE) { 616 rdesc = mousepen_i608x_rdesc_fixed; 617 *rsize = sizeof(mousepen_i608x_rdesc_fixed); 618 } 619 break; 620 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2: 621 if (*rsize == MOUSEPEN_I608X_V2_RDESC_ORIG_SIZE) { 622 rdesc = mousepen_i608x_v2_rdesc_fixed; 623 *rsize = sizeof(mousepen_i608x_v2_rdesc_fixed); 624 } 625 break; 626 case USB_DEVICE_ID_KYE_EASYPEN_M610X: 627 if (*rsize == EASYPEN_M610X_RDESC_ORIG_SIZE) { 628 rdesc = easypen_m610x_rdesc_fixed; 629 *rsize = sizeof(easypen_m610x_rdesc_fixed); 630 } 631 break; 632 case USB_DEVICE_ID_KYE_EASYPEN_M406XE: 633 if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) { 634 rdesc = easypen_m406xe_rdesc_fixed; 635 *rsize = sizeof(easypen_m406xe_rdesc_fixed); 636 } 637 break; 638 case USB_DEVICE_ID_KYE_PENSKETCH_M912: 639 if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) { 640 rdesc = pensketch_m912_rdesc_fixed; 641 *rsize = sizeof(pensketch_m912_rdesc_fixed); 642 } 643 break; 644 case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE: 645 rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104, 646 "Genius Gila Gaming Mouse"); 647 break; 648 case USB_DEVICE_ID_GENIUS_GX_IMPERATOR: 649 rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 83, 650 "Genius Gx Imperator Keyboard"); 651 break; 652 case USB_DEVICE_ID_GENIUS_MANTICORE: 653 rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104, 654 "Genius Manticore Keyboard"); 655 break; 656 } 657 return rdesc; 658 } 659 660 /** 661 * Enable fully-functional tablet mode by setting a special feature report. 662 * 663 * @hdev: HID device 664 * 665 * The specific report ID and data were discovered by sniffing the 666 * Windows driver traffic. 667 */ 668 static int kye_tablet_enable(struct hid_device *hdev) 669 { 670 struct list_head *list; 671 struct list_head *head; 672 struct hid_report *report; 673 __s32 *value; 674 675 list = &hdev->report_enum[HID_FEATURE_REPORT].report_list; 676 list_for_each(head, list) { 677 report = list_entry(head, struct hid_report, list); 678 if (report->id == 5) 679 break; 680 } 681 682 if (head == list) { 683 hid_err(hdev, "tablet-enabling feature report not found\n"); 684 return -ENODEV; 685 } 686 687 if (report->maxfield < 1 || report->field[0]->report_count < 7) { 688 hid_err(hdev, "invalid tablet-enabling feature report\n"); 689 return -ENODEV; 690 } 691 692 value = report->field[0]->value; 693 694 value[0] = 0x12; 695 value[1] = 0x10; 696 value[2] = 0x11; 697 value[3] = 0x12; 698 value[4] = 0x00; 699 value[5] = 0x00; 700 value[6] = 0x00; 701 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); 702 703 return 0; 704 } 705 706 static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id) 707 { 708 int ret; 709 710 ret = hid_parse(hdev); 711 if (ret) { 712 hid_err(hdev, "parse failed\n"); 713 goto err; 714 } 715 716 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 717 if (ret) { 718 hid_err(hdev, "hw start failed\n"); 719 goto err; 720 } 721 722 switch (id->product) { 723 case USB_DEVICE_ID_KYE_EASYPEN_I405X: 724 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: 725 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2: 726 case USB_DEVICE_ID_KYE_EASYPEN_M610X: 727 case USB_DEVICE_ID_KYE_EASYPEN_M406XE: 728 case USB_DEVICE_ID_KYE_PENSKETCH_M912: 729 ret = kye_tablet_enable(hdev); 730 if (ret) { 731 hid_err(hdev, "tablet enabling failed\n"); 732 goto enabling_err; 733 } 734 break; 735 case USB_DEVICE_ID_GENIUS_MANTICORE: 736 /* 737 * The manticore keyboard needs to have all the interfaces 738 * opened at least once to be fully functional. 739 */ 740 if (hid_hw_open(hdev)) 741 hid_hw_close(hdev); 742 break; 743 } 744 745 return 0; 746 enabling_err: 747 hid_hw_stop(hdev); 748 err: 749 return ret; 750 } 751 752 static const struct hid_device_id kye_devices[] = { 753 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 754 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 755 USB_DEVICE_ID_KYE_EASYPEN_I405X) }, 756 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 757 USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, 758 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 759 USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) }, 760 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 761 USB_DEVICE_ID_KYE_EASYPEN_M610X) }, 762 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 763 USB_DEVICE_ID_KYE_EASYPEN_M406XE) }, 764 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 765 USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, 766 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 767 USB_DEVICE_ID_GENIUS_GX_IMPERATOR) }, 768 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 769 USB_DEVICE_ID_GENIUS_MANTICORE) }, 770 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 771 USB_DEVICE_ID_KYE_PENSKETCH_M912) }, 772 { } 773 }; 774 MODULE_DEVICE_TABLE(hid, kye_devices); 775 776 static struct hid_driver kye_driver = { 777 .name = "kye", 778 .id_table = kye_devices, 779 .probe = kye_probe, 780 .report_fixup = kye_report_fixup, 781 }; 782 module_hid_driver(kye_driver); 783 784 MODULE_LICENSE("GPL"); 785