summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vaccaro <nvaccaro@google.com>2015-11-21 01:33:51 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-11-21 01:33:51 +0000
commitf5ab288a816e327c72357d8047bccd89b686b669 (patch)
tree0e459b10512c98ee500505be67b5afc01ec743e2
parent52e65be6cd18750cda3934585c6dad3389a67c23 (diff)
parent7af2cd1c96ced368c1ddeff60231000394b5cd95 (diff)
downloadinvensense-f5ab288a816e327c72357d8047bccd89b686b669.tar.gz
Sensors: Invensense: 6515: don\'t send duplicate events
am: 7af2cd1c96 * commit '7af2cd1c96ced368c1ddeff60231000394b5cd95': Sensors: Invensense: 6515: don't send duplicate events
-rw-r--r--6515/libsensors_iio/MPLSensor.cpp26
-rw-r--r--6515/libsensors_iio/MPLSensor.h1
2 files changed, 21 insertions, 6 deletions
diff --git a/6515/libsensors_iio/MPLSensor.cpp b/6515/libsensors_iio/MPLSensor.cpp
index aef93e1..cfdded8 100644
--- a/6515/libsensors_iio/MPLSensor.cpp
+++ b/6515/libsensors_iio/MPLSensor.cpp
@@ -178,6 +178,7 @@ MPLSensor::MPLSensor(CompassSensor *compass, int (*m_pt2AccelCalLoadFunc)(long *
memset(mInitial6QuatValue, 0, sizeof(mInitial6QuatValue));
mFlushSensorEnabledVector.setCapacity(NumSensors);
memset(mEnabledTime, 0, sizeof(mEnabledTime));
+ memset(mLastTimestamp, 0, sizeof(mLastTimestamp));
/* setup sysfs paths */
inv_init_sysfs_attributes();
@@ -3896,9 +3897,15 @@ int MPLSensor::readEvents(sensors_event_t* data, int count)
update = readDmpPedometerEvents(data, count, ID_P, 1);
mPedUpdate = 0;
if(update == 1 && count > 0) {
- data->timestamp = mStepSensorTimestamp;
- count--;
- numEventReceived++;
+ if (mLastTimestamp[i] != mStepSensorTimestamp) {
+ count--;
+ numEventReceived++;
+ data->timestamp = mStepSensorTimestamp;
+ mLastTimestamp[i] = mStepSensorTimestamp;
+ } else {
+ ALOGE("Event from type=%d with duplicate timestamp %lld discarded",
+ mPendingEvents[i].type, mStepSensorTimestamp);
+ }
continue;
}
} else {
@@ -3914,9 +3921,16 @@ int MPLSensor::readEvents(sensors_event_t* data, int count)
mPendingMask |= (1 << i);
if (update && (count > 0)) {
- *data++ = mPendingEvents[i];
- count--;
- numEventReceived++;
+ // Discard any events with duplicate timestamps
+ if (mLastTimestamp[i] != mPendingEvents[i].timestamp) {
+ mLastTimestamp[i] = mPendingEvents[i].timestamp;
+ *data++ = mPendingEvents[i];
+ count--;
+ numEventReceived++;
+ } else {
+ ALOGE("Event from type=%d with duplicate timestamp %lld discarded",
+ mPendingEvents[i].type, mStepSensorTimestamp);
+ }
}
}
}
diff --git a/6515/libsensors_iio/MPLSensor.h b/6515/libsensors_iio/MPLSensor.h
index 63df411..306a07f 100644
--- a/6515/libsensors_iio/MPLSensor.h
+++ b/6515/libsensors_iio/MPLSensor.h
@@ -370,6 +370,7 @@ protected:
int64_t mBatchTimeouts[NumSensors];
hfunc_t mHandlers[NumSensors];
int64_t mEnabledTime[NumSensors];
+ int64_t mLastTimestamp[NumSensors];
short mCachedGyroData[3];
long mCachedAccelData[3];
long mCachedCompassData[3];