diff options
author | Arve Hjønnevåg <arve@android.com> | 2011-08-17 17:51:47 -0700 |
---|---|---|
committer | Arve Hjønnevåg <arve@android.com> | 2011-08-18 15:41:14 -0700 |
commit | 47bb9acbaf953df46a7f7469927136b2cfd618a2 (patch) | |
tree | 317d88075ed63e554cc04aa20de78d252dfa7f7e /libsensors | |
parent | 40155765aa0eb3832ef83fd0a53257d84e553e62 (diff) | |
download | device_samsung_tuna-47bb9acbaf953df46a7f7469927136b2cfd618a2.zip device_samsung_tuna-47bb9acbaf953df46a7f7469927136b2cfd618a2.tar.gz device_samsung_tuna-47bb9acbaf953df46a7f7469927136b2cfd618a2.tar.bz2 |
sensors: Let MPLSensor populate the sensor list with the sensors it provides
If the mpl library is not available we do not want the fused sensors from
MPLSensor.
Change-Id: If2ac70188db8c0319cc24dc546d60a34de1c986d
Diffstat (limited to 'libsensors')
-rw-r--r-- | libsensors/sensors.cpp | 39 | ||||
-rw-r--r-- | libsensors/sensors.h | 15 |
2 files changed, 10 insertions, 44 deletions
diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp index ab2c571..4002006 100644 --- a/libsensors/sensors.cpp +++ b/libsensors/sensors.cpp @@ -74,35 +74,8 @@ /*****************************************************************************/ /* The SENSORS Module */ -static const struct sensor_t sSensorList[] = { - { "MPL rotation vector", - "Invensense", - 1, SENSORS_ROTATION_VECTOR_HANDLE, - SENSOR_TYPE_ROTATION_VECTOR, 10240.0f, 1.0f, 0.5f, 20000,{ } }, - { "MPL linear accel", - "Invensense", - 1, SENSORS_LINEAR_ACCEL_HANDLE, - SENSOR_TYPE_LINEAR_ACCELERATION, 10240.0f, 1.0f, 0.5f, 20000,{ } }, - { "MPL gravity", - "Invensense", - 1, SENSORS_GRAVITY_HANDLE, - SENSOR_TYPE_GRAVITY, 10240.0f, 1.0f, 0.5f, 20000,{ } }, - { "MPL Gyro", - "Invensense", - 1, SENSORS_GYROSCOPE_HANDLE, - SENSOR_TYPE_GYROSCOPE, 10240.0f, 1.0f, 0.5f, 20000,{ } }, - { "MPL accel", - "Invensense", - 1, SENSORS_ACCELERATION_HANDLE, - SENSOR_TYPE_ACCELEROMETER, 10240.0f, 1.0f, 0.5f, 20000,{ } }, - { "MPL magnetic field", - "Invensense", - 1, SENSORS_MAGNETIC_FIELD_HANDLE, - SENSOR_TYPE_MAGNETIC_FIELD, 10240.0f, 1.0f, 0.5f, 20000,{ } }, - { "MPL Orientation (android deprecated format)", - "Invensense", - 1, SENSORS_ORIENTATION_HANDLE, - SENSOR_TYPE_ORIENTATION, 360.0f, 1.0f, 9.7f, 20000,{ } }, +#define LOCAL_SENSORS (3) +static struct sensor_t sSensorList[LOCAL_SENSORS + MPLSensor::numSensors] = { { "GP2A Light sensor", "Sharp", 1, SENSORS_LIGHT_HANDLE, @@ -116,7 +89,7 @@ static const struct sensor_t sSensorList[] = { 1, SENSORS_PRESSURE_HANDLE, SENSOR_TYPE_PRESSURE, 1100.0f, 0.01f, 0.67f, 20000, { } }, }; - +static int numSensors = LOCAL_SENSORS; static int open_sensors(const struct hw_module_t* module, const char* id, struct hw_device_t** device); @@ -126,7 +99,7 @@ static int sensors__get_sensors_list(struct sensors_module_t* module, struct sensor_t const** list) { *list = sSensorList; - return ARRAY_SIZE(sSensorList); + return numSensors; } static struct hw_module_methods_t sensors_module_methods = { @@ -204,6 +177,10 @@ sensors_poll_context_t::sensors_poll_context_t() FUNC_LOG; MPLSensor* p_mplsen = new MPLSensor(); setCallbackObject(p_mplsen); //setup the callback object for handing mpl callbacks + numSensors = + LOCAL_SENSORS + + p_mplsen->populateSensorList(sSensorList + LOCAL_SENSORS, + sizeof(sSensorList[0]) * (ARRAY_SIZE(sSensorList) - LOCAL_SENSORS)); mSensors[mpl] = p_mplsen; mPollFds[mpl].fd = mSensors[mpl]->getFd(); diff --git a/libsensors/sensors.h b/libsensors/sensors.h index 49610ca..a7e077d 100644 --- a/libsensors/sensors.h +++ b/libsensors/sensors.h @@ -33,19 +33,8 @@ __BEGIN_DECLS #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) -/* - * The MPL-supported sensors need to have same IDs as in Invensense .so - * (from ID_MPL_BASE up to ID_O) - */ -#define ID_MPL_BASE (0) -#define ID_RV (ID_MPL_BASE) -#define ID_LA (ID_RV + 1) -#define ID_GR (ID_LA + 1) -#define ID_GY (ID_GR + 1) -#define ID_A (ID_GY + 1) -#define ID_M (ID_A + 1) -#define ID_O (ID_M + 1) -#define ID_L (ID_O + 1) +#define ID_SAMSUNG_BASE (0x1000) +#define ID_L (ID_SAMSUNG_BASE) #define ID_P (ID_L + 1) #define ID_PR (ID_P + 1) |