diff options
author | Nick Dyer <nick.dyer@itdev.co.uk> | 2014-07-23 15:47:50 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-07-23 17:42:12 -0400 |
commit | 497767d158491521c706f9ae1b805eca2eceb434 (patch) | |
tree | 08e95d2e8c9357b1f81e4f2852cb261df448aad5 | |
parent | 5f3f9bc2b1f3a09e732dfb5faad9cd3f42bd0328 (diff) |
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: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 215ffe1595e3..c8c6ac1d38a1 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -92,6 +92,11 @@ | |||
92 | 92 | ||
93 | /* Define for T6 status byte */ | 93 | /* Define for T6 status byte */ |
94 | #define MXT_T6_STATUS_RESET (1 << 7) | 94 | #define MXT_T6_STATUS_RESET (1 << 7) |
95 | #define MXT_T6_STATUS_OFL (1 << 6) | ||
96 | #define MXT_T6_STATUS_SIGERR (1 << 5) | ||
97 | #define MXT_T6_STATUS_CAL (1 << 4) | ||
98 | #define MXT_T6_STATUS_CFGERR (1 << 3) | ||
99 | #define MXT_T6_STATUS_COMSERR (1 << 2) | ||
95 | 100 | ||
96 | /* MXT_GEN_POWER_T7 field */ | 101 | /* MXT_GEN_POWER_T7 field */ |
97 | #define MXT_POWER_IDLEACQINT 0 | 102 | #define MXT_POWER_IDLEACQINT 0 |
@@ -243,6 +248,7 @@ struct mxt_data { | |||
243 | u32 info_crc; | 248 | u32 info_crc; |
244 | u8 bootloader_addr; | 249 | u8 bootloader_addr; |
245 | u8 *msg_buf; | 250 | u8 *msg_buf; |
251 | u8 t6_status; | ||
246 | 252 | ||
247 | /* Cached parameters from object table */ | 253 | /* Cached parameters from object table */ |
248 | u8 T5_msg_size; | 254 | u8 T5_msg_size; |
@@ -623,6 +629,39 @@ mxt_get_object(struct mxt_data *data, u8 type) | |||
623 | return NULL; | 629 | return NULL; |
624 | } | 630 | } |
625 | 631 | ||
632 | static void mxt_proc_t6_messages(struct mxt_data *data, u8 *msg) | ||
633 | { | ||
634 | struct device *dev = &data->client->dev; | ||
635 | u8 status = msg[1]; | ||
636 | u32 crc = msg[2] | (msg[3] << 8) | (msg[4] << 16); | ||
637 | |||
638 | complete(&data->crc_completion); | ||
639 | |||
640 | if (crc != data->config_crc) { | ||
641 | data->config_crc = crc; | ||
642 | dev_dbg(dev, "T6 Config Checksum: 0x%06X\n", crc); | ||
643 | } | ||
644 | |||
645 | /* Detect reset */ | ||
646 | if (status & MXT_T6_STATUS_RESET) | ||
647 | complete(&data->reset_completion); | ||
648 | |||
649 | /* Output debug if status has changed */ | ||
650 | if (status != data->t6_status) | ||
651 | dev_dbg(dev, "T6 Status 0x%02X%s%s%s%s%s%s%s\n", | ||
652 | status, | ||
653 | status == 0 ? " OK" : "", | ||
654 | status & MXT_T6_STATUS_RESET ? " RESET" : "", | ||
655 | status & MXT_T6_STATUS_OFL ? " OFL" : "", | ||
656 | status & MXT_T6_STATUS_SIGERR ? " SIGERR" : "", | ||
657 | status & MXT_T6_STATUS_CAL ? " CAL" : "", | ||
658 | status & MXT_T6_STATUS_CFGERR ? " CFGERR" : "", | ||
659 | status & MXT_T6_STATUS_COMSERR ? " COMSERR" : ""); | ||
660 | |||
661 | /* Save current status */ | ||
662 | data->t6_status = status; | ||
663 | } | ||
664 | |||
626 | static int mxt_read_message(struct mxt_data *data, u8 *message) | 665 | static int mxt_read_message(struct mxt_data *data, u8 *message) |
627 | { | 666 | { |
628 | struct mxt_object *object; | 667 | struct mxt_object *object; |
@@ -738,11 +777,6 @@ static void mxt_input_touchevent(struct mxt_data *data, u8 *message) | |||
738 | } | 777 | } |
739 | } | 778 | } |
740 | 779 | ||
741 | static u16 mxt_extract_T6_csum(const u8 *csum) | ||
742 | { | ||
743 | return csum[0] | (csum[1] << 8) | (csum[2] << 16); | ||
744 | } | ||
745 | |||
746 | static bool mxt_is_T9_message(struct mxt_data *data, u8 *msg) | 780 | static bool mxt_is_T9_message(struct mxt_data *data, u8 *msg) |
747 | { | 781 | { |
748 | u8 id = msg[0]; | 782 | u8 id = msg[0]; |
@@ -752,11 +786,9 @@ static bool mxt_is_T9_message(struct mxt_data *data, u8 *msg) | |||
752 | static irqreturn_t mxt_process_messages_until_invalid(struct mxt_data *data) | 786 | static irqreturn_t mxt_process_messages_until_invalid(struct mxt_data *data) |
753 | { | 787 | { |
754 | u8 *message = &data->msg_buf[0]; | 788 | u8 *message = &data->msg_buf[0]; |
755 | const u8 *payload = &data->msg_buf[1]; | ||
756 | struct device *dev = &data->client->dev; | 789 | struct device *dev = &data->client->dev; |
757 | u8 reportid; | 790 | u8 reportid; |
758 | bool update_input = false; | 791 | bool update_input = false; |
759 | u32 crc; | ||
760 | 792 | ||
761 | do { | 793 | do { |
762 | if (mxt_read_message(data, message)) { | 794 | if (mxt_read_message(data, message)) { |
@@ -767,19 +799,7 @@ static irqreturn_t mxt_process_messages_until_invalid(struct mxt_data *data) | |||
767 | reportid = message[0]; | 799 | reportid = message[0]; |
768 | 800 | ||
769 | if (reportid == data->T6_reportid) { | 801 | if (reportid == data->T6_reportid) { |
770 | u8 status = payload[0]; | 802 | mxt_proc_t6_messages(data, message); |
771 | |||
772 | crc = mxt_extract_T6_csum(&payload[1]); | ||
773 | if (crc != data->config_crc) { | ||
774 | data->config_crc = crc; | ||
775 | complete(&data->crc_completion); | ||
776 | } | ||
777 | |||
778 | dev_dbg(dev, "Status: %02x Config Checksum: %06x\n", | ||
779 | status, data->config_crc); | ||
780 | |||
781 | if (status & MXT_T6_STATUS_RESET) | ||
782 | complete(&data->reset_completion); | ||
783 | } else if (!data->input_dev) { | 803 | } else if (!data->input_dev) { |
784 | /* | 804 | /* |
785 | * do not report events if input device | 805 | * do not report events if input device |