diff options
author | Nick Vaccaro <nvaccaro@google.com> | 2015-07-22 09:17:35 -0700 |
---|---|---|
committer | Nick Vaccaro <nvaccaro@google.com> | 2015-07-23 14:26:04 -0700 |
commit | 70d66cf47a692a165f668ae219d239b54a3dcc83 (patch) | |
tree | 04c9f28b775e2ef47eb2ee86a78c285814b916f4 | |
parent | a38914db2fd5b3192bfa8fbd46269aa860d7937b (diff) | |
download | invensense-70d66cf47a692a165f668ae219d239b54a3dcc83.tar.gz |
Invensense: 6515: use CLOCK_BOOTTIME for timestamps
Sensor timestamps must include time during sleep. CLOCK_MONOTONIC
does not include time during sleep, so sensor timestamps need to use
CLOCK_BOOTTIME instead.
Change-Id: I40c91dec5cbf4e7ec99c239de0725d492ba40e2f
-rw-r--r-- | 6515/libsensors_iio/MPLSensor.cpp | 15 | ||||
-rwxr-xr-x | 6515/libsensors_iio/SensorBase.cpp | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/6515/libsensors_iio/MPLSensor.cpp b/6515/libsensors_iio/MPLSensor.cpp index 1cfab7a..c66007e 100644 --- a/6515/libsensors_iio/MPLSensor.cpp +++ b/6515/libsensors_iio/MPLSensor.cpp @@ -1822,7 +1822,7 @@ int MPLSensor::enableDmpPedometer(int en, int interruptMode) mFeatureActiveMask |= INV_DMP_PEDOMETER_STEP; } - clock_gettime(CLOCK_MONOTONIC, &mt_pre); + clock_gettime(CLOCK_BOOTTIME, &mt_pre); } else { if (interruptMode) { mFeatureActiveMask &= ~INV_DMP_PEDOMETER; @@ -2827,7 +2827,7 @@ int MPLSensor::smHandler(sensors_event_t* s) /* Capture timestamp in HAL */ struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); + clock_gettime(CLOCK_BOOTTIME, &ts); s->timestamp = (int64_t) ts.tv_sec * 1000000000 + ts.tv_nsec; LOGV_IF(HANDLER_DATA, "HAL:sm data: %f - %lld - %d", @@ -2886,7 +2886,7 @@ int MPLSensor::sdHandler(sensors_event_t* s) /* get current timestamp */ struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts) ; + clock_gettime(CLOCK_BOOTTIME, &ts) ; s->timestamp = (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec; LOGV_IF(HANDLER_DATA, "HAL:sd data: %f - %lld - %d", @@ -2912,7 +2912,7 @@ int MPLSensor::scHandler(sensors_event_t* s) if (s->timestamp == 0 && update) { struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); + clock_gettime(CLOCK_BOOTTIME, &ts); s->timestamp = (int64_t) ts.tv_sec * 1000000000 + ts.tv_nsec; // workaround for some platform which has gap between monotonic clock // and Android SystemClock. @@ -4695,7 +4695,7 @@ int MPLSensor::readDmpOrientEvents(sensors_event_t* data, int count) temp.screen_orientation = screen_orientation; #endif struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); + clock_gettime(CLOCK_BOOTTIME, &ts); temp.timestamp = (int64_t) ts.tv_sec * 1000000000 + ts.tv_nsec; *data++ = temp; @@ -4767,7 +4767,7 @@ bool MPLSensor::hasStepCountPendingEvents(void) struct timespec t_now; int64_t interval = 0; - clock_gettime(CLOCK_MONOTONIC, &t_now); + clock_gettime(CLOCK_BOOTTIME, &t_now); interval = ((int64_t(t_now.tv_sec) * 1000000000LL + t_now.tv_nsec) - (int64_t(mt_pre.tv_sec) * 1000000000LL + mt_pre.tv_nsec)); @@ -4777,7 +4777,7 @@ bool MPLSensor::hasStepCountPendingEvents(void) interval, mStepCountPollTime); return false; } else { - clock_gettime(CLOCK_MONOTONIC, &mt_pre); + clock_gettime(CLOCK_BOOTTIME, &mt_pre); LOGV_IF(0, "Step Count previous time: %ld ms", mt_pre.tv_nsec / 1000); return true; @@ -5230,6 +5230,7 @@ int MPLSensor::inv_init_sysfs_attributes(void) // get proper (in absolute) IIO path & build MPU's sysfs paths inv_get_sysfs_path(sysfs_path); + LOGV_IF(true, "njv Invensense sysfs path : %s", sysfs_path); memcpy(mSysfsPath, sysfs_path, sizeof(sysfs_path)); sprintf(mpu.key, "%s%s", sysfs_path, "/key"); diff --git a/6515/libsensors_iio/SensorBase.cpp b/6515/libsensors_iio/SensorBase.cpp index 544ac15..f1d00fb 100755 --- a/6515/libsensors_iio/SensorBase.cpp +++ b/6515/libsensors_iio/SensorBase.cpp @@ -143,7 +143,7 @@ int64_t SensorBase::getTimestamp() { struct timespec t; t.tv_sec = t.tv_nsec = 0; - clock_gettime(CLOCK_MONOTONIC, &t); + clock_gettime(CLOCK_BOOTTIME, &t); return int64_t(t.tv_sec) * 1000000000LL + t.tv_nsec; } |