diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2010-10-15 12:49:07 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-10-18 00:12:18 -0400 |
commit | 47026b25fc6cd2d7ec85d4a83c472bca20946a94 (patch) | |
tree | 2a5d1c118a49c7d5c34271212dec4f30c3bb2915 /drivers/input/touchscreen | |
parent | e92c27fb5319d8b12f0c291c827e252f0e17afc4 (diff) |
Input: ad7877 - implement EV_KEY:BTN_TOUCH reporting
Some input users such as Android or X require BTN_TOUCH events.
Implement EV_KEY:BTN_TOUCH and make sure that the release event
is not erroneous scheduled without a preceding valid touch.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/ad7877.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c index 53f4d79ee530..96c0a0d4b69c 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c | |||
@@ -333,7 +333,7 @@ static int ad7877_read_adc(struct spi_device *spi, unsigned command) | |||
333 | return status ? : sample; | 333 | return status ? : sample; |
334 | } | 334 | } |
335 | 335 | ||
336 | static void ad7877_rx(struct ad7877 *ts) | 336 | static int ad7877_rx(struct ad7877 *ts) |
337 | { | 337 | { |
338 | struct input_dev *input_dev = ts->input; | 338 | struct input_dev *input_dev = ts->input; |
339 | unsigned Rt; | 339 | unsigned Rt; |
@@ -360,11 +360,17 @@ static void ad7877_rx(struct ad7877 *ts) | |||
360 | Rt /= z1; | 360 | Rt /= z1; |
361 | Rt = (Rt + 2047) >> 12; | 361 | Rt = (Rt + 2047) >> 12; |
362 | 362 | ||
363 | if (!timer_pending(&ts->timer)) | ||
364 | input_report_key(input_dev, BTN_TOUCH, 1); | ||
365 | |||
363 | input_report_abs(input_dev, ABS_X, x); | 366 | input_report_abs(input_dev, ABS_X, x); |
364 | input_report_abs(input_dev, ABS_Y, y); | 367 | input_report_abs(input_dev, ABS_Y, y); |
365 | input_report_abs(input_dev, ABS_PRESSURE, Rt); | 368 | input_report_abs(input_dev, ABS_PRESSURE, Rt); |
366 | input_sync(input_dev); | 369 | input_sync(input_dev); |
370 | return 0; | ||
367 | } | 371 | } |
372 | |||
373 | return -EINVAL; | ||
368 | } | 374 | } |
369 | 375 | ||
370 | static inline void ad7877_ts_event_release(struct ad7877 *ts) | 376 | static inline void ad7877_ts_event_release(struct ad7877 *ts) |
@@ -372,6 +378,7 @@ static inline void ad7877_ts_event_release(struct ad7877 *ts) | |||
372 | struct input_dev *input_dev = ts->input; | 378 | struct input_dev *input_dev = ts->input; |
373 | 379 | ||
374 | input_report_abs(input_dev, ABS_PRESSURE, 0); | 380 | input_report_abs(input_dev, ABS_PRESSURE, 0); |
381 | input_report_key(input_dev, BTN_TOUCH, 0); | ||
375 | input_sync(input_dev); | 382 | input_sync(input_dev); |
376 | } | 383 | } |
377 | 384 | ||
@@ -413,11 +420,9 @@ static void ad7877_callback(void *_ts) | |||
413 | struct ad7877 *ts = _ts; | 420 | struct ad7877 *ts = _ts; |
414 | 421 | ||
415 | spin_lock_irq(&ts->lock); | 422 | spin_lock_irq(&ts->lock); |
416 | 423 | if (!ad7877_rx(ts)) | |
417 | ad7877_rx(ts); | 424 | mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); |
418 | ts->pending = 0; | 425 | ts->pending = 0; |
419 | mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); | ||
420 | |||
421 | spin_unlock_irq(&ts->lock); | 426 | spin_unlock_irq(&ts->lock); |
422 | } | 427 | } |
423 | 428 | ||
@@ -728,6 +733,8 @@ static int __devinit ad7877_probe(struct spi_device *spi) | |||
728 | input_dev->phys = ts->phys; | 733 | input_dev->phys = ts->phys; |
729 | input_dev->dev.parent = &spi->dev; | 734 | input_dev->dev.parent = &spi->dev; |
730 | 735 | ||
736 | __set_bit(EV_KEY, input_dev->evbit); | ||
737 | __set_bit(BTN_TOUCH, input_dev->keybit); | ||
731 | __set_bit(EV_ABS, input_dev->evbit); | 738 | __set_bit(EV_ABS, input_dev->evbit); |
732 | __set_bit(ABS_X, input_dev->absbit); | 739 | __set_bit(ABS_X, input_dev->absbit); |
733 | __set_bit(ABS_Y, input_dev->absbit); | 740 | __set_bit(ABS_Y, input_dev->absbit); |