]> Pileus Git - ~andy/linux/commitdiff
Input: ad7877 - implement EV_KEY:BTN_TOUCH reporting
authorMichael Hennerich <michael.hennerich@analog.com>
Fri, 15 Oct 2010 16:49:07 +0000 (09:49 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 18 Oct 2010 04:12:18 +0000 (21:12 -0700)
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>
drivers/input/touchscreen/ad7877.c

index 53f4d79ee5307583ba76ab7b4ea0718d01012951..96c0a0d4b69c2819497bb7cecad1de64d7c290a3 100644 (file)
@@ -333,7 +333,7 @@ static int ad7877_read_adc(struct spi_device *spi, unsigned command)
        return status ? : sample;
 }
 
-static void ad7877_rx(struct ad7877 *ts)
+static int ad7877_rx(struct ad7877 *ts)
 {
        struct input_dev *input_dev = ts->input;
        unsigned Rt;
@@ -360,11 +360,17 @@ static void ad7877_rx(struct ad7877 *ts)
                Rt /= z1;
                Rt = (Rt + 2047) >> 12;
 
+               if (!timer_pending(&ts->timer))
+                       input_report_key(input_dev, BTN_TOUCH, 1);
+
                input_report_abs(input_dev, ABS_X, x);
                input_report_abs(input_dev, ABS_Y, y);
                input_report_abs(input_dev, ABS_PRESSURE, Rt);
                input_sync(input_dev);
+               return 0;
        }
+
+       return -EINVAL;
 }
 
 static inline void ad7877_ts_event_release(struct ad7877 *ts)
@@ -372,6 +378,7 @@ static inline void ad7877_ts_event_release(struct ad7877 *ts)
        struct input_dev *input_dev = ts->input;
 
        input_report_abs(input_dev, ABS_PRESSURE, 0);
+       input_report_key(input_dev, BTN_TOUCH, 0);
        input_sync(input_dev);
 }
 
@@ -413,11 +420,9 @@ static void ad7877_callback(void *_ts)
        struct ad7877 *ts = _ts;
 
        spin_lock_irq(&ts->lock);
-
-       ad7877_rx(ts);
+       if (!ad7877_rx(ts))
+               mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
        ts->pending = 0;
-       mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
-
        spin_unlock_irq(&ts->lock);
 }
 
@@ -728,6 +733,8 @@ static int __devinit ad7877_probe(struct spi_device *spi)
        input_dev->phys = ts->phys;
        input_dev->dev.parent = &spi->dev;
 
+       __set_bit(EV_KEY, input_dev->evbit);
+       __set_bit(BTN_TOUCH, input_dev->keybit);
        __set_bit(EV_ABS, input_dev->evbit);
        __set_bit(ABS_X, input_dev->absbit);
        __set_bit(ABS_Y, input_dev->absbit);