Merge branch 'next' into for-linus

+2309 -352
+1
Documentation/kernel-parameters.txt
··· 796 796 Defaults to the default architecture's huge page size 797 797 if not specified. 798 798 799 + i8042.debug [HW] Toggle i8042 debug mode 799 800 i8042.direct [HW] Put keyboard port into non-translated mode 800 801 i8042.dumbkbd [HW] Pretend that controller can only read data from 801 802 keyboard and cannot control its state
+1 -1
MAINTAINERS
··· 4548 4548 P: Mark Brown 4549 4549 M: broonie@opensource.wolfsonmicro.com 4550 4550 P: Liam Girdwood 4551 - M: liam.girdwood@wolfsonmicro.com 4551 + M: lrg@slimlogic.co.uk 4552 4552 L: linux-input@vger.kernel.org 4553 4553 T: git git://opensource.wolfsonmicro.com/linux-2.6-touch 4554 4554 W: http://opensource.wolfsonmicro.com/node/7
+1 -1
drivers/char/keyboard.c
··· 1249 1249 return; 1250 1250 } 1251 1251 1252 - if (keycode > NR_KEYS) 1252 + if (keycode >= NR_KEYS) 1253 1253 if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8) 1254 1254 keysym = K(KT_BRL, keycode - KEY_BRL_DOT1 + 1); 1255 1255 else
+68 -22
drivers/input/gameport/gameport.c
··· 231 231 enum gameport_event_type { 232 232 GAMEPORT_REGISTER_PORT, 233 233 GAMEPORT_REGISTER_DRIVER, 234 + GAMEPORT_ATTACH_DRIVER, 234 235 }; 235 236 236 237 struct gameport_event { ··· 246 245 static DECLARE_WAIT_QUEUE_HEAD(gameport_wait); 247 246 static struct task_struct *gameport_task; 248 247 249 - static void gameport_queue_event(void *object, struct module *owner, 250 - enum gameport_event_type event_type) 248 + static int gameport_queue_event(void *object, struct module *owner, 249 + enum gameport_event_type event_type) 251 250 { 252 251 unsigned long flags; 253 252 struct gameport_event *event; 253 + int retval = 0; 254 254 255 255 spin_lock_irqsave(&gameport_event_lock, flags); 256 256 ··· 270 268 } 271 269 } 272 270 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); 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; 288 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 + 289 296 out: 290 297 spin_unlock_irqrestore(&gameport_event_lock, flags); 298 + return retval; 291 299 } 292 300 293 301 static void gameport_free_event(struct gameport_event *event) ··· 390 378 } 391 379 392 380 /* 393 - * Remove all events that have been submitted for a given gameport port. 381 + * Remove all events that have been submitted for a given object, 382 + * be it a gameport port or a driver. 394 383 */ 395 - static void gameport_remove_pending_events(struct gameport *gameport) 384 + static void gameport_remove_pending_events(void *object) 396 385 { 397 386 struct list_head *node, *next; 398 387 struct gameport_event *event; ··· 403 390 404 391 list_for_each_safe(node, next, &gameport_event_list) { 405 392 event = list_entry(node, struct gameport_event, node); 406 - if (event->object == gameport) { 393 + if (event->object == object) { 407 394 list_del_init(node); 408 395 gameport_free_event(event); 409 396 } ··· 718 705 drv->driver.name, error); 719 706 } 720 707 721 - void __gameport_register_driver(struct gameport_driver *drv, struct module *owner) 708 + int __gameport_register_driver(struct gameport_driver *drv, struct module *owner, 709 + const char *mod_name) 722 710 { 711 + int error; 712 + 723 713 drv->driver.bus = &gameport_bus; 724 - gameport_queue_event(drv, owner, GAMEPORT_REGISTER_DRIVER); 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; 725 742 } 726 743 727 744 void gameport_unregister_driver(struct gameport_driver *drv) ··· 759 716 struct gameport *gameport; 760 717 761 718 mutex_lock(&gameport_mutex); 719 + 762 720 drv->ignore = 1; /* so gameport_find_driver ignores it */ 721 + gameport_remove_pending_events(drv); 763 722 764 723 start_over: 765 724 list_for_each_entry(gameport, &gameport_list, node) { ··· 774 729 } 775 730 776 731 driver_unregister(&drv->driver); 732 + 777 733 mutex_unlock(&gameport_mutex); 778 734 } 779 735
+1 -2
drivers/input/joystick/a3d.c
··· 414 414 415 415 static int __init a3d_init(void) 416 416 { 417 - gameport_register_driver(&a3d_drv); 418 - return 0; 417 + return gameport_register_driver(&a3d_drv); 419 418 } 420 419 421 420 static void __exit a3d_exit(void)
+1 -2
drivers/input/joystick/adi.c
··· 572 572 573 573 static int __init adi_init(void) 574 574 { 575 - gameport_register_driver(&adi_drv); 576 - return 0; 575 + return gameport_register_driver(&adi_drv); 577 576 } 578 577 579 578 static void __exit adi_exit(void)
+1 -3
drivers/input/joystick/analog.c
··· 761 761 static int __init analog_init(void) 762 762 { 763 763 analog_parse_options(); 764 - gameport_register_driver(&analog_drv); 765 - 766 - return 0; 764 + return gameport_register_driver(&analog_drv); 767 765 } 768 766 769 767 static void __exit analog_exit(void)
+1 -2
drivers/input/joystick/cobra.c
··· 263 263 264 264 static int __init cobra_init(void) 265 265 { 266 - gameport_register_driver(&cobra_drv); 267 - return 0; 266 + return gameport_register_driver(&cobra_drv); 268 267 } 269 268 270 269 static void __exit cobra_exit(void)
+1 -2
drivers/input/joystick/gf2k.c
··· 375 375 376 376 static int __init gf2k_init(void) 377 377 { 378 - gameport_register_driver(&gf2k_drv); 379 - return 0; 378 + return gameport_register_driver(&gf2k_drv); 380 379 } 381 380 382 381 static void __exit gf2k_exit(void)
+1 -2
drivers/input/joystick/grip.c
··· 426 426 427 427 static int __init grip_init(void) 428 428 { 429 - gameport_register_driver(&grip_drv); 430 - return 0; 429 + return gameport_register_driver(&grip_drv); 431 430 } 432 431 433 432 static void __exit grip_exit(void)
+1 -2
drivers/input/joystick/grip_mp.c
··· 689 689 690 690 static int __init grip_init(void) 691 691 { 692 - gameport_register_driver(&grip_drv); 693 - return 0; 692 + return gameport_register_driver(&grip_drv); 694 693 } 695 694 696 695 static void __exit grip_exit(void)
+1 -2
drivers/input/joystick/guillemot.c
··· 283 283 284 284 static int __init guillemot_init(void) 285 285 { 286 - gameport_register_driver(&guillemot_drv); 287 - return 0; 286 + return gameport_register_driver(&guillemot_drv); 288 287 } 289 288 290 289 static void __exit guillemot_exit(void)
+1 -2
drivers/input/joystick/interact.c
··· 317 317 318 318 static int __init interact_init(void) 319 319 { 320 - gameport_register_driver(&interact_drv); 321 - return 0; 320 + return gameport_register_driver(&interact_drv); 322 321 } 323 322 324 323 static void __exit interact_exit(void)
+1 -2
drivers/input/joystick/joydump.c
··· 161 161 162 162 static int __init joydump_init(void) 163 163 { 164 - gameport_register_driver(&joydump_drv); 165 - return 0; 164 + return gameport_register_driver(&joydump_drv); 166 165 } 167 166 168 167 static void __exit joydump_exit(void)
+1 -2
drivers/input/joystick/sidewinder.c
··· 818 818 819 819 static int __init sw_init(void) 820 820 { 821 - gameport_register_driver(&sw_drv); 822 - return 0; 821 + return gameport_register_driver(&sw_drv); 823 822 } 824 823 825 824 static void __exit sw_exit(void)
+1 -2
drivers/input/joystick/tmdc.c
··· 438 438 439 439 static int __init tmdc_init(void) 440 440 { 441 - gameport_register_driver(&tmdc_drv); 442 - return 0; 441 + return gameport_register_driver(&tmdc_drv); 443 442 } 444 443 445 444 static void __exit tmdc_exit(void)
+10 -20
drivers/input/keyboard/atkbd.c
··· 834 834 } 835 835 836 836 /* 837 - * Most special keys (Fn+F?) on Dell Latitudes do not generate release 837 + * Most special keys (Fn+F?) on Dell laptops do not generate release 838 838 * events so we have to do it ourselves. 839 839 */ 840 - static void atkbd_latitude_keymap_fixup(struct atkbd *atkbd) 840 + static void atkbd_dell_laptop_keymap_fixup(struct atkbd *atkbd) 841 841 { 842 842 const unsigned int forced_release_keys[] = { 843 843 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93, ··· 1207 1207 { 1208 1208 struct input_dev *old_dev, *new_dev; 1209 1209 unsigned long value; 1210 - char *rest; 1211 1210 int err; 1212 1211 unsigned char old_extra, old_set; 1213 1212 1214 1213 if (!atkbd->write) 1215 1214 return -EIO; 1216 1215 1217 - value = simple_strtoul(buf, &rest, 10); 1218 - if (*rest || value > 1) 1216 + if (strict_strtoul(buf, 10, &value) || value > 1) 1219 1217 return -EINVAL; 1220 1218 1221 1219 if (atkbd->extra != value) { ··· 1262 1264 { 1263 1265 struct input_dev *old_dev, *new_dev; 1264 1266 unsigned long value; 1265 - char *rest; 1266 1267 int err; 1267 1268 unsigned char old_scroll; 1268 1269 1269 - value = simple_strtoul(buf, &rest, 10); 1270 - if (*rest || value > 1) 1270 + if (strict_strtoul(buf, 10, &value) || value > 1) 1271 1271 return -EINVAL; 1272 1272 1273 1273 if (atkbd->scroll != value) { ··· 1306 1310 { 1307 1311 struct input_dev *old_dev, *new_dev; 1308 1312 unsigned long value; 1309 - char *rest; 1310 1313 int err; 1311 1314 unsigned char old_set, old_extra; 1312 1315 1313 1316 if (!atkbd->write) 1314 1317 return -EIO; 1315 1318 1316 - value = simple_strtoul(buf, &rest, 10); 1317 - if (*rest || (value != 2 && value != 3)) 1319 + if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3)) 1318 1320 return -EINVAL; 1319 1321 1320 1322 if (atkbd->set != value) { ··· 1355 1361 { 1356 1362 struct input_dev *old_dev, *new_dev; 1357 1363 unsigned long value; 1358 - char *rest; 1359 1364 int err; 1360 1365 unsigned char old_softrepeat, old_softraw; 1361 1366 1362 1367 if (!atkbd->write) 1363 1368 return -EIO; 1364 1369 1365 - value = simple_strtoul(buf, &rest, 10); 1366 - if (*rest || value > 1) 1370 + if (strict_strtoul(buf, 10, &value) || value > 1) 1367 1371 return -EINVAL; 1368 1372 1369 1373 if (atkbd->softrepeat != value) { ··· 1405 1413 { 1406 1414 struct input_dev *old_dev, *new_dev; 1407 1415 unsigned long value; 1408 - char *rest; 1409 1416 int err; 1410 1417 unsigned char old_softraw; 1411 1418 1412 - value = simple_strtoul(buf, &rest, 10); 1413 - if (*rest || value > 1) 1419 + if (strict_strtoul(buf, 10, &value) || value > 1) 1414 1420 return -EINVAL; 1415 1421 1416 1422 if (atkbd->softraw != value) { ··· 1451 1461 1452 1462 static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = { 1453 1463 { 1454 - .ident = "Dell Latitude series", 1464 + .ident = "Dell Laptop", 1455 1465 .matches = { 1456 1466 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1457 - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"), 1467 + DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */ 1458 1468 }, 1459 1469 .callback = atkbd_setup_fixup, 1460 - .driver_data = atkbd_latitude_keymap_fixup, 1470 + .driver_data = atkbd_dell_laptop_keymap_fixup, 1461 1471 }, 1462 1472 { 1463 1473 .ident = "HP 2133",
+12 -1
drivers/input/keyboard/bf54x-keys.c
··· 8 8 * 9 9 * 10 10 * Modified: 11 - * Copyright 2007 Analog Devices Inc. 11 + * Copyright 2007-2008 Analog Devices Inc. 12 12 * 13 13 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 14 14 * ··· 81 81 unsigned short *keycode; 82 82 struct timer_list timer; 83 83 unsigned int keyup_test_jiffies; 84 + unsigned short kpad_msel; 85 + unsigned short kpad_prescale; 86 + unsigned short kpad_ctl; 84 87 }; 85 88 86 89 static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad, ··· 363 360 { 364 361 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 365 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 + 366 367 if (device_may_wakeup(&pdev->dev)) 367 368 enable_irq_wake(bf54x_kpad->irq); 368 369 ··· 376 369 static int bfin_kpad_resume(struct platform_device *pdev) 377 370 { 378 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); 379 376 380 377 if (device_may_wakeup(&pdev->dev)) 381 378 disable_irq_wake(bf54x_kpad->irq);
+16 -26
drivers/input/keyboard/gpio_keys.c
··· 36 36 struct gpio_button_data data[0]; 37 37 }; 38 38 39 - static void gpio_keys_report_event(struct gpio_keys_button *button, 40 - struct input_dev *input) 39 + static void gpio_keys_report_event(struct gpio_button_data *bdata) 41 40 { 41 + struct gpio_keys_button *button = bdata->button; 42 + struct input_dev *input = bdata->input; 42 43 unsigned int type = button->type ?: EV_KEY; 43 44 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; 44 45 ··· 51 50 { 52 51 struct gpio_button_data *data = (struct gpio_button_data *)_data; 53 52 54 - gpio_keys_report_event(data->button, data->input); 53 + gpio_keys_report_event(data); 55 54 } 56 55 57 56 static irqreturn_t gpio_keys_isr(int irq, void *dev_id) 58 57 { 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; 58 + struct gpio_button_data *bdata = dev_id; 59 + struct gpio_keys_button *button = bdata->button; 63 60 64 - for (i = 0; i < pdata->nbuttons; i++) { 65 - struct gpio_keys_button *button = &pdata->buttons[i]; 61 + BUG_ON(irq != gpio_to_irq(button->gpio)); 66 62 67 - if (irq == gpio_to_irq(button->gpio)) { 68 - struct gpio_button_data *bdata = &ddata->data[i]; 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); 69 68 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; 69 + return IRQ_HANDLED; 82 70 } 83 71 84 72 static int __devinit gpio_keys_probe(struct platform_device *pdev) ··· 141 151 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | 142 152 IRQF_TRIGGER_FALLING, 143 153 button->desc ? button->desc : "gpio_keys", 144 - pdev); 154 + bdata); 145 155 if (error) { 146 156 pr_err("gpio-keys: Unable to claim irq %d; error %d\n", 147 157 irq, error); ··· 168 178 169 179 fail2: 170 180 while (--i >= 0) { 171 - free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); 181 + free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 172 182 if (pdata->buttons[i].debounce_interval) 173 183 del_timer_sync(&ddata->data[i].timer); 174 184 gpio_free(pdata->buttons[i].gpio); ··· 193 203 194 204 for (i = 0; i < pdata->nbuttons; i++) { 195 205 int irq = gpio_to_irq(pdata->buttons[i].gpio); 196 - free_irq(irq, pdev); 206 + free_irq(irq, &ddata->data[i]); 197 207 if (pdata->buttons[i].debounce_interval) 198 208 del_timer_sync(&ddata->data[i].timer); 199 209 gpio_free(pdata->buttons[i].gpio);
+13
drivers/input/misc/Kconfig
··· 180 180 To compile this driver as a module, choose M here: the module will be 181 181 called yealink. 182 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 + 183 196 config INPUT_UINPUT 184 197 tristate "User level driver support" 185 198 help
+1
drivers/input/misc/Makefile
··· 16 16 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o 17 17 obj-$(CONFIG_INPUT_POWERMATE) += powermate.o 18 18 obj-$(CONFIG_INPUT_YEALINK) += yealink.o 19 + obj-$(CONFIG_INPUT_CM109) += cm109.o 19 20 obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 20 21 obj-$(CONFIG_INPUT_UINPUT) += uinput.o 21 22 obj-$(CONFIG_INPUT_APANEL) += apanel.o
+228 -35
drivers/input/misc/ati_remote2.c
··· 1 1 /* 2 2 * ati_remote2 - ATI/Philips USB RF remote driver 3 3 * 4 - * Copyright (C) 2005 Ville Syrjala <syrjala@sci.fi> 5 - * Copyright (C) 2007 Peter Stokes <linux@dadeos.freeserve.co.uk> 4 + * Copyright (C) 2005-2008 Ville Syrjala <syrjala@sci.fi> 5 + * Copyright (C) 2007-2008 Peter Stokes <linux@dadeos.co.uk> 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify 8 8 * it under the terms of the GNU General Public License version 2 ··· 12 12 #include <linux/usb/input.h> 13 13 14 14 #define DRIVER_DESC "ATI/Philips USB RF remote driver" 15 - #define DRIVER_VERSION "0.2" 15 + #define DRIVER_VERSION "0.3" 16 16 17 17 MODULE_DESCRIPTION(DRIVER_DESC); 18 18 MODULE_VERSION(DRIVER_VERSION); ··· 27 27 * A remote's "channel" may be altered by pressing and holding the "PC" button for 28 28 * approximately 3 seconds, after which the button will slowly flash the count of the 29 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 30 + * 16 and then press the "PC" button again, the button will slowly flash the count of the 31 31 * newly configured "channel". 32 32 */ 33 33 ··· 45 45 }; 46 46 MODULE_DEVICE_TABLE(usb, ati_remote2_id_table); 47 47 48 - static struct { 49 - int hw_code; 50 - int key_code; 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; 51 67 } ati_remote2_key_table[] = { 52 68 { 0x00, KEY_0 }, 53 69 { 0x01, KEY_1 }, ··· 89 73 { 0x37, KEY_RECORD }, 90 74 { 0x38, KEY_DVD }, 91 75 { 0x39, KEY_TV }, 76 + { 0x3f, KEY_PROG1 }, /* AUX1-AUX4 and PC */ 92 77 { 0x54, KEY_MENU }, 93 78 { 0x58, KEY_UP }, 94 79 { 0x59, KEY_DOWN }, ··· 108 91 { 0xa9, BTN_LEFT }, 109 92 { 0xaa, BTN_RIGHT }, 110 93 { 0xbe, KEY_QUESTION }, 111 - { 0xd5, KEY_FRONT }, 112 94 { 0xd0, KEY_EDIT }, 95 + { 0xd5, KEY_FRONT }, 113 96 { 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 97 }; 121 98 122 99 struct ati_remote2 { ··· 128 117 129 118 char name[64]; 130 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; 131 125 }; 132 126 133 127 static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id); 134 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); 135 131 136 132 static struct usb_driver ati_remote2_driver = { 137 133 .name = "ati_remote2", 138 134 .probe = ati_remote2_probe, 139 135 .disconnect = ati_remote2_disconnect, 140 136 .id_table = ati_remote2_id_table, 137 + .suspend = ati_remote2_suspend, 138 + .resume = ati_remote2_resume, 139 + .supports_autosuspend = 1, 141 140 }; 142 141 143 - static int ati_remote2_open(struct input_dev *idev) 142 + static int ati_remote2_submit_urbs(struct ati_remote2 *ar2) 144 143 { 145 - struct ati_remote2 *ar2 = input_get_drvdata(idev); 146 144 int r; 147 145 148 146 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); 149 147 if (r) { 150 148 dev_err(&ar2->intf[0]->dev, 151 - "%s: usb_submit_urb() = %d\n", __func__, r); 149 + "%s(): usb_submit_urb() = %d\n", __func__, r); 152 150 return r; 153 151 } 154 152 r = usb_submit_urb(ar2->urb[1], GFP_KERNEL); 155 153 if (r) { 156 154 usb_kill_urb(ar2->urb[0]); 157 155 dev_err(&ar2->intf[1]->dev, 158 - "%s: usb_submit_urb() = %d\n", __func__, r); 156 + "%s(): usb_submit_urb() = %d\n", __func__, r); 159 157 return r; 160 158 } 161 159 162 160 return 0; 163 161 } 164 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 + 165 206 static void ati_remote2_close(struct input_dev *idev) 166 207 { 167 208 struct ati_remote2 *ar2 = input_get_drvdata(idev); 168 209 169 - usb_kill_urb(ar2->urb[0]); 170 - usb_kill_urb(ar2->urb[1]); 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); 171 220 } 172 221 173 222 static void ati_remote2_input_mouse(struct ati_remote2 *ar2) ··· 243 172 244 173 mode = data[0] & 0x0F; 245 174 246 - if (mode > 4) { 175 + if (mode > ATI_REMOTE2_PC) { 247 176 dev_err(&ar2->intf[0]->dev, 248 177 "Unknown mode byte (%02x %02x %02x %02x)\n", 249 178 data[3], data[2], data[1], data[0]); ··· 262 191 { 263 192 int i; 264 193 265 - for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) 194 + for (i = 0; i < ARRAY_SIZE(ati_remote2_key_table); i++) 266 195 if (ati_remote2_key_table[i].hw_code == hw_code) 267 196 return i; 268 197 ··· 282 211 283 212 mode = data[0] & 0x0F; 284 213 285 - if (mode > 4) { 214 + if (mode > ATI_REMOTE2_PC) { 286 215 dev_err(&ar2->intf[1]->dev, 287 216 "Unknown mode byte (%02x %02x %02x %02x)\n", 288 217 data[3], data[2], data[1], data[0]); ··· 290 219 } 291 220 292 221 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 222 if (hw_code == 0x3f) { 298 223 /* 299 224 * For some incomprehensible reason the mouse pad generates ··· 303 236 304 237 if (data[1] == 0) 305 238 ar2->mode = mode; 306 - 307 - hw_code |= mode << 8; 308 239 } 309 240 310 241 if (!((1 << mode) & mode_mask)) ··· 325 260 case 2: /* repeat */ 326 261 327 262 /* 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) 263 + if (ar2->keycode[mode][index] == BTN_LEFT || 264 + ar2->keycode[mode][index] == BTN_RIGHT) 330 265 return; 331 266 332 267 if (!time_after_eq(jiffies, ar2->jiffies)) ··· 341 276 return; 342 277 } 343 278 344 - input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]); 279 + input_event(idev, EV_KEY, ar2->keycode[mode][index], data[1]); 345 280 input_sync(idev); 346 281 } 347 282 ··· 352 287 353 288 switch (urb->status) { 354 289 case 0: 290 + usb_mark_last_busy(ar2->udev); 355 291 ati_remote2_input_mouse(ar2); 356 292 break; 357 293 case -ENOENT: ··· 363 297 "%s(): urb status = %d\n", __func__, urb->status); 364 298 return; 365 299 default: 300 + usb_mark_last_busy(ar2->udev); 366 301 dev_err(&ar2->intf[0]->dev, 367 302 "%s(): urb status = %d\n", __func__, urb->status); 368 303 } ··· 381 314 382 315 switch (urb->status) { 383 316 case 0: 317 + usb_mark_last_busy(ar2->udev); 384 318 ati_remote2_input_key(ar2); 385 319 break; 386 320 case -ENOENT: ··· 392 324 "%s(): urb status = %d\n", __func__, urb->status); 393 325 return; 394 326 default: 327 + usb_mark_last_busy(ar2->udev); 395 328 dev_err(&ar2->intf[1]->dev, 396 329 "%s(): urb status = %d\n", __func__, urb->status); 397 330 } ··· 403 334 "%s(): usb_submit_urb() = %d\n", __func__, r); 404 335 } 405 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 + 406 387 static int ati_remote2_input_init(struct ati_remote2 *ar2) 407 388 { 408 389 struct input_dev *idev; 409 - int i, retval; 390 + int index, mode, retval; 410 391 411 392 idev = input_allocate_device(); 412 393 if (!idev) ··· 469 350 idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | 470 351 BIT_MASK(BTN_RIGHT); 471 352 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); 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); 474 373 475 374 idev->rep[REP_DELAY] = 250; 476 375 idev->rep[REP_PERIOD] = 33; 477 376 478 377 idev->open = ati_remote2_open; 479 378 idev->close = ati_remote2_close; 379 + 380 + idev->getkeycode = ati_remote2_getkeycode; 381 + idev->setkeycode = ati_remote2_setkeycode; 480 382 481 383 idev->name = ar2->name; 482 384 idev->phys = ar2->phys; ··· 630 490 631 491 usb_set_intfdata(interface, ar2); 632 492 493 + interface->needs_remote_wakeup = 1; 494 + 633 495 return 0; 634 496 635 497 fail2: ··· 662 520 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); 663 521 664 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; 665 574 } 666 575 667 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 1 /* 2 - * drivers/usb/input/map_to_7segment.h 3 - * 4 2 * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> 5 3 * 6 4 * This program is free software; you can redistribute it and/or ··· 34 36 * Usage: 35 37 * 36 38 * Register a map variable, and fill it with a character set: 37 - * static SEG7_DEFAULT_MAP(map_seg7); 39 + * static SEG7_DEFAULT_MAP(map_seg7); 38 40 * 39 41 * 40 42 * Then use for conversion:
+19
drivers/input/misc/wistron_btns.c
··· 277 277 { KE_END, 0 } 278 278 }; 279 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 + 280 290 static struct key_entry keymap_fujitsu_n3510[] __initdata = { 281 291 { KE_KEY, 0x11, {KEY_PROG1} }, 282 292 { KE_KEY, 0x12, {KEY_PROG2} }, ··· 625 615 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"), 626 616 }, 627 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 628 627 }, 629 628 { 630 629 .callback = dmi_matched,
+1 -1
drivers/input/misc/yealink.c
··· 52 52 #include <linux/module.h> 53 53 #include <linux/rwsem.h> 54 54 #include <linux/usb/input.h> 55 + #include <linux/map_to_7segment.h> 55 56 56 - #include "map_to_7segment.h" 57 57 #include "yealink.h" 58 58 59 59 #define DRIVER_VERSION "yld-20051230"
+10
drivers/input/mouse/Kconfig
··· 96 96 97 97 If unsure, say N. 98 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 + 99 109 config MOUSE_SERIAL 100 110 tristate "Serial mouse" 101 111 select SERIO
+1
drivers/input/mouse/Makefile
··· 21 21 psmouse-objs := psmouse-base.o synaptics.o 22 22 23 23 psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o 24 + psmouse-$(CONFIG_MOUSE_PS2_OLPC) += hgpk.o 24 25 psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o 25 26 psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o 26 27 psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o
+1
drivers/input/mouse/alps.c
··· 54 54 { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ 55 55 { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, 56 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 */ 57 58 { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */ 58 59 }; 59 60
+223 -78
drivers/input/mouse/appletouch.c
··· 136 136 #define ATP_GEYSER_MODE_REQUEST_INDEX 0 137 137 #define ATP_GEYSER_MODE_VENDOR_VALUE 0x04 138 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 + 139 155 /* Structure to hold all of our device specific stuff */ 140 156 struct atp { 141 157 char phys[64]; 142 158 struct usb_device *udev; /* usb device */ 143 159 struct urb *urb; /* usb request block */ 144 - signed char *data; /* transferred data */ 160 + u8 *data; /* transferred data */ 145 161 struct input_dev *input; /* input dev */ 146 162 enum atp_touchpad_type type; /* type of touchpad */ 147 163 bool open; ··· 267 251 int retval; 268 252 269 253 dprintk("appletouch: putting appletouch to sleep (reinit)\n"); 270 - dev->idlecount = 0; 271 - 272 254 atp_geyser_init(udev); 273 255 274 256 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); ··· 341 327 input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); 342 328 } 343 329 344 - static void atp_complete(struct urb *urb) 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) 345 337 { 346 - int x, y, x_z, y_z, x_f, y_f; 347 - int retval, i, j; 348 - int key; 349 338 struct atp *dev = urb->context; 350 339 351 340 switch (urb->status) { ··· 368 351 /* This urb is terminated, clean up */ 369 352 dbg("atp_complete: urb shutting down with status: %d", 370 353 urb->status); 371 - return; 354 + return ATP_URB_STATUS_ERROR_FATAL; 355 + 372 356 default: 373 357 dbg("atp_complete: nonzero urb status received: %d", 374 358 urb->status); 375 - goto exit; 359 + return ATP_URB_STATUS_ERROR; 376 360 } 377 361 378 362 /* drop incomplete datasets */ ··· 381 363 dprintk("appletouch: incomplete data package" 382 364 " (first byte: %d, length: %d).\n", 383 365 dev->data[0], dev->urb->actual_length); 384 - goto exit; 366 + return ATP_URB_STATUS_ERROR; 385 367 } 386 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 + 387 391 /* 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) { 392 + if (dev->type == ATP_GEYSER2) { 408 393 memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); 409 394 410 395 /* ··· 448 427 /* first sample */ 449 428 dev->valid = true; 450 429 dev->x_old = dev->y_old = -1; 430 + 431 + /* Store first sample */ 451 432 memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); 452 433 453 - if (dev->size_detect_done || 454 - dev->type == ATP_GEYSER3) /* No 17" Macbooks (yet) */ 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; 455 462 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 463 } 476 - 477 - dev->size_detect_done = 1; 478 - goto exit; 479 464 } 480 465 481 466 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { ··· 502 475 ATP_XFACT, &x_z, &x_f); 503 476 y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, 504 477 ATP_YFACT, &y_z, &y_f); 505 - key = dev->data[dev->datalen - 1] & 1; 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; 506 590 507 591 if (x && y) { 508 592 if (dev->x_old != -1) { ··· 652 514 input_sync(dev->input); 653 515 654 516 /* 655 - * Many Geysers will continue to send packets continually after 517 + * Geysers 3/4 will continue to send packets continually after 656 518 * the first touch unless reinitialised. Do so if it's been 657 519 * 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. 520 + * several hundred times a second. 660 521 */ 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 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; 675 531 dev->idlecount = 0; 676 - } 532 + schedule_work(&dev->work); 533 + /* Don't resubmit urb here, wait for reinit */ 534 + return; 535 + } 536 + } else 537 + dev->idlecount = 0; 677 538 678 539 exit: 679 540 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); ··· 769 632 if (!dev->data) 770 633 goto err_free_urb; 771 634 772 - usb_fill_int_urb(dev->urb, udev, 773 - usb_rcvintpipe(udev, int_in_endpointAddr), 774 - dev->data, dev->datalen, atp_complete, dev, 1); 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); 775 648 776 649 error = atp_handle_geyser(dev); 777 650 if (error) ··· 898 751 struct atp *dev = usb_get_intfdata(iface); 899 752 900 753 usb_kill_urb(dev->urb); 901 - dev->valid = false; 902 - 903 754 return 0; 904 755 } 905 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 157 static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) 158 158 { 159 159 unsigned long value; 160 - char *rest; 161 160 162 - value = simple_strtoul(buf, &rest, 10); 163 - if (*rest || value > 1) 161 + if (strict_strtoul(buf, 10, &value) || value > 1) 164 162 return -EINVAL; 165 163 166 164 ps2pp_set_smartscroll(psmouse, value);
+53 -28
drivers/input/mouse/psmouse-base.c
··· 25 25 #include "synaptics.h" 26 26 #include "logips2pp.h" 27 27 #include "alps.h" 28 + #include "hgpk.h" 28 29 #include "lifebook.h" 29 30 #include "trackpoint.h" 30 31 #include "touchkit_ps2.h" ··· 202 201 return PSMOUSE_FULL_PACKET; 203 202 } 204 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 + 205 210 /* 206 211 * __psmouse_set_state() sets new psmouse state and resets all flags. 207 212 */ ··· 227 220 * is not a concern. 228 221 */ 229 222 230 - static void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 223 + void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 231 224 { 232 225 serio_pause_rx(psmouse->ps2dev.serio); 233 226 __psmouse_set_state(psmouse, new_state); ··· 312 305 psmouse->name, psmouse->phys, psmouse->pktcnt); 313 306 psmouse->badbyte = psmouse->packet[0]; 314 307 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 315 - queue_work(kpsmoused_wq, &psmouse->resync_work); 308 + psmouse_queue_work(psmouse, &psmouse->resync_work, 0); 316 309 goto out; 317 310 } 318 311 ··· 349 342 time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) { 350 343 psmouse->badbyte = psmouse->packet[0]; 351 344 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 352 - queue_work(kpsmoused_wq, &psmouse->resync_work); 345 + psmouse_queue_work(psmouse, &psmouse->resync_work, 0); 353 346 goto out; 354 347 } 355 348 ··· 637 630 } 638 631 } 639 632 640 - if (max_proto > PSMOUSE_IMEX) { 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 + } 641 645 646 + if (max_proto > PSMOUSE_IMEX) { 642 647 if (genius_detect(psmouse, set_properties) == 0) 643 648 return PSMOUSE_GENPS; 644 649 ··· 779 760 .name = "touchkitPS/2", 780 761 .alias = "touchkit", 781 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, 782 771 }, 783 772 #endif 784 773 { ··· 962 935 static void psmouse_resync(struct work_struct *work) 963 936 { 964 937 struct psmouse *parent = NULL, *psmouse = 965 - container_of(work, struct psmouse, resync_work); 938 + container_of(work, struct psmouse, resync_work.work); 966 939 struct serio *serio = psmouse->ps2dev.serio; 967 940 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 968 941 int failed = 0, enabled = 0; ··· 1221 1194 goto err_free; 1222 1195 1223 1196 ps2_init(&psmouse->ps2dev, serio); 1224 - INIT_WORK(&psmouse->resync_work, psmouse_resync); 1197 + INIT_DELAYED_WORK(&psmouse->resync_work, psmouse_resync); 1225 1198 psmouse->dev = input_dev; 1226 1199 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); 1227 1200 ··· 1422 1395 1423 1396 psmouse = serio_get_drvdata(serio); 1424 1397 1425 - if (psmouse->state == PSMOUSE_IGNORE) { 1426 - retval = -ENODEV; 1427 - goto out_unlock; 1428 - } 1398 + if (attr->protect) { 1399 + if (psmouse->state == PSMOUSE_IGNORE) { 1400 + retval = -ENODEV; 1401 + goto out_unlock; 1402 + } 1429 1403 1430 - if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1431 - parent = serio_get_drvdata(serio->parent); 1432 - psmouse_deactivate(parent); 1433 - } 1404 + if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1405 + parent = serio_get_drvdata(serio->parent); 1406 + psmouse_deactivate(parent); 1407 + } 1434 1408 1435 - psmouse_deactivate(psmouse); 1409 + psmouse_deactivate(psmouse); 1410 + } 1436 1411 1437 1412 retval = attr->set(psmouse, attr->data, buf, count); 1438 1413 1439 - if (retval != -ENODEV) 1440 - psmouse_activate(psmouse); 1414 + if (attr->protect) { 1415 + if (retval != -ENODEV) 1416 + psmouse_activate(psmouse); 1441 1417 1442 - if (parent) 1443 - psmouse_activate(parent); 1418 + if (parent) 1419 + psmouse_activate(parent); 1420 + } 1444 1421 1445 1422 out_unlock: 1446 1423 mutex_unlock(&psmouse_mutex); ··· 1464 1433 { 1465 1434 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); 1466 1435 unsigned long value; 1467 - char *rest; 1468 1436 1469 - value = simple_strtoul(buf, &rest, 10); 1470 - if (*rest) 1437 + if (strict_strtoul(buf, 10, &value)) 1471 1438 return -EINVAL; 1472 1439 1473 1440 if ((unsigned int)value != value) ··· 1578 1549 static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1579 1550 { 1580 1551 unsigned long value; 1581 - char *rest; 1582 1552 1583 - value = simple_strtoul(buf, &rest, 10); 1584 - if (*rest) 1553 + if (strict_strtoul(buf, 10, &value)) 1585 1554 return -EINVAL; 1586 1555 1587 1556 psmouse->set_rate(psmouse, value); ··· 1589 1562 static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1590 1563 { 1591 1564 unsigned long value; 1592 - char *rest; 1593 1565 1594 - value = simple_strtoul(buf, &rest, 10); 1595 - if (*rest) 1566 + if (strict_strtoul(buf, 10, &value)) 1596 1567 return -EINVAL; 1597 1568 1598 1569 psmouse->set_resolution(psmouse, value);
+11 -3
drivers/input/mouse/psmouse.h
··· 39 39 void *private; 40 40 struct input_dev *dev; 41 41 struct ps2dev ps2dev; 42 - struct work_struct resync_work; 42 + struct delayed_work resync_work; 43 43 char *vendor; 44 44 char *name; 45 45 unsigned char packet[8]; ··· 89 89 PSMOUSE_TRACKPOINT, 90 90 PSMOUSE_TOUCHKIT_PS2, 91 91 PSMOUSE_CORTRON, 92 + PSMOUSE_HGPK, 92 93 PSMOUSE_AUTO /* This one should always be last */ 93 94 }; 94 95 96 + void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work, 97 + unsigned long delay); 95 98 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); 96 99 int psmouse_reset(struct psmouse *psmouse); 100 + void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state); 97 101 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); 98 - 99 102 100 103 struct psmouse_attribute { 101 104 struct device_attribute dattr; ··· 106 103 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); 107 104 ssize_t (*set)(struct psmouse *psmouse, void *data, 108 105 const char *buf, size_t count); 106 + int protect; 109 107 }; 110 108 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) 111 109 ··· 115 111 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, 116 112 const char *buf, size_t count); 117 113 118 - #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ 114 + #define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \ 119 115 static ssize_t _show(struct psmouse *, void *data, char *); \ 120 116 static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ 121 117 static struct psmouse_attribute psmouse_attr_##_name = { \ ··· 130 126 .data = _data, \ 131 127 .show = _show, \ 132 128 .set = _set, \ 129 + .protect = _protect, \ 133 130 } 131 + 132 + #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ 133 + __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, 1) 134 134 135 135 #endif /* _PSMOUSE_H */
+2 -6
drivers/input/mouse/trackpoint.c
··· 89 89 struct trackpoint_attr_data *attr = data; 90 90 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 91 91 unsigned long value; 92 - char *rest; 93 92 94 - value = simple_strtoul(buf, &rest, 10); 95 - if (*rest || value > 255) 93 + if (strict_strtoul(buf, 10, &value) || value > 255) 96 94 return -EINVAL; 97 95 98 96 *field = value; ··· 115 117 struct trackpoint_attr_data *attr = data; 116 118 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 117 119 unsigned long value; 118 - char *rest; 119 120 120 - value = simple_strtoul(buf, &rest, 10); 121 - if (*rest || value > 1) 121 + if (strict_strtoul(buf, 10, &value) || value > 1) 122 122 return -EINVAL; 123 123 124 124 if (attr->inverted)
+7
drivers/input/serio/i8042-x86ia64io.h
··· 322 322 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"), 323 323 }, 324 324 }, 325 + { 326 + .ident = "IBM 2656", 327 + .matches = { 328 + DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 329 + DMI_MATCH(DMI_PRODUCT_NAME, "2656"), 330 + }, 331 + }, 325 332 { } 326 333 }; 327 334
+6
drivers/input/serio/serio_raw.c
··· 373 373 .id = SERIO_ANY, 374 374 .extra = SERIO_ANY, 375 375 }, 376 + { 377 + .type = SERIO_8042_XL, 378 + .proto = SERIO_ANY, 379 + .id = SERIO_ANY, 380 + .extra = SERIO_ANY, 381 + }, 376 382 { 0 } 377 383 }; 378 384
+38 -15
drivers/input/tablet/aiptek.c
··· 1202 1202 store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1203 1203 { 1204 1204 struct aiptek *aiptek = dev_get_drvdata(dev); 1205 - int x; 1205 + long x; 1206 1206 1207 - if (strcmp(buf, "disable") == 0) { 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 + 1208 1213 aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; 1209 1214 } 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 - } 1215 + if (x < AIPTEK_TILT_MIN || x > AIPTEK_TILT_MAX) 1216 + return -EINVAL; 1217 + 1218 + aiptek->newSetting.xTilt = x; 1214 1219 } 1220 + 1215 1221 return count; 1216 1222 } 1217 1223 ··· 1244 1238 store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1245 1239 { 1246 1240 struct aiptek *aiptek = dev_get_drvdata(dev); 1247 - int y; 1241 + long y; 1248 1242 1249 - if (strcmp(buf, "disable") == 0) { 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 + 1250 1249 aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; 1251 1250 } 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 - } 1251 + if (y < AIPTEK_TILT_MIN || y > AIPTEK_TILT_MAX) 1252 + return -EINVAL; 1253 + 1254 + aiptek->newSetting.yTilt = y; 1256 1255 } 1256 + 1257 1257 return count; 1258 1258 } 1259 1259 ··· 1281 1269 store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1282 1270 { 1283 1271 struct aiptek *aiptek = dev_get_drvdata(dev); 1272 + long j; 1284 1273 1285 - aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10); 1274 + if (strict_strtol(buf, 10, &j)) 1275 + return -EINVAL; 1276 + 1277 + aiptek->newSetting.jitterDelay = (int)j; 1286 1278 return count; 1287 1279 } 1288 1280 ··· 1310 1294 store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1311 1295 { 1312 1296 struct aiptek *aiptek = dev_get_drvdata(dev); 1297 + long d; 1313 1298 1314 - aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10); 1299 + if (strict_strtol(buf, 10, &d)) 1300 + return -EINVAL; 1301 + 1302 + aiptek->newSetting.programmableDelay = (int)d; 1315 1303 return count; 1316 1304 } 1317 1305 ··· 1561 1541 store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1562 1542 { 1563 1543 struct aiptek *aiptek = dev_get_drvdata(dev); 1544 + long w; 1564 1545 1565 - aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10); 1546 + if (strict_strtol(buf, 10, &w)) return -EINVAL; 1547 + 1548 + aiptek->newSetting.wheel = (int)w; 1566 1549 return count; 1567 1550 } 1568 1551
+109 -53
drivers/input/touchscreen/ads7846.c
··· 24 24 #include <linux/input.h> 25 25 #include <linux/interrupt.h> 26 26 #include <linux/slab.h> 27 + #include <linux/gpio.h> 27 28 #include <linux/spi/spi.h> 28 29 #include <linux/spi/ads7846.h> 29 30 #include <asm/irq.h> ··· 69 68 int ignore; 70 69 }; 71 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 + 72 82 struct ads7846 { 73 83 struct input_dev *input; 74 84 char phys[32]; ··· 97 85 u16 x_plate_ohms; 98 86 u16 pressure_max; 99 87 100 - u8 read_x, read_y, read_z1, read_z2, pwrdown; 101 - u16 dummy; /* for the pwrdown read */ 102 - struct ts_event tc; 88 + struct ads7846_packet *packet; 103 89 104 90 struct spi_transfer xfer[18]; 105 91 struct spi_message msg[5]; ··· 126 116 void *filter_data; 127 117 void (*filter_cleanup)(void *data); 128 118 int (*get_pendown_state)(void); 119 + int gpio_pendown; 129 120 }; 130 121 131 122 /* leave chip selected when we're done, for quicker re-select? */ ··· 472 461 const char *buf, size_t count) 473 462 { 474 463 struct ads7846 *ts = dev_get_drvdata(dev); 475 - char *endp; 476 - int i; 464 + long i; 477 465 478 - i = simple_strtoul(buf, &endp, 10); 466 + if (strict_strtoul(buf, 10, &i)) 467 + return -EINVAL; 468 + 479 469 spin_lock_irq(&ts->lock); 480 470 481 471 if (i) ··· 503 491 504 492 /*--------------------------------------------------------------------------*/ 505 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 + 506 502 /* 507 503 * PENIRQ only kicks the timer. The timer only reissues the SPI transfer, 508 504 * to retrieve touchscreen status. ··· 522 502 static void ads7846_rx(void *ads) 523 503 { 524 504 struct ads7846 *ts = ads; 505 + struct ads7846_packet *packet = ts->packet; 525 506 unsigned Rt; 526 507 u16 x, y, z1, z2; 527 508 528 509 /* ads7846_rx_val() did in-place conversion (including byteswap) from 529 510 * on-the-wire format as part of debouncing to get stable readings. 530 511 */ 531 - x = ts->tc.x; 532 - y = ts->tc.y; 533 - z1 = ts->tc.z1; 534 - z2 = ts->tc.z2; 512 + x = packet->tc.x; 513 + y = packet->tc.y; 514 + z1 = packet->tc.z1; 515 + z2 = packet->tc.z2; 535 516 536 517 /* range filtering */ 537 518 if (x == MAX_12BIT) ··· 556 535 * the maximum. Don't report it to user space, repeat at least 557 536 * once more the measurement 558 537 */ 559 - if (ts->tc.ignore || Rt > ts->pressure_max) { 538 + if (packet->tc.ignore || Rt > ts->pressure_max) { 560 539 #ifdef VERBOSE 561 540 pr_debug("%s: ignored %d pressure %d\n", 562 - ts->spi->dev.bus_id, ts->tc.ignore, Rt); 541 + ts->spi->dev.bus_id, packet->tc.ignore, Rt); 563 542 #endif 564 543 hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), 565 544 HRTIMER_MODE_REL); ··· 571 550 */ 572 551 if (ts->penirq_recheck_delay_usecs) { 573 552 udelay(ts->penirq_recheck_delay_usecs); 574 - if (!ts->get_pendown_state()) 553 + if (!get_pendown_state(ts)) 575 554 Rt = 0; 576 555 } 577 556 ··· 652 631 static void ads7846_rx_val(void *ads) 653 632 { 654 633 struct ads7846 *ts = ads; 634 + struct ads7846_packet *packet = ts->packet; 655 635 struct spi_message *m; 656 636 struct spi_transfer *t; 657 637 int val; ··· 672 650 case ADS7846_FILTER_REPEAT: 673 651 break; 674 652 case ADS7846_FILTER_IGNORE: 675 - ts->tc.ignore = 1; 653 + packet->tc.ignore = 1; 676 654 /* Last message will contain ads7846_rx() as the 677 655 * completion function. 678 656 */ ··· 680 658 break; 681 659 case ADS7846_FILTER_OK: 682 660 *(u16 *)t->rx_buf = val; 683 - ts->tc.ignore = 0; 661 + packet->tc.ignore = 0; 684 662 m = &ts->msg[++ts->msg_idx]; 685 663 break; 686 664 default: ··· 699 677 700 678 spin_lock_irq(&ts->lock); 701 679 702 - if (unlikely(!ts->get_pendown_state() || 680 + if (unlikely(!get_pendown_state(ts) || 703 681 device_suspended(&ts->spi->dev))) { 704 682 if (ts->pendown) { 705 683 struct input_dev *input = ts->input; ··· 738 716 unsigned long flags; 739 717 740 718 spin_lock_irqsave(&ts->lock, flags); 741 - if (likely(ts->get_pendown_state())) { 719 + if (likely(get_pendown_state(ts))) { 742 720 if (!ts->irq_disabled) { 743 721 /* The ARM do_simple_IRQ() dispatcher doesn't act 744 722 * like the other dispatchers: it will report IRQs ··· 785 763 /* we know the chip's in lowpower mode since we always 786 764 * leave it that way after every request 787 765 */ 788 - 789 766 } 790 767 791 768 /* Must be called with ts->lock held */ ··· 827 806 return 0; 828 807 } 829 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 + 830 839 static int __devinit ads7846_probe(struct spi_device *spi) 831 840 { 832 841 struct ads7846 *ts; 842 + struct ads7846_packet *packet; 833 843 struct input_dev *input_dev; 834 844 struct ads7846_platform_data *pdata = spi->dev.platform_data; 835 845 struct spi_message *m; ··· 885 833 return -EINVAL; 886 834 } 887 835 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 836 /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except 898 837 * that even if the hardware can do that, the SPI controller driver 899 838 * may not. So we stick to very-portable 8 bit words, both RX and TX. ··· 896 853 return err; 897 854 898 855 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); 856 + packet = kzalloc(sizeof(struct ads7846_packet), GFP_KERNEL); 899 857 input_dev = input_allocate_device(); 900 - if (!ts || !input_dev) { 858 + if (!ts || !packet || !input_dev) { 901 859 err = -ENOMEM; 902 860 goto err_free_mem; 903 861 } 904 862 905 863 dev_set_drvdata(&spi->dev, ts); 906 864 865 + ts->packet = packet; 907 866 ts->spi = spi; 908 867 ts->input = input_dev; 909 868 ts->vref_mv = pdata->vref_mv; ··· 938 893 ts->filter_data = ts; 939 894 } else 940 895 ts->filter = ads7846_no_filter; 941 - ts->get_pendown_state = pdata->get_pendown_state; 896 + 897 + err = setup_pendown(spi, ts); 898 + if (err) 899 + goto err_cleanup_filter; 942 900 943 901 if (pdata->penirq_recheck_delay_usecs) 944 902 ts->penirq_recheck_delay_usecs = ··· 977 929 spi_message_init(m); 978 930 979 931 /* y- still on; turn on only y+ (and ADC) */ 980 - ts->read_y = READ_Y(vref); 981 - x->tx_buf = &ts->read_y; 932 + packet->read_y = READ_Y(vref); 933 + x->tx_buf = &packet->read_y; 982 934 x->len = 1; 983 935 spi_message_add_tail(x, m); 984 936 985 937 x++; 986 - x->rx_buf = &ts->tc.y; 938 + x->rx_buf = &packet->tc.y; 987 939 x->len = 2; 988 940 spi_message_add_tail(x, m); 989 941 ··· 995 947 x->delay_usecs = pdata->settle_delay_usecs; 996 948 997 949 x++; 998 - x->tx_buf = &ts->read_y; 950 + x->tx_buf = &packet->read_y; 999 951 x->len = 1; 1000 952 spi_message_add_tail(x, m); 1001 953 1002 954 x++; 1003 - x->rx_buf = &ts->tc.y; 955 + x->rx_buf = &packet->tc.y; 1004 956 x->len = 2; 1005 957 spi_message_add_tail(x, m); 1006 958 } ··· 1013 965 1014 966 /* turn y- off, x+ on, then leave in lowpower */ 1015 967 x++; 1016 - ts->read_x = READ_X(vref); 1017 - x->tx_buf = &ts->read_x; 968 + packet->read_x = READ_X(vref); 969 + x->tx_buf = &packet->read_x; 1018 970 x->len = 1; 1019 971 spi_message_add_tail(x, m); 1020 972 1021 973 x++; 1022 - x->rx_buf = &ts->tc.x; 974 + x->rx_buf = &packet->tc.x; 1023 975 x->len = 2; 1024 976 spi_message_add_tail(x, m); 1025 977 ··· 1028 980 x->delay_usecs = pdata->settle_delay_usecs; 1029 981 1030 982 x++; 1031 - x->tx_buf = &ts->read_x; 983 + x->tx_buf = &packet->read_x; 1032 984 x->len = 1; 1033 985 spi_message_add_tail(x, m); 1034 986 1035 987 x++; 1036 - x->rx_buf = &ts->tc.x; 988 + x->rx_buf = &packet->tc.x; 1037 989 x->len = 2; 1038 990 spi_message_add_tail(x, m); 1039 991 } ··· 1047 999 spi_message_init(m); 1048 1000 1049 1001 x++; 1050 - ts->read_z1 = READ_Z1(vref); 1051 - x->tx_buf = &ts->read_z1; 1002 + packet->read_z1 = READ_Z1(vref); 1003 + x->tx_buf = &packet->read_z1; 1052 1004 x->len = 1; 1053 1005 spi_message_add_tail(x, m); 1054 1006 1055 1007 x++; 1056 - x->rx_buf = &ts->tc.z1; 1008 + x->rx_buf = &packet->tc.z1; 1057 1009 x->len = 2; 1058 1010 spi_message_add_tail(x, m); 1059 1011 ··· 1062 1014 x->delay_usecs = pdata->settle_delay_usecs; 1063 1015 1064 1016 x++; 1065 - x->tx_buf = &ts->read_z1; 1017 + x->tx_buf = &packet->read_z1; 1066 1018 x->len = 1; 1067 1019 spi_message_add_tail(x, m); 1068 1020 1069 1021 x++; 1070 - x->rx_buf = &ts->tc.z1; 1022 + x->rx_buf = &packet->tc.z1; 1071 1023 x->len = 2; 1072 1024 spi_message_add_tail(x, m); 1073 1025 } ··· 1079 1031 spi_message_init(m); 1080 1032 1081 1033 x++; 1082 - ts->read_z2 = READ_Z2(vref); 1083 - x->tx_buf = &ts->read_z2; 1034 + packet->read_z2 = READ_Z2(vref); 1035 + x->tx_buf = &packet->read_z2; 1084 1036 x->len = 1; 1085 1037 spi_message_add_tail(x, m); 1086 1038 1087 1039 x++; 1088 - x->rx_buf = &ts->tc.z2; 1040 + x->rx_buf = &packet->tc.z2; 1089 1041 x->len = 2; 1090 1042 spi_message_add_tail(x, m); 1091 1043 ··· 1094 1046 x->delay_usecs = pdata->settle_delay_usecs; 1095 1047 1096 1048 x++; 1097 - x->tx_buf = &ts->read_z2; 1049 + x->tx_buf = &packet->read_z2; 1098 1050 x->len = 1; 1099 1051 spi_message_add_tail(x, m); 1100 1052 1101 1053 x++; 1102 - x->rx_buf = &ts->tc.z2; 1054 + x->rx_buf = &packet->tc.z2; 1103 1055 x->len = 2; 1104 1056 spi_message_add_tail(x, m); 1105 1057 } ··· 1113 1065 spi_message_init(m); 1114 1066 1115 1067 x++; 1116 - ts->pwrdown = PWRDOWN; 1117 - x->tx_buf = &ts->pwrdown; 1068 + packet->pwrdown = PWRDOWN; 1069 + x->tx_buf = &packet->pwrdown; 1118 1070 x->len = 1; 1119 1071 spi_message_add_tail(x, m); 1120 1072 1121 1073 x++; 1122 - x->rx_buf = &ts->dummy; 1074 + x->rx_buf = &packet->dummy; 1123 1075 x->len = 2; 1124 1076 CS_CHANGE(*x); 1125 1077 spi_message_add_tail(x, m); ··· 1133 1085 spi->dev.driver->name, ts)) { 1134 1086 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1135 1087 err = -EBUSY; 1136 - goto err_cleanup_filter; 1088 + goto err_free_gpio; 1137 1089 } 1138 1090 1139 1091 err = ads784x_hwmon_register(spi, ts); ··· 1164 1116 ads784x_hwmon_unregister(spi, ts); 1165 1117 err_free_irq: 1166 1118 free_irq(spi->irq, ts); 1119 + err_free_gpio: 1120 + if (ts->gpio_pendown != -1) 1121 + gpio_free(ts->gpio_pendown); 1167 1122 err_cleanup_filter: 1168 1123 if (ts->filter_cleanup) 1169 1124 ts->filter_cleanup(ts->filter_data); 1170 1125 err_free_mem: 1171 1126 input_free_device(input_dev); 1127 + kfree(packet); 1172 1128 kfree(ts); 1173 1129 return err; 1174 1130 } ··· 1192 1140 /* suspend left the IRQ disabled */ 1193 1141 enable_irq(ts->spi->irq); 1194 1142 1143 + if (ts->gpio_pendown != -1) 1144 + gpio_free(ts->gpio_pendown); 1145 + 1195 1146 if (ts->filter_cleanup) 1196 1147 ts->filter_cleanup(ts->filter_data); 1197 1148 1149 + kfree(ts->packet); 1198 1150 kfree(ts); 1199 1151 1200 1152 dev_dbg(&spi->dev, "unregistered touchscreen\n");
+22 -11
drivers/input/touchscreen/atmel_tsadcc.c
··· 91 91 char phys[32]; 92 92 struct clk *clk; 93 93 int irq; 94 + unsigned int prev_absx; 95 + unsigned int prev_absy; 96 + unsigned char bufferedmeasure; 94 97 }; 95 98 96 99 static void __iomem *tsc_base; ··· 103 100 104 101 static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev) 105 102 { 106 - struct input_dev *input_dev = ((struct atmel_tsadcc *)dev)->input; 103 + struct atmel_tsadcc *ts_dev = (struct atmel_tsadcc *)dev; 104 + struct input_dev *input_dev = ts_dev->input; 107 105 108 - unsigned int absx; 109 - unsigned int absy; 110 106 unsigned int status; 111 107 unsigned int reg; 112 108 ··· 123 121 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); 124 122 125 123 input_report_key(input_dev, BTN_TOUCH, 0); 124 + ts_dev->bufferedmeasure = 0; 126 125 input_sync(input_dev); 127 126 128 127 } else if (status & ATMEL_TSADCC_PENCNT) { ··· 141 138 } else if (status & ATMEL_TSADCC_EOC(3)) { 142 139 /* Conversion finished */ 143 140 144 - absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10; 145 - absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2); 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; 146 151 147 - absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10; 148 - absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0); 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); 149 155 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); 156 + ts_dev->prev_absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10; 157 + ts_dev->prev_absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0); 154 158 } 155 159 156 160 return IRQ_HANDLED; ··· 233 223 } 234 224 235 225 ts_dev->input = input_dev; 226 + ts_dev->bufferedmeasure = 0; 236 227 237 228 snprintf(ts_dev->phys, sizeof(ts_dev->phys), 238 229 "%s/input0", pdev->dev.bus_id);
+2 -3
drivers/input/touchscreen/mainstone-wm97xx.c
··· 3 3 * Wolfson WM97xx AC97 Codecs. 4 4 * 5 5 * Copyright 2004, 2007 Wolfson Microelectronics PLC. 6 - * Author: Liam Girdwood 7 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 6 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 8 7 * Parts Copyright : Ian Molton <spyro@f2s.com> 9 8 * Andrew Zabolotny <zap@homelink.ru> 10 9 * ··· 295 296 module_exit(mainstone_wm97xx_exit); 296 297 297 298 /* Module information */ 298 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 299 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 299 300 MODULE_DESCRIPTION("wm97xx continuous touch driver for mainstone"); 300 301 MODULE_LICENSE("GPL");
+2 -3
drivers/input/touchscreen/wm9705.c
··· 2 2 * wm9705.c -- Codec driver for Wolfson WM9705 AC97 Codec. 3 3 * 4 4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. 5 - * Author: Liam Girdwood 6 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 5 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 7 6 * Parts Copyright : Ian Molton <spyro@f2s.com> 8 7 * Andrew Zabolotny <zap@homelink.ru> 9 8 * Russell King <rmk@arm.linux.org.uk> ··· 346 347 EXPORT_SYMBOL_GPL(wm9705_codec); 347 348 348 349 /* Module information */ 349 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 350 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 350 351 MODULE_DESCRIPTION("WM9705 Touch Screen Driver"); 351 352 MODULE_LICENSE("GPL");
+2 -3
drivers/input/touchscreen/wm9712.c
··· 2 2 * wm9712.c -- Codec driver for Wolfson WM9712 AC97 Codecs. 3 3 * 4 4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. 5 - * Author: Liam Girdwood 6 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 5 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 7 6 * Parts Copyright : Ian Molton <spyro@f2s.com> 8 7 * Andrew Zabolotny <zap@homelink.ru> 9 8 * Russell King <rmk@arm.linux.org.uk> ··· 461 462 EXPORT_SYMBOL_GPL(wm9712_codec); 462 463 463 464 /* Module information */ 464 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 465 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 465 466 MODULE_DESCRIPTION("WM9712 Touch Screen Driver"); 466 467 MODULE_LICENSE("GPL");
+2 -3
drivers/input/touchscreen/wm9713.c
··· 2 2 * wm9713.c -- Codec touch driver for Wolfson WM9713 AC97 Codec. 3 3 * 4 4 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC. 5 - * Author: Liam Girdwood 6 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 5 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 7 6 * Parts Copyright : Ian Molton <spyro@f2s.com> 8 7 * Andrew Zabolotny <zap@homelink.ru> 9 8 * Russell King <rmk@arm.linux.org.uk> ··· 475 476 EXPORT_SYMBOL_GPL(wm9713_codec); 476 477 477 478 /* Module information */ 478 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 479 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 479 480 MODULE_DESCRIPTION("WM9713 Touch Screen Driver"); 480 481 MODULE_LICENSE("GPL");
+2 -3
drivers/input/touchscreen/wm97xx-core.c
··· 3 3 * and WM9713 AC97 Codecs. 4 4 * 5 5 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC. 6 - * Author: Liam Girdwood 7 - * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com 6 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 8 7 * Parts Copyright : Ian Molton <spyro@f2s.com> 9 8 * Andrew Zabolotny <zap@homelink.ru> 10 9 * Russell King <rmk@arm.linux.org.uk> ··· 823 824 module_exit(wm97xx_exit); 824 825 825 826 /* Module information */ 826 - MODULE_AUTHOR("Liam Girdwood <liam.girdwood@wolfsonmicro.com>"); 827 + MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>"); 827 828 MODULE_DESCRIPTION("WM97xx Core - Touch Screen / AUX ADC / GPIO Driver"); 828 829 MODULE_LICENSE("GPL");
+1
include/linux/Kbuild
··· 107 107 header-y += limits.h 108 108 header-y += magic.h 109 109 header-y += major.h 110 + header-y += map_to_7segment.h 110 111 header-y += matroxfb.h 111 112 header-y += meye.h 112 113 header-y += minix_fs.h
+4 -3
include/linux/gameport.h
··· 146 146 mutex_unlock(&gameport->drv_mutex); 147 147 } 148 148 149 - void __gameport_register_driver(struct gameport_driver *drv, struct module *owner); 150 - static inline void gameport_register_driver(struct gameport_driver *drv) 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) 151 152 { 152 - __gameport_register_driver(drv, THIS_MODULE); 153 + return __gameport_register_driver(drv, THIS_MODULE, KBUILD_MODNAME); 153 154 } 154 155 155 156 void gameport_unregister_driver(struct gameport_driver *drv);
+14 -1
include/linux/input.h
··· 577 577 #define KEY_BRL_DOT9 0x1f9 578 578 #define KEY_BRL_DOT10 0x1fa 579 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 + 580 593 /* We avoid low common keys in module aliases so they don't get huge. */ 581 594 #define KEY_MIN_INTERESTING KEY_MUTE 582 - #define KEY_MAX 0x1ff 595 + #define KEY_MAX 0x2ff 583 596 #define KEY_CNT (KEY_MAX+1) 584 597 585 598 /*
+1 -1
include/linux/mod_devicetable.h
··· 274 274 /* Input */ 275 275 #define INPUT_DEVICE_ID_EV_MAX 0x1f 276 276 #define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71 277 - #define INPUT_DEVICE_ID_KEY_MAX 0x1ff 277 + #define INPUT_DEVICE_ID_KEY_MAX 0x2ff 278 278 #define INPUT_DEVICE_ID_REL_MAX 0x0f 279 279 #define INPUT_DEVICE_ID_ABS_MAX 0x3f 280 280 #define INPUT_DEVICE_ID_MSC_MAX 0x07
+3
include/linux/spi/ads7846.h
··· 43 43 u16 debounce_tol; /* tolerance used for filtering */ 44 44 u16 debounce_rep; /* additional consecutive good readings 45 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 + */ 46 49 int (*get_pendown_state)(void); 47 50 int (*filter_init) (struct ads7846_platform_data *pdata, 48 51 void **filter_data);