OSDN Git Service

Reinstate monotonic timestamp in data acquisition threads
[android-x86/hardware-intel-libsensors.git] / common.h
index 48e2124..f07d364 100644 (file)
--- a/common.h
+++ b/common.h
 
 #define PROP_BASE      "ro.iio.%s.%s" /* Note: PROPERTY_KEY_MAX is small */
 
-#define MAX_EVENTS 400         /* 400 Hz */
 #define MAX_TYPE_SPEC_LEN 32   /* Channel type spec len; ex: "le:u10/16>>0" */
 #define MAX_SENSOR_REPORT_SIZE 32      /* Sensor report buffer size */
+#define MAX_DEVICE_REPORT_SIZE 32      /* iio device scan buffer size */
 
 #define MAX_NAME_SIZE          32
 
-#define MIN_SAMPLES 5
-
 #define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])
 #define REPORTING_MODE(x)      ((x) & 0x06)
 
@@ -101,6 +99,15 @@ struct sample_ops_t
        int (*finalize)(int s, struct sensors_event_t* data);
 };
 
+/*
+ * Whenever we have sensor data recorded for a sensor in the associated
+ * sensor_info cell, its report_pending field is set to a non-zero value
+ * indicating how we got this data.
+ */
+#define DATA_TRIGGER   1       /* From /dev/iio:device fd              */
+#define DATA_SYSFS     2       /* Through polling                      */
+#define DATA_DUPLICATE 3       /* Duplicate of triggered motion sample */
+
 struct sensor_info_t
 {
        char friendly_name[MAX_NAME_SIZE];      /* ex: Accelerometer         */
@@ -129,7 +136,7 @@ struct sensor_info_t
        float sampling_rate;    /* requested events / second */
 
        int dev_num;    /* Associated iio dev num, ex: 3 for /dev/iio:device3 */
-       int enable_count;
+       int enabled;
 
        int catalog_index;/* Associated entry within the sensor_catalog array */
        int type;         /* Sensor type, such as SENSOR_TYPE_GYROSCOPE       */
@@ -149,7 +156,8 @@ struct sensor_info_t
        /*
         * This flag is set if we acquired data from the sensor but did not
         * forward it to upper layers (i.e. Android) yet. If so, report_buffer
-        * contains that data.
+        * contains that data. Valid values are 0: empty, 1: normal, 2: repeat
+        * of last acquired value after timeout.
         */
        int report_pending;
 
@@ -175,6 +183,9 @@ struct sensor_info_t
        struct sample_ops_t ops;
 
        int cal_level; /* 0 means not calibrated */
+
+       /* Depending on the sensor calibration may take too much at higher levels */
+       int max_cal_level;
        void* cal_data;
 
        /* Filtering data for noisy sensors */
@@ -230,7 +241,4 @@ extern struct sensor_t      sensor_desc[MAX_SENSORS];
 extern struct sensor_info_t            sensor_info[MAX_SENSORS];
 extern struct sensor_catalog_entry_t   sensor_catalog[];
 
-/* We are required to be in sync with SystemClock.getNanos */
-extern int64_t ts_delta;
-
 #endif