summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawit Pornkitprasan <p.pawit@gmail.com>2012-05-16 16:27:37 +0700
committerPawit Pornkitprasan <p.pawit@gmail.com>2012-05-16 16:39:38 +0700
commit0545906db2463684887ee84ab2775930c37f5128 (patch)
tree597212d936fc40ed0703b51a4a6062f7c7a24580
parent3899679acadf3a64a1a72dcaf15e983b15d2231d (diff)
downloaddevice_samsung_aries-common-0545906db2463684887ee84ab2775930c37f5128.zip
device_samsung_aries-common-0545906db2463684887ee84ab2775930c37f5128.tar.gz
device_samsung_aries-common-0545906db2463684887ee84ab2775930c37f5128.tar.bz2
libsensors: Fix setting delay for compass sensor
The kernel driver only supports specific values and setting the delay will fail if other values are choosen Thanks to burakgon for reporting Change-Id: Ia3a2b73bad13cc8da75e5ce654962ae192af9a4c
-rw-r--r--libsensors/CompassSensor.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/libsensors/CompassSensor.cpp b/libsensors/CompassSensor.cpp
index f4b3685..c98d068 100644
--- a/libsensors/CompassSensor.cpp
+++ b/libsensors/CompassSensor.cpp
@@ -106,19 +106,29 @@ bool CompassSensor::hasPendingEvents() const {
int CompassSensor::setDelay(int32_t handle, int64_t ns)
{
- LOGD("CompassSensor::~setDelay(%d, %lld)", handle, ns);
-
int fd;
-
- if (ns < 10000000) {
- ns = 10000000; // Minimum on stock
+ int val;
+
+ // Kernel driver only support specific values
+ if (ns < 20000000L) {
+ val = 1;
+ } else if (ns < 60000000L) {
+ val = 20;
+ } else if (ns < 200000000L) {
+ val = 60;
+ } else if (ns < 1000000000L) {
+ val = 200;
+ } else {
+ val = 1000;
}
+ LOGD("CompassSensor::~setDelay(%d, %lld) val = %d", handle, ns, val);
+
strcpy(&input_sysfs_path[input_sysfs_path_len], "delay");
fd = open(input_sysfs_path, O_RDWR);
if (fd >= 0) {
char buf[80];
- sprintf(buf, "%lld", ns / 10000000 * 10); // Some flooring to match stock value
+ sprintf(buf, "%d", val);
write(fd, buf, strlen(buf)+1);
close(fd);
return 0;