summaryrefslogtreecommitdiffstats
path: root/libsensors_iio/MPLSensor.h
diff options
context:
space:
mode:
Diffstat (limited to 'libsensors_iio/MPLSensor.h')
-rw-r--r--libsensors_iio/MPLSensor.h80
1 files changed, 67 insertions, 13 deletions
diff --git a/libsensors_iio/MPLSensor.h b/libsensors_iio/MPLSensor.h
index 3ef1ba3..879f37b 100644
--- a/libsensors_iio/MPLSensor.h
+++ b/libsensors_iio/MPLSensor.h
@@ -28,17 +28,18 @@
#include "SensorBase.h"
#include "InputEventReader.h"
-// TODO: change to wanted vendor
#ifdef INVENSENSE_COMPASS_CAL
-#ifdef COMPASS_AMI306
+#ifdef COMPASS_YAS530
+#warning "unified HAL for YAS530"
+#include "CompassSensor.IIO.primary.h"
+#elif COMPASS_AMI306
#warning "unified HAL for AMI306"
-#include "CompassSensor.IIO.AMI.h"
+#include "CompassSensor.IIO.primary.h"
#else
#warning "unified HAL for MPU9150"
#include "CompassSensor.IIO.9150.h"
#endif
-
#else
#warning "unified HAL for AKM"
#include "CompassSensor.AKM.h"
@@ -60,7 +61,6 @@
| INV_THREE_AXIS_COMPASS \
| INV_THREE_AXIS_GYRO)
#else
-// TODO: ID_M = 2 even for 3rd-party solution
#define ALL_MPL_SENSORS_NP (INV_THREE_AXIS_ACCEL \
| INV_THREE_AXIS_COMPASS \
| INV_THREE_AXIS_GYRO)
@@ -70,6 +70,39 @@
#define INV_COMPASS_CAL 0x01
#define INV_COMPASS_FIT 0x02
#define INV_DMP_QUATERNION 0x04
+#define INV_DMP_DISPL_ORIENTATION 0x08
+
+// #define ENABLE_LP_QUAT_FEAT /* Uncomment to enable Low Power Quaternion */
+// #define ENABLE_DMP_DISPL_ORIENT_FEAT /* Uncomment to enable DMP display orientation */
+
+#ifdef ENABLE_DMP_DISPL_ORIENT_FEAT
+/* Uncomment followings to enable screen auto-rotation by DMP (need the latest Android source tree update) */
+// #define ENABLE_DMP_SCREEN_AUTO_ROTATION
+#endif
+
+int isLowPowerQuatEnabled() {
+#ifdef ENABLE_LP_QUAT_FEAT
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+int isDmpDisplayOrientationOn() {
+#ifdef ENABLE_DMP_DISPL_ORIENT_FEAT
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+int isDmpScreenAutoRotationOn() {
+#ifdef ENABLE_DMP_SCREEN_AUTO_ROTATION
+ return 1;
+#else
+ return 0;
+#endif
+}
/*****************************************************************************/
/** MPLSensor implementation which fits into the HAL example for crespo provided
@@ -82,12 +115,9 @@ class MPLSensor: public SensorBase
typedef int (MPLSensor::*hfunc_t)(sensors_event_t*);
public:
- MPLSensor(CompassSensor *);
- virtual ~MPLSensor();
-
- enum
- {
+ enum {
Gyro = 0,
+ RawGyro,
Accelerometer,
MagneticField,
Orientation,
@@ -97,6 +127,9 @@ public:
numSensors
};
+ MPLSensor(CompassSensor *);
+ virtual ~MPLSensor();
+
virtual int setDelay(int32_t handle, int64_t ns);
virtual int enable(int32_t handle, int enabled);
int32_t getEnableMask() { return mEnabled; }
@@ -124,6 +157,17 @@ public:
int readAccelEvents(sensors_event_t* data, int count);
int readCompassEvents(sensors_event_t* data, int count);
+ int turnOffAccelFifo();
+ int enableDmpOrientation(int);
+ int dmpOrientHandler(int);
+ int readDmpOrientEvents(sensors_event_t* data, int count);
+ int getDmpOrientFd();
+ int openDmpOrientFd();
+ int closeDmpOrientFd();
+
+ int getDmpRate(int64_t *);
+ int checkDMPOrientation();
+
protected:
// Lets us know if the constructor was actually able to finish its job.
// E.g. false if init sysfs failed.
@@ -131,6 +175,7 @@ protected:
CompassSensor *mCompassSensor;
int gyroHandler(sensors_event_t *data);
+ int rawGyroHandler(sensors_event_t *data);
int accelHandler(sensors_event_t *data);
int compassHandler(sensors_event_t *data);
int rvHandler(sensors_event_t *data);
@@ -156,7 +201,6 @@ protected:
void computeLocalSensorMask(int enabled_sensors);
int enableSensors(unsigned long sensors, int en, uint32_t changed);
int inv_read_gyro_buffer(int fd, short *data, long long *timestamp);
- int update_delay_sysfs_sensor(int fd, uint64_t ns);
int inv_float_to_q16(float *fdata, long *ldata);
int inv_long_to_q16(long *fdata, long *ldata);
int inv_float_to_round(float *fdata, long *ldata);
@@ -166,6 +210,9 @@ protected:
int inv_read_sensor_bias(int fd, long *data);
void inv_get_sensors_orientation(void);
int inv_init_sysfs_attributes(void);
+#ifdef COMPASS_YAS530
+ int resetCompass(void);
+#endif
void setCompassDelay(int64_t ns);
void enable_iio_sysfs(void);
int enableTap(int);
@@ -192,11 +239,14 @@ protected:
int accel_fd;
int mpufifo_fd;
int gyro_temperature_fd;
+ int dmp_orient_fd;
+
+ int mDmpOrientationEnabled;
uint32_t mEnabled;
uint32_t mOldEnabledMask;
sensors_event_t mPendingEvents[numSensors];
- uint64_t mDelays[numSensors];
+ int64_t mDelays[numSensors];
hfunc_t mHandlers[numSensors];
short mCachedGyroData[3];
long mCachedAccelData[3];
@@ -231,11 +281,12 @@ protected:
char *firmware_loaded;
char *dmp_on;
char *dmp_int_on;
+ char *dmp_event_int_on;
+ char *dmp_output_rate;
char *tap_on;
char *key;
char *self_test;
char *temperature;
- char *dmp_output_rate;
char *gyro_enable;
char *gyro_fifo_rate;
@@ -263,6 +314,9 @@ protected:
char *trigger_name;
char *current_trigger;
char *buffer_length;
+
+ char *display_orientation_on;
+ char *event_display_orientation;
} mpu;
char *sysfs_names_ptr;