OSDN Git Service

libsensors: Allow IIO max sample rate to be configured via properties
authorAndy Ross <andy.ross@windriver.com>
Thu, 26 Sep 2013 20:07:35 +0000 (13:07 -0700)
committerMattias Pettersson <mattias.pettersson@intel.com>
Wed, 4 Dec 2013 14:13:12 +0000 (15:13 +0100)
Different hubs have different behavior.  Really we want to probe this
out of the hardware, but for HID sensors on I2C (as opposed to USB)
userspace doesn't get access to the descriptor right now.

Change-Id: I8bcd077509b43bba6025ca5f55ba9373db89cd8b
For: AXIA-3287
Signed-off-by: Andy Ross <andy.ross@windriver.com>
Reviewed-on: https://otc-android.intel.com/gerrit/22151
Tested-by: jenkins autobuilder
Reviewed-by: Russell Webb <russell.webb@intel.com>
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);