Commit 497767d1 authored by Nick Dyer's avatar Nick Dyer Committed by Dmitry Torokhov

Input: atmel_mxt_ts - decode T6 status messages

By storing the previous T6 status byte multiple debug output of the same
status can be suppressed (for example CFGERR).
Signed-off-by: default avatarNick Dyer <nick.dyer@itdev.co.uk>
Acked-by: default avatarBenson Leung <bleung@chromium.org>
Acked-by: default avatarYufeng Shen <miletus@chromium.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 5f3f9bc2
...@@ -92,6 +92,11 @@ ...@@ -92,6 +92,11 @@
/* Define for T6 status byte */ /* Define for T6 status byte */
#define MXT_T6_STATUS_RESET (1 << 7) #define MXT_T6_STATUS_RESET (1 << 7)
#define MXT_T6_STATUS_OFL (1 << 6)
#define MXT_T6_STATUS_SIGERR (1 << 5)
#define MXT_T6_STATUS_CAL (1 << 4)
#define MXT_T6_STATUS_CFGERR (1 << 3)
#define MXT_T6_STATUS_COMSERR (1 << 2)
/* MXT_GEN_POWER_T7 field */ /* MXT_GEN_POWER_T7 field */
#define MXT_POWER_IDLEACQINT 0 #define MXT_POWER_IDLEACQINT 0
...@@ -243,6 +248,7 @@ struct mxt_data { ...@@ -243,6 +248,7 @@ struct mxt_data {
u32 info_crc; u32 info_crc;
u8 bootloader_addr; u8 bootloader_addr;
u8 *msg_buf; u8 *msg_buf;
u8 t6_status;
/* Cached parameters from object table */ /* Cached parameters from object table */
u8 T5_msg_size; u8 T5_msg_size;
...@@ -623,6 +629,39 @@ mxt_get_object(struct mxt_data *data, u8 type) ...@@ -623,6 +629,39 @@ mxt_get_object(struct mxt_data *data, u8 type)
return NULL; return NULL;
} }
static void mxt_proc_t6_messages(struct mxt_data *data, u8 *msg)
{
struct device *dev = &data->client->dev;
u8 status = msg[1];
u32 crc = msg[2] | (msg[3] << 8) | (msg[4] << 16);
complete(&data->crc_completion);
if (crc != data->config_crc) {
data->config_crc = crc;
dev_dbg(dev, "T6 Config Checksum: 0x%06X\n", crc);
}
/* Detect reset */
if (status & MXT_T6_STATUS_RESET)
complete(&data->reset_completion);
/* Output debug if status has changed */
if (status != data->t6_status)
dev_dbg(dev, "T6 Status 0x%02X%s%s%s%s%s%s%s\n",
status,
status == 0 ? " OK" : "",
status & MXT_T6_STATUS_RESET ? " RESET" : "",
status & MXT_T6_STATUS_OFL ? " OFL" : "",
status & MXT_T6_STATUS_SIGERR ? " SIGERR" : "",
status & MXT_T6_STATUS_CAL ? " CAL" : "",
status & MXT_T6_STATUS_CFGERR ? " CFGERR" : "",
status & MXT_T6_STATUS_COMSERR ? " COMSERR" : "");
/* Save current status */
data->t6_status = status;
}
static int mxt_read_message(struct mxt_data *data, u8 *message) static int mxt_read_message(struct mxt_data *data, u8 *message)
{ {
struct mxt_object *object; struct mxt_object *object;
...@@ -738,11 +777,6 @@ static void mxt_input_touchevent(struct mxt_data *data, u8 *message) ...@@ -738,11 +777,6 @@ static void mxt_input_touchevent(struct mxt_data *data, u8 *message)
} }
} }
static u16 mxt_extract_T6_csum(const u8 *csum)
{
return csum[0] | (csum[1] << 8) | (csum[2] << 16);
}
static bool mxt_is_T9_message(struct mxt_data *data, u8 *msg) static bool mxt_is_T9_message(struct mxt_data *data, u8 *msg)
{ {
u8 id = msg[0]; u8 id = msg[0];
...@@ -752,11 +786,9 @@ static bool mxt_is_T9_message(struct mxt_data *data, u8 *msg) ...@@ -752,11 +786,9 @@ static bool mxt_is_T9_message(struct mxt_data *data, u8 *msg)
static irqreturn_t mxt_process_messages_until_invalid(struct mxt_data *data) static irqreturn_t mxt_process_messages_until_invalid(struct mxt_data *data)
{ {
u8 *message = &data->msg_buf[0]; u8 *message = &data->msg_buf[0];
const u8 *payload = &data->msg_buf[1];
struct device *dev = &data->client->dev; struct device *dev = &data->client->dev;
u8 reportid; u8 reportid;
bool update_input = false; bool update_input = false;
u32 crc;
do { do {
if (mxt_read_message(data, message)) { if (mxt_read_message(data, message)) {
...@@ -767,19 +799,7 @@ static irqreturn_t mxt_process_messages_until_invalid(struct mxt_data *data) ...@@ -767,19 +799,7 @@ static irqreturn_t mxt_process_messages_until_invalid(struct mxt_data *data)
reportid = message[0]; reportid = message[0];
if (reportid == data->T6_reportid) { if (reportid == data->T6_reportid) {
u8 status = payload[0]; mxt_proc_t6_messages(data, message);
crc = mxt_extract_T6_csum(&payload[1]);
if (crc != data->config_crc) {
data->config_crc = crc;
complete(&data->crc_completion);
}
dev_dbg(dev, "Status: %02x Config Checksum: %06x\n",
status, data->config_crc);
if (status & MXT_T6_STATUS_RESET)
complete(&data->reset_completion);
} else if (!data->input_dev) { } else if (!data->input_dev) {
/* /*
* do not report events if input device * do not report events if input device
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment