sensord: hal: splite sensor_hal.h into sensor_hal interface and hal
[platform/core/system/sensord.git] / src / hal / sensor_hal_types.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef _SENSOR_HAL_TYPES_H_
19 #define _SENSOR_HAL_TYPES_H_
20
21 #include <stdint.h>
22 #include <stdbool.h>
23
24 #define SENSOR_HAL_VERSION(maj, min) \
25                 ((((maj) & 0xFFFF) << 24) | ((min) & 0xFFFF))
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif /* __cplusplus */
31
32 /*
33  * Sensor Types
34  * These types are used to controll the sensors
35  *
36  * - base unit
37  *   acceleration values : meter per second^2 (m/s^2)
38  *   magnetic values     : micro-Tesla (uT)
39  *   orientation values  : degrees
40  *   gyroscope values    : degree/s
41  *   temperature values  : degrees centigrade
42  *   proximity valeus    : distance
43  *   light values        : lux
44  *   pressure values     : hectopascal (hPa)
45  *   humidity            : relative humidity (%)
46  */
47 typedef enum {
48         SENSOR_DEVICE_UNKNOWN = -2,
49         SENSOR_DEVICE_ALL = -1,
50         SENSOR_DEVICE_ACCELEROMETER,
51         SENSOR_DEVICE_GRAVITY,
52         SENSOR_DEVICE_LINEAR_ACCELERATION,
53         SENSOR_DEVICE_GEOMAGNETIC,
54         SENSOR_DEVICE_ROTATION_VECTOR,
55         SENSOR_DEVICE_ORIENTATION,
56         SENSOR_DEVICE_GYROSCOPE,
57         SENSOR_DEVICE_LIGHT,
58         SENSOR_DEVICE_PROXIMITY,
59         SENSOR_DEVICE_PRESSURE,
60         SENSOR_DEVICE_ULTRAVIOLET,
61         SENSOR_DEVICE_TEMPERATURE,
62         SENSOR_DEVICE_HUMIDITY,
63         SENSOR_DEVICE_HRM,
64         SENSOR_DEVICE_HRM_LED_GREEN,
65         SENSOR_DEVICE_HRM_LED_IR,
66         SENSOR_DEVICE_HRM_LED_RED,
67         SENSOR_DEVICE_GYROSCOPE_UNCAL,
68         SENSOR_DEVICE_GEOMAGNETIC_UNCAL,
69         SENSOR_DEVICE_GYROSCOPE_RV,
70         SENSOR_DEVICE_GEOMAGNETIC_RV,
71
72         SENSOR_DEVICE_HUMAN_PEDOMETER = 0x300,
73         SENSOR_DEVICE_HUMAN_SLEEP_MONITOR,
74
75         SENSOR_DEVICE_FUSION = 0x900,
76         SENSOR_DEVICE_AUTO_ROTATION,
77         SENSOR_DEVICE_AUTO_BRIGHTNESS,
78
79         SENSOR_DEVICE_CONTEXT = 0x1000,
80         SENSOR_DEVICE_MOTION,
81         SENSOR_DEVICE_PIR,
82         SENSOR_DEVICE_PIR_LONG,
83         SENSOR_DEVICE_DUST,
84         SENSOR_DEVICE_THERMOMETER,
85         SENSOR_DEVICE_PEDOMETER,
86         SENSOR_DEVICE_FLAT,
87         SENSOR_DEVICE_HRM_RAW,
88         SENSOR_DEVICE_TILT,
89         SENSOR_DEVICE_ROTATION_VECTOR_RAW,
90         SENSOR_DEVICE_EXERCISE,
91         SENSOR_DEVICE_GSR,
92         SENSOR_DEVICE_SIMSENSE,
93         SENSOR_DEVICE_PPG,
94
95         SENSOR_DEVICE_GESTURE_MOVEMENT = 0x1200,
96         SENSOR_DEVICE_GESTURE_WRIST_UP,
97         SENSOR_DEVICE_GESTURE_WRIST_DOWN,
98         SENSOR_DEVICE_GESTURE_MOVEMENT_STATE,
99
100         SENSOR_DEVICE_WEAR_STATUS = 0x1A00,
101         SENSOR_DEVICE_WEAR_ON_MONITOR,
102         SENSOR_DEVICE_GPS_BATCH,
103         SENSOR_DEVICE_ACTIVITY_TRACKER,
104         SENSOR_DEVICE_SLEEP_DETECTOR,
105         SENSOR_DEVICE_NO_MOVE_DETECTOR = 0x1A80,
106         SENSOR_DEVICE_HRM_CTRL,
107         SENSOR_DEVICE_EXERCISE_COACH,
108         SENSOR_DEVICE_EXERCISE_HR,
109         SENSOR_DEVICE_RESTING_HR,
110         SENSOR_DEVICE_STEP_LEVEL_MONITOR,
111         SENSOR_DEVICE_ACTIVITY_LEVEL_MONITOR,
112         SENSOR_DEVICE_CYCLE_MONITOR,
113         SENSOR_DEVICE_STRESS_MONITOR,
114         SENSOR_DEVICE_AUTOSESSION_EXERCISE,
115         SENSOR_DEVICE_STAIR_TRACKER,
116
117 } sensor_device_type;
118
119 /*
120  * A platform sensor handler is generated based on this handle
121  * This id can be assigned from HAL developer. so it has to be unique in 1 sensor_device.
122  */
123 typedef struct sensor_info_t {
124         uint32_t id;
125         const char *name;
126         sensor_device_type type;
127         unsigned int event_type; // for Internal API
128         const char *model_name;
129         const char *vendor;
130         float min_range;
131         float max_range;
132         float resolution;
133         int min_interval;
134         int max_batch_count;
135         bool wakeup_supported;
136 } sensor_info_t;
137
138 enum sensor_accuracy_t {
139         SENSOR_ACCURACY_UNDEFINED = -1,
140         SENSOR_ACCURACY_BAD = 0,
141         SENSOR_ACCURACY_NORMAL =1,
142         SENSOR_ACCURACY_GOOD = 2,
143         SENSOR_ACCURACY_VERYGOOD = 3
144 };
145
146 #define SENSOR_DATA_VALUE_SIZE 16
147
148 /* sensor_data_t */
149 typedef struct sensor_data_t {
150         int accuracy;
151         unsigned long long timestamp;
152         int value_count;
153         float values[SENSOR_DATA_VALUE_SIZE];
154 } sensor_data_t;
155
156 #define SENSORHUB_DATA_VALUE_SIZE 4096
157
158 /* sensorhub_data_t */
159 typedef struct sensorhub_data_t {
160         int accuracy;
161         unsigned long long timestamp;
162
163         /*
164          *  Use "value_count" instead of "hub_data_size"
165          *  which is going to be removed soon
166          */
167         union {
168                 int value_count;
169                 int hub_data_size; /* deprecated */
170         };
171
172         /*
173          *  Use "values" instead of "hub_data"
174          *  which is going to be removed soon
175          */
176         union {
177                 char values[SENSORHUB_DATA_VALUE_SIZE];
178                 char hub_data[SENSORHUB_DATA_VALUE_SIZE]; /* deprecated */
179         };
180 } sensorhub_data_t;
181
182 #define SENSOR_PEDOMETER_DATA_DIFFS_SIZE        20
183
184 typedef struct {
185         int accuracy;
186         unsigned long long timestamp;
187         int value_count;        /* value_count == 8 */
188         float values[SENSOR_DATA_VALUE_SIZE];
189         /* values = {step count, walk step count, run step count,
190                      moving distance, calorie burned, last speed,
191                      last stepping frequency (steps per sec),
192                      last step status (walking, running, ...)} */
193         /* Additional data attributes (not in sensor_data_t)*/
194         int diffs_count;
195         struct differences {
196                 int timestamp;
197                 int steps;
198                 int walk_steps;
199                 int run_steps;
200                 float distance;
201                 float calories;
202                 float speed;
203         } diffs[SENSOR_PEDOMETER_DATA_DIFFS_SIZE];
204         unsigned long long accumulated_steps;
205         unsigned long long accumulated_walk_steps;
206         unsigned long long accumulated_run_steps;
207         double accumulated_distance;
208         double accumulated_calories;
209 } sensor_pedometer_data_t;
210
211 enum sensor_attribute {
212         SENSOR_ATTR_ACTIVITY = 0x100,
213 };
214
215 enum sensor_activity {
216         SENSOR_ACTIVITY_UNKNOWN = 1,
217         SENSOR_ACTIVITY_STILL = 2,
218         SENSOR_ACTIVITY_WALKING = 4,
219         SENSOR_ACTIVITY_RUNNING = 8,
220         SENSOR_ACTIVITY_IN_VEHICLE = 16,
221         SENSOR_ACTIVITY_ON_BICYCLE = 32,
222 };
223
224 #ifdef __cplusplus
225 }
226 #endif /* __cplusplus */
227
228 #endif /* _SENSOR_HAL_TYPES_H_ */