summaryrefslogtreecommitdiffstats
path: root/libsensors/CompassSensor.cpp
diff options
context:
space:
mode:
authorPawit Pornkitprasan <p.pawit@gmail.com>2011-11-26 08:49:42 +0700
committerPawit Pornkitprasan <p.pawit@gmail.com>2011-11-26 10:28:33 +0700
commit5cdad8ef873758b192c20d5eeb4b2afd86068e2b (patch)
tree9c0e9b34b186825140fd5efc68092244e860613b /libsensors/CompassSensor.cpp
parent9a6854703191d9d35d06c17e00f1f4eb398d3db5 (diff)
downloaddevice_samsung_aries-common-5cdad8ef873758b192c20d5eeb4b2afd86068e2b.zip
device_samsung_aries-common-5cdad8ef873758b192c20d5eeb4b2afd86068e2b.tar.gz
device_samsung_aries-common-5cdad8ef873758b192c20d5eeb4b2afd86068e2b.tar.bz2
aries-common: Implement libsensors setDelay
Change-Id: Ibc1bae37d3fd791eb7b24824a899ba3932e9c5e8 (cherry picked from commit 241d5c032e64569128eb11a754cb6ee359b25380)
Diffstat (limited to 'libsensors/CompassSensor.cpp')
-rw-r--r--libsensors/CompassSensor.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/libsensors/CompassSensor.cpp b/libsensors/CompassSensor.cpp
index c4b6822..cea0249 100644
--- a/libsensors/CompassSensor.cpp
+++ b/libsensors/CompassSensor.cpp
@@ -106,12 +106,24 @@ bool CompassSensor::hasPendingEvents() const {
int CompassSensor::setDelay(int32_t handle, int64_t ns)
{
- LOGD("CompassSensor::~setDelay(%d, %d)", handle, ns);
- /* FIXME needs changes to the kernel driver.
- We need to add a IOCTL that can set the samplingrate
- the driver in ther kernel supports this allready only need
- to add a IOCTL on both sides for that*/
- return 0;
+ LOGD("CompassSensor::~setDelay(%d, %lld)", handle, ns);
+
+ int fd;
+
+ if (ns < 10000000) {
+ ns = 10000000; // Minimum on stock
+ }
+
+ 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
+ write(fd, buf, strlen(buf)+1);
+ close(fd);
+ return 0;
+ }
+ return -1;
}