diff options
author | Steve Kondik <steve@cyngn.com> | 2015-03-15 00:25:12 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-03-15 00:25:12 -0700 |
commit | 155dd329a811376200e702c79da3066ffa794b76 (patch) | |
tree | b680384126c75ff97892c15690028d7de5c044ce | |
parent | d05408a6357935a329e50726e47b56948df6d853 (diff) | |
parent | dda0105984d0d83ffbdc3644d7d4735a86b88867 (diff) | |
download | android_hardware_invensense-staging/cm-12.1.tar.gz android_hardware_invensense-staging/cm-12.1.tar.bz2 android_hardware_invensense-staging/cm-12.1.zip |
Merge tag 'android-5.1.0_r1' of https://android.googlesource.com/platform/hardware/invensense into cm-12.1staging/cm-12.1
Android 5.1.0 release 1
-rwxr-xr-x | 6515/libsensors_iio/Android.mk | 1 | ||||
-rwxr-xr-x | 6515/libsensors_iio/sensors_mpl.cpp | 38 |
2 files changed, 28 insertions, 11 deletions
diff --git a/6515/libsensors_iio/Android.mk b/6515/libsensors_iio/Android.mk index 94e03f1..7ae62cd 100755 --- a/6515/libsensors_iio/Android.mk +++ b/6515/libsensors_iio/Android.mk @@ -153,6 +153,7 @@ LOCAL_SHARED_LIBRARIES += libutils LOCAL_SHARED_LIBRARIES += libdl LOCAL_SHARED_LIBRARIES += liblog LOCAL_SHARED_LIBRARIES += libmllite +LOCAL_SHARED_LIBRARIES += libhardware_legacy include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) diff --git a/6515/libsensors_iio/sensors_mpl.cpp b/6515/libsensors_iio/sensors_mpl.cpp index 3e1ff52..df0a97f 100755 --- a/6515/libsensors_iio/sensors_mpl.cpp +++ b/6515/libsensors_iio/sensors_mpl.cpp @@ -16,6 +16,7 @@ #define FUNC_LOG LOGV("%s", __PRETTY_FUNCTION__) +#include <hardware_legacy/power.h> #include <hardware/sensors.h> #include <fcntl.h> #include <errno.h> @@ -61,6 +62,8 @@ static SIMPLEQ_HEAD(simplehead, handle_entry) pending_flush_items_head; struct simplehead *headp; static pthread_mutex_t flush_handles_mutex = PTHREAD_MUTEX_INITIALIZER; +static const char *smdWakelockStr = "significant motion"; + static struct sensor_t sSensorList[LOCAL_SENSORS]; static int sensors = (sizeof(sSensorList) / sizeof(sensor_t)); @@ -121,6 +124,10 @@ private: struct pollfd mPollFds[numFds]; SensorBase *mSensor; CompassSensor *mCompassSensor; + + /* Significant Motion wakelock support */ + bool mSMDWakelockHeld; + }; /******************************************************************************/ @@ -132,6 +139,9 @@ sensors_poll_context_t::sensors_poll_context_t() { mCompassSensor = new CompassSensor(); MPLSensor *mplSensor = new MPLSensor(mCompassSensor); + /* No significant motion events pending yet */ + mSMDWakelockHeld = false; + /* For Vendor-defined Accel Calibration File Load * Use the Following Constructor and Pass Your Load Cal File Function * @@ -197,6 +207,11 @@ int sensors_poll_context_t::pollEvents(sensors_event_t *data, int count) int nbEvents = 0; int nb, polltime = -1; + if (mSMDWakelockHeld) { + mSMDWakelockHeld = false; + release_wake_lock(smdWakelockStr); + } + struct handle_entry *handle_element; pthread_mutex_lock(&flush_handles_mutex); if (!SIMPLEQ_EMPTY(&pending_flush_items_head)) { @@ -243,9 +258,18 @@ int sensors_poll_context_t::pollEvents(sensors_event_t *data, int count) nb = ((MPLSensor*) mSensor)-> readDmpSignificantMotionEvents(data, count); mPollFds[i].revents = 0; - count -= nb; - nbEvents += nb; - data += nb; + if (nb) { + if (!mSMDWakelockHeld) { + /* Hold wakelock until Sensor Services reads event */ + acquire_wake_lock(PARTIAL_WAKE_LOCK, smdWakelockStr); + LOGI_IF(1, "HAL: grabbed %s wakelock", smdWakelockStr); + mSMDWakelockHeld = true; + } + + count -= nb; + nbEvents += nb; + data += nb; + } } else if (i == dmpPed) { nb = ((MPLSensor*) mSensor)->readDmpPedometerEvents( data, count, ID_P, 0); @@ -299,14 +323,6 @@ int sensors_poll_context_t::pollEvents(sensors_event_t *data, int count) data += nb; } } - - if (mPollFds[numSensorDrivers].revents & POLLIN) { - char msg; - int result = read(mPollFds[numSensorDrivers].fd, &msg, 1); - LOGE_IF(result < 0, - "error reading from wake pipe (%s)", strerror(errno)); - mPollFds[numSensorDrivers].revents = 0; - } } return nbEvents; } |