diff options
author | codeworkx <codeworkx@cyanogenmod.org> | 2016-04-30 20:56:15 +0200 |
---|---|---|
committer | codeworkx <codeworkx@cyanogenmod.org> | 2016-04-30 20:56:15 +0200 |
commit | 732bf7a24e16add354c45704e237cb2357d2683c (patch) | |
tree | b25b62ef6c1715638ab3e0b7b40961d13bf32ad1 /libsensors | |
parent | 3dd3324a32a32cf6295e56b0bf7ef697d7d58bdd (diff) | |
parent | d41c859a0678da88519a27560e75983c750155c0 (diff) | |
download | device_samsung_n7100-732bf7a24e16add354c45704e237cb2357d2683c.zip device_samsung_n7100-732bf7a24e16add354c45704e237cb2357d2683c.tar.gz device_samsung_n7100-732bf7a24e16add354c45704e237cb2357d2683c.tar.bz2 |
Merge branch 'cm-13.0' of github.com:tilaksidduram/android_device_samsung_n7100 into HEAD
Change-Id: I492f715515d6cf681a5f6d2bc59f6929f92b7b47
Diffstat (limited to 'libsensors')
-rw-r--r-- | libsensors/AccelSensor.cpp | 23 | ||||
-rw-r--r-- | libsensors/AkmSensor.cpp | 50 | ||||
-rw-r--r-- | libsensors/Android.mk | 3 | ||||
-rw-r--r-- | libsensors/GyroSensor.cpp | 9 | ||||
-rw-r--r-- | libsensors/InputEventReader.cpp | 3 | ||||
-rw-r--r-- | libsensors/LightSensor.cpp | 11 | ||||
-rw-r--r-- | libsensors/PressureSensor.cpp | 6 | ||||
-rw-r--r-- | libsensors/ProximitySensor.cpp | 6 | ||||
-rw-r--r-- | libsensors/SensorBase.cpp | 44 | ||||
-rw-r--r-- | libsensors/SensorBase.h | 5 | ||||
-rw-r--r-- | libsensors/ak8973b.h | 51 | ||||
-rw-r--r-- | libsensors/sensors.cpp | 37 | ||||
-rw-r--r-- | libsensors/sensors.h | 1 |
13 files changed, 181 insertions, 68 deletions
diff --git a/libsensors/AccelSensor.cpp b/libsensors/AccelSensor.cpp index 72334be..7b6ba67 100644 --- a/libsensors/AccelSensor.cpp +++ b/libsensors/AccelSensor.cpp @@ -21,7 +21,8 @@ #include <unistd.h> #include <dirent.h> #include <sys/select.h> -#include <utils/Log.h> +#include <cutils/log.h> +#include <cstring> #include "AccelSensor.h" @@ -31,6 +32,7 @@ AccelSensor::AccelSensor() : SensorBase(NULL, "accelerometer_sensor"), mEnabled(0), + mInputReader(4), mHasPendingEvent(false) { @@ -49,7 +51,7 @@ AccelSensor::AccelSensor() AccelSensor::~AccelSensor() { - ALOGD("AccelSensor::~AccelSensor()"); + // ALOGD("AccelSensor::~AccelSensor()"); if (mEnabled) { enable(0, 0); } @@ -61,11 +63,12 @@ int AccelSensor::setInitialState() } int AccelSensor::enable(int32_t handle, int en) { + int flags = en ? 1 : 0; int err; - if (en != mEnabled) { + if (flags != mEnabled) { err = sspEnable(LOGTAG, SSP_ACCEL, en); if(err >= 0){ - mEnabled = en; + mEnabled = flags; setInitialState(); return 0; @@ -88,17 +91,19 @@ int AccelSensor::setDelay(int32_t handle, int64_t ns) { int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "acc_poll_delay"); + if (ns < 10000000) { + ns = 10000000; // Minimum on stock + } + + strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); fd = open(input_sysfs_path, O_RDWR); if (fd >= 0) { char buf[80]; - sprintf(buf, "%lld", ns); // Some flooring to match stock value + sprintf(buf, "%lld", ns); write(fd, buf, strlen(buf)+1); close(fd); return 0; } - - ALOGD("AccelSensor: fail to set delay through %s.", input_sysfs_path); return -1; } @@ -146,6 +151,6 @@ int AccelSensor::readEvents(sensors_event_t* data, int count) mInputReader.next(); } - return numEventReceived; + return numEventReceived++; } diff --git a/libsensors/AkmSensor.cpp b/libsensors/AkmSensor.cpp index 8a87f65..d82e6f8 100644 --- a/libsensors/AkmSensor.cpp +++ b/libsensors/AkmSensor.cpp @@ -22,8 +22,11 @@ #include <dirent.h> #include <sys/select.h> #include <dlfcn.h> +#include <cstring> -#include <utils/Log.h> +#include "ak8973b.h" + +#include <cutils/log.h> #include "AkmSensor.h" #define LOGTAG "AkmSensor" @@ -78,6 +81,11 @@ AkmSensor::AkmSensor() memset(mPendingEvents, 0, sizeof(mPendingEvents)); + mPendingEvents[Accelerometer].version = sizeof(sensors_event_t); + mPendingEvents[Accelerometer].sensor = ID_A; + mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER; + mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_UNRELIABLE; + mPendingEvents[MagneticField].version = sizeof(sensors_event_t); mPendingEvents[MagneticField].sensor = ID_M; mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD; @@ -86,6 +94,19 @@ AkmSensor::AkmSensor() // read the actual value of all sensors if they're enabled already struct input_absinfo absinfo; short flags = 0; + + if (akm_is_sensor_enabled(SENSOR_TYPE_ACCELEROMETER)) { + mEnabled |= 1<<Accelerometer; + if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_X), &absinfo)) { + mPendingEvents[Accelerometer].acceleration.x = absinfo.value * CONVERT_A_X; + } + if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Y), &absinfo)) { + mPendingEvents[Accelerometer].acceleration.y = absinfo.value * CONVERT_A_Y; + } + if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Z), &absinfo)) { + mPendingEvents[Accelerometer].acceleration.z = absinfo.value * CONVERT_A_Z; + } + } if (akm_is_sensor_enabled(SENSOR_TYPE_MAGNETIC_FIELD)) { mEnabled |= 1<<MagneticField; if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_X), &absinfo)) { @@ -117,6 +138,7 @@ int AkmSensor::enable(int32_t handle, int en) int what = -1; switch (handle) { + case ID_A: what = Accelerometer; break; case ID_M: what = MagneticField; break; case ID_O: what = Orientation; break; } @@ -163,6 +185,7 @@ int AkmSensor::setDelay(int32_t handle, int64_t ns) return -EINVAL; switch (handle) { + case ID_A: sensor_type = SENSOR_TYPE_ACCELEROMETER; break; case ID_M: sensor_type = SENSOR_TYPE_MAGNETIC_FIELD; break; } @@ -186,6 +209,24 @@ int AkmSensor::setDelay(int32_t handle, int64_t ns) } mDelays[what] = ns; + return update_delay(); +} + +int AkmSensor::update_delay() +{ + if (mEnabled) { + uint64_t wanted = -1LLU; + for (int i=0 ; i<numSensors ; i++) { + if (mEnabled & (1<<i)) { + uint64_t ns = mDelays[i]; + wanted = wanted < ns ? wanted : ns; + } + } + short delay = int64_t(wanted) / 1000000; + if (ioctl(dev_fd, ECS_IOCTL_APP_SET_DELAY, &delay)) { + return -errno; + } + } return 0; } @@ -270,5 +311,12 @@ void AkmSensor::processEvent(int code, int value) mPendingMask |= 1<<MagneticField; mPendingEvents[MagneticField].magnetic.z = value * CONVERT_M_Z; break; + case EVENT_TYPE_MAGV_ACC: + ALOGV("AkmSensor: MAGV_ACC=>%d", value); + mPendingMask |= 1<<MagneticField; + mPendingEvents[MagneticField].magnetic.status = value; + default: + ALOGV("AkmSensor: unkown REL event code=%d, value=%d", code, value); + break; } } diff --git a/libsensors/Android.mk b/libsensors/Android.mk index 1b8e721..47a90e5 100644 --- a/libsensors/Android.mk +++ b/libsensors/Android.mk @@ -27,8 +27,7 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" - +LOCAL_CFLAGS := -DALOG_TAG=\"Sensors\" LOCAL_SRC_FILES := \ sensors.cpp \ SensorBase.cpp \ diff --git a/libsensors/GyroSensor.cpp b/libsensors/GyroSensor.cpp index 5bccbc8..75a24ca 100644 --- a/libsensors/GyroSensor.cpp +++ b/libsensors/GyroSensor.cpp @@ -22,6 +22,7 @@ #include <dirent.h> #include <sys/select.h> #include <cutils/log.h> +#include <cstring> #include "GyroSensor.h" @@ -48,6 +49,7 @@ GyroSensor::GyroSensor() strcat(input_sysfs_path, input_name); strcat(input_sysfs_path, "/device/"); input_sysfs_path_len = strlen(input_sysfs_path); + enable(0, 1); } } @@ -77,11 +79,12 @@ int GyroSensor::setInitialState() { } int GyroSensor::enable(int32_t handle, int en) { + int flags = en ? 1 : 0; int err; - if (en != mEnabled) { + if (flags != mEnabled) { err = sspEnable(LOGTAG, SSP_GYRO, en); if(err >= 0){ - mEnabled = en; + mEnabled = flags; setInitialState(); return 0; @@ -99,7 +102,7 @@ int GyroSensor::setDelay(int32_t handle, int64_t ns) { int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "gyro_poll_delay"); + strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); fd = open(input_sysfs_path, O_RDWR); if (fd >= 0) { char buf[80]; diff --git a/libsensors/InputEventReader.cpp b/libsensors/InputEventReader.cpp index d5c2349..ab23a22 100644 --- a/libsensors/InputEventReader.cpp +++ b/libsensors/InputEventReader.cpp @@ -21,10 +21,11 @@ #include <sys/cdefs.h> #include <sys/types.h> +#include <cstring> #include <linux/input.h> -#include <utils/Log.h> +#include <cutils/log.h> #include "InputEventReader.h" diff --git a/libsensors/LightSensor.cpp b/libsensors/LightSensor.cpp index 4f2fad9..4423412 100644 --- a/libsensors/LightSensor.cpp +++ b/libsensors/LightSensor.cpp @@ -21,8 +21,9 @@ #include <unistd.h> #include <dirent.h> #include <sys/select.h> +#include <cstring> -#include <utils/Log.h> +#include <cutils/log.h> #include "LightSensor.h" @@ -48,6 +49,7 @@ LightSensor::LightSensor() strcat(input_sysfs_path, input_name); strcat(input_sysfs_path, "/device/"); input_sysfs_path_len = strlen(input_sysfs_path); + enable(0, 1); } } @@ -71,7 +73,7 @@ int LightSensor::setDelay(int32_t handle, int64_t ns) { int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "light_poll_delay"); + strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); fd = open(input_sysfs_path, O_RDWR); if (fd >= 0) { char buf[80]; @@ -85,11 +87,12 @@ int LightSensor::setDelay(int32_t handle, int64_t ns) int LightSensor::enable(int32_t handle, int en) { + int flags = en ? 1 : 0; int err; - if (en != mEnabled) { + if (flags != mEnabled) { err = sspEnable(LOGTAG, SSP_LIGHT, en); if(err >= 0){ - mEnabled = en; + mEnabled = flags; setInitialState(); return 0; diff --git a/libsensors/PressureSensor.cpp b/libsensors/PressureSensor.cpp index 93423a8..e77ee79 100644 --- a/libsensors/PressureSensor.cpp +++ b/libsensors/PressureSensor.cpp @@ -21,8 +21,9 @@ #include <unistd.h> #include <dirent.h> #include <sys/select.h> +#include <cstring> -#include <utils/Log.h> +#include <cutils/log.h> #include "PressureSensor.h" @@ -52,6 +53,7 @@ PressureSensor::PressureSensor() strcat(input_sysfs_path, input_name); strcat(input_sysfs_path, "/device/"); input_sysfs_path_len = strlen(input_sysfs_path); + enable(0, 1); } } @@ -95,7 +97,7 @@ int PressureSensor::setDelay(int32_t handle, int64_t ns) { int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "pressure_poll_delay"); + strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); fd = open(input_sysfs_path, O_RDWR); if (fd >= 0) { char buf[80]; diff --git a/libsensors/ProximitySensor.cpp b/libsensors/ProximitySensor.cpp index d06501e..ab7db13 100644 --- a/libsensors/ProximitySensor.cpp +++ b/libsensors/ProximitySensor.cpp @@ -22,8 +22,9 @@ #include <dirent.h> #include <sys/select.h> #include <stdio.h> +#include <cstring> -#include <utils/Log.h> +#include <cutils/log.h> #include "ProximitySensor.h" #include "SensorBase.h" @@ -48,6 +49,7 @@ ProximitySensor::ProximitySensor() strcat(input_sysfs_path, input_name); strcat(input_sysfs_path, "/device/"); input_sysfs_path_len = strlen(input_sysfs_path); + enable(0, 1); } } @@ -71,7 +73,7 @@ int ProximitySensor::setDelay(int32_t handle, int64_t ns) { int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "prox_poll_delay"); + strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); fd = open(input_sysfs_path, O_RDWR); if (fd >= 0) { char buf[80]; diff --git a/libsensors/SensorBase.cpp b/libsensors/SensorBase.cpp index 5c5b52d..5742ed2 100644 --- a/libsensors/SensorBase.cpp +++ b/libsensors/SensorBase.cpp @@ -21,8 +21,10 @@ #include <unistd.h> #include <dirent.h> #include <sys/select.h> +#include <pthread.h> +#include <cstring> -#include <utils/Log.h> +#include <cutils/log.h> #include <linux/input.h> @@ -30,6 +32,8 @@ /*****************************************************************************/ +static pthread_mutex_t sspEnableLock = PTHREAD_MUTEX_INITIALIZER; + SensorBase::SensorBase( const char* dev_name, const char* data_name) @@ -39,11 +43,6 @@ SensorBase::SensorBase( if (data_name) { data_fd = openInput(data_name); } - - if (!data_fd) - { - ALOGE("open device %s failed", dev_name); - } } SensorBase::~SensorBase() { @@ -89,7 +88,7 @@ bool SensorBase::hasPendingEvents() const { int64_t SensorBase::getTimestamp() { struct timespec t; t.tv_sec = t.tv_nsec = 0; - clock_gettime(CLOCK_MONOTONIC, &t); + clock_gettime(CLOCK_BOOTTIME, &t); return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec; } @@ -146,30 +145,29 @@ int SensorBase::flush(int handle) int SensorBase::sspEnable(const char* sensorname, int sensorvalue, int en) { FILE* sspfile; - int oldvalue = 0; - int reset = 0; - int newvalue; - int fd; + int sspValue = 0; - sspfile = fopen(SSP_DEVICE_ENABLE, "r"); - fscanf(sspfile, "%d", &oldvalue); + pthread_mutex_lock(&sspEnableLock); + + sspfile = fopen(SSP_DEVICE_ENABLE, "r+"); + fscanf(sspfile, "%d", &sspValue); fclose(sspfile); - if(en) { - newvalue = oldvalue | sensorvalue; - } else { - newvalue = oldvalue & (~sensorvalue); - } - ALOGI("%s: name: %s sensor: %i old value: %x new value: %x ", __func__, sensorname, sensorvalue, oldvalue, newvalue); - if (sspWrite(newvalue)) - return -1; + if (en) + sspValue |= sensorvalue; else - return 0; + sspValue &= ~sensorvalue; + + sspWrite(sspValue); + + pthread_mutex_unlock(&sspEnableLock); + + return 0; } int SensorBase::sspWrite(int sensorvalue) { - char buf[10]; + char buf[12]; int fd, ret, err; sprintf(buf, "%d", sensorvalue); diff --git a/libsensors/SensorBase.h b/libsensors/SensorBase.h index 4476be0..aeac510 100644 --- a/libsensors/SensorBase.h +++ b/libsensors/SensorBase.h @@ -60,12 +60,11 @@ public: virtual int getFd() const; virtual int setDelay(int32_t handle, int64_t ns); virtual int enable(int32_t handle, int enabled) = 0; - static int sspEnable(const char* sensorname, int sensorvalue, int en); + int sspEnable(const char* sensorname, int sensorvalue, int en); + int sspWrite(int sensorvalue); virtual int batch(int handle, int flags, int64_t period_ns, int64_t timeout); virtual int flush(int handle); -private: - static int sspWrite(int sensorvalue); }; /*****************************************************************************/ diff --git a/libsensors/ak8973b.h b/libsensors/ak8973b.h new file mode 100644 index 0000000..9b7ab60 --- /dev/null +++ b/libsensors/ak8973b.h @@ -0,0 +1,51 @@ +/* + * Definitions for akm8973 compass chip. + */ +#ifndef AKM8973_H +#define AKM8973_H + +#include <linux/ioctl.h> + +#define AKM8973_I2C_NAME "ak8973b" + +#define AKMIO 0xA1 + +/* IOCTLs for AKM library */ +#define ECS_IOCTL_WRITE _IOW(AKMIO, 0x01, char*) +#define ECS_IOCTL_READ _IOWR(AKMIO, 0x02, char*) +#define ECS_IOCTL_RESET _IO(AKMIO, 0x03) +#define ECS_IOCTL_SET_MODE _IOW(AKMIO, 0x04, short) +#define ECS_IOCTL_GETDATA _IOR(AKMIO, 0x05, char[SENSOR_DATA_SIZE]) +#define ECS_IOCTL_SET_YPR _IOW(AKMIO, 0x06, short[12]) +#define ECS_IOCTL_GET_OPEN_STATUS _IOR(AKMIO, 0x07, int) +#define ECS_IOCTL_GET_CLOSE_STATUS _IOR(AKMIO, 0x08, int) +#define ECS_IOCTL_GET_DELAY _IOR(AKMIO, 0x30, int64_t) +#define ECS_IOCTL_GET_PROJECT_NAME _IOR(AKMIO, 0x0D, char[64]) +#define ECS_IOCTL_GET_MATRIX _IOR(AKMIO, 0x0E, short [4][3][3]) + +/* IOCTLs for APPs */ +#define ECS_IOCTL_APP_SET_MODE _IOW(AKMIO, 0x10, short) +#define ECS_IOCTL_APP_SET_MFLAG _IOW(AKMIO, 0x11, short) +#define ECS_IOCTL_APP_GET_MFLAG _IOW(AKMIO, 0x12, short) +#define ECS_IOCTL_APP_SET_AFLAG _IOW(AKMIO, 0x13, short) +#define ECS_IOCTL_APP_GET_AFLAG _IOR(AKMIO, 0x14, short) +#define ECS_IOCTL_APP_SET_TFLAG _IOR(AKMIO, 0x15, short) +#define ECS_IOCTL_APP_GET_TFLAG _IOR(AKMIO, 0x16, short) +#define ECS_IOCTL_APP_RESET_PEDOMETER _IO(AKMIO, 0x17) +#define ECS_IOCTL_APP_SET_DELAY _IOW(AKMIO, 0x18, int64_t) +#define ECS_IOCTL_APP_GET_DELAY ECS_IOCTL_GET_DELAY + +/* Set raw magnetic vector flag */ +#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short) + +/* Get raw magnetic vector flag */ +#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short) + +struct akm8973_platform_data { + short layouts[4][3][3]; + char project_name[64]; + int gpio_RST; + int gpio_INT; +}; + +#endif diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp index d5ee60c..e7e48ec 100644 --- a/libsensors/sensors.cpp +++ b/libsensors/sensors.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#define ALOG_TAG "Sensors" + #include <hardware/sensors.h> #include <fcntl.h> #include <errno.h> @@ -22,6 +24,7 @@ #include <poll.h> #include <pthread.h> #include <stdlib.h> +#include <cstring> #include <linux/input.h> @@ -71,38 +74,38 @@ static const struct sensor_t sSensorList[] = { { "LSM330DLC Acceleration Sensor", "STMicroelectronics", 1, SENSORS_ACCELERATION_HANDLE, - SENSOR_TYPE_ACCELEROMETER, RANGE_A, CONVERT_A, 0.23f, 20000, 0, 0, - SENSOR_STRING_TYPE_ACCELEROMETER, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, { } }, + SENSOR_TYPE_ACCELEROMETER, RANGE_A, CONVERT_A, 0.23f, 20000, 0, 0, + SENSOR_STRING_TYPE_ACCELEROMETER, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, { } }, { "AK8963C Magnetic field Sensor", "Asahi Kasei Microdevices", 1, SENSORS_MAGNETIC_FIELD_HANDLE, - SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, CONVERT_M, 6.8f, 16667, 0, 0, - SENSOR_STRING_TYPE_MAGNETIC_FIELD, 0, 0, SENSOR_FLAG_CONTINUOUS_MODE, { } }, + SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, CONVERT_M, 6.8f, 16667, 0, 0, + SENSOR_STRING_TYPE_MAGNETIC_FIELD, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, { } }, { "AK8963C Orientation Sensor", "Asahi Kasei Microdevices", 1, SENSORS_ORIENTATION_HANDLE, - SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.8f, 16667, 0, 0, - SENSOR_STRING_TYPE_ORIENTATION, 0, 200, SENSOR_FLAG_CONTINUOUS_MODE, { } }, + SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.8f, 16667, 0, 0, + SENSOR_STRING_TYPE_ORIENTATION, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, { } }, { "LSM330DLC Gyroscope Sensor", "STMicroelectronics", 1, SENSORS_GYROSCOPE_HANDLE, - SENSOR_TYPE_GYROSCOPE, RANGE_GYRO, CONVERT_GYRO, 6.1f, 1190, 0, 0, - SENSOR_STRING_TYPE_GYROSCOPE, 0, 200, SENSOR_FLAG_CONTINUOUS_MODE, { } }, + SENSOR_TYPE_GYROSCOPE, RANGE_GYRO, CONVERT_GYRO, 6.1f, 1190, 0, 0, + SENSOR_STRING_TYPE_GYROSCOPE, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, { } }, { "BMP182 Pressure sensor", "Bosch", 1, SENSORS_PRESSURE_HANDLE, SENSOR_TYPE_PRESSURE, 1100.0f, 0.01f, 0.06f, 50000, 0, 0, - SENSOR_STRING_TYPE_PRESSURE, 0, 200, SENSOR_FLAG_CONTINUOUS_MODE, { } }, + SENSOR_STRING_TYPE_PRESSURE, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, { } }, { "CM36651 Proximity Sensor", "Capella Microsystems", 1, SENSORS_PROXIMITY_HANDLE, SENSOR_TYPE_PROXIMITY, 5.0f, 5.0f, 0.75f, 0, 0, 0, - SENSOR_STRING_TYPE_PROXIMITY, 0, 0, SENSOR_FLAG_WAKE_UP | SENSOR_FLAG_ON_CHANGE_MODE, { } }, + SENSOR_STRING_TYPE_PROXIMITY, "", 0, SENSOR_FLAG_WAKE_UP, { } }, { "CM36651 Light Sensor", "Capella Microsystems", 1, SENSORS_LIGHT_HANDLE, - SENSOR_TYPE_LIGHT, 10240.0f, 1.0f, 0.75f, 0, 0, 0, - SENSOR_STRING_TYPE_LIGHT, 0, 0, SENSOR_FLAG_ON_CHANGE_MODE, { } }, + SENSOR_TYPE_LIGHT, 10240.0f, 1.0f, 0.75f, 0, 0, 0, + SENSOR_STRING_TYPE_LIGHT, "", 0, SENSOR_FLAG_CONTINUOUS_MODE, { } }, }; @@ -184,7 +187,7 @@ private: case ID_PR: return pressure; } - return -1; + return -EINVAL; } }; @@ -245,12 +248,10 @@ sensors_poll_context_t::~sensors_poll_context_t() { } int sensors_poll_context_t::activate(int handle, int enabled) { - if (!mInitialized) - return -EINVAL; + if (!mInitialized) return -EINVAL; int index = handleToDriver(handle); - ALOGI("Sensors: enable(%d) handle: %i (index:%i)", enabled, handle, index); - if (index < 0) - return -EINVAL; + //ALOGI("Sensors: handle: %i", handle); + if (index < 0) return index; int err = mSensors[index]->enable(handle, enabled); if (enabled && !err) { const char wakeMessage(WAKE_MESSAGE); diff --git a/libsensors/sensors.h b/libsensors/sensors.h index 5ad1b80..a415253 100644 --- a/libsensors/sensors.h +++ b/libsensors/sensors.h @@ -84,6 +84,7 @@ const int ssp_sensors[] = { #define EVENT_TYPE_MAGV_X ABS_RX // 3 #define EVENT_TYPE_MAGV_Y ABS_RY // 4 #define EVENT_TYPE_MAGV_Z ABS_RZ // 5 +#define EVENT_TYPE_MAGV_ACC ABS_WHEEL // 8 #define EVENT_TYPE_TEMPERATURE ABS_THROTTLE #define EVENT_TYPE_STEP_COUNT ABS_GAS |