[Android] [PATCH 1/4] Add missing hardware headers for gingerbread

Jean-Baptiste Kempf jb at videolan.org
Fri Jul 25 00:59:48 CEST 2014


LGTM.

On 25 Jul, Martin Storsjö wrote :
> From: Thomas Guillem <guillem at archos.com>
> 
> This allows building most of the iomx hwbuffer code for gingerbread
> as well, even though it's not hooked up completely yet.
> ---
>  .../libhardware/include/hardware/copybit.h         | 219 +++++++
>  .../hardware/libhardware/include/hardware/gps.h    | 666 +++++++++++++++++++++
>  .../libhardware/include/hardware/gralloc.h         | 351 +++++++++++
>  .../libhardware/include/hardware/hardware.h        | 205 +++++++
>  .../hardware/libhardware/include/hardware/lights.h | 137 +++++
>  .../libhardware/include/hardware/overlay.h         | 243 ++++++++
>  .../hardware/libhardware/include/hardware/qemud.h  | 144 +++++
>  .../libhardware/include/hardware/sensors.h         | 448 ++++++++++++++
>  .../include/hardware/sensors_deprecated.h          |  75 +++
>  9 files changed, 2488 insertions(+)
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/copybit.h
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/gps.h
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/gralloc.h
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/hardware.h
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/lights.h
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/overlay.h
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/qemud.h
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/sensors.h
>  create mode 100644 android-headers-gingerbread/hardware/libhardware/include/hardware/sensors_deprecated.h
> 
> diff --git a/android-headers-gingerbread/hardware/libhardware/include/hardware/copybit.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/copybit.h
> new file mode 100644
> index 0000000..b6302c3
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/include/hardware/copybit.h
> @@ -0,0 +1,219 @@
> +/*
> + * 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    = HAL_PIXEL_FORMAT_RGBA_8888,
> +    COPYBIT_FORMAT_RGBX_8888    = HAL_PIXEL_FORMAT_RGBX_8888,
> +    COPYBIT_FORMAT_RGB_888      = HAL_PIXEL_FORMAT_RGB_888,
> +    COPYBIT_FORMAT_RGB_565      = HAL_PIXEL_FORMAT_RGB_565,
> +    COPYBIT_FORMAT_BGRA_8888    = HAL_PIXEL_FORMAT_BGRA_8888,
> +    COPYBIT_FORMAT_RGBA_5551    = HAL_PIXEL_FORMAT_RGBA_5551,
> +    COPYBIT_FORMAT_RGBA_4444    = HAL_PIXEL_FORMAT_RGBA_4444,
> +    COPYBIT_FORMAT_YCbCr_422_SP = 0x10,
> +    COPYBIT_FORMAT_YCrCb_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,
> +    /* blurs the copied bitmap. The amount of blurring cannot be changed 
> +     * at this time. */
> +    COPYBIT_BLUR            = 5
> +};
> +
> +/* values for copybit_set_parameter(COPYBIT_TRANSFORM) */
> +enum {
> +    /* flip source image horizontally */
> +    COPYBIT_TRANSFORM_FLIP_H    = HAL_TRANSFORM_FLIP_H,
> +    /* flip source image vertically */
> +    COPYBIT_TRANSFORM_FLIP_V    = HAL_TRANSFORM_FLIP_V,
> +    /* rotate source image 90 degres */
> +    COPYBIT_TRANSFORM_ROT_90    = HAL_TRANSFORM_ROT_90,
> +    /* rotate source image 180 degres */
> +    COPYBIT_TRANSFORM_ROT_180   = HAL_TRANSFORM_ROT_180,
> +    /* rotate source image 270 degres */
> +    COPYBIT_TRANSFORM_ROT_270   = HAL_TRANSFORM_ROT_270,
> +};
> +
> +/* 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;
> +    /* base of buffer with image */
> +    void        *base;
> +    /* handle to the image */
> +    native_handle_t* handle;
> +};
> +
> +/* 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/android-headers-gingerbread/hardware/libhardware/include/hardware/gps.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/gps.h
> new file mode 100644
> index 0000000..235c72d
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/include/hardware/gps.h
> @@ -0,0 +1,666 @@
> +/*
> + * Copyright (C) 2010 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_GPS_H
> +#define ANDROID_INCLUDE_HARDWARE_GPS_H
> +
> +#include <stdint.h>
> +#include <sys/cdefs.h>
> +#include <sys/types.h>
> +#include <pthread.h>
> +
> +#include <hardware/hardware.h>
> +
> +__BEGIN_DECLS
> +
> +/**
> + * The id of this module
> + */
> +#define GPS_HARDWARE_MODULE_ID "gps"
> +
> +
> +/** Milliseconds since January 1, 1970 */
> +typedef int64_t GpsUtcTime;
> +
> +/** Maximum number of SVs for gps_sv_status_callback(). */
> +#define GPS_MAX_SVS 32
> +
> +/** Requested operational mode for GPS operation. */
> +typedef uint32_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
> +/** AGPS MS-Based mode. */
> +#define GPS_POSITION_MODE_MS_BASED      1
> +/** AGPS MS-Assisted mode. */
> +#define GPS_POSITION_MODE_MS_ASSISTED   2
> +
> +/** Requested recurrence mode for GPS operation. */
> +typedef uint32_t GpsPositionRecurrence;
> +// IMPORTANT: Note that the following values must match
> +// constants in GpsLocationProvider.java.
> +/** Receive GPS fixes on a recurring basis at a specified period. */
> +#define GPS_POSITION_RECURRENCE_PERIODIC    0
> +/** Request a single shot GPS fix. */
> +#define GPS_POSITION_RECURRENCE_SINGLE      1
> +
> +/** GPS status event values. */
> +typedef uint16_t GpsStatusValue;
> +// 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: 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 for the gps_set_capabilities callback. */
> +
> +/** GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode.
> +    If this is not set, then the framework will use 1000ms for min_interval
> +    and will start and call start() and stop() to schedule the GPS.
> + */
> +#define GPS_CAPABILITY_SCHEDULING       0x0000001
> +/** GPS supports MS-Based AGPS mode */
> +#define GPS_CAPABILITY_MSB              0x0000002
> +/** GPS supports MS-Assisted AGPS mode */
> +#define GPS_CAPABILITY_MSA              0x0000004
> +/** GPS supports single-shot fixes */
> +#define GPS_CAPABILITY_SINGLE_SHOT      0x0000008
> +
> +/** Flags used to specify which aiding data to delete
> +    when calling delete_aiding_data(). */
> +typedef uint16_t GpsAidingData;
> +// 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
> +#define GPS_DELETE_TIME             0x0008
> +#define GPS_DELETE_IONO             0x0010
> +#define GPS_DELETE_UTC              0x0020
> +#define GPS_DELETE_HEALTH           0x0040
> +#define GPS_DELETE_SVDIR            0x0080
> +#define GPS_DELETE_SVSTEER          0x0100
> +#define GPS_DELETE_SADATA           0x0200
> +#define GPS_DELETE_RTI              0x0400
> +#define GPS_DELETE_CELLDB_INFO      0x8000
> +#define GPS_DELETE_ALL              0xFFFF
> +
> +/** AGPS type */
> +typedef uint16_t AGpsType;
> +#define AGPS_TYPE_SUPL          1
> +#define AGPS_TYPE_C2K           2
> +
> +typedef uint16_t AGpsSetIDType;
> +#define AGPS_SETID_TYPE_NONE    0
> +#define AGPS_SETID_TYPE_IMSI    1
> +#define AGPS_SETID_TYPE_MSISDN  2
> +
> +/**
> + * String length constants
> + */
> +#define GPS_NI_SHORT_STRING_MAXLEN      256
> +#define GPS_NI_LONG_STRING_MAXLEN       2048
> +
> +/**
> + * GpsNiType constants
> + */
> +typedef uint32_t GpsNiType;
> +#define GPS_NI_TYPE_VOICE              1
> +#define GPS_NI_TYPE_UMTS_SUPL          2
> +#define GPS_NI_TYPE_UMTS_CTRL_PLANE    3
> +
> +/**
> + * GpsNiNotifyFlags constants
> + */
> +typedef uint32_t GpsNiNotifyFlags;
> +/** NI requires notification */
> +#define GPS_NI_NEED_NOTIFY          0x0001
> +/** NI requires verification */
> +#define GPS_NI_NEED_VERIFY          0x0002
> +/** NI requires privacy override, no notification/minimal trace */
> +#define GPS_NI_PRIVACY_OVERRIDE     0x0004
> +
> +/**
> + * GPS NI responses, used to define the response in
> + * NI structures
> + */
> +typedef int GpsUserResponseType;
> +#define GPS_NI_RESPONSE_ACCEPT         1
> +#define GPS_NI_RESPONSE_DENY           2
> +#define GPS_NI_RESPONSE_NORESP         3
> +
> +/**
> + * NI data encoding scheme
> + */
> +typedef int GpsNiEncodingType;
> +#define GPS_ENC_NONE                   0
> +#define GPS_ENC_SUPL_GSM_DEFAULT       1
> +#define GPS_ENC_SUPL_UTF8              2
> +#define GPS_ENC_SUPL_UCS2              3
> +#define GPS_ENC_UNKNOWN                -1
> +
> +/** AGPS status event values. */
> +typedef uint16_t AGpsStatusValue;
> +/** GPS requests data connection for AGPS. */
> +#define GPS_REQUEST_AGPS_DATA_CONN  1
> +/** GPS releases the AGPS data connection. */
> +#define GPS_RELEASE_AGPS_DATA_CONN  2
> +/** AGPS data connection initiated */
> +#define GPS_AGPS_DATA_CONNECTED     3
> +/** AGPS data connection completed */
> +#define GPS_AGPS_DATA_CONN_DONE     4
> +/** AGPS data connection failed */
> +#define GPS_AGPS_DATA_CONN_FAILED   5
> +
> +#define AGPS_REF_LOCATION_TYPE_GSM_CELLID   1
> +#define AGPS_REF_LOCATION_TYPE_UMTS_CELLID  2
> +#define AGPS_REG_LOCATION_TYPE_MAC          3
> +
> +/** Network types for update_network_state "type" parameter */
> +#define AGPS_RIL_NETWORK_TYPE_MOBILE        0
> +#define AGPS_RIL_NETWORK_TYPE_WIFI          1
> +#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS    2
> +#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL   3
> +#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN   4
> +#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5
> +#define AGPS_RIL_NETWORK_TTYPE_WIMAX        6
> +
> +/**
> + * Name for the GPS XTRA interface.
> + */
> +#define GPS_XTRA_INTERFACE      "gps-xtra"
> +
> +/**
> + * Name for the GPS DEBUG interface.
> + */
> +#define GPS_DEBUG_INTERFACE      "gps-debug"
> +
> +/**
> + * Name for the AGPS interface.
> + */
> +#define AGPS_INTERFACE      "agps"
> +
> +/**
> + * Name for NI interface
> + */
> +#define GPS_NI_INTERFACE "gps-ni"
> +
> +/**
> + * Name for the AGPS-RIL interface.
> + */
> +#define AGPS_RIL_INTERFACE      "agps_ril"
> +
> +/** Represents a location. */
> +typedef struct {
> +    /** set to sizeof(GpsLocation) */
> +    size_t          size;
> +    /** 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;
> +
> +/** Represents the status. */
> +typedef struct {
> +    /** set to sizeof(GpsStatus) */
> +    size_t          size;
> +    GpsStatusValue status;
> +} GpsStatus;
> +
> +/** Represents SV information. */
> +typedef struct {
> +    /** set to sizeof(GpsSvInfo) */
> +    size_t          size;
> +    /** 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;
> +
> +/** Represents SV status. */
> +typedef struct {
> +    /** set to sizeof(GpsSvStatus) */
> +    size_t          size;
> +
> +    /** Number of SVs currently visible. */
> +    int         num_svs;
> +
> +    /** Contains an array of SV information. */
> +    GpsSvInfo   sv_list[GPS_MAX_SVS];
> +
> +    /** Represents a bit mask indicating which SVs
> +     * have ephemeris data.
> +     */
> +    uint32_t    ephemeris_mask;
> +
> +    /** Represents a bit mask indicating which SVs
> +     * have almanac data.
> +     */
> +    uint32_t    almanac_mask;
> +
> +    /**
> +     * Represents a bit mask indicating which SVs
> +     * were used for computing the most recent position fix.
> +     */
> +    uint32_t    used_in_fix_mask;
> +} GpsSvStatus;
> +
> +/* 2G and 3G */
> +/* In 3G lac is discarded */
> +typedef struct {
> +    uint16_t type;
> +    uint16_t mcc;
> +    uint16_t mnc;
> +    uint16_t lac;
> +    uint32_t cid;
> +} AGpsRefLocationCellID;
> +
> +typedef struct {
> +    uint8_t mac[6];
> +} AGpsRefLocationMac;
> +
> +/** Represents ref locations */
> +typedef struct {
> +    uint16_t type;
> +    union {
> +        AGpsRefLocationCellID   cellID;
> +        AGpsRefLocationMac      mac;
> +    } u;
> +} AGpsRefLocation;
> +
> +/** Callback with location information.
> + *  Can only be called from a thread created by create_thread_cb.
> + */
> +typedef void (* gps_location_callback)(GpsLocation* location);
> +
> +/** Callback with status information.
> + *  Can only be called from a thread created by create_thread_cb.
> + */
> +typedef void (* gps_status_callback)(GpsStatus* status);
> +
> +/** Callback with SV status information.
> + *  Can only be called from a thread created by create_thread_cb.
> + */
> +typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
> +
> +/** Callback for reporting NMEA sentences.
> + *  Can only be called from a thread created by create_thread_cb.
> + */
> +typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);
> +
> +/** Callback to inform framework of the GPS engine's capabilities.
> + *  Capability parameter is a bit field of GPS_CAPABILITY_* flags.
> + */
> +typedef void (* gps_set_capabilities)(uint32_t capabilities);
> +
> +/** Callback utility for acquiring the GPS wakelock.
> + *  This can be used to prevent the CPU from suspending while handling GPS events.
> + */
> +typedef void (* gps_acquire_wakelock)();
> +
> +/** Callback utility for releasing the GPS wakelock. */
> +typedef void (* gps_release_wakelock)();
> +
> +/** Callback for creating a thread that can call into the Java framework code.
> + *  This must be used to create any threads that report events up to the framework.
> + */
> +typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg);
> +
> +/** GPS callback structure. */
> +typedef struct {
> +    /** set to sizeof(GpsCallbacks) */
> +    size_t      size;
> +    gps_location_callback location_cb;
> +    gps_status_callback status_cb;
> +    gps_sv_status_callback sv_status_cb;
> +    gps_nmea_callback nmea_cb;
> +    gps_set_capabilities set_capabilities_cb;
> +    gps_acquire_wakelock acquire_wakelock_cb;
> +    gps_release_wakelock release_wakelock_cb;
> +    gps_create_thread create_thread_cb;
> +} GpsCallbacks;
> +
> +
> +/** Represents the standard GPS interface. */
> +typedef struct {
> +    /** set to sizeof(GpsInterface) */
> +    size_t          size;
> +    /**
> +     * Opens the interface and provides the callback routines
> +     * to the implemenation of this interface.
> +     */
> +    int   (*init)( GpsCallbacks* callbacks );
> +
> +    /** Starts navigating. */
> +    int   (*start)( void );
> +
> +    /** Stops navigating. */
> +    int   (*stop)( void );
> +
> +    /** Closes the interface. */
> +    void  (*cleanup)( void );
> +
> +    /** Injects the current time. */
> +    int   (*inject_time)(GpsUtcTime time, int64_t timeReference,
> +                         int uncertainty);
> +
> +    /** Injects current location from another location provider
> +     *  (typically cell ID).
> +     *  latitude and longitude are measured in degrees
> +     *  expected accuracy is measured in meters
> +     */
> +    int  (*inject_location)(double latitude, double longitude, float accuracy);
> +
> +    /**
> +     * 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);
> +
> +    /**
> +     * min_interval represents the time between fixes in milliseconds.
> +     * preferred_accuracy represents the requested fix accuracy in meters.
> +     * preferred_time represents the requested time to first fix in milliseconds.
> +     */
> +    int   (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence,
> +            uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
> +
> +    /** Get a pointer to extension information. */
> +    const void* (*get_extension)(const char* name);
> +} GpsInterface;
> +
> +/** Callback to request the client to download XTRA data.
> + *  The client should download XTRA data and inject it by calling inject_xtra_data().
> + *  Can only be called from a thread created by create_thread_cb.
> + */
> +typedef void (* gps_xtra_download_request)();
> +
> +/** Callback structure for the XTRA interface. */
> +typedef struct {
> +    gps_xtra_download_request download_request_cb;
> +    gps_create_thread create_thread_cb;
> +} GpsXtraCallbacks;
> +
> +/** Extended interface for XTRA support. */
> +typedef struct {
> +    /** set to sizeof(GpsXtraInterface) */
> +    size_t          size;
> +    /**
> +     * 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;
> +
> +/** Extended interface for DEBUG support. */
> +typedef struct {
> +    /** set to sizeof(GpsDebugInterface) */
> +    size_t          size;
> +
> +    /**
> +     * This function should return any information that the native
> +     * implementation wishes to include in a bugreport.
> +     */
> +    size_t (*get_internal_state)(char* buffer, size_t bufferSize);
> +} GpsDebugInterface;
> +
> +/** Represents the status of AGPS. */
> +typedef struct {
> +    /** set to sizeof(AGpsStatus) */
> +    size_t          size;
> +
> +    AGpsType        type;
> +    AGpsStatusValue status;
> +} AGpsStatus;
> +
> +/** Callback with AGPS status information.
> + *  Can only be called from a thread created by create_thread_cb.
> + */
> +typedef void (* agps_status_callback)(AGpsStatus* status);
> +
> +/** Callback structure for the AGPS interface. */
> +typedef struct {
> +    agps_status_callback status_cb;
> +    gps_create_thread create_thread_cb;
> +} AGpsCallbacks;
> +
> +
> +/** Extended interface for AGPS support. */
> +typedef struct {
> +    /** set to sizeof(AGpsInterface) */
> +    size_t          size;
> +
> +    /**
> +     * Opens the AGPS interface and provides the callback routines
> +     * to the implemenation of this interface.
> +     */
> +    void  (*init)( AGpsCallbacks* callbacks );
> +    /**
> +     * Notifies that a data connection is available and sets 
> +     * the name of the APN to be used for SUPL.
> +     */
> +    int  (*data_conn_open)( const char* apn );
> +    /**
> +     * Notifies that the AGPS data connection has been closed.
> +     */
> +    int  (*data_conn_closed)();
> +    /**
> +     * Notifies that a data connection is not available for AGPS. 
> +     */
> +    int  (*data_conn_failed)();
> +    /**
> +     * Sets the hostname and port for the AGPS server.
> +     */
> +    int  (*set_server)( AGpsType type, const char* hostname, int port );
> +} AGpsInterface;
> +
> +
> +/** Represents an NI request */
> +typedef struct {
> +    /** set to sizeof(GpsNiNotification) */
> +    size_t          size;
> +
> +    /**
> +     * An ID generated by HAL to associate NI notifications and UI
> +     * responses
> +     */
> +    int             notification_id;
> +
> +    /**
> +     * An NI type used to distinguish different categories of NI
> +     * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ...
> +     */
> +    GpsNiType       ni_type;
> +
> +    /**
> +     * Notification/verification options, combinations of GpsNiNotifyFlags constants
> +     */
> +    GpsNiNotifyFlags notify_flags;
> +
> +    /**
> +     * Timeout period to wait for user response.
> +     * Set to 0 for no time out limit.
> +     */
> +    int             timeout;
> +
> +    /**
> +     * Default response when time out.
> +     */
> +    GpsUserResponseType default_response;
> +
> +    /**
> +     * Requestor ID
> +     */
> +    char            requestor_id[GPS_NI_SHORT_STRING_MAXLEN];
> +
> +    /**
> +     * Notification message. It can also be used to store client_id in some cases
> +     */
> +    char            text[GPS_NI_LONG_STRING_MAXLEN];
> +
> +    /**
> +     * Client name decoding scheme
> +     */
> +    GpsNiEncodingType requestor_id_encoding;
> +
> +    /**
> +     * Client name decoding scheme
> +     */
> +    GpsNiEncodingType text_encoding;
> +
> +    /**
> +     * A pointer to extra data. Format:
> +     * key_1 = value_1
> +     * key_2 = value_2
> +     */
> +    char           extras[GPS_NI_LONG_STRING_MAXLEN];
> +
> +} GpsNiNotification;
> +
> +/** Callback with NI notification.
> + *  Can only be called from a thread created by create_thread_cb.
> + */
> +typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification);
> +
> +/** GPS NI callback structure. */
> +typedef struct
> +{
> +    /**
> +     * Sends the notification request from HAL to GPSLocationProvider.
> +     */
> +    gps_ni_notify_callback notify_cb;
> +    gps_create_thread create_thread_cb;
> +} GpsNiCallbacks;
> +
> +/**
> + * Extended interface for Network-initiated (NI) support.
> + */
> +typedef struct
> +{
> +    /** set to sizeof(GpsNiInterface) */
> +    size_t          size;
> +
> +   /** Registers the callbacks for HAL to use. */
> +   void (*init) (GpsNiCallbacks *callbacks);
> +
> +   /** Sends a response to HAL. */
> +   void (*respond) (int notif_id, GpsUserResponseType user_response);
> +} GpsNiInterface;
> +
> +struct gps_device_t {
> +    struct hw_device_t common;
> +
> +    /**
> +     * Set the provided lights to the provided values.
> +     *
> +     * Returns: 0 on succes, error code on failure.
> +     */
> +    const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev);
> +};
> +
> +#define AGPS_RIL_REQUEST_SETID_IMSI     (1<<0L)
> +#define AGPS_RIL_REQUEST_SETID_MSISDN   (1<<1L)
> +
> +#define AGPS_RIL_REQUEST_REFLOC_CELLID  (1<<0L)
> +#define AGPS_RIL_REQUEST_REFLOC_MAC     (1<<1L)
> +
> +typedef void (*agps_ril_request_set_id)(uint32_t flags);
> +typedef void (*agps_ril_request_ref_loc)(uint32_t flags);
> +
> +typedef struct {
> +    agps_ril_request_set_id request_setid;
> +    agps_ril_request_ref_loc request_refloc;
> +    gps_create_thread create_thread_cb;
> +} AGpsRilCallbacks;
> +
> +/** Extended interface for AGPS_RIL support. */
> +typedef struct {
> +    /** set to sizeof(AGpsRilInterface) */
> +    size_t          size;
> +    /**
> +     * Opens the AGPS interface and provides the callback routines
> +     * to the implemenation of this interface.
> +     */
> +    void  (*init)( AGpsRilCallbacks* callbacks );
> +
> +    /**
> +     * Sets the reference location.
> +     */
> +    void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct);
> +    /**
> +     * Sets the set ID.
> +     */
> +    void (*set_set_id) (AGpsSetIDType type, const char* setid);
> +
> +    /**
> +     * Send network initiated message.
> +     */
> +    void (*ni_message) (uint8_t *msg, size_t len);
> +
> +    /**
> +     * Notify GPS of network status changes.
> +     * These parameters match values in the android.net.NetworkInfo class.
> +     */
> +    void (*update_network_state) (int connected, int type, int roaming, const char* extra_info);
> +} AGpsRilInterface;
> +
> +__END_DECLS
> +
> +#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */
> +
> diff --git a/android-headers-gingerbread/hardware/libhardware/include/hardware/gralloc.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/gralloc.h
> new file mode 100644
> index 0000000..73cc9e0
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/include/hardware/gralloc.h
> @@ -0,0 +1,351 @@
> +/*
> + * 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_GRALLOC_INTERFACE_H
> +#define ANDROID_GRALLOC_INTERFACE_H
> +
> +#include <cutils/native_handle.h>
> +
> +#include <hardware/hardware.h>
> +
> +#include <stdint.h>
> +#include <sys/cdefs.h>
> +#include <sys/types.h>
> +
> +__BEGIN_DECLS
> +
> +/**
> + * The id of this module
> + */
> +#define GRALLOC_HARDWARE_MODULE_ID "gralloc"
> +
> +/**
> + * Name of the graphics device to open
> + */
> +
> +#define GRALLOC_HARDWARE_FB0 "fb0"
> +#define GRALLOC_HARDWARE_GPU0 "gpu0"
> +
> +enum {
> +    /* buffer is never read in software */
> +    GRALLOC_USAGE_SW_READ_NEVER   = 0x00000000,
> +    /* buffer is rarely read in software */
> +    GRALLOC_USAGE_SW_READ_RARELY  = 0x00000002,
> +    /* buffer is often read in software */
> +    GRALLOC_USAGE_SW_READ_OFTEN   = 0x00000003,
> +    /* mask for the software read values */
> +    GRALLOC_USAGE_SW_READ_MASK    = 0x0000000F,
> +    
> +    /* buffer is never written in software */
> +    GRALLOC_USAGE_SW_WRITE_NEVER  = 0x00000000,
> +    /* buffer is never written in software */
> +    GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020,
> +    /* buffer is never written in software */
> +    GRALLOC_USAGE_SW_WRITE_OFTEN  = 0x00000030,
> +    /* mask for the software write values */
> +    GRALLOC_USAGE_SW_WRITE_MASK   = 0x000000F0,
> +
> +    /* buffer will be used as an OpenGL ES texture */
> +    GRALLOC_USAGE_HW_TEXTURE      = 0x00000100,
> +    /* buffer will be used as an OpenGL ES render target */
> +    GRALLOC_USAGE_HW_RENDER       = 0x00000200,
> +    /* buffer will be used by the 2D hardware blitter */
> +    GRALLOC_USAGE_HW_2D           = 0x00000400,
> +    /* buffer will be used with the framebuffer device */
> +    GRALLOC_USAGE_HW_FB           = 0x00001000,
> +    /* mask for the software usage bit-mask */
> +    GRALLOC_USAGE_HW_MASK         = 0x00001F00,
> +
> +    /* implementation-specific private usage flags */
> +    GRALLOC_USAGE_PRIVATE_0       = 0x10000000,
> +    GRALLOC_USAGE_PRIVATE_1       = 0x20000000,
> +    GRALLOC_USAGE_PRIVATE_2       = 0x40000000,
> +    GRALLOC_USAGE_PRIVATE_3       = 0x80000000,
> +    GRALLOC_USAGE_PRIVATE_MASK    = 0xF0000000,
> +};
> +
> +/*****************************************************************************/
> +
> +typedef const native_handle* buffer_handle_t;
> +
> +enum {
> +    /* FIXME: this only exists to work-around some issues with
> +     * the video and camera frameworks. don't implement unless
> +     * you know what you're doing.
> +     */
> +    GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER = 0x080000001,
> +};
> +
> +/**
> + * 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.
> + */
> +typedef struct gralloc_module_t {
> +    struct hw_module_t common;
> +    
> +    /*
> +     * (*registerBuffer)() must be called before a buffer_handle_t that has not
> +     * been created with (*alloc_device_t::alloc)() can be used.
> +     * 
> +     * This is intended to be used with buffer_handle_t's that have been
> +     * received in this process through IPC.
> +     * 
> +     * This function checks that the handle is indeed a valid one and prepares
> +     * it for use with (*lock)() and (*unlock)().
> +     * 
> +     * It is not necessary to call (*registerBuffer)() on a handle created 
> +     * with (*alloc_device_t::alloc)().
> +     * 
> +     * returns an error if this buffer_handle_t is not valid.
> +     */
> +    int (*registerBuffer)(struct gralloc_module_t const* module,
> +            buffer_handle_t handle);
> +
> +    /*
> +     * (*unregisterBuffer)() is called once this handle is no longer needed in
> +     * this process. After this call, it is an error to call (*lock)(),
> +     * (*unlock)(), or (*registerBuffer)().
> +     * 
> +     * This function doesn't close or free the handle itself; this is done
> +     * by other means, usually through libcutils's native_handle_close() and
> +     * native_handle_free(). 
> +     * 
> +     * It is an error to call (*unregisterBuffer)() on a buffer that wasn't
> +     * explicitly registered first.
> +     */
> +    int (*unregisterBuffer)(struct gralloc_module_t const* module,
> +            buffer_handle_t handle);
> +    
> +    /*
> +     * The (*lock)() method is called before a buffer is accessed for the 
> +     * specified usage. This call may block, for instance if the h/w needs
> +     * to finish rendering or if CPU caches need to be synchronized.
> +     * 
> +     * The caller promises to modify only pixels in the area specified 
> +     * by (l,t,w,h).
> +     * 
> +     * The content of the buffer outside of the specified area is NOT modified
> +     * by this call.
> +     *
> +     * If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address
> +     * of the buffer in virtual memory.
> +     *
> +     * THREADING CONSIDERATIONS:
> +     *
> +     * It is legal for several different threads to lock a buffer from 
> +     * read access, none of the threads are blocked.
> +     * 
> +     * However, locking a buffer simultaneously for write or read/write is
> +     * undefined, but:
> +     * - shall not result in termination of the process
> +     * - shall not block the caller
> +     * It is acceptable to return an error or to leave the buffer's content
> +     * into an indeterminate state.
> +     *
> +     * If the buffer was created with a usage mask incompatible with the
> +     * requested usage flags here, -EINVAL is returned. 
> +     * 
> +     */
> +    
> +    int (*lock)(struct gralloc_module_t const* module,
> +            buffer_handle_t handle, int usage,
> +            int l, int t, int w, int h,
> +            void** vaddr);
> +
> +    
> +    /*
> +     * The (*unlock)() method must be called after all changes to the buffer
> +     * are completed.
> +     */
> +    
> +    int (*unlock)(struct gralloc_module_t const* module,
> +            buffer_handle_t handle);
> +
> +
> +    /* reserved for future use */
> +    int (*perform)(struct gralloc_module_t const* module,
> +            int operation, ... );
> +
> +    /* reserved for future use */
> +    void* reserved_proc[7];
> +} gralloc_module_t;
> +
> +/*****************************************************************************/
> +
> +/**
> + * Every device data structure must begin with hw_device_t
> + * followed by module specific public methods and attributes.
> + */
> +
> +typedef struct alloc_device_t {
> +    struct hw_device_t common;
> +
> +    /* 
> +     * (*alloc)() Allocates a buffer in graphic memory with the requested
> +     * parameters and returns a buffer_handle_t and the stride in pixels to
> +     * allow the implementation to satisfy hardware constraints on the width
> +     * of a pixmap (eg: it may have to be multiple of 8 pixels). 
> +     * The CALLER TAKES OWNERSHIP of the buffer_handle_t.
> +     * 
> +     * Returns 0 on success or -errno on error.
> +     */
> +    
> +    int (*alloc)(struct alloc_device_t* dev,
> +            int w, int h, int format, int usage,
> +            buffer_handle_t* handle, int* stride);
> +
> +    /*
> +     * (*free)() Frees a previously allocated buffer. 
> +     * Behavior is undefined if the buffer is still mapped in any process,
> +     * but shall not result in termination of the program or security breaches
> +     * (allowing a process to get access to another process' buffers).
> +     * THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes
> +     * invalid after the call. 
> +     * 
> +     * Returns 0 on success or -errno on error.
> +     */
> +    int (*free)(struct alloc_device_t* dev,
> +            buffer_handle_t handle);
> +
> +} alloc_device_t;
> +
> +
> +typedef struct framebuffer_device_t {
> +    struct hw_device_t common;
> +
> +    /* flags describing some attributes of the framebuffer */
> +    const uint32_t  flags;
> +    
> +    /* dimensions of the framebuffer in pixels */
> +    const uint32_t  width;
> +    const uint32_t  height;
> +
> +    /* frambuffer stride in pixels */
> +    const int       stride;
> +    
> +    /* framebuffer pixel format */
> +    const int       format;
> +    
> +    /* resolution of the framebuffer's display panel in pixel per inch*/
> +    const float     xdpi;
> +    const float     ydpi;
> +
> +    /* framebuffer's display panel refresh rate in frames per second */
> +    const float     fps;
> +
> +    /* min swap interval supported by this framebuffer */
> +    const int       minSwapInterval;
> +
> +    /* max swap interval supported by this framebuffer */
> +    const int       maxSwapInterval;
> +
> +    int reserved[8];
> +    
> +    /* 
> +     * requests a specific swap-interval (same definition than EGL) 
> +     * 
> +     * Returns 0 on success or -errno on error.
> +     */
> +    int (*setSwapInterval)(struct framebuffer_device_t* window,
> +            int interval);
> +
> +    /*
> +     * This hook is OPTIONAL.
> +     * 
> +     * It is non NULL If the framebuffer driver supports "update-on-demand" 
> +     * and the given rectangle is the area of the screen that gets 
> +     * updated during (*post)().
> +     * 
> +     * This is useful on devices that are able to DMA only a portion of
> +     * the screen to the display panel, upon demand -- as opposed to
> +     * constantly refreshing the panel 60 times per second, for instance.
> +     * 
> +     * Only the area defined by this rectangle is guaranteed to be valid, that
> +     * is, the driver is not allowed to post anything outside of this
> +     * rectangle. 
> +     * 
> +     * The rectangle evaluated during (*post)() and specifies which area
> +     * of the buffer passed in (*post)() shall to be posted.
> +     * 
> +     * return -EINVAL if width or height <=0, or if left or top < 0 
> +     */
> +    int (*setUpdateRect)(struct framebuffer_device_t* window,
> +            int left, int top, int width, int height);
> +    
> +    /*
> +     * Post <buffer> to the display (display it on the screen)
> +     * The buffer must have been allocated with the 
> +     *   GRALLOC_USAGE_HW_FB usage flag.
> +     * buffer must be the same width and height as the display and must NOT
> +     * be locked.
> +     * 
> +     * The buffer is shown during the next VSYNC. 
> +     * 
> +     * If the same buffer is posted again (possibly after some other buffer),
> +     * post() will block until the the first post is completed.
> +     *
> +     * Internally, post() is expected to lock the buffer so that a 
> +     * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or
> +     * USAGE_*_WRITE will block until it is safe; that is typically once this
> +     * buffer is shown and another buffer has been posted.
> +     *
> +     * Returns 0 on success or -errno on error.
> +     */
> +    int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer);
> +
> +
> +    /*
> +     * The (*compositionComplete)() method must be called after the
> +     * compositor has finished issuing GL commands for client buffers.
> +     */
> +
> +    int (*compositionComplete)(struct framebuffer_device_t* dev);
> +
> +
> +    void* reserved_proc[8];
> +
> +} framebuffer_device_t;
> +
> +
> +/** convenience API for opening and closing a supported device */
> +
> +static inline int gralloc_open(const struct hw_module_t* module, 
> +        struct alloc_device_t** device) {
> +    return module->methods->open(module, 
> +            GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device);
> +}
> +
> +static inline int gralloc_close(struct alloc_device_t* device) {
> +    return device->common.close(&device->common);
> +}
> +
> +
> +static inline int framebuffer_open(const struct hw_module_t* module, 
> +        struct framebuffer_device_t** device) {
> +    return module->methods->open(module, 
> +            GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device);
> +}
> +
> +static inline int framebuffer_close(struct framebuffer_device_t* device) {
> +    return device->common.close(&device->common);
> +}
> +
> +
> +__END_DECLS
> +
> +#endif  // ANDROID_ALLOC_INTERFACE_H
> diff --git a/android-headers-gingerbread/hardware/libhardware/include/hardware/hardware.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/hardware.h
> new file mode 100644
> index 0000000..d9cc0dc
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/include/hardware/hardware.h
> @@ -0,0 +1,205 @@
> +/*
> + * 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>
> +
> +#include <cutils/native_handle.h>
> +
> +__BEGIN_DECLS
> +
> +/*
> + * Value for the hw_module_t.tag field
> + */
> +
> +#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
> +
> +#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T')
> +#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T')
> +
> +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.
> + */
> +typedef 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;
> +
> +    /** module's dso */
> +    void* dso;
> +
> +    /** padding to 128 bytes, reserved for future use */
> +    uint32_t reserved[32-7];
> +
> +} hw_module_t;
> +
> +typedef 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);
> +
> +} hw_module_methods_t;
> +
> +/**
> + * Every device data structure must begin with hw_device_t
> + * followed by module specific public methods and attributes.
> + */
> +typedef 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);
> +
> +} hw_device_t;
> +
> +/**
> + * 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);
> +
> +
> +/**
> + * pixel format definitions
> + */
> +
> +enum {
> +    HAL_PIXEL_FORMAT_RGBA_8888          = 1,
> +    HAL_PIXEL_FORMAT_RGBX_8888          = 2,
> +    HAL_PIXEL_FORMAT_RGB_888            = 3,
> +    HAL_PIXEL_FORMAT_RGB_565            = 4,
> +    HAL_PIXEL_FORMAT_BGRA_8888          = 5,
> +    HAL_PIXEL_FORMAT_RGBA_5551          = 6,
> +    HAL_PIXEL_FORMAT_RGBA_4444          = 7,
> +
> +    /* 0x8 - 0xFF range unavailable */
> +
> +    /*
> +     * 0x100 - 0x1FF
> +     *
> +     * This range is reserved for pixel formats that are specific to the HAL
> +     * implementation.  Implementations can use any value in this range to
> +     * communicate video pixel formats between their HAL modules.  These formats
> +     * must not have an alpha channel.  Additionally, an EGLimage created from a
> +     * gralloc buffer of one of these formats must be supported for use with the
> +     * GL_OES_EGL_image_external OpenGL ES extension.
> +     */
> +
> +    /*
> +     * Android YUV format:
> +     *
> +     * This format is exposed outside of the HAL to software
> +     * decoders and applications.
> +     * EGLImageKHR must support it in conjunction with the
> +     * OES_EGL_image_external extension.
> +     *
> +     * YV12 is 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
> +     * by (W/2) x (H/2) Cr and Cb planes.
> +     *
> +     * This format assumes
> +     * - an even width
> +     * - an even height
> +     * - a horizontal stride multiple of 16 pixels
> +     * - a vertical stride equal to the height
> +     *
> +     *   y_size = stride * height
> +     *   c_size = ALIGN(stride/2, 16) * height/2
> +     *   size = y_size + c_size * 2
> +     *   cr_offset = y_size
> +     *   cb_offset = y_size + c_size
> +     *
> +     */
> +    HAL_PIXEL_FORMAT_YV12   = 0x32315659, // YCrCb 4:2:0 Planar
> +
> +
> +
> +    /* Legacy formats (deprecated), used by ImageFormat.java */
> +    HAL_PIXEL_FORMAT_YCbCr_422_SP       = 0x10, // NV16
> +    HAL_PIXEL_FORMAT_YCrCb_420_SP       = 0x11, // NV21
> +    HAL_PIXEL_FORMAT_YCbCr_422_I        = 0x14, // YUY2
> +};
> +
> +
> +/**
> + * Transformation definitions
> + *
> + * IMPORTANT NOTE:
> + * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}.
> + *
> + */
> +
> +enum {
> +    /* flip source image horizontally (around the vertical axis) */
> +    HAL_TRANSFORM_FLIP_H    = 0x01,
> +    /* flip source image vertically (around the horizontal axis)*/
> +    HAL_TRANSFORM_FLIP_V    = 0x02,
> +    /* rotate source image 90 degrees clockwise */
> +    HAL_TRANSFORM_ROT_90    = 0x04,
> +    /* rotate source image 180 degrees */
> +    HAL_TRANSFORM_ROT_180   = 0x03,
> +    /* rotate source image 270 degrees clockwise */
> +    HAL_TRANSFORM_ROT_270   = 0x07,
> +};
> +
> +__END_DECLS
> +
> +#endif  /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */
> diff --git a/android-headers-gingerbread/hardware/libhardware/include/hardware/lights.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/lights.h
> new file mode 100644
> index 0000000..2cf5519
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/include/hardware/lights.h
> @@ -0,0 +1,137 @@
> +/*
> + * 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_LIGHTS_INTERFACE_H
> +#define ANDROID_LIGHTS_INTERFACE_H
> +
> +#include <stdint.h>
> +#include <sys/cdefs.h>
> +#include <sys/types.h>
> +
> +#include <hardware/hardware.h>
> +
> +__BEGIN_DECLS
> +
> +/**
> + * The id of this module
> + */
> +#define LIGHTS_HARDWARE_MODULE_ID "lights"
> +
> +/*
> + * These light IDs correspond to logical lights, not physical.
> + * So for example, if your INDICATOR light is in line with your
> + * BUTTONS, it might make sense to also light the INDICATOR
> + * light to a reasonable color when the BUTTONS are lit.
> + */
> +#define LIGHT_ID_BACKLIGHT          "backlight"
> +#define LIGHT_ID_KEYBOARD           "keyboard"
> +#define LIGHT_ID_BUTTONS            "buttons"
> +#define LIGHT_ID_BATTERY            "battery"
> +#define LIGHT_ID_NOTIFICATIONS      "notifications"
> +#define LIGHT_ID_ATTENTION          "attention"
> +
> +/*
> + * These lights aren't currently supported by the higher
> + * layers, but could be someday, so we have the constants
> + * here now.
> + */
> +#define LIGHT_ID_BLUETOOTH          "bluetooth"
> +#define LIGHT_ID_WIFI               "wifi"
> +
> +/* ************************************************************************
> + * Flash modes for the flashMode field of light_state_t.
> + */
> +
> +#define LIGHT_FLASH_NONE            0
> +
> +/**
> + * To flash the light at a given rate, set flashMode to LIGHT_FLASH_TIMED,
> + * and then flashOnMS should be set to the number of milliseconds to turn
> + * the light on, followed by the number of milliseconds to turn the light
> + * off.
> + */
> +#define LIGHT_FLASH_TIMED           1
> +
> +/**
> + * To flash the light using hardware assist, set flashMode to
> + * the hardware mode.
> + */
> +#define LIGHT_FLASH_HARDWARE        2
> +
> +/**
> + * Light brightness is managed by a user setting.
> + */
> +#define BRIGHTNESS_MODE_USER        0
> +
> +/**
> + * Light brightness is managed by a light sensor.
> + */
> +#define BRIGHTNESS_MODE_SENSOR      1
> +
> +/**
> + * The parameters that can be set for a given light.
> + *
> + * Not all lights must support all parameters.  If you
> + * can do something backward-compatible, you should.
> + */
> +struct light_state_t {
> +    /**
> +     * The color of the LED in ARGB.
> +     *
> +     * Do your best here.
> +     *   - If your light can only do red or green, if they ask for blue,
> +     *     you should do green.
> +     *   - If you can only do a brightness ramp, then use this formula:
> +     *      unsigned char brightness = ((77*((color>>16)&0x00ff))
> +     *              + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
> +     *   - If you can only do on or off, 0 is off, anything else is on.
> +     *
> +     * The high byte should be ignored.  Callers will set it to 0xff (which
> +     * would correspond to 255 alpha).
> +     */
> +    unsigned int color;
> +
> +    /**
> +     * See the LIGHT_FLASH_* constants
> +     */
> +    int flashMode;
> +    int flashOnMS;
> +    int flashOffMS;
> +
> +    /**
> +     * Policy used by the framework to manage the light's brightness.
> +     * Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR.
> +     */
> +    int brightnessMode;
> +};
> +
> +struct light_device_t {
> +    struct hw_device_t common;
> +
> +    /**
> +     * Set the provided lights to the provided values.
> +     *
> +     * Returns: 0 on succes, error code on failure.
> +     */
> +    int (*set_light)(struct light_device_t* dev,
> +            struct light_state_t const* state);
> +};
> +
> +
> +__END_DECLS
> +
> +#endif  // ANDROID_LIGHTS_INTERFACE_H
> +
> diff --git a/android-headers-gingerbread/hardware/libhardware/include/hardware/overlay.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/overlay.h
> new file mode 100644
> index 0000000..c56a974
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/include/hardware/overlay.h
> @@ -0,0 +1,243 @@
> +/*
> + * 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 <cutils/native_handle.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_CONTROL    "control"
> +#define OVERLAY_HARDWARE_DATA       "data"
> +
> +/*****************************************************************************/
> +
> +/* possible overlay formats */
> +enum {
> +    OVERLAY_FORMAT_RGBA_8888    = HAL_PIXEL_FORMAT_RGBA_8888,
> +    OVERLAY_FORMAT_RGB_565      = HAL_PIXEL_FORMAT_RGB_565,
> +    OVERLAY_FORMAT_BGRA_8888    = HAL_PIXEL_FORMAT_BGRA_8888,
> +    OVERLAY_FORMAT_YCbYCr_422_I = 0x14,
> +    OVERLAY_FORMAT_CbYCrY_422_I = 0x16,
> +    OVERLAY_FORMAT_DEFAULT      = 99    // The actual color format is determined
> +                                        // by the overlay
> +};
> +
> +/* values for copybit_set_parameter(OVERLAY_TRANSFORM) */
> +enum {
> +    /* flip source image horizontally */
> +    OVERLAY_TRANSFORM_FLIP_H    = HAL_TRANSFORM_FLIP_H,
> +    /* flip source image vertically */
> +    OVERLAY_TRANSFORM_FLIP_V    = HAL_TRANSFORM_FLIP_V,
> +    /* rotate source image 90 degrees */
> +    OVERLAY_TRANSFORM_ROT_90    = HAL_TRANSFORM_ROT_90,
> +    /* rotate source image 180 degrees */
> +    OVERLAY_TRANSFORM_ROT_180   = HAL_TRANSFORM_ROT_180,
> +    /* rotate source image 270 degrees */
> +    OVERLAY_TRANSFORM_ROT_270   = HAL_TRANSFORM_ROT_270
> +};
> +
> +/* names for setParameter() */
> +enum {
> +    /* rotation of the source image in degrees (0 to 359) */
> +    OVERLAY_ROTATION_DEG  = 1,
> +    /* enable or disable dithering */
> +    OVERLAY_DITHER        = 3,
> +    /* transformation applied (this is a superset of COPYBIT_ROTATION_DEG) */
> +    OVERLAY_TRANSFORM    = 4,
> +};
> +
> +/* 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 const native_handle* 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    (*getHandleRef)(struct overlay_t* overlay);
> +    uint32_t            reserved_procs[7];
> +} overlay_t;
> +
> +typedef void* overlay_buffer_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_control_device_t {
> +    struct hw_device_t common;
> +    
> +    /* get static informations about the capabilities of the overlay engine */
> +    int (*get)(struct overlay_control_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_control_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_control_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_control_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_control_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_control_device_t *dev,
> +            overlay_t* overlay, int param, int value);
> +
> +    int (*stage)(struct overlay_control_device_t *dev, overlay_t* overlay);
> +    int (*commit)(struct overlay_control_device_t *dev, overlay_t* overlay);
> +};
> +
> +
> +struct overlay_data_device_t {
> +    struct hw_device_t common;
> +
> +    /* initialize the overlay from the given handle. this associates this
> +     * overlay data module to its control module */
> +    int (*initialize)(struct overlay_data_device_t *dev,
> +            overlay_handle_t handle);
> +
> +    /* can be called to change the width and height of the overlay. */
> +    int (*resizeInput)(struct overlay_data_device_t *dev,
> +            uint32_t w, uint32_t h);
> +
> +    int (*setCrop)(struct overlay_data_device_t *dev,
> +            uint32_t x, uint32_t y, uint32_t w, uint32_t h) ;
> +
> +    int (*getCrop)(struct overlay_data_device_t *dev,
> +       uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) ;
> +
> +    int (*setParameter)(struct overlay_data_device_t *dev,
> +            int param, int value);
> +
> +    /* blocks until an overlay buffer is available and return that buffer. */
> +    int (*dequeueBuffer)(struct overlay_data_device_t *dev,
> +		         overlay_buffer_t *buf);
> +
> +    /* release the overlay buffer and post it */
> +    int (*queueBuffer)(struct overlay_data_device_t *dev,
> +            overlay_buffer_t buffer);
> +
> +    /* returns the address of a given buffer if supported, NULL otherwise. */
> +    void* (*getBufferAddress)(struct overlay_data_device_t *dev,
> +            overlay_buffer_t buffer);
> +
> +    int (*getBufferCount)(struct overlay_data_device_t *dev);
> +};
> +
> +
> +/*****************************************************************************/
> +
> +/** convenience API for opening and closing a device */
> +
> +static inline int overlay_control_open(const struct hw_module_t* module, 
> +        struct overlay_control_device_t** device) {
> +    return module->methods->open(module, 
> +            OVERLAY_HARDWARE_CONTROL, (struct hw_device_t**)device);
> +}
> +
> +static inline int overlay_control_close(struct overlay_control_device_t* device) {
> +    return device->common.close(&device->common);
> +}
> +
> +static inline int overlay_data_open(const struct hw_module_t* module, 
> +        struct overlay_data_device_t** device) {
> +    return module->methods->open(module, 
> +            OVERLAY_HARDWARE_DATA, (struct hw_device_t**)device);
> +}
> +
> +static inline int overlay_data_close(struct overlay_data_device_t* device) {
> +    return device->common.close(&device->common);
> +}
> +
> +__END_DECLS
> +
> +#endif  // ANDROID_OVERLAY_INTERFACE_H
> diff --git a/android-headers-gingerbread/hardware/libhardware/include/hardware/qemud.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/qemud.h
> new file mode 100644
> index 0000000..874a32f
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/include/hardware/qemud.h
> @@ -0,0 +1,144 @@
> +/*
> + * 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_QEMUD_H
> +#define ANDROID_INCLUDE_HARDWARE_QEMUD_H
> +
> +#include <cutils/sockets.h>
> +
> +/* the following is helper code that is used by the QEMU-specific
> + * hardware HAL modules to communicate with the emulator program
> + * through the 'qemud' multiplexing daemon.
> + *
> + * see the documentation comments for details in
> + * development/emulator/qemud/qemud.c
> + *
> + * all definitions here are built into the HAL module to avoid
> + * having to write a tiny shared library for this.
> + */
> +
> +/* we expect the D macro to be defined to a function macro
> + * that sends its formatted string argument(s) to the log.
> + * If not, ignore the traces.
> + */
> +#ifndef D
> +#  define  D(...)  ((void)0)
> +#endif
> +
> +static __inline__ int
> +qemud_fd_write(int  fd, const void*  buff, int  len)
> +{
> +    int  len2;
> +    do {
> +        len2 = write(fd, buff, len);
> +    } while (len2 < 0 && errno == EINTR);
> +    return len2;
> +}
> +
> +static __inline__ int
> +qemud_fd_read(int  fd, void*  buff, int  len)
> +{
> +    int  len2;
> +    do {
> +        len2 = read(fd, buff, len);
> +    } while (len2 < 0 && errno == EINTR);
> +    return len2;
> +}
> +
> +static __inline__ int
> +qemud_channel_open(const char*  name)
> +{
> +    int  fd;
> +    int  namelen = strlen(name);
> +    char answer[2];
> +
> +    /* connect to qemud control socket */
> +    fd = socket_local_client( "qemud",
> +                              ANDROID_SOCKET_NAMESPACE_RESERVED,
> +                              SOCK_STREAM );
> +    if (fd < 0) {
> +        D("no qemud control socket: %s", strerror(errno));
> +        return -1;
> +    }
> +
> +    /* send service name to connect */
> +    if (qemud_fd_write(fd, name, namelen) != namelen) {
> +        D("can't send service name to qemud: %s",
> +           strerror(errno));
> +        close(fd);
> +        return -1;
> +    }
> +
> +    /* read answer from daemon */
> +    if (qemud_fd_read(fd, answer, 2) != 2 ||
> +        answer[0] != 'O' || answer[1] != 'K') {
> +        D("cant' connect to %s service through qemud", name);
> +        close(fd);
> +        return -1;
> +    }
> +    return fd;
> +}
> +
> +static __inline__ int
> +qemud_channel_send(int  fd, const void*  msg, int  msglen)
> +{
> +    char  header[5];
> +
> +    if (msglen < 0)
> +        msglen = strlen((const char*)msg);
> +
> +    if (msglen == 0)
> +        return 0;
> +
> +    snprintf(header, sizeof header, "%04x", msglen);
> +    if (qemud_fd_write(fd, header, 4) != 4) {
> +        D("can't write qemud frame header: %s", strerror(errno));
> +        return -1;
> +    }
> +
> +    if (qemud_fd_write(fd, msg, msglen) != msglen) {
> +        D("can4t write qemud frame payload: %s", strerror(errno));
> +        return -1;
> +    }
> +    return 0;
> +}
> +
> +static __inline__ int
> +qemud_channel_recv(int  fd, void*  msg, int  msgsize)
> +{
> +    char  header[5];
> +    int   size, avail;
> +
> +    if (qemud_fd_read(fd, header, 4) != 4) {
> +        D("can't read qemud frame header: %s", strerror(errno));
> +        return -1;
> +    }
> +    header[4] = 0;
> +    if (sscanf(header, "%04x", &size) != 1) {
> +        D("malformed qemud frame header: '%.*s'", 4, header);
> +        return -1;
> +    }
> +    if (size > msgsize)
> +        return -1;
> +
> +    if (qemud_fd_read(fd, msg, size) != size) {
> +        D("can't read qemud frame payload: %s", strerror(errno));
> +        return -1;
> +    }
> +    return size;
> +}
> +
> +#endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_H */
> diff --git a/android-headers-gingerbread/hardware/libhardware/include/hardware/sensors.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/sensors.h
> new file mode 100644
> index 0000000..7f9706b
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/include/hardware/sensors.h
> @@ -0,0 +1,448 @@
> +/*
> + * 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_SENSORS_INTERFACE_H
> +#define ANDROID_SENSORS_INTERFACE_H
> +
> +#include <stdint.h>
> +#include <sys/cdefs.h>
> +#include <sys/types.h>
> +
> +#include <hardware/hardware.h>
> +#include <cutils/native_handle.h>
> +
> +__BEGIN_DECLS
> +
> +/**
> + * The id of this module
> + */
> +#define SENSORS_HARDWARE_MODULE_ID "sensors"
> +
> +/**
> + * Name of the sensors device to open
> + */
> +#define SENSORS_HARDWARE_POLL       "poll"
> +
> +/**
> + * Handles must be higher than SENSORS_HANDLE_BASE and must be unique.
> + * A Handle identifies a given sensors. The handle is used to activate
> + * and/or deactivate sensors.
> + * In this version of the API there can only be 256 handles.
> + */
> +#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
> +#define SENSOR_TYPE_GRAVITY             9
> +#define SENSOR_TYPE_LINEAR_ACCELERATION 10
> +#define SENSOR_TYPE_ROTATION_VECTOR     11
> +
> +/**
> + * Values returned by the accelerometer in various locations in the universe.
> + * all values are in SI units (m/s^2)
> + */
> +
> +#define GRAVITY_SUN             (275.0f)
> +#define GRAVITY_EARTH           (9.80665f)
> +
> +/** Maximum magnetic field on Earth's surface */
> +#define MAGNETIC_FIELD_EARTH_MAX    (60.0f)
> +
> +/** Minimum magnetic field on Earth's surface */
> +#define MAGNETIC_FIELD_EARTH_MIN    (30.0f)
> +
> +
> +/**
> + * status of each sensor
> + */
> +
> +#define SENSOR_STATUS_UNRELIABLE        0
> +#define SENSOR_STATUS_ACCURACY_LOW      1
> +#define SENSOR_STATUS_ACCURACY_MEDIUM   2
> +#define SENSOR_STATUS_ACCURACY_HIGH     3
> +
> +/**
> + * 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
> + * is only relative to the NATURAL orientation of the screen. In other words,
> + * the axis are not swapped when the device's screen orientation changes.
> + * Higher level services /may/ perform this transformation.
> + *
> + *   x<0         x>0
> + *                ^
> + *                |
> + *    +-----------+-->  y>0
> + *    |           |
> + *    |           |
> + *    |           |
> + *    |           |   / z<0
> + *    |           |  /
> + *    |           | /
> + *    O-----------+/
> + *    |[]  [ ]  []/
> + *    +----------/+     y<0
> + *              /
> + *             /
> + *           |/ z>0 (toward the sky)
> + *
> + *    O: Origin (x=0,y=0,z=0)
> + *
> + *
> + * Orientation
> + * ----------- 
> + * 
> + * All values are angles in degrees.
> + * 
> + * Orientation sensors return sensor events for all 3 axes at a constant
> + * rate defined by setDelay().
> + *
> + * 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 x-axis moves towards the z-axis.
> + *
> + * Note: For historical reasons the roll angle is positive in the clockwise
> + *  direction (mathematically speaking, it should be positive in the
> + *  counter-clockwise direction):
> + *
> + *                Z
> + *                ^
> + *  (+roll)  .--> |
> + *          /     |
> + *         |      |  roll: rotation around Y axis
> + *     X <-------(.)
> + *                 Y
> + *       note that +Y == -roll
> + *
> + *
> + *
> + * 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.
> + *  
> + *  Acceleration sensors return sensor events for all 3 axes at a constant
> + *  rate defined by setDelay().
> + *
> + *  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.
> + *
> + *  Magnetic Field sensors return sensor events for all 3 axes at a constant
> + *  rate defined by setDelay().
> + *
> + * Gyroscope
> + * ---------
> + *  All values are in radians/second and measure the rate of rotation
> + *  around the X, Y and Z axis.  The coordinate system is the same as is
> + *  used for the acceleration sensor. Rotation is positive in the
> + *  counter-clockwise direction (right-hand rule). That is, an observer
> + *  looking from some positive location on the x, y or z axis at a device
> + *  positioned on the origin would report positive rotation if the device
> + *  appeared to be rotating counter clockwise. Note that this is the
> + *  standard mathematical definition of positive rotation and does not agree
> + *  with the definition of roll given earlier.
> + *  The range should at least be 17.45 rad/s (ie: ~1000 deg/s).
> + *
> + * Proximity
> + * ---------
> + *
> + * The distance value is measured in centimeters.  Note that some proximity
> + * sensors only support a binary "close" or "far" measurement.  In this case,
> + * the sensor should report its maxRange value in the "far" state and a value
> + * less than maxRange in the "near" state.
> + *
> + * Proximity sensors report a value only when it changes and each time the
> + * sensor is enabled. setDelay() is ignored.
> + *
> + * Light
> + * -----
> + *
> + * The light sensor value is returned in SI lux units.
> + *
> + * Light sensors report a value only when it changes and each time the
> + * sensor is enabled. setDelay() is ignored.
> + *
> + * Pressure
> + * --------
> + *
> + * The pressure sensor value is returned in hectopascal (hPa)
> + *
> + * Pressure sensors report events at a constant rate defined by setDelay().
> + *
> + * Gravity
> + * -------
> + * A gravity output indicates the direction of and magnitude of gravity in the devices's
> + * coordinates.  On Earth, the magnitude is 9.8.  Units are m/s^2.  The coordinate system
> + * is the same as is used for the acceleration sensor.
> + * When the device is at rest, the output of the gravity sensor should be identical
> + * to that of the accelerometer.
> + *
> + * Linear Acceleration
> + * -------------------
> + * Indicates the linear acceleration of the device in device coordinates, not including gravity.
> + * This output is essentially Acceleration - Gravity.  Units are m/s^2.  The coordinate system is
> + * the same as is used for the acceleration sensor.
> + * The output of the accelerometer, gravity and  linear-acceleration sensors must obey the
> + * following relation:
> + *
> + *   acceleration = gravity + linear-acceleration
> + *
> + *
> + * Rotation Vector
> + * ---------------
> + * A rotation vector represents the orientation of the device as a combination
> + * of an angle and an axis, in which the device has rotated through an angle
> + * theta around an axis <x, y, z>. The three elements of the rotation vector
> + * are <x*sin(theta/2), y*sin(theta/2), z*sin(theta/2)>, such that the magnitude
> + * of the rotation vector is equal to sin(theta/2), and the direction of the
> + * rotation vector is equal to the direction of the axis of rotation. The three
> + * elements of the rotation vector are equal to the last three components of a
> + * unit quaternion <cos(theta/2), x*sin(theta/2), y*sin(theta/2), z*sin(theta/2)>.
> + * Elements of the rotation vector are unitless.  The x, y, and z axis are defined
> + * in the same was as for the acceleration sensor.
> + *
> + * The rotation-vector is stored as:
> + *
> + *   sensors_event_t.data[0] = x*sin(theta/2)
> + *   sensors_event_t.data[1] = y*sin(theta/2)
> + *   sensors_event_t.data[2] = z*sin(theta/2)
> + *   sensors_event_t.data[3] =   cos(theta/2)
> + *
> + */
> +
> +typedef struct {
> +    union {
> +        float v[3];
> +        struct {
> +            float x;
> +            float y;
> +            float z;
> +        };
> +        struct {
> +            float azimuth;
> +            float pitch;
> +            float roll;
> +        };
> +    };
> +    int8_t status;
> +    uint8_t reserved[3];
> +} sensors_vec_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;
> +
> +    /* sensor identifier */
> +    int32_t sensor;
> +
> +    /* sensor type */
> +    int32_t type;
> +
> +    /* reserved */
> +    int32_t reserved0;
> +
> +    /* time is in nanosecond */
> +    int64_t timestamp;
> +
> +    union {
> +        float           data[16];
> +
> +        /* 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;
> +
> +        /* orientation values are in degrees */
> +        sensors_vec_t   orientation;
> +
> +        /* gyroscope values are in rad/s */
> +        sensors_vec_t   gyro;
> +
> +        /* temperature is in degrees centigrade (Celsius) */
> +        float           temperature;
> +
> +        /* distance in centimeters */
> +        float           distance;
> +
> +        /* light in SI lux units */
> +        float           light;
> +
> +        /* pressure in hectopascal (hPa) */
> +        float           pressure;
> +    };
> +    uint32_t        reserved1[4];
> +} sensors_event_t;
> +
> +
> +
> +struct sensor_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 sensors_module_t {
> +    struct hw_module_t common;
> +
> +    /**
> +     * Enumerate all available sensors. The list is returned in "list".
> +     * @return number of sensors in the list
> +     */
> +    int (*get_sensors_list)(struct sensors_module_t* module,
> +            struct sensor_t const** list);
> +};
> +
> +struct sensor_t {
> +    /* name of this sensors */
> +    const char*     name;
> +    /* vendor of the hardware part */
> +    const char*     vendor;
> +    /* version of the hardware part + driver. The value of this field is
> +     * left to the implementation and doesn't have to be monotonically
> +     * increasing.
> +     */    
> +    int             version;
> +    /* handle that identifies this sensors. This handle is used to activate
> +     * and deactivate this sensor. The value of the handle must be 8 bits
> +     * in this version of the API. 
> +     */
> +    int             handle;
> +    /* this sensor's type. */
> +    int             type;
> +    /* maximaum range of this sensor's value in SI units */
> +    float           maxRange;
> +    /* smallest difference between two values reported by this sensor */
> +    float           resolution;
> +    /* rough estimate of this sensor's power consumption in mA */
> +    float           power;
> +    /* minimum delay allowed between events in microseconds. A value of zero
> +     * means that this sensor doesn't report events at a constant rate, but
> +     * rather only when a new data is available */
> +    int32_t         minDelay;
> +    /* reserved fields, must be zero */
> +    void*           reserved[8];
> +};
> +
> +
> +/**
> + * Every device data structure must begin with hw_device_t
> + * followed by module specific public methods and attributes.
> + */
> +struct sensors_poll_device_t {
> +    struct hw_device_t common;
> +
> +    /** 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_poll_device_t *dev,
> +            int handle, int enabled);
> +
> +    /**
> +     * Set the delay between sensor events in nanoseconds for a given sensor.
> +     * It is an error to set a delay inferior to the value defined by
> +     * sensor_t::minDelay. If sensor_t::minDelay is zero, setDelay() is
> +     * ignored and returns 0.
> +     *
> +     * @return 0 if successful, < 0 on error
> +     */
> +    int (*setDelay)(struct sensors_poll_device_t *dev,
> +            int handle, int64_t ns);
> +
> +    /**
> +     * Returns an array of sensor data.
> +     * This function must block until events are available.
> +     *
> +     * @return the number of events read on success, or -errno in case of an error.
> +     * This function should never return 0 (no event).
> +     *
> +     */
> +    int (*poll)(struct sensors_poll_device_t *dev,
> +            sensors_event_t* data, int count);
> +};
> +
> +/** convenience API for opening and closing a device */
> +
> +static inline int sensors_open(const struct hw_module_t* module,
> +        struct sensors_poll_device_t** device) {
> +    return module->methods->open(module,
> +            SENSORS_HARDWARE_POLL, (struct hw_device_t**)device);
> +}
> +
> +static inline int sensors_close(struct sensors_poll_device_t* device) {
> +    return device->common.close(&device->common);
> +}
> +
> +__END_DECLS
> +
> +#include <hardware/sensors_deprecated.h>
> +
> +#endif  // ANDROID_SENSORS_INTERFACE_H
> diff --git a/android-headers-gingerbread/hardware/libhardware/include/hardware/sensors_deprecated.h b/android-headers-gingerbread/hardware/libhardware/include/hardware/sensors_deprecated.h
> new file mode 100644
> index 0000000..7974788
> --- /dev/null
> +++ b/android-headers-gingerbread/hardware/libhardware/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
> -- 
> 1.8.5.2 (Apple Git-48)
> 
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android

-- 
With my kindest regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device



More information about the Android mailing list