From: Daniel Kurtz <djkurtz@chromium.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Henrik Rydberg <rydberg@euromail.se>,
Joonyoung Shim <jy0922.shim@samsung.com>,
Nick Dyer <nick.dyer@itdev.co.uk>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Benson Leung <bleung@chromium.org>,
Yufeng Shen <miletus@chromium.org>
Cc: Daniel Kurtz <djkurtz@chromium.org>
Subject: [PATCH 13/16 v2] Input: atmel_mxt_ts - cache T9 reportid range when reading object table
Date: Fri, 30 Mar 2012 00:49:23 +0800 [thread overview]
Message-ID: <1333039766-8617-14-git-send-email-djkurtz@chromium.org> (raw)
In-Reply-To: <1333039766-8617-1-git-send-email-djkurtz@chromium.org>
Streamline interrupt processing by caching the T9 reportid range when
first reading the object table.
Note: the cached T9 reportid's are initialized to 0, which is an invalid
reportid. Thus, the checks in the interrupt handler will always fail for
devices that do not support the T9 object.
One side effect of this is we can know the max number of contacts that
can be tracked, and therefore can properly report max number of MT-B slots
to userspace instead of assuming a fixed 10.
This patch tested on an MXT224E.
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 67 +++++++++++++++--------------
1 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 731293b..40dd3e6 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -212,8 +212,6 @@
/* Touchscreen absolute values */
#define MXT_MAX_AREA 0xff
-#define MXT_MAX_FINGER 10
-
struct mxt_info {
u8 family_id;
u8 variant_id;
@@ -230,9 +228,6 @@ struct mxt_object {
u16 size;
u16 instances;
u8 num_report_ids;
-
- /* to map object and message */
- u8 max_reportid;
};
struct mxt_message {
@@ -250,6 +245,10 @@ struct mxt_data {
unsigned int irq;
unsigned int max_x;
unsigned int max_y;
+
+ /* Cached parameters from object table */
+ u8 T9_reportid_min;
+ u8 T9_reportid_max;
};
static bool mxt_object_readable(unsigned int type)
@@ -480,8 +479,7 @@ static int mxt_write_object(struct mxt_data *data,
return mxt_write_reg(data->client, reg + offset, 1, &val);
}
-static void mxt_input_touchevent(struct mxt_data *data,
- struct mxt_message *message, int id)
+static void mxt_input_touch(struct mxt_data *data, struct mxt_message *message)
{
struct device *dev = &data->client->dev;
struct input_dev *input_dev = data->input_dev;
@@ -490,6 +488,9 @@ static void mxt_input_touchevent(struct mxt_data *data,
int y;
int area;
int amplitude;
+ int id;
+
+ id = message->reportid - data->T9_reportid_min;
status = message->message[0];
x = (message->message[1] << 4) | ((message->message[3] >> 4) & 0xf);
@@ -534,12 +535,7 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id)
{
struct mxt_data *data = dev_id;
struct mxt_message message;
- struct mxt_object *object;
struct device *dev = &data->client->dev;
- int id;
- u8 reportid;
- u8 max_reportid;
- u8 min_reportid;
do {
if (mxt_read_message(data, &message)) {
@@ -547,22 +543,13 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id)
goto end;
}
- reportid = message.reportid;
-
- /* whether reportid is thing of MXT_TOUCH_MULTI_T9 */
- object = mxt_get_object(data, MXT_TOUCH_MULTI_T9);
- if (!object)
- goto end;
-
- max_reportid = object->max_reportid;
- min_reportid = max_reportid - object->num_report_ids + 1;
- id = reportid - min_reportid;
-
- if (reportid >= min_reportid && reportid <= max_reportid)
- mxt_input_touchevent(data, &message, id);
- else
+ if (message.reportid >= data->T9_reportid_min &&
+ message.reportid <= data->T9_reportid_max) {
+ mxt_input_touch(data, &message);
+ } else {
mxt_dump_message(dev, &message);
- } while (reportid != 0xff);
+ }
+ } while (message.reportid != 0xff);
end:
return IRQ_HANDLED;
@@ -679,7 +666,7 @@ static int mxt_get_object_table(struct mxt_data *data)
struct device *dev = &client->dev;
int error;
int i;
- u8 reportid = 0;
+ u8 reportid;
u8 *buf;
size_t buf_size;
@@ -701,9 +688,12 @@ static int mxt_get_object_table(struct mxt_data *data)
if (error)
goto done;
+ /* Valid Report IDs start counting from 1 */
+ reportid = 1;
for (i = 0; i < data->info.object_num; i++) {
struct mxt_object *object = &data->object_table[i];
u8 *obj_buf = &buf[i * MXT_OBJECT_SIZE];
+ u8 num_ids, min_id, max_id;
object->type = obj_buf[0];
object->start_address = (obj_buf[2] << 8) | obj_buf[1];
@@ -711,9 +701,21 @@ static int mxt_get_object_table(struct mxt_data *data)
object->instances = obj_buf[4] + 1;
object->num_report_ids = obj_buf[5];
- if (object->num_report_ids) {
- reportid += object->num_report_ids * object->instances;
- object->max_reportid = reportid;
+ num_ids = object->num_report_ids * object->instances;
+ min_id = num_ids ? reportid : 0;
+ max_id = num_ids ? reportid + num_ids - 1 : 0;
+ reportid += num_ids;
+
+ dev_info(dev,
+ "Type %2d Start %3d Size %3d Instances %2d ReportIDs %3u : %3u\n",
+ object->type, object->start_address, object->size,
+ object->instances, min_id, max_id);
+
+ switch (object->type) {
+ case MXT_TOUCH_MULTI_T9:
+ data->T9_reportid_min = min_id;
+ data->T9_reportid_max = max_id;
+ break;
}
}
@@ -1023,7 +1025,8 @@ static int __devinit mxt_probe(struct i2c_client *client,
0, 255, 0, 0);
/* For multi touch */
- input_mt_init_slots(input_dev, MXT_MAX_FINGER);
+ input_mt_init_slots(input_dev,
+ data->T9_reportid_max - data->T9_reportid_min + 1);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
0, MXT_MAX_AREA, 0, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_X,
--
1.7.7.3
next prev parent reply other threads:[~2012-03-29 16:49 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 16:49 [PATCH 00/16 v2] cleanup atmel_mxt_ts Daniel Kurtz
2012-03-29 16:49 ` [PATCH 01/16 v2] Input: atmel_mxt_ts - use CONFIG_PM_SLEEP Daniel Kurtz
2012-03-29 16:49 ` [PATCH 02/16 v2] Input: atmel_mxt_ts - only allow root to update firmware Daniel Kurtz
2012-03-29 16:49 ` [PATCH 03/16 v2] Input: atmel_mxt_ts - refactor mxt_read/write_reg to take a length Daniel Kurtz
2012-04-11 9:05 ` Henrik Rydberg
2012-04-14 4:12 ` Daniel Kurtz
2012-03-29 16:49 ` [PATCH 04/16 v2] Input: atmel_mxt_ts - store actual size and instance Daniel Kurtz
2012-03-29 16:49 ` [PATCH 05/16 v2] Input: atmel_mxt_ts - verify object size in mxt_write_object Daniel Kurtz
2012-03-29 16:49 ` [PATCH 06/16 v2] Input: atmel_mxt_ts - do not read extra (checksum) byte Daniel Kurtz
2012-03-29 16:49 ` [PATCH 07/16 v2] Input: atmel_mxt_ts - dump each message on just 1 line Daniel Kurtz
2012-03-29 16:49 ` [PATCH 08/16 v2] Input: atmel_mxt_ts - refactor mxt_object_show Daniel Kurtz
2012-04-11 16:25 ` Henrik Rydberg
2012-03-29 16:49 ` [PATCH 09/16 v2] Input: atmel_mxt_ts - optimize writing of object table entries Daniel Kurtz
2012-04-13 9:13 ` Henrik Rydberg
2012-03-29 16:49 ` [PATCH 10/16 v2] Input: atmel_mxt_ts - refactor get info Daniel Kurtz
2012-03-29 16:49 ` [PATCH 11/16 v2] Input: atmel_mxt_ts - refactor reading object table Daniel Kurtz
2012-04-13 9:11 ` Henrik Rydberg
2012-04-13 9:21 ` Daniel Kurtz
2012-04-13 9:34 ` Henrik Rydberg
2012-04-13 10:10 ` Daniel Kurtz
2012-04-13 11:09 ` Henrik Rydberg
2012-03-29 16:49 ` [PATCH 12/16 v2] Input: atmel_mxt_ts - simplify event reporting Daniel Kurtz
2012-03-29 16:49 ` Daniel Kurtz [this message]
2012-03-29 16:49 ` [PATCH 14/16 v2] Input: atmel_mxt_ts - parse vector field of data packets Daniel Kurtz
2012-03-29 16:49 ` [PATCH 15/16 v2] Input: atmel_mxt_ts - send all MT-B slots in one input report Daniel Kurtz
2012-04-13 9:20 ` Henrik Rydberg
2012-03-29 16:49 ` [PATCH 16/16 v2] Input: atmel_mxt_ts - parse T6 reports Daniel Kurtz
2012-04-09 13:14 ` [PATCH 00/16 v2] cleanup atmel_mxt_ts Daniel Kurtz
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=1333039766-8617-14-git-send-email-djkurtz@chromium.org \
--to=djkurtz@chromium.org \
--cc=bleung@chromium.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jy0922.shim@samsung.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miletus@chromium.org \
--cc=nick.dyer@itdev.co.uk \
--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).