Code drop from //branches/cupcake/...@124589
diff --git a/include/hardware/AudioHardwareBase.h b/include/hardware/AudioHardwareBase.h
new file mode 100644
index 0000000..1c83d70
--- /dev/null
+++ b/include/hardware/AudioHardwareBase.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2007 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.
+ */
+
+#ifndef ANDROID_AUDIO_HARDWARE_BASE_H
+#define ANDROID_AUDIO_HARDWARE_BASE_H
+
+#include "hardware/AudioHardwareInterface.h"
+
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+/** 
+ * AudioHardwareBase is a convenient base class used for implementing the 
+ * AudioHardwareInterface interface.
+ */
+class AudioHardwareBase : public AudioHardwareInterface
+{
+public:
+                        AudioHardwareBase();
+    virtual             ~AudioHardwareBase() { }
+
+    /**  
+     * Audio routing methods. Routes defined in include/hardware/AudioSystem.h. 
+     * Audio routes can be (ROUTE_EARPIECE | ROUTE_SPEAKER | ROUTE_BLUETOOTH 
+     *                    | ROUTE_HEADSET)
+     * 
+     * setRouting sets the routes for a mode. This is called at startup. It is
+     * also called when a new device is connected, such as a wired headset is 
+     * plugged in or a Bluetooth headset is paired.
+     */
+    virtual status_t    setRouting(int mode, uint32_t routes);
+    
+    virtual status_t    getRouting(int mode, uint32_t* routes);
+    
+    /**
+     * setMode is called when the audio mode changes. NORMAL mode is for
+     * standard audio playback, RINGTONE when a ringtone is playing, and IN_CALL
+     * when a call is in progress.
+     */
+    virtual status_t    setMode(int mode);
+    virtual status_t    getMode(int* mode);
+
+    // Temporary interface, do not use
+    // TODO: Replace with a more generic key:value get/set mechanism
+    virtual status_t    setParameter(const char* key, const char* value);
+    
+    virtual  size_t     getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
+    
+    /**This method dumps the state of the audio hardware */
+    virtual status_t dumpState(int fd, const Vector<String16>& args);
+
+protected:
+    int             mMode;
+    uint32_t        mRoutes[AudioSystem::NUM_MODES];
+};
+
+}; // namespace android
+
+#endif // ANDROID_AUDIO_HARDWARE_BASE_H
diff --git a/include/hardware/AudioHardwareInterface.h b/include/hardware/AudioHardwareInterface.h
index febc86a..66cf0ff 100644
--- a/include/hardware/AudioHardwareInterface.h
+++ b/include/hardware/AudioHardwareInterface.h
@@ -33,137 +33,159 @@
 // ----------------------------------------------------------------------------
 
 /**
- * This is the abstraction interface for the audio output hardware. It provides 
- * information about various properties of the audio output hardware driver.
+ * AudioStreamOut is the abstraction interface for the audio output hardware.
+ *
+ * It provides information about various properties of the audio output hardware driver.
  */
 class AudioStreamOut {
 public:
     virtual             ~AudioStreamOut() = 0;
-    
+
     /** return audio sampling rate in hz - eg. 44100 */
     virtual uint32_t    sampleRate() const = 0;
-    
+
     /** returns size of output buffer - eg. 4800 */
     virtual size_t      bufferSize() const = 0;
-    
-    /** 
-     * return number of output audio channels. 
-     * Acceptable values are 1 (mono) or 2 (stereo) 
+
+    /**
+     * return number of output audio channels.
+     * Acceptable values are 1 (mono) or 2 (stereo)
      */
     virtual int         channelCount() const = 0;
-    
+
     /**
-     * return audio format in 8bit or 16bit PCM format - 
-     * eg. AudioSystem:PCM_16_BIT 
+     * return audio format in 8bit or 16bit PCM format -
+     * eg. AudioSystem:PCM_16_BIT
      */
     virtual int         format() const = 0;
-    
-    /** 
-     * This method can be used in situations where audio mixing is done in the
-     * hardware. It is a direct interface to the hardware to set the volume as
-     * as opposed to controlling this via the framework. It could be multiple 
-     * PCM outputs or hardware accelerated codecs such as MP3 or AAC
+
+    /**
+     * return the frame size (number of bytes per sample).
+     */
+    uint32_t    frameSize() const { return channelCount()*((format()==AudioSystem::PCM_16_BIT)?sizeof(int16_t):sizeof(int8_t)); }
+
+    /**
+     * return the audio hardware driver latency in milli seconds.
+     */
+    virtual uint32_t    latency() const = 0;
+
+    /**
+     * Use this method in situations where audio mixing is done in the
+     * hardware. This method serves as a direct interface with hardware,
+     * allowing you to directly set the volume as apposed to via the framework.
+     * This method might produce multiple PCM outputs or hardware accelerated
+     * codecs, such as MP3 or AAC.
      */
     virtual status_t    setVolume(float volume) = 0;
-    
+
     /** write audio buffer to driver. Returns number of bytes written */
     virtual ssize_t     write(const void* buffer, size_t bytes) = 0;
 
     /** dump the state of the audio output device */
-    virtual status_t dump(int fd, const Vector<String16>& args) = 0; 
+    virtual status_t dump(int fd, const Vector<String16>& args) = 0;
 };
 
 /**
- * This is the abstraction interface for the audio input hardware. It defines 
- * the various properties of the audio hardware input driver.  
+ * AudioStreamIn is the abstraction interface for the audio input hardware.
+ *
+ * It defines the various properties of the audio hardware input driver.
  */
 class AudioStreamIn {
 public:
     virtual             ~AudioStreamIn() = 0;
-    
+
     /** return the input buffer size allowed by audio driver */
     virtual size_t      bufferSize() const = 0;
 
     /** return the number of audio input channels */
     virtual int         channelCount() const = 0;
-    
-    /** 
-     * return audio format in 8bit or 16bit PCM format - 
-     * eg. AudioSystem:PCM_16_BIT 
+
+    /**
+     * return audio format in 8bit or 16bit PCM format -
+     * eg. AudioSystem:PCM_16_BIT
      */
     virtual int         format() const = 0;
 
+    /**
+     * return the frame size (number of bytes per sample).
+     */
+    uint32_t    frameSize() const { return channelCount()*((format()==AudioSystem::PCM_16_BIT)?sizeof(int16_t):sizeof(int8_t)); }
+
     /** set the input gain for the audio driver. This method is for
      *  for future use */
     virtual status_t    setGain(float gain) = 0;
-    
+
     /** read audio buffer in from audio driver */
     virtual ssize_t     read(void* buffer, ssize_t bytes) = 0;
 
     /** dump the state of the audio input device */
     virtual status_t dump(int fd, const Vector<String16>& args) = 0;
+
+    /**
+     * Put the audio hardware input into standby mode. Returns
+     * status based on include/utils/Errors.h
+     */
+    virtual status_t    standby() = 0;
+
 };
 
