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 | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 35 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 36 | /** |
| 37 | * The id of this module |
| 38 | */ |
| 39 | #define SENSORS_HARDWARE_MODULE_ID "sensors" |
| 40 | |
| 41 | /** |
| 42 | * Name of the sensors device to open |
| 43 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 44 | #define SENSORS_HARDWARE_POLL "poll" |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. |
| 48 | * A Handle identifies a given sensors. The handle is used to activate |
| 49 | * and/or deactivate sensors. |
| 50 | * In this version of the API there can only be 256 handles. |
| 51 | */ |
| 52 | #define SENSORS_HANDLE_BASE 0 |
| 53 | #define SENSORS_HANDLE_BITS 8 |
| 54 | #define SENSORS_HANDLE_COUNT (1<<SENSORS_HANDLE_BITS) |
| 55 | |
| 56 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 57 | /* attributes queriable with query() */ |
| 58 | enum { |
| 59 | /* |
| 60 | * Availability: SENSORS_DEVICE_API_VERSION_1_0 |
| 61 | * return the maximum number of events that can be returned |
| 62 | * in a single call to (*poll)(). This value is used by the |
| 63 | * framework to adequately dimension the buffer passed to |
| 64 | * (*poll)(), note that (*poll)() still needs to pay attention to |
| 65 | * the count parameter passed to it, it cannot blindly expect that |
| 66 | * this value will be used for all calls to (*poll)(). |
| 67 | * |
| 68 | * Generally this value should be set to match the sum of the internal |
| 69 | * FIFOs of all available sensors. |
| 70 | */ |
| 71 | SENSORS_QUERY_MAX_EVENTS_BATCH_COUNT = 0 |
| 72 | }; |
| 73 | |
| 74 | /* |
| 75 | * flags for (*batch)() |
| 76 | * Availability: SENSORS_DEVICE_API_VERSION_1_0 |
| 77 | * see (*batch)() documentation for details |
| 78 | */ |
| 79 | enum { |
| 80 | SENSORS_BATCH_DRY_RUN = 0x00000001, |
| 81 | SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 |
| 82 | }; |
| 83 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 84 | /** |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 85 | * Definition of the axis used by the sensor HAL API |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 86 | * |
| 87 | * This API is relative to the screen of the device in its default orientation, |
| 88 | * that is, if the device can be used in portrait or landscape, this API |
| 89 | * is only relative to the NATURAL orientation of the screen. In other words, |
| 90 | * the axis are not swapped when the device's screen orientation changes. |
| 91 | * Higher level services /may/ perform this transformation. |
| 92 | * |
| 93 | * x<0 x>0 |
| 94 | * ^ |
| 95 | * | |
| 96 | * +-----------+--> y>0 |
| 97 | * | | |
| 98 | * | | |
| 99 | * | | |
| 100 | * | | / z<0 |
| 101 | * | | / |
| 102 | * | | / |
| 103 | * O-----------+/ |
| 104 | * |[] [ ] []/ |
| 105 | * +----------/+ y<0 |
| 106 | * / |
| 107 | * / |
| 108 | * |/ z>0 (toward the sky) |
| 109 | * |
| 110 | * O: Origin (x=0,y=0,z=0) |
| 111 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 112 | */ |
| 113 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 114 | /* |
| 115 | * Interaction with suspend mode |
| 116 | * |
| 117 | * Unless otherwise noted, an enabled sensor shall not prevent the |
| 118 | * SoC to go into suspend mode. It is the responsibility of applications |
| 119 | * to keep a partial wake-lock should they wish to receive sensor |
| 120 | * events while the screen is off. While in suspend mode, and unless |
| 121 | * otherwise noted, enabled sensors' events are lost. |
| 122 | * |
| 123 | * Note that conceptually, the sensor itself is not de-activated while in |
| 124 | * suspend mode -- it's just that the data it returns are lost. As soon as |
| 125 | * the SoC gets out of suspend mode, operations resume as usual. Of course, |
| 126 | * in practice sensors shall be disabled while in suspend mode to |
| 127 | * save power, unless batch mode is active, in which case they must |
| 128 | * continue fill their internal FIFO (see the documentation of batch() to |
| 129 | * learn how suspend interacts with batch mode). |
| 130 | * |
| 131 | * In batch mode and only when the flag SENSORS_BATCH_WAKE_UPON_FIFO_FULL is |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 132 | * set and supported, the specified sensor must be able to wake-up the SoC and |
| 133 | * be able to buffer at least 10 seconds worth of the requested sensor events. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 134 | * |
| 135 | * There are notable exceptions to this behavior, which are sensor-dependent |
| 136 | * (see sensor types definitions below) |
| 137 | * |
| 138 | * |
| 139 | * The sensor type documentation below specifies the wake-up behavior of |
| 140 | * each sensor: |
| 141 | * wake-up: yes this sensor must wake-up the SoC to deliver events |
| 142 | * wake-up: no this sensor shall not wake-up the SoC, events are dropped |
| 143 | * |
| 144 | */ |
| 145 | |
| 146 | /* |
| 147 | * Sensor type |
| 148 | * |
| 149 | * Each sensor has a type which defines what this sensor measures and how |
| 150 | * measures are reported. All types are defined below. |
| 151 | */ |
| 152 | |
| 153 | /* |
| 154 | * Sensor fusion and virtual sensors |
| 155 | * |
| 156 | * Many sensor types are or can be implemented as virtual sensors from |
| 157 | * physical sensors on the device. For instance the rotation vector sensor, |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 158 | * orientation sensor, step-detector, step-counter, etc... |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 159 | * |
| 160 | * From the point of view of this API these virtual sensors MUST appear as |
| 161 | * real, individual sensors. It is the responsibility of the driver and HAL |
| 162 | * to make sure this is the case. |
| 163 | * |
| 164 | * In particular, all sensors must be able to function concurrently. |
| 165 | * For example, if defining both an accelerometer and a step counter, |
| 166 | * then both must be able to work concurrently. |
| 167 | */ |
| 168 | |
| 169 | /* |
| 170 | * Trigger modes |
| 171 | * |
| 172 | * Sensors can report events in different ways called trigger modes, |
| 173 | * each sensor type has one and only one trigger mode associated to it. |
| 174 | * Currently there are four trigger modes defined: |
| 175 | * |
| 176 | * continuous: events are reported at a constant rate defined by setDelay(). |
| 177 | * eg: accelerometers, gyroscopes. |
| 178 | * on-change: events are reported only if the sensor's value has changed. |
| 179 | * setDelay() is used to set a lower limit to the reporting |
| 180 | * period (minimum time between two events). |
| 181 | * The HAL must return an event immediately when an on-change |
| 182 | * sensor is activated. |
| 183 | * eg: proximity, light sensors |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 184 | * one-shot: upon detection of an event, the sensor deactivates itself and |
| 185 | * then sends a single event. Order matters to avoid race |
| 186 | * conditions. No other event is sent until the sensor get |
| 187 | * reactivated. setDelay() is ignored. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 188 | * eg: significant motion sensor |
| 189 | * special: see details in the sensor type specification below |
| 190 | * |
| 191 | */ |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 192 | |
| 193 | /* |
| 194 | * SENSOR_TYPE_ACCELEROMETER |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 195 | * trigger-mode: continuous |
| 196 | * wake-up sensor: no |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 197 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 198 | * All values are in SI units (m/s^2) and measure the acceleration of the |
| 199 | * device minus the force of gravity. |
| 200 | * |
| 201 | * Acceleration sensors return sensor events for all 3 axes at a constant |
| 202 | * rate defined by setDelay(). |
| 203 | * |
| 204 | * x: Acceleration on the x-axis |
| 205 | * y: Acceleration on the y-axis |
| 206 | * z: Acceleration on the z-axis |
| 207 | * |
| 208 | * Note that the readings from the accelerometer include the acceleration |
| 209 | * due to gravity (which is opposite to the direction of the gravity vector). |
| 210 | * |
| 211 | * Examples: |
| 212 | * The norm of <x, y, z> should be close to 0 when in free fall. |
| 213 | * |
| 214 | * When the device lies flat on a table and is pushed on its left side |
| 215 | * toward the right, the x acceleration value is positive. |
| 216 | * |
| 217 | * When the device lies flat on a table, the acceleration value is +9.81, |
| 218 | * which correspond to the acceleration of the device (0 m/s^2) minus the |
| 219 | * force of gravity (-9.81 m/s^2). |
| 220 | * |
| 221 | * When the device lies flat on a table and is pushed toward the sky, the |
| 222 | * acceleration value is greater than +9.81, which correspond to the |
| 223 | * acceleration of the device (+A m/s^2) minus the force of |
| 224 | * gravity (-9.81 m/s^2). |
| 225 | */ |
| 226 | #define SENSOR_TYPE_ACCELEROMETER (1) |
| 227 | |
| 228 | /* |
| 229 | * SENSOR_TYPE_GEOMAGNETIC_FIELD |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 230 | * trigger-mode: continuous |
| 231 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 232 | * |
| 233 | * All values are in micro-Tesla (uT) and measure the geomagnetic |
| 234 | * field in the X, Y and Z axis. |
| 235 | * |
| 236 | * Returned values include calibration mechanisms such that the vector is |
| 237 | * aligned with the magnetic declination and heading of the earth's |
| 238 | * geomagnetic field. |
| 239 | * |
| 240 | * Magnetic Field sensors return sensor events for all 3 axes at a constant |
| 241 | * rate defined by setDelay(). |
| 242 | */ |
| 243 | #define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) |
| 244 | #define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD |
| 245 | |
| 246 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 247 | * SENSOR_TYPE_ORIENTATION |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 248 | * trigger-mode: continuous |
| 249 | * wake-up sensor: no |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 250 | * |
| 251 | * All values are angles in degrees. |
| 252 | * |
Mathias Agopian | 66a4095 | 2010-07-22 17:11:50 -0700 | [diff] [blame] | 253 | * Orientation sensors return sensor events for all 3 axes at a constant |
| 254 | * rate defined by setDelay(). |
| 255 | * |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 256 | * azimuth: angle between the magnetic north direction and the Y axis, around |
| 257 | * the Z axis (0<=azimuth<360). |
| 258 | * 0=North, 90=East, 180=South, 270=West |
| 259 | * |
| 260 | * pitch: Rotation around X axis (-180<=pitch<=180), with positive values when |
| 261 | * the z-axis moves toward the y-axis. |
| 262 | * |
| 263 | * roll: Rotation around Y axis (-90<=roll<=90), with positive values when |
Mathias Agopian | 19ea59f | 2010-02-26 13:15:18 -0800 | [diff] [blame] | 264 | * the x-axis moves towards the z-axis. |
| 265 | * |
| 266 | * Note: For historical reasons the roll angle is positive in the clockwise |
| 267 | * direction (mathematically speaking, it should be positive in the |
| 268 | * counter-clockwise direction): |
| 269 | * |
| 270 | * Z |
| 271 | * ^ |
| 272 | * (+roll) .--> | |
| 273 | * / | |
| 274 | * | | roll: rotation around Y axis |
| 275 | * X <-------(.) |
| 276 | * Y |
| 277 | * note that +Y == -roll |
| 278 | * |
| 279 | * |
| 280 | * |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 281 | * Note: This definition is different from yaw, pitch and roll used in aviation |
| 282 | * where the X axis is along the long side of the plane (tail to nose). |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 283 | */ |
| 284 | #define SENSOR_TYPE_ORIENTATION (3) |
| 285 | |
| 286 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 287 | * SENSOR_TYPE_GYROSCOPE |
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 | * |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 291 | * All values are in radians/second and measure the rate of rotation |
| 292 | * around the X, Y and Z axis. The coordinate system is the same as is |
Mathias Agopian | c04e5f6 | 2010-09-14 10:53:55 -0700 | [diff] [blame] | 293 | * used for the acceleration sensor. Rotation is positive in the |
| 294 | * counter-clockwise direction (right-hand rule). That is, an observer |
| 295 | * looking from some positive location on the x, y or z axis at a device |
| 296 | * positioned on the origin would report positive rotation if the device |
| 297 | * appeared to be rotating counter clockwise. Note that this is the |
| 298 | * standard mathematical definition of positive rotation and does not agree |
| 299 | * with the definition of roll given earlier. |
| 300 | * The range should at least be 17.45 rad/s (ie: ~1000 deg/s). |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 301 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 302 | * automatic gyro-drift compensation is allowed but not required. |
| 303 | */ |
| 304 | #define SENSOR_TYPE_GYROSCOPE (4) |
| 305 | |
| 306 | /* |
| 307 | * SENSOR_TYPE_LIGHT |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 308 | * trigger-mode: on-change |
| 309 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 310 | * |
| 311 | * The light sensor value is returned in SI lux units. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 312 | */ |
| 313 | #define SENSOR_TYPE_LIGHT (5) |
| 314 | |
| 315 | /* |
| 316 | * SENSOR_TYPE_PRESSURE |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 317 | * trigger-mode: continuous |
| 318 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 319 | * |
| 320 | * The pressure sensor return the athmospheric pressure in hectopascal (hPa) |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 321 | */ |
| 322 | #define SENSOR_TYPE_PRESSURE (6) |
| 323 | |
| 324 | /* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */ |
| 325 | #define SENSOR_TYPE_TEMPERATURE (7) |
| 326 | |
| 327 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 328 | * SENSOR_TYPE_PROXIMITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 329 | * trigger-mode: on-change |
| 330 | * wake-up sensor: yes |
Mike Lockwood | a241431 | 2009-11-03 10:29:50 -0500 | [diff] [blame] | 331 | * |
| 332 | * The distance value is measured in centimeters. Note that some proximity |
| 333 | * sensors only support a binary "close" or "far" measurement. In this case, |
| 334 | * the sensor should report its maxRange value in the "far" state and a value |
| 335 | * less than maxRange in the "near" state. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 336 | */ |
| 337 | #define SENSOR_TYPE_PROXIMITY (8) |
| 338 | |
| 339 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 340 | * SENSOR_TYPE_GRAVITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 341 | * trigger-mode: continuous |
| 342 | * wake-up sensor: no |
Mathias Agopian | 42b743c | 2010-11-22 15:55:32 -0800 | [diff] [blame] | 343 | * |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 344 | * A gravity output indicates the direction of and magnitude of gravity in |
| 345 | * the devices's coordinates. On Earth, the magnitude is 9.8 m/s^2. |
| 346 | * Units are m/s^2. The coordinate system is the same as is used for the |
| 347 | * acceleration sensor. When the device is at rest, the output of the |
| 348 | * gravity sensor should be identical to that of the accelerometer. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 349 | */ |
| 350 | #define SENSOR_TYPE_GRAVITY (9) |
| 351 | |
| 352 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 353 | * SENSOR_TYPE_LINEAR_ACCELERATION |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 354 | * trigger-mode: continuous |
| 355 | * wake-up sensor: no |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 356 | * |
| 357 | * Indicates the linear acceleration of the device in device coordinates, |
| 358 | * not including gravity. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 359 | * |
| 360 | * The output is conceptually: |
| 361 | * output of TYPE_ACCELERATION - output of TYPE_GRAVITY |
| 362 | * |
| 363 | * Readings on all axes should be close to 0 when device lies on a table. |
| 364 | * Units are m/s^2. |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 365 | * The coordinate system is the same as is used for the acceleration sensor. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 366 | */ |
| 367 | #define SENSOR_TYPE_LINEAR_ACCELERATION (10) |
| 368 | |
| 369 | |
| 370 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 371 | * SENSOR_TYPE_ROTATION_VECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 372 | * trigger-mode: continuous |
| 373 | * wake-up sensor: no |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 374 | * |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 375 | * A rotation vector represents the orientation of the device as a combination |
| 376 | * of an angle and an axis, in which the device has rotated through an angle |
| 377 | * theta around an axis <x, y, z>. The three elements of the rotation vector |
| 378 | * are <x*sin(theta/2), y*sin(theta/2), z*sin(theta/2)>, such that the magnitude |
| 379 | * of the rotation vector is equal to sin(theta/2), and the direction of the |
| 380 | * rotation vector is equal to the direction of the axis of rotation. The three |
| 381 | * elements of the rotation vector are equal to the last three components of a |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 382 | * unit quaternion |
| 383 | * <cos(theta/2), x*sin(theta/2), y*sin(theta/2), z*sin(theta/2)>. |
| 384 | * Elements of the rotation vector are unitless. The x, y, and z axis are |
| 385 | * defined in the same way as for the acceleration sensor. |
Mathias Agopian | 42b743c | 2010-11-22 15:55:32 -0800 | [diff] [blame] | 386 | * |
Mathias Agopian | d93ff97 | 2011-05-02 19:10:31 -0700 | [diff] [blame] | 387 | * The reference coordinate system is defined as a direct orthonormal basis, |
| 388 | * where: |
| 389 | * |
| 390 | * - X is defined as the vector product Y.Z (It is tangential to |
| 391 | * the ground at the device's current location and roughly points East). |
| 392 | * |
| 393 | * - Y is tangential to the ground at the device's current location and |
| 394 | * points towards the magnetic North Pole. |
| 395 | * |
| 396 | * - Z points towards the sky and is perpendicular to the ground. |
| 397 | * |
| 398 | * |
Mathias Agopian | 42b743c | 2010-11-22 15:55:32 -0800 | [diff] [blame] | 399 | * The rotation-vector is stored as: |
| 400 | * |
| 401 | * sensors_event_t.data[0] = x*sin(theta/2) |
| 402 | * sensors_event_t.data[1] = y*sin(theta/2) |
| 403 | * sensors_event_t.data[2] = z*sin(theta/2) |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 404 | * |
| 405 | * In addition, this sensor reports an estimated heading accuracy. |
| 406 | * sensors_event_t.data[3] = estimated_accuracy (in radians) |
| 407 | * The heading error must be less than estimated_accuracy 95% of the time |
| 408 | * |
| 409 | * This sensor must use a gyroscope and an accelerometer as main orientation |
| 410 | * change input. |
| 411 | * |
| 412 | * This sensor can also include magnetometer input to make up for gyro drift, |
| 413 | * but it cannot be implemented using only a magnetometer. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 414 | */ |
| 415 | #define SENSOR_TYPE_ROTATION_VECTOR (11) |
| 416 | |
| 417 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 418 | * SENSOR_TYPE_RELATIVE_HUMIDITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 419 | * trigger-mode: on-change |
| 420 | * wake-up sensor: no |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 421 | * |
| 422 | * A relative humidity sensor measures relative ambient air humidity and |
| 423 | * returns a value in percent. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 424 | */ |
| 425 | #define SENSOR_TYPE_RELATIVE_HUMIDITY (12) |
| 426 | |
| 427 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 428 | * SENSOR_TYPE_AMBIENT_TEMPERATURE |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 429 | * trigger-mode: on-change |
| 430 | * wake-up sensor: no |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 431 | * |
| 432 | * The ambient (room) temperature in degree Celsius. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 433 | */ |
| 434 | #define SENSOR_TYPE_AMBIENT_TEMPERATURE (13) |
| 435 | |
| 436 | /* |
| 437 | * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 438 | * trigger-mode: continuous |
| 439 | * wake-up sensor: no |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 440 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 441 | * Similar to SENSOR_TYPE_MAGNETIC_FIELD, but the hard iron calibration is |
| 442 | * reported separately instead of being included in the measurement. |
| 443 | * Factory calibration and temperature compensation should still be applied to |
| 444 | * the "uncalibrated" measurement. |
| 445 | * Separating away the hard iron calibration estimation allows the system to |
| 446 | * better recover from bad hard iron estimation. |
| 447 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 448 | * All values are in micro-Tesla (uT) and measure the ambient magnetic |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 449 | * field in the X, Y and Z axis. Assumptions that the the magnetic field |
| 450 | * is due to the Earth's poles should be avoided. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 451 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 452 | * The uncalibrated_magnetic event contains |
| 453 | * - 3 fields for uncalibrated measurement: x_uncalib, y_uncalib, z_uncalib. |
| 454 | * Each is a component of the measured magnetic field, with soft iron |
| 455 | * and temperature compensation applied, but not hard iron calibration. |
| 456 | * These values should be continuous (no re-calibration should cause a jump). |
| 457 | * - 3 fields for hard iron bias estimates: x_bias, y_bias, z_bias. |
| 458 | * Each field is a component of the estimated hard iron calibration. |
| 459 | * They represent the offsets to apply to the uncalibrated readings to obtain |
| 460 | * calibrated readings (x_calibrated = x_uncalib + x_bias) |
| 461 | * These values are expected to jump as soon as the estimate of the hard iron |
| 462 | * changes. |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 463 | * |
| 464 | * If this sensor is present, then the corresponding |
| 465 | * SENSOR_TYPE_MAGNETIC_FIELD must be present and both must return the |
| 466 | * same sensor_t::name and sensor_t::vendor. |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 467 | * |
| 468 | * See SENSOR_TYPE_MAGNETIC_FIELD for more information |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 469 | */ |
| 470 | #define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14) |
| 471 | |
| 472 | /* |
| 473 | * SENSOR_TYPE_GAME_ROTATION_VECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 474 | * trigger-mode: continuous |
| 475 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 476 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 477 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but not using the geomagnetic |
| 478 | * field. Therefore the Y axis doesn't point north, but instead to some other |
| 479 | * reference. That reference is allowed to drift by the same order of |
| 480 | * magnitude than the gyroscope drift around the Z axis. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 481 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 482 | * This sensor does not report an estimated heading accuracy: |
| 483 | * sensors_event_t.data[3] is reserved and should be set to 0 |
| 484 | * |
| 485 | * In the ideal case, a phone rotated and returning to the same real-world |
| 486 | * orientation should report the same game rotation vector |
| 487 | * (without using the earth's geomagnetic field). |
| 488 | * |
| 489 | * This sensor must be based on a gyroscope. It cannot be implemented using |
| 490 | * a magnetometer. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 491 | * |
| 492 | * see SENSOR_TYPE_ROTATION_VECTOR for more details |
| 493 | */ |
| 494 | #define SENSOR_TYPE_GAME_ROTATION_VECTOR (15) |
| 495 | |
| 496 | /* |
| 497 | * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 498 | * trigger-mode: continuous |
| 499 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 500 | * |
| 501 | * All values are in radians/second and measure the rate of rotation |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 502 | * around the X, Y and Z axis. An estimation of the drift on each axis is |
| 503 | * reported as well. |
| 504 | * |
| 505 | * No gyro-drift compensation shall be performed. |
| 506 | * Factory calibration and temperature compensation should still be applied |
| 507 | * to the rate of rotation (angular speeds). |
| 508 | * |
| 509 | * The coordinate system is the same as is |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 510 | * used for the acceleration sensor. Rotation is positive in the |
| 511 | * counter-clockwise direction (right-hand rule). That is, an observer |
| 512 | * looking from some positive location on the x, y or z axis at a device |
| 513 | * positioned on the origin would report positive rotation if the device |
| 514 | * appeared to be rotating counter clockwise. Note that this is the |
| 515 | * standard mathematical definition of positive rotation and does not agree |
| 516 | * with the definition of roll given earlier. |
| 517 | * The range should at least be 17.45 rad/s (ie: ~1000 deg/s). |
| 518 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 519 | * Content of an uncalibrated_gyro event: (units are rad/sec) |
| 520 | * x_uncalib : angular speed (w/o drift compensation) around the X axis |
| 521 | * y_uncalib : angular speed (w/o drift compensation) around the Y axis |
| 522 | * z_uncalib : angular speed (w/o drift compensation) around the Z axis |
| 523 | * x_bias : estimated drift around X axis in rad/s |
| 524 | * y_bias : estimated drift around Y axis in rad/s |
| 525 | * z_bias : estimated drift around Z axis in rad/s |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 526 | * |
| 527 | * IMPLEMENTATION NOTES: |
| 528 | * |
| 529 | * If the implementation is not able to estimate the drift, then this |
| 530 | * sensor MUST NOT be reported by this HAL. Instead, the regular |
| 531 | * SENSOR_TYPE_GYROSCOPE is used without drift compensation. |
| 532 | * |
| 533 | * If this sensor is present, then the corresponding |
| 534 | * SENSOR_TYPE_GYROSCOPE must be present and both must return the |
| 535 | * same sensor_t::name and sensor_t::vendor. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 536 | */ |
| 537 | #define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16) |
| 538 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 539 | |
| 540 | /* |
| 541 | * SENSOR_TYPE_SIGNIFICANT_MOTION |
| 542 | * trigger-mode: one-shot |
| 543 | * wake-up sensor: yes |
| 544 | * |
| 545 | * A sensor of this type triggers an event each time significant motion |
| 546 | * is detected and automatically disables itself. |
| 547 | * The only allowed value to return is 1.0. |
| 548 | * |
| 549 | * |
| 550 | * TODO: give more details about what constitute significant motion |
| 551 | * and/or what algorithm is to be used |
| 552 | * |
| 553 | * |
| 554 | * IMPORTANT NOTE: this sensor type is very different from other types |
| 555 | * in that it must work when the screen is off without the need of |
| 556 | * holding a partial wake-lock and MUST allow the SoC to go into suspend. |
| 557 | * When significant motion is detected, the sensor must awaken the SoC and |
| 558 | * the event be reported. |
| 559 | * |
| 560 | * If a particular hardware cannot support this mode of operation then this |
| 561 | * sensor type MUST NOT be reported by the HAL. ie: it is not acceptable |
| 562 | * to "emulate" this sensor in the HAL. |
| 563 | * |
| 564 | * The whole point of this sensor type is to save power by keeping the |
| 565 | * SoC in suspend mode when the device is at rest. |
| 566 | * |
| 567 | * When the sensor is not activated, it must also be deactivated in the |
| 568 | * hardware: it must not wake up the SoC anymore, even in case of |
| 569 | * significant motion. |
| 570 | * |
| 571 | * setDelay() has no effect and is ignored. |
| 572 | * Once a "significant motion" event is returned, a sensor of this type |
| 573 | * must disables itself automatically, as if activate(..., 0) had been called. |
| 574 | */ |
| 575 | |
| 576 | #define SENSOR_TYPE_SIGNIFICANT_MOTION (17) |
| 577 | |
| 578 | |
| 579 | /* |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 580 | * SENSOR_TYPE_STEP_DETECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 581 | * trigger-mode: special |
| 582 | * wake-up sensor: no |
| 583 | * |
| 584 | * A sensor of this type triggers an event each time a step is taken |
| 585 | * by the user. The only allowed value to return is 1.0 and an event is |
| 586 | * generated for each step. Like with any other event, the timestamp |
| 587 | * indicates when the event (here the step) occurred, this corresponds to when |
| 588 | * the foot hit the ground, generating a high variation in acceleration. |
| 589 | * |
| 590 | * While this sensor operates, it shall not disrupt any other sensors, in |
| 591 | * particular, but not limited to, the accelerometer; which might very well |
| 592 | * be in use as well. |
| 593 | * |
| 594 | * This sensor must be low power. That is, if the step detection cannot be |
| 595 | * done in hardware, this sensor should not be defined. Also, when the |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 596 | * step detector is activated and the accelerometer is not, only steps should |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 597 | * trigger interrupts (not accelerometer data). |
| 598 | * |
| 599 | * setDelay() has no impact on this sensor type |
| 600 | */ |
| 601 | |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 602 | #define SENSOR_TYPE_STEP_DETECTOR (18) |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 603 | |
| 604 | |
| 605 | /* |
| 606 | * SENSOR_TYPE_STEP_COUNTER |
| 607 | * trigger-mode: on-change |
| 608 | * wake-up sensor: no |
| 609 | * |
| 610 | * 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] | 611 | * the last reboot while activated. The value is returned as a uint64_t and is |
| 612 | * reset to zero only on a system reboot. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 613 | * |
| 614 | * The timestamp of the event is set to the time when the first step |
| 615 | * for that event was taken. |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 616 | * See SENSOR_TYPE_STEP_DETECTOR for the signification of the time of a step. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 617 | * |
| 618 | * The minimum size of the hardware's internal counter shall be 16 bits |
| 619 | * (this restriction is here to avoid too frequent wake-ups when the |
| 620 | * delay is very large). |
| 621 | * |
| 622 | * IMPORTANT NOTE: this sensor type is different from other types |
| 623 | * in that it must work when the screen is off without the need of |
| 624 | * holding a partial wake-lock and MUST allow the SoC to go into suspend. |
| 625 | * Unlike other sensors, while in suspend mode this sensor must stay active, |
| 626 | * no events are reported during that time but, steps continue to be |
| 627 | * accounted for; an event will be reported as soon as the SoC resumes if |
| 628 | * the timeout has expired. |
| 629 | * |
| 630 | * In other words, when the screen is off and the device allowed to |
| 631 | * go into suspend mode, we don't want to be woken up, regardless of the |
| 632 | * setDelay() value, but the steps shall continue to be counted. |
| 633 | * |
| 634 | * The driver must however ensure that the internal step count never |
| 635 | * overflows. It is allowed in this situation to wake the SoC up so the |
| 636 | * driver can do the counter maintenance. |
| 637 | * |
| 638 | * While this sensor operates, it shall not disrupt any other sensors, in |
| 639 | * particular, but not limited to, the accelerometer; which might very well |
| 640 | * be in use as well. |
| 641 | * |
| 642 | * If a particular hardware cannot support these modes of operation then this |
| 643 | * sensor type MUST NOT be reported by the HAL. ie: it is not acceptable |
| 644 | * to "emulate" this sensor in the HAL. |
| 645 | * |
| 646 | * This sensor must be low power. That is, if the step detection cannot be |
| 647 | * done in hardware, this sensor should not be defined. Also, when the |
| 648 | * step counter is activated and the accelerometer is not, only steps should |
| 649 | * trigger interrupts (not accelerometer data). |
| 650 | * |
| 651 | * The whole point of this sensor type is to save power by keeping the |
| 652 | * SoC in suspend mode when the device is at rest. |
| 653 | */ |
| 654 | |
| 655 | #define SENSOR_TYPE_STEP_COUNTER (19) |
| 656 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 657 | /* |
| 658 | * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR |
| 659 | * trigger-mode: continuous |
| 660 | * wake-up sensor: no |
| 661 | * |
| 662 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but using a magnetometer instead |
| 663 | * of using a gyroscope. |
| 664 | * |
| 665 | * This sensor must be based on a magnetometer. It cannot be implemented using |
| 666 | * a gyroscope, and gyroscope input cannot be used by this sensor. |
| 667 | * |
| 668 | * Just like SENSOR_TYPE_ROTATION_VECTOR, this sensor reports an estimated |
| 669 | * heading accuracy: |
| 670 | * sensors_event_t.data[3] = estimated_accuracy (in radians) |
| 671 | * The heading error must be less than estimated_accuracy 95% of the time |
| 672 | * |
| 673 | * see SENSOR_TYPE_ROTATION_VECTOR for more details |
| 674 | */ |
| 675 | #define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20) |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 676 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 677 | /** |
| 678 | * Values returned by the accelerometer in various locations in the universe. |
| 679 | * all values are in SI units (m/s^2) |
| 680 | */ |
| 681 | #define GRAVITY_SUN (275.0f) |
| 682 | #define GRAVITY_EARTH (9.80665f) |
| 683 | |
| 684 | /** Maximum magnetic field on Earth's surface */ |
| 685 | #define MAGNETIC_FIELD_EARTH_MAX (60.0f) |
| 686 | |
| 687 | /** Minimum magnetic field on Earth's surface */ |
| 688 | #define MAGNETIC_FIELD_EARTH_MIN (30.0f) |
| 689 | |
| 690 | |
| 691 | /** |
| 692 | * status of orientation sensor |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 693 | */ |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 694 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 695 | #define SENSOR_STATUS_UNRELIABLE 0 |
| 696 | #define SENSOR_STATUS_ACCURACY_LOW 1 |
| 697 | #define SENSOR_STATUS_ACCURACY_MEDIUM 2 |
| 698 | #define SENSOR_STATUS_ACCURACY_HIGH 3 |
| 699 | |
| 700 | |
| 701 | /** |
| 702 | * sensor event data |
| 703 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 704 | typedef struct { |
| 705 | union { |
| 706 | float v[3]; |
| 707 | struct { |
| 708 | float x; |
| 709 | float y; |
| 710 | float z; |
| 711 | }; |
| 712 | struct { |
| 713 | float azimuth; |
| 714 | float pitch; |
| 715 | float roll; |
| 716 | }; |
| 717 | }; |
| 718 | int8_t status; |
| 719 | uint8_t reserved[3]; |
| 720 | } sensors_vec_t; |
| 721 | |
| 722 | /** |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 723 | * uncalibrated gyroscope and magnetometer event data |
| 724 | */ |
| 725 | typedef struct { |
| 726 | float x_uncalib; |
| 727 | float y_uncalib; |
| 728 | float z_uncalib; |
| 729 | float x_bias; |
| 730 | float y_bias; |
| 731 | float z_bias; |
| 732 | } uncalibrated_event_t; |
| 733 | |
| 734 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 735 | * Union of the various types of sensor data |
| 736 | * that can be returned. |
| 737 | */ |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 738 | typedef struct sensors_event_t { |
| 739 | /* must be sizeof(struct sensors_event_t) */ |
| 740 | int32_t version; |
| 741 | |
| 742 | /* sensor identifier */ |
| 743 | int32_t sensor; |
| 744 | |
| 745 | /* sensor type */ |
| 746 | int32_t type; |
| 747 | |
| 748 | /* reserved */ |
| 749 | int32_t reserved0; |
| 750 | |
| 751 | /* time is in nanosecond */ |
| 752 | int64_t timestamp; |
| 753 | |
| 754 | union { |
| 755 | float data[16]; |
| 756 | |
| 757 | /* acceleration values are in meter per second per second (m/s^2) */ |
Jeff Brown | 296cf93 | 2013-02-09 02:46:33 +0000 | [diff] [blame] | 758 | sensors_vec_t acceleration; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 759 | |
| 760 | /* magnetic vector values are in micro-Tesla (uT) */ |
| 761 | sensors_vec_t magnetic; |
| 762 | |
| 763 | /* orientation values are in degrees */ |
| 764 | sensors_vec_t orientation; |
| 765 | |
Mathias Agopian | c04e5f6 | 2010-09-14 10:53:55 -0700 | [diff] [blame] | 766 | /* gyroscope values are in rad/s */ |
Jeff Brown | 296cf93 | 2013-02-09 02:46:33 +0000 | [diff] [blame] | 767 | sensors_vec_t gyro; |
Makarand Karvekar | 3120b58 | 2010-08-11 15:10:10 -0700 | [diff] [blame] | 768 | |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 769 | /* temperature is in degrees centigrade (Celsius) */ |
| 770 | float temperature; |
| 771 | |
| 772 | /* distance in centimeters */ |
| 773 | float distance; |
| 774 | |
| 775 | /* light in SI lux units */ |
| 776 | float light; |
Mathias Agopian | 1832f55 | 2010-07-29 15:22:30 -0700 | [diff] [blame] | 777 | |
| 778 | /* pressure in hectopascal (hPa) */ |
| 779 | float pressure; |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 780 | |
| 781 | /* relative humidity in percent */ |
| 782 | float relative_humidity; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 783 | |
| 784 | /* step-counter */ |
| 785 | uint64_t step_counter; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 786 | |
| 787 | /* uncalibrated gyroscope values are in rad/s */ |
| 788 | uncalibrated_event_t uncalibrated_gyro; |
| 789 | |
| 790 | /* uncalibrated magnetometer values are in micro-Teslas */ |
| 791 | uncalibrated_event_t uncalibrated_magnetic; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 792 | }; |
| 793 | uint32_t reserved1[4]; |
| 794 | } sensors_event_t; |
| 795 | |
| 796 | |
| 797 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 798 | struct sensor_t; |
| 799 | |
| 800 | /** |
| 801 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 802 | * and the fields of this data structure must begin with hw_module_t |
| 803 | * followed by module specific information. |
| 804 | */ |
| 805 | struct sensors_module_t { |
| 806 | struct hw_module_t common; |
| 807 | |
| 808 | /** |
| 809 | * Enumerate all available sensors. The list is returned in "list". |
| 810 | * @return number of sensors in the list |
| 811 | */ |
| 812 | int (*get_sensors_list)(struct sensors_module_t* module, |
| 813 | struct sensor_t const** list); |
| 814 | }; |
| 815 | |
| 816 | struct sensor_t { |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 817 | |
| 818 | /* Name of this sensor. |
| 819 | * All sensors of the same "type" must have a different "name". |
| 820 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 821 | const char* name; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 822 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 823 | /* vendor of the hardware part */ |
| 824 | const char* vendor; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 825 | |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 826 | /* version of the hardware part + driver. The value of this field |
| 827 | * must increase when the driver is updated in a way that changes the |
| 828 | * output of this sensor. This is important for fused sensors when the |
| 829 | * fusion algorithm is updated. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 830 | */ |
| 831 | int version; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 832 | |
| 833 | /* handle that identifies this sensors. This handle is used to reference |
| 834 | * this sensor throughout the HAL API. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 835 | */ |
| 836 | int handle; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 837 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 838 | /* this sensor's type. */ |
| 839 | int type; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 840 | |
| 841 | /* 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] | 842 | float maxRange; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 843 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 844 | /* smallest difference between two values reported by this sensor */ |
| 845 | float resolution; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 846 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 847 | /* rough estimate of this sensor's power consumption in mA */ |
| 848 | float power; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 849 | |
| 850 | /* this value depends on the trigger mode: |
| 851 | * |
| 852 | * continuous: minimum sample period allowed in microseconds |
| 853 | * on-change : 0 |
| 854 | * one-shot :-1 |
| 855 | * special : 0, unless otherwise noted |
| 856 | */ |
Mathias Agopian | 1511e20 | 2010-07-29 15:33:22 -0700 | [diff] [blame] | 857 | int32_t minDelay; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 858 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 859 | /* reserved fields, must be zero */ |
Mathias Agopian | 1511e20 | 2010-07-29 15:33:22 -0700 | [diff] [blame] | 860 | void* reserved[8]; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 861 | }; |
| 862 | |
| 863 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 864 | /* |
| 865 | * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 |
| 866 | * and is present for backward binary and source compatibility. |
| 867 | * (see documentation of the hooks in struct sensors_poll_device_1 below) |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 868 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 869 | struct sensors_poll_device_t { |
| 870 | struct hw_device_t common; |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 871 | int (*activate)(struct sensors_poll_device_t *dev, |
| 872 | int handle, int enabled); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 873 | int (*setDelay)(struct sensors_poll_device_t *dev, |
| 874 | int handle, int64_t ns); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 875 | int (*poll)(struct sensors_poll_device_t *dev, |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 876 | sensors_event_t* data, int count); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 877 | }; |
| 878 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 879 | /* |
| 880 | * struct sensors_poll_device_1 is used with SENSORS_DEVICE_API_VERSION_1_0 |
| 881 | */ |
| 882 | typedef struct sensors_poll_device_1 { |
| 883 | union { |
| 884 | /* sensors_poll_device_1 is compatible with sensors_poll_device_t, |
| 885 | * and can be down-cast to it |
| 886 | */ |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 887 | struct sensors_poll_device_t v0; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 888 | |
| 889 | struct { |
| 890 | struct hw_device_t common; |
| 891 | |
| 892 | /* Activate/de-activate one sensor. |
| 893 | * |
| 894 | * handle is the handle of the sensor to change. |
| 895 | * enabled set to 1 to enable, or 0 to disable the sensor. |
| 896 | * |
| 897 | * unless otherwise noted in the sensor types definitions, an |
| 898 | * activated sensor never prevents the SoC to go into suspend |
| 899 | * mode; that is, the HAL shall not hold a partial wake-lock on |
| 900 | * behalf of applications. |
| 901 | * |
| 902 | * one-shot sensors de-activate themselves automatically upon |
| 903 | * receiving an event and they must still accept to be deactivated |
| 904 | * through a call to activate(..., ..., 0). |
| 905 | * |
| 906 | * if "enabled" is true and the sensor is already activated, this |
| 907 | * function is a no-op and succeeds. |
| 908 | * |
| 909 | * if "enabled" is false and the sensor is already de-activated, |
| 910 | * this function is a no-op and succeeds. |
| 911 | * |
| 912 | * return 0 on success, negative errno code otherwise |
| 913 | */ |
| 914 | int (*activate)(struct sensors_poll_device_t *dev, |
| 915 | int handle, int enabled); |
| 916 | |
| 917 | /** |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 918 | * Set the events's period in nanoseconds for a given sensor. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 919 | * |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 920 | * What the period_ns parameter means depends on the specified |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 921 | * sensor's trigger mode: |
| 922 | * |
| 923 | * continuous: setDelay() sets the sampling rate. |
| 924 | * on-change: setDelay() limits the delivery rate of events |
| 925 | * one-shot: setDelay() is ignored. it has no effect. |
| 926 | * special: see specific sensor type definitions |
| 927 | * |
| 928 | * For continuous and on-change sensors, if the requested value is |
| 929 | * less than sensor_t::minDelay, then it's silently clamped to |
| 930 | * sensor_t::minDelay unless sensor_t::minDelay is 0, in which |
| 931 | * case it is clamped to >= 1ms. |
| 932 | * |
| 933 | * @return 0 if successful, < 0 on error |
| 934 | */ |
| 935 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 936 | int handle, int64_t period_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 937 | |
| 938 | /** |
| 939 | * Returns an array of sensor data. |
| 940 | * This function must block until events are available. |
| 941 | * |
| 942 | * return the number of events read on success, or -errno in case |
| 943 | * of an error. |
| 944 | * |
| 945 | * The number of events returned in data must be less or equal |
| 946 | * to SENSORS_QUERY_MAX_EVENTS_BATCH_COUNT. |
| 947 | * |
| 948 | * This function shall never return 0 (no event). |
| 949 | */ |
| 950 | int (*poll)(struct sensors_poll_device_t *dev, |
| 951 | sensors_event_t* data, int count); |
| 952 | }; |
| 953 | }; |
| 954 | |
| 955 | /* |
| 956 | * Used to retrieve information about the sensor HAL |
| 957 | * |
| 958 | * Returns 0 on success or -errno on error. |
| 959 | */ |
| 960 | int (*query)(struct sensors_poll_device_1* dev, int what, int* value); |
| 961 | |
| 962 | |
| 963 | /* |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 964 | * Enables batch mode for the given sensor and sets the delay between events |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 965 | * |
| 966 | * A timeout value of zero disables batch mode for the given sensor. |
| 967 | * |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 968 | * The period_ns parameter is equivalent to calling setDelay() -- this |
| 969 | * function both enables or disables the batch mode AND sets the events's |
| 970 | * period in nanosecond. See setDelay() above for a detailed explanation of |
| 971 | * the period_ns parameter. |
| 972 | * |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 973 | * While in batch mode sensor events are reported in batches at least |
| 974 | * every "timeout" nanosecond; that is all events since the previous batch |
| 975 | * are recorded and returned all at once. Batches can be interleaved and |
| 976 | * split, and as usual events of the same sensor type are time-ordered. |
| 977 | * |
| 978 | * setDelay() is not affected and it behaves as usual. |
| 979 | * |
| 980 | * Each event has a timestamp associated with it, the timestamp |
| 981 | * must be accurate and correspond to the time at which the event |
| 982 | * physically happened. |
| 983 | * |
| 984 | * If internal h/w FIFOs fill-up before the timeout, then events are |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 985 | * reported at that point. No event shall be dropped or lost. |
| 986 | * |
| 987 | * |
| 988 | * INTERACTION WITH SUSPEND MODE: |
| 989 | * ------------------------------ |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 990 | * |
| 991 | * By default batch mode doesn't significantly change the interaction with |
| 992 | * suspend mode, that is, sensors must continue to allow the SoC to |
| 993 | * go into suspend mode and sensors must stay active to fill their |
| 994 | * internal FIFO, in this mode, when the FIFO fills-up, it shall wrap |
| 995 | * around (basically behave like a circular buffer, overwriting events). |
| 996 | * As soon as the SoC comes out of suspend mode, a batch is produced with |
| 997 | * as much as the recent history as possible, and batch operation |
| 998 | * resumes as usual. |
| 999 | * |
| 1000 | * The behavior described above allows applications to record the recent |
| 1001 | * history of a set of sensor while keeping the SoC into suspend. It |
| 1002 | * also allows the hardware to not have to rely on a wake-up interrupt line. |
| 1003 | * |
| 1004 | * There are cases however where an application cannot afford to lose |
| 1005 | * any events, even when the device goes into suspend mode. The behavior |
| 1006 | * specified above can be altered by setting the |
| 1007 | * SENSORS_BATCH_WAKE_UPON_FIFO_FULL flag. If this flag is set, the SoC |
| 1008 | * must be woken up from suspend and a batch must be returned before |
| 1009 | * the FIFO fills-up. Enough head room must be allocated in the FIFO to allow |
| 1010 | * the device to entirely come out of suspend (which might take a while and |
| 1011 | * is device dependent) such that no event are lost. |
| 1012 | * |
| 1013 | * If the hardware cannot support this mode, or, if the physical |
| 1014 | * FIFO is so small that the device would never be allowed to go into |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 1015 | * suspend for at least 10 seconds, then this function MUST fail when |
| 1016 | * the flag SENSORS_BATCH_WAKE_UPON_FIFO_FULL is set, regardless of |
| 1017 | * the value of the timeout parameter. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1018 | * |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 1019 | * DRY RUN: |
| 1020 | * -------- |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1021 | * |
| 1022 | * If the flag SENSORS_BATCH_DRY_RUN is set, this function returns |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 1023 | * without modifying the batch mode or the event period and has no side |
| 1024 | * effects, but returns errors as usual (as it would if this flag was |
| 1025 | * not set). This flag is used to check if batch mode is available for a |
| 1026 | * given configuration -- in particular for a given sensor at a given rate. |
| 1027 | * |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1028 | * |
| 1029 | * Return values: |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 1030 | * -------------- |
| 1031 | * |
| 1032 | * Because sensors must be independent, the return value must not depend |
| 1033 | * on the state of the system (whether another sensor is on or not), |
| 1034 | * nor on whether the flag SENSORS_BATCH_DRY_RUN is set (in other words, |
| 1035 | * if a batch call with SENSORS_BATCH_DRY_RUN is successful, |
| 1036 | * the same call without SENSORS_BATCH_DRY_RUN must succeed as well). |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1037 | * |
| 1038 | * If successful, 0 is returned. |
| 1039 | * If the specified sensor doesn't support batch mode, -EINVAL is returned. |
| 1040 | * If the specified sensor's trigger-mode is one-shot, -EINVAL is returned. |
| 1041 | * If any of the constraint above cannot be satisfied, -EINVAL is returned. |
| 1042 | * |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 1043 | * Note: the timeout parameter, when > 0, has no impact on whether this |
| 1044 | * function succeeds or fails. |
| 1045 | * |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1046 | * If timeout is set to 0, this function must succeed. |
| 1047 | * |
| 1048 | * |
| 1049 | * IMPLEMENTATION NOTES: |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 1050 | * --------------------- |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1051 | * |
| 1052 | * batch mode, if supported, should happen at the hardware level, |
| 1053 | * typically using hardware FIFOs. In particular, it SHALL NOT be |
| 1054 | * implemented in the HAL, as this would be counter productive. |
| 1055 | * The goal here is to save significant amounts of power. |
| 1056 | * |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1057 | * batch mode can be enabled or disabled at any time, in particular |
| 1058 | * while the specified sensor is already enabled and this shall not |
| 1059 | * result in the loss of events. |
| 1060 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame^] | 1061 | * COMPARATIVE IMPORTANCE OF BATCHING FOR DIFFERENT SENSORS: |
| 1062 | * --------------------------------------------------------- |
| 1063 | * |
| 1064 | * On platforms on which hardware fifo size is limited, the system designers |
| 1065 | * might have to choose how much fifo to reserve for each sensor. To help |
| 1066 | * with this choice, Here is a list of applications made possible when |
| 1067 | * batching is implemented on the different sensors. |
| 1068 | * |
| 1069 | * High value: Low power pedestrian dead reckoning |
| 1070 | * Target batching time: 20 seconds to 1 minute |
| 1071 | * Sensors to batch: |
| 1072 | * - Step detector |
| 1073 | * - Rotation vector or game rotation vector at 5Hz |
| 1074 | * Gives us step and heading while letting the AP go to Suspend. |
| 1075 | * |
| 1076 | * High value: Medium power activity/gesture recognition |
| 1077 | * Target batching time: 3 seconds |
| 1078 | * Sensors to batch: accelerometer between 20Hz and 50Hz |
| 1079 | * Allows recognizing arbitrary activities and gestures without having |
| 1080 | * to keep the AP fully awake while the data is collected. |
| 1081 | * |
| 1082 | * Medium-high value: Interrupt load reduction |
| 1083 | * Target batching time: < 1 second |
| 1084 | * Sensors to batch: any high frequency sensor. |
| 1085 | * If the gyroscope is set at 800Hz, even batching just 10 gyro events can |
| 1086 | * reduce the number of interrupts from 800/second to 80/second. |
| 1087 | * |
| 1088 | * Medium value: Continuous low frequency data collection |
| 1089 | * Target batching time: > 1 minute |
| 1090 | * Sensors to batch: barometer, humidity sensor, other low frequency |
| 1091 | * sensors. |
| 1092 | * Allows creating monitoring applications at low power. |
| 1093 | * |
| 1094 | * Medium value: Continuous full-sensors collection |
| 1095 | * Target batching time: > 1 minute |
| 1096 | * Sensors to batch: all, at high frequencies |
| 1097 | * Allows full collection of sensor data while leaving the AP in |
| 1098 | * suspend mode. Only to consider if fifo space is not an issue. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1099 | */ |
| 1100 | int (*batch)(struct sensors_poll_device_1* dev, |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 1101 | int handle, int flags, int64_t period_ns, int64_t timeout); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1102 | |
| 1103 | void (*reserved_procs[8])(void); |
| 1104 | |
| 1105 | } sensors_poll_device_1_t; |
| 1106 | |
| 1107 | |
| 1108 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1109 | /** convenience API for opening and closing a device */ |
| 1110 | |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1111 | static inline int sensors_open(const struct hw_module_t* module, |
| 1112 | struct sensors_poll_device_t** device) { |
| 1113 | return module->methods->open(module, |
| 1114 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 1115 | } |
| 1116 | |
| 1117 | static inline int sensors_close(struct sensors_poll_device_t* device) { |
| 1118 | return device->common.close(&device->common); |
| 1119 | } |
| 1120 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1121 | static inline int sensors_open_1(const struct hw_module_t* module, |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1122 | sensors_poll_device_1_t** device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1123 | return module->methods->open(module, |
| 1124 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 1125 | } |
| 1126 | |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1127 | static inline int sensors_close_1(sensors_poll_device_1_t* device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1128 | return device->common.close(&device->common); |
| 1129 | } |
| 1130 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1131 | __END_DECLS |
| 1132 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1133 | #endif // ANDROID_SENSORS_INTERFACE_H |