The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H |
| 18 | #define ANDROID_INCLUDE_HARDWARE_HARDWARE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/cdefs.h> |
| 22 | |
Mathias Agopian | a8a7516 | 2009-04-10 14:24:31 -0700 | [diff] [blame] | 23 | #include <cutils/native_handle.h> |
| 24 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 25 | __BEGIN_DECLS |
| 26 | |
| 27 | /* |
| 28 | * Value for the hw_module_t.tag field |
| 29 | */ |
Mathias Agopian | a8a7516 | 2009-04-10 14:24:31 -0700 | [diff] [blame] | 30 | |
| 31 | #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) |
| 32 | |
| 33 | #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') |
| 34 | #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 35 | |
| 36 | struct hw_module_t; |
| 37 | struct hw_module_methods_t; |
| 38 | struct hw_device_t; |
| 39 | |
| 40 | /** |
| 41 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 42 | * and the fields of this data structure must begin with hw_module_t |
| 43 | * followed by module specific information. |
| 44 | */ |
Mathias Agopian | 9d82c1a | 2009-08-19 11:20:55 -0700 | [diff] [blame] | 45 | typedef struct hw_module_t { |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 46 | /** tag must be initialized to HARDWARE_MODULE_TAG */ |
| 47 | uint32_t tag; |
| 48 | |
| 49 | /** major version number for the module */ |
| 50 | uint16_t version_major; |
| 51 | |
| 52 | /** minor version number of the module */ |
| 53 | uint16_t version_minor; |
| 54 | |
| 55 | /** Identifier of module */ |
| 56 | const char *id; |
| 57 | |
| 58 | /** Name of this module */ |
| 59 | const char *name; |
| 60 | |
| 61 | /** Author/owner/implementor of the module */ |
| 62 | const char *author; |
| 63 | |
| 64 | /** Modules methods */ |
| 65 | struct hw_module_methods_t* methods; |
Mathias Agopian | a8a7516 | 2009-04-10 14:24:31 -0700 | [diff] [blame] | 66 | |
| 67 | /** module's dso */ |
| 68 | void* dso; |
| 69 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 70 | /** padding to 128 bytes, reserved for future use */ |
Mathias Agopian | a8a7516 | 2009-04-10 14:24:31 -0700 | [diff] [blame] | 71 | uint32_t reserved[32-7]; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 72 | |
Mathias Agopian | 9d82c1a | 2009-08-19 11:20:55 -0700 | [diff] [blame] | 73 | } hw_module_t; |
| 74 | |
| 75 | typedef struct hw_module_methods_t { |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 76 | /** Open a specific device */ |
| 77 | int (*open)(const struct hw_module_t* module, const char* id, |
| 78 | struct hw_device_t** device); |
Mathias Agopian | 9d82c1a | 2009-08-19 11:20:55 -0700 | [diff] [blame] | 79 | |
| 80 | } hw_module_methods_t; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * Every device data structure must begin with hw_device_t |
| 84 | * followed by module specific public methods and attributes. |
| 85 | */ |
Mathias Agopian | 9d82c1a | 2009-08-19 11:20:55 -0700 | [diff] [blame] | 86 | typedef struct hw_device_t { |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 87 | /** tag must be initialized to HARDWARE_DEVICE_TAG */ |
| 88 | uint32_t tag; |
| 89 | |
| 90 | /** version number for hw_device_t */ |
| 91 | uint32_t version; |
| 92 | |
| 93 | /** reference to the module this device belongs to */ |
| 94 | struct hw_module_t* module; |
| 95 | |
| 96 | /** padding reserved for future use */ |
| 97 | uint32_t reserved[12]; |
| 98 | |
| 99 | /** Close this device */ |
| 100 | int (*close)(struct hw_device_t* device); |
Mathias Agopian | 9d82c1a | 2009-08-19 11:20:55 -0700 | [diff] [blame] | 101 | |
| 102 | } hw_device_t; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 103 | |
| 104 | /** |
Mathias Agopian | a8a7516 | 2009-04-10 14:24:31 -0700 | [diff] [blame] | 105 | * Name of the hal_module_info |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 106 | */ |
| 107 | #define HAL_MODULE_INFO_SYM HMI |
| 108 | |
| 109 | /** |
| 110 | * Name of the hal_module_info as a string |
| 111 | */ |
| 112 | #define HAL_MODULE_INFO_SYM_AS_STR "HMI" |
| 113 | |
| 114 | /** |
| 115 | * Get the module info associated with a module by id. |
Dima Zavin | 54921de | 2011-04-18 10:55:37 -0700 | [diff] [blame^] | 116 | * |
| 117 | * @return: 0 == success, <0 == error and *module == NULL |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 118 | */ |
| 119 | int hw_get_module(const char *id, const struct hw_module_t **module); |
| 120 | |
Dima Zavin | 54921de | 2011-04-18 10:55:37 -0700 | [diff] [blame^] | 121 | /** |
| 122 | * Get the module info associated with a module instance by class 'class_id' |
| 123 | * and instance 'inst'. |
| 124 | * |
| 125 | * Some modules types necessitate multiple instances. For example audio supports |
| 126 | * multiple concurrent interfaces and thus 'audio' is the module class |
| 127 | * and 'primary' or 'a2dp' are module interfaces. This implies that the files |
| 128 | * providing these modules would be named audio.primary.<variant>.so and |
| 129 | * audio.a2dp.<variant>.so |
| 130 | * |
| 131 | * @return: 0 == success, <0 == error and *module == NULL |
| 132 | */ |
| 133 | int hw_get_module_by_class(const char *class_id, const char *inst, |
| 134 | const struct hw_module_t **module); |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 135 | |
| 136 | /** |
| 137 | * pixel format definitions |
| 138 | */ |
| 139 | |
| 140 | enum { |
Mathias Agopian | 373a9c6 | 2010-06-14 21:08:00 -0700 | [diff] [blame] | 141 | HAL_PIXEL_FORMAT_RGBA_8888 = 1, |
| 142 | HAL_PIXEL_FORMAT_RGBX_8888 = 2, |
| 143 | HAL_PIXEL_FORMAT_RGB_888 = 3, |
| 144 | HAL_PIXEL_FORMAT_RGB_565 = 4, |
| 145 | HAL_PIXEL_FORMAT_BGRA_8888 = 5, |
| 146 | HAL_PIXEL_FORMAT_RGBA_5551 = 6, |
| 147 | HAL_PIXEL_FORMAT_RGBA_4444 = 7, |
Mathias Agopian | 6915eb3 | 2010-07-01 20:36:08 -0700 | [diff] [blame] | 148 | |
| 149 | /* 0x8 - 0xFF range unavailable */ |
| 150 | |
| 151 | /* |
| 152 | * 0x100 - 0x1FF |
| 153 | * |
Jamie Gennis | 2ec2193 | 2010-11-22 15:28:58 -0800 | [diff] [blame] | 154 | * This range is reserved for pixel formats that are specific to the HAL |
| 155 | * implementation. Implementations can use any value in this range to |
| 156 | * communicate video pixel formats between their HAL modules. These formats |
| 157 | * must not have an alpha channel. Additionally, an EGLimage created from a |
| 158 | * gralloc buffer of one of these formats must be supported for use with the |
| 159 | * GL_OES_EGL_image_external OpenGL ES extension. |
Mathias Agopian | 6915eb3 | 2010-07-01 20:36:08 -0700 | [diff] [blame] | 160 | */ |
| 161 | |
| 162 | /* |
Mathias Agopian | 80107f8 | 2010-07-07 14:54:14 -0700 | [diff] [blame] | 163 | * Android YUV format: |
Mathias Agopian | 6915eb3 | 2010-07-01 20:36:08 -0700 | [diff] [blame] | 164 | * |
Mathias Agopian | 80107f8 | 2010-07-07 14:54:14 -0700 | [diff] [blame] | 165 | * This format is exposed outside of the HAL to software |
Mathias Agopian | 6915eb3 | 2010-07-01 20:36:08 -0700 | [diff] [blame] | 166 | * decoders and applications. |
Mathias Agopian | 80107f8 | 2010-07-07 14:54:14 -0700 | [diff] [blame] | 167 | * EGLImageKHR must support it in conjunction with the |
Mathias Agopian | 6915eb3 | 2010-07-01 20:36:08 -0700 | [diff] [blame] | 168 | * OES_EGL_image_external extension. |
| 169 | * |
Mathias Agopian | 80107f8 | 2010-07-07 14:54:14 -0700 | [diff] [blame] | 170 | * YV12 is 4:2:0 YCrCb planar format comprised of a WxH Y plane followed |
Mathias Agopian | 6915eb3 | 2010-07-01 20:36:08 -0700 | [diff] [blame] | 171 | * by (W/2) x (H/2) Cr and Cb planes. |
| 172 | * |
Mathias Agopian | a2df7ab | 2010-09-10 14:33:16 -0700 | [diff] [blame] | 173 | * This format assumes |
| 174 | * - an even width |
| 175 | * - an even height |
| 176 | * - a horizontal stride multiple of 16 pixels |
| 177 | * - a vertical stride equal to the height |
| 178 | * |
| 179 | * y_size = stride * height |
| 180 | * c_size = ALIGN(stride/2, 16) * height/2 |
Mathias Agopian | 80107f8 | 2010-07-07 14:54:14 -0700 | [diff] [blame] | 181 | * size = y_size + c_size * 2 |
| 182 | * cr_offset = y_size |
| 183 | * cb_offset = y_size + c_size |
Mathias Agopian | 6915eb3 | 2010-07-01 20:36:08 -0700 | [diff] [blame] | 184 | * |
| 185 | */ |
Mathias Agopian | 80107f8 | 2010-07-07 14:54:14 -0700 | [diff] [blame] | 186 | HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar |
| 187 | |
Mathias Agopian | 6915eb3 | 2010-07-01 20:36:08 -0700 | [diff] [blame] | 188 | |
| 189 | |
| 190 | /* Legacy formats (deprecated), used by ImageFormat.java */ |
| 191 | HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 |
| 192 | HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 |
| 193 | HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 194 | }; |
| 195 | |
| 196 | |
| 197 | /** |
| 198 | * Transformation definitions |
Mathias Agopian | 2d1e978 | 2010-10-25 17:20:19 -0700 | [diff] [blame] | 199 | * |
| 200 | * IMPORTANT NOTE: |
| 201 | * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. |
| 202 | * |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 203 | */ |
| 204 | |
| 205 | enum { |
Mathias Agopian | 2d1e978 | 2010-10-25 17:20:19 -0700 | [diff] [blame] | 206 | /* flip source image horizontally (around the vertical axis) */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 207 | HAL_TRANSFORM_FLIP_H = 0x01, |
Mathias Agopian | 2d1e978 | 2010-10-25 17:20:19 -0700 | [diff] [blame] | 208 | /* flip source image vertically (around the horizontal axis)*/ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 209 | HAL_TRANSFORM_FLIP_V = 0x02, |
Mathias Agopian | 2d1e978 | 2010-10-25 17:20:19 -0700 | [diff] [blame] | 210 | /* rotate source image 90 degrees clockwise */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 211 | HAL_TRANSFORM_ROT_90 = 0x04, |
Mathias Agopian | 9e149fc | 2010-02-17 21:27:20 -0800 | [diff] [blame] | 212 | /* rotate source image 180 degrees */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 213 | HAL_TRANSFORM_ROT_180 = 0x03, |
Mathias Agopian | 2d1e978 | 2010-10-25 17:20:19 -0700 | [diff] [blame] | 214 | /* rotate source image 270 degrees clockwise */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 215 | HAL_TRANSFORM_ROT_270 = 0x07, |
| 216 | }; |
| 217 | |
| 218 | __END_DECLS |
| 219 | |
| 220 | #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ |