1 /*
2  * Copyright (C) 2008-2014 The Android Open Source Project
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 #ifndef ANDROID_SENSORS_H
18 #define ANDROID_SENSORS_H
19 
20 #include <errno.h>
21 #include <stdint.h>
22 #include <sys/cdefs.h>
23 #include <sys/types.h>
24 
25 #include <linux/input.h>
26 
27 #include <hardware/hardware.h>
28 #include <hardware/sensors.h>
29 
30 __BEGIN_DECLS
31 
32 /*****************************************************************************/
33 
34 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
35 
36 #define ID_A                                        0//CW_ACCELERATION
37 #define ID_M                                        1//CW_MAGNETIC
38 #define ID_GY                                       2//CW_GYRO
39 #define ID_L                                        3//CW_LIGHT
40 #define ID_PS                                       4//CW_PRESSURE
41 #define ID_O                                        5//CW_ORIENTATION
42 #define ID_RV                                       6//CW_ROTATIONVECTOR
43 #define ID_LA                                       7//CW_LINEARACCELERATION
44 #define ID_G                                        8//CW_GRAVITY
45 
46 #define ID_CW_MAGNETIC_UNCALIBRATED                 9//CW_MAGNETIC_UNCALIBRATED
47 #define ID_CW_GYROSCOPE_UNCALIBRATED               10//CW_GYROSCOPE_UNCALIBRATED
48 #define ID_CW_GAME_ROTATION_VECTOR                 11//CW_GAME_ROTATION_VECTOR
49 #define ID_CW_GEOMAGNETIC_ROTATION_VECTOR          12//CW_GEOMAGNETIC_ROTATION_VECTOR
50 #define ID_CW_SIGNIFICANT_MOTION                   13//CW_SIGNIFICANT_MOTION
51 #define ID_CW_STEP_DETECTOR                        14//CW_STEP_DETECTOR
52 #define ID_CW_STEP_COUNTER                         15//CW_STEP_COUNTER
53 
54 #define ID_A_W                                     16//CW_ACCELERATION_WAKE_UP
55 #define ID_M_W                                     17//CW_MAGNETIC_WAKE_UP
56 #define ID_GY_W                                    18//CW_GYRO_WAKE_UP
57 #define ID_PS_W                                    19//CW_PRESSURE_WAKE_UP
58 #define ID_O_W                                     20//CW_ORIENTATION_WAKE_UP
59 #define ID_RV_W                                    21//CW_ROTATIONVECTOR_WAKE_UP
60 #define ID_LA_W                                    22//CW_LINEARACCELERATION_WAKE_UP
61 #define ID_G_W                                     23//CW_GRAVITY_WAKE_UP
62 #define ID_CW_MAGNETIC_UNCALIBRATED_W              24//CW_MAGNETIC_UNCALIBRATED_WAKE_UP
63 #define ID_CW_GYROSCOPE_UNCALIBRATED_W             25//CW_GYROSCOPE_UNCALIBRATED_WAKE_UP
64 #define ID_CW_GAME_ROTATION_VECTOR_W               26//CW_GAME_ROTATION_VECTOR_WAKE_UP
65 #define ID_CW_GEOMAGNETIC_ROTATION_VECTOR_W        27//CW_GEOMAGNETIC_ROTATION_VECTOR_WAKE_UP
66 #define ID_CW_STEP_DETECTOR_W                      28//CW_STEP_DETECTOR_WAKE_UP
67 #define ID_CW_STEP_COUNTER_W                       29//CW_STEP_COUNTER_WAKE_UP
68 /*****************************************************************************/
69 
70 // The SENSORS Module
71 #define EVENT_TYPE_LIGHT           ABS_MISC
72 
73 enum ABS_status {
74 	CW_ABS_X = 0x01,
75 	CW_ABS_Y,
76 	CW_ABS_Z,
77 	CW_ABS_X1,
78 	CW_ABS_Y1,
79 	CW_ABS_Z1,
80 	CW_ABS_TIMEDIFF,
81 	ABS_MAG_ACCURACY = 0x0A,
82 	ABS_ORI_ACCURACY = 0x0B,
83 	ABS_PRESSURE_X = 0x10,
84 	ABS_PRESSURE_Y = 0x11,
85 	ABS_PRESSURE_Z = 0x12,
86 	ABS_STEP_DETECTOR = 0x23,
87 	ABS_STEP_COUNTER = 0x24,
88 	ABS_TRANSPORT_BUFFER_FULL = 0x2E,
89 };
90 
91 #define CONVERT_A        0.01f
92 #define CONVERT_M        0.01f
93 #define CONVERT_GYRO     0.01f
94 #define CONVERT_PS       1.0f
95 #define CONVERT_O        0.1f
96 #define CONVERT_ALL      0.01f
97 #define CONVERT_PRESSURE 100
98 #define CONVERT_RV       10000
99 
100 #define CONVERT_1		1.0f
101 #define CONVERT_10		0.1f
102 #define CONVERT_100		0.01f
103 #define CONVERT_1000		0.001f
104 #define CONVERT_10000		0.0001f
105 
106 #define RANGE_A                     (4*GRAVITY_EARTH)
107 
108 #define SENSOR_STATE_MASK           (0x7FFF)
109 
110 /*****************************************************************************/
111 
112 __END_DECLS
113 
114 #endif  // ANDROID_SENSORS_H
115