Adding Tilt Sensor and related files
[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         PEDOMETER_SENSOR,
58         CONTEXT_SENSOR,
59         FLAT_SENSOR,
60         BIO_SENSOR,
61         BIO_HRM_SENSOR,
62         AUTO_ROTATION_SENSOR,
63         GRAVITY_SENSOR,
64         LINEAR_ACCEL_SENSOR,
65         ROTATION_VECTOR_SENSOR,
66         GEOMAGNETIC_RV_SENSOR,
67         GAMING_RV_SENSOR,
68         ORIENTATION_SENSOR,
69         TILT_SENSOR,
70         PIR_SENSOR,
71         PIR_LONG_SENSOR,
72         TEMPERATURE_SENSOR,
73         HUMIDITY_SENSOR,
74         ULTRAVIOLET_SENSOR,
75         DUST_SENSOR,
76         BIO_LED_GREEN_SENSOR,
77         BIO_LED_IR_SENSOR,
78         BIO_LED_RED_SENSOR,
79         RV_RAW_SENSOR,
80         UNCAL_GYROSCOPE_SENSOR,
81         UNCAL_GEOMAGNETIC_SENSOR
82 } sensor_type_t;
83
84 typedef unsigned int sensor_id_t;
85
86 typedef void *sensor_t;
87
88 typedef enum {
89         SENSOR_PRIVILEGE_PUBLIC,
90         SENSOR_PRIVILEGE_INTERNAL,
91 } sensor_privilege_t;
92
93
94 #define SENSOR_DATA_VALUE_SIZE 16
95
96 /*
97  *      When modifying it, check copy_sensor_data()
98  */
99 typedef struct sensor_data_t {
100 /*
101  *      Use "accuracy" instead of "data_accuracy"
102  *      which is going to be removed soon
103  */
104         union {
105                 int accuracy;
106                 int data_accuracy; //deprecated
107         };
108
109         union {
110                 unsigned long long timestamp;
111                 unsigned long long time_stamp; //deprecated
112         };
113
114 /*
115  *      Use "value_count" instead of "values_num"
116  *      which is going to be removed soon
117  */
118         union {
119                 int value_count;
120                 int values_num; //deprecated
121         };
122
123         float values[SENSOR_DATA_VALUE_SIZE];
124 } sensor_data_t;
125
126 #define SENSOR_HUB_DATA_SIZE    4096
127
128 typedef struct sensorhub_data_t {
129     int version;
130     int sensorhub;
131     int type;
132     int hub_data_size;
133     unsigned long long timestamp;
134     char hub_data[SENSOR_HUB_DATA_SIZE];
135     float data[16];
136 } sensorhub_data_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 /*
147  *      To prevent naming confliction as using same enums as sensor CAPI use
148  */
149 #ifndef __SENSOR_H__
150 enum sensor_option_t {
151         SENSOR_OPTION_DEFAULT = 0,
152         SENSOR_OPTION_ON_IN_SCREEN_OFF = 1,
153         SENSOR_OPTION_ON_IN_POWERSAVE_MODE = 2,
154         SENSOR_OPTION_ALWAYS_ON = SENSOR_OPTION_ON_IN_SCREEN_OFF | SENSOR_OPTION_ON_IN_POWERSAVE_MODE,
155         SENSOR_OPTION_END
156 };
157
158 typedef enum sensor_option_t sensor_option_e;
159 #endif
160
161 enum sensor_interval_t {
162         SENSOR_INTERVAL_FASTEST = 0,
163         SENSOR_INTERVAL_NORMAL = 200,
164 };
165
166
167 typedef enum {
168         CONDITION_NO_OP,
169         CONDITION_EQUAL,
170         CONDITION_GREAT_THAN,
171         CONDITION_LESS_THAN,
172 } condition_op_t;
173
174 #ifdef __cplusplus
175 }
176 #endif
177
178
179 #endif
180 //! End of a file