diff options
25 files changed, 152 insertions, 302 deletions
diff --git a/60xx/libsensors/Android.mk b/60xx/libsensors/Android.mk index a324dae..326e096 100644 --- a/60xx/libsensors/Android.mk +++ b/60xx/libsensors/Android.mk @@ -25,7 +25,7 @@ LOCAL_MODULE := libinvensense_hal LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" +LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall LOCAL_CFLAGS += -DCONFIG_MPU_SENSORS_MPU3050=1 LOCAL_SRC_FILES := SensorBase.cpp MPLSensor.cpp @@ -41,7 +41,6 @@ LOCAL_C_INCLUDES += hardware/invensense/60xx/mlsdk/external/akmd LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libdl libmllite libmlplatform LOCAL_CPPFLAGS+=-DLINUX=1 LOCAL_LDFLAGS:=-rdynamic -LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) diff --git a/60xx/libsensors/MPLSensor.cpp b/60xx/libsensors/MPLSensor.cpp index fa5385b..4676d0e 100644 --- a/60xx/libsensors/MPLSensor.cpp +++ b/60xx/libsensors/MPLSensor.cpp @@ -152,8 +152,7 @@ MPLSensor::MPLSensor() : mEnabled(0), mPendingMask(0) { FUNC_LOG; - inv_error_t rv; - int mpu_int_fd, i; + int mpu_int_fd; char *port = NULL; ALOGV_IF(EXTRA_VERBOSE, "MPLSensor constructor: numSensors = %d", numSensors); @@ -167,7 +166,7 @@ MPLSensor::MPLSensor() : /* sensor list will be changed based on this variable */ mNineAxisEnabled = false; - for (i = 0; i < ARRAY_SIZE(mPollFds); i++) { + for (size_t i = 0; i < ARRAY_SIZE(mPollFds); i++) { mPollFds[i].fd = -1; mPollFds[i].events = 0; } @@ -179,7 +178,6 @@ MPLSensor::MPLSensor() : ALOGE("could not open the mpu irq device node"); } else { fcntl(mpu_int_fd, F_SETFL, O_NONBLOCK); - //ioctl(mpu_int_fd, MPUIRQ_SET_TIMEOUT, 0); mIrqFds.add(MPUIRQ_FD, mpu_int_fd); mPollFds[MPUIRQ_FD].fd = mpu_int_fd; mPollFds[MPUIRQ_FD].events = POLLIN; @@ -190,7 +188,6 @@ MPLSensor::MPLSensor() : ALOGE("could not open the accel irq device node"); } else { fcntl(accel_fd, F_SETFL, O_NONBLOCK); - //ioctl(accel_fd, SLAVEIRQ_SET_TIMEOUT, 0); mIrqFds.add(ACCELIRQ_FD, accel_fd); mPollFds[ACCELIRQ_FD].fd = accel_fd; mPollFds[ACCELIRQ_FD].events = POLLIN; @@ -201,7 +198,6 @@ MPLSensor::MPLSensor() : ALOGE("could not open the timer irq device node"); } else { fcntl(timer_fd, F_SETFL, O_NONBLOCK); - //ioctl(timer_fd, TIMERIRQ_SET_TIMEOUT, 0); mIrqFds.add(TIMERIRQ_FD, timer_fd); mPollFds[TIMERIRQ_FD].fd = timer_fd; mPollFds[TIMERIRQ_FD].events = POLLIN; @@ -212,7 +208,6 @@ MPLSensor::MPLSensor() : if ((accel_fd == -1) && (timer_fd != -1)) { //no accel irq and timer available mUseTimerIrqAccel = true; - //ALOGD("MPLSensor falling back to timerirq for accel data"); } memset(mPendingEvents, 0, sizeof(mPendingEvents)); @@ -269,10 +264,6 @@ MPLSensor::MPLSensor() : //setup the FIFO contents setupFIFO(); - //we start the motion processing only when a sensor is enabled... - //rv = inv_dmp_start(); - //ALOGE_IF(rv != INV_SUCCESS, "Fatal error: could not start the DMP correctly. (code = %d)\n", rv); - //dmp_started = true; pthread_mutex_unlock(&mMplMutex); @@ -308,13 +299,11 @@ void MPLSensor::clearIrqData(bool* irq_set) for (i = 0; i < ARRAY_SIZE(mPollFds); i++) { int cur_fd = mPollFds[i].fd; - int j = 0; if (mPollFds[i].revents & POLLIN) { nread = read(cur_fd, &irqdata, sizeof(irqdata)); if (nread > 0) { irq_set[i] = true; irq_timestamp = irqdata.irqtime; - //ALOGV_IF(EXTRA_VERBOSE, "irq: %d %d (%d)", i, irqdata.interruptcount, j++); } } mPollFds[i].revents = 0; @@ -329,8 +318,6 @@ void MPLSensor::setPowerStates(int enabled_sensors) FUNC_LOG; bool irq_set[5] = { false, false, false, false, false }; - //ALOGV(" setPowerStates: %d dmp_started: %d", enabled_sensors, mDmpStarted); - do { if (LA_ENABLED || GR_ENABLED || RV_ENABLED || O_ENABLED) { @@ -366,7 +353,7 @@ void MPLSensor::setPowerStates(int enabled_sensors) //record the new sensor state inv_error_t rv; - long sen_mask = mLocalSensorMask & mMasterSensorMask; + unsigned long sen_mask = mLocalSensorMask & mMasterSensorMask; bool changing_sensors = ((inv_get_dl_config()->requested_sensors != sen_mask) && (sen_mask != 0)); @@ -383,7 +370,6 @@ void MPLSensor::setPowerStates(int enabled_sensors) } if (sen_mask != inv_get_dl_config()->requested_sensors) { - //ALOGV("setPowerStates: %lx", sen_mask); rv = inv_set_mpu_sensors(sen_mask); ALOGE_IF(rv != INV_SUCCESS, "error: unable to set MPL sensor power states (sens=%ld retcode = %d)", @@ -412,7 +398,6 @@ void MPLSensor::setPowerStates(int enabled_sensors) mHaveGoodMpuCal = false; mHaveGoodCompassCal = false; } - //ALOGV("Starting DMP"); rv = inv_dmp_start(); ALOGE_IF(rv != INV_SUCCESS, "unable to start dmp"); mDmpStarted = true; @@ -421,7 +406,6 @@ void MPLSensor::setPowerStates(int enabled_sensors) //check if we should stop the DMP if (mDmpStarted && (sen_mask == 0)) { - //ALOGV("Stopping DMP"); rv = inv_dmp_stop(); ALOGE_IF(rv != INV_SUCCESS, "error: unable to stop DMP (retcode = %d)", rv); @@ -445,7 +429,6 @@ void MPLSensor::initMPL() FUNC_LOG; inv_error_t result; unsigned short bias_update_mask = 0xFFFF; - struct mldl_cfg *mldl_cfg; if (inv_dmp_open() != INV_SUCCESS) { ALOGE("Fatal Error : could not open DMP correctly.\n"); @@ -481,8 +464,6 @@ void MPLSensor::initMPL() ALOGE("libinvensense_mpl.so not found, 9x sensor fusion disabled (%s)",error); } - mldl_cfg = inv_get_dl_config(); - if (inv_set_bias_update(bias_update_mask) != INV_SUCCESS) { ALOGE("Error : Bias update function could not be set.\n"); } @@ -584,7 +565,6 @@ void MPLSensor::cbProcData() { mNewData = 1; mSampleCount++; - //ALOGV_IF(EXTRA_VERBOSE, "new data (%d)", sampleCount); } //these handlers transform mpl data into one of the Android sensor types @@ -613,7 +593,6 @@ void MPLSensor::accelHandler(sensors_event_t* s, uint32_t* pending_mask, s->acceleration.v[0] = s->acceleration.v[0] * 9.81; s->acceleration.v[1] = s->acceleration.v[1] * 9.81; s->acceleration.v[2] = s->acceleration.v[2] * 9.81; - //ALOGV_IF(EXTRA_VERBOSE, "accel data: %f %f %f", s->acceleration.v[0], s->acceleration.v[1], s->acceleration.v[2]); if (res == INV_SUCCESS) *pending_mask |= (1 << index); } @@ -636,10 +615,7 @@ void MPLSensor::compassHandler(sensors_event_t* s, uint32_t* pending_mask, int index) { VFUNC_LOG; - inv_error_t res, res2; - float bias_error[3]; - float total_be; - static int bias_error_settled = 0; + inv_error_t res; res = inv_get_float_array(INV_MAGNETOMETER, s->magnetic.v); @@ -661,7 +637,6 @@ void MPLSensor::rvHandler(sensors_event_t* s, uint32_t* pending_mask, VFUNC_LOG; float quat[4]; float norm = 0; - float ang = 0; inv_error_t r; r = inv_get_float_array(INV_QUATERNION, quat); @@ -771,13 +746,10 @@ void MPLSensor::orienHandler(sensors_event_t* s, uint32_t* pending_mask, { VFUNC_LOG; inv_error_t res; - float euler[3]; - float heading[1]; float rot_mat[9]; res = inv_get_float_array(INV_ROTATION_MATRIX, rot_mat); - //ComputeAndOrientation(heading[0], euler, s->orientation.v); calcOrientationSensor(rot_mat, s->orientation.v); s->orientation.status = estimateCompassAccuracy(); @@ -792,7 +764,6 @@ void MPLSensor::orienHandler(sensors_event_t* s, uint32_t* pending_mask, int MPLSensor::enable(int32_t handle, int en) { FUNC_LOG; - //ALOGV("handle : %d en: %d", handle, en); int what = -1; @@ -828,12 +799,9 @@ int MPLSensor::enable(int32_t handle, int en) int newState = en ? 1 : 0; int err = 0; - //ALOGV_IF((uint32_t(newState) << what) != (mEnabled & (1 << what)), - // "sensor state change what=%d", what); pthread_mutex_lock(&mMplMutex); if ((uint32_t(newState) << what) != (mEnabled & (1 << what))) { - uint32_t sensor_type; short flags = newState; mEnabled &= ~(1 << what); mEnabled |= (uint32_t(flags) << what); @@ -921,14 +889,10 @@ int MPLSensor::update_delay() rate = 1; if (rate != mCurFifoRate) { - //ALOGD("set fifo rate: %d %llu", rate, wanted); inv_error_t res; // = inv_dmp_stop(); res = inv_set_fifo_rate(rate); ALOGE_IF(res != INV_SUCCESS, "error setting FIFO rate"); - //res = inv_dmp_start(); - //ALOGE_IF(res != INV_SUCCESS, "error re-starting DMP"); - mCurFifoRate = rate; rv = (res == INV_SUCCESS); } @@ -964,14 +928,12 @@ int64_t MPLSensor::now_ns(void) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - //ALOGV("Time %lld", (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec); return (int64_t) ts.tv_sec * 1000000000 + ts.tv_nsec; } int MPLSensor::readEvents(sensors_event_t* data, int count) { //VFUNC_LOG; - int i; bool irq_set[5] = { false, false, false, false, false }; inv_error_t rv; if (count < 1) @@ -982,7 +944,6 @@ int MPLSensor::readEvents(sensors_event_t* data, int count) pthread_mutex_lock(&mMplMutex); if (mDmpStarted) { - //ALOGV_IF(EXTRA_VERBOSE, "Update Data"); rv = inv_update_data(); ALOGE_IF(rv != INV_SUCCESS, "inv_update_data error (code %d)", (int) rv); } @@ -1029,26 +990,22 @@ int MPLSensor::readEvents(sensors_event_t* data, int count) int MPLSensor::getFd() const { - //ALOGV("MPLSensor::getFd returning %d", data_fd); return data_fd; } int MPLSensor::getAccelFd() const { - //ALOGV("MPLSensor::getAccelFd returning %d", accel_fd); return accel_fd; } int MPLSensor::getTimerFd() const { - //ALOGV("MPLSensor::getTimerFd returning %d", timer_fd); return timer_fd; } int MPLSensor::getPowerFd() const { int hdl = (uintptr_t) inv_get_serial_handle(); - //ALOGV("MPLSensor::getPowerFd returning %d", hdl); return hdl; } @@ -1111,7 +1068,7 @@ void MPLSensor::wakeEvent() * parameter len gives the length of the buffer pointed to by list */ -int MPLSensor::populateSensorList(struct sensor_t *list, int len) +int MPLSensor::populateSensorList(struct sensor_t *list, size_t len) { int numsensors; @@ -1127,18 +1084,16 @@ int MPLSensor::populateSensorList(struct sensor_t *list, int len) /* fill in accel values */ unsigned short accelId = inv_get_accel_id(); - if(accelId == 0) - { - ALOGE("Can not get accel id"); - } + if(accelId == 0) { + ALOGE("Can not get accel id"); + } fillAccel(accelId, list); /* fill in compass values */ unsigned short compassId = inv_get_compass_id(); - if(compassId == 0) - { - ALOGE("Can not get compass id"); - } + if(compassId == 0) { + ALOGE("Can not get compass id"); + } fillCompass(compassId, list); /* fill in gyro values */ diff --git a/60xx/libsensors/MPLSensor.h b/60xx/libsensors/MPLSensor.h index 5b5d121..f580732 100644 --- a/60xx/libsensors/MPLSensor.h +++ b/60xx/libsensors/MPLSensor.h @@ -66,7 +66,7 @@ public: virtual void handlePowerEvent(); virtual void sleepEvent(); virtual void wakeEvent(); - int populateSensorList(struct sensor_t *list, int len); + int populateSensorList(struct sensor_t *list, size_t len); void cbOnMotion(uint16_t); void cbProcData(); diff --git a/60xx/libsensors/SensorBase.cpp b/60xx/libsensors/SensorBase.cpp index 79b1ee2..9cc1ee8 100644 --- a/60xx/libsensors/SensorBase.cpp +++ b/60xx/libsensors/SensorBase.cpp @@ -18,6 +18,7 @@ #include <errno.h> #include <math.h> #include <poll.h> +#include <string.h> #include <unistd.h> #include <dirent.h> #include <sys/select.h> diff --git a/60xx/libsensors_iio/Android.mk b/60xx/libsensors_iio/Android.mk index 3b95c86..fd8e472 100644 --- a/60xx/libsensors_iio/Android.mk +++ b/60xx/libsensors_iio/Android.mk @@ -15,8 +15,6 @@ LOCAL_PATH := $(call my-dir) -ifneq ($(TARGET_SIMULATOR),true) - # InvenSense fragment of the HAL include $(CLEAR_VARS) @@ -25,7 +23,7 @@ LOCAL_MODULE := libinvensense_hal LOCAL_MODULE_TAGS := optional LOCAL_MODULE_OWNER := invensense -LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" +LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall # Comment out for ICS. Affects Android LOG macros. LOCAL_CFLAGS += -DANDROID_JELLYBEAN @@ -75,7 +73,6 @@ LOCAL_CPPFLAGS += -DLINUX=1 ifeq ($(BOARD_INV_LIBMLLITE_FROM_SOURCE),true) LOCAL_CPPFLAGS += -DLIBMLLITE_FROM_SOURCE endif -LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) @@ -119,5 +116,3 @@ LOCAL_MODULE_PATH := $(TARGET_OUT)/lib LOCAL_SHARED_LIBRARIES := liblog include $(BUILD_SHARED_LIBRARY) endif - -endif # !TARGET_SIMULATOR diff --git a/60xx/libsensors_iio/CompassSensor.IIO.9150.cpp b/60xx/libsensors_iio/CompassSensor.IIO.9150.cpp index 0c8222b..be8c912 100644 --- a/60xx/libsensors_iio/CompassSensor.IIO.9150.cpp +++ b/60xx/libsensors_iio/CompassSensor.IIO.9150.cpp @@ -36,19 +36,19 @@ #define COMPASS_MAX_SYSFS_ATTRB sizeof(compassSysFs) / sizeof(char*) #if defined COMPASS_YAS53x -# warning "Invensense compass cal with YAS53x IIO on secondary bus" +# pragma message "Invensense compass cal with YAS53x IIO on secondary bus" # define USE_MPL_COMPASS_HAL (1) # define COMPASS_NAME "INV_YAS530" #elif defined COMPASS_AK8975 -# warning "Invensense compass cal with AK8975 on primary bus" +# pragma message "Invensense compass cal with AK8975 on primary bus" # define USE_MPL_COMPASS_HAL (1) # define COMPASS_NAME "INV_AK8975" #elif defined INVENSENSE_COMPASS_CAL -# warning "Invensense compass cal with compass IIO on secondary bus" +# pragma message "Invensense compass cal with compass IIO on secondary bus" # define USE_MPL_COMPASS_HAL (1) # define COMPASS_NAME "INV_COMPASS" #else -# warning "third party compass cal HAL" +# pragma message "third party compass cal HAL" # define USE_MPL_COMPASS_HAL (0) // TODO: change to vendor's name # define COMPASS_NAME "AKM8975" @@ -239,7 +239,7 @@ int CompassSensor::readSample(long *data, int64_t *timestamp) { VHANDLER_LOG; - int numEventReceived = 0, done = 0; + int done = 0; ssize_t n = mCompassInputReader.fill(compass_fd); if (n < 0) { @@ -288,7 +288,6 @@ void CompassSensor::fillList(struct sensor_t *list) list->maxRange = COMPASS_MPU9150_RANGE; /* since target platform would use AK8963 instead of AK8975, need to adopt AK8963's resolution here */ - // list->resolution = COMPASS_MPU9150_RESOLUTION; list->resolution = COMPASS_AKM8963_RESOLUTION; list->power = COMPASS_MPU9150_POWER; list->minDelay = COMPASS_MPU9150_MINDELAY; @@ -332,10 +331,9 @@ int CompassSensor::inv_init_sysfs_attributes(void) VFUNC_LOG; unsigned char i = 0; - char sysfs_path[MAX_SYSFS_NAME_LEN], iio_trigger_path[MAX_SYSFS_NAME_LEN], tbuf[2]; + char sysfs_path[MAX_SYSFS_NAME_LEN], iio_trigger_path[MAX_SYSFS_NAME_LEN]; char *sptr; char **dptr; - int num; pathP = (char*)malloc( sizeof(char[COMPASS_MAX_SYSFS_ATTRB][MAX_SYSFS_NAME_LEN])); @@ -359,6 +357,8 @@ int CompassSensor::inv_init_sysfs_attributes(void) inv_get_iio_trigger_path(iio_trigger_path); #if defined COMPASS_AK8975 + char tbuf[2]; + int num; inv_get_input_number(COMPASS_NAME, &num); tbuf[0] = num + 0x30; tbuf[1] = 0; diff --git a/60xx/libsensors_iio/InputEventReader.cpp b/60xx/libsensors_iio/InputEventReader.cpp index ca0a61a..fc48892 100644 --- a/60xx/libsensors_iio/InputEventReader.cpp +++ b/60xx/libsensors_iio/InputEventReader.cpp @@ -18,6 +18,7 @@ #include <stdint.h>
#include <errno.h>
+#include <string.h>
#include <unistd.h>
#include <poll.h>
diff --git a/60xx/libsensors_iio/MPLSensor.cpp b/60xx/libsensors_iio/MPLSensor.cpp index 9b9534d..031ae6e 100644 --- a/60xx/libsensors_iio/MPLSensor.cpp +++ b/60xx/libsensors_iio/MPLSensor.cpp @@ -177,12 +177,8 @@ MPLSensor::MPLSensor(CompassSensor *compass, int (*m_pt2AccelCalLoadFunc)(long * VFUNC_LOG; inv_error_t rv; - int i, fd; - char *port = NULL; + int fd; char *ver_str; - unsigned long mSensorMask; - int res; - FILE *fptr; mCompassSensor = compass; @@ -592,8 +588,6 @@ void MPLSensor::loadDMP() LOGV_IF(PROCESS_VERBOSE, "HAL:DMP loaded"); } fclose(fptr); - - // onDMP(1); //Can't enable here. See note onDMP() } void MPLSensor::inv_get_sensors_orientation() @@ -746,7 +740,6 @@ int MPLSensor::setAccelInitialState() mPendingEvents[Accelerometer].data[1] = value * CONVERT_A_Y; value = absinfo_z.value; mPendingEvents[Accelerometer].data[2] = value * CONVERT_A_Z; - //mHasPendingEvent = true; } return 0; } @@ -757,7 +750,7 @@ int MPLSensor::onPower(int en) int res; - int count, curr_power_state; + int curr_power_state; LOGV_IF(SYSFS_VERBOSE, "HAL:sysfs:echo %d > %s (%lld)", en, mpu.power_state, getTimestamp()); @@ -1361,11 +1354,7 @@ int MPLSensor::enable(int32_t handle, int en) LOGV_IF(PROCESS_VERBOSE, "HAL:%s sensor state change what=%d", sname.string(), what); - // pthread_mutex_lock(&mMplMutex); - // pthread_mutex_lock(&mHALMutex); - if ((uint32_t(newState) << what) != (mEnabled & (1 << what))) { - uint32_t sensor_type; short flags = newState; uint32_t lastEnabled = mEnabled, changed = 0; @@ -1412,9 +1401,6 @@ int MPLSensor::enable(int32_t handle, int en) enableSensors(sen_mask, flags, changed); } - // pthread_mutex_unlock(&mMplMutex); - // pthread_mutex_unlock(&mHALMutex); - #ifdef INV_PLAYBACK_DBG /* apparently the logging needs to be go through this sequence to properly flush the log file */ @@ -1548,9 +1534,7 @@ int MPLSensor::setDelay(int32_t handle, int64_t ns) break; } - // pthread_mutex_lock(&mHALMutex); int res = update_delay(); - // pthread_mutex_unlock(&mHALMutex); return res; } @@ -1772,7 +1756,7 @@ int MPLSensor::readAccelEvents(sensors_event_t* /*data*/, int count) int numEventReceived = 0; input_event const* event; - int nb, done = 0; + int done = 0; while (!done && count && mAccelInputReader.readEvent(&event)) { int type = event->type; @@ -1862,7 +1846,7 @@ int MPLSensor::readEvents(sensors_event_t* /*data*/, int /*count*/) { int lp_quaternion_on = 0, nbyte; - int i, nb, mask = 0, numEventReceived = 0, + int i, mask = 0, numEventReceived = 0, sensors = ((mLocalSensorMask & INV_THREE_AXIS_GYRO)? 1 : 0) + ((mLocalSensorMask & INV_THREE_AXIS_ACCEL)? 1 : 0) + (((mLocalSensorMask & INV_THREE_AXIS_COMPASS) && mCompassSensor->isIntegrated())? 1 : 0); @@ -1877,12 +1861,8 @@ int MPLSensor::readEvents(sensors_event_t* /*data*/, int /*count*/) { } } - // pthread_mutex_lock(&mMplMutex); - // pthread_mutex_lock(&mHALMutex); - ssize_t rsize = read(iio_fd, rdata, nbyte); if (sensors == 0) { - // read(iio_fd, rdata, nbyte); rsize = read(iio_fd, rdata, sizeof(mIIOBuffer)); } @@ -2025,9 +2005,6 @@ int MPLSensor::readEvents(sensors_event_t* /*data*/, int /*count*/) { mCachedQuaternionData[2], mCachedQuaternionData[3], mSensorTimestamp); } - // pthread_mutex_unlock(&mMplMutex); - // pthread_mutex_unlock(&mHALMutex); - return numEventReceived; } @@ -2041,10 +2018,6 @@ int MPLSensor::readCompassEvents(sensors_event_t* /*data*/, int count) int numEventReceived = 0; int done = 0; - int nb; - - // pthread_mutex_lock(&mMplMutex); - // pthread_mutex_lock(&mHALMutex); done = mCompassSensor->readSample(mCachedCompassData, &mCompassTimestamp); #ifdef COMPASS_YAS53x @@ -2068,9 +2041,6 @@ int MPLSensor::readCompassEvents(sensors_event_t* /*data*/, int count) } } - // pthread_mutex_unlock(&mMplMutex); - // pthread_mutex_unlock(&mHALMutex); - return numEventReceived; } @@ -2118,7 +2088,7 @@ int MPLSensor::getCompassFd() const } int MPLSensor::turnOffAccelFifo() { - int i, res, tempFd; + int i, res; char *accel_fifo_enable[3] = {mpu.accel_x_fifo_enable, mpu.accel_y_fifo_enable, mpu.accel_z_fifo_enable}; @@ -2495,9 +2465,6 @@ int MPLSensor::populateSensorList(struct sensor_t *list, int len) /* first add gyro, accel and compass to the list */ /* fill in gyro/accel values */ - if(chip_ID == NULL) { - LOGE("HAL:Can not get gyro/accel id"); - } fillGyro(chip_ID, list); fillAccel(chip_ID, list); @@ -2679,7 +2646,6 @@ int MPLSensor::inv_init_sysfs_attributes(void) char sysfs_path[MAX_SYSFS_NAME_LEN], iio_trigger_path[MAX_SYSFS_NAME_LEN]; char *sptr; char **dptr; - int num; sysfs_names_ptr = (char*)calloc(1, sizeof(char[MAX_SYSFS_ATTRB][MAX_SYSFS_NAME_LEN])); diff --git a/60xx/libsensors_iio/MPLSensor.h b/60xx/libsensors_iio/MPLSensor.h index 4162324..4698f33 100644 --- a/60xx/libsensors_iio/MPLSensor.h +++ b/60xx/libsensors_iio/MPLSensor.h @@ -31,17 +31,17 @@ #ifdef INVENSENSE_COMPASS_CAL
#ifdef COMPASS_YAS53x
-#warning "unified HAL for YAS53x"
+#pragma message "unified HAL for YAS53x"
#include "CompassSensor.IIO.primary.h"
#elif COMPASS_AMI306
-#warning "unified HAL for AMI306"
+#pragma message "unified HAL for AMI306"
#include "CompassSensor.IIO.primary.h"
#else
-#warning "unified HAL for MPU9150"
+#pragma message "unified HAL for MPU9150"
#include "CompassSensor.IIO.9150.h"
#endif
#else
-#warning "unified HAL for AKM"
+#pragma message "unified HAL for AKM"
#include "CompassSensor.AKM.h"
#endif
diff --git a/60xx/libsensors_iio/SensorBase.cpp b/60xx/libsensors_iio/SensorBase.cpp index 14e8861..587aaf5 100644 --- a/60xx/libsensors_iio/SensorBase.cpp +++ b/60xx/libsensors_iio/SensorBase.cpp @@ -19,6 +19,7 @@ #include <math.h>
#include <poll.h>
#include <dirent.h>
+#include <string.h>
#include <sys/select.h>
#include <cutils/log.h>
#include <linux/input.h>
diff --git a/60xx/libsensors_iio/software/core/mpl/gyro_tc.h b/60xx/libsensors_iio/software/core/mpl/gyro_tc.h index 8f1d50e..69918d5 100644 --- a/60xx/libsensors_iio/software/core/mpl/gyro_tc.h +++ b/60xx/libsensors_iio/software/core/mpl/gyro_tc.h @@ -11,7 +11,7 @@ * *****************************************************************************/ -#ifndef _GYRO_TC_H +#ifndef _GYRO_TC_H_ #define _GYRO_TC_H_ #include "mltypes.h" diff --git a/60xx/mlsdk/Android.mk b/60xx/mlsdk/Android.mk index 41b1457..929a776 100644 --- a/60xx/mlsdk/Android.mk +++ b/60xx/mlsdk/Android.mk @@ -25,7 +25,6 @@ ML_SOURCES := \ LOCAL_SRC_FILES := $(ML_SOURCES) LOCAL_SHARED_LIBRARIES := liblog libm libutils libcutils -LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -86,7 +85,6 @@ endif LOCAL_SRC_FILES := $(ML_SOURCES) LOCAL_SHARED_LIBRARIES := libm libutils libcutils liblog libmlplatform -LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) #This makes an .so from our .a @@ -97,7 +95,6 @@ include $(BUILD_SHARED_LIBRARY) #LOCAL_SHARED_LIBRARIES := libm libutils libcutils liblog libmlplatform libmllite #LOCAL_WHOLE_STATIC_LIBRARIES := libmpl #LOCAL_PREBUILT_LIBS := mlsdk/mldmp/mpl/android/libmpl.a -#LOCAL_PRELINK_MODULE := false #include $(BUILD_SHARED_LIBRARY) #include $(BUILD_MULTI_PREBUILT) diff --git a/6515/libsensors_iio/Android.mk b/6515/libsensors_iio/Android.mk index 7fc9636..f33c7ae 100755 --- a/6515/libsensors_iio/Android.mk +++ b/6515/libsensors_iio/Android.mk @@ -15,8 +15,6 @@ LOCAL_PATH := $(call my-dir) -#ifneq ($(TARGET_SIMULATOR),true) - # InvenSense fragment of the HAL include $(CLEAR_VARS) @@ -24,7 +22,7 @@ LOCAL_MODULE := libinvensense_hal LOCAL_MODULE_TAGS := optional LOCAL_MODULE_OWNER := invensense -LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" +LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall # ANDROID version check $(info YD>>PLATFORM_VERSION=$(PLATFORM_VERSION)) @@ -88,17 +86,13 @@ LOCAL_SHARED_LIBRARIES += libmllite LOCAL_SHARED_LIBRARIES += libmplmpu LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mpl LOCAL_CPPFLAGS += -DLINUX=1 -LOCAL_PRELINK_MODULE := false LOCAL_SHARED_LIBRARIES += libmllite LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite LOCAL_CPPFLAGS += -DLINUX=1 -LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) -#endif # !TARGET_SIMULATOR - # Build a temporary HAL that links the InvenSense .so include $(CLEAR_VARS) ifeq ($(filter eng, userdebug, user, $(TARGET_BUILD_VARIANT)),) @@ -138,9 +132,8 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mpl LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include/linux -LOCAL_PRELINK_MODULE := false LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" +LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall ifeq ($(VERSION_KK),true) LOCAL_CFLAGS += -DANDROID_KITKAT diff --git a/6515/libsensors_iio/CompassSensor.IIO.9150.cpp b/6515/libsensors_iio/CompassSensor.IIO.9150.cpp index a1b9214..a8238f4 100755 --- a/6515/libsensors_iio/CompassSensor.IIO.9150.cpp +++ b/6515/libsensors_iio/CompassSensor.IIO.9150.cpp @@ -378,28 +378,23 @@ int CompassSensor::inv_init_sysfs_attributes(void) { VFUNC_LOG; - unsigned char i = 0; char sysfs_path[MAX_SYSFS_NAME_LEN]; - char iio_trigger_path[MAX_SYSFS_NAME_LEN], tbuf[2]; - char *sptr; - char **dptr; - int num; + char iio_trigger_path[MAX_SYSFS_NAME_LEN]; - pathP = (char*)malloc( - sizeof(char[COMPASS_MAX_SYSFS_ATTRB][MAX_SYSFS_NAME_LEN])); - sptr = pathP; - dptr = (char**)&compassSysFs; - if (sptr == NULL) + pathP = (char*)calloc(COMPASS_MAX_SYSFS_ATTRB, + sizeof(char[MAX_SYSFS_NAME_LEN])); + if (pathP == NULL) return -1; memset(sysfs_path, 0, sizeof(sysfs_path)); memset(iio_trigger_path, 0, sizeof(iio_trigger_path)); - do { - *dptr++ = sptr; - memset(sptr, 0, sizeof(sptr)); - sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); - } while (++i < COMPASS_MAX_SYSFS_ATTRB); + char *sptr = pathP; + char **dptr = reinterpret_cast<char **>(&compassSysFs); + for (size_t i = 0; i < COMPASS_MAX_SYSFS_ATTRB; i++) { + *dptr++ = sptr; + sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); + } // get proper (in absolute/relative) IIO path & build MPU's sysfs paths // inv_get_sysfs_abs_path(sysfs_path); @@ -407,6 +402,9 @@ int CompassSensor::inv_init_sysfs_attributes(void) inv_get_iio_trigger_path(iio_trigger_path); #if defined COMPASS_AK8975 + char tbuf[2]; + int num; + inv_get_input_number(dev_name, &num); tbuf[0] = num + 0x30; tbuf[1] = 0; @@ -425,12 +423,5 @@ int CompassSensor::inv_init_sysfs_attributes(void) sprintf(compassSysFs.compass_orient, "%s%s", sysfs_path, "/compass_matrix"); #endif -#if 0 - // test print sysfs paths - dptr = (char**)&compassSysFs; - for (i = 0; i < COMPASS_MAX_SYSFS_ATTRB; i++) { - LOGE("HAL:sysfs path: %s", *dptr++); - } -#endif return 0; } diff --git a/6515/libsensors_iio/MPLSensor.cpp b/6515/libsensors_iio/MPLSensor.cpp index 1cfab7a..ad6d4e9 100644 --- a/6515/libsensors_iio/MPLSensor.cpp +++ b/6515/libsensors_iio/MPLSensor.cpp @@ -3866,7 +3866,7 @@ void MPLSensor::buildMpuEvent(void) /* append with just read data */ if (mLeftOverBufferSize > 0) { LOGV_IF(0, "append old buffer size=%d", mLeftOverBufferSize); - memset(rdata, 0, sizeof(rdata)); + memset(rdata, 0, sizeof(mIIOBuffer)); memcpy(rdata, mLeftOverBuffer, mLeftOverBufferSize); LOGV_IF(0, "HAL:input retrieve old buffer data=:%d, %d, %d, %d,%d, %d, %d, %d,%d, %d, " @@ -5204,30 +5204,24 @@ int MPLSensor::inv_init_sysfs_attributes(void) { VFUNC_LOG; - unsigned char i = 0; char sysfs_path[MAX_SYSFS_NAME_LEN]; - char tbuf[2]; - char *sptr; - char **dptr; - int num; memset(sysfs_path, 0, sizeof(sysfs_path)); - sysfs_names_ptr = - (char*)malloc(sizeof(char[MAX_SYSFS_ATTRB][MAX_SYSFS_NAME_LEN])); - sptr = sysfs_names_ptr; - if (sptr != NULL) { - dptr = (char**)&mpu; - do { - *dptr++ = sptr; - memset(sptr, 0, sizeof(sptr)); - sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); - } while (++i < MAX_SYSFS_ATTRB); - } else { + sysfs_names_ptr = (char*)calloc(MAX_SYSFS_ATTRB, + sizeof(char[MAX_SYSFS_NAME_LEN])); + if (sysfs_names_ptr == NULL) { LOGE("HAL:couldn't alloc mem for sysfs paths"); return -1; } + char *sptr = sysfs_names_ptr; + char **dptr = reinterpret_cast<char **>(&mpu); + for (size_t i = 0; i < MAX_SYSFS_ATTRB; i++) { + *dptr++ = sptr; + sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); + } + // get proper (in absolute) IIO path & build MPU's sysfs paths inv_get_sysfs_path(sysfs_path); diff --git a/6515/libsensors_iio/PressureSensor.IIO.secondary.cpp b/6515/libsensors_iio/PressureSensor.IIO.secondary.cpp index c213cd4..6f32cc7 100755 --- a/6515/libsensors_iio/PressureSensor.IIO.secondary.cpp +++ b/6515/libsensors_iio/PressureSensor.IIO.secondary.cpp @@ -181,19 +181,19 @@ void PressureSensor::fillList(struct sensor_t *list) int PressureSensor::inv_init_sysfs_attributes(void) { VFUNC_LOG; - - pathP = (char*)malloc(sizeof(char[PRESSURE_MAX_SYSFS_ATTRB][MAX_SYSFS_NAME_LEN])); - char *sptr = pathP; - char **dptr = (char**)&pressureSysFs; - if (sptr == NULL) + + pathP = (char*)calloc(PRESSURE_MAX_SYSFS_ATTRB, + sizeof(char[MAX_SYSFS_NAME_LEN])); + if (pathP == NULL) return -1; - unsigned char i = 0; - do { - *dptr++ = sptr; - memset(sptr, 0, sizeof(sptr)); - sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); - } while (++i < PRESSURE_MAX_SYSFS_ATTRB); - + + char *sptr = pathP; + char **dptr = reinterpret_cast<char **>(&pressureSysFs); + for (size_t i = 0; i < PRESSURE_MAX_SYSFS_ATTRB; i++) { + *dptr++ = sptr; + sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); + } + sprintf(pressureSysFs.pressure_enable, "%s%s", mSysfsPath, "/pressure_enable"); sprintf(pressureSysFs.pressure_rate, "%s%s", mSysfsPath, "/pressure_rate"); diff --git a/65xx/libsensors_iio/Android.mk b/65xx/libsensors_iio/Android.mk index 5200285..ee4b021 100644 --- a/65xx/libsensors_iio/Android.mk +++ b/65xx/libsensors_iio/Android.mk @@ -15,16 +15,21 @@ LOCAL_PATH := $(call my-dir) -#ifneq ($(TARGET_SIMULATOR),true) +# Too many benign warnings to be fixed later. +my_ignored_clang_warnings := \ + -Wno-unused-parameter \ + -Wno-unused-private-field \ + -Wno-gnu-designator # InvenSense fragment of the HAL include $(CLEAR_VARS) +LOCAL_CLANG_CFLAGS += $(my_ignored_clang_warnings) LOCAL_MODULE := libinvensense_hal LOCAL_MODULE_TAGS := optional LOCAL_MODULE_OWNER := invensense -LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" +LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall # ANDROID version check MAJOR_VERSION :=$(shell echo $(PLATFORM_VERSION) | cut -f1 -d.) @@ -82,19 +87,17 @@ LOCAL_SHARED_LIBRARIES += libmllite LOCAL_SHARED_LIBRARIES += libmplmpu LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mpl LOCAL_CPPFLAGS += -DLINUX=1 -LOCAL_PRELINK_MODULE := false LOCAL_SHARED_LIBRARIES += libmllite LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite LOCAL_CPPFLAGS += -DLINUX=1 -LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) -#endif # !TARGET_SIMULATOR - # Build a temporary HAL that links the InvenSense .so include $(CLEAR_VARS) + +LOCAL_CLANG_CFLAGS += $(my_ignored_clang_warnings) ifneq ($(filter dory guppy guppypdk, $(TARGET_DEVICE)),) LOCAL_MODULE := sensors.invensense else @@ -117,9 +120,8 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mpl LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include/linux -LOCAL_PRELINK_MODULE := false LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" +LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall ifeq ($(VERSION_JB),true) LOCAL_CFLAGS += -DANDROID_JELLYBEAN @@ -187,3 +189,4 @@ OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES) LOCAL_STRIP_MODULE := true include $(BUILD_PREBUILT) +my_ignored_clang_warnings := diff --git a/65xx/libsensors_iio/CompassSensor.IIO.9150.cpp b/65xx/libsensors_iio/CompassSensor.IIO.9150.cpp index 0e4698a..737f74d 100644 --- a/65xx/libsensors_iio/CompassSensor.IIO.9150.cpp +++ b/65xx/libsensors_iio/CompassSensor.IIO.9150.cpp @@ -167,7 +167,7 @@ int CompassSensor::setDelay(int32_t handle, int64_t ns) int CompassSensor::turnOffCompassFifo(void) { - int i, res = 0, tempFd; + int res = 0; LOGV_IF(SYSFS_VERBOSE, "HAL:sysfs:echo %d > %s (%lld)", 0, compassSysFs.compass_fifo_enable, getTimestamp()); res += write_sysfs_int(compassSysFs.compass_fifo_enable, 0); @@ -176,7 +176,7 @@ int CompassSensor::turnOffCompassFifo(void) int CompassSensor::turnOnCompassFifo(void) { - int i, res = 0, tempFd; + int res = 0; LOGV_IF(SYSFS_VERBOSE, "HAL:sysfs:echo %d > %s (%lld)", 1, compassSysFs.compass_fifo_enable, getTimestamp()); res += write_sysfs_int(compassSysFs.compass_fifo_enable, 1); @@ -247,7 +247,7 @@ int CompassSensor::readSample(long *data, int64_t *timestamp) { VHANDLER_LOG; - int numEventReceived = 0, done = 0; + int done = 0; ssize_t n = mCompassInputReader.fill(compass_fd); if (n < 0) { @@ -346,28 +346,23 @@ int CompassSensor::inv_init_sysfs_attributes(void) { VFUNC_LOG; - unsigned char i = 0; char sysfs_path[MAX_SYSFS_NAME_LEN]; - char iio_trigger_path[MAX_SYSFS_NAME_LEN], tbuf[2]; - char *sptr; - char **dptr; - int num; + char iio_trigger_path[MAX_SYSFS_NAME_LEN]; - pathP = (char*)malloc( - sizeof(char[COMPASS_MAX_SYSFS_ATTRB][MAX_SYSFS_NAME_LEN])); - sptr = pathP; - dptr = (char**)&compassSysFs; - if (sptr == NULL) + pathP = (char*)calloc(COMPASS_MAX_SYSFS_ATTRB, + sizeof(char[MAX_SYSFS_NAME_LEN])); + if (pathP == NULL) return -1; memset(sysfs_path, 0, sizeof(sysfs_path)); memset(iio_trigger_path, 0, sizeof(iio_trigger_path)); - do { - *dptr++ = sptr; - memset(sptr, 0, sizeof(sptr)); - sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); - } while (++i < COMPASS_MAX_SYSFS_ATTRB); + char *sptr = pathP; + char **dptr = reinterpret_cast<char **>(&compassSysFs); + for (size_t i = 0; i < COMPASS_MAX_SYSFS_ATTRB; i++) { + *dptr++ = sptr; + sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); + } // get proper (in absolute/relative) IIO path & build MPU's sysfs paths // inv_get_sysfs_abs_path(sysfs_path); @@ -378,6 +373,9 @@ int CompassSensor::inv_init_sysfs_attributes(void) return 0; #if defined COMPASS_AK8975 + char tbuf[2]; + int num; + inv_get_input_number(dev_name, &num); tbuf[0] = num + 0x30; tbuf[1] = 0; @@ -396,12 +394,5 @@ int CompassSensor::inv_init_sysfs_attributes(void) sprintf(compassSysFs.compass_orient, "%s%s", sysfs_path, "/compass_matrix"); #endif -#if 0 - // test print sysfs paths - dptr = (char**)&compassSysFs; - for (i = 0; i < COMPASS_MAX_SYSFS_ATTRB; i++) { - LOGE("HAL:sysfs path: %s", *dptr++); - } -#endif return 0; } diff --git a/65xx/libsensors_iio/InputEventReader.cpp b/65xx/libsensors_iio/InputEventReader.cpp index 968e32e..83de389 100644 --- a/65xx/libsensors_iio/InputEventReader.cpp +++ b/65xx/libsensors_iio/InputEventReader.cpp @@ -18,6 +18,7 @@ #include <stdint.h> #include <errno.h> +#include <string.h> #include <unistd.h> #include <poll.h> diff --git a/65xx/libsensors_iio/MPLSensor.cpp b/65xx/libsensors_iio/MPLSensor.cpp index ed16e19..d63c0ae 100644 --- a/65xx/libsensors_iio/MPLSensor.cpp +++ b/65xx/libsensors_iio/MPLSensor.cpp @@ -257,12 +257,8 @@ MPLSensor::MPLSensor(CompassSensor *compass, int (*m_pt2AccelCalLoadFunc)(long * VFUNC_LOG; inv_error_t rv; - int i, fd; - char *port = NULL; + int fd; char *ver_str; - unsigned long mSensorMask; - int res; - FILE *fptr; mCompassSensor = compass; @@ -897,7 +893,7 @@ void MPLSensor::loadDMP(void) { VFUNC_LOG; - int res, fd; + int fd; FILE *fptr; if (isMpuNonDmp()) { @@ -2052,7 +2048,6 @@ int MPLSensor::enableSensors(unsigned long sensors, int en, uint32_t changed) inv_error_t res = -1; int on = 1; - int off = 0; int cal_stored = 0; // Sequence to enable or disable a sensor @@ -2328,8 +2323,6 @@ int MPLSensor::setBatch(int en, int toggleEnable) VFUNC_LOG; int res = 0; - int64_t wanted = 1000000000LL; - int64_t timeout = 0; int timeoutInMs = 0; int featureMask = computeBatchDataOutput(); @@ -2704,7 +2697,6 @@ int MPLSensor::gmHandler(sensors_event_t* s) int MPLSensor::psHandler(sensors_event_t* s) { VHANDLER_LOG; - int8_t status; int update = 0; s->pressure = mCachedPressureData / 100.f; //hpa (millibar) @@ -2878,7 +2870,6 @@ int MPLSensor::enable(int32_t handle, int en) // pthread_mutex_lock(&mHALMutex); if ((uint32_t(newState) << what) != (mEnabled & (1 << what))) { - uint32_t sensor_type; short flags = newState; uint32_t lastEnabled = mEnabled, changed = 0; @@ -3217,13 +3208,8 @@ int MPLSensor::update_delay(void) int64_t gyroRate; int64_t accelRate; int64_t compassRate; - int64_t pressureRate; int rateInus; - int mplGyroRate; - int mplAccelRate; - int mplCompassRate; - int tempRate = wanted; /* search the minimum delay requested across all enabled sensors */ for (int i = 0; i < NumSensors; i++) { @@ -3237,13 +3223,11 @@ int MPLSensor::update_delay(void) gyroRate = mDelays[Gyro] < mDelays[RawGyro] ? mDelays[Gyro] : mDelays[RawGyro]; accelRate = mDelays[Accelerometer]; compassRate = mDelays[MagneticField] < mDelays[RawMagneticField] ? mDelays[MagneticField] : mDelays[RawMagneticField]; - pressureRate = mDelays[Pressure]; #ifdef ENABLE_MULTI_RATE gyroRate = wanted; accelRate = wanted; compassRate = wanted; - pressureRate = wanted; // same delay for 3rd party Accel or Compass wanted_3rd_party_sensor = wanted; #endif @@ -3253,7 +3237,6 @@ int MPLSensor::update_delay(void) gyroRate = wanted; accelRate = wanted; compassRate = wanted; - pressureRate = wanted; // same delay for 3rd party Accel or Compass wanted_3rd_party_sensor = wanted; } @@ -3303,7 +3286,6 @@ int MPLSensor::update_delay(void) "mFeatureActiveMask=%016llx", mFeatureActiveMask); //TODO: may be able to combine DMP_FEATURE_MASK, DMP_SENSOR_MASK in the future if(mFeatureActiveMask & DMP_FEATURE_MASK) { - bool setDMPrate= 0; gyroRate = wanted; accelRate = wanted; compassRate = wanted; @@ -3335,7 +3317,6 @@ int MPLSensor::update_delay(void) LOGV_IF(ENG_VERBOSE, "HAL:MPL quat sample rate: " "(mpl)=%d us (mpu)=%.2f Hz", rateInus, 1000000000.f / wanted); - setDMPrate= 1; } } } @@ -3564,7 +3545,7 @@ int MPLSensor::readAccelEvents(sensors_event_t* data, int count) int numEventReceived = 0; input_event const* event; - int nb, done = 0; + int done = 0; while (done == 0 && count && mAccelInputReader.readEvent(&event)) { int type = event->type; @@ -3711,7 +3692,7 @@ void MPLSensor::buildMpuEvent(void) ped_quaternion_on = 0, ped_standalone_on = 0; size_t nbyte; unsigned short data_format = 0; - int i, nb, mask = 0, + int mask = 0, sensors = ((mLocalSensorMask & INV_THREE_AXIS_GYRO)? 1 : 0) + ((mLocalSensorMask & INV_THREE_AXIS_ACCEL)? 1 : 0) + (((mLocalSensorMask & INV_THREE_AXIS_COMPASS) @@ -3955,7 +3936,6 @@ void MPLSensor::buildMpuEvent(void) if ((readCounter != 0) && ((checkBatchEnabled() && (rsize == (ssize_t)nbyte)) || (!checkBatchEnabled() && (rsize != (ssize_t)nbyte))) &&(readCounter <= storeBufferSize)) { - int currentBufferCounter = 0; LOGV_IF(0, "!!! not enough data readCounter=%d, expected nbyte=%d, rsize=%d", readCounter, nbyte, (int)rsize); memcpy(mLeftOverBuffer, rdata, readCounter); LOGV_IF(0, @@ -4238,7 +4218,7 @@ int MPLSensor::getCompassFd(void) const int MPLSensor::turnOffAccelFifo(void) { VFUNC_LOG; - int i, res = 0, tempFd; + int res = 0; LOGV_IF(SYSFS_VERBOSE, "HAL:sysfs:echo %d > %s (%lld)", 0, mpu.accel_fifo_enable, getTimestamp()); res += write_sysfs_int(mpu.accel_fifo_enable, 0); @@ -4248,7 +4228,7 @@ int MPLSensor::turnOffAccelFifo(void) int MPLSensor::turnOffGyroFifo(void) { VFUNC_LOG; - int i, res = 0, tempFd; + int res = 0; LOGV_IF(SYSFS_VERBOSE, "HAL:sysfs:echo %d > %s (%lld)", 0, mpu.gyro_fifo_enable, getTimestamp()); res += write_sysfs_int(mpu.gyro_fifo_enable, 0); @@ -4259,7 +4239,6 @@ int MPLSensor::enableDmpOrientation(int en) { VFUNC_LOG; int res = 0; - int enabled_sensors = mEnabled; if (isMpuNonDmp()) return res; @@ -4731,9 +4710,10 @@ int MPLSensor::populateSensorList(struct sensor_t *list, int len) /* first add gyro, accel and compass to the list */ /* fill in gyro/accel values */ - if(chip_ID == NULL) { - LOGE("HAL:Can not get gyro/accel id"); - } + // chip_ID is an array and will never equal to NULL. + //if(chip_ID == NULL) { + // LOGE("HAL:Can not get gyro/accel id"); + //} fillGyro(chip_ID, list); fillAccel(chip_ID, list); @@ -5020,30 +5000,24 @@ int MPLSensor::inv_init_sysfs_attributes(void) { VFUNC_LOG; - unsigned char i = 0; char sysfs_path[MAX_SYSFS_NAME_LEN]; - char tbuf[2]; - char *sptr; - char **dptr; - int num; memset(sysfs_path, 0, sizeof(sysfs_path)); - sysfs_names_ptr = - (char*)malloc(sizeof(char[MAX_SYSFS_ATTRB][MAX_SYSFS_NAME_LEN])); - sptr = sysfs_names_ptr; - if (sptr != NULL) { - dptr = (char**)&mpu; - do { - *dptr++ = sptr; - memset(sptr, 0, sizeof(sptr)); - sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); - } while (++i < MAX_SYSFS_ATTRB); - } else { + sysfs_names_ptr = (char*)calloc(MAX_SYSFS_ATTRB, + sizeof(char[MAX_SYSFS_NAME_LEN])); + if (sysfs_names_ptr == NULL) { LOGE("HAL:couldn't alloc mem for sysfs paths"); return -1; } + char *sptr = sysfs_names_ptr; + char **dptr = reinterpret_cast<char **>(&mpu); + for (size_t i = 0; i < MAX_SYSFS_ATTRB; i++) { + *dptr++ = sptr; + sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); + } + // get proper (in absolute) IIO path & build MPU's sysfs paths inv_get_sysfs_path(sysfs_path); @@ -5298,7 +5272,6 @@ void MPLSensor::getGyroBias() VFUNC_LOG; long *temp = NULL; - long chipBias[3]; long bias[3]; unsigned short orient; @@ -5371,8 +5344,6 @@ void MPLSensor::getFactoryAccelBias() { VFUNC_LOG; - long temp; - /* Get Values from MPL */ inv_get_accel_bias(mFactoryAccelBias); LOGV_IF(ENG_VERBOSE, "Factory Accel Bias (mg) %ld %ld %ld", mFactoryAccelBias[0], mFactoryAccelBias[1], mFactoryAccelBias[2]); @@ -5665,9 +5636,9 @@ int MPLSensor::batch(int handle, int flags, int64_t period_ns, int64_t timeout) mBatchTimeoutInMs = timeoutInMs; /* TODO: Calculate nSamples */ - int nSamples = 0; - nSamples = (unsigned long)( - (1000000000.f / wanted) * ((float)timeout / 1000000000.f)); + /* int nSamples = 0; + nSamples = (unsigned long)( + (1000000000.f / wanted) * ((float)timeout / 1000000000.f)); */ } else { timeoutInMs = 0; } @@ -5921,12 +5892,10 @@ int MPLSensor::readDmpPedometerEvents(sensors_event_t* data, int count, { VFUNC_LOG; - int res = 0; char dummy[4]; FILE *fp; uint64_t stepCount = 0; int numEventReceived = 0; - int update = 0; if((mDmpStepCountEnabled || mDmpPedometerEnabled) && count > 0) { /* handles return event */ @@ -6001,13 +5970,14 @@ int MPLSensor::readDmpSignificantMotionEvents(sensors_event_t* data, int count) { VFUNC_LOG; - int res = 0; char dummy[4]; int significantMotion; FILE *fp; +#if 0 + int res = 0; int sensors = mEnabled; +#endif int numEventReceived = 0; - int update = 0; /* Technically this step is not necessary for now */ /* In the future, we may have meaningful values */ diff --git a/65xx/libsensors_iio/MPLSupport.cpp b/65xx/libsensors_iio/MPLSupport.cpp index 4ab0b85..e33fb32 100644 --- a/65xx/libsensors_iio/MPLSupport.cpp +++ b/65xx/libsensors_iio/MPLSupport.cpp @@ -261,9 +261,6 @@ int fill_dev_full_name_by_prefix(const char* dev_prefix, void dump_dmp_img(const char *outFile) { - FILE *fp; - int i; - char sysfs_path[MAX_SYSFS_NAME_LEN]; char dmp_path[MAX_SYSFS_NAME_LEN]; diff --git a/65xx/libsensors_iio/PressureSensor.IIO.secondary.cpp b/65xx/libsensors_iio/PressureSensor.IIO.secondary.cpp index 1a1fd14..ad64de6 100644 --- a/65xx/libsensors_iio/PressureSensor.IIO.secondary.cpp +++ b/65xx/libsensors_iio/PressureSensor.IIO.secondary.cpp @@ -40,9 +40,10 @@ #define DEFAULT_POLL_TIME 300 #define PRESSURE_MAX_SYSFS_ATTRB sizeof(pressureSysFs) / sizeof(char*) +#ifdef TIMER static int s_poll_time = -1; static int min_poll_time = 50; -static struct timespec t_pre; +#endif /*****************************************************************************/ @@ -181,24 +182,24 @@ void PressureSensor::fillList(struct sensor_t *list) int PressureSensor::inv_init_sysfs_attributes(void) { VFUNC_LOG; - - pathP = (char*)malloc(sizeof(char[PRESSURE_MAX_SYSFS_ATTRB][MAX_SYSFS_NAME_LEN])); - char *sptr = pathP; - char **dptr = (char**)&pressureSysFs; - if (sptr == NULL) + + pathP = (char*)calloc(PRESSURE_MAX_SYSFS_ATTRB, + sizeof(char[MAX_SYSFS_NAME_LEN])); + if (pathP == NULL) return -1; - unsigned char i = 0; - do { - *dptr++ = sptr; - memset(sptr, 0, sizeof(sptr)); - sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); - } while (++i < PRESSURE_MAX_SYSFS_ATTRB); - - + if (mSysfsPath == NULL) return 0; + char *sptr = pathP; + char **dptr = reinterpret_cast<char **>(&pressureSysFs); + for (size_t i = 0; i < PRESSURE_MAX_SYSFS_ATTRB; i++) { + *dptr++ = sptr; + sptr += sizeof(char[MAX_SYSFS_NAME_LEN]); + } + sprintf(pressureSysFs.pressure_enable, "%s%s", mSysfsPath, "/pressure_enable"); sprintf(pressureSysFs.pressure_rate, "%s%s", mSysfsPath, "/pressure_rate"); + return 0; } diff --git a/65xx/libsensors_iio/SensorBase.cpp b/65xx/libsensors_iio/SensorBase.cpp index c01d394..1c7eddd 100644 --- a/65xx/libsensors_iio/SensorBase.cpp +++ b/65xx/libsensors_iio/SensorBase.cpp @@ -20,6 +20,7 @@ #include <poll.h> #include <unistd.h> #include <stdlib.h> +#include <string.h> #include <dirent.h> #include <sys/select.h> #include <cutils/log.h> diff --git a/65xx/libsensors_iio/sensors_mpl.cpp b/65xx/libsensors_iio/sensors_mpl.cpp index c675da8..e7a3116 100644 --- a/65xx/libsensors_iio/sensors_mpl.cpp +++ b/65xx/libsensors_iio/sensors_mpl.cpp @@ -323,11 +323,11 @@ int sensors_poll_context_t::batch(int handle, int flags, int64_t period_ns, } int sensors_poll_context_t::flush(int handle) -{
- FUNC_LOG;
+{ + FUNC_LOG; return mSensor->flush(handle); -}
-
+} + /******************************************************************************/ static int poll__close(struct hw_device_t *dev) @@ -362,13 +362,6 @@ static int poll__poll(struct sensors_poll_device_t *dev, return ctx->pollEvents(data, count); } -static int poll__query(struct sensors_poll_device_1 *dev, - int what, int *value) -{ - sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; - return ctx->query(what, value); -} - static int poll__batch(struct sensors_poll_device_1 *dev, int handle, int flags, int64_t period_ns, int64_t timeout) { @@ -376,12 +369,12 @@ static int poll__batch(struct sensors_poll_device_1 *dev, return ctx->batch(handle, flags, period_ns, timeout); } -static int poll__flush(struct sensors_poll_device_1 *dev,
+static int poll__flush(struct sensors_poll_device_1 *dev, int handle) -{
- sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
+{ + sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; return ctx->flush(handle); -}
+} /******************************************************************************/ /** Open a new instance of a sensor device using name */ diff --git a/65xx/libsensors_iio/software/core/mpl/gyro_tc.h b/65xx/libsensors_iio/software/core/mpl/gyro_tc.h index 3347a14..183afa9 100644 --- a/65xx/libsensors_iio/software/core/mpl/gyro_tc.h +++ b/65xx/libsensors_iio/software/core/mpl/gyro_tc.h @@ -12,7 +12,7 @@ *****************************************************************************/ #ifndef _GYRO_TC_H -#define _GYRO_TC_H_ +#define _GYRO_TC_H #include "mltypes.h" |