summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiogo Ferreira <defer@cyngn.com>2016-08-27 10:39:25 +0100
committerDiogo Ferreira <defer@cyngn.com>2016-08-27 10:39:25 +0100
commit7108a23ba40bbaaed5c333abcb2067f789459f80 (patch)
tree3a996db16ad89955156b6123403d46182bb6b7d6
parent85c5a9a6ce65949004581e53a74b84bfc854278f (diff)
parent1cd2b91506d2398677c4cb110266132ebcc8384c (diff)
downloadandroid_hardware_invensense-staging/cm-14.0.tar.gz
android_hardware_invensense-staging/cm-14.0.tar.bz2
android_hardware_invensense-staging/cm-14.0.zip
Merge tag 'android-7.0.0_r1' into HEADstaging/cm-14.0
Android 7.0.0 release 1
-rw-r--r--6515/libsensors_iio/MPLSensor.cpp94
-rw-r--r--6515/libsensors_iio/sensors.h11
-rwxr-xr-x6515/libsensors_iio/sensors_mpl.cpp34
-rw-r--r--65xx/libsensors_iio/Android.mk3
4 files changed, 76 insertions, 66 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.h b/6515/libsensors_iio/sensors.h
index 4ea3e4d..77aa04a 100644
--- a/6515/libsensors_iio/sensors.h
+++ b/6515/libsensors_iio/sensors.h
@@ -113,6 +113,7 @@ enum {
stringType, requiredPermission, maxDelay, flags, reserved[]}
*/
#if defined ANDROID_LOLLIPOP
+
static struct sensor_t sBaseSensorList[] =
{
{"MPL Gyroscope", "Invensense", 1, SENSORS_GYROSCOPE_HANDLE,
@@ -137,19 +138,19 @@ static struct sensor_t sBaseSensorList[] =
#endif
{"MPL Orientation", "Invensense", 1, SENSORS_ORIENTATION_HANDLE,
SENSOR_TYPE_ORIENTATION, 360.0f, 1.0f, 9.7f, 10000, 0, 0,
- SENSOR_STRING_TYPE_ORIENTATION, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, {}},
+ SENSOR_STRING_TYPE_ORIENTATION, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}},
{"MPL Rotation Vector", "Invensense", 1, SENSORS_ROTATION_VECTOR_HANDLE,
SENSOR_TYPE_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, 0, 0,
- SENSOR_STRING_TYPE_ROTATION_VECTOR, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, {}},
+ SENSOR_STRING_TYPE_ROTATION_VECTOR, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}},
{"MPL Game Rotation Vector", "Invensense", 1, SENSORS_GAME_ROTATION_VECTOR_HANDLE,
SENSOR_TYPE_GAME_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 10000, 0, 62,
SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}},
{"MPL Linear Acceleration", "Invensense", 1, SENSORS_LINEAR_ACCEL_HANDLE,
SENSOR_TYPE_LINEAR_ACCELERATION, 10240.0f, 1.0f, 0.5f, 10000, 0, 0,
- SENSOR_STRING_TYPE_LINEAR_ACCELERATION, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, {}},
+ SENSOR_STRING_TYPE_LINEAR_ACCELERATION, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}},
{"MPL Gravity", "Invensense", 1, SENSORS_GRAVITY_HANDLE,
SENSOR_TYPE_GRAVITY, 10240.0f, 1.0f, 0.5f, 10000, 0, 0,
- SENSOR_STRING_TYPE_GRAVITY, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, {}},
+ SENSOR_STRING_TYPE_GRAVITY, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}},
{"MPL Significant Motion", "Invensense", 1, SENSORS_SIGNIFICANT_MOTION_HANDLE,
SENSOR_TYPE_SIGNIFICANT_MOTION, 100.0f, 1.0f, 1.1f, 0, 0, 0,
SENSOR_STRING_TYPE_SIGNIFICANT_MOTION, "", 0,
@@ -163,7 +164,7 @@ static struct sensor_t sBaseSensorList[] =
{"MPL Geomagnetic Rotation Vector", "Invensense", 1,
SENSORS_GEOMAGNETIC_ROTATION_VECTOR_HANDLE,
SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 5000, 0, 0,
- SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, {}},
+ SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR, "", 200000, SENSOR_FLAG_CONTINUOUS_MODE, {}},
#ifdef ENABLE_DMP_SCREEN_AUTO_ROTATION
{"MPL Screen Orientation", "Invensense ", 1, SENSORS_SCREEN_ORIENTATION_HANDLE,
SENSOR_TYPE_SCREEN_ORIENTATION, 100.0f, 1.0f, 1.1f, 0, 0, 0,
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;
diff --git a/65xx/libsensors_iio/Android.mk b/65xx/libsensors_iio/Android.mk
index ee4b021..7c21a6a 100644
--- a/65xx/libsensors_iio/Android.mk
+++ b/65xx/libsensors_iio/Android.mk
@@ -17,7 +17,6 @@ LOCAL_PATH := $(call my-dir)
# Too many benign warnings to be fixed later.
my_ignored_clang_warnings := \
- -Wno-unused-parameter \
-Wno-unused-private-field \
-Wno-gnu-designator
@@ -30,6 +29,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_OWNER := invensense
LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall
+LOCAL_CFLAGS += -Wno-unused-parameter
# ANDROID version check
MAJOR_VERSION :=$(shell echo $(PLATFORM_VERSION) | cut -f1 -d.)
@@ -122,6 +122,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include/linux
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall
+LOCAL_CFLAGS += -Wno-unused-parameter
ifeq ($(VERSION_JB),true)
LOCAL_CFLAGS += -DANDROID_JELLYBEAN