diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2011-11-26 08:49:42 +0700 |
---|---|---|
committer | Pawit Pornkitprasan <p.pawit@gmail.com> | 2011-11-26 08:50:57 +0700 |
commit | 241d5c032e64569128eb11a754cb6ee359b25380 (patch) | |
tree | fefe4bbbf7623fa78edf43fca40cd930ac5674ad | |
parent | 9a6c28ad416af2d160f83b3b7706c19825ebd342 (diff) | |
download | device_samsung_aries-common-241d5c032e64569128eb11a754cb6ee359b25380.zip device_samsung_aries-common-241d5c032e64569128eb11a754cb6ee359b25380.tar.gz device_samsung_aries-common-241d5c032e64569128eb11a754cb6ee359b25380.tar.bz2 |
aries-common: Implement libsensors setDelay
Change-Id: Ibc1bae37d3fd791eb7b24824a899ba3932e9c5e8
-rw-r--r-- | libsensors/CompassSensor.cpp | 24 | ||||
-rw-r--r-- | libsensors/OrientationSensor.cpp | 24 | ||||
-rw-r--r-- | libsensors/Smb380Sensor.cpp | 24 | ||||
-rw-r--r-- | ueventd.aries.rc | 1 |
4 files changed, 55 insertions, 18 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;
}
diff --git a/libsensors/OrientationSensor.cpp b/libsensors/OrientationSensor.cpp index 3fb5d29..2925ba7 100644 --- a/libsensors/OrientationSensor.cpp +++ b/libsensors/OrientationSensor.cpp @@ -103,12 +103,24 @@ bool OrientationSensor::hasPendingEvents() const { int OrientationSensor::setDelay(int32_t handle, int64_t ns) { - LOGD("OrientationSensor::~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("OrientationSensor::~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; } diff --git a/libsensors/Smb380Sensor.cpp b/libsensors/Smb380Sensor.cpp index 3de4d9b..feb1b22 100644 --- a/libsensors/Smb380Sensor.cpp +++ b/libsensors/Smb380Sensor.cpp @@ -105,12 +105,24 @@ bool Smb380Sensor::hasPendingEvents() const { int Smb380Sensor::setDelay(int32_t handle, int64_t ns)
{
- LOGD("Smb380Sensor::~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("Smb380Sensor::~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;
}
diff --git a/ueventd.aries.rc b/ueventd.aries.rc index 9b0998d..9e8441c 100644 --- a/ueventd.aries.rc +++ b/ueventd.aries.rc @@ -18,6 +18,7 @@ /dev/yamaha_compass 0660 system system /dev/akm8973 0660 system system /dev/accelerometer 0660 system system +/sys/devices/virtual/input/input* delay 0660 root input # for GPS /dev/s3c2410_serial1 0600 gps gps |