From: Daniel Kurtz <djkurtz@chromium.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Joonyoung Shim <jy0922.shim@samsung.com>,
Iiro Valkonen <iiro.valkonen@atmel.com>,
Henrik Rydberg <rydberg@euromail.se>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Benson Leung <bleung@chromium.org>,
Yufeng Shen <miletus@chromium.org>,
Daniel Kurtz <djkurtz@chromium.org>
Subject: [PATCH 12/20] Input: atmel_mxt_ts - simplify event reporting
Date: Tue, 13 Mar 2012 20:04:15 +0800 [thread overview]
Message-ID: <1331640263-18935-13-git-send-email-djkurtz@chromium.org> (raw)
In-Reply-To: <1331640263-18935-1-git-send-email-djkurtz@chromium.org>
Instead of carrying around per-finger state in the driver instance, just
report each finger as it arrives to the input layer, and let the input
layer (evdev) hold the event state (which it does anyway).
Also, the atmel pad reports "amplitude", which is reported to userspace
using the "PRESSURE" event type. The variables now reflect this.
Note: this driver does not really do MT-B properly. Each input report
(a goup of input events followed by a SYN_REPORT) only contains data for
a single contact. When multiple fingers are present on a device, each is
properly reported in its own MT_SLOT. However, there is only ever one
MT_SLOT per SYN_REPORT. This is fixed in a subsequent patch.
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 122 +++++++++---------------------
1 files changed, 36 insertions(+), 86 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 4363511..fa692e5 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -194,6 +194,7 @@
#define MXT_BOOT_STATUS_MASK 0x3f
/* Touch status */
+#define MXT_UNGRIP (1 << 0)
#define MXT_SUPPRESS (1 << 1)
#define MXT_AMP (1 << 2)
#define MXT_VECTOR (1 << 3)
@@ -238,14 +239,6 @@ struct mxt_message {
u8 message[7];
};
-struct mxt_finger {
- int status;
- int x;
- int y;
- int area;
- int pressure;
-};
-
/* Each client has this additional data */
struct mxt_data {
struct i2c_client *client;
@@ -253,7 +246,6 @@ struct mxt_data {
const struct mxt_platform_data *pdata;
struct mxt_object *object_table;
struct mxt_info info;
- struct mxt_finger finger[MXT_MAX_FINGER];
unsigned int irq;
unsigned int max_x;
unsigned int max_y;
@@ -526,97 +518,55 @@ static int mxt_write_object(struct mxt_data *data,
return mxt_write_reg(data->client, reg + offset, 1, &val);
}
-static void mxt_input_report(struct mxt_data *data, int single_id)
-{
- struct mxt_finger *finger = data->finger;
- struct input_dev *input_dev = data->input_dev;
- int status = finger[single_id].status;
- int finger_num = 0;
- int id;
-
- for (id = 0; id < MXT_MAX_FINGER; id++) {
- if (!finger[id].status)
- continue;
-
- input_mt_slot(input_dev, id);
- input_mt_report_slot_state(input_dev, MT_TOOL_FINGER,
- finger[id].status != MXT_RELEASE);
-
- if (finger[id].status != MXT_RELEASE) {
- finger_num++;
- input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
- finger[id].area);
- input_report_abs(input_dev, ABS_MT_POSITION_X,
- finger[id].x);
- input_report_abs(input_dev, ABS_MT_POSITION_Y,
- finger[id].y);
- input_report_abs(input_dev, ABS_MT_PRESSURE,
- finger[id].pressure);
- } else {
- finger[id].status = 0;
- }
- }
-
- input_report_key(input_dev, BTN_TOUCH, finger_num > 0);
-
- if (status != MXT_RELEASE) {
- input_report_abs(input_dev, ABS_X, finger[single_id].x);
- input_report_abs(input_dev, ABS_Y, finger[single_id].y);
- input_report_abs(input_dev,
- ABS_PRESSURE, finger[single_id].pressure);
- }
-
- input_sync(input_dev);
-}
-
static void mxt_input_touchevent(struct mxt_data *data,
- struct mxt_message *message, int id)
+ struct mxt_message *message, int id)
{
- struct mxt_finger *finger = data->finger;
struct device *dev = &data->client->dev;
- u8 status = message->message[0];
+ struct input_dev *input_dev = data->input_dev;
+ u8 status;
int x;
int y;
int area;
- int pressure;
-
- /* Check the touch is present on the screen */
- if (!(status & MXT_DETECT)) {
- if (status & MXT_RELEASE) {
- dev_dbg(dev, "[%d] released\n", id);
-
- finger[id].status = MXT_RELEASE;
- mxt_input_report(data, id);
- }
- return;
- }
-
- /* Check only AMP detection */
- if (!(status & (MXT_PRESS | MXT_MOVE)))
- return;
+ int amplitude;
+ status = message->message[0];
x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf);
y = (message->message[2] << 4) | ((message->message[3] & 0xf));
if (data->max_x < 1024)
- x = x >> 2;
+ x >>= 2;
if (data->max_y < 1024)
- y = y >> 2;
+ y >>= 2;
area = message->message[4];
- pressure = message->message[5];
-
- dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id,
- status & MXT_MOVE ? "moved" : "pressed",
- x, y, area);
-
- finger[id].status = status & MXT_MOVE ?
- MXT_MOVE : MXT_PRESS;
- finger[id].x = x;
- finger[id].y = y;
- finger[id].area = area;
- finger[id].pressure = pressure;
+ amplitude = message->message[5];
+
+ dev_dbg(dev,
+ "[%d] %c%c%c%c%c%c%c%c x: %d y: %d area: %d amp: %d\n",
+ id,
+ (status & MXT_DETECT) ? 'D' : '.',
+ (status & MXT_PRESS) ? 'P' : '.',
+ (status & MXT_RELEASE) ? 'R' : '.',
+ (status & MXT_MOVE) ? 'M' : '.',
+ (status & MXT_VECTOR) ? 'V' : '.',
+ (status & MXT_AMP) ? 'A' : '.',
+ (status & MXT_SUPPRESS) ? 'S' : '.',
+ (status & MXT_UNGRIP) ? 'U' : '.',
+ x, y, area, amplitude);
+
+ input_mt_slot(input_dev, id);
+ input_mt_report_slot_state(input_dev, MT_TOOL_FINGER,
+ status & MXT_DETECT);
+
+ if (status & MXT_DETECT) {
+ input_report_abs(input_dev, ABS_MT_POSITION_X, x);
+ input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
+ input_report_abs(input_dev, ABS_MT_PRESSURE, amplitude);
+ /* TODO: This should really be sqrt(area) */
+ input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, area);
+ }
- mxt_input_report(data, id);
+ input_mt_report_pointer_emulation(input_dev, false);
+ input_sync(input_dev);
}
static irqreturn_t mxt_interrupt(int irq, void *dev_id)
--
1.7.7.3
next prev parent reply other threads:[~2012-03-13 12:04 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-13 12:04 [PATCH 00/20] cleanup atmel_mxt_ts Daniel Kurtz
2012-03-13 12:04 ` [PATCH 01/20] Input: atmel_mxt_ts - use CONFIG_PM_SLEEP Daniel Kurtz
2012-03-13 12:04 ` [PATCH 02/20] Input: atmel_mxt_ts - only allow root to update firmware Daniel Kurtz
2012-03-20 14:38 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 03/20] Input: atmel_mxt_ts - verify object size in mxt_write_object Daniel Kurtz
2012-03-14 1:33 ` Joonyoung Shim
2012-03-14 2:13 ` Daniel Kurtz
2012-03-14 2:37 ` Joonyoung Shim
2012-03-13 12:04 ` [PATCH 04/20] Input: atmel_mxt_ts - refactor mxt_read/write_reg to take a length Daniel Kurtz
2012-03-13 12:04 ` [PATCH 05/20] Input: atmel_mxt_ts - dump mxt_read/write_reg Daniel Kurtz
2012-03-20 14:43 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 06/20] Input: atmel_mxt_ts - allow writing to object sysfs entry Daniel Kurtz
2012-03-19 8:04 ` Henrik Rydberg
2012-03-19 8:26 ` Daniel Kurtz
2012-03-20 14:51 ` Nick Dyer
2012-03-20 23:03 ` Alan Cox
2012-03-20 23:32 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 07/20] Input: atmel_mxt_ts - add backupnv " Daniel Kurtz
2012-03-20 15:01 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 08/20] Input: atmel_mxt_ts - store actual size and instance Daniel Kurtz
2012-03-20 15:05 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 09/20] Input: atmel_mxt_ts - do not read extra (checksum) byte Daniel Kurtz
2012-03-20 15:07 ` Nick Dyer
2012-03-22 10:18 ` Bowens, Alan
2012-03-13 12:04 ` [PATCH 10/20] Input: atmel_mxt_ts - dump each message on just 1 line Daniel Kurtz
2012-03-20 15:08 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 11/20] Input: atmel_mxt_ts - refactor mxt_object_show Daniel Kurtz
2012-03-20 15:11 ` Nick Dyer
2012-03-13 12:04 ` Daniel Kurtz [this message]
2012-03-19 8:26 ` [PATCH 12/20] Input: atmel_mxt_ts - simplify event reporting Henrik Rydberg
2012-03-19 9:06 ` Daniel Kurtz
2012-03-20 15:13 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 13/20] Input: atmel_mxt_ts - parse vector field of data packets Daniel Kurtz
2012-03-20 15:23 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 14/20] Input: atmel_mxt_ts - refactor reading object table Daniel Kurtz
2012-03-20 15:19 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 15/20] Input: atmel_mxt_ts - optimize writing of object table entries Daniel Kurtz
2012-03-13 12:04 ` [PATCH 16/20] Input: atmel_mxt_ts - refactor get info Daniel Kurtz
2012-03-20 15:21 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 17/20] Input: atmel_mxt_ts - use cached T9 reportid range in isr Daniel Kurtz
2012-03-20 15:30 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 18/20] Input: atmel_mxt_ts - read num messages, then all messages Daniel Kurtz
2012-03-14 2:32 ` Joonyoung Shim
2012-03-14 3:13 ` Daniel Kurtz
2012-03-20 15:28 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 19/20] Input: atmel_mxt_ts - remove mxt_make_highchg and parse T6 report Daniel Kurtz
2012-03-20 15:38 ` Nick Dyer
2012-03-29 15:20 ` Daniel Kurtz
2012-03-30 7:00 ` Nick Dyer
2012-03-13 12:04 ` [PATCH 20/20] Input: atmel_mxt_ts - send all MT-B slots in one input report Daniel Kurtz
2012-03-20 15:39 ` Nick Dyer
2012-03-14 2:43 ` [PATCH 00/20] cleanup atmel_mxt_ts Joonyoung Shim
2012-03-14 17:00 ` Valkonen, Iiro
2012-03-20 14:33 ` Nick Dyer
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=1331640263-18935-13-git-send-email-djkurtz@chromium.org \
--to=djkurtz@chromium.org \
--cc=bleung@chromium.org \
--cc=dmitry.torokhov@gmail.com \
--cc=iiro.valkonen@atmel.com \
--cc=jy0922.shim@samsung.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miletus@chromium.org \
--cc=rydberg@euromail.se \
/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).