Merge branch 'next' into for-linus

+2309 -352
+1
Documentation/kernel-parameters.txt
··· 796 Defaults to the default architecture's huge page size 797 if not specified. 798 799 i8042.direct [HW] Put keyboard port into non-translated mode 800 i8042.dumbkbd [HW] Pretend that controller can only read data from 801 keyboard and cannot control its state
··· 796 Defaults to the default architecture's huge page size 797 if not specified. 798 799 + i8042.debug [HW] Toggle i8042 debug mode 800 i8042.direct [HW] Put keyboard port into non-translated mode 801 i8042.dumbkbd [HW] Pretend that controller can only read data from 802 keyboard and cannot control its state
+1 -1
MAINTAINERS
··· 4548 P: Mark Brown 4549 M: broonie@opensource.wolfsonmicro.com 4550 P: Liam Girdwood 4551 - M: liam.girdwood@wolfsonmicro.com 4552 L: linux-input@vger.kernel.org 4553 T: git git://opensource.wolfsonmicro.com/linux-2.6-touch 4554 W: http://opensource.wolfsonmicro.com/node/7
··· 4548 P: Mark Brown 4549 M: broonie@opensource.wolfsonmicro.com 4550 P: Liam Girdwood 4551 + M: lrg@slimlogic.co.uk 4552 L: linux-input@vger.kernel.org 4553 T: git git://opensource.wolfsonmicro.com/linux-2.6-touch 4554 W: http://opensource.wolfsonmicro.com/node/7
+1 -1
drivers/char/keyboard.c
··· 1249 return; 1250 } 1251 1252 - if (keycode > NR_KEYS) 1253 if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8) 1254 keysym = K(KT_BRL, keycode - KEY_BRL_DOT1 + 1); 1255 else
··· 1249 return; 1250 } 1251 1252 + if (keycode >= NR_KEYS) 1253 if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8) 1254 keysym = K(KT_BRL, keycode - KEY_BRL_DOT1 + 1); 1255 else
+68 -22
drivers/input/gameport/gameport.c
··· 231 enum gameport_event_type { 232 GAMEPORT_REGISTER_PORT, 233 GAMEPORT_REGISTER_DRIVER, 234 }; 235 236 struct gameport_event { ··· 246 static DECLARE_WAIT_QUEUE_HEAD(gameport_wait); 247 static struct task_struct *gameport_task; 248 249 - static void gameport_queue_event(void *object, struct module *owner, 250 - enum gameport_event_type event_type) 251 { 252 unsigned long flags; 253 struct gameport_event *event; 254 255 spin_lock_irqsave(&gameport_event_lock, flags); 256 ··· 270 } 271 } 272 273 - if ((event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC))) { 274 - if (!try_module_get(owner)) { 275 - printk(KERN_WARNING "gameport: Can't get module reference, dropping event %d\n", event_type); 276 - kfree(event); 277 - goto out; 278 - } 279 - 280 - event->type = event_type; 281 - event->object = object; 282 - event->owner = owner; 283 - 284 - list_add_tail(&event->node, &gameport_event_list); 285 - wake_up(&gameport_wait); 286 - } else { 287 - printk(KERN_ERR "gameport: Not enough memory to queue event %d\n", event_type); 288 } 289 out: 290 spin_unlock_irqrestore(&gameport_event_lock, flags); 291 } 292 293 static void gameport_free_event(struct gameport_event *event) ··· 390 } 391 392 /* 393 - * Remove all events that have been submitted for a given gameport port. 394 */ 395 - static void gameport_remove_pending_events(struct gameport *gameport) 396 { 397 struct list_head *node, *next; 398 struct gameport_event *event; ··· 403 404 list_for_each_safe(node, next, &gameport_event_list) { 405 event = list_entry(node, struct gameport_event, node); 406 - if (event->object == gameport) { 407 list_del_init(node); 408 gameport_free_event(event); 409 } ··· 718 drv->driver.name, error); 719 } 720 721 - void __gameport_register_driver(struct gameport_driver *drv, struct module *owner) 722 { 723 drv->driver.bus = &gameport_bus; 724 - gameport_queue_event(drv, owner, GAMEPORT_REGISTER_DRIVER); 725 } 726 727 void gameport_unregister_driver(struct gameport_driver *drv) ··· 759 struct gameport *gameport; 760 761 mutex_lock(&gameport_mutex); 762 drv->ignore = 1; /* so gameport_find_driver ignores it */ 763 764 start_over: 765 list_for_each_entry(gameport, &gameport_list, node) { ··· 774 } 775 776 driver_unregister(&drv->driver); 777 mutex_unlock(&gameport_mutex); 778 } 779
··· 231 enum gameport_event_type { 232 GAMEPORT_REGISTER_PORT, 233 GAMEPORT_REGISTER_DRIVER, 234 + GAMEPORT_ATTACH_DRIVER, 235 }; 236 237 struct gameport_event { ··· 245 static DECLARE_WAIT_QUEUE_HEAD(gameport_wait); 246 static struct task_struct *gameport_task; 247 248 + static int gameport_queue_event(void *object, struct module *owner, 249 + enum gameport_event_type event_type) 250 { 251 unsigned long flags; 252 struct gameport_event *event; 253 + int retval = 0; 254 255 spin_lock_irqsave(&gameport_event_lock, flags); 256 ··· 268 } 269 } 270 271 + event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC); 272 + if (!event) { 273 + printk(KERN_ERR 274 + "gameport: Not enough memory to queue event %d\n", 275 + event_type); 276 + retval = -ENOMEM; 277 + goto out; 278 } 279 + 280 + if (!try_module_get(owner)) { 281 + printk(KERN_WARNING 282 + "gameport: Can't get module reference, dropping event %d\n", 283 + event_type); 284 + kfree(event); 285 + retval = -EINVAL; 286 + goto out; 287 + } 288 + 289 + event->type = event_type; 290 + event->object = object; 291 + event->owner = owner; 292 + 293 + list_add_tail(&event->node, &gameport_event_list); 294 + wake_up(&gameport_wait); 295 + 296 out: 297 spin_unlock_irqrestore(&gameport_event_lock, flags); 298 + return retval; 299 } 300 301 static void gameport_free_event(struct gameport_event *event) ··· 378 } 379 380 /* 381 + * Remove all events that have been submitted for a given object, 382 + * be it a gameport port or a driver. 383 */ 384 + static void gameport_remove_pending_events(void *object) 385 { 386 struct list_head *node, *next; 387 struct gameport_event *event; ··· 390 391 list_for_each_safe(node, next, &gameport_event_list) { 392 event = list_entry(node, struct gameport_event, node); 393 + if (event->object == object) { 394 list_del_init(node); 395 gameport_free_event(event); 396 } ··· 705 drv->driver.name, error); 706 } 707 708 + int __gameport_register_driver(struct gameport_driver *drv, struct module *owner, 709 + const char *mod_name) 710 { 711 + int error; 712 + 713 drv->driver.bus = &gameport_bus; 714 + drv->driver.owner = owner; 715 + drv->driver.mod_name = mod_name; 716 + 717 + /* 718 + * Temporarily disable automatic binding because probing 719 + * takes long time and we are better off doing it in kgameportd 720 + */ 721 + drv->ignore = 1; 722 + 723 + error = driver_register(&drv->driver); 724 + if (error) { 725 + printk(KERN_ERR 726 + "gameport: driver_register() failed for %s, error: %d\n", 727 + drv->driver.name, error); 728 + return error; 729 + } 730 + 731 + /* 732 + * Reset ignore flag and let kgameportd bind the driver to free ports 733 + */ 734 + drv->ignore = 0; 735 + error = gameport_queue_event(drv, NULL, GAMEPORT_ATTACH_DRIVER); 736 + if (error) { 737 + driver_unregister(&drv->driver); 738 + return error; 739 + } 740 + 741 + return 0; 742 } 743 744 void gameport_unregister_driver(struct gameport_driver *drv) ··· 716 struct gameport *gameport; 717 718 mutex_lock(&gameport_mutex); 719 + 720 drv->ignore = 1; /* so gameport_find_driver ignores it */ 721 + gameport_remove_pending_events(drv); 722 723 start_over: 724 list_for_each_entry(gameport, &gameport_list, node) { ··· 729 } 730 731 driver_unregister(&drv->driver); 732 + 733 mutex_unlock(&gameport_mutex); 734 } 735
+1 -2
drivers/input/joystick/a3d.c
··· 414 415 static int __init a3d_init(void) 416 { 417 - gameport_register_driver(&a3d_drv); 418 - return 0; 419 } 420 421 static void __exit a3d_exit(void)
··· 414 415 static int __init a3d_init(void) 416 { 417 + return gameport_register_driver(&a3d_drv); 418 } 419 420 static void __exit a3d_exit(void)
+1 -2
drivers/input/joystick/adi.c
··· 572 573 static int __init adi_init(void) 574 { 575 - gameport_register_driver(&adi_drv); 576 - return 0; 577 } 578 579 static void __exit adi_exit(void)
··· 572 573 static int __init adi_init(void) 574 { 575 + return gameport_register_driver(&adi_drv); 576 } 577 578 static void __exit adi_exit(void)
+1 -3
drivers/input/joystick/analog.c
··· 761 static int __init analog_init(void) 762 { 763 analog_parse_options(); 764 - gameport_register_driver(&analog_drv); 765 - 766 - return 0; 767 } 768 769 static void __exit analog_exit(void)
··· 761 static int __init analog_init(void) 762 { 763 analog_parse_options(); 764 + return gameport_register_driver(&analog_drv); 765 } 766 767 static void __exit analog_exit(void)
+1 -2
drivers/input/joystick/cobra.c
··· 263 264 static int __init cobra_init(void) 265 { 266 - gameport_register_driver(&cobra_drv); 267 - return 0; 268 } 269 270 static void __exit cobra_exit(void)
··· 263 264 static int __init cobra_init(void) 265 { 266 + return gameport_register_driver(&cobra_drv); 267 } 268 269 static void __exit cobra_exit(void)
+1 -2
drivers/input/joystick/gf2k.c
··· 375 376 static int __init gf2k_init(void) 377 { 378 - gameport_register_driver(&gf2k_drv); 379 - return 0; 380 } 381 382 static void __exit gf2k_exit(void)
··· 375 376 static int __init gf2k_init(void) 377 { 378 + return gameport_register_driver(&gf2k_drv); 379 } 380 381 static void __exit gf2k_exit(void)
+1 -2
drivers/input/joystick/grip.c
··· 426 427 static int __init grip_init(void) 428 { 429 - gameport_register_driver(&grip_drv); 430 - return 0; 431 } 432 433 static void __exit grip_exit(void)
··· 426 427 static int __init grip_init(void) 428 { 429 + return gameport_register_driver(&grip_drv); 430 } 431 432 static void __exit grip_exit(void)
+1 -2
drivers/input/joystick/grip_mp.c
··· 689 690 static int __init grip_init(void) 691 { 692 - gameport_register_driver(&grip_drv); 693 - return 0; 694 } 695 696 static void __exit grip_exit(void)
··· 689 690 static int __init grip_init(void) 691 { 692 + return gameport_register_driver(&grip_drv); 693 } 694 695 static void __exit grip_exit(void)
+1 -2
drivers/input/joystick/guillemot.c
··· 283 284 static int __init guillemot_init(void) 285 { 286 - gameport_register_driver(&guillemot_drv); 287 - return 0; 288 } 289 290 static void __exit guillemot_exit(void)
··· 283 284 static int __init guillemot_init(void) 285 { 286 + return gameport_register_driver(&guillemot_drv); 287 } 288 289 static void __exit guillemot_exit(void)
+1 -2
drivers/input/joystick/interact.c
··· 317 318 static int __init interact_init(void) 319 { 320 - gameport_register_driver(&interact_drv); 321 - return 0; 322 } 323 324 static void __exit interact_exit(void)
··· 317 318 static int __init interact_init(void) 319 { 320 + return gameport_register_driver(&interact_drv); 321 } 322 323 static void __exit interact_exit(void)
+1 -2
drivers/input/joystick/joydump.c
··· 161 162 static int __init joydump_init(void) 163 { 164 - gameport_register_driver(&joydump_drv); 165 - return 0; 166 } 167 168 static void __exit joydump_exit(void)
··· 161 162 static int __init joydump_init(void) 163 { 164 + return gameport_register_driver(&joydump_drv); 165 } 166 167 static void __exit joydump_exit(void)
+1 -2
drivers/input/joystick/sidewinder.c
··· 818 819 static int __init sw_init(void) 820 { 821 - gameport_register_driver(&sw_drv); 822 - return 0; 823 } 824 825 static void __exit sw_exit(void)
··· 818 819 static int __init sw_init(void) 820 { 821 + return gameport_register_driver(&sw_drv); 822 } 823 824 static void __exit sw_exit(void)
+1 -2
drivers/input/joystick/tmdc.c
··· 438 439 static int __init tmdc_init(void) 440 { 441 - gameport_register_driver(&tmdc_drv); 442 - return 0; 443 } 444 445 static void __exit tmdc_exit(void)
··· 438 439 static int __init tmdc_init(void) 440 { 441 + return gameport_register_driver(&tmdc_drv); 442 } 443 444 static void __exit tmdc_exit(void)
+10 -20
drivers/input/keyboard/atkbd.c
··· 834 } 835 836 /* 837 - * Most special keys (Fn+F?) on Dell Latitudes do not generate release 838 * events so we have to do it ourselves. 839 */ 840 - static void atkbd_latitude_keymap_fixup(struct atkbd *atkbd) 841 { 842 const unsigned int forced_release_keys[] = { 843 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93, ··· 1207 { 1208 struct input_dev *old_dev, *new_dev; 1209 unsigned long value; 1210 - char *rest; 1211 int err; 1212 unsigned char old_extra, old_set; 1213 1214 if (!atkbd->write) 1215 return -EIO; 1216 1217 - value = simple_strtoul(buf, &rest, 10); 1218 - if (*rest || value > 1) 1219 return -EINVAL; 1220 1221 if (atkbd->extra != value) { ··· 1262 { 1263 struct input_dev *old_dev, *new_dev; 1264 unsigned long value; 1265 - char *rest; 1266 int err; 1267 unsigned char old_scroll; 1268 1269 - value = simple_strtoul(buf, &rest, 10); 1270 - if (*rest || value > 1) 1271 return -EINVAL; 1272 1273 if (atkbd->scroll != value) { ··· 1306 { 1307 struct input_dev *old_dev, *new_dev; 1308 unsigned long value; 1309 - char *rest; 1310 int err; 1311 unsigned char old_set, old_extra; 1312 1313 if (!atkbd->write) 1314 return -EIO; 1315 1316 - value = simple_strtoul(buf, &rest, 10); 1317 - if (*rest || (value != 2 && value != 3)) 1318 return -EINVAL; 1319 1320 if (atkbd->set != value) { ··· 1355 { 1356 struct input_dev *old_dev, *new_dev; 1357 unsigned long value; 1358 - char *rest; 1359 int err; 1360 unsigned char old_softrepeat, old_softraw; 1361 1362 if (!atkbd->write) 1363 return -EIO; 1364 1365 - value = simple_strtoul(buf, &rest, 10); 1366 - if (*rest || value > 1) 1367 return -EINVAL; 1368 1369 if (atkbd->softrepeat != value) { ··· 1405 { 1406 struct input_dev *old_dev, *new_dev; 1407 unsigned long value; 1408 - char *rest; 1409 int err; 1410 unsigned char old_softraw; 1411 1412 - value = simple_strtoul(buf, &rest, 10); 1413 - if (*rest || value > 1) 1414 return -EINVAL; 1415 1416 if (atkbd->softraw != value) { ··· 1451 1452 static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = { 1453 { 1454 - .ident = "Dell Latitude series", 1455 .matches = { 1456 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1457 - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"), 1458 }, 1459 .callback = atkbd_setup_fixup, 1460 - .driver_data = atkbd_latitude_keymap_fixup, 1461 }, 1462 { 1463 .ident = "HP 2133",
··· 834 } 835 836 /* 837 + * Most special keys (Fn+F?) on Dell laptops do not generate release 838 * events so we have to do it ourselves. 839 */ 840 + static void atkbd_dell_laptop_keymap_fixup(struct atkbd *atkbd) 841 { 842 const unsigned int forced_release_keys[] = { 843 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93, ··· 1207 { 1208 struct input_dev *old_dev, *new_dev; 1209 unsigned long value; 1210 int err; 1211 unsigned char old_extra, old_set; 1212 1213 if (!atkbd->write) 1214 return -EIO; 1215 1216 + if (strict_strtoul(buf, 10, &value) || value > 1) 1217 return -EINVAL; 1218 1219 if (atkbd->extra != value) { ··· 1264 { 1265 struct input_dev *old_dev, *new_dev; 1266 unsigned long value; 1267 int err; 1268 unsigned char old_scroll; 1269 1270 + if (strict_strtoul(buf, 10, &value) || value > 1) 1271 return -EINVAL; 1272 1273 if (atkbd->scroll != value) { ··· 1310 { 1311 struct input_dev *old_dev, *new_dev; 1312 unsigned long value; 1313 int err; 1314 unsigned char old_set, old_extra; 1315 1316 if (!atkbd->write) 1317 return -EIO; 1318 1319 + if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3)) 1320 return -EINVAL; 1321 1322 if (atkbd->set != value) { ··· 1361 { 1362 struct input_dev *old_dev, *new_dev; 1363 unsigned long value; 1364 int err; 1365 unsigned char old_softrepeat, old_softraw; 1366 1367 if (!atkbd->write) 1368 return -EIO; 1369 1370 + if (strict_strtoul(buf, 10, &value) || value > 1) 1371 return -EINVAL; 1372 1373 if (atkbd->softrepeat != value) { ··· 1413 { 1414 struct input_dev *old_dev, *new_dev; 1415 unsigned long value; 1416 int err; 1417 unsigned char old_softraw; 1418 1419 + if (strict_strtoul(buf, 10, &value) || value > 1) 1420 return -EINVAL; 1421 1422 if (atkbd->softraw != value) { ··· 1461 1462 static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = { 1463 { 1464 + .ident = "Dell Laptop", 1465 .matches = { 1466 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1467 + DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */ 1468 }, 1469 .callback = atkbd_setup_fixup, 1470 + .driver_data = atkbd_dell_laptop_keymap_fixup, 1471 }, 1472 { 1473 .ident = "HP 2133",
+12 -1
drivers/input/keyboard/bf54x-keys.c
··· 8 * 9 * 10 * Modified: 11 - * Copyright 2007 Analog Devices Inc. 12 * 13 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 14 * ··· 81 unsigned short *keycode; 82 struct timer_list timer; 83 unsigned int keyup_test_jiffies; 84 }; 85 86 static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad, ··· 363 { 364 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 365 366 if (device_may_wakeup(&pdev->dev)) 367 enable_irq_wake(bf54x_kpad->irq); 368 ··· 376 static int bfin_kpad_resume(struct platform_device *pdev) 377 { 378 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 379 380 if (device_may_wakeup(&pdev->dev)) 381 disable_irq_wake(bf54x_kpad->irq);
··· 8 * 9 * 10 * Modified: 11 + * Copyright 2007-2008 Analog Devices Inc. 12 * 13 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 14 * ··· 81 unsigned short *keycode; 82 struct timer_list timer; 83 unsigned int keyup_test_jiffies; 84 + unsigned short kpad_msel; 85 + unsigned short kpad_prescale; 86 + unsigned short kpad_ctl; 87 }; 88 89 static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad, ··· 360 { 361 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 362 363 + bf54x_kpad->kpad_msel = bfin_read_KPAD_MSEL(); 364 + bf54x_kpad->kpad_prescale = bfin_read_KPAD_PRESCALE(); 365 + bf54x_kpad->kpad_ctl = bfin_read_KPAD_CTL(); 366 + 367 if (device_may_wakeup(&pdev->dev)) 368 enable_irq_wake(bf54x_kpad->irq); 369 ··· 369 static int bfin_kpad_resume(struct platform_device *pdev) 370 { 371 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 372 + 373 + bfin_write_KPAD_MSEL(bf54x_kpad->kpad_msel); 374 + bfin_write_KPAD_PRESCALE(bf54x_kpad->kpad_prescale); 375 + bfin_write_KPAD_CTL(bf54x_kpad->kpad_ctl); 376 377 if (device_may_wakeup(&pdev->dev)) 378 disable_irq_wake(bf54x_kpad->irq);
+16 -26
drivers/input/keyboard/gpio_keys.c
··· 36 struct gpio_button_data data[0]; 37 }; 38 39 - static void gpio_keys_report_event(struct gpio_keys_button *button, 40 - struct input_dev *input) 41 { 42 unsigned int type = button->type ?: EV_KEY; 43 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; 44 ··· 51 { 52 struct gpio_button_data *data = (struct gpio_button_data *)_data; 53 54 - gpio_keys_report_event(data->button, data->input); 55 } 56 57 static irqreturn_t gpio_keys_isr(int irq, void *dev_id) 58 { 59 - struct platform_device *pdev = dev_id; 60 - struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; 61 - struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); 62 - int i; 63 64 - for (i = 0; i < pdata->nbuttons; i++) { 65 - struct gpio_keys_button *button = &pdata->buttons[i]; 66 67 - if (irq == gpio_to_irq(button->gpio)) { 68 - struct gpio_button_data *bdata = &ddata->data[i]; 69 70 - if (button->debounce_interval) 71 - mod_timer(&bdata->timer, 72 - jiffies + 73 - msecs_to_jiffies(button->debounce_interval)); 74 - else 75 - gpio_keys_report_event(button, bdata->input); 76 - 77 - return IRQ_HANDLED; 78 - } 79 - } 80 - 81 - return IRQ_NONE; 82 } 83 84 static int __devinit gpio_keys_probe(struct platform_device *pdev) ··· 141 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | 142 IRQF_TRIGGER_FALLING, 143 button->desc ? button->desc : "gpio_keys", 144 - pdev); 145 if (error) { 146 pr_err("gpio-keys: Unable to claim irq %d; error %d\n", 147 irq, error); ··· 168 169 fail2: 170 while (--i >= 0) { 171 - free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); 172 if (pdata->buttons[i].debounce_interval) 173 del_timer_sync(&ddata->data[i].timer); 174 gpio_free(pdata->buttons[i].gpio); ··· 193 194 for (i = 0; i < pdata->nbuttons; i++) { 195 int irq = gpio_to_irq(pdata->buttons[i].gpio); 196 - free_irq(irq, pdev); 197 if (pdata->buttons[i].debounce_interval) 198 del_timer_sync(&ddata->data[i].timer); 199 gpio_free(pdata->buttons[i].gpio);
··· 36 struct gpio_button_data data[0]; 37 }; 38 39 + static void gpio_keys_report_event(struct gpio_button_data *bdata) 40 { 41 + struct gpio_keys_button *button = bdata->button; 42 + struct input_dev *input = bdata->input; 43 unsigned int type = button->type ?: EV_KEY; 44 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; 45 ··· 50 { 51 struct gpio_button_data *data = (struct gpio_button_data *)_data; 52 53 + gpio_keys_report_event(data); 54 } 55 56 static irqreturn_t gpio_keys_isr(int irq, void *dev_id) 57 { 58 + struct gpio_button_data *bdata = dev_id; 59 + struct gpio_keys_button *button = bdata->button; 60 61 + BUG_ON(irq != gpio_to_irq(button->gpio)); 62 63 + if (button->debounce_interval) 64 + mod_timer(&bdata->timer, 65 + jiffies + msecs_to_jiffies(button->debounce_interval)); 66 + else 67 + gpio_keys_report_event(bdata); 68 69 + return IRQ_HANDLED; 70 } 71 72 static int __devinit gpio_keys_probe(struct platform_device *pdev) ··· 151 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | 152 IRQF_TRIGGER_FALLING, 153 button->desc ? button->desc : "gpio_keys", 154 + bdata); 155 if (error) { 156 pr_err("gpio-keys: Unable to claim irq %d; error %d\n", 157 irq, error); ··· 178 179 fail2: 180 while (--i >= 0) { 181 + free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 182 if (pdata->buttons[i].debounce_interval) 183 del_timer_sync(&ddata->data[i].timer); 184 gpio_free(pdata->buttons[i].gpio); ··· 203 204 for (i = 0; i < pdata->nbuttons; i++) { 205 int irq = gpio_to_irq(pdata->buttons[i].gpio); 206 + free_irq(irq, &ddata->data[i]); 207 if (pdata->buttons[i].debounce_interval) 208 del_timer_sync(&ddata->data[i].timer); 209 gpio_free(pdata->buttons[i].gpio);
+13
drivers/input/misc/Kconfig
··· 180 To compile this driver as a module, choose M here: the module will be 181 called yealink. 182 183 config INPUT_UINPUT 184 tristate "User level driver support" 185 help
··· 180 To compile this driver as a module, choose M here: the module will be 181 called yealink. 182 183 + config INPUT_CM109 184 + tristate "C-Media CM109 USB I/O Controller" 185 + depends on EXPERIMENTAL 186 + depends on USB_ARCH_HAS_HCD 187 + select USB 188 + help 189 + Say Y here if you want to enable keyboard and buzzer functions of the 190 + C-Media CM109 usb phones. The audio part is enabled by the generic 191 + usb sound driver, so you might want to enable that as well. 192 + 193 + To compile this driver as a module, choose M here: the module will be 194 + called cm109. 195 + 196 config INPUT_UINPUT 197 tristate "User level driver support" 198 help
+1
drivers/input/misc/Makefile
··· 16 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o 17 obj-$(CONFIG_INPUT_POWERMATE) += powermate.o 18 obj-$(CONFIG_INPUT_YEALINK) += yealink.o 19 obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 20 obj-$(CONFIG_INPUT_UINPUT) += uinput.o 21 obj-$(CONFIG_INPUT_APANEL) += apanel.o
··· 16 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o 17 obj-$(CONFIG_INPUT_POWERMATE) += powermate.o 18 obj-$(CONFIG_INPUT_YEALINK) += yealink.o 19 + obj-$(CONFIG_INPUT_CM109) += cm109.o 20 obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 21 obj-$(CONFIG_INPUT_UINPUT) += uinput.o 22 obj-$(CONFIG_INPUT_APANEL) += apanel.o
+228 -35
drivers/input/misc/ati_remote2.c
··· 1 /* 2 * ati_remote2 - ATI/Philips USB RF remote driver 3 * 4 - * Copyright (C) 2005 Ville Syrjala <syrjala@sci.fi> 5 - * Copyright (C) 2007 Peter Stokes <linux@dadeos.freeserve.co.uk> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 ··· 12 #include <linux/usb/input.h> 13 14 #define DRIVER_DESC "ATI/Philips USB RF remote driver" 15 - #define DRIVER_VERSION "0.2" 16 17 MODULE_DESCRIPTION(DRIVER_DESC); 18 MODULE_VERSION(DRIVER_VERSION); ··· 27 * A remote's "channel" may be altered by pressing and holding the "PC" button for 28 * approximately 3 seconds, after which the button will slowly flash the count of the 29 * currently configured "channel", using the numeric keypad enter a number between 1 and 30 - * 16 and then the "PC" button again, the button will slowly flash the count of the 31 * newly configured "channel". 32 */ 33 ··· 45 }; 46 MODULE_DEVICE_TABLE(usb, ati_remote2_id_table); 47 48 - static struct { 49 - int hw_code; 50 - int key_code; 51 } ati_remote2_key_table[] = { 52 { 0x00, KEY_0 }, 53 { 0x01, KEY_1 }, ··· 89 { 0x37, KEY_RECORD }, 90 { 0x38, KEY_DVD }, 91 { 0x39, KEY_TV }, 92 { 0x54, KEY_MENU }, 93 { 0x58, KEY_UP }, 94 { 0x59, KEY_DOWN }, ··· 108 { 0xa9, BTN_LEFT }, 109 { 0xaa, BTN_RIGHT }, 110 { 0xbe, KEY_QUESTION }, 111 - { 0xd5, KEY_FRONT }, 112 { 0xd0, KEY_EDIT }, 113 { 0xf9, KEY_INFO }, 114 - { (0x00 << 8) | 0x3f, KEY_PROG1 }, 115 - { (0x01 << 8) | 0x3f, KEY_PROG2 }, 116 - { (0x02 << 8) | 0x3f, KEY_PROG3 }, 117 - { (0x03 << 8) | 0x3f, KEY_PROG4 }, 118 - { (0x04 << 8) | 0x3f, KEY_PC }, 119 - { 0, KEY_RESERVED } 120 }; 121 122 struct ati_remote2 { ··· 128 129 char name[64]; 130 char phys[64]; 131 }; 132 133 static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id); 134 static void ati_remote2_disconnect(struct usb_interface *interface); 135 136 static struct usb_driver ati_remote2_driver = { 137 .name = "ati_remote2", 138 .probe = ati_remote2_probe, 139 .disconnect = ati_remote2_disconnect, 140 .id_table = ati_remote2_id_table, 141 }; 142 143 - static int ati_remote2_open(struct input_dev *idev) 144 { 145 - struct ati_remote2 *ar2 = input_get_drvdata(idev); 146 int r; 147 148 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); 149 if (r) { 150 dev_err(&ar2->intf[0]->dev, 151 - "%s: usb_submit_urb() = %d\n", __func__, r); 152 return r; 153 } 154 r = usb_submit_urb(ar2->urb[1], GFP_KERNEL); 155 if (r) { 156 usb_kill_urb(ar2->urb[0]); 157 dev_err(&ar2->intf[1]->dev, 158 - "%s: usb_submit_urb() = %d\n", __func__, r); 159 return r; 160 } 161 162 return 0; 163 } 164 165 static void ati_remote2_close(struct input_dev *idev) 166 { 167 struct ati_remote2 *ar2 = input_get_drvdata(idev); 168 169 - usb_kill_urb(ar2->urb[0]); 170 - usb_kill_urb(ar2->urb[1]); 171 } 172 173 static void ati_remote2_input_mouse(struct ati_remote2 *ar2) ··· 243 244 mode = data[0] & 0x0F; 245 246 - if (mode > 4) { 247 dev_err(&ar2->intf[0]->dev, 248 "Unknown mode byte (%02x %02x %02x %02x)\n", 249 data[3], data[2], data[1], data[0]); ··· 262 { 263 int i; 264 265 - for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) 266 if (ati_remote2_key_table[i].hw_code == hw_code) 267 return i; 268 ··· 282 283 mode = data[0] & 0x0F; 284 285 - if (mode > 4) { 286 dev_err(&ar2->intf[1]->dev, 287 "Unknown mode byte (%02x %02x %02x %02x)\n", 288 data[3], data[2], data[1], data[0]); ··· 290 } 291 292 hw_code = data[2]; 293 - /* 294 - * Mode keys (AUX1-AUX4, PC) all generate the same code byte. 295 - * Use the mode byte to figure out which one was pressed. 296 - */ 297 if (hw_code == 0x3f) { 298 /* 299 * For some incomprehensible reason the mouse pad generates ··· 303 304 if (data[1] == 0) 305 ar2->mode = mode; 306 - 307 - hw_code |= mode << 8; 308 } 309 310 if (!((1 << mode) & mode_mask)) ··· 325 case 2: /* repeat */ 326 327 /* No repeat for mouse buttons. */ 328 - if (ati_remote2_key_table[index].key_code == BTN_LEFT || 329 - ati_remote2_key_table[index].key_code == BTN_RIGHT) 330 return; 331 332 if (!time_after_eq(jiffies, ar2->jiffies)) ··· 341 return; 342 } 343 344 - input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]); 345 input_sync(idev); 346 } 347 ··· 352 353 switch (urb->status) { 354 case 0: 355 ati_remote2_input_mouse(ar2); 356 break; 357 case -ENOENT: ··· 363 "%s(): urb status = %d\n", __func__, urb->status); 364 return; 365 default: 366 dev_err(&ar2->intf[0]->dev, 367 "%s(): urb status = %d\n", __func__, urb->status); 368 } ··· 381 382 switch (urb->status) { 383 case 0: 384 ati_remote2_input_key(ar2); 385 break; 386 case -ENOENT: ··· 392 "%s(): urb status = %d\n", __func__, urb->status); 393 return; 394 default: 395 dev_err(&ar2->intf[1]->dev, 396 "%s(): urb status = %d\n", __func__, urb->status); 397 } ··· 403 "%s(): usb_submit_urb() = %d\n", __func__, r); 404 } 405 406 static int ati_remote2_input_init(struct ati_remote2 *ar2) 407 { 408 struct input_dev *idev; 409 - int i, retval; 410 411 idev = input_allocate_device(); 412 if (!idev) ··· 469 idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 470 BIT_MASK(BTN_RIGHT); 471 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 472 - for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) 473 - set_bit(ati_remote2_key_table[i].key_code, idev->keybit); 474 475 idev->rep[REP_DELAY] = 250; 476 idev->rep[REP_PERIOD] = 33; 477 478 idev->open = ati_remote2_open; 479 idev->close = ati_remote2_close; 480 481 idev->name = ar2->name; 482 idev->phys = ar2->phys; ··· 630 631 usb_set_intfdata(interface, ar2); 632 633 return 0; 634 635 fail2: ··· 662 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); 663 664 kfree(ar2); 665 } 666 667 static int __init ati_remote2_init(void)
··· 1 /* 2 * ati_remote2 - ATI/Philips USB RF remote driver 3 * 4 + * Copyright (C) 2005-2008 Ville Syrjala <syrjala@sci.fi> 5 + * Copyright (C) 2007-2008 Peter Stokes <linux@dadeos.co.uk> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 ··· 12 #include <linux/usb/input.h> 13 14 #define DRIVER_DESC "ATI/Philips USB RF remote driver" 15 + #define DRIVER_VERSION "0.3" 16 17 MODULE_DESCRIPTION(DRIVER_DESC); 18 MODULE_VERSION(DRIVER_VERSION); ··· 27 * A remote's "channel" may be altered by pressing and holding the "PC" button for 28 * approximately 3 seconds, after which the button will slowly flash the count of the 29 * currently configured "channel", using the numeric keypad enter a number between 1 and 30 + * 16 and then press the "PC" button again, the button will slowly flash the count of the 31 * newly configured "channel". 32 */ 33 ··· 45 }; 46 MODULE_DEVICE_TABLE(usb, ati_remote2_id_table); 47 48 + static DEFINE_MUTEX(ati_remote2_mutex); 49 + 50 + enum { 51 + ATI_REMOTE2_OPENED = 0x1, 52 + ATI_REMOTE2_SUSPENDED = 0x2, 53 + }; 54 + 55 + enum { 56 + ATI_REMOTE2_AUX1, 57 + ATI_REMOTE2_AUX2, 58 + ATI_REMOTE2_AUX3, 59 + ATI_REMOTE2_AUX4, 60 + ATI_REMOTE2_PC, 61 + ATI_REMOTE2_MODES, 62 + }; 63 + 64 + static const struct { 65 + u8 hw_code; 66 + u16 keycode; 67 } ati_remote2_key_table[] = { 68 { 0x00, KEY_0 }, 69 { 0x01, KEY_1 }, ··· 73 { 0x37, KEY_RECORD }, 74 { 0x38, KEY_DVD }, 75 { 0x39, KEY_TV }, 76 + { 0x3f, KEY_PROG1 }, /* AUX1-AUX4 and PC */ 77 { 0x54, KEY_MENU }, 78 { 0x58, KEY_UP }, 79 { 0x59, KEY_DOWN }, ··· 91 { 0xa9, BTN_LEFT }, 92 { 0xaa, BTN_RIGHT }, 93 { 0xbe, KEY_QUESTION }, 94 { 0xd0, KEY_EDIT }, 95 + { 0xd5, KEY_FRONT }, 96 { 0xf9, KEY_INFO }, 97 }; 98 99 struct ati_remote2 { ··· 117 118 char name[64]; 119 char phys[64]; 120 + 121 + /* Each mode (AUX1-AUX4 and PC) can have an independent keymap. */ 122 + u16 keycode[ATI_REMOTE2_MODES][ARRAY_SIZE(ati_remote2_key_table)]; 123 + 124 + unsigned int flags; 125 }; 126 127 static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id); 128 static void ati_remote2_disconnect(struct usb_interface *interface); 129 + static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message); 130 + static int ati_remote2_resume(struct usb_interface *interface); 131 132 static struct usb_driver ati_remote2_driver = { 133 .name = "ati_remote2", 134 .probe = ati_remote2_probe, 135 .disconnect = ati_remote2_disconnect, 136 .id_table = ati_remote2_id_table, 137 + .suspend = ati_remote2_suspend, 138 + .resume = ati_remote2_resume, 139 + .supports_autosuspend = 1, 140 }; 141 142 + static int ati_remote2_submit_urbs(struct ati_remote2 *ar2) 143 { 144 int r; 145 146 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); 147 if (r) { 148 dev_err(&ar2->intf[0]->dev, 149 + "%s(): usb_submit_urb() = %d\n", __func__, r); 150 return r; 151 } 152 r = usb_submit_urb(ar2->urb[1], GFP_KERNEL); 153 if (r) { 154 usb_kill_urb(ar2->urb[0]); 155 dev_err(&ar2->intf[1]->dev, 156 + "%s(): usb_submit_urb() = %d\n", __func__, r); 157 return r; 158 } 159 160 return 0; 161 } 162 163 + static void ati_remote2_kill_urbs(struct ati_remote2 *ar2) 164 + { 165 + usb_kill_urb(ar2->urb[1]); 166 + usb_kill_urb(ar2->urb[0]); 167 + } 168 + 169 + static int ati_remote2_open(struct input_dev *idev) 170 + { 171 + struct ati_remote2 *ar2 = input_get_drvdata(idev); 172 + int r; 173 + 174 + dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); 175 + 176 + r = usb_autopm_get_interface(ar2->intf[0]); 177 + if (r) { 178 + dev_err(&ar2->intf[0]->dev, 179 + "%s(): usb_autopm_get_interface() = %d\n", __func__, r); 180 + goto fail1; 181 + } 182 + 183 + mutex_lock(&ati_remote2_mutex); 184 + 185 + if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) { 186 + r = ati_remote2_submit_urbs(ar2); 187 + if (r) 188 + goto fail2; 189 + } 190 + 191 + ar2->flags |= ATI_REMOTE2_OPENED; 192 + 193 + mutex_unlock(&ati_remote2_mutex); 194 + 195 + usb_autopm_put_interface(ar2->intf[0]); 196 + 197 + return 0; 198 + 199 + fail2: 200 + mutex_unlock(&ati_remote2_mutex); 201 + usb_autopm_put_interface(ar2->intf[0]); 202 + fail1: 203 + return r; 204 + } 205 + 206 static void ati_remote2_close(struct input_dev *idev) 207 { 208 struct ati_remote2 *ar2 = input_get_drvdata(idev); 209 210 + dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); 211 + 212 + mutex_lock(&ati_remote2_mutex); 213 + 214 + if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) 215 + ati_remote2_kill_urbs(ar2); 216 + 217 + ar2->flags &= ~ATI_REMOTE2_OPENED; 218 + 219 + mutex_unlock(&ati_remote2_mutex); 220 } 221 222 static void ati_remote2_input_mouse(struct ati_remote2 *ar2) ··· 172 173 mode = data[0] & 0x0F; 174 175 + if (mode > ATI_REMOTE2_PC) { 176 dev_err(&ar2->intf[0]->dev, 177 "Unknown mode byte (%02x %02x %02x %02x)\n", 178 data[3], data[2], data[1], data[0]); ··· 191 { 192 int i; 193 194 + for (i = 0; i < ARRAY_SIZE(ati_remote2_key_table); i++) 195 if (ati_remote2_key_table[i].hw_code == hw_code) 196 return i; 197 ··· 211 212 mode = data[0] & 0x0F; 213 214 + if (mode > ATI_REMOTE2_PC) { 215 dev_err(&ar2->intf[1]->dev, 216 "Unknown mode byte (%02x %02x %02x %02x)\n", 217 data[3], data[2], data[1], data[0]); ··· 219 } 220 221 hw_code = data[2]; 222 if (hw_code == 0x3f) { 223 /* 224 * For some incomprehensible reason the mouse pad generates ··· 236 237 if (data[1] == 0) 238 ar2->mode = mode; 239 } 240 241 if (!((1 << mode) & mode_mask)) ··· 260 case 2: /* repeat */ 261 262 /* No repeat for mouse buttons. */ 263 + if (ar2->keycode[mode][index] == BTN_LEFT || 264 + ar2->keycode[mode][index] == BTN_RIGHT) 265 return; 266 267 if (!time_after_eq(jiffies, ar2->jiffies)) ··· 276 return; 277 } 278 279 + input_event(idev, EV_KEY, ar2->keycode[mode][index], data[1]); 280 input_sync(idev); 281 } 282 ··· 287 288 switch (urb->status) { 289 case 0: 290 + usb_mark_last_busy(ar2->udev); 291 ati_remote2_input_mouse(ar2); 292 break; 293 case -ENOENT: ··· 297 "%s(): urb status = %d\n", __func__, urb->status); 298 return; 299 default: 300 + usb_mark_last_busy(ar2->udev); 301 dev_err(&ar2->intf[0]->dev, 302 "%s(): urb status = %d\n", __func__, urb->status); 303 } ··· 314 315 switch (urb->status) { 316 case 0: 317 + usb_mark_last_busy(ar2->udev); 318 ati_remote2_input_key(ar2); 319 break; 320 case -ENOENT: ··· 324 "%s(): urb status = %d\n", __func__, urb->status); 325 return; 326 default: 327 + usb_mark_last_busy(ar2->udev); 328 dev_err(&ar2->intf[1]->dev, 329 "%s(): urb status = %d\n", __func__, urb->status); 330 } ··· 334 "%s(): usb_submit_urb() = %d\n", __func__, r); 335 } 336 337 + static int ati_remote2_getkeycode(struct input_dev *idev, 338 + int scancode, int *keycode) 339 + { 340 + struct ati_remote2 *ar2 = input_get_drvdata(idev); 341 + int index, mode; 342 + 343 + mode = scancode >> 8; 344 + if (mode > ATI_REMOTE2_PC || !((1 << mode) & mode_mask)) 345 + return -EINVAL; 346 + 347 + index = ati_remote2_lookup(scancode & 0xFF); 348 + if (index < 0) 349 + return -EINVAL; 350 + 351 + *keycode = ar2->keycode[mode][index]; 352 + return 0; 353 + } 354 + 355 + static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keycode) 356 + { 357 + struct ati_remote2 *ar2 = input_get_drvdata(idev); 358 + int index, mode, old_keycode; 359 + 360 + mode = scancode >> 8; 361 + if (mode > ATI_REMOTE2_PC || !((1 << mode) & mode_mask)) 362 + return -EINVAL; 363 + 364 + index = ati_remote2_lookup(scancode & 0xFF); 365 + if (index < 0) 366 + return -EINVAL; 367 + 368 + if (keycode < KEY_RESERVED || keycode > KEY_MAX) 369 + return -EINVAL; 370 + 371 + old_keycode = ar2->keycode[mode][index]; 372 + ar2->keycode[mode][index] = keycode; 373 + set_bit(keycode, idev->keybit); 374 + 375 + for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) { 376 + for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) { 377 + if (ar2->keycode[mode][index] == old_keycode) 378 + return 0; 379 + } 380 + } 381 + 382 + clear_bit(old_keycode, idev->keybit); 383 + 384 + return 0; 385 + } 386 + 387 static int ati_remote2_input_init(struct ati_remote2 *ar2) 388 { 389 struct input_dev *idev; 390 + int index, mode, retval; 391 392 idev = input_allocate_device(); 393 if (!idev) ··· 350 idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 351 BIT_MASK(BTN_RIGHT); 352 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 353 + 354 + for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) { 355 + for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) { 356 + ar2->keycode[mode][index] = ati_remote2_key_table[index].keycode; 357 + set_bit(ar2->keycode[mode][index], idev->keybit); 358 + } 359 + } 360 + 361 + /* AUX1-AUX4 and PC generate the same scancode. */ 362 + index = ati_remote2_lookup(0x3f); 363 + ar2->keycode[ATI_REMOTE2_AUX1][index] = KEY_PROG1; 364 + ar2->keycode[ATI_REMOTE2_AUX2][index] = KEY_PROG2; 365 + ar2->keycode[ATI_REMOTE2_AUX3][index] = KEY_PROG3; 366 + ar2->keycode[ATI_REMOTE2_AUX4][index] = KEY_PROG4; 367 + ar2->keycode[ATI_REMOTE2_PC][index] = KEY_PC; 368 + set_bit(KEY_PROG1, idev->keybit); 369 + set_bit(KEY_PROG2, idev->keybit); 370 + set_bit(KEY_PROG3, idev->keybit); 371 + set_bit(KEY_PROG4, idev->keybit); 372 + set_bit(KEY_PC, idev->keybit); 373 374 idev->rep[REP_DELAY] = 250; 375 idev->rep[REP_PERIOD] = 33; 376 377 idev->open = ati_remote2_open; 378 idev->close = ati_remote2_close; 379 + 380 + idev->getkeycode = ati_remote2_getkeycode; 381 + idev->setkeycode = ati_remote2_setkeycode; 382 383 idev->name = ar2->name; 384 idev->phys = ar2->phys; ··· 490 491 usb_set_intfdata(interface, ar2); 492 493 + interface->needs_remote_wakeup = 1; 494 + 495 return 0; 496 497 fail2: ··· 520 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); 521 522 kfree(ar2); 523 + } 524 + 525 + static int ati_remote2_suspend(struct usb_interface *interface, 526 + pm_message_t message) 527 + { 528 + struct ati_remote2 *ar2; 529 + struct usb_host_interface *alt = interface->cur_altsetting; 530 + 531 + if (alt->desc.bInterfaceNumber) 532 + return 0; 533 + 534 + ar2 = usb_get_intfdata(interface); 535 + 536 + dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); 537 + 538 + mutex_lock(&ati_remote2_mutex); 539 + 540 + if (ar2->flags & ATI_REMOTE2_OPENED) 541 + ati_remote2_kill_urbs(ar2); 542 + 543 + ar2->flags |= ATI_REMOTE2_SUSPENDED; 544 + 545 + mutex_unlock(&ati_remote2_mutex); 546 + 547 + return 0; 548 + } 549 + 550 + static int ati_remote2_resume(struct usb_interface *interface) 551 + { 552 + struct ati_remote2 *ar2; 553 + struct usb_host_interface *alt = interface->cur_altsetting; 554 + int r = 0; 555 + 556 + if (alt->desc.bInterfaceNumber) 557 + return 0; 558 + 559 + ar2 = usb_get_intfdata(interface); 560 + 561 + dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); 562 + 563 + mutex_lock(&ati_remote2_mutex); 564 + 565 + if (ar2->flags & ATI_REMOTE2_OPENED) 566 + r = ati_remote2_submit_urbs(ar2); 567 + 568 + if (!r) 569 + ar2->flags &= ~ATI_REMOTE2_SUSPENDED; 570 + 571 + mutex_unlock(&ati_remote2_mutex); 572 + 573 + return r; 574 } 575 576 static int __init ati_remote2_init(void)
+882
drivers/input/misc/cm109.c
···
··· 1 + /* 2 + * Driver for the VoIP USB phones with CM109 chipsets. 3 + * 4 + * Copyright (C) 2007 - 2008 Alfred E. Heggestad <aeh@db.org> 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation, version 2. 9 + */ 10 + 11 + /* 12 + * Tested devices: 13 + * - Komunikate KIP1000 14 + * - Genius G-talk 15 + * - Allied-Telesis Corega USBPH01 16 + * - ... 17 + * 18 + * This driver is based on the yealink.c driver 19 + * 20 + * Thanks to: 21 + * - Authors of yealink.c 22 + * - Thomas Reitmayr 23 + * - Oliver Neukum for good review comments and code 24 + * - Shaun Jackman <sjackman@gmail.com> for Genius G-talk keymap 25 + * - Dmitry Torokhov for valuable input and review 26 + * 27 + * Todo: 28 + * - Read/write EEPROM 29 + */ 30 + 31 + #include <linux/kernel.h> 32 + #include <linux/init.h> 33 + #include <linux/slab.h> 34 + #include <linux/module.h> 35 + #include <linux/moduleparam.h> 36 + #include <linux/rwsem.h> 37 + #include <linux/usb/input.h> 38 + 39 + #define DRIVER_VERSION "20080805" 40 + #define DRIVER_AUTHOR "Alfred E. Heggestad" 41 + #define DRIVER_DESC "CM109 phone driver" 42 + 43 + static char *phone = "kip1000"; 44 + module_param(phone, charp, S_IRUSR); 45 + MODULE_PARM_DESC(phone, "Phone name {kip1000, gtalk, usbph01}"); 46 + 47 + enum { 48 + /* HID Registers */ 49 + HID_IR0 = 0x00, /* Record/Playback-mute button, Volume up/down */ 50 + HID_IR1 = 0x01, /* GPI, generic registers or EEPROM_DATA0 */ 51 + HID_IR2 = 0x02, /* Generic registers or EEPROM_DATA1 */ 52 + HID_IR3 = 0x03, /* Generic registers or EEPROM_CTRL */ 53 + HID_OR0 = 0x00, /* Mapping control, buzzer, SPDIF (offset 0x04) */ 54 + HID_OR1 = 0x01, /* GPO - General Purpose Output */ 55 + HID_OR2 = 0x02, /* Set GPIO to input/output mode */ 56 + HID_OR3 = 0x03, /* SPDIF status channel or EEPROM_CTRL */ 57 + 58 + /* HID_IR0 */ 59 + RECORD_MUTE = 1 << 3, 60 + PLAYBACK_MUTE = 1 << 2, 61 + VOLUME_DOWN = 1 << 1, 62 + VOLUME_UP = 1 << 0, 63 + 64 + /* HID_OR0 */ 65 + /* bits 7-6 66 + 0: HID_OR1-2 are used for GPO; HID_OR0, 3 are used for buzzer 67 + and SPDIF 68 + 1: HID_OR0-3 are used as generic HID registers 69 + 2: Values written to HID_OR0-3 are also mapped to MCU_CTRL, 70 + EEPROM_DATA0-1, EEPROM_CTRL (see Note) 71 + 3: Reserved 72 + */ 73 + HID_OR_GPO_BUZ_SPDIF = 0 << 6, 74 + HID_OR_GENERIC_HID_REG = 1 << 6, 75 + HID_OR_MAP_MCU_EEPROM = 2 << 6, 76 + 77 + BUZZER_ON = 1 << 5, 78 + 79 + /* up to 256 normal keys, up to 16 special keys */ 80 + KEYMAP_SIZE = 256 + 16, 81 + }; 82 + 83 + /* CM109 protocol packet */ 84 + struct cm109_ctl_packet { 85 + u8 byte[4]; 86 + } __attribute__ ((packed)); 87 + 88 + enum { USB_PKT_LEN = sizeof(struct cm109_ctl_packet) }; 89 + 90 + /* CM109 device structure */ 91 + struct cm109_dev { 92 + struct input_dev *idev; /* input device */ 93 + struct usb_device *udev; /* usb device */ 94 + struct usb_interface *intf; 95 + 96 + /* irq input channel */ 97 + struct cm109_ctl_packet *irq_data; 98 + dma_addr_t irq_dma; 99 + struct urb *urb_irq; 100 + 101 + /* control output channel */ 102 + struct cm109_ctl_packet *ctl_data; 103 + dma_addr_t ctl_dma; 104 + struct usb_ctrlrequest *ctl_req; 105 + dma_addr_t ctl_req_dma; 106 + struct urb *urb_ctl; 107 + /* 108 + * The 3 bitfields below are protected by ctl_submit_lock. 109 + * They have to be separate since they are accessed from IRQ 110 + * context. 111 + */ 112 + unsigned irq_urb_pending:1; /* irq_urb is in flight */ 113 + unsigned ctl_urb_pending:1; /* ctl_urb is in flight */ 114 + unsigned buzzer_pending:1; /* need to issue buzz command */ 115 + spinlock_t ctl_submit_lock; 116 + 117 + unsigned char buzzer_state; /* on/off */ 118 + 119 + /* flags */ 120 + unsigned open:1; 121 + unsigned resetting:1; 122 + unsigned shutdown:1; 123 + 124 + /* This mutex protects writes to the above flags */ 125 + struct mutex pm_mutex; 126 + 127 + unsigned short keymap[KEYMAP_SIZE]; 128 + 129 + char phys[64]; /* physical device path */ 130 + int key_code; /* last reported key */ 131 + int keybit; /* 0=new scan 1,2,4,8=scan columns */ 132 + u8 gpi; /* Cached value of GPI (high nibble) */ 133 + }; 134 + 135 + /****************************************************************************** 136 + * CM109 key interface 137 + *****************************************************************************/ 138 + 139 + static unsigned short special_keymap(int code) 140 + { 141 + if (code > 0xff) { 142 + switch (code - 0xff) { 143 + case RECORD_MUTE: return KEY_MUTE; 144 + case PLAYBACK_MUTE: return KEY_MUTE; 145 + case VOLUME_DOWN: return KEY_VOLUMEDOWN; 146 + case VOLUME_UP: return KEY_VOLUMEUP; 147 + } 148 + } 149 + return KEY_RESERVED; 150 + } 151 + 152 + /* Map device buttons to internal key events. 153 + * 154 + * The "up" and "down" keys, are symbolised by arrows on the button. 155 + * The "pickup" and "hangup" keys are symbolised by a green and red phone 156 + * on the button. 157 + 158 + Komunikate KIP1000 Keyboard Matrix 159 + 160 + -> -- 1 -- 2 -- 3 --> GPI pin 4 (0x10) 161 + | | | | 162 + <- -- 4 -- 5 -- 6 --> GPI pin 5 (0x20) 163 + | | | | 164 + END - 7 -- 8 -- 9 --> GPI pin 6 (0x40) 165 + | | | | 166 + OK -- * -- 0 -- # --> GPI pin 7 (0x80) 167 + | | | | 168 + 169 + /|\ /|\ /|\ /|\ 170 + | | | | 171 + GPO 172 + pin: 3 2 1 0 173 + 0x8 0x4 0x2 0x1 174 + 175 + */ 176 + static unsigned short keymap_kip1000(int scancode) 177 + { 178 + switch (scancode) { /* phone key: */ 179 + case 0x82: return KEY_NUMERIC_0; /* 0 */ 180 + case 0x14: return KEY_NUMERIC_1; /* 1 */ 181 + case 0x12: return KEY_NUMERIC_2; /* 2 */ 182 + case 0x11: return KEY_NUMERIC_3; /* 3 */ 183 + case 0x24: return KEY_NUMERIC_4; /* 4 */ 184 + case 0x22: return KEY_NUMERIC_5; /* 5 */ 185 + case 0x21: return KEY_NUMERIC_6; /* 6 */ 186 + case 0x44: return KEY_NUMERIC_7; /* 7 */ 187 + case 0x42: return KEY_NUMERIC_8; /* 8 */ 188 + case 0x41: return KEY_NUMERIC_9; /* 9 */ 189 + case 0x81: return KEY_NUMERIC_POUND; /* # */ 190 + case 0x84: return KEY_NUMERIC_STAR; /* * */ 191 + case 0x88: return KEY_ENTER; /* pickup */ 192 + case 0x48: return KEY_ESC; /* hangup */ 193 + case 0x28: return KEY_LEFT; /* IN */ 194 + case 0x18: return KEY_RIGHT; /* OUT */ 195 + default: return special_keymap(scancode); 196 + } 197 + } 198 + 199 + /* 200 + Contributed by Shaun Jackman <sjackman@gmail.com> 201 + 202 + Genius G-Talk keyboard matrix 203 + 0 1 2 3 204 + 4: 0 4 8 Talk 205 + 5: 1 5 9 End 206 + 6: 2 6 # Up 207 + 7: 3 7 * Down 208 + */ 209 + static unsigned short keymap_gtalk(int scancode) 210 + { 211 + switch (scancode) { 212 + case 0x11: return KEY_NUMERIC_0; 213 + case 0x21: return KEY_NUMERIC_1; 214 + case 0x41: return KEY_NUMERIC_2; 215 + case 0x81: return KEY_NUMERIC_3; 216 + case 0x12: return KEY_NUMERIC_4; 217 + case 0x22: return KEY_NUMERIC_5; 218 + case 0x42: return KEY_NUMERIC_6; 219 + case 0x82: return KEY_NUMERIC_7; 220 + case 0x14: return KEY_NUMERIC_8; 221 + case 0x24: return KEY_NUMERIC_9; 222 + case 0x44: return KEY_NUMERIC_POUND; /* # */ 223 + case 0x84: return KEY_NUMERIC_STAR; /* * */ 224 + case 0x18: return KEY_ENTER; /* Talk (green handset) */ 225 + case 0x28: return KEY_ESC; /* End (red handset) */ 226 + case 0x48: return KEY_UP; /* Menu up (rocker switch) */ 227 + case 0x88: return KEY_DOWN; /* Menu down (rocker switch) */ 228 + default: return special_keymap(scancode); 229 + } 230 + } 231 + 232 + /* 233 + * Keymap for Allied-Telesis Corega USBPH01 234 + * http://www.alliedtelesis-corega.com/2/1344/1437/1360/chprd.html 235 + * 236 + * Contributed by july@nat.bg 237 + */ 238 + static unsigned short keymap_usbph01(int scancode) 239 + { 240 + switch (scancode) { 241 + case 0x11: return KEY_NUMERIC_0; /* 0 */ 242 + case 0x21: return KEY_NUMERIC_1; /* 1 */ 243 + case 0x41: return KEY_NUMERIC_2; /* 2 */ 244 + case 0x81: return KEY_NUMERIC_3; /* 3 */ 245 + case 0x12: return KEY_NUMERIC_4; /* 4 */ 246 + case 0x22: return KEY_NUMERIC_5; /* 5 */ 247 + case 0x42: return KEY_NUMERIC_6; /* 6 */ 248 + case 0x82: return KEY_NUMERIC_7; /* 7 */ 249 + case 0x14: return KEY_NUMERIC_8; /* 8 */ 250 + case 0x24: return KEY_NUMERIC_9; /* 9 */ 251 + case 0x44: return KEY_NUMERIC_POUND; /* # */ 252 + case 0x84: return KEY_NUMERIC_STAR; /* * */ 253 + case 0x18: return KEY_ENTER; /* pickup */ 254 + case 0x28: return KEY_ESC; /* hangup */ 255 + case 0x48: return KEY_LEFT; /* IN */ 256 + case 0x88: return KEY_RIGHT; /* OUT */ 257 + default: return special_keymap(scancode); 258 + } 259 + } 260 + 261 + static unsigned short (*keymap)(int) = keymap_kip1000; 262 + 263 + /* 264 + * Completes a request by converting the data into events for the 265 + * input subsystem. 266 + */ 267 + static void report_key(struct cm109_dev *dev, int key) 268 + { 269 + struct input_dev *idev = dev->idev; 270 + 271 + if (dev->key_code >= 0) { 272 + /* old key up */ 273 + input_report_key(idev, dev->key_code, 0); 274 + } 275 + 276 + dev->key_code = key; 277 + if (key >= 0) { 278 + /* new valid key */ 279 + input_report_key(idev, key, 1); 280 + } 281 + 282 + input_sync(idev); 283 + } 284 + 285 + /****************************************************************************** 286 + * CM109 usb communication interface 287 + *****************************************************************************/ 288 + 289 + static void cm109_submit_buzz_toggle(struct cm109_dev *dev) 290 + { 291 + int error; 292 + 293 + if (dev->buzzer_state) 294 + dev->ctl_data->byte[HID_OR0] |= BUZZER_ON; 295 + else 296 + dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON; 297 + 298 + error = usb_submit_urb(dev->urb_ctl, GFP_ATOMIC); 299 + if (error) 300 + err("%s: usb_submit_urb (urb_ctl) failed %d", __func__, error); 301 + } 302 + 303 + /* 304 + * IRQ handler 305 + */ 306 + static void cm109_urb_irq_callback(struct urb *urb) 307 + { 308 + struct cm109_dev *dev = urb->context; 309 + const int status = urb->status; 310 + int error; 311 + 312 + dev_dbg(&urb->dev->dev, "### URB IRQ: [0x%02x 0x%02x 0x%02x 0x%02x] keybit=0x%02x\n", 313 + dev->irq_data->byte[0], 314 + dev->irq_data->byte[1], 315 + dev->irq_data->byte[2], 316 + dev->irq_data->byte[3], 317 + dev->keybit); 318 + 319 + if (status) { 320 + if (status == -ESHUTDOWN) 321 + return; 322 + err("%s: urb status %d", __func__, status); 323 + } 324 + 325 + /* Special keys */ 326 + if (dev->irq_data->byte[HID_IR0] & 0x0f) { 327 + const int code = (dev->irq_data->byte[HID_IR0] & 0x0f); 328 + report_key(dev, dev->keymap[0xff + code]); 329 + } 330 + 331 + /* Scan key column */ 332 + if (dev->keybit == 0xf) { 333 + 334 + /* Any changes ? */ 335 + if ((dev->gpi & 0xf0) == (dev->irq_data->byte[HID_IR1] & 0xf0)) 336 + goto out; 337 + 338 + dev->gpi = dev->irq_data->byte[HID_IR1] & 0xf0; 339 + dev->keybit = 0x1; 340 + } else { 341 + report_key(dev, dev->keymap[dev->irq_data->byte[HID_IR1]]); 342 + 343 + dev->keybit <<= 1; 344 + if (dev->keybit > 0x8) 345 + dev->keybit = 0xf; 346 + } 347 + 348 + out: 349 + 350 + spin_lock(&dev->ctl_submit_lock); 351 + 352 + dev->irq_urb_pending = 0; 353 + 354 + if (likely(!dev->shutdown)) { 355 + 356 + if (dev->buzzer_state) 357 + dev->ctl_data->byte[HID_OR0] |= BUZZER_ON; 358 + else 359 + dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON; 360 + 361 + dev->ctl_data->byte[HID_OR1] = dev->keybit; 362 + dev->ctl_data->byte[HID_OR2] = dev->keybit; 363 + 364 + dev->buzzer_pending = 0; 365 + dev->ctl_urb_pending = 1; 366 + 367 + error = usb_submit_urb(dev->urb_ctl, GFP_ATOMIC); 368 + if (error) 369 + err("%s: usb_submit_urb (urb_ctl) failed %d", 370 + __func__, error); 371 + } 372 + 373 + spin_unlock(&dev->ctl_submit_lock); 374 + } 375 + 376 + static void cm109_urb_ctl_callback(struct urb *urb) 377 + { 378 + struct cm109_dev *dev = urb->context; 379 + const int status = urb->status; 380 + int error; 381 + 382 + dev_dbg(&urb->dev->dev, "### URB CTL: [0x%02x 0x%02x 0x%02x 0x%02x]\n", 383 + dev->ctl_data->byte[0], 384 + dev->ctl_data->byte[1], 385 + dev->ctl_data->byte[2], 386 + dev->ctl_data->byte[3]); 387 + 388 + if (status) 389 + err("%s: urb status %d", __func__, status); 390 + 391 + spin_lock(&dev->ctl_submit_lock); 392 + 393 + dev->ctl_urb_pending = 0; 394 + 395 + if (likely(!dev->shutdown)) { 396 + 397 + if (dev->buzzer_pending) { 398 + dev->buzzer_pending = 0; 399 + dev->ctl_urb_pending = 1; 400 + cm109_submit_buzz_toggle(dev); 401 + } else if (likely(!dev->irq_urb_pending)) { 402 + /* ask for key data */ 403 + dev->irq_urb_pending = 1; 404 + error = usb_submit_urb(dev->urb_irq, GFP_ATOMIC); 405 + if (error) 406 + err("%s: usb_submit_urb (urb_irq) failed %d", 407 + __func__, error); 408 + } 409 + } 410 + 411 + spin_unlock(&dev->ctl_submit_lock); 412 + } 413 + 414 + static void cm109_toggle_buzzer_async(struct cm109_dev *dev) 415 + { 416 + unsigned long flags; 417 + 418 + spin_lock_irqsave(&dev->ctl_submit_lock, flags); 419 + 420 + if (dev->ctl_urb_pending) { 421 + /* URB completion will resubmit */ 422 + dev->buzzer_pending = 1; 423 + } else { 424 + dev->ctl_urb_pending = 1; 425 + cm109_submit_buzz_toggle(dev); 426 + } 427 + 428 + spin_unlock_irqrestore(&dev->ctl_submit_lock, flags); 429 + } 430 + 431 + static void cm109_toggle_buzzer_sync(struct cm109_dev *dev, int on) 432 + { 433 + int error; 434 + 435 + if (on) 436 + dev->ctl_data->byte[HID_OR0] |= BUZZER_ON; 437 + else 438 + dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON; 439 + 440 + error = usb_control_msg(dev->udev, 441 + usb_sndctrlpipe(dev->udev, 0), 442 + dev->ctl_req->bRequest, 443 + dev->ctl_req->bRequestType, 444 + le16_to_cpu(dev->ctl_req->wValue), 445 + le16_to_cpu(dev->ctl_req->wIndex), 446 + dev->ctl_data, 447 + USB_PKT_LEN, USB_CTRL_SET_TIMEOUT); 448 + if (error && error != EINTR) 449 + err("%s: usb_control_msg() failed %d", __func__, error); 450 + } 451 + 452 + static void cm109_stop_traffic(struct cm109_dev *dev) 453 + { 454 + dev->shutdown = 1; 455 + /* 456 + * Make sure other CPUs see this 457 + */ 458 + smp_wmb(); 459 + 460 + usb_kill_urb(dev->urb_ctl); 461 + usb_kill_urb(dev->urb_irq); 462 + 463 + cm109_toggle_buzzer_sync(dev, 0); 464 + 465 + dev->shutdown = 0; 466 + smp_wmb(); 467 + } 468 + 469 + static void cm109_restore_state(struct cm109_dev *dev) 470 + { 471 + if (dev->open) { 472 + /* 473 + * Restore buzzer state. 474 + * This will also kick regular URB submission 475 + */ 476 + cm109_toggle_buzzer_async(dev); 477 + } 478 + } 479 + 480 + /****************************************************************************** 481 + * input event interface 482 + *****************************************************************************/ 483 + 484 + static int cm109_input_open(struct input_dev *idev) 485 + { 486 + struct cm109_dev *dev = input_get_drvdata(idev); 487 + int error; 488 + 489 + error = usb_autopm_get_interface(dev->intf); 490 + if (error < 0) { 491 + err("%s - cannot autoresume, result %d", 492 + __func__, error); 493 + return error; 494 + } 495 + 496 + mutex_lock(&dev->pm_mutex); 497 + 498 + dev->buzzer_state = 0; 499 + dev->key_code = -1; /* no keys pressed */ 500 + dev->keybit = 0xf; 501 + 502 + /* issue INIT */ 503 + dev->ctl_data->byte[HID_OR0] = HID_OR_GPO_BUZ_SPDIF; 504 + dev->ctl_data->byte[HID_OR1] = dev->keybit; 505 + dev->ctl_data->byte[HID_OR2] = dev->keybit; 506 + dev->ctl_data->byte[HID_OR3] = 0x00; 507 + 508 + error = usb_submit_urb(dev->urb_ctl, GFP_KERNEL); 509 + if (error) 510 + err("%s: usb_submit_urb (urb_ctl) failed %d", __func__, error); 511 + else 512 + dev->open = 1; 513 + 514 + mutex_unlock(&dev->pm_mutex); 515 + 516 + if (error) 517 + usb_autopm_put_interface(dev->intf); 518 + 519 + return error; 520 + } 521 + 522 + static void cm109_input_close(struct input_dev *idev) 523 + { 524 + struct cm109_dev *dev = input_get_drvdata(idev); 525 + 526 + mutex_lock(&dev->pm_mutex); 527 + 528 + /* 529 + * Once we are here event delivery is stopped so we 530 + * don't need to worry about someone starting buzzer 531 + * again 532 + */ 533 + cm109_stop_traffic(dev); 534 + dev->open = 0; 535 + 536 + mutex_unlock(&dev->pm_mutex); 537 + 538 + usb_autopm_put_interface(dev->intf); 539 + } 540 + 541 + static int cm109_input_ev(struct input_dev *idev, unsigned int type, 542 + unsigned int code, int value) 543 + { 544 + struct cm109_dev *dev = input_get_drvdata(idev); 545 + 546 + dev_dbg(&dev->udev->dev, 547 + "input_ev: type=%u code=%u value=%d\n", type, code, value); 548 + 549 + if (type != EV_SND) 550 + return -EINVAL; 551 + 552 + switch (code) { 553 + case SND_TONE: 554 + case SND_BELL: 555 + dev->buzzer_state = !!value; 556 + if (!dev->resetting) 557 + cm109_toggle_buzzer_async(dev); 558 + return 0; 559 + 560 + default: 561 + return -EINVAL; 562 + } 563 + } 564 + 565 + 566 + /****************************************************************************** 567 + * Linux interface and usb initialisation 568 + *****************************************************************************/ 569 + 570 + struct driver_info { 571 + char *name; 572 + }; 573 + 574 + static const struct driver_info info_cm109 = { 575 + .name = "CM109 USB driver", 576 + }; 577 + 578 + enum { 579 + VENDOR_ID = 0x0d8c, /* C-Media Electronics */ 580 + PRODUCT_ID_CM109 = 0x000e, /* CM109 defines range 0x0008 - 0x000f */ 581 + }; 582 + 583 + /* table of devices that work with this driver */ 584 + static const struct usb_device_id cm109_usb_table[] = { 585 + { 586 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 587 + USB_DEVICE_ID_MATCH_INT_INFO, 588 + .idVendor = VENDOR_ID, 589 + .idProduct = PRODUCT_ID_CM109, 590 + .bInterfaceClass = USB_CLASS_HID, 591 + .bInterfaceSubClass = 0, 592 + .bInterfaceProtocol = 0, 593 + .driver_info = (kernel_ulong_t) &info_cm109 594 + }, 595 + /* you can add more devices here with product ID 0x0008 - 0x000f */ 596 + { } 597 + }; 598 + 599 + static void cm109_usb_cleanup(struct cm109_dev *dev) 600 + { 601 + if (dev->ctl_req) 602 + usb_buffer_free(dev->udev, sizeof(*(dev->ctl_req)), 603 + dev->ctl_req, dev->ctl_req_dma); 604 + if (dev->ctl_data) 605 + usb_buffer_free(dev->udev, USB_PKT_LEN, 606 + dev->ctl_data, dev->ctl_dma); 607 + if (dev->irq_data) 608 + usb_buffer_free(dev->udev, USB_PKT_LEN, 609 + dev->irq_data, dev->irq_dma); 610 + 611 + usb_free_urb(dev->urb_irq); /* parameter validation in core/urb */ 612 + usb_free_urb(dev->urb_ctl); /* parameter validation in core/urb */ 613 + kfree(dev); 614 + } 615 + 616 + static void cm109_usb_disconnect(struct usb_interface *interface) 617 + { 618 + struct cm109_dev *dev = usb_get_intfdata(interface); 619 + 620 + usb_set_intfdata(interface, NULL); 621 + input_unregister_device(dev->idev); 622 + cm109_usb_cleanup(dev); 623 + } 624 + 625 + static int cm109_usb_probe(struct usb_interface *intf, 626 + const struct usb_device_id *id) 627 + { 628 + struct usb_device *udev = interface_to_usbdev(intf); 629 + struct driver_info *nfo = (struct driver_info *)id->driver_info; 630 + struct usb_host_interface *interface; 631 + struct usb_endpoint_descriptor *endpoint; 632 + struct cm109_dev *dev; 633 + struct input_dev *input_dev = NULL; 634 + int ret, pipe, i; 635 + int error = -ENOMEM; 636 + 637 + interface = intf->cur_altsetting; 638 + endpoint = &interface->endpoint[0].desc; 639 + 640 + if (!usb_endpoint_is_int_in(endpoint)) 641 + return -ENODEV; 642 + 643 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 644 + if (!dev) 645 + return -ENOMEM; 646 + 647 + spin_lock_init(&dev->ctl_submit_lock); 648 + mutex_init(&dev->pm_mutex); 649 + 650 + dev->udev = udev; 651 + dev->intf = intf; 652 + 653 + dev->idev = input_dev = input_allocate_device(); 654 + if (!input_dev) 655 + goto err_out; 656 + 657 + /* allocate usb buffers */ 658 + dev->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, 659 + GFP_KERNEL, &dev->irq_dma); 660 + if (!dev->irq_data) 661 + goto err_out; 662 + 663 + dev->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN, 664 + GFP_KERNEL, &dev->ctl_dma); 665 + if (!dev->ctl_data) 666 + goto err_out; 667 + 668 + dev->ctl_req = usb_buffer_alloc(udev, sizeof(*(dev->ctl_req)), 669 + GFP_KERNEL, &dev->ctl_req_dma); 670 + if (!dev->ctl_req) 671 + goto err_out; 672 + 673 + /* allocate urb structures */ 674 + dev->urb_irq = usb_alloc_urb(0, GFP_KERNEL); 675 + if (!dev->urb_irq) 676 + goto err_out; 677 + 678 + dev->urb_ctl = usb_alloc_urb(0, GFP_KERNEL); 679 + if (!dev->urb_ctl) 680 + goto err_out; 681 + 682 + /* get a handle to the interrupt data pipe */ 683 + pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 684 + ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 685 + if (ret != USB_PKT_LEN) 686 + err("invalid payload size %d, expected %d", ret, USB_PKT_LEN); 687 + 688 + /* initialise irq urb */ 689 + usb_fill_int_urb(dev->urb_irq, udev, pipe, dev->irq_data, 690 + USB_PKT_LEN, 691 + cm109_urb_irq_callback, dev, endpoint->bInterval); 692 + dev->urb_irq->transfer_dma = dev->irq_dma; 693 + dev->urb_irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 694 + dev->urb_irq->dev = udev; 695 + 696 + /* initialise ctl urb */ 697 + dev->ctl_req->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | 698 + USB_DIR_OUT; 699 + dev->ctl_req->bRequest = USB_REQ_SET_CONFIGURATION; 700 + dev->ctl_req->wValue = cpu_to_le16(0x200); 701 + dev->ctl_req->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); 702 + dev->ctl_req->wLength = cpu_to_le16(USB_PKT_LEN); 703 + 704 + usb_fill_control_urb(dev->urb_ctl, udev, usb_sndctrlpipe(udev, 0), 705 + (void *)dev->ctl_req, dev->ctl_data, USB_PKT_LEN, 706 + cm109_urb_ctl_callback, dev); 707 + dev->urb_ctl->setup_dma = dev->ctl_req_dma; 708 + dev->urb_ctl->transfer_dma = dev->ctl_dma; 709 + dev->urb_ctl->transfer_flags |= URB_NO_SETUP_DMA_MAP | 710 + URB_NO_TRANSFER_DMA_MAP; 711 + dev->urb_ctl->dev = udev; 712 + 713 + /* find out the physical bus location */ 714 + usb_make_path(udev, dev->phys, sizeof(dev->phys)); 715 + strlcat(dev->phys, "/input0", sizeof(dev->phys)); 716 + 717 + /* register settings for the input device */ 718 + input_dev->name = nfo->name; 719 + input_dev->phys = dev->phys; 720 + usb_to_input_id(udev, &input_dev->id); 721 + input_dev->dev.parent = &intf->dev; 722 + 723 + input_set_drvdata(input_dev, dev); 724 + input_dev->open = cm109_input_open; 725 + input_dev->close = cm109_input_close; 726 + input_dev->event = cm109_input_ev; 727 + 728 + input_dev->keycode = dev->keymap; 729 + input_dev->keycodesize = sizeof(unsigned char); 730 + input_dev->keycodemax = ARRAY_SIZE(dev->keymap); 731 + 732 + input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND); 733 + input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); 734 + 735 + /* register available key events */ 736 + for (i = 0; i < KEYMAP_SIZE; i++) { 737 + unsigned short k = keymap(i); 738 + dev->keymap[i] = k; 739 + __set_bit(k, input_dev->keybit); 740 + } 741 + __clear_bit(KEY_RESERVED, input_dev->keybit); 742 + 743 + error = input_register_device(dev->idev); 744 + if (error) 745 + goto err_out; 746 + 747 + usb_set_intfdata(intf, dev); 748 + 749 + return 0; 750 + 751 + err_out: 752 + input_free_device(input_dev); 753 + cm109_usb_cleanup(dev); 754 + return error; 755 + } 756 + 757 + static int cm109_usb_suspend(struct usb_interface *intf, pm_message_t message) 758 + { 759 + struct cm109_dev *dev = usb_get_intfdata(intf); 760 + 761 + dev_info(&intf->dev, "cm109: usb_suspend (event=%d)\n", message.event); 762 + 763 + mutex_lock(&dev->pm_mutex); 764 + cm109_stop_traffic(dev); 765 + mutex_unlock(&dev->pm_mutex); 766 + 767 + return 0; 768 + } 769 + 770 + static int cm109_usb_resume(struct usb_interface *intf) 771 + { 772 + struct cm109_dev *dev = usb_get_intfdata(intf); 773 + 774 + dev_info(&intf->dev, "cm109: usb_resume\n"); 775 + 776 + mutex_lock(&dev->pm_mutex); 777 + cm109_restore_state(dev); 778 + mutex_unlock(&dev->pm_mutex); 779 + 780 + return 0; 781 + } 782 + 783 + static int cm109_usb_pre_reset(struct usb_interface *intf) 784 + { 785 + struct cm109_dev *dev = usb_get_intfdata(intf); 786 + 787 + mutex_lock(&dev->pm_mutex); 788 + 789 + /* 790 + * Make sure input events don't try to toggle buzzer 791 + * while we are resetting 792 + */ 793 + dev->resetting = 1; 794 + smp_wmb(); 795 + 796 + cm109_stop_traffic(dev); 797 + 798 + return 0; 799 + } 800 + 801 + static int cm109_usb_post_reset(struct usb_interface *intf) 802 + { 803 + struct cm109_dev *dev = usb_get_intfdata(intf); 804 + 805 + dev->resetting = 0; 806 + smp_wmb(); 807 + 808 + cm109_restore_state(dev); 809 + 810 + mutex_unlock(&dev->pm_mutex); 811 + 812 + return 0; 813 + } 814 + 815 + static struct usb_driver cm109_driver = { 816 + .name = "cm109", 817 + .probe = cm109_usb_probe, 818 + .disconnect = cm109_usb_disconnect, 819 + .suspend = cm109_usb_suspend, 820 + .resume = cm109_usb_resume, 821 + .reset_resume = cm109_usb_resume, 822 + .pre_reset = cm109_usb_pre_reset, 823 + .post_reset = cm109_usb_post_reset, 824 + .id_table = cm109_usb_table, 825 + .supports_autosuspend = 1, 826 + }; 827 + 828 + static int __init cm109_select_keymap(void) 829 + { 830 + /* Load the phone keymap */ 831 + if (!strcasecmp(phone, "kip1000")) { 832 + keymap = keymap_kip1000; 833 + printk(KERN_INFO KBUILD_MODNAME ": " 834 + "Keymap for Komunikate KIP1000 phone loaded\n"); 835 + } else if (!strcasecmp(phone, "gtalk")) { 836 + keymap = keymap_gtalk; 837 + printk(KERN_INFO KBUILD_MODNAME ": " 838 + "Keymap for Genius G-talk phone loaded\n"); 839 + } else if (!strcasecmp(phone, "usbph01")) { 840 + keymap = keymap_usbph01; 841 + printk(KERN_INFO KBUILD_MODNAME ": " 842 + "Keymap for Allied-Telesis Corega USBPH01 phone loaded\n"); 843 + } else { 844 + printk(KERN_ERR KBUILD_MODNAME ": " 845 + "Unsupported phone: %s\n", phone); 846 + return -EINVAL; 847 + } 848 + 849 + return 0; 850 + } 851 + 852 + static int __init cm109_init(void) 853 + { 854 + int err; 855 + 856 + err = cm109_select_keymap(); 857 + if (err) 858 + return err; 859 + 860 + err = usb_register(&cm109_driver); 861 + if (err) 862 + return err; 863 + 864 + printk(KERN_INFO KBUILD_MODNAME ": " 865 + DRIVER_DESC ": " DRIVER_VERSION " (C) " DRIVER_AUTHOR "\n"); 866 + 867 + return 0; 868 + } 869 + 870 + static void __exit cm109_exit(void) 871 + { 872 + usb_deregister(&cm109_driver); 873 + } 874 + 875 + module_init(cm109_init); 876 + module_exit(cm109_exit); 877 + 878 + MODULE_DEVICE_TABLE(usb, cm109_usb_table); 879 + 880 + MODULE_AUTHOR(DRIVER_AUTHOR); 881 + MODULE_DESCRIPTION(DRIVER_DESC); 882 + MODULE_LICENSE("GPL");
+1 -3
drivers/input/misc/map_to_7segment.h include/linux/map_to_7segment.h
··· 1 /* 2 - * drivers/usb/input/map_to_7segment.h 3 - * 4 * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or ··· 34 * Usage: 35 * 36 * Register a map variable, and fill it with a character set: 37 - * static SEG7_DEFAULT_MAP(map_seg7); 38 * 39 * 40 * Then use for conversion:
··· 1 /* 2 * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> 3 * 4 * This program is free software; you can redistribute it and/or ··· 36 * Usage: 37 * 38 * Register a map variable, and fill it with a character set: 39 + * static SEG7_DEFAULT_MAP(map_seg7); 40 * 41 * 42 * Then use for conversion:
+19
drivers/input/misc/wistron_btns.c
··· 277 { KE_END, 0 } 278 }; 279 280 static struct key_entry keymap_fujitsu_n3510[] __initdata = { 281 { KE_KEY, 0x11, {KEY_PROG1} }, 282 { KE_KEY, 0x12, {KEY_PROG2} }, ··· 625 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"), 626 }, 627 .driver_data = keymap_fs_amilo_pro_v2000 628 }, 629 { 630 .callback = dmi_matched,
··· 277 { KE_END, 0 } 278 }; 279 280 + static struct key_entry keymap_fs_amilo_pro_v3505[] __initdata = { 281 + { KE_KEY, 0x01, {KEY_HELP} }, /* Fn+F1 */ 282 + { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Fn+F4 */ 283 + { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */ 284 + { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */ 285 + { KE_KEY, 0x36, {KEY_WWW} }, /* www button */ 286 + { KE_WIFI, 0x78 }, /* satelite dish button */ 287 + { KE_END, 0 } 288 + }; 289 + 290 static struct key_entry keymap_fujitsu_n3510[] __initdata = { 291 { KE_KEY, 0x11, {KEY_PROG1} }, 292 { KE_KEY, 0x12, {KEY_PROG2} }, ··· 615 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"), 616 }, 617 .driver_data = keymap_fs_amilo_pro_v2000 618 + }, 619 + { 620 + .callback = dmi_matched, 621 + .ident = "Fujitsu-Siemens Amilo Pro Edition V3505", 622 + .matches = { 623 + DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 624 + DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro Edition V3505"), 625 + }, 626 + .driver_data = keymap_fs_amilo_pro_v3505 627 }, 628 { 629 .callback = dmi_matched,
+1 -1
drivers/input/misc/yealink.c
··· 52 #include <linux/module.h> 53 #include <linux/rwsem.h> 54 #include <linux/usb/input.h> 55 56 - #include "map_to_7segment.h" 57 #include "yealink.h" 58 59 #define DRIVER_VERSION "yld-20051230"
··· 52 #include <linux/module.h> 53 #include <linux/rwsem.h> 54 #include <linux/usb/input.h> 55 + #include <linux/map_to_7segment.h> 56 57 #include "yealink.h" 58 59 #define DRIVER_VERSION "yld-20051230"
+10
drivers/input/mouse/Kconfig
··· 96 97 If unsure, say N. 98 99 config MOUSE_SERIAL 100 tristate "Serial mouse" 101 select SERIO
··· 96 97 If unsure, say N. 98 99 + config MOUSE_PS2_OLPC 100 + bool "OLPC PS/2 mouse protocol extension" 101 + depends on MOUSE_PS2 && OLPC 102 + help 103 + Say Y here if you have an OLPC XO-1 laptop (with built-in 104 + PS/2 touchpad/tablet device). The manufacturer calls the 105 + touchpad an HGPK. 106 + 107 + If unsure, say N. 108 + 109 config MOUSE_SERIAL 110 tristate "Serial mouse" 111 select SERIO
+1
drivers/input/mouse/Makefile
··· 21 psmouse-objs := psmouse-base.o synaptics.o 22 23 psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o 24 psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o 25 psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o 26 psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o
··· 21 psmouse-objs := psmouse-base.o synaptics.o 22 23 psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o 24 + psmouse-$(CONFIG_MOUSE_PS2_OLPC) += hgpk.o 25 psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o 26 psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o 27 psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o
+1
drivers/input/mouse/alps.c
··· 54 { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ 55 { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, 56 { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ 57 { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */ 58 }; 59
··· 54 { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ 55 { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, 56 { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ 57 + { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude E6500 */ 58 { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */ 59 }; 60
+223 -78
drivers/input/mouse/appletouch.c
··· 136 #define ATP_GEYSER_MODE_REQUEST_INDEX 0 137 #define ATP_GEYSER_MODE_VENDOR_VALUE 0x04 138 139 /* Structure to hold all of our device specific stuff */ 140 struct atp { 141 char phys[64]; 142 struct usb_device *udev; /* usb device */ 143 struct urb *urb; /* usb request block */ 144 - signed char *data; /* transferred data */ 145 struct input_dev *input; /* input dev */ 146 enum atp_touchpad_type type; /* type of touchpad */ 147 bool open; ··· 267 int retval; 268 269 dprintk("appletouch: putting appletouch to sleep (reinit)\n"); 270 - dev->idlecount = 0; 271 - 272 atp_geyser_init(udev); 273 274 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); ··· 341 input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); 342 } 343 344 - static void atp_complete(struct urb *urb) 345 { 346 - int x, y, x_z, y_z, x_f, y_f; 347 - int retval, i, j; 348 - int key; 349 struct atp *dev = urb->context; 350 351 switch (urb->status) { ··· 368 /* This urb is terminated, clean up */ 369 dbg("atp_complete: urb shutting down with status: %d", 370 urb->status); 371 - return; 372 default: 373 dbg("atp_complete: nonzero urb status received: %d", 374 urb->status); 375 - goto exit; 376 } 377 378 /* drop incomplete datasets */ ··· 381 dprintk("appletouch: incomplete data package" 382 " (first byte: %d, length: %d).\n", 383 dev->data[0], dev->urb->actual_length); 384 - goto exit; 385 } 386 387 /* reorder the sensors values */ 388 - if (dev->type == ATP_GEYSER3 || dev->type == ATP_GEYSER4) { 389 - memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); 390 - 391 - /* 392 - * The values are laid out like this: 393 - * -, Y1, Y2, -, Y3, Y4, -, ..., -, X1, X2, -, X3, X4, ... 394 - * '-' is an unused value. 395 - */ 396 - 397 - /* read X values */ 398 - for (i = 0, j = 19; i < 20; i += 2, j += 3) { 399 - dev->xy_cur[i] = dev->data[j + 1]; 400 - dev->xy_cur[i + 1] = dev->data[j + 2]; 401 - } 402 - /* read Y values */ 403 - for (i = 0, j = 1; i < 9; i += 2, j += 3) { 404 - dev->xy_cur[ATP_XSENSORS + i] = dev->data[j + 1]; 405 - dev->xy_cur[ATP_XSENSORS + i + 1] = dev->data[j + 2]; 406 - } 407 - } else if (dev->type == ATP_GEYSER2) { 408 memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); 409 410 /* ··· 448 /* first sample */ 449 dev->valid = true; 450 dev->x_old = dev->y_old = -1; 451 memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); 452 453 - if (dev->size_detect_done || 454 - dev->type == ATP_GEYSER3) /* No 17" Macbooks (yet) */ 455 goto exit; 456 - 457 - /* 17" Powerbooks have extra X sensors */ 458 - for (i = (dev->type == ATP_GEYSER2 ? 15 : 16); 459 - i < ATP_XSENSORS; i++) { 460 - if (!dev->xy_cur[i]) 461 - continue; 462 - 463 - printk(KERN_INFO "appletouch: 17\" model detected.\n"); 464 - if (dev->type == ATP_GEYSER2) 465 - input_set_abs_params(dev->input, ABS_X, 0, 466 - (20 - 1) * 467 - ATP_XFACT - 1, 468 - ATP_FUZZ, 0); 469 - else 470 - input_set_abs_params(dev->input, ABS_X, 0, 471 - (ATP_XSENSORS - 1) * 472 - ATP_XFACT - 1, 473 - ATP_FUZZ, 0); 474 - break; 475 } 476 - 477 - dev->size_detect_done = 1; 478 - goto exit; 479 } 480 481 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { ··· 502 ATP_XFACT, &x_z, &x_f); 503 y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, 504 ATP_YFACT, &y_z, &y_f); 505 - key = dev->data[dev->datalen - 1] & 1; 506 507 if (x && y) { 508 if (dev->x_old != -1) { ··· 652 input_sync(dev->input); 653 654 /* 655 - * Many Geysers will continue to send packets continually after 656 * the first touch unless reinitialised. Do so if it's been 657 * idle for a while in order to avoid waking the kernel up 658 - * several hundred times a second. Re-initialization does not 659 - * work on Fountain touchpads. 660 */ 661 - if (dev->type != ATP_FOUNTAIN) { 662 - /* 663 - * Button must not be pressed when entering suspend, 664 - * otherwise we will never release the button. 665 - */ 666 - if (!x && !y && !key) { 667 - dev->idlecount++; 668 - if (dev->idlecount == 10) { 669 - dev->valid = false; 670 - schedule_work(&dev->work); 671 - /* Don't resubmit urb here, wait for reinit */ 672 - return; 673 - } 674 - } else 675 dev->idlecount = 0; 676 - } 677 678 exit: 679 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); ··· 769 if (!dev->data) 770 goto err_free_urb; 771 772 - usb_fill_int_urb(dev->urb, udev, 773 - usb_rcvintpipe(udev, int_in_endpointAddr), 774 - dev->data, dev->datalen, atp_complete, dev, 1); 775 776 error = atp_handle_geyser(dev); 777 if (error) ··· 898 struct atp *dev = usb_get_intfdata(iface); 899 900 usb_kill_urb(dev->urb); 901 - dev->valid = false; 902 - 903 return 0; 904 } 905
··· 136 #define ATP_GEYSER_MODE_REQUEST_INDEX 0 137 #define ATP_GEYSER_MODE_VENDOR_VALUE 0x04 138 139 + /** 140 + * enum atp_status_bits - status bit meanings 141 + * 142 + * These constants represent the meaning of the status bits. 143 + * (only Geyser 3/4) 144 + * 145 + * @ATP_STATUS_BUTTON: The button was pressed 146 + * @ATP_STATUS_BASE_UPDATE: Update of the base values (untouched pad) 147 + * @ATP_STATUS_FROM_RESET: Reset previously performed 148 + */ 149 + enum atp_status_bits { 150 + ATP_STATUS_BUTTON = BIT(0), 151 + ATP_STATUS_BASE_UPDATE = BIT(2), 152 + ATP_STATUS_FROM_RESET = BIT(4), 153 + }; 154 + 155 /* Structure to hold all of our device specific stuff */ 156 struct atp { 157 char phys[64]; 158 struct usb_device *udev; /* usb device */ 159 struct urb *urb; /* usb request block */ 160 + u8 *data; /* transferred data */ 161 struct input_dev *input; /* input dev */ 162 enum atp_touchpad_type type; /* type of touchpad */ 163 bool open; ··· 251 int retval; 252 253 dprintk("appletouch: putting appletouch to sleep (reinit)\n"); 254 atp_geyser_init(udev); 255 256 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); ··· 327 input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); 328 } 329 330 + /* Check URB status and for correct length of data package */ 331 + 332 + #define ATP_URB_STATUS_SUCCESS 0 333 + #define ATP_URB_STATUS_ERROR 1 334 + #define ATP_URB_STATUS_ERROR_FATAL 2 335 + 336 + static int atp_status_check(struct urb *urb) 337 { 338 struct atp *dev = urb->context; 339 340 switch (urb->status) { ··· 351 /* This urb is terminated, clean up */ 352 dbg("atp_complete: urb shutting down with status: %d", 353 urb->status); 354 + return ATP_URB_STATUS_ERROR_FATAL; 355 + 356 default: 357 dbg("atp_complete: nonzero urb status received: %d", 358 urb->status); 359 + return ATP_URB_STATUS_ERROR; 360 } 361 362 /* drop incomplete datasets */ ··· 363 dprintk("appletouch: incomplete data package" 364 " (first byte: %d, length: %d).\n", 365 dev->data[0], dev->urb->actual_length); 366 + return ATP_URB_STATUS_ERROR; 367 } 368 369 + return ATP_URB_STATUS_SUCCESS; 370 + } 371 + 372 + /* 373 + * USB interrupt callback functions 374 + */ 375 + 376 + /* Interrupt function for older touchpads: FOUNTAIN/GEYSER1/GEYSER2 */ 377 + 378 + static void atp_complete_geyser_1_2(struct urb *urb) 379 + { 380 + int x, y, x_z, y_z, x_f, y_f; 381 + int retval, i, j; 382 + int key; 383 + struct atp *dev = urb->context; 384 + int status = atp_status_check(urb); 385 + 386 + if (status == ATP_URB_STATUS_ERROR_FATAL) 387 + return; 388 + else if (status == ATP_URB_STATUS_ERROR) 389 + goto exit; 390 + 391 /* reorder the sensors values */ 392 + if (dev->type == ATP_GEYSER2) { 393 memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); 394 395 /* ··· 427 /* first sample */ 428 dev->valid = true; 429 dev->x_old = dev->y_old = -1; 430 + 431 + /* Store first sample */ 432 memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); 433 434 + /* Perform size detection, if not done already */ 435 + if (!dev->size_detect_done) { 436 + 437 + /* 17" Powerbooks have extra X sensors */ 438 + for (i = (dev->type == ATP_GEYSER2 ? 15 : 16); 439 + i < ATP_XSENSORS; i++) { 440 + if (!dev->xy_cur[i]) 441 + continue; 442 + 443 + printk(KERN_INFO 444 + "appletouch: 17\" model detected.\n"); 445 + 446 + if (dev->type == ATP_GEYSER2) 447 + input_set_abs_params(dev->input, ABS_X, 448 + 0, 449 + (20 - 1) * 450 + ATP_XFACT - 1, 451 + ATP_FUZZ, 0); 452 + else 453 + input_set_abs_params(dev->input, ABS_X, 454 + 0, 455 + (26 - 1) * 456 + ATP_XFACT - 1, 457 + ATP_FUZZ, 0); 458 + break; 459 + } 460 + 461 + dev->size_detect_done = 1; 462 goto exit; 463 } 464 } 465 466 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { ··· 475 ATP_XFACT, &x_z, &x_f); 476 y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, 477 ATP_YFACT, &y_z, &y_f); 478 + key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON; 479 + 480 + if (x && y) { 481 + if (dev->x_old != -1) { 482 + x = (dev->x_old * 3 + x) >> 2; 483 + y = (dev->y_old * 3 + y) >> 2; 484 + dev->x_old = x; 485 + dev->y_old = y; 486 + 487 + if (debug > 1) 488 + printk(KERN_DEBUG "appletouch: " 489 + "X: %3d Y: %3d Xz: %3d Yz: %3d\n", 490 + x, y, x_z, y_z); 491 + 492 + input_report_key(dev->input, BTN_TOUCH, 1); 493 + input_report_abs(dev->input, ABS_X, x); 494 + input_report_abs(dev->input, ABS_Y, y); 495 + input_report_abs(dev->input, ABS_PRESSURE, 496 + min(ATP_PRESSURE, x_z + y_z)); 497 + atp_report_fingers(dev->input, max(x_f, y_f)); 498 + } 499 + dev->x_old = x; 500 + dev->y_old = y; 501 + 502 + } else if (!x && !y) { 503 + 504 + dev->x_old = dev->y_old = -1; 505 + input_report_key(dev->input, BTN_TOUCH, 0); 506 + input_report_abs(dev->input, ABS_PRESSURE, 0); 507 + atp_report_fingers(dev->input, 0); 508 + 509 + /* reset the accumulator on release */ 510 + memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); 511 + } 512 + 513 + input_report_key(dev->input, BTN_LEFT, key); 514 + input_sync(dev->input); 515 + 516 + exit: 517 + retval = usb_submit_urb(dev->urb, GFP_ATOMIC); 518 + if (retval) 519 + err("atp_complete: usb_submit_urb failed with result %d", 520 + retval); 521 + } 522 + 523 + /* Interrupt function for older touchpads: GEYSER3/GEYSER4 */ 524 + 525 + static void atp_complete_geyser_3_4(struct urb *urb) 526 + { 527 + int x, y, x_z, y_z, x_f, y_f; 528 + int retval, i, j; 529 + int key; 530 + struct atp *dev = urb->context; 531 + int status = atp_status_check(urb); 532 + 533 + if (status == ATP_URB_STATUS_ERROR_FATAL) 534 + return; 535 + else if (status == ATP_URB_STATUS_ERROR) 536 + goto exit; 537 + 538 + /* Reorder the sensors values: 539 + * 540 + * The values are laid out like this: 541 + * -, Y1, Y2, -, Y3, Y4, -, ..., -, X1, X2, -, X3, X4, ... 542 + * '-' is an unused value. 543 + */ 544 + 545 + /* read X values */ 546 + for (i = 0, j = 19; i < 20; i += 2, j += 3) { 547 + dev->xy_cur[i] = dev->data[j + 1]; 548 + dev->xy_cur[i + 1] = dev->data[j + 2]; 549 + } 550 + /* read Y values */ 551 + for (i = 0, j = 1; i < 9; i += 2, j += 3) { 552 + dev->xy_cur[ATP_XSENSORS + i] = dev->data[j + 1]; 553 + dev->xy_cur[ATP_XSENSORS + i + 1] = dev->data[j + 2]; 554 + } 555 + 556 + dbg_dump("sample", dev->xy_cur); 557 + 558 + /* Just update the base values (i.e. touchpad in untouched state) */ 559 + if (dev->data[dev->datalen - 1] & ATP_STATUS_BASE_UPDATE) { 560 + 561 + dprintk(KERN_DEBUG "appletouch: updated base values\n"); 562 + 563 + memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); 564 + goto exit; 565 + } 566 + 567 + for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { 568 + /* calculate the change */ 569 + dev->xy_acc[i] = dev->xy_cur[i] - dev->xy_old[i]; 570 + 571 + /* this is a round-robin value, so couple with that */ 572 + if (dev->xy_acc[i] > 127) 573 + dev->xy_acc[i] -= 256; 574 + 575 + if (dev->xy_acc[i] < -127) 576 + dev->xy_acc[i] += 256; 577 + 578 + /* prevent down drifting */ 579 + if (dev->xy_acc[i] < 0) 580 + dev->xy_acc[i] = 0; 581 + } 582 + 583 + dbg_dump("accumulator", dev->xy_acc); 584 + 585 + x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS, 586 + ATP_XFACT, &x_z, &x_f); 587 + y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, 588 + ATP_YFACT, &y_z, &y_f); 589 + key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON; 590 591 if (x && y) { 592 if (dev->x_old != -1) { ··· 514 input_sync(dev->input); 515 516 /* 517 + * Geysers 3/4 will continue to send packets continually after 518 * the first touch unless reinitialised. Do so if it's been 519 * idle for a while in order to avoid waking the kernel up 520 + * several hundred times a second. 521 */ 522 + 523 + /* 524 + * Button must not be pressed when entering suspend, 525 + * otherwise we will never release the button. 526 + */ 527 + if (!x && !y && !key) { 528 + dev->idlecount++; 529 + if (dev->idlecount == 10) { 530 + dev->x_old = dev->y_old = -1; 531 dev->idlecount = 0; 532 + schedule_work(&dev->work); 533 + /* Don't resubmit urb here, wait for reinit */ 534 + return; 535 + } 536 + } else 537 + dev->idlecount = 0; 538 539 exit: 540 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); ··· 632 if (!dev->data) 633 goto err_free_urb; 634 635 + /* Select the USB complete (callback) function */ 636 + if (dev->type == ATP_FOUNTAIN || 637 + dev->type == ATP_GEYSER1 || 638 + dev->type == ATP_GEYSER2) 639 + usb_fill_int_urb(dev->urb, udev, 640 + usb_rcvintpipe(udev, int_in_endpointAddr), 641 + dev->data, dev->datalen, 642 + atp_complete_geyser_1_2, dev, 1); 643 + else 644 + usb_fill_int_urb(dev->urb, udev, 645 + usb_rcvintpipe(udev, int_in_endpointAddr), 646 + dev->data, dev->datalen, 647 + atp_complete_geyser_3_4, dev, 1); 648 649 error = atp_handle_geyser(dev); 650 if (error) ··· 751 struct atp *dev = usb_get_intfdata(iface); 752 753 usb_kill_urb(dev->urb); 754 return 0; 755 } 756
+477
drivers/input/mouse/hgpk.c
···
··· 1 + /* 2 + * OLPC HGPK (XO-1) touchpad PS/2 mouse driver 3 + * 4 + * Copyright (c) 2006-2008 One Laptop Per Child 5 + * Authors: 6 + * Zephaniah E. Hull 7 + * Andres Salomon <dilinger@debian.org> 8 + * 9 + * This driver is partly based on the ALPS driver, which is: 10 + * 11 + * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au> 12 + * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com> 13 + * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru> 14 + * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> 15 + * 16 + * This program is free software; you can redistribute it and/or modify 17 + * it under the terms of the GNU General Public License version 2 as 18 + * published by the Free Software Foundation. 19 + */ 20 + 21 + /* 22 + * The spec from ALPS is available from 23 + * <http://wiki.laptop.org/go/Touch_Pad/Tablet>. It refers to this 24 + * device as HGPK (Hybrid GS, PT, and Keymatrix). 25 + * 26 + * The earliest versions of the device had simultaneous reporting; that 27 + * was removed. After that, the device used the Advanced Mode GS/PT streaming 28 + * stuff. That turned out to be too buggy to support, so we've finally 29 + * switched to Mouse Mode (which utilizes only the center 1/3 of the touchpad). 30 + */ 31 + 32 + #define DEBUG 33 + #include <linux/input.h> 34 + #include <linux/serio.h> 35 + #include <linux/libps2.h> 36 + #include <linux/delay.h> 37 + #include <asm/olpc.h> 38 + 39 + #include "psmouse.h" 40 + #include "hgpk.h" 41 + 42 + static int tpdebug; 43 + module_param(tpdebug, int, 0644); 44 + MODULE_PARM_DESC(tpdebug, "enable debugging, dumping packets to KERN_DEBUG."); 45 + 46 + static int recalib_delta = 100; 47 + module_param(recalib_delta, int, 0644); 48 + MODULE_PARM_DESC(recalib_delta, 49 + "packets containing a delta this large will cause a recalibration."); 50 + 51 + /* 52 + * When the touchpad gets ultra-sensitive, one can keep their finger 1/2" 53 + * above the pad and still have it send packets. This causes a jump cursor 54 + * when one places their finger on the pad. We can probably detect the 55 + * jump as we see a large deltas (>= 100px). In mouse mode, I've been 56 + * unable to even come close to 100px deltas during normal usage, so I think 57 + * this threshold is safe. If a large delta occurs, trigger a recalibration. 58 + */ 59 + static void hgpk_jumpy_hack(struct psmouse *psmouse, int x, int y) 60 + { 61 + struct hgpk_data *priv = psmouse->private; 62 + 63 + if (abs(x) > recalib_delta || abs(y) > recalib_delta) { 64 + hgpk_err(psmouse, ">%dpx jump detected (%d,%d)\n", 65 + recalib_delta, x, y); 66 + /* My car gets forty rods to the hogshead and that's the 67 + * way I likes it! */ 68 + psmouse_queue_work(psmouse, &priv->recalib_wq, 69 + msecs_to_jiffies(1000)); 70 + } 71 + } 72 + 73 + /* 74 + * We have no idea why this particular hardware bug occurs. The touchpad 75 + * will randomly start spewing packets without anything touching the 76 + * pad. This wouldn't necessarily be bad, but it's indicative of a 77 + * severely miscalibrated pad; attempting to use the touchpad while it's 78 + * spewing means the cursor will jump all over the place, and act "drunk". 79 + * 80 + * The packets that are spewed tend to all have deltas between -2 and 2, and 81 + * the cursor will move around without really going very far. It will 82 + * tend to end up in the same location; if we tally up the changes over 83 + * 100 packets, we end up w/ a final delta of close to 0. This happens 84 + * pretty regularly when the touchpad is spewing, and is pretty hard to 85 + * manually trigger (at least for *my* fingers). So, it makes a perfect 86 + * scheme for detecting spews. 87 + */ 88 + static void hgpk_spewing_hack(struct psmouse *psmouse, 89 + int l, int r, int x, int y) 90 + { 91 + struct hgpk_data *priv = psmouse->private; 92 + 93 + /* ignore button press packets; many in a row could trigger 94 + * a false-positive! */ 95 + if (l || r) 96 + return; 97 + 98 + priv->x_tally += x; 99 + priv->y_tally += y; 100 + 101 + if (++priv->count > 100) { 102 + if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) { 103 + hgpk_dbg(psmouse, "packet spew detected (%d,%d)\n", 104 + priv->x_tally, priv->y_tally); 105 + psmouse_queue_work(psmouse, &priv->recalib_wq, 106 + msecs_to_jiffies(1000)); 107 + } 108 + /* reset every 100 packets */ 109 + priv->count = 0; 110 + priv->x_tally = 0; 111 + priv->y_tally = 0; 112 + } 113 + } 114 + 115 + /* 116 + * HGPK Mouse Mode format (standard mouse format, sans middle button) 117 + * 118 + * byte 0: y-over x-over y-neg x-neg 1 0 swr swl 119 + * byte 1: x7 x6 x5 x4 x3 x2 x1 x0 120 + * byte 2: y7 y6 y5 y4 y3 y2 y1 y0 121 + * 122 + * swr/swl are the left/right buttons. 123 + * x-neg/y-neg are the x and y delta negative bits 124 + * x-over/y-over are the x and y overflow bits 125 + */ 126 + static int hgpk_validate_byte(unsigned char *packet) 127 + { 128 + return (packet[0] & 0x0C) == 0x08; 129 + } 130 + 131 + static void hgpk_process_packet(struct psmouse *psmouse) 132 + { 133 + struct input_dev *dev = psmouse->dev; 134 + unsigned char *packet = psmouse->packet; 135 + int x, y, left, right; 136 + 137 + left = packet[0] & 1; 138 + right = (packet[0] >> 1) & 1; 139 + 140 + x = packet[1] - ((packet[0] << 4) & 0x100); 141 + y = ((packet[0] << 3) & 0x100) - packet[2]; 142 + 143 + hgpk_jumpy_hack(psmouse, x, y); 144 + hgpk_spewing_hack(psmouse, left, right, x, y); 145 + 146 + if (tpdebug) 147 + hgpk_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", left, right, x, y); 148 + 149 + input_report_key(dev, BTN_LEFT, left); 150 + input_report_key(dev, BTN_RIGHT, right); 151 + 152 + input_report_rel(dev, REL_X, x); 153 + input_report_rel(dev, REL_Y, y); 154 + 155 + input_sync(dev); 156 + } 157 + 158 + static psmouse_ret_t hgpk_process_byte(struct psmouse *psmouse) 159 + { 160 + struct hgpk_data *priv = psmouse->private; 161 + 162 + if (hgpk_validate_byte(psmouse->packet)) { 163 + hgpk_dbg(psmouse, "%s: (%d) %02x %02x %02x\n", 164 + __func__, psmouse->pktcnt, psmouse->packet[0], 165 + psmouse->packet[1], psmouse->packet[2]); 166 + return PSMOUSE_BAD_DATA; 167 + } 168 + 169 + if (psmouse->pktcnt >= psmouse->pktsize) { 170 + hgpk_process_packet(psmouse); 171 + return PSMOUSE_FULL_PACKET; 172 + } 173 + 174 + if (priv->recalib_window) { 175 + if (time_before(jiffies, priv->recalib_window)) { 176 + /* 177 + * ugh, got a packet inside our recalibration 178 + * window, schedule another recalibration. 179 + */ 180 + hgpk_dbg(psmouse, 181 + "packet inside calibration window, " 182 + "queueing another recalibration\n"); 183 + psmouse_queue_work(psmouse, &priv->recalib_wq, 184 + msecs_to_jiffies(1000)); 185 + } 186 + priv->recalib_window = 0; 187 + } 188 + 189 + return PSMOUSE_GOOD_DATA; 190 + } 191 + 192 + static int hgpk_force_recalibrate(struct psmouse *psmouse) 193 + { 194 + struct ps2dev *ps2dev = &psmouse->ps2dev; 195 + struct hgpk_data *priv = psmouse->private; 196 + 197 + /* C-series touchpads added the recalibrate command */ 198 + if (psmouse->model < HGPK_MODEL_C) 199 + return 0; 200 + 201 + /* we don't want to race with the irq handler, nor with resyncs */ 202 + psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 203 + 204 + /* start by resetting the device */ 205 + psmouse_reset(psmouse); 206 + 207 + /* send the recalibrate request */ 208 + if (ps2_command(ps2dev, NULL, 0xf5) || 209 + ps2_command(ps2dev, NULL, 0xf5) || 210 + ps2_command(ps2dev, NULL, 0xe6) || 211 + ps2_command(ps2dev, NULL, 0xf5)) { 212 + return -1; 213 + } 214 + 215 + /* according to ALPS, 150mS is required for recalibration */ 216 + msleep(150); 217 + 218 + /* XXX: If a finger is down during this delay, recalibration will 219 + * detect capacitance incorrectly. This is a hardware bug, and 220 + * we don't have a good way to deal with it. The 2s window stuff 221 + * (below) is our best option for now. 222 + */ 223 + 224 + if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) 225 + return -1; 226 + 227 + psmouse_set_state(psmouse, PSMOUSE_ACTIVATED); 228 + 229 + /* After we recalibrate, we shouldn't get any packets for 2s. If 230 + * we do, it's likely that someone's finger was on the touchpad. 231 + * If someone's finger *was* on the touchpad, it's probably 232 + * miscalibrated. So, we should schedule another recalibration 233 + */ 234 + priv->recalib_window = jiffies + msecs_to_jiffies(2000); 235 + 236 + return 0; 237 + } 238 + 239 + /* 240 + * This kills power to the touchpad; according to ALPS, current consumption 241 + * goes down to 50uA after running this. To turn power back on, we drive 242 + * MS-DAT low. 243 + */ 244 + static int hgpk_toggle_power(struct psmouse *psmouse, int enable) 245 + { 246 + struct ps2dev *ps2dev = &psmouse->ps2dev; 247 + int timeo; 248 + 249 + /* Added on D-series touchpads */ 250 + if (psmouse->model < HGPK_MODEL_D) 251 + return 0; 252 + 253 + if (enable) { 254 + psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 255 + 256 + /* 257 + * Sending a byte will drive MS-DAT low; this will wake up 258 + * the controller. Once we get an ACK back from it, it 259 + * means we can continue with the touchpad re-init. ALPS 260 + * tells us that 1s should be long enough, so set that as 261 + * the upper bound. 262 + */ 263 + for (timeo = 20; timeo > 0; timeo--) { 264 + if (!ps2_sendbyte(&psmouse->ps2dev, 265 + PSMOUSE_CMD_DISABLE, 20)) 266 + break; 267 + msleep(50); 268 + } 269 + 270 + psmouse_reset(psmouse); 271 + 272 + /* should be all set, enable the touchpad */ 273 + ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE); 274 + psmouse_set_state(psmouse, PSMOUSE_ACTIVATED); 275 + 276 + } else { 277 + hgpk_dbg(psmouse, "Powering off touchpad.\n"); 278 + psmouse_set_state(psmouse, PSMOUSE_IGNORE); 279 + 280 + if (ps2_command(ps2dev, NULL, 0xec) || 281 + ps2_command(ps2dev, NULL, 0xec) || 282 + ps2_command(ps2dev, NULL, 0xea)) { 283 + return -1; 284 + } 285 + 286 + /* probably won't see an ACK, the touchpad will be off */ 287 + ps2_sendbyte(&psmouse->ps2dev, 0xec, 20); 288 + } 289 + 290 + return 0; 291 + } 292 + 293 + static int hgpk_poll(struct psmouse *psmouse) 294 + { 295 + /* We can't poll, so always return failure. */ 296 + return -1; 297 + } 298 + 299 + static int hgpk_reconnect(struct psmouse *psmouse) 300 + { 301 + /* During suspend/resume the ps2 rails remain powered. We don't want 302 + * to do a reset because it's flush data out of buffers; however, 303 + * earlier prototypes (B1) had some brokenness that required a reset. */ 304 + if (olpc_board_at_least(olpc_board(0xb2))) 305 + if (psmouse->ps2dev.serio->dev.power.power_state.event != 306 + PM_EVENT_ON) 307 + return 0; 308 + 309 + psmouse_reset(psmouse); 310 + 311 + return 0; 312 + } 313 + 314 + static ssize_t hgpk_show_powered(struct psmouse *psmouse, void *data, char *buf) 315 + { 316 + struct hgpk_data *priv = psmouse->private; 317 + 318 + return sprintf(buf, "%d\n", priv->powered); 319 + } 320 + 321 + static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data, 322 + const char *buf, size_t count) 323 + { 324 + struct hgpk_data *priv = psmouse->private; 325 + unsigned long value; 326 + int err; 327 + 328 + err = strict_strtoul(buf, 10, &value); 329 + if (err || value > 1) 330 + return -EINVAL; 331 + 332 + if (value != priv->powered) { 333 + /* 334 + * hgpk_toggle_power will deal w/ state so 335 + * we're not racing w/ irq 336 + */ 337 + err = hgpk_toggle_power(psmouse, value); 338 + if (!err) 339 + priv->powered = value; 340 + } 341 + 342 + return err ? err : count; 343 + } 344 + 345 + __PSMOUSE_DEFINE_ATTR(powered, S_IWUSR | S_IRUGO, NULL, 346 + hgpk_show_powered, hgpk_set_powered, 0); 347 + 348 + static void hgpk_disconnect(struct psmouse *psmouse) 349 + { 350 + struct hgpk_data *priv = psmouse->private; 351 + 352 + device_remove_file(&psmouse->ps2dev.serio->dev, 353 + &psmouse_attr_powered.dattr); 354 + psmouse_reset(psmouse); 355 + kfree(priv); 356 + } 357 + 358 + static void hgpk_recalib_work(struct work_struct *work) 359 + { 360 + struct delayed_work *w = container_of(work, struct delayed_work, work); 361 + struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq); 362 + struct psmouse *psmouse = priv->psmouse; 363 + 364 + hgpk_dbg(psmouse, "recalibrating touchpad..\n"); 365 + 366 + if (hgpk_force_recalibrate(psmouse)) 367 + hgpk_err(psmouse, "recalibration failed!\n"); 368 + } 369 + 370 + static int hgpk_register(struct psmouse *psmouse) 371 + { 372 + struct input_dev *dev = psmouse->dev; 373 + int err; 374 + 375 + /* unset the things that psmouse-base sets which we don't have */ 376 + __clear_bit(BTN_MIDDLE, dev->keybit); 377 + 378 + /* set the things we do have */ 379 + __set_bit(EV_KEY, dev->evbit); 380 + __set_bit(EV_REL, dev->evbit); 381 + 382 + __set_bit(REL_X, dev->relbit); 383 + __set_bit(REL_Y, dev->relbit); 384 + 385 + __set_bit(BTN_LEFT, dev->keybit); 386 + __set_bit(BTN_RIGHT, dev->keybit); 387 + 388 + /* register handlers */ 389 + psmouse->protocol_handler = hgpk_process_byte; 390 + psmouse->poll = hgpk_poll; 391 + psmouse->disconnect = hgpk_disconnect; 392 + psmouse->reconnect = hgpk_reconnect; 393 + psmouse->pktsize = 3; 394 + 395 + /* Disable the idle resync. */ 396 + psmouse->resync_time = 0; 397 + /* Reset after a lot of bad bytes. */ 398 + psmouse->resetafter = 1024; 399 + 400 + err = device_create_file(&psmouse->ps2dev.serio->dev, 401 + &psmouse_attr_powered.dattr); 402 + if (err) 403 + hgpk_err(psmouse, "Failed to create sysfs attribute\n"); 404 + 405 + return err; 406 + } 407 + 408 + int hgpk_init(struct psmouse *psmouse) 409 + { 410 + struct hgpk_data *priv; 411 + int err = -ENOMEM; 412 + 413 + priv = kzalloc(sizeof(struct hgpk_data), GFP_KERNEL); 414 + if (!priv) 415 + goto alloc_fail; 416 + 417 + psmouse->private = priv; 418 + priv->psmouse = psmouse; 419 + priv->powered = 1; 420 + INIT_DELAYED_WORK(&priv->recalib_wq, hgpk_recalib_work); 421 + 422 + err = psmouse_reset(psmouse); 423 + if (err) 424 + goto init_fail; 425 + 426 + err = hgpk_register(psmouse); 427 + if (err) 428 + goto init_fail; 429 + 430 + return 0; 431 + 432 + init_fail: 433 + kfree(priv); 434 + alloc_fail: 435 + return err; 436 + } 437 + 438 + static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse) 439 + { 440 + struct ps2dev *ps2dev = &psmouse->ps2dev; 441 + unsigned char param[3]; 442 + 443 + /* E7, E7, E7, E9 gets us a 3 byte identifier */ 444 + if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || 445 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || 446 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || 447 + ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { 448 + return -EIO; 449 + } 450 + 451 + hgpk_dbg(psmouse, "ID: %02x %02x %02x", param[0], param[1], param[2]); 452 + 453 + /* HGPK signature: 0x67, 0x00, 0x<model> */ 454 + if (param[0] != 0x67 || param[1] != 0x00) 455 + return -ENODEV; 456 + 457 + hgpk_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]); 458 + 459 + return param[2]; 460 + } 461 + 462 + int hgpk_detect(struct psmouse *psmouse, int set_properties) 463 + { 464 + int version; 465 + 466 + version = hgpk_get_model(psmouse); 467 + if (version < 0) 468 + return version; 469 + 470 + if (set_properties) { 471 + psmouse->vendor = "ALPS"; 472 + psmouse->name = "HGPK"; 473 + psmouse->model = version; 474 + } 475 + 476 + return 0; 477 + }
+49
drivers/input/mouse/hgpk.h
···
··· 1 + /* 2 + * OLPC HGPK (XO-1) touchpad PS/2 mouse driver 3 + */ 4 + 5 + #ifndef _HGPK_H 6 + #define _HGPK_H 7 + 8 + enum hgpk_model_t { 9 + HGPK_MODEL_PREA = 0x0a, /* pre-B1s */ 10 + HGPK_MODEL_A = 0x14, /* found on B1s, PT disabled in hardware */ 11 + HGPK_MODEL_B = 0x28, /* B2s, has capacitance issues */ 12 + HGPK_MODEL_C = 0x3c, 13 + HGPK_MODEL_D = 0x50, /* C1, mass production */ 14 + }; 15 + 16 + struct hgpk_data { 17 + struct psmouse *psmouse; 18 + int powered; 19 + int count, x_tally, y_tally; /* hardware workaround stuff */ 20 + unsigned long recalib_window; 21 + struct delayed_work recalib_wq; 22 + }; 23 + 24 + #define hgpk_dbg(psmouse, format, arg...) \ 25 + dev_dbg(&(psmouse)->ps2dev.serio->dev, format, ## arg) 26 + #define hgpk_err(psmouse, format, arg...) \ 27 + dev_err(&(psmouse)->ps2dev.serio->dev, format, ## arg) 28 + #define hgpk_info(psmouse, format, arg...) \ 29 + dev_info(&(psmouse)->ps2dev.serio->dev, format, ## arg) 30 + #define hgpk_warn(psmouse, format, arg...) \ 31 + dev_warn(&(psmouse)->ps2dev.serio->dev, format, ## arg) 32 + #define hgpk_notice(psmouse, format, arg...) \ 33 + dev_notice(&(psmouse)->ps2dev.serio->dev, format, ## arg) 34 + 35 + #ifdef CONFIG_MOUSE_PS2_OLPC 36 + int hgpk_detect(struct psmouse *psmouse, int set_properties); 37 + int hgpk_init(struct psmouse *psmouse); 38 + #else 39 + static inline int hgpk_detect(struct psmouse *psmouse, int set_properties) 40 + { 41 + return -ENODEV; 42 + } 43 + static inline int hgpk_init(struct psmouse *psmouse) 44 + { 45 + return -ENODEV; 46 + } 47 + #endif 48 + 49 + #endif
+1 -3
drivers/input/mouse/logips2pp.c
··· 157 static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) 158 { 159 unsigned long value; 160 - char *rest; 161 162 - value = simple_strtoul(buf, &rest, 10); 163 - if (*rest || value > 1) 164 return -EINVAL; 165 166 ps2pp_set_smartscroll(psmouse, value);
··· 157 static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) 158 { 159 unsigned long value; 160 161 + if (strict_strtoul(buf, 10, &value) || value > 1) 162 return -EINVAL; 163 164 ps2pp_set_smartscroll(psmouse, value);
+53 -28
drivers/input/mouse/psmouse-base.c
··· 25 #include "synaptics.h" 26 #include "logips2pp.h" 27 #include "alps.h" 28 #include "lifebook.h" 29 #include "trackpoint.h" 30 #include "touchkit_ps2.h" ··· 202 return PSMOUSE_FULL_PACKET; 203 } 204 205 /* 206 * __psmouse_set_state() sets new psmouse state and resets all flags. 207 */ ··· 227 * is not a concern. 228 */ 229 230 - static void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 231 { 232 serio_pause_rx(psmouse->ps2dev.serio); 233 __psmouse_set_state(psmouse, new_state); ··· 312 psmouse->name, psmouse->phys, psmouse->pktcnt); 313 psmouse->badbyte = psmouse->packet[0]; 314 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 315 - queue_work(kpsmoused_wq, &psmouse->resync_work); 316 goto out; 317 } 318 ··· 349 time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) { 350 psmouse->badbyte = psmouse->packet[0]; 351 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 352 - queue_work(kpsmoused_wq, &psmouse->resync_work); 353 goto out; 354 } 355 ··· 637 } 638 } 639 640 - if (max_proto > PSMOUSE_IMEX) { 641 642 if (genius_detect(psmouse, set_properties) == 0) 643 return PSMOUSE_GENPS; 644 ··· 779 .name = "touchkitPS/2", 780 .alias = "touchkit", 781 .detect = touchkit_ps2_detect, 782 }, 783 #endif 784 { ··· 962 static void psmouse_resync(struct work_struct *work) 963 { 964 struct psmouse *parent = NULL, *psmouse = 965 - container_of(work, struct psmouse, resync_work); 966 struct serio *serio = psmouse->ps2dev.serio; 967 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 968 int failed = 0, enabled = 0; ··· 1221 goto err_free; 1222 1223 ps2_init(&psmouse->ps2dev, serio); 1224 - INIT_WORK(&psmouse->resync_work, psmouse_resync); 1225 psmouse->dev = input_dev; 1226 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); 1227 ··· 1422 1423 psmouse = serio_get_drvdata(serio); 1424 1425 - if (psmouse->state == PSMOUSE_IGNORE) { 1426 - retval = -ENODEV; 1427 - goto out_unlock; 1428 - } 1429 1430 - if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1431 - parent = serio_get_drvdata(serio->parent); 1432 - psmouse_deactivate(parent); 1433 - } 1434 1435 - psmouse_deactivate(psmouse); 1436 1437 retval = attr->set(psmouse, attr->data, buf, count); 1438 1439 - if (retval != -ENODEV) 1440 - psmouse_activate(psmouse); 1441 1442 - if (parent) 1443 - psmouse_activate(parent); 1444 1445 out_unlock: 1446 mutex_unlock(&psmouse_mutex); ··· 1464 { 1465 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); 1466 unsigned long value; 1467 - char *rest; 1468 1469 - value = simple_strtoul(buf, &rest, 10); 1470 - if (*rest) 1471 return -EINVAL; 1472 1473 if ((unsigned int)value != value) ··· 1578 static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1579 { 1580 unsigned long value; 1581 - char *rest; 1582 1583 - value = simple_strtoul(buf, &rest, 10); 1584 - if (*rest) 1585 return -EINVAL; 1586 1587 psmouse->set_rate(psmouse, value); ··· 1589 static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1590 { 1591 unsigned long value; 1592 - char *rest; 1593 1594 - value = simple_strtoul(buf, &rest, 10); 1595 - if (*rest) 1596 return -EINVAL; 1597 1598 psmouse->set_resolution(psmouse, value);
··· 25 #include "synaptics.h" 26 #include "logips2pp.h" 27 #include "alps.h" 28 + #include "hgpk.h" 29 #include "lifebook.h" 30 #include "trackpoint.h" 31 #include "touchkit_ps2.h" ··· 201 return PSMOUSE_FULL_PACKET; 202 } 203 204 + void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work, 205 + unsigned long delay) 206 + { 207 + queue_delayed_work(kpsmoused_wq, work, delay); 208 + } 209 + 210 /* 211 * __psmouse_set_state() sets new psmouse state and resets all flags. 212 */ ··· 220 * is not a concern. 221 */ 222 223 + void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 224 { 225 serio_pause_rx(psmouse->ps2dev.serio); 226 __psmouse_set_state(psmouse, new_state); ··· 305 psmouse->name, psmouse->phys, psmouse->pktcnt); 306 psmouse->badbyte = psmouse->packet[0]; 307 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 308 + psmouse_queue_work(psmouse, &psmouse->resync_work, 0); 309 goto out; 310 } 311 ··· 342 time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) { 343 psmouse->badbyte = psmouse->packet[0]; 344 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 345 + psmouse_queue_work(psmouse, &psmouse->resync_work, 0); 346 goto out; 347 } 348 ··· 630 } 631 } 632 633 + /* 634 + * Try OLPC HGPK touchpad. 635 + */ 636 + if (max_proto > PSMOUSE_IMEX && 637 + hgpk_detect(psmouse, set_properties) == 0) { 638 + if (!set_properties || hgpk_init(psmouse) == 0) 639 + return PSMOUSE_HGPK; 640 + /* 641 + * Init failed, try basic relative protocols 642 + */ 643 + max_proto = PSMOUSE_IMEX; 644 + } 645 646 + if (max_proto > PSMOUSE_IMEX) { 647 if (genius_detect(psmouse, set_properties) == 0) 648 return PSMOUSE_GENPS; 649 ··· 760 .name = "touchkitPS/2", 761 .alias = "touchkit", 762 .detect = touchkit_ps2_detect, 763 + }, 764 + #endif 765 + #ifdef CONFIG_MOUSE_PS2_OLPC 766 + { 767 + .type = PSMOUSE_HGPK, 768 + .name = "OLPC HGPK", 769 + .alias = "hgpk", 770 + .detect = hgpk_detect, 771 }, 772 #endif 773 { ··· 935 static void psmouse_resync(struct work_struct *work) 936 { 937 struct psmouse *parent = NULL, *psmouse = 938 + container_of(work, struct psmouse, resync_work.work); 939 struct serio *serio = psmouse->ps2dev.serio; 940 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 941 int failed = 0, enabled = 0; ··· 1194 goto err_free; 1195 1196 ps2_init(&psmouse->ps2dev, serio); 1197 + INIT_DELAYED_WORK(&psmouse->resync_work, psmouse_resync); 1198 psmouse->dev = input_dev; 1199 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); 1200 ··· 1395 1396 psmouse = serio_get_drvdata(serio); 1397 1398 + if (attr->protect) { 1399 + if (psmouse->state == PSMOUSE_IGNORE) { 1400 + retval = -ENODEV; 1401 + goto out_unlock; 1402 + } 1403 1404 + if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1405 + parent = serio_get_drvdata(serio->parent); 1406 + psmouse_deactivate(parent); 1407 + } 1408 1409 + psmouse_deactivate(psmouse); 1410 + } 1411 1412 retval = attr->set(psmouse, attr->data, buf, count); 1413 1414 + if (attr->protect) { 1415 + if (retval != -ENODEV) 1416 + psmouse_activate(psmouse); 1417 1418 + if (parent) 1419 + psmouse_activate(parent); 1420 + } 1421 1422 out_unlock: 1423 mutex_unlock(&psmouse_mutex); ··· 1433 { 1434 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); 1435 unsigned long value; 1436 1437 + if (strict_strtoul(buf, 10, &value)) 1438 return -EINVAL; 1439 1440 if ((unsigned int)value != value) ··· 1549 static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1550 { 1551 unsigned long value; 1552 1553 + if (strict_strtoul(buf, 10, &value)) 1554 return -EINVAL; 1555 1556 psmouse->set_rate(psmouse, value); ··· 1562 static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1563 { 1564 unsigned long value; 1565 1566 + if (strict_strtoul(buf, 10, &value)) 1567 return -EINVAL; 1568 1569 psmouse->set_resolution(psmouse, value);
+11 -3
drivers/input/mouse/psmouse.h
··· 39 void *private; 40 struct input_dev *dev; 41 struct ps2dev ps2dev; 42 - struct work_struct resync_work; 43 char *vendor; 44 char *name; 45 unsigned char packet[8]; ··· 89 PSMOUSE_TRACKPOINT, 90 PSMOUSE_TOUCHKIT_PS2, 91 PSMOUSE_CORTRON, 92 PSMOUSE_AUTO /* This one should always be last */ 93 }; 94 95 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); 96 int psmouse_reset(struct psmouse *psmouse); 97 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); 98 - 99 100 struct psmouse_attribute { 101 struct device_attribute dattr; ··· 106 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); 107 ssize_t (*set)(struct psmouse *psmouse, void *data, 108 const char *buf, size_t count); 109 }; 110 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) 111 ··· 115 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, 116 const char *buf, size_t count); 117 118 - #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ 119 static ssize_t _show(struct psmouse *, void *data, char *); \ 120 static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ 121 static struct psmouse_attribute psmouse_attr_##_name = { \ ··· 130 .data = _data, \ 131 .show = _show, \ 132 .set = _set, \ 133 } 134 135 #endif /* _PSMOUSE_H */
··· 39 void *private; 40 struct input_dev *dev; 41 struct ps2dev ps2dev; 42 + struct delayed_work resync_work; 43 char *vendor; 44 char *name; 45 unsigned char packet[8]; ··· 89 PSMOUSE_TRACKPOINT, 90 PSMOUSE_TOUCHKIT_PS2, 91 PSMOUSE_CORTRON, 92 + PSMOUSE_HGPK, 93 PSMOUSE_AUTO /* This one should always be last */ 94 }; 95 96 + void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work, 97 + unsigned long delay); 98 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); 99 int psmouse_reset(struct psmouse *psmouse); 100 + void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state); 101 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); 102 103 struct psmouse_attribute { 104 struct device_attribute dattr; ··· 103 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); 104 ssize_t (*set)(struct psmouse *psmouse, void *data, 105 const char *buf, size_t count); 106 + int protect; 107 }; 108 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) 109 ··· 111 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, 112 const char *buf, size_t count); 113 114 + #define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \ 115 static ssize_t _show(struct psmouse *, void *data, char *); \ 116 static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ 117 static struct psmouse_attribute psmouse_attr_##_name = { \ ··· 126 .data = _data, \ 127 .show = _show, \ 128 .set = _set, \ 129 + .protect = _protect, \ 130 } 131 + 132 + #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ 133 + __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, 1) 134 135 #endif /* _PSMOUSE_H */
+2 -6
drivers/input/mouse/trackpoint.c
··· 89 struct trackpoint_attr_data *attr = data; 90 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 91 unsigned long value; 92 - char *rest; 93 94 - value = simple_strtoul(buf, &rest, 10); 95 - if (*rest || value > 255) 96 return -EINVAL; 97 98 *field = value; ··· 115 struct trackpoint_attr_data *attr = data; 116 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 117 unsigned long value; 118 - char *rest; 119 120 - value = simple_strtoul(buf, &rest, 10); 121 - if (*rest || value > 1) 122 return -EINVAL; 123 124 if (attr->inverted)
··· 89 struct trackpoint_attr_data *attr = data; 90 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 91 unsigned long value; 92 93 + if (strict_strtoul(buf, 10, &value) || value > 255) 94 return -EINVAL; 95 96 *field = value; ··· 117 struct trackpoint_attr_data *attr = data; 118 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 119 unsigned long value; 120 121 + if (strict_strtoul(buf, 10, &value) || value > 1) 122 return -EINVAL; 123 124 if (attr->inverted)
+7
drivers/input/serio/i8042-x86ia64io.h
··· 322 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"), 323 }, 324 }, 325 { } 326 }; 327
··· 322 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"), 323 }, 324 }, 325 + { 326 + .ident = "IBM 2656", 327 + .matches = { 328 + DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 329 + DMI_MATCH(DMI_PRODUCT_NAME, "2656"), 330 + }, 331 + }, 332 { } 333 }; 334
+6
drivers/input/serio/serio_raw.c
··· 373 .id = SERIO_ANY, 374 .extra = SERIO_ANY, 375 }, 376 { 0 } 377 }; 378
··· 373 .id = SERIO_ANY, 374 .extra = SERIO_ANY, 375 }, 376 + { 377 + .type = SERIO_8042_XL, 378 + .proto = SERIO_ANY, 379 + .id = SERIO_ANY, 380 + .extra = SERIO_ANY, 381 + }, 382 { 0 } 383 }; 384
+38 -15
drivers/input/tablet/aiptek.c
··· 1202 store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1203 { 1204 struct aiptek *aiptek = dev_get_drvdata(dev); 1205 - int x; 1206 1207 - if (strcmp(buf, "disable") == 0) { 1208 aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; 1209 } else { 1210 - x = (int)simple_strtol(buf, NULL, 10); 1211 - if (x >= AIPTEK_TILT_MIN && x <= AIPTEK_TILT_MAX) { 1212 - aiptek->newSetting.xTilt = x; 1213 - } 1214 } 1215 return count; 1216 } 1217 ··· 1244 store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1245 { 1246 struct aiptek *aiptek = dev_get_drvdata(dev); 1247 - int y; 1248 1249 - if (strcmp(buf, "disable") == 0) { 1250 aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; 1251 } else { 1252 - y = (int)simple_strtol(buf, NULL, 10); 1253 - if (y >= AIPTEK_TILT_MIN && y <= AIPTEK_TILT_MAX) { 1254 - aiptek->newSetting.yTilt = y; 1255 - } 1256 } 1257 return count; 1258 } 1259 ··· 1281 store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1282 { 1283 struct aiptek *aiptek = dev_get_drvdata(dev); 1284 1285 - aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10); 1286 return count; 1287 } 1288 ··· 1310 store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1311 { 1312 struct aiptek *aiptek = dev_get_drvdata(dev); 1313 1314 - aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10); 1315 return count; 1316 } 1317 ··· 1561 store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1562 { 1563 struct aiptek *aiptek = dev_get_drvdata(dev); 1564 1565 - aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10); 1566 return count; 1567 } 1568
··· 1202 store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1203 { 1204 struct aiptek *aiptek = dev_get_drvdata(dev); 1205 + long x; 1206 1207 + if (strict_strtol(buf, 10, &x)) { 1208 + size_t len = buf[count - 1] == '\n' ? count - 1 : count; 1209 + 1210 + if (strncmp(buf, "disable", len)) 1211 + return -EINVAL; 1212 + 1213 aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; 1214 } else { 1215 + if (x < AIPTEK_TILT_MIN || x > AIPTEK_TILT_MAX) 1216 + return -EINVAL; 1217 + 1218 + aiptek->newSetting.xTilt = x; 1219 } 1220 + 1221 return count; 1222 } 1223 ··· 1238 store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1239 { 1240 struct aiptek *aiptek = dev_get_drvdata(dev); 1241 + long y; 1242 1243 + if (strict_strtol(buf, 10, &y)) { 1244 + size_t len = buf[count - 1] == '\n' ? count - 1 : count; 1245 + 1246 + if (strncmp(buf, "disable", len)) 1247 + return -EINVAL; 1248 + 1249 aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; 1250 } else { 1251 + if (y < AIPTEK_TILT_MIN || y > AIPTEK_TILT_MAX) 1252 + return -EINVAL; 1253 + 1254 + aiptek->newSetting.yTilt = y; 1255 } 1256 + 1257 return count; 1258 } 1259 ··· 1269 store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1270 { 1271 struct aiptek *aiptek = dev_get_drvdata(dev); 1272 + long j; 1273 1274 + if (strict_strtol(buf, 10, &j)) 1275 + return -EINVAL; 1276 + 1277 + aiptek->newSetting.jitterDelay = (int)j; 1278 return count; 1279 } 1280 ··· 1294 store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1295 { 1296 struct aiptek *aiptek = dev_get_drvdata(dev); 1297 + long d; 1298 1299 + if (strict_strtol(buf, 10, &d)) 1300 + return -EINVAL; 1301 + 1302 + aiptek->newSetting.programmableDelay = (int)d; 1303 return count; 1304 } 1305 ··· 1541 store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1542 { 1543 struct aiptek *aiptek = dev_get_drvdata(dev); 1544 + long w; 1545 1546 + if (strict_strtol(buf, 10, &w)) return -EINVAL; 1547 + 1548 + aiptek->newSetting.wheel = (int)w; 1549 return count; 1550 } 1551
+109 -53
drivers/input/touchscreen/ads7846.c
··· 24 #include <linux/input.h> 25 #include <linux/interrupt.h> 26 #include <linux/slab.h> 27 #include <linux/spi/spi.h> 28 #include <linux/spi/ads7846.h> 29 #include <asm/irq.h> ··· 69 int ignore; 70 }; 71 72 struct ads7846 { 73 struct input_dev *input; 74 char phys[32]; ··· 97 u16 x_plate_ohms; 98 u16 pressure_max; 99 100 - u8 read_x, read_y, read_z1, read_z2, pwrdown; 101 - u16 dummy; /* for the pwrdown read */ 102 - struct ts_event tc; 103 104 struct spi_transfer xfer[18]; 105 struct spi_message msg[5]; ··· 126 void *filter_data; 127 void (*filter_cleanup)(void *data); 128 int (*get_pendown_state)(void); 129 }; 130 131 /* leave chip selected when we're done, for quicker re-select? */ ··· 472 const char *buf, size_t count) 473 { 474 struct ads7846 *ts = dev_get_drvdata(dev); 475 - char *endp; 476 - int i; 477 478 - i = simple_strtoul(buf, &endp, 10); 479 spin_lock_irq(&ts->lock); 480 481 if (i) ··· 503 504 /*--------------------------------------------------------------------------*/ 505 506 /* 507 * PENIRQ only kicks the timer. The timer only reissues the SPI transfer, 508 * to retrieve touchscreen status. ··· 522 static void ads7846_rx(void *ads) 523 { 524 struct ads7846 *ts = ads; 525 unsigned Rt; 526 u16 x, y, z1, z2; 527 528 /* ads7846_rx_val() did in-place conversion (including byteswap) from 529 * on-the-wire format as part of debouncing to get stable readings. 530 */ 531 - x = ts->tc.x; 532 - y = ts->tc.y; 533 - z1 = ts->tc.z1; 534 - z2 = ts->tc.z2; 535 536 /* range filtering */ 537 if (x == MAX_12BIT) ··· 556 * the maximum. Don't report it to user space, repeat at least 557 * once more the measurement 558 */ 559 - if (ts->tc.ignore || Rt > ts->pressure_max) { 560 #ifdef VERBOSE 561 pr_debug("%s: ignored %d pressure %d\n", 562 - ts->spi->dev.bus_id, ts->tc.ignore, Rt); 563 #endif 564 hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), 565 HRTIMER_MODE_REL); ··· 571 */ 572 if (ts->penirq_recheck_delay_usecs) { 573 udelay(ts->penirq_recheck_delay_usecs); 574 - if (!ts->get_pendown_state()) 575 Rt = 0; 576 } 577 ··· 652 static void ads7846_rx_val(void *ads) 653 { 654 struct ads7846 *ts = ads; 655 struct spi_message *m; 656 struct spi_transfer *t; 657 int val; ··· 672 case ADS7846_FILTER_REPEAT: 673 break; 674 case ADS7846_FILTER_IGNORE: 675 - ts->tc.ignore = 1; 676 /* Last message will contain ads7846_rx() as the 677 * completion function. 678 */ ··· 680 break; 681 case ADS7846_FILTER_OK: 682 *(u16 *)t->rx_buf = val; 683 - ts->tc.ignore = 0; 684 m = &ts->msg[++ts->msg_idx]; 685 break; 686 default: ··· 699 700 spin_lock_irq(&ts->lock); 701 702 - if (unlikely(!ts->get_pendown_state() || 703 device_suspended(&ts->spi->dev))) { 704 if (ts->pendown) { 705 struct input_dev *input = ts->input; ··· 738 unsigned long flags; 739 740 spin_lock_irqsave(&ts->lock, flags); 741 - if (likely(ts->get_pendown_state())) { 742 if (!ts->irq_disabled) { 743 /* The ARM do_simple_IRQ() dispatcher doesn't act 744 * like the other dispatchers: it will report IRQs ··· 785 /* we know the chip's in lowpower mode since we always 786 * leave it that way after every request 787 */ 788 - 789 } 790 791 /* Must be called with ts->lock held */ ··· 827 return 0; 828 } 829 830 static int __devinit ads7846_probe(struct spi_device *spi) 831 { 832 struct ads7846 *ts; 833 struct input_dev *input_dev; 834 struct ads7846_platform_data *pdata = spi->dev.platform_data; 835 struct spi_message *m; ··· 885 return -EINVAL; 886 } 887 888 - /* REVISIT when the irq can be triggered active-low, or if for some 889 - * reason the touchscreen isn't hooked up, we don't need to access 890 - * the pendown state. 891 - */ 892 - if (pdata->get_pendown_state == NULL) { 893 - dev_dbg(&spi->dev, "no get_pendown_state function?\n"); 894 - return -EINVAL; 895 - } 896 - 897 /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except 898 * that even if the hardware can do that, the SPI controller driver 899 * may not. So we stick to very-portable 8 bit words, both RX and TX. ··· 896 return err; 897 898 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); 899 input_dev = input_allocate_device(); 900 - if (!ts || !input_dev) { 901 err = -ENOMEM; 902 goto err_free_mem; 903 } 904 905 dev_set_drvdata(&spi->dev, ts); 906 907 ts->spi = spi; 908 ts->input = input_dev; 909 ts->vref_mv = pdata->vref_mv; ··· 938 ts->filter_data = ts; 939 } else 940 ts->filter = ads7846_no_filter; 941 - ts->get_pendown_state = pdata->get_pendown_state; 942 943 if (pdata->penirq_recheck_delay_usecs) 944 ts->penirq_recheck_delay_usecs = ··· 977 spi_message_init(m); 978 979 /* y- still on; turn on only y+ (and ADC) */ 980 - ts->read_y = READ_Y(vref); 981 - x->tx_buf = &ts->read_y; 982 x->len = 1; 983 spi_message_add_tail(x, m); 984 985 x++; 986 - x->rx_buf = &ts->tc.y; 987 x->len = 2; 988 spi_message_add_tail(x, m); 989 ··· 995 x->delay_usecs = pdata->settle_delay_usecs; 996 997 x++; 998 - x->tx_buf = &ts->read_y; 999 x->len = 1; 1000 spi_message_add_tail(x, m); 1001 1002 x++; 1003 - x->rx_buf = &ts->tc.y; 1004 x->len = 2; 1005 spi_message_add_tail(x, m); 1006 } ··· 1013 1014 /* turn y- off, x+ on, then leave in lowpower */ 1015 x++; 1016 - ts->read_x = READ_X(vref); 1017 - x->tx_buf = &ts->read_x; 1018 x->len = 1; 1019 spi_message_add_tail(x, m); 1020 1021 x++; 1022 - x->rx_buf = &ts->tc.x; 1023 x->len = 2; 1024 spi_message_add_tail(x, m); 1025 ··· 1028 x->delay_usecs = pdata->settle_delay_usecs; 1029 1030 x++; 1031 - x->tx_buf = &ts->read_x; 1032 x->len = 1; 1033 spi_message_add_tail(x, m); 1034 1035 x++; 1036 - x->rx_buf = &ts->tc.x; 1037 x->len = 2; 1038 spi_message_add_tail(x, m); 1039 } ··· 1047 spi_message_init(m); 1048 1049 x++; 1050 - ts->read_z1 = READ_Z1(vref); 1051 - x->tx_buf = &ts->read_z1; 1052 x->len = 1; 1053 spi_message_add_tail(x, m); 1054 1055 x++; 1056 - x->rx_buf = &ts->tc.z1; 1057 x->len = 2; 1058 spi_message_add_tail(x, m); 1059 ··· 1062 x->delay_usecs = pdata->settle_delay_usecs; 1063 1064 x++; 1065 - x->tx_buf = &ts->read_z1; 1066 x->len = 1; 1067 spi_message_add_tail(x, m); 1068 1069 x++; 1070 - x->rx_buf = &ts->tc.z1; 1071 x->len = 2; 1072 spi_message_add_tail(x, m); 1073 } ··· 1079 spi_message_init(m); 1080 1081 x++; 1082 - ts->read_z2 = READ_Z2(vref); 1083 - x->tx_buf = &ts->read_z2; 1084 x->len = 1; 1085 spi_message_add_tail(x, m); 1086 1087 x++; 1088 - x->rx_buf = &ts->tc.z2; 1089 x->len = 2; 1090 spi_message_add_tail(x, m); 1091 ··· 1094 x->delay_usecs = pdata->settle_delay_usecs; 1095 1096 x++; 1097 - x->tx_buf = &ts->read_z2; 1098 x->len = 1; 1099 spi_message_add_tail(x, m); 1100 1101 x++; 1102 - x->rx_buf = &ts->tc.z2; 1103 x->len = 2; 1104 spi_message_add_tail(x, m); 1105 } ··· 1113 spi_message_init(m); 1114 1115 x++; 1116 - ts->pwrdown = PWRDOWN; 1117 - x->tx_buf = &ts->pwrdown; 1118 x->len = 1; 1119 spi_message_add_tail(x, m); 1120 1121 x++; 1122 - x->rx_buf = &ts->dummy; 1123 x->len = 2; 1124 CS_CHANGE(*x); 1125 spi_message_add_tail(x, m); ··· 1133 spi->dev.driver->name, ts)) { 1134 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1135 err = -EBUSY; 1136 - goto err_cleanup_filter; 1137 } 1138 1139 err = ads784x_hwmon_register(spi, ts); ··· 1164 ads784x_hwmon_unregister(spi, ts); 1165 err_free_irq: 1166 free_irq(spi->irq, ts); 1167 err_cleanup_filter: 1168 if (ts->filter_cleanup) 1169 ts->filter_cleanup(ts->filter_data); 1170 err_free_mem: 1171 input_free_device(input_dev); 1172 kfree(ts); 1173 return err; 1174 } ··· 1192 /* suspend left the IRQ disabled */ 1193 enable_irq(ts->spi->irq); 1194 1195 if (ts->filter_cleanup) 1196 ts->filter_cleanup(ts->filter_data); 1197 1198 kfree(ts); 1199 1200 dev_dbg(&spi->dev, "unregistered touchscreen\n");
··· 24 #include <linux/input.h> 25 #include <linux/interrupt.h> 26 #include <linux/slab.h> 27 + #include <linux/gpio.h> 28 #include <linux/spi/spi.h> 29 #include <linux/spi/ads7846.h> 30 #include <asm/irq.h> ··· 68 int ignore; 69 }; 70 71 + /* 72 + * We allocate this separately to avoid cache line sharing issues when 73 + * driver is used with DMA-based SPI controllers (like atmel_spi) on 74 + * systems where main memory is not DMA-coherent (most non-x86 boards). 75 + */ 76 + struct ads7846_packet { 77 + u8 read_x, read_y, read_z1, read_z2, pwrdown; 78 + u16 dummy; /* for the pwrdown read */ 79 + struct ts_event tc; 80 + }; 81 + 82 struct ads7846 { 83 struct input_dev *input; 84 char phys[32]; ··· 85 u16 x_plate_ohms; 86 u16 pressure_max; 87 88 + struct ads7846_packet *packet; 89 90 struct spi_transfer xfer[18]; 91 struct spi_message msg[5]; ··· 116 void *filter_data; 117 void (*filter_cleanup)(void *data); 118 int (*get_pendown_state)(void); 119 + int gpio_pendown; 120 }; 121 122 /* leave chip selected when we're done, for quicker re-select? */ ··· 461 const char *buf, size_t count) 462 { 463 struct ads7846 *ts = dev_get_drvdata(dev); 464 + long i; 465 466 + if (strict_strtoul(buf, 10, &i)) 467 + return -EINVAL; 468 + 469 spin_lock_irq(&ts->lock); 470 471 if (i) ··· 491 492 /*--------------------------------------------------------------------------*/ 493 494 + static int get_pendown_state(struct ads7846 *ts) 495 + { 496 + if (ts->get_pendown_state) 497 + return ts->get_pendown_state(); 498 + 499 + return !gpio_get_value(ts->gpio_pendown); 500 + } 501 + 502 /* 503 * PENIRQ only kicks the timer. The timer only reissues the SPI transfer, 504 * to retrieve touchscreen status. ··· 502 static void ads7846_rx(void *ads) 503 { 504 struct ads7846 *ts = ads; 505 + struct ads7846_packet *packet = ts->packet; 506 unsigned Rt; 507 u16 x, y, z1, z2; 508 509 /* ads7846_rx_val() did in-place conversion (including byteswap) from 510 * on-the-wire format as part of debouncing to get stable readings. 511 */ 512 + x = packet->tc.x; 513 + y = packet->tc.y; 514 + z1 = packet->tc.z1; 515 + z2 = packet->tc.z2; 516 517 /* range filtering */ 518 if (x == MAX_12BIT) ··· 535 * the maximum. Don't report it to user space, repeat at least 536 * once more the measurement 537 */ 538 + if (packet->tc.ignore || Rt > ts->pressure_max) { 539 #ifdef VERBOSE 540 pr_debug("%s: ignored %d pressure %d\n", 541 + ts->spi->dev.bus_id, packet->tc.ignore, Rt); 542 #endif 543 hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), 544 HRTIMER_MODE_REL); ··· 550 */ 551 if (ts->penirq_recheck_delay_usecs) { 552 udelay(ts->penirq_recheck_delay_usecs); 553 + if (!get_pendown_state(ts)) 554 Rt = 0; 555 } 556 ··· 631 static void ads7846_rx_val(void *ads) 632 { 633 struct ads7846 *ts = ads; 634 + struct ads7846_packet *packet = ts->packet; 635 struct spi_message *m; 636 struct spi_transfer *t; 637 int val; ··· 650 case ADS7846_FILTER_REPEAT: 651 break; 652 case ADS7846_FILTER_IGNORE: 653 + packet->tc.ignore = 1; 654 /* Last message will contain ads7846_rx() as the 655 * completion function. 656 */ ··· 658 break; 659 case ADS7846_FILTER_OK: 660 *(u16 *)t->rx_buf = val; 661 + packet->tc.ignore = 0; 662 m = &ts->msg[++ts->msg_idx]; 663 break; 664 default: ··· 677 678 spin_lock_irq(&ts->lock); 679 680 + if (unlikely(!get_pendown_state(ts) || 681 device_suspended(&ts->spi->dev))) { 682 if (ts->pendown) { 683 struct input_dev *input = ts->input; ··· 716 unsigned long flags; 717 718 spin_lock_irqsave(&ts->lock, flags); 719 + if (likely(get_pendown_state(ts))) { 720 if (!ts->irq_disabled) { 721 /* The ARM do_simple_IRQ() dispatcher doesn't act 722 * like the other dispatchers: it will report IRQs ··· 763 /* we know the chip's in lowpower mode since we always 764 * leave it that way after every request 765 */ 766 } 767 768 /* Must be called with ts->lock held */ ··· 806 return 0; 807 } 808 809 + static int __devinit setup_pendown(struct spi_device *spi, struct ads7846 *ts) 810 + { 811 + struct ads7846_platform_data *pdata = spi->dev.platform_data; 812 + int err; 813 + 814 + /* REVISIT when the irq can be triggered active-low, or if for some 815 + * reason the touchscreen isn't hooked up, we don't need to access 816 + * the pendown state. 817 + */ 818 + if (!pdata->get_pendown_state && !gpio_is_valid(pdata->gpio_pendown)) { 819 + dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); 820 + return -EINVAL; 821 + } 822 + 823 + if (pdata->get_pendown_state) { 824 + ts->get_pendown_state = pdata->get_pendown_state; 825 + return 0; 826 + } 827 + 828 + err = gpio_request(pdata->gpio_pendown, "ads7846_pendown"); 829 + if (err) { 830 + dev_err(&spi->dev, "failed to request pendown GPIO%d\n", 831 + pdata->gpio_pendown); 832 + return err; 833 + } 834 + 835 + ts->gpio_pendown = pdata->gpio_pendown; 836 + return 0; 837 + } 838 + 839 static int __devinit ads7846_probe(struct spi_device *spi) 840 { 841 struct ads7846 *ts; 842 + struct ads7846_packet *packet; 843 struct input_dev *input_dev; 844 struct ads7846_platform_data *pdata = spi->dev.platform_data; 845 struct spi_message *m; ··· 833 return -EINVAL; 834 } 835 836 /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except 837 * that even if the hardware can do that, the SPI controller driver 838 * may not. So we stick to very-portable 8 bit words, both RX and TX. ··· 853 return err; 854 855 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); 856 + packet = kzalloc(sizeof(struct ads7846_packet), GFP_KERNEL); 857 input_dev = input_allocate_device(); 858 + if (!ts || !packet || !input_dev) { 859 err = -ENOMEM; 860 goto err_free_mem; 861 } 862 863 dev_set_drvdata(&spi->dev, ts); 864 865 + ts->packet = packet; 866 ts->spi = spi; 867 ts->input = input_dev; 868 ts->vref_mv = pdata->vref_mv; ··· 893 ts->filter_data = ts; 894 } else 895 ts->filter = ads7846_no_filter; 896 + 897 + err = setup_pendown(spi, ts); 898 + if (err) 899 + goto err_cleanup_filter; 900 901 if (pdata->penirq_recheck_delay_usecs) 902 ts->penirq_recheck_delay_usecs = ··· 929 spi_message_init(m); 930 931 /* y- still on; turn on only y+ (and ADC) */ 932 + packet->read_y = READ_Y(vref); 933 + x->tx_buf = &packet->read_y; 934 x->len = 1; 935 spi_message_add_tail(x, m); 936 937 x++; 938 + x->rx_buf = &packet->tc.y; 939 x->len = 2; 940 spi_message_add_tail(x, m); 941 ··· 947 x->delay_usecs = pdata->settle_delay_usecs; 948 949 x++; 950 + x->tx_buf = &packet->read_y; 951 x->len = 1; 952 spi_message_add_tail(x, m); 953 954 x++; 955 + x->rx_buf = &packet->tc.y; 956 x->len = 2; 957 spi_message_add_tail(x, m); 958 } ··· 965 966 /* turn y- off, x+ on, then leave in lowpower */ 967 x++; 968 + packet->read_x = READ_X(vref); 969 + x->tx_buf = &packet->read_x; 970 x->len = 1; 971 spi_message_add_tail(x, m); 972 973 x++; 974 + x->rx_buf = &packet->tc.x; 975 x->len = 2; 976 spi_message_add_tail(x, m); 977 ··· 980 x->delay_usecs = pdata->settle_delay_usecs; 981 982 x++; 983 + x->tx_buf = &packet->read_x; 984 x->len = 1; 985 spi_message_add_tail(x, m); 986 987 x++; 988 + x->rx_buf = &packet->tc.x; 989 x->len = 2; 990 spi_message_add_tail(x, m); 991 } ··· 999 spi_message_init(m); 1000 1001 x++; 1002 + packet->read_z1 = READ_Z1(vref); 1003 + x->tx_buf = &packet->read_z1; 1004 x->len = 1; 1005 spi_message_add_tail(x, m); 1006 1007 x++; 1008 + x->rx_buf = &packet->tc.z1; 1009 x->len = 2; 1010 spi_message_add_tail(x, m); 1011 ··· 1014 x->delay_usecs = pdata->settle_delay_usecs; 1015 1016 x++; 1017 + x->tx_buf = &packet->read_z1; 1018 x->len = 1; 1019 spi_message_add_tail(x, m); 1020 1021 x++; 1022 + x->rx_buf = &packet->tc.z1; 1023 x->len = 2; 1024 spi_message_add_tail(x, m); 1025 } ··· 1031 spi_message_init(m); 1032 1033 x++; 1034 + packet->read_z2 = READ_Z2(vref); 1035 + x->tx_buf = &packet->read_z2; 1036 x->len = 1; 1037 spi_message_add_tail(x, m); 1038 1039 x++; 1040 + x->rx_buf = &packet->tc.z2; 1041 x->len = 2; 1042 spi_message_add_tail(x, m); 1043 ··· 1046 x->delay_usecs = pdata->settle_delay_usecs; 1047 1048 x++; 1049 + x->tx_buf = &packet->read_z2; 1050 x->len = 1; 1051 spi_message_add_tail(x, m); 1052 1053 x++; 1054 + x->rx_buf = &packet->tc.z2; 1055 x->len = 2; 1056 spi_message_add_tail(x, m); 1057 } ··· 1065 spi_message_init(m); 1066 1067 x++; 1068 + packet->pwrdown = PWRDOWN; 1069 + x->tx_buf = &packet->pwrdown; 1070 x->len = 1; 1071 spi_message_add_tail(x, m); 1072 1073 x++; 1074 + x->rx_buf = &packet->dummy; 1075 x->len = 2; 1076 CS_CHANGE(*x); 1077 spi_message_add_tail(x, m); ··· 1085 spi->dev.driver->name, ts)) { 1086 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1087 err = -EBUSY; 1088 + goto err_free_gpio; 1089 } 1090 1091 err = ads784x_hwmon_register(spi, ts); ··· 1116 ads784x_hwmon_unregister(spi, ts); 1117 err_free_irq: 1118 free_irq(spi->irq, ts); 1119 + err_free_gpio: 1120 + if (ts->gpio_pendown != -1) 1121 + gpio_free(ts->gpio_pendown); 1122 err_cleanup_filter: 1123 if (ts->filter_cleanup) 1124 ts->filter_cleanup(ts->filter_data); 1125 err_free_mem: 1126 input_free_device(input_dev); 1127 + kfree(packet); 1128 kfree(ts); 1129 return err; 1130 } ··· 1140 /* suspend left the IRQ disabled */ 1141 enable_irq(ts->spi->irq); 1142 1143 + if (ts->gpio_pendown != -1) 1144 + gpio_free(ts->gpio_pendown); 1145 + 1146 if (ts->filter_cleanup) 1147 ts->filter_cleanup(ts->filter_data); 1148 1149 + kfree(ts->packet); 1150 kfree(ts); 1151 1152 dev_dbg(&spi->dev, "unregistered touchscreen\n");
+22 -11
drivers/input/touchscreen/atmel_tsadcc.c
··· 91 char phys[32]; 92 struct clk *clk; 93 int irq; 94 }; 95 96 static void __iomem *tsc_base; ··· 103 104 static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev) 105 { 106 - struct input_dev *input_dev = ((struct atmel_tsadcc *)dev)->input; 107 108 - unsigned int absx; 109 - unsigned int absy; 110 unsigned int status; 111 unsigned int reg; 112 ··· 123 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); 124 125 input_report_key(input_dev, BTN_TOUCH, 0); 126 input_sync(input_dev); 127 128 } else if (status & ATMEL_TSADCC_PENCNT) { ··· 141 } else if (status & ATMEL_TSADCC_EOC(3)) { 142 /* Conversion finished */ 143 144 - absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10; 145 - absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2); 146 147 - absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10; 148 - absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0); 149 150 - input_report_abs(input_dev, ABS_X, absx); 151 - input_report_abs(input_dev, ABS_Y, absy); 152 - input_report_key(input_dev, BTN_TOUCH, 1); 153 - input_sync(input_dev); 154 } 155 156 return IRQ_HANDLED; ··· 233 } 234 235 ts_dev->input = input_dev; 236 237 snprintf(ts_dev->phys, sizeof(ts_dev->phys), 238 "%s/input0", pdev->dev.bus_id);
··· 91 char phys[32]; 92 struct clk *clk; 93 int irq; 94 + unsigned int prev_absx; 95 + unsigned int prev_absy; 96 + unsigned char bufferedmeasure; 97 }; 98 99 static void __iomem *tsc_base; ··· 100 101 static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev) 102 { 103 + struct atmel_tsadcc *ts_dev = (struct atmel_tsadcc *)dev; 104 + struct input_dev *input_dev = ts_dev->input; 105 106 unsigned int status; 107 unsigned int reg; 108 ··· 121 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); 122 123 input_report_key(input_dev, BTN_TOUCH, 0); 124 + ts_dev->bufferedmeasure = 0; 125 input_sync(input_dev); 126 127 } else if (status & ATMEL_TSADCC_PENCNT) { ··· 138 } else if (status & ATMEL_TSADCC_EOC(3)) { 139 /* Conversion finished */ 140 141 + if (ts_dev->bufferedmeasure) { 142 + /* Last measurement is always discarded, since it can 143 + * be erroneous. 144 + * Always report previous measurement */ 145 + input_report_abs(input_dev, ABS_X, ts_dev->prev_absx); 146 + input_report_abs(input_dev, ABS_Y, ts_dev->prev_absy); 147 + input_report_key(input_dev, BTN_TOUCH, 1); 148 + input_sync(input_dev); 149 + } else 150 + ts_dev->bufferedmeasure = 1; 151 152 + /* Now make new measurement */ 153 + ts_dev->prev_absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10; 154 + ts_dev->prev_absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2); 155 156 + ts_dev->prev_absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10; 157 + ts_dev->prev_absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0); 158 } 159 160 return IRQ_HANDLED; ··· 223 } 224 225 ts_dev->input = input_dev; 226 + ts_dev->bufferedmeasure = 0; 227 228 snprintf(ts_dev->phys, sizeof(ts_dev->phys), 229 "%s/input0", pdev->dev.bus_id);
+2 -3
drivers/input/touchscreen/mainstone-wm97xx.c
··· 3 * Wolfson WM97xx AC97 Codecs. 4 * 5 * Copyright 2004, 2007 Wolfson Microelectronics PLC. 6 - * Author: Liam Girdwood 7 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 8 * Parts Copyright : Ian Molton <spyro@f2s.com> 9 * Andrew Zabolotny <zap@homelink.ru> 10 * ··· 295 module_exit(mainstone_wm97xx_exit); 296 297 /* Module information */ 298 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 299 MODULE_DESCRIPTION("wm97xx continuous touch driver for mainstone"); 300 MODULE_LICENSE("GPL");
··· 3 * Wolfson WM97xx AC97 Codecs. 4 * 5 * Copyright 2004, 2007 Wolfson Microelectronics PLC. 6 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 7 * Parts Copyright : Ian Molton <spyro@f2s.com> 8 * Andrew Zabolotny <zap@homelink.ru> 9 * ··· 296 module_exit(mainstone_wm97xx_exit); 297 298 /* Module information */ 299 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 300 MODULE_DESCRIPTION("wm97xx continuous touch driver for mainstone"); 301 MODULE_LICENSE("GPL");
+2 -3
drivers/input/touchscreen/wm9705.c
··· 2 * wm9705.c -- Codec driver for Wolfson WM9705 AC97 Codec. 3 * 4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. 5 - * Author: Liam Girdwood 6 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 7 * Parts Copyright : Ian Molton <spyro@f2s.com> 8 * Andrew Zabolotny <zap@homelink.ru> 9 * Russell King <rmk@arm.linux.org.uk> ··· 346 EXPORT_SYMBOL_GPL(wm9705_codec); 347 348 /* Module information */ 349 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 350 MODULE_DESCRIPTION("WM9705 Touch Screen Driver"); 351 MODULE_LICENSE("GPL");
··· 2 * wm9705.c -- Codec driver for Wolfson WM9705 AC97 Codec. 3 * 4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. 5 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 6 * Parts Copyright : Ian Molton <spyro@f2s.com> 7 * Andrew Zabolotny <zap@homelink.ru> 8 * Russell King <rmk@arm.linux.org.uk> ··· 347 EXPORT_SYMBOL_GPL(wm9705_codec); 348 349 /* Module information */ 350 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 351 MODULE_DESCRIPTION("WM9705 Touch Screen Driver"); 352 MODULE_LICENSE("GPL");
+2 -3
drivers/input/touchscreen/wm9712.c
··· 2 * wm9712.c -- Codec driver for Wolfson WM9712 AC97 Codecs. 3 * 4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. 5 - * Author: Liam Girdwood 6 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 7 * Parts Copyright : Ian Molton <spyro@f2s.com> 8 * Andrew Zabolotny <zap@homelink.ru> 9 * Russell King <rmk@arm.linux.org.uk> ··· 461 EXPORT_SYMBOL_GPL(wm9712_codec); 462 463 /* Module information */ 464 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 465 MODULE_DESCRIPTION("WM9712 Touch Screen Driver"); 466 MODULE_LICENSE("GPL");
··· 2 * wm9712.c -- Codec driver for Wolfson WM9712 AC97 Codecs. 3 * 4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. 5 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 6 * Parts Copyright : Ian Molton <spyro@f2s.com> 7 * Andrew Zabolotny <zap@homelink.ru> 8 * Russell King <rmk@arm.linux.org.uk> ··· 462 EXPORT_SYMBOL_GPL(wm9712_codec); 463 464 /* Module information */ 465 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 466 MODULE_DESCRIPTION("WM9712 Touch Screen Driver"); 467 MODULE_LICENSE("GPL");
+2 -3
drivers/input/touchscreen/wm9713.c
··· 2 * wm9713.c -- Codec touch driver for Wolfson WM9713 AC97 Codec. 3 * 4 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC. 5 - * Author: Liam Girdwood 6 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 7 * Parts Copyright : Ian Molton <spyro@f2s.com> 8 * Andrew Zabolotny <zap@homelink.ru> 9 * Russell King <rmk@arm.linux.org.uk> ··· 475 EXPORT_SYMBOL_GPL(wm9713_codec); 476 477 /* Module information */ 478 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 479 MODULE_DESCRIPTION("WM9713 Touch Screen Driver"); 480 MODULE_LICENSE("GPL");
··· 2 * wm9713.c -- Codec touch driver for Wolfson WM9713 AC97 Codec. 3 * 4 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC. 5 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 6 * Parts Copyright : Ian Molton <spyro@f2s.com> 7 * Andrew Zabolotny <zap@homelink.ru> 8 * Russell King <rmk@arm.linux.org.uk> ··· 476 EXPORT_SYMBOL_GPL(wm9713_codec); 477 478 /* Module information */ 479 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 480 MODULE_DESCRIPTION("WM9713 Touch Screen Driver"); 481 MODULE_LICENSE("GPL");
+2 -3
drivers/input/touchscreen/wm97xx-core.c
··· 3 * and WM9713 AC97 Codecs. 4 * 5 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC. 6 - * Author: Liam Girdwood 7 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 8 * Parts Copyright : Ian Molton <spyro@f2s.com> 9 * Andrew Zabolotny <zap@homelink.ru> 10 * Russell King <rmk@arm.linux.org.uk> ··· 823 module_exit(wm97xx_exit); 824 825 /* Module information */ 826 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 827 MODULE_DESCRIPTION("WM97xx Core - Touch Screen / AUX ADC / GPIO Driver"); 828 MODULE_LICENSE("GPL");
··· 3 * and WM9713 AC97 Codecs. 4 * 5 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC. 6 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 7 * Parts Copyright : Ian Molton <spyro@f2s.com> 8 * Andrew Zabolotny <zap@homelink.ru> 9 * Russell King <rmk@arm.linux.org.uk> ··· 824 module_exit(wm97xx_exit); 825 826 /* Module information */ 827 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 828 MODULE_DESCRIPTION("WM97xx Core - Touch Screen / AUX ADC / GPIO Driver"); 829 MODULE_LICENSE("GPL");
+1
include/linux/Kbuild
··· 107 header-y += limits.h 108 header-y += magic.h 109 header-y += major.h 110 header-y += matroxfb.h 111 header-y += meye.h 112 header-y += minix_fs.h
··· 107 header-y += limits.h 108 header-y += magic.h 109 header-y += major.h 110 + header-y += map_to_7segment.h 111 header-y += matroxfb.h 112 header-y += meye.h 113 header-y += minix_fs.h
+4 -3
include/linux/gameport.h
··· 146 mutex_unlock(&gameport->drv_mutex); 147 } 148 149 - void __gameport_register_driver(struct gameport_driver *drv, struct module *owner); 150 - static inline void gameport_register_driver(struct gameport_driver *drv) 151 { 152 - __gameport_register_driver(drv, THIS_MODULE); 153 } 154 155 void gameport_unregister_driver(struct gameport_driver *drv);
··· 146 mutex_unlock(&gameport->drv_mutex); 147 } 148 149 + int __gameport_register_driver(struct gameport_driver *drv, 150 + struct module *owner, const char *mod_name); 151 + static inline int __must_check gameport_register_driver(struct gameport_driver *drv) 152 { 153 + return __gameport_register_driver(drv, THIS_MODULE, KBUILD_MODNAME); 154 } 155 156 void gameport_unregister_driver(struct gameport_driver *drv);
+14 -1
include/linux/input.h
··· 577 #define KEY_BRL_DOT9 0x1f9 578 #define KEY_BRL_DOT10 0x1fa 579 580 /* We avoid low common keys in module aliases so they don't get huge. */ 581 #define KEY_MIN_INTERESTING KEY_MUTE 582 - #define KEY_MAX 0x1ff 583 #define KEY_CNT (KEY_MAX+1) 584 585 /*
··· 577 #define KEY_BRL_DOT9 0x1f9 578 #define KEY_BRL_DOT10 0x1fa 579 580 + #define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ 581 + #define KEY_NUMERIC_1 0x201 /* and other keypads */ 582 + #define KEY_NUMERIC_2 0x202 583 + #define KEY_NUMERIC_3 0x203 584 + #define KEY_NUMERIC_4 0x204 585 + #define KEY_NUMERIC_5 0x205 586 + #define KEY_NUMERIC_6 0x206 587 + #define KEY_NUMERIC_7 0x207 588 + #define KEY_NUMERIC_8 0x208 589 + #define KEY_NUMERIC_9 0x209 590 + #define KEY_NUMERIC_STAR 0x20a 591 + #define KEY_NUMERIC_POUND 0x20b 592 + 593 /* We avoid low common keys in module aliases so they don't get huge. */ 594 #define KEY_MIN_INTERESTING KEY_MUTE 595 + #define KEY_MAX 0x2ff 596 #define KEY_CNT (KEY_MAX+1) 597 598 /*
+1 -1
include/linux/mod_devicetable.h
··· 274 /* Input */ 275 #define INPUT_DEVICE_ID_EV_MAX 0x1f 276 #define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71 277 - #define INPUT_DEVICE_ID_KEY_MAX 0x1ff 278 #define INPUT_DEVICE_ID_REL_MAX 0x0f 279 #define INPUT_DEVICE_ID_ABS_MAX 0x3f 280 #define INPUT_DEVICE_ID_MSC_MAX 0x07
··· 274 /* Input */ 275 #define INPUT_DEVICE_ID_EV_MAX 0x1f 276 #define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71 277 + #define INPUT_DEVICE_ID_KEY_MAX 0x2ff 278 #define INPUT_DEVICE_ID_REL_MAX 0x0f 279 #define INPUT_DEVICE_ID_ABS_MAX 0x3f 280 #define INPUT_DEVICE_ID_MSC_MAX 0x07
+3
include/linux/spi/ads7846.h
··· 43 u16 debounce_tol; /* tolerance used for filtering */ 44 u16 debounce_rep; /* additional consecutive good readings 45 * required after the first two */ 46 int (*get_pendown_state)(void); 47 int (*filter_init) (struct ads7846_platform_data *pdata, 48 void **filter_data);
··· 43 u16 debounce_tol; /* tolerance used for filtering */ 44 u16 debounce_rep; /* additional consecutive good readings 45 * required after the first two */ 46 + int gpio_pendown; /* the GPIO used to decide the pendown 47 + * state if get_pendown_state == NULL 48 + */ 49 int (*get_pendown_state)(void); 50 int (*filter_init) (struct ads7846_platform_data *pdata, 51 void **filter_data);