-/** 
- * This defines the interface to the audio hardware abstraction layer. It 
- * supports setting and getting parameters, selecting audio routing paths and 
- * defining input and output streams.
- * 
- * AudioFlinger initializes the audio hardware and immediately opens an output 
- * stream. Audio routing can be set to output to handset, speaker, bluetooth or 
- * headset. 
+/**
+ * AudioHardwareInterface.h defines the interface to the audio hardware abstraction layer.
  *
- * The audio input stream is initialized when AudioFlinger is called to carry 
- * out a record operation. 
+ * The interface supports setting and getting parameters, selecting audio routing
+ * paths, and defining input and output streams.
+ *
+ * AudioFlinger initializes the audio hardware and immediately opens an output stream.
+ * You can set Audio routing to output to handset, speaker, Bluetooth, or a headset.
+ *
+ * The audio input stream is initialized when AudioFlinger is called to carry out
+ * a record operation.
  */
 class AudioHardwareInterface
 {
 public:
-                        AudioHardwareInterface();
-    virtual             ~AudioHardwareInterface() { }
-
-    /** 
-     * check to see if the audio hardware interface has been initialized. 
-     * return status based on values defined in include/utils/Errors.h 
+    /**
+     * check to see if the audio hardware interface has been initialized.
+     * return status based on values defined in include/utils/Errors.h
      */
     virtual status_t    initCheck() = 0;
 
-    /** 
-     * put the audio hardware into standby mode to conserve power. Returns 
-     * status based on include/utils/Errors.h 
+    /**
+     * put the audio hardware into standby mode to conserve power. Returns
+     * status based on include/utils/Errors.h
      */
     virtual status_t    standby() = 0;
 
     /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */
     virtual status_t    setVoiceVolume(float volume) = 0;
-    
-    /** 
-     * set the audio volume for all audio activities other than voice call. 
-     * Range between 0.0 and 1.0. IF any value other than NO_ERROR is returned,
+
+    /**
+     * set the audio volume for all audio activities other than voice call.
+     * Range between 0.0 and 1.0. If any value other than NO_ERROR is returned,
      * the software mixer will emulate this capability.
      */
     virtual status_t    setMasterVolume(float volume) = 0;
 
-    /**  
-     * Audio routing methods. Routes defined in include/hardware/AudioSystem.h. 
-     * Audio routes can be (ROUTE_EARPIECE | ROUTE_SPEAKER | ROUTE_BLUETOOTH 
+    /**
+     * Audio routing methods. Routes defined in include/hardware/AudioSystem.h.
+     * Audio routes can be (ROUTE_EARPIECE | ROUTE_SPEAKER | ROUTE_BLUETOOTH
      *                    | ROUTE_HEADSET)
-     * 
+     *
      * setRouting sets the routes for a mode. This is called at startup. It is
-     * also called when a new device is connected, such as a wired headset is 
-     * plugged in or a Bluetooth headset is paired
+     * also called when a new device is connected, such as a wired headset is
+     * plugged in or a Bluetooth headset is paired.
      */
-    virtual status_t    setRouting(int mode, uint32_t routes);
-    
-    virtual status_t    getRouting(int mode, uint32_t* routes);
-    
+    virtual status_t    setRouting(int mode, uint32_t routes) = 0;
+
+    virtual status_t    getRouting(int mode, uint32_t* routes) = 0;
+
     /**
      * setMode is called when the audio mode changes. NORMAL mode is for
-     * standard audio playback, RINGTONE when a ringtone is playing and IN_CALL
+     * standard audio playback, RINGTONE when a ringtone is playing, and IN_CALL
      * when a call is in progress.
      */
-    virtual status_t    setMode(int mode);
-    virtual status_t    getMode(int* mode);
+    virtual status_t    setMode(int mode) = 0;
+    virtual status_t    getMode(int* mode) = 0;
 
     // mic mute
     virtual status_t    setMicMute(bool state) = 0;
@@ -171,38 +193,41 @@
 
     // Temporary interface, do not use
     // TODO: Replace with a more generic key:value get/set mechanism
-    virtual status_t    setParameter(const char* key, const char* value);
+    virtual status_t    setParameter(const char* key, const char* value) = 0;
 
+    // Returns audio input buffer size according to parameters passed or 0 if one of the
+    // parameters is not supported
+    virtual size_t    getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0;
+    
     /** This method creates and opens the audio hardware output stream */
     virtual AudioStreamOut* openOutputStream(
                                 int format=0,
                                 int channelCount=0,
-                                uint32_t sampleRate=0) = 0;
+                                uint32_t sampleRate=0,
+                                status_t *status=0) = 0;
 
     /** This method creates and opens the audio hardware input stream */
     virtual AudioStreamIn* openInputStream(
                                 int format,
                                 int channelCount,
-                                uint32_t sampleRate) = 0;
-    
+                                uint32_t sampleRate,
+                                status_t *status) = 0;
+
     /**This method dumps the state of the audio hardware */
-    virtual status_t dumpState(int fd, const Vector<String16>& args);
+    virtual status_t dumpState(int fd, const Vector<String16>& args) = 0;
 
     static AudioHardwareInterface* create();
 
 protected:
     /**
-     * doRouting actually initiates the routing to occur. A call to setRouting 
-     * or setMode may result in a routing change. The generic logic will call 
+     * doRouting actually initiates the routing. A call to setRouting
+     * or setMode may result in a routing change. The generic logic calls
      * doRouting when required. If the device has any special requirements these
      * methods can be overriden.
      */
     virtual status_t    doRouting() = 0;
-    
-    virtual status_t dump(int fd, const Vector<String16>& args) = 0;
 
