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