OSDN Git Service

[Activity HAL] Separation of common macros
[android-x86/hardware-intel-libsensors.git] / common.h
index 8ad1196..809400b 100644 (file)
--- a/common.h
+++ b/common.h
@@ -1,14 +1,14 @@
 /*
- * Copyright (C) 2014 Intel Corporation.
+ * Copyright (C) 2014-2015 Intel Corporation.
  */
 
 #ifndef __COMMON_H__
 #define __COMMON_H__
 
 #define MAX_DEVICES    9       /* Check iio devices 0 to MAX_DEVICES-1 */
-#define MAX_SENSORS    11      /* We can handle as many sensors */
+#define MAX_SENSORS    12      /* We can handle as many sensors */
 #define MAX_CHANNELS   4       /* We can handle as many channels per sensor */
-#define MAX_EVENTS     8       /* We can handle as many events per channel */
+#define MAX_EVENTS     2       /* We can handle as many events per channel */
 #define MAX_TRIGGERS   8       /* Check for triggers 0 to MAX_TRIGGERS-1 */
 
 #define DEV_FILE_PATH          "/dev/iio:device%d"
@@ -116,6 +116,8 @@ typedef struct
                          * 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 raw_path_present;   /* Flag signalling the presence of in_<sens>_<axis>_raw file */
+       int input_path_present; /* Flag signalling the presence of in_<sens>_input file */
 }
 channel_info_t;
 
@@ -272,6 +274,7 @@ typedef struct
         */
        int needs_enable;
 
+       int semi_arbitrated_rate;       /* Arbitrated sampling rate before we considered other sensors co-located on the same iio device */
 }
 sensor_info_t;
 
@@ -281,5 +284,52 @@ extern int                 sensor_count;
 extern struct sensor_t         sensor_desc[MAX_SENSORS];
 extern sensor_info_t           sensor[MAX_SENSORS];
 extern sensor_catalog_entry_t  sensor_catalog[];
+extern unsigned int            catalog_size;
+
+/* Needed both in sensors and activity HALs */
+void check_trig_sensors (int i, char *sysfs_file, char map[catalog_size]);
+void check_poll_sensors (int i, char *sysfs_file, char map[catalog_size]);
+void check_event_sensors (int i, char *sysfs_file, char map[catalog_size]);
+void discover_sensors(int dev_num, char *sysfs_base_path, char map[catalog_size],
+                     void (*discover_sensor)(int, char*, char*));
+
+/*
+ * Macros associating iio sysfs entries to to sensor types ; see
+ * linux/kernel/drivers/iio/industrialio-core.c and
+ * hardware/libhardware/include/hardware/sensor.h
+ */
+
+#define DECLARE_VOID_CHANNEL(tag)      \
+                       tag,    \
+                       "",     \
+                       "",     \
+                       "",     \
+                       "",     \
+                       "",     \
+                       "",     \
+
+#define DECLARE_CHANNEL(tag, spacer, name)             \
+                       name,                           \
+                       "in_"tag spacer name"_en",      \
+                       "in_"tag spacer name"_type",    \
+                       "in_"tag spacer name"_index",   \
+                       "in_"tag spacer name"_raw",     \
+                       "in_"tag spacer name"_input",   \
+                       "in_"tag spacer name"_scale",   \
+                       0, {{0}},
+
+#define DECLARE_NAMED_CHANNEL(tag, name)       DECLARE_CHANNEL(tag, "_", name)
+
+#define DECLARE_GENERIC_CHANNEL(tag)           DECLARE_CHANNEL(tag, "", "")
+
+#define DECLARE_EVENT(tag, spacer1, name, spacer2, type, spacer3, dir)         \
+                     type, dir,                                                \
+                     "in_"tag spacer1 name spacer2 type spacer3 dir"_en",      \
+                     "in_"tag spacer1 name spacer2 type spacer3 dir"_value",   \
+
+#define DECLARE_GENERIC_EVENT(tag, name, type, dir) \
+               DECLARE_EVENT(tag, "_", name, "_", type, "_", dir)
+#define DECLARE_NAMED_EVENT(tag, name) \
+               DECLARE_EVENT(tag, "_", name, "","","","")
 
 #endif