-    int             mMode;
-    uint32_t        mRoutes[AudioSystem::NUM_MODES];
+    virtual status_t dump(int fd, const Vector<String16>& args) = 0;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/include/hardware/copybit.h b/include/hardware/copybit.h
new file mode 100644
index 0000000..3c873e0
--- /dev/null
+++ b/include/hardware/copybit.h
@@ -0,0 +1,216 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_COPYBIT_INTERFACE_H
+#define ANDROID_COPYBIT_INTERFACE_H
+
+#include <hardware/hardware.h>
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+/**
+ * The id of this module
+ */
+#define COPYBIT_HARDWARE_MODULE_ID "copybit"
+
+/**
+ * Name of the graphics device to open
+ */
+#define COPYBIT_HARDWARE_COPYBIT0 "copybit0"
+
+/* supported pixel-formats. these must be compatible with
+ * graphics/PixelFormat.java, ui/PixelFormat.h, pixelflinger/format.h
+ */
+enum {
+    COPYBIT_FORMAT_RGBA_8888    = 1,
+    COPYBIT_FORMAT_RGB_565      = 4,
+    COPYBIT_FORMAT_BGRA_8888    = 5,
+    COPYBIT_FORMAT_RGBA_5551    = 6,
+    COPYBIT_FORMAT_RGBA_4444    = 7,
+    COPYBIT_FORMAT_YCbCr_422_SP = 0x10,
+    COPYBIT_FORMAT_YCbCr_420_SP = 0x11
+};
+
+/* name for copybit_set_parameter */
+enum {
+    /* rotation of the source image in degrees (0 to 359) */
+    COPYBIT_ROTATION_DEG    = 1,
+    /* plane alpha value */
+    COPYBIT_PLANE_ALPHA     = 2,
+    /* enable or disable dithering */
+    COPYBIT_DITHER          = 3,
+    /* transformation applied (this is a superset of COPYBIT_ROTATION_DEG) */
+    COPYBIT_TRANSFORM       = 4,
+};
+
+/* values for copybit_set_parameter(COPYBIT_TRANSFORM) */
+enum {
+    /* flip source image horizontally */
+    COPYBIT_TRANSFORM_FLIP_H    = 0x01,
+    /* flip source image vertically */
+    COPYBIT_TRANSFORM_FLIP_V    = 0x02,
+    /* rotate source image 90 degres */
+    COPYBIT_TRANSFORM_ROT_90    = 0x04,
+    /* rotate source image 180 degres */
+    COPYBIT_TRANSFORM_ROT_180   = 0x03,
+    /* rotate source image 270 degres */
+    COPYBIT_TRANSFORM_ROT_270   = 0x07,
+};
+
+/* enable/disable value copybit_set_parameter */
+enum {
+    COPYBIT_DISABLE = 0,
+    COPYBIT_ENABLE  = 1
+};
+
+/* use get_static_info() to query static informations about the hardware */
+enum {
+    /* Maximum amount of minification supported by the hardware*/
+    COPYBIT_MINIFICATION_LIMIT  = 1,
+    /* Maximum amount of magnification supported by the hardware */
+    COPYBIT_MAGNIFICATION_LIMIT = 2,
+    /* Number of fractional bits support by the scaling engine */
+    COPYBIT_SCALING_FRAC_BITS   = 3,
+    /* Supported rotation step in degres. */
+    COPYBIT_ROTATION_STEP_DEG   = 4,
+};
+
+/* Image structure */
+struct copybit_image_t {
+    /* width */
+    uint32_t    w;
+    /* height */
+    uint32_t    h;
+    /* format COPYBIT_FORMAT_xxx */
+    int32_t     format;
+    /* offset from base to first pixel */
+    uint32_t    offset;
+    /* base of buffer with image */
+    void       *base;
+    /* file descriptor for image */
+    int         fd;
+};
+
+/* Rectangle */
+struct copybit_rect_t {
+    /* left */
+    int l;
+    /* top */
+    int t;
+    /* right */
+    int r;
+    /* bottom */
+    int b;
+};
+
+/* Region */
+struct copybit_region_t {
+    int (*next)(struct copybit_region_t const *region, struct copybit_rect_t *rect);
+};
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+struct copybit_module_t {
+    struct hw_module_t common;
+};
+
+/**
+ * Every device data structure must begin with hw_device_t
+ * followed by module specific public methods and attributes.
+ */
+struct copybit_device_t {
+    struct hw_device_t common;
+
+    /**
+     * Set a copybit parameter.
+     *
+     * @param dev from open
+     * @param name one for the COPYBIT_NAME_xxx
+     * @param value one of the COPYBIT_VALUE_xxx
+     *
+     * @return 0 if successful
+     */
+    int (*set_parameter)(struct copybit_device_t *dev, int name, int value);
+
+    /**
+     * Get a static copybit information.
+     *
+     * @param dev from open
+     * @param name one of the COPYBIT_STATIC_xxx
+     *
+     * @return value or -EINVAL if error
+     */
+    int (*get)(struct copybit_device_t *dev, int name);
+
+    /**
+     * Execute the bit blit copy operation
+     *
+     * @param dev from open
+     * @param dst is the destination image
+     * @param src is the source image
+     * @param region the clip region
+     *
+     * @return 0 if successful
+     */
+    int (*blit)(struct copybit_device_t *dev,
+                struct copybit_image_t const *dst,
+                struct copybit_image_t const *src,
+                struct copybit_region_t const *region);
+
+    /**
+     * Execute the stretch bit blit copy operation
+     *
+     * @param dev from open
+     * @param dst is the destination image
+     * @param src is the source image
+     * @param dst_rect is the destination rectangle
+     * @param src_rect is the source rectangle
+     * @param region the clip region
+     *
+     * @return 0 if successful
+     */
+    int (*stretch)(struct copybit_device_t *dev,
+                   struct copybit_image_t const *dst,
+                   struct copybit_image_t const *src,
+                   struct copybit_rect_t const *dst_rect,
+                   struct copybit_rect_t const *src_rect,
+                   struct copybit_region_t const *region);
+};
+
+
+/** convenience API for opening and closing a device */
+
+static inline int copybit_open(const struct hw_module_t* module, 
+        struct copybit_device_t** device) {
+    return module->methods->open(module, 
+            COPYBIT_HARDWARE_COPYBIT0, (struct hw_device_t**)device);
+}
+
+static inline int copybit_close(struct copybit_device_t* device) {
+    return device->common.close(&device->common);
+}
+
+
+__END_DECLS
+
+#endif  // ANDROID_COPYBIT_INTERFACE_H
diff --git a/include/hardware/gps.h b/include/hardware/gps.h
index 54b50a5..5f8740f 100644
--- a/include/hardware/gps.h
+++ b/include/hardware/gps.h
@@ -23,36 +23,58 @@
 extern "C" {
 #endif
 
-/** milliseconds since January 1, 1970 */
+/** Milliseconds since January 1, 1970 */
 typedef int64_t GpsUtcTime;
 
-/** maximum number of Space Vehicles for gps_sv_status_callback */
+/** Maximum number of SVs for gps_sv_status_callback(). */
 #define GPS_MAX_SVS 32
 
-
+/** Requested mode for GPS operation. */
 typedef uint16_t GpsPositionMode;
+// IMPORTANT: Note that the following values must match
+// constants in GpsLocationProvider.java.
+/** Mode for running GPS standalone (no assistance). */
 #define GPS_POSITION_MODE_STANDALONE    0
+/** SUPL MS-Based mode. */
 #define GPS_POSITION_MODE_MS_BASED      1
+/** SUPL MS-Assisted mode. */
 #define GPS_POSITION_MODE_MS_ASSISTED   2
 
+/** GPS status event values. */
 typedef uint16_t GpsStatusValue;
-// IMPORTANT - these symbols here must match constants in GpsLocationProvider.java
+// IMPORTANT: Note that the following values must match
+// constants in GpsLocationProvider.java.
+/** GPS status unknown. */
 #define GPS_STATUS_NONE             0
+/** GPS has begun navigating. */
 #define GPS_STATUS_SESSION_BEGIN    1
+/** GPS has stopped navigating. */
 #define GPS_STATUS_SESSION_END      2
+/** GPS has powered on but is not navigating. */
 #define GPS_STATUS_ENGINE_ON        3
+/** GPS is powered off. */
 #define GPS_STATUS_ENGINE_OFF       4
 
+/** Flags to indicate which values are valid in a GpsLocation. */
 typedef uint16_t GpsLocationFlags;
-// IMPORTANT - these symbols here must match constants in GpsLocationProvider.java
+// IMPORTANT: Note that the following values must match
+// constants in GpsLocationProvider.java.
+/** GpsLocation has valid latitude and longitude. */
 #define GPS_LOCATION_HAS_LAT_LONG   0x0001
+/** GpsLocation has valid altitude. */
 #define GPS_LOCATION_HAS_ALTITUDE   0x0002
+/** GpsLocation has valid speed. */
 #define GPS_LOCATION_HAS_SPEED      0x0004
+/** GpsLocation has valid bearing. */
 #define GPS_LOCATION_HAS_BEARING    0x0008
+/** GpsLocation has valid accuracy. */
 #define GPS_LOCATION_HAS_ACCURACY   0x0010
 
+/** Flags used to specify which aiding data to delete
+    when calling delete_aiding_data(). */
 typedef uint16_t GpsAidingData;
-// IMPORTANT - these symbols here must match constants in GpsLocationProvider.java
+// IMPORTANT: Note that the following values must match
+// constants in GpsLocationProvider.java.
 #define GPS_DELETE_EPHEMERIS        0x0001
 #define GPS_DELETE_ALMANAC          0x0002
 #define GPS_DELETE_POSITION         0x0004
@@ -68,73 +90,88 @@
 #define GPS_DELETE_ALL              0xFFFF
 
 /**
- * names for GPS XTRA interface
+ * Name for the GPS XTRA interface.
  */
 #define GPS_XTRA_INTERFACE      "gps-xtra"
 
 /**
- * names for GPS supplemental interface
- * TODO: Remove not used.
+ * Name for the GPS SUPL interface.
  */
 #define GPS_SUPL_INTERFACE      "gps-supl"
 
-/** The location */
+/** Represents a location. */
 typedef struct {
-    /** contains GpsLocationFlags bits */
+    /** Contains GpsLocationFlags bits. */
     uint16_t        flags;
+    /** Represents latitude in degrees. */
     double          latitude;
+    /** Represents longitude in degrees. */
     double          longitude;
+    /** Represents altitude in meters above the WGS 84 reference
+     * ellipsoid. */
     double          altitude;
+    /** Represents speed in meters per second. */
     float           speed;
+    /** Represents heading in degrees. */
     float           bearing;
+    /** Represents expected accuracy in meters. */
     float           accuracy;
+    /** Timestamp for the location fix. */
     GpsUtcTime      timestamp;
 } GpsLocation;
 
-/** The status */
+/** Represents the status. */
 typedef struct {
     GpsStatusValue status;
 } GpsStatus;
 
-/** Space Vehicle info */
+/** Represents SV information. */
 typedef struct {
+    /** Pseudo-random number for the SV. */
     int     prn;
+    /** Signal to noise ratio. */
     float   snr;
+    /** Elevation of SV in degrees. */
     float   elevation;
+    /** Azimuth of SV in degrees. */
     float   azimuth;
 } GpsSvInfo;
 
-/** Space Vehicle status */
+/** Represents SV status. */
 typedef struct {
-        /** number of SVs currently visible */
+        /** Number of SVs currently visible. */
         int         num_svs;
 
-        /** Array of space vehicle info */
+        /** Contains an array of SV information. */
         GpsSvInfo   sv_list[GPS_MAX_SVS];
 
-        /** bit mask indicating which SVs have ephemeris data */
+        /** Represents a bit mask indicating which SVs
+         * have ephemeris data.
+         */
         uint32_t    ephemeris_mask;
 
-        /** bit mask indicating which SVs have almanac data */
+        /** Represents a bit mask indicating which SVs
+         * have almanac data.
+         */
         uint32_t    almanac_mask;
 
         /**
-         * bit mask indicating which SVs were used for
-         * computing the most recent position fix
+         * Represents a bit mask indicating which SVs
+         * were used for computing the most recent position fix.
          */
         uint32_t    used_in_fix_mask;
 } GpsSvStatus;
 
-/** Callback with location information */
+/** Callback with location information. */
 typedef void (* gps_location_callback)(GpsLocation* location);
 
-/** Callback with the status information */
+/** Callback with status information. */
 typedef void (* gps_status_callback)(GpsStatus* status);
 
-/** Callback with the space vehicle status information */
+/** Callback with SV status information. */
 typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
 
-/** GPS call back structure */
+/** GPS callback structure. */
 typedef struct {
         gps_location_callback location_cb;
         gps_status_callback status_cb;
@@ -142,40 +179,40 @@
 } GpsCallbacks;
 
 
-/** Standard GPS interface */
+/** Represents the standard GPS interface. */
 typedef struct {
     /**
-     * Open the interface and provide the callback routines
+     * Opens the interface and provides the callback routines
      * to the implemenation of this interface.
      */
     int   (*init)( GpsCallbacks* callbacks );
 
-    /** Start navigating */
+    /** Starts navigating. */
     int   (*start)( void );
 
-    /** Stop navigating */
+    /** Stops navigating. */
     int   (*stop)( void );
 
-    /** Set requested frequency of fixes in seconds */
+    /** Sets requested frequency of fixes in seconds. */
     void  (*set_fix_frequency)( int frequency );
 
-    /** Close the interface */
+    /** Closes the interface. */
     void  (*cleanup)( void );
 
-    /** Inject the current time */
+    /** Injects the current time. */
     int   (*inject_time)(GpsUtcTime time, int64_t timeReference,
                          int uncertainty);
 
     /**
-     * The next call to start will not use the information
-     * defined in the flags. GPS_DELETE_ALL  is passed for
+     * Specifies that the next call to start will not use the
+     * information defined in the flags. GPS_DELETE_ALL is passed for
      * a cold start.
      */
     void  (*delete_aiding_data)(GpsAidingData flags);
 
     /**
-     * fix_frequency is time between fixes in seconds.
-     * set fix_frequency to zero for a single shot fix.
+     * fix_frequency represents the time between fixes in seconds.
+     * Set fix_frequency to zero for a single-shot fix.
      */
     int   (*set_position_mode)(GpsPositionMode mode, int fix_frequency);
 
@@ -183,31 +220,37 @@
     const void* (*get_extension)(const char* name);
 } GpsInterface;
 
-/** The download request callback routine. */
+/** Callback to request the client to download XTRA data.
+    The client should download XTRA data and inject it by calling
+     inject_xtra_data(). */
 typedef void (* gps_xtra_download_request)();
 
-/** The download request callback structure. */
+/** Callback structure for the XTRA interface. */
 typedef struct {
         gps_xtra_download_request download_request_cb;
 } GpsXtraCallbacks;
 
 /** Extended interface for XTRA support. */
 typedef struct {
+    /**
+     * Opens the XTRA interface and provides the callback routines
+     * to the implemenation of this interface.
+     */
     int  (*init)( GpsXtraCallbacks* callbacks );
+    /** Injects XTRA data into the GPS. */
     int  (*inject_xtra_data)( char* data, int length );
 } GpsXtraInterface;
 
-/** returns the hardware GPS interface. */
+/** Returns the hardware GPS interface. */
 const GpsInterface* gps_get_hardware_interface();
 
 /**
- * returns the qemu hardware interface GPS interface.
+ * Returns the qemu emulated GPS interface.
  */
 const GpsInterface* gps_get_qemu_interface();
 
 /**
- * returns the default GPS interface,
- * implemented in lib/hardware/gps.cpp.
+ * Returns the default GPS interface.
  */
 const GpsInterface* gps_get_interface();
 
diff --git a/include/hardware/hardware.h b/include/hardware/hardware.h
new file mode 100644
index 0000000..65ce8d0
--- /dev/null
+++ b/include/hardware/hardware.h
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H
+#define ANDROID_INCLUDE_HARDWARE_HARDWARE_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/*
+ * Value for the hw_module_t.tag field
+ */
+#define HARDWARE_MODULE_TAG 'HWMT'
+#define HARDWARE_DEVICE_TAG 'HWDT'
+
+struct hw_module_t;
+struct hw_module_methods_t;
+struct hw_device_t;
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+struct hw_module_t {
+    /** tag must be initialized to HARDWARE_MODULE_TAG */
+    uint32_t tag;
+
+    /** major version number for the module */
+    uint16_t version_major;
+
+    /** minor version number of the module */
+    uint16_t version_minor;
+
+    /** Identifier of module */
+    const char *id;
+
+    /** Name of this module */
+    const char *name;
+
+    /** Author/owner/implementor of the module */
+    const char *author;
+
+    /** Modules methods */
+    struct hw_module_methods_t* methods;
+    
+    /** padding to 128 bytes, reserved for future use */
+    uint32_t reserved[32-6];
+};
+
+struct hw_module_methods_t {
+    /** Open a specific device */
+    int (*open)(const struct hw_module_t* module, const char* id,
+            struct hw_device_t** device);
+};
+
+/**
+ * Every device data structure must begin with hw_device_t
+ * followed by module specific public methods and attributes.
+ */
+struct hw_device_t {
+    /** tag must be initialized to HARDWARE_DEVICE_TAG */
+    uint32_t tag;
+
+    /** version number for hw_device_t */
+    uint32_t version;
+
+    /** reference to the module this device belongs to */
+    struct hw_module_t* module;
+
+    /** padding reserved for future use */
+    uint32_t reserved[12];
+
+    /** Close this device */
+    int (*close)(struct hw_device_t* device);
+};
+
+/**
+ * Name of the hal_module_info 
+ */
+#define HAL_MODULE_INFO_SYM         HMI
+
+/**
+ * Name of the hal_module_info as a string
+ */
+#define HAL_MODULE_INFO_SYM_AS_STR  "HMI"
+
+/**
+ * Get the module info associated with a module by id.
+ * @return: 0 == success, <0 == error and *pHmi == NULL
+ */
+int hw_get_module(const char *id, const struct hw_module_t **module);
+
+__END_DECLS
+
+#endif  /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */
diff --git a/include/hardware/led.h b/include/hardware/led.h
index d7b2363..b5acb73 100644
--- a/include/hardware/led.h
+++ b/include/hardware/led.h
@@ -22,15 +22,16 @@
 #endif
 
 /**
- * Change the state of the led
+ * Changes the state of the LED.
  *
- * To turn on the led; Alpha != 0 and RBG != 0, onMS == 0 && offMS == 0.
- * To blink the led; Alpha != 0 and RBG != 0, onMS != 0 && offMS != 0.
- * To turn off the led; Alpha == 0 or RGB == 0.
+ *   -# Turn on LED: Alpha != 0 and RBG != 0, onMS == 0 && offMS == 0.
+ *   -# Blink LED: Alpha != 0 and RBG != 0, onMS != 0 && offMS != 0.
+ *   -# Turn off LED: Alpha == 0 or RGB == 0.
  *
- * @param colorARGB the is color, Alpha=31:24, Red=23:16 Green=15:8 Blue=7:0
- * @param onMS is the time on in milli-seconds
- * @param offMS is the time off in milli-seconds
+ * @param colorARGB represents the LED's color: Alpha=31:24, Red=23:16
+ * Green=15:8 Blue=7:0
+ * @param onMS represents the time the LED is on in milliseconds
+ * @param offMS represents the time the LED is off in milliseconds
  *
  * @return 0 if successful
  */
diff --git a/include/hardware/overlay.h b/include/hardware/overlay.h
new file mode 100644
index 0000000..b798c56
--- /dev/null
+++ b/include/hardware/overlay.h
@@ -0,0 +1,204 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_OVERLAY_INTERFACE_H
+#define ANDROID_OVERLAY_INTERFACE_H
+
+#include <hardware/hardware.h>
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+/**
+ * The id of this module
+ */
+#define OVERLAY_HARDWARE_MODULE_ID "overlay"
+
+/**
+ * Name of the overlay device to open
+ */
+#define OVERLAY_HARDWARE_OVERLAY0 "overlay0"
+
+/*****************************************************************************/
+
+/* possible overlay formats */
+enum {
+    OVERLAY_FORMAT_RGBA_8888    = 1,
+    OVERLAY_FORMAT_RGB_565      = 4,
+    OVERLAY_FORMAT_BGRA_8888    = 5,
+    OVERLAY_FORMAT_YCbCr_422_SP = 0x10,
+    OVERLAY_FORMAT_YCbCr_420_SP = 0x11,
+    OVERLAY_FORMAT_YCbCr_422_P = 0x14,
+    OVERLAY_FORMAT_YCbCr_420_P = 0x15
+};
+
+/* values for rotation */
+enum {
+    /* flip source image horizontally */
+    OVERLAY_TRANSFORM_FLIP_H    = 0x01,
+    /* flip source image vertically */
+    OVERLAY_TRANSFORM_FLIP_V    = 0x02,
+    /* rotate source image 90 degrees */
+    OVERLAY_TRANSFORM_ROT_90    = 0x04,
+    /* rotate source image 180 degrees */
+    OVERLAY_TRANSFORM_ROT_180   = 0x03,
+    /* rotate source image 270 degrees */
+    OVERLAY_TRANSFORM_ROT_270   = 0x07,
+};
+
+/* names for setParameter() */
+enum {
+    OVERLAY_ROTATION_DEG  = 1,
+    OVERLAY_DITHER        = 3,
+};
+
+/* enable/disable value setParameter() */
+enum {
+    OVERLAY_DISABLE = 0,
+    OVERLAY_ENABLE  = 1
+};
+
+/* names for get() */
+enum {
+    /* Maximum amount of minification supported by the hardware*/
+    OVERLAY_MINIFICATION_LIMIT      = 1,
+    /* Maximum amount of magnification supported by the hardware */
+    OVERLAY_MAGNIFICATION_LIMIT     = 2,
+    /* Number of fractional bits support by the overlay scaling engine */
+    OVERLAY_SCALING_FRAC_BITS       = 3,
+    /* Supported rotation step in degrees. */
+    OVERLAY_ROTATION_STEP_DEG       = 4,
+    /* horizontal alignment in pixels */
+    OVERLAY_HORIZONTAL_ALIGNMENT    = 5,
+    /* vertical alignment in pixels */
+    OVERLAY_VERTICAL_ALIGNMENT      = 6,
+    /* width alignment restrictions. negative number for max. power-of-two */
+    OVERLAY_WIDTH_ALIGNMENT         = 7,
+    /* height alignment restrictions. negative number for max. power-of-two */
+    OVERLAY_HEIGHT_ALIGNMENT        = 8,
+};
+
+/*****************************************************************************/
+
+/* opaque reference to an Overlay kernel object */
+typedef struct {
+    int numFds;
+    int fds[4];
+    int numInts;
+    int data[0];
+} overlay_handle_t;
+
+typedef struct overlay_t {
+    uint32_t            w;
+    uint32_t            h;
+    int32_t             format;
+    uint32_t            w_stride;
+    uint32_t            h_stride;
+    uint32_t            reserved[3];
+    /* returns a reference to this overlay's handle (the caller doesn't
+     * take ownership) */
+    overlay_handle_t const* (*getHandleRef)(struct overlay_t* overlay);
+    uint32_t            reserved_procs[7];
+} overlay_t;
+
+/*****************************************************************************/
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+struct overlay_module_t {
+    struct hw_module_t common;
+};
+
+/*****************************************************************************/
+
+/**
+ * Every device data structure must begin with hw_device_t
+ * followed by module specific public methods and attributes.
+ */
+struct overlay_device_t {
+    struct hw_device_t common;
+    
+    /* get static informations about the capabilities of the overlay engine */
+    int (*get)(struct overlay_device_t *dev, int name);
+
+    /* creates an overlay matching the given parameters as closely as possible.
+     * returns an error if no more overlays are available. The actual
+     * size and format is returned in overlay_t. */
+    overlay_t* (*createOverlay)(struct overlay_device_t *dev,
+            uint32_t w, uint32_t h, int32_t format);
+    
+    /* destroys an overlay. This call releases all
+     * resources associated with overlay_t and make it invalid */
+    void (*destroyOverlay)(struct overlay_device_t *dev,
+            overlay_t* overlay);
+
+    /* set position and scaling of the given overlay as closely as possible.
+     * if scaling cannot be performed, overlay must be centered. */
+    int (*setPosition)(struct overlay_device_t *dev,
+            overlay_t* overlay, 
+            int x, int y, uint32_t w, uint32_t h);
+
+    /* returns the actual position and size of the overlay */
+    int (*getPosition)(struct overlay_device_t *dev,
+            overlay_t* overlay, 
+            int* x, int* y, uint32_t* w, uint32_t* h);
+
+    /* sets configurable parameters for this overlay. returns an error if not
+     * supported. */
+    int (*setParameter)(struct overlay_device_t *dev,
+            overlay_t* overlay, int param, int value);
+    
+    /* swaps overlay buffers for double-buffered overlay. the actual swap is
+     * synchronized with VSYNC. Typically, this function blocks until a new
+     * buffer is available. */
+    int (*swapBuffers)(struct overlay_device_t *dev,
+            overlay_t* overlay);
+    
+    /* returns the offset in bytes of the current available buffer. When this 
+     * function returns, the buffer is ready to be used immediately. Typically,
+     * this function blocks until a buffer is available. */
+    int (*getOffset)(struct overlay_device_t *dev,
+            overlay_t* overlay);
+    
+    /* returns a filedescriptor that can be used to mmap() the overlay's
+     * memory. If this feature is not supported, an error is returned. */
+    int (*getMemory)(struct overlay_device_t *dev);
+};
+
+/*****************************************************************************/
+
+/** convenience API for opening and closing a device */
+
+static inline int overlay_open(const struct hw_module_t* module, 
+        struct overlay_device_t** device) {
+    return module->methods->open(module, 
+            OVERLAY_HARDWARE_OVERLAY0, (struct hw_device_t**)device);
+}
+
+static inline int overlay_close(struct overlay_device_t* device) {
+    return device->common.close(&device->common);
+}
+
+
+__END_DECLS
+
+#endif  // ANDROID_OVERLAY_INTERFACE_H
diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h
index 19fd72c..a7ab7ad 100644
--- a/include/hardware/sensors.h
+++ b/include/hardware/sensors.h
@@ -14,29 +14,47 @@
  * limitations under the License.
  */
 
-#ifndef _HARDWARE_SENSORS_H
-#define _HARDWARE_SENSORS_H
+#ifndef ANDROID_SENSORS_INTERFACE_H
+#define ANDROID_SENSORS_INTERFACE_H
 
 #include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
 
-#if __cplusplus
-extern "C" {
-#endif
+#include <hardware/hardware.h>
+
+__BEGIN_DECLS
 
 /**
- * Sensor IDs must be a power of two and
- * must match values in SensorManager.java
+ * The id of this module
  */
+#define SENSORS_HARDWARE_MODULE_ID "sensors"
 
-#define SENSORS_ORIENTATION     0x00000001
-#define SENSORS_ACCELERATION    0x00000002
-#define SENSORS_TEMPERATURE     0x00000004
-#define SENSORS_MAGNETIC_FIELD  0x00000008
-#define SENSORS_LIGHT           0x00000010
-#define SENSORS_PROXIMITY       0x00000020
-#define SENSORS_TRICORDER       0x00000040
-#define SENSORS_ORIENTATION_RAW 0x00000080
-#define SENSORS_MASK            0x000000FF
+/**
+ * Name of the sensors device to open
+ */
+#define SENSORS_HARDWARE_CONTROL    "control"
+#define SENSORS_HARDWARE_DATA       "data"
+
+/**
+ * Handles must be higher than SENSORS_HANDLE_BASE
+ */
+#define SENSORS_HANDLE_BASE             0
+#define SENSORS_HANDLE_BITS             8
+#define SENSORS_HANDLE_COUNT            (1<<SENSORS_HANDLE_BITS)
+
+
+/**
+ * Sensor types
+ */
+#define SENSOR_TYPE_ACCELEROMETER       1
+#define SENSOR_TYPE_MAGNETIC_FIELD      2
+#define SENSOR_TYPE_ORIENTATION         3
+#define SENSOR_TYPE_GYROSCOPE           4
+#define SENSOR_TYPE_LIGHT               5
+#define SENSOR_TYPE_PRESSURE            6
+#define SENSOR_TYPE_TEMPERATURE         7
+#define SENSOR_TYPE_PROXIMITY           8
 
 /**
  * Values returned by the accelerometer in various locations in the universe.
@@ -52,7 +70,7 @@
 #define GRAVITY_JUPITER         (23.12f)
 #define GRAVITY_SATURN          (8.96f)
 #define GRAVITY_URANUS          (8.69f)
-#define GRAVITY_NEPTUN          (11.0f)
+#define GRAVITY_NEPTUNE         (11.0f)
 #define GRAVITY_PLUTO           (0.6f)
 #define GRAVITY_DEATH_STAR_I    (0.000000353036145f)
 #define GRAVITY_THE_ISLAND      (4.815162342f)
@@ -63,23 +81,6 @@
 /** Minimum magnetic field on Earth's surface */
 #define MAGNETIC_FIELD_EARTH_MIN    (30.0f)
 
-/**
- * Various luminance values during the day (lux)
- */
-
-#define LIGHT_SUNLIGHT_MAX      (120000.0f)
-#define LIGHT_SUNLIGHT          (110000.0f)
-#define LIGHT_SHADE             (20000.0f)
-#define LIGHT_OVERCAST          (10000.0f)
-#define LIGHT_SUNRISE           (400.0f)
-#define LIGHT_CLOUDY            (100.0f)
-
-/*
- * Various luminance values during the night (lux)
- */
-
-#define LIGHT_FULLMOON          (0.25f)
-#define LIGHT_NO_MOON           (0.001f)
 
 /**
  * status of each sensor
@@ -92,6 +93,7 @@
 
 /**
  * Definition of the axis
+ * ----------------------
  *
  * This API is relative to the screen of the device in its default orientation,
  * that is, if the device can be used in portrait or landscape, this API
@@ -99,23 +101,75 @@
  * the axis are not swapped when the device's screen orientation changes.
  * Higher level services /may/ perform this transformation.
  *
- *    -x         +x
+ *   x<0         x>0
  *                ^
  *                |
- *    +-----------+-->  +y
+ *    +-----------+-->  y>0
  *    |           |
  *    |           |
  *    |           |
- *    |           |   / -z
+ *    |           |   / z<0
  *    |           |  /
  *    |           | /
- *    +-----------+/
- *    | o   O   o /
- *    +----------/+     -y
+ *    O-----------+/
+ *    |[]  [ ]  []/
+ *    +----------/+     y<0
  *              /
  *             /
- *           |/ +z
+ *           |/ z>0 (toward the sky)
  *
+ *    O: Origin (x=0,y=0,z=0)
+ *
+ *
+ * Orientation
+ * ----------- 
+ * 
+ * All values are angles in degrees.
+ * 
+ * azimuth: angle between the magnetic north direction and the Y axis, around 
+ *  the Z axis (0<=azimuth<360).
+ *      0=North, 90=East, 180=South, 270=West
+ * 
+ * pitch: Rotation around X axis (-180<=pitch<=180), with positive values when
+ *  the z-axis moves toward the y-axis.
+ *
+ * roll: Rotation around Y axis (-90<=roll<=90), with positive values when
+ *  the z-axis moves AWAY from the x-axis.
+ * 
+ * Note: This definition is different from yaw, pitch and roll used in aviation
+ *  where the X axis is along the long side of the plane (tail to nose).
+ *  
+ *  
+ * Acceleration
+ * ------------
+ *
+ *  All values are in SI units (m/s^2) and measure the acceleration of the
+ *  device minus the force of gravity.
+ *  
+ *  x: Acceleration minus Gx on the x-axis 
+ *  y: Acceleration minus Gy on the y-axis 
+ *  z: Acceleration minus Gz on the z-axis
+ *  
+ *  Examples:
+ *    When the device lies flat on a table and is pushed on its left side
+ *    toward the right, the x acceleration value is positive.
+ *    
+ *    When the device lies flat on a table, the acceleration value is +9.81,
+ *    which correspond to the acceleration of the device (0 m/s^2) minus the
+ *    force of gravity (-9.81 m/s^2).
+ *    
+ *    When the device lies flat on a table and is pushed toward the sky, the
+ *    acceleration value is greater than +9.81, which correspond to the
+ *    acceleration of the device (+A m/s^2) minus the force of 
+ *    gravity (-9.81 m/s^2).
+ *    
+ *    
+ * Magnetic Field
+ * --------------
+ * 
+ *  All values are in micro-Tesla (uT) and measure the ambient magnetic
+ *  field in the X, Y and Z axis.
+ *    
  */
 typedef struct {
     union {
@@ -126,7 +180,7 @@
             float z;
         };
         struct {
-            float yaw;
+            float azimuth;
             float pitch;
             float roll;
         };
@@ -147,7 +201,7 @@
         /* x,y,z values of the given sensor */
         sensors_vec_t   vector;
 
-        /* orientation values are in degres */
+        /* orientation values are in degrees */
         sensors_vec_t   orientation;
 
         /* acceleration values are in meter per second per second (m/s^2) */
@@ -156,7 +210,7 @@
         /* magnetic vector values are in micro-Tesla (uT) */
         sensors_vec_t   magnetic;
 
-        /* temperature is in degres C */
+        /* temperature is in degrees centigrade (Celsius) */
         float           temperature;
     };
 
@@ -166,78 +220,138 @@
     uint32_t        reserved;
 } sensors_data_t;
 
-/**
- * Initialize the module. This is the first entry point
- * called and typically initializes the hardware.
- *
- * @return bit map of available sensors defined by
- *         the constants SENSORS_XXXX.
- */
-uint32_t sensors_control_init();
+
+struct sensor_t;
 
 /**
- * Returns the fd which will be the parameter to
- * sensors_data_open. The caller takes ownership
- * of this fd.
- *
- * @return a fd if successful, < 0 on error
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
  */
-int sensors_control_open();
+struct sensors_module_t {
+    struct hw_module_t common;
 
-/** Activate/deactiveate one or more of the sensors.
- *
- * @param sensors is a bitmask of the sensors to change.
- * @param mask is a bitmask for enabling/disabling sensors.
- *
- * @return bitmask of SENSORS_XXXX indicating which sensors are enabled
- */
-uint32_t sensors_control_activate(uint32_t sensors, uint32_t mask);
+    /**
+     * @return bit map of available sensors defined by
+     *         the constants SENSORS_XXXX.
+     */
+    int (*get_sensors_list)(struct sensors_module_t* module,
+            struct sensor_t const**);
+};
+
+struct sensor_t {
+    const char*     name;
+    const char*     vendor;
+    int             version;
+    int             handle;
+    int             type;
+    float           maxRange;
+    float           resolution;
+    float           power;
+    void*           reserved[9];
+};
+
 
 /**
- * Set the delay between sensor events in ms
- *
- * @return 0 if successful, < 0 on error
+ * Every device data structure must begin with hw_device_t
+ * followed by module specific public methods and attributes.
  */
-int sensors_control_delay(int32_t ms);
+struct sensors_control_device_t {
+    struct hw_device_t common;
+    
+    /**
+     * Returns the fd which will be the parameter to
+     * sensors_data_device_t::open_data(). 
+     * The caller takes ownership of this fd. This is intended to be
+     * passed cross processes.
+     *
+     * @return a fd if successful, < 0 on error
+     */
+    int (*open_data_source)(struct sensors_control_device_t *dev);
+    
+    /** Activate/deactivate one or more of the sensors.
+     *
+     * @param sensors is the handle of the sensors 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);
 
-/**
- * Prepare to read sensor data.
- *
- * This routiune does NOT take ownership of the fd
- * and must not close it. Typcially this routine would
- * use a duplicate of the fd parameter.
- *
- * @param fd from sensors_control_open.
- *
- * @return 0 if successful, < 0 on error
- */
-int sensors_data_open(int fd);
+    /**
+     * Causes sensors_data_device_t.poll() to return -EWOULDBLOCK immediately.
+     */
+    int (*wake)(struct sensors_control_device_t *dev);
+};
 
-/**
- * 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 sensors_data_close();
+struct sensors_data_device_t {
+    struct hw_device_t common;
 
-/**
- * Return sensor data for one of the enabled sensors.
- *
- * @return SENSOR_XXXX for the returned data, -1 on error
- * */
-int sensors_data_poll(sensors_data_t* data, uint32_t sensors_of_interest);
-
-/**
- * @return bit map of available sensors defined by
- *         the constants SENSORS_XXXX.
- */
-uint32_t sensors_data_get_sensors();
+    /**
+     * Prepare to read sensor data.
+     *
+     * This routine does NOT take ownership of the fd
+     * and must not close it. Typically this routine would
+     * use a duplicate of the fd parameter.
+     *
+     * @param fd from sensors_control_open.
+     *
+     * @return 0 if successful, < 0 on error
+     */
+    int (*data_open)(struct sensors_data_device_t *dev, int fd);
+    
+    /**
+     * 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);
+};
 
 
-#if __cplusplus
-}  // extern "C"
-#endif
+/** convenience API for opening and closing a device */
 
-#endif  // _HARDWARE_SENSORS_H
+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
+
+#endif  // ANDROID_SENSORS_INTERFACE_H
diff --git a/include/hardware/wifi.h b/include/hardware/wifi.h
index 0b1acdc..23cc92a 100644
--- a/include/hardware/wifi.h
+++ b/include/hardware/wifi.h
@@ -22,14 +22,14 @@
 #endif
 
 /**
- * Load the wifi driver.
+ * Load the Wi-Fi driver.
  *
  * @return 0 on success, < 0 on failure.
  */
 int wifi_load_driver();
 
 /**
- * Unload the wifi driver.
+ * Unload the Wi-Fi driver.
  *
  * @return 0 on success, < 0 on failure.
  */
@@ -64,59 +64,76 @@
 void wifi_close_supplicant_connection();
 
 /**
- * Do a blocking call to get a wifi event and
- * return a string representing a wifi event
- * when it occurs.
+ * wifi_wait_for_event() performs a blocking call to 
+ * get a Wi-Fi event and returns a string representing 
+ * a Wi-Fi event when it occurs.
  *
  * @param buf is the buffer that receives the event
  * @param len is the maximum length of the buffer
  *
  * @returns number of bytes in buffer, 0 if no
- * event, for instance no connection, < 0 if an
- * error.
+ * event (for instance, no connection), and less than 0
+ * if there is an error.
  */
 int wifi_wait_for_event(char *buf, size_t len);
 
 /**
- * Issue a command to the wifi driver.
+ * wifi_command() issues a command to the Wi-Fi driver.
  *
- * see \link http://hostap.epitest.fi/wpa_supplicant/devel/ctrl_iface_page.html
- * for the list of the standard commands. Android has extended these to include
- * support for sending commands to the driver:
+ * Android extends the standard commands listed at 
+ * /link http://hostap.epitest.fi/wpa_supplicant/devel/ctrl_iface_page.html 
+ * to include support for sending commands to the driver:
  *
- *------------------------------------------------------------------------------
- *   command                 form of response                processing
- *      Summary of the command
- *------------------------------------------------------------------------------
- * "DRIVER START"        -> "OK" if successful            -> "OK" ? true : false
- *      Turn on WiFi Hardware
- *
- * "DRIVER STOP"         -> "OK" if successful            -> "OK" ? true : false
- *      Turn off WiFi Hardware
- *
- * "DRIVER RSSI"         -> "<ssid> Rssi xx"              -> "%*s %*s %d", &rssi
- *      Return received signal strength indicator in -db for current AP
- *
- * "DRIVER LINKSPEED"    -> "LinkSpeed xx"                -> "%*s %d", &linkspd
- *      Return link speed in MBPS
- *
- * "DRIVER MACADDR"      -> "Macaddr = xx.xx.xx.xx.xx.xx" -> "%*s = %s", &macadr
- *      Return mac address of the station
- *
- * "DRIVER SCAN-ACTIVE"  -> "OK" if successful            -> "OK" ? true : false
- *      Set scan type to active
- *
- * "DRIVER SCAN-PASSIVE" -> "OK" if successful            -> "OK" ? true : false
- *      Set scan type to passive
- *------------------------------------------------------------------------------
+ * <table border="2" cellspacing="2" cellpadding="2">
+ *   <tr>
+ *     <td><strong>Command / Command summary</strong></td>
+ *     <td><strong>Form of Response</strong></td>
+ *     <td><strong>Processing</strong></td>
+ *   </tr>
+ *   <tr>
+ *     <td>DRIVER START<BR>&nbsp;&nbsp;Turn on Wi-Fi Hardware</td>
+ *     <td>OK if successful</td>
+ *     <td>OK ? true : false</td>
+ *   </tr>
+ *   <tr>
+ *     <td>DRIVER STOP<BR>&nbsp;&nbsp;Turn off Wi-Fi hardware</td>
+ *     <td>OK if successful</td>
+ *     <td>OK ? true : false</td>
+ *   </tr>
+ *   <tr>
+ *     <td>DRIVER RSSI<BR>&nbsp;&nbsp;Return received signal strength indicator in -db for current AP</td>
+ *     <td>&lt;ssid&gt; Rssi xx</td>
+ *     <td>%*s %*s %d", &rssi</td>
+ *   </tr>
+ *   <tr>
+ *     <td>DRIVER LINKSPEED<BR>&nbsp;&nbsp;Return link speed in MBPS</td>
+ *     <td>LinkSpeed xx</td>
+ *     <td>%*s %d", &linkspd</td>
+ *   </tr>
+ *   <tr>
+ *     <td>DRIVER MACADDR<BR>&nbsp;&nbsp;Return mac address of the station</td>
+ *     <td>Macaddr = xx.xx.xx.xx.xx.xx</td>
+ *     <td>"%*s = %s", &macadr</td>
+ *   </tr>
+ *   <tr>
+ *     <td>DRIVER SCAN-ACTIVE<BR>&nbsp;&nbsp;Set scan type to active</td>
+ *     <td>"OK" if successful</td>
+ *     <td>"OK" ? true : false</td>
+ *   </tr>
+ *   <tr>
+ *     <td>DRIVER SCAN-PASSIVE<BR>&nbsp;&nbsp;Set scan type to passive</td>
+ *     <td>"OK" if successful</td>
+ *     <td>"OK" ? true : false</td>
+ *   </tr>
+ * </table>
  *
  * See libs/android_runtime/android_net_wifi_Wifi.cpp for more information
- * on how these and other commands invoked.
+ * describing how these and other commands are invoked.
  *
  * @param command is the string command
  * @param reply is a buffer to receive a reply string
- * @param reply_len on entry is the maximum length of
- *        reply buffer and on exit the number of
+ * @param reply_len on entry, this is the maximum length of
+ *        the reply buffer. On exit, the number of
  *        bytes in the reply buffer.
  *
  * @return 0 if successful, < 0 if an error.
@@ -124,16 +141,17 @@
 int wifi_command(const char *command, char *reply, size_t *reply_len);
 
 /**
- * Issues a dhcp request returning the acquired
- * information. All IPV4 addresses/mask are in
- * network byte order.
+ * do_dhcp_request() issues a dhcp request and returns the acquired
+ * information. 
+ * 
+ * All IPV4 addresses/mask are in network byte order.
  *
  * @param ipaddr return the assigned IPV4 address
  * @param gateway return the gateway being used
  * @param mask return the IPV4 mask
- * @param dns1 return the IPV4 address of a dns server
- * @param dns2 return the IPV4 address of a dns server
- * @param serverAddress return the IPV4 address of dhcp server
+ * @param dns1 return the IPV4 address of a DNS server
+ * @param dns2 return the IPV4 address of a DNS server
+ * @param server return the IPV4 address of DHCP server
  * @param lease return the length of lease in seconds.
  *
  * @return 0 if successful, < 0 if error.
@@ -142,7 +160,7 @@
                    int *dns1, int *dns2, int *server, int *lease);
 
 /**
- * Return the error string of the last do_dhcp_request.
+ * Return the error string of the last do_dhcp_request().
  */
 const char *get_dhcp_error_string();