OSDN Git Service

libsensors: Allow IIO max sample rate to be configured via properties
[android-x86/hardware-intel-libsensors.git] / common / libsensors / SensorIIODev.cpp
index faf7fdd..dfc2638 100644 (file)
@@ -16,6 +16,7 @@
 #include <dirent.h>
 #include <fcntl.h>
 #include <cutils/log.h>
+#include <cutils/properties.h>
 #include "SensorIIODev.h"
 #include "Helpers.h"
 
@@ -65,6 +66,15 @@ int SensorIIODev::discover()
     int status;
     int ret;
 
+    // Allow overriding sample_delay_min_ms via properties using
+    // the IIO device name.  e.g.:
+    //     ro.sys.sensors_accel_3d_samp_min_ms = 16
+    char sampmin[PROPERTY_VALUE_MAX];
+    std::string pn = "ro.sys.sensors_" + device_name + "_samp_min_ms";
+    property_get(pn.c_str(), sampmin, "");
+    if(*sampmin)
+        sample_delay_min_ms = strtol(sampmin, NULL, 10);
+
     ALOGD(">>%s discover", __func__);
     for (cnt = 0; cnt < retry_count; cnt++) {
         status = ParseIIODirectory(device_name);