sensors: support Invensense MLP 5.1.2
* try to deal with DMP for display orientation
* remove the isValid() check, as the failure is handled more gracefully
in the HAL.
* enable uevent handling for needed entries.
* tweak lock inits
Change-Id: Iccb8dc8f9bd110d99875a56dd406419f3db7f762
diff --git a/libsensors/IioSensorBase.cpp b/libsensors/IioSensorBase.cpp
index 5e0eddf..437d095 100644
--- a/libsensors/IioSensorBase.cpp
+++ b/libsensors/IioSensorBase.cpp
@@ -48,9 +48,9 @@
mHasPendingEvent(false),
mInputReader(MAX_BUFFER_FOR_EVENT),
mIioChanType(iio_chan_type),
- mIioSysfsChanFp(NULL),
- mLock(PTHREAD_MUTEX_INITIALIZER)
+ mIioSysfsChanFp(NULL)
{
+ pthread_mutex_init(&mLock, NULL);
ALOGV("%s(): dev_name=%s", __func__, dev_name);
mPendingEvent.version = sizeof(sensors_event_t);
memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp
index 33853eb..22c005d 100644
--- a/libsensors/sensors.cpp
+++ b/libsensors/sensors.cpp
@@ -70,7 +70,7 @@
/*****************************************************************************/
/* The SENSORS Module */
-#define LOCAL_SENSORS (2)
+#define LOCAL_SENSORS 2
static struct sensor_t sSensorList[LOCAL_SENSORS + MPLSensor::numSensors] = {
{ "BH1721fvc Light sensor",
"Rohm",
@@ -132,6 +132,9 @@
enum {
mpl = 0,
compass,
+#ifdef ENABLE_DMP_DISPL_ORIENT_FEAT
+ dmpOrient,
+#endif
light,
pressure,
numSensorDrivers, // wake pipe goes here
@@ -155,6 +158,10 @@
case ID_M:
case ID_O:
return mpl;
+#ifdef ENABLE_DMP_DISPL_ORIENT_FEAT
+ case ID_SO:
+ return dmpOrient;
+#endif
case ID_L:
return light;
case ID_PR:
@@ -175,11 +182,6 @@
// Must clean this up early or else the destructor will make a mess.
memset(mSensors, 0, sizeof(mSensors));
- if (!p_mplsen->isValid()) {
- delete p_compasssensor;
- return;
- }
-
setCallbackObject(p_mplsen); //setup the callback object for handing mpl callbacks
numSensors =
LOCAL_SENSORS +
@@ -196,6 +198,11 @@
mPollFds[compass].events = POLLIN;
mPollFds[compass].revents = 0;
+#ifdef ENABLE_DMP_DISPL_ORIENT_FEAT
+ mPollFds[dmpOrient].fd = ((MPLSensor*)mSensors[mpl])->getDmpOrientFd();
+ mPollFds[dmpOrient].events = POLLPRI;
+ mPollFds[dmpOrient].revents = 0;
+#endif
mSensors[light] = new LightSensor();
mPollFds[light].fd = mSensors[light]->getFd();
mPollFds[light].events = POLLIN;
@@ -276,6 +283,16 @@
nb = ((MPLSensor*) mSensors[mpl])->executeOnData(data, count);
mPollFds[i].revents = 0;
}
+#ifdef ENABLE_DMP_DISPL_ORIENT_FEAT
+ else if (i == dmpOrient) {
+ nb = ((MPLSensor*) mSensors[mpl])->readDmpOrientEvents(data, count);
+ mPollFds[dmpOrient].revents= 0;
+ if (!isDmpScreenAutoRotationEnabled()) {
+ /* ignore the data */
+ nb = 0;
+ }
+ }
+#endif
else {
nb = sensor->readEvents(data, count);
}
diff --git a/ueventd.manta.rc b/ueventd.manta.rc
index f60b330..e2c0ecb 100755
--- a/ueventd.manta.rc
+++ b/ueventd.manta.rc
@@ -30,6 +30,12 @@
/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* power_state 0660 system system
/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* buffer/enable 0660 system system
/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* buffer/length 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* firmware_loaded 0660 system system
+
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* dmp_firmware 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* dmp_on 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* dmp_int_on 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* dmp_output_rate 0660 system system
/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* scan_elements/in_accel_x_en 0660 system system
/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* scan_elements/in_accel_y_en 0660 system system
@@ -47,13 +53,13 @@
/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0068/iio:device* scan_elements/in_timestamp_en 0660 system system
# led
-/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 color 0660 system system
-/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 brightness 0660 system system
-/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 delay_on 0660 system system
-/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 delay_off 0660 system system
-/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 trigger 0660 system system
-/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 slope_up 0660 system system
-/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 slope_down 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 color 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 brightness 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 delay_on 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 delay_off 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 trigger 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 slope_up 0660 system system
+/sys/devices/platform/s3c2440-i2c.1/i2c-1/1-0042/leds/as3668 slope_down 0660 system system
# gscalers
/dev/video23 0660 media graphics