summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Bunker <trevorbunker@google.com>2016-09-21 13:34:43 -0700
committerBen Fennema <fennema@google.com>2016-09-21 14:59:38 -0700
commit06b098c883dca461a2b5ad4357f4ba5abce43eb3 (patch)
treeb5bf5d7d20e87b5b1179196a7024c6d79ec39aec
parent93abd206644e40146daaa873fdd2f297b9322f8b (diff)
downloadcontexthub-06b098c883dca461a2b5ad4357f4ba5abce43eb3.tar.gz
synaptics_s3708: disable interrupt when powering off
Bug: 31653505 Change-Id: I1577e93420daf053b273b793e0e4966ff6ed6aa1
-rw-r--r--firmware/src/drivers/synaptics_s3708/synaptics_s3708.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/firmware/src/drivers/synaptics_s3708/synaptics_s3708.c b/firmware/src/drivers/synaptics_s3708/synaptics_s3708.c
index 6508dd97..c858adac 100644
--- a/firmware/src/drivers/synaptics_s3708/synaptics_s3708.c
+++ b/firmware/src/drivers/synaptics_s3708/synaptics_s3708.c
@@ -141,14 +141,15 @@ static struct TaskStruct
struct Gpio *pin;
struct ChainedIsr isr;
struct TaskStatistics stats;
+ struct I2cTransfer transfers[MAX_PENDING_I2C_REQUESTS];
uint32_t id;
uint32_t handle;
uint32_t retryTimerHandle;
uint32_t retryCnt;
- struct I2cTransfer transfers[MAX_PENDING_I2C_REQUESTS];
- bool on;
uint32_t proxHandle;
enum ProxState proxState;
+ bool on;
+ bool gestureEnabled;
} mTask;
static inline void enableInterrupt(bool enable)
@@ -292,7 +293,7 @@ static void setRetryTimer()
}
}
-static void setGesturePower(bool enable)
+static void setGesturePower(bool enable, bool skipI2c)
{
bool ret;
size_t i;
@@ -318,11 +319,16 @@ static void setGesturePower(bool enable)
mTask.retryTimerHandle = 0;
}
- // Reset to continuous reporting mode
- ret = setReportingMode(S3708_REPORT_MODE_CONT, STATE_DISABLE_0);
+ if (skipI2c) {
+ ret = true;
+ } else {
+ // Reset to continuous reporting mode
+ ret = setReportingMode(S3708_REPORT_MODE_CONT, STATE_DISABLE_0);
+ }
}
if (ret) {
+ mTask.gestureEnabled = enable;
enableInterrupt(enable);
}
}
@@ -367,6 +373,12 @@ static bool callbackPower(bool on, void *cookie)
proxEnabledSeconds / 3600, (proxEnabledSeconds % 3600) / 60, proxEnabledSeconds % 60,
proxFarSeconds / 3600, (proxFarSeconds % 3600) / 60, proxFarSeconds % 60);
+ // If the task is disabled, that means the AP is on and has switched the I2C
+ // mux. Therefore, no I2C transactions will succeed so skip them.
+ if (mTask.gestureEnabled) {
+ setGesturePower(false, true /* skipI2c */);
+ }
+
mTask.on = on;
configProx(on);
@@ -507,17 +519,19 @@ static void handleEvent(uint32_t evtType, const void* evtData)
break;
case EVT_SENSOR_PROX:
- // cast off the const, and cast to union
- embeddedSample = (union EmbeddedDataPoint)((void*)evtData);
- lastProxState = mTask.proxState;
- mTask.proxState = (embeddedSample.fdata < PROXIMITY_THRESH_NEAR) ? PROX_STATE_NEAR : PROX_STATE_FAR;
-
- if ((lastProxState != PROX_STATE_FAR) && (mTask.proxState == PROX_STATE_FAR)) {
- mTask.stats.lastProxFarTimestamp = sensorGetTime();
- setGesturePower(true);
- } else if ((lastProxState == PROX_STATE_FAR) && (mTask.proxState == PROX_STATE_NEAR)) {
- mTask.stats.totalProxFarTime += sensorGetTime() - mTask.stats.lastProxFarTimestamp;
- setGesturePower(false);
+ if (mTask.on) {
+ // cast off the const, and cast to union
+ embeddedSample = (union EmbeddedDataPoint)((void*)evtData);
+ lastProxState = mTask.proxState;
+ mTask.proxState = (embeddedSample.fdata < PROXIMITY_THRESH_NEAR) ? PROX_STATE_NEAR : PROX_STATE_FAR;
+
+ if ((lastProxState != PROX_STATE_FAR) && (mTask.proxState == PROX_STATE_FAR)) {
+ mTask.stats.lastProxFarTimestamp = sensorGetTime();
+ setGesturePower(true, false);
+ } else if ((lastProxState == PROX_STATE_FAR) && (mTask.proxState == PROX_STATE_NEAR)) {
+ mTask.stats.totalProxFarTime += sensorGetTime() - mTask.stats.lastProxFarTimestamp;
+ setGesturePower(false, false);
+ }
}
break;