The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1 | /* |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 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_INTERFACE_H |
| 18 | #define ANDROID_SENSORS_INTERFACE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/cdefs.h> |
| 22 | #include <sys/types.h> |
| 23 | |
| 24 | #include <hardware/hardware.h> |
Mike Lockwood | 21b652f | 2009-05-22 10:05:48 -0400 | [diff] [blame] | 25 | #include <cutils/native_handle.h> |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 26 | |
| 27 | __BEGIN_DECLS |
| 28 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 29 | /*****************************************************************************/ |
| 30 | |
| 31 | #define SENSORS_HEADER_VERSION 1 |
| 32 | #define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) |
| 33 | #define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 34 | #define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 35 | #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 36 | #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 37 | #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 38 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 39 | /** |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 40 | * Please see the Sensors section of source.android.com for an |
| 41 | * introduction to and detailed descriptions of Android sensor types: |
| 42 | * http://source.android.com/devices/sensors/index.html |
| 43 | */ |
| 44 | |
| 45 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 46 | * The id of this module |
| 47 | */ |
| 48 | #define SENSORS_HARDWARE_MODULE_ID "sensors" |
| 49 | |
| 50 | /** |
| 51 | * Name of the sensors device to open |
| 52 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 53 | #define SENSORS_HARDWARE_POLL "poll" |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. |
| 57 | * A Handle identifies a given sensors. The handle is used to activate |
| 58 | * and/or deactivate sensors. |
| 59 | * In this version of the API there can only be 256 handles. |
| 60 | */ |
| 61 | #define SENSORS_HANDLE_BASE 0 |
| 62 | #define SENSORS_HANDLE_BITS 8 |
| 63 | #define SENSORS_HANDLE_COUNT (1<<SENSORS_HANDLE_BITS) |
| 64 | |
| 65 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 66 | /* |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 67 | * **** Deprecated ***** |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 68 | * flags for (*batch)() |
| 69 | * Availability: SENSORS_DEVICE_API_VERSION_1_0 |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 70 | * see (*batch)() documentation for details. |
| 71 | * Deprecated as of SENSORS_DEVICE_API_VERSION_1_3. |
| 72 | * WAKE_UP_* sensors replace WAKE_UPON_FIFO_FULL concept. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 73 | */ |
| 74 | enum { |
| 75 | SENSORS_BATCH_DRY_RUN = 0x00000001, |
| 76 | SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 |
| 77 | }; |
| 78 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 79 | /* |
| 80 | * what field for meta_data_event_t |
| 81 | */ |
| 82 | enum { |
| 83 | /* a previous flush operation has completed */ |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 84 | META_DATA_FLUSH_COMPLETE = 1, |
| 85 | META_DATA_VERSION /* always last, leave auto-assigned */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 88 | /* |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 89 | * The permission to use for body sensors (like heart rate monitors). |
| 90 | * See sensor types for more details on what sensors should require this |
| 91 | * permission. |
| 92 | */ |
| 93 | #define SENSOR_PERMISSION_BODY_SENSORS "android.permission.BODY_SENSORS" |
| 94 | |
| 95 | /* |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 96 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 97 | * Sensor flags used in sensor_t.flags. |
| 98 | */ |
| 99 | enum { |
| 100 | /* |
| 101 | * Whether this sensor wakes up the AP from suspend mode when data is available. |
| 102 | */ |
| 103 | SENSOR_FLAG_WAKE_UP = 1U << 0 |
| 104 | }; |
| 105 | |
| 106 | /* |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 107 | * Sensor type |
| 108 | * |
| 109 | * Each sensor has a type which defines what this sensor measures and how |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 110 | * measures are reported. See the Base sensors and Composite sensors lists |
| 111 | * for complete descriptions: |
| 112 | * http://source.android.com/devices/sensors/base_triggers.html |
| 113 | * http://source.android.com/devices/sensors/composite_sensors.html |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 114 | * |
| 115 | * Device manufacturers (OEMs) can define their own sensor types, for |
| 116 | * their private use by applications or services provided by them. Such |
| 117 | * sensor types are specific to an OEM and can't be exposed in the SDK. |
| 118 | * These types must start at SENSOR_TYPE_DEVICE_PRIVATE_BASE. |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 119 | * |
| 120 | * All sensors defined outside of the device private range must correspond to |
| 121 | * a type defined in this file, and must satisfy the characteristics listed in |
| 122 | * the description of the sensor type. |
| 123 | * |
| 124 | * Starting with version SENSORS_DEVICE_API_VERSION_1_2, each sensor also |
| 125 | * has a stringType. |
| 126 | * - StringType of sensors inside of the device private range MUST be prefixed |
| 127 | * by the sensor provider's or OEM reverse domain name. In particular, they |
| 128 | * cannot use the "android.sensor" prefix. |
| 129 | * - StringType of sensors outside of the device private range MUST correspond |
| 130 | * to the one defined in this file (starting with "android.sensor"). |
| 131 | * For example, accelerometers must have |
| 132 | * type=SENSOR_TYPE_ACCELEROMETER and |
| 133 | * stringType=SENSOR_STRING_TYPE_ACCELEROMETER |
| 134 | * |
| 135 | * When android introduces a new sensor type that can replace an OEM-defined |
| 136 | * sensor type, the OEM must use the official sensor type and stringType on |
| 137 | * versions of the HAL that support this new official sensor type. |
| 138 | * |
| 139 | * Example (made up): Suppose Google's Glass team wants to surface a sensor |
| 140 | * detecting that Glass is on a head. |
| 141 | * - Such a sensor is not officially supported in android KitKat |
| 142 | * - Glass devices launching on KitKat can implement a sensor with |
| 143 | * type = 0x10001 and stringType = "com.google.glass.onheaddetector" |
| 144 | * - In L android release, if android decides to define |
| 145 | * SENSOR_TYPE_ON_HEAD_DETECTOR and STRING_SENSOR_TYPE_ON_HEAD_DETECTOR, |
| 146 | * those types should replace the Glass-team-specific types in all future |
| 147 | * launches. |
| 148 | * - When launching glass on the L release, Google should now use the official |
| 149 | * type (SENSOR_TYPE_ON_HEAD_DETECTOR) and stringType. |
| 150 | * - This way, all applications can now use this sensor. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 151 | */ |
| 152 | |
| 153 | /* |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 154 | * Base for device manufacturers private sensor types. |
| 155 | * These sensor types can't be exposed in the SDK. |
| 156 | */ |
| 157 | #define SENSOR_TYPE_DEVICE_PRIVATE_BASE 0x10000 |
| 158 | |
| 159 | /* |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 160 | * SENSOR_TYPE_META_DATA |
| 161 | * trigger-mode: n/a |
| 162 | * wake-up sensor: n/a |
| 163 | * |
| 164 | * NO SENSOR OF THAT TYPE MUST BE RETURNED (*get_sensors_list)() |
| 165 | * |
| 166 | * SENSOR_TYPE_META_DATA is a special token used to populate the |
| 167 | * sensors_meta_data_event structure. It doesn't correspond to a physical |
| 168 | * sensor. sensors_meta_data_event are special, they exist only inside |
| 169 | * the HAL and are generated spontaneously, as opposed to be related to |
| 170 | * a physical sensor. |
| 171 | * |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 172 | * sensors_meta_data_event_t.version must be META_DATA_VERSION |
| 173 | * sensors_meta_data_event_t.sensor must be 0 |
| 174 | * sensors_meta_data_event_t.type must be SENSOR_TYPE_META_DATA |
| 175 | * sensors_meta_data_event_t.reserved must be 0 |
| 176 | * sensors_meta_data_event_t.timestamp must be 0 |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 177 | * |
| 178 | * The payload is a meta_data_event_t, where: |
| 179 | * meta_data_event_t.what can take the following values: |
| 180 | * |
| 181 | * META_DATA_FLUSH_COMPLETE |
| 182 | * This event indicates that a previous (*flush)() call has completed for the sensor |
| 183 | * handle specified in meta_data_event_t.sensor. |
| 184 | * see (*flush)() for more details |
| 185 | * |
| 186 | * All other values for meta_data_event_t.what are reserved and |
| 187 | * must not be used. |
| 188 | * |
| 189 | */ |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 190 | #define SENSOR_TYPE_META_DATA (0) |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 191 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 192 | /* |
| 193 | * SENSOR_TYPE_ACCELEROMETER |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 194 | * trigger-mode: continuous |
| 195 | * wake-up sensor: no |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 196 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 197 | * All values are in SI units (m/s^2) and measure the acceleration of the |
| 198 | * device minus the force of gravity. |
| 199 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 200 | */ |
| 201 | #define SENSOR_TYPE_ACCELEROMETER (1) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 202 | #define SENSOR_STRING_TYPE_ACCELEROMETER "android.sensor.accelerometer" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 203 | |
| 204 | /* |
| 205 | * SENSOR_TYPE_GEOMAGNETIC_FIELD |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 206 | * trigger-mode: continuous |
| 207 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 208 | * |
| 209 | * All values are in micro-Tesla (uT) and measure the geomagnetic |
| 210 | * field in the X, Y and Z axis. |
| 211 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 212 | */ |
| 213 | #define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) |
| 214 | #define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 215 | #define SENSOR_STRING_TYPE_MAGNETIC_FIELD "android.sensor.magnetic_field" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 216 | |
| 217 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 218 | * SENSOR_TYPE_ORIENTATION |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 219 | * trigger-mode: continuous |
| 220 | * wake-up sensor: no |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 221 | * |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 222 | * All values are angles in degrees. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 223 | * |
Mathias Agopian | 66a4095 | 2010-07-22 17:11:50 -0700 | [diff] [blame] | 224 | * Orientation sensors return sensor events for all 3 axes at a constant |
| 225 | * rate defined by setDelay(). |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 226 | */ |
| 227 | #define SENSOR_TYPE_ORIENTATION (3) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 228 | #define SENSOR_STRING_TYPE_ORIENTATION "android.sensor.orientation" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 229 | |
| 230 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 231 | * SENSOR_TYPE_GYROSCOPE |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 232 | * trigger-mode: continuous |
| 233 | * wake-up sensor: no |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 234 | * |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 235 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 236 | * around the X, Y and Z axis. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 237 | */ |
| 238 | #define SENSOR_TYPE_GYROSCOPE (4) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 239 | #define SENSOR_STRING_TYPE_GYROSCOPE "android.sensor.gyroscope" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 240 | |
| 241 | /* |
| 242 | * SENSOR_TYPE_LIGHT |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 243 | * trigger-mode: on-change |
| 244 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 245 | * |
| 246 | * The light sensor value is returned in SI lux units. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 247 | */ |
| 248 | #define SENSOR_TYPE_LIGHT (5) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 249 | #define SENSOR_STRING_TYPE_LIGHT "android.sensor.light" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 250 | |
| 251 | /* |
| 252 | * SENSOR_TYPE_PRESSURE |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 253 | * trigger-mode: continuous |
| 254 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 255 | * |
| 256 | * The pressure sensor return the athmospheric pressure in hectopascal (hPa) |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 257 | */ |
| 258 | #define SENSOR_TYPE_PRESSURE (6) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 259 | #define SENSOR_STRING_TYPE_PRESSURE "android.sensor.pressure" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 260 | |
| 261 | /* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */ |
| 262 | #define SENSOR_TYPE_TEMPERATURE (7) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 263 | #define SENSOR_STRING_TYPE_TEMPERATURE "android.sensor.temperature" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 264 | |
| 265 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 266 | * SENSOR_TYPE_PROXIMITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 267 | * trigger-mode: on-change |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 268 | * wake-up sensor: yes (set SENSOR_FLAG_WAKE_UP flag) |
Mike Lockwood | a241431 | 2009-11-03 10:29:50 -0500 | [diff] [blame] | 269 | * |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 270 | * The value corresponds to the distance to the nearest object in centimeters. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 271 | */ |
| 272 | #define SENSOR_TYPE_PROXIMITY (8) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 273 | #define SENSOR_STRING_TYPE_PROXIMITY "android.sensor.proximity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 274 | |
| 275 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 276 | * SENSOR_TYPE_GRAVITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 277 | * trigger-mode: continuous |
| 278 | * wake-up sensor: no |
Mathias Agopian | 42b743c | 2010-11-22 15:55:32 -0800 | [diff] [blame] | 279 | * |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 280 | * A gravity output indicates the direction of and magnitude of gravity in |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 281 | * the devices's coordinates. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 282 | */ |
| 283 | #define SENSOR_TYPE_GRAVITY (9) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 284 | #define SENSOR_STRING_TYPE_GRAVITY "android.sensor.gravity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 285 | |
| 286 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 287 | * SENSOR_TYPE_LINEAR_ACCELERATION |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 288 | * trigger-mode: continuous |
| 289 | * wake-up sensor: no |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 290 | * |
| 291 | * Indicates the linear acceleration of the device in device coordinates, |
| 292 | * not including gravity. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 293 | */ |
| 294 | #define SENSOR_TYPE_LINEAR_ACCELERATION (10) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 295 | #define SENSOR_STRING_TYPE_LINEAR_ACCELERATION "android.sensor.linear_acceleration" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 296 | |
| 297 | |
| 298 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 299 | * SENSOR_TYPE_ROTATION_VECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 300 | * trigger-mode: continuous |
| 301 | * wake-up sensor: no |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 302 | * |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 303 | * The rotation vector symbolizes the orientation of the device relative to the |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 304 | * East-North-Up coordinates frame. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 305 | */ |
| 306 | #define SENSOR_TYPE_ROTATION_VECTOR (11) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 307 | #define SENSOR_STRING_TYPE_ROTATION_VECTOR "android.sensor.rotation_vector" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 308 | |
| 309 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 310 | * SENSOR_TYPE_RELATIVE_HUMIDITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 311 | * trigger-mode: on-change |
| 312 | * wake-up sensor: no |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 313 | * |
| 314 | * A relative humidity sensor measures relative ambient air humidity and |
| 315 | * returns a value in percent. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 316 | */ |
| 317 | #define SENSOR_TYPE_RELATIVE_HUMIDITY (12) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 318 | #define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY "android.sensor.relative_humidity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 319 | |
| 320 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 321 | * SENSOR_TYPE_AMBIENT_TEMPERATURE |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 322 | * trigger-mode: on-change |
| 323 | * wake-up sensor: no |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 324 | * |
| 325 | * The ambient (room) temperature in degree Celsius. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 326 | */ |
| 327 | #define SENSOR_TYPE_AMBIENT_TEMPERATURE (13) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 328 | #define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE "android.sensor.ambient_temperature" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 329 | |
| 330 | /* |
| 331 | * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 332 | * trigger-mode: continuous |
| 333 | * wake-up sensor: no |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 334 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 335 | * Similar to SENSOR_TYPE_MAGNETIC_FIELD, but the hard iron calibration is |
| 336 | * reported separately instead of being included in the measurement. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 337 | */ |
| 338 | #define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 339 | #define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED "android.sensor.magnetic_field_uncalibrated" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 340 | |
| 341 | /* |
| 342 | * SENSOR_TYPE_GAME_ROTATION_VECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 343 | * trigger-mode: continuous |
| 344 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 345 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 346 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but not using the geomagnetic |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 347 | * field. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 348 | */ |
| 349 | #define SENSOR_TYPE_GAME_ROTATION_VECTOR (15) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 350 | #define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR "android.sensor.game_rotation_vector" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 351 | |
| 352 | /* |
| 353 | * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 354 | * trigger-mode: continuous |
| 355 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 356 | * |
| 357 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 358 | * around the X, Y and Z axis. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 359 | */ |
| 360 | #define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 361 | #define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED "android.sensor.gyroscope_uncalibrated" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 362 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 363 | /* |
| 364 | * SENSOR_TYPE_SIGNIFICANT_MOTION |
| 365 | * trigger-mode: one-shot |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 366 | * wake-up sensor: yes (set SENSOR_FLAG_WAKE_UP flag) |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 367 | * |
| 368 | * A sensor of this type triggers an event each time significant motion |
| 369 | * is detected and automatically disables itself. |
| 370 | * The only allowed value to return is 1.0. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 371 | */ |
| 372 | |
| 373 | #define SENSOR_TYPE_SIGNIFICANT_MOTION (17) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 374 | #define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION "android.sensor.significant_motion" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 375 | |
| 376 | /* |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 377 | * SENSOR_TYPE_STEP_DETECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 378 | * trigger-mode: special |
| 379 | * wake-up sensor: no |
| 380 | * |
| 381 | * A sensor of this type triggers an event each time a step is taken |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 382 | * by the user. The only allowed value to return is 1.0 and an event |
| 383 | * is generated for each step. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 384 | */ |
| 385 | |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 386 | #define SENSOR_TYPE_STEP_DETECTOR (18) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 387 | #define SENSOR_STRING_TYPE_STEP_DETECTOR "android.sensor.step_detector" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 388 | |
| 389 | |
| 390 | /* |
| 391 | * SENSOR_TYPE_STEP_COUNTER |
| 392 | * trigger-mode: on-change |
| 393 | * wake-up sensor: no |
| 394 | * |
| 395 | * A sensor of this type returns the number of steps taken by the user since |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 396 | * the last reboot while activated. The value is returned as a uint64_t and is |
Etienne Le Grand | f770b7a | 2013-07-10 14:08:40 -0700 | [diff] [blame] | 397 | * reset to zero only on a system / android reboot. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 398 | */ |
| 399 | |
| 400 | #define SENSOR_TYPE_STEP_COUNTER (19) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 401 | #define SENSOR_STRING_TYPE_STEP_COUNTER "android.sensor.step_counter" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 402 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 403 | /* |
| 404 | * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR |
| 405 | * trigger-mode: continuous |
| 406 | * wake-up sensor: no |
| 407 | * |
| 408 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but using a magnetometer instead |
| 409 | * of using a gyroscope. |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 410 | */ |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 411 | #define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20) |
| 412 | #define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR "android.sensor.geomagnetic_rotation_vector" |
| 413 | |
| 414 | /* |
| 415 | * SENSOR_TYPE_HEART_RATE |
| 416 | * trigger-mode: on-change |
| 417 | * wake-up sensor: no |
| 418 | * |
| 419 | * A sensor of this type returns the current heart rate if activated. |
| 420 | * The value is returned as a float which represents the heart rate in beats |
| 421 | * per minute (BPM). |
| 422 | * When the sensor cannot measure the heart rate, the returned value must be 0. |
| 423 | * sensor_t.requiredPermission must be set to SENSOR_PERMISSION_BODY_SENSORS. |
| 424 | */ |
| 425 | #define SENSOR_TYPE_HEART_RATE (21) |
| 426 | #define SENSOR_STRING_TYPE_HEART_RATE "android.sensor.heart_rate" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 427 | |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 428 | /* |
| 429 | * SENSOR_TYPE_NON_WAKE_UP_PROXIMITY_SENSOR |
| 430 | * Same as proximity_sensor but does not wake up the AP from suspend mode. |
| 431 | * wake-up sensor: no |
| 432 | */ |
| 433 | #define SENSOR_TYPE_NON_WAKE_UP_PROXIMITY_SENSOR (22) |
| 434 | #define SENSOR_STRING_TYPE_NON_WAKE_UP_PROXIMITY_SENSOR "android.sensor.non_wake_up_proximity_sensor" |
| 435 | |
| 436 | /* |
| 437 | * The sensors below are wake_up variants of the base sensor types defined |
| 438 | * above. When registered in batch mode, these sensors will wake up the AP when |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 439 | * their FIFOs are full or when the batch timeout expires. A separate FIFO has |
| 440 | * to be maintained for wake up sensors and non wake up sensors. The non wake-up |
| 441 | * sensors need to overwrite their FIFOs when they are full till the AP wakes up |
| 442 | * and the wake-up sensors will wake-up the AP when their FIFOs are full or when |
| 443 | * the batch timeout expires without losing events. |
| 444 | * Note: Sensors of type SENSOR_TYPE_PROXIMITY are also wake up sensors and |
| 445 | * should be treated as such. Wake-up one-shot sensors like SIGNIFICANT_MOTION |
| 446 | * cannot be batched, hence the text about batch above doesn't apply to them. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 447 | * |
| 448 | * Define these sensors only if: |
| 449 | * 1) batching is supported. |
| 450 | * 2) wake-up and non wake-up variants of each sensor can be activated at |
| 451 | * different rates. |
| 452 | * |
| 453 | * wake-up sensor: yes |
| 454 | * Set SENSOR_FLAG_WAKE_UP flag for all these sensors. |
| 455 | */ |
| 456 | #define SENSOR_TYPE_WAKE_UP_ACCELEROMETER (23) |
| 457 | #define SENSOR_STRING_TYPE_WAKE_UP_ACCELEROMETER "android.sensor.wake_up_accelerometer" |
| 458 | |
| 459 | #define SENSOR_TYPE_WAKE_UP_MAGNETIC_FIELD (24) |
| 460 | #define SENSOR_STRING_TYPE_WAKE_UP_MAGNETIC_FIELD "android.sensor.wake_up_magnetic_field" |
| 461 | |
| 462 | #define SENSOR_TYPE_WAKE_UP_ORIENTATION (25) |
| 463 | #define SENSOR_STRING_TYPE_WAKE_UP_ORIENTATION "android.sensor.wake_up_orientation" |
| 464 | |
| 465 | #define SENSOR_TYPE_WAKE_UP_GYROSCOPE (26) |
| 466 | #define SENSOR_STRING_TYPE_WAKE_UP_GYROSCOPE "android.sensor.wake_up_gyroscope" |
| 467 | |
| 468 | #define SENSOR_TYPE_WAKE_UP_LIGHT (27) |
| 469 | #define SENSOR_STRING_TYPE_WAKE_UP_LIGHT "android.sensor.wake_up_light" |
| 470 | |
| 471 | #define SENSOR_TYPE_WAKE_UP_PRESSURE (28) |
| 472 | #define SENSOR_STRING_TYPE_WAKE_UP_PRESSURE "android.sensor.wake_up_pressure" |
| 473 | |
| 474 | #define SENSOR_TYPE_WAKE_UP_GRAVITY (29) |
| 475 | #define SENSOR_STRING_TYPE_WAKE_UP_GRAVITY "android.sensor.wake_up_gravity" |
| 476 | |
| 477 | #define SENSOR_TYPE_WAKE_UP_LINEAR_ACCELERATION (30) |
| 478 | #define SENSOR_STRING_TYPE_WAKE_UP_LINEAR_ACCELERATION "android.sensor.wake_up_linear_acceleration" |
| 479 | |
| 480 | #define SENSOR_TYPE_WAKE_UP_ROTATION_VECTOR (31) |
| 481 | #define SENSOR_STRING_TYPE_WAKE_UP_ROTATION_VECTOR "android.sensor.wake_up_rotation_vector" |
| 482 | |
| 483 | #define SENSOR_TYPE_WAKE_UP_RELATIVE_HUMIDITY (32) |
| 484 | #define SENSOR_STRING_TYPE_WAKE_UP_RELATIVE_HUMIDITY "android.sensor.wake_up_relative_humidity" |
| 485 | |
| 486 | #define SENSOR_TYPE_WAKE_UP_AMBIENT_TEMPERATURE (33) |
| 487 | #define SENSOR_STRING_TYPE_WAKE_UP_AMBIENT_TEMPERATURE "android.sensor.wake_up_ambient_temperature" |
| 488 | |
| 489 | #define SENSOR_TYPE_WAKE_UP_MAGNETIC_FIELD_UNCALIBRATED (34) |
| 490 | #define SENSOR_STRING_TYPE_WAKE_UP_MAGNETIC_FIELD_UNCALIBRATED "android.sensor.wake_up_magnetic_field_uncalibrated" |
| 491 | |
| 492 | #define SENSOR_TYPE_WAKE_UP_GAME_ROTATION_VECTOR (35) |
| 493 | #define SENSOR_STRING_TYPE_WAKE_UP_GAME_ROTATION_VECTOR "android.sensor.wake_up_game_rotation_vector" |
| 494 | |
| 495 | #define SENSOR_TYPE_WAKE_UP_GYROSCOPE_UNCALIBRATED (36) |
| 496 | #define SENSOR_STRING_TYPE_WAKE_UP_GYROSCOPE_UNCALIBRATED "android.sensor.wake_up_gyroscope_uncalibrated" |
| 497 | |
| 498 | #define SENSOR_TYPE_WAKE_UP_STEP_DETECTOR (37) |
| 499 | #define SENSOR_STRING_TYPE_WAKE_UP_STEP_DETECTOR "android.sensor.wake_up_step_detector" |
| 500 | |
| 501 | #define SENSOR_TYPE_WAKE_UP_STEP_COUNTER (38) |
| 502 | #define SENSOR_STRING_TYPE_WAKE_UP_STEP_COUNTER "android.sensor.wake_up_step_counter" |
| 503 | |
| 504 | #define SENSOR_TYPE_WAKE_UP_GEOMAGNETIC_ROTATION_VECTOR (39) |
| 505 | #define SENSOR_STRING_TYPE_WAKE_UP_GEOMAGNETIC_ROTATION_VECTOR "android.sensor.wake_up_geomagnetic_rotation_vector" |
| 506 | |
| 507 | #define SENSOR_TYPE_WAKE_UP_HEART_RATE (40) |
| 508 | #define SENSOR_STRING_TYPE_WAKE_UP_HEART_RATE "android.sensor.wake_up_heart_rate" |
| 509 | |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 510 | /* |
| 511 | * SENSOR_TYPE_WAKE_UP_TILT_DETECTOR |
| 512 | * trigger-mode: special (setDelay has no impact) |
| 513 | * wake-up sensor: yes (set SENSOR_FLAG_WAKE_UP flag) |
| 514 | * |
| 515 | * A sensor of this type generates an event each time a tilt event is detected. A tilt event |
| 516 | * should be generated if the direction of the 2-seconds window average gravity changed by at least |
| 517 | * 35 degrees since the activation of the sensor. |
| 518 | * initial_estimated_gravity = average of accelerometer measurements over the first |
| 519 | * 1 second after activation. |
| 520 | * current_estimated_gravity = average of accelerometer measurements over the last 2 seconds. |
| 521 | * trigger when angle (initial_estimated_gravity, current_estimated_gravity) > 35 degrees |
| 522 | * |
| 523 | * Large accelerations without a change in phone orientation should not trigger a tilt event. |
| 524 | * For example, a sharp turn or strong acceleration while driving a car should not trigger a tilt |
| 525 | * event, even though the angle of the average acceleration might vary by more than 35 degrees. |
| 526 | * |
| 527 | * Typically, this sensor is implemented with the help of only an accelerometer. Other sensors can |
| 528 | * be used as well if they do not increase the power consumption significantly. This is a low power |
| 529 | * sensor that should allow the AP to go into suspend mode. Do not emulate this sensor in the HAL. |
| 530 | * Like other wake up sensors, the driver is expected to a hold a wake_lock with a timeout of 200 ms |
| 531 | * while reporting this event. The only allowed return value is 1.0. |
| 532 | */ |
| 533 | #define SENSOR_TYPE_WAKE_UP_TILT_DETECTOR (41) |
| 534 | #define SENSOR_STRING_TYPE_WAKE_UP_TILT_DETECTOR "android.sensor.wake_up_tilt_detector" |
| 535 | |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame^] | 536 | /* |
| 537 | * SENSOR_TYPE_WAKE_GESTURE |
| 538 | * trigger-mode: one-shot |
| 539 | * wake-up sensor: yes (set SENSOR_FLAG_WAKE_UP flag) |
| 540 | * |
| 541 | * A sensor enabling waking up the device based on a device specific motion. |
| 542 | * |
| 543 | * When this sensor triggers, the device behaves as if the power button was |
| 544 | * pressed, turning the screen on. This behavior (turning on the screen when |
| 545 | * this sensor triggers) might be deactivated by the user in the device |
| 546 | * settings. Changes in settings do not impact the behavior of the sensor: |
| 547 | * only whether the framework turns the screen on when it triggers. |
| 548 | * |
| 549 | * The actual gesture to be detected is not specified, and can be chosen by |
| 550 | * the manufacturer of the device. |
| 551 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 552 | * The only allowed value to return is 1.0. |
| 553 | */ |
| 554 | #define SENSOR_TYPE_WAKE_GESTURE (42) |
| 555 | #define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture" |
| 556 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 557 | /** |
| 558 | * Values returned by the accelerometer in various locations in the universe. |
| 559 | * all values are in SI units (m/s^2) |
| 560 | */ |
| 561 | #define GRAVITY_SUN (275.0f) |
| 562 | #define GRAVITY_EARTH (9.80665f) |
| 563 | |
| 564 | /** Maximum magnetic field on Earth's surface */ |
| 565 | #define MAGNETIC_FIELD_EARTH_MAX (60.0f) |
| 566 | |
| 567 | /** Minimum magnetic field on Earth's surface */ |
| 568 | #define MAGNETIC_FIELD_EARTH_MIN (30.0f) |
| 569 | |
| 570 | |
| 571 | /** |
| 572 | * status of orientation sensor |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 573 | */ |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 574 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 575 | #define SENSOR_STATUS_UNRELIABLE 0 |
| 576 | #define SENSOR_STATUS_ACCURACY_LOW 1 |
| 577 | #define SENSOR_STATUS_ACCURACY_MEDIUM 2 |
| 578 | #define SENSOR_STATUS_ACCURACY_HIGH 3 |
| 579 | |
| 580 | |
| 581 | /** |
| 582 | * sensor event data |
| 583 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 584 | typedef struct { |
| 585 | union { |
| 586 | float v[3]; |
| 587 | struct { |
| 588 | float x; |
| 589 | float y; |
| 590 | float z; |
| 591 | }; |
| 592 | struct { |
| 593 | float azimuth; |
| 594 | float pitch; |
| 595 | float roll; |
| 596 | }; |
| 597 | }; |
| 598 | int8_t status; |
| 599 | uint8_t reserved[3]; |
| 600 | } sensors_vec_t; |
| 601 | |
| 602 | /** |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 603 | * uncalibrated gyroscope and magnetometer event data |
| 604 | */ |
| 605 | typedef struct { |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 606 | union { |
| 607 | float uncalib[3]; |
| 608 | struct { |
| 609 | float x_uncalib; |
| 610 | float y_uncalib; |
| 611 | float z_uncalib; |
| 612 | }; |
| 613 | }; |
| 614 | union { |
| 615 | float bias[3]; |
| 616 | struct { |
| 617 | float x_bias; |
| 618 | float y_bias; |
| 619 | float z_bias; |
| 620 | }; |
| 621 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 622 | } uncalibrated_event_t; |
| 623 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 624 | typedef struct meta_data_event { |
| 625 | int32_t what; |
| 626 | int32_t sensor; |
| 627 | } meta_data_event_t; |
| 628 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 629 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 630 | * Union of the various types of sensor data |
| 631 | * that can be returned. |
| 632 | */ |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 633 | typedef struct sensors_event_t { |
| 634 | /* must be sizeof(struct sensors_event_t) */ |
| 635 | int32_t version; |
| 636 | |
| 637 | /* sensor identifier */ |
| 638 | int32_t sensor; |
| 639 | |
| 640 | /* sensor type */ |
| 641 | int32_t type; |
| 642 | |
| 643 | /* reserved */ |
| 644 | int32_t reserved0; |
| 645 | |
| 646 | /* time is in nanosecond */ |
| 647 | int64_t timestamp; |
| 648 | |
| 649 | union { |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 650 | union { |
| 651 | float data[16]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 652 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 653 | /* acceleration values are in meter per second per second (m/s^2) */ |
| 654 | sensors_vec_t acceleration; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 655 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 656 | /* magnetic vector values are in micro-Tesla (uT) */ |
| 657 | sensors_vec_t magnetic; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 658 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 659 | /* orientation values are in degrees */ |
| 660 | sensors_vec_t orientation; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 661 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 662 | /* gyroscope values are in rad/s */ |
| 663 | sensors_vec_t gyro; |
Makarand Karvekar | 3120b58 | 2010-08-11 15:10:10 -0700 | [diff] [blame] | 664 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 665 | /* temperature is in degrees centigrade (Celsius) */ |
| 666 | float temperature; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 667 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 668 | /* distance in centimeters */ |
| 669 | float distance; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 670 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 671 | /* light in SI lux units */ |
| 672 | float light; |
Mathias Agopian | 1832f55 | 2010-07-29 15:22:30 -0700 | [diff] [blame] | 673 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 674 | /* pressure in hectopascal (hPa) */ |
| 675 | float pressure; |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 676 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 677 | /* relative humidity in percent */ |
| 678 | float relative_humidity; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 679 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 680 | /* uncalibrated gyroscope values are in rad/s */ |
| 681 | uncalibrated_event_t uncalibrated_gyro; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 682 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 683 | /* uncalibrated magnetometer values are in micro-Teslas */ |
| 684 | uncalibrated_event_t uncalibrated_magnetic; |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 685 | |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 686 | /* heart rate in bpm */ |
| 687 | float heart_rate; |
| 688 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 689 | /* this is a special event. see SENSOR_TYPE_META_DATA above. |
| 690 | * sensors_meta_data_event_t events are all reported with a type of |
| 691 | * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. |
| 692 | */ |
| 693 | meta_data_event_t meta_data; |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 694 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 695 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 696 | union { |
| 697 | uint64_t data[8]; |
| 698 | |
| 699 | /* step-counter */ |
| 700 | uint64_t step_counter; |
| 701 | } u64; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 702 | }; |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 703 | |
| 704 | /* Reserved flags for internal use. Set to zero. */ |
| 705 | uint32_t flags; |
| 706 | |
| 707 | uint32_t reserved1[3]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 708 | } sensors_event_t; |
| 709 | |
| 710 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 711 | /* see SENSOR_TYPE_META_DATA */ |
| 712 | typedef sensors_event_t sensors_meta_data_event_t; |
| 713 | |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 714 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 715 | struct sensor_t; |
| 716 | |
| 717 | /** |
| 718 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 719 | * and the fields of this data structure must begin with hw_module_t |
| 720 | * followed by module specific information. |
| 721 | */ |
| 722 | struct sensors_module_t { |
| 723 | struct hw_module_t common; |
| 724 | |
| 725 | /** |
| 726 | * Enumerate all available sensors. The list is returned in "list". |
| 727 | * @return number of sensors in the list |
| 728 | */ |
| 729 | int (*get_sensors_list)(struct sensors_module_t* module, |
| 730 | struct sensor_t const** list); |
| 731 | }; |
| 732 | |
| 733 | struct sensor_t { |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 734 | |
| 735 | /* Name of this sensor. |
| 736 | * All sensors of the same "type" must have a different "name". |
| 737 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 738 | const char* name; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 739 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 740 | /* vendor of the hardware part */ |
| 741 | const char* vendor; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 742 | |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 743 | /* version of the hardware part + driver. The value of this field |
| 744 | * must increase when the driver is updated in a way that changes the |
| 745 | * output of this sensor. This is important for fused sensors when the |
| 746 | * fusion algorithm is updated. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 747 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 748 | int version; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 749 | |
| 750 | /* handle that identifies this sensors. This handle is used to reference |
| 751 | * this sensor throughout the HAL API. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 752 | */ |
| 753 | int handle; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 754 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 755 | /* this sensor's type. */ |
| 756 | int type; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 757 | |
| 758 | /* maximum range of this sensor's value in SI units */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 759 | float maxRange; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 760 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 761 | /* smallest difference between two values reported by this sensor */ |
| 762 | float resolution; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 763 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 764 | /* rough estimate of this sensor's power consumption in mA */ |
| 765 | float power; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 766 | |
| 767 | /* this value depends on the trigger mode: |
| 768 | * |
| 769 | * continuous: minimum sample period allowed in microseconds |
| 770 | * on-change : 0 |
| 771 | * one-shot :-1 |
| 772 | * special : 0, unless otherwise noted |
| 773 | */ |
Mathias Agopian | 1511e20 | 2010-07-29 15:33:22 -0700 | [diff] [blame] | 774 | int32_t minDelay; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 775 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 776 | /* number of events reserved for this sensor in the batch mode FIFO. |
| 777 | * If there is a dedicated FIFO for this sensor, then this is the |
| 778 | * size of this FIFO. If the FIFO is shared with other sensors, |
| 779 | * this is the size reserved for that sensor and it can be zero. |
| 780 | */ |
| 781 | uint32_t fifoReservedEventCount; |
| 782 | |
| 783 | /* maximum number of events of this sensor that could be batched. |
| 784 | * This is especially relevant when the FIFO is shared between |
| 785 | * several sensors; this value is then set to the size of that FIFO. |
| 786 | */ |
| 787 | uint32_t fifoMaxEventCount; |
| 788 | |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 789 | /* type of this sensor as a string. Set to corresponding |
| 790 | * SENSOR_STRING_TYPE_*. |
| 791 | * When defining an OEM specific sensor or sensor manufacturer specific |
| 792 | * sensor, use your reserve domain name as a prefix. |
| 793 | * ex: com.google.glass.onheaddetector |
| 794 | * For sensors of known type, the android framework might overwrite this |
| 795 | * string automatically. |
| 796 | */ |
| 797 | const char* stringType; |
| 798 | |
| 799 | /* permission required to see this sensor, register to it and receive data. |
| 800 | * Set to "" if no permission is required. Some sensor types like the |
| 801 | * heart rate monitor have a mandatory require_permission. |
| 802 | * For sensors that always require a specific permission, like the heart |
| 803 | * rate monitor, the android framework might overwrite this string |
| 804 | * automatically. |
| 805 | */ |
| 806 | const char* requiredPermission; |
| 807 | |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 808 | /* This value is defined only for continuous mode sensors. It is the delay between two |
| 809 | * sensor events corresponding to the lowest frequency that this sensor supports. When |
| 810 | * lower frequencies are requested through batch()/setDelay() the events will be generated |
| 811 | * at this frequency instead. It can be used by the framework or applications to estimate |
| 812 | * when the batch FIFO may be full. |
| 813 | * NOTE: period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. |
| 814 | * continuous: maximum sampling period allowed in microseconds. |
| 815 | * on-change, one-shot, special : -1 |
| 816 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 817 | */ |
| 818 | #ifdef __LP64__ |
| 819 | int64_t maxDelay; |
| 820 | #else |
| 821 | int32_t maxDelay; |
| 822 | #endif |
| 823 | |
| 824 | /* Flags for sensor. See SENSOR_FLAG_* above. */ |
| 825 | #ifdef __LP64__ |
| 826 | uint64_t flags; |
| 827 | #else |
| 828 | uint32_t flags; |
| 829 | #endif |
| 830 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 831 | /* reserved fields, must be zero */ |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 832 | void* reserved[2]; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 833 | }; |
| 834 | |
| 835 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 836 | /* |
| 837 | * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 |
| 838 | * and is present for backward binary and source compatibility. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 839 | * See the Sensors HAL interface section for complete descriptions of the |
| 840 | * following functions: |
| 841 | * http://source.android.com/devices/sensors/index.html#hal |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 842 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 843 | struct sensors_poll_device_t { |
| 844 | struct hw_device_t common; |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 845 | int (*activate)(struct sensors_poll_device_t *dev, |
| 846 | int handle, int enabled); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 847 | int (*setDelay)(struct sensors_poll_device_t *dev, |
| 848 | int handle, int64_t ns); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 849 | int (*poll)(struct sensors_poll_device_t *dev, |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 850 | sensors_event_t* data, int count); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 851 | }; |
| 852 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 853 | /* |
| 854 | * struct sensors_poll_device_1 is used with SENSORS_DEVICE_API_VERSION_1_0 |
| 855 | */ |
| 856 | typedef struct sensors_poll_device_1 { |
| 857 | union { |
| 858 | /* sensors_poll_device_1 is compatible with sensors_poll_device_t, |
| 859 | * and can be down-cast to it |
| 860 | */ |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 861 | struct sensors_poll_device_t v0; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 862 | |
| 863 | struct { |
| 864 | struct hw_device_t common; |
| 865 | |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 866 | /* Activate/de-activate one sensor. Return 0 on success, negative |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 867 | * |
| 868 | * handle is the handle of the sensor to change. |
| 869 | * enabled set to 1 to enable, or 0 to disable the sensor. |
| 870 | * |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 871 | * Return 0 on success, negative errno code otherwise. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 872 | */ |
| 873 | int (*activate)(struct sensors_poll_device_t *dev, |
| 874 | int handle, int enabled); |
| 875 | |
| 876 | /** |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 877 | * Set the events's period in nanoseconds for a given sensor. If |
| 878 | * period_ns > max_delay it will be truncated to max_delay and if |
| 879 | * period_ns < min_delay it will be replaced by min_delay. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 880 | */ |
| 881 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 882 | int handle, int64_t period_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 883 | |
| 884 | /** |
| 885 | * Returns an array of sensor data. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 886 | */ |
| 887 | int (*poll)(struct sensors_poll_device_t *dev, |
| 888 | sensors_event_t* data, int count); |
| 889 | }; |
| 890 | }; |
| 891 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 892 | |
| 893 | /* |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 894 | * Enables batch mode for the given sensor and sets the delay between events. |
| 895 | * See the Batching sensor results page for details: |
| 896 | * http://source.android.com/devices/sensors/batching.html |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 897 | */ |
| 898 | int (*batch)(struct sensors_poll_device_1* dev, |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 899 | int handle, int flags, int64_t period_ns, int64_t timeout); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 900 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 901 | /* |
| 902 | * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) |
| 903 | * to the end of the "batch mode" FIFO for the specified sensor and flushes |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 904 | * the FIFO. |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 905 | */ |
| 906 | int (*flush)(struct sensors_poll_device_1* dev, int handle); |
| 907 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 908 | void (*reserved_procs[8])(void); |
| 909 | |
| 910 | } sensors_poll_device_1_t; |
| 911 | |
| 912 | |
| 913 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 914 | /** convenience API for opening and closing a device */ |
| 915 | |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 916 | static inline int sensors_open(const struct hw_module_t* module, |
| 917 | struct sensors_poll_device_t** device) { |
| 918 | return module->methods->open(module, |
| 919 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 920 | } |
| 921 | |
| 922 | static inline int sensors_close(struct sensors_poll_device_t* device) { |
| 923 | return device->common.close(&device->common); |
| 924 | } |
| 925 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 926 | static inline int sensors_open_1(const struct hw_module_t* module, |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 927 | sensors_poll_device_1_t** device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 928 | return module->methods->open(module, |
| 929 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 930 | } |
| 931 | |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 932 | static inline int sensors_close_1(sensors_poll_device_1_t* device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 933 | return device->common.close(&device->common); |
| 934 | } |
| 935 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 936 | __END_DECLS |
| 937 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 938 | #endif // ANDROID_SENSORS_INTERFACE_H |