summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Pfetsch <spfetsch@google.com>2019-05-03 16:38:36 -0700
committerSteve Pfetsch <spfetsch@google.com>2019-05-03 17:43:21 -0700
commit4aad5f259c9dbe487ad50fc25739e0439e0c6e58 (patch)
tree707a1101c29ad0fa8475609ad1225b049a130252
parent359bdd24203a314f7e95994a4f2d947e2acb7c86 (diff)
downloadfts_touch-4aad5f259c9dbe487ad50fc25739e0439e0c6e58.tar.gz
input: touchscreen: stm: remove excessive delays from pollForEvent
pollForEvent is designed to consume events from the touch IC until a desired event is received, but it incorrectly waits between all read operations regardless of how many events are queued in the FIFO. Instead, read continuosly while the touch IC is responsive and it is not reporting that the FIFO is empty. Bug: 131922554 Change-Id: Id1cfc83ab2bec9dafa6460d0d142b52fb353c838 Signed-off-by: Steve Pfetsch <spfetsch@google.com>
-rw-r--r--fts_lib/ftsCore.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/fts_lib/ftsCore.c b/fts_lib/ftsCore.c
index 67f181f..3e470c2 100644
--- a/fts_lib/ftsCore.c
+++ b/fts_lib/ftsCore.c
@@ -114,7 +114,7 @@ int fts_system_reset(void)
data));
else {
gpio_set_value(reset_gpio, 0);
- mdelay(10);
+ msleep(10);
gpio_set_value(reset_gpio, 1);
res = OK;
}
@@ -197,6 +197,8 @@ void setSystemResetedUp(int val)
int pollForEvent(int *event_to_search, int event_bytes, u8 *readData, int
time_to_wait)
{
+ const u8 NO_RESPONSE = 0xFF;
+ const int POLL_SLEEP_TIME_MS = 5;
int i, find, retry, count_err;
int time_to_count;
int err_handling = OK;
@@ -208,15 +210,21 @@ int pollForEvent(int *event_to_search, int event_bytes, u8 *readData, int
find = 0;
retry = 0;
count_err = 0;
- time_to_count = time_to_wait / TIMEOUT_RESOLUTION;
+ time_to_count = time_to_wait / POLL_SLEEP_TIME_MS;
startStopWatch(&clock);
while (find != 1 && retry < time_to_count &&
fts_writeReadU8UX(cmd[0], 0, 0, readData, FIFO_EVENT_SIZE,
DUMMY_FIFO)
>= OK) {
- /* Log of errors */
- if (readData[0] == EVT_ID_ERROR) {
+ if (readData[0] == NO_RESPONSE ||
+ readData[0] == EVT_ID_NOEVENT) {
+ /* No events available, so sleep briefly */
+ msleep(POLL_SLEEP_TIME_MS);
+ retry++;
+ continue;
+ } else if (readData[0] == EVT_ID_ERROR) {
+ /* Log of errors */
pr_err("%s\n",
printHex("ERROR EVENT = ",
readData,
@@ -233,14 +241,13 @@ int pollForEvent(int *event_to_search, int event_bytes, u8 *readData, int
return err_handling;
}
} else {
- if (readData[0] != EVT_ID_NOEVENT) {
- pr_info("%s\n",
- printHex("READ EVENT = ", readData,
- FIFO_EVENT_SIZE,
- temp,
- sizeof(temp)));
- memset(temp, 0, 128);
- }
+ pr_info("%s\n",
+ printHex("READ EVENT = ", readData,
+ FIFO_EVENT_SIZE,
+ temp,
+ sizeof(temp)));
+ memset(temp, 0, 128);
+
if (readData[0] == EVT_ID_CONTROLLER_READY &&
event_to_search[0] != EVT_ID_CONTROLLER_READY) {
pr_err("pollForEvent: Unmanned Controller Ready Event! Setting reset flags...\n");
@@ -258,9 +265,6 @@ int pollForEvent(int *event_to_search, int event_bytes, u8 *readData, int
break;
}
}
-
- retry++;
- mdelay(TIMEOUT_RESOLUTION);
}
stopStopWatch(&clock);
if ((retry >= time_to_count) && find != 1) {