summaryrefslogtreecommitdiffstats
path: root/libsensors/Smb380Sensor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsensors/Smb380Sensor.cpp')
-rw-r--r--libsensors/Smb380Sensor.cpp24
1 files changed, 18 insertions, 6 deletions
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;
}