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 10/16 v2] Input: atmel_mxt_ts - refactor get info
Date: Fri, 30 Mar 2012 00:49:20 +0800 [thread overview]
Message-ID: <1333039766-8617-11-git-send-email-djkurtz@chromium.org> (raw)
In-Reply-To: <1333039766-8617-1-git-send-email-djkurtz@chromium.org>
Read whole info block in one i2c transaction.
And then re-read the matrix size after applying pdata config, since
it may have changed.
Note, however, that the matrix x & y size are just displayed for
information purposes. They aren't actually used by the driver itself.
Also, parse and info print the firmware major and minor version numbers.
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 65 +++++------------------------
1 files changed, 12 insertions(+), 53 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 3abc5b0..9d88faf 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -36,6 +36,7 @@
#define MXT_FW_NAME "maxtouch.fw"
/* Registers */
+#define MXT_INFO 0x00
#define MXT_FAMILY_ID 0x00
#define MXT_VARIANT_ID 0x01
#define MXT_VERSION 0x02
@@ -730,41 +731,6 @@ static void mxt_handle_pdata(struct mxt_data *data)
}
}
-static int mxt_get_info(struct mxt_data *data)
-{
- struct i2c_client *client = data->client;
- struct mxt_info *info = &data->info;
- int error;
- u8 val;
-
- error = mxt_read_reg(client, MXT_FAMILY_ID, 1, &val);
- if (error)
- return error;
- info->family_id = val;
-
- error = mxt_read_reg(client, MXT_VARIANT_ID, 1, &val);
- if (error)
- return error;
- info->variant_id = val;
-
- error = mxt_read_reg(client, MXT_VERSION, 1, &val);
- if (error)
- return error;
- info->version = val;
-
- error = mxt_read_reg(client, MXT_BUILD, 1, &val);
- if (error)
- return error;
- info->build = val;
-
- error = mxt_read_reg(client, MXT_OBJECT_NUM, 1, &val);
- if (error)
- return error;
- info->object_num = val;
-
- return 0;
-}
-
static int mxt_get_object_table(struct mxt_data *data)
{
int error;
@@ -799,11 +765,12 @@ static int mxt_get_object_table(struct mxt_data *data)
static int mxt_initialize(struct mxt_data *data)
{
struct i2c_client *client = data->client;
+ struct device *dev = &client->dev;
struct mxt_info *info = &data->info;
int error;
- u8 val;
- error = mxt_get_info(data);
+ /* Read 7-byte info block starting at address 0 */
+ error = mxt_read_reg(client, MXT_INFO, sizeof(*info), info);
if (error)
return error;
@@ -838,26 +805,18 @@ static int mxt_initialize(struct mxt_data *data)
MXT_COMMAND_RESET, 1);
msleep(MXT_RESET_TIME);
- /* Update matrix size at info struct */
- error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, 1, &val);
- if (error)
- return error;
- info->matrix_xsize = val;
-
- error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, 1, &val);
+ /* Update matrix size, since it may have been modified by pdata */
+ error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, 2,
+ &info->matrix_xsize);
if (error)
return error;
- info->matrix_ysize = val;
- dev_info(&client->dev,
- "Family ID: %d Variant ID: %d Version: %d Build: %d\n",
- info->family_id, info->variant_id, info->version,
- info->build);
+ dev_info(dev, "Family ID: %d Variant ID: %d Major.Minor.Build: %d.%d.%d\n",
+ info->family_id, info->variant_id, info->version >> 4,
+ info->version & 0xf, info->build);
- dev_info(&client->dev,
- "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
- info->matrix_xsize, info->matrix_ysize,
- info->object_num);
+ dev_info(dev, "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n",
+ info->matrix_xsize, info->matrix_ysize, info->object_num);
return 0;
}
--
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 ` Daniel Kurtz [this message]
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 ` [PATCH 13/16 v2] Input: atmel_mxt_ts - cache T9 reportid range when reading object table Daniel Kurtz
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-11-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).