OSDN Git Service

Don't let the timestamp get too far behind
authorAdriana Reus <adriana.reus@intel.com>
Mon, 10 Nov 2014 17:56:36 +0000 (19:56 +0200)
committerAdriana Reus <adriana.reus@intel.com>
Thu, 13 Nov 2014 12:47:03 +0000 (14:47 +0200)
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-3896
Change-Id: I151d9cc964524998fb4fa5dc388395e5e1857eb7
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
control.c

index 839fdf0..9565f46 100644 (file)
--- a/control.c
+++ b/control.c
@@ -747,6 +747,7 @@ static void enable_motion_trigger (int dev_num)
  *     FrequencyVerification.java: (0.9)*(expected freq) => (th <= 1.1111)
  */
 #define THRESHOLD 1.10
+#define MAX_DELAY 500000000 /* 500 ms */
 void set_report_ts(int s, int64_t ts)
 {
        int64_t maxTs, period;
@@ -765,6 +766,9 @@ void set_report_ts(int s, int64_t ts)
        {
                period = (int64_t) (1000000000LL / sensor_info[s].sampling_rate);
                maxTs = sensor_info[s].report_ts + (is_accel ? 1 : THRESHOLD) * period;
+               /* If we're too far behind get back on track */
+               if (ts - maxTs >= MAX_DELAY)
+                       maxTs = ts;
                sensor_info[s].report_ts = (ts < maxTs ? ts : maxTs);
        } else {
                sensor_info[s].report_ts = ts;