diff options
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/evdev.c | 60 | ||||
-rw-r--r-- | drivers/input/input.c | 22 | ||||
-rw-r--r-- | drivers/input/keyboard/Kconfig | 1 | ||||
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 114 | ||||
-rw-r--r-- | drivers/input/keyboard/hil_kbd.c | 6 | ||||
-rw-r--r-- | drivers/input/keyboard/stmpe-keypad.c | 141 | ||||
-rw-r--r-- | drivers/input/mouse/alps.c | 84 | ||||
-rw-r--r-- | drivers/input/mouse/trackpoint.c | 4 | ||||
-rw-r--r-- | drivers/input/mouse/trackpoint.h | 5 | ||||
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 99 | ||||
-rw-r--r-- | drivers/input/touchscreen/edt-ft5x06.c | 4 |
11 files changed, 310 insertions, 230 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 8afa28e4570e..18d4b2c8fe55 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -28,6 +28,13 @@ | |||
28 | #include <linux/cdev.h> | 28 | #include <linux/cdev.h> |
29 | #include "input-compat.h" | 29 | #include "input-compat.h" |
30 | 30 | ||
31 | enum evdev_clock_type { | ||
32 | EV_CLK_REAL = 0, | ||
33 | EV_CLK_MONO, | ||
34 | EV_CLK_BOOT, | ||
35 | EV_CLK_MAX | ||
36 | }; | ||
37 | |||
31 | struct evdev { | 38 | struct evdev { |
32 | int open; | 39 | int open; |
33 | struct input_handle handle; | 40 | struct input_handle handle; |
@@ -49,12 +56,32 @@ struct evdev_client { | |||
49 | struct fasync_struct *fasync; | 56 | struct fasync_struct *fasync; |
50 | struct evdev *evdev; | 57 | struct evdev *evdev; |
51 | struct list_head node; | 58 | struct list_head node; |
52 | int clkid; | 59 | int clk_type; |
53 | bool revoked; | 60 | bool revoked; |
54 | unsigned int bufsize; | 61 | unsigned int bufsize; |
55 | struct input_event buffer[]; | 62 | struct input_event buffer[]; |
56 | }; | 63 | }; |
57 | 64 | ||
65 | static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid) | ||
66 | { | ||
67 | switch (clkid) { | ||
68 | |||
69 | case CLOCK_REALTIME: | ||
70 | client->clk_type = EV_CLK_REAL; | ||
71 | break; | ||
72 | case CLOCK_MONOTONIC: | ||
73 | client->clk_type = EV_CLK_MONO; | ||
74 | break; | ||
75 | case CLOCK_BOOTTIME: | ||
76 | client->clk_type = EV_CLK_BOOT; | ||
77 | break; | ||
78 | default: | ||
79 | return -EINVAL; | ||
80 | } | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | |||
58 | /* flush queued events of type @type, caller must hold client->buffer_lock */ | 85 | /* flush queued events of type @type, caller must hold client->buffer_lock */ |
59 | static void __evdev_flush_queue(struct evdev_client *client, unsigned int type) | 86 | static void __evdev_flush_queue(struct evdev_client *client, unsigned int type) |
60 | { | 87 | { |
@@ -108,8 +135,11 @@ static void evdev_queue_syn_dropped(struct evdev_client *client) | |||
108 | struct input_event ev; | 135 | struct input_event ev; |
109 | ktime_t time; | 136 | ktime_t time; |
110 | 137 | ||
111 | time = (client->clkid == CLOCK_MONOTONIC) ? | 138 | time = client->clk_type == EV_CLK_REAL ? |
112 | ktime_get() : ktime_get_real(); | 139 | ktime_get_real() : |
140 | client->clk_type == EV_CLK_MONO ? | ||
141 | ktime_get() : | ||
142 | ktime_get_boottime(); | ||
113 | 143 | ||
114 | ev.time = ktime_to_timeval(time); | 144 | ev.time = ktime_to_timeval(time); |
115 | ev.type = EV_SYN; | 145 | ev.type = EV_SYN; |
@@ -159,7 +189,7 @@ static void __pass_event(struct evdev_client *client, | |||
159 | 189 | ||
160 | static void evdev_pass_values(struct evdev_client *client, | 190 | static void evdev_pass_values(struct evdev_client *client, |
161 | const struct input_value *vals, unsigned int count, | 191 | const struct input_value *vals, unsigned int count, |
162 | ktime_t mono, ktime_t real) | 192 | ktime_t *ev_time) |
163 | { | 193 | { |
164 | struct evdev *evdev = client->evdev; | 194 | struct evdev *evdev = client->evdev; |
165 | const struct input_value *v; | 195 | const struct input_value *v; |
@@ -169,8 +199,7 @@ static void evdev_pass_values(struct evdev_client *client, | |||
169 | if (client->revoked) | 199 | if (client->revoked) |
170 | return; | 200 | return; |
171 | 201 | ||
172 | event.time = ktime_to_timeval(client->clkid == CLOCK_MONOTONIC ? | 202 | event.time = ktime_to_timeval(ev_time[client->clk_type]); |
173 | mono : real); | ||
174 | 203 | ||
175 | /* Interrupts are disabled, just acquire the lock. */ | 204 | /* Interrupts are disabled, just acquire the lock. */ |
176 | spin_lock(&client->buffer_lock); | 205 | spin_lock(&client->buffer_lock); |
@@ -198,21 +227,22 @@ static void evdev_events(struct input_handle *handle, | |||
198 | { | 227 | { |
199 | struct evdev *evdev = handle->private; | 228 | struct evdev *evdev = handle->private; |
200 | struct evdev_client *client; | 229 | struct evdev_client *client; |
201 | ktime_t time_mono, time_real; | 230 | ktime_t ev_time[EV_CLK_MAX]; |
202 | 231 | ||
203 | time_mono = ktime_get(); | 232 | ev_time[EV_CLK_MONO] = ktime_get(); |
204 | time_real = ktime_mono_to_real(time_mono); | 233 | ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]); |
234 | ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO], | ||
235 | TK_OFFS_BOOT); | ||
205 | 236 | ||
206 | rcu_read_lock(); | 237 | rcu_read_lock(); |
207 | 238 | ||
208 | client = rcu_dereference(evdev->grab); | 239 | client = rcu_dereference(evdev->grab); |
209 | 240 | ||
210 | if (client) | 241 | if (client) |
211 | evdev_pass_values(client, vals, count, time_mono, time_real); | 242 | evdev_pass_values(client, vals, count, ev_time); |
212 | else | 243 | else |
213 | list_for_each_entry_rcu(client, &evdev->client_list, node) | 244 | list_for_each_entry_rcu(client, &evdev->client_list, node) |
214 | evdev_pass_values(client, vals, count, | 245 | evdev_pass_values(client, vals, count, ev_time); |
215 | time_mono, time_real); | ||
216 | 246 | ||
217 | rcu_read_unlock(); | 247 | rcu_read_unlock(); |
218 | } | 248 | } |
@@ -877,10 +907,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, | |||
877 | case EVIOCSCLOCKID: | 907 | case EVIOCSCLOCKID: |
878 | if (copy_from_user(&i, p, sizeof(unsigned int))) | 908 | if (copy_from_user(&i, p, sizeof(unsigned int))) |
879 | return -EFAULT; | 909 | return -EFAULT; |
880 | if (i != CLOCK_MONOTONIC && i != CLOCK_REALTIME) | 910 | |
881 | return -EINVAL; | 911 | return evdev_set_clk_type(client, i); |
882 | client->clkid = i; | ||
883 | return 0; | ||
884 | 912 | ||
885 | case EVIOCGKEYCODE: | 913 | case EVIOCGKEYCODE: |
886 | return evdev_handle_get_keycode(dev, p); | 914 | return evdev_handle_get_keycode(dev, p); |
diff --git a/drivers/input/input.c b/drivers/input/input.c index 04217c2e345c..213e3a1903ee 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -1974,18 +1974,22 @@ static unsigned int input_estimate_events_per_packet(struct input_dev *dev) | |||
1974 | 1974 | ||
1975 | events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */ | 1975 | events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */ |
1976 | 1976 | ||
1977 | for (i = 0; i < ABS_CNT; i++) { | 1977 | if (test_bit(EV_ABS, dev->evbit)) { |
1978 | if (test_bit(i, dev->absbit)) { | 1978 | for (i = 0; i < ABS_CNT; i++) { |
1979 | if (input_is_mt_axis(i)) | 1979 | if (test_bit(i, dev->absbit)) { |
1980 | events += mt_slots; | 1980 | if (input_is_mt_axis(i)) |
1981 | else | 1981 | events += mt_slots; |
1982 | events++; | 1982 | else |
1983 | events++; | ||
1984 | } | ||
1983 | } | 1985 | } |
1984 | } | 1986 | } |
1985 | 1987 | ||
1986 | for (i = 0; i < REL_CNT; i++) | 1988 | if (test_bit(EV_REL, dev->evbit)) { |
1987 | if (test_bit(i, dev->relbit)) | 1989 | for (i = 0; i < REL_CNT; i++) |
1988 | events++; | 1990 | if (test_bit(i, dev->relbit)) |
1991 | events++; | ||
1992 | } | ||
1989 | 1993 | ||
1990 | /* Make room for KEY and MSC events */ | 1994 | /* Make room for KEY and MSC events */ |
1991 | events += 7; | 1995 | events += 7; |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 96ee26c555e0..a5d9b3f3c871 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -559,6 +559,7 @@ config KEYBOARD_SH_KEYSC | |||
559 | config KEYBOARD_STMPE | 559 | config KEYBOARD_STMPE |
560 | tristate "STMPE keypad support" | 560 | tristate "STMPE keypad support" |
561 | depends on MFD_STMPE | 561 | depends on MFD_STMPE |
562 | depends on OF | ||
562 | select INPUT_MATRIXKMAP | 563 | select INPUT_MATRIXKMAP |
563 | help | 564 | help |
564 | Say Y here if you want to use the keypad controller on STMPE I/O | 565 | Say Y here if you want to use the keypad controller on STMPE I/O |
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index d4dd78a7d56b..883d6aed5b9a 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -35,9 +35,13 @@ | |||
35 | struct gpio_button_data { | 35 | struct gpio_button_data { |
36 | const struct gpio_keys_button *button; | 36 | const struct gpio_keys_button *button; |
37 | struct input_dev *input; | 37 | struct input_dev *input; |
38 | struct timer_list timer; | 38 | |
39 | struct work_struct work; | 39 | struct timer_list release_timer; |
40 | unsigned int timer_debounce; /* in msecs */ | 40 | unsigned int release_delay; /* in msecs, for IRQ-only buttons */ |
41 | |||
42 | struct delayed_work work; | ||
43 | unsigned int software_debounce; /* in msecs, for GPIO-driven buttons */ | ||
44 | |||
41 | unsigned int irq; | 45 | unsigned int irq; |
42 | spinlock_t lock; | 46 | spinlock_t lock; |
43 | bool disabled; | 47 | bool disabled; |
@@ -116,11 +120,14 @@ static void gpio_keys_disable_button(struct gpio_button_data *bdata) | |||
116 | { | 120 | { |
117 | if (!bdata->disabled) { | 121 | if (!bdata->disabled) { |
118 | /* | 122 | /* |
119 | * Disable IRQ and possible debouncing timer. | 123 | * Disable IRQ and associated timer/work structure. |
120 | */ | 124 | */ |
121 | disable_irq(bdata->irq); | 125 | disable_irq(bdata->irq); |
122 | if (bdata->timer_debounce) | 126 | |
123 | del_timer_sync(&bdata->timer); | 127 | if (gpio_is_valid(bdata->button->gpio)) |
128 | cancel_delayed_work_sync(&bdata->work); | ||
129 | else | ||
130 | del_timer_sync(&bdata->release_timer); | ||
124 | 131 | ||
125 | bdata->disabled = true; | 132 | bdata->disabled = true; |
126 | } | 133 | } |
@@ -343,7 +350,7 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) | |||
343 | static void gpio_keys_gpio_work_func(struct work_struct *work) | 350 | static void gpio_keys_gpio_work_func(struct work_struct *work) |
344 | { | 351 | { |
345 | struct gpio_button_data *bdata = | 352 | struct gpio_button_data *bdata = |
346 | container_of(work, struct gpio_button_data, work); | 353 | container_of(work, struct gpio_button_data, work.work); |
347 | 354 | ||
348 | gpio_keys_gpio_report_event(bdata); | 355 | gpio_keys_gpio_report_event(bdata); |
349 | 356 | ||
@@ -351,13 +358,6 @@ static void gpio_keys_gpio_work_func(struct work_struct *work) | |||
351 | pm_relax(bdata->input->dev.parent); | 358 | pm_relax(bdata->input->dev.parent); |
352 | } | 359 | } |
353 | 360 | ||
354 | static void gpio_keys_gpio_timer(unsigned long _data) | ||
355 | { | ||
356 | struct gpio_button_data *bdata = (struct gpio_button_data *)_data; | ||
357 | |||
358 | schedule_work(&bdata->work); | ||
359 | } | ||
360 | |||
361 | static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) | 361 | static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) |
362 | { | 362 | { |
363 | struct gpio_button_data *bdata = dev_id; | 363 | struct gpio_button_data *bdata = dev_id; |
@@ -366,11 +366,10 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) | |||
366 | 366 | ||
367 | if (bdata->button->wakeup) | 367 | if (bdata->button->wakeup) |
368 | pm_stay_awake(bdata->input->dev.parent); | 368 | pm_stay_awake(bdata->input->dev.parent); |
369 | if (bdata->timer_debounce) | 369 | |
370 | mod_timer(&bdata->timer, | 370 | mod_delayed_work(system_wq, |
371 | jiffies + msecs_to_jiffies(bdata->timer_debounce)); | 371 | &bdata->work, |
372 | else | 372 | msecs_to_jiffies(bdata->software_debounce)); |
373 | schedule_work(&bdata->work); | ||
374 | 373 | ||
375 | return IRQ_HANDLED; | 374 | return IRQ_HANDLED; |
376 | } | 375 | } |
@@ -408,7 +407,7 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) | |||
408 | input_event(input, EV_KEY, button->code, 1); | 407 | input_event(input, EV_KEY, button->code, 1); |
409 | input_sync(input); | 408 | input_sync(input); |
410 | 409 | ||
411 | if (!bdata->timer_debounce) { | 410 | if (!bdata->release_delay) { |
412 | input_event(input, EV_KEY, button->code, 0); | 411 | input_event(input, EV_KEY, button->code, 0); |
413 | input_sync(input); | 412 | input_sync(input); |
414 | goto out; | 413 | goto out; |
@@ -417,9 +416,9 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) | |||
417 | bdata->key_pressed = true; | 416 | bdata->key_pressed = true; |
418 | } | 417 | } |
419 | 418 | ||
420 | if (bdata->timer_debounce) | 419 | if (bdata->release_delay) |
421 | mod_timer(&bdata->timer, | 420 | mod_timer(&bdata->release_timer, |
422 | jiffies + msecs_to_jiffies(bdata->timer_debounce)); | 421 | jiffies + msecs_to_jiffies(bdata->release_delay)); |
423 | out: | 422 | out: |
424 | spin_unlock_irqrestore(&bdata->lock, flags); | 423 | spin_unlock_irqrestore(&bdata->lock, flags); |
425 | return IRQ_HANDLED; | 424 | return IRQ_HANDLED; |
@@ -429,10 +428,10 @@ static void gpio_keys_quiesce_key(void *data) | |||
429 | { | 428 | { |
430 | struct gpio_button_data *bdata = data; | 429 | struct gpio_button_data *bdata = data; |
431 | 430 | ||
432 | if (bdata->timer_debounce) | 431 | if (gpio_is_valid(bdata->button->gpio)) |
433 | del_timer_sync(&bdata->timer); | 432 | cancel_delayed_work_sync(&bdata->work); |
434 | 433 | else | |
435 | cancel_work_sync(&bdata->work); | 434 | del_timer_sync(&bdata->release_timer); |
436 | } | 435 | } |
437 | 436 | ||
438 | static int gpio_keys_setup_key(struct platform_device *pdev, | 437 | static int gpio_keys_setup_key(struct platform_device *pdev, |
@@ -466,23 +465,25 @@ static int gpio_keys_setup_key(struct platform_device *pdev, | |||
466 | button->debounce_interval * 1000); | 465 | button->debounce_interval * 1000); |
467 | /* use timer if gpiolib doesn't provide debounce */ | 466 | /* use timer if gpiolib doesn't provide debounce */ |
468 | if (error < 0) | 467 | if (error < 0) |
469 | bdata->timer_debounce = | 468 | bdata->software_debounce = |
470 | button->debounce_interval; | 469 | button->debounce_interval; |
471 | } | 470 | } |
472 | 471 | ||
473 | irq = gpio_to_irq(button->gpio); | 472 | if (button->irq) { |
474 | if (irq < 0) { | 473 | bdata->irq = button->irq; |
475 | error = irq; | 474 | } else { |
476 | dev_err(dev, | 475 | irq = gpio_to_irq(button->gpio); |
477 | "Unable to get irq number for GPIO %d, error %d\n", | 476 | if (irq < 0) { |
478 | button->gpio, error); | 477 | error = irq; |
479 | return error; | 478 | dev_err(dev, |
479 | "Unable to get irq number for GPIO %d, error %d\n", | ||
480 | button->gpio, error); | ||
481 | return error; | ||
482 | } | ||
483 | bdata->irq = irq; | ||
480 | } | 484 | } |
481 | bdata->irq = irq; | ||
482 | 485 | ||
483 | INIT_WORK(&bdata->work, gpio_keys_gpio_work_func); | 486 | INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func); |
484 | setup_timer(&bdata->timer, | ||
485 | gpio_keys_gpio_timer, (unsigned long)bdata); | ||
486 | 487 | ||
487 | isr = gpio_keys_gpio_isr; | 488 | isr = gpio_keys_gpio_isr; |
488 | irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; | 489 | irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; |
@@ -499,8 +500,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, | |||
499 | return -EINVAL; | 500 | return -EINVAL; |
500 | } | 501 | } |
501 | 502 | ||
502 | bdata->timer_debounce = button->debounce_interval; | 503 | bdata->release_delay = button->debounce_interval; |
503 | setup_timer(&bdata->timer, | 504 | setup_timer(&bdata->release_timer, |
504 | gpio_keys_irq_timer, (unsigned long)bdata); | 505 | gpio_keys_irq_timer, (unsigned long)bdata); |
505 | 506 | ||
506 | isr = gpio_keys_irq_isr; | 507 | isr = gpio_keys_irq_isr; |
@@ -510,7 +511,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, | |||
510 | input_set_capability(input, button->type ?: EV_KEY, button->code); | 511 | input_set_capability(input, button->type ?: EV_KEY, button->code); |
511 | 512 | ||
512 | /* | 513 | /* |
513 | * Install custom action to cancel debounce timer and | 514 | * Install custom action to cancel release timer and |
514 | * workqueue item. | 515 | * workqueue item. |
515 | */ | 516 | */ |
516 | error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata); | 517 | error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata); |
@@ -618,33 +619,30 @@ gpio_keys_get_devtree_pdata(struct device *dev) | |||
618 | 619 | ||
619 | i = 0; | 620 | i = 0; |
620 | for_each_child_of_node(node, pp) { | 621 | for_each_child_of_node(node, pp) { |
621 | int gpio = -1; | ||
622 | enum of_gpio_flags flags; | 622 | enum of_gpio_flags flags; |
623 | 623 | ||
624 | button = &pdata->buttons[i++]; | 624 | button = &pdata->buttons[i++]; |
625 | 625 | ||
626 | if (!of_find_property(pp, "gpios", NULL)) { | 626 | button->gpio = of_get_gpio_flags(pp, 0, &flags); |
627 | button->irq = irq_of_parse_and_map(pp, 0); | 627 | if (button->gpio < 0) { |
628 | if (button->irq == 0) { | 628 | error = button->gpio; |
629 | i--; | 629 | if (error != -ENOENT) { |
630 | pdata->nbuttons--; | ||
631 | dev_warn(dev, "Found button without gpios or irqs\n"); | ||
632 | continue; | ||
633 | } | ||
634 | } else { | ||
635 | gpio = of_get_gpio_flags(pp, 0, &flags); | ||
636 | if (gpio < 0) { | ||
637 | error = gpio; | ||
638 | if (error != -EPROBE_DEFER) | 630 | if (error != -EPROBE_DEFER) |
639 | dev_err(dev, | 631 | dev_err(dev, |
640 | "Failed to get gpio flags, error: %d\n", | 632 | "Failed to get gpio flags, error: %d\n", |
641 | error); | 633 | error); |
642 | return ERR_PTR(error); | 634 | return ERR_PTR(error); |
643 | } | 635 | } |
636 | } else { | ||
637 | button->active_low = flags & OF_GPIO_ACTIVE_LOW; | ||
644 | } | 638 | } |
645 | 639 | ||
646 | button->gpio = gpio; | 640 | button->irq = irq_of_parse_and_map(pp, 0); |
647 | button->active_low = flags & OF_GPIO_ACTIVE_LOW; | 641 | |
642 | if (!gpio_is_valid(button->gpio) && !button->irq) { | ||
643 | dev_err(dev, "Found button without gpios or irqs\n"); | ||
644 | return ERR_PTR(-EINVAL); | ||
645 | } | ||
648 | 646 | ||
649 | if (of_property_read_u32(pp, "linux,code", &button->code)) { | 647 | if (of_property_read_u32(pp, "linux,code", &button->code)) { |
650 | dev_err(dev, "Button without keycode: 0x%x\n", | 648 | dev_err(dev, "Button without keycode: 0x%x\n", |
@@ -659,6 +657,8 @@ gpio_keys_get_devtree_pdata(struct device *dev) | |||
659 | 657 | ||
660 | button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); | 658 | button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); |
661 | 659 | ||
660 | button->can_disable = !!of_get_property(pp, "linux,can-disable", NULL); | ||
661 | |||
662 | if (of_property_read_u32(pp, "debounce-interval", | 662 | if (of_property_read_u32(pp, "debounce-interval", |
663 | &button->debounce_interval)) | 663 | &button->debounce_interval)) |
664 | button->debounce_interval = 5; | 664 | button->debounce_interval = 5; |
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index 610a8af795a1..5b152f25a8e1 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c | |||
@@ -473,7 +473,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) | |||
473 | if (error) | 473 | if (error) |
474 | goto bail1; | 474 | goto bail1; |
475 | 475 | ||
476 | init_completion(&dev->cmd_done); | 476 | reinit_completion(&dev->cmd_done); |
477 | serio_write(serio, 0); | 477 | serio_write(serio, 0); |
478 | serio_write(serio, 0); | 478 | serio_write(serio, 0); |
479 | serio_write(serio, HIL_PKT_CMD >> 8); | 479 | serio_write(serio, HIL_PKT_CMD >> 8); |
@@ -482,7 +482,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) | |||
482 | if (error) | 482 | if (error) |
483 | goto bail1; | 483 | goto bail1; |
484 | 484 | ||
485 | init_completion(&dev->cmd_done); | 485 | reinit_completion(&dev->cmd_done); |
486 | serio_write(serio, 0); | 486 | serio_write(serio, 0); |
487 | serio_write(serio, 0); | 487 | serio_write(serio, 0); |
488 | serio_write(serio, HIL_PKT_CMD >> 8); | 488 | serio_write(serio, HIL_PKT_CMD >> 8); |
@@ -491,7 +491,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) | |||
491 | if (error) | 491 | if (error) |
492 | goto bail1; | 492 | goto bail1; |
493 | 493 | ||
494 | init_completion(&dev->cmd_done); | 494 | reinit_completion(&dev->cmd_done); |
495 | serio_write(serio, 0); | 495 | serio_write(serio, 0); |
496 | serio_write(serio, 0); | 496 | serio_write(serio, 0); |
497 | serio_write(serio, HIL_PKT_CMD >> 8); | 497 | serio_write(serio, HIL_PKT_CMD >> 8); |
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c index ef5e67fb567e..fe6e3f22eed7 100644 --- a/drivers/input/keyboard/stmpe-keypad.c +++ b/drivers/input/keyboard/stmpe-keypad.c | |||
@@ -45,13 +45,14 @@ | |||
45 | #define STMPE_KEYPAD_MAX_ROWS 8 | 45 | #define STMPE_KEYPAD_MAX_ROWS 8 |
46 | #define STMPE_KEYPAD_MAX_COLS 8 | 46 | #define STMPE_KEYPAD_MAX_COLS 8 |
47 | #define STMPE_KEYPAD_ROW_SHIFT 3 | 47 | #define STMPE_KEYPAD_ROW_SHIFT 3 |
48 | #define STMPE_KEYPAD_KEYMAP_SIZE \ | 48 | #define STMPE_KEYPAD_KEYMAP_MAX_SIZE \ |
49 | (STMPE_KEYPAD_MAX_ROWS * STMPE_KEYPAD_MAX_COLS) | 49 | (STMPE_KEYPAD_MAX_ROWS * STMPE_KEYPAD_MAX_COLS) |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * struct stmpe_keypad_variant - model-specific attributes | 52 | * struct stmpe_keypad_variant - model-specific attributes |
53 | * @auto_increment: whether the KPC_DATA_BYTE register address | 53 | * @auto_increment: whether the KPC_DATA_BYTE register address |
54 | * auto-increments on multiple read | 54 | * auto-increments on multiple read |
55 | * @set_pullup: whether the pins need to have their pull-ups set | ||
55 | * @num_data: number of data bytes | 56 | * @num_data: number of data bytes |
56 | * @num_normal_data: number of normal keys' data bytes | 57 | * @num_normal_data: number of normal keys' data bytes |
57 | * @max_cols: maximum number of columns supported | 58 | * @max_cols: maximum number of columns supported |
@@ -61,6 +62,7 @@ | |||
61 | */ | 62 | */ |
62 | struct stmpe_keypad_variant { | 63 | struct stmpe_keypad_variant { |
63 | bool auto_increment; | 64 | bool auto_increment; |
65 | bool set_pullup; | ||
64 | int num_data; | 66 | int num_data; |
65 | int num_normal_data; | 67 | int num_normal_data; |
66 | int max_cols; | 68 | int max_cols; |
@@ -81,6 +83,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { | |||
81 | }, | 83 | }, |
82 | [STMPE2401] = { | 84 | [STMPE2401] = { |
83 | .auto_increment = false, | 85 | .auto_increment = false, |
86 | .set_pullup = true, | ||
84 | .num_data = 3, | 87 | .num_data = 3, |
85 | .num_normal_data = 2, | 88 | .num_normal_data = 2, |
86 | .max_cols = 8, | 89 | .max_cols = 8, |
@@ -90,6 +93,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { | |||
90 | }, | 93 | }, |
91 | [STMPE2403] = { | 94 | [STMPE2403] = { |
92 | .auto_increment = true, | 95 | .auto_increment = true, |
96 | .set_pullup = true, | ||
93 | .num_data = 5, | 97 | .num_data = 5, |
94 | .num_normal_data = 3, | 98 | .num_normal_data = 3, |
95 | .max_cols = 8, | 99 | .max_cols = 8, |
@@ -99,16 +103,30 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { | |||
99 | }, | 103 | }, |
100 | }; | 104 | }; |
101 | 105 | ||
106 | /** | ||
107 | * struct stmpe_keypad - STMPE keypad state container | ||
108 | * @stmpe: pointer to parent STMPE device | ||
109 | * @input: spawned input device | ||
110 | * @variant: STMPE variant | ||
111 | * @debounce_ms: debounce interval, in ms. Maximum is | ||
112 | * %STMPE_KEYPAD_MAX_DEBOUNCE. | ||
113 | * @scan_count: number of key scanning cycles to confirm key data. | ||
114 | * Maximum is %STMPE_KEYPAD_MAX_SCAN_COUNT. | ||
115 | * @no_autorepeat: disable key autorepeat | ||
116 | * @rows: bitmask for the rows | ||
117 | * @cols: bitmask for the columns | ||
118 | * @keymap: the keymap | ||
119 | */ | ||
102 | struct stmpe_keypad { | 120 | struct stmpe_keypad { |
103 | struct stmpe *stmpe; | 121 | struct stmpe *stmpe; |
104 | struct input_dev *input; | 122 | struct input_dev *input; |
105 | const struct stmpe_keypad_variant *variant; | 123 | const struct stmpe_keypad_variant *variant; |
106 | const struct stmpe_keypad_platform_data *plat; | 124 | unsigned int debounce_ms; |
107 | 125 | unsigned int scan_count; | |
126 | bool no_autorepeat; | ||
108 | unsigned int rows; | 127 | unsigned int rows; |
109 | unsigned int cols; | 128 | unsigned int cols; |
110 | 129 | unsigned short keymap[STMPE_KEYPAD_KEYMAP_MAX_SIZE]; | |
111 | unsigned short keymap[STMPE_KEYPAD_KEYMAP_SIZE]; | ||
112 | }; | 130 | }; |
113 | 131 | ||
114 | static int stmpe_keypad_read_data(struct stmpe_keypad *keypad, u8 *data) | 132 | static int stmpe_keypad_read_data(struct stmpe_keypad *keypad, u8 *data) |
@@ -171,7 +189,10 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad) | |||
171 | unsigned int col_gpios = variant->col_gpios; | 189 | unsigned int col_gpios = variant->col_gpios; |
172 | unsigned int row_gpios = variant->row_gpios; | 190 | unsigned int row_gpios = variant->row_gpios; |
173 | struct stmpe *stmpe = keypad->stmpe; | 191 | struct stmpe *stmpe = keypad->stmpe; |
192 | u8 pureg = stmpe->regs[STMPE_IDX_GPPUR_LSB]; | ||
174 | unsigned int pins = 0; | 193 | unsigned int pins = 0; |
194 | unsigned int pu_pins = 0; | ||
195 | int ret; | ||
175 | int i; | 196 | int i; |
176 | 197 | ||
177 | /* | 198 | /* |
@@ -188,8 +209,10 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad) | |||
188 | for (i = 0; i < variant->max_cols; i++) { | 209 | for (i = 0; i < variant->max_cols; i++) { |
189 | int num = __ffs(col_gpios); | 210 | int num = __ffs(col_gpios); |
190 | 211 | ||
191 | if (keypad->cols & (1 << i)) | 212 | if (keypad->cols & (1 << i)) { |
192 | pins |= 1 << num; | 213 | pins |= 1 << num; |
214 | pu_pins |= 1 << num; | ||
215 | } | ||
193 | 216 | ||
194 | col_gpios &= ~(1 << num); | 217 | col_gpios &= ~(1 << num); |
195 | } | 218 | } |
@@ -203,20 +226,43 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad) | |||
203 | row_gpios &= ~(1 << num); | 226 | row_gpios &= ~(1 << num); |
204 | } | 227 | } |
205 | 228 | ||
206 | return stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); | 229 | ret = stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); |
230 | if (ret) | ||
231 | return ret; | ||
232 | |||
233 | /* | ||
234 | * On STMPE24xx, set pin bias to pull-up on all keypad input | ||
235 | * pins (columns), this incidentally happen to be maximum 8 pins | ||
236 | * and placed at GPIO0-7 so only the LSB of the pull up register | ||
237 | * ever needs to be written. | ||
238 | */ | ||
239 | if (variant->set_pullup) { | ||
240 | u8 val; | ||
241 | |||
242 | ret = stmpe_reg_read(stmpe, pureg); | ||
243 | if (ret) | ||
244 | return ret; | ||
245 | |||
246 | /* Do not touch unused pins, may be used for GPIO */ | ||
247 | val = ret & ~pu_pins; | ||
248 | val |= pu_pins; | ||
249 | |||
250 | ret = stmpe_reg_write(stmpe, pureg, val); | ||
251 | } | ||
252 | |||
253 | return 0; | ||
207 | } | 254 | } |
208 | 255 | ||
209 | static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad) | 256 | static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad) |
210 | { | 257 | { |
211 | const struct stmpe_keypad_platform_data *plat = keypad->plat; | ||
212 | const struct stmpe_keypad_variant *variant = keypad->variant; | 258 | const struct stmpe_keypad_variant *variant = keypad->variant; |
213 | struct stmpe *stmpe = keypad->stmpe; | 259 | struct stmpe *stmpe = keypad->stmpe; |
214 | int ret; | 260 | int ret; |
215 | 261 | ||
216 | if (plat->debounce_ms > STMPE_KEYPAD_MAX_DEBOUNCE) | 262 | if (keypad->debounce_ms > STMPE_KEYPAD_MAX_DEBOUNCE) |
217 | return -EINVAL; | 263 | return -EINVAL; |
218 | 264 | ||
219 | if (plat->scan_count > STMPE_KEYPAD_MAX_SCAN_COUNT) | 265 | if (keypad->scan_count > STMPE_KEYPAD_MAX_SCAN_COUNT) |
220 | return -EINVAL; | 266 | return -EINVAL; |
221 | 267 | ||
222 | ret = stmpe_enable(stmpe, STMPE_BLOCK_KEYPAD); | 268 | ret = stmpe_enable(stmpe, STMPE_BLOCK_KEYPAD); |
@@ -245,7 +291,7 @@ static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad) | |||
245 | 291 | ||
246 | ret = stmpe_set_bits(stmpe, STMPE_KPC_CTRL_MSB, | 292 | ret = stmpe_set_bits(stmpe, STMPE_KPC_CTRL_MSB, |
247 | STMPE_KPC_CTRL_MSB_SCAN_COUNT, | 293 | STMPE_KPC_CTRL_MSB_SCAN_COUNT, |
248 | plat->scan_count << 4); | 294 | keypad->scan_count << 4); |
249 | if (ret < 0) | 295 | if (ret < 0) |
250 | return ret; | 296 | return ret; |
251 | 297 | ||
@@ -253,17 +299,18 @@ static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad) | |||
253 | STMPE_KPC_CTRL_LSB_SCAN | | 299 | STMPE_KPC_CTRL_LSB_SCAN | |
254 | STMPE_KPC_CTRL_LSB_DEBOUNCE, | 300 | STMPE_KPC_CTRL_LSB_DEBOUNCE, |
255 | STMPE_KPC_CTRL_LSB_SCAN | | 301 | STMPE_KPC_CTRL_LSB_SCAN | |
256 | (plat->debounce_ms << 1)); | 302 | (keypad->debounce_ms << 1)); |
257 | } | 303 | } |
258 | 304 | ||
259 | static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad) | 305 | static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad, |
306 | u32 used_rows, u32 used_cols) | ||
260 | { | 307 | { |
261 | int row, col; | 308 | int row, col; |
262 | 309 | ||
263 | for (row = 0; row < STMPE_KEYPAD_MAX_ROWS; row++) { | 310 | for (row = 0; row < used_rows; row++) { |
264 | for (col = 0; col < STMPE_KEYPAD_MAX_COLS; col++) { | 311 | for (col = 0; col < used_cols; col++) { |
265 | int code = MATRIX_SCAN_CODE(row, col, | 312 | int code = MATRIX_SCAN_CODE(row, col, |
266 | STMPE_KEYPAD_ROW_SHIFT); | 313 | STMPE_KEYPAD_ROW_SHIFT); |
267 | if (keypad->keymap[code] != KEY_RESERVED) { | 314 | if (keypad->keymap[code] != KEY_RESERVED) { |
268 | keypad->rows |= 1 << row; | 315 | keypad->rows |= 1 << row; |
269 | keypad->cols |= 1 << col; | 316 | keypad->cols |= 1 << col; |
@@ -272,51 +319,17 @@ static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad) | |||
272 | } | 319 | } |
273 | } | 320 | } |
274 | 321 | ||
275 | #ifdef CONFIG_OF | ||
276 | static const struct stmpe_keypad_platform_data * | ||
277 | stmpe_keypad_of_probe(struct device *dev) | ||
278 | { | ||
279 | struct device_node *np = dev->of_node; | ||
280 | struct stmpe_keypad_platform_data *plat; | ||
281 | |||
282 | if (!np) | ||
283 | return ERR_PTR(-ENODEV); | ||
284 | |||
285 | plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL); | ||
286 | if (!plat) | ||
287 | return ERR_PTR(-ENOMEM); | ||
288 | |||
289 | of_property_read_u32(np, "debounce-interval", &plat->debounce_ms); | ||
290 | of_property_read_u32(np, "st,scan-count", &plat->scan_count); | ||
291 | |||
292 | plat->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat"); | ||
293 | |||
294 | return plat; | ||
295 | } | ||
296 | #else | ||
297 | static inline const struct stmpe_keypad_platform_data * | ||
298 | stmpe_keypad_of_probe(struct device *dev) | ||
299 | { | ||
300 | return ERR_PTR(-EINVAL); | ||
301 | } | ||
302 | #endif | ||
303 | |||
304 | static int stmpe_keypad_probe(struct platform_device *pdev) | 322 | static int stmpe_keypad_probe(struct platform_device *pdev) |
305 | { | 323 | { |
306 | struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); | 324 | struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); |
307 | const struct stmpe_keypad_platform_data *plat; | 325 | struct device_node *np = pdev->dev.of_node; |
308 | struct stmpe_keypad *keypad; | 326 | struct stmpe_keypad *keypad; |
309 | struct input_dev *input; | 327 | struct input_dev *input; |
328 | u32 rows; | ||
329 | u32 cols; | ||
310 | int error; | 330 | int error; |
311 | int irq; | 331 | int irq; |
312 | 332 | ||
313 | plat = stmpe->pdata->keypad; | ||
314 | if (!plat) { | ||
315 | plat = stmpe_keypad_of_probe(&pdev->dev); | ||
316 | if (IS_ERR(plat)) | ||
317 | return PTR_ERR(plat); | ||
318 | } | ||
319 | |||
320 | irq = platform_get_irq(pdev, 0); | 333 | irq = platform_get_irq(pdev, 0); |
321 | if (irq < 0) | 334 | if (irq < 0) |
322 | return irq; | 335 | return irq; |
@@ -326,6 +339,13 @@ static int stmpe_keypad_probe(struct platform_device *pdev) | |||
326 | if (!keypad) | 339 | if (!keypad) |
327 | return -ENOMEM; | 340 | return -ENOMEM; |
328 | 341 | ||
342 | keypad->stmpe = stmpe; | ||
343 | keypad->variant = &stmpe_keypad_variants[stmpe->partnum]; | ||
344 | |||
345 | of_property_read_u32(np, "debounce-interval", &keypad->debounce_ms); | ||
346 | of_property_read_u32(np, "st,scan-count", &keypad->scan_count); | ||
347 | keypad->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat"); | ||
348 | |||
329 | input = devm_input_allocate_device(&pdev->dev); | 349 | input = devm_input_allocate_device(&pdev->dev); |
330 | if (!input) | 350 | if (!input) |
331 | return -ENOMEM; | 351 | return -ENOMEM; |
@@ -334,23 +354,22 @@ static int stmpe_keypad_probe(struct platform_device *pdev) | |||
334 | input->id.bustype = BUS_I2C; | 354 | input->id.bustype = BUS_I2C; |
335 | input->dev.parent = &pdev->dev; | 355 | input->dev.parent = &pdev->dev; |
336 | 356 | ||
337 | error = matrix_keypad_build_keymap(plat->keymap_data, NULL, | 357 | error = matrix_keypad_parse_of_params(&pdev->dev, &rows, &cols); |
338 | STMPE_KEYPAD_MAX_ROWS, | 358 | if (error) |
339 | STMPE_KEYPAD_MAX_COLS, | 359 | return error; |
360 | |||
361 | error = matrix_keypad_build_keymap(NULL, NULL, rows, cols, | ||
340 | keypad->keymap, input); | 362 | keypad->keymap, input); |
341 | if (error) | 363 | if (error) |
342 | return error; | 364 | return error; |
343 | 365 | ||
344 | input_set_capability(input, EV_MSC, MSC_SCAN); | 366 | input_set_capability(input, EV_MSC, MSC_SCAN); |
345 | if (!plat->no_autorepeat) | 367 | if (!keypad->no_autorepeat) |
346 | __set_bit(EV_REP, input->evbit); | 368 | __set_bit(EV_REP, input->evbit); |
347 | 369 | ||
348 | stmpe_keypad_fill_used_pins(keypad); | 370 | stmpe_keypad_fill_used_pins(keypad, rows, cols); |
349 | 371 | ||
350 | keypad->stmpe = stmpe; | ||
351 | keypad->plat = plat; | ||
352 | keypad->input = input; | 372 | keypad->input = input; |
353 | keypad->variant = &stmpe_keypad_variants[stmpe->partnum]; | ||
354 | 373 | ||
355 | error = stmpe_keypad_chip_init(keypad); | 374 | error = stmpe_keypad_chip_init(keypad); |
356 | if (error < 0) | 375 | if (error < 0) |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index d125a019383f..d88d73d83552 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -881,6 +881,34 @@ static void alps_get_finger_coordinate_v7(struct input_mt_pos *mt, | |||
881 | unsigned char *pkt, | 881 | unsigned char *pkt, |
882 | unsigned char pkt_id) | 882 | unsigned char pkt_id) |
883 | { | 883 | { |
884 | /* | ||
885 | * packet-fmt b7 b6 b5 b4 b3 b2 b1 b0 | ||
886 | * Byte0 TWO & MULTI L 1 R M 1 Y0-2 Y0-1 Y0-0 | ||
887 | * Byte0 NEW L 1 X1-5 1 1 Y0-2 Y0-1 Y0-0 | ||
888 | * Byte1 Y0-10 Y0-9 Y0-8 Y0-7 Y0-6 Y0-5 Y0-4 Y0-3 | ||
889 | * Byte2 X0-11 1 X0-10 X0-9 X0-8 X0-7 X0-6 X0-5 | ||
890 | * Byte3 X1-11 1 X0-4 X0-3 1 X0-2 X0-1 X0-0 | ||
891 | * Byte4 TWO X1-10 TWO X1-9 X1-8 X1-7 X1-6 X1-5 X1-4 | ||
892 | * Byte4 MULTI X1-10 TWO X1-9 X1-8 X1-7 X1-6 Y1-5 1 | ||
893 | * Byte4 NEW X1-10 TWO X1-9 X1-8 X1-7 X1-6 0 0 | ||
894 | * Byte5 TWO & NEW Y1-10 0 Y1-9 Y1-8 Y1-7 Y1-6 Y1-5 Y1-4 | ||
895 | * Byte5 MULTI Y1-10 0 Y1-9 Y1-8 Y1-7 Y1-6 F-1 F-0 | ||
896 | * L: Left button | ||
897 | * R / M: Non-clickpads: Right / Middle button | ||
898 | * Clickpads: When > 2 fingers are down, and some fingers | ||
899 | * are in the button area, then the 2 coordinates reported | ||
900 | * are for fingers outside the button area and these report | ||
901 | * extra fingers being present in the right / left button | ||
902 | * area. Note these fingers are not added to the F field! | ||
903 | * so if a TWO packet is received and R = 1 then there are | ||
904 | * 3 fingers down, etc. | ||
905 | * TWO: 1: Two touches present, byte 0/4/5 are in TWO fmt | ||
906 | * 0: If byte 4 bit 0 is 1, then byte 0/4/5 are in MULTI fmt | ||
907 | * otherwise byte 0 bit 4 must be set and byte 0/4/5 are | ||
908 | * in NEW fmt | ||
909 | * F: Number of fingers - 3, 0 means 3 fingers, 1 means 4 ... | ||
910 | */ | ||
911 | |||
884 | mt[0].x = ((pkt[2] & 0x80) << 4); | 912 | mt[0].x = ((pkt[2] & 0x80) << 4); |
885 | mt[0].x |= ((pkt[2] & 0x3F) << 5); | 913 | mt[0].x |= ((pkt[2] & 0x3F) << 5); |
886 | mt[0].x |= ((pkt[3] & 0x30) >> 1); | 914 | mt[0].x |= ((pkt[3] & 0x30) >> 1); |
@@ -919,18 +947,21 @@ static void alps_get_finger_coordinate_v7(struct input_mt_pos *mt, | |||
919 | 947 | ||
920 | static int alps_get_mt_count(struct input_mt_pos *mt) | 948 | static int alps_get_mt_count(struct input_mt_pos *mt) |
921 | { | 949 | { |
922 | int i; | 950 | int i, fingers = 0; |
923 | 951 | ||
924 | for (i = 0; i < MAX_TOUCHES && mt[i].x != 0 && mt[i].y != 0; i++) | 952 | for (i = 0; i < MAX_TOUCHES; i++) { |
925 | /* empty */; | 953 | if (mt[i].x != 0 || mt[i].y != 0) |
954 | fingers++; | ||
955 | } | ||
926 | 956 | ||
927 | return i; | 957 | return fingers; |
928 | } | 958 | } |
929 | 959 | ||
930 | static int alps_decode_packet_v7(struct alps_fields *f, | 960 | static int alps_decode_packet_v7(struct alps_fields *f, |
931 | unsigned char *p, | 961 | unsigned char *p, |
932 | struct psmouse *psmouse) | 962 | struct psmouse *psmouse) |
933 | { | 963 | { |
964 | struct alps_data *priv = psmouse->private; | ||
934 | unsigned char pkt_id; | 965 | unsigned char pkt_id; |
935 | 966 | ||
936 | pkt_id = alps_get_packet_id_v7(p); | 967 | pkt_id = alps_get_packet_id_v7(p); |
@@ -938,19 +969,52 @@ static int alps_decode_packet_v7(struct alps_fields *f, | |||
938 | return 0; | 969 | return 0; |
939 | if (pkt_id == V7_PACKET_ID_UNKNOWN) | 970 | if (pkt_id == V7_PACKET_ID_UNKNOWN) |
940 | return -1; | 971 | return -1; |
972 | /* | ||
973 | * NEW packets are send to indicate a discontinuity in the finger | ||
974 | * coordinate reporting. Specifically a finger may have moved from | ||
975 | * slot 0 to 1 or vice versa. INPUT_MT_TRACK takes care of this for | ||
976 | * us. | ||
977 | * | ||
978 | * NEW packets have 3 problems: | ||
979 | * 1) They do not contain middle / right button info (on non clickpads) | ||
980 | * this can be worked around by preserving the old button state | ||
981 | * 2) They do not contain an accurate fingercount, and they are | ||
982 | * typically send when the number of fingers changes. We cannot use | ||
983 | * the old finger count as that may mismatch with the amount of | ||
984 | * touch coordinates we've available in the NEW packet | ||
985 | * 3) Their x data for the second touch is inaccurate leading to | ||
986 | * a possible jump of the x coordinate by 16 units when the first | ||
987 | * non NEW packet comes in | ||
988 | * Since problems 2 & 3 cannot be worked around, just ignore them. | ||
989 | */ | ||
990 | if (pkt_id == V7_PACKET_ID_NEW) | ||
991 | return 1; | ||
941 | 992 | ||
942 | alps_get_finger_coordinate_v7(f->mt, p, pkt_id); | 993 | alps_get_finger_coordinate_v7(f->mt, p, pkt_id); |
943 | 994 | ||
944 | if (pkt_id == V7_PACKET_ID_TWO || pkt_id == V7_PACKET_ID_MULTI) { | 995 | if (pkt_id == V7_PACKET_ID_TWO) |
945 | f->left = (p[0] & 0x80) >> 7; | 996 | f->fingers = alps_get_mt_count(f->mt); |
997 | else /* pkt_id == V7_PACKET_ID_MULTI */ | ||
998 | f->fingers = 3 + (p[5] & 0x03); | ||
999 | |||
1000 | f->left = (p[0] & 0x80) >> 7; | ||
1001 | if (priv->flags & ALPS_BUTTONPAD) { | ||
1002 | if (p[0] & 0x20) | ||
1003 | f->fingers++; | ||
1004 | if (p[0] & 0x10) | ||
1005 | f->fingers++; | ||
1006 | } else { | ||
946 | f->right = (p[0] & 0x20) >> 5; | 1007 | f->right = (p[0] & 0x20) >> 5; |
947 | f->middle = (p[0] & 0x10) >> 4; | 1008 | f->middle = (p[0] & 0x10) >> 4; |
948 | } | 1009 | } |
949 | 1010 | ||
950 | if (pkt_id == V7_PACKET_ID_TWO) | 1011 | /* Sometimes a single touch is reported in mt[1] rather then mt[0] */ |
951 | f->fingers = alps_get_mt_count(f->mt); | 1012 | if (f->fingers == 1 && f->mt[0].x == 0 && f->mt[0].y == 0) { |
952 | else if (pkt_id == V7_PACKET_ID_MULTI) | 1013 | f->mt[0].x = f->mt[1].x; |
953 | f->fingers = 3 + (p[5] & 0x03); | 1014 | f->mt[0].y = f->mt[1].y; |
1015 | f->mt[1].x = 0; | ||
1016 | f->mt[1].y = 0; | ||
1017 | } | ||
954 | 1018 | ||
955 | return 0; | 1019 | return 0; |
956 | } | 1020 | } |
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index 30c8b6998808..354d47ecd66a 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c | |||
@@ -227,6 +227,7 @@ TRACKPOINT_INT_ATTR(thresh, TP_THRESH, TP_DEF_THRESH); | |||
227 | TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH, TP_DEF_UP_THRESH); | 227 | TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH, TP_DEF_UP_THRESH); |
228 | TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME); | 228 | TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME); |
229 | TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV); | 229 | TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV); |
230 | TRACKPOINT_INT_ATTR(drift_time, TP_DRIFT_TIME, TP_DEF_DRIFT_TIME); | ||
230 | 231 | ||
231 | TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0, | 232 | TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0, |
232 | TP_DEF_PTSON); | 233 | TP_DEF_PTSON); |
@@ -246,6 +247,7 @@ static struct attribute *trackpoint_attrs[] = { | |||
246 | &psmouse_attr_upthresh.dattr.attr, | 247 | &psmouse_attr_upthresh.dattr.attr, |
247 | &psmouse_attr_ztime.dattr.attr, | 248 | &psmouse_attr_ztime.dattr.attr, |
248 | &psmouse_attr_jenks.dattr.attr, | 249 | &psmouse_attr_jenks.dattr.attr, |
250 | &psmouse_attr_drift_time.dattr.attr, | ||
249 | &psmouse_attr_press_to_select.dattr.attr, | 251 | &psmouse_attr_press_to_select.dattr.attr, |
250 | &psmouse_attr_skipback.dattr.attr, | 252 | &psmouse_attr_skipback.dattr.attr, |
251 | &psmouse_attr_ext_dev.dattr.attr, | 253 | &psmouse_attr_ext_dev.dattr.attr, |
@@ -312,6 +314,7 @@ static int trackpoint_sync(struct psmouse *psmouse, bool in_power_on_state) | |||
312 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, upthresh); | 314 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, upthresh); |
313 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ztime); | 315 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ztime); |
314 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, jenks); | 316 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, jenks); |
317 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, drift_time); | ||
315 | 318 | ||
316 | /* toggles */ | 319 | /* toggles */ |
317 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, press_to_select); | 320 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, press_to_select); |
@@ -332,6 +335,7 @@ static void trackpoint_defaults(struct trackpoint_data *tp) | |||
332 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, upthresh); | 335 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, upthresh); |
333 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ztime); | 336 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ztime); |
334 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, jenks); | 337 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, jenks); |
338 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, drift_time); | ||
335 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, inertia); | 339 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, inertia); |
336 | 340 | ||
337 | /* toggles */ | 341 | /* toggles */ |
diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h index ecd0547964a5..5617ed3a7d7a 100644 --- a/drivers/input/mouse/trackpoint.h +++ b/drivers/input/mouse/trackpoint.h | |||
@@ -70,6 +70,9 @@ | |||
70 | #define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */ | 70 | #define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */ |
71 | #define TP_Z_TIME 0x5E /* How sharp of a press */ | 71 | #define TP_Z_TIME 0x5E /* How sharp of a press */ |
72 | #define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */ | 72 | #define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */ |
73 | #define TP_DRIFT_TIME 0x5F /* How long a 'hands off' condition */ | ||
74 | /* must last (x*107ms) for drift */ | ||
75 | /* correction to occur */ | ||
73 | 76 | ||
74 | /* | 77 | /* |
75 | * Toggling Flag bits | 78 | * Toggling Flag bits |
@@ -120,6 +123,7 @@ | |||
120 | #define TP_DEF_UP_THRESH 0xFF | 123 | #define TP_DEF_UP_THRESH 0xFF |
121 | #define TP_DEF_Z_TIME 0x26 | 124 | #define TP_DEF_Z_TIME 0x26 |
122 | #define TP_DEF_JENKS_CURV 0x87 | 125 | #define TP_DEF_JENKS_CURV 0x87 |
126 | #define TP_DEF_DRIFT_TIME 0x05 | ||
123 | 127 | ||
124 | /* Toggles */ | 128 | /* Toggles */ |
125 | #define TP_DEF_MB 0x00 | 129 | #define TP_DEF_MB 0x00 |
@@ -137,6 +141,7 @@ struct trackpoint_data | |||
137 | unsigned char draghys, mindrag; | 141 | unsigned char draghys, mindrag; |
138 | unsigned char thresh, upthresh; | 142 | unsigned char thresh, upthresh; |
139 | unsigned char ztime, jenks; | 143 | unsigned char ztime, jenks; |
144 | unsigned char drift_time; | ||
140 | 145 | ||
141 | /* toggles */ | 146 | /* toggles */ |
142 | unsigned char press_to_select; | 147 | unsigned char press_to_select; |
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index bb070206223c..95ee92a91bd2 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -99,13 +99,9 @@ | |||
99 | #define MXT_T6_STATUS_COMSERR (1 << 2) | 99 | #define MXT_T6_STATUS_COMSERR (1 << 2) |
100 | 100 | ||
101 | /* MXT_GEN_POWER_T7 field */ | 101 | /* MXT_GEN_POWER_T7 field */ |
102 | struct t7_config { | 102 | #define MXT_POWER_IDLEACQINT 0 |
103 | u8 idle; | 103 | #define MXT_POWER_ACTVACQINT 1 |
104 | u8 active; | 104 | #define MXT_POWER_ACTV2IDLETO 2 |
105 | } __packed; | ||
106 | |||
107 | #define MXT_POWER_CFG_RUN 0 | ||
108 | #define MXT_POWER_CFG_DEEPSLEEP 1 | ||
109 | 105 | ||
110 | /* MXT_GEN_ACQUIRE_T8 field */ | 106 | /* MXT_GEN_ACQUIRE_T8 field */ |
111 | #define MXT_ACQUIRE_CHRGTIME 0 | 107 | #define MXT_ACQUIRE_CHRGTIME 0 |
@@ -117,6 +113,7 @@ struct t7_config { | |||
117 | #define MXT_ACQUIRE_ATCHCALSTHR 7 | 113 | #define MXT_ACQUIRE_ATCHCALSTHR 7 |
118 | 114 | ||
119 | /* MXT_TOUCH_MULTI_T9 field */ | 115 | /* MXT_TOUCH_MULTI_T9 field */ |
116 | #define MXT_TOUCH_CTRL 0 | ||
120 | #define MXT_T9_ORIENT 9 | 117 | #define MXT_T9_ORIENT 9 |
121 | #define MXT_T9_RANGE 18 | 118 | #define MXT_T9_RANGE 18 |
122 | 119 | ||
@@ -256,7 +253,6 @@ struct mxt_data { | |||
256 | bool update_input; | 253 | bool update_input; |
257 | u8 last_message_count; | 254 | u8 last_message_count; |
258 | u8 num_touchids; | 255 | u8 num_touchids; |
259 | struct t7_config t7_cfg; | ||
260 | 256 | ||
261 | /* Cached parameters from object table */ | 257 | /* Cached parameters from object table */ |
262 | u16 T5_address; | 258 | u16 T5_address; |
@@ -672,6 +668,20 @@ static void mxt_proc_t6_messages(struct mxt_data *data, u8 *msg) | |||
672 | data->t6_status = status; | 668 | data->t6_status = status; |
673 | } | 669 | } |
674 | 670 | ||
671 | static int mxt_write_object(struct mxt_data *data, | ||
672 | u8 type, u8 offset, u8 val) | ||
673 | { | ||
674 | struct mxt_object *object; | ||
675 | u16 reg; | ||
676 | |||
677 | object = mxt_get_object(data, type); | ||
678 | if (!object || offset >= mxt_obj_size(object)) | ||
679 | return -EINVAL; | ||
680 | |||
681 | reg = object->start_address; | ||
682 | return mxt_write_reg(data->client, reg + offset, val); | ||
683 | } | ||
684 | |||
675 | static void mxt_input_button(struct mxt_data *data, u8 *message) | 685 | static void mxt_input_button(struct mxt_data *data, u8 *message) |
676 | { | 686 | { |
677 | struct input_dev *input = data->input_dev; | 687 | struct input_dev *input = data->input_dev; |
@@ -1742,60 +1752,6 @@ err_free_object_table: | |||
1742 | return error; | 1752 | return error; |
1743 | } | 1753 | } |
1744 | 1754 | ||
1745 | static int mxt_set_t7_power_cfg(struct mxt_data *data, u8 sleep) | ||
1746 | { | ||
1747 | struct device *dev = &data->client->dev; | ||
1748 | int error; | ||
1749 | struct t7_config *new_config; | ||
1750 | struct t7_config deepsleep = { .active = 0, .idle = 0 }; | ||
1751 | |||
1752 | if (sleep == MXT_POWER_CFG_DEEPSLEEP) | ||
1753 | new_config = &deepsleep; | ||
1754 | else | ||
1755 | new_config = &data->t7_cfg; | ||
1756 | |||
1757 | error = __mxt_write_reg(data->client, data->T7_address, | ||
1758 | sizeof(data->t7_cfg), new_config); | ||
1759 | if (error) | ||
1760 | return error; | ||
1761 | |||
1762 | dev_dbg(dev, "Set T7 ACTV:%d IDLE:%d\n", | ||
1763 | new_config->active, new_config->idle); | ||
1764 | |||
1765 | return 0; | ||
1766 | } | ||
1767 | |||
1768 | static int mxt_init_t7_power_cfg(struct mxt_data *data) | ||
1769 | { | ||
1770 | struct device *dev = &data->client->dev; | ||
1771 | int error; | ||
1772 | bool retry = false; | ||
1773 | |||
1774 | recheck: | ||
1775 | error = __mxt_read_reg(data->client, data->T7_address, | ||
1776 | sizeof(data->t7_cfg), &data->t7_cfg); | ||
1777 | if (error) | ||
1778 | return error; | ||
1779 | |||
1780 | if (data->t7_cfg.active == 0 || data->t7_cfg.idle == 0) { | ||
1781 | if (!retry) { | ||
1782 | dev_dbg(dev, "T7 cfg zero, resetting\n"); | ||
1783 | mxt_soft_reset(data); | ||
1784 | retry = true; | ||
1785 | goto recheck; | ||
1786 | } else { | ||
1787 | dev_dbg(dev, "T7 cfg zero after reset, overriding\n"); | ||
1788 | data->t7_cfg.active = 20; | ||
1789 | data->t7_cfg.idle = 100; | ||
1790 | return mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); | ||
1791 | } | ||
1792 | } | ||
1793 | |||
1794 | dev_dbg(dev, "Initialized power cfg: ACTV %d, IDLE %d\n", | ||
1795 | data->t7_cfg.active, data->t7_cfg.idle); | ||
1796 | return 0; | ||
1797 | } | ||
1798 | |||
1799 | static int mxt_configure_objects(struct mxt_data *data, | 1755 | static int mxt_configure_objects(struct mxt_data *data, |
1800 | const struct firmware *cfg) | 1756 | const struct firmware *cfg) |
1801 | { | 1757 | { |
@@ -1809,12 +1765,6 @@ static int mxt_configure_objects(struct mxt_data *data, | |||
1809 | dev_warn(dev, "Error %d updating config\n", error); | 1765 | dev_warn(dev, "Error %d updating config\n", error); |
1810 | } | 1766 | } |
1811 | 1767 | ||
1812 | error = mxt_init_t7_power_cfg(data); | ||
1813 | if (error) { | ||
1814 | dev_err(dev, "Failed to initialize power cfg\n"); | ||
1815 | return error; | ||
1816 | } | ||
1817 | |||
1818 | error = mxt_initialize_t9_input_device(data); | 1768 | error = mxt_initialize_t9_input_device(data); |
1819 | if (error) | 1769 | if (error) |
1820 | return error; | 1770 | return error; |
@@ -2093,15 +2043,16 @@ static const struct attribute_group mxt_attr_group = { | |||
2093 | 2043 | ||
2094 | static void mxt_start(struct mxt_data *data) | 2044 | static void mxt_start(struct mxt_data *data) |
2095 | { | 2045 | { |
2096 | mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); | 2046 | /* Touch enable */ |
2097 | 2047 | mxt_write_object(data, | |
2098 | /* Recalibrate since chip has been in deep sleep */ | 2048 | MXT_TOUCH_MULTI_T9, MXT_TOUCH_CTRL, 0x83); |
2099 | mxt_t6_command(data, MXT_COMMAND_CALIBRATE, 1, false); | ||
2100 | } | 2049 | } |
2101 | 2050 | ||
2102 | static void mxt_stop(struct mxt_data *data) | 2051 | static void mxt_stop(struct mxt_data *data) |
2103 | { | 2052 | { |
2104 | mxt_set_t7_power_cfg(data, MXT_POWER_CFG_DEEPSLEEP); | 2053 | /* Touch disable */ |
2054 | mxt_write_object(data, | ||
2055 | MXT_TOUCH_MULTI_T9, MXT_TOUCH_CTRL, 0); | ||
2105 | } | 2056 | } |
2106 | 2057 | ||
2107 | static int mxt_input_open(struct input_dev *dev) | 2058 | static int mxt_input_open(struct input_dev *dev) |
@@ -2266,6 +2217,8 @@ static int __maybe_unused mxt_resume(struct device *dev) | |||
2266 | struct mxt_data *data = i2c_get_clientdata(client); | 2217 | struct mxt_data *data = i2c_get_clientdata(client); |
2267 | struct input_dev *input_dev = data->input_dev; | 2218 | struct input_dev *input_dev = data->input_dev; |
2268 | 2219 | ||
2220 | mxt_soft_reset(data); | ||
2221 | |||
2269 | mutex_lock(&input_dev->mutex); | 2222 | mutex_lock(&input_dev->mutex); |
2270 | 2223 | ||
2271 | if (input_dev->users) | 2224 | if (input_dev->users) |
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 3793fcc7e5db..d4c24fb7704f 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c | |||
@@ -850,9 +850,11 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client, | |||
850 | } | 850 | } |
851 | 851 | ||
852 | #define EDT_ATTR_CHECKSET(name, reg) \ | 852 | #define EDT_ATTR_CHECKSET(name, reg) \ |
853 | do { \ | ||
853 | if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ | 854 | if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ |
854 | pdata->name <= edt_ft5x06_attr_##name.limit_high) \ | 855 | pdata->name <= edt_ft5x06_attr_##name.limit_high) \ |
855 | edt_ft5x06_register_write(tsdata, reg, pdata->name) | 856 | edt_ft5x06_register_write(tsdata, reg, pdata->name); \ |
857 | } while (0) | ||
856 | 858 | ||
857 | #define EDT_GET_PROP(name, reg) { \ | 859 | #define EDT_GET_PROP(name, reg) { \ |
858 | u32 val; \ | 860 | u32 val; \ |