diff options
author | Mathias Agopian <mathias@google.com> | 2010-11-12 00:54:09 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-11-12 00:54:09 -0800 |
commit | e3d3b3173b5258f3629e1e2d0c1692270262e8c1 (patch) | |
tree | 30fb552e507afc788e9cab6d2364a9e22256cdfb | |
parent | 9801b8be94bf338ec390e8b8fe0d87532e67cfdf (diff) | |
download | device_samsung_crespo-e3d3b3173b5258f3629e1e2d0c1692270262e8c1.zip device_samsung_crespo-e3d3b3173b5258f3629e1e2d0c1692270262e8c1.tar.gz device_samsung_crespo-e3d3b3173b5258f3629e1e2d0c1692270262e8c1.tar.bz2 |
Revert "S5PC11X: libsensor: Changes to match libakm change"
This reverts commit 749e2d79ec72c186019456f60ce7f3dd18b2f68b.
-rw-r--r-- | libsensors/AkmSensor.cpp | 43 | ||||
-rw-r--r-- | libsensors/AkmSensor.h | 2 | ||||
-rw-r--r-- | libsensors/sensors.cpp | 6 | ||||
-rw-r--r-- | libsensors/sensors.h | 13 |
4 files changed, 43 insertions, 21 deletions
diff --git a/libsensors/AkmSensor.cpp b/libsensors/AkmSensor.cpp index 32bdd6d..68d2fc2 100644 --- a/libsensors/AkmSensor.cpp +++ b/libsensors/AkmSensor.cpp @@ -34,7 +34,7 @@ int (*akm_is_sensor_enabled)(uint32_t sensor_type); int (*akm_enable_sensor)(uint32_t sensor_type); int (*akm_disable_sensor)(uint32_t sensor_type); -int (*akm_set_delay)(uint32_t sensor_type, uint64_t delay); +int (*akm_set_delay)(uint64_t delay); int stub_is_sensor_enabled(uint32_t sensor_type) { return 0; @@ -44,7 +44,7 @@ int stub_enable_disable_sensor(uint32_t sensor_type) { return -ENODEV; } -int stub_set_delay(uint32_t sensor_type, uint64_t delay) { +int stub_set_delay(uint64_t delay) { return -ENODEV; } @@ -79,6 +79,9 @@ AkmSensor::AkmSensor() mPendingEvents[Orientation ].type = SENSOR_TYPE_ORIENTATION; mPendingEvents[Orientation ].orientation.status = SENSOR_STATUS_ACCURACY_HIGH; + for (int i=0 ; i<numSensors ; i++) + mDelays[i] = 200000000; // 200 ms by default + // read the actual value of all sensors if they're enabled already struct input_absinfo absinfo; short flags = 0; @@ -167,6 +170,7 @@ int AkmSensor::enable(int32_t handle, int en) if (!err) { mEnabled &= ~(1<<what); mEnabled |= (uint32_t(flags)<<what); + update_delay(); } } return err; @@ -174,21 +178,36 @@ int AkmSensor::enable(int32_t handle, int en) int AkmSensor::setDelay(int32_t handle, int64_t ns) { - uint32_t sensor_type = 0; - - if (ns < 0) - return -EINVAL; - + int what = -1; switch (handle) { - case ID_A: sensor_type = SENSOR_TYPE_ACCELEROMETER; break; - case ID_M: sensor_type = SENSOR_TYPE_MAGNETIC_FIELD; break; - case ID_O: sensor_type = SENSOR_TYPE_ORIENTATION; break; + case ID_A: what = Accelerometer; break; + case ID_M: what = MagneticField; break; + case ID_O: what = Orientation; break; } - if (sensor_type == 0) + if (uint32_t(what) >= numSensors) + return -EINVAL; + + if (ns < 0) return -EINVAL; - return akm_set_delay(sensor_type, 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; + } + } + return akm_set_delay(int64_t(wanted)); + } + return 0; } int AkmSensor::loadAKMLibrary() diff --git a/libsensors/AkmSensor.h b/libsensors/AkmSensor.h index 44214e0..f637284 100644 --- a/libsensors/AkmSensor.h +++ b/libsensors/AkmSensor.h @@ -49,12 +49,14 @@ public: void processEvent(int code, int value); private: + int update_delay(); int loadAKMLibrary(); void *mLibAKM; uint32_t mEnabled; uint32_t mPendingMask; InputEventCircularReader mInputReader; sensors_event_t mPendingEvents[numSensors]; + uint64_t mDelays[numSensors]; }; /*****************************************************************************/ diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp index 4ba1265..2f85225 100644 --- a/libsensors/sensors.cpp +++ b/libsensors/sensors.cpp @@ -70,15 +70,15 @@ static const struct sensor_t sSensorList[] = { { "KR3DM 3-axis Accelerometer", "STMicroelectronics", 1, SENSORS_ACCELERATION_HANDLE, - SENSOR_TYPE_ACCELEROMETER, RANGE_A, CONVERT_A, 0.23f, 20000, { } }, + SENSOR_TYPE_ACCELEROMETER, RANGE_A, RESOLUTION_A, 0.23f, 20000, { } }, { "AK8973 3-axis Magnetic field sensor", "Asahi Kasei Microdevices", 1, SENSORS_MAGNETIC_FIELD_HANDLE, - SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, CONVERT_M, 6.8f, 16667, { } }, + SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, CONVERT_M, 6.8f, 30000, { } }, { "AK8973 Orientation sensor", "Asahi Kasei Microdevices", 1, SENSORS_ORIENTATION_HANDLE, - SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.8f, 16667, { } }, + SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.8f, 30000, { } }, { "GP2A Light sensor", "Sharp", 1, SENSORS_LIGHT_HANDLE, diff --git a/libsensors/sensors.h b/libsensors/sensors.h index 4b12606..20884b6 100644 --- a/libsensors/sensors.h +++ b/libsensors/sensors.h @@ -76,16 +76,17 @@ __BEGIN_DECLS #define EVENT_TYPE_GYRO_Z REL_RZ -// 64 LSB = 1G for KR3DM -#define LSB (64.0f) -#define NUMOFACCDATA (8.0f) +// 720 LSG = 1G +#define LSG (720.0f) +#define NUMOFACCDATA 8 // conversion of acceleration data to SI units (m/s^2) #define RANGE_A (2*GRAVITY_EARTH) -#define CONVERT_A (GRAVITY_EARTH / LSB / NUMOFACCDATA) +#define RESOLUTION_A (RANGE_A/(256*NUMOFACCDATA)) +#define CONVERT_A (GRAVITY_EARTH / LSG / NUMOFACCDATA) #define CONVERT_A_X (CONVERT_A) -#define CONVERT_A_Y (CONVERT_A) -#define CONVERT_A_Z (CONVERT_A) +#define CONVERT_A_Y (-CONVERT_A) +#define CONVERT_A_Z (-CONVERT_A) // conversion of magnetic data to uT units #define CONVERT_M (1.0f/16.0f) |