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