OSDN Git Service

Min/Max delay for Light and Temperature
[android-x86/hardware-intel-libsensors.git] / control.c
index 7ec8bca..7d942fd 100644 (file)
--- a/control.c
+++ b/control.c
@@ -377,7 +377,9 @@ static void* acquisition_routine (void* param)
        struct timespec target_time;
        int64_t period;
 
-       ALOGV("Entering data acquisition thread for sensor %d\n", s);
+       ALOGI("Entering data acquisition thread S%d (%s): rate(%f), minDelay(%ld), maxDelay(%ld)\n",
+               s, sensor_info[s].friendly_name, sensor_info[s].sampling_rate,
+               sensor_desc[s].minDelay, sensor_desc[s].maxDelay);
 
        if (s < 0 || s >= sensor_count) {
                ALOGE("Invalid sensor handle!\n");
@@ -601,6 +603,10 @@ int sensor_activate(int s, int enabled)
                        free(sensor_info[s].history);
                        sensor_info[s].history = NULL;
                        sensor_info[s].history_size = 0;
+                       if (sensor_info[s].history_sum) {
+                               free(sensor_info[s].history_sum);
+                               sensor_info[s].history_sum = NULL;
+                       }
                }
 
                return 0;
@@ -739,7 +745,16 @@ void set_report_ts(int s, int64_t ts)
 {
        int64_t maxTs, period;
 
-       if (sensor_info[s].report_ts && sensor_info[s].sampling_rate) {
+       /*
+       *  A bit of a hack to please a bunch of cts tests. They
+       *  expect the timestamp to be exacly according to the set-up
+       *  frequency but if we're simply getting the timestamp at hal level
+       *  this may not be the case. Perhaps we'll get rid of this when
+       *  we'll be reading the timestamp from the iio channel for all sensors
+       */
+       if (sensor_info[s].report_ts && sensor_info[s].sampling_rate &&
+               REPORTING_MODE(sensor_desc[s].flags) == SENSOR_FLAG_CONTINUOUS_MODE)
+       {
                period = (int64_t) (1000000000LL / sensor_info[s].sampling_rate);
                maxTs = sensor_info[s].report_ts + period;
                sensor_info[s].report_ts = (ts < maxTs ? ts : maxTs);
@@ -899,9 +914,8 @@ static void synthetize_duplicate_samples (void)
                if (!sensor_info[s].enable_count)
                        continue;
 
-               /* If the sensor can generate duplicates, leave it alone */
-               if (!(sensor_info[s].quirks & QUIRK_TERSE_DRIVER) &&
-                       sensor_info[s].selected_trigger !=
+               /* If the sensor is continuously firing, leave it alone */
+               if (    sensor_info[s].selected_trigger !=
                        sensor_info[s].motion_trigger_name)
                        continue;
 
@@ -971,10 +985,9 @@ static int get_poll_wait_timeout (void)
         */
        for (s=0; s<sensor_count; s++)
                if (sensor_info[s].enable_count &&
-                   ((sensor_info[s].quirks & QUIRK_TERSE_DRIVER) ||
-                     sensor_info[s].selected_trigger ==
-                     sensor_info[s].motion_trigger_name) &&
-                    sensor_info[s].sampling_rate) {
+                   sensor_info[s].selected_trigger ==
+                   sensor_info[s].motion_trigger_name &&
+                   sensor_info[s].sampling_rate) {
                        period = (int64_t) (1000000000.0 /
                                                sensor_info[s].sampling_rate);