From: <michael.hennerich@analog.com>
To: greg@kroah.com
Cc: linux-iio@vger.kernel.org, drivers@analog.com, jic23@cam.ac.uk,
linux-input@vger.kernel.org,
device-drivers-devel@blackfin.uclinux.org,
Michael Hennerich <michael.hennerich@analog.com>
Subject: [PATCH 2/3] Input: touchscreen: ad7877 implement EV_KEY:BTN_TOUCH reporting
Date: Fri, 15 Oct 2010 12:36:10 +0200 [thread overview]
Message-ID: <1287138971-24753-2-git-send-email-michael.hennerich@analog.com> (raw)
In-Reply-To: <1287138971-24753-1-git-send-email-michael.hennerich@analog.com>
From: Michael Hennerich <michael.hennerich@analog.com>
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>
---
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 53f4d79..96c0a0d 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)
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);
--
1.6.0.2
next prev parent reply other threads:[~2010-10-15 10:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-15 10:36 [PATCH 1/3] Input: touchscreen: ad7877 implement specified chip select behavior michael.hennerich
2010-10-15 10:36 ` michael.hennerich [this message]
2010-10-15 10:36 ` [PATCH 3/3] Input: touchscreen: ad7877 filter events where pressure is beyond the maximum michael.hennerich
-- strict thread matches above, loose matches on Subject: below --
2010-10-15 10:40 [PATCH 1/3] Input: touchscreen: ad7877 implement specified chip select behavior michael.hennerich
2010-10-15 10:40 ` [PATCH 2/3] Input: touchscreen: ad7877 implement EV_KEY:BTN_TOUCH reporting michael.hennerich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1287138971-24753-2-git-send-email-michael.hennerich@analog.com \
--to=michael.hennerich@analog.com \
--cc=device-drivers-devel@blackfin.uclinux.org \
--cc=drivers@analog.com \
--cc=greg@kroah.com \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).