2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H
18 #define ANDROID_INCLUDE_HARDWARE_HARDWARE_H
21 #include <sys/cdefs.h>
23 #include <cutils/native_handle.h>
28 * Value for the hw_module_t.tag field
31 #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
33 #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T')
34 #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T')
37 struct hw_module_methods_t;
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.
45 typedef struct hw_module_t {
46 /** tag must be initialized to HARDWARE_MODULE_TAG */
49 /** major version number for the module */
50 uint16_t version_major;
52 /** minor version number of the module */
53 uint16_t version_minor;
55 /** Identifier of module */
58 /** Name of this module */
61 /** Author/owner/implementor of the module */
64 /** Modules methods */
65 struct hw_module_methods_t* methods;
70 /** padding to 128 bytes, reserved for future use */
71 uint32_t reserved[32-7];
75 typedef struct hw_module_methods_t {
76 /** Open a specific device */
77 int (*open)(const struct hw_module_t* module, const char* id,
78 struct hw_device_t** device);
80 } hw_module_methods_t;
83 * Every device data structure must begin with hw_device_t
84 * followed by module specific public methods and attributes.
86 typedef struct hw_device_t {
87 /** tag must be initialized to HARDWARE_DEVICE_TAG */
90 /** version number for hw_device_t */
93 /** reference to the module this device belongs to */
94 struct hw_module_t* module;
96 /** padding reserved for future use */
97 uint32_t reserved[12];
99 /** Close this device */
100 int (*close)(struct hw_device_t* device);
105 * Name of the hal_module_info
107 #define HAL_MODULE_INFO_SYM HMI
110 * Name of the hal_module_info as a string
112 #define HAL_MODULE_INFO_SYM_AS_STR "HMI"
115 * Get the module info associated with a module by id.
116 * @return: 0 == success, <0 == error and *pHmi == NULL
118 int hw_get_module(const char *id, const struct hw_module_t **module);
122 * pixel format definitions
126 HAL_PIXEL_FORMAT_RGBA_8888 = 1,
127 HAL_PIXEL_FORMAT_RGBX_8888 = 2,
128 HAL_PIXEL_FORMAT_RGB_888 = 3,
129 HAL_PIXEL_FORMAT_RGB_565 = 4,
130 HAL_PIXEL_FORMAT_BGRA_8888 = 5,
131 HAL_PIXEL_FORMAT_RGBA_5551 = 6,
132 HAL_PIXEL_FORMAT_RGBA_4444 = 7,
133 /* 0x8 - 0xF range unavailable */
134 HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16
135 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 (_adreno)
136 HAL_PIXEL_FORMAT_YCbCr_422_P = 0x12, // IYUV
137 HAL_PIXEL_FORMAT_YCbCr_420_P = 0x13, // YUV9
138 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 (_adreno)
140 HAL_PIXEL_FORMAT_CbYCrY_422_I = 0x16, // UYVY (_adreno)
142 /* 0x18 - 0x1F range unavailable */
143 HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED = 0x20, // NV12_adreno_tiled
144 HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x21, // NV12
145 HAL_PIXEL_FORMAT_YCrCb_420_SP_TILED = 0x22, // NV21_adreno_tiled
146 HAL_PIXEL_FORMAT_YCrCb_422_SP = 0x23, // NV61
147 HAL_PIXEL_FORMAT_YCrCb_422_P = 0x24, // YV12 (_adreno)
150 /* fourcc mapping for the YUV formats. see http://www.fourcc.org */
152 HAL_PIXEL_FORMAT_NV16 = HAL_PIXEL_FORMAT_YCbCr_422_SP,
153 HAL_PIXEL_FORMAT_NV21 = HAL_PIXEL_FORMAT_YCrCb_420_SP,
154 HAL_PIXEL_FORMAT_IYUV = HAL_PIXEL_FORMAT_YCbCr_422_P,
155 HAL_PIXEL_FORMAT_YUV9 = HAL_PIXEL_FORMAT_YCbCr_420_P,
156 HAL_PIXEL_FORMAT_YUY2 = HAL_PIXEL_FORMAT_YCbCr_422_I,
157 HAL_PIXEL_FORMAT_UYVY = HAL_PIXEL_FORMAT_CbYCrY_422_I,
158 HAL_PIXEL_FORMAT_NV12_ADRENO_TILED = HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED,
159 HAL_PIXEL_FORMAT_NV12 = HAL_PIXEL_FORMAT_YCbCr_420_SP,
160 HAL_PIXEL_FORMAT_NV21_ADRENO_TILED = HAL_PIXEL_FORMAT_YCrCb_420_SP_TILED,
161 HAL_PIXEL_FORMAT_NV61 = HAL_PIXEL_FORMAT_YCrCb_422_SP,
162 HAL_PIXEL_FORMAT_YV12 = HAL_PIXEL_FORMAT_YCrCb_422_P
166 * Transformation definitions
170 /* flip source image horizontally */
171 HAL_TRANSFORM_FLIP_H = 0x01,
172 /* flip source image vertically */
173 HAL_TRANSFORM_FLIP_V = 0x02,
174 /* rotate source image 90 degrees */
175 HAL_TRANSFORM_ROT_90 = 0x04,
176 /* rotate source image 180 degrees */
177 HAL_TRANSFORM_ROT_180 = 0x03,
178 /* rotate source image 270 degrees */
179 HAL_TRANSFORM_ROT_270 = 0x07,
184 #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */