OSDN Git Service

Winter cleanup: switch to 160 characters lines
[android-x86/hardware-intel-libsensors.git] / common.h
index 1d40842..f83cd79 100644 (file)
--- a/common.h
+++ b/common.h
 #define DEVICE_AVAIL_FREQ_PATH BASE_PATH "sampling_frequency_available"
 #define ILLUMINATION_CALIBPATH BASE_PATH "in_illuminance_calibscale"
 
-#define PROP_BASE      "ro.iio.%s.%s" /* Note: PROPERTY_KEY_MAX is small */
+#define PROP_BASE              "ro.iio.%s.%s" /* Note: PROPERTY_KEY_MAX is small */
 
-#define MAX_TYPE_SPEC_LEN 32   /* Channel type spec len; ex: "le:u10/16>>0" */
+#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 MAX_SENSOR_BASES 3 /* Max number of base sensors a sensor can rely on */
+#define MAX_SENSOR_BASES       3       /* Max number of base sensors a sensor can rely on */
 
 #define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])
 #define REPORTING_MODE(x)      ((x) & 0x06)
@@ -66,10 +66,10 @@ channel_descriptor_t;
 
 typedef struct
 {
-       const char *tag; /* Prefix such as "accel", "gyro", "temp"... */
-       const int type;  /* Sensor type ; ex: SENSOR_TYPE_ACCELEROMETER */
+       const char *tag;        /* Prefix such as "accel", "gyro", "temp"... */
+       const int type;         /* Sensor type ; ex: SENSOR_TYPE_ACCELEROMETER */
        const int num_channels; /* Expected iio channels for this sensor */
-       const int is_virtual;  /* Is the sensor virtual or not */
+       const int is_virtual;   /* Is the sensor virtual or not */
        channel_descriptor_t channel[MAX_CHANNELS];
 }
 sensor_catalog_entry_t;
@@ -88,15 +88,14 @@ datum_info_t;
 
 typedef struct
 {
-       int offset; /* Offset in bytes within the iio character device report */
-       int size;                       /* Field size in bytes */
-       float scale;                    /* scale for each channel */
-       char type_spec[MAX_TYPE_SPEC_LEN]; /* From driver; ex: le:u10/16>>0 */
-       datum_info_t type_info;         /* Decoded contents of type spec */
-       float opt_scale; /* Optional correction scale read from a property such
-                         * as iio.accel.x.scale, allowing late compensation of
-                         * problems such as misconfigured axes ; set to 1 by
-                         * default. Applied at the end of the scaling process.
+       int offset;     /* Offset in bytes within the iio character device report */
+       int size;       /* Field size in bytes */
+       float scale;    /* scale for each channel */
+       char type_spec[MAX_TYPE_SPEC_LEN];      /* From driver; ex: le:u10/16>>0 */
+       datum_info_t type_info;                 /* Decoded contents of type spec */
+       float opt_scale; /*
+                         * Optional correction scale read from a property such as iio.accel.x.scale, allowing late compensation of
+                         * problems such as misconfigured axes ; set to 1 by default. Applied at the end of the scaling process.
                          */
 }
 channel_info_t;
@@ -135,57 +134,45 @@ typedef struct
        float power;
 
        /*
-        * Currently active trigger - either a pointer to the initial (default)
-        * trigger name buffer, or a pointer to the motion trigger name buffer,
-        * or something else (typically NULL or a pointer to some static "\n".
-        * This is used to determine if the conditions are met to switch from
-        * the default trigger to the motion trigger for a sensor, or rather for
-        * the interrupt-driven sensors associated to a given iio device.
+        * Currently active trigger - either a pointer to the initial (default) trigger name buffer, or a pointer to the motion trigger name buffer,
+        * or something else (typically NULL or a pointer to some static "\n". This is used to determine if the conditions are met to switch from
+        * the default trigger to the motion trigger for a sensor, or rather for the interrupt-driven sensors associated to a given iio device.
         */
        const char* selected_trigger;
 
-       float offset;   /* (cooked = raw + offset) * scale */
-       float scale;    /*default:1. when set to 0, use channel specific value*/
-       float illumincalib;     /* to set the calibration for the ALS */
+       float offset;           /* (cooked = raw + offset) * scale                      */
+       float scale;            /* default:1. when set to 0, use channel specific value */
+       float illumincalib;     /* to set the calibration for the ALS                   */
 
-       float requested_rate;   /* requested events / second */
-       float sampling_rate;    /* setup events / second */
+       float requested_rate;   /* requested events / second                            */
+       float sampling_rate;    /* setup events / second                                */
 
-       int dev_num;    /* Associated iio dev num, ex: 3 for /dev/iio:device3 */
+       int dev_num;            /* Associated iio dev num, ex: 3 for /dev/iio:device3   */
 
-       int catalog_index;/* Associated entry within the sensor_catalog array */
-       int type;         /* Sensor type, such as SENSOR_TYPE_GYROSCOPE       */
+       int catalog_index;      /* Associated entry within the sensor_catalog array     */
+       int type;               /* Sensor type, such as SENSOR_TYPE_GYROSCOPE           */
 
-       int num_channels; /* Actual channel count ; 0 for poll mode sensors */
+       int num_channels;       /* Actual channel count ; 0 for poll mode sensors       */
 
        /*
-        * The array below indicates where to gather report data for this
-        * sensor inside the reports that we read from the iio character device.
-        * It is updated whenever channels are enabled or disabled on the same
-        * device. Channel size indicates the size in bytes of fields, and
-        * should be zero for disabled channels. The type field indicates how a
-        * specific channel data item is structured.
+        * The array below indicates where to gather report data for this sensor inside the reports that we read from the iio character device.
+        * It is updated whenever channels are enabled or disabled on the same device. Channel size indicates the size in bytes of fields, and
+        * should be zero for disabled channels. The type field indicates how a specific channel data item is structured.
         */
        channel_info_t channel[MAX_CHANNELS];
 
        /*
-        * 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. Valid values are 0: empty, 1: normal, 2: repeat
-        * of last acquired value after timeout.
+        * 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. Valid values are 0: empty, 1: normal, 2: repeat of last acquired value after timeout.
         */
        int report_pending;
 
-       /*
-        * This flag is set if we have a meta data event pending
-        */
+       /* This flag is set if we have a meta data event pending */
        int meta_data_pending;
 
        /*
-        * Timestamp closely matching the date of sampling, preferably retrieved
-        * from a iio channel alongside sample data. Value zero indicates that
-        * we couldn't get such a closely correlated timestamp, and that one
-        * has to be generated before the report gets sent up to Android.
+        * Timestamp closely matching the date of sampling, preferably retrieved from a iio channel alongside sample data. Value zero indicates that
+        * we couldn't get such a closely correlated timestamp, and that one has to be generated before the report gets sent up to Android.
         */
        int64_t report_ts;
 
@@ -201,8 +188,7 @@ typedef struct
        int cal_level; /* 0 means not calibrated */
 
        /*
-        * Depending on the sensor, calibration may take too much time at
-        * higher levels. Allow optional capping to a certain level.
+        * Depending on the sensor, calibration may take too much time at higher levels. Allow optional capping to a certain level.
         */
        int max_cal_level;
 
@@ -214,47 +200,35 @@ typedef struct
        float prev_val; /* Previously reported value, for on-change sensors */
 
        /*
-        * Certain sensors expose their readings through sysfs files that have
-        * a long response time (100-200 ms for ALS). Rather than block our
-        * global control loop for several hundred ms each second, offload those
-        * lengthy blocking reads to dedicated threads, which will then report
+        * Certain sensors expose their readings through sysfs files that have a long response time (100-200 ms for ALS). Rather than block our
+        * global control loop for several hundred ms each second, offload those lengthy blocking reads to dedicated threads, which will then report
         * their data through a fd that we can add to our poll fd set.
         */
        int thread_data_fd[2];
        pthread_t acquisition_thread;
 
-       /* How many base sensors is the sensor depending on */
-       int base_count;
+       int base_count; /* How many base sensors is the sensor depending on */
        int base[MAX_SENSOR_BASES];
 
        uint32_t quirks; /* Bit mask expressing the need for special tweaks */
 
        /* Note: we may have to explicitely serialize access to some fields */
 
-       int is_virtual;
-       /*
-       * Dependency count - for a real sensor how many active virtual sensors are
-       * depending on it
-       */
-       uint32_t ref_count;
+       int is_virtual;                 /* Composite sensor, exposed from data acquired through other sensors */
 
-       /*
-        * Flag showing if a sensor was enabled directly by Android
-        */
-       uint32_t directly_enabled;
+       uint32_t ref_count;             /* Dependency count - for a real sensor how many active virtual sensors are depending on it */
+
+       uint32_t directly_enabled;      /* Flag showing if a sensor was enabled directly by Android */
 
        /*
-        * Current sample for a virtual sensor - when a report is ready we'll
-        * keep the data here until it's finally processed. Can be modified for
+        * Current sample for a virtual sensor - when a report is ready we'll keep the data here until it's finally processed. Can be modified for
         * more than one at a later time.
         */
        sensors_event_t sample;
 
        /*
-        * If the QUIRK_FIELD_ORDERING bit is set in quirks, the contents of
-        * this array are used in the finalization stage to swap sample fields
-        * before transmitting them to Android ; they form a mapping between
-        * the indices of the input and output arrays: ex: 0123 is identity for
+        * If the QUIRK_FIELD_ORDERING bit is set in quirks, the contents of this array are used in the finalization stage to swap sample fields
+        * before transmitting them to Android ; they form a mapping between the indices of the input and output arrays: ex: 0123 is identity for
         * a sample containing 4 fields.
         */
        unsigned char order[MAX_CHANNELS];
@@ -267,8 +241,7 @@ typedef struct
        int history_index;      /* Index of sample to evict next time         */
 
        /*
-        * Event counter - will be used to check if we have a significant sample
-        * for noisy sensors. We want to make sure we do not send any wrong
+        * Event counter - will be used to check if we have a significant sample for noisy sensors. We want to make sure we do not send any wrong
         * events before filtering kicks in. We can also use it for statistics.
         */
        uint64_t event_count;