Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (62 commits)
Input: atkbd - release previously reserved keycodes 248 - 254
Input: add KEY_WPS_BUTTON definition
Input: ads7846 - add regulator support
Input: winbond-cir - fix suspend/resume
Input: gamecon - use pr_err() and friends
Input: gamecon - constify some of the setup structures
Input: gamecon - simplify pad type handling
Input: gamecon - simplify coordinate calculation for PSX
Input: gamecon - fix some formatting issues
Input: gamecon - add rumble support for N64 pads
Input: wacom - add device type to device name string
Input: s3c24xx_ts - report touch only when stylus is down
Input: s3c24xx_ts - re-enable IRQ on resume
Input: wacom - constify product features data
Input: wacom - use per-device instance of wacom_features
Input: sh_keysc - enable building on SH-Mobile ARM
Input: wacom - get features from driver info
Input: rotary-encoder - set gpio direction for each requested gpio
Input: sh_keysc - update the driver with mode 6
Input: sh_keysc - switch to using bitmaps
...

+3260 -1344
+23
Documentation/feature-removal-schedule.txt
··· 538 538 sensors) wich are also supported by the gspca_zc3xx driver 539 539 (which supports 53 USB-ID's in total) 540 540 Who: Hans de Goede <hdegoede@redhat.com> 541 + 542 + ---------------------------- 543 + 544 + What: corgikbd, spitzkbd, tosakbd driver 545 + When: 2.6.35 546 + Files: drivers/input/keyboard/{corgi,spitz,tosa}kbd.c 547 + Why: We now have a generic GPIO based matrix keyboard driver that 548 + are fully capable of handling all the keys on these devices. 549 + The original drivers manipulate the GPIO registers directly 550 + and so are difficult to maintain. 551 + Who: Eric Miao <eric.y.miao@gmail.com> 552 + 553 + ---------------------------- 554 + 555 + What: corgi_ssp and corgi_ts driver 556 + When: 2.6.35 557 + Files: arch/arm/mach-pxa/corgi_ssp.c, drivers/input/touchscreen/corgi_ts.c 558 + Why: The corgi touchscreen is now deprecated in favour of the generic 559 + ads7846.c driver. The noise reduction technique used in corgi_ts.c, 560 + that's to wait till vsync before ADC sampling, is also integrated into 561 + ads7846 driver now. Provided that the original driver is not generic 562 + and is difficult to maintain, it will be removed later. 563 + Who: Eric Miao <eric.y.miao@gmail.com>
+110 -14
Documentation/input/sentelic.txt
··· 1 - Copyright (C) 2002-2008 Sentelic Corporation. 2 - Last update: Oct-31-2008 1 + Copyright (C) 2002-2010 Sentelic Corporation. 2 + Last update: Jan-13-2010 3 3 4 4 ============================================================================== 5 5 * Finger Sensing Pad Intellimouse Mode(scrolling wheel, 4th and 5th buttons) ··· 44 44 Packet 1 45 45 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 46 46 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------| 47 - 1 |Y|X|y|x|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 | | |B|F|l|r|u|d| 47 + 1 |Y|X|y|x|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 | | |B|F|r|l|u|d| 48 48 |---------------| |---------------| |---------------| |---------------| 49 49 50 50 Byte 1: Bit7 => Y overflow ··· 59 59 Byte 3: Y Movement(9-bit 2's complement integers) 60 60 Byte 4: Bit0 => the Vertical scrolling movement downward. 61 61 Bit1 => the Vertical scrolling movement upward. 62 - Bit2 => the Vertical scrolling movement rightward. 63 - Bit3 => the Vertical scrolling movement leftward. 62 + Bit2 => the Horizontal scrolling movement leftward. 63 + Bit3 => the Horizontal scrolling movement rightward. 64 64 Bit4 => 1 = 4th mouse button is pressed, Forward one page. 65 65 0 = 4th mouse button is not pressed. 66 66 Bit5 => 1 = 5th mouse button is pressed, Backward one page. 67 67 0 = 5th mouse button is not pressed. 68 68 69 69 C) MSID 7: 70 - # FSP uses 2 packets(8 Bytes) data to represent Absolute Position 70 + # FSP uses 2 packets (8 Bytes) to represent Absolute Position. 71 71 so we have PACKET NUMBER to identify packets. 72 72 If PACKET NUMBER is 0, the packet is Packet 1. 73 73 If PACKET NUMBER is 1, the packet is Packet 2. ··· 129 129 Byte 4: Bit7~Bit0 => Don't Care 130 130 131 131 ============================================================================== 132 - * Absolute position for STL3888-A0. 132 + * Absolute position for STL3888-Ax. 133 133 ============================================================================== 134 134 Packet 1 (ABSOLUTE POSITION) 135 135 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 ··· 179 179 Bit5~Bit4 => y2_g 180 180 Bit7~Bit6 => x2_g 181 181 182 - Notify Packet for STL3888-A0 182 + Notify Packet for STL3888-Ax 183 183 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 184 184 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------| 185 185 1 |1|0|1|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|d|u|0|0|0|0| 186 186 |---------------| |---------------| |---------------| |---------------| 187 187 188 188 Byte 1: Bit7~Bit6 => 00, Normal data packet 189 - => 01, Absolute coordination packet 189 + => 01, Absolute coordinates packet 190 190 => 10, Notify packet 191 191 Bit5 => 1 192 192 Bit4 => when in absolute coordinates mode (valid when EN_PKT_GO is 1): ··· 205 205 Bit6 => scroll left button 206 206 Bit5 => scroll down button 207 207 Bit4 => scroll up button 208 - * Note that if gesture and additional button (Bit4~Bit7) 209 - happen at the same time, the button information will not 210 - be sent. 208 + * Note that if gesture and additional buttoni (Bit4~Bit7) 209 + happen at the same time, the button information will not 210 + be sent. 211 211 Bit3~Bit0 => Reserved 212 212 213 213 Sample sequence of Multi-finger, Multi-coordinate mode: 214 214 215 215 notify packet (valid bit == 1), abs pkt 1, abs pkt 2, abs pkt 1, 216 - abs pkt 2, ..., notify packet(valid bit == 0) 216 + abs pkt 2, ..., notify packet (valid bit == 0) 217 + 218 + ============================================================================== 219 + * Absolute position for STL3888-B0. 220 + ============================================================================== 221 + Packet 1(ABSOLUTE POSITION) 222 + Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 223 + BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------| 224 + 1 |0|1|V|F|1|0|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|u|d|X|X|Y|Y| 225 + |---------------| |---------------| |---------------| |---------------| 226 + 227 + Byte 1: Bit7~Bit6 => 00, Normal data packet 228 + => 01, Absolute coordinates packet 229 + => 10, Notify packet 230 + Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up. 231 + When both fingers are up, the last two reports have zero valid 232 + bit. 233 + Bit4 => finger up/down information. 1: finger down, 0: finger up. 234 + Bit3 => 1 235 + Bit2 => finger index, 0 is the first finger, 1 is the second finger. 236 + Bit1 => Right Button, 1 is pressed, 0 is not pressed. 237 + Bit0 => Left Button, 1 is pressed, 0 is not pressed. 238 + Byte 2: X coordinate (xpos[9:2]) 239 + Byte 3: Y coordinate (ypos[9:2]) 240 + Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0]) 241 + Bit3~Bit2 => X coordinate (ypos[1:0]) 242 + Bit4 => scroll down button 243 + Bit5 => scroll up button 244 + Bit6 => scroll left button 245 + Bit7 => scroll right button 246 + 247 + Packet 2 (ABSOLUTE POSITION) 248 + Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 249 + BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------| 250 + 1 |0|1|V|F|1|1|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|u|d|X|X|Y|Y| 251 + |---------------| |---------------| |---------------| |---------------| 252 + 253 + Byte 1: Bit7~Bit6 => 00, Normal data packet 254 + => 01, Absolute coordination packet 255 + => 10, Notify packet 256 + Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up. 257 + When both fingers are up, the last two reports have zero valid 258 + bit. 259 + Bit4 => finger up/down information. 1: finger down, 0: finger up. 260 + Bit3 => 1 261 + Bit2 => finger index, 0 is the first finger, 1 is the second finger. 262 + Bit1 => Right Button, 1 is pressed, 0 is not pressed. 263 + Bit0 => Left Button, 1 is pressed, 0 is not pressed. 264 + Byte 2: X coordinate (xpos[9:2]) 265 + Byte 3: Y coordinate (ypos[9:2]) 266 + Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0]) 267 + Bit3~Bit2 => X coordinate (ypos[1:0]) 268 + Bit4 => scroll down button 269 + Bit5 => scroll up button 270 + Bit6 => scroll left button 271 + Bit7 => scroll right button 272 + 273 + Notify Packet for STL3888-B0 274 + Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 275 + BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------| 276 + 1 |1|0|1|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|u|d|0|0|0|0| 277 + |---------------| |---------------| |---------------| |---------------| 278 + 279 + Byte 1: Bit7~Bit6 => 00, Normal data packet 280 + => 01, Absolute coordination packet 281 + => 10, Notify packet 282 + Bit5 => 1 283 + Bit4 => when in absolute coordinate mode (valid when EN_PKT_GO is 1): 284 + 0: left button is generated by the on-pad command 285 + 1: left button is generated by the external button 286 + Bit3 => 1 287 + Bit2 => Middle Button, 1 is pressed, 0 is not pressed. 288 + Bit1 => Right Button, 1 is pressed, 0 is not pressed. 289 + Bit0 => Left Button, 1 is pressed, 0 is not pressed. 290 + Byte 2: Message Type => 0xB7 (Multi Finger, Multi Coordinate mode) 291 + Byte 3: Bit7~Bit6 => Don't care 292 + Bit5~Bit4 => Number of fingers 293 + Bit3~Bit1 => Reserved 294 + Bit0 => 1: enter gesture mode; 0: leaving gesture mode 295 + Byte 4: Bit7 => scroll right button 296 + Bit6 => scroll left button 297 + Bit5 => scroll up button 298 + Bit4 => scroll down button 299 + * Note that if gesture and additional button(Bit4~Bit7) 300 + happen at the same time, the button information will not 301 + be sent. 302 + Bit3~Bit0 => Reserved 303 + 304 + Sample sequence of Multi-finger, Multi-coordinate mode: 305 + 306 + notify packet (valid bit == 1), abs pkt 1, abs pkt 2, abs pkt 1, 307 + abs pkt 2, ..., notify packet (valid bit == 0) 217 308 218 309 ============================================================================== 219 310 * FSP Enable/Disable packet ··· 500 409 0: read only, 1: read/write enable 501 410 (Note that following registers does not require clock gating being 502 411 enabled prior to write: 05 06 07 08 09 0c 0f 10 11 12 16 17 18 23 2e 503 - 40 41 42 43.) 412 + 40 41 42 43. In addition to that, this bit must be 1 when gesture 413 + mode is enabled) 504 414 505 415 0x31 RW on-pad command detection 506 416 bit7 0 RW on-pad command left button down tag ··· 554 462 bit 2 and 3. That is, if any of those bit is 1, host will receive 555 463 absolute coordinates; otherwise, host only receives packets with 556 464 relative coordinate.) 465 + 466 + bit7 0 RW EN_PS2_F2: PS/2 gesture mode 2nd 467 + finger packet enable 468 + 0: disable, 1: enable 557 469 558 470 0x43 RW on-pad control 559 471 bit0 0 RW on-pad control enable
+7 -7
arch/arm/mach-ep93xx/include/mach/ep93xx_keypad.h
··· 5 5 #ifndef __ASM_ARCH_EP93XX_KEYPAD_H 6 6 #define __ASM_ARCH_EP93XX_KEYPAD_H 7 7 8 + struct matrix_keymap_data; 9 + 8 10 /* flags for the ep93xx_keypad driver */ 9 11 #define EP93XX_KEYPAD_DISABLE_3_KEY (1<<0) /* disable 3-key reset */ 10 12 #define EP93XX_KEYPAD_DIAG_MODE (1<<1) /* diagnostic mode */ ··· 17 15 18 16 /** 19 17 * struct ep93xx_keypad_platform_data - platform specific device structure 20 - * @matrix_key_map: array of keycodes defining the keypad matrix 21 - * @matrix_key_map_size: ARRAY_SIZE(matrix_key_map) 22 - * @debounce: debounce start count; terminal count is 0xff 23 - * @prescale: row/column counter pre-scaler load value 24 - * @flags: see above 18 + * @keymap_data: pointer to &matrix_keymap_data 19 + * @debounce: debounce start count; terminal count is 0xff 20 + * @prescale: row/column counter pre-scaler load value 21 + * @flags: see above 25 22 */ 26 23 struct ep93xx_keypad_platform_data { 27 - unsigned int *matrix_key_map; 28 - int matrix_key_map_size; 24 + struct matrix_keymap_data *keymap_data; 29 25 unsigned int debounce; 30 26 unsigned int prescale; 31 27 unsigned int flags;
+16 -13
drivers/char/keyboard.c
··· 1185 1185 1186 1186 rep = (down == 2); 1187 1187 1188 - #ifdef CONFIG_MAC_EMUMOUSEBTN 1189 - if (mac_hid_mouse_emulate_buttons(1, keycode, down)) 1190 - return; 1191 - #endif /* CONFIG_MAC_EMUMOUSEBTN */ 1192 - 1193 1188 if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw) 1194 1189 if (emulate_raw(vc, keycode, !down << 7)) 1195 1190 if (keycode < BTN_MISC && printk_ratelimit()) ··· 1323 1328 schedule_console_callback(); 1324 1329 } 1325 1330 1331 + static bool kbd_match(struct input_handler *handler, struct input_dev *dev) 1332 + { 1333 + int i; 1334 + 1335 + if (test_bit(EV_SND, dev->evbit)) 1336 + return true; 1337 + 1338 + if (test_bit(EV_KEY, dev->evbit)) 1339 + for (i = KEY_RESERVED; i < BTN_MISC; i++) 1340 + if (test_bit(i, dev->keybit)) 1341 + return true; 1342 + 1343 + return false; 1344 + } 1345 + 1326 1346 /* 1327 1347 * When a keyboard (or other input device) is found, the kbd_connect 1328 1348 * function is called. The function then looks at the device, and if it ··· 1349 1339 { 1350 1340 struct input_handle *handle; 1351 1341 int error; 1352 - int i; 1353 - 1354 - for (i = KEY_RESERVED; i < BTN_MISC; i++) 1355 - if (test_bit(i, dev->keybit)) 1356 - break; 1357 - 1358 - if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) 1359 - return -ENODEV; 1360 1342 1361 1343 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); 1362 1344 if (!handle) ··· 1414 1412 1415 1413 static struct input_handler kbd_handler = { 1416 1414 .event = kbd_event, 1415 + .match = kbd_match, 1417 1416 .connect = kbd_connect, 1418 1417 .disconnect = kbd_disconnect, 1419 1418 .start = kbd_start,
+2
drivers/input/evdev.c
··· 278 278 goto err_free_client; 279 279 280 280 file->private_data = client; 281 + nonseekable_open(inode, file); 282 + 281 283 return 0; 282 284 283 285 err_free_client:
+1 -1
drivers/input/gameport/emu10k1-gp.c
··· 46 46 int size; 47 47 }; 48 48 49 - static struct pci_device_id emu_tbl[] = { 49 + static const struct pci_device_id emu_tbl[] = { 50 50 51 51 { 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */ 52 52 { 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */
+1 -1
drivers/input/gameport/fm801-gp.c
··· 140 140 } 141 141 } 142 142 143 - static struct pci_device_id fm801_gp_id_table[] = { 143 + static const struct pci_device_id fm801_gp_id_table[] = { 144 144 { PCI_VENDOR_ID_FORTEMEDIA, PCI_DEVICE_ID_FM801_GP, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 145 145 { 0 } 146 146 };
+40 -58
drivers/input/gameport/gameport.c
··· 11 11 * the Free Software Foundation. 12 12 */ 13 13 14 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 15 + 14 16 #include <linux/stddef.h> 15 17 #include <linux/module.h> 16 18 #include <linux/ioport.h> ··· 192 190 193 191 error = device_bind_driver(&gameport->dev); 194 192 if (error) { 195 - printk(KERN_WARNING 196 - "gameport: device_bind_driver() failed " 197 - "for %s (%s) and %s, error: %d\n", 193 + dev_warn(&gameport->dev, 194 + "device_bind_driver() failed for %s (%s) and %s, error: %d\n", 198 195 gameport->phys, gameport->name, 199 196 drv->description, error); 200 197 drv->disconnect(gameport); ··· 210 209 211 210 error = device_attach(&gameport->dev); 212 211 if (error < 0) 213 - printk(KERN_WARNING 214 - "gameport: device_attach() failed for %s (%s), error: %d\n", 215 - gameport->phys, gameport->name, error); 212 + dev_warn(&gameport->dev, 213 + "device_attach() failed for %s (%s), error: %d\n", 214 + gameport->phys, gameport->name, error); 216 215 } 217 216 218 217 ··· 263 262 264 263 event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC); 265 264 if (!event) { 266 - printk(KERN_ERR 267 - "gameport: Not enough memory to queue event %d\n", 268 - event_type); 265 + pr_err("Not enough memory to queue event %d\n", event_type); 269 266 retval = -ENOMEM; 270 267 goto out; 271 268 } 272 269 273 270 if (!try_module_get(owner)) { 274 - printk(KERN_WARNING 275 - "gameport: Can't get module reference, dropping event %d\n", 276 - event_type); 271 + pr_warning("Can't get module reference, dropping event %d\n", 272 + event_type); 277 273 kfree(event); 278 274 retval = -EINVAL; 279 275 goto out; ··· 296 298 297 299 static void gameport_remove_duplicate_events(struct gameport_event *event) 298 300 { 299 - struct list_head *node, *next; 300 - struct gameport_event *e; 301 + struct gameport_event *e, *next; 301 302 unsigned long flags; 302 303 303 304 spin_lock_irqsave(&gameport_event_lock, flags); 304 305 305 - list_for_each_safe(node, next, &gameport_event_list) { 306 - e = list_entry(node, struct gameport_event, node); 306 + list_for_each_entry_safe(e, next, &gameport_event_list, node) { 307 307 if (event->object == e->object) { 308 308 /* 309 309 * If this event is of different type we should not ··· 311 315 if (event->type != e->type) 312 316 break; 313 317 314 - list_del_init(node); 318 + list_del_init(&e->node); 315 319 gameport_free_event(e); 316 320 } 317 321 } ··· 321 325 322 326 static struct gameport_event *gameport_get_event(void) 323 327 { 324 - struct gameport_event *event; 325 - struct list_head *node; 328 + struct gameport_event *event = NULL; 326 329 unsigned long flags; 327 330 328 331 spin_lock_irqsave(&gameport_event_lock, flags); 329 332 330 - if (list_empty(&gameport_event_list)) { 331 - spin_unlock_irqrestore(&gameport_event_lock, flags); 332 - return NULL; 333 + if (!list_empty(&gameport_event_list)) { 334 + event = list_first_entry(&gameport_event_list, 335 + struct gameport_event, node); 336 + list_del_init(&event->node); 333 337 } 334 338 335 - node = gameport_event_list.next; 336 - event = list_entry(node, struct gameport_event, node); 337 - list_del_init(node); 338 - 339 339 spin_unlock_irqrestore(&gameport_event_lock, flags); 340 - 341 340 return event; 342 341 } 343 342 ··· 351 360 if ((event = gameport_get_event())) { 352 361 353 362 switch (event->type) { 354 - case GAMEPORT_REGISTER_PORT: 355 - gameport_add_port(event->object); 356 - break; 357 363 358 - case GAMEPORT_ATTACH_DRIVER: 359 - gameport_attach_driver(event->object); 360 - break; 364 + case GAMEPORT_REGISTER_PORT: 365 + gameport_add_port(event->object); 366 + break; 361 367 362 - default: 363 - break; 368 + case GAMEPORT_ATTACH_DRIVER: 369 + gameport_attach_driver(event->object); 370 + break; 364 371 } 365 372 366 373 gameport_remove_duplicate_events(event); ··· 374 385 */ 375 386 static void gameport_remove_pending_events(void *object) 376 387 { 377 - struct list_head *node, *next; 378 - struct gameport_event *event; 388 + struct gameport_event *event, *next; 379 389 unsigned long flags; 380 390 381 391 spin_lock_irqsave(&gameport_event_lock, flags); 382 392 383 - list_for_each_safe(node, next, &gameport_event_list) { 384 - event = list_entry(node, struct gameport_event, node); 393 + list_for_each_entry_safe(event, next, &gameport_event_list, node) { 385 394 if (event->object == object) { 386 - list_del_init(node); 395 + list_del_init(&event->node); 387 396 gameport_free_event(event); 388 397 } 389 398 } ··· 428 441 kthread_should_stop() || !list_empty(&gameport_event_list)); 429 442 } while (!kthread_should_stop()); 430 443 431 - printk(KERN_DEBUG "gameport: kgameportd exiting\n"); 432 444 return 0; 433 445 } 434 446 ··· 439 453 static ssize_t gameport_show_description(struct device *dev, struct device_attribute *attr, char *buf) 440 454 { 441 455 struct gameport *gameport = to_gameport_port(dev); 456 + 442 457 return sprintf(buf, "%s\n", gameport->name); 443 458 } 444 459 ··· 508 521 509 522 mutex_init(&gameport->drv_mutex); 510 523 device_initialize(&gameport->dev); 511 - dev_set_name(&gameport->dev, "gameport%lu", (unsigned long)atomic_inc_return(&gameport_no) - 1); 524 + dev_set_name(&gameport->dev, "gameport%lu", 525 + (unsigned long)atomic_inc_return(&gameport_no) - 1); 512 526 gameport->dev.bus = &gameport_bus; 513 527 gameport->dev.release = gameport_release_port; 514 528 if (gameport->parent) ··· 538 550 list_add_tail(&gameport->node, &gameport_list); 539 551 540 552 if (gameport->io) 541 - printk(KERN_INFO "gameport: %s is %s, io %#x, speed %dkHz\n", 542 - gameport->name, gameport->phys, gameport->io, gameport->speed); 553 + dev_info(&gameport->dev, "%s is %s, io %#x, speed %dkHz\n", 554 + gameport->name, gameport->phys, gameport->io, gameport->speed); 543 555 else 544 - printk(KERN_INFO "gameport: %s is %s, speed %dkHz\n", 556 + dev_info(&gameport->dev, "%s is %s, speed %dkHz\n", 545 557 gameport->name, gameport->phys, gameport->speed); 546 558 547 559 error = device_add(&gameport->dev); 548 560 if (error) 549 - printk(KERN_ERR 550 - "gameport: device_add() failed for %s (%s), error: %d\n", 561 + dev_err(&gameport->dev, 562 + "device_add() failed for %s (%s), error: %d\n", 551 563 gameport->phys, gameport->name, error); 552 - else 553 - gameport->registered = 1; 554 564 } 555 565 556 566 /* ··· 570 584 gameport->parent = NULL; 571 585 } 572 586 573 - if (gameport->registered) { 587 + if (device_is_registered(&gameport->dev)) 574 588 device_del(&gameport->dev); 575 - gameport->registered = 0; 576 - } 577 589 578 590 list_del_init(&gameport->node); 579 591 ··· 689 705 690 706 error = driver_attach(&drv->driver); 691 707 if (error) 692 - printk(KERN_ERR 693 - "gameport: driver_attach() failed for %s, error: %d\n", 708 + pr_err("driver_attach() failed for %s, error: %d\n", 694 709 drv->driver.name, error); 695 710 } 696 711 ··· 710 727 711 728 error = driver_register(&drv->driver); 712 729 if (error) { 713 - printk(KERN_ERR 714 - "gameport: driver_register() failed for %s, error: %d\n", 730 + pr_err("driver_register() failed for %s, error: %d\n", 715 731 drv->driver.name, error); 716 732 return error; 717 733 } ··· 810 828 811 829 error = bus_register(&gameport_bus); 812 830 if (error) { 813 - printk(KERN_ERR "gameport: failed to register gameport bus, error: %d\n", error); 831 + pr_err("failed to register gameport bus, error: %d\n", error); 814 832 return error; 815 833 } 816 834 ··· 818 836 if (IS_ERR(gameport_task)) { 819 837 bus_unregister(&gameport_bus); 820 838 error = PTR_ERR(gameport_task); 821 - printk(KERN_ERR "gameport: Failed to start kgameportd, error: %d\n", error); 839 + pr_err("Failed to start kgameportd, error: %d\n", error); 822 840 return error; 823 841 } 824 842
+1 -1
drivers/input/gameport/ns558.c
··· 166 166 167 167 #ifdef CONFIG_PNP 168 168 169 - static struct pnp_device_id pnp_devids[] = { 169 + static const struct pnp_device_id pnp_devids[] = { 170 170 { .id = "@P@0001", .driver_data = 0 }, /* ALS 100 */ 171 171 { .id = "@P@0020", .driver_data = 0 }, /* ALS 200 */ 172 172 { .id = "@P@1001", .driver_data = 0 }, /* ALS 100+ */
+72 -18
drivers/input/input.c
··· 87 87 } 88 88 89 89 /* 90 - * Pass event through all open handles. This function is called with 90 + * Pass event first through all filters and then, if event has not been 91 + * filtered out, through all open handles. This function is called with 91 92 * dev->event_lock held and interrupts disabled. 92 93 */ 93 94 static void input_pass_event(struct input_dev *dev, 94 95 unsigned int type, unsigned int code, int value) 95 96 { 97 + struct input_handler *handler; 96 98 struct input_handle *handle; 97 99 98 100 rcu_read_lock(); ··· 102 100 handle = rcu_dereference(dev->grab); 103 101 if (handle) 104 102 handle->handler->event(handle, type, code, value); 105 - else 106 - list_for_each_entry_rcu(handle, &dev->h_list, d_node) 107 - if (handle->open) 108 - handle->handler->event(handle, 109 - type, code, value); 103 + else { 104 + bool filtered = false; 105 + 106 + list_for_each_entry_rcu(handle, &dev->h_list, d_node) { 107 + if (!handle->open) 108 + continue; 109 + 110 + handler = handle->handler; 111 + if (!handler->filter) { 112 + if (filtered) 113 + break; 114 + 115 + handler->event(handle, type, code, value); 116 + 117 + } else if (handler->filter(handle, type, code, value)) 118 + filtered = true; 119 + } 120 + } 121 + 110 122 rcu_read_unlock(); 111 123 } 112 124 ··· 631 615 } 632 616 } 633 617 634 - clear_bit(old_keycode, dev->keybit); 635 - set_bit(keycode, dev->keybit); 618 + __clear_bit(old_keycode, dev->keybit); 619 + __set_bit(keycode, dev->keybit); 636 620 637 621 for (i = 0; i < dev->keycodemax; i++) { 638 622 if (input_fetch_keycode(dev, i) == old_keycode) { 639 - set_bit(old_keycode, dev->keybit); 623 + __set_bit(old_keycode, dev->keybit); 640 624 break; /* Setting the bit twice is useless, so break */ 641 625 } 642 626 } ··· 694 678 if (retval) 695 679 goto out; 696 680 681 + /* Make sure KEY_RESERVED did not get enabled. */ 682 + __clear_bit(KEY_RESERVED, dev->keybit); 683 + 697 684 /* 698 685 * Simulate keyup event if keycode is not present 699 686 * in the keymap anymore ··· 724 705 if (i != BITS_TO_LONGS(max)) \ 725 706 continue; 726 707 727 - static const struct input_device_id *input_match_device(const struct input_device_id *id, 708 + static const struct input_device_id *input_match_device(struct input_handler *handler, 728 709 struct input_dev *dev) 729 710 { 711 + const struct input_device_id *id; 730 712 int i; 731 713 732 - for (; id->flags || id->driver_info; id++) { 714 + for (id = handler->id_table; id->flags || id->driver_info; id++) { 733 715 734 716 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) 735 717 if (id->bustype != dev->id.bustype) ··· 758 738 MATCH_BIT(ffbit, FF_MAX); 759 739 MATCH_BIT(swbit, SW_MAX); 760 740 761 - return id; 741 + if (!handler->match || handler->match(handler, dev)) 742 + return id; 762 743 } 763 744 764 745 return NULL; ··· 770 749 const struct input_device_id *id; 771 750 int error; 772 751 773 - if (handler->blacklist && input_match_device(handler->blacklist, dev)) 774 - return -ENODEV; 775 - 776 - id = input_match_device(handler->id_table, dev); 752 + id = input_match_device(handler, dev); 777 753 if (!id) 778 754 return -ENODEV; 779 755 ··· 1006 988 union input_seq_state *state = (union input_seq_state *)&seq->private; 1007 989 1008 990 seq_printf(seq, "N: Number=%u Name=%s", state->pos, handler->name); 991 + if (handler->filter) 992 + seq_puts(seq, " (filter)"); 1009 993 if (handler->fops) 1010 994 seq_printf(seq, " Minor=%d", handler->minor); 1011 995 seq_putc(seq, '\n'); ··· 1571 1551 } 1572 1552 EXPORT_SYMBOL(input_set_capability); 1573 1553 1554 + #define INPUT_CLEANSE_BITMASK(dev, type, bits) \ 1555 + do { \ 1556 + if (!test_bit(EV_##type, dev->evbit)) \ 1557 + memset(dev->bits##bit, 0, \ 1558 + sizeof(dev->bits##bit)); \ 1559 + } while (0) 1560 + 1561 + static void input_cleanse_bitmasks(struct input_dev *dev) 1562 + { 1563 + INPUT_CLEANSE_BITMASK(dev, KEY, key); 1564 + INPUT_CLEANSE_BITMASK(dev, REL, rel); 1565 + INPUT_CLEANSE_BITMASK(dev, ABS, abs); 1566 + INPUT_CLEANSE_BITMASK(dev, MSC, msc); 1567 + INPUT_CLEANSE_BITMASK(dev, LED, led); 1568 + INPUT_CLEANSE_BITMASK(dev, SND, snd); 1569 + INPUT_CLEANSE_BITMASK(dev, FF, ff); 1570 + INPUT_CLEANSE_BITMASK(dev, SW, sw); 1571 + } 1572 + 1574 1573 /** 1575 1574 * input_register_device - register device with input core 1576 1575 * @dev: device to be registered ··· 1609 1570 const char *path; 1610 1571 int error; 1611 1572 1573 + /* Every input device generates EV_SYN/SYN_REPORT events. */ 1612 1574 __set_bit(EV_SYN, dev->evbit); 1575 + 1576 + /* KEY_RESERVED is not supposed to be transmitted to userspace. */ 1577 + __clear_bit(KEY_RESERVED, dev->keybit); 1578 + 1579 + /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ 1580 + input_cleanse_bitmasks(dev); 1613 1581 1614 1582 /* 1615 1583 * If delay and period are pre-set by the driver, then autorepeating 1616 1584 * is handled by the driver itself and we don't do it in input.c. 1617 1585 */ 1618 - 1619 1586 init_timer(&dev->timer); 1620 1587 if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) { 1621 1588 dev->timer.data = (long) dev; ··· 1821 1776 error = mutex_lock_interruptible(&dev->mutex); 1822 1777 if (error) 1823 1778 return error; 1824 - list_add_tail_rcu(&handle->d_node, &dev->h_list); 1779 + 1780 + /* 1781 + * Filters go to the head of the list, normal handlers 1782 + * to the tail. 1783 + */ 1784 + if (handler->filter) 1785 + list_add_rcu(&handle->d_node, &dev->h_list); 1786 + else 1787 + list_add_tail_rcu(&handle->d_node, &dev->h_list); 1788 + 1825 1789 mutex_unlock(&dev->mutex); 1826 1790 1827 1791 /*
+17 -17
drivers/input/joydev.c
··· 286 286 goto err_free_client; 287 287 288 288 file->private_data = client; 289 + nonseekable_open(inode, file); 290 + 289 291 return 0; 290 292 291 293 err_free_client: ··· 777 775 input_close_device(handle); 778 776 } 779 777 778 + 779 + static bool joydev_match(struct input_handler *handler, struct input_dev *dev) 780 + { 781 + /* Avoid touchpads and touchscreens */ 782 + if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit)) 783 + return false; 784 + 785 + /* Avoid tablets, digitisers and similar devices */ 786 + if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit)) 787 + return false; 788 + 789 + return true; 790 + } 791 + 780 792 static int joydev_connect(struct input_handler *handler, struct input_dev *dev, 781 793 const struct input_device_id *id) 782 794 { ··· 910 894 put_device(&joydev->dev); 911 895 } 912 896 913 - static const struct input_device_id joydev_blacklist[] = { 914 - { 915 - .flags = INPUT_DEVICE_ID_MATCH_EVBIT | 916 - INPUT_DEVICE_ID_MATCH_KEYBIT, 917 - .evbit = { BIT_MASK(EV_KEY) }, 918 - .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, 919 - }, /* Avoid itouchpads and touchscreens */ 920 - { 921 - .flags = INPUT_DEVICE_ID_MATCH_EVBIT | 922 - INPUT_DEVICE_ID_MATCH_KEYBIT, 923 - .evbit = { BIT_MASK(EV_KEY) }, 924 - .keybit = { [BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_DIGI) }, 925 - }, /* Avoid tablets, digitisers and similar devices */ 926 - { } /* Terminating entry */ 927 - }; 928 - 929 897 static const struct input_device_id joydev_ids[] = { 930 898 { 931 899 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | ··· 936 936 937 937 static struct input_handler joydev_handler = { 938 938 .event = joydev_event, 939 + .match = joydev_match, 939 940 .connect = joydev_connect, 940 941 .disconnect = joydev_disconnect, 941 942 .fops = &joydev_fops, 942 943 .minor = JOYDEV_MINOR_BASE, 943 944 .name = "joydev", 944 945 .id_table = joydev_ids, 945 - .blacklist = joydev_blacklist, 946 946 }; 947 947 948 948 static int __init joydev_init(void)
+1
drivers/input/joystick/Kconfig
··· 221 221 config JOYSTICK_GAMECON 222 222 tristate "Multisystem, NES, SNES, N64, PSX joysticks and gamepads" 223 223 depends on PARPORT 224 + select INPUT_FF_MEMLESS 224 225 ---help--- 225 226 Say Y here if you have a Nintendo Entertainment System gamepad, 226 227 Super Nintendo Entertainment System gamepad, Nintendo 64 gamepad,
+439 -235
drivers/input/joystick/gamecon.c
··· 30 30 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 31 31 */ 32 32 33 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 34 + 33 35 #include <linux/kernel.h> 34 36 #include <linux/delay.h> 35 37 #include <linux/module.h> ··· 63 61 64 62 /* see also gs_psx_delay parameter in PSX support section */ 65 63 66 - #define GC_SNES 1 67 - #define GC_NES 2 68 - #define GC_NES4 3 69 - #define GC_MULTI 4 70 - #define GC_MULTI2 5 71 - #define GC_N64 6 72 - #define GC_PSX 7 73 - #define GC_DDR 8 74 - #define GC_SNESMOUSE 9 75 - 76 - #define GC_MAX 9 64 + enum gc_type { 65 + GC_NONE = 0, 66 + GC_SNES, 67 + GC_NES, 68 + GC_NES4, 69 + GC_MULTI, 70 + GC_MULTI2, 71 + GC_N64, 72 + GC_PSX, 73 + GC_DDR, 74 + GC_SNESMOUSE, 75 + GC_MAX 76 + }; 77 77 78 78 #define GC_REFRESH_TIME HZ/100 79 79 80 + struct gc_pad { 81 + struct input_dev *dev; 82 + enum gc_type type; 83 + char phys[32]; 84 + }; 85 + 80 86 struct gc { 81 87 struct pardevice *pd; 88 + struct gc_pad pads[GC_MAX_DEVICES]; 82 89 struct input_dev *dev[GC_MAX_DEVICES]; 83 90 struct timer_list timer; 84 - unsigned char pads[GC_MAX + 1]; 91 + int pad_count[GC_MAX]; 85 92 int used; 86 93 struct mutex mutex; 87 - char phys[GC_MAX_DEVICES][32]; 94 + }; 95 + 96 + struct gc_subdev { 97 + unsigned int idx; 88 98 }; 89 99 90 100 static struct gc *gc_base[3]; 91 101 92 - static int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 }; 102 + static const int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 }; 93 103 94 - static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick", 95 - "Multisystem 2-button joystick", "N64 controller", "PSX controller", 96 - "PSX DDR controller", "SNES mouse" }; 104 + static const char *gc_names[] = { 105 + NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick", 106 + "Multisystem 2-button joystick", "N64 controller", "PSX controller", 107 + "PSX DDR controller", "SNES mouse" 108 + }; 109 + 97 110 /* 98 111 * N64 support. 99 112 */ 100 113 101 - static unsigned char gc_n64_bytes[] = { 0, 1, 13, 15, 14, 12, 10, 11, 2, 3 }; 102 - static short gc_n64_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TRIGGER, BTN_START }; 114 + static const unsigned char gc_n64_bytes[] = { 0, 1, 13, 15, 14, 12, 10, 11, 2, 3 }; 115 + static const short gc_n64_btn[] = { 116 + BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, 117 + BTN_TL, BTN_TR, BTN_TRIGGER, BTN_START 118 + }; 103 119 104 120 #define GC_N64_LENGTH 32 /* N64 bit length, not including stop bit */ 105 - #define GC_N64_REQUEST_LENGTH 37 /* transmit request sequence is 9 bits long */ 121 + #define GC_N64_STOP_LENGTH 5 /* Length of encoded stop bit */ 122 + #define GC_N64_CMD_00 0x11111111UL 123 + #define GC_N64_CMD_01 0xd1111111UL 124 + #define GC_N64_CMD_03 0xdd111111UL 125 + #define GC_N64_CMD_1b 0xdd1dd111UL 126 + #define GC_N64_CMD_c0 0x111111ddUL 127 + #define GC_N64_CMD_80 0x1111111dUL 128 + #define GC_N64_STOP_BIT 0x1d /* Encoded stop bit */ 129 + #define GC_N64_REQUEST_DATA GC_N64_CMD_01 /* the request data command */ 106 130 #define GC_N64_DELAY 133 /* delay between transmit request, and response ready (us) */ 107 - #define GC_N64_REQUEST 0x1dd1111111ULL /* the request data command (encoded for 000000011) */ 108 131 #define GC_N64_DWS 3 /* delay between write segments (required for sound playback because of ISA DMA) */ 109 132 /* GC_N64_DWS > 24 is known to fail */ 110 133 #define GC_N64_POWER_W 0xe2 /* power during write (transmit request) */ ··· 141 114 #define GC_N64_CLOCK 0x02 /* clock bits for read */ 142 115 143 116 /* 117 + * Used for rumble code. 118 + */ 119 + 120 + /* Send encoded command */ 121 + static void gc_n64_send_command(struct gc *gc, unsigned long cmd, 122 + unsigned char target) 123 + { 124 + struct parport *port = gc->pd->port; 125 + int i; 126 + 127 + for (i = 0; i < GC_N64_LENGTH; i++) { 128 + unsigned char data = (cmd >> i) & 1 ? target : 0; 129 + parport_write_data(port, GC_N64_POWER_W | data); 130 + udelay(GC_N64_DWS); 131 + } 132 + } 133 + 134 + /* Send stop bit */ 135 + static void gc_n64_send_stop_bit(struct gc *gc, unsigned char target) 136 + { 137 + struct parport *port = gc->pd->port; 138 + int i; 139 + 140 + for (i = 0; i < GC_N64_STOP_LENGTH; i++) { 141 + unsigned char data = (GC_N64_STOP_BIT >> i) & 1 ? target : 0; 142 + parport_write_data(port, GC_N64_POWER_W | data); 143 + udelay(GC_N64_DWS); 144 + } 145 + } 146 + 147 + /* 144 148 * gc_n64_read_packet() reads an N64 packet. 145 - * Each pad uses one bit per byte. So all pads connected to this port are read in parallel. 149 + * Each pad uses one bit per byte. So all pads connected to this port 150 + * are read in parallel. 146 151 */ 147 152 148 153 static void gc_n64_read_packet(struct gc *gc, unsigned char *data) ··· 187 128 */ 188 129 189 130 local_irq_save(flags); 190 - for (i = 0; i < GC_N64_REQUEST_LENGTH; i++) { 191 - parport_write_data(gc->pd->port, GC_N64_POWER_W | ((GC_N64_REQUEST >> i) & 1 ? GC_N64_OUT : 0)); 192 - udelay(GC_N64_DWS); 193 - } 131 + gc_n64_send_command(gc, GC_N64_REQUEST_DATA, GC_N64_OUT); 132 + gc_n64_send_stop_bit(gc, GC_N64_OUT); 194 133 local_irq_restore(flags); 195 134 196 135 /* 197 - * Wait for the pad response to be loaded into the 33-bit register of the adapter 136 + * Wait for the pad response to be loaded into the 33-bit register 137 + * of the adapter. 198 138 */ 199 139 200 140 udelay(GC_N64_DELAY); ··· 204 146 205 147 for (i = 0; i < GC_N64_LENGTH; i++) { 206 148 parport_write_data(gc->pd->port, GC_N64_POWER_R); 149 + udelay(2); 207 150 data[i] = parport_read_status(gc->pd->port); 208 151 parport_write_data(gc->pd->port, GC_N64_POWER_R | GC_N64_CLOCK); 209 152 } 210 153 211 154 /* 212 - * We must wait 200 ms here for the controller to reinitialize before the next read request. 213 - * No worries as long as gc_read is polled less frequently than this. 155 + * We must wait 200 ms here for the controller to reinitialize before 156 + * the next read request. No worries as long as gc_read is polled less 157 + * frequently than this. 214 158 */ 215 159 216 160 } ··· 220 160 static void gc_n64_process_packet(struct gc *gc) 221 161 { 222 162 unsigned char data[GC_N64_LENGTH]; 223 - signed char axes[2]; 224 163 struct input_dev *dev; 225 164 int i, j, s; 165 + signed char x, y; 226 166 227 167 gc_n64_read_packet(gc, data); 228 168 229 169 for (i = 0; i < GC_MAX_DEVICES; i++) { 230 170 231 - dev = gc->dev[i]; 232 - if (!dev) 171 + if (gc->pads[i].type != GC_N64) 233 172 continue; 234 173 174 + dev = gc->pads[i].dev; 235 175 s = gc_status_bit[i]; 236 176 237 - if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { 177 + if (s & ~(data[8] | data[9])) { 238 178 239 - axes[0] = axes[1] = 0; 179 + x = y = 0; 240 180 241 181 for (j = 0; j < 8; j++) { 242 182 if (data[23 - j] & s) 243 - axes[0] |= 1 << j; 183 + x |= 1 << j; 244 184 if (data[31 - j] & s) 245 - axes[1] |= 1 << j; 185 + y |= 1 << j; 246 186 } 247 187 248 - input_report_abs(dev, ABS_X, axes[0]); 249 - input_report_abs(dev, ABS_Y, -axes[1]); 188 + input_report_abs(dev, ABS_X, x); 189 + input_report_abs(dev, ABS_Y, -y); 250 190 251 - input_report_abs(dev, ABS_HAT0X, !(s & data[6]) - !(s & data[7])); 252 - input_report_abs(dev, ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); 191 + input_report_abs(dev, ABS_HAT0X, 192 + !(s & data[6]) - !(s & data[7])); 193 + input_report_abs(dev, ABS_HAT0Y, 194 + !(s & data[4]) - !(s & data[5])); 253 195 254 196 for (j = 0; j < 10; j++) 255 - input_report_key(dev, gc_n64_btn[j], s & data[gc_n64_bytes[j]]); 197 + input_report_key(dev, gc_n64_btn[j], 198 + s & data[gc_n64_bytes[j]]); 256 199 257 200 input_sync(dev); 258 201 } 259 202 } 203 + } 204 + 205 + static int gc_n64_play_effect(struct input_dev *dev, void *data, 206 + struct ff_effect *effect) 207 + { 208 + int i; 209 + unsigned long flags; 210 + struct gc *gc = input_get_drvdata(dev); 211 + struct gc_subdev *sdev = data; 212 + unsigned char target = 1 << sdev->idx; /* select desired pin */ 213 + 214 + if (effect->type == FF_RUMBLE) { 215 + struct ff_rumble_effect *rumble = &effect->u.rumble; 216 + unsigned int cmd = 217 + rumble->strong_magnitude || rumble->weak_magnitude ? 218 + GC_N64_CMD_01 : GC_N64_CMD_00; 219 + 220 + local_irq_save(flags); 221 + 222 + /* Init Rumble - 0x03, 0x80, 0x01, (34)0x80 */ 223 + gc_n64_send_command(gc, GC_N64_CMD_03, target); 224 + gc_n64_send_command(gc, GC_N64_CMD_80, target); 225 + gc_n64_send_command(gc, GC_N64_CMD_01, target); 226 + for (i = 0; i < 32; i++) 227 + gc_n64_send_command(gc, GC_N64_CMD_80, target); 228 + gc_n64_send_stop_bit(gc, target); 229 + 230 + udelay(GC_N64_DELAY); 231 + 232 + /* Now start or stop it - 0x03, 0xc0, 0zx1b, (32)0x01/0x00 */ 233 + gc_n64_send_command(gc, GC_N64_CMD_03, target); 234 + gc_n64_send_command(gc, GC_N64_CMD_c0, target); 235 + gc_n64_send_command(gc, GC_N64_CMD_1b, target); 236 + for (i = 0; i < 32; i++) 237 + gc_n64_send_command(gc, cmd, target); 238 + gc_n64_send_stop_bit(gc, target); 239 + 240 + local_irq_restore(flags); 241 + 242 + } 243 + 244 + return 0; 245 + } 246 + 247 + static int __init gc_n64_init_ff(struct input_dev *dev, int i) 248 + { 249 + struct gc_subdev *sdev; 250 + int err; 251 + 252 + sdev = kmalloc(sizeof(*sdev), GFP_KERNEL); 253 + if (!sdev) 254 + return -ENOMEM; 255 + 256 + sdev->idx = i; 257 + 258 + input_set_capability(dev, EV_FF, FF_RUMBLE); 259 + 260 + err = input_ff_create_memless(dev, sdev, gc_n64_play_effect); 261 + if (err) { 262 + kfree(sdev); 263 + return err; 264 + } 265 + 266 + return 0; 260 267 } 261 268 262 269 /* ··· 341 214 #define GC_NES_CLOCK 0x01 342 215 #define GC_NES_LATCH 0x02 343 216 344 - static unsigned char gc_nes_bytes[] = { 0, 1, 2, 3 }; 345 - static unsigned char gc_snes_bytes[] = { 8, 0, 2, 3, 9, 1, 10, 11 }; 346 - static short gc_snes_btn[] = { BTN_A, BTN_B, BTN_SELECT, BTN_START, BTN_X, BTN_Y, BTN_TL, BTN_TR }; 217 + static const unsigned char gc_nes_bytes[] = { 0, 1, 2, 3 }; 218 + static const unsigned char gc_snes_bytes[] = { 8, 0, 2, 3, 9, 1, 10, 11 }; 219 + static const short gc_snes_btn[] = { 220 + BTN_A, BTN_B, BTN_SELECT, BTN_START, BTN_X, BTN_Y, BTN_TL, BTN_TR 221 + }; 347 222 348 223 /* 349 224 * gc_nes_read_packet() reads a NES/SNES packet. ··· 373 244 static void gc_nes_process_packet(struct gc *gc) 374 245 { 375 246 unsigned char data[GC_SNESMOUSE_LENGTH]; 247 + struct gc_pad *pad; 376 248 struct input_dev *dev; 377 249 int i, j, s, len; 378 250 char x_rel, y_rel; 379 251 380 - len = gc->pads[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : 381 - (gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); 252 + len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : 253 + (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); 382 254 383 255 gc_nes_read_packet(gc, len, data); 384 256 385 257 for (i = 0; i < GC_MAX_DEVICES; i++) { 386 258 259 + pad = &gc->pads[i]; 387 260 dev = gc->dev[i]; 388 - if (!dev) 389 - continue; 390 - 391 261 s = gc_status_bit[i]; 392 262 393 - if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { 263 + switch (pad->type) { 264 + 265 + case GC_NES: 266 + 394 267 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7])); 395 268 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5])); 396 - } 397 269 398 - if (s & gc->pads[GC_NES]) 399 270 for (j = 0; j < 4; j++) 400 - input_report_key(dev, gc_snes_btn[j], s & data[gc_nes_bytes[j]]); 271 + input_report_key(dev, gc_snes_btn[j], 272 + s & data[gc_nes_bytes[j]]); 273 + input_sync(dev); 274 + break; 401 275 402 - if (s & gc->pads[GC_SNES]) 276 + case GC_SNES: 277 + 278 + input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7])); 279 + input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5])); 280 + 403 281 for (j = 0; j < 8; j++) 404 - input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); 282 + input_report_key(dev, gc_snes_btn[j], 283 + s & data[gc_snes_bytes[j]]); 284 + input_sync(dev); 285 + break; 405 286 406 - if (s & gc->pads[GC_SNESMOUSE]) { 287 + case GC_SNESMOUSE: 407 288 /* 408 - * The 4 unused bits from SNES controllers appear to be ID bits 409 - * so use them to make sure iwe are dealing with a mouse. 289 + * The 4 unused bits from SNES controllers appear 290 + * to be ID bits so use them to make sure we are 291 + * dealing with a mouse. 410 292 * gamepad is connected. This is important since 411 293 * my SNES gamepad sends 1's for bits 16-31, which 412 294 * cause the mouse pointer to quickly move to the ··· 450 310 y_rel = -y_rel; 451 311 input_report_rel(dev, REL_Y, y_rel); 452 312 } 313 + 314 + input_sync(dev); 453 315 } 316 + break; 317 + 318 + default: 319 + break; 454 320 } 455 - input_sync(dev); 456 321 } 457 322 } 458 323 ··· 485 340 static void gc_multi_process_packet(struct gc *gc) 486 341 { 487 342 unsigned char data[GC_MULTI2_LENGTH]; 343 + int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH; 344 + struct gc_pad *pad; 488 345 struct input_dev *dev; 489 346 int i, s; 490 347 491 - gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data); 348 + gc_multi_read_packet(gc, data_len, data); 492 349 493 350 for (i = 0; i < GC_MAX_DEVICES; i++) { 494 - 495 - dev = gc->dev[i]; 496 - if (!dev) 497 - continue; 498 - 351 + pad = &gc->pads[i]; 352 + dev = pad->dev; 499 353 s = gc_status_bit[i]; 500 354 501 - if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { 502 - input_report_abs(dev, ABS_X, !(s & data[2]) - !(s & data[3])); 503 - input_report_abs(dev, ABS_Y, !(s & data[0]) - !(s & data[1])); 504 - input_report_key(dev, BTN_TRIGGER, s & data[4]); 505 - } 506 - 507 - if (s & gc->pads[GC_MULTI2]) 355 + switch (pad->type) { 356 + case GC_MULTI2: 508 357 input_report_key(dev, BTN_THUMB, s & data[5]); 358 + /* fall through */ 509 359 510 - input_sync(dev); 360 + case GC_MULTI: 361 + input_report_abs(dev, ABS_X, 362 + !(s & data[2]) - !(s & data[3])); 363 + input_report_abs(dev, ABS_Y, 364 + !(s & data[0]) - !(s & data[1])); 365 + input_report_key(dev, BTN_TRIGGER, s & data[4]); 366 + input_sync(dev); 367 + break; 368 + 369 + default: 370 + break; 371 + } 511 372 } 512 373 } 513 374 ··· 549 398 module_param_named(psx_delay, gc_psx_delay, uint, 0); 550 399 MODULE_PARM_DESC(psx_delay, "Delay when accessing Sony PSX controller (usecs)"); 551 400 552 - static short gc_psx_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y }; 553 - static short gc_psx_btn[] = { BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_A, BTN_B, BTN_X, BTN_Y, 554 - BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR }; 555 - static short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 }; 401 + static const short gc_psx_abs[] = { 402 + ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y 403 + }; 404 + static const short gc_psx_btn[] = { 405 + BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_A, BTN_B, BTN_X, BTN_Y, 406 + BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR 407 + }; 408 + static const short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 }; 556 409 557 410 /* 558 411 * gc_psx_command() writes 8bit command and reads 8bit data from 559 412 * the psx pad. 560 413 */ 561 414 562 - static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVICES]) 415 + static void gc_psx_command(struct gc *gc, int b, unsigned char *data) 563 416 { 417 + struct parport *port = gc->pd->port; 564 418 int i, j, cmd, read; 565 419 566 - for (i = 0; i < GC_MAX_DEVICES; i++) 567 - data[i] = 0; 420 + memset(data, 0, GC_MAX_DEVICES); 568 421 569 422 for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) { 570 423 cmd = (b & 1) ? GC_PSX_COMMAND : 0; 571 - parport_write_data(gc->pd->port, cmd | GC_PSX_POWER); 424 + parport_write_data(port, cmd | GC_PSX_POWER); 572 425 udelay(gc_psx_delay); 573 - read = parport_read_status(gc->pd->port) ^ 0x80; 574 - for (j = 0; j < GC_MAX_DEVICES; j++) 575 - data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0; 426 + 427 + read = parport_read_status(port) ^ 0x80; 428 + 429 + for (j = 0; j < GC_MAX_DEVICES; j++) { 430 + struct gc_pad *pad = &gc->pads[i]; 431 + 432 + if (pad->type == GC_PSX || pad->type == GC_DDR) 433 + data[j] |= (read & gc_status_bit[j]) ? (1 << i) : 0; 434 + } 435 + 576 436 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); 577 437 udelay(gc_psx_delay); 578 438 } ··· 594 432 * device identifier code. 595 433 */ 596 434 597 - static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES], 435 + static void gc_psx_read_packet(struct gc *gc, 436 + unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES], 598 437 unsigned char id[GC_MAX_DEVICES]) 599 438 { 600 439 int i, j, max_len = 0; 601 440 unsigned long flags; 602 441 unsigned char data2[GC_MAX_DEVICES]; 603 442 604 - parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */ 443 + /* Select pad */ 444 + parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); 605 445 udelay(gc_psx_delay); 606 - parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); /* Deselect, begin command */ 446 + /* Deselect, begin command */ 447 + parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_POWER); 607 448 udelay(gc_psx_delay); 608 449 609 450 local_irq_save(flags); 610 451 611 - gc_psx_command(gc, 0x01, data2); /* Access pad */ 612 - gc_psx_command(gc, 0x42, id); /* Get device ids */ 613 - gc_psx_command(gc, 0, data2); /* Dump status */ 452 + gc_psx_command(gc, 0x01, data2); /* Access pad */ 453 + gc_psx_command(gc, 0x42, id); /* Get device ids */ 454 + gc_psx_command(gc, 0, data2); /* Dump status */ 614 455 615 - for (i =0; i < GC_MAX_DEVICES; i++) /* Find the longest pad */ 616 - if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) 617 - && (GC_PSX_LEN(id[i]) > max_len) 618 - && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES)) 456 + /* Find the longest pad */ 457 + for (i = 0; i < GC_MAX_DEVICES; i++) { 458 + struct gc_pad *pad = &gc->pads[i]; 459 + 460 + if ((pad->type == GC_PSX || pad->type == GC_DDR) && 461 + GC_PSX_LEN(id[i]) > max_len && 462 + GC_PSX_LEN(id[i]) <= GC_PSX_BYTES) { 619 463 max_len = GC_PSX_LEN(id[i]); 464 + } 465 + } 620 466 621 - for (i = 0; i < max_len; i++) { /* Read in all the data */ 467 + /* Read in all the data */ 468 + for (i = 0; i < max_len; i++) { 622 469 gc_psx_command(gc, 0, data2); 623 470 for (j = 0; j < GC_MAX_DEVICES; j++) 624 471 data[j][i] = data2[j]; ··· 637 466 638 467 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); 639 468 640 - for(i = 0; i < GC_MAX_DEVICES; i++) /* Set id's to the real value */ 469 + /* Set id's to the real value */ 470 + for (i = 0; i < GC_MAX_DEVICES; i++) 641 471 id[i] = GC_PSX_ID(id[i]); 472 + } 473 + 474 + static void gc_psx_report_one(struct gc_pad *pad, unsigned char psx_type, 475 + unsigned char *data) 476 + { 477 + struct input_dev *dev = pad->dev; 478 + int i; 479 + 480 + switch (psx_type) { 481 + 482 + case GC_PSX_RUMBLE: 483 + 484 + input_report_key(dev, BTN_THUMBL, ~data[0] & 0x04); 485 + input_report_key(dev, BTN_THUMBR, ~data[0] & 0x02); 486 + 487 + case GC_PSX_NEGCON: 488 + case GC_PSX_ANALOG: 489 + 490 + if (pad->type == GC_DDR) { 491 + for (i = 0; i < 4; i++) 492 + input_report_key(dev, gc_psx_ddr_btn[i], 493 + ~data[0] & (0x10 << i)); 494 + } else { 495 + for (i = 0; i < 4; i++) 496 + input_report_abs(dev, gc_psx_abs[i + 2], 497 + data[i + 2]); 498 + 499 + input_report_abs(dev, ABS_X, 500 + !!(data[0] & 0x80) * 128 + !(data[0] & 0x20) * 127); 501 + input_report_abs(dev, ABS_Y, 502 + !!(data[0] & 0x10) * 128 + !(data[0] & 0x40) * 127); 503 + } 504 + 505 + for (i = 0; i < 8; i++) 506 + input_report_key(dev, gc_psx_btn[i], ~data[1] & (1 << i)); 507 + 508 + input_report_key(dev, BTN_START, ~data[0] & 0x08); 509 + input_report_key(dev, BTN_SELECT, ~data[0] & 0x01); 510 + 511 + input_sync(dev); 512 + 513 + break; 514 + 515 + case GC_PSX_NORMAL: 516 + 517 + if (pad->type == GC_DDR) { 518 + for (i = 0; i < 4; i++) 519 + input_report_key(dev, gc_psx_ddr_btn[i], 520 + ~data[0] & (0x10 << i)); 521 + } else { 522 + input_report_abs(dev, ABS_X, 523 + !!(data[0] & 0x80) * 128 + !(data[0] & 0x20) * 127); 524 + input_report_abs(dev, ABS_Y, 525 + !!(data[0] & 0x10) * 128 + !(data[0] & 0x40) * 127); 526 + 527 + /* 528 + * For some reason if the extra axes are left unset 529 + * they drift. 530 + * for (i = 0; i < 4; i++) 531 + input_report_abs(dev, gc_psx_abs[i + 2], 128); 532 + * This needs to be debugged properly, 533 + * maybe fuzz processing needs to be done 534 + * in input_sync() 535 + * --vojtech 536 + */ 537 + } 538 + 539 + for (i = 0; i < 8; i++) 540 + input_report_key(dev, gc_psx_btn[i], ~data[1] & (1 << i)); 541 + 542 + input_report_key(dev, BTN_START, ~data[0] & 0x08); 543 + input_report_key(dev, BTN_SELECT, ~data[0] & 0x01); 544 + 545 + input_sync(dev); 546 + 547 + break; 548 + 549 + default: /* not a pad, ignore */ 550 + break; 551 + } 642 552 } 643 553 644 554 static void gc_psx_process_packet(struct gc *gc) 645 555 { 646 556 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES]; 647 557 unsigned char id[GC_MAX_DEVICES]; 648 - struct input_dev *dev; 649 - int i, j; 558 + struct gc_pad *pad; 559 + int i; 650 560 651 561 gc_psx_read_packet(gc, data, id); 652 562 653 563 for (i = 0; i < GC_MAX_DEVICES; i++) { 654 - 655 - dev = gc->dev[i]; 656 - if (!dev) 657 - continue; 658 - 659 - switch (id[i]) { 660 - 661 - case GC_PSX_RUMBLE: 662 - 663 - input_report_key(dev, BTN_THUMBL, ~data[i][0] & 0x04); 664 - input_report_key(dev, BTN_THUMBR, ~data[i][0] & 0x02); 665 - 666 - case GC_PSX_NEGCON: 667 - case GC_PSX_ANALOG: 668 - 669 - if (gc->pads[GC_DDR] & gc_status_bit[i]) { 670 - for(j = 0; j < 4; j++) 671 - input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j)); 672 - } else { 673 - for (j = 0; j < 4; j++) 674 - input_report_abs(dev, gc_psx_abs[j + 2], data[i][j + 2]); 675 - 676 - input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); 677 - input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128); 678 - } 679 - 680 - for (j = 0; j < 8; j++) 681 - input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j)); 682 - 683 - input_report_key(dev, BTN_START, ~data[i][0] & 0x08); 684 - input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01); 685 - 686 - input_sync(dev); 687 - 688 - break; 689 - 690 - case GC_PSX_NORMAL: 691 - if (gc->pads[GC_DDR] & gc_status_bit[i]) { 692 - for(j = 0; j < 4; j++) 693 - input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j)); 694 - } else { 695 - input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128); 696 - input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128); 697 - 698 - /* for some reason if the extra axes are left unset they drift */ 699 - /* for (j = 0; j < 4; j++) 700 - input_report_abs(dev, gc_psx_abs[j + 2], 128); 701 - * This needs to be debugged properly, 702 - * maybe fuzz processing needs to be done in input_sync() 703 - * --vojtech 704 - */ 705 - } 706 - 707 - for (j = 0; j < 8; j++) 708 - input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j)); 709 - 710 - input_report_key(dev, BTN_START, ~data[i][0] & 0x08); 711 - input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01); 712 - 713 - input_sync(dev); 714 - 715 - break; 716 - 717 - case 0: /* not a pad, ignore */ 718 - break; 719 - } 564 + pad = &gc->pads[i]; 565 + if (pad->type == GC_PSX || pad->type == GC_DDR) 566 + gc_psx_report_one(pad, id[i], data[i]); 720 567 } 721 568 } 722 569 ··· 750 561 * N64 pads - must be read first, any read confuses them for 200 us 751 562 */ 752 563 753 - if (gc->pads[GC_N64]) 564 + if (gc->pad_count[GC_N64]) 754 565 gc_n64_process_packet(gc); 755 566 756 567 /* 757 568 * NES and SNES pads or mouse 758 569 */ 759 570 760 - if (gc->pads[GC_NES] || gc->pads[GC_SNES] || gc->pads[GC_SNESMOUSE]) 571 + if (gc->pad_count[GC_NES] || 572 + gc->pad_count[GC_SNES] || 573 + gc->pad_count[GC_SNESMOUSE]) { 761 574 gc_nes_process_packet(gc); 575 + } 762 576 763 577 /* 764 578 * Multi and Multi2 joysticks 765 579 */ 766 580 767 - if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) 581 + if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2]) 768 582 gc_multi_process_packet(gc); 769 583 770 584 /* 771 585 * PSX controllers 772 586 */ 773 587 774 - if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) 588 + if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR]) 775 589 gc_psx_process_packet(gc); 776 590 777 591 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); ··· 814 622 815 623 static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) 816 624 { 625 + struct gc_pad *pad = &gc->pads[idx]; 817 626 struct input_dev *input_dev; 818 627 int i; 819 - 820 - if (!pad_type) 821 - return 0; 628 + int err; 822 629 823 630 if (pad_type < 1 || pad_type > GC_MAX) { 824 - printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", pad_type); 631 + pr_err("Pad type %d unknown\n", pad_type); 825 632 return -EINVAL; 826 633 } 827 634 828 - gc->dev[idx] = input_dev = input_allocate_device(); 635 + pad->dev = input_dev = input_allocate_device(); 829 636 if (!input_dev) { 830 - printk(KERN_ERR "gamecon.c: Not enough memory for input device\n"); 637 + pr_err("Not enough memory for input device\n"); 831 638 return -ENOMEM; 832 639 } 833 640 641 + pad->type = pad_type; 642 + 643 + snprintf(pad->phys, sizeof(pad->phys), 644 + "%s/input%d", gc->pd->port->name, idx); 645 + 834 646 input_dev->name = gc_names[pad_type]; 835 - input_dev->phys = gc->phys[idx]; 647 + input_dev->phys = pad->phys; 836 648 input_dev->id.bustype = BUS_PARPORT; 837 649 input_dev->id.vendor = 0x0001; 838 650 input_dev->id.product = pad_type; ··· 855 659 } else 856 660 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 857 661 858 - gc->pads[0] |= gc_status_bit[idx]; 859 - gc->pads[pad_type] |= gc_status_bit[idx]; 662 + gc->pad_count[pad_type]++; 860 663 861 664 switch (pad_type) { 862 665 863 - case GC_N64: 864 - for (i = 0; i < 10; i++) 865 - set_bit(gc_n64_btn[i], input_dev->keybit); 666 + case GC_N64: 667 + for (i = 0; i < 10; i++) 668 + __set_bit(gc_n64_btn[i], input_dev->keybit); 866 669 867 - for (i = 0; i < 2; i++) { 868 - input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2); 869 - input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); 870 - } 670 + for (i = 0; i < 2; i++) { 671 + input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2); 672 + input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); 673 + } 871 674 872 - break; 675 + err = gc_n64_init_ff(input_dev, idx); 676 + if (err) { 677 + pr_warning("Failed to initiate rumble for N64 device %d\n", idx); 678 + goto err_free_dev; 679 + } 873 680 874 - case GC_SNESMOUSE: 875 - set_bit(BTN_LEFT, input_dev->keybit); 876 - set_bit(BTN_RIGHT, input_dev->keybit); 877 - set_bit(REL_X, input_dev->relbit); 878 - set_bit(REL_Y, input_dev->relbit); 879 - break; 681 + break; 880 682 881 - case GC_SNES: 882 - for (i = 4; i < 8; i++) 883 - set_bit(gc_snes_btn[i], input_dev->keybit); 884 - case GC_NES: 885 - for (i = 0; i < 4; i++) 886 - set_bit(gc_snes_btn[i], input_dev->keybit); 887 - break; 683 + case GC_SNESMOUSE: 684 + __set_bit(BTN_LEFT, input_dev->keybit); 685 + __set_bit(BTN_RIGHT, input_dev->keybit); 686 + __set_bit(REL_X, input_dev->relbit); 687 + __set_bit(REL_Y, input_dev->relbit); 688 + break; 888 689 889 - case GC_MULTI2: 890 - set_bit(BTN_THUMB, input_dev->keybit); 891 - case GC_MULTI: 892 - set_bit(BTN_TRIGGER, input_dev->keybit); 893 - break; 690 + case GC_SNES: 691 + for (i = 4; i < 8; i++) 692 + __set_bit(gc_snes_btn[i], input_dev->keybit); 693 + case GC_NES: 694 + for (i = 0; i < 4; i++) 695 + __set_bit(gc_snes_btn[i], input_dev->keybit); 696 + break; 894 697 895 - case GC_PSX: 896 - for (i = 0; i < 6; i++) 897 - input_set_abs_params(input_dev, gc_psx_abs[i], 4, 252, 0, 2); 898 - for (i = 0; i < 12; i++) 899 - set_bit(gc_psx_btn[i], input_dev->keybit); 698 + case GC_MULTI2: 699 + __set_bit(BTN_THUMB, input_dev->keybit); 700 + case GC_MULTI: 701 + __set_bit(BTN_TRIGGER, input_dev->keybit); 702 + break; 900 703 901 - break; 704 + case GC_PSX: 705 + for (i = 0; i < 6; i++) 706 + input_set_abs_params(input_dev, 707 + gc_psx_abs[i], 4, 252, 0, 2); 708 + for (i = 0; i < 12; i++) 709 + __set_bit(gc_psx_btn[i], input_dev->keybit); 902 710 903 - case GC_DDR: 904 - for (i = 0; i < 4; i++) 905 - set_bit(gc_psx_ddr_btn[i], input_dev->keybit); 906 - for (i = 0; i < 12; i++) 907 - set_bit(gc_psx_btn[i], input_dev->keybit); 711 + break; 908 712 909 - break; 713 + case GC_DDR: 714 + for (i = 0; i < 4; i++) 715 + __set_bit(gc_psx_ddr_btn[i], input_dev->keybit); 716 + for (i = 0; i < 12; i++) 717 + __set_bit(gc_psx_btn[i], input_dev->keybit); 718 + 719 + break; 910 720 } 911 721 722 + err = input_register_device(pad->dev); 723 + if (err) 724 + goto err_free_dev; 725 + 912 726 return 0; 727 + 728 + err_free_dev: 729 + input_free_device(pad->dev); 730 + pad->dev = NULL; 731 + return err; 913 732 } 914 733 915 734 static struct gc __init *gc_probe(int parport, int *pads, int n_pads) ··· 933 722 struct parport *pp; 934 723 struct pardevice *pd; 935 724 int i; 725 + int count = 0; 936 726 int err; 937 727 938 728 pp = parport_find_number(parport); 939 729 if (!pp) { 940 - printk(KERN_ERR "gamecon.c: no such parport\n"); 730 + pr_err("no such parport %d\n", parport); 941 731 err = -EINVAL; 942 732 goto err_out; 943 733 } 944 734 945 735 pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 946 736 if (!pd) { 947 - printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n"); 737 + pr_err("parport busy already - lp.o loaded?\n"); 948 738 err = -EBUSY; 949 739 goto err_put_pp; 950 740 } 951 741 952 742 gc = kzalloc(sizeof(struct gc), GFP_KERNEL); 953 743 if (!gc) { 954 - printk(KERN_ERR "gamecon.c: Not enough memory\n"); 744 + pr_err("Not enough memory\n"); 955 745 err = -ENOMEM; 956 746 goto err_unreg_pardev; 957 747 } 958 748 959 749 mutex_init(&gc->mutex); 960 750 gc->pd = pd; 961 - init_timer(&gc->timer); 962 - gc->timer.data = (long) gc; 963 - gc->timer.function = gc_timer; 751 + setup_timer(&gc->timer, gc_timer, (long) gc); 964 752 965 753 for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) { 966 754 if (!pads[i]) 967 755 continue; 968 756 969 - snprintf(gc->phys[i], sizeof(gc->phys[i]), 970 - "%s/input%d", gc->pd->port->name, i); 971 757 err = gc_setup_pad(gc, i, pads[i]); 972 758 if (err) 973 759 goto err_unreg_devs; 974 760 975 - err = input_register_device(gc->dev[i]); 976 - if (err) 977 - goto err_free_dev; 761 + count++; 978 762 } 979 763 980 - if (!gc->pads[0]) { 981 - printk(KERN_ERR "gamecon.c: No valid devices specified\n"); 764 + if (count == 0) { 765 + pr_err("No valid devices specified\n"); 982 766 err = -EINVAL; 983 767 goto err_free_gc; 984 768 } ··· 981 775 parport_put_port(pp); 982 776 return gc; 983 777 984 - err_free_dev: 985 - input_free_device(gc->dev[i]); 986 778 err_unreg_devs: 987 779 while (--i >= 0) 988 - if (gc->dev[i]) 989 - input_unregister_device(gc->dev[i]); 780 + if (gc->pads[i].dev) 781 + input_unregister_device(gc->pads[i].dev); 990 782 err_free_gc: 991 783 kfree(gc); 992 784 err_unreg_pardev: ··· 1000 796 int i; 1001 797 1002 798 for (i = 0; i < GC_MAX_DEVICES; i++) 1003 - if (gc->dev[i]) 1004 - input_unregister_device(gc->dev[i]); 799 + if (gc->pads[i].dev) 800 + input_unregister_device(gc->pads[i].dev); 1005 801 parport_unregister_device(gc->pd); 1006 802 kfree(gc); 1007 803 } ··· 1017 813 continue; 1018 814 1019 815 if (gc_cfg[i].nargs < 2) { 1020 - printk(KERN_ERR "gamecon.c: at least one device must be specified\n"); 816 + pr_err("at least one device must be specified\n"); 1021 817 err = -EINVAL; 1022 818 break; 1023 819 }
+158 -95
drivers/input/joystick/xpad.c
··· 86 86 87 87 /* xbox d-pads should map to buttons, as is required for DDR pads 88 88 but we map them to axes when possible to simplify things */ 89 - #define MAP_DPAD_TO_BUTTONS 0 90 - #define MAP_DPAD_TO_AXES 1 91 - #define MAP_DPAD_UNKNOWN 2 89 + #define MAP_DPAD_TO_BUTTONS (1 << 0) 90 + #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) 92 91 93 92 #define XTYPE_XBOX 0 94 93 #define XTYPE_XBOX360 1 ··· 98 99 module_param(dpad_to_buttons, bool, S_IRUGO); 99 100 MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads"); 100 101 102 + static int triggers_to_buttons; 103 + module_param(triggers_to_buttons, bool, S_IRUGO); 104 + MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads"); 105 + 101 106 static const struct xpad_device { 102 107 u16 idVendor; 103 108 u16 idProduct; 104 109 char *name; 105 - u8 dpad_mapping; 110 + u8 mapping; 106 111 u8 xtype; 107 112 } xpad_device[] = { 108 - { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 109 - { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 110 - { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 111 - { 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 113 + { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX }, 114 + { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX }, 115 + { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX }, 116 + { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX }, 112 117 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 113 118 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 114 - { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 115 - { 0x046d, 0xc242, "Logitech Chillstream Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 116 - { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 117 - { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 118 - { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 119 - { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 120 - { 0x0738, 0x4516, "Mad Catz Control Pad", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 121 - { 0x0738, 0x4522, "Mad Catz LumiCON", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 122 - { 0x0738, 0x4526, "Mad Catz Control Pad Pro", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 123 - { 0x0738, 0x4536, "Mad Catz MicroCON", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 119 + { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, 120 + { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, 121 + { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, 122 + { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX }, 123 + { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX }, 124 + { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX }, 125 + { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX }, 126 + { 0x0738, 0x4522, "Mad Catz LumiCON", 0, XTYPE_XBOX }, 127 + { 0x0738, 0x4526, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX }, 128 + { 0x0738, 0x4536, "Mad Catz MicroCON", 0, XTYPE_XBOX }, 124 129 { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 125 - { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 126 - { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 127 - { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 130 + { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX }, 131 + { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, 132 + { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 128 133 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 129 - { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 130 - { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 131 - { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 132 - { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 133 - { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 134 - { 0x0e4c, 0x2390, "Radica Games Jtech Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 135 - { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 136 - { 0x0e6f, 0x0005, "Eclipse wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 137 - { 0x0e6f, 0x0006, "Edge wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 138 - { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 139 - { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 140 - { 0x0f30, 0x0202, "Joytech Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 141 - { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 142 - { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 134 + { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX }, 135 + { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX }, 136 + { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX }, 137 + { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX }, 138 + { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX }, 139 + { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX }, 140 + { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX }, 141 + { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX }, 142 + { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX }, 143 + { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, 144 + { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX }, 145 + { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, 146 + { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, 147 + { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX }, 143 148 { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 144 - { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 149 + { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 }, 145 150 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 146 - { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 147 - { 0x045e, 0x028e, "Microsoft X-Box 360 pad", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 151 + { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, 152 + { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, 148 153 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 149 - { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 150 - { 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 151 - { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN, XTYPE_UNKNOWN } 154 + { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 155 + { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, 156 + { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } 152 157 }; 153 158 154 159 /* buttons shared with xbox and xbox360 */ ··· 168 165 -1 /* terminating entry */ 169 166 }; 170 167 171 - /* only used if MAP_DPAD_TO_BUTTONS */ 168 + /* used when dpad is mapped to nuttons */ 172 169 static const signed short xpad_btn_pad[] = { 173 170 BTN_LEFT, BTN_RIGHT, /* d-pad left, right */ 174 171 BTN_0, BTN_1, /* d-pad up, down (XXX names??) */ 175 172 -1 /* terminating entry */ 176 173 }; 174 + 175 + /* used when triggers are mapped to buttons */ 176 + static const signed short xpad_btn_triggers[] = { 177 + BTN_TL2, BTN_TR2, /* triggers left/right */ 178 + -1 179 + }; 180 + 177 181 178 182 static const signed short xpad360_btn[] = { /* buttons for x360 controller */ 179 183 BTN_TL, BTN_TR, /* Button LB/RB */ ··· 191 181 static const signed short xpad_abs[] = { 192 182 ABS_X, ABS_Y, /* left stick */ 193 183 ABS_RX, ABS_RY, /* right stick */ 194 - ABS_Z, ABS_RZ, /* triggers left/right */ 195 184 -1 /* terminating entry */ 196 185 }; 197 186 198 - /* only used if MAP_DPAD_TO_AXES */ 187 + /* used when dpad is mapped to axes */ 199 188 static const signed short xpad_abs_pad[] = { 200 189 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */ 201 190 -1 /* terminating entry */ 191 + }; 192 + 193 + /* used when triggers are mapped to axes */ 194 + static const signed short xpad_abs_triggers[] = { 195 + ABS_Z, ABS_RZ, /* triggers left/right */ 196 + -1 202 197 }; 203 198 204 199 /* Xbox 360 has a vendor-specific class, so we cannot match it with only ··· 261 246 262 247 char phys[64]; /* physical device path */ 263 248 264 - int dpad_mapping; /* map d-pad to buttons or to axes */ 249 + int mapping; /* map d-pad to buttons or to axes */ 265 250 int xtype; /* type of xbox device */ 266 251 }; 267 252 ··· 292 277 ~(__s16) le16_to_cpup((__le16 *)(data + 18))); 293 278 294 279 /* triggers left/right */ 295 - input_report_abs(dev, ABS_Z, data[10]); 296 - input_report_abs(dev, ABS_RZ, data[11]); 280 + if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { 281 + input_report_key(dev, BTN_TL2, data[10]); 282 + input_report_key(dev, BTN_TR2, data[11]); 283 + } else { 284 + input_report_abs(dev, ABS_Z, data[10]); 285 + input_report_abs(dev, ABS_RZ, data[11]); 286 + } 297 287 298 288 /* digital pad */ 299 - if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) { 300 - input_report_abs(dev, ABS_HAT0X, 301 - !!(data[2] & 0x08) - !!(data[2] & 0x04)); 302 - input_report_abs(dev, ABS_HAT0Y, 303 - !!(data[2] & 0x02) - !!(data[2] & 0x01)); 304 - } else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ { 289 + if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 305 290 input_report_key(dev, BTN_LEFT, data[2] & 0x04); 306 291 input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 307 292 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ 308 293 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ 294 + } else { 295 + input_report_abs(dev, ABS_HAT0X, 296 + !!(data[2] & 0x08) - !!(data[2] & 0x04)); 297 + input_report_abs(dev, ABS_HAT0Y, 298 + !!(data[2] & 0x02) - !!(data[2] & 0x01)); 309 299 } 310 300 311 301 /* start/back buttons and stick press left/right */ ··· 348 328 struct input_dev *dev = xpad->dev; 349 329 350 330 /* digital pad */ 351 - if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) { 352 - input_report_abs(dev, ABS_HAT0X, 353 - !!(data[2] & 0x08) - !!(data[2] & 0x04)); 354 - input_report_abs(dev, ABS_HAT0Y, 355 - !!(data[2] & 0x02) - !!(data[2] & 0x01)); 356 - } else if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS) { 331 + if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 357 332 /* dpad as buttons (right, left, down, up) */ 358 333 input_report_key(dev, BTN_LEFT, data[2] & 0x04); 359 334 input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 360 335 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ 361 336 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ 337 + } else { 338 + input_report_abs(dev, ABS_HAT0X, 339 + !!(data[2] & 0x08) - !!(data[2] & 0x04)); 340 + input_report_abs(dev, ABS_HAT0Y, 341 + !!(data[2] & 0x02) - !!(data[2] & 0x01)); 362 342 } 363 343 364 344 /* start/back buttons */ ··· 391 371 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); 392 372 393 373 /* triggers left/right */ 394 - input_report_abs(dev, ABS_Z, data[4]); 395 - input_report_abs(dev, ABS_RZ, data[5]); 374 + if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { 375 + input_report_key(dev, BTN_TL2, data[4]); 376 + input_report_key(dev, BTN_TR2, data[5]); 377 + } else { 378 + input_report_abs(dev, ABS_Z, data[4]); 379 + input_report_abs(dev, ABS_RZ, data[5]); 380 + } 396 381 397 382 input_sync(dev); 398 383 } ··· 530 505 struct usb_endpoint_descriptor *ep_irq_out; 531 506 int error = -ENOMEM; 532 507 533 - if (xpad->xtype != XTYPE_XBOX360) 508 + if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX) 534 509 return 0; 535 510 536 511 xpad->odata = usb_buffer_alloc(xpad->udev, XPAD_PKT_LEN, ··· 560 535 561 536 static void xpad_stop_output(struct usb_xpad *xpad) 562 537 { 563 - if (xpad->xtype == XTYPE_XBOX360) 538 + if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX) 564 539 usb_kill_urb(xpad->irq_out); 565 540 } 566 541 567 542 static void xpad_deinit_output(struct usb_xpad *xpad) 568 543 { 569 - if (xpad->xtype == XTYPE_XBOX360) { 544 + if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX) { 570 545 usb_free_urb(xpad->irq_out); 571 546 usb_buffer_free(xpad->udev, XPAD_PKT_LEN, 572 547 xpad->odata, xpad->odata_dma); ··· 579 554 #endif 580 555 581 556 #ifdef CONFIG_JOYSTICK_XPAD_FF 582 - static int xpad_play_effect(struct input_dev *dev, void *data, 583 - struct ff_effect *effect) 557 + static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) 584 558 { 585 559 struct usb_xpad *xpad = input_get_drvdata(dev); 586 560 587 561 if (effect->type == FF_RUMBLE) { 588 562 __u16 strong = effect->u.rumble.strong_magnitude; 589 563 __u16 weak = effect->u.rumble.weak_magnitude; 590 - xpad->odata[0] = 0x00; 591 - xpad->odata[1] = 0x08; 592 - xpad->odata[2] = 0x00; 593 - xpad->odata[3] = strong / 256; 594 - xpad->odata[4] = weak / 256; 595 - xpad->odata[5] = 0x00; 596 - xpad->odata[6] = 0x00; 597 - xpad->odata[7] = 0x00; 598 - xpad->irq_out->transfer_buffer_length = 8; 599 - usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 564 + 565 + switch (xpad->xtype) { 566 + 567 + case XTYPE_XBOX: 568 + xpad->odata[0] = 0x00; 569 + xpad->odata[1] = 0x06; 570 + xpad->odata[2] = 0x00; 571 + xpad->odata[3] = strong / 256; /* left actuator */ 572 + xpad->odata[4] = 0x00; 573 + xpad->odata[5] = weak / 256; /* right actuator */ 574 + xpad->irq_out->transfer_buffer_length = 6; 575 + 576 + return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 577 + 578 + case XTYPE_XBOX360: 579 + xpad->odata[0] = 0x00; 580 + xpad->odata[1] = 0x08; 581 + xpad->odata[2] = 0x00; 582 + xpad->odata[3] = strong / 256; /* left actuator? */ 583 + xpad->odata[4] = weak / 256; /* right actuator? */ 584 + xpad->odata[5] = 0x00; 585 + xpad->odata[6] = 0x00; 586 + xpad->odata[7] = 0x00; 587 + xpad->irq_out->transfer_buffer_length = 8; 588 + 589 + return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 590 + 591 + default: 592 + dbg("%s - rumble command sent to unsupported xpad type: %d", 593 + __func__, xpad->xtype); 594 + return -1; 595 + } 600 596 } 601 597 602 598 return 0; ··· 625 579 626 580 static int xpad_init_ff(struct usb_xpad *xpad) 627 581 { 628 - if (xpad->xtype != XTYPE_XBOX360) 582 + if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX) 629 583 return 0; 630 584 631 585 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); ··· 758 712 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); 759 713 break; 760 714 case ABS_Z: 761 - case ABS_RZ: /* the triggers */ 715 + case ABS_RZ: /* the triggers (if mapped to axes) */ 762 716 input_set_abs_params(input_dev, abs, 0, 255, 0, 0); 763 717 break; 764 718 case ABS_HAT0X: 765 - case ABS_HAT0Y: /* the d-pad (only if MAP_DPAD_TO_AXES) */ 719 + case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ 766 720 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); 767 721 break; 768 722 } ··· 798 752 goto fail2; 799 753 800 754 xpad->udev = udev; 801 - xpad->dpad_mapping = xpad_device[i].dpad_mapping; 755 + xpad->mapping = xpad_device[i].mapping; 802 756 xpad->xtype = xpad_device[i].xtype; 803 - if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN) 804 - xpad->dpad_mapping = !dpad_to_buttons; 757 + 805 758 if (xpad->xtype == XTYPE_UNKNOWN) { 806 759 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { 807 760 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) ··· 809 764 xpad->xtype = XTYPE_XBOX360; 810 765 } else 811 766 xpad->xtype = XTYPE_XBOX; 767 + 768 + if (dpad_to_buttons) 769 + xpad->mapping |= MAP_DPAD_TO_BUTTONS; 770 + if (triggers_to_buttons) 771 + xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; 812 772 } 773 + 813 774 xpad->dev = input_dev; 814 775 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); 815 776 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); ··· 832 781 833 782 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 834 783 835 - /* set up buttons */ 784 + /* set up standard buttons and axes */ 836 785 for (i = 0; xpad_common_btn[i] >= 0; i++) 837 - set_bit(xpad_common_btn[i], input_dev->keybit); 838 - if ((xpad->xtype == XTYPE_XBOX360) || (xpad->xtype == XTYPE_XBOX360W)) 839 - for (i = 0; xpad360_btn[i] >= 0; i++) 840 - set_bit(xpad360_btn[i], input_dev->keybit); 841 - else 842 - for (i = 0; xpad_btn[i] >= 0; i++) 843 - set_bit(xpad_btn[i], input_dev->keybit); 844 - if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS) 845 - for (i = 0; xpad_btn_pad[i] >= 0; i++) 846 - set_bit(xpad_btn_pad[i], input_dev->keybit); 786 + __set_bit(xpad_common_btn[i], input_dev->keybit); 847 787 848 - /* set up axes */ 849 788 for (i = 0; xpad_abs[i] >= 0; i++) 850 789 xpad_set_up_abs(input_dev, xpad_abs[i]); 851 - if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) 790 + 791 + /* Now set up model-specific ones */ 792 + if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) { 793 + for (i = 0; xpad360_btn[i] >= 0; i++) 794 + __set_bit(xpad360_btn[i], input_dev->keybit); 795 + } else { 796 + for (i = 0; xpad_btn[i] >= 0; i++) 797 + __set_bit(xpad_btn[i], input_dev->keybit); 798 + } 799 + 800 + if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 801 + for (i = 0; xpad_btn_pad[i] >= 0; i++) 802 + __set_bit(xpad_btn_pad[i], input_dev->keybit); 803 + } else { 852 804 for (i = 0; xpad_abs_pad[i] >= 0; i++) 853 805 xpad_set_up_abs(input_dev, xpad_abs_pad[i]); 806 + } 807 + 808 + if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { 809 + for (i = 0; xpad_btn_triggers[i] >= 0; i++) 810 + __set_bit(xpad_btn_triggers[i], input_dev->keybit); 811 + } else { 812 + for (i = 0; xpad_abs_triggers[i] >= 0; i++) 813 + xpad_set_up_abs(input_dev, xpad_abs_triggers[i]); 814 + } 854 815 855 816 error = xpad_init_output(intf, xpad); 856 817 if (error)
+24 -9
drivers/input/keyboard/Kconfig
··· 35 35 be called adp5520-keys. 36 36 37 37 config KEYBOARD_ADP5588 38 - tristate "ADP5588 I2C QWERTY Keypad and IO Expander" 38 + tristate "ADP5588/87 I2C QWERTY Keypad and IO Expander" 39 39 depends on I2C 40 40 help 41 - Say Y here if you want to use a ADP5588 attached to your 41 + Say Y here if you want to use a ADP5588/87 attached to your 42 42 system I2C bus. 43 43 44 44 To compile this driver as a module, choose M here: the ··· 144 144 module will be called bf54x-keys. 145 145 146 146 config KEYBOARD_CORGI 147 - tristate "Corgi keyboard" 147 + tristate "Corgi keyboard (deprecated)" 148 148 depends on PXA_SHARPSL 149 - default y 150 149 help 151 150 Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx 152 151 series of PDAs. 152 + 153 + This driver is now deprecated, use generic GPIO based matrix 154 + keyboard driver instead. 153 155 154 156 To compile this driver as a module, choose M here: the 155 157 module will be called corgikbd. ··· 294 292 To compile this driver as a module, choose M here: the 295 293 module will be called max7359_keypad. 296 294 295 + config KEYBOARD_IMX 296 + tristate "IMX keypad support" 297 + depends on ARCH_MXC 298 + help 299 + Enable support for IMX keypad port. 300 + 301 + To compile this driver as a module, choose M here: the 302 + module will be called imx_keypad. 303 + 297 304 config KEYBOARD_NEWTON 298 305 tristate "Newton keyboard" 299 306 select SERIO ··· 340 329 module will be called pxa930_rotary. 341 330 342 331 config KEYBOARD_SPITZ 343 - tristate "Spitz keyboard" 332 + tristate "Spitz keyboard (deprecated)" 344 333 depends on PXA_SHARPSL 345 - default y 346 334 help 347 335 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000, 348 336 SL-C3000 and Sl-C3100 series of PDAs. 337 + 338 + This driver is now deprecated, use generic GPIO based matrix 339 + keyboard driver instead. 349 340 350 341 To compile this driver as a module, choose M here: the 351 342 module will be called spitzkbd. ··· 376 363 377 364 config KEYBOARD_SH_KEYSC 378 365 tristate "SuperH KEYSC keypad support" 379 - depends on SUPERH 366 + depends on SUPERH || ARCH_SHMOBILE 380 367 help 381 368 Say Y here if you want to use a keypad attached to the KEYSC block 382 369 on SuperH processors such as sh7722 and sh7343. ··· 415 402 module will be called twl4030_keypad. 416 403 417 404 config KEYBOARD_TOSA 418 - tristate "Tosa keyboard" 405 + tristate "Tosa keyboard (deprecated)" 419 406 depends on MACH_TOSA 420 - default y 421 407 help 422 408 Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa) 409 + 410 + This driver is now deprecated, use generic GPIO based matrix 411 + keyboard driver instead. 423 412 424 413 To compile this driver as a module, choose M here: the 425 414 module will be called tosakbd.
+1
drivers/input/keyboard/Makefile
··· 17 17 obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 18 18 obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 19 19 obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 20 + obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o 20 21 obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o 21 22 obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o 22 23 obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
+4 -2
drivers/input/keyboard/adp5588-keys.c
··· 1 1 /* 2 2 * File: drivers/input/keyboard/adp5588_keys.c 3 - * Description: keypad driver for ADP5588 I2C QWERTY Keypad and IO Expander 3 + * Description: keypad driver for ADP5588 and ADP5587 4 + * I2C QWERTY Keypad and IO Expander 4 5 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 5 6 * 6 7 * Copyright (C) 2008-2009 Analog Devices Inc. ··· 328 327 329 328 static const struct i2c_device_id adp5588_id[] = { 330 329 { KBUILD_MODNAME, 0 }, 330 + { "adp5587-keys", 0 }, 331 331 { } 332 332 }; 333 333 MODULE_DEVICE_TABLE(i2c, adp5588_id); ··· 359 357 360 358 MODULE_LICENSE("GPL"); 361 359 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 362 - MODULE_DESCRIPTION("ADP5588 Keypad driver"); 360 + MODULE_DESCRIPTION("ADP5588/87 Keypad driver"); 363 361 MODULE_ALIAS("platform:adp5588-keys");
+160 -147
drivers/input/keyboard/atkbd.c
··· 40 40 MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3 = PS/2 native)"); 41 41 42 42 #if defined(__i386__) || defined(__x86_64__) || defined(__hppa__) 43 - static int atkbd_reset; 43 + static bool atkbd_reset; 44 44 #else 45 - static int atkbd_reset = 1; 45 + static bool atkbd_reset = true; 46 46 #endif 47 47 module_param_named(reset, atkbd_reset, bool, 0); 48 48 MODULE_PARM_DESC(reset, "Reset keyboard during initialization"); 49 49 50 - static int atkbd_softrepeat; 50 + static bool atkbd_softrepeat; 51 51 module_param_named(softrepeat, atkbd_softrepeat, bool, 0); 52 52 MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat"); 53 53 54 - static int atkbd_softraw = 1; 54 + static bool atkbd_softraw = true; 55 55 module_param_named(softraw, atkbd_softraw, bool, 0); 56 56 MODULE_PARM_DESC(softraw, "Use software generated rawmode"); 57 57 58 - static int atkbd_scroll; 58 + static bool atkbd_scroll; 59 59 module_param_named(scroll, atkbd_scroll, bool, 0); 60 60 MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); 61 61 62 - static int atkbd_extra; 62 + static bool atkbd_extra; 63 63 module_param_named(extra, atkbd_extra, bool, 0); 64 64 MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards"); 65 65 ··· 153 153 #define ATKBD_RET_HANGEUL 0xf2 154 154 #define ATKBD_RET_ERR 0xff 155 155 156 - #define ATKBD_KEY_UNKNOWN 0 156 + #define ATKBD_KEY_UNKNOWN 0 157 157 #define ATKBD_KEY_NULL 255 158 158 159 - #define ATKBD_SCR_1 254 160 - #define ATKBD_SCR_2 253 161 - #define ATKBD_SCR_4 252 162 - #define ATKBD_SCR_8 251 163 - #define ATKBD_SCR_CLICK 250 164 - #define ATKBD_SCR_LEFT 249 165 - #define ATKBD_SCR_RIGHT 248 159 + #define ATKBD_SCR_1 0xfffe 160 + #define ATKBD_SCR_2 0xfffd 161 + #define ATKBD_SCR_4 0xfffc 162 + #define ATKBD_SCR_8 0xfffb 163 + #define ATKBD_SCR_CLICK 0xfffa 164 + #define ATKBD_SCR_LEFT 0xfff9 165 + #define ATKBD_SCR_RIGHT 0xfff8 166 166 167 167 #define ATKBD_SPECIAL ATKBD_SCR_RIGHT 168 168 ··· 177 177 #define ATKBD_XL_HANJA 0x20 178 178 179 179 static const struct { 180 - unsigned char keycode; 180 + unsigned short keycode; 181 181 unsigned char set2; 182 182 } atkbd_scroll_keys[] = { 183 183 { ATKBD_SCR_1, 0xc5 }, ··· 206 206 unsigned short keycode[ATKBD_KEYMAP_SIZE]; 207 207 DECLARE_BITMAP(force_release_mask, ATKBD_KEYMAP_SIZE); 208 208 unsigned char set; 209 - unsigned char translated; 210 - unsigned char extra; 211 - unsigned char write; 212 - unsigned char softrepeat; 213 - unsigned char softraw; 214 - unsigned char scroll; 215 - unsigned char enabled; 209 + bool translated; 210 + bool extra; 211 + bool write; 212 + bool softrepeat; 213 + bool softraw; 214 + bool scroll; 215 + bool enabled; 216 216 217 217 /* Accessed only from interrupt */ 218 218 unsigned char emul; 219 - unsigned char resend; 220 - unsigned char release; 219 + bool resend; 220 + bool release; 221 221 unsigned long xl_bit; 222 222 unsigned int last; 223 223 unsigned long time; ··· 301 301 * Checks if we should mangle the scancode to extract 'release' bit 302 302 * in translated mode. 303 303 */ 304 - static int atkbd_need_xlate(unsigned long xl_bit, unsigned char code) 304 + static bool atkbd_need_xlate(unsigned long xl_bit, unsigned char code) 305 305 { 306 306 int i; 307 307 308 308 if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1) 309 - return 0; 309 + return false; 310 310 311 311 for (i = 0; i < ARRAY_SIZE(xl_table); i++) 312 312 if (code == xl_table[i]) 313 313 return test_bit(i, &xl_bit); 314 314 315 - return 1; 315 + return true; 316 316 } 317 317 318 318 /* ··· 359 359 */ 360 360 361 361 static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, 362 - unsigned int flags) 362 + unsigned int flags) 363 363 { 364 364 struct atkbd *atkbd = serio_get_drvdata(serio); 365 365 struct input_dev *dev = atkbd->dev; ··· 368 368 int value; 369 369 unsigned short keycode; 370 370 371 - #ifdef ATKBD_DEBUG 372 - printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags); 373 - #endif 371 + dev_dbg(&serio->dev, "Received %02x flags %02x\n", data, flags); 374 372 375 373 #if !defined(__i386__) && !defined (__x86_64__) 376 374 if ((flags & (SERIO_FRAME | SERIO_PARITY)) && (~flags & SERIO_TIMEOUT) && !atkbd->resend && atkbd->write) { 377 - printk(KERN_WARNING "atkbd.c: frame/parity error: %02x\n", flags); 375 + dev_warn(&serio->dev, "Frame/parity error: %02x\n", flags); 378 376 serio_write(serio, ATKBD_CMD_RESEND); 379 - atkbd->resend = 1; 377 + atkbd->resend = true; 380 378 goto out; 381 379 } 382 380 383 381 if (!flags && data == ATKBD_RET_ACK) 384 - atkbd->resend = 0; 382 + atkbd->resend = false; 385 383 #endif 386 384 387 385 if (unlikely(atkbd->ps2dev.flags & PS2_FLAG_ACK)) ··· 410 412 } 411 413 412 414 switch (code) { 413 - case ATKBD_RET_BAT: 414 - atkbd->enabled = 0; 415 - serio_reconnect(atkbd->ps2dev.serio); 416 - goto out; 417 - case ATKBD_RET_EMUL0: 418 - atkbd->emul = 1; 419 - goto out; 420 - case ATKBD_RET_EMUL1: 421 - atkbd->emul = 2; 422 - goto out; 423 - case ATKBD_RET_RELEASE: 424 - atkbd->release = 1; 425 - goto out; 426 - case ATKBD_RET_ACK: 427 - case ATKBD_RET_NAK: 428 - if (printk_ratelimit()) 429 - printk(KERN_WARNING "atkbd.c: Spurious %s on %s. " 430 - "Some program might be trying access hardware directly.\n", 431 - data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); 432 - goto out; 433 - case ATKBD_RET_ERR: 434 - atkbd->err_count++; 435 - #ifdef ATKBD_DEBUG 436 - printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); 437 - #endif 438 - goto out; 415 + case ATKBD_RET_BAT: 416 + atkbd->enabled = false; 417 + serio_reconnect(atkbd->ps2dev.serio); 418 + goto out; 419 + case ATKBD_RET_EMUL0: 420 + atkbd->emul = 1; 421 + goto out; 422 + case ATKBD_RET_EMUL1: 423 + atkbd->emul = 2; 424 + goto out; 425 + case ATKBD_RET_RELEASE: 426 + atkbd->release = true; 427 + goto out; 428 + case ATKBD_RET_ACK: 429 + case ATKBD_RET_NAK: 430 + if (printk_ratelimit()) 431 + dev_warn(&serio->dev, 432 + "Spurious %s on %s. " 433 + "Some program might be trying access hardware directly.\n", 434 + data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); 435 + goto out; 436 + case ATKBD_RET_ERR: 437 + atkbd->err_count++; 438 + dev_dbg(&serio->dev, "Keyboard on %s reports too many keys pressed.\n", 439 + serio->phys); 440 + goto out; 439 441 } 440 442 441 443 code = atkbd_compat_scancode(atkbd, code); ··· 449 451 input_event(dev, EV_MSC, MSC_SCAN, code); 450 452 451 453 switch (keycode) { 452 - case ATKBD_KEY_NULL: 453 - break; 454 - case ATKBD_KEY_UNKNOWN: 455 - printk(KERN_WARNING 456 - "atkbd.c: Unknown key %s (%s set %d, code %#x on %s).\n", 457 - atkbd->release ? "released" : "pressed", 458 - atkbd->translated ? "translated" : "raw", 459 - atkbd->set, code, serio->phys); 460 - printk(KERN_WARNING 461 - "atkbd.c: Use 'setkeycodes %s%02x <keycode>' to make it known.\n", 462 - code & 0x80 ? "e0" : "", code & 0x7f); 463 - input_sync(dev); 464 - break; 465 - case ATKBD_SCR_1: 466 - scroll = 1 - atkbd->release * 2; 467 - break; 468 - case ATKBD_SCR_2: 469 - scroll = 2 - atkbd->release * 4; 470 - break; 471 - case ATKBD_SCR_4: 472 - scroll = 4 - atkbd->release * 8; 473 - break; 474 - case ATKBD_SCR_8: 475 - scroll = 8 - atkbd->release * 16; 476 - break; 477 - case ATKBD_SCR_CLICK: 478 - click = !atkbd->release; 479 - break; 480 - case ATKBD_SCR_LEFT: 481 - hscroll = -1; 482 - break; 483 - case ATKBD_SCR_RIGHT: 484 - hscroll = 1; 485 - break; 486 - default: 487 - if (atkbd->release) { 488 - value = 0; 489 - atkbd->last = 0; 490 - } else if (!atkbd->softrepeat && test_bit(keycode, dev->key)) { 491 - /* Workaround Toshiba laptop multiple keypress */ 492 - value = time_before(jiffies, atkbd->time) && atkbd->last == code ? 1 : 2; 493 - } else { 494 - value = 1; 495 - atkbd->last = code; 496 - atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2; 497 - } 454 + case ATKBD_KEY_NULL: 455 + break; 456 + case ATKBD_KEY_UNKNOWN: 457 + dev_warn(&serio->dev, 458 + "Unknown key %s (%s set %d, code %#x on %s).\n", 459 + atkbd->release ? "released" : "pressed", 460 + atkbd->translated ? "translated" : "raw", 461 + atkbd->set, code, serio->phys); 462 + dev_warn(&serio->dev, 463 + "Use 'setkeycodes %s%02x <keycode>' to make it known.\n", 464 + code & 0x80 ? "e0" : "", code & 0x7f); 465 + input_sync(dev); 466 + break; 467 + case ATKBD_SCR_1: 468 + scroll = 1; 469 + break; 470 + case ATKBD_SCR_2: 471 + scroll = 2; 472 + break; 473 + case ATKBD_SCR_4: 474 + scroll = 4; 475 + break; 476 + case ATKBD_SCR_8: 477 + scroll = 8; 478 + break; 479 + case ATKBD_SCR_CLICK: 480 + click = !atkbd->release; 481 + break; 482 + case ATKBD_SCR_LEFT: 483 + hscroll = -1; 484 + break; 485 + case ATKBD_SCR_RIGHT: 486 + hscroll = 1; 487 + break; 488 + default: 489 + if (atkbd->release) { 490 + value = 0; 491 + atkbd->last = 0; 492 + } else if (!atkbd->softrepeat && test_bit(keycode, dev->key)) { 493 + /* Workaround Toshiba laptop multiple keypress */ 494 + value = time_before(jiffies, atkbd->time) && atkbd->last == code ? 1 : 2; 495 + } else { 496 + value = 1; 497 + atkbd->last = code; 498 + atkbd->time = jiffies + msecs_to_jiffies(dev->rep[REP_DELAY]) / 2; 499 + } 498 500 499 - input_event(dev, EV_KEY, keycode, value); 500 - input_sync(dev); 501 + input_event(dev, EV_KEY, keycode, value); 502 + input_sync(dev); 501 503 502 - if (value && test_bit(code, atkbd->force_release_mask)) { 503 - input_report_key(dev, keycode, 0); 504 - input_sync(dev); 505 - } 504 + if (value && test_bit(code, atkbd->force_release_mask)) { 505 + input_report_key(dev, keycode, 0); 506 + input_sync(dev); 507 + } 506 508 } 507 509 508 510 if (atkbd->scroll) { 509 511 if (click != -1) 510 512 input_report_key(dev, BTN_MIDDLE, click); 511 - input_report_rel(dev, REL_WHEEL, scroll); 513 + input_report_rel(dev, REL_WHEEL, 514 + atkbd->release ? -scroll : scroll); 512 515 input_report_rel(dev, REL_HWHEEL, hscroll); 513 516 input_sync(dev); 514 517 } 515 518 516 - atkbd->release = 0; 519 + atkbd->release = false; 517 520 out: 518 521 return IRQ_HANDLED; 519 522 } ··· 633 634 634 635 switch (type) { 635 636 636 - case EV_LED: 637 - atkbd_schedule_event_work(atkbd, ATKBD_LED_EVENT_BIT); 638 - return 0; 637 + case EV_LED: 638 + atkbd_schedule_event_work(atkbd, ATKBD_LED_EVENT_BIT); 639 + return 0; 639 640 640 - case EV_REP: 641 - if (!atkbd->softrepeat) 642 - atkbd_schedule_event_work(atkbd, ATKBD_REP_EVENT_BIT); 643 - return 0; 641 + case EV_REP: 642 + if (!atkbd->softrepeat) 643 + atkbd_schedule_event_work(atkbd, ATKBD_REP_EVENT_BIT); 644 + return 0; 645 + 646 + default: 647 + return -1; 644 648 } 645 - 646 - return -1; 647 649 } 648 650 649 651 /* ··· 655 655 static inline void atkbd_enable(struct atkbd *atkbd) 656 656 { 657 657 serio_pause_rx(atkbd->ps2dev.serio); 658 - atkbd->enabled = 1; 658 + atkbd->enabled = true; 659 659 serio_continue_rx(atkbd->ps2dev.serio); 660 660 } 661 661 ··· 667 667 static inline void atkbd_disable(struct atkbd *atkbd) 668 668 { 669 669 serio_pause_rx(atkbd->ps2dev.serio); 670 - atkbd->enabled = 0; 670 + atkbd->enabled = false; 671 671 serio_continue_rx(atkbd->ps2dev.serio); 672 672 } 673 673 ··· 688 688 689 689 if (atkbd_reset) 690 690 if (ps2_command(ps2dev, NULL, ATKBD_CMD_RESET_BAT)) 691 - printk(KERN_WARNING "atkbd.c: keyboard reset failed on %s\n", ps2dev->serio->phys); 691 + dev_warn(&ps2dev->serio->dev, 692 + "keyboard reset failed on %s\n", 693 + ps2dev->serio->phys); 692 694 693 695 /* 694 696 * Then we check the keyboard ID. We should get 0xab83 under normal conditions. ··· 720 718 atkbd->id = (param[0] << 8) | param[1]; 721 719 722 720 if (atkbd->id == 0xaca1 && atkbd->translated) { 723 - printk(KERN_ERR "atkbd.c: NCD terminal keyboards are only supported on non-translating\n"); 724 - printk(KERN_ERR "atkbd.c: controllers. Use i8042.direct=1 to disable translation.\n"); 721 + dev_err(&ps2dev->serio->dev, 722 + "NCD terminal keyboards are only supported on non-translating controlelrs. " 723 + "Use i8042.direct=1 to disable translation.\n"); 725 724 return -1; 726 725 } 727 726 ··· 740 737 struct ps2dev *ps2dev = &atkbd->ps2dev; 741 738 unsigned char param[2]; 742 739 743 - atkbd->extra = 0; 740 + atkbd->extra = false; 744 741 /* 745 742 * For known special keyboards we can go ahead and set the correct set. 746 743 * We check for NCD PS/2 Sun, NorthGate OmniKey 101 and ··· 759 756 if (allow_extra) { 760 757 param[0] = 0x71; 761 758 if (!ps2_command(ps2dev, param, ATKBD_CMD_EX_ENABLE)) { 762 - atkbd->extra = 1; 759 + atkbd->extra = true; 763 760 return 2; 764 761 } 765 762 } ··· 824 821 */ 825 822 826 823 if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) { 827 - printk(KERN_ERR "atkbd.c: Failed to enable keyboard on %s\n", 824 + dev_err(&ps2dev->serio->dev, 825 + "Failed to enable keyboard on %s\n", 828 826 ps2dev->serio->phys); 829 827 return -1; 830 828 } ··· 1074 1070 input_dev->keycodesize = sizeof(unsigned short); 1075 1071 input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode); 1076 1072 1077 - for (i = 0; i < ATKBD_KEYMAP_SIZE; i++) 1078 - if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL) 1073 + for (i = 0; i < ATKBD_KEYMAP_SIZE; i++) { 1074 + if (atkbd->keycode[i] != KEY_RESERVED && 1075 + atkbd->keycode[i] != ATKBD_KEY_NULL && 1076 + atkbd->keycode[i] < ATKBD_SPECIAL) { 1079 1077 __set_bit(atkbd->keycode[i], input_dev->keybit); 1078 + } 1079 + } 1080 1080 } 1081 1081 1082 1082 /* ··· 1108 1100 1109 1101 switch (serio->id.type) { 1110 1102 1111 - case SERIO_8042_XL: 1112 - atkbd->translated = 1; 1113 - case SERIO_8042: 1114 - if (serio->write) 1115 - atkbd->write = 1; 1116 - break; 1103 + case SERIO_8042_XL: 1104 + atkbd->translated = true; 1105 + /* Fall through */ 1106 + 1107 + case SERIO_8042: 1108 + if (serio->write) 1109 + atkbd->write = true; 1110 + break; 1117 1111 } 1118 1112 1119 1113 atkbd->softraw = atkbd_softraw; ··· 1123 1113 atkbd->scroll = atkbd_scroll; 1124 1114 1125 1115 if (atkbd->softrepeat) 1126 - atkbd->softraw = 1; 1116 + atkbd->softraw = true; 1127 1117 1128 1118 serio_set_drvdata(serio, atkbd); 1129 1119 ··· 1182 1172 int retval = -1; 1183 1173 1184 1174 if (!atkbd || !drv) { 1185 - printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n"); 1175 + dev_dbg(&serio->dev, 1176 + "reconnect request, but serio is disconnected, ignoring...\n"); 1186 1177 return -1; 1187 1178 } 1188 1179 ··· 1297 1286 struct input_dev *old_dev, *new_dev; 1298 1287 unsigned long value; 1299 1288 int err; 1300 - unsigned char old_extra, old_set; 1289 + bool old_extra; 1290 + unsigned char old_set; 1301 1291 1302 1292 if (!atkbd->write) 1303 1293 return -EIO; ··· 1381 1369 struct input_dev *old_dev, *new_dev; 1382 1370 unsigned long value; 1383 1371 int err; 1384 - unsigned char old_scroll; 1372 + bool old_scroll; 1385 1373 1386 1374 if (strict_strtoul(buf, 10, &value) || value > 1) 1387 1375 return -EINVAL; ··· 1425 1413 struct input_dev *old_dev, *new_dev; 1426 1414 unsigned long value; 1427 1415 int err; 1428 - unsigned char old_set, old_extra; 1416 + unsigned char old_set; 1417 + bool old_extra; 1429 1418 1430 1419 if (!atkbd->write) 1431 1420 return -EIO; ··· 1476 1463 struct input_dev *old_dev, *new_dev; 1477 1464 unsigned long value; 1478 1465 int err; 1479 - unsigned char old_softrepeat, old_softraw; 1466 + bool old_softrepeat, old_softraw; 1480 1467 1481 1468 if (!atkbd->write) 1482 1469 return -EIO; ··· 1496 1483 atkbd->dev = new_dev; 1497 1484 atkbd->softrepeat = value; 1498 1485 if (atkbd->softrepeat) 1499 - atkbd->softraw = 1; 1486 + atkbd->softraw = true; 1500 1487 atkbd_set_device_attrs(atkbd); 1501 1488 1502 1489 err = input_register_device(atkbd->dev); ··· 1526 1513 struct input_dev *old_dev, *new_dev; 1527 1514 unsigned long value; 1528 1515 int err; 1529 - unsigned char old_softraw; 1516 + bool old_softraw; 1530 1517 1531 1518 if (strict_strtoul(buf, 10, &value) || value > 1) 1532 1519 return -EINVAL;
+15 -25
drivers/input/keyboard/ep93xx_keypad.c
··· 69 69 70 70 void __iomem *mmio_base; 71 71 72 - unsigned int matrix_keycodes[EP93XX_MATRIX_SIZE]; 72 + unsigned short keycodes[EP93XX_MATRIX_SIZE]; 73 73 74 74 int key1; 75 75 int key2; ··· 78 78 79 79 bool enabled; 80 80 }; 81 - 82 - static void ep93xx_keypad_build_keycode(struct ep93xx_keypad *keypad) 83 - { 84 - struct ep93xx_keypad_platform_data *pdata = keypad->pdata; 85 - struct input_dev *input_dev = keypad->input_dev; 86 - unsigned int *key; 87 - int i; 88 - 89 - key = &pdata->matrix_key_map[0]; 90 - for (i = 0; i < pdata->matrix_key_map_size; i++, key++) { 91 - int row = KEY_ROW(*key); 92 - int col = KEY_COL(*key); 93 - int code = KEY_VAL(*key); 94 - 95 - keypad->matrix_keycodes[(row << 3) + col] = code; 96 - __set_bit(code, input_dev->keybit); 97 - } 98 - } 99 81 100 82 static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id) 101 83 { ··· 89 107 status = __raw_readl(keypad->mmio_base + KEY_REG); 90 108 91 109 keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT; 92 - key1 = keypad->matrix_keycodes[keycode]; 110 + key1 = keypad->keycodes[keycode]; 93 111 94 112 keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT; 95 - key2 = keypad->matrix_keycodes[keycode]; 113 + key2 = keypad->keycodes[keycode]; 96 114 97 115 if (status & KEY_REG_2KEYS) { 98 116 if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1) ··· 238 256 static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) 239 257 { 240 258 struct ep93xx_keypad *keypad; 259 + const struct matrix_keymap_data *keymap_data; 241 260 struct input_dev *input_dev; 242 261 struct resource *res; 243 262 int err; ··· 249 266 250 267 keypad->pdata = pdev->dev.platform_data; 251 268 if (!keypad->pdata) { 269 + err = -EINVAL; 270 + goto failed_free; 271 + } 272 + 273 + keymap_data = keypad->pdata->keymap_data; 274 + if (!keymap_data) { 252 275 err = -EINVAL; 253 276 goto failed_free; 254 277 } ··· 306 317 input_dev->open = ep93xx_keypad_open; 307 318 input_dev->close = ep93xx_keypad_close; 308 319 input_dev->dev.parent = &pdev->dev; 309 - input_dev->keycode = keypad->matrix_keycodes; 310 - input_dev->keycodesize = sizeof(keypad->matrix_keycodes[0]); 311 - input_dev->keycodemax = ARRAY_SIZE(keypad->matrix_keycodes); 320 + input_dev->keycode = keypad->keycodes; 321 + input_dev->keycodesize = sizeof(keypad->keycodes[0]); 322 + input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); 312 323 313 324 input_set_drvdata(input_dev, keypad); 314 325 ··· 316 327 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) 317 328 input_dev->evbit[0] |= BIT_MASK(EV_REP); 318 329 319 - ep93xx_keypad_build_keycode(keypad); 330 + matrix_keypad_build_keymap(keymap_data, 3, 331 + input_dev->keycode, input_dev->keybit); 320 332 platform_set_drvdata(pdev, keypad); 321 333 322 334 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler,
+307 -11
drivers/input/keyboard/gpio_keys.c
··· 30 30 struct input_dev *input; 31 31 struct timer_list timer; 32 32 struct work_struct work; 33 + bool disabled; 33 34 }; 34 35 35 36 struct gpio_keys_drvdata { 36 37 struct input_dev *input; 38 + struct mutex disable_lock; 39 + unsigned int n_buttons; 37 40 struct gpio_button_data data[0]; 41 + }; 42 + 43 + /* 44 + * SYSFS interface for enabling/disabling keys and switches: 45 + * 46 + * There are 4 attributes under /sys/devices/platform/gpio-keys/ 47 + * keys [ro] - bitmap of keys (EV_KEY) which can be 48 + * disabled 49 + * switches [ro] - bitmap of switches (EV_SW) which can be 50 + * disabled 51 + * disabled_keys [rw] - bitmap of keys currently disabled 52 + * disabled_switches [rw] - bitmap of switches currently disabled 53 + * 54 + * Userland can change these values and hence disable event generation 55 + * for each key (or switch). Disabling a key means its interrupt line 56 + * is disabled. 57 + * 58 + * For example, if we have following switches set up as gpio-keys: 59 + * SW_DOCK = 5 60 + * SW_CAMERA_LENS_COVER = 9 61 + * SW_KEYPAD_SLIDE = 10 62 + * SW_FRONT_PROXIMITY = 11 63 + * This is read from switches: 64 + * 11-9,5 65 + * Next we want to disable proximity (11) and dock (5), we write: 66 + * 11,5 67 + * to file disabled_switches. Now proximity and dock IRQs are disabled. 68 + * This can be verified by reading the file disabled_switches: 69 + * 11,5 70 + * If we now want to enable proximity (11) switch we write: 71 + * 5 72 + * to disabled_switches. 73 + * 74 + * We can disable only those keys which don't allow sharing the irq. 75 + */ 76 + 77 + /** 78 + * get_n_events_by_type() - returns maximum number of events per @type 79 + * @type: type of button (%EV_KEY, %EV_SW) 80 + * 81 + * Return value of this function can be used to allocate bitmap 82 + * large enough to hold all bits for given type. 83 + */ 84 + static inline int get_n_events_by_type(int type) 85 + { 86 + BUG_ON(type != EV_SW && type != EV_KEY); 87 + 88 + return (type == EV_KEY) ? KEY_CNT : SW_CNT; 89 + } 90 + 91 + /** 92 + * gpio_keys_disable_button() - disables given GPIO button 93 + * @bdata: button data for button to be disabled 94 + * 95 + * Disables button pointed by @bdata. This is done by masking 96 + * IRQ line. After this function is called, button won't generate 97 + * input events anymore. Note that one can only disable buttons 98 + * that don't share IRQs. 99 + * 100 + * Make sure that @bdata->disable_lock is locked when entering 101 + * this function to avoid races when concurrent threads are 102 + * disabling buttons at the same time. 103 + */ 104 + static void gpio_keys_disable_button(struct gpio_button_data *bdata) 105 + { 106 + if (!bdata->disabled) { 107 + /* 108 + * Disable IRQ and possible debouncing timer. 109 + */ 110 + disable_irq(gpio_to_irq(bdata->button->gpio)); 111 + if (bdata->button->debounce_interval) 112 + del_timer_sync(&bdata->timer); 113 + 114 + bdata->disabled = true; 115 + } 116 + } 117 + 118 + /** 119 + * gpio_keys_enable_button() - enables given GPIO button 120 + * @bdata: button data for button to be disabled 121 + * 122 + * Enables given button pointed by @bdata. 123 + * 124 + * Make sure that @bdata->disable_lock is locked when entering 125 + * this function to avoid races with concurrent threads trying 126 + * to enable the same button at the same time. 127 + */ 128 + static void gpio_keys_enable_button(struct gpio_button_data *bdata) 129 + { 130 + if (bdata->disabled) { 131 + enable_irq(gpio_to_irq(bdata->button->gpio)); 132 + bdata->disabled = false; 133 + } 134 + } 135 + 136 + /** 137 + * gpio_keys_attr_show_helper() - fill in stringified bitmap of buttons 138 + * @ddata: pointer to drvdata 139 + * @buf: buffer where stringified bitmap is written 140 + * @type: button type (%EV_KEY, %EV_SW) 141 + * @only_disabled: does caller want only those buttons that are 142 + * currently disabled or all buttons that can be 143 + * disabled 144 + * 145 + * This function writes buttons that can be disabled to @buf. If 146 + * @only_disabled is true, then @buf contains only those buttons 147 + * that are currently disabled. Returns 0 on success or negative 148 + * errno on failure. 149 + */ 150 + static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata, 151 + char *buf, unsigned int type, 152 + bool only_disabled) 153 + { 154 + int n_events = get_n_events_by_type(type); 155 + unsigned long *bits; 156 + ssize_t ret; 157 + int i; 158 + 159 + bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL); 160 + if (!bits) 161 + return -ENOMEM; 162 + 163 + for (i = 0; i < ddata->n_buttons; i++) { 164 + struct gpio_button_data *bdata = &ddata->data[i]; 165 + 166 + if (bdata->button->type != type) 167 + continue; 168 + 169 + if (only_disabled && !bdata->disabled) 170 + continue; 171 + 172 + __set_bit(bdata->button->code, bits); 173 + } 174 + 175 + ret = bitmap_scnlistprintf(buf, PAGE_SIZE - 2, bits, n_events); 176 + buf[ret++] = '\n'; 177 + buf[ret] = '\0'; 178 + 179 + kfree(bits); 180 + 181 + return ret; 182 + } 183 + 184 + /** 185 + * gpio_keys_attr_store_helper() - enable/disable buttons based on given bitmap 186 + * @ddata: pointer to drvdata 187 + * @buf: buffer from userspace that contains stringified bitmap 188 + * @type: button type (%EV_KEY, %EV_SW) 189 + * 190 + * This function parses stringified bitmap from @buf and disables/enables 191 + * GPIO buttons accordinly. Returns 0 on success and negative error 192 + * on failure. 193 + */ 194 + static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, 195 + const char *buf, unsigned int type) 196 + { 197 + int n_events = get_n_events_by_type(type); 198 + unsigned long *bits; 199 + ssize_t error; 200 + int i; 201 + 202 + bits = kcalloc(BITS_TO_LONGS(n_events), sizeof(*bits), GFP_KERNEL); 203 + if (!bits) 204 + return -ENOMEM; 205 + 206 + error = bitmap_parselist(buf, bits, n_events); 207 + if (error) 208 + goto out; 209 + 210 + /* First validate */ 211 + for (i = 0; i < ddata->n_buttons; i++) { 212 + struct gpio_button_data *bdata = &ddata->data[i]; 213 + 214 + if (bdata->button->type != type) 215 + continue; 216 + 217 + if (test_bit(bdata->button->code, bits) && 218 + !bdata->button->can_disable) { 219 + error = -EINVAL; 220 + goto out; 221 + } 222 + } 223 + 224 + mutex_lock(&ddata->disable_lock); 225 + 226 + for (i = 0; i < ddata->n_buttons; i++) { 227 + struct gpio_button_data *bdata = &ddata->data[i]; 228 + 229 + if (bdata->button->type != type) 230 + continue; 231 + 232 + if (test_bit(bdata->button->code, bits)) 233 + gpio_keys_disable_button(bdata); 234 + else 235 + gpio_keys_enable_button(bdata); 236 + } 237 + 238 + mutex_unlock(&ddata->disable_lock); 239 + 240 + out: 241 + kfree(bits); 242 + return error; 243 + } 244 + 245 + #define ATTR_SHOW_FN(name, type, only_disabled) \ 246 + static ssize_t gpio_keys_show_##name(struct device *dev, \ 247 + struct device_attribute *attr, \ 248 + char *buf) \ 249 + { \ 250 + struct platform_device *pdev = to_platform_device(dev); \ 251 + struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); \ 252 + \ 253 + return gpio_keys_attr_show_helper(ddata, buf, \ 254 + type, only_disabled); \ 255 + } 256 + 257 + ATTR_SHOW_FN(keys, EV_KEY, false); 258 + ATTR_SHOW_FN(switches, EV_SW, false); 259 + ATTR_SHOW_FN(disabled_keys, EV_KEY, true); 260 + ATTR_SHOW_FN(disabled_switches, EV_SW, true); 261 + 262 + /* 263 + * ATTRIBUTES: 264 + * 265 + * /sys/devices/platform/gpio-keys/keys [ro] 266 + * /sys/devices/platform/gpio-keys/switches [ro] 267 + */ 268 + static DEVICE_ATTR(keys, S_IRUGO, gpio_keys_show_keys, NULL); 269 + static DEVICE_ATTR(switches, S_IRUGO, gpio_keys_show_switches, NULL); 270 + 271 + #define ATTR_STORE_FN(name, type) \ 272 + static ssize_t gpio_keys_store_##name(struct device *dev, \ 273 + struct device_attribute *attr, \ 274 + const char *buf, \ 275 + size_t count) \ 276 + { \ 277 + struct platform_device *pdev = to_platform_device(dev); \ 278 + struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); \ 279 + ssize_t error; \ 280 + \ 281 + error = gpio_keys_attr_store_helper(ddata, buf, type); \ 282 + if (error) \ 283 + return error; \ 284 + \ 285 + return count; \ 286 + } 287 + 288 + ATTR_STORE_FN(disabled_keys, EV_KEY); 289 + ATTR_STORE_FN(disabled_switches, EV_SW); 290 + 291 + /* 292 + * ATTRIBUTES: 293 + * 294 + * /sys/devices/platform/gpio-keys/disabled_keys [rw] 295 + * /sys/devices/platform/gpio-keys/disables_switches [rw] 296 + */ 297 + static DEVICE_ATTR(disabled_keys, S_IWUSR | S_IRUGO, 298 + gpio_keys_show_disabled_keys, 299 + gpio_keys_store_disabled_keys); 300 + static DEVICE_ATTR(disabled_switches, S_IWUSR | S_IRUGO, 301 + gpio_keys_show_disabled_switches, 302 + gpio_keys_store_disabled_switches); 303 + 304 + static struct attribute *gpio_keys_attrs[] = { 305 + &dev_attr_keys.attr, 306 + &dev_attr_switches.attr, 307 + &dev_attr_disabled_keys.attr, 308 + &dev_attr_disabled_switches.attr, 309 + NULL, 310 + }; 311 + 312 + static struct attribute_group gpio_keys_attr_group = { 313 + .attrs = gpio_keys_attrs, 38 314 }; 39 315 40 316 static void gpio_keys_report_event(struct gpio_button_data *bdata) ··· 355 79 return IRQ_HANDLED; 356 80 } 357 81 358 - static int __devinit gpio_keys_setup_key(struct device *dev, 82 + static int __devinit gpio_keys_setup_key(struct platform_device *pdev, 359 83 struct gpio_button_data *bdata, 360 84 struct gpio_keys_button *button) 361 85 { 362 86 char *desc = button->desc ? button->desc : "gpio_keys"; 87 + struct device *dev = &pdev->dev; 88 + unsigned long irqflags; 363 89 int irq, error; 364 90 365 91 setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata); ··· 390 112 goto fail3; 391 113 } 392 114 393 - error = request_irq(irq, gpio_keys_isr, 394 - IRQF_SHARED | 395 - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 396 - desc, bdata); 115 + irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; 116 + /* 117 + * If platform has specified that the button can be disabled, 118 + * we don't want it to share the interrupt line. 119 + */ 120 + if (!button->can_disable) 121 + irqflags |= IRQF_SHARED; 122 + 123 + error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata); 397 124 if (error) { 398 125 dev_err(dev, "Unable to claim irq %d; error %d\n", 399 126 irq, error); ··· 432 149 goto fail1; 433 150 } 434 151 152 + ddata->input = input; 153 + ddata->n_buttons = pdata->nbuttons; 154 + mutex_init(&ddata->disable_lock); 155 + 435 156 platform_set_drvdata(pdev, ddata); 436 157 437 158 input->name = pdev->name; ··· 451 164 if (pdata->rep) 452 165 __set_bit(EV_REP, input->evbit); 453 166 454 - ddata->input = input; 455 - 456 167 for (i = 0; i < pdata->nbuttons; i++) { 457 168 struct gpio_keys_button *button = &pdata->buttons[i]; 458 169 struct gpio_button_data *bdata = &ddata->data[i]; ··· 459 174 bdata->input = input; 460 175 bdata->button = button; 461 176 462 - error = gpio_keys_setup_key(dev, bdata, button); 177 + error = gpio_keys_setup_key(pdev, bdata, button); 463 178 if (error) 464 179 goto fail2; 465 180 ··· 469 184 input_set_capability(input, type, button->code); 470 185 } 471 186 187 + error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); 188 + if (error) { 189 + dev_err(dev, "Unable to export keys/switches, error: %d\n", 190 + error); 191 + goto fail2; 192 + } 193 + 472 194 error = input_register_device(input); 473 195 if (error) { 474 - dev_err(dev, "Unable to register input device, " 475 - "error: %d\n", error); 476 - goto fail2; 196 + dev_err(dev, "Unable to register input device, error: %d\n", 197 + error); 198 + goto fail3; 477 199 } 478 200 479 201 /* get current state of buttons */ ··· 492 200 493 201 return 0; 494 202 203 + fail3: 204 + sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); 495 205 fail2: 496 206 while (--i >= 0) { 497 207 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); ··· 517 223 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); 518 224 struct input_dev *input = ddata->input; 519 225 int i; 226 + 227 + sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); 520 228 521 229 device_init_wakeup(&pdev->dev, 0); 522 230
+594
drivers/input/keyboard/imx_keypad.c
··· 1 + /* 2 + * Driver for the IMX keypad port. 3 + * Copyright (C) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + * 9 + * <<Power management needs to be implemented>>. 10 + */ 11 + 12 + #include <linux/clk.h> 13 + #include <linux/delay.h> 14 + #include <linux/device.h> 15 + #include <linux/err.h> 16 + #include <linux/init.h> 17 + #include <linux/input/matrix_keypad.h> 18 + #include <linux/interrupt.h> 19 + #include <linux/io.h> 20 + #include <linux/jiffies.h> 21 + #include <linux/kernel.h> 22 + #include <linux/module.h> 23 + #include <linux/platform_device.h> 24 + #include <linux/timer.h> 25 + 26 + /* 27 + * Keypad Controller registers (halfword) 28 + */ 29 + #define KPCR 0x00 /* Keypad Control Register */ 30 + 31 + #define KPSR 0x02 /* Keypad Status Register */ 32 + #define KBD_STAT_KPKD (0x1 << 0) /* Key Press Interrupt Status bit (w1c) */ 33 + #define KBD_STAT_KPKR (0x1 << 1) /* Key Release Interrupt Status bit (w1c) */ 34 + #define KBD_STAT_KDSC (0x1 << 2) /* Key Depress Synch Chain Status bit (w1c)*/ 35 + #define KBD_STAT_KRSS (0x1 << 3) /* Key Release Synch Status bit (w1c)*/ 36 + #define KBD_STAT_KDIE (0x1 << 8) /* Key Depress Interrupt Enable Status bit */ 37 + #define KBD_STAT_KRIE (0x1 << 9) /* Key Release Interrupt Enable */ 38 + #define KBD_STAT_KPPEN (0x1 << 10) /* Keypad Clock Enable */ 39 + 40 + #define KDDR 0x04 /* Keypad Data Direction Register */ 41 + #define KPDR 0x06 /* Keypad Data Register */ 42 + 43 + #define MAX_MATRIX_KEY_ROWS 8 44 + #define MAX_MATRIX_KEY_COLS 8 45 + #define MATRIX_ROW_SHIFT 3 46 + 47 + #define MAX_MATRIX_KEY_NUM (MAX_MATRIX_KEY_ROWS * MAX_MATRIX_KEY_COLS) 48 + 49 + struct imx_keypad { 50 + 51 + struct clk *clk; 52 + struct input_dev *input_dev; 53 + void __iomem *mmio_base; 54 + 55 + int irq; 56 + struct timer_list check_matrix_timer; 57 + 58 + /* 59 + * The matrix is stable only if no changes are detected after 60 + * IMX_KEYPAD_SCANS_FOR_STABILITY scans 61 + */ 62 + #define IMX_KEYPAD_SCANS_FOR_STABILITY 3 63 + int stable_count; 64 + 65 + bool enabled; 66 + 67 + /* Masks for enabled rows/cols */ 68 + unsigned short rows_en_mask; 69 + unsigned short cols_en_mask; 70 + 71 + unsigned short keycodes[MAX_MATRIX_KEY_NUM]; 72 + 73 + /* 74 + * Matrix states: 75 + * -stable: achieved after a complete debounce process. 76 + * -unstable: used in the debouncing process. 77 + */ 78 + unsigned short matrix_stable_state[MAX_MATRIX_KEY_COLS]; 79 + unsigned short matrix_unstable_state[MAX_MATRIX_KEY_COLS]; 80 + }; 81 + 82 + /* Scan the matrix and return the new state in *matrix_volatile_state. */ 83 + static void imx_keypad_scan_matrix(struct imx_keypad *keypad, 84 + unsigned short *matrix_volatile_state) 85 + { 86 + int col; 87 + unsigned short reg_val; 88 + 89 + for (col = 0; col < MAX_MATRIX_KEY_COLS; col++) { 90 + if ((keypad->cols_en_mask & (1 << col)) == 0) 91 + continue; 92 + /* 93 + * Discharge keypad capacitance: 94 + * 2. write 1s on column data. 95 + * 3. configure columns as totem-pole to discharge capacitance. 96 + * 4. configure columns as open-drain. 97 + */ 98 + reg_val = readw(keypad->mmio_base + KPDR); 99 + reg_val |= 0xff00; 100 + writew(reg_val, keypad->mmio_base + KPDR); 101 + 102 + reg_val = readw(keypad->mmio_base + KPCR); 103 + reg_val &= ~((keypad->cols_en_mask & 0xff) << 8); 104 + writew(reg_val, keypad->mmio_base + KPCR); 105 + 106 + udelay(2); 107 + 108 + reg_val = readw(keypad->mmio_base + KPCR); 109 + reg_val |= (keypad->cols_en_mask & 0xff) << 8; 110 + writew(reg_val, keypad->mmio_base + KPCR); 111 + 112 + /* 113 + * 5. Write a single column to 0, others to 1. 114 + * 6. Sample row inputs and save data. 115 + * 7. Repeat steps 2 - 6 for remaining columns. 116 + */ 117 + reg_val = readw(keypad->mmio_base + KPDR); 118 + reg_val &= ~(1 << (8 + col)); 119 + writew(reg_val, keypad->mmio_base + KPDR); 120 + 121 + /* 122 + * Delay added to avoid propagating the 0 from column to row 123 + * when scanning. 124 + */ 125 + udelay(5); 126 + 127 + /* 128 + * 1s in matrix_volatile_state[col] means key pressures 129 + * throw data from non enabled rows. 130 + */ 131 + reg_val = readw(keypad->mmio_base + KPDR); 132 + matrix_volatile_state[col] = (~reg_val) & keypad->rows_en_mask; 133 + } 134 + 135 + /* 136 + * Return in standby mode: 137 + * 9. write 0s to columns 138 + */ 139 + reg_val = readw(keypad->mmio_base + KPDR); 140 + reg_val &= 0x00ff; 141 + writew(reg_val, keypad->mmio_base + KPDR); 142 + } 143 + 144 + /* 145 + * Compare the new matrix state (volatile) with the stable one stored in 146 + * keypad->matrix_stable_state and fire events if changes are detected. 147 + */ 148 + static void imx_keypad_fire_events(struct imx_keypad *keypad, 149 + unsigned short *matrix_volatile_state) 150 + { 151 + struct input_dev *input_dev = keypad->input_dev; 152 + int row, col; 153 + 154 + for (col = 0; col < MAX_MATRIX_KEY_COLS; col++) { 155 + unsigned short bits_changed; 156 + int code; 157 + 158 + if ((keypad->cols_en_mask & (1 << col)) == 0) 159 + continue; /* Column is not enabled */ 160 + 161 + bits_changed = keypad->matrix_stable_state[col] ^ 162 + matrix_volatile_state[col]; 163 + 164 + if (bits_changed == 0) 165 + continue; /* Column does not contain changes */ 166 + 167 + for (row = 0; row < MAX_MATRIX_KEY_ROWS; row++) { 168 + if ((keypad->rows_en_mask & (1 << row)) == 0) 169 + continue; /* Row is not enabled */ 170 + if ((bits_changed & (1 << row)) == 0) 171 + continue; /* Row does not contain changes */ 172 + 173 + code = MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT); 174 + input_event(input_dev, EV_MSC, MSC_SCAN, code); 175 + input_report_key(input_dev, keypad->keycodes[code], 176 + matrix_volatile_state[col] & (1 << row)); 177 + dev_dbg(&input_dev->dev, "Event code: %d, val: %d", 178 + keypad->keycodes[code], 179 + matrix_volatile_state[col] & (1 << row)); 180 + } 181 + } 182 + input_sync(input_dev); 183 + } 184 + 185 + /* 186 + * imx_keypad_check_for_events is the timer handler. 187 + */ 188 + static void imx_keypad_check_for_events(unsigned long data) 189 + { 190 + struct imx_keypad *keypad = (struct imx_keypad *) data; 191 + unsigned short matrix_volatile_state[MAX_MATRIX_KEY_COLS]; 192 + unsigned short reg_val; 193 + bool state_changed, is_zero_matrix; 194 + int i; 195 + 196 + memset(matrix_volatile_state, 0, sizeof(matrix_volatile_state)); 197 + 198 + imx_keypad_scan_matrix(keypad, matrix_volatile_state); 199 + 200 + state_changed = false; 201 + for (i = 0; i < MAX_MATRIX_KEY_COLS; i++) { 202 + if ((keypad->cols_en_mask & (1 << i)) == 0) 203 + continue; 204 + 205 + if (keypad->matrix_unstable_state[i] ^ matrix_volatile_state[i]) { 206 + state_changed = true; 207 + break; 208 + } 209 + } 210 + 211 + /* 212 + * If the matrix state is changed from the previous scan 213 + * (Re)Begin the debouncing process, saving the new state in 214 + * keypad->matrix_unstable_state. 215 + * else 216 + * Increase the count of number of scans with a stable state. 217 + */ 218 + if (state_changed) { 219 + memcpy(keypad->matrix_unstable_state, matrix_volatile_state, 220 + sizeof(matrix_volatile_state)); 221 + keypad->stable_count = 0; 222 + } else 223 + keypad->stable_count++; 224 + 225 + /* 226 + * If the matrix is not as stable as we want reschedule scan 227 + * in the near future. 228 + */ 229 + if (keypad->stable_count < IMX_KEYPAD_SCANS_FOR_STABILITY) { 230 + mod_timer(&keypad->check_matrix_timer, 231 + jiffies + msecs_to_jiffies(10)); 232 + return; 233 + } 234 + 235 + /* 236 + * If the matrix state is stable, fire the events and save the new 237 + * stable state. Note, if the matrix is kept stable for longer 238 + * (keypad->stable_count > IMX_KEYPAD_SCANS_FOR_STABILITY) all 239 + * events have already been generated. 240 + */ 241 + if (keypad->stable_count == IMX_KEYPAD_SCANS_FOR_STABILITY) { 242 + imx_keypad_fire_events(keypad, matrix_volatile_state); 243 + 244 + memcpy(keypad->matrix_stable_state, matrix_volatile_state, 245 + sizeof(matrix_volatile_state)); 246 + } 247 + 248 + is_zero_matrix = true; 249 + for (i = 0; i < MAX_MATRIX_KEY_COLS; i++) { 250 + if (matrix_volatile_state[i] != 0) { 251 + is_zero_matrix = false; 252 + break; 253 + } 254 + } 255 + 256 + 257 + if (is_zero_matrix) { 258 + /* 259 + * All keys have been released. Enable only the KDI 260 + * interrupt for future key presses (clear the KDI 261 + * status bit and its sync chain before that). 262 + */ 263 + reg_val = readw(keypad->mmio_base + KPSR); 264 + reg_val |= KBD_STAT_KPKD | KBD_STAT_KDSC; 265 + writew(reg_val, keypad->mmio_base + KPSR); 266 + 267 + reg_val = readw(keypad->mmio_base + KPSR); 268 + reg_val |= KBD_STAT_KDIE; 269 + reg_val &= ~KBD_STAT_KRIE; 270 + writew(reg_val, keypad->mmio_base + KPSR); 271 + } else { 272 + /* 273 + * Some keys are still pressed. Schedule a rescan in 274 + * attempt to detect multiple key presses and enable 275 + * the KRI interrupt to react quickly to key release 276 + * event. 277 + */ 278 + mod_timer(&keypad->check_matrix_timer, 279 + jiffies + msecs_to_jiffies(60)); 280 + 281 + reg_val = readw(keypad->mmio_base + KPSR); 282 + reg_val |= KBD_STAT_KPKR | KBD_STAT_KRSS; 283 + writew(reg_val, keypad->mmio_base + KPSR); 284 + 285 + reg_val = readw(keypad->mmio_base + KPSR); 286 + reg_val |= KBD_STAT_KRIE; 287 + reg_val &= ~KBD_STAT_KDIE; 288 + writew(reg_val, keypad->mmio_base + KPSR); 289 + } 290 + } 291 + 292 + static irqreturn_t imx_keypad_irq_handler(int irq, void *dev_id) 293 + { 294 + struct imx_keypad *keypad = dev_id; 295 + unsigned short reg_val; 296 + 297 + reg_val = readw(keypad->mmio_base + KPSR); 298 + 299 + /* Disable both interrupt types */ 300 + reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE); 301 + /* Clear interrupts status bits */ 302 + reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD; 303 + writew(reg_val, keypad->mmio_base + KPSR); 304 + 305 + if (keypad->enabled) { 306 + /* The matrix is supposed to be changed */ 307 + keypad->stable_count = 0; 308 + 309 + /* Schedule the scanning procedure near in the future */ 310 + mod_timer(&keypad->check_matrix_timer, 311 + jiffies + msecs_to_jiffies(2)); 312 + } 313 + 314 + return IRQ_HANDLED; 315 + } 316 + 317 + static void imx_keypad_config(struct imx_keypad *keypad) 318 + { 319 + unsigned short reg_val; 320 + 321 + /* 322 + * Include enabled rows in interrupt generation (KPCR[7:0]) 323 + * Configure keypad columns as open-drain (KPCR[15:8]) 324 + */ 325 + reg_val = readw(keypad->mmio_base + KPCR); 326 + reg_val |= keypad->rows_en_mask & 0xff; /* rows */ 327 + reg_val |= (keypad->cols_en_mask & 0xff) << 8; /* cols */ 328 + writew(reg_val, keypad->mmio_base + KPCR); 329 + 330 + /* Write 0's to KPDR[15:8] (Colums) */ 331 + reg_val = readw(keypad->mmio_base + KPDR); 332 + reg_val &= 0x00ff; 333 + writew(reg_val, keypad->mmio_base + KPDR); 334 + 335 + /* Configure columns as output, rows as input (KDDR[15:0]) */ 336 + writew(0xff00, keypad->mmio_base + KDDR); 337 + 338 + /* 339 + * Clear Key Depress and Key Release status bit. 340 + * Clear both synchronizer chain. 341 + */ 342 + reg_val = readw(keypad->mmio_base + KPSR); 343 + reg_val |= KBD_STAT_KPKR | KBD_STAT_KPKD | 344 + KBD_STAT_KDSC | KBD_STAT_KRSS; 345 + writew(reg_val, keypad->mmio_base + KPSR); 346 + 347 + /* Enable KDI and disable KRI (avoid false release events). */ 348 + reg_val |= KBD_STAT_KDIE; 349 + reg_val &= ~KBD_STAT_KRIE; 350 + writew(reg_val, keypad->mmio_base + KPSR); 351 + } 352 + 353 + static void imx_keypad_inhibit(struct imx_keypad *keypad) 354 + { 355 + unsigned short reg_val; 356 + 357 + /* Inhibit KDI and KRI interrupts. */ 358 + reg_val = readw(keypad->mmio_base + KPSR); 359 + reg_val &= ~(KBD_STAT_KRIE | KBD_STAT_KDIE); 360 + writew(reg_val, keypad->mmio_base + KPSR); 361 + 362 + /* Colums as open drain and disable all rows */ 363 + writew(0xff00, keypad->mmio_base + KPCR); 364 + } 365 + 366 + static void imx_keypad_close(struct input_dev *dev) 367 + { 368 + struct imx_keypad *keypad = input_get_drvdata(dev); 369 + 370 + dev_dbg(&dev->dev, ">%s\n", __func__); 371 + 372 + /* Mark keypad as being inactive */ 373 + keypad->enabled = false; 374 + synchronize_irq(keypad->irq); 375 + del_timer_sync(&keypad->check_matrix_timer); 376 + 377 + imx_keypad_inhibit(keypad); 378 + 379 + /* Disable clock unit */ 380 + clk_disable(keypad->clk); 381 + } 382 + 383 + static int imx_keypad_open(struct input_dev *dev) 384 + { 385 + struct imx_keypad *keypad = input_get_drvdata(dev); 386 + 387 + dev_dbg(&dev->dev, ">%s\n", __func__); 388 + 389 + /* We became active from now */ 390 + keypad->enabled = true; 391 + 392 + /* Enable the kpp clock */ 393 + clk_enable(keypad->clk); 394 + imx_keypad_config(keypad); 395 + 396 + /* Sanity control, not all the rows must be actived now. */ 397 + if ((readw(keypad->mmio_base + KPDR) & keypad->rows_en_mask) == 0) { 398 + dev_err(&dev->dev, 399 + "too many keys pressed, control pins initialisation\n"); 400 + goto open_err; 401 + } 402 + 403 + return 0; 404 + 405 + open_err: 406 + imx_keypad_close(dev); 407 + return -EIO; 408 + } 409 + 410 + static int __devinit imx_keypad_probe(struct platform_device *pdev) 411 + { 412 + const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data; 413 + struct imx_keypad *keypad; 414 + struct input_dev *input_dev; 415 + struct resource *res; 416 + int irq, error, i; 417 + 418 + if (keymap_data == NULL) { 419 + dev_err(&pdev->dev, "no keymap defined\n"); 420 + return -EINVAL; 421 + } 422 + 423 + irq = platform_get_irq(pdev, 0); 424 + if (irq < 0) { 425 + dev_err(&pdev->dev, "no irq defined in platform data\n"); 426 + return -EINVAL; 427 + } 428 + 429 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 430 + if (res == NULL) { 431 + dev_err(&pdev->dev, "no I/O memory defined in platform data\n"); 432 + return -EINVAL; 433 + } 434 + 435 + res = request_mem_region(res->start, resource_size(res), pdev->name); 436 + if (res == NULL) { 437 + dev_err(&pdev->dev, "failed to request I/O memory\n"); 438 + return -EBUSY; 439 + } 440 + 441 + input_dev = input_allocate_device(); 442 + if (!input_dev) { 443 + dev_err(&pdev->dev, "failed to allocate the input device\n"); 444 + error = -ENOMEM; 445 + goto failed_rel_mem; 446 + } 447 + 448 + keypad = kzalloc(sizeof(struct imx_keypad), GFP_KERNEL); 449 + if (!keypad) { 450 + dev_err(&pdev->dev, "not enough memory for driver data\n"); 451 + error = -ENOMEM; 452 + goto failed_free_input; 453 + } 454 + 455 + keypad->input_dev = input_dev; 456 + keypad->irq = irq; 457 + keypad->stable_count = 0; 458 + 459 + setup_timer(&keypad->check_matrix_timer, 460 + imx_keypad_check_for_events, (unsigned long) keypad); 461 + 462 + keypad->mmio_base = ioremap(res->start, resource_size(res)); 463 + if (keypad->mmio_base == NULL) { 464 + dev_err(&pdev->dev, "failed to remap I/O memory\n"); 465 + error = -ENOMEM; 466 + goto failed_free_priv; 467 + } 468 + 469 + keypad->clk = clk_get(&pdev->dev, "kpp"); 470 + if (IS_ERR(keypad->clk)) { 471 + dev_err(&pdev->dev, "failed to get keypad clock\n"); 472 + error = PTR_ERR(keypad->clk); 473 + goto failed_unmap; 474 + } 475 + 476 + /* Search for rows and cols enabled */ 477 + for (i = 0; i < keymap_data->keymap_size; i++) { 478 + keypad->rows_en_mask |= 1 << KEY_ROW(keymap_data->keymap[i]); 479 + keypad->cols_en_mask |= 1 << KEY_COL(keymap_data->keymap[i]); 480 + } 481 + 482 + if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) || 483 + keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) { 484 + dev_err(&pdev->dev, 485 + "invalid key data (too many rows or colums)\n"); 486 + error = -EINVAL; 487 + goto failed_clock_put; 488 + } 489 + dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask); 490 + dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask); 491 + 492 + /* Init the Input device */ 493 + input_dev->name = pdev->name; 494 + input_dev->id.bustype = BUS_HOST; 495 + input_dev->dev.parent = &pdev->dev; 496 + input_dev->open = imx_keypad_open; 497 + input_dev->close = imx_keypad_close; 498 + input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 499 + input_dev->keycode = keypad->keycodes; 500 + input_dev->keycodesize = sizeof(keypad->keycodes[0]); 501 + input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); 502 + 503 + matrix_keypad_build_keymap(keymap_data, MATRIX_ROW_SHIFT, 504 + keypad->keycodes, input_dev->keybit); 505 + 506 + input_set_capability(input_dev, EV_MSC, MSC_SCAN); 507 + input_set_drvdata(input_dev, keypad); 508 + 509 + /* Ensure that the keypad will stay dormant until opened */ 510 + imx_keypad_inhibit(keypad); 511 + 512 + error = request_irq(irq, imx_keypad_irq_handler, IRQF_DISABLED, 513 + pdev->name, keypad); 514 + if (error) { 515 + dev_err(&pdev->dev, "failed to request IRQ\n"); 516 + goto failed_clock_put; 517 + } 518 + 519 + /* Register the input device */ 520 + error = input_register_device(input_dev); 521 + if (error) { 522 + dev_err(&pdev->dev, "failed to register input device\n"); 523 + goto failed_free_irq; 524 + } 525 + 526 + platform_set_drvdata(pdev, keypad); 527 + device_init_wakeup(&pdev->dev, 1); 528 + 529 + return 0; 530 + 531 + failed_free_irq: 532 + free_irq(irq, pdev); 533 + failed_clock_put: 534 + clk_put(keypad->clk); 535 + failed_unmap: 536 + iounmap(keypad->mmio_base); 537 + failed_free_priv: 538 + kfree(keypad); 539 + failed_free_input: 540 + input_free_device(input_dev); 541 + failed_rel_mem: 542 + release_mem_region(res->start, resource_size(res)); 543 + return error; 544 + } 545 + 546 + static int __devexit imx_keypad_remove(struct platform_device *pdev) 547 + { 548 + struct imx_keypad *keypad = platform_get_drvdata(pdev); 549 + struct resource *res; 550 + 551 + dev_dbg(&pdev->dev, ">%s\n", __func__); 552 + 553 + platform_set_drvdata(pdev, NULL); 554 + 555 + input_unregister_device(keypad->input_dev); 556 + 557 + free_irq(keypad->irq, keypad); 558 + clk_put(keypad->clk); 559 + 560 + iounmap(keypad->mmio_base); 561 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 562 + release_mem_region(res->start, resource_size(res)); 563 + 564 + kfree(keypad); 565 + 566 + return 0; 567 + } 568 + 569 + static struct platform_driver imx_keypad_driver = { 570 + .driver = { 571 + .name = "imx-keypad", 572 + .owner = THIS_MODULE, 573 + }, 574 + .probe = imx_keypad_probe, 575 + .remove = __devexit_p(imx_keypad_remove), 576 + }; 577 + 578 + static int __init imx_keypad_init(void) 579 + { 580 + return platform_driver_register(&imx_keypad_driver); 581 + } 582 + 583 + static void __exit imx_keypad_exit(void) 584 + { 585 + platform_driver_unregister(&imx_keypad_driver); 586 + } 587 + 588 + module_init(imx_keypad_init); 589 + module_exit(imx_keypad_exit); 590 + 591 + MODULE_AUTHOR("Alberto Panizzo <maramaopercheseimorto@gmail.com>"); 592 + MODULE_DESCRIPTION("IMX Keypad Port Driver"); 593 + MODULE_LICENSE("GPL v2"); 594 + MODULE_ALIAS("platform:imx-keypad");
+1 -1
drivers/input/keyboard/qt2160.c
··· 362 362 return 0; 363 363 } 364 364 365 - static struct i2c_device_id qt2160_idtable[] = { 365 + static const struct i2c_device_id qt2160_idtable[] = { 366 366 { "qt2160", 0, }, 367 367 { } 368 368 };
+91 -54
drivers/input/keyboard/sh_keysc.c
··· 19 19 #include <linux/platform_device.h> 20 20 #include <linux/input.h> 21 21 #include <linux/input/sh_keysc.h> 22 + #include <linux/bitmap.h> 22 23 #include <linux/clk.h> 23 24 #include <linux/io.h> 24 - 25 - #define KYCR1_OFFS 0x00 26 - #define KYCR2_OFFS 0x04 27 - #define KYINDR_OFFS 0x08 28 - #define KYOUTDR_OFFS 0x0c 29 - 30 - #define KYCR2_IRQ_LEVEL 0x10 31 - #define KYCR2_IRQ_DISABLED 0x00 32 25 33 26 static const struct { 34 27 unsigned char kymd, keyout, keyin; ··· 29 36 [SH_KEYSC_MODE_1] = { 0, 6, 5 }, 30 37 [SH_KEYSC_MODE_2] = { 1, 5, 6 }, 31 38 [SH_KEYSC_MODE_3] = { 2, 4, 7 }, 39 + [SH_KEYSC_MODE_4] = { 3, 6, 6 }, 40 + [SH_KEYSC_MODE_5] = { 4, 6, 7 }, 41 + [SH_KEYSC_MODE_6] = { 5, 7, 7 }, 32 42 }; 33 43 34 44 struct sh_keysc_priv { 35 45 void __iomem *iomem_base; 36 46 struct clk *clk; 37 - unsigned long last_keys; 47 + DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS); 38 48 struct input_dev *input; 39 49 struct sh_keysc_info pdata; 40 50 }; 51 + 52 + #define KYCR1 0 53 + #define KYCR2 1 54 + #define KYINDR 2 55 + #define KYOUTDR 3 56 + 57 + #define KYCR2_IRQ_LEVEL 0x10 58 + #define KYCR2_IRQ_DISABLED 0x00 59 + 60 + static unsigned long sh_keysc_read(struct sh_keysc_priv *p, int reg_nr) 61 + { 62 + return ioread16(p->iomem_base + (reg_nr << 2)); 63 + } 64 + 65 + static void sh_keysc_write(struct sh_keysc_priv *p, int reg_nr, 66 + unsigned long value) 67 + { 68 + iowrite16(value, p->iomem_base + (reg_nr << 2)); 69 + } 70 + 71 + static void sh_keysc_level_mode(struct sh_keysc_priv *p, 72 + unsigned long keys_set) 73 + { 74 + struct sh_keysc_info *pdata = &p->pdata; 75 + 76 + sh_keysc_write(p, KYOUTDR, 0); 77 + sh_keysc_write(p, KYCR2, KYCR2_IRQ_LEVEL | (keys_set << 8)); 78 + 79 + if (pdata->kycr2_delay) 80 + udelay(pdata->kycr2_delay); 81 + } 82 + 83 + static void sh_keysc_map_dbg(struct device *dev, unsigned long *map, 84 + const char *str) 85 + { 86 + int k; 87 + 88 + for (k = 0; k < BITS_TO_LONGS(SH_KEYSC_MAXKEYS); k++) 89 + dev_dbg(dev, "%s[%d] 0x%lx\n", str, k, map[k]); 90 + } 41 91 42 92 static irqreturn_t sh_keysc_isr(int irq, void *dev_id) 43 93 { 44 94 struct platform_device *pdev = dev_id; 45 95 struct sh_keysc_priv *priv = platform_get_drvdata(pdev); 46 96 struct sh_keysc_info *pdata = &priv->pdata; 47 - unsigned long keys, keys1, keys0, mask; 97 + int keyout_nr = sh_keysc_mode[pdata->mode].keyout; 98 + int keyin_nr = sh_keysc_mode[pdata->mode].keyin; 99 + DECLARE_BITMAP(keys, SH_KEYSC_MAXKEYS); 100 + DECLARE_BITMAP(keys0, SH_KEYSC_MAXKEYS); 101 + DECLARE_BITMAP(keys1, SH_KEYSC_MAXKEYS); 48 102 unsigned char keyin_set, tmp; 49 - int i, k; 103 + int i, k, n; 50 104 51 105 dev_dbg(&pdev->dev, "isr!\n"); 52 106 53 - keys1 = ~0; 54 - keys0 = 0; 107 + bitmap_fill(keys1, SH_KEYSC_MAXKEYS); 108 + bitmap_zero(keys0, SH_KEYSC_MAXKEYS); 55 109 56 110 do { 57 - keys = 0; 111 + bitmap_zero(keys, SH_KEYSC_MAXKEYS); 58 112 keyin_set = 0; 59 113 60 - iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); 114 + sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED); 61 115 62 - for (i = 0; i < sh_keysc_mode[pdata->mode].keyout; i++) { 63 - iowrite16(0xfff ^ (3 << (i * 2)), 64 - priv->iomem_base + KYOUTDR_OFFS); 116 + for (i = 0; i < keyout_nr; i++) { 117 + n = keyin_nr * i; 118 + 119 + /* drive one KEYOUT pin low, read KEYIN pins */ 120 + sh_keysc_write(priv, KYOUTDR, 0xffff ^ (3 << (i * 2))); 65 121 udelay(pdata->delay); 66 - tmp = ioread16(priv->iomem_base + KYINDR_OFFS); 67 - keys |= tmp << (sh_keysc_mode[pdata->mode].keyin * i); 68 - tmp ^= (1 << sh_keysc_mode[pdata->mode].keyin) - 1; 69 - keyin_set |= tmp; 122 + tmp = sh_keysc_read(priv, KYINDR); 123 + 124 + /* set bit if key press has been detected */ 125 + for (k = 0; k < keyin_nr; k++) { 126 + if (tmp & (1 << k)) 127 + __set_bit(n + k, keys); 128 + } 129 + 130 + /* keep track of which KEYIN bits that have been set */ 131 + keyin_set |= tmp ^ ((1 << keyin_nr) - 1); 70 132 } 71 133 72 - iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); 73 - iowrite16(KYCR2_IRQ_LEVEL | (keyin_set << 8), 74 - priv->iomem_base + KYCR2_OFFS); 134 + sh_keysc_level_mode(priv, keyin_set); 75 135 76 - if (pdata->kycr2_delay) 77 - udelay(pdata->kycr2_delay); 136 + bitmap_complement(keys, keys, SH_KEYSC_MAXKEYS); 137 + bitmap_and(keys1, keys1, keys, SH_KEYSC_MAXKEYS); 138 + bitmap_or(keys0, keys0, keys, SH_KEYSC_MAXKEYS); 78 139 79 - keys ^= ~0; 80 - keys &= (1 << (sh_keysc_mode[pdata->mode].keyin * 81 - sh_keysc_mode[pdata->mode].keyout)) - 1; 82 - keys1 &= keys; 83 - keys0 |= keys; 140 + sh_keysc_map_dbg(&pdev->dev, keys, "keys"); 84 141 85 - dev_dbg(&pdev->dev, "keys 0x%08lx\n", keys); 142 + } while (sh_keysc_read(priv, KYCR2) & 0x01); 86 143 87 - } while (ioread16(priv->iomem_base + KYCR2_OFFS) & 0x01); 88 - 89 - dev_dbg(&pdev->dev, "last_keys 0x%08lx keys0 0x%08lx keys1 0x%08lx\n", 90 - priv->last_keys, keys0, keys1); 144 + sh_keysc_map_dbg(&pdev->dev, priv->last_keys, "last_keys"); 145 + sh_keysc_map_dbg(&pdev->dev, keys0, "keys0"); 146 + sh_keysc_map_dbg(&pdev->dev, keys1, "keys1"); 91 147 92 148 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { 93 149 k = pdata->keycodes[i]; 94 150 if (!k) 95 151 continue; 96 152 97 - mask = 1 << i; 98 - 99 - if (!((priv->last_keys ^ keys0) & mask)) 153 + if (test_bit(i, keys0) == test_bit(i, priv->last_keys)) 100 154 continue; 101 155 102 - if ((keys1 | keys0) & mask) { 156 + if (test_bit(i, keys1) || test_bit(i, keys0)) { 103 157 input_event(priv->input, EV_KEY, k, 1); 104 - priv->last_keys |= mask; 158 + __set_bit(i, priv->last_keys); 105 159 } 106 160 107 - if (!(keys1 & mask)) { 161 + if (!test_bit(i, keys1)) { 108 162 input_event(priv->input, EV_KEY, k, 0); 109 - priv->last_keys &= ~mask; 163 + __clear_bit(i, priv->last_keys); 110 164 } 111 165 112 166 } ··· 161 121 162 122 return IRQ_HANDLED; 163 123 } 164 - 165 - #define res_size(res) ((res)->end - (res)->start + 1) 166 124 167 125 static int __devinit sh_keysc_probe(struct platform_device *pdev) 168 126 { ··· 202 164 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); 203 165 pdata = &priv->pdata; 204 166 205 - priv->iomem_base = ioremap_nocache(res->start, res_size(res)); 167 + priv->iomem_base = ioremap_nocache(res->start, resource_size(res)); 206 168 if (priv->iomem_base == NULL) { 207 169 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 208 170 error = -ENXIO; ··· 258 220 259 221 clk_enable(priv->clk); 260 222 261 - iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | 262 - pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); 263 - iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); 264 - iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); 223 + sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) | 224 + pdata->scan_timing); 225 + sh_keysc_level_mode(priv, 0); 265 226 266 227 device_init_wakeup(&pdev->dev, 1); 267 228 ··· 285 248 { 286 249 struct sh_keysc_priv *priv = platform_get_drvdata(pdev); 287 250 288 - iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); 251 + sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED); 289 252 290 253 input_unregister_device(priv->input); 291 254 free_irq(platform_get_irq(pdev, 0), pdev); ··· 307 270 int irq = platform_get_irq(pdev, 0); 308 271 unsigned short value; 309 272 310 - value = ioread16(priv->iomem_base + KYCR1_OFFS); 273 + value = sh_keysc_read(priv, KYCR1); 311 274 312 275 if (device_may_wakeup(dev)) { 313 276 value |= 0x80; ··· 316 279 value &= ~0x80; 317 280 } 318 281 319 - iowrite16(value, priv->iomem_base + KYCR1_OFFS); 282 + sh_keysc_write(priv, KYCR1, value); 320 283 321 284 return 0; 322 285 }
+1 -1
drivers/input/misc/apanel.c
··· 149 149 apanel_remove(client); 150 150 } 151 151 152 - static struct i2c_device_id apanel_id[] = { 152 + static const struct i2c_device_id apanel_id[] = { 153 153 { "fujitsu_apanel", 0 }, 154 154 { } 155 155 };
+14
drivers/input/misc/rotary_encoder.c
··· 152 152 goto exit_unregister_input; 153 153 } 154 154 155 + err = gpio_direction_input(pdata->gpio_a); 156 + if (err) { 157 + dev_err(&pdev->dev, "unable to set GPIO %d for input\n", 158 + pdata->gpio_a); 159 + goto exit_unregister_input; 160 + } 161 + 155 162 err = gpio_request(pdata->gpio_b, DRV_NAME); 156 163 if (err) { 157 164 dev_err(&pdev->dev, "unable to request GPIO %d\n", 165 + pdata->gpio_b); 166 + goto exit_free_gpio_a; 167 + } 168 + 169 + err = gpio_direction_input(pdata->gpio_b); 170 + if (err) { 171 + dev_err(&pdev->dev, "unable to set GPIO %d for input\n", 158 172 pdata->gpio_b); 159 173 goto exit_free_gpio_a; 160 174 }
+1 -3
drivers/input/misc/uinput.c
··· 34 34 #include <linux/slab.h> 35 35 #include <linux/module.h> 36 36 #include <linux/init.h> 37 - #include <linux/smp_lock.h> 38 37 #include <linux/fs.h> 39 38 #include <linux/miscdevice.h> 40 39 #include <linux/uinput.h> ··· 283 284 if (!newdev) 284 285 return -ENOMEM; 285 286 286 - lock_kernel(); 287 287 mutex_init(&newdev->mutex); 288 288 spin_lock_init(&newdev->requests_lock); 289 289 init_waitqueue_head(&newdev->requests_waitq); ··· 290 292 newdev->state = UIST_NEW_DEVICE; 291 293 292 294 file->private_data = newdev; 293 - unlock_kernel(); 295 + nonseekable_open(inode, file); 294 296 295 297 return 0; 296 298 }
+104 -109
drivers/input/misc/winbond-cir.c
··· 538 538 data->irdata_count = 0; 539 539 data->irdata_off = 0; 540 540 data->irdata_error = 0; 541 + data->idle_count = 0; 541 542 } 542 543 543 544 /* Adds one bit of irdata */ ··· 1007 1006 } 1008 1007 1009 1008 wbcir_reset_irdata(data); 1010 - data->idle_count = 0; 1011 1009 } 1012 1010 1013 1011 out: ··· 1018 1018 1019 1019 /***************************************************************************** 1020 1020 * 1021 - * SUSPEND/RESUME FUNCTIONS 1021 + * SETUP/INIT/SUSPEND/RESUME FUNCTIONS 1022 1022 * 1023 1023 *****************************************************************************/ 1024 1024 ··· 1197 1197 } 1198 1198 1199 1199 /* Disable interrupts */ 1200 + wbcir_select_bank(data, WBCIR_BANK_0); 1200 1201 outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER); 1202 + 1203 + /* 1204 + * ACPI will set the HW disable bit for SP3 which means that the 1205 + * output signals are left in an undefined state which may cause 1206 + * spurious interrupts which we need to ignore until the hardware 1207 + * is reinitialized. 1208 + */ 1209 + disable_irq(data->irq); 1201 1210 } 1202 1211 1203 1212 static int ··· 1216 1207 return 0; 1217 1208 } 1218 1209 1219 - static int 1220 - wbcir_resume(struct pnp_dev *device) 1221 - { 1222 - struct wbcir_data *data = pnp_get_drvdata(device); 1223 - 1224 - /* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */ 1225 - wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07); 1226 - 1227 - /* Clear CEIR_EN */ 1228 - wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x00, 0x01); 1229 - 1230 - /* Enable interrupts */ 1231 - wbcir_reset_irdata(data); 1232 - outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER); 1233 - 1234 - return 0; 1235 - } 1236 - 1237 - 1238 - 1239 - /***************************************************************************** 1240 - * 1241 - * SETUP/INIT FUNCTIONS 1242 - * 1243 - *****************************************************************************/ 1244 - 1245 1210 static void 1246 - wbcir_cfg_ceir(struct wbcir_data *data) 1211 + wbcir_init_hw(struct wbcir_data *data) 1247 1212 { 1248 1213 u8 tmp; 1214 + 1215 + /* Disable interrupts */ 1216 + wbcir_select_bank(data, WBCIR_BANK_0); 1217 + outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER); 1249 1218 1250 1219 /* Set PROT_SEL, RX_INV, Clear CEIR_EN (needed for the led) */ 1251 1220 tmp = protocol << 4; ··· 1251 1264 * set SP3_IRRX_SW to binary 01, helpfully not documented 1252 1265 */ 1253 1266 outb(0x10, data->ebase + WBCIR_REG_ECEIR_CTS); 1267 + 1268 + /* Enable extended mode */ 1269 + wbcir_select_bank(data, WBCIR_BANK_2); 1270 + outb(WBCIR_EXT_ENABLE, data->sbase + WBCIR_REG_SP3_EXCR1); 1271 + 1272 + /* 1273 + * Configure baud generator, IR data will be sampled at 1274 + * a bitrate of: (24Mhz * prescaler) / (divisor * 16). 1275 + * 1276 + * The ECIR registers include a flag to change the 1277 + * 24Mhz clock freq to 48Mhz. 1278 + * 1279 + * It's not documented in the specs, but fifo levels 1280 + * other than 16 seems to be unsupported. 1281 + */ 1282 + 1283 + /* prescaler 1.0, tx/rx fifo lvl 16 */ 1284 + outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2); 1285 + 1286 + /* Set baud divisor to generate one byte per bit/cell */ 1287 + switch (protocol) { 1288 + case IR_PROTOCOL_RC5: 1289 + outb(0xA7, data->sbase + WBCIR_REG_SP3_BGDL); 1290 + break; 1291 + case IR_PROTOCOL_RC6: 1292 + outb(0x53, data->sbase + WBCIR_REG_SP3_BGDL); 1293 + break; 1294 + case IR_PROTOCOL_NEC: 1295 + outb(0x69, data->sbase + WBCIR_REG_SP3_BGDL); 1296 + break; 1297 + } 1298 + outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH); 1299 + 1300 + /* Set CEIR mode */ 1301 + wbcir_select_bank(data, WBCIR_BANK_0); 1302 + outb(0xC0, data->sbase + WBCIR_REG_SP3_MCR); 1303 + inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */ 1304 + inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */ 1305 + 1306 + /* Disable RX demod, run-length encoding/decoding, set freq span */ 1307 + wbcir_select_bank(data, WBCIR_BANK_7); 1308 + outb(0x10, data->sbase + WBCIR_REG_SP3_RCCFG); 1309 + 1310 + /* Disable timer */ 1311 + wbcir_select_bank(data, WBCIR_BANK_4); 1312 + outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR1); 1313 + 1314 + /* Enable MSR interrupt, Clear AUX_IRX */ 1315 + wbcir_select_bank(data, WBCIR_BANK_5); 1316 + outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR2); 1317 + 1318 + /* Disable CRC */ 1319 + wbcir_select_bank(data, WBCIR_BANK_6); 1320 + outb(0x20, data->sbase + WBCIR_REG_SP3_IRCR3); 1321 + 1322 + /* Set RX/TX (de)modulation freq, not really used */ 1323 + wbcir_select_bank(data, WBCIR_BANK_7); 1324 + outb(0xF2, data->sbase + WBCIR_REG_SP3_IRRXDC); 1325 + outb(0x69, data->sbase + WBCIR_REG_SP3_IRTXMC); 1326 + 1327 + /* Set invert and pin direction */ 1328 + if (invert) 1329 + outb(0x10, data->sbase + WBCIR_REG_SP3_IRCFG4); 1330 + else 1331 + outb(0x00, data->sbase + WBCIR_REG_SP3_IRCFG4); 1332 + 1333 + /* Set FIFO thresholds (RX = 8, TX = 3), reset RX/TX */ 1334 + wbcir_select_bank(data, WBCIR_BANK_0); 1335 + outb(0x97, data->sbase + WBCIR_REG_SP3_FCR); 1336 + 1337 + /* Clear AUX status bits */ 1338 + outb(0xE0, data->sbase + WBCIR_REG_SP3_ASCR); 1339 + 1340 + /* Enable interrupts */ 1341 + wbcir_reset_irdata(data); 1342 + outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER); 1343 + } 1344 + 1345 + static int 1346 + wbcir_resume(struct pnp_dev *device) 1347 + { 1348 + struct wbcir_data *data = pnp_get_drvdata(device); 1349 + 1350 + wbcir_init_hw(data); 1351 + enable_irq(data->irq); 1352 + 1353 + return 0; 1254 1354 } 1255 1355 1256 1356 static int __devinit ··· 1467 1393 1468 1394 device_init_wakeup(&device->dev, 1); 1469 1395 1470 - wbcir_cfg_ceir(data); 1471 - 1472 - /* Disable interrupts */ 1473 - wbcir_select_bank(data, WBCIR_BANK_0); 1474 - outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER); 1475 - 1476 - /* Enable extended mode */ 1477 - wbcir_select_bank(data, WBCIR_BANK_2); 1478 - outb(WBCIR_EXT_ENABLE, data->sbase + WBCIR_REG_SP3_EXCR1); 1479 - 1480 - /* 1481 - * Configure baud generator, IR data will be sampled at 1482 - * a bitrate of: (24Mhz * prescaler) / (divisor * 16). 1483 - * 1484 - * The ECIR registers include a flag to change the 1485 - * 24Mhz clock freq to 48Mhz. 1486 - * 1487 - * It's not documented in the specs, but fifo levels 1488 - * other than 16 seems to be unsupported. 1489 - */ 1490 - 1491 - /* prescaler 1.0, tx/rx fifo lvl 16 */ 1492 - outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2); 1493 - 1494 - /* Set baud divisor to generate one byte per bit/cell */ 1495 - switch (protocol) { 1496 - case IR_PROTOCOL_RC5: 1497 - outb(0xA7, data->sbase + WBCIR_REG_SP3_BGDL); 1498 - break; 1499 - case IR_PROTOCOL_RC6: 1500 - outb(0x53, data->sbase + WBCIR_REG_SP3_BGDL); 1501 - break; 1502 - case IR_PROTOCOL_NEC: 1503 - outb(0x69, data->sbase + WBCIR_REG_SP3_BGDL); 1504 - break; 1505 - } 1506 - outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH); 1507 - 1508 - /* Set CEIR mode */ 1509 - wbcir_select_bank(data, WBCIR_BANK_0); 1510 - outb(0xC0, data->sbase + WBCIR_REG_SP3_MCR); 1511 - inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */ 1512 - inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */ 1513 - 1514 - /* Disable RX demod, run-length encoding/decoding, set freq span */ 1515 - wbcir_select_bank(data, WBCIR_BANK_7); 1516 - outb(0x10, data->sbase + WBCIR_REG_SP3_RCCFG); 1517 - 1518 - /* Disable timer */ 1519 - wbcir_select_bank(data, WBCIR_BANK_4); 1520 - outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR1); 1521 - 1522 - /* Enable MSR interrupt, Clear AUX_IRX */ 1523 - wbcir_select_bank(data, WBCIR_BANK_5); 1524 - outb(0x00, data->sbase + WBCIR_REG_SP3_IRCR2); 1525 - 1526 - /* Disable CRC */ 1527 - wbcir_select_bank(data, WBCIR_BANK_6); 1528 - outb(0x20, data->sbase + WBCIR_REG_SP3_IRCR3); 1529 - 1530 - /* Set RX/TX (de)modulation freq, not really used */ 1531 - wbcir_select_bank(data, WBCIR_BANK_7); 1532 - outb(0xF2, data->sbase + WBCIR_REG_SP3_IRRXDC); 1533 - outb(0x69, data->sbase + WBCIR_REG_SP3_IRTXMC); 1534 - 1535 - /* Set invert and pin direction */ 1536 - if (invert) 1537 - outb(0x10, data->sbase + WBCIR_REG_SP3_IRCFG4); 1538 - else 1539 - outb(0x00, data->sbase + WBCIR_REG_SP3_IRCFG4); 1540 - 1541 - /* Set FIFO thresholds (RX = 8, TX = 3), reset RX/TX */ 1542 - wbcir_select_bank(data, WBCIR_BANK_0); 1543 - outb(0x97, data->sbase + WBCIR_REG_SP3_FCR); 1544 - 1545 - /* Clear AUX status bits */ 1546 - outb(0xE0, data->sbase + WBCIR_REG_SP3_ASCR); 1547 - 1548 - /* Enable interrupts */ 1549 - outb(WBCIR_IRQ_RX | WBCIR_IRQ_ERR, data->sbase + WBCIR_REG_SP3_IER); 1396 + wbcir_init_hw(data); 1550 1397 1551 1398 return 0; 1552 1399
-4
drivers/input/mouse/hgpk.c
··· 68 68 MODULE_PARM_DESC(post_interrupt_delay, 69 69 "delay (ms) before recal after recal interrupt detected"); 70 70 71 - static int autorecal = 1; 72 - module_param(autorecal, int, 0644); 73 - MODULE_PARM_DESC(autorecal, "enable recalibration in the driver"); 74 - 75 71 /* 76 72 * When the touchpad gets ultra-sensitive, one can keep their finger 1/2" 77 73 * above the pad and still have it send packets. This causes a jump cursor
+1 -1
drivers/input/serio/pcips2.c
··· 186 186 pci_disable_device(dev); 187 187 } 188 188 189 - static struct pci_device_id pcips2_ids[] = { 189 + static const struct pci_device_id pcips2_ids[] = { 190 190 { 191 191 .vendor = 0x14f2, /* MOBILITY */ 192 192 .device = 0x0123, /* Keyboard */
+56 -75
drivers/input/serio/serio.c
··· 26 26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 27 27 */ 28 28 29 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 30 + 29 31 #include <linux/stddef.h> 30 32 #include <linux/module.h> 31 33 #include <linux/serio.h> ··· 121 119 122 120 error = device_bind_driver(&serio->dev); 123 121 if (error) { 124 - printk(KERN_WARNING 125 - "serio: device_bind_driver() failed " 126 - "for %s (%s) and %s, error: %d\n", 127 - serio->phys, serio->name, 128 - drv->description, error); 122 + dev_warn(&serio->dev, 123 + "device_bind_driver() failed for %s (%s) and %s, error: %d\n", 124 + serio->phys, serio->name, 125 + drv->description, error); 129 126 serio_disconnect_driver(serio); 130 127 serio->dev.driver = NULL; 131 128 return error; ··· 139 138 140 139 error = device_attach(&serio->dev); 141 140 if (error < 0) 142 - printk(KERN_WARNING 143 - "serio: device_attach() failed for %s (%s), error: %d\n", 144 - serio->phys, serio->name, error); 141 + dev_warn(&serio->dev, 142 + "device_attach() failed for %s (%s), error: %d\n", 143 + serio->phys, serio->name, error); 145 144 } 146 145 147 146 ··· 195 194 196 195 event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC); 197 196 if (!event) { 198 - printk(KERN_ERR 199 - "serio: Not enough memory to queue event %d\n", 200 - event_type); 197 + pr_err("Not enough memory to queue event %d\n", event_type); 201 198 retval = -ENOMEM; 202 199 goto out; 203 200 } 204 201 205 202 if (!try_module_get(owner)) { 206 - printk(KERN_WARNING 207 - "serio: Can't get module reference, dropping event %d\n", 208 - event_type); 203 + pr_warning("Can't get module reference, dropping event %d\n", 204 + event_type); 209 205 kfree(event); 210 206 retval = -EINVAL; 211 207 goto out; ··· 228 230 229 231 static void serio_remove_duplicate_events(struct serio_event *event) 230 232 { 231 - struct list_head *node, *next; 232 - struct serio_event *e; 233 + struct serio_event *e, *next; 233 234 unsigned long flags; 234 235 235 236 spin_lock_irqsave(&serio_event_lock, flags); 236 237 237 - list_for_each_safe(node, next, &serio_event_list) { 238 - e = list_entry(node, struct serio_event, node); 238 + list_for_each_entry_safe(e, next, &serio_event_list, node) { 239 239 if (event->object == e->object) { 240 240 /* 241 241 * If this event is of different type we should not ··· 243 247 if (event->type != e->type) 244 248 break; 245 249 246 - list_del_init(node); 250 + list_del_init(&e->node); 247 251 serio_free_event(e); 248 252 } 249 253 } ··· 254 258 255 259 static struct serio_event *serio_get_event(void) 256 260 { 257 - struct serio_event *event; 258 - struct list_head *node; 261 + struct serio_event *event = NULL; 259 262 unsigned long flags; 260 263 261 264 spin_lock_irqsave(&serio_event_lock, flags); 262 265 263 - if (list_empty(&serio_event_list)) { 264 - spin_unlock_irqrestore(&serio_event_lock, flags); 265 - return NULL; 266 + if (!list_empty(&serio_event_list)) { 267 + event = list_first_entry(&serio_event_list, 268 + struct serio_event, node); 269 + list_del_init(&event->node); 266 270 } 267 271 268 - node = serio_event_list.next; 269 - event = list_entry(node, struct serio_event, node); 270 - list_del_init(node); 271 - 272 272 spin_unlock_irqrestore(&serio_event_lock, flags); 273 - 274 273 return event; 275 274 } 276 275 ··· 278 287 while ((event = serio_get_event())) { 279 288 280 289 switch (event->type) { 281 - case SERIO_REGISTER_PORT: 282 - serio_add_port(event->object); 283 - break; 284 290 285 - case SERIO_RECONNECT_PORT: 286 - serio_reconnect_port(event->object); 287 - break; 291 + case SERIO_REGISTER_PORT: 292 + serio_add_port(event->object); 293 + break; 288 294 289 - case SERIO_RESCAN_PORT: 290 - serio_disconnect_port(event->object); 291 - serio_find_driver(event->object); 292 - break; 295 + case SERIO_RECONNECT_PORT: 296 + serio_reconnect_port(event->object); 297 + break; 293 298 294 - case SERIO_RECONNECT_CHAIN: 295 - serio_reconnect_chain(event->object); 296 - break; 299 + case SERIO_RESCAN_PORT: 300 + serio_disconnect_port(event->object); 301 + serio_find_driver(event->object); 302 + break; 297 303 298 - case SERIO_ATTACH_DRIVER: 299 - serio_attach_driver(event->object); 300 - break; 304 + case SERIO_RECONNECT_CHAIN: 305 + serio_reconnect_chain(event->object); 306 + break; 301 307 302 - default: 303 - break; 308 + case SERIO_ATTACH_DRIVER: 309 + serio_attach_driver(event->object); 310 + break; 304 311 } 305 312 306 313 serio_remove_duplicate_events(event); ··· 314 325 */ 315 326 static void serio_remove_pending_events(void *object) 316 327 { 317 - struct list_head *node, *next; 318 - struct serio_event *event; 328 + struct serio_event *event, *next; 319 329 unsigned long flags; 320 330 321 331 spin_lock_irqsave(&serio_event_lock, flags); 322 332 323 - list_for_each_safe(node, next, &serio_event_list) { 324 - event = list_entry(node, struct serio_event, node); 333 + list_for_each_entry_safe(event, next, &serio_event_list, node) { 325 334 if (event->object == object) { 326 - list_del_init(node); 335 + list_del_init(&event->node); 327 336 serio_free_event(event); 328 337 } 329 338 } ··· 367 380 kthread_should_stop() || !list_empty(&serio_event_list)); 368 381 } while (!kthread_should_stop()); 369 382 370 - printk(KERN_DEBUG "serio: kseriod exiting\n"); 371 383 return 0; 372 384 } 373 385 ··· 429 443 static struct attribute_group serio_id_attr_group = { 430 444 .name = "id", 431 445 .attrs = serio_device_id_attrs, 446 + }; 447 + 448 + static const struct attribute_group *serio_device_attr_groups[] = { 449 + &serio_id_attr_group, 450 + NULL 432 451 }; 433 452 434 453 static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) ··· 523 532 (long)atomic_inc_return(&serio_no) - 1); 524 533 serio->dev.bus = &serio_bus; 525 534 serio->dev.release = serio_release_port; 535 + serio->dev.groups = serio_device_attr_groups; 526 536 if (serio->parent) { 527 537 serio->dev.parent = &serio->parent->dev; 528 538 serio->depth = serio->parent->depth + 1; ··· 547 555 } 548 556 549 557 list_add_tail(&serio->node, &serio_list); 558 + 550 559 if (serio->start) 551 560 serio->start(serio); 561 + 552 562 error = device_add(&serio->dev); 553 563 if (error) 554 - printk(KERN_ERR 555 - "serio: device_add() failed for %s (%s), error: %d\n", 564 + dev_err(&serio->dev, 565 + "device_add() failed for %s (%s), error: %d\n", 556 566 serio->phys, serio->name, error); 557 - else { 558 - serio->registered = true; 559 - error = sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group); 560 - if (error) 561 - printk(KERN_ERR 562 - "serio: sysfs_create_group() failed for %s (%s), error: %d\n", 563 - serio->phys, serio->name, error); 564 - } 565 567 } 566 568 567 569 /* ··· 582 596 serio->parent = NULL; 583 597 } 584 598 585 - if (serio->registered) { 586 - sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group); 599 + if (device_is_registered(&serio->dev)) 587 600 device_del(&serio->dev); 588 - serio->registered = false; 589 - } 590 601 591 602 list_del_init(&serio->node); 592 603 serio_remove_pending_events(serio); ··· 781 798 782 799 error = driver_attach(&drv->driver); 783 800 if (error) 784 - printk(KERN_WARNING 785 - "serio: driver_attach() failed for %s with error %d\n", 786 - drv->driver.name, error); 801 + pr_warning("driver_attach() failed for %s with error %d\n", 802 + drv->driver.name, error); 787 803 } 788 804 789 805 int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name) ··· 802 820 803 821 error = driver_register(&drv->driver); 804 822 if (error) { 805 - printk(KERN_ERR 806 - "serio: driver_register() failed for %s, error: %d\n", 823 + pr_err("driver_register() failed for %s, error: %d\n", 807 824 drv->driver.name, error); 808 825 return error; 809 826 } ··· 968 987 969 988 if (likely(serio->drv)) { 970 989 ret = serio->drv->interrupt(serio, data, dfl); 971 - } else if (!dfl && serio->registered) { 990 + } else if (!dfl && device_is_registered(&serio->dev)) { 972 991 serio_rescan(serio); 973 992 ret = IRQ_HANDLED; 974 993 } ··· 999 1018 1000 1019 error = bus_register(&serio_bus); 1001 1020 if (error) { 1002 - printk(KERN_ERR "serio: failed to register serio bus, error: %d\n", error); 1021 + pr_err("Failed to register serio bus, error: %d\n", error); 1003 1022 return error; 1004 1023 } 1005 1024 ··· 1007 1026 if (IS_ERR(serio_task)) { 1008 1027 bus_unregister(&serio_bus); 1009 1028 error = PTR_ERR(serio_task); 1010 - printk(KERN_ERR "serio: Failed to start kseriod, error: %d\n", error); 1029 + pr_err("Failed to start kseriod, error: %d\n", error); 1011 1030 return error; 1012 1031 } 1013 1032
+3 -3
drivers/input/serio/xilinx_ps2.c
··· 270 270 drvdata->irq = r_irq.start; 271 271 272 272 phys_addr = r_mem.start; 273 - remap_size = r_mem.end - r_mem.start + 1; 273 + remap_size = resource_size(&r_mem); 274 274 if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) { 275 275 dev_err(dev, "Couldn't lock memory region at 0x%08llX\n", 276 276 (unsigned long long)phys_addr); ··· 344 344 if (of_address_to_resource(of_dev->node, 0, &r_mem)) 345 345 dev_err(dev, "invalid address\n"); 346 346 else 347 - release_mem_region(r_mem.start, r_mem.end - r_mem.start + 1); 347 + release_mem_region(r_mem.start, resource_size(&r_mem)); 348 348 349 349 kfree(drvdata); 350 350 ··· 354 354 } 355 355 356 356 /* Match table for of_platform binding */ 357 - static struct of_device_id xps2_of_match[] __devinitdata = { 357 + static const struct of_device_id xps2_of_match[] __devinitconst = { 358 358 { .compatible = "xlnx,xps-ps2-1.00.a", }, 359 359 { /* end of list */ }, 360 360 };
+1 -1
drivers/input/tablet/gtco.c
··· 92 92 /* DATA STRUCTURES */ 93 93 94 94 /* Device table */ 95 - static struct usb_device_id gtco_usbid_table [] = { 95 + static const struct usb_device_id gtco_usbid_table[] = { 96 96 { USB_DEVICE(VENDOR_ID_GTCO, PID_400) }, 97 97 { USB_DEVICE(VENDOR_ID_GTCO, PID_401) }, 98 98 { USB_DEVICE(VENDOR_ID_GTCO, PID_1000) },
+3 -2
drivers/input/tablet/wacom.h
··· 85 85 #include <linux/kernel.h> 86 86 #include <linux/slab.h> 87 87 #include <linux/module.h> 88 + #include <linux/mod_devicetable.h> 88 89 #include <linux/init.h> 89 90 #include <linux/usb/input.h> 90 91 #include <asm/unaligned.h> ··· 121 120 struct urb *urb; 122 121 }; 123 122 123 + extern const struct usb_device_id wacom_ids[]; 124 + 124 125 extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 125 126 extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data); 126 127 extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data); ··· 145 142 extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 146 143 extern __u16 wacom_le16_to_cpu(unsigned char *data); 147 144 extern __u16 wacom_be16_to_cpu(unsigned char *data); 148 - extern struct wacom_features *get_wacom_feature(const struct usb_device_id *id); 149 - extern const struct usb_device_id *get_device_table(void); 150 145 151 146 #endif
+50 -20
drivers/input/tablet/wacom_sys.c
··· 211 211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | 212 212 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | 213 213 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); 214 - input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 214 + input_set_abs_params(input_dev, ABS_DISTANCE, 215 + 0, wacom_wac->features.distance_max, 0, 0); 215 216 } 216 217 217 218 void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) ··· 262 261 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) | 263 262 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) | 264 263 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2); 265 - input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 264 + input_set_abs_params(input_dev, ABS_DISTANCE, 265 + 0, wacom_wac->features.distance_max, 0, 0); 266 266 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); 267 267 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); 268 268 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); ··· 284 282 285 283 void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 286 284 { 287 - if (wacom_wac->features->device_type == BTN_TOOL_DOUBLETAP || 288 - wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { 289 - input_set_abs_params(input_dev, ABS_RX, 0, wacom_wac->features->x_phy, 0, 0); 290 - input_set_abs_params(input_dev, ABS_RY, 0, wacom_wac->features->y_phy, 0, 0); 291 - input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP); 285 + struct wacom_features *features = &wacom_wac->features; 286 + 287 + if (features->device_type == BTN_TOOL_DOUBLETAP || 288 + features->device_type == BTN_TOOL_TRIPLETAP) { 289 + input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0); 290 + input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0); 291 + __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 292 292 } 293 293 } 294 294 295 295 void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 296 296 { 297 - if (wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { 297 + if (wacom_wac->features.device_type == BTN_TOOL_TRIPLETAP) { 298 298 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP); 299 299 input_dev->evbit[0] |= BIT_MASK(EV_MSC); 300 300 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); ··· 536 532 struct wacom_wac *wacom_wac; 537 533 struct wacom_features *features; 538 534 struct input_dev *input_dev; 539 - int error = -ENOMEM; 535 + int error; 536 + 537 + if (!id->driver_info) 538 + return -EINVAL; 540 539 541 540 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 542 541 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); 543 542 input_dev = input_allocate_device(); 544 - if (!wacom || !input_dev || !wacom_wac) 543 + if (!wacom || !input_dev || !wacom_wac) { 544 + error = -ENOMEM; 545 545 goto fail1; 546 + } 546 547 547 - wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX, GFP_KERNEL, &wacom->data_dma); 548 - if (!wacom_wac->data) 548 + wacom_wac->features = *((struct wacom_features *)id->driver_info); 549 + features = &wacom_wac->features; 550 + if (features->pktlen > WACOM_PKGLEN_MAX) { 551 + error = -EINVAL; 549 552 goto fail1; 553 + } 554 + 555 + wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX, 556 + GFP_KERNEL, &wacom->data_dma); 557 + if (!wacom_wac->data) { 558 + error = -ENOMEM; 559 + goto fail1; 560 + } 550 561 551 562 wacom->irq = usb_alloc_urb(0, GFP_KERNEL); 552 - if (!wacom->irq) 563 + if (!wacom->irq) { 564 + error = -ENOMEM; 553 565 goto fail2; 566 + } 554 567 555 568 wacom->usbdev = dev; 556 569 wacom->dev = input_dev; ··· 576 555 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 577 556 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 578 557 579 - wacom_wac->features = features = get_wacom_feature(id); 580 - BUG_ON(features->pktlen > WACOM_PKGLEN_MAX); 581 - 582 - input_dev->name = wacom_wac->features->name; 583 - wacom->wacom_wac = wacom_wac; 584 558 usb_to_input_id(dev, &input_dev->id); 585 559 586 560 input_dev->dev.parent = &intf->dev; ··· 591 575 error = wacom_retrieve_hid_descriptor(intf, features); 592 576 if (error) 593 577 goto fail2; 578 + 579 + strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); 580 + 581 + if (features->type == TABLETPC || features->type == TABLETPC2FG) { 582 + /* Append the device type to the name */ 583 + strlcat(wacom_wac->name, 584 + features->device_type == BTN_TOOL_PEN ? 585 + " Pen" : " Finger", 586 + sizeof(wacom_wac->name)); 587 + } 588 + 589 + input_dev->name = wacom_wac->name; 590 + wacom->wacom_wac = wacom_wac; 594 591 595 592 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 596 593 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH); ··· 669 640 static int wacom_resume(struct usb_interface *intf) 670 641 { 671 642 struct wacom *wacom = usb_get_intfdata(intf); 672 - struct wacom_features *features = wacom->wacom_wac->features; 643 + struct wacom_features *features = &wacom->wacom_wac->features; 673 644 int rv; 674 645 675 646 mutex_lock(&wacom->lock); ··· 692 663 693 664 static struct usb_driver wacom_driver = { 694 665 .name = "wacom", 666 + .id_table = wacom_ids, 695 667 .probe = wacom_probe, 696 668 .disconnect = wacom_disconnect, 697 669 .suspend = wacom_suspend, ··· 704 674 static int __init wacom_init(void) 705 675 { 706 676 int result; 707 - wacom_driver.id_table = get_device_table(); 677 + 708 678 result = usb_register(&wacom_driver); 709 679 if (result == 0) 710 680 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+231 -177
drivers/input/tablet/wacom_wac.c
··· 55 55 56 56 static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo) 57 57 { 58 + struct wacom_features *features = &wacom->features; 58 59 unsigned char *data = wacom->data; 59 60 int prox, pressure; 60 61 ··· 69 68 if (prox) { 70 69 wacom->id[0] = ERASER_DEVICE_ID; 71 70 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); 72 - if (wacom->features->pressure_max > 255) 71 + if (features->pressure_max > 255) 73 72 pressure = (pressure << 1) | ((data[4] >> 6) & 1); 74 - pressure += (wacom->features->pressure_max + 1) / 2; 73 + pressure += (features->pressure_max + 1) / 2; 75 74 76 75 /* 77 76 * if going from out of proximity into proximity select between the eraser ··· 153 152 154 153 static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo) 155 154 { 155 + struct wacom_features *features = &wacom->features; 156 156 unsigned char *data = wacom->data; 157 157 int x, y, rw; 158 158 static int penData = 0; ··· 181 179 182 180 case 2: /* Mouse with wheel */ 183 181 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04); 184 - if (wacom->features->type == WACOM_G4 || 185 - wacom->features->type == WACOM_MO) { 182 + if (features->type == WACOM_G4 || features->type == WACOM_MO) { 186 183 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03); 187 184 wacom_report_rel(wcombo, REL_WHEEL, -rw); 188 185 } else ··· 193 192 wacom->id[0] = CURSOR_DEVICE_ID; 194 193 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); 195 194 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); 196 - if (wacom->features->type == WACOM_G4 || 197 - wacom->features->type == WACOM_MO) 195 + if (features->type == WACOM_G4 || features->type == WACOM_MO) 198 196 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f); 199 197 else 200 198 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f); ··· 230 230 } 231 231 232 232 /* send pad data */ 233 - switch (wacom->features->type) { 233 + switch (features->type) { 234 234 case WACOM_G4: 235 235 if (data[7] & 0xf8) { 236 236 if (penData) { ··· 300 300 301 301 static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo) 302 302 { 303 + struct wacom_features *features = &wacom->features; 303 304 unsigned char *data = wacom->data; 304 305 int idx = 0; 305 306 306 307 /* tool number */ 307 - if (wacom->features->type == INTUOS) 308 + if (features->type == INTUOS) 308 309 idx = data[1] & 0x01; 309 310 310 311 /* Enter report */ ··· 403 402 wacom_report_key(wcombo, BTN_STYLUS2, 0); 404 403 wacom_report_key(wcombo, BTN_TOUCH, 0); 405 404 wacom_report_abs(wcombo, ABS_WHEEL, 0); 406 - if (wacom->features->type >= INTUOS3S) 405 + if (features->type >= INTUOS3S) 407 406 wacom_report_abs(wcombo, ABS_Z, 0); 408 407 } 409 408 wacom_report_key(wcombo, wacom->tool[idx], 0); ··· 417 416 418 417 static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo) 419 418 { 419 + struct wacom_features *features = &wacom->features; 420 420 unsigned char *data = wacom->data; 421 421 unsigned int t; 422 422 423 423 /* general pen packet */ 424 424 if ((data[1] & 0xb8) == 0xa0) { 425 425 t = (data[6] << 2) | ((data[7] >> 6) & 3); 426 - if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) 426 + if (features->type >= INTUOS4S && features->type <= INTUOS4L) 427 427 t = (t << 1) | (data[1] & 1); 428 428 wacom_report_abs(wcombo, ABS_PRESSURE, t); 429 429 wacom_report_abs(wcombo, ABS_TILT_X, ··· 448 446 449 447 static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo) 450 448 { 449 + struct wacom_features *features = &wacom->features; 451 450 unsigned char *data = wacom->data; 452 451 unsigned int t; 453 452 int idx = 0, result; ··· 460 457 } 461 458 462 459 /* tool number */ 463 - if (wacom->features->type == INTUOS) 460 + if (features->type == INTUOS) 464 461 idx = data[1] & 0x01; 465 462 466 463 /* pad packets. Works as a second tool and is always in prox */ ··· 469 466 if (wacom->tool[1] != BTN_TOOL_FINGER) 470 467 wacom->tool[1] = BTN_TOOL_FINGER; 471 468 472 - if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) { 469 + if (features->type >= INTUOS4S && features->type <= INTUOS4L) { 473 470 wacom_report_key(wcombo, BTN_0, (data[2] & 0x01)); 474 471 wacom_report_key(wcombo, BTN_1, (data[3] & 0x01)); 475 472 wacom_report_key(wcombo, BTN_2, (data[3] & 0x02)); ··· 483 480 /* Out of proximity, clear wheel value. */ 484 481 wacom_report_abs(wcombo, ABS_WHEEL, 0); 485 482 } 486 - if (wacom->features->type != INTUOS4S) { 483 + if (features->type != INTUOS4S) { 487 484 wacom_report_key(wcombo, BTN_7, (data[3] & 0x40)); 488 485 wacom_report_key(wcombo, BTN_8, (data[3] & 0x80)); 489 486 } ··· 531 528 return 0; 532 529 533 530 /* Only large Intuos support Lense Cursor */ 534 - if ((wacom->tool[idx] == BTN_TOOL_LENS) 535 - && ((wacom->features->type == INTUOS3) 536 - || (wacom->features->type == INTUOS3S) 537 - || (wacom->features->type == INTUOS4) 538 - || (wacom->features->type == INTUOS4S))) 531 + if (wacom->tool[idx] == BTN_TOOL_LENS && 532 + (features->type == INTUOS3 || 533 + features->type == INTUOS3S || 534 + features->type == INTUOS4 || 535 + features->type == INTUOS4S)) { 536 + 539 537 return 0; 538 + } 540 539 541 540 /* Cintiq doesn't send data when RDY bit isn't set */ 542 - if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40)) 541 + if (features->type == CINTIQ && !(data[1] & 0x40)) 543 542 return 0; 544 543 545 - if (wacom->features->type >= INTUOS3S) { 544 + if (features->type >= INTUOS3S) { 546 545 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); 547 546 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); 548 547 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); ··· 562 557 563 558 if (data[1] & 0x02) { 564 559 /* Rotation packet */ 565 - if (wacom->features->type >= INTUOS3S) { 560 + if (features->type >= INTUOS3S) { 566 561 /* I3 marker pen rotation */ 567 562 t = (data[6] << 3) | ((data[7] >> 5) & 7); 568 563 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : ··· 575 570 ((t - 1) / 2) : -t / 2); 576 571 } 577 572 578 - } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) { 573 + } else if (!(data[1] & 0x10) && features->type < INTUOS3S) { 579 574 /* 4D mouse packet */ 580 575 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 581 576 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); ··· 588 583 589 584 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { 590 585 /* I4 mouse */ 591 - if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) { 586 + if (features->type >= INTUOS4S && features->type <= INTUOS4L) { 592 587 wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01); 593 588 wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02); 594 589 wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04); ··· 609 604 - ((data[8] & 0x02) >> 1)); 610 605 611 606 /* I3 2D mouse side buttons */ 612 - if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) { 607 + if (features->type >= INTUOS3S && features->type <= INTUOS3L) { 613 608 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40); 614 609 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20); 615 610 } 616 611 } 617 - } else if ((wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L || 618 - wacom->features->type == INTUOS4L) && 612 + } else if ((features->type < INTUOS3S || features->type == INTUOS3L || 613 + features->type == INTUOS4L) && 619 614 wacom->tool[idx] == BTN_TOOL_LENS) { 620 615 /* Lens cursor packets */ 621 616 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); ··· 723 718 724 719 static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo) 725 720 { 721 + struct wacom_features *features = &wacom->features; 726 722 char *data = wacom->data; 727 723 int prox = 0, pressure, idx = -1; 728 724 static int stylusInProx, touchInProx = 1, touchOut; ··· 797 791 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 798 792 pressure = ((data[7] & 0x01) << 8) | data[6]; 799 793 if (pressure < 0) 800 - pressure = wacom->features->pressure_max + pressure + 1; 794 + pressure = features->pressure_max + pressure + 1; 801 795 wacom_report_abs(wcombo, ABS_PRESSURE, pressure); 802 796 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05); 803 797 } else { ··· 821 815 822 816 int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo) 823 817 { 824 - switch (wacom_wac->features->type) { 818 + switch (wacom_wac->features.type) { 825 819 case PENPARTNER: 826 820 return wacom_penpartner_irq(wacom_wac, wcombo); 827 821 ··· 859 853 860 854 void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 861 855 { 862 - switch (wacom_wac->features->type) { 856 + switch (wacom_wac->features.type) { 863 857 case WACOM_MO: 864 858 input_dev_mo(input_dev, wacom_wac); 865 859 case WACOM_G4: ··· 894 888 /* fall through */ 895 889 case TABLETPC: 896 890 input_dev_tpc(input_dev, wacom_wac); 897 - if (wacom_wac->features->device_type != BTN_TOOL_PEN) 891 + if (wacom_wac->features.device_type != BTN_TOOL_PEN) 898 892 break; /* no need to process stylus stuff */ 899 893 900 894 /* fall through */ ··· 909 903 return; 910 904 } 911 905 912 - static struct wacom_features wacom_features[] = { 913 - { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER }, 914 - { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }, 915 - { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }, 916 - { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE }, 917 - { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE }, 918 - { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }, 919 - { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 }, 920 - { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 }, 921 - { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }, 922 - { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO }, 923 - { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }, 924 - { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 925 - { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE }, 926 - { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 927 - { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE }, 928 - { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE }, 929 - { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }, 930 - { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }, 931 - { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }, 932 - { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 933 - { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }, 934 - { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }, 935 - { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }, 936 - { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL }, 937 - { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL }, 938 - { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL }, 939 - { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL }, 940 - { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL }, 941 - { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL }, 942 - { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL }, 943 - { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }, 944 - { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL }, 945 - { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }, 946 - { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }, 947 - { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }, 948 - { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU }, 949 - { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }, 950 - { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 951 - { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }, 952 - { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }, 953 - { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }, 954 - { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S }, 955 - { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 }, 956 - { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 }, 957 - { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L }, 958 - { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L }, 959 - { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 }, 960 - { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S }, 961 - { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S }, 962 - { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 }, 963 - { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L }, 964 - { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L }, 965 - { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ }, 966 - { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE }, 967 - { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE }, 968 - { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL }, 969 - { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 970 - { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 971 - { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }, 972 - { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC }, 973 - { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }, 974 - { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }, 975 - { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }, 906 + static const struct wacom_features wacom_features_0x00 = 907 + { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER }; 908 + static const struct wacom_features wacom_features_0x10 = 909 + { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }; 910 + static const struct wacom_features wacom_features_0x11 = 911 + { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE }; 912 + static const struct wacom_features wacom_features_0x12 = 913 + { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE }; 914 + static const struct wacom_features wacom_features_0x13 = 915 + { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE }; 916 + static const struct wacom_features wacom_features_0x14 = 917 + { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }; 918 + static const struct wacom_features wacom_features_0x15 = 919 + { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 }; 920 + static const struct wacom_features wacom_features_0x16 = 921 + { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 }; 922 + static const struct wacom_features wacom_features_0x17 = 923 + { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }; 924 + static const struct wacom_features wacom_features_0x18 = 925 + { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO }; 926 + static const struct wacom_features wacom_features_0x19 = 927 + { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE }; 928 + static const struct wacom_features wacom_features_0x60 = 929 + { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }; 930 + static const struct wacom_features wacom_features_0x61 = 931 + { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE }; 932 + static const struct wacom_features wacom_features_0x62 = 933 + { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }; 934 + static const struct wacom_features wacom_features_0x63 = 935 + { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE }; 936 + static const struct wacom_features wacom_features_0x64 = 937 + { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE }; 938 + static const struct wacom_features wacom_features_0x65 = 939 + { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }; 940 + static const struct wacom_features wacom_features_0x69 = 941 + { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE }; 942 + static const struct wacom_features wacom_features_0x20 = 943 + { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }; 944 + static const struct wacom_features wacom_features_0x21 = 945 + { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; 946 + static const struct wacom_features wacom_features_0x22 = 947 + { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }; 948 + static const struct wacom_features wacom_features_0x23 = 949 + { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }; 950 + static const struct wacom_features wacom_features_0x24 = 951 + { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }; 952 + static const struct wacom_features wacom_features_0x30 = 953 + { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL }; 954 + static const struct wacom_features wacom_features_0x31 = 955 + { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL }; 956 + static const struct wacom_features wacom_features_0x32 = 957 + { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL }; 958 + static const struct wacom_features wacom_features_0x33 = 959 + { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL }; 960 + static const struct wacom_features wacom_features_0x34 = 961 + { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL }; 962 + static const struct wacom_features wacom_features_0x35 = 963 + { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL }; 964 + static const struct wacom_features wacom_features_0x37 = 965 + { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL }; 966 + static const struct wacom_features wacom_features_0x38 = 967 + { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }; 968 + static const struct wacom_features wacom_features_0x39 = 969 + { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL }; 970 + static const struct wacom_features wacom_features_0xC4 = 971 + { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL }; 972 + static const struct wacom_features wacom_features_0xC0 = 973 + { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }; 974 + static const struct wacom_features wacom_features_0xC2 = 975 + { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL }; 976 + static const struct wacom_features wacom_features_0x03 = 977 + { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU }; 978 + static const struct wacom_features wacom_features_0x41 = 979 + { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS }; 980 + static const struct wacom_features wacom_features_0x42 = 981 + { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; 982 + static const struct wacom_features wacom_features_0x43 = 983 + { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS }; 984 + static const struct wacom_features wacom_features_0x44 = 985 + { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS }; 986 + static const struct wacom_features wacom_features_0x45 = 987 + { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS }; 988 + static const struct wacom_features wacom_features_0xB0 = 989 + { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S }; 990 + static const struct wacom_features wacom_features_0xB1 = 991 + { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 }; 992 + static const struct wacom_features wacom_features_0xB2 = 993 + { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 }; 994 + static const struct wacom_features wacom_features_0xB3 = 995 + { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L }; 996 + static const struct wacom_features wacom_features_0xB4 = 997 + { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L }; 998 + static const struct wacom_features wacom_features_0xB5 = 999 + { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 }; 1000 + static const struct wacom_features wacom_features_0xB7 = 1001 + { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S }; 1002 + static const struct wacom_features wacom_features_0xB8 = 1003 + { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S }; 1004 + static const struct wacom_features wacom_features_0xB9 = 1005 + { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 }; 1006 + static const struct wacom_features wacom_features_0xBA = 1007 + { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L }; 1008 + static const struct wacom_features wacom_features_0xBB = 1009 + { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L }; 1010 + static const struct wacom_features wacom_features_0x3F = 1011 + { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ }; 1012 + static const struct wacom_features wacom_features_0xC5 = 1013 + { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE }; 1014 + static const struct wacom_features wacom_features_0xC6 = 1015 + { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE }; 1016 + static const struct wacom_features wacom_features_0xC7 = 1017 + { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL }; 1018 + static const struct wacom_features wacom_features_0x90 = 1019 + { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }; 1020 + static const struct wacom_features wacom_features_0x93 = 1021 + { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }; 1022 + static const struct wacom_features wacom_features_0x9A = 1023 + { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC }; 1024 + static const struct wacom_features wacom_features_0x9F = 1025 + { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC }; 1026 + static const struct wacom_features wacom_features_0xE2 = 1027 + { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }; 1028 + static const struct wacom_features wacom_features_0xE3 = 1029 + { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }; 1030 + static const struct wacom_features wacom_features_0x47 = 1031 + { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; 1032 + 1033 + #define USB_DEVICE_WACOM(prod) \ 1034 + USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ 1035 + .driver_info = (kernel_ulong_t)&wacom_features_##prod 1036 + 1037 + const struct usb_device_id wacom_ids[] = { 1038 + { USB_DEVICE_WACOM(0x00) }, 1039 + { USB_DEVICE_WACOM(0x10) }, 1040 + { USB_DEVICE_WACOM(0x11) }, 1041 + { USB_DEVICE_WACOM(0x12) }, 1042 + { USB_DEVICE_WACOM(0x13) }, 1043 + { USB_DEVICE_WACOM(0x14) }, 1044 + { USB_DEVICE_WACOM(0x15) }, 1045 + { USB_DEVICE_WACOM(0x16) }, 1046 + { USB_DEVICE_WACOM(0x17) }, 1047 + { USB_DEVICE_WACOM(0x18) }, 1048 + { USB_DEVICE_WACOM(0x19) }, 1049 + { USB_DEVICE_WACOM(0x60) }, 1050 + { USB_DEVICE_WACOM(0x61) }, 1051 + { USB_DEVICE_WACOM(0x62) }, 1052 + { USB_DEVICE_WACOM(0x63) }, 1053 + { USB_DEVICE_WACOM(0x64) }, 1054 + { USB_DEVICE_WACOM(0x65) }, 1055 + { USB_DEVICE_WACOM(0x69) }, 1056 + { USB_DEVICE_WACOM(0x20) }, 1057 + { USB_DEVICE_WACOM(0x21) }, 1058 + { USB_DEVICE_WACOM(0x22) }, 1059 + { USB_DEVICE_WACOM(0x23) }, 1060 + { USB_DEVICE_WACOM(0x24) }, 1061 + { USB_DEVICE_WACOM(0x30) }, 1062 + { USB_DEVICE_WACOM(0x31) }, 1063 + { USB_DEVICE_WACOM(0x32) }, 1064 + { USB_DEVICE_WACOM(0x33) }, 1065 + { USB_DEVICE_WACOM(0x34) }, 1066 + { USB_DEVICE_WACOM(0x35) }, 1067 + { USB_DEVICE_WACOM(0x37) }, 1068 + { USB_DEVICE_WACOM(0x38) }, 1069 + { USB_DEVICE_WACOM(0x39) }, 1070 + { USB_DEVICE_WACOM(0xC4) }, 1071 + { USB_DEVICE_WACOM(0xC0) }, 1072 + { USB_DEVICE_WACOM(0xC2) }, 1073 + { USB_DEVICE_WACOM(0x03) }, 1074 + { USB_DEVICE_WACOM(0x41) }, 1075 + { USB_DEVICE_WACOM(0x42) }, 1076 + { USB_DEVICE_WACOM(0x43) }, 1077 + { USB_DEVICE_WACOM(0x44) }, 1078 + { USB_DEVICE_WACOM(0x45) }, 1079 + { USB_DEVICE_WACOM(0xB0) }, 1080 + { USB_DEVICE_WACOM(0xB1) }, 1081 + { USB_DEVICE_WACOM(0xB2) }, 1082 + { USB_DEVICE_WACOM(0xB3) }, 1083 + { USB_DEVICE_WACOM(0xB4) }, 1084 + { USB_DEVICE_WACOM(0xB5) }, 1085 + { USB_DEVICE_WACOM(0xB7) }, 1086 + { USB_DEVICE_WACOM(0xB8) }, 1087 + { USB_DEVICE_WACOM(0xB9) }, 1088 + { USB_DEVICE_WACOM(0xBA) }, 1089 + { USB_DEVICE_WACOM(0xBB) }, 1090 + { USB_DEVICE_WACOM(0x3F) }, 1091 + { USB_DEVICE_WACOM(0xC5) }, 1092 + { USB_DEVICE_WACOM(0xC6) }, 1093 + { USB_DEVICE_WACOM(0xC7) }, 1094 + { USB_DEVICE_WACOM(0x90) }, 1095 + { USB_DEVICE_WACOM(0x93) }, 1096 + { USB_DEVICE_WACOM(0x9A) }, 1097 + { USB_DEVICE_WACOM(0x9F) }, 1098 + { USB_DEVICE_WACOM(0xE2) }, 1099 + { USB_DEVICE_WACOM(0xE3) }, 1100 + { USB_DEVICE_WACOM(0x47) }, 976 1101 { } 977 1102 }; 978 - 979 - static struct usb_device_id wacom_ids[] = { 980 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) }, 981 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) }, 982 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) }, 983 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) }, 984 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) }, 985 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) }, 986 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) }, 987 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) }, 988 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) }, 989 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) }, 990 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x19) }, 991 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) }, 992 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) }, 993 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) }, 994 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) }, 995 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) }, 996 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) }, 997 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x69) }, 998 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) }, 999 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) }, 1000 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) }, 1001 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) }, 1002 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) }, 1003 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) }, 1004 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) }, 1005 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) }, 1006 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) }, 1007 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) }, 1008 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) }, 1009 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) }, 1010 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) }, 1011 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) }, 1012 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) }, 1013 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) }, 1014 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC2) }, 1015 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) }, 1016 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) }, 1017 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) }, 1018 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) }, 1019 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) }, 1020 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) }, 1021 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) }, 1022 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) }, 1023 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) }, 1024 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) }, 1025 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) }, 1026 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) }, 1027 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) }, 1028 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB8) }, 1029 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB9) }, 1030 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBA) }, 1031 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBB) }, 1032 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 1033 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) }, 1034 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) }, 1035 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC7) }, 1036 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x90) }, 1037 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x93) }, 1038 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9A) }, 1039 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9F) }, 1040 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE2) }, 1041 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE3) }, 1042 - { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 1043 - { } 1044 - }; 1045 - 1046 - const struct usb_device_id *get_device_table(void) 1047 - { 1048 - const struct usb_device_id *id_table = wacom_ids; 1049 - 1050 - return id_table; 1051 - } 1052 - 1053 - struct wacom_features * get_wacom_feature(const struct usb_device_id *id) 1054 - { 1055 - int index = id - wacom_ids; 1056 - struct wacom_features *wf = &wacom_features[index]; 1057 - 1058 - return wf; 1059 - } 1060 - 1061 1103 MODULE_DEVICE_TABLE(usb, wacom_ids);
+9 -8
drivers/input/tablet/wacom_wac.h
··· 15 15 /* packet length for individual models */ 16 16 #define WACOM_PKGLEN_PENPRTN 7 17 17 #define WACOM_PKGLEN_GRAPHIRE 8 18 - #define WACOM_PKGLEN_BBFUN 9 19 - #define WACOM_PKGLEN_INTUOS 10 18 + #define WACOM_PKGLEN_BBFUN 9 19 + #define WACOM_PKGLEN_INTUOS 10 20 20 #define WACOM_PKGLEN_PENABLED 8 21 21 #define WACOM_PKGLEN_TPC1FG 5 22 - #define WACOM_PKGLEN_TPC2FG 14 22 + #define WACOM_PKGLEN_TPC2FG 14 23 23 24 24 /* device IDs */ 25 25 #define STYLUS_DEVICE_ID 0x02 ··· 58 58 }; 59 59 60 60 struct wacom_features { 61 - char *name; 61 + const char *name; 62 62 int pktlen; 63 63 int x_max; 64 64 int y_max; ··· 73 73 }; 74 74 75 75 struct wacom_wac { 76 + char name[64]; 76 77 unsigned char *data; 77 - int tool[2]; 78 - int id[2]; 79 - __u32 serial[2]; 80 - struct wacom_features *features; 78 + int tool[2]; 79 + int id[2]; 80 + __u32 serial[2]; 81 + struct wacom_features features; 81 82 }; 82 83 83 84 #endif
+5 -1
drivers/input/touchscreen/Kconfig
··· 90 90 tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)" 91 91 depends on PXA_SHARPSL 92 92 select CORGI_SSP_DEPRECATED 93 - default y 94 93 help 95 94 Say Y here to enable the driver for the touchscreen on the 96 95 Sharp SL-C7xx and SL-Cxx00 series of PDAs. ··· 534 535 config TOUCHSCREEN_USB_ETT_TC5UH 535 536 default y 536 537 bool "ET&T TC5UH touchscreen controler support" if EMBEDDED 538 + depends on TOUCHSCREEN_USB_COMPOSITE 539 + 540 + config TOUCHSCREEN_USB_NEXIO 541 + default y 542 + bool "NEXIO/iNexio device support" if EMBEDDED 537 543 depends on TOUCHSCREEN_USB_COMPOSITE 538 544 539 545 config TOUCHSCREEN_TOUCHIT213
+27 -1
drivers/input/touchscreen/ads7846.c
··· 27 27 #include <linux/gpio.h> 28 28 #include <linux/spi/spi.h> 29 29 #include <linux/spi/ads7846.h> 30 + #include <linux/regulator/consumer.h> 30 31 #include <asm/irq.h> 31 32 32 33 /* ··· 86 85 char name[32]; 87 86 88 87 struct spi_device *spi; 88 + struct regulator *reg; 89 89 90 90 #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) 91 91 struct attribute_group *attr_group; ··· 790 788 } 791 789 } 792 790 791 + regulator_disable(ts->reg); 792 + 793 793 /* we know the chip's in lowpower mode since we always 794 794 * leave it that way after every request 795 795 */ ··· 802 798 { 803 799 if (!ts->disabled) 804 800 return; 801 + 802 + regulator_enable(ts->reg); 805 803 806 804 ts->disabled = 0; 807 805 ts->irq_disabled = 0; ··· 1145 1139 1146 1140 ts->last_msg = m; 1147 1141 1142 + ts->reg = regulator_get(&spi->dev, "vcc"); 1143 + if (IS_ERR(ts->reg)) { 1144 + dev_err(&spi->dev, "unable to get regulator: %ld\n", 1145 + PTR_ERR(ts->reg)); 1146 + goto err_free_gpio; 1147 + } 1148 + 1149 + err = regulator_enable(ts->reg); 1150 + if (err) { 1151 + dev_err(&spi->dev, "unable to enable regulator: %d\n", err); 1152 + goto err_put_regulator; 1153 + } 1154 + 1148 1155 if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING, 1149 1156 spi->dev.driver->name, ts)) { 1150 1157 dev_info(&spi->dev, ··· 1167 1148 spi->dev.driver->name, ts); 1168 1149 if (err) { 1169 1150 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1170 - goto err_free_gpio; 1151 + goto err_disable_regulator; 1171 1152 } 1172 1153 } 1173 1154 ··· 1199 1180 ads784x_hwmon_unregister(spi, ts); 1200 1181 err_free_irq: 1201 1182 free_irq(spi->irq, ts); 1183 + err_disable_regulator: 1184 + regulator_disable(ts->reg); 1185 + err_put_regulator: 1186 + regulator_put(ts->reg); 1202 1187 err_free_gpio: 1203 1188 if (ts->gpio_pendown != -1) 1204 1189 gpio_free(ts->gpio_pendown); ··· 1230 1207 free_irq(ts->spi->irq, ts); 1231 1208 /* suspend left the IRQ disabled */ 1232 1209 enable_irq(ts->spi->irq); 1210 + 1211 + regulator_disable(ts->reg); 1212 + regulator_put(ts->reg); 1233 1213 1234 1214 if (ts->gpio_pendown != -1) 1235 1215 gpio_free(ts->gpio_pendown);
+121 -106
drivers/input/touchscreen/elo.c
··· 72 72 struct input_dev *dev = elo->dev; 73 73 74 74 elo->data[elo->idx] = data; 75 - switch (elo->idx++) { 76 - case 0: 77 - elo->csum = 0xaa; 78 - if (data != ELO10_LEAD_BYTE) { 79 - pr_debug("elo: unsynchronized data: 0x%02x\n", data); 80 - elo->idx = 0; 81 - } 82 - break; 83 75 84 - case 9: 76 + switch (elo->idx++) { 77 + case 0: 78 + elo->csum = 0xaa; 79 + if (data != ELO10_LEAD_BYTE) { 80 + dev_dbg(&elo->serio->dev, 81 + "unsynchronized data: 0x%02x\n", data); 85 82 elo->idx = 0; 86 - if (data != elo->csum) { 87 - pr_debug("elo: bad checksum: 0x%02x, expected 0x%02x\n", 88 - data, elo->csum); 89 - break; 90 - } 91 - if (elo->data[1] != elo->expected_packet) { 92 - if (elo->data[1] != ELO10_TOUCH_PACKET) 93 - pr_debug("elo: unexpected packet: 0x%02x\n", 94 - elo->data[1]); 95 - break; 96 - } 97 - if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) { 98 - input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); 99 - input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); 100 - if (elo->data[2] & ELO10_PRESSURE) 101 - input_report_abs(dev, ABS_PRESSURE, 102 - (elo->data[8] << 8) | elo->data[7]); 103 - input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH); 104 - input_sync(dev); 105 - } else if (elo->data[1] == ELO10_ACK_PACKET) { 106 - if (elo->data[2] == '0') 107 - elo->expected_packet = ELO10_TOUCH_PACKET; 108 - complete(&elo->cmd_done); 109 - } else { 110 - memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN); 111 - elo->expected_packet = ELO10_ACK_PACKET; 112 - } 83 + } 84 + break; 85 + 86 + case 9: 87 + elo->idx = 0; 88 + if (data != elo->csum) { 89 + dev_dbg(&elo->serio->dev, 90 + "bad checksum: 0x%02x, expected 0x%02x\n", 91 + data, elo->csum); 113 92 break; 93 + } 94 + if (elo->data[1] != elo->expected_packet) { 95 + if (elo->data[1] != ELO10_TOUCH_PACKET) 96 + dev_dbg(&elo->serio->dev, 97 + "unexpected packet: 0x%02x\n", 98 + elo->data[1]); 99 + break; 100 + } 101 + if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) { 102 + input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); 103 + input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); 104 + if (elo->data[2] & ELO10_PRESSURE) 105 + input_report_abs(dev, ABS_PRESSURE, 106 + (elo->data[8] << 8) | elo->data[7]); 107 + input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH); 108 + input_sync(dev); 109 + } else if (elo->data[1] == ELO10_ACK_PACKET) { 110 + if (elo->data[2] == '0') 111 + elo->expected_packet = ELO10_TOUCH_PACKET; 112 + complete(&elo->cmd_done); 113 + } else { 114 + memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN); 115 + elo->expected_packet = ELO10_ACK_PACKET; 116 + } 117 + break; 114 118 } 115 119 elo->csum += data; 116 120 } ··· 127 123 128 124 switch (elo->idx++) { 129 125 130 - case 0: if ((data & 0xc0) != 0xc0) elo->idx = 0; break; 131 - case 1: if ((data & 0xc0) != 0x80) elo->idx = 0; break; 132 - case 2: if ((data & 0xc0) != 0x40) elo->idx = 0; break; 126 + case 0: 127 + if ((data & 0xc0) != 0xc0) 128 + elo->idx = 0; 129 + break; 133 130 134 - case 3: 135 - if (data & 0xc0) { 136 - elo->idx = 0; 137 - break; 138 - } 131 + case 1: 132 + if ((data & 0xc0) != 0x80) 133 + elo->idx = 0; 134 + break; 139 135 140 - input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f)); 141 - input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f)); 136 + case 2: 137 + if ((data & 0xc0) != 0x40) 138 + elo->idx = 0; 139 + break; 142 140 143 - if (elo->id == 2) { 144 - input_report_key(dev, BTN_TOUCH, 1); 145 - input_sync(dev); 146 - elo->idx = 0; 147 - } 148 - 149 - break; 150 - 151 - case 4: 152 - if (data) { 153 - input_sync(dev); 154 - elo->idx = 0; 155 - } 156 - break; 157 - 158 - case 5: 159 - if ((data & 0xf0) == 0) { 160 - input_report_abs(dev, ABS_PRESSURE, elo->data[5]); 161 - input_report_key(dev, BTN_TOUCH, !!elo->data[5]); 162 - } 163 - input_sync(dev); 141 + case 3: 142 + if (data & 0xc0) { 164 143 elo->idx = 0; 165 144 break; 145 + } 146 + 147 + input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f)); 148 + input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f)); 149 + 150 + if (elo->id == 2) { 151 + input_report_key(dev, BTN_TOUCH, 1); 152 + input_sync(dev); 153 + elo->idx = 0; 154 + } 155 + 156 + break; 157 + 158 + case 4: 159 + if (data) { 160 + input_sync(dev); 161 + elo->idx = 0; 162 + } 163 + break; 164 + 165 + case 5: 166 + if ((data & 0xf0) == 0) { 167 + input_report_abs(dev, ABS_PRESSURE, elo->data[5]); 168 + input_report_key(dev, BTN_TOUCH, !!elo->data[5]); 169 + } 170 + input_sync(dev); 171 + elo->idx = 0; 172 + break; 166 173 } 167 174 } 168 175 ··· 185 170 186 171 switch (elo->idx++) { 187 172 188 - case 0: 189 - if ((data & 0x7f) != 0x01) 190 - elo->idx = 0; 191 - break; 192 - case 2: 193 - input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80)); 194 - input_report_abs(dev, ABS_X, elo->data[1]); 195 - input_report_abs(dev, ABS_Y, elo->data[2]); 196 - input_sync(dev); 173 + case 0: 174 + if ((data & 0x7f) != 0x01) 197 175 elo->idx = 0; 198 - break; 176 + break; 177 + case 2: 178 + input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80)); 179 + input_report_abs(dev, ABS_X, elo->data[1]); 180 + input_report_abs(dev, ABS_Y, elo->data[2]); 181 + input_sync(dev); 182 + elo->idx = 0; 183 + break; 199 184 } 200 185 } 201 186 ··· 204 189 { 205 190 struct elo *elo = serio_get_drvdata(serio); 206 191 207 - switch(elo->id) { 208 - case 0: 209 - elo_process_data_10(elo, data); 210 - break; 192 + switch (elo->id) { 193 + case 0: 194 + elo_process_data_10(elo, data); 195 + break; 211 196 212 - case 1: 213 - case 2: 214 - elo_process_data_6(elo, data); 215 - break; 197 + case 1: 198 + case 2: 199 + elo_process_data_6(elo, data); 200 + break; 216 201 217 - case 3: 218 - elo_process_data_3(elo, data); 219 - break; 202 + case 3: 203 + elo_process_data_3(elo, data); 204 + break; 220 205 } 221 206 222 207 return IRQ_HANDLED; ··· 276 261 if (packet[3] & ELO10_PRESSURE) 277 262 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); 278 263 279 - printk(KERN_INFO "elo: %sTouch touchscreen, fw: %02x.%02x, " 280 - "features: 0x%02x, controller: 0x%02x\n", 281 - elo_types[(packet[1] -'0') & 0x03], 282 - packet[5], packet[4], packet[3], packet[7]); 264 + dev_info(&elo->serio->dev, 265 + "%sTouch touchscreen, fw: %02x.%02x, features: 0x%02x, controller: 0x%02x\n", 266 + elo_types[(packet[1] -'0') & 0x03], 267 + packet[5], packet[4], packet[3], packet[7]); 283 268 284 269 return 0; 285 270 } ··· 345 330 346 331 switch (elo->id) { 347 332 348 - case 0: /* 10-byte protocol */ 349 - if (elo_setup_10(elo)) 350 - goto fail3; 333 + case 0: /* 10-byte protocol */ 334 + if (elo_setup_10(elo)) 335 + goto fail3; 351 336 352 - break; 337 + break; 353 338 354 - case 1: /* 6-byte protocol */ 355 - input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); 339 + case 1: /* 6-byte protocol */ 340 + input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); 356 341 357 - case 2: /* 4-byte protocol */ 358 - input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); 359 - input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); 360 - break; 342 + case 2: /* 4-byte protocol */ 343 + input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); 344 + input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); 345 + break; 361 346 362 - case 3: /* 3-byte protocol */ 363 - input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); 364 - input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); 365 - break; 347 + case 3: /* 3-byte protocol */ 348 + input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); 349 + input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); 350 + break; 366 351 } 367 352 368 353 err = input_register_device(elo->dev);
+3
drivers/input/touchscreen/mainstone-wm97xx.c
··· 153 153 if (pressure) 154 154 p = MODR; 155 155 156 + dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n", 157 + x, y, p); 158 + 156 159 /* are samples valid */ 157 160 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || 158 161 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y ||
+21 -18
drivers/input/touchscreen/s3c2410_ts.c
··· 128 128 129 129 down = get_down(data0, data1); 130 130 131 - if (ts.count == (1 << ts.shift)) { 132 - ts.xp >>= ts.shift; 133 - ts.yp >>= ts.shift; 134 - 135 - dev_dbg(ts.dev, "%s: X=%lu, Y=%lu, count=%d\n", 136 - __func__, ts.xp, ts.yp, ts.count); 137 - 138 - input_report_abs(ts.input, ABS_X, ts.xp); 139 - input_report_abs(ts.input, ABS_Y, ts.yp); 140 - 141 - input_report_key(ts.input, BTN_TOUCH, 1); 142 - input_sync(ts.input); 143 - 144 - ts.xp = 0; 145 - ts.yp = 0; 146 - ts.count = 0; 147 - } 148 - 149 131 if (down) { 132 + if (ts.count == (1 << ts.shift)) { 133 + ts.xp >>= ts.shift; 134 + ts.yp >>= ts.shift; 135 + 136 + dev_dbg(ts.dev, "%s: X=%lu, Y=%lu, count=%d\n", 137 + __func__, ts.xp, ts.yp, ts.count); 138 + 139 + input_report_abs(ts.input, ABS_X, ts.xp); 140 + input_report_abs(ts.input, ABS_Y, ts.yp); 141 + 142 + input_report_key(ts.input, BTN_TOUCH, 1); 143 + input_sync(ts.input); 144 + 145 + ts.xp = 0; 146 + ts.yp = 0; 147 + ts.count = 0; 148 + } 149 + 150 150 s3c_adc_start(ts.client, 0, 1 << ts.shift); 151 151 } else { 152 + ts.xp = 0; 153 + ts.yp = 0; 152 154 ts.count = 0; 153 155 154 156 input_report_key(ts.input, BTN_TOUCH, 0); ··· 403 401 struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; 404 402 405 403 clk_enable(ts.clock); 404 + enable_irq(ts.irq_tc); 406 405 407 406 /* Initialise registers */ 408 407 if ((info->delay & 0xffff) > 0)
+1 -1
drivers/input/touchscreen/tsc2007.c
··· 358 358 return 0; 359 359 } 360 360 361 - static struct i2c_device_id tsc2007_idtable[] = { 361 + static const struct i2c_device_id tsc2007_idtable[] = { 362 362 { "tsc2007", 0 }, 363 363 { } 364 364 };
+299 -18
drivers/input/touchscreen/usbtouchscreen.c
··· 15 15 * - GoTop Super_Q2/GogoPen/PenPower tablets 16 16 * - JASTEC USB touch controller/DigiTech DTR-02U 17 17 * - Zytronic capacitive touchscreen 18 + * - NEXIO/iNexio 18 19 * 19 20 * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch> 20 21 * Copyright (C) by Todd E. Johnson (mtouchusb.c) ··· 96 95 97 96 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); 98 97 int (*init) (struct usbtouch_usb *usbtouch); 98 + void (*exit) (struct usbtouch_usb *usbtouch); 99 99 }; 100 100 101 101 /* a usbtouch device */ ··· 106 104 unsigned char *buffer; 107 105 int buf_len; 108 106 struct urb *irq; 109 - struct usb_device *udev; 107 + struct usb_interface *interface; 110 108 struct input_dev *input; 111 109 struct usbtouch_device_info *type; 112 110 char name[128]; 113 111 char phys[64]; 112 + void *priv; 114 113 115 114 int x, y; 116 115 int touch, press; ··· 136 133 DEVTYPE_E2I, 137 134 DEVTYPE_ZYTRONIC, 138 135 DEVTYPE_TC5UH, 136 + DEVTYPE_NEXIO, 139 137 }; 140 138 141 139 #define USB_DEVICE_HID_CLASS(vend, prod) \ ··· 148 144 .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ 149 145 .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE 150 146 151 - static struct usb_device_id usbtouch_devices[] = { 147 + static const struct usb_device_id usbtouch_devices[] = { 152 148 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX 153 149 /* ignore the HID capable devices, handled by usbhid */ 154 150 {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE}, ··· 226 222 {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC5UH}, 227 223 #endif 228 224 225 + #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO 226 + /* data interface only */ 227 + {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00), 228 + .driver_info = DEVTYPE_NEXIO}, 229 + {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00), 230 + .driver_info = DEVTYPE_NEXIO}, 231 + #endif 232 + 229 233 {} 230 234 }; 231 235 ··· 246 234 static int e2i_init(struct usbtouch_usb *usbtouch) 247 235 { 248 236 int ret; 237 + struct usb_device *udev = interface_to_usbdev(usbtouch->interface); 249 238 250 - ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 239 + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 251 240 0x01, 0x02, 0x0000, 0x0081, 252 241 NULL, 0, USB_CTRL_SET_TIMEOUT); 253 242 ··· 357 344 static int mtouch_init(struct usbtouch_usb *usbtouch) 358 345 { 359 346 int ret, i; 347 + struct usb_device *udev = interface_to_usbdev(usbtouch->interface); 360 348 361 - ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 349 + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 362 350 MTOUCHUSB_RESET, 363 351 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 364 352 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); ··· 370 356 msleep(150); 371 357 372 358 for (i = 0; i < 3; i++) { 373 - ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 359 + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 374 360 MTOUCHUSB_ASYNC_REPORT, 375 361 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 376 362 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); ··· 503 489 504 490 static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) 505 491 { 506 - struct usb_device *dev = usbtouch->udev; 492 + struct usb_device *dev = interface_to_usbdev(usbtouch->interface); 507 493 int ret = -ENOMEM; 508 494 unsigned char *buf; 509 495 ··· 704 690 #endif 705 691 706 692 /***************************************************************************** 693 + * NEXIO Part 694 + */ 695 + #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO 696 + 697 + #define NEXIO_TIMEOUT 5000 698 + #define NEXIO_BUFSIZE 1024 699 + #define NEXIO_THRESHOLD 50 700 + 701 + struct nexio_priv { 702 + struct urb *ack; 703 + unsigned char *ack_buf; 704 + }; 705 + 706 + struct nexio_touch_packet { 707 + u8 flags; /* 0xe1 = touch, 0xe1 = release */ 708 + __be16 data_len; /* total bytes of touch data */ 709 + __be16 x_len; /* bytes for X axis */ 710 + __be16 y_len; /* bytes for Y axis */ 711 + u8 data[]; 712 + } __attribute__ ((packed)); 713 + 714 + static unsigned char nexio_ack_pkt[2] = { 0xaa, 0x02 }; 715 + static unsigned char nexio_init_pkt[4] = { 0x82, 0x04, 0x0a, 0x0f }; 716 + 717 + static void nexio_ack_complete(struct urb *urb) 718 + { 719 + } 720 + 721 + static int nexio_init(struct usbtouch_usb *usbtouch) 722 + { 723 + struct usb_device *dev = interface_to_usbdev(usbtouch->interface); 724 + struct usb_host_interface *interface = usbtouch->interface->cur_altsetting; 725 + struct nexio_priv *priv; 726 + int ret = -ENOMEM; 727 + int actual_len, i; 728 + unsigned char *buf; 729 + char *firmware_ver = NULL, *device_name = NULL; 730 + int input_ep = 0, output_ep = 0; 731 + 732 + /* find first input and output endpoint */ 733 + for (i = 0; i < interface->desc.bNumEndpoints; i++) { 734 + if (!input_ep && 735 + usb_endpoint_dir_in(&interface->endpoint[i].desc)) 736 + input_ep = interface->endpoint[i].desc.bEndpointAddress; 737 + if (!output_ep && 738 + usb_endpoint_dir_out(&interface->endpoint[i].desc)) 739 + output_ep = interface->endpoint[i].desc.bEndpointAddress; 740 + } 741 + if (!input_ep || !output_ep) 742 + return -ENXIO; 743 + 744 + buf = kmalloc(NEXIO_BUFSIZE, GFP_KERNEL); 745 + if (!buf) 746 + goto out_buf; 747 + 748 + /* two empty reads */ 749 + for (i = 0; i < 2; i++) { 750 + ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep), 751 + buf, NEXIO_BUFSIZE, &actual_len, 752 + NEXIO_TIMEOUT); 753 + if (ret < 0) 754 + goto out_buf; 755 + } 756 + 757 + /* send init command */ 758 + memcpy(buf, nexio_init_pkt, sizeof(nexio_init_pkt)); 759 + ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, output_ep), 760 + buf, sizeof(nexio_init_pkt), &actual_len, 761 + NEXIO_TIMEOUT); 762 + if (ret < 0) 763 + goto out_buf; 764 + 765 + /* read replies */ 766 + for (i = 0; i < 3; i++) { 767 + memset(buf, 0, NEXIO_BUFSIZE); 768 + ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep), 769 + buf, NEXIO_BUFSIZE, &actual_len, 770 + NEXIO_TIMEOUT); 771 + if (ret < 0 || actual_len < 1 || buf[1] != actual_len) 772 + continue; 773 + switch (buf[0]) { 774 + case 0x83: /* firmware version */ 775 + if (!firmware_ver) 776 + firmware_ver = kstrdup(&buf[2], GFP_KERNEL); 777 + break; 778 + case 0x84: /* device name */ 779 + if (!device_name) 780 + device_name = kstrdup(&buf[2], GFP_KERNEL); 781 + break; 782 + } 783 + } 784 + 785 + printk(KERN_INFO "Nexio device: %s, firmware version: %s\n", 786 + device_name, firmware_ver); 787 + 788 + kfree(firmware_ver); 789 + kfree(device_name); 790 + 791 + /* prepare ACK URB */ 792 + ret = -ENOMEM; 793 + 794 + usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL); 795 + if (!usbtouch->priv) 796 + goto out_buf; 797 + 798 + priv = usbtouch->priv; 799 + 800 + priv->ack_buf = kmalloc(sizeof(nexio_ack_pkt), GFP_KERNEL); 801 + if (!priv->ack_buf) 802 + goto err_priv; 803 + 804 + memcpy(priv->ack_buf, nexio_ack_pkt, sizeof(nexio_ack_pkt)); 805 + 806 + priv->ack = usb_alloc_urb(0, GFP_KERNEL); 807 + if (!priv->ack) { 808 + dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__); 809 + goto err_ack_buf; 810 + } 811 + 812 + usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep), 813 + priv->ack_buf, sizeof(nexio_ack_pkt), 814 + nexio_ack_complete, usbtouch); 815 + ret = 0; 816 + goto out_buf; 817 + 818 + err_ack_buf: 819 + kfree(priv->ack_buf); 820 + err_priv: 821 + kfree(priv); 822 + out_buf: 823 + kfree(buf); 824 + return ret; 825 + } 826 + 827 + static void nexio_exit(struct usbtouch_usb *usbtouch) 828 + { 829 + struct nexio_priv *priv = usbtouch->priv; 830 + 831 + usb_kill_urb(priv->ack); 832 + usb_free_urb(priv->ack); 833 + kfree(priv->ack_buf); 834 + kfree(priv); 835 + } 836 + 837 + static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt) 838 + { 839 + int x, y, begin_x, begin_y, end_x, end_y, w, h, ret; 840 + struct nexio_touch_packet *packet = (void *) pkt; 841 + struct nexio_priv *priv = usbtouch->priv; 842 + 843 + /* got touch data? */ 844 + if ((pkt[0] & 0xe0) != 0xe0) 845 + return 0; 846 + 847 + /* send ACK */ 848 + ret = usb_submit_urb(priv->ack, GFP_ATOMIC); 849 + 850 + if (!usbtouch->type->max_xc) { 851 + usbtouch->type->max_xc = 2 * be16_to_cpu(packet->x_len); 852 + input_set_abs_params(usbtouch->input, ABS_X, 0, 853 + 2 * be16_to_cpu(packet->x_len), 0, 0); 854 + usbtouch->type->max_yc = 2 * be16_to_cpu(packet->y_len); 855 + input_set_abs_params(usbtouch->input, ABS_Y, 0, 856 + 2 * be16_to_cpu(packet->y_len), 0, 0); 857 + } 858 + /* 859 + * The device reports state of IR sensors on X and Y axes. 860 + * Each byte represents "darkness" percentage (0-100) of one element. 861 + * 17" touchscreen reports only 64 x 52 bytes so the resolution is low. 862 + * This also means that there's a limited multi-touch capability but 863 + * it's disabled (and untested) here as there's no X driver for that. 864 + */ 865 + begin_x = end_x = begin_y = end_y = -1; 866 + for (x = 0; x < be16_to_cpu(packet->x_len); x++) { 867 + if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) { 868 + begin_x = x; 869 + continue; 870 + } 871 + if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) { 872 + end_x = x - 1; 873 + for (y = be16_to_cpu(packet->x_len); 874 + y < be16_to_cpu(packet->data_len); y++) { 875 + if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) { 876 + begin_y = y - be16_to_cpu(packet->x_len); 877 + continue; 878 + } 879 + if (end_y == -1 && 880 + begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) { 881 + end_y = y - 1 - be16_to_cpu(packet->x_len); 882 + w = end_x - begin_x; 883 + h = end_y - begin_y; 884 + #if 0 885 + /* multi-touch */ 886 + input_report_abs(usbtouch->input, 887 + ABS_MT_TOUCH_MAJOR, max(w,h)); 888 + input_report_abs(usbtouch->input, 889 + ABS_MT_TOUCH_MINOR, min(x,h)); 890 + input_report_abs(usbtouch->input, 891 + ABS_MT_POSITION_X, 2*begin_x+w); 892 + input_report_abs(usbtouch->input, 893 + ABS_MT_POSITION_Y, 2*begin_y+h); 894 + input_report_abs(usbtouch->input, 895 + ABS_MT_ORIENTATION, w > h); 896 + input_mt_sync(usbtouch->input); 897 + #endif 898 + /* single touch */ 899 + usbtouch->x = 2 * begin_x + w; 900 + usbtouch->y = 2 * begin_y + h; 901 + usbtouch->touch = packet->flags & 0x01; 902 + begin_y = end_y = -1; 903 + return 1; 904 + } 905 + } 906 + begin_x = end_x = -1; 907 + } 908 + 909 + } 910 + return 0; 911 + } 912 + #endif 913 + 914 + 915 + /***************************************************************************** 707 916 * the different device descriptors 708 917 */ 709 918 #ifdef MULTI_PACKET ··· 1110 873 .read_data = tc5uh_read_data, 1111 874 }, 1112 875 #endif 876 + 877 + #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO 878 + [DEVTYPE_NEXIO] = { 879 + .rept_size = 128, 880 + .irq_always = true, 881 + .read_data = nexio_read_data, 882 + .init = nexio_init, 883 + .exit = nexio_exit, 884 + }, 885 + #endif 1113 886 }; 1114 887 1115 888 ··· 1245 998 case -ECONNRESET: 1246 999 case -ENOENT: 1247 1000 case -ESHUTDOWN: 1001 + case -EPIPE: 1248 1002 /* this urb is terminated, clean up */ 1249 1003 dbg("%s - urb shutting down with status: %d", 1250 1004 __func__, urb->status); ··· 1269 1021 { 1270 1022 struct usbtouch_usb *usbtouch = input_get_drvdata(input); 1271 1023 1272 - usbtouch->irq->dev = usbtouch->udev; 1024 + usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface); 1273 1025 1274 1026 if (!usbtouch->type->irq_always) { 1275 1027 if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) ··· 1296 1048 kfree(usbtouch->buffer); 1297 1049 } 1298 1050 1051 + static struct usb_endpoint_descriptor * 1052 + usbtouch_get_input_endpoint(struct usb_host_interface *interface) 1053 + { 1054 + int i; 1055 + 1056 + for (i = 0; i < interface->desc.bNumEndpoints; i++) 1057 + if (usb_endpoint_dir_in(&interface->endpoint[i].desc)) 1058 + return &interface->endpoint[i].desc; 1059 + 1060 + return NULL; 1061 + } 1299 1062 1300 1063 static int usbtouch_probe(struct usb_interface *intf, 1301 1064 const struct usb_device_id *id) 1302 1065 { 1303 1066 struct usbtouch_usb *usbtouch; 1304 1067 struct input_dev *input_dev; 1305 - struct usb_host_interface *interface; 1306 1068 struct usb_endpoint_descriptor *endpoint; 1307 1069 struct usb_device *udev = interface_to_usbdev(intf); 1308 1070 struct usbtouch_device_info *type; ··· 1322 1064 if (id->driver_info == DEVTYPE_IGNORE) 1323 1065 return -ENODEV; 1324 1066 1325 - interface = intf->cur_altsetting; 1326 - endpoint = &interface->endpoint[0].desc; 1067 + endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting); 1068 + if (!endpoint) 1069 + return -ENXIO; 1327 1070 1328 1071 usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); 1329 1072 input_dev = input_allocate_device(); ··· 1353 1094 goto out_free_buffers; 1354 1095 } 1355 1096 1356 - usbtouch->udev = udev; 1097 + usbtouch->interface = intf; 1357 1098 usbtouch->input = input_dev; 1358 1099 1359 1100 if (udev->manufacturer) ··· 1392 1133 input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press, 1393 1134 type->max_press, 0, 0); 1394 1135 1395 - usb_fill_int_urb(usbtouch->irq, usbtouch->udev, 1396 - usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress), 1136 + if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT) 1137 + usb_fill_int_urb(usbtouch->irq, udev, 1138 + usb_rcvintpipe(udev, endpoint->bEndpointAddress), 1397 1139 usbtouch->data, type->rept_size, 1398 1140 usbtouch_irq, usbtouch, endpoint->bInterval); 1141 + else 1142 + usb_fill_bulk_urb(usbtouch->irq, udev, 1143 + usb_rcvbulkpipe(udev, endpoint->bEndpointAddress), 1144 + usbtouch->data, type->rept_size, 1145 + usbtouch_irq, usbtouch); 1399 1146 1400 - usbtouch->irq->dev = usbtouch->udev; 1147 + usbtouch->irq->dev = udev; 1401 1148 usbtouch->irq->transfer_dma = usbtouch->data_dma; 1402 1149 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1403 1150 ··· 1412 1147 err = type->init(usbtouch); 1413 1148 if (err) { 1414 1149 dbg("%s - type->init() failed, err: %d", __func__, err); 1415 - goto out_free_buffers; 1150 + goto out_free_urb; 1416 1151 } 1417 1152 } 1418 1153 1419 1154 err = input_register_device(usbtouch->input); 1420 1155 if (err) { 1421 1156 dbg("%s - input_register_device failed, err: %d", __func__, err); 1422 - goto out_free_buffers; 1157 + goto out_do_exit; 1423 1158 } 1424 1159 1425 1160 usb_set_intfdata(intf, usbtouch); 1426 1161 1427 - if (usbtouch->type->irq_always) 1428 - usb_submit_urb(usbtouch->irq, GFP_KERNEL); 1162 + if (usbtouch->type->irq_always) { 1163 + err = usb_submit_urb(usbtouch->irq, GFP_KERNEL); 1164 + if (err) { 1165 + err("%s - usb_submit_urb failed with result: %d", 1166 + __func__, err); 1167 + goto out_unregister_input; 1168 + } 1169 + } 1429 1170 1430 1171 return 0; 1431 1172 1173 + out_unregister_input: 1174 + input_unregister_device(input_dev); 1175 + input_dev = NULL; 1176 + out_do_exit: 1177 + if (type->exit) 1178 + type->exit(usbtouch); 1179 + out_free_urb: 1180 + usb_free_urb(usbtouch->irq); 1432 1181 out_free_buffers: 1433 1182 usbtouch_free_buffers(udev, usbtouch); 1434 1183 out_free: ··· 1465 1186 /* this will stop IO via close */ 1466 1187 input_unregister_device(usbtouch->input); 1467 1188 usb_free_urb(usbtouch->irq); 1189 + if (usbtouch->type->exit) 1190 + usbtouch->type->exit(usbtouch); 1468 1191 usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch); 1469 1192 kfree(usbtouch); 1470 1193 }
+3
drivers/input/touchscreen/zylonite-wm97xx.c
··· 118 118 if (pressure) 119 119 p = MODR; 120 120 121 + dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n", 122 + x, y, p); 123 + 121 124 /* are samples valid */ 122 125 if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || 123 126 (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y ||
+1 -1
drivers/input/xen-kbdfront.c
··· 321 321 } 322 322 } 323 323 324 - static struct xenbus_device_id xenkbd_ids[] = { 324 + static const struct xenbus_device_id xenkbd_ids[] = { 325 325 { "vkbd" }, 326 326 { "" } 327 327 };
+5 -2
drivers/macintosh/Kconfig
··· 171 171 If unsure, say Y. 172 172 173 173 config MAC_EMUMOUSEBTN 174 - bool "Support for mouse button 2+3 emulation" 175 - select INPUT 174 + tristate "Support for mouse button 2+3 emulation" 175 + depends on SYSCTL && INPUT 176 176 help 177 177 This provides generic support for emulating the 2nd and 3rd mouse 178 178 button with keypresses. If you say Y here, the emulation is still ··· 183 183 /proc/sys/dev/mac_hid/mouse_button3_keycode 184 184 185 185 If you have an Apple machine with a 1-button mouse, say Y here. 186 + 187 + To compile this driver as a module, choose M here: the 188 + module will be called mac_hid. 186 189 187 190 config THERM_WINDTUNNEL 188 191 tristate "Support for thermal management on Windtunnel G4s"
+197 -71
drivers/macintosh/mac_hid.c
··· 13 13 #include <linux/sysctl.h> 14 14 #include <linux/input.h> 15 15 #include <linux/module.h> 16 - #include <linux/kbd_kern.h> 17 16 17 + MODULE_LICENSE("GPL"); 18 18 19 - static struct input_dev *emumousebtn; 20 - static int emumousebtn_input_register(void); 21 19 static int mouse_emulate_buttons; 22 20 static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ 23 21 static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ 24 - static int mouse_last_keycode; 25 22 26 - #if defined(CONFIG_SYSCTL) 23 + static struct input_dev *mac_hid_emumouse_dev; 24 + 25 + static int mac_hid_create_emumouse(void) 26 + { 27 + static struct lock_class_key mac_hid_emumouse_dev_event_class; 28 + static struct lock_class_key mac_hid_emumouse_dev_mutex_class; 29 + int err; 30 + 31 + mac_hid_emumouse_dev = input_allocate_device(); 32 + if (!mac_hid_emumouse_dev) 33 + return -ENOMEM; 34 + 35 + lockdep_set_class(&mac_hid_emumouse_dev->event_lock, 36 + &mac_hid_emumouse_dev_event_class); 37 + lockdep_set_class(&mac_hid_emumouse_dev->mutex, 38 + &mac_hid_emumouse_dev_mutex_class); 39 + 40 + mac_hid_emumouse_dev->name = "Macintosh mouse button emulation"; 41 + mac_hid_emumouse_dev->id.bustype = BUS_ADB; 42 + mac_hid_emumouse_dev->id.vendor = 0x0001; 43 + mac_hid_emumouse_dev->id.product = 0x0001; 44 + mac_hid_emumouse_dev->id.version = 0x0100; 45 + 46 + mac_hid_emumouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 47 + mac_hid_emumouse_dev->keybit[BIT_WORD(BTN_MOUSE)] = 48 + BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); 49 + mac_hid_emumouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 50 + 51 + err = input_register_device(mac_hid_emumouse_dev); 52 + if (err) { 53 + input_free_device(mac_hid_emumouse_dev); 54 + mac_hid_emumouse_dev = NULL; 55 + return err; 56 + } 57 + 58 + return 0; 59 + } 60 + 61 + static void mac_hid_destroy_emumouse(void) 62 + { 63 + input_unregister_device(mac_hid_emumouse_dev); 64 + mac_hid_emumouse_dev = NULL; 65 + } 66 + 67 + static bool mac_hid_emumouse_filter(struct input_handle *handle, 68 + unsigned int type, unsigned int code, 69 + int value) 70 + { 71 + unsigned int btn; 72 + 73 + if (type != EV_KEY) 74 + return false; 75 + 76 + if (code == mouse_button2_keycode) 77 + btn = BTN_MIDDLE; 78 + else if (code == mouse_button3_keycode) 79 + btn = BTN_RIGHT; 80 + else 81 + return false; 82 + 83 + input_report_key(mac_hid_emumouse_dev, btn, value); 84 + input_sync(mac_hid_emumouse_dev); 85 + 86 + return true; 87 + } 88 + 89 + static int mac_hid_emumouse_connect(struct input_handler *handler, 90 + struct input_dev *dev, 91 + const struct input_device_id *id) 92 + { 93 + struct input_handle *handle; 94 + int error; 95 + 96 + /* Don't bind to ourselves */ 97 + if (dev == mac_hid_emumouse_dev) 98 + return -ENODEV; 99 + 100 + handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); 101 + if (!handle) 102 + return -ENOMEM; 103 + 104 + handle->dev = dev; 105 + handle->handler = handler; 106 + handle->name = "mac-button-emul"; 107 + 108 + error = input_register_handle(handle); 109 + if (error) { 110 + printk(KERN_ERR 111 + "mac_hid: Failed to register button emulation handle, " 112 + "error %d\n", error); 113 + goto err_free; 114 + } 115 + 116 + error = input_open_device(handle); 117 + if (error) { 118 + printk(KERN_ERR 119 + "mac_hid: Failed to open input device, error %d\n", 120 + error); 121 + goto err_unregister; 122 + } 123 + 124 + return 0; 125 + 126 + err_unregister: 127 + input_unregister_handle(handle); 128 + err_free: 129 + kfree(handle); 130 + return error; 131 + } 132 + 133 + static void mac_hid_emumouse_disconnect(struct input_handle *handle) 134 + { 135 + input_close_device(handle); 136 + input_unregister_handle(handle); 137 + kfree(handle); 138 + } 139 + 140 + static const struct input_device_id mac_hid_emumouse_ids[] = { 141 + { 142 + .flags = INPUT_DEVICE_ID_MATCH_EVBIT, 143 + .evbit = { BIT_MASK(EV_KEY) }, 144 + }, 145 + { }, 146 + }; 147 + 148 + MODULE_DEVICE_TABLE(input, mac_hid_emumouse_ids); 149 + 150 + static struct input_handler mac_hid_emumouse_handler = { 151 + .filter = mac_hid_emumouse_filter, 152 + .connect = mac_hid_emumouse_connect, 153 + .disconnect = mac_hid_emumouse_disconnect, 154 + .name = "mac-button-emul", 155 + .id_table = mac_hid_emumouse_ids, 156 + }; 157 + 158 + static int mac_hid_start_emulation(void) 159 + { 160 + int err; 161 + 162 + err = mac_hid_create_emumouse(); 163 + if (err) 164 + return err; 165 + 166 + err = input_register_handler(&mac_hid_emumouse_handler); 167 + if (err) { 168 + mac_hid_destroy_emumouse(); 169 + return err; 170 + } 171 + 172 + return 0; 173 + } 174 + 175 + static void mac_hid_stop_emulation(void) 176 + { 177 + input_unregister_handler(&mac_hid_emumouse_handler); 178 + mac_hid_destroy_emumouse(); 179 + } 180 + 181 + static int mac_hid_toggle_emumouse(ctl_table *table, int write, 182 + void __user *buffer, size_t *lenp, 183 + loff_t *ppos) 184 + { 185 + int *valp = table->data; 186 + int old_val = *valp; 187 + int rc; 188 + 189 + rc = proc_dointvec(table, write, buffer, lenp, ppos); 190 + 191 + if (rc == 0 && write && *valp != old_val) { 192 + if (*valp == 1) 193 + rc = mac_hid_start_emulation(); 194 + else if (*valp == 0) 195 + mac_hid_stop_emulation(); 196 + else 197 + rc = -EINVAL; 198 + } 199 + 200 + /* Restore the old value in case of error */ 201 + if (rc) 202 + *valp = old_val; 203 + 204 + return rc; 205 + } 206 + 27 207 /* file(s) in /proc/sys/dev/mac_hid */ 28 208 static ctl_table mac_hid_files[] = { 29 209 { ··· 211 31 .data = &mouse_emulate_buttons, 212 32 .maxlen = sizeof(int), 213 33 .mode = 0644, 214 - .proc_handler = proc_dointvec, 34 + .proc_handler = mac_hid_toggle_emumouse, 215 35 }, 216 36 { 217 37 .procname = "mouse_button2_keycode", ··· 254 74 255 75 static struct ctl_table_header *mac_hid_sysctl_header; 256 76 257 - #endif /* endif CONFIG_SYSCTL */ 258 - 259 - int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down) 260 - { 261 - switch (caller) { 262 - case 1: 263 - /* Called from keyboard.c */ 264 - if (mouse_emulate_buttons 265 - && (keycode == mouse_button2_keycode 266 - || keycode == mouse_button3_keycode)) { 267 - if (mouse_emulate_buttons == 1) { 268 - input_report_key(emumousebtn, 269 - keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT, 270 - down); 271 - input_sync(emumousebtn); 272 - return 1; 273 - } 274 - mouse_last_keycode = down ? keycode : 0; 275 - } 276 - break; 277 - } 278 - return 0; 279 - } 280 - 281 - static struct lock_class_key emumousebtn_event_class; 282 - static struct lock_class_key emumousebtn_mutex_class; 283 - 284 - static int emumousebtn_input_register(void) 285 - { 286 - int ret; 287 - 288 - emumousebtn = input_allocate_device(); 289 - if (!emumousebtn) 290 - return -ENOMEM; 291 - 292 - lockdep_set_class(&emumousebtn->event_lock, &emumousebtn_event_class); 293 - lockdep_set_class(&emumousebtn->mutex, &emumousebtn_mutex_class); 294 - 295 - emumousebtn->name = "Macintosh mouse button emulation"; 296 - emumousebtn->id.bustype = BUS_ADB; 297 - emumousebtn->id.vendor = 0x0001; 298 - emumousebtn->id.product = 0x0001; 299 - emumousebtn->id.version = 0x0100; 300 - 301 - emumousebtn->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 302 - emumousebtn->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 303 - BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); 304 - emumousebtn->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 305 - 306 - ret = input_register_device(emumousebtn); 307 - if (ret) 308 - input_free_device(emumousebtn); 309 - 310 - return ret; 311 - } 312 - 313 77 static int __init mac_hid_init(void) 314 78 { 315 - int err; 316 - 317 - err = emumousebtn_input_register(); 318 - if (err) 319 - return err; 320 - 321 - #if defined(CONFIG_SYSCTL) 322 79 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir); 323 - #endif /* CONFIG_SYSCTL */ 80 + if (!mac_hid_sysctl_header) 81 + return -ENOMEM; 324 82 325 83 return 0; 326 84 } 85 + module_init(mac_hid_init); 327 86 328 - device_initcall(mac_hid_init); 87 + static void __exit mac_hid_exit(void) 88 + { 89 + unregister_sysctl_table(mac_hid_sysctl_header); 90 + 91 + if (mouse_emulate_buttons) 92 + mac_hid_stop_emulation(); 93 + } 94 + module_exit(mac_hid_exit);
-1
include/linux/gameport.h
··· 46 46 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */ 47 47 48 48 struct device dev; 49 - unsigned int registered; /* port has been fully registered with driver core */ 50 49 51 50 struct list_head node; 52 51 };
+1
include/linux/gpio_keys.h
··· 10 10 int type; /* input event type (EV_KEY, EV_SW) */ 11 11 int wakeup; /* configure the button as a wake-up source */ 12 12 int debounce_interval; /* debounce ticks interval in msecs */ 13 + bool can_disable; 13 14 }; 14 15 15 16 struct gpio_keys_platform_data {
+13 -4
include/linux/input.h
··· 378 378 #define KEY_WIMAX 246 379 379 #define KEY_RFKILL 247 /* Key that controls all radios */ 380 380 381 - /* Range 248 - 255 is reserved for special needs of AT keyboard driver */ 381 + /* Code 255 is reserved for special needs of AT keyboard driver */ 382 382 383 383 #define BTN_MISC 0x100 384 384 #define BTN_0 0x100 ··· 597 597 #define KEY_NUMERIC_POUND 0x20b 598 598 599 599 #define KEY_CAMERA_FOCUS 0x210 600 + #define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ 600 601 601 602 #define BTN_TRIGGER_HAPPY 0x2c0 602 603 #define BTN_TRIGGER_HAPPY1 0x2c0 ··· 1243 1242 * @event: event handler. This method is being called by input core with 1244 1243 * interrupts disabled and dev->event_lock spinlock held and so 1245 1244 * it may not sleep 1245 + * @filter: similar to @event; separates normal event handlers from 1246 + * "filters". 1247 + * @match: called after comparing device's id with handler's id_table 1248 + * to perform fine-grained matching between device and handler 1246 1249 * @connect: called when attaching a handler to an input device 1247 1250 * @disconnect: disconnects a handler from input device 1248 1251 * @start: starts handler for given handle. This function is called by ··· 1258 1253 * @name: name of the handler, to be shown in /proc/bus/input/handlers 1259 1254 * @id_table: pointer to a table of input_device_ids this driver can 1260 1255 * handle 1261 - * @blacklist: pointer to a table of input_device_ids this driver should 1262 - * ignore even if they match @id_table 1263 1256 * @h_list: list of input handles associated with the handler 1264 1257 * @node: for placing the driver onto input_handler_list 1265 1258 * ··· 1265 1262 * are likely several handlers attached to any given input device at the 1266 1263 * same time. All of them will get their copy of input event generated by 1267 1264 * the device. 1265 + * 1266 + * The very same structure is used to implement input filters. Input core 1267 + * allows filters to run first and will not pass event to regular handlers 1268 + * if any of the filters indicate that the event should be filtered (by 1269 + * returning %true from their filter() method). 1268 1270 * 1269 1271 * Note that input core serializes calls to connect() and disconnect() 1270 1272 * methods. ··· 1279 1271 void *private; 1280 1272 1281 1273 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 1274 + bool (*filter)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 1275 + bool (*match)(struct input_handler *handler, struct input_dev *dev); 1282 1276 int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id); 1283 1277 void (*disconnect)(struct input_handle *handle); 1284 1278 void (*start)(struct input_handle *handle); ··· 1290 1280 const char *name; 1291 1281 1292 1282 const struct input_device_id *id_table; 1293 - const struct input_device_id *blacklist; 1294 1283 1295 1284 struct list_head h_list; 1296 1285 struct list_head node;
+4 -3
include/linux/input/sh_keysc.h
··· 1 1 #ifndef __SH_KEYSC_H__ 2 2 #define __SH_KEYSC_H__ 3 3 4 - #define SH_KEYSC_MAXKEYS 30 4 + #define SH_KEYSC_MAXKEYS 49 5 5 6 6 struct sh_keysc_info { 7 - enum { SH_KEYSC_MODE_1, SH_KEYSC_MODE_2, SH_KEYSC_MODE_3 } mode; 7 + enum { SH_KEYSC_MODE_1, SH_KEYSC_MODE_2, SH_KEYSC_MODE_3, 8 + SH_KEYSC_MODE_4, SH_KEYSC_MODE_5, SH_KEYSC_MODE_6 } mode; 8 9 int scan_timing; /* 0 -> 7, see KYCR1, SCN[2:0] */ 9 10 int delay; 10 11 int kycr2_delay; 11 - int keycodes[SH_KEYSC_MAXKEYS]; 12 + int keycodes[SH_KEYSC_MAXKEYS]; /* KEYIN * KEYOUT */ 12 13 }; 13 14 14 15 #endif /* __SH_KEYSC_H__ */
-3
include/linux/kbd_kern.h
··· 161 161 schedule_delayed_work(&t->buf.work, 0); 162 162 } 163 163 164 - /* mac_hid.c */ 165 - extern int mac_hid_mouse_emulate_buttons(int, unsigned int, int); 166 - 167 164 #endif
-1
include/linux/serio.h
··· 30 30 char phys[32]; 31 31 32 32 bool manual_bind; 33 - bool registered; /* port has been fully registered with driver core */ 34 33 35 34 struct serio_device_id id; 36 35