diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2009-03-17 16:30:41 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2009-03-17 16:30:41 -0700 |
commit | fe0bd690095978fd817ae0ee90e23edb43841cc4 (patch) | |
tree | 9d8c1a8b2f4d3c2808154ab634c9a458b422bc33 | |
parent | e97d33d5ee914244d6c69789f4f7bbe3ebac1102 (diff) | |
parent | 8232b50d981ce9c584fc1a4af82dae5e70e6ce52 (diff) | |
download | libhardware-fe0bd690095978fd817ae0ee90e23edb43841cc4.tar.gz |
Merge commit 'remotes/korg/cupcake' into merge
Conflicts:
include/hardware/overlay.h
-rw-r--r-- | hardware.c | 58 | ||||
-rw-r--r-- | include/hardware/copybit.h | 24 | ||||
-rw-r--r-- | include/hardware/hardware.h | 37 | ||||
-rw-r--r-- | include/hardware/overlay.h | 23 | ||||
-rw-r--r-- | include/hardware/sensors.h | 30 | ||||
-rw-r--r-- | modules/README.android | 2 |
6 files changed, 110 insertions, 64 deletions
@@ -41,28 +41,32 @@ * led.default.so */ -#define HAL_DEFAULT_VARIANT "default" -#define HAL_VARIANT_KEYS_COUNT 3 -static const char *variant_keys[HAL_VARIANT_KEYS_COUNT] = { +#define HAL_DEFAULT_VARIANT "default" +static const char *variant_keys[] = { + "ro.hardware", /* This goes first so that it can pick up a different + file on the emulator. */ "ro.product.board", "ro.board.platform", - "ro.arch", - HAL_DEFAULT_VARIANT + "ro.arch" }; +#define HAL_VARIANT_KEYS_COUNT (sizeof(variant_keys)/sizeof(variant_keys[0])) /** - * Load the file defined by the path and if succesfull + * Load the file defined by the variant and if succesfull * return the dlopen handle and the hmi. * @return 0 = success, !0 = failure. */ static int load(const char *id, - const char *path, - void **pHandle, + const char *variant, const struct hw_module_t **pHmi) { int status; void *handle; const struct hw_module_t *hmi; + char path[PATH_MAX]; + + /* Construct the path. */ + snprintf(path, sizeof(path), "%s/%s.%s.so", HAL_LIBRARY_PATH, id, variant); LOGV("load: E id=%s path=%s", id, path); @@ -109,21 +113,18 @@ done: } *pHmi = hmi; - *pHandle = handle; - LOGV("load: X id=%s path=%s hmi=%p pHandle=%p status=%d", - id, path, *pHmi, *pHandle, status); + LOGV("load: X id=%s path=%s hmi=%p handle=%p status=%d", + id, path, *pHmi, handle, status); return status; } int hw_get_module(const char *id, const struct hw_module_t **module) { int status; - const struct hw_module_t *hmi = NULL; - char path[PATH_MAX]; - char variant[PATH_MAX]; - void *handle = NULL; int i; + const struct hw_module_t *hmi = NULL; + char prop[PATH_MAX]; /* * Here we rely on the fact that calling dlopen multiple times on @@ -134,30 +135,19 @@ int hw_get_module(const char *id, const struct hw_module_t **module) LOGV("hal_module_info_get: Load module id=%s", id); - /* Loop through the configuration variants looking for a module */ status = -EINVAL; - for (i = 0; (status != 0) && (i < HAL_VARIANT_KEYS_COUNT); i++) { - /* Get variant or default */ - if (strcmp(variant_keys[i], HAL_DEFAULT_VARIANT) == 0) { - strncpy(variant, HAL_DEFAULT_VARIANT, sizeof(variant)-1); - variant[sizeof(variant)-1] = 0; - } else { - if (property_get(variant_keys[i], variant, NULL) == 0) { - continue; - } + /* Loop through the configuration variants looking for a module */ + for (i = 0; (status != 0) && (i < HAL_VARIANT_KEYS_COUNT); i++) { + if (property_get(variant_keys[i], prop, NULL) == 0) { + continue; } - - /* Construct the path then try to load */ - snprintf(path, sizeof(path), "%s/%s.%s.so", - HAL_LIBRARY_PATH, id, variant); - status = load(id, path, &handle, &hmi); + status = load(id, prop, &hmi); } + + /* Try default */ if (status != 0) { - hmi = NULL; - if (handle != NULL) { - dlclose(handle); - } + status = load(id, HAL_DEFAULT_VARIANT, &hmi); } *module = hmi; diff --git a/include/hardware/copybit.h b/include/hardware/copybit.h index 3c873e06..7774cd26 100644 --- a/include/hardware/copybit.h +++ b/include/hardware/copybit.h @@ -39,13 +39,13 @@ __BEGIN_DECLS * 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 + COPYBIT_FORMAT_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888, + 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 = HAL_PIXEL_FORMAT_YCbCr_422_SP, + COPYBIT_FORMAT_YCbCr_420_SP = HAL_PIXEL_FORMAT_YCbCr_420_SP, }; /* name for copybit_set_parameter */ @@ -63,15 +63,15 @@ enum { /* values for copybit_set_parameter(COPYBIT_TRANSFORM) */ enum { /* flip source image horizontally */ - COPYBIT_TRANSFORM_FLIP_H = 0x01, + COPYBIT_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, /* flip source image vertically */ - COPYBIT_TRANSFORM_FLIP_V = 0x02, + COPYBIT_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degres */ - COPYBIT_TRANSFORM_ROT_90 = 0x04, + COPYBIT_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degres */ - COPYBIT_TRANSFORM_ROT_180 = 0x03, + COPYBIT_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degres */ - COPYBIT_TRANSFORM_ROT_270 = 0x07, + COPYBIT_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, }; /* enable/disable value copybit_set_parameter */ diff --git a/include/hardware/hardware.h b/include/hardware/hardware.h index 65ce8d0c..53257442 100644 --- a/include/hardware/hardware.h +++ b/include/hardware/hardware.h @@ -106,6 +106,43 @@ struct hw_device_t { */ 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_RGB_565 = 4, + HAL_PIXEL_FORMAT_BGRA_8888 = 5, + HAL_PIXEL_FORMAT_RGBA_5551 = 6, + HAL_PIXEL_FORMAT_RGBA_4444 = 7, + HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, + HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x11, + HAL_PIXEL_FORMAT_YCbCr_422_P = 0x12, + HAL_PIXEL_FORMAT_YCbCr_420_P = 0x13, + HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, + HAL_PIXEL_FORMAT_YCbCr_420_I = 0x15 +}; + + +/** + * Transformation definitions + */ + +enum { + /* flip source image horizontally */ + HAL_TRANSFORM_FLIP_H = 0x01, + /* flip source image vertically */ + HAL_TRANSFORM_FLIP_V = 0x02, + /* rotate source image 90 degres */ + HAL_TRANSFORM_ROT_90 = 0x04, + /* rotate source image 180 degres */ + HAL_TRANSFORM_ROT_180 = 0x03, + /* rotate source image 270 degres */ + HAL_TRANSFORM_ROT_270 = 0x07, +}; + __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ diff --git a/include/hardware/overlay.h b/include/hardware/overlay.h index 12f8369b..92992d18 100644 --- a/include/hardware/overlay.h +++ b/include/hardware/overlay.h @@ -42,27 +42,25 @@ __BEGIN_DECLS /* 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_I = 0x14, - OVERLAY_FORMAT_YCbCr_420_I = 0x15 + 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_YCbCr_422_I = HAL_PIXEL_FORMAT_YCbCr_422_I, + OVERLAY_FORMAT_YCbCr_420_I = HAL_PIXEL_FORMAT_YCbCr_420_I }; /* values for copybit_set_parameter(OVERLAY_TRANSFORM) */ enum { /* flip source image horizontally */ - OVERLAY_TRANSFORM_FLIP_H = 0x01, + OVERLAY_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_V, /* flip source image vertically */ - OVERLAY_TRANSFORM_FLIP_V = 0x02, + OVERLAY_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_H, /* rotate source image 90 degrees */ - OVERLAY_TRANSFORM_ROT_90 = 0x04, + OVERLAY_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ - OVERLAY_TRANSFORM_ROT_180 = 0x03, + OVERLAY_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees */ - OVERLAY_TRANSFORM_ROT_270 = 0x07, + OVERLAY_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270 }; /* names for setParameter() */ @@ -193,6 +191,7 @@ struct overlay_data_device_t { /* 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); }; diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h index a7ab7ad5..094b3eee 100644 --- a/include/hardware/sensors.h +++ b/include/hardware/sensors.h @@ -37,7 +37,10 @@ __BEGIN_DECLS #define SENSORS_HARDWARE_DATA "data" /** - * Handles must be higher than SENSORS_HANDLE_BASE + * 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 @@ -232,22 +235,37 @@ struct sensors_module_t { struct hw_module_t common; /** - * @return bit map of available sensors defined by - * the constants SENSORS_XXXX. + * 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**); + 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 monotonicaly + * 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; + /* reserved fields, must be zero */ void* reserved[9]; }; @@ -269,9 +287,9 @@ struct sensors_control_device_t { */ int (*open_data_source)(struct sensors_control_device_t *dev); - /** Activate/deactivate one or more of the sensors. + /** Activate/deactivate one sensor. * - * @param sensors is the handle of the sensors to change. + * @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 diff --git a/modules/README.android b/modules/README.android index a79a1d55..57abb726 100644 --- a/modules/README.android +++ b/modules/README.android @@ -7,6 +7,8 @@ libhardware.so eventually should contain *just* the HAL hub Modules are .so in /system/libs/hw/ and have a well defined naming convention: + /system/libs/hw/<*_HARDWARE_MODULE_ID>.<ro.product.board>.so + /system/libs/hw/<*_HARDWARE_MODULE_ID>.<ro.board.platform>.so /system/libs/hw/<*_HARDWARE_MODULE_ID>.<ro.arch>.so /system/libs/hw/<*_HARDWARE_MODULE_ID>.default.so |