diff options
author | Mike J. Chen <mjchen@sta.samsung.com> | 2010-11-11 17:31:07 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-11-11 20:02:04 -0800 |
commit | 749e2d79ec72c186019456f60ce7f3dd18b2f68b (patch) | |
tree | bec8428878a25a30e925dc566fd410c1004c7fb6 /libsensors | |
parent | ae5be4a124733403d5025b536bf8271da4c16c41 (diff) | |
download | device_samsung_crespo-749e2d79ec72c186019456f60ce7f3dd18b2f68b.zip device_samsung_crespo-749e2d79ec72c186019456f60ce7f3dd18b2f68b.tar.gz device_samsung_crespo-749e2d79ec72c186019456f60ce7f3dd18b2f68b.tar.bz2 |
S5PC11X: libsensor: Changes to match libakm change
Changes to match libakm change to get raw acc data from
driver and to allow setting acc driver delay separately
from mag/orientation driver.
Change-Id: I7cfa7f5076e0735c17931558687c4cdf96959ac3
Signed-off-by: Mike J. Chen <mjchen@sta.samsung.com>
Diffstat (limited to 'libsensors')
-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, 21 insertions, 43 deletions
diff --git a/libsensors/AkmSensor.cpp b/libsensors/AkmSensor.cpp index 68d2fc2..32bdd6d 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)(uint64_t delay); +int (*akm_set_delay)(uint32_t sensor_type, 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(uint64_t delay) { +int stub_set_delay(uint32_t sensor_type, uint64_t delay) { return -ENODEV; } @@ -79,9 +79,6 @@ 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; @@ -170,7 +167,6 @@ int AkmSensor::enable(int32_t handle, int en) if (!err) { mEnabled &= ~(1<<what); mEnabled |= (uint32_t(flags)<<what); - update_delay(); } } return err; @@ -178,36 +174,21 @@ int AkmSensor::enable(int32_t handle, int en) int AkmSensor::setDelay(int32_t handle, int64_t ns) { - int what = -1; - switch (handle) { - case ID_A: what = Accelerometer; break; - case ID_M: what = MagneticField; break; - case ID_O: what = Orientation; break; - } - - if (uint32_t(what) >= numSensors) - return -EINVAL; + uint32_t sensor_type = 0; if (ns < 0) return -EINVAL; - 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)); + 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; } - return 0; + + if (sensor_type == 0) + return -EINVAL; + + return akm_set_delay(sensor_type, ns); } int AkmSensor::loadAKMLibrary() diff --git a/libsensors/AkmSensor.h b/libsensors/AkmSensor.h index f637284..44214e0 100644 --- a/libsensors/AkmSensor.h +++ b/libsensors/AkmSensor.h @@ -49,14 +49,12 @@ 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 2f85225..4ba1265 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, RESOLUTION_A, 0.23f, 20000, { } }, + SENSOR_TYPE_ACCELEROMETER, RANGE_A, CONVERT_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, 30000, { } }, + SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, CONVERT_M, 6.8f, 16667, { } }, { "AK8973 Orientation sensor", "Asahi Kasei Microdevices", 1, SENSORS_ORIENTATION_HANDLE, - SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.8f, 30000, { } }, + SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.8f, 16667, { } }, { "GP2A Light sensor", "Sharp", 1, SENSORS_LIGHT_HANDLE, diff --git a/libsensors/sensors.h b/libsensors/sensors.h index 20884b6..4b12606 100644 --- a/libsensors/sensors.h +++ b/libsensors/sensors.h @@ -76,17 +76,16 @@ __BEGIN_DECLS #define EVENT_TYPE_GYRO_Z REL_RZ -// 720 LSG = 1G -#define LSG (720.0f) -#define NUMOFACCDATA 8 +// 64 LSB = 1G for KR3DM +#define LSB (64.0f) +#define NUMOFACCDATA (8.0f) // conversion of acceleration data to SI units (m/s^2) #define RANGE_A (2*GRAVITY_EARTH) -#define RESOLUTION_A (RANGE_A/(256*NUMOFACCDATA)) -#define CONVERT_A (GRAVITY_EARTH / LSG / NUMOFACCDATA) +#define CONVERT_A (GRAVITY_EARTH / LSB / 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) |