The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1 | /* |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_SENSORS_INTERFACE_H |
| 18 | #define ANDROID_SENSORS_INTERFACE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/cdefs.h> |
| 22 | #include <sys/types.h> |
| 23 | |
| 24 | #include <hardware/hardware.h> |
Mike Lockwood | 21b652f | 2009-05-22 10:05:48 -0400 | [diff] [blame] | 25 | #include <cutils/native_handle.h> |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 26 | |
| 27 | __BEGIN_DECLS |
| 28 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 29 | /*****************************************************************************/ |
| 30 | |
| 31 | #define SENSORS_HEADER_VERSION 1 |
| 32 | #define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) |
| 33 | #define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 34 | #define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 35 | #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 36 | #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 37 | #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame^] | 38 | #define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 39 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 40 | /** |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 41 | * Please see the Sensors section of source.android.com for an |
| 42 | * introduction to and detailed descriptions of Android sensor types: |
| 43 | * http://source.android.com/devices/sensors/index.html |
| 44 | */ |
| 45 | |
| 46 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 47 | * The id of this module |
| 48 | */ |
| 49 | #define SENSORS_HARDWARE_MODULE_ID "sensors" |
| 50 | |
| 51 | /** |
| 52 | * Name of the sensors device to open |
| 53 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 54 | #define SENSORS_HARDWARE_POLL "poll" |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. |
| 58 | * A Handle identifies a given sensors. The handle is used to activate |
| 59 | * and/or deactivate sensors. |
| 60 | * In this version of the API there can only be 256 handles. |
| 61 | */ |
| 62 | #define SENSORS_HANDLE_BASE 0 |
| 63 | #define SENSORS_HANDLE_BITS 8 |
| 64 | #define SENSORS_HANDLE_COUNT (1<<SENSORS_HANDLE_BITS) |
| 65 | |
| 66 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 67 | /* |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 68 | * **** Deprecated ***** |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 69 | * flags for (*batch)() |
| 70 | * Availability: SENSORS_DEVICE_API_VERSION_1_0 |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 71 | * see (*batch)() documentation for details. |
| 72 | * Deprecated as of SENSORS_DEVICE_API_VERSION_1_3. |
| 73 | * WAKE_UP_* sensors replace WAKE_UPON_FIFO_FULL concept. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 74 | */ |
| 75 | enum { |
| 76 | SENSORS_BATCH_DRY_RUN = 0x00000001, |
| 77 | SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 |
| 78 | }; |
| 79 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 80 | /* |
| 81 | * what field for meta_data_event_t |
| 82 | */ |
| 83 | enum { |
| 84 | /* a previous flush operation has completed */ |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 85 | META_DATA_FLUSH_COMPLETE = 1, |
| 86 | META_DATA_VERSION /* always last, leave auto-assigned */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 89 | /* |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 90 | * The permission to use for body sensors (like heart rate monitors). |
| 91 | * See sensor types for more details on what sensors should require this |
| 92 | * permission. |
| 93 | */ |
| 94 | #define SENSOR_PERMISSION_BODY_SENSORS "android.permission.BODY_SENSORS" |
| 95 | |
| 96 | /* |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame^] | 97 | * Availability: SENSORS_DEVICE_API_VERSION_1_4 |
| 98 | * Sensor HAL modes uses in set_operation_mode method |
| 99 | */ |
| 100 | enum { |
| 101 | /* |
| 102 | * Operating modes for the HAL. |
| 103 | */ |
| 104 | |
| 105 | /* |
| 106 | * Normal mode operation. This is the default state of operation. |
| 107 | * The HAL shall initialize into this mode on device startup. |
| 108 | */ |
| 109 | SENSOR_HAL_NORMAL_MODE = 0, |
| 110 | |
| 111 | /* Loopback mode. In this mode, the device shall not source data from the |
| 112 | * physical sensors as it would in normal mode. Instead sensor data is |
| 113 | * injected by the sensor service. |
| 114 | */ |
| 115 | SENSOR_HAL_LOOPBACK_MODE = 0x1 |
| 116 | }; |
| 117 | |
| 118 | /* |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 119 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 120 | * Sensor flags used in sensor_t.flags. |
| 121 | */ |
| 122 | enum { |
| 123 | /* |
Aravind Akella | 110d2f2 | 2014-09-04 15:36:31 -0700 | [diff] [blame] | 124 | * Whether this sensor wakes up the AP from suspend mode when data is available. Whenever |
| 125 | * sensor events are delivered from a wake_up sensor, the driver needs to hold a wake_lock till |
| 126 | * the events are read by the SensorService i.e till sensors_poll_device_t.poll() is called the |
| 127 | * next time. Once poll is called again it means events have been read by the SensorService, the |
| 128 | * driver can safely release the wake_lock. SensorService will continue to hold a wake_lock till |
| 129 | * the app actually reads the events. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 130 | */ |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 131 | SENSOR_FLAG_WAKE_UP = 1U << 0, |
| 132 | /* |
| 133 | * Reporting modes for various sensors. Each sensor will have exactly one of these modes set. |
| 134 | * The least significant 2nd, 3rd and 4th bits are used to represent four possible reporting |
| 135 | * modes. |
| 136 | */ |
| 137 | SENSOR_FLAG_CONTINUOUS_MODE = 0, // 0000 |
| 138 | SENSOR_FLAG_ON_CHANGE_MODE = 0x2, // 0010 |
| 139 | SENSOR_FLAG_ONE_SHOT_MODE = 0x4, // 0100 |
| 140 | SENSOR_FLAG_SPECIAL_REPORTING_MODE = 0x6 // 0110 |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | /* |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 144 | * Mask and shift for reporting mode sensor flags defined above. |
| 145 | */ |
| 146 | #define REPORTING_MODE_MASK (0xE) |
| 147 | #define REPORTING_MODE_SHIFT (1) |
| 148 | |
| 149 | /* |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 150 | * Sensor type |
| 151 | * |
| 152 | * 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] | 153 | * measures are reported. See the Base sensors and Composite sensors lists |
| 154 | * for complete descriptions: |
| 155 | * http://source.android.com/devices/sensors/base_triggers.html |
| 156 | * http://source.android.com/devices/sensors/composite_sensors.html |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 157 | * |
| 158 | * Device manufacturers (OEMs) can define their own sensor types, for |
| 159 | * their private use by applications or services provided by them. Such |
| 160 | * sensor types are specific to an OEM and can't be exposed in the SDK. |
| 161 | * These types must start at SENSOR_TYPE_DEVICE_PRIVATE_BASE. |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 162 | * |
| 163 | * All sensors defined outside of the device private range must correspond to |
| 164 | * a type defined in this file, and must satisfy the characteristics listed in |
| 165 | * the description of the sensor type. |
| 166 | * |
| 167 | * Starting with version SENSORS_DEVICE_API_VERSION_1_2, each sensor also |
| 168 | * has a stringType. |
| 169 | * - StringType of sensors inside of the device private range MUST be prefixed |
| 170 | * by the sensor provider's or OEM reverse domain name. In particular, they |
| 171 | * cannot use the "android.sensor" prefix. |
| 172 | * - StringType of sensors outside of the device private range MUST correspond |
| 173 | * to the one defined in this file (starting with "android.sensor"). |
| 174 | * For example, accelerometers must have |
| 175 | * type=SENSOR_TYPE_ACCELEROMETER and |
| 176 | * stringType=SENSOR_STRING_TYPE_ACCELEROMETER |
| 177 | * |
| 178 | * When android introduces a new sensor type that can replace an OEM-defined |
| 179 | * sensor type, the OEM must use the official sensor type and stringType on |
| 180 | * versions of the HAL that support this new official sensor type. |
| 181 | * |
| 182 | * Example (made up): Suppose Google's Glass team wants to surface a sensor |
| 183 | * detecting that Glass is on a head. |
| 184 | * - Such a sensor is not officially supported in android KitKat |
| 185 | * - Glass devices launching on KitKat can implement a sensor with |
| 186 | * type = 0x10001 and stringType = "com.google.glass.onheaddetector" |
| 187 | * - In L android release, if android decides to define |
| 188 | * SENSOR_TYPE_ON_HEAD_DETECTOR and STRING_SENSOR_TYPE_ON_HEAD_DETECTOR, |
| 189 | * those types should replace the Glass-team-specific types in all future |
| 190 | * launches. |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 191 | * - When launching Glass on the L release, Google should now use the official |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 192 | * type (SENSOR_TYPE_ON_HEAD_DETECTOR) and stringType. |
| 193 | * - This way, all applications can now use this sensor. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 194 | */ |
| 195 | |
| 196 | /* |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 197 | * Base for device manufacturers private sensor types. |
| 198 | * These sensor types can't be exposed in the SDK. |
| 199 | */ |
| 200 | #define SENSOR_TYPE_DEVICE_PRIVATE_BASE 0x10000 |
| 201 | |
| 202 | /* |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 203 | * SENSOR_TYPE_META_DATA |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 204 | * reporting-mode: n/a |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 205 | * wake-up sensor: n/a |
| 206 | * |
| 207 | * NO SENSOR OF THAT TYPE MUST BE RETURNED (*get_sensors_list)() |
| 208 | * |
| 209 | * SENSOR_TYPE_META_DATA is a special token used to populate the |
| 210 | * sensors_meta_data_event structure. It doesn't correspond to a physical |
| 211 | * sensor. sensors_meta_data_event are special, they exist only inside |
| 212 | * the HAL and are generated spontaneously, as opposed to be related to |
| 213 | * a physical sensor. |
| 214 | * |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 215 | * sensors_meta_data_event_t.version must be META_DATA_VERSION |
| 216 | * sensors_meta_data_event_t.sensor must be 0 |
| 217 | * sensors_meta_data_event_t.type must be SENSOR_TYPE_META_DATA |
| 218 | * sensors_meta_data_event_t.reserved must be 0 |
| 219 | * sensors_meta_data_event_t.timestamp must be 0 |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 220 | * |
| 221 | * The payload is a meta_data_event_t, where: |
| 222 | * meta_data_event_t.what can take the following values: |
| 223 | * |
| 224 | * META_DATA_FLUSH_COMPLETE |
| 225 | * This event indicates that a previous (*flush)() call has completed for the sensor |
| 226 | * handle specified in meta_data_event_t.sensor. |
| 227 | * see (*flush)() for more details |
| 228 | * |
| 229 | * All other values for meta_data_event_t.what are reserved and |
| 230 | * must not be used. |
| 231 | * |
| 232 | */ |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 233 | #define SENSOR_TYPE_META_DATA (0) |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 234 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 235 | /* |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 236 | * Wake up sensors. |
| 237 | * Each sensor may have either or both a wake-up and a non-wake variant. |
| 238 | * When registered in batch mode, wake-up sensors will wake up the AP when |
| 239 | * their FIFOs are full or when the batch timeout expires. A separate FIFO has |
| 240 | * to be maintained for wake up sensors and non wake up sensors. The non wake-up |
| 241 | * sensors need to overwrite their FIFOs when they are full till the AP wakes up |
| 242 | * and the wake-up sensors will wake-up the AP when their FIFOs are full or when |
| 243 | * the batch timeout expires without losing events. Wake-up and non wake-up variants |
| 244 | * of each sensor can be activated at different rates independently of each other. |
| 245 | * |
| 246 | * Note: Proximity sensor and significant motion sensor which were defined in previous |
| 247 | * releases are also wake-up sensors and should be treated as such. Wake-up one-shot |
| 248 | * sensors like SIGNIFICANT_MOTION cannot be batched, hence the text about batch above |
| 249 | * doesn't apply to them. See the definitions of SENSOR_TYPE_PROXIMITY and |
| 250 | * SENSOR_TYPE_SIGNIFICANT_MOTION for more info. |
| 251 | * |
| 252 | * Set SENSOR_FLAG_WAKE_UP flag for all wake-up sensors. |
| 253 | * |
| 254 | * For example, A device can have two sensors both of SENSOR_TYPE_ACCELEROMETER and |
| 255 | * one of them can be a wake_up sensor (with SENSOR_FLAG_WAKE_UP flag set) and the other |
| 256 | * can be a regular non wake_up sensor. Both of these sensors must be activated/deactivated |
| 257 | * independently of the other. |
| 258 | */ |
| 259 | |
| 260 | /* |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 261 | * SENSOR_TYPE_ACCELEROMETER |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 262 | * reporting-mode: continuous |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 263 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 264 | * All values are in SI units (m/s^2) and measure the acceleration of the |
| 265 | * device minus the force of gravity. |
| 266 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 267 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 268 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 269 | */ |
| 270 | #define SENSOR_TYPE_ACCELEROMETER (1) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 271 | #define SENSOR_STRING_TYPE_ACCELEROMETER "android.sensor.accelerometer" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 272 | |
| 273 | /* |
| 274 | * SENSOR_TYPE_GEOMAGNETIC_FIELD |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 275 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 276 | * |
| 277 | * All values are in micro-Tesla (uT) and measure the geomagnetic |
| 278 | * field in the X, Y and Z axis. |
| 279 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 280 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 281 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 282 | */ |
| 283 | #define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) |
| 284 | #define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 285 | #define SENSOR_STRING_TYPE_MAGNETIC_FIELD "android.sensor.magnetic_field" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 286 | |
| 287 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 288 | * SENSOR_TYPE_ORIENTATION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 289 | * reporting-mode: continuous |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 290 | * |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 291 | * All values are angles in degrees. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 292 | * |
Mathias Agopian | 66a4095 | 2010-07-22 17:11:50 -0700 | [diff] [blame] | 293 | * Orientation sensors return sensor events for all 3 axes at a constant |
| 294 | * rate defined by setDelay(). |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 295 | * |
| 296 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 297 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 298 | */ |
| 299 | #define SENSOR_TYPE_ORIENTATION (3) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 300 | #define SENSOR_STRING_TYPE_ORIENTATION "android.sensor.orientation" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 301 | |
| 302 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 303 | * SENSOR_TYPE_GYROSCOPE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 304 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 305 | * |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 306 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 307 | * around the X, Y and Z axis. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 308 | * |
| 309 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 310 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 311 | */ |
| 312 | #define SENSOR_TYPE_GYROSCOPE (4) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 313 | #define SENSOR_STRING_TYPE_GYROSCOPE "android.sensor.gyroscope" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 314 | |
| 315 | /* |
| 316 | * SENSOR_TYPE_LIGHT |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 317 | * reporting-mode: on-change |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 318 | * |
| 319 | * The light sensor value is returned in SI lux units. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 320 | * |
| 321 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 322 | */ |
| 323 | #define SENSOR_TYPE_LIGHT (5) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 324 | #define SENSOR_STRING_TYPE_LIGHT "android.sensor.light" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 325 | |
| 326 | /* |
| 327 | * SENSOR_TYPE_PRESSURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 328 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 329 | * |
| 330 | * The pressure sensor return the athmospheric pressure in hectopascal (hPa) |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 331 | * |
| 332 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 333 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 334 | */ |
| 335 | #define SENSOR_TYPE_PRESSURE (6) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 336 | #define SENSOR_STRING_TYPE_PRESSURE "android.sensor.pressure" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 337 | |
| 338 | /* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */ |
| 339 | #define SENSOR_TYPE_TEMPERATURE (7) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 340 | #define SENSOR_STRING_TYPE_TEMPERATURE "android.sensor.temperature" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 341 | |
| 342 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 343 | * SENSOR_TYPE_PROXIMITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 344 | * reporting-mode: on-change |
Mike Lockwood | a241431 | 2009-11-03 10:29:50 -0500 | [diff] [blame] | 345 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 346 | * The proximity sensor which turns the screen off and back on during calls is the |
| 347 | * wake-up proximity sensor. Implement wake-up proximity sensor before implementing |
| 348 | * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag |
| 349 | * SENSOR_FLAG_WAKE_UP. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 350 | * The value corresponds to the distance to the nearest object in centimeters. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 351 | */ |
| 352 | #define SENSOR_TYPE_PROXIMITY (8) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 353 | #define SENSOR_STRING_TYPE_PROXIMITY "android.sensor.proximity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 354 | |
| 355 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 356 | * SENSOR_TYPE_GRAVITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 357 | * reporting-mode: continuous |
Mathias Agopian | 42b743c | 2010-11-22 15:55:32 -0800 | [diff] [blame] | 358 | * |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 359 | * A gravity output indicates the direction of and magnitude of gravity in |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 360 | * the devices's coordinates. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 361 | * |
| 362 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 363 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 364 | */ |
| 365 | #define SENSOR_TYPE_GRAVITY (9) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 366 | #define SENSOR_STRING_TYPE_GRAVITY "android.sensor.gravity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 367 | |
| 368 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 369 | * SENSOR_TYPE_LINEAR_ACCELERATION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 370 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 371 | * |
| 372 | * Indicates the linear acceleration of the device in device coordinates, |
| 373 | * not including gravity. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 374 | * |
| 375 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 376 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 377 | */ |
| 378 | #define SENSOR_TYPE_LINEAR_ACCELERATION (10) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 379 | #define SENSOR_STRING_TYPE_LINEAR_ACCELERATION "android.sensor.linear_acceleration" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 380 | |
| 381 | |
| 382 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 383 | * SENSOR_TYPE_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 384 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 385 | * |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 386 | * The rotation vector symbolizes the orientation of the device relative to the |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 387 | * East-North-Up coordinates frame. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 388 | * |
| 389 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 390 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 391 | */ |
| 392 | #define SENSOR_TYPE_ROTATION_VECTOR (11) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 393 | #define SENSOR_STRING_TYPE_ROTATION_VECTOR "android.sensor.rotation_vector" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 394 | |
| 395 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 396 | * SENSOR_TYPE_RELATIVE_HUMIDITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 397 | * reporting-mode: on-change |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 398 | * |
| 399 | * A relative humidity sensor measures relative ambient air humidity and |
| 400 | * returns a value in percent. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 401 | * |
| 402 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 403 | */ |
| 404 | #define SENSOR_TYPE_RELATIVE_HUMIDITY (12) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 405 | #define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY "android.sensor.relative_humidity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 406 | |
| 407 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 408 | * SENSOR_TYPE_AMBIENT_TEMPERATURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 409 | * reporting-mode: on-change |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 410 | * |
| 411 | * The ambient (room) temperature in degree Celsius. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 412 | * |
| 413 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 414 | */ |
| 415 | #define SENSOR_TYPE_AMBIENT_TEMPERATURE (13) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 416 | #define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE "android.sensor.ambient_temperature" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 417 | |
| 418 | /* |
| 419 | * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 420 | * reporting-mode: continuous |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 421 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 422 | * Similar to SENSOR_TYPE_MAGNETIC_FIELD, but the hard iron calibration is |
| 423 | * reported separately instead of being included in the measurement. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 424 | * |
| 425 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 426 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 427 | */ |
| 428 | #define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 429 | #define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED "android.sensor.magnetic_field_uncalibrated" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 430 | |
| 431 | /* |
| 432 | * SENSOR_TYPE_GAME_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 433 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 434 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 435 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but not using the geomagnetic |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 436 | * field. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 437 | * |
| 438 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 439 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 440 | */ |
| 441 | #define SENSOR_TYPE_GAME_ROTATION_VECTOR (15) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 442 | #define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR "android.sensor.game_rotation_vector" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 443 | |
| 444 | /* |
| 445 | * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 446 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 447 | * |
| 448 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 449 | * around the X, Y and Z axis. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 450 | * |
| 451 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 452 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 453 | */ |
| 454 | #define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 455 | #define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED "android.sensor.gyroscope_uncalibrated" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 456 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 457 | /* |
| 458 | * SENSOR_TYPE_SIGNIFICANT_MOTION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 459 | * reporting-mode: one-shot |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 460 | * |
| 461 | * A sensor of this type triggers an event each time significant motion |
| 462 | * is detected and automatically disables itself. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 463 | * For Significant Motion sensor to be useful, it must be defined as a |
| 464 | * wake-up sensor. (set SENSOR_FLAG_WAKE_UP). Implement the wake-up significant motion |
| 465 | * sensor. A non wake-up version is not useful. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 466 | * The only allowed value to return is 1.0. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 467 | */ |
| 468 | |
| 469 | #define SENSOR_TYPE_SIGNIFICANT_MOTION (17) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 470 | #define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION "android.sensor.significant_motion" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 471 | |
| 472 | /* |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 473 | * SENSOR_TYPE_STEP_DETECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 474 | * reporting-mode: special |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 475 | * |
| 476 | * 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] | 477 | * by the user. The only allowed value to return is 1.0 and an event |
| 478 | * is generated for each step. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 479 | * |
| 480 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 481 | */ |
| 482 | |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 483 | #define SENSOR_TYPE_STEP_DETECTOR (18) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 484 | #define SENSOR_STRING_TYPE_STEP_DETECTOR "android.sensor.step_detector" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 485 | |
| 486 | |
| 487 | /* |
| 488 | * SENSOR_TYPE_STEP_COUNTER |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 489 | * reporting-mode: on-change |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 490 | * |
| 491 | * 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] | 492 | * 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] | 493 | * reset to zero only on a system / android reboot. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 494 | * |
| 495 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 496 | * version if the system possesses a wake up fifo. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 497 | */ |
| 498 | |
| 499 | #define SENSOR_TYPE_STEP_COUNTER (19) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 500 | #define SENSOR_STRING_TYPE_STEP_COUNTER "android.sensor.step_counter" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 501 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 502 | /* |
| 503 | * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 504 | * reporting-mode: continuous |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 505 | * |
| 506 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but using a magnetometer instead |
| 507 | * of using a gyroscope. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 508 | * |
| 509 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 510 | * version if the system possesses a wake up fifo. |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 511 | */ |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 512 | #define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20) |
| 513 | #define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR "android.sensor.geomagnetic_rotation_vector" |
| 514 | |
| 515 | /* |
| 516 | * SENSOR_TYPE_HEART_RATE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 517 | * reporting-mode: on-change |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 518 | * |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 519 | * A sensor of this type returns the current heart rate. |
| 520 | * The events contain the current heart rate in beats per minute (BPM) and the |
| 521 | * status of the sensor during the measurement. See heart_rate_event_t for more |
| 522 | * details. |
| 523 | * |
| 524 | * Because this sensor is on-change, events must be generated when and only |
| 525 | * when heart_rate.bpm or heart_rate.status have changed since the last |
Vinod Krishnan | 74279e3 | 2014-08-28 15:25:13 -0700 | [diff] [blame] | 526 | * event. In particular, upon the first activation, unless the device is known |
| 527 | * to not be on the body, the status field of the first event must be set to |
| 528 | * SENSOR_STATUS_UNRELIABLE. The event should be generated no faster than every |
| 529 | * period_ns passed to setDelay() or to batch(). |
Griff Hazen | f0f67e6 | 2014-08-28 17:02:50 -0700 | [diff] [blame] | 530 | * See the definition of the on-change reporting mode for more information. |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 531 | * |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 532 | * sensor_t.requiredPermission must be set to SENSOR_PERMISSION_BODY_SENSORS. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 533 | * |
| 534 | * Both wake-up and non wake-up versions are useful. |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 535 | */ |
| 536 | #define SENSOR_TYPE_HEART_RATE (21) |
| 537 | #define SENSOR_STRING_TYPE_HEART_RATE "android.sensor.heart_rate" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 538 | |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 539 | /* |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 540 | * SENSOR_TYPE_WAKE_UP_TILT_DETECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 541 | * reporting-mode: special (setDelay has no impact) |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 542 | * |
| 543 | * A sensor of this type generates an event each time a tilt event is detected. A tilt event |
| 544 | * should be generated if the direction of the 2-seconds window average gravity changed by at least |
Etienne Le Grand | 53017ef | 2014-05-28 15:42:48 -0700 | [diff] [blame] | 545 | * 35 degrees since the activation or the last trigger of the sensor. |
Etienne Le Grand | 426f14d | 2014-05-29 19:35:48 -0700 | [diff] [blame] | 546 | * reference_estimated_gravity = average of accelerometer measurements over the first |
Etienne Le Grand | 53017ef | 2014-05-28 15:42:48 -0700 | [diff] [blame] | 547 | * 1 second after activation or the estimated gravity at the last |
| 548 | * trigger. |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 549 | * current_estimated_gravity = average of accelerometer measurements over the last 2 seconds. |
Etienne Le Grand | 426f14d | 2014-05-29 19:35:48 -0700 | [diff] [blame] | 550 | * trigger when angle (reference_estimated_gravity, current_estimated_gravity) > 35 degrees |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 551 | * |
| 552 | * Large accelerations without a change in phone orientation should not trigger a tilt event. |
| 553 | * For example, a sharp turn or strong acceleration while driving a car should not trigger a tilt |
| 554 | * event, even though the angle of the average acceleration might vary by more than 35 degrees. |
| 555 | * |
| 556 | * Typically, this sensor is implemented with the help of only an accelerometer. Other sensors can |
| 557 | * be used as well if they do not increase the power consumption significantly. This is a low power |
| 558 | * sensor that should allow the AP to go into suspend mode. Do not emulate this sensor in the HAL. |
| 559 | * Like other wake up sensors, the driver is expected to a hold a wake_lock with a timeout of 200 ms |
| 560 | * while reporting this event. The only allowed return value is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 561 | * |
| 562 | * Implement only the wake-up version of this sensor. |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 563 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 564 | #define SENSOR_TYPE_TILT_DETECTOR (22) |
| 565 | #define SENSOR_STRING_TYPE_TILT_DETECTOR "android.sensor.tilt_detector" |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 566 | |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 567 | /* |
| 568 | * SENSOR_TYPE_WAKE_GESTURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 569 | * reporting-mode: one-shot |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 570 | * |
| 571 | * A sensor enabling waking up the device based on a device specific motion. |
| 572 | * |
| 573 | * When this sensor triggers, the device behaves as if the power button was |
| 574 | * pressed, turning the screen on. This behavior (turning on the screen when |
| 575 | * this sensor triggers) might be deactivated by the user in the device |
| 576 | * settings. Changes in settings do not impact the behavior of the sensor: |
| 577 | * only whether the framework turns the screen on when it triggers. |
| 578 | * |
| 579 | * The actual gesture to be detected is not specified, and can be chosen by |
| 580 | * the manufacturer of the device. |
| 581 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 582 | * The only allowed value to return is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 583 | * |
| 584 | * Implement only the wake-up version of this sensor. |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 585 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 586 | #define SENSOR_TYPE_WAKE_GESTURE (23) |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 587 | #define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture" |
| 588 | |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 589 | /* |
| 590 | * SENSOR_TYPE_GLANCE_GESTURE |
| 591 | * reporting-mode: one-shot |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 592 | * |
| 593 | * A sensor enabling briefly turning the screen on to enable the user to |
| 594 | * glance content on screen based on a specific motion. The device should |
| 595 | * turn the screen off after a few moments. |
| 596 | * |
| 597 | * When this sensor triggers, the device turns the screen on momentarily |
| 598 | * to allow the user to glance notifications or other content while the |
| 599 | * device remains locked in a non-interactive state (dozing). This behavior |
| 600 | * (briefly turning on the screen when this sensor triggers) might be deactivated |
| 601 | * by the user in the device settings. Changes in settings do not impact the |
| 602 | * behavior of the sensor: only whether the framework briefly turns the screen on |
| 603 | * when it triggers. |
| 604 | * |
| 605 | * The actual gesture to be detected is not specified, and can be chosen by |
| 606 | * the manufacturer of the device. |
| 607 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 608 | * The only allowed value to return is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 609 | * |
| 610 | * Implement only the wake-up version of this sensor. |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 611 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 612 | #define SENSOR_TYPE_GLANCE_GESTURE (24) |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 613 | #define SENSOR_STRING_TYPE_GLANCE_GESTURE "android.sensor.glance_gesture" |
| 614 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 615 | /** |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 616 | * SENSOR_TYPE_PICK_UP_GESTURE |
| 617 | * reporting-mode: one-shot |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 618 | * |
| 619 | * A sensor of this type triggers when the device is picked up regardless of wherever is was |
| 620 | * before (desk, pocket, bag). The only allowed return value is 1.0. |
| 621 | * This sensor de-activates itself immediately after it triggers. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 622 | * |
| 623 | * Implement only the wake-up version of this sensor. |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 624 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 625 | #define SENSOR_TYPE_PICK_UP_GESTURE (25) |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 626 | #define SENSOR_STRING_TYPE_PICK_UP_GESTURE "android.sensor.pick_up_gesture" |
| 627 | |
Nick Vaccaro | adbfbb7 | 2015-01-13 12:14:28 -0800 | [diff] [blame] | 628 | /* |
| 629 | * SENSOR_TYPE_WRIST_TILT_GESTURE |
| 630 | * trigger-mode: special |
| 631 | * wake-up sensor: yes |
| 632 | * |
| 633 | * A sensor of this type triggers an event each time a tilt of the wrist-worn |
| 634 | * device is detected. |
| 635 | * |
| 636 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 637 | * The only allowed value to return is 1.0. |
| 638 | * |
| 639 | * Implement only the wake-up version of this sensor. |
| 640 | */ |
| 641 | #define SENSOR_TYPE_WRIST_TILT_GESTURE (26) |
| 642 | #define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE "android.sensor.wrist_tilt_gesture" |
| 643 | |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 644 | /** |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame^] | 645 | * SENSOR_TYPE_TIME_SYNC |
| 646 | * reporting-mode: continuous |
| 647 | * |
| 648 | * A time synchronization mechanism sensor to synchronize timing between |
| 649 | * differnt parts of the device. |
| 650 | * This sensor returns the following values in the sensor_event |
| 651 | * Time_stamp of the event |
| 652 | * u64.data[0] -> Type of event latched |
| 653 | * u64.data[1] -> count |
| 654 | * |
| 655 | * Implement only the wake-up version of this sensor. |
| 656 | */ |
| 657 | #define SENSOR_TYPE_TIME_SYNC (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 0x10) |
| 658 | #define SENSOR_STRING_TYPE_TIME_SYNC "android.sensor.time_sync" |
| 659 | |
| 660 | /** |
| 661 | * SENSOR_TYPE_NUDGE_GESTURE |
| 662 | * reporting-mode: one-shot |
| 663 | * |
| 664 | * A sensor of this type triggers when the device is nudged. |
| 665 | * |
| 666 | * The only allowed return value is 1.0. This sensor |
| 667 | * de-activates itself immediately after it triggers. |
| 668 | * |
| 669 | * Implement only the wake-up version of this sensor. |
| 670 | */ |
| 671 | #define SENSOR_TYPE_NUDGE_GESTURE (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 0x11) |
| 672 | #define SENSOR_STRING_NUDGE_UP_GESTURE "android.sensor.nudge_gesture" |
| 673 | |
| 674 | /** |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 675 | * Values returned by the accelerometer in various locations in the universe. |
| 676 | * all values are in SI units (m/s^2) |
| 677 | */ |
| 678 | #define GRAVITY_SUN (275.0f) |
| 679 | #define GRAVITY_EARTH (9.80665f) |
| 680 | |
| 681 | /** Maximum magnetic field on Earth's surface */ |
| 682 | #define MAGNETIC_FIELD_EARTH_MAX (60.0f) |
| 683 | |
| 684 | /** Minimum magnetic field on Earth's surface */ |
| 685 | #define MAGNETIC_FIELD_EARTH_MIN (30.0f) |
| 686 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 687 | /** |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 688 | * Possible values of the status field of sensor events. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 689 | */ |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 690 | #define SENSOR_STATUS_NO_CONTACT -1 |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 691 | #define SENSOR_STATUS_UNRELIABLE 0 |
| 692 | #define SENSOR_STATUS_ACCURACY_LOW 1 |
| 693 | #define SENSOR_STATUS_ACCURACY_MEDIUM 2 |
| 694 | #define SENSOR_STATUS_ACCURACY_HIGH 3 |
| 695 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 696 | /** |
| 697 | * sensor event data |
| 698 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 699 | typedef struct { |
| 700 | union { |
| 701 | float v[3]; |
| 702 | struct { |
| 703 | float x; |
| 704 | float y; |
| 705 | float z; |
| 706 | }; |
| 707 | struct { |
| 708 | float azimuth; |
| 709 | float pitch; |
| 710 | float roll; |
| 711 | }; |
| 712 | }; |
| 713 | int8_t status; |
| 714 | uint8_t reserved[3]; |
| 715 | } sensors_vec_t; |
| 716 | |
| 717 | /** |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 718 | * uncalibrated gyroscope and magnetometer event data |
| 719 | */ |
| 720 | typedef struct { |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 721 | union { |
| 722 | float uncalib[3]; |
| 723 | struct { |
| 724 | float x_uncalib; |
| 725 | float y_uncalib; |
| 726 | float z_uncalib; |
| 727 | }; |
| 728 | }; |
| 729 | union { |
| 730 | float bias[3]; |
| 731 | struct { |
| 732 | float x_bias; |
| 733 | float y_bias; |
| 734 | float z_bias; |
| 735 | }; |
| 736 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 737 | } uncalibrated_event_t; |
| 738 | |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 739 | /** |
| 740 | * Meta data event data |
| 741 | */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 742 | typedef struct meta_data_event { |
| 743 | int32_t what; |
| 744 | int32_t sensor; |
| 745 | } meta_data_event_t; |
| 746 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 747 | /** |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 748 | * Heart rate event data |
| 749 | */ |
| 750 | typedef struct { |
| 751 | // Heart rate in beats per minute. |
| 752 | // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT |
| 753 | float bpm; |
| 754 | // Status of the sensor for this reading. Set to one SENSOR_STATUS_... |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 755 | // Note that this value should only be set for sensors that explicitly define |
| 756 | // the meaning of this field. This field is not piped through the framework |
| 757 | // for other sensors. |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 758 | int8_t status; |
| 759 | } heart_rate_event_t; |
| 760 | |
| 761 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 762 | * Union of the various types of sensor data |
| 763 | * that can be returned. |
| 764 | */ |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 765 | typedef struct sensors_event_t { |
| 766 | /* must be sizeof(struct sensors_event_t) */ |
| 767 | int32_t version; |
| 768 | |
| 769 | /* sensor identifier */ |
| 770 | int32_t sensor; |
| 771 | |
| 772 | /* sensor type */ |
| 773 | int32_t type; |
| 774 | |
| 775 | /* reserved */ |
| 776 | int32_t reserved0; |
| 777 | |
| 778 | /* time is in nanosecond */ |
| 779 | int64_t timestamp; |
| 780 | |
| 781 | union { |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 782 | union { |
| 783 | float data[16]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 784 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 785 | /* acceleration values are in meter per second per second (m/s^2) */ |
| 786 | sensors_vec_t acceleration; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 787 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 788 | /* magnetic vector values are in micro-Tesla (uT) */ |
| 789 | sensors_vec_t magnetic; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 790 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 791 | /* orientation values are in degrees */ |
| 792 | sensors_vec_t orientation; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 793 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 794 | /* gyroscope values are in rad/s */ |
| 795 | sensors_vec_t gyro; |
Makarand Karvekar | 3120b58 | 2010-08-11 15:10:10 -0700 | [diff] [blame] | 796 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 797 | /* temperature is in degrees centigrade (Celsius) */ |
| 798 | float temperature; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 799 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 800 | /* distance in centimeters */ |
| 801 | float distance; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 802 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 803 | /* light in SI lux units */ |
| 804 | float light; |
Mathias Agopian | 1832f55 | 2010-07-29 15:22:30 -0700 | [diff] [blame] | 805 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 806 | /* pressure in hectopascal (hPa) */ |
| 807 | float pressure; |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 808 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 809 | /* relative humidity in percent */ |
| 810 | float relative_humidity; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 811 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 812 | /* uncalibrated gyroscope values are in rad/s */ |
| 813 | uncalibrated_event_t uncalibrated_gyro; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 814 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 815 | /* uncalibrated magnetometer values are in micro-Teslas */ |
| 816 | uncalibrated_event_t uncalibrated_magnetic; |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 817 | |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 818 | /* heart rate data containing value in bpm and status */ |
| 819 | heart_rate_event_t heart_rate; |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 820 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 821 | /* this is a special event. see SENSOR_TYPE_META_DATA above. |
| 822 | * sensors_meta_data_event_t events are all reported with a type of |
| 823 | * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. |
| 824 | */ |
| 825 | meta_data_event_t meta_data; |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 826 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 827 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 828 | union { |
| 829 | uint64_t data[8]; |
| 830 | |
| 831 | /* step-counter */ |
| 832 | uint64_t step_counter; |
| 833 | } u64; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 834 | }; |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 835 | |
| 836 | /* Reserved flags for internal use. Set to zero. */ |
| 837 | uint32_t flags; |
| 838 | |
| 839 | uint32_t reserved1[3]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 840 | } sensors_event_t; |
| 841 | |
| 842 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 843 | /* see SENSOR_TYPE_META_DATA */ |
| 844 | typedef sensors_event_t sensors_meta_data_event_t; |
| 845 | |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 846 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 847 | struct sensor_t; |
| 848 | |
| 849 | /** |
| 850 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 851 | * and the fields of this data structure must begin with hw_module_t |
| 852 | * followed by module specific information. |
| 853 | */ |
| 854 | struct sensors_module_t { |
| 855 | struct hw_module_t common; |
| 856 | |
| 857 | /** |
| 858 | * Enumerate all available sensors. The list is returned in "list". |
| 859 | * @return number of sensors in the list |
| 860 | */ |
| 861 | int (*get_sensors_list)(struct sensors_module_t* module, |
| 862 | struct sensor_t const** list); |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame^] | 863 | |
| 864 | /** |
| 865 | * Place the module in a specific mode. The following modes are defined |
| 866 | * |
| 867 | * 0 - Normal operation. Default state of the module. |
| 868 | * 1 - Loopback mode. Data is injected for the the supported sensors by |
| 869 | * the sensor service in this mode. |
| 870 | */ |
| 871 | int (*set_operation_mode)(unsigned int mode); |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 872 | }; |
| 873 | |
| 874 | struct sensor_t { |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 875 | |
| 876 | /* Name of this sensor. |
| 877 | * All sensors of the same "type" must have a different "name". |
| 878 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 879 | const char* name; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 880 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 881 | /* vendor of the hardware part */ |
| 882 | const char* vendor; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 883 | |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 884 | /* version of the hardware part + driver. The value of this field |
| 885 | * must increase when the driver is updated in a way that changes the |
| 886 | * output of this sensor. This is important for fused sensors when the |
| 887 | * fusion algorithm is updated. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 888 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 889 | int version; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 890 | |
| 891 | /* handle that identifies this sensors. This handle is used to reference |
| 892 | * this sensor throughout the HAL API. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 893 | */ |
| 894 | int handle; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 895 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 896 | /* this sensor's type. */ |
| 897 | int type; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 898 | |
| 899 | /* 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] | 900 | float maxRange; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 901 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 902 | /* smallest difference between two values reported by this sensor */ |
| 903 | float resolution; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 904 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 905 | /* rough estimate of this sensor's power consumption in mA */ |
| 906 | float power; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 907 | |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 908 | /* this value depends on the reporting mode: |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 909 | * |
| 910 | * continuous: minimum sample period allowed in microseconds |
| 911 | * on-change : 0 |
| 912 | * one-shot :-1 |
| 913 | * special : 0, unless otherwise noted |
| 914 | */ |
Mathias Agopian | 1511e20 | 2010-07-29 15:33:22 -0700 | [diff] [blame] | 915 | int32_t minDelay; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 916 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 917 | /* number of events reserved for this sensor in the batch mode FIFO. |
| 918 | * If there is a dedicated FIFO for this sensor, then this is the |
| 919 | * size of this FIFO. If the FIFO is shared with other sensors, |
| 920 | * this is the size reserved for that sensor and it can be zero. |
| 921 | */ |
| 922 | uint32_t fifoReservedEventCount; |
| 923 | |
| 924 | /* maximum number of events of this sensor that could be batched. |
| 925 | * This is especially relevant when the FIFO is shared between |
| 926 | * several sensors; this value is then set to the size of that FIFO. |
| 927 | */ |
| 928 | uint32_t fifoMaxEventCount; |
| 929 | |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 930 | /* type of this sensor as a string. Set to corresponding |
| 931 | * SENSOR_STRING_TYPE_*. |
| 932 | * When defining an OEM specific sensor or sensor manufacturer specific |
| 933 | * sensor, use your reserve domain name as a prefix. |
| 934 | * ex: com.google.glass.onheaddetector |
| 935 | * For sensors of known type, the android framework might overwrite this |
| 936 | * string automatically. |
| 937 | */ |
| 938 | const char* stringType; |
| 939 | |
| 940 | /* permission required to see this sensor, register to it and receive data. |
| 941 | * Set to "" if no permission is required. Some sensor types like the |
| 942 | * heart rate monitor have a mandatory require_permission. |
| 943 | * For sensors that always require a specific permission, like the heart |
| 944 | * rate monitor, the android framework might overwrite this string |
| 945 | * automatically. |
| 946 | */ |
| 947 | const char* requiredPermission; |
| 948 | |
Aravind Akella | 110d2f2 | 2014-09-04 15:36:31 -0700 | [diff] [blame] | 949 | /* This value is defined only for continuous mode and on-change sensors. It is the delay between |
| 950 | * two sensor events corresponding to the lowest frequency that this sensor supports. When lower |
| 951 | * frequencies are requested through batch()/setDelay() the events will be generated at this |
| 952 | * frequency instead. It can be used by the framework or applications to estimate when the batch |
| 953 | * FIFO may be full. |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 954 | * |
| 955 | * NOTE: 1) period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. |
Aravind Akella | 110d2f2 | 2014-09-04 15:36:31 -0700 | [diff] [blame] | 956 | * continuous, on-change: maximum sampling period allowed in microseconds. |
| 957 | * one-shot, special : 0 |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 958 | * 2) maxDelay should always fit within a 32 bit signed integer. It is declared as 64 bit |
| 959 | * on 64 bit architectures only for binary compatibility reasons. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 960 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 961 | */ |
| 962 | #ifdef __LP64__ |
| 963 | int64_t maxDelay; |
| 964 | #else |
| 965 | int32_t maxDelay; |
| 966 | #endif |
| 967 | |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 968 | /* Flags for sensor. See SENSOR_FLAG_* above. Only the least significant 32 bits are used here. |
| 969 | * It is declared as 64 bit on 64 bit architectures only for binary compatibility reasons. |
| 970 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 971 | */ |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 972 | #ifdef __LP64__ |
| 973 | uint64_t flags; |
| 974 | #else |
| 975 | uint32_t flags; |
| 976 | #endif |
| 977 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 978 | /* reserved fields, must be zero */ |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 979 | void* reserved[2]; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 980 | }; |
| 981 | |
| 982 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 983 | /* |
| 984 | * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 |
| 985 | * and is present for backward binary and source compatibility. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 986 | * See the Sensors HAL interface section for complete descriptions of the |
| 987 | * following functions: |
| 988 | * http://source.android.com/devices/sensors/index.html#hal |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 989 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 990 | struct sensors_poll_device_t { |
| 991 | struct hw_device_t common; |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 992 | int (*activate)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 993 | int sensor_handle, int enabled); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 994 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 995 | int sensor_handle, int64_t sampling_period_ns); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 996 | int (*poll)(struct sensors_poll_device_t *dev, |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 997 | sensors_event_t* data, int count); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 998 | }; |
| 999 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1000 | /* |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1001 | * struct sensors_poll_device_1 is used in HAL versions >= SENSORS_DEVICE_API_VERSION_1_0 |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1002 | */ |
| 1003 | typedef struct sensors_poll_device_1 { |
| 1004 | union { |
| 1005 | /* sensors_poll_device_1 is compatible with sensors_poll_device_t, |
| 1006 | * and can be down-cast to it |
| 1007 | */ |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1008 | struct sensors_poll_device_t v0; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1009 | |
| 1010 | struct { |
| 1011 | struct hw_device_t common; |
| 1012 | |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 1013 | /* Activate/de-activate one sensor. Return 0 on success, negative |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1014 | * |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1015 | * sensor_handle is the handle of the sensor to change. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1016 | * enabled set to 1 to enable, or 0 to disable the sensor. |
| 1017 | * |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 1018 | * Return 0 on success, negative errno code otherwise. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1019 | */ |
| 1020 | int (*activate)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1021 | int sensor_handle, int enabled); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1022 | |
| 1023 | /** |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1024 | * Set the events's period in nanoseconds for a given sensor. |
| 1025 | * If sampling_period_ns > max_delay it will be truncated to |
| 1026 | * max_delay and if sampling_period_ns < min_delay it will be |
| 1027 | * replaced by min_delay. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1028 | */ |
| 1029 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1030 | int sensor_handle, int64_t sampling_period_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1031 | |
| 1032 | /** |
| 1033 | * Returns an array of sensor data. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1034 | */ |
| 1035 | int (*poll)(struct sensors_poll_device_t *dev, |
| 1036 | sensors_event_t* data, int count); |
| 1037 | }; |
| 1038 | }; |
| 1039 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1040 | |
| 1041 | /* |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1042 | * Sets a sensor’s parameters, including sampling frequency and maximum |
| 1043 | * report latency. This function can be called while the sensor is |
| 1044 | * activated, in which case it must not cause any sensor measurements to |
| 1045 | * be lost: transitioning from one sampling rate to the other cannot cause |
| 1046 | * lost events, nor can transitioning from a high maximum report latency to |
| 1047 | * a low maximum report latency. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 1048 | * See the Batching sensor results page for details: |
| 1049 | * http://source.android.com/devices/sensors/batching.html |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1050 | */ |
| 1051 | int (*batch)(struct sensors_poll_device_1* dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1052 | int sensor_handle, int flags, int64_t sampling_period_ns, |
| 1053 | int64_t max_report_latency_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1054 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1055 | /* |
| 1056 | * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) |
| 1057 | * to the end of the "batch mode" FIFO for the specified sensor and flushes |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1058 | * the FIFO. |
| 1059 | * If the FIFO is empty or if the sensor doesn't support batching (FIFO size zero), |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 1060 | * it should return SUCCESS along with a trivial META_DATA_FLUSH_COMPLETE event added to the |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1061 | * event stream. This applies to all sensors other than one-shot sensors. |
| 1062 | * If the sensor is a one-shot sensor, flush must return -EINVAL and not generate |
| 1063 | * any flush complete metadata. |
Aravind Akella | a7f2cda | 2014-08-21 16:31:14 -0700 | [diff] [blame] | 1064 | * If the sensor is not active at the time flush() is called, flush() should return |
| 1065 | * -EINVAL. |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1066 | */ |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1067 | int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle); |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1068 | |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame^] | 1069 | /* |
| 1070 | * Inject a sensor samples to be to this device. |
| 1071 | */ |
| 1072 | int (*inject_sensor_data)(struct sensors_poll_device_1 *dev, const sensors_event_t *data); |
| 1073 | |
| 1074 | void (*reserved_procs[7])(void); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1075 | |
| 1076 | } sensors_poll_device_1_t; |
| 1077 | |
| 1078 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1079 | /** convenience API for opening and closing a device */ |
| 1080 | |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1081 | static inline int sensors_open(const struct hw_module_t* module, |
| 1082 | struct sensors_poll_device_t** device) { |
| 1083 | return module->methods->open(module, |
| 1084 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 1085 | } |
| 1086 | |
| 1087 | static inline int sensors_close(struct sensors_poll_device_t* device) { |
| 1088 | return device->common.close(&device->common); |
| 1089 | } |
| 1090 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1091 | static inline int sensors_open_1(const struct hw_module_t* module, |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1092 | sensors_poll_device_1_t** device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1093 | return module->methods->open(module, |
| 1094 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 1095 | } |
| 1096 | |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1097 | static inline int sensors_close_1(sensors_poll_device_1_t* device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1098 | return device->common.close(&device->common); |
| 1099 | } |
| 1100 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1101 | __END_DECLS |
| 1102 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1103 | #endif // ANDROID_SENSORS_INTERFACE_H |