91630c4076b3cc0aa49ad95541fd8a592b020ff2
[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 } sensor_device_type;
117
118 /*
119  * A platform sensor handler is generated based on this handle
120  * This id can be assigned from HAL developer. so it has to be unique in 1 sensor_device.
121  */
122 typedef struct sensor_info_t {
123         uint32_t id;
124         const char *name;
125         sensor_device_type type;
126         unsigned int event_type; // for Internal API
127         const char *model_name;
128         const char *vendor;
129         float min_range;
130         float max_range;
131         float resolution;
132         int min_interval;
133         int max_batch_count;
134         bool wakeup_supported;
135 } sensor_info_t;
136
137 enum sensor_accuracy_t {
138         SENSOR_ACCURACY_UNDEFINED = -1,
139         SENSOR_ACCURACY_BAD = 0,
140         SENSOR_ACCURACY_NORMAL = 1,
141         SENSOR_ACCURACY_GOOD = 2,
142         SENSOR_ACCURACY_VERYGOOD = 3
143 };
144
145 #define SENSOR_DATA_VALUE_SIZE 16
146
147 /* sensor_data_t */
148 typedef struct sensor_data_t {
149         int accuracy;
150         unsigned long long timestamp;
151         int value_count;
152         float values[SENSOR_DATA_VALUE_SIZE];
153 } sensor_data_t;
154
155 #define SENSORHUB_DATA_VALUE_SIZE 4096
156
157 /* sensorhub_data_t */
158 typedef struct sensorhub_data_t {
159         int accuracy;
160         unsigned long long timestamp;
161
162         /*
163          *  Use "value_count" instead of "hub_data_size"
164          *  which is going to be removed soon
165          */
166         union {
167                 int value_count;
168                 int hub_data_size; /* deprecated */
169         };
170
171         /*
172          *  Use "values" instead of "hub_data"
173          *  which is going to be removed soon
174          */
175         union {
176                 char values[SENSORHUB_DATA_VALUE_SIZE];
177                 char hub_data[SENSORHUB_DATA_VALUE_SIZE]; /* deprecated */
178         };
179 } sensorhub_data_t;
180
181 #define SENSOR_PEDOMETER_DATA_DIFFS_SIZE        20
182
183 typedef struct {
184         int accuracy;
185         unsigned long long timestamp;
186         int value_count;        /* value_count == 8 */
187         float values[SENSOR_DATA_VALUE_SIZE];
188         /* values = {step count, walk step count, run step count,
189                      moving distance, calorie burned, last speed,
190                      last stepping frequency (steps per sec),
191                      last step status (walking, running, ...)} */
192         /* Additional data attributes (not in sensor_data_t)*/
193         int diffs_count;
194         struct differences {
195                 int timestamp;
196                 int steps;
197                 int walk_steps;
198                 int run_steps;
199                 int walk_up_steps;
200                 int walk_down_steps;
201                 int run_up_steps;
202                 int run_down_steps;
203                 float distance;
204                 float calories;
205                 float speed;
206         } diffs[SENSOR_PEDOMETER_DATA_DIFFS_SIZE];
207 } sensor_pedometer_data_t;
208
209 enum sensor_attribute {
210         SENSOR_ATTR_ACTIVITY = 0x100,
211 };
212
213 enum sensor_activity {
214         SENSOR_ACTIVITY_UNKNOWN = 1,
215         SENSOR_ACTIVITY_STILL = 2,
216         SENSOR_ACTIVITY_WALKING = 4,
217         SENSOR_ACTIVITY_RUNNING = 8,
218         SENSOR_ACTIVITY_IN_VEHICLE = 16,
219         SENSOR_ACTIVITY_ON_BICYCLE = 32,
220 };
221
222 #ifdef __cplusplus
223 }
224 #endif /* __cplusplus */
225
226 #endif /* _SENSOR_HAL_TYPES_H_ */