1 /*
2  * Copyright (C) 2015 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 HUB_DEFS_H_
18 #define HUB_DEFS_H_
19 
20 #include <hardware/sensors.h>
21 
22 namespace android {
23 
24 #define CONTEXTHUB_SETTINGS_PATH        "/persist/sensorcal.json"
25 #define CONTEXTHUB_SAVED_SETTINGS_PATH  "/data/vendor/sensor/sensorcal_saved.json"
26 #define MAG_BIAS_FILE_PATH              "/sys/class/power_supply/battery/compass_compensation"
27 
28 static const uint32_t kMinClockRateHz = 960000;
29 static const uint32_t kClockRateHz = kMinClockRateHz * 5;  // 4.8MHz
30 
31 enum comms_sensor_t {
32     COMMS_SENSOR_INVALID                     = 0,
33     COMMS_SENSOR_ACCEL                       = 1,
34     COMMS_SENSOR_GYRO                        = 2,
35     COMMS_SENSOR_MAG                         = 3,
36     COMMS_SENSOR_PRESSURE                    = 4,
37     COMMS_SENSOR_TEMPERATURE                 = 5,
38     COMMS_SENSOR_PROXIMITY                   = 6,
39     COMMS_SENSOR_LIGHT                       = 7,
40     COMMS_SENSOR_ORIENTATION                 = 8,
41     COMMS_SENSOR_STEP_DETECTOR               = 9,
42     COMMS_SENSOR_ANY_MOTION                  = 10,
43     COMMS_SENSOR_NO_MOTION                   = 11,
44     COMMS_SENSOR_SIGNIFICANT_MOTION          = 12,
45     COMMS_SENSOR_FLAT                        = 13,
46     COMMS_SENSOR_GRAVITY                     = 14,
47     COMMS_SENSOR_LINEAR_ACCEL                = 15,
48     COMMS_SENSOR_ROTATION_VECTOR             = 16,
49     COMMS_SENSOR_HALL                        = 17,
50     COMMS_SENSOR_GEO_MAG                     = 18,
51     COMMS_SENSOR_GAME_ROTATION_VECTOR        = 19,
52     COMMS_SENSOR_GESTURE                     = 20,
53     COMMS_SENSOR_TILT                        = 21,
54     COMMS_SENSOR_MAG_BIAS                    = 22,
55     COMMS_SENSOR_STEP_COUNTER                = 23,
56     COMMS_SENSOR_MAG_UNCALIBRATED            = 24,
57     COMMS_SENSOR_GYRO_UNCALIBRATED           = 25,
58     COMMS_SENSOR_GYRO_BIAS                   = 26,
59     COMMS_SENSOR_SYNC                        = 27,
60     COMMS_SENSOR_DOUBLE_TWIST                = 28,
61     COMMS_SENSOR_DOUBLE_TAP                  = 29,
62     COMMS_SENSOR_WINDOW_ORIENTATION          = 30,
63     COMMS_SENSOR_WRIST_TILT                  = 31,
64     COMMS_SENSOR_ACCEL_BIAS                  = 32,
65     COMMS_SENSOR_DOUBLE_TOUCH                = 33,
66     COMMS_SENSOR_GAZE                        = 34,
67     COMMS_SENSOR_UNGAZE                      = 35,
68     COMMS_SENSOR_ACCEL_UNCALIBRATED          = 36,
69     COMMS_SENSOR_HUMIDITY                    = 37,
70     COMMS_SENSOR_ACCEL_WRIST_AWARE           = 38,
71     COMMS_SENSOR_GYRO_WRIST_AWARE            = 39,
72     COMMS_SENSOR_AMBIENT_TEMPERATURE         = 40,
73 
74     NUM_COMMS_SENSORS_PLUS_1,
75 
76     COMMS_SENSOR_DEBUG                       = 0x99,
77 };
78 
79 // Please keep existing values unchanged when adding or removing SENSOR_TYPE
80 enum {
81     SENSOR_TYPE_INTERNAL_TEMPERATURE    = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 0,
82     SENSOR_TYPE_SYNC                    = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 1,
83     SENSOR_TYPE_DOUBLE_TWIST            = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 2,
84     SENSOR_TYPE_DOUBLE_TAP              = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 3,
85     SENSOR_TYPE_DOUBLE_TOUCH            = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 4,
86     SENSOR_TYPE_GAZE                    = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 5,
87     SENSOR_TYPE_UNGAZE                  = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 6,
88     SENSOR_TYPE_ACCELEROMETER_WRIST_AWARE=SENSOR_TYPE_DEVICE_PRIVATE_BASE + 7,
89     SENSOR_TYPE_GYROSCOPE_WRIST_AWARE   = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 8,
90 };
91 
92 }  // namespace android
93 
94 #endif  // HUB_DEFS_H_
95