5bf16fe1ef5e88c0f0e96b39176324271b89eaf5
[platform/core/system/sensord.git] / src / shared / sensor_common.h
1 /*
2  * sensord
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 #include <stddef.h>
24 #include <stdint.h>
25 #include <sensor_hal_types.h>
26 #include <sensor_types.h>
27
28 #define OP_ERROR -1
29 #define OP_SUCCESS 0
30
31 #define CLIENT_ID_INVALID -1
32 #define SENSOR_ID_INVALID -1
33
34 #define SENSOR_TYPE_SHIFT 32
35 #define SENSOR_INDEX_MASK 0xFFFFFFFF
36
37 #ifndef NAME_MAX
38 #define NAME_MAX 256
39 #endif
40
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif
45
46 /*
47 typedef union {
48         struct {
49                 sensor_type_t type;
50                 int32_t id;
51         } __attribute__((packed));
52         int64_t id;
53 } sensor_id_t;
54 */
55 typedef int64_t sensor_id_t;
56
57 typedef void *sensor_t;
58
59 /*
60  *      To prevent naming confliction as using same enums as sensor CAPI use
61  */
62 #ifndef __SENSOR_H__
63 enum sensor_option_t {
64         SENSOR_OPTION_DEFAULT = 0,
65         SENSOR_OPTION_ON_IN_SCREEN_OFF = 1,
66         SENSOR_OPTION_ON_IN_POWERSAVE_MODE = 2,
67         SENSOR_OPTION_ALWAYS_ON = SENSOR_OPTION_ON_IN_SCREEN_OFF | SENSOR_OPTION_ON_IN_POWERSAVE_MODE,
68         SENSOR_OPTION_END
69 };
70
71 typedef enum sensor_option_t sensor_option_e;
72 #endif
73
74 enum poll_interval_t {
75         POLL_100HZ_MS   = 10,
76         POLL_50HZ_MS    = 20,
77         POLL_25HZ_MS    = 40,
78         POLL_20HZ_MS    = 50,
79         POLL_10HZ_MS    = 100,
80         POLL_5HZ_MS             = 200,
81         POLL_1HZ_MS             = 1000,
82         POLL_MAX_HZ_MS  = 255000,
83 };
84
85 enum sensor_interval_t {
86         SENSOR_INTERVAL_FASTEST = POLL_100HZ_MS,
87         SENSOR_INTERVAL_NORMAL = POLL_5HZ_MS,
88 };
89
90 typedef enum {
91         CONDITION_NO_OP,
92         CONDITION_EQUAL,
93         CONDITION_GREAT_THAN,
94         CONDITION_LESS_THAN,
95 } condition_op_t;
96
97 enum sensor_state_t {
98         SENSOR_STATE_UNKNOWN = -1,
99         SENSOR_STATE_STOPPED = 0,
100         SENSOR_STATE_STARTED = 1,
101         SENSOR_STATE_PAUSED = 2
102 };
103
104 typedef enum {
105         SENSOR_PRIVILEGE_PUBLIC,
106         SENSOR_PRIVILEGE_INTERNAL,
107 } sensor_privilege_t;
108
109 enum sensor_permission_t {
110         SENSOR_PERMISSION_NONE = 0,
111         SENSOR_PERMISSION_STANDARD = (1 << 0),
112         SENSOR_PERMISSION_BIO = (1 << 1)
113 };
114
115 typedef struct sensor_event_t {
116         unsigned int event_type;
117         sensor_id_t sensor_id;
118         unsigned int data_length;
119         sensor_data_t *data;
120 } sensor_event_t;
121
122 #ifdef __cplusplus
123 }
124 #endif
125
126 #ifdef __cplusplus
127 #include <vector>
128
129 typedef std::vector<unsigned int> event_type_vector;
130 #endif /* __cplusplus */
131
132 #endif /* __SENSOR_COMMON_H__ */