Skip to content

Commit fdf8042

Browse files
djkurtzrydberg
authored andcommitted
Input: atmel_mxt_ts - parse T6 reports
The normal messages sent after boot or NVRAM update are T6 reports, containing a status, and the config memory checksum. Parse them and dump a useful info message. This patch tested on an MXT224E. Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
1 parent 64464ae commit fdf8042

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

‎drivers/input/touchscreen/atmel_mxt_ts.c‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ struct mxt_data {
248248
unsigned int max_y;
249249

250250
/* Cached parameters from object table */
251+
u8 T6_reportid;
251252
u8 T9_reportid_min;
252253
u8 T9_reportid_max;
253254
};
@@ -549,6 +550,11 @@ static void mxt_input_touchevent(struct mxt_data *data,
549550
}
550551
}
551552

553+
static unsigned mxt_extract_T6_csum(const u8 *csum)
554+
{
555+
return csum[0] | (csum[1] << 8) | (csum[2] << 16);
556+
}
557+
552558
static bool mxt_is_T9_message(struct mxt_data *data, struct mxt_message *msg)
553559
{
554560
u8 id = msg->reportid;
@@ -559,8 +565,8 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id)
559565
{
560566
struct mxt_data *data = dev_id;
561567
struct mxt_message message;
568+
const u8 *payload = &message.message[0];
562569
struct device *dev = &data->client->dev;
563-
int id;
564570
u8 reportid;
565571
bool update_input = false;
566572

@@ -572,9 +578,13 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id)
572578

573579
reportid = message.reportid;
574580

575-
id = reportid - data->T9_reportid_min;
576-
577-
if (mxt_is_T9_message(data, &message)) {
581+
if (reportid == data->T6_reportid) {
582+
u8 status = payload[0];
583+
unsigned csum = mxt_extract_T6_csum(&payload[1]);
584+
dev_dbg(dev, "Status: %02x Config Checksum: %06x\n",
585+
status, csum);
586+
} else if (mxt_is_T9_message(data, &message)) {
587+
int id = reportid - data->T9_reportid_min;
578588
mxt_input_touchevent(data, &message, id);
579589
update_input = true;
580590
} else {
@@ -749,6 +759,9 @@ static int mxt_get_object_table(struct mxt_data *data)
749759
object->instances + 1, min_id, max_id);
750760

751761
switch (object->type) {
762+
case MXT_GEN_COMMAND_T6:
763+
data->T6_reportid = min_id;
764+
break;
752765
case MXT_TOUCH_MULTI_T9:
753766
data->T9_reportid_min = min_id;
754767
data->T9_reportid_max = max_id;
@@ -763,8 +776,10 @@ static void mxt_free_object_table(struct mxt_data *data)
763776
{
764777
kfree(data->object_table);
765778
data->object_table = NULL;
779+
data->T6_reportid = 0;
766780
data->T9_reportid_min = 0;
767781
data->T9_reportid_max = 0;
782+
768783
}
769784

770785
static int mxt_initialize(struct mxt_data *data)

0 commit comments

Comments
 (0)