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

Merge branch 'next' into for-linus

Conflicts:
drivers/input/tablet/wacom_sys.c

+698 -206
-7
arch/arm/plat-spear/include/plat/keyboard.h
··· 159 159 unsigned int mode; 160 160 }; 161 161 162 - /* This function is used to set platform data field of pdev->dev */ 163 - static inline void 164 - kbd_set_plat_data(struct platform_device *pdev, struct kbd_platform_data *data) 165 - { 166 - pdev->dev.platform_data = data; 167 - } 168 - 169 162 #endif /* __PLAT_KEYBOARD_H */
+3
drivers/input/joystick/amijoy.c
··· 108 108 int i, j; 109 109 int err; 110 110 111 + if (!MACH_IS_AMIGA) 112 + return -ENODEV; 113 + 111 114 for (i = 0; i < 2; i++) { 112 115 if (!amijoy[i]) 113 116 continue;
+171 -92
drivers/input/keyboard/gpio_keys.c
··· 28 28 #include <linux/gpio.h> 29 29 #include <linux/of_platform.h> 30 30 #include <linux/of_gpio.h> 31 + #include <linux/spinlock.h> 31 32 32 33 struct gpio_button_data { 33 - struct gpio_keys_button *button; 34 + const struct gpio_keys_button *button; 34 35 struct input_dev *input; 35 36 struct timer_list timer; 36 37 struct work_struct work; 37 - int timer_debounce; /* in msecs */ 38 + unsigned int timer_debounce; /* in msecs */ 39 + unsigned int irq; 40 + spinlock_t lock; 38 41 bool disabled; 42 + bool key_pressed; 39 43 }; 40 44 41 45 struct gpio_keys_drvdata { ··· 118 114 /* 119 115 * Disable IRQ and possible debouncing timer. 120 116 */ 121 - disable_irq(gpio_to_irq(bdata->button->gpio)); 117 + disable_irq(bdata->irq); 122 118 if (bdata->timer_debounce) 123 119 del_timer_sync(&bdata->timer); 124 120 ··· 139 135 static void gpio_keys_enable_button(struct gpio_button_data *bdata) 140 136 { 141 137 if (bdata->disabled) { 142 - enable_irq(gpio_to_irq(bdata->button->gpio)); 138 + enable_irq(bdata->irq); 143 139 bdata->disabled = false; 144 140 } 145 141 } ··· 199 195 * @type: button type (%EV_KEY, %EV_SW) 200 196 * 201 197 * This function parses stringified bitmap from @buf and disables/enables 202 - * GPIO buttons accordinly. Returns 0 on success and negative error 198 + * GPIO buttons accordingly. Returns 0 on success and negative error 203 199 * on failure. 204 200 */ 205 201 static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, ··· 324 320 .attrs = gpio_keys_attrs, 325 321 }; 326 322 327 - static void gpio_keys_report_event(struct gpio_button_data *bdata) 323 + static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) 328 324 { 329 - struct gpio_keys_button *button = bdata->button; 325 + const struct gpio_keys_button *button = bdata->button; 330 326 struct input_dev *input = bdata->input; 331 327 unsigned int type = button->type ?: EV_KEY; 332 328 int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; ··· 340 336 input_sync(input); 341 337 } 342 338 343 - static void gpio_keys_work_func(struct work_struct *work) 339 + static void gpio_keys_gpio_work_func(struct work_struct *work) 344 340 { 345 341 struct gpio_button_data *bdata = 346 342 container_of(work, struct gpio_button_data, work); 347 343 348 - gpio_keys_report_event(bdata); 344 + gpio_keys_gpio_report_event(bdata); 349 345 } 350 346 351 - static void gpio_keys_timer(unsigned long _data) 347 + static void gpio_keys_gpio_timer(unsigned long _data) 352 348 { 353 - struct gpio_button_data *data = (struct gpio_button_data *)_data; 349 + struct gpio_button_data *bdata = (struct gpio_button_data *)_data; 354 350 355 - schedule_work(&data->work); 351 + schedule_work(&bdata->work); 356 352 } 357 353 358 - static irqreturn_t gpio_keys_isr(int irq, void *dev_id) 354 + static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) 359 355 { 360 356 struct gpio_button_data *bdata = dev_id; 361 - struct gpio_keys_button *button = bdata->button; 362 357 363 - BUG_ON(irq != gpio_to_irq(button->gpio)); 358 + BUG_ON(irq != bdata->irq); 364 359 365 360 if (bdata->timer_debounce) 366 361 mod_timer(&bdata->timer, ··· 370 367 return IRQ_HANDLED; 371 368 } 372 369 370 + static void gpio_keys_irq_timer(unsigned long _data) 371 + { 372 + struct gpio_button_data *bdata = (struct gpio_button_data *)_data; 373 + struct input_dev *input = bdata->input; 374 + unsigned long flags; 375 + 376 + spin_lock_irqsave(&bdata->lock, flags); 377 + if (bdata->key_pressed) { 378 + input_event(input, EV_KEY, bdata->button->code, 0); 379 + input_sync(input); 380 + bdata->key_pressed = false; 381 + } 382 + spin_unlock_irqrestore(&bdata->lock, flags); 383 + } 384 + 385 + static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) 386 + { 387 + struct gpio_button_data *bdata = dev_id; 388 + const struct gpio_keys_button *button = bdata->button; 389 + struct input_dev *input = bdata->input; 390 + unsigned long flags; 391 + 392 + BUG_ON(irq != bdata->irq); 393 + 394 + spin_lock_irqsave(&bdata->lock, flags); 395 + 396 + if (!bdata->key_pressed) { 397 + input_event(input, EV_KEY, button->code, 1); 398 + input_sync(input); 399 + 400 + if (!bdata->timer_debounce) { 401 + input_event(input, EV_KEY, button->code, 0); 402 + input_sync(input); 403 + goto out; 404 + } 405 + 406 + bdata->key_pressed = true; 407 + } 408 + 409 + if (bdata->timer_debounce) 410 + mod_timer(&bdata->timer, 411 + jiffies + msecs_to_jiffies(bdata->timer_debounce)); 412 + out: 413 + spin_unlock_irqrestore(&bdata->lock, flags); 414 + return IRQ_HANDLED; 415 + } 416 + 373 417 static int __devinit gpio_keys_setup_key(struct platform_device *pdev, 418 + struct input_dev *input, 374 419 struct gpio_button_data *bdata, 375 - struct gpio_keys_button *button) 420 + const struct gpio_keys_button *button) 376 421 { 377 422 const char *desc = button->desc ? button->desc : "gpio_keys"; 378 423 struct device *dev = &pdev->dev; 424 + irq_handler_t isr; 379 425 unsigned long irqflags; 380 426 int irq, error; 381 427 382 - setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata); 383 - INIT_WORK(&bdata->work, gpio_keys_work_func); 428 + bdata->input = input; 429 + bdata->button = button; 430 + spin_lock_init(&bdata->lock); 384 431 385 - error = gpio_request(button->gpio, desc); 386 - if (error < 0) { 387 - dev_err(dev, "failed to request GPIO %d, error %d\n", 388 - button->gpio, error); 389 - goto fail2; 432 + if (gpio_is_valid(button->gpio)) { 433 + 434 + error = gpio_request(button->gpio, desc); 435 + if (error < 0) { 436 + dev_err(dev, "Failed to request GPIO %d, error %d\n", 437 + button->gpio, error); 438 + return error; 439 + } 440 + 441 + error = gpio_direction_input(button->gpio); 442 + if (error < 0) { 443 + dev_err(dev, 444 + "Failed to configure direction for GPIO %d, error %d\n", 445 + button->gpio, error); 446 + goto fail; 447 + } 448 + 449 + if (button->debounce_interval) { 450 + error = gpio_set_debounce(button->gpio, 451 + button->debounce_interval * 1000); 452 + /* use timer if gpiolib doesn't provide debounce */ 453 + if (error < 0) 454 + bdata->timer_debounce = 455 + button->debounce_interval; 456 + } 457 + 458 + irq = gpio_to_irq(button->gpio); 459 + if (irq < 0) { 460 + error = irq; 461 + dev_err(dev, 462 + "Unable to get irq number for GPIO %d, error %d\n", 463 + button->gpio, error); 464 + goto fail; 465 + } 466 + bdata->irq = irq; 467 + 468 + INIT_WORK(&bdata->work, gpio_keys_gpio_work_func); 469 + setup_timer(&bdata->timer, 470 + gpio_keys_gpio_timer, (unsigned long)bdata); 471 + 472 + isr = gpio_keys_gpio_isr; 473 + irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; 474 + 475 + } else { 476 + if (!button->irq) { 477 + dev_err(dev, "No IRQ specified\n"); 478 + return -EINVAL; 479 + } 480 + bdata->irq = button->irq; 481 + 482 + if (button->type && button->type != EV_KEY) { 483 + dev_err(dev, "Only EV_KEY allowed for IRQ buttons.\n"); 484 + return -EINVAL; 485 + } 486 + 487 + bdata->timer_debounce = button->debounce_interval; 488 + setup_timer(&bdata->timer, 489 + gpio_keys_irq_timer, (unsigned long)bdata); 490 + 491 + isr = gpio_keys_irq_isr; 492 + irqflags = 0; 390 493 } 391 494 392 - error = gpio_direction_input(button->gpio); 393 - if (error < 0) { 394 - dev_err(dev, "failed to configure" 395 - " direction for GPIO %d, error %d\n", 396 - button->gpio, error); 397 - goto fail3; 398 - } 495 + input_set_capability(input, button->type ?: EV_KEY, button->code); 399 496 400 - if (button->debounce_interval) { 401 - error = gpio_set_debounce(button->gpio, 402 - button->debounce_interval * 1000); 403 - /* use timer if gpiolib doesn't provide debounce */ 404 - if (error < 0) 405 - bdata->timer_debounce = button->debounce_interval; 406 - } 407 - 408 - irq = gpio_to_irq(button->gpio); 409 - if (irq < 0) { 410 - error = irq; 411 - dev_err(dev, "Unable to get irq number for GPIO %d, error %d\n", 412 - button->gpio, error); 413 - goto fail3; 414 - } 415 - 416 - irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; 417 497 /* 418 498 * If platform has specified that the button can be disabled, 419 499 * we don't want it to share the interrupt line. ··· 504 418 if (!button->can_disable) 505 419 irqflags |= IRQF_SHARED; 506 420 507 - error = request_threaded_irq(irq, NULL, gpio_keys_isr, irqflags, desc, bdata); 421 + error = request_any_context_irq(bdata->irq, isr, irqflags, desc, bdata); 508 422 if (error < 0) { 509 423 dev_err(dev, "Unable to claim irq %d; error %d\n", 510 - irq, error); 511 - goto fail3; 424 + bdata->irq, error); 425 + goto fail; 512 426 } 513 427 514 428 return 0; 515 429 516 - fail3: 517 - gpio_free(button->gpio); 518 - fail2: 430 + fail: 431 + if (gpio_is_valid(button->gpio)) 432 + gpio_free(button->gpio); 433 + 519 434 return error; 520 435 } 521 436 ··· 634 547 635 548 #endif 636 549 550 + static void gpio_remove_key(struct gpio_button_data *bdata) 551 + { 552 + free_irq(bdata->irq, bdata); 553 + if (bdata->timer_debounce) 554 + del_timer_sync(&bdata->timer); 555 + cancel_work_sync(&bdata->work); 556 + if (gpio_is_valid(bdata->button->gpio)) 557 + gpio_free(bdata->button->gpio); 558 + } 559 + 637 560 static int __devinit gpio_keys_probe(struct platform_device *pdev) 638 561 { 639 - struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; 562 + const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; 640 563 struct gpio_keys_drvdata *ddata; 641 564 struct device *dev = &pdev->dev; 642 565 struct gpio_keys_platform_data alt_pdata; ··· 696 599 __set_bit(EV_REP, input->evbit); 697 600 698 601 for (i = 0; i < pdata->nbuttons; i++) { 699 - struct gpio_keys_button *button = &pdata->buttons[i]; 602 + const struct gpio_keys_button *button = &pdata->buttons[i]; 700 603 struct gpio_button_data *bdata = &ddata->data[i]; 701 - unsigned int type = button->type ?: EV_KEY; 702 604 703 - bdata->input = input; 704 - bdata->button = button; 705 - 706 - error = gpio_keys_setup_key(pdev, bdata, button); 605 + error = gpio_keys_setup_key(pdev, input, bdata, button); 707 606 if (error) 708 607 goto fail2; 709 608 710 609 if (button->wakeup) 711 610 wakeup = 1; 712 - 713 - input_set_capability(input, type, button->code); 714 611 } 715 612 716 613 error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); ··· 721 630 goto fail3; 722 631 } 723 632 724 - /* get current state of buttons */ 725 - for (i = 0; i < pdata->nbuttons; i++) 726 - gpio_keys_report_event(&ddata->data[i]); 633 + /* get current state of buttons that are connected to GPIOs */ 634 + for (i = 0; i < pdata->nbuttons; i++) { 635 + struct gpio_button_data *bdata = &ddata->data[i]; 636 + if (gpio_is_valid(bdata->button->gpio)) 637 + gpio_keys_gpio_report_event(bdata); 638 + } 727 639 input_sync(input); 728 640 729 641 device_init_wakeup(&pdev->dev, wakeup); ··· 736 642 fail3: 737 643 sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); 738 644 fail2: 739 - while (--i >= 0) { 740 - free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 741 - if (ddata->data[i].timer_debounce) 742 - del_timer_sync(&ddata->data[i].timer); 743 - cancel_work_sync(&ddata->data[i].work); 744 - gpio_free(pdata->buttons[i].gpio); 745 - } 645 + while (--i >= 0) 646 + gpio_remove_key(&ddata->data[i]); 746 647 747 648 platform_set_drvdata(pdev, NULL); 748 649 fail1: ··· 760 671 761 672 device_init_wakeup(&pdev->dev, 0); 762 673 763 - for (i = 0; i < ddata->n_buttons; i++) { 764 - int irq = gpio_to_irq(ddata->data[i].button->gpio); 765 - free_irq(irq, &ddata->data[i]); 766 - if (ddata->data[i].timer_debounce) 767 - del_timer_sync(&ddata->data[i].timer); 768 - cancel_work_sync(&ddata->data[i].work); 769 - gpio_free(ddata->data[i].button->gpio); 770 - } 674 + for (i = 0; i < ddata->n_buttons; i++) 675 + gpio_remove_key(&ddata->data[i]); 771 676 772 677 input_unregister_device(input); 773 678 ··· 786 703 787 704 if (device_may_wakeup(dev)) { 788 705 for (i = 0; i < ddata->n_buttons; i++) { 789 - struct gpio_keys_button *button = ddata->data[i].button; 790 - if (button->wakeup) { 791 - int irq = gpio_to_irq(button->gpio); 792 - enable_irq_wake(irq); 793 - } 706 + struct gpio_button_data *bdata = &ddata->data[i]; 707 + if (bdata->button->wakeup) 708 + enable_irq_wake(bdata->irq); 794 709 } 795 710 } 796 711 ··· 801 720 int i; 802 721 803 722 for (i = 0; i < ddata->n_buttons; i++) { 723 + struct gpio_button_data *bdata = &ddata->data[i]; 724 + if (bdata->button->wakeup && device_may_wakeup(dev)) 725 + disable_irq_wake(bdata->irq); 804 726 805 - struct gpio_keys_button *button = ddata->data[i].button; 806 - if (button->wakeup && device_may_wakeup(dev)) { 807 - int irq = gpio_to_irq(button->gpio); 808 - disable_irq_wake(irq); 809 - } 810 - 811 - gpio_keys_report_event(&ddata->data[i]); 727 + if (gpio_is_valid(bdata->button->gpio)) 728 + gpio_keys_gpio_report_event(bdata); 812 729 } 813 730 input_sync(ddata->input); 814 731
+1
drivers/input/keyboard/tegra-kbc.c
··· 630 630 if (!np) 631 631 return NULL; 632 632 633 + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 633 634 if (!pdata) 634 635 return NULL; 635 636
+226 -72
drivers/input/mouse/sentelic.c
··· 2 2 * Finger Sensing Pad PS/2 mouse driver. 3 3 * 4 4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd. 5 - * Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation. 5 + * Copyright (C) 2005-2012 Tai-hwa Liang, Sentelic Corporation. 6 6 * 7 7 * This program is free software; you can redistribute it and/or 8 8 * modify it under the terms of the GNU General Public License ··· 21 21 22 22 #include <linux/module.h> 23 23 #include <linux/input.h> 24 + #include <linux/input/mt.h> 24 25 #include <linux/ctype.h> 25 26 #include <linux/libps2.h> 26 27 #include <linux/serio.h> ··· 36 35 */ 37 36 #define FSP_CMD_TIMEOUT 200 38 37 #define FSP_CMD_TIMEOUT2 30 38 + 39 + #define GET_ABS_X(packet) ((packet[1] << 2) | ((packet[3] >> 2) & 0x03)) 40 + #define GET_ABS_Y(packet) ((packet[2] << 2) | (packet[3] & 0x03)) 39 41 40 42 /** Driver version. */ 41 43 static const char fsp_drv_ver[] = "1.0.0-K"; ··· 132 128 out: 133 129 ps2_end_command(ps2dev); 134 130 psmouse_activate(psmouse); 135 - dev_dbg(&ps2dev->serio->dev, "READ REG: 0x%02x is 0x%02x (rc = %d)\n", 136 - reg_addr, *reg_val, rc); 131 + psmouse_dbg(psmouse, 132 + "READ REG: 0x%02x is 0x%02x (rc = %d)\n", 133 + reg_addr, *reg_val, rc); 137 134 return rc; 138 135 } 139 136 ··· 184 179 185 180 out: 186 181 ps2_end_command(ps2dev); 187 - dev_dbg(&ps2dev->serio->dev, "WRITE REG: 0x%02x to 0x%02x (rc = %d)\n", 188 - reg_addr, reg_val, rc); 182 + psmouse_dbg(psmouse, 183 + "WRITE REG: 0x%02x to 0x%02x (rc = %d)\n", 184 + reg_addr, reg_val, rc); 189 185 return rc; 190 186 } 191 187 ··· 243 237 out: 244 238 ps2_end_command(ps2dev); 245 239 psmouse_activate(psmouse); 246 - dev_dbg(&ps2dev->serio->dev, "READ PAGE REG: 0x%02x (rc = %d)\n", 247 - *reg_val, rc); 240 + psmouse_dbg(psmouse, 241 + "READ PAGE REG: 0x%02x (rc = %d)\n", 242 + *reg_val, rc); 248 243 return rc; 249 244 } 250 245 ··· 281 274 282 275 out: 283 276 ps2_end_command(ps2dev); 284 - dev_dbg(&ps2dev->serio->dev, "WRITE PAGE REG: to 0x%02x (rc = %d)\n", 285 - reg_val, rc); 277 + psmouse_dbg(psmouse, 278 + "WRITE PAGE REG: to 0x%02x (rc = %d)\n", 279 + reg_val, rc); 286 280 return rc; 287 281 } 288 282 ··· 327 319 int res = 0; 328 320 329 321 if (fsp_reg_read(psmouse, FSP_REG_OPC_QDOWN, &v) == -1) { 330 - dev_err(&psmouse->ps2dev.serio->dev, "Unable get OPC state.\n"); 322 + psmouse_err(psmouse, "Unable get OPC state.\n"); 331 323 return -EIO; 332 324 } 333 325 ··· 344 336 } 345 337 346 338 if (res != 0) { 347 - dev_err(&psmouse->ps2dev.serio->dev, 348 - "Unable to enable OPC tag.\n"); 339 + psmouse_err(psmouse, "Unable to enable OPC tag.\n"); 349 340 res = -EIO; 350 341 } 351 342 ··· 622 615 .attrs = fsp_attributes, 623 616 }; 624 617 625 - #ifdef FSP_DEBUG 626 - static void fsp_packet_debug(unsigned char packet[]) 618 + #ifdef FSP_DEBUG 619 + static void fsp_packet_debug(struct psmouse *psmouse, unsigned char packet[]) 627 620 { 628 621 static unsigned int ps2_packet_cnt; 629 622 static unsigned int ps2_last_second; 630 623 unsigned int jiffies_msec; 624 + const char *packet_type = "UNKNOWN"; 625 + unsigned short abs_x = 0, abs_y = 0; 626 + 627 + /* Interpret & dump the packet data. */ 628 + switch (packet[0] >> FSP_PKT_TYPE_SHIFT) { 629 + case FSP_PKT_TYPE_ABS: 630 + packet_type = "Absolute"; 631 + abs_x = GET_ABS_X(packet); 632 + abs_y = GET_ABS_Y(packet); 633 + break; 634 + case FSP_PKT_TYPE_NORMAL: 635 + packet_type = "Normal"; 636 + break; 637 + case FSP_PKT_TYPE_NOTIFY: 638 + packet_type = "Notify"; 639 + break; 640 + case FSP_PKT_TYPE_NORMAL_OPC: 641 + packet_type = "Normal-OPC"; 642 + break; 643 + } 631 644 632 645 ps2_packet_cnt++; 633 646 jiffies_msec = jiffies_to_msecs(jiffies); 634 647 psmouse_dbg(psmouse, 635 - "%08dms PS/2 packets: %02x, %02x, %02x, %02x\n", 636 - jiffies_msec, packet[0], packet[1], packet[2], packet[3]); 648 + "%08dms %s packets: %02x, %02x, %02x, %02x; " 649 + "abs_x: %d, abs_y: %d\n", 650 + jiffies_msec, packet_type, 651 + packet[0], packet[1], packet[2], packet[3], abs_x, abs_y); 637 652 638 653 if (jiffies_msec - ps2_last_second > 1000) { 639 654 psmouse_dbg(psmouse, "PS/2 packets/sec = %d\n", ps2_packet_cnt); ··· 664 635 } 665 636 } 666 637 #else 667 - static void fsp_packet_debug(unsigned char packet[]) 638 + static void fsp_packet_debug(struct psmouse *psmouse, unsigned char packet[]) 668 639 { 669 640 } 670 641 #endif 642 + 643 + static void fsp_set_slot(struct input_dev *dev, int slot, bool active, 644 + unsigned int x, unsigned int y) 645 + { 646 + input_mt_slot(dev, slot); 647 + input_mt_report_slot_state(dev, MT_TOOL_FINGER, active); 648 + if (active) { 649 + input_report_abs(dev, ABS_MT_POSITION_X, x); 650 + input_report_abs(dev, ABS_MT_POSITION_Y, y); 651 + } 652 + } 671 653 672 654 static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse) 673 655 { ··· 686 646 struct fsp_data *ad = psmouse->private; 687 647 unsigned char *packet = psmouse->packet; 688 648 unsigned char button_status = 0, lscroll = 0, rscroll = 0; 649 + unsigned short abs_x, abs_y, fgrs = 0; 689 650 int rel_x, rel_y; 690 651 691 652 if (psmouse->pktcnt < 4) ··· 696 655 * Full packet accumulated, process it 697 656 */ 698 657 658 + fsp_packet_debug(psmouse, packet); 659 + 699 660 switch (psmouse->packet[0] >> FSP_PKT_TYPE_SHIFT) { 700 661 case FSP_PKT_TYPE_ABS: 701 - dev_warn(&psmouse->ps2dev.serio->dev, 702 - "Unexpected absolute mode packet, ignored.\n"); 662 + abs_x = GET_ABS_X(packet); 663 + abs_y = GET_ABS_Y(packet); 664 + 665 + if (packet[0] & FSP_PB0_MFMC) { 666 + /* 667 + * MFMC packet: assume that there are two fingers on 668 + * pad 669 + */ 670 + fgrs = 2; 671 + 672 + /* MFMC packet */ 673 + if (packet[0] & FSP_PB0_MFMC_FGR2) { 674 + /* 2nd finger */ 675 + if (ad->last_mt_fgr == 2) { 676 + /* 677 + * workaround for buggy firmware 678 + * which doesn't clear MFMC bit if 679 + * the 1st finger is up 680 + */ 681 + fgrs = 1; 682 + fsp_set_slot(dev, 0, false, 0, 0); 683 + } 684 + ad->last_mt_fgr = 2; 685 + 686 + fsp_set_slot(dev, 1, fgrs == 2, abs_x, abs_y); 687 + } else { 688 + /* 1st finger */ 689 + if (ad->last_mt_fgr == 1) { 690 + /* 691 + * workaround for buggy firmware 692 + * which doesn't clear MFMC bit if 693 + * the 2nd finger is up 694 + */ 695 + fgrs = 1; 696 + fsp_set_slot(dev, 1, false, 0, 0); 697 + } 698 + ad->last_mt_fgr = 1; 699 + fsp_set_slot(dev, 0, fgrs != 0, abs_x, abs_y); 700 + } 701 + } else { 702 + /* SFAC packet */ 703 + 704 + /* no multi-finger information */ 705 + ad->last_mt_fgr = 0; 706 + 707 + if (abs_x != 0 && abs_y != 0) 708 + fgrs = 1; 709 + 710 + fsp_set_slot(dev, 0, fgrs > 0, abs_x, abs_y); 711 + fsp_set_slot(dev, 1, false, 0, 0); 712 + } 713 + if (fgrs > 0) { 714 + input_report_abs(dev, ABS_X, abs_x); 715 + input_report_abs(dev, ABS_Y, abs_y); 716 + } 717 + input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 718 + input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); 719 + input_report_key(dev, BTN_TOUCH, fgrs); 720 + input_report_key(dev, BTN_TOOL_FINGER, fgrs == 1); 721 + input_report_key(dev, BTN_TOOL_DOUBLETAP, fgrs == 2); 703 722 break; 704 723 705 724 case FSP_PKT_TYPE_NORMAL_OPC: 706 725 /* on-pad click, filter it if necessary */ 707 726 if ((ad->flags & FSPDRV_FLAG_EN_OPC) != FSPDRV_FLAG_EN_OPC) 708 - packet[0] &= ~BIT(0); 727 + packet[0] &= ~FSP_PB0_LBTN; 709 728 /* fall through */ 710 729 711 730 case FSP_PKT_TYPE_NORMAL: ··· 812 711 813 712 input_sync(dev); 814 713 815 - fsp_packet_debug(packet); 816 - 817 714 return PSMOUSE_FULL_PACKET; 818 715 } 819 716 ··· 835 736 836 737 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID); 837 738 if (param[0] != 0x04) { 838 - dev_err(&psmouse->ps2dev.serio->dev, 839 - "Unable to enable 4 bytes packet format.\n"); 739 + psmouse_err(psmouse, 740 + "Unable to enable 4 bytes packet format.\n"); 840 741 return -EIO; 841 742 } 842 743 843 - if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &val)) { 844 - dev_err(&psmouse->ps2dev.serio->dev, 845 - "Unable to read SYSCTL5 register.\n"); 846 - return -EIO; 744 + if (pad->ver < FSP_VER_STL3888_C0) { 745 + /* Preparing relative coordinates output for older hardware */ 746 + if (fsp_reg_read(psmouse, FSP_REG_SYSCTL5, &val)) { 747 + psmouse_err(psmouse, 748 + "Unable to read SYSCTL5 register.\n"); 749 + return -EIO; 750 + } 751 + 752 + if (fsp_get_buttons(psmouse, &pad->buttons)) { 753 + psmouse_err(psmouse, 754 + "Unable to retrieve number of buttons.\n"); 755 + return -EIO; 756 + } 757 + 758 + val &= ~(FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8 | FSP_BIT_EN_AUTO_MSID8); 759 + /* Ensure we are not in absolute mode */ 760 + val &= ~FSP_BIT_EN_PKT_G0; 761 + if (pad->buttons == 0x06) { 762 + /* Left/Middle/Right & Scroll Up/Down/Right/Left */ 763 + val |= FSP_BIT_EN_MSID6; 764 + } 765 + 766 + if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, val)) { 767 + psmouse_err(psmouse, 768 + "Unable to set up required mode bits.\n"); 769 + return -EIO; 770 + } 771 + 772 + /* 773 + * Enable OPC tags such that driver can tell the difference 774 + * between on-pad and real button click 775 + */ 776 + if (fsp_opc_tag_enable(psmouse, true)) 777 + psmouse_warn(psmouse, 778 + "Failed to enable OPC tag mode.\n"); 779 + /* enable on-pad click by default */ 780 + pad->flags |= FSPDRV_FLAG_EN_OPC; 781 + 782 + /* Enable on-pad vertical and horizontal scrolling */ 783 + fsp_onpad_vscr(psmouse, true); 784 + fsp_onpad_hscr(psmouse, true); 785 + } else { 786 + /* Enable absolute coordinates output for Cx/Dx hardware */ 787 + if (fsp_reg_write(psmouse, FSP_REG_SWC1, 788 + FSP_BIT_SWC1_EN_ABS_1F | 789 + FSP_BIT_SWC1_EN_ABS_2F | 790 + FSP_BIT_SWC1_EN_FUP_OUT | 791 + FSP_BIT_SWC1_EN_ABS_CON)) { 792 + psmouse_err(psmouse, 793 + "Unable to enable absolute coordinates output.\n"); 794 + return -EIO; 795 + } 847 796 } 848 797 849 - val &= ~(FSP_BIT_EN_MSID7 | FSP_BIT_EN_MSID8 | FSP_BIT_EN_AUTO_MSID8); 850 - /* Ensure we are not in absolute mode */ 851 - val &= ~FSP_BIT_EN_PKT_G0; 852 - if (pad->buttons == 0x06) { 853 - /* Left/Middle/Right & Scroll Up/Down/Right/Left */ 854 - val |= FSP_BIT_EN_MSID6; 798 + return 0; 799 + } 800 + 801 + static int fsp_set_input_params(struct psmouse *psmouse) 802 + { 803 + struct input_dev *dev = psmouse->dev; 804 + struct fsp_data *pad = psmouse->private; 805 + 806 + if (pad->ver < FSP_VER_STL3888_C0) { 807 + __set_bit(BTN_MIDDLE, dev->keybit); 808 + __set_bit(BTN_BACK, dev->keybit); 809 + __set_bit(BTN_FORWARD, dev->keybit); 810 + __set_bit(REL_WHEEL, dev->relbit); 811 + __set_bit(REL_HWHEEL, dev->relbit); 812 + } else { 813 + /* 814 + * Hardware prior to Cx performs much better in relative mode; 815 + * hence, only enable absolute coordinates output as well as 816 + * multi-touch output for the newer hardware. 817 + * 818 + * Maximum coordinates can be computed as: 819 + * 820 + * number of scanlines * 64 - 57 821 + * 822 + * where number of X/Y scanline lines are 16/12. 823 + */ 824 + int abs_x = 967, abs_y = 711; 825 + 826 + __set_bit(EV_ABS, dev->evbit); 827 + __clear_bit(EV_REL, dev->evbit); 828 + __set_bit(BTN_TOUCH, dev->keybit); 829 + __set_bit(BTN_TOOL_FINGER, dev->keybit); 830 + __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit); 831 + __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); 832 + 833 + input_set_abs_params(dev, ABS_X, 0, abs_x, 0, 0); 834 + input_set_abs_params(dev, ABS_Y, 0, abs_y, 0, 0); 835 + input_mt_init_slots(dev, 2); 836 + input_set_abs_params(dev, ABS_MT_POSITION_X, 0, abs_x, 0, 0); 837 + input_set_abs_params(dev, ABS_MT_POSITION_Y, 0, abs_y, 0, 0); 855 838 } 856 - 857 - if (fsp_reg_write(psmouse, FSP_REG_SYSCTL5, val)) { 858 - dev_err(&psmouse->ps2dev.serio->dev, 859 - "Unable to set up required mode bits.\n"); 860 - return -EIO; 861 - } 862 - 863 - /* 864 - * Enable OPC tags such that driver can tell the difference between 865 - * on-pad and real button click 866 - */ 867 - if (fsp_opc_tag_enable(psmouse, true)) 868 - dev_warn(&psmouse->ps2dev.serio->dev, 869 - "Failed to enable OPC tag mode.\n"); 870 - 871 - /* Enable on-pad vertical and horizontal scrolling */ 872 - fsp_onpad_vscr(psmouse, true); 873 - fsp_onpad_hscr(psmouse, true); 874 839 875 840 return 0; 876 841 } ··· 992 829 int fsp_init(struct psmouse *psmouse) 993 830 { 994 831 struct fsp_data *priv; 995 - int ver, rev, buttons; 832 + int ver, rev; 996 833 int error; 997 834 998 835 if (fsp_get_version(psmouse, &ver) || 999 - fsp_get_revision(psmouse, &rev) || 1000 - fsp_get_buttons(psmouse, &buttons)) { 836 + fsp_get_revision(psmouse, &rev)) { 1001 837 return -ENODEV; 1002 838 } 1003 839 1004 - psmouse_info(psmouse, 1005 - "Finger Sensing Pad, hw: %d.%d.%d, sw: %s, buttons: %d\n", 1006 - ver >> 4, ver & 0x0F, rev, fsp_drv_ver, buttons & 7); 840 + psmouse_info(psmouse, "Finger Sensing Pad, hw: %d.%d.%d, sw: %s\n", 841 + ver >> 4, ver & 0x0F, rev, fsp_drv_ver); 1007 842 1008 843 psmouse->private = priv = kzalloc(sizeof(struct fsp_data), GFP_KERNEL); 1009 844 if (!priv) ··· 1009 848 1010 849 priv->ver = ver; 1011 850 priv->rev = rev; 1012 - priv->buttons = buttons; 1013 - 1014 - /* enable on-pad click by default */ 1015 - priv->flags |= FSPDRV_FLAG_EN_OPC; 1016 - 1017 - /* Set up various supported input event bits */ 1018 - __set_bit(BTN_MIDDLE, psmouse->dev->keybit); 1019 - __set_bit(BTN_BACK, psmouse->dev->keybit); 1020 - __set_bit(BTN_FORWARD, psmouse->dev->keybit); 1021 - __set_bit(REL_WHEEL, psmouse->dev->relbit); 1022 - __set_bit(REL_HWHEEL, psmouse->dev->relbit); 1023 851 1024 852 psmouse->protocol_handler = fsp_process_byte; 1025 853 psmouse->disconnect = fsp_disconnect; ··· 1016 866 psmouse->cleanup = fsp_reset; 1017 867 psmouse->pktsize = 4; 1018 868 1019 - /* set default packet output based on number of buttons we found */ 1020 869 error = fsp_activate_protocol(psmouse); 870 + if (error) 871 + goto err_out; 872 + 873 + /* Set up various supported input event bits */ 874 + error = fsp_set_input_params(psmouse); 1021 875 if (error) 1022 876 goto err_out; 1023 877 1024 878 error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj, 1025 879 &fsp_attribute_group); 1026 880 if (error) { 1027 - dev_err(&psmouse->ps2dev.serio->dev, 1028 - "Failed to create sysfs attributes (%d)", error); 881 + psmouse_err(psmouse, 882 + "Failed to create sysfs attributes (%d)", error); 1029 883 goto err_out; 1030 884 } 1031 885
+33 -2
drivers/input/mouse/sentelic.h
··· 2 2 * Finger Sensing Pad PS/2 mouse driver. 3 3 * 4 4 * Copyright (C) 2005-2007 Asia Vital Components Co., Ltd. 5 - * Copyright (C) 2005-2011 Tai-hwa Liang, Sentelic Corporation. 5 + * Copyright (C) 2005-2012 Tai-hwa Liang, Sentelic Corporation. 6 6 * 7 7 * This program is free software; you can redistribute it and/or 8 8 * modify it under the terms of the GNU General Public License ··· 55 55 #define FSP_BIT_FIX_HSCR BIT(5) 56 56 #define FSP_BIT_DRAG_LOCK BIT(6) 57 57 58 + #define FSP_REG_SWC1 (0x90) 59 + #define FSP_BIT_SWC1_EN_ABS_1F BIT(0) 60 + #define FSP_BIT_SWC1_EN_GID BIT(1) 61 + #define FSP_BIT_SWC1_EN_ABS_2F BIT(2) 62 + #define FSP_BIT_SWC1_EN_FUP_OUT BIT(3) 63 + #define FSP_BIT_SWC1_EN_ABS_CON BIT(4) 64 + #define FSP_BIT_SWC1_GST_GRP0 BIT(5) 65 + #define FSP_BIT_SWC1_GST_GRP1 BIT(6) 66 + #define FSP_BIT_SWC1_BX_COMPAT BIT(7) 67 + 58 68 /* Finger-sensing Pad packet formating related definitions */ 59 69 60 70 /* absolute packet type */ ··· 74 64 #define FSP_PKT_TYPE_NORMAL_OPC (0x03) 75 65 #define FSP_PKT_TYPE_SHIFT (6) 76 66 67 + /* bit definitions for the first byte of report packet */ 68 + #define FSP_PB0_LBTN BIT(0) 69 + #define FSP_PB0_RBTN BIT(1) 70 + #define FSP_PB0_MBTN BIT(2) 71 + #define FSP_PB0_MFMC_FGR2 FSP_PB0_MBTN 72 + #define FSP_PB0_MUST_SET BIT(3) 73 + #define FSP_PB0_PHY_BTN BIT(4) 74 + #define FSP_PB0_MFMC BIT(5) 75 + 76 + /* hardware revisions */ 77 + #define FSP_VER_STL3888_A4 (0xC1) 78 + #define FSP_VER_STL3888_B0 (0xD0) 79 + #define FSP_VER_STL3888_B1 (0xD1) 80 + #define FSP_VER_STL3888_B2 (0xD2) 81 + #define FSP_VER_STL3888_C0 (0xE0) 82 + #define FSP_VER_STL3888_C1 (0xE1) 83 + #define FSP_VER_STL3888_D0 (0xE2) 84 + #define FSP_VER_STL3888_D1 (0xE3) 85 + #define FSP_VER_STL3888_E0 (0xE4) 86 + 77 87 #ifdef __KERNEL__ 78 88 79 89 struct fsp_data { 80 90 unsigned char ver; /* hardware version */ 81 91 unsigned char rev; /* hardware revison */ 82 - unsigned char buttons; /* Number of buttons */ 92 + unsigned int buttons; /* Number of buttons */ 83 93 unsigned int flags; 84 94 #define FSPDRV_FLAG_EN_OPC (0x001) /* enable on-pad clicking */ 85 95 ··· 108 78 109 79 unsigned char last_reg; /* Last register we requested read from */ 110 80 unsigned char last_val; 81 + unsigned int last_mt_fgr; /* Last seen finger(multitouch) */ 111 82 }; 112 83 113 84 #ifdef CONFIG_MOUSE_PS2_SENTELIC
+1
drivers/input/tablet/Kconfig
··· 76 76 config TABLET_USB_WACOM 77 77 tristate "Wacom Intuos/Graphire tablet support (USB)" 78 78 depends on USB_ARCH_HAS_HCD 79 + select POWER_SUPPLY 79 80 select USB 80 81 select NEW_LEDS 81 82 select LEDS_CLASS
+9
drivers/input/tablet/wacom.h
··· 88 88 #include <linux/mod_devicetable.h> 89 89 #include <linux/init.h> 90 90 #include <linux/usb/input.h> 91 + #include <linux/power_supply.h> 91 92 #include <asm/unaligned.h> 92 93 93 94 /* ··· 113 112 struct urb *irq; 114 113 struct wacom_wac wacom_wac; 115 114 struct mutex lock; 115 + struct work_struct work; 116 116 bool open; 117 117 char phys[32]; 118 118 struct wacom_led { ··· 122 120 u8 hlv; /* status led brightness button pressed (1..127) */ 123 121 u8 img_lum; /* OLED matrix display brightness */ 124 122 } led; 123 + struct power_supply battery; 125 124 }; 125 + 126 + static inline void wacom_schedule_work(struct wacom_wac *wacom_wac) 127 + { 128 + struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); 129 + schedule_work(&wacom->work); 130 + } 126 131 127 132 extern const struct usb_device_id wacom_ids[]; 128 133
+198 -31
drivers/input/tablet/wacom_sys.c
··· 167 167 usb_autopm_put_interface(wacom->intf); 168 168 } 169 169 170 + /* 171 + * Static values for max X/Y and resolution of Pen interface is stored in 172 + * features. This mean physical size of active area can be computed. 173 + * This is useful to do when Pen and Touch have same active area of tablet. 174 + * This means for Touch device, we only need to find max X/Y value and we 175 + * have enough information to compute resolution of touch. 176 + */ 177 + static void wacom_set_phy_from_res(struct wacom_features *features) 178 + { 179 + features->x_phy = (features->x_max * 100) / features->x_resolution; 180 + features->y_phy = (features->y_max * 100) / features->y_resolution; 181 + } 182 + 170 183 static int wacom_parse_logical_collection(unsigned char *report, 171 184 struct wacom_features *features) 172 185 { ··· 191 178 features->pktlen = WACOM_PKGLEN_BBTOUCH3; 192 179 features->device_type = BTN_TOOL_FINGER; 193 180 194 - /* 195 - * Stylus and Touch have same active area 196 - * so compute physical size based on stylus 197 - * data before its overwritten. 198 - */ 199 - features->x_phy = 200 - (features->x_max * 100) / features->x_resolution; 201 - features->y_phy = 202 - (features->y_max * 100) / features->y_resolution; 181 + wacom_set_phy_from_res(features); 203 182 204 183 features->x_max = features->y_max = 205 184 get_unaligned_le16(&report[10]); ··· 427 422 report_id, rep_data, 4, 1); 428 423 } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES); 429 424 } else if (features->type != TABLETPC && 425 + features->type != WIRELESS && 430 426 features->device_type == BTN_TOOL_PEN) { 431 427 do { 432 428 rep_data[0] = 2; ··· 459 453 features->y_fuzz = 4; 460 454 features->pressure_fuzz = 0; 461 455 features->distance_fuzz = 0; 456 + 457 + /* 458 + * The wireless device HID is basic and layout conflicts with 459 + * other tablets (monitor and touch interface can look like pen). 460 + * Skip the query for this type and modify defaults based on 461 + * interface number. 462 + */ 463 + if (features->type == WIRELESS) { 464 + if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { 465 + features->device_type = 0; 466 + } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { 467 + features->device_type = BTN_TOOL_DOUBLETAP; 468 + features->pktlen = WACOM_PKGLEN_BBTOUCH3; 469 + } 470 + } 462 471 463 472 /* only Tablet PCs and Bamboo P&T need to retrieve the info */ 464 473 if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) && ··· 843 822 } 844 823 } 845 824 825 + static enum power_supply_property wacom_battery_props[] = { 826 + POWER_SUPPLY_PROP_CAPACITY 827 + }; 828 + 829 + static int wacom_battery_get_property(struct power_supply *psy, 830 + enum power_supply_property psp, 831 + union power_supply_propval *val) 832 + { 833 + struct wacom *wacom = container_of(psy, struct wacom, battery); 834 + int ret = 0; 835 + 836 + switch (psp) { 837 + case POWER_SUPPLY_PROP_CAPACITY: 838 + val->intval = 839 + wacom->wacom_wac.battery_capacity * 100 / 31; 840 + break; 841 + default: 842 + ret = -EINVAL; 843 + break; 844 + } 845 + 846 + return ret; 847 + } 848 + 849 + static int wacom_initialize_battery(struct wacom *wacom) 850 + { 851 + int error = 0; 852 + 853 + if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR) { 854 + wacom->battery.properties = wacom_battery_props; 855 + wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props); 856 + wacom->battery.get_property = wacom_battery_get_property; 857 + wacom->battery.name = "wacom_battery"; 858 + wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY; 859 + wacom->battery.use_for_apm = 0; 860 + 861 + error = power_supply_register(&wacom->usbdev->dev, 862 + &wacom->battery); 863 + } 864 + 865 + return error; 866 + } 867 + 868 + static void wacom_destroy_battery(struct wacom *wacom) 869 + { 870 + if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR) 871 + power_supply_unregister(&wacom->battery); 872 + } 873 + 874 + static int wacom_register_input(struct wacom *wacom) 875 + { 876 + struct input_dev *input_dev; 877 + struct usb_interface *intf = wacom->intf; 878 + struct usb_device *dev = interface_to_usbdev(intf); 879 + struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 880 + int error; 881 + 882 + input_dev = input_allocate_device(); 883 + if (!input_dev) 884 + return -ENOMEM; 885 + 886 + input_dev->name = wacom_wac->name; 887 + input_dev->dev.parent = &intf->dev; 888 + input_dev->open = wacom_open; 889 + input_dev->close = wacom_close; 890 + usb_to_input_id(dev, &input_dev->id); 891 + input_set_drvdata(input_dev, wacom); 892 + 893 + wacom_wac->input = input_dev; 894 + wacom_setup_input_capabilities(input_dev, wacom_wac); 895 + 896 + error = input_register_device(input_dev); 897 + if (error) { 898 + input_free_device(input_dev); 899 + wacom_wac->input = NULL; 900 + } 901 + 902 + return error; 903 + } 904 + 905 + static void wacom_wireless_work(struct work_struct *work) 906 + { 907 + struct wacom *wacom = container_of(work, struct wacom, work); 908 + struct usb_device *usbdev = wacom->usbdev; 909 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 910 + 911 + /* 912 + * Regardless if this is a disconnect or a new tablet, 913 + * remove any existing input devices. 914 + */ 915 + 916 + /* Stylus interface */ 917 + wacom = usb_get_intfdata(usbdev->config->interface[1]); 918 + if (wacom->wacom_wac.input) 919 + input_unregister_device(wacom->wacom_wac.input); 920 + wacom->wacom_wac.input = 0; 921 + 922 + /* Touch interface */ 923 + wacom = usb_get_intfdata(usbdev->config->interface[2]); 924 + if (wacom->wacom_wac.input) 925 + input_unregister_device(wacom->wacom_wac.input); 926 + wacom->wacom_wac.input = 0; 927 + 928 + if (wacom_wac->pid == 0) { 929 + printk(KERN_INFO "wacom: wireless tablet disconnected\n"); 930 + } else { 931 + const struct usb_device_id *id = wacom_ids; 932 + 933 + printk(KERN_INFO 934 + "wacom: wireless tablet connected with PID %x\n", 935 + wacom_wac->pid); 936 + 937 + while (id->match_flags) { 938 + if (id->idVendor == USB_VENDOR_ID_WACOM && 939 + id->idProduct == wacom_wac->pid) 940 + break; 941 + id++; 942 + } 943 + 944 + if (!id->match_flags) { 945 + printk(KERN_INFO 946 + "wacom: ignorning unknown PID.\n"); 947 + return; 948 + } 949 + 950 + /* Stylus interface */ 951 + wacom = usb_get_intfdata(usbdev->config->interface[1]); 952 + wacom_wac = &wacom->wacom_wac; 953 + wacom_wac->features = 954 + *((struct wacom_features *)id->driver_info); 955 + wacom_wac->features.device_type = BTN_TOOL_PEN; 956 + wacom_register_input(wacom); 957 + 958 + /* Touch interface */ 959 + wacom = usb_get_intfdata(usbdev->config->interface[2]); 960 + wacom_wac = &wacom->wacom_wac; 961 + wacom_wac->features = 962 + *((struct wacom_features *)id->driver_info); 963 + wacom_wac->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 964 + wacom_wac->features.device_type = BTN_TOOL_FINGER; 965 + wacom_set_phy_from_res(&wacom_wac->features); 966 + wacom_wac->features.x_max = wacom_wac->features.y_max = 4096; 967 + wacom_register_input(wacom); 968 + } 969 + } 970 + 846 971 static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 847 972 { 848 973 struct usb_device *dev = interface_to_usbdev(intf); ··· 996 829 struct wacom *wacom; 997 830 struct wacom_wac *wacom_wac; 998 831 struct wacom_features *features; 999 - struct input_dev *input_dev; 1000 832 int error; 1001 833 1002 834 if (!id->driver_info) 1003 835 return -EINVAL; 1004 836 1005 837 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 1006 - input_dev = input_allocate_device(); 1007 - if (!wacom || !input_dev) { 1008 - error = -ENOMEM; 1009 - goto fail1; 1010 - } 1011 838 1012 839 wacom_wac = &wacom->wacom_wac; 1013 840 wacom_wac->features = *((struct wacom_features *)id->driver_info); ··· 1027 866 wacom->usbdev = dev; 1028 867 wacom->intf = intf; 1029 868 mutex_init(&wacom->lock); 869 + INIT_WORK(&wacom->work, wacom_wireless_work); 1030 870 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 1031 871 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 1032 - 1033 - wacom_wac->input = input_dev; 1034 872 1035 873 endpoint = &intf->cur_altsetting->endpoint[0].desc; 1036 874 ··· 1054 894 goto fail3; 1055 895 } 1056 896 1057 - input_dev->name = wacom_wac->name; 1058 - input_dev->dev.parent = &intf->dev; 1059 - input_dev->open = wacom_open; 1060 - input_dev->close = wacom_close; 1061 - usb_to_input_id(dev, &input_dev->id); 1062 - input_set_drvdata(input_dev, wacom); 1063 - 1064 - wacom_setup_input_capabilities(input_dev, wacom_wac); 1065 - 1066 897 usb_fill_int_urb(wacom->irq, dev, 1067 898 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 1068 899 wacom_wac->data, features->pktlen, ··· 1065 914 if (error) 1066 915 goto fail4; 1067 916 1068 - error = input_register_device(input_dev); 917 + error = wacom_initialize_battery(wacom); 1069 918 if (error) 1070 919 goto fail5; 920 + 921 + if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { 922 + error = wacom_register_input(wacom); 923 + if (error) 924 + goto fail6; 925 + } 1071 926 1072 927 /* Note that if query fails it is not a hard failure */ 1073 928 wacom_query_tablet_data(intf, features); 1074 929 1075 930 usb_set_intfdata(intf, wacom); 931 + 932 + if (features->quirks & WACOM_QUIRK_MONITOR) { 933 + if (usb_submit_urb(wacom->irq, GFP_KERNEL)) 934 + goto fail5; 935 + } 936 + 1076 937 return 0; 1077 938 939 + fail6: wacom_destroy_battery(wacom); 1078 940 fail5: wacom_destroy_leds(wacom); 1079 941 fail4: wacom_remove_shared_data(wacom_wac); 1080 942 fail3: usb_free_urb(wacom->irq); 1081 943 fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma); 1082 - fail1: input_free_device(input_dev); 1083 - kfree(wacom); 944 + fail1: kfree(wacom); 1084 945 return error; 1085 946 } 1086 947 ··· 1103 940 usb_set_intfdata(intf, NULL); 1104 941 1105 942 usb_kill_urb(wacom->irq); 1106 - input_unregister_device(wacom->wacom_wac.input); 943 + cancel_work_sync(&wacom->work); 944 + if (wacom->wacom_wac.input) 945 + input_unregister_device(wacom->wacom_wac.input); 946 + wacom_destroy_battery(wacom); 1107 947 wacom_destroy_leds(wacom); 1108 948 usb_free_urb(wacom->irq); 1109 949 usb_free_coherent(interface_to_usbdev(intf), WACOM_PKGLEN_MAX, ··· 1138 972 wacom_query_tablet_data(intf, features); 1139 973 wacom_led_control(wacom); 1140 974 1141 - if (wacom->open && usb_submit_urb(wacom->irq, GFP_NOIO) < 0) 975 + if ((wacom->open || features->quirks & WACOM_QUIRK_MONITOR) 976 + && usb_submit_urb(wacom->irq, GFP_NOIO) < 0) 1142 977 rv = -EIO; 1143 978 1144 979 mutex_unlock(&wacom->lock);
+48 -1
drivers/input/tablet/wacom_wac.c
··· 1044 1044 return 0; 1045 1045 } 1046 1046 1047 + static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len) 1048 + { 1049 + unsigned char *data = wacom->data; 1050 + int connected; 1051 + 1052 + if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80) 1053 + return 0; 1054 + 1055 + connected = data[1] & 0x01; 1056 + if (connected) { 1057 + int pid, battery; 1058 + 1059 + pid = get_unaligned_be16(&data[6]); 1060 + battery = data[5] & 0x3f; 1061 + if (wacom->pid != pid) { 1062 + wacom->pid = pid; 1063 + wacom_schedule_work(wacom); 1064 + } 1065 + wacom->battery_capacity = battery; 1066 + } else if (wacom->pid != 0) { 1067 + /* disconnected while previously connected */ 1068 + wacom->pid = 0; 1069 + wacom_schedule_work(wacom); 1070 + wacom->battery_capacity = 0; 1071 + } 1072 + 1073 + return 0; 1074 + } 1075 + 1047 1076 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) 1048 1077 { 1049 1078 bool sync; ··· 1121 1092 1122 1093 case BAMBOO_PT: 1123 1094 sync = wacom_bpt_irq(wacom_wac, len); 1095 + break; 1096 + 1097 + case WIRELESS: 1098 + sync = wacom_wireless_irq(wacom_wac, len); 1124 1099 break; 1125 1100 1126 1101 default: ··· 1188 1155 1189 1156 /* these device have multiple inputs */ 1190 1157 if (features->type == TABLETPC || features->type == TABLETPC2FG || 1191 - features->type == BAMBOO_PT) 1158 + features->type == BAMBOO_PT || features->type == WIRELESS) 1192 1159 features->quirks |= WACOM_QUIRK_MULTI_INPUT; 1193 1160 1194 1161 /* quirk for bamboo touch with 2 low res touches */ ··· 1199 1166 features->x_fuzz <<= 5; 1200 1167 features->y_fuzz <<= 5; 1201 1168 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES; 1169 + } 1170 + 1171 + if (features->type == WIRELESS) { 1172 + 1173 + /* monitor never has input and pen/touch have delayed create */ 1174 + features->quirks |= WACOM_QUIRK_NO_INPUT; 1175 + 1176 + /* must be monitor interface if no device_type set */ 1177 + if (!features->device_type) 1178 + features->quirks |= WACOM_QUIRK_MONITOR; 1202 1179 } 1203 1180 } 1204 1181 ··· 1683 1640 static const struct wacom_features wacom_features_0x47 = 1684 1641 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 1685 1642 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1643 + static const struct wacom_features wacom_features_0x84 = 1644 + { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0, 1645 + 0, WIRELESS, 0, 0 }; 1686 1646 static const struct wacom_features wacom_features_0xD0 = 1687 1647 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 1688 1648 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; ··· 1812 1766 { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID, 1813 1767 USB_INTERFACE_SUBCLASS_BOOT, 1814 1768 USB_INTERFACE_PROTOCOL_MOUSE) }, 1769 + { USB_DEVICE_WACOM(0x84) }, 1815 1770 { USB_DEVICE_WACOM(0xD0) }, 1816 1771 { USB_DEVICE_WACOM(0xD1) }, 1817 1772 { USB_DEVICE_WACOM(0xD2) },
+6
drivers/input/tablet/wacom_wac.h
··· 24 24 #define WACOM_PKGLEN_BBTOUCH 20 25 25 #define WACOM_PKGLEN_BBTOUCH3 64 26 26 #define WACOM_PKGLEN_BBPEN 10 27 + #define WACOM_PKGLEN_WIRELESS 32 27 28 28 29 /* device IDs */ 29 30 #define STYLUS_DEVICE_ID 0x02 ··· 46 45 /* device quirks */ 47 46 #define WACOM_QUIRK_MULTI_INPUT 0x0001 48 47 #define WACOM_QUIRK_BBTOUCH_LOWRES 0x0002 48 + #define WACOM_QUIRK_NO_INPUT 0x0004 49 + #define WACOM_QUIRK_MONITOR 0x0008 49 50 50 51 enum { 51 52 PENPARTNER = 0, ··· 57 54 PL, 58 55 DTU, 59 56 BAMBOO_PT, 57 + WIRELESS, 60 58 INTUOS, 61 59 INTUOS3S, 62 60 INTUOS3, ··· 111 107 struct wacom_features features; 112 108 struct wacom_shared *shared; 113 109 struct input_dev *input; 110 + int pid; 111 + int battery_capacity; 114 112 }; 115 113 116 114 #endif
+2 -1
include/linux/gpio_keys.h
··· 6 6 struct gpio_keys_button { 7 7 /* Configuration parameters */ 8 8 unsigned int code; /* input event code (KEY_*, SW_*) */ 9 - int gpio; 9 + int gpio; /* -1 if this key does not support gpio */ 10 10 int active_low; 11 11 const char *desc; 12 12 unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */ ··· 14 14 int debounce_interval; /* debounce ticks interval in msecs */ 15 15 bool can_disable; 16 16 int value; /* axis value for EV_ABS */ 17 + unsigned int irq; /* Irq number in case of interrupt keys */ 17 18 }; 18 19 19 20 struct gpio_keys_platform_data {