Merge "Synchronizing sensord code with IIO driver support for accelerometer plugin...
[platform/core/system/sensord.git] / src / shared / sensor_common.h
1 /*
2  * libsensord-share
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __SENSOR_COMMON_H__
21 #define __SENSOR_COMMON_H__
22
23 #ifndef DEPRECATED
24 #define DEPRECATED __attribute__((deprecated))
25 #endif
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 /**
33  * @defgroup SENSOR_FRAMEWORK SensorFW
34  * To support the unified API for the various sensors
35  */
36
37 /**
38  * @defgroup SENSOR_FRAMEWORK_COMMON Sensor Framework Common API
39  * @ingroup SENSOR_FRAMEWORK
40  *
41  * These APIs are used to control the sensors.
42  * @{
43  */
44
45 typedef enum {
46         ALL_SENSOR = -1,
47         UNKNOWN_SENSOR = 0,
48         ACCELEROMETER_SENSOR,
49         GEOMAGNETIC_SENSOR,
50         LIGHT_SENSOR,
51         PROXIMITY_SENSOR,
52         THERMOMETER_SENSOR,
53         GYROSCOPE_SENSOR,
54         PRESSURE_SENSOR,
55         MOTION_SENSOR,
56         FUSION_SENSOR,
57         CONTEXT_SENSOR,
58         FLAT_SENSOR,
59         AUTO_ROTATION_SENSOR,
60         GRAVITY_SENSOR,
61         LINEAR_ACCEL_SENSOR,
62         ORIENTATION_SENSOR,
63         TEMPERATURE_SENSOR
64 } sensor_type_t;
65
66 typedef unsigned int sensor_id_t;
67
68 typedef void *sensor_t;
69
70 typedef enum {
71         SENSOR_PRIVILEGE_PUBLIC,
72         SENSOR_PRIVILEGE_INTERNAL,
73 } sensor_privilege_t;
74
75
76 #define SENSOR_DATA_VALUE_SIZE 16
77
78 /*
79  *      When modifying it, check copy_sensor_data()
80  */
81 typedef struct sensor_data_t {
82 /*
83  *      Use "accuracy" instead of "data_accuracy"
84  *      which is going to be removed soon
85  */
86         union {
87                 int accuracy;
88                 int data_accuracy; //deprecated
89         };
90
91         unsigned long long timestamp;
92
93 /*
94  *      Use "value_count" instead of "values_num"
95  *      which is going to be removed soon
96  */
97         union {
98                 int value_count;
99                 int values_num; //deprecated
100         };
101
102         float values[SENSOR_DATA_VALUE_SIZE];
103 } sensor_data_t;
104
105 #define SENSOR_HUB_DATA_SIZE    4096
106
107 typedef struct sensorhub_data_t {
108     int version;
109     int sensorhub;
110     int type;
111     int hub_data_size;
112     unsigned long long timestamp;
113     char hub_data[SENSOR_HUB_DATA_SIZE];
114     float data[16];
115 } sensorhub_data_t;
116
117 enum sensor_accuracy_t {
118         SENSOR_ACCURACY_UNDEFINED = -1,
119         SENSOR_ACCURACY_BAD = 0,
120         SENSOR_ACCURACY_NORMAL =1,
121         SENSOR_ACCURACY_GOOD = 2,
122         SENSOR_ACCURACY_VERYGOOD = 3
123 };
124
125 /*
126  *      To prevent naming confliction as using same enums as sensor CAPI use
127  */
128 #ifndef __SENSORS_H__
129 enum sensor_option_t {
130         SENSOR_OPTION_DEFAULT = 0,
131         SENSOR_OPTION_ON_IN_SCREEN_OFF = 1,
132         SENSOR_OPTION_ON_IN_POWERSAVE_MODE = 2,
133         SENSOR_OPTION_ALWAYS_ON = SENSOR_OPTION_ON_IN_SCREEN_OFF | SENSOR_OPTION_ON_IN_POWERSAVE_MODE,
134         SENSOR_OPTION_END
135 };
136
137 typedef enum sensor_option_t sensor_option_e;
138 #endif
139
140 enum sensor_interval_t {
141         SENSOR_INTERVAL_FASTEST = 0,
142         SENSOR_INTERVAL_NORMAL = 200,
143 };
144
145
146 typedef enum {
147         CONDITION_NO_OP,
148         CONDITION_EQUAL,
149         CONDITION_GREAT_THAN,
150         CONDITION_LESS_THAN,
151 } condition_op_t;
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157
158 #endif
159 //! End of a file