summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-07-19 15:32:24 -0700
committerMathias Agopian <mathias@google.com>2010-07-19 15:32:24 -0700
commit98c5309047d2eedfe93ac42243f9750cfeb3517e (patch)
treefe0e2b8c20bc4e8933a8d465ad347f9a2b42214f
parentcdefccdba52337df41f577d9ebfcfd67c05708cf (diff)
downloadlibhardware-98c5309047d2eedfe93ac42243f9750cfeb3517e.tar.gz
move the old sensorHAL interface into a separate header
sensors_deprecated.h is included from sensors.h, for easier reading. Change-Id: I97883e1db73beb6c612da2ec023ee6bb8d4858c3
-rw-r--r--[-rwxr-xr-x]include/hardware/lights.h0
-rw-r--r--include/hardware/sensors.h147
-rw-r--r--include/hardware/sensors_deprecated.h75
3 files changed, 77 insertions, 145 deletions
diff --git a/include/hardware/lights.h b/include/hardware/lights.h
index 2cf55193..2cf55193 100755..100644
--- a/include/hardware/lights.h
+++ b/include/hardware/lights.h
diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h
index a044e47b..7439c5ee 100644
--- a/include/hardware/sensors.h
+++ b/include/hardware/sensors.h
@@ -34,8 +34,6 @@ __BEGIN_DECLS
/**
* Name of the sensors device to open
*/
-#define SENSORS_HARDWARE_CONTROL "control"
-#define SENSORS_HARDWARE_DATA "data"
#define SENSORS_HARDWARE_POLL "poll"
/**
@@ -215,45 +213,6 @@ typedef struct {
* Union of the various types of sensor data
* that can be returned.
*/
-typedef struct {
- /* sensor identifier */
- int sensor;
-
- union {
- /* x,y,z values of the given sensor */
- sensors_vec_t vector;
-
- /* orientation values are in degrees */
- sensors_vec_t orientation;
-
- /* acceleration values are in meter per second per second (m/s^2) */
- sensors_vec_t acceleration;
-
- /* magnetic vector values are in micro-Tesla (uT) */
- sensors_vec_t magnetic;
-
- /* temperature is in degrees centigrade (Celsius) */
- float temperature;
-
- /* distance in centimeters */
- float distance;
-
- /* light in SI lux units */
- float light;
- };
-
- /* time is in nanosecond */
- int64_t time;
-
- uint32_t reserved;
-} sensors_data_t;
-
-
-
-/**
- * Union of the various types of sensor data
- * that can be returned.
- */
typedef struct sensors_event_t {
/* must be sizeof(struct sensors_event_t) */
int32_t version;
@@ -377,89 +336,6 @@ struct sensors_poll_device_t {
sensors_event_t* data, int count);
};
-
-struct sensors_control_device_t {
- struct hw_device_t common;
-
- /**
- * Returns a native_handle_t, which will be the parameter to
- * sensors_data_device_t::open_data().
- * The caller takes ownership of this handle. This is intended to be
- * passed cross processes.
- *
- * @return a native_handle_t if successful, NULL on error
- */
- native_handle_t* (*open_data_source)(struct sensors_control_device_t *dev);
-
- /**
- * Releases any resources that were created by open_data_source.
- * This call is optional and can be NULL if not implemented
- * by the sensor HAL.
- *
- * @return 0 if successful, < 0 on error
- */
- int (*close_data_source)(struct sensors_control_device_t *dev);
-
- /** Activate/deactivate one sensor.
- *
- * @param handle is the handle of the sensor to change.
- * @param enabled set to 1 to enable, or 0 to disable the sensor.
- *
- * @return 0 on success, negative errno code otherwise
- */
- int (*activate)(struct sensors_control_device_t *dev,
- int handle, int enabled);
-
- /**
- * Set the delay between sensor events in ms
- *
- * @return 0 if successful, < 0 on error
- */
- int (*set_delay)(struct sensors_control_device_t *dev, int32_t ms);
-
- /**
- * Causes sensors_data_device_t.poll() to return -EWOULDBLOCK immediately.
- */
- int (*wake)(struct sensors_control_device_t *dev);
-};
-
-struct sensors_data_device_t {
- struct hw_device_t common;
-
- /**
- * Prepare to read sensor data.
- *
- * This routine does NOT take ownership of the handle
- * and must not close it. Typically this routine would
- * use a duplicate of the nh parameter.
- *
- * @param nh from sensors_control_open.
- *
- * @return 0 if successful, < 0 on error
- */
- int (*data_open)(struct sensors_data_device_t *dev, native_handle_t* nh);
-
- /**
- * Caller has completed using the sensor data.
- * The caller will not be blocked in sensors_data_poll
- * when this routine is called.
- *
- * @return 0 if successful, < 0 on error
- */
- int (*data_close)(struct sensors_data_device_t *dev);
-
- /**
- * Return sensor data for one of the enabled sensors.
- *
- * @return sensor handle for the returned data, 0x7FFFFFFF when
- * sensors_control_device_t.wake() is called and -errno on error
- *
- */
- int (*poll)(struct sensors_data_device_t *dev,
- sensors_data_t* data);
-};
-
-
/** convenience API for opening and closing a device */
static inline int sensors_open(const struct hw_module_t* module,
@@ -472,27 +348,8 @@ static inline int sensors_close(struct sensors_poll_device_t* device) {
return device->common.close(&device->common);
}
-static inline int sensors_control_open(const struct hw_module_t* module,
- struct sensors_control_device_t** device) {
- return module->methods->open(module,
- SENSORS_HARDWARE_CONTROL, (struct hw_device_t**)device);
-}
-
-static inline int sensors_control_close(struct sensors_control_device_t* device) {
- return device->common.close(&device->common);
-}
-
-static inline int sensors_data_open(const struct hw_module_t* module,
- struct sensors_data_device_t** device) {
- return module->methods->open(module,
- SENSORS_HARDWARE_DATA, (struct hw_device_t**)device);
-}
-
-static inline int sensors_data_close(struct sensors_data_device_t* device) {
- return device->common.close(&device->common);
-}
-
-
__END_DECLS
+#include <hardware/sensors_deprecated.h>
+
#endif // ANDROID_SENSORS_INTERFACE_H
diff --git a/include/hardware/sensors_deprecated.h b/include/hardware/sensors_deprecated.h
new file mode 100644
index 00000000..79747882
--- /dev/null
+++ b/include/hardware/sensors_deprecated.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define SENSORS_HARDWARE_CONTROL "control"
+#define SENSORS_HARDWARE_DATA "data"
+
+__BEGIN_DECLS
+
+typedef struct {
+ int sensor;
+ union {
+ sensors_vec_t vector;
+ sensors_vec_t orientation;
+ sensors_vec_t acceleration;
+ sensors_vec_t magnetic;
+ float temperature;
+ float distance;
+ float light;
+ };
+ int64_t time;
+ uint32_t reserved;
+} sensors_data_t;
+
+struct sensors_control_device_t {
+ struct hw_device_t common;
+ native_handle_t* (*open_data_source)(struct sensors_control_device_t *dev);
+ int (*close_data_source)(struct sensors_control_device_t *dev);
+ int (*activate)(struct sensors_control_device_t *dev,
+ int handle, int enabled);
+ int (*set_delay)(struct sensors_control_device_t *dev, int32_t ms);
+ int (*wake)(struct sensors_control_device_t *dev);
+};
+
+struct sensors_data_device_t {
+ struct hw_device_t common;
+ int (*data_open)(struct sensors_data_device_t *dev, native_handle_t* nh);
+ int (*data_close)(struct sensors_data_device_t *dev);
+ int (*poll)(struct sensors_data_device_t *dev,
+ sensors_data_t* data);
+};
+
+static inline int sensors_control_open(const struct hw_module_t* module,
+ struct sensors_control_device_t** device) {
+ return module->methods->open(module,
+ SENSORS_HARDWARE_CONTROL, (struct hw_device_t**)device);
+}
+
+static inline int sensors_control_close(struct sensors_control_device_t* device) {
+ return device->common.close(&device->common);
+}
+
+static inline int sensors_data_open(const struct hw_module_t* module,
+ struct sensors_data_device_t** device) {
+ return module->methods->open(module,
+ SENSORS_HARDWARE_DATA, (struct hw_device_t**)device);
+}
+
+static inline int sensors_data_close(struct sensors_data_device_t* device) {
+ return device->common.close(&device->common);
+}
+
+__END_DECLS