blob: e0ed8a959aed93b8a3b1b3230e2e9009191c5e1a [file] [log] [blame]
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef 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 Lockwood21b652f2009-05-22 10:05:48 -040025#include <cutils/native_handle.h>
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080026
27__BEGIN_DECLS
28
Mathias Agopian56f66cc2012-11-08 15:57:38 -080029/*****************************************************************************/
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)
34
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080035/**
36 * The id of this module
37 */
38#define SENSORS_HARDWARE_MODULE_ID "sensors"
39
40/**
41 * Name of the sensors device to open
42 */
Mathias Agopianb1e212e2010-07-08 16:44:54 -070043#define SENSORS_HARDWARE_POLL "poll"
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080044
45/**
46 * Handles must be higher than SENSORS_HANDLE_BASE and must be unique.
47 * A Handle identifies a given sensors. The handle is used to activate
48 * and/or deactivate sensors.
49 * In this version of the API there can only be 256 handles.
50 */
51#define SENSORS_HANDLE_BASE 0
52#define SENSORS_HANDLE_BITS 8
53#define SENSORS_HANDLE_COUNT (1<<SENSORS_HANDLE_BITS)
54
55
56/**
Mathias Agopian56f66cc2012-11-08 15:57:38 -080057 * Definition of the axis used by the sensor HAL API
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080058 *
59 * This API is relative to the screen of the device in its default orientation,
60 * that is, if the device can be used in portrait or landscape, this API
61 * is only relative to the NATURAL orientation of the screen. In other words,
62 * the axis are not swapped when the device's screen orientation changes.
63 * Higher level services /may/ perform this transformation.
64 *
65 * x<0 x>0
66 * ^
67 * |
68 * +-----------+--> y>0
69 * | |
70 * | |
71 * | |
72 * | | / z<0
73 * | | /
74 * | | /
75 * O-----------+/
76 * |[] [ ] []/
77 * +----------/+ y<0
78 * /
79 * /
80 * |/ z>0 (toward the sky)
81 *
82 * O: Origin (x=0,y=0,z=0)
83 *
Mathias Agopian56f66cc2012-11-08 15:57:38 -080084 */
85
86
87/*
88 * SENSOR_TYPE_ACCELEROMETER
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080089 *
Mathias Agopian56f66cc2012-11-08 15:57:38 -080090 * All values are in SI units (m/s^2) and measure the acceleration of the
91 * device minus the force of gravity.
92 *
93 * Acceleration sensors return sensor events for all 3 axes at a constant
94 * rate defined by setDelay().
95 *
96 * x: Acceleration on the x-axis
97 * y: Acceleration on the y-axis
98 * z: Acceleration on the z-axis
99 *
100 * Note that the readings from the accelerometer include the acceleration
101 * due to gravity (which is opposite to the direction of the gravity vector).
102 *
103 * Examples:
104 * The norm of <x, y, z> should be close to 0 when in free fall.
105 *
106 * When the device lies flat on a table and is pushed on its left side
107 * toward the right, the x acceleration value is positive.
108 *
109 * When the device lies flat on a table, the acceleration value is +9.81,
110 * which correspond to the acceleration of the device (0 m/s^2) minus the
111 * force of gravity (-9.81 m/s^2).
112 *
113 * When the device lies flat on a table and is pushed toward the sky, the
114 * acceleration value is greater than +9.81, which correspond to the
115 * acceleration of the device (+A m/s^2) minus the force of
116 * gravity (-9.81 m/s^2).
117 */
118#define SENSOR_TYPE_ACCELEROMETER (1)
119
120/*
121 * SENSOR_TYPE_GEOMAGNETIC_FIELD
122 *
123 * All values are in micro-Tesla (uT) and measure the geomagnetic
124 * field in the X, Y and Z axis.
125 *
126 * Returned values include calibration mechanisms such that the vector is
127 * aligned with the magnetic declination and heading of the earth's
128 * geomagnetic field.
129 *
130 * Magnetic Field sensors return sensor events for all 3 axes at a constant
131 * rate defined by setDelay().
132 */
133#define SENSOR_TYPE_GEOMAGNETIC_FIELD (2)
134#define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD
135
136/*
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800137 * SENSOR_TYPE_ORIENTATION
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800138 *
139 * All values are angles in degrees.
140 *
Mathias Agopian66a40952010-07-22 17:11:50 -0700141 * Orientation sensors return sensor events for all 3 axes at a constant
142 * rate defined by setDelay().
143 *
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800144 * azimuth: angle between the magnetic north direction and the Y axis, around
145 * the Z axis (0<=azimuth<360).
146 * 0=North, 90=East, 180=South, 270=West
147 *
148 * pitch: Rotation around X axis (-180<=pitch<=180), with positive values when
149 * the z-axis moves toward the y-axis.
150 *
151 * roll: Rotation around Y axis (-90<=roll<=90), with positive values when
Mathias Agopian19ea59f2010-02-26 13:15:18 -0800152 * the x-axis moves towards the z-axis.
153 *
154 * Note: For historical reasons the roll angle is positive in the clockwise
155 * direction (mathematically speaking, it should be positive in the
156 * counter-clockwise direction):
157 *
158 * Z
159 * ^
160 * (+roll) .--> |
161 * / |
162 * | | roll: rotation around Y axis
163 * X <-------(.)
164 * Y
165 * note that +Y == -roll
166 *
167 *
168 *
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800169 * Note: This definition is different from yaw, pitch and roll used in aviation
170 * where the X axis is along the long side of the plane (tail to nose).
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800171 */
172#define SENSOR_TYPE_ORIENTATION (3)
173
174/*
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800175 * SENSOR_TYPE_GYROSCOPE
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800176 *
Kevin Powellb01a0432010-07-19 19:12:15 -0700177 * All values are in radians/second and measure the rate of rotation
178 * around the X, Y and Z axis. The coordinate system is the same as is
Mathias Agopianc04e5f62010-09-14 10:53:55 -0700179 * used for the acceleration sensor. Rotation is positive in the
180 * counter-clockwise direction (right-hand rule). That is, an observer
181 * looking from some positive location on the x, y or z axis at a device
182 * positioned on the origin would report positive rotation if the device
183 * appeared to be rotating counter clockwise. Note that this is the
184 * standard mathematical definition of positive rotation and does not agree
185 * with the definition of roll given earlier.
186 * The range should at least be 17.45 rad/s (ie: ~1000 deg/s).
Kevin Powellb01a0432010-07-19 19:12:15 -0700187 *
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800188 * automatic gyro-drift compensation is allowed but not required.
189 */
190#define SENSOR_TYPE_GYROSCOPE (4)
191
192/*
193 * SENSOR_TYPE_LIGHT
194 *
195 * The light sensor value is returned in SI lux units.
196 *
197 * Light sensors report a value only when it changes and each time the
198 * sensor is enabled.
199 */
200#define SENSOR_TYPE_LIGHT (5)
201
202/*
203 * SENSOR_TYPE_PRESSURE
204 *
205 * The pressure sensor return the athmospheric pressure in hectopascal (hPa)
206 *
207 * Pressure sensors report events at a constant rate defined by setDelay().
208 */
209#define SENSOR_TYPE_PRESSURE (6)
210
211/* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */
212#define SENSOR_TYPE_TEMPERATURE (7)
213
214/*
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800215 * SENSOR_TYPE_PROXIMITY
Mike Lockwooda2414312009-11-03 10:29:50 -0500216 *
217 * The distance value is measured in centimeters. Note that some proximity
218 * sensors only support a binary "close" or "far" measurement. In this case,
219 * the sensor should report its maxRange value in the "far" state and a value
220 * less than maxRange in the "near" state.
221 *
Mathias Agopian478994a2010-07-23 17:23:43 -0700222 * Proximity sensors report a value only when it changes and each time the
Mathias Agopian15879d82011-11-01 19:17:58 -0700223 * sensor is enabled.
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800224 */
225#define SENSOR_TYPE_PROXIMITY (8)
226
227/*
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800228 * SENSOR_TYPE_GRAVITY
Mathias Agopian42b743c2010-11-22 15:55:32 -0800229 *
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800230 * A gravity output indicates the direction of and magnitude of gravity in
231 * the devices's coordinates. On Earth, the magnitude is 9.8 m/s^2.
232 * Units are m/s^2. The coordinate system is the same as is used for the
233 * acceleration sensor. When the device is at rest, the output of the
234 * gravity sensor should be identical to that of the accelerometer.
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800235 */
236#define SENSOR_TYPE_GRAVITY (9)
237
238/*
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800239 * SENSOR_TYPE_LINEAR_ACCELERATION
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800240 *
241 * Indicates the linear acceleration of the device in device coordinates,
242 * not including gravity.
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800243 *
244 * The output is conceptually:
245 * output of TYPE_ACCELERATION - output of TYPE_GRAVITY
246 *
247 * Readings on all axes should be close to 0 when device lies on a table.
248 * Units are m/s^2.
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800249 * The coordinate system is the same as is used for the acceleration sensor.
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800250 */
251#define SENSOR_TYPE_LINEAR_ACCELERATION (10)
252
253
254/*
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800255 * SENSOR_TYPE_ROTATION_VECTOR
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800256 *
Kevin Powellb01a0432010-07-19 19:12:15 -0700257 * A rotation vector represents the orientation of the device as a combination
258 * of an angle and an axis, in which the device has rotated through an angle
259 * theta around an axis <x, y, z>. The three elements of the rotation vector
260 * are <x*sin(theta/2), y*sin(theta/2), z*sin(theta/2)>, such that the magnitude
261 * of the rotation vector is equal to sin(theta/2), and the direction of the
262 * rotation vector is equal to the direction of the axis of rotation. The three
263 * elements of the rotation vector are equal to the last three components of a
264 * unit quaternion <cos(theta/2), x*sin(theta/2), y*sin(theta/2), z*sin(theta/2)>.
265 * Elements of the rotation vector are unitless. The x, y, and z axis are defined
266 * in the same was as for the acceleration sensor.
Mathias Agopian42b743c2010-11-22 15:55:32 -0800267 *
Mathias Agopiand93ff972011-05-02 19:10:31 -0700268 * The reference coordinate system is defined as a direct orthonormal basis,
269 * where:
270 *
271 * - X is defined as the vector product Y.Z (It is tangential to
272 * the ground at the device's current location and roughly points East).
273 *
274 * - Y is tangential to the ground at the device's current location and
275 * points towards the magnetic North Pole.
276 *
277 * - Z points towards the sky and is perpendicular to the ground.
278 *
279 *
Mathias Agopian42b743c2010-11-22 15:55:32 -0800280 * The rotation-vector is stored as:
281 *
282 * sensors_event_t.data[0] = x*sin(theta/2)
283 * sensors_event_t.data[1] = y*sin(theta/2)
284 * sensors_event_t.data[2] = z*sin(theta/2)
285 * sensors_event_t.data[3] = cos(theta/2)
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800286 */
287#define SENSOR_TYPE_ROTATION_VECTOR (11)
288
289/*
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800290 * SENSOR_TYPE_RELATIVE_HUMIDITY
Urs Fleischd2ed15a2010-12-29 17:00:33 +0100291 *
292 * A relative humidity sensor measures relative ambient air humidity and
293 * returns a value in percent.
294 *
295 * Relative humidity sensors report a value only when it changes and each
Mathias Agopian15879d82011-11-01 19:17:58 -0700296 * time the sensor is enabled.
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800297 */
298#define SENSOR_TYPE_RELATIVE_HUMIDITY (12)
299
300/*
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800301 * SENSOR_TYPE_AMBIENT_TEMPERATURE
Mathias Agopian54f9dd02011-03-22 18:42:03 -0700302 *
303 * The ambient (room) temperature in degree Celsius.
304 *
305 * Temperature sensors report a value only when it changes and each time the
Mathias Agopian15879d82011-11-01 19:17:58 -0700306 * sensor is enabled.
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800307 */
308#define SENSOR_TYPE_AMBIENT_TEMPERATURE (13)
309
310/*
311 * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED
Mathias Agopian54f9dd02011-03-22 18:42:03 -0700312 *
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800313 * All values are in micro-Tesla (uT) and measure the ambient magnetic
314 * field in the X, Y and Z axis.
315 *
316 * No periodic calibration is performed (ie: there are no discontinuities
317 * in the data stream while using this sensor). Assumptions that the the
318 * magnetic field is due to the Earth's poles should be avoided.
319 *
320 * Factory calibration and temperature compensation should still be applied.
321 *
322 * Magnetic Field sensors return sensor events for all 3 axes at a constant
323 * rate defined by setDelay().
324 */
325#define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14)
326
327/*
328 * SENSOR_TYPE_GAME_ROTATION_VECTOR
329 *
330 * SENSOR_TYPE_GAME_ROTATION_VECTOR is identical to SENSOR_TYPE_ROTATION_VECTOR,
331 * except that it doesn't use the geomagnetic field. Therefore the Y axis doesn't
332 * point north, but instead to some other reference, that reference is allowed
333 * to drift by the same order of magnitude than the gyroscope drift around
334 * the Z axis.
335 *
336 * In the ideal case, a phone rotated and returning to the same real-world
337 * orientation should report the same game rotation vector
338 * (without using the earth's geomagnetic field).
339 *
340 * see SENSOR_TYPE_ROTATION_VECTOR for more details
341 */
342#define SENSOR_TYPE_GAME_ROTATION_VECTOR (15)
343
344/*
345 * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED
346 *
347 * All values are in radians/second and measure the rate of rotation
348 * around the X, Y and Z axis. The coordinate system is the same as is
349 * used for the acceleration sensor. Rotation is positive in the
350 * counter-clockwise direction (right-hand rule). That is, an observer
351 * looking from some positive location on the x, y or z axis at a device
352 * positioned on the origin would report positive rotation if the device
353 * appeared to be rotating counter clockwise. Note that this is the
354 * standard mathematical definition of positive rotation and does not agree
355 * with the definition of roll given earlier.
356 * The range should at least be 17.45 rad/s (ie: ~1000 deg/s).
357 *
358 * No gyro-drift compensation shall be performed.
359 * Factory calibration and temperature compensation should still be applied.
360 */
361#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16)
362
363/**
364 * Values returned by the accelerometer in various locations in the universe.
365 * all values are in SI units (m/s^2)
366 */
367#define GRAVITY_SUN (275.0f)
368#define GRAVITY_EARTH (9.80665f)
369
370/** Maximum magnetic field on Earth's surface */
371#define MAGNETIC_FIELD_EARTH_MAX (60.0f)
372
373/** Minimum magnetic field on Earth's surface */
374#define MAGNETIC_FIELD_EARTH_MIN (30.0f)
375
376
377/**
378 * status of orientation sensor
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800379 */
Kevin Powellb01a0432010-07-19 19:12:15 -0700380
Mathias Agopian56f66cc2012-11-08 15:57:38 -0800381#define SENSOR_STATUS_UNRELIABLE 0
382#define SENSOR_STATUS_ACCURACY_LOW 1
383#define SENSOR_STATUS_ACCURACY_MEDIUM 2
384#define SENSOR_STATUS_ACCURACY_HIGH 3
385
386
387/**
388 * sensor event data
389 */
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800390typedef struct {
391 union {
392 float v[3];
393 struct {
394 float x;
395 float y;
396 float z;
397 };
398 struct {
399 float azimuth;
400 float pitch;
401 float roll;
402 };
403 };
404 int8_t status;
405 uint8_t reserved[3];
406} sensors_vec_t;
407
408/**
409 * Union of the various types of sensor data
410 * that can be returned.
411 */
Mathias Agopiancdefccd2010-07-15 18:29:03 -0700412typedef struct sensors_event_t {
413 /* must be sizeof(struct sensors_event_t) */
414 int32_t version;
415
416 /* sensor identifier */
417 int32_t sensor;
418
419 /* sensor type */
420 int32_t type;
421
422 /* reserved */
423 int32_t reserved0;
424
425 /* time is in nanosecond */
426 int64_t timestamp;
427
428 union {
429 float data[16];
430
431 /* acceleration values are in meter per second per second (m/s^2) */
432 sensors_vec_t acceleration;
433
434 /* magnetic vector values are in micro-Tesla (uT) */
435 sensors_vec_t magnetic;
436
437 /* orientation values are in degrees */
438 sensors_vec_t orientation;
439
Mathias Agopianc04e5f62010-09-14 10:53:55 -0700440 /* gyroscope values are in rad/s */
441 sensors_vec_t gyro;
Makarand Karvekar3120b582010-08-11 15:10:10 -0700442
Mathias Agopiancdefccd2010-07-15 18:29:03 -0700443 /* temperature is in degrees centigrade (Celsius) */
444 float temperature;
445
446 /* distance in centimeters */
447 float distance;
448
449 /* light in SI lux units */
450 float light;
Mathias Agopian1832f552010-07-29 15:22:30 -0700451
452 /* pressure in hectopascal (hPa) */
453 float pressure;
Urs Fleischd2ed15a2010-12-29 17:00:33 +0100454
455 /* relative humidity in percent */
456 float relative_humidity;
Mathias Agopiancdefccd2010-07-15 18:29:03 -0700457 };
458 uint32_t reserved1[4];
459} sensors_event_t;
460
461
462
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800463struct sensor_t;
464
465/**
466 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
467 * and the fields of this data structure must begin with hw_module_t
468 * followed by module specific information.
469 */
470struct sensors_module_t {
471 struct hw_module_t common;
472
473 /**
474 * Enumerate all available sensors. The list is returned in "list".
475 * @return number of sensors in the list
476 */
477 int (*get_sensors_list)(struct sensors_module_t* module,
478 struct sensor_t const** list);
479};
480
481struct sensor_t {
482 /* name of this sensors */
483 const char* name;
484 /* vendor of the hardware part */
485 const char* vendor;
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800486 /* version of the hardware part + driver. The value of this field
487 * must increase when the driver is updated in a way that changes the
488 * output of this sensor. This is important for fused sensors when the
489 * fusion algorithm is updated.
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800490 */
491 int version;
492 /* handle that identifies this sensors. This handle is used to activate
493 * and deactivate this sensor. The value of the handle must be 8 bits
494 * in this version of the API.
495 */
496 int handle;
497 /* this sensor's type. */
498 int type;
499 /* maximaum range of this sensor's value in SI units */
500 float maxRange;
501 /* smallest difference between two values reported by this sensor */
502 float resolution;
503 /* rough estimate of this sensor's power consumption in mA */
504 float power;
Mathias Agopian1511e202010-07-29 15:33:22 -0700505 /* minimum delay allowed between events in microseconds. A value of zero
506 * means that this sensor doesn't report events at a constant rate, but
507 * rather only when a new data is available */
508 int32_t minDelay;
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800509 /* reserved fields, must be zero */
Mathias Agopian1511e202010-07-29 15:33:22 -0700510 void* reserved[8];
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800511};
512
513
514/**
515 * Every device data structure must begin with hw_device_t
516 * followed by module specific public methods and attributes.
517 */
Mathias Agopianb1e212e2010-07-08 16:44:54 -0700518struct sensors_poll_device_t {
519 struct hw_device_t common;
520
521 /** Activate/deactivate one sensor.
522 *
523 * @param handle is the handle of the sensor to change.
524 * @param enabled set to 1 to enable, or 0 to disable the sensor.
525 *
526 * @return 0 on success, negative errno code otherwise
527 */
528 int (*activate)(struct sensors_poll_device_t *dev,
529 int handle, int enabled);
530
531 /**
Mathias Agopian1511e202010-07-29 15:33:22 -0700532 * Set the delay between sensor events in nanoseconds for a given sensor.
Mathias Agopian15879d82011-11-01 19:17:58 -0700533 *
Mathias Agopiane9eaf372011-11-07 21:32:34 -0800534 * If the requested value is less than sensor_t::minDelay, then it's
535 * silently clamped to sensor_t::minDelay unless sensor_t::minDelay is
536 * 0, in which case it is clamped to >= 1ms.
Mathias Agopianb1e212e2010-07-08 16:44:54 -0700537 *
538 * @return 0 if successful, < 0 on error
539 */
540 int (*setDelay)(struct sensors_poll_device_t *dev,
541 int handle, int64_t ns);
542
543 /**
544 * Returns an array of sensor data.
Mathias Agopian1511e202010-07-29 15:33:22 -0700545 * This function must block until events are available.
Mathias Agopianb1e212e2010-07-08 16:44:54 -0700546 *
547 * @return the number of events read on success, or -errno in case of an error.
Mathias Agopian1511e202010-07-29 15:33:22 -0700548 * This function should never return 0 (no event).
Mathias Agopianb1e212e2010-07-08 16:44:54 -0700549 *
550 */
551 int (*poll)(struct sensors_poll_device_t *dev,
Mathias Agopiancdefccd2010-07-15 18:29:03 -0700552 sensors_event_t* data, int count);
Mathias Agopianb1e212e2010-07-08 16:44:54 -0700553};
554
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800555/** convenience API for opening and closing a device */
556
Mathias Agopianb1e212e2010-07-08 16:44:54 -0700557static inline int sensors_open(const struct hw_module_t* module,
558 struct sensors_poll_device_t** device) {
559 return module->methods->open(module,
560 SENSORS_HARDWARE_POLL, (struct hw_device_t**)device);
561}
562
563static inline int sensors_close(struct sensors_poll_device_t* device) {
564 return device->common.close(&device->common);
565}
566
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800567__END_DECLS
568
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800569#endif // ANDROID_SENSORS_INTERFACE_H