OSDN Git Service

iio-sensors: Add suport for STEP_DETECTOR sensor
[android-x86/hardware-intel-libsensors.git] / entry.c
diff --git a/entry.c b/entry.c
index baa8017..9aaf0ca 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -31,7 +31,7 @@ static int activate (__attribute__((unused)) struct sensors_poll_device_t* dev,
        if (enabled && sensor_get_quirks(handle) & QUIRK_INITIAL_RATE) {
                ALOGI("Forcing initial sampling rate\n");
                sensor_activate(handle, 1, 0);
-               sensor_set_delay(handle, 100000000L);   /* Start with 100 ms */
+               sensor_set_delay(handle, 100000000);    /* Start with 100 ms */
                sensor_activate(handle, 0, 0);
 
                /* Clear flag for this sensor as do this only once */
@@ -45,9 +45,19 @@ static int activate (__attribute__((unused)) struct sensors_poll_device_t* dev,
 static int set_delay (__attribute__((unused)) struct sensors_poll_device_t* dev,
                      int handle, int64_t ns)
 {
+       int i;
+
        if (init_count == 0 || handle < 0 || handle >= sensor_count)
                return -EINVAL;
 
+       /*
+        * If this sensor relies on other sensors, try to propagate the
+        * requested sampling rate to the base sensors.
+        */
+
+       for (i=0; i<sensor[handle].base_count; i++)
+               sensor_set_delay(sensor[handle].base[i], ns);
+
        return sensor_set_delay(handle, ns);
 }