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

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>

authored by

Michael Hennerich and committed by
Dmitry Torokhov
47026b25 e92c27fb

+12 -5
+12 -5
drivers/input/touchscreen/ad7877.c
··· 333 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 338 struct input_dev *input_dev = ts->input; 339 339 unsigned Rt; ··· 360 360 Rt /= z1; 361 361 Rt = (Rt + 2047) >> 12; 362 362 363 + if (!timer_pending(&ts->timer)) 364 + input_report_key(input_dev, BTN_TOUCH, 1); 365 + 363 366 input_report_abs(input_dev, ABS_X, x); 364 367 input_report_abs(input_dev, ABS_Y, y); 365 368 input_report_abs(input_dev, ABS_PRESSURE, Rt); 366 369 input_sync(input_dev); 370 + return 0; 367 371 } 372 + 373 + return -EINVAL; 368 374 } 369 375 370 376 static inline void ad7877_ts_event_release(struct ad7877 *ts) ··· 378 372 struct input_dev *input_dev = ts->input; 379 373 380 374 input_report_abs(input_dev, ABS_PRESSURE, 0); 375 + input_report_key(input_dev, BTN_TOUCH, 0); 381 376 input_sync(input_dev); 382 377 } 383 378 ··· 420 413 struct ad7877 *ts = _ts; 421 414 422 415 spin_lock_irq(&ts->lock); 423 - 424 - ad7877_rx(ts); 416 + if (!ad7877_rx(ts)) 417 + mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); 425 418 ts->pending = 0; 426 - mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); 427 - 428 419 spin_unlock_irq(&ts->lock); 429 420 } 430 421 ··· 733 728 input_dev->phys = ts->phys; 734 729 input_dev->dev.parent = &spi->dev; 735 730 731 + __set_bit(EV_KEY, input_dev->evbit); 732 + __set_bit(BTN_TOUCH, input_dev->keybit); 736 733 __set_bit(EV_ABS, input_dev->evbit); 737 734 __set_bit(ABS_X, input_dev->absbit); 738 735 __set_bit(ABS_Y, input_dev->absbit);