4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef __SENSOR_COMMON_H__
21 #define __SENSOR_COMMON_H__
25 #include <sensor_hal_types.h>
26 #include <sensor_types.h>
31 #define CLIENT_ID_INVALID -1
32 #define SENSOR_ID_INVALID -1
34 #define SENSOR_TYPE_SHIFT 32
35 #define SENSOR_EVENT_SHIFT 16
36 #define SENSOR_INDEX_MASK 0xFFFFFFFF
38 #define CONVERT_ID_TYPE(id) ((id) >> SENSOR_TYPE_SHIFT)
39 #define CONVERT_TYPE_EVENT(type) ((type) << SENSOR_EVENT_SHIFT | 0x1)
55 } __attribute__((packed));
59 typedef int64_t sensor_id_t;
61 typedef void *sensor_t;
64 * To prevent naming confliction as using same enums as sensor CAPI use
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,
75 typedef enum sensor_option_t sensor_option_e;
78 enum poll_interval_t {
86 POLL_MAX_HZ_MS = 255000,
89 enum sensor_interval_t {
90 SENSOR_INTERVAL_FASTEST = POLL_100HZ_MS,
91 SENSOR_INTERVAL_NORMAL = POLL_5HZ_MS,
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
109 SENSOR_PRIVILEGE_PUBLIC,
110 SENSOR_PRIVILEGE_INTERNAL,
111 } sensor_privilege_t;
113 enum sensor_permission_t {
114 SENSOR_PERMISSION_NONE = 0,
115 SENSOR_PERMISSION_STANDARD = (1 << 0),
116 SENSOR_PERMISSION_BIO = (1 << 1)
119 typedef struct sensor_event_t {
120 unsigned int event_type;
121 sensor_id_t sensor_id;
122 unsigned int data_length;
133 typedef std::vector<unsigned int> event_type_vector;
134 #endif /* __cplusplus */
136 #endif /* __SENSOR_COMMON_H__ */