OSDN Git Service

libsensors: make the implementation be compatible with new IIO ABI
[android-x86/hardware-intel-libsensors.git] / common.h
1 /*
2  * Copyright (C) 2008 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_COMMON_H
18 #define ANDROID_SENSORS_COMMON_H
19
20 #include <linux/input.h>
21
22 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
23
24 #define ID_A  (0)
25 #define ID_M  (1)
26 #define ID_O  (2)
27 #define ID_L  (3)
28 #define ID_P  (4)
29 #define ID_GY (5)
30 #define ID_PR (6)
31 #define ID_T  (7)
32 #define ID_R  (8) // rotation vector
33 #define ID_SC (9) // "faked" level compass
34 #define MAX_SENSOR_CNT (ID_SC+1)
35
36 #define SENSORS_ACCELERATION     (1<<ID_A)
37 #define SENSORS_MAGNETIC_FIELD   (1<<ID_M)
38 #define SENSORS_ORIENTATION      (1<<ID_O)
39 #define SENSORS_LIGHT            (1<<ID_L)
40 #define SENSORS_PROXIMITY        (1<<ID_P)
41 #define SENSORS_GYROSCOPE        (1<<ID_GY)
42 #define SENSORS_PRESSURE         (1<<ID_PR)
43 #define SENSORS_TEMPERATURE      (1<<ID_T)
44 #define SENSORS_ROT_VEC          (1<<ID_R)
45 #define SENSORS_SYNCOMPASS       (1<<ID_SC)
46
47 #define SENSORS_ACCELERATION_HANDLE     0
48 #define SENSORS_MAGNETIC_FIELD_HANDLE   1
49 #define SENSORS_ORIENTATION_HANDLE      2
50 #define SENSORS_LIGHT_HANDLE            3
51 #define SENSORS_PROXIMITY_HANDLE        4
52 #define SENSORS_GYROSCOPE_HANDLE        5
53 #define SENSORS_PRESSURE_HANDLE         6
54 #define SENSORS_TEMPERATURE_HANDLE      7
55 #define SENSORS_ROT_VEC_HANDLE          8
56 #define SENSORS_SYNCOMPASS_HANDLE       9
57
58 /* The next one is used to set the timeout used for polling the file
59  * descriptors.
60  */
61 #define POLL_TIMEOUT_MSEC           3000L
62
63 #endif