summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vaccaro <nvaccaro@google.com>2016-02-16 20:31:32 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-02-16 20:31:32 +0000
commit11e5ff75af866f91622b6008fa13db1c3685ae69 (patch)
tree765fb353c11f69cce9107a78c4ce4dce49c76258
parent1fcfa8feab7866abafa27b83a56655a5eff00e2c (diff)
parentd47d7879a03b983dc3546b717c729f7294e16c7f (diff)
downloadinvensense-11e5ff75af866f91622b6008fa13db1c3685ae69.tar.gz
Sensors: Invensense: 6515: increase event throughputandroid-wear-o-preview-4android-wear-o-preview-3android-wear-8.1.0_r1android-wear-8.0.0_r1android-vts-8.1_r9android-vts-8.1_r8android-vts-8.1_r7android-vts-8.1_r6android-vts-8.1_r5android-vts-8.1_r4android-vts-8.1_r3android-vts-8.1_r14android-vts-8.1_r13android-vts-8.1_r12android-vts-8.1_r11android-vts-8.1_r10android-vts-8.0_r9android-vts-8.0_r8android-vts-8.0_r7android-vts-8.0_r6android-vts-8.0_r2android-vts-8.0_r13android-vts-8.0_r12android-vts-8.0_r11android-vts-8.0_r10android-vts-8.0_r1android-security-8.1.0_r93android-security-8.1.0_r92android-security-8.1.0_r91android-security-8.1.0_r90android-security-8.1.0_r89android-security-8.1.0_r88android-security-8.1.0_r87android-security-8.1.0_r86android-security-8.1.0_r85android-security-8.1.0_r84android-security-8.1.0_r83android-security-8.1.0_r82android-security-8.0.0_r54android-security-8.0.0_r53android-security-8.0.0_r52android-o-preview-4android-o-preview-3android-o-preview-2android-o-preview-1android-o-mr1-preview-2android-o-mr1-preview-1android-o-mr1-iot-preview-6android-o-iot-preview-5android-n-mr2-preview-2android-n-mr2-preview-1android-n-mr1-preview-2android-n-mr1-preview-1android-n-iot-preview-4android-cts_7.1_r1android-cts-8.1_r9android-cts-8.1_r8android-cts-8.1_r7android-cts-8.1_r6android-cts-8.1_r5android-cts-8.1_r4android-cts-8.1_r3android-cts-8.1_r25android-cts-8.1_r24android-cts-8.1_r23android-cts-8.1_r22android-cts-8.1_r21android-cts-8.1_r20android-cts-8.1_r2android-cts-8.1_r19android-cts-8.1_r18android-cts-8.1_r17android-cts-8.1_r16android-cts-8.1_r15android-cts-8.1_r14android-cts-8.1_r13android-cts-8.1_r12android-cts-8.1_r11android-cts-8.1_r10android-cts-8.1_r1android-cts-8.0_r9android-cts-8.0_r8android-cts-8.0_r7android-cts-8.0_r6android-cts-8.0_r5android-cts-8.0_r4android-cts-8.0_r3android-cts-8.0_r26android-cts-8.0_r25android-cts-8.0_r24android-cts-8.0_r23android-cts-8.0_r22android-cts-8.0_r21android-cts-8.0_r20android-cts-8.0_r2android-cts-8.0_r19android-cts-8.0_r18android-cts-8.0_r17android-cts-8.0_r16android-cts-8.0_r15android-cts-8.0_r14android-cts-8.0_r13android-cts-8.0_r12android-cts-8.0_r11android-cts-8.0_r10android-cts-8.0_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-8.1.0_r9android-8.1.0_r81android-8.1.0_r80android-8.1.0_r8android-8.1.0_r79android-8.1.0_r78android-8.1.0_r77android-8.1.0_r76android-8.1.0_r75android-8.1.0_r74android-8.1.0_r73android-8.1.0_r72android-8.1.0_r71android-8.1.0_r70android-8.1.0_r7android-8.1.0_r69android-8.1.0_r68android-8.1.0_r67android-8.1.0_r66android-8.1.0_r65android-8.1.0_r64android-8.1.0_r63android-8.1.0_r62android-8.1.0_r61android-8.1.0_r60android-8.1.0_r6android-8.1.0_r53android-8.1.0_r52android-8.1.0_r51android-8.1.0_r50android-8.1.0_r5android-8.1.0_r48android-8.1.0_r47android-8.1.0_r46android-8.1.0_r45android-8.1.0_r43android-8.1.0_r42android-8.1.0_r41android-8.1.0_r40android-8.1.0_r4android-8.1.0_r39android-8.1.0_r38android-8.1.0_r37android-8.1.0_r36android-8.1.0_r35android-8.1.0_r33android-8.1.0_r32android-8.1.0_r31android-8.1.0_r30android-8.1.0_r3android-8.1.0_r29android-8.1.0_r28android-8.1.0_r27android-8.1.0_r26android-8.1.0_r25android-8.1.0_r23android-8.1.0_r22android-8.1.0_r21android-8.1.0_r20android-8.1.0_r2android-8.1.0_r19android-8.1.0_r18android-8.1.0_r17android-8.1.0_r16android-8.1.0_r15android-8.1.0_r14android-8.1.0_r13android-8.1.0_r12android-8.1.0_r11android-8.1.0_r10android-8.1.0_r1android-8.0.0_r9android-8.0.0_r7android-8.0.0_r51android-8.0.0_r50android-8.0.0_r49android-8.0.0_r48android-8.0.0_r47android-8.0.0_r46android-8.0.0_r45android-8.0.0_r44android-8.0.0_r43android-8.0.0_r42android-8.0.0_r41android-8.0.0_r40android-8.0.0_r4android-8.0.0_r39android-8.0.0_r38android-8.0.0_r37android-8.0.0_r36android-8.0.0_r35android-8.0.0_r34android-8.0.0_r33android-8.0.0_r32android-8.0.0_r31android-8.0.0_r30android-8.0.0_r3android-8.0.0_r29android-8.0.0_r28android-8.0.0_r27android-8.0.0_r26android-8.0.0_r25android-8.0.0_r24android-8.0.0_r23android-8.0.0_r22android-8.0.0_r21android-8.0.0_r2android-8.0.0_r17android-8.0.0_r16android-8.0.0_r15android-8.0.0_r13android-8.0.0_r12android-8.0.0_r11android-8.0.0_r10android-8.0.0_r1android-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1android-7.1.0_r7android-7.1.0_r6android-7.1.0_r5android-7.1.0_r4android-7.1.0_r3android-7.1.0_r2android-7.1.0_r1security-oc-releasesecurity-oc-mr1-releaseoreo-vts-releaseoreo-security-releaseoreo-releaseoreo-r6-releaseoreo-r5-releaseoreo-r4-releaseoreo-r3-releaseoreo-r2-releaseoreo-mr1-wear-releaseoreo-mr1-vts-releaseoreo-mr1-security-releaseoreo-mr1-s1-releaseoreo-mr1-releaseoreo-mr1-devoreo-mr1-cuttlefish-testingoreo-mr1-cts-releaseoreo-m8-releaseoreo-m7-releaseoreo-m6-s4-releaseoreo-m6-s3-releaseoreo-m6-s2-releaseoreo-m5-releaseoreo-m4-s9-releaseoreo-m4-s8-releaseoreo-m4-s7-releaseoreo-m4-s6-releaseoreo-m4-s5-releaseoreo-m4-s4-releaseoreo-m4-s3-releaseoreo-m4-s2-releaseoreo-m4-s12-releaseoreo-m4-s11-releaseoreo-m4-s10-releaseoreo-m4-s1-releaseoreo-m3-releaseoreo-m2-s5-releaseoreo-m2-s4-releaseoreo-m2-s3-releaseoreo-m2-s2-releaseoreo-m2-s1-releaseoreo-m2-releaseoreo-dr3-releaseoreo-dr2-releaseoreo-dr1-releaseoreo-dr1-devoreo-devoreo-cts-releaseo-previewo-mr1-iot-preview-6o-iot-preview-5nougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-devnougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-releasenougat-dr1-releasenougat-devn-iot-preview-4
am: d47d7879a0 * commit 'd47d7879a03b983dc3546b717c729f7294e16c7f': Sensors: Invensense: 6515: increase event throughput
-rw-r--r--6515/libsensors_iio/MPLSensor.cpp94
-rwxr-xr-x6515/libsensors_iio/sensors_mpl.cpp34
2 files changed, 68 insertions, 60 deletions
diff --git a/6515/libsensors_iio/MPLSensor.cpp b/6515/libsensors_iio/MPLSensor.cpp
index 5a57d0b..67cc010 100644
--- a/6515/libsensors_iio/MPLSensor.cpp
+++ b/6515/libsensors_iio/MPLSensor.cpp
@@ -244,7 +244,7 @@ MPLSensor::MPLSensor(CompassSensor *compass, int (*m_pt2AccelCalLoadFunc)(long *
if(fd < 0) {
LOGE("HAL:Error opening gyro self test scale");
} else {
- memset(gyroBuf, 0, sizeof(gyroBuf));
+ memset(gyroScale, 0, sizeof(gyroScale));
count = read_attribute_sensor(fd, gyroScale, sizeof(gyroScale));
if(count < 1) {
LOGE("HAL:Error reading gyro self test scale");
@@ -323,7 +323,7 @@ MPLSensor::MPLSensor(CompassSensor *compass, int (*m_pt2AccelCalLoadFunc)(long *
if(fd < 0) {
LOGE("HAL:Error opening gyro self test scale");
} else {
- memset(buf, 0, sizeof(buf));
+ memset(accelScale, 0, sizeof(accelScale));
count = read_attribute_sensor(fd, accelScale, sizeof(accelScale));
if(count < 1) {
LOGE("HAL:Error reading accel self test scale");
@@ -377,13 +377,13 @@ MPLSensor::MPLSensor(CompassSensor *compass, int (*m_pt2AccelCalLoadFunc)(long *
LOGV_IF(ENG_VERBOSE,
"HAL:dmp_sign_motion_fd opened : %d", dmp_sign_motion_fd);
}
-#if 1
+
/* the following threshold can be modified for SMD sensitivity */
int motionThreshold = 3000;
LOGV_IF(SYSFS_VERBOSE, "HAL:sysfs:echo %d > %s (%lld)",
motionThreshold, mpu.smd_threshold, getTimestamp());
res = write_sysfs_int(mpu.smd_threshold, motionThreshold);
-#endif
+
#if 0
int StepCounterThreshold = 5;
LOGV_IF(SYSFS_VERBOSE, "HAL:sysfs:echo %d > %s (%lld)",
@@ -419,7 +419,7 @@ MPLSensor::MPLSensor(CompassSensor *compass, int (*m_pt2AccelCalLoadFunc)(long *
/* initialize sensor data */
memset(mPendingEvents, 0, sizeof(mPendingEvents));
- memset(mPendingFlushEvents, 0, sizeof(mPendingEvents));
+ memset(mPendingFlushEvents, 0, sizeof(mPendingFlushEvents));
mPendingEvents[RotationVector].version = sizeof(sensors_event_t);
mPendingEvents[RotationVector].sensor = ID_RV;
@@ -978,13 +978,13 @@ MPLSensor::~MPLSensor()
}
if (gyro_x_offset_fd > 0) {
- close(gyro_x_dmp_bias_fd);
+ close(gyro_x_offset_fd);
}
if (gyro_y_offset_fd > 0) {
close(gyro_y_offset_fd);
}
if (gyro_z_offset_fd > 0) {
- close(accel_z_offset_fd);
+ close(gyro_z_offset_fd);
}
/* Turn off Gyro master enable */
@@ -2391,7 +2391,7 @@ int MPLSensor::computeBatchSensorMask(int enableSensors, int tempBatchSensor)
}
// if virtual sensors are on but not batched, turn off batch mode.
- for(int i = Orientation; i <= GeomagneticRotationVector; i++) {
+ for(int i = Orientation; i < NumSensors; i++) {
if ((enableSensors & (1 << i)) && !(tempBatchSensor & (1 << i))) {
LOGV_IF(ENG_VERBOSE, "HAL:computeBatchSensorMask: "
"composite sensor on continuous mode:%d", i);
@@ -2400,7 +2400,7 @@ int MPLSensor::computeBatchSensorMask(int enableSensors, int tempBatchSensor)
}
if ((mFeatureActiveMask & INV_DMP_PEDOMETER) && !(tempBatchSensor & (1 << StepDetector))) {
- LOGV("HAL:computeBatchSensorMask: step detector on continuous mode.");
+ LOGV_IF(ENG_VERBOSE, "HAL:computeBatchSensorMask: step detector on continuous mode.");
return 0;
}
@@ -3847,8 +3847,11 @@ int MPLSensor::readEvents(sensors_event_t* data, int count)
inv_execute_on_data();
int numEventReceived = 0;
-
long msg;
+
+ if (count <= 0)
+ return 0;
+
msg = inv_get_message_level_0(1);
if (msg) {
if (msg & INV_MSG_MOTION_EVENT) {
@@ -3930,46 +3933,45 @@ int MPLSensor::readEvents(sensors_event_t* data, int count)
count--;
numEventReceived++;
} else {
- ALOGE("Event from type=%d with duplicate timestamp %lld discarded",
- mPendingEvents[i].type, mStepSensorTimestamp);
+ ALOGE("Event from type=%d with duplicate timestamp %lld (%+f, %+f, %+f) discarded",
+ mPendingEvents[i].type, mLastTimestamp[i], mPendingEvents[i].data[0], mPendingEvents[i].data[1], mPendingEvents[i].data[2]);
}
}
}
- }
- mCompassOverFlow = 0;
- }
+ mCompassOverFlow = 0;
+
+ // handle partial packet read and end marker
+ // skip readEvents from hal_outputs
+ if (mFlushBatchSet && count>0 && !mFlushSensorEnabledVector.isEmpty()) {
+ while (mFlushBatchSet && count>0 && !mFlushSensorEnabledVector.isEmpty()) {
+ int sendEvent = metaHandler(&mPendingFlushEvents[0], META_DATA_FLUSH_COMPLETE);
+ if (sendEvent) {
+ LOGV_IF(ENG_VERBOSE, "Queueing flush complete for handle=%d",
+ mPendingFlushEvents[0].meta_data.sensor);
+ *data++ = mPendingFlushEvents[0];
+ count--;
+ numEventReceived++;
+ } else {
+ LOGV_IF(ENG_VERBOSE, "sendEvent false, NOT queueing flush complete for handle=%d",
+ mPendingFlushEvents[0].meta_data.sensor);
+ }
+ mFlushBatchSet--;
+ }
- // handle partial packet read and end marker
- // skip readEvents from hal_outputs
- if (mFlushBatchSet && count>0 && !mFlushSensorEnabledVector.isEmpty()) {
- while (mFlushBatchSet && count>0 && !mFlushSensorEnabledVector.isEmpty()) {
- int sendEvent = metaHandler(&mPendingFlushEvents[0], META_DATA_FLUSH_COMPLETE);
- if (sendEvent) {
- LOGV_IF(ENG_VERBOSE, "Queueing flush complete for handle=%d",
- mPendingFlushEvents[0].meta_data.sensor);
- *data++ = mPendingFlushEvents[0];
- count--;
- numEventReceived++;
- } else {
- LOGV_IF(ENG_VERBOSE, "sendEvent false, NOT queueing flush complete for handle=%d",
- mPendingFlushEvents[0].meta_data.sensor);
+ // Double check flush status
+ if (mFlushSensorEnabledVector.isEmpty()) {
+ mEmptyDataMarkerDetected = 0;
+ mDataMarkerDetected = 0;
+ mFlushBatchSet = 0;
+ LOGV_IF(ENG_VERBOSE, "Flush completed");
+ } else {
+ LOGV_IF(ENG_VERBOSE, "Flush is still active");
+ }
+ } else if (mFlushBatchSet && mFlushSensorEnabledVector.isEmpty()) {
+ mFlushBatchSet = 0;
}
- mFlushBatchSet--;
- }
-
- // Double check flush status
- if (mFlushSensorEnabledVector.isEmpty()) {
- mEmptyDataMarkerDetected = 0;
- mDataMarkerDetected = 0;
- mFlushBatchSet = 0;
- LOGV_IF(ENG_VERBOSE, "Flush completed");
- } else {
- LOGV_IF(ENG_VERBOSE, "Flush is still active");
}
- } else if (mFlushBatchSet && mFlushSensorEnabledVector.isEmpty()) {
- mFlushBatchSet = 0;
}
-
return numEventReceived;
}
@@ -6065,7 +6067,7 @@ int MPLSensor::batch(int handle, int flags, int64_t period_ns, int64_t timeout)
} else {
if (calctDataRates(&tmp_reset_rate, &tmp_gyro_rate, &tmp_accel_rate, &tmp_compass_rate, &tmp_pressure_rate) < 0) {
skip_reset_data_rate = true;
- LOGW("HAL:ERR can't get output rate back to original setting");
+ LOGV_IF(ENG_VERBOSE, "HAL:ERR can't get output rate back to original setting");
}
if (tmp_reset_rate != mResetRate)
master_enable_call++;
@@ -6275,7 +6277,7 @@ int MPLSensor::flush(int handle)
/* driver returns 0 if FIFO is empty */
if (res == 0) {
- LOGI("HAL: flush - no data in FIFO");
+ LOGV_IF(ENG_VERBOSE, "HAL: flush - no data in FIFO");
}
LOGV_IF(ENG_VERBOSE, "HAl:flush - mFlushSensorEnabledVector=%d res=%d status=%d", handle, res, status);
@@ -6447,7 +6449,7 @@ int MPLSensor::readDmpPedometerEvents(sensors_event_t* data, int count,
LOGE("HAL:cannot open pedometer_steps");
} else {
if (fscanf(fp, "%lld\n", &stepCount) < 0) {
- LOGW("HAL:cannot read pedometer_steps");
+ LOGV_IF(PROCESS_VERBOSE, "HAL:cannot read pedometer_steps");
if (fclose(fp) < 0) {
LOGW("HAL:cannot close pedometer_steps");
}
diff --git a/6515/libsensors_iio/sensors_mpl.cpp b/6515/libsensors_iio/sensors_mpl.cpp
index b277e3b..3f1b67a 100755
--- a/6515/libsensors_iio/sensors_mpl.cpp
+++ b/6515/libsensors_iio/sensors_mpl.cpp
@@ -250,7 +250,21 @@ int sensors_poll_context_t::pollEvents(sensors_event_t *data, int count)
// look for new events
nb = poll(mPollFds, numSensorDrivers, polltime);
LOGI_IF(0, "poll nb=%d, count=%d, pt=%d ts=%lld", nb, count, polltime, getTimestamp());
- if (nb > 0) {
+ if (nb == 0 && count > 0) {
+ /* to see if any step counter events */
+ if(((MPLSensor*) mSensor)->hasStepCountPendingEvents() == true) {
+ nb = ((MPLSensor*) mSensor)->readDmpPedometerEvents(
+ data, count, ID_SC, 0);
+ LOGI_IF(SensorBase::HANDLER_DATA, "sensors_mpl:readStepCount() - "
+ "nb=%d, count=%d, nbEvents=%d, data->timestamp=%lld, ",
+ nb, count, nbEvents, data->timestamp);
+ if (nb > 0) {
+ count -= nb;
+ nbEvents += nb;
+ data += nb;
+ }
+ }
+ } else while (nb > 0) {
for (int i = 0; count && i < numSensorDrivers; i++) {
if (mPollFds[i].revents & (POLLIN | POLLPRI)) {
nb = 0;
@@ -293,6 +307,7 @@ int sensors_poll_context_t::pollEvents(sensors_event_t *data, int count)
nbEvents += nb;
data += nb;
}
+
if(nb == 0) {
nb = ((MPLSensor*) mSensor)->readEvents(data, count);
LOGI_IF(0, "sensors_mpl:readEvents() - "
@@ -323,20 +338,11 @@ int sensors_poll_context_t::pollEvents(sensors_event_t *data, int count)
data += nb;
}
}
- } else if(nb == 0) {
- /* to see if any step counter events */
- if(((MPLSensor*) mSensor)->hasStepCountPendingEvents() == true) {
+ if (count > 0) {
+ // We still have room for more events, try an immediate poll for more data
+ nb = poll(mPollFds, numSensorDrivers, 0);
+ } else {
nb = 0;
- nb = ((MPLSensor*) mSensor)->readDmpPedometerEvents(
- data, count, ID_SC, 0);
- LOGI_IF(SensorBase::HANDLER_DATA, "sensors_mpl:readStepCount() - "
- "nb=%d, count=%d, nbEvents=%d, data->timestamp=%lld, ",
- nb, count, nbEvents, data->timestamp);
- if (nb > 0) {
- count -= nb;
- nbEvents += nb;
- data += nb;
- }
}
}
return nbEvents;