coverity issues fix
[platform/core/system/sensord.git] / include / sensor_types.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2016 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_TYPES_H__
21 #define __SENSOR_TYPES_H__
22
23 /* TODO: It is for compatibility with capi-system-sensor */
24 #define __SENSOR_COMMON_H__
25
26 #include <stddef.h>
27 #include <stdint.h>
28 #include <sensor_hal_types.h>
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34
35 #ifndef OP_SUCCESS
36 #define OP_SUCCESS 0
37 #endif
38 #ifndef OP_ERROR
39 #define OP_ERROR   -1
40 #endif
41 #ifndef OP_DEFAULT
42 #define OP_DEFAULT 1
43 #endif
44 #ifndef OP_CONTINUE
45 #define OP_CONTINUE 2
46 #endif
47 #ifndef NAME_MAX
48 #define NAME_MAX 256
49 #endif
50
51 #define SENSOR_TYPE_SHIFT 32
52 #define SENSOR_EVENT_SHIFT 16
53 #define SENSOR_INDEX_MASK 0xFFFFFFFF
54
55 #define CONVERT_ID_TYPE(id) ((id) >> SENSOR_TYPE_SHIFT)
56 #define CONVERT_TYPE_EVENT(type) ((type) << SENSOR_EVENT_SHIFT | 0x1)
57
58 #define MICROSECONDS(tv)        ((tv.tv_sec * 1000000ll) + tv.tv_usec)
59
60 #define SENSOR_UNKNOWN_TYPE "http://tizen.org/sensor/unknown"
61 #define SENSOR_UNKNOWN_NAME "Unknown"
62
63 typedef int64_t sensor_id_t;
64 typedef void *sensor_t;
65
66 typedef enum sensor_type_t {
67         UNKNOWN_SENSOR = -2,
68         ALL_SENSOR = -1,
69         ACCELEROMETER_SENSOR = 0,
70         GRAVITY_SENSOR,
71         LINEAR_ACCEL_SENSOR,
72         GEOMAGNETIC_SENSOR,
73         ROTATION_VECTOR_SENSOR,
74         ORIENTATION_SENSOR,
75         GYROSCOPE_SENSOR,
76         LIGHT_SENSOR,
77         PROXIMITY_SENSOR,
78         PRESSURE_SENSOR,
79         ULTRAVIOLET_SENSOR,
80         TEMPERATURE_SENSOR,
81         HUMIDITY_SENSOR,
82         HRM_SENSOR,
83         BIO_HRM_SENSOR = HRM_SENSOR,
84         HRM_LED_GREEN_SENSOR,
85         BIO_LED_GREEN_SENSOR = HRM_LED_GREEN_SENSOR,
86         HRM_LED_IR_SENSOR,
87         BIO_LED_IR_SENSOR = HRM_LED_IR_SENSOR,
88         HRM_LED_RED_SENSOR,
89         BIO_LED_RED_SENSOR = HRM_LED_RED_SENSOR,
90         GYROSCOPE_UNCAL_SENSOR,
91         GEOMAGNETIC_UNCAL_SENSOR,
92         GYROSCOPE_RV_SENSOR,
93         GEOMAGNETIC_RV_SENSOR,
94
95         HUMAN_PEDOMETER_SENSOR = 0x300,
96         HUMAN_SLEEP_MONITOR_SENSOR,
97         HUMAN_SLEEP_DETECTOR_SENSOR,
98         SLEEP_DETECTOR_SENSOR = HUMAN_SLEEP_DETECTOR_SENSOR,
99         HUMAN_STRESS_MONITOR_SENSOR,
100         STRESS_MONITOR_SENSOR = HUMAN_STRESS_MONITOR_SENSOR,
101
102         EXERCISE_WALKING_SENSOR = 0x400,
103         EXERCISE_RUNNING_SENSOR,
104         EXERCISE_HIKING_SENSOR,
105         EXERCISE_CYCLING_SENSOR,
106         EXERCISE_ELLIPTICAL_SENSOR,
107         EXERCISE_INDOOR_CYCLING_SENSOR,
108         EXERCISE_ROWING_SENSOR,
109         EXERCISE_STEPPER_SENSOR,
110
111         EXTERNAL_EXERCISE_SENSOR = 0x800,
112         EXERCISE_SENSOR = EXTERNAL_EXERCISE_SENSOR,
113
114         FUSION_SENSOR = 0x900,
115         AUTO_ROTATION_SENSOR,
116         AUTO_BRIGHTNESS_SENSOR,
117
118         GESTURE_MOVEMENT_SENSOR = 0x1200,
119         GESTURE_WRIST_UP_SENSOR,
120         GESTURE_WRIST_DOWN_SENSOR,
121         GESTURE_MOVEMENT_STATE_SENSOR,
122         GESTURE_FACE_DOWN_SENSOR,
123
124         ACTIVITY_TRACKER_SENSOR = 0x1A00,
125         ACTIVITY_LEVEL_MONITOR_SENSOR,
126         GPS_BATCH_SENSOR,
127
128         HRM_CTRL_SENSOR = 0x1A80,
129
130         WEAR_STATUS_SENSOR = 0x2000,
131         WEAR_ON_MONITOR_SENSOR,
132         NO_MOVE_DETECTOR_SENSOR,
133         RESTING_HR_SENSOR,
134         STEP_LEVEL_MONITOR_SENSOR,
135         EXERCISE_STANDALONE_SENSOR,
136         EXERCISE_COACH_SENSOR = EXERCISE_STANDALONE_SENSOR,
137         EXERCISE_HR_SENSOR,
138         WORKOUT_SENSOR,
139         AUTOSESSION_EXERCISE_SENSOR = WORKOUT_SENSOR,
140         CYCLE_MONITOR_SENSOR,
141         STAIR_TRACKER_SENSOR,
142         PRESSURE_INDICATOR_SENSOR,
143         PRESSURE_ALERT_SENSOR,
144         HR_CALORIE_SENSOR,
145
146         CONTEXT_SENSOR = 0x7000,
147         MOTION_SENSOR,
148         PIR_SENSOR,
149         PIR_LONG_SENSOR,
150         DUST_SENSOR,
151         THERMOMETER_SENSOR,
152         PEDOMETER_SENSOR,
153         FLAT_SENSOR,
154         HRM_RAW_SENSOR,
155         BIO_SENSOR = HRM_RAW_SENSOR,
156         TILT_SENSOR,
157         RV_RAW_SENSOR,
158         GSR_SENSOR,
159         SIMSENSE_SENSOR,
160         PPG_SENSOR,
161
162         CUSTOM_SENSOR = 0X9000,
163 } sensor_type_t;
164
165 typedef struct sensor_info2_t {
166         uint32_t id;
167         sensor_type_t type;
168         const char *uri;
169         const char *vendor;
170         float min_range;
171         float max_range;
172         float resolution;
173         int min_interval;
174         int max_batch_count;
175         bool wakeup_supported;
176         const char *privilege;
177         void *reserved[8];
178 } sensor_info2_t;
179
180 typedef enum sensor_privilege_t {
181         SENSOR_PRIVILEGE_PUBLIC = 0,
182 } sensor_privilege_t;
183
184 typedef struct sensor_event_t {
185         unsigned int event_type;
186         sensor_id_t sensor_id;
187         unsigned int data_length;
188         sensor_data_t *data;
189 } sensor_event_t;
190
191 /*
192  *      To prevent naming confliction as using same enums as sensor CAPI use
193  */
194 #ifndef __SENSOR_H__
195 enum sensor_option_t {
196         SENSOR_OPTION_DEFAULT = 0,
197         SENSOR_OPTION_ON_IN_SCREEN_OFF = 1,
198         SENSOR_OPTION_ON_IN_POWERSAVE_MODE = 2,
199         SENSOR_OPTION_ALWAYS_ON = SENSOR_OPTION_ON_IN_SCREEN_OFF | SENSOR_OPTION_ON_IN_POWERSAVE_MODE,
200         SENSOR_OPTION_END
201 };
202
203 typedef enum sensor_option_t sensor_option_e;
204 #endif
205
206 enum sensord_attribute_e {
207         SENSORD_ATTRIBUTE_AXIS_ORIENTATION = 1,
208         SENSORD_ATTRIBUTE_PAUSE_POLICY,
209         SENSORD_ATTRIBUTE_INTERVAL = 0x10,
210         SENSORD_ATTRIBUTE_MAX_BATCH_LATENCY,
211         SENSORD_ATTRIBUTE_PASSIVE_MODE,
212         SENSORD_ATTRIBUTE_FLUSH,
213 };
214
215 enum sensord_axis_e {
216         SENSORD_AXIS_DEVICE_ORIENTED = 1,
217         SENSORD_AXIS_DISPLAY_ORIENTED,
218 };
219
220 enum sensord_pause_e {
221         SENSORD_PAUSE_NONE = 0,
222         SENSORD_PAUSE_ON_DISPLAY_OFF = 1,
223         SENSORD_PAUSE_ON_POWERSAVE_MODE = 2,
224         SENSORD_PAUSE_ALL = 3,
225         SENSORD_PAUSE_END,
226 };
227
228 enum poll_interval_t {
229         POLL_100HZ_MS   = 10,
230         POLL_50HZ_MS    = 20,
231         POLL_25HZ_MS    = 40,
232         POLL_20HZ_MS    = 50,
233         POLL_10HZ_MS    = 100,
234         POLL_5HZ_MS             = 200,
235         POLL_1HZ_MS             = 1000,
236         POLL_MAX_HZ_MS  = 255000,
237 };
238
239 #define DEFAULT_INTERVAL POLL_10HZ_MS
240
241 enum sensor_interval_t {
242         SENSOR_INTERVAL_FASTEST = POLL_100HZ_MS,
243         SENSOR_INTERVAL_NORMAL = POLL_5HZ_MS,
244 };
245
246 enum proxi_change_state {
247         PROXIMITY_STATE_NEAR = 0,
248         PROXIMITY_STATE_FAR = 1,
249 };
250
251 enum auto_rotation_state {
252         AUTO_ROTATION_DEGREE_UNKNOWN = 0,
253         AUTO_ROTATION_DEGREE_0,
254         AUTO_ROTATION_DEGREE_90,
255         AUTO_ROTATION_DEGREE_180,
256         AUTO_ROTATION_DEGREE_270,
257 };
258
259 #ifdef __cplusplus
260 }
261 #endif
262
263 #include <sensor_deprecated.h>
264
265 #endif /* __SENSOR_TYPES_H__ */