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) |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 36 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 37 | /** |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 38 | * Please see the Sensors section of source.android.com for an |
| 39 | * introduction to and detailed descriptions of Android sensor types: |
| 40 | * http://source.android.com/devices/sensors/index.html |
| 41 | */ |
| 42 | |
| 43 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 44 | * The id of this module |
| 45 | */ |
| 46 | #define SENSORS_HARDWARE_MODULE_ID "sensors" |
| 47 | |
| 48 | /** |
| 49 | * Name of the sensors device to open |
| 50 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 51 | #define SENSORS_HARDWARE_POLL "poll" |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. |
| 55 | * A Handle identifies a given sensors. The handle is used to activate |
| 56 | * and/or deactivate sensors. |
| 57 | * In this version of the API there can only be 256 handles. |
| 58 | */ |
| 59 | #define SENSORS_HANDLE_BASE 0 |
| 60 | #define SENSORS_HANDLE_BITS 8 |
| 61 | #define SENSORS_HANDLE_COUNT (1<<SENSORS_HANDLE_BITS) |
| 62 | |
| 63 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 64 | /* |
| 65 | * flags for (*batch)() |
| 66 | * Availability: SENSORS_DEVICE_API_VERSION_1_0 |
| 67 | * see (*batch)() documentation for details |
| 68 | */ |
| 69 | enum { |
| 70 | SENSORS_BATCH_DRY_RUN = 0x00000001, |
| 71 | SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 |
| 72 | }; |
| 73 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 74 | /* |
| 75 | * what field for meta_data_event_t |
| 76 | */ |
| 77 | enum { |
| 78 | /* a previous flush operation has completed */ |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 79 | META_DATA_FLUSH_COMPLETE = 1, |
| 80 | META_DATA_VERSION /* always last, leave auto-assigned */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 83 | /* |
| 84 | * Sensor type |
| 85 | * |
| 86 | * 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^] | 87 | * measures are reported. See the Base sensors and Composite sensors lists |
| 88 | * for complete descriptions: |
| 89 | * http://source.android.com/devices/sensors/base_triggers.html |
| 90 | * http://source.android.com/devices/sensors/composite_sensors.html |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 91 | * |
| 92 | * Device manufacturers (OEMs) can define their own sensor types, for |
| 93 | * their private use by applications or services provided by them. Such |
| 94 | * sensor types are specific to an OEM and can't be exposed in the SDK. |
| 95 | * These types must start at SENSOR_TYPE_DEVICE_PRIVATE_BASE. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 96 | */ |
| 97 | |
| 98 | /* |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 99 | * Base for device manufacturers private sensor types. |
| 100 | * These sensor types can't be exposed in the SDK. |
| 101 | */ |
| 102 | #define SENSOR_TYPE_DEVICE_PRIVATE_BASE 0x10000 |
| 103 | |
| 104 | /* |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 105 | * SENSOR_TYPE_META_DATA |
| 106 | * trigger-mode: n/a |
| 107 | * wake-up sensor: n/a |
| 108 | * |
| 109 | * NO SENSOR OF THAT TYPE MUST BE RETURNED (*get_sensors_list)() |
| 110 | * |
| 111 | * SENSOR_TYPE_META_DATA is a special token used to populate the |
| 112 | * sensors_meta_data_event structure. It doesn't correspond to a physical |
| 113 | * sensor. sensors_meta_data_event are special, they exist only inside |
| 114 | * the HAL and are generated spontaneously, as opposed to be related to |
| 115 | * a physical sensor. |
| 116 | * |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 117 | * sensors_meta_data_event_t.version must be META_DATA_VERSION |
| 118 | * sensors_meta_data_event_t.sensor must be 0 |
| 119 | * sensors_meta_data_event_t.type must be SENSOR_TYPE_META_DATA |
| 120 | * sensors_meta_data_event_t.reserved must be 0 |
| 121 | * sensors_meta_data_event_t.timestamp must be 0 |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 122 | * |
| 123 | * The payload is a meta_data_event_t, where: |
| 124 | * meta_data_event_t.what can take the following values: |
| 125 | * |
| 126 | * META_DATA_FLUSH_COMPLETE |
| 127 | * This event indicates that a previous (*flush)() call has completed for the sensor |
| 128 | * handle specified in meta_data_event_t.sensor. |
| 129 | * see (*flush)() for more details |
| 130 | * |
| 131 | * All other values for meta_data_event_t.what are reserved and |
| 132 | * must not be used. |
| 133 | * |
| 134 | */ |
| 135 | #define SENSOR_TYPE_META_DATA (0) |
| 136 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 137 | /* |
| 138 | * SENSOR_TYPE_ACCELEROMETER |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 139 | * trigger-mode: continuous |
| 140 | * wake-up sensor: no |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 141 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 142 | * All values are in SI units (m/s^2) and measure the acceleration of the |
| 143 | * device minus the force of gravity. |
| 144 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 145 | */ |
| 146 | #define SENSOR_TYPE_ACCELEROMETER (1) |
| 147 | |
| 148 | /* |
| 149 | * SENSOR_TYPE_GEOMAGNETIC_FIELD |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 150 | * trigger-mode: continuous |
| 151 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 152 | * |
| 153 | * All values are in micro-Tesla (uT) and measure the geomagnetic |
| 154 | * field in the X, Y and Z axis. |
| 155 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 156 | */ |
| 157 | #define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) |
| 158 | #define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD |
| 159 | |
| 160 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 161 | * SENSOR_TYPE_ORIENTATION |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 162 | * trigger-mode: continuous |
| 163 | * wake-up sensor: no |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 164 | * |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 165 | * All values are angles in degrees. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 166 | * |
Mathias Agopian | 66a4095 | 2010-07-22 17:11:50 -0700 | [diff] [blame] | 167 | * Orientation sensors return sensor events for all 3 axes at a constant |
| 168 | * rate defined by setDelay(). |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 169 | */ |
| 170 | #define SENSOR_TYPE_ORIENTATION (3) |
| 171 | |
| 172 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 173 | * SENSOR_TYPE_GYROSCOPE |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 174 | * trigger-mode: continuous |
| 175 | * wake-up sensor: no |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 176 | * |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 177 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 178 | * around the X, Y and Z axis. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 179 | */ |
| 180 | #define SENSOR_TYPE_GYROSCOPE (4) |
| 181 | |
| 182 | /* |
| 183 | * SENSOR_TYPE_LIGHT |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 184 | * trigger-mode: on-change |
| 185 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 186 | * |
| 187 | * The light sensor value is returned in SI lux units. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 188 | */ |
| 189 | #define SENSOR_TYPE_LIGHT (5) |
| 190 | |
| 191 | /* |
| 192 | * SENSOR_TYPE_PRESSURE |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 193 | * trigger-mode: continuous |
| 194 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 195 | * |
| 196 | * The pressure sensor return the athmospheric pressure in hectopascal (hPa) |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 197 | */ |
| 198 | #define SENSOR_TYPE_PRESSURE (6) |
| 199 | |
| 200 | /* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */ |
| 201 | #define SENSOR_TYPE_TEMPERATURE (7) |
| 202 | |
| 203 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 204 | * SENSOR_TYPE_PROXIMITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 205 | * trigger-mode: on-change |
| 206 | * wake-up sensor: yes |
Mike Lockwood | a241431 | 2009-11-03 10:29:50 -0500 | [diff] [blame] | 207 | * |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 208 | * The value corresponds to the distance to the nearest object in centimeters. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 209 | */ |
| 210 | #define SENSOR_TYPE_PROXIMITY (8) |
| 211 | |
| 212 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 213 | * SENSOR_TYPE_GRAVITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 214 | * trigger-mode: continuous |
| 215 | * wake-up sensor: no |
Mathias Agopian | 42b743c | 2010-11-22 15:55:32 -0800 | [diff] [blame] | 216 | * |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 217 | * A gravity output indicates the direction of and magnitude of gravity in |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 218 | * the devices's coordinates. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 219 | */ |
| 220 | #define SENSOR_TYPE_GRAVITY (9) |
| 221 | |
| 222 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 223 | * SENSOR_TYPE_LINEAR_ACCELERATION |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 224 | * trigger-mode: continuous |
| 225 | * wake-up sensor: no |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 226 | * |
| 227 | * Indicates the linear acceleration of the device in device coordinates, |
| 228 | * not including gravity. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 229 | */ |
| 230 | #define SENSOR_TYPE_LINEAR_ACCELERATION (10) |
| 231 | |
| 232 | |
| 233 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 234 | * SENSOR_TYPE_ROTATION_VECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 235 | * trigger-mode: continuous |
| 236 | * wake-up sensor: no |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 237 | * |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 238 | * The rotation vector symbolizes the orientation of the device relative to the |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 239 | * East-North-Up coordinates frame. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 240 | */ |
| 241 | #define SENSOR_TYPE_ROTATION_VECTOR (11) |
| 242 | |
| 243 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 244 | * SENSOR_TYPE_RELATIVE_HUMIDITY |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 245 | * trigger-mode: on-change |
| 246 | * wake-up sensor: no |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 247 | * |
| 248 | * A relative humidity sensor measures relative ambient air humidity and |
| 249 | * returns a value in percent. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 250 | */ |
| 251 | #define SENSOR_TYPE_RELATIVE_HUMIDITY (12) |
| 252 | |
| 253 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 254 | * SENSOR_TYPE_AMBIENT_TEMPERATURE |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 255 | * trigger-mode: on-change |
| 256 | * wake-up sensor: no |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 257 | * |
| 258 | * The ambient (room) temperature in degree Celsius. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 259 | */ |
| 260 | #define SENSOR_TYPE_AMBIENT_TEMPERATURE (13) |
| 261 | |
| 262 | /* |
| 263 | * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 264 | * trigger-mode: continuous |
| 265 | * wake-up sensor: no |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 266 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 267 | * Similar to SENSOR_TYPE_MAGNETIC_FIELD, but the hard iron calibration is |
| 268 | * reported separately instead of being included in the measurement. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 269 | */ |
| 270 | #define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14) |
| 271 | |
| 272 | /* |
| 273 | * SENSOR_TYPE_GAME_ROTATION_VECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 274 | * trigger-mode: continuous |
| 275 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 276 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 277 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but not using the geomagnetic |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 278 | * field. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 279 | */ |
| 280 | #define SENSOR_TYPE_GAME_ROTATION_VECTOR (15) |
| 281 | |
| 282 | /* |
| 283 | * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 284 | * trigger-mode: continuous |
| 285 | * wake-up sensor: no |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 286 | * |
| 287 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 288 | * around the X, Y and Z axis. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 289 | */ |
| 290 | #define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16) |
| 291 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 292 | /* |
| 293 | * SENSOR_TYPE_SIGNIFICANT_MOTION |
| 294 | * trigger-mode: one-shot |
| 295 | * wake-up sensor: yes |
| 296 | * |
| 297 | * A sensor of this type triggers an event each time significant motion |
| 298 | * is detected and automatically disables itself. |
| 299 | * The only allowed value to return is 1.0. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 300 | */ |
| 301 | |
| 302 | #define SENSOR_TYPE_SIGNIFICANT_MOTION (17) |
| 303 | |
| 304 | |
| 305 | /* |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 306 | * SENSOR_TYPE_STEP_DETECTOR |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 307 | * trigger-mode: special |
| 308 | * wake-up sensor: no |
| 309 | * |
| 310 | * 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^] | 311 | * by the user. The only allowed value to return is 1.0 and an event |
| 312 | * is generated for each step. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 313 | */ |
| 314 | |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 315 | #define SENSOR_TYPE_STEP_DETECTOR (18) |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 316 | |
| 317 | |
| 318 | /* |
| 319 | * SENSOR_TYPE_STEP_COUNTER |
| 320 | * trigger-mode: on-change |
| 321 | * wake-up sensor: no |
| 322 | * |
| 323 | * 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] | 324 | * 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] | 325 | * reset to zero only on a system / android reboot. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 326 | */ |
| 327 | |
| 328 | #define SENSOR_TYPE_STEP_COUNTER (19) |
| 329 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 330 | /* |
| 331 | * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR |
| 332 | * trigger-mode: continuous |
| 333 | * wake-up sensor: no |
| 334 | * |
| 335 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but using a magnetometer instead |
| 336 | * of using a gyroscope. |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 337 | */ |
| 338 | #define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20) |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 339 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 340 | /** |
| 341 | * Values returned by the accelerometer in various locations in the universe. |
| 342 | * all values are in SI units (m/s^2) |
| 343 | */ |
| 344 | #define GRAVITY_SUN (275.0f) |
| 345 | #define GRAVITY_EARTH (9.80665f) |
| 346 | |
| 347 | /** Maximum magnetic field on Earth's surface */ |
| 348 | #define MAGNETIC_FIELD_EARTH_MAX (60.0f) |
| 349 | |
| 350 | /** Minimum magnetic field on Earth's surface */ |
| 351 | #define MAGNETIC_FIELD_EARTH_MIN (30.0f) |
| 352 | |
| 353 | |
| 354 | /** |
| 355 | * status of orientation sensor |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 356 | */ |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 357 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 358 | #define SENSOR_STATUS_UNRELIABLE 0 |
| 359 | #define SENSOR_STATUS_ACCURACY_LOW 1 |
| 360 | #define SENSOR_STATUS_ACCURACY_MEDIUM 2 |
| 361 | #define SENSOR_STATUS_ACCURACY_HIGH 3 |
| 362 | |
| 363 | |
| 364 | /** |
| 365 | * sensor event data |
| 366 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 367 | typedef struct { |
| 368 | union { |
| 369 | float v[3]; |
| 370 | struct { |
| 371 | float x; |
| 372 | float y; |
| 373 | float z; |
| 374 | }; |
| 375 | struct { |
| 376 | float azimuth; |
| 377 | float pitch; |
| 378 | float roll; |
| 379 | }; |
| 380 | }; |
| 381 | int8_t status; |
| 382 | uint8_t reserved[3]; |
| 383 | } sensors_vec_t; |
| 384 | |
| 385 | /** |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 386 | * uncalibrated gyroscope and magnetometer event data |
| 387 | */ |
| 388 | typedef struct { |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 389 | union { |
| 390 | float uncalib[3]; |
| 391 | struct { |
| 392 | float x_uncalib; |
| 393 | float y_uncalib; |
| 394 | float z_uncalib; |
| 395 | }; |
| 396 | }; |
| 397 | union { |
| 398 | float bias[3]; |
| 399 | struct { |
| 400 | float x_bias; |
| 401 | float y_bias; |
| 402 | float z_bias; |
| 403 | }; |
| 404 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 405 | } uncalibrated_event_t; |
| 406 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 407 | typedef struct meta_data_event { |
| 408 | int32_t what; |
| 409 | int32_t sensor; |
| 410 | } meta_data_event_t; |
| 411 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 412 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 413 | * Union of the various types of sensor data |
| 414 | * that can be returned. |
| 415 | */ |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 416 | typedef struct sensors_event_t { |
| 417 | /* must be sizeof(struct sensors_event_t) */ |
| 418 | int32_t version; |
| 419 | |
| 420 | /* sensor identifier */ |
| 421 | int32_t sensor; |
| 422 | |
| 423 | /* sensor type */ |
| 424 | int32_t type; |
| 425 | |
| 426 | /* reserved */ |
| 427 | int32_t reserved0; |
| 428 | |
| 429 | /* time is in nanosecond */ |
| 430 | int64_t timestamp; |
| 431 | |
| 432 | union { |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 433 | union { |
| 434 | float data[16]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 435 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 436 | /* acceleration values are in meter per second per second (m/s^2) */ |
| 437 | sensors_vec_t acceleration; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 438 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 439 | /* magnetic vector values are in micro-Tesla (uT) */ |
| 440 | sensors_vec_t magnetic; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 441 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 442 | /* orientation values are in degrees */ |
| 443 | sensors_vec_t orientation; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 444 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 445 | /* gyroscope values are in rad/s */ |
| 446 | sensors_vec_t gyro; |
Makarand Karvekar | 3120b58 | 2010-08-11 15:10:10 -0700 | [diff] [blame] | 447 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 448 | /* temperature is in degrees centigrade (Celsius) */ |
| 449 | float temperature; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 450 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 451 | /* distance in centimeters */ |
| 452 | float distance; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 453 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 454 | /* light in SI lux units */ |
| 455 | float light; |
Mathias Agopian | 1832f55 | 2010-07-29 15:22:30 -0700 | [diff] [blame] | 456 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 457 | /* pressure in hectopascal (hPa) */ |
| 458 | float pressure; |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 459 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 460 | /* relative humidity in percent */ |
| 461 | float relative_humidity; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 462 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 463 | /* uncalibrated gyroscope values are in rad/s */ |
| 464 | uncalibrated_event_t uncalibrated_gyro; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 465 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 466 | /* uncalibrated magnetometer values are in micro-Teslas */ |
| 467 | uncalibrated_event_t uncalibrated_magnetic; |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 468 | |
| 469 | /* this is a special event. see SENSOR_TYPE_META_DATA above. |
| 470 | * sensors_meta_data_event_t events are all reported with a type of |
| 471 | * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. |
| 472 | */ |
| 473 | meta_data_event_t meta_data; |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 474 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 475 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 476 | union { |
| 477 | uint64_t data[8]; |
| 478 | |
| 479 | /* step-counter */ |
| 480 | uint64_t step_counter; |
| 481 | } u64; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 482 | }; |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 483 | uint32_t reserved1[4]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 484 | } sensors_event_t; |
| 485 | |
| 486 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 487 | /* see SENSOR_TYPE_META_DATA */ |
| 488 | typedef sensors_event_t sensors_meta_data_event_t; |
| 489 | |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 490 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 491 | struct sensor_t; |
| 492 | |
| 493 | /** |
| 494 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 495 | * and the fields of this data structure must begin with hw_module_t |
| 496 | * followed by module specific information. |
| 497 | */ |
| 498 | struct sensors_module_t { |
| 499 | struct hw_module_t common; |
| 500 | |
| 501 | /** |
| 502 | * Enumerate all available sensors. The list is returned in "list". |
| 503 | * @return number of sensors in the list |
| 504 | */ |
| 505 | int (*get_sensors_list)(struct sensors_module_t* module, |
| 506 | struct sensor_t const** list); |
| 507 | }; |
| 508 | |
| 509 | struct sensor_t { |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 510 | |
| 511 | /* Name of this sensor. |
| 512 | * All sensors of the same "type" must have a different "name". |
| 513 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 514 | const char* name; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 515 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 516 | /* vendor of the hardware part */ |
| 517 | const char* vendor; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 518 | |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 519 | /* version of the hardware part + driver. The value of this field |
| 520 | * must increase when the driver is updated in a way that changes the |
| 521 | * output of this sensor. This is important for fused sensors when the |
| 522 | * fusion algorithm is updated. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 523 | */ |
| 524 | int version; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 525 | |
| 526 | /* handle that identifies this sensors. This handle is used to reference |
| 527 | * this sensor throughout the HAL API. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 528 | */ |
| 529 | int handle; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 530 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 531 | /* this sensor's type. */ |
| 532 | int type; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 533 | |
| 534 | /* 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] | 535 | float maxRange; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 536 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 537 | /* smallest difference between two values reported by this sensor */ |
| 538 | float resolution; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 539 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 540 | /* rough estimate of this sensor's power consumption in mA */ |
| 541 | float power; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 542 | |
| 543 | /* this value depends on the trigger mode: |
| 544 | * |
| 545 | * continuous: minimum sample period allowed in microseconds |
| 546 | * on-change : 0 |
| 547 | * one-shot :-1 |
| 548 | * special : 0, unless otherwise noted |
| 549 | */ |
Mathias Agopian | 1511e20 | 2010-07-29 15:33:22 -0700 | [diff] [blame] | 550 | int32_t minDelay; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 551 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 552 | /* number of events reserved for this sensor in the batch mode FIFO. |
| 553 | * If there is a dedicated FIFO for this sensor, then this is the |
| 554 | * size of this FIFO. If the FIFO is shared with other sensors, |
| 555 | * this is the size reserved for that sensor and it can be zero. |
| 556 | */ |
| 557 | uint32_t fifoReservedEventCount; |
| 558 | |
| 559 | /* maximum number of events of this sensor that could be batched. |
| 560 | * This is especially relevant when the FIFO is shared between |
| 561 | * several sensors; this value is then set to the size of that FIFO. |
| 562 | */ |
| 563 | uint32_t fifoMaxEventCount; |
| 564 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 565 | /* reserved fields, must be zero */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 566 | void* reserved[6]; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 567 | }; |
| 568 | |
| 569 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 570 | /* |
| 571 | * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 |
| 572 | * and is present for backward binary and source compatibility. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 573 | * See the Sensors HAL interface section for complete descriptions of the |
| 574 | * following functions: |
| 575 | * http://source.android.com/devices/sensors/index.html#hal |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 576 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 577 | struct sensors_poll_device_t { |
| 578 | struct hw_device_t common; |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 579 | int (*activate)(struct sensors_poll_device_t *dev, |
| 580 | int handle, int enabled); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 581 | int (*setDelay)(struct sensors_poll_device_t *dev, |
| 582 | int handle, int64_t ns); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 583 | int (*poll)(struct sensors_poll_device_t *dev, |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 584 | sensors_event_t* data, int count); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 585 | }; |
| 586 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 587 | /* |
| 588 | * struct sensors_poll_device_1 is used with SENSORS_DEVICE_API_VERSION_1_0 |
| 589 | */ |
| 590 | typedef struct sensors_poll_device_1 { |
| 591 | union { |
| 592 | /* sensors_poll_device_1 is compatible with sensors_poll_device_t, |
| 593 | * and can be down-cast to it |
| 594 | */ |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 595 | struct sensors_poll_device_t v0; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 596 | |
| 597 | struct { |
| 598 | struct hw_device_t common; |
| 599 | |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 600 | /* Activate/de-activate one sensor. Return 0 on success, negative |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 601 | * |
| 602 | * handle is the handle of the sensor to change. |
| 603 | * enabled set to 1 to enable, or 0 to disable the sensor. |
| 604 | * |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 605 | * Return 0 on success, negative errno code otherwise. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 606 | */ |
| 607 | int (*activate)(struct sensors_poll_device_t *dev, |
| 608 | int handle, int enabled); |
| 609 | |
| 610 | /** |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 611 | * Set the events's period in nanoseconds for a given sensor. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 612 | */ |
| 613 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 614 | int handle, int64_t period_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 615 | |
| 616 | /** |
| 617 | * Returns an array of sensor data. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 618 | */ |
| 619 | int (*poll)(struct sensors_poll_device_t *dev, |
| 620 | sensors_event_t* data, int count); |
| 621 | }; |
| 622 | }; |
| 623 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 624 | |
| 625 | /* |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame^] | 626 | * Enables batch mode for the given sensor and sets the delay between events. |
| 627 | * See the Batching sensor results page for details: |
| 628 | * http://source.android.com/devices/sensors/batching.html |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 629 | */ |
| 630 | int (*batch)(struct sensors_poll_device_1* dev, |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 631 | int handle, int flags, int64_t period_ns, int64_t timeout); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 632 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 633 | /* |
| 634 | * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) |
| 635 | * 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^] | 636 | * the FIFO. |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 637 | */ |
| 638 | int (*flush)(struct sensors_poll_device_1* dev, int handle); |
| 639 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 640 | void (*reserved_procs[8])(void); |
| 641 | |
| 642 | } sensors_poll_device_1_t; |
| 643 | |
| 644 | |
| 645 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 646 | /** convenience API for opening and closing a device */ |
| 647 | |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 648 | static inline int sensors_open(const struct hw_module_t* module, |
| 649 | struct sensors_poll_device_t** device) { |
| 650 | return module->methods->open(module, |
| 651 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 652 | } |
| 653 | |
| 654 | static inline int sensors_close(struct sensors_poll_device_t* device) { |
| 655 | return device->common.close(&device->common); |
| 656 | } |
| 657 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 658 | static inline int sensors_open_1(const struct hw_module_t* module, |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 659 | sensors_poll_device_1_t** device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 660 | return module->methods->open(module, |
| 661 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 662 | } |
| 663 | |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 664 | static inline int sensors_close_1(sensors_poll_device_1_t* device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 665 | return device->common.close(&device->common); |
| 666 | } |
| 667 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 668 | __END_DECLS |
| 669 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 670 | #endif // ANDROID_SENSORS_INTERFACE_H |