diff options
author | Ed Heyl <edheyl@google.com> | 2010-11-15 18:57:38 -0800 |
---|---|---|
committer | Ed Heyl <edheyl@google.com> | 2010-11-15 18:57:38 -0800 |
commit | 339031d332706f21cbce560ca379e7624cad8316 (patch) | |
tree | c5da8bd2e9a5a35f8711f5efbc354cb5b59912ae /libsensors/AkmSensor.cpp | |
parent | fc8ea6902972c12e26bc5f8a488bc228ce379b17 (diff) | |
download | device_samsung_crespo-339031d332706f21cbce560ca379e7624cad8316.zip device_samsung_crespo-339031d332706f21cbce560ca379e7624cad8316.tar.gz device_samsung_crespo-339031d332706f21cbce560ca379e7624cad8316.tar.bz2 |
Revert "Revert "S5PC11X: libsensor: Changes to match libakm change""
This reverts commit e3d3b3173b5258f3629e1e2d0c1692270262e8c1.
Diffstat (limited to 'libsensors/AkmSensor.cpp')
-rw-r--r-- | libsensors/AkmSensor.cpp | 43 |
1 files changed, 12 insertions, 31 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() |