1 /* 2 * Copyright (C) 2012 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 /* 18 * @file csc.h 19 * 20 * @brief color space convertion abstract header 21 * 22 * @author Pyoungjae Jung (pjet.jung (at) samsung.com) 23 * 24 * @version 1.0 25 * 26 * @history 27 * 2011.12.27 : Create 28 */ 29 30 #ifndef CSC_H 31 #define CSC_H 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #define CSC_MAX_PLANES 3 38 39 typedef enum _CSC_ERRORCODE { 40 CSC_ErrorNone = 0, 41 CSC_Error, 42 CSC_ErrorNotInit, 43 CSC_ErrorInvalidAddress, 44 CSC_ErrorUnsupportFormat, 45 CSC_ErrorNotImplemented 46 } CSC_ERRORCODE; 47 48 typedef enum _CSC_METHOD { 49 CSC_METHOD_SW = 0, 50 CSC_METHOD_HW 51 } CSC_METHOD; 52 53 typedef enum _CSC_HW_PROPERTY_TYPE { 54 CSC_HW_PROPERTY_FIXED_NODE = 0, 55 CSC_HW_PROPERTY_MODE_DRM, 56 CSC_HW_PROPERTY_HW_TYPE, 57 } CSC_HW_PROPERTY_TYPE; 58 59 typedef enum _CSC_HW_TYPE { 60 CSC_HW_TYPE_NONE = 0, 61 CSC_HW_TYPE_FIMC, 62 CSC_HW_TYPE_GSCALER, 63 CSC_HW_TYPE_G2D, 64 } CSC_HW_TYPE; 65 66 /* 67 * change hal pixel format to omx pixel format 68 * 69 * @param hal_format 70 * hal pixel format[in] 71 * 72 * @return 73 * omx pixel format 74 */ 75 unsigned int hal_2_omx_pixel_format( 76 unsigned int hal_format); 77 78 /* 79 * change omx pixel format to hal pixel format 80 * 81 * @param hal_format 82 * omx pixel format[in] 83 * 84 * @return 85 * hal pixel format 86 */ 87 unsigned int omx_2_hal_pixel_format( 88 unsigned int omx_format); 89 90 /* 91 * change hal pixel format to g2d color format 92 * 93 * @param hal_format 94 * hal pixel format[in] 95 * 96 * @return 97 * g2d color format 98 */ 99 unsigned int hal_2_g2d_color_format(unsigned int hal_format); 100 101 /* 102 * change hal pixel format to g2d pixel order 103 * 104 * @param hal_format 105 * hal pixel format[in] 106 * 107 * @return 108 * g2d pixel order 109 */ 110 unsigned int hal_2_g2d_pixel_order(unsigned int hal_format); 111 112 /* 113 * change hal pixel format to g2d "bpp" (actual bpp for RGB formats, 8 bpp for 114 * YUV formats) 115 * 116 * @param hal_format 117 * hal pixel format[in] 118 * 119 * @return 120 * g2d bpp 121 */ 122 size_t hal_2_g2d_bpp(unsigned int hal_format); 123 124 /* 125 * Init CSC handle 126 * 127 * @return 128 * csc handle 129 */ 130 void *csc_init( 131 CSC_METHOD method); 132 133 /* 134 * Deinit CSC handle 135 * 136 * @param handle 137 * CSC handle[in] 138 * 139 * @return 140 * error code 141 */ 142 CSC_ERRORCODE csc_deinit( 143 void *handle); 144 145 /* 146 * get color space converter method 147 * 148 * @param handle 149 * CSC handle[in] 150 * 151 * @param method 152 * CSC method[out] 153 * 154 * @return 155 * error code 156 */ 157 CSC_ERRORCODE csc_get_method( 158 void *handle, 159 CSC_METHOD *method); 160 161 /* 162 * set color space converter method 163 * 164 * @param handle 165 * CSC handle[in] 166 * 167 * @param method 168 * CSC method[in] 169 * 170 * @return 171 * error code 172 */ 173 CSC_ERRORCODE csc_set_method( 174 void *handle, 175 CSC_METHOD method); 176 177 /* 178 * Set hw property 179 * 180 * @param handle 181 * CSC handle[in] 182 * 183 * @param property 184 * csc hw property[in] 185 * 186 * @param value 187 * csc hw property value[in] 188 * 189 * @return 190 * csc handle 191 */ 192 CSC_ERRORCODE csc_set_hw_property( 193 void *handle, 194 CSC_HW_PROPERTY_TYPE property, 195 int value); 196 197 /* 198 * Get source format. 199 * 200 * @param handle 201 * CSC handle[in] 202 * 203 * @param width 204 * address of image width[out] 205 * 206 * @param height 207 * address of image height[out] 208 * 209 * @param crop_left 210 * address of image left crop size[out] 211 * 212 * @param crop_top 213 * address of image top crop size[out] 214 * 215 * @param crop_width 216 * address of cropped image width[out] 217 * 218 * @param crop_height 219 * address of cropped image height[out] 220 * 221 * @param color_format 222 * address of source color format(HAL format)[out] 223 * 224 * @return 225 * error code 226 */ 227 CSC_ERRORCODE csc_get_src_format( 228 void *handle, 229 unsigned int *width, 230 unsigned int *height, 231 unsigned int *crop_left, 232 unsigned int *crop_top, 233 unsigned int *crop_width, 234 unsigned int *crop_height, 235 unsigned int *color_format, 236 unsigned int *cacheable); 237 238 /* 239 * Set source format. 240 * Don't call each converting time. 241 * Pls call this function as below. 242 * 1. first converting time 243 * 2. format is changed 244 * 245 * @param handle 246 * CSC handle[in] 247 * 248 * @param width 249 * image width[in] 250 * 251 * @param height 252 * image height[in] 253 * 254 * @param crop_left 255 * image left crop size[in] 256 * 257 * @param crop_top 258 * image top crop size[in] 259 * 260 * @param crop_width 261 * cropped image width[in] 262 * 263 * @param crop_height 264 * cropped image height[in] 265 * 266 * @param color_format 267 * source color format(HAL format)[in] 268 * 269 * @return 270 * error code 271 */ 272 CSC_ERRORCODE csc_set_src_format( 273 void *handle, 274 unsigned int width, 275 unsigned int height, 276 unsigned int crop_left, 277 unsigned int crop_top, 278 unsigned int crop_width, 279 unsigned int crop_height, 280 unsigned int color_format, 281 unsigned int cacheable); 282 283 /* 284 * Get destination format. 285 * 286 * @param handle 287 * CSC handle[in] 288 * 289 * @param width 290 * address of image width[out] 291 * 292 * @param height 293 * address of image height[out] 294 * 295 * @param crop_left 296 * address of image left crop size[out] 297 * 298 * @param crop_top 299 * address of image top crop size[out] 300 * 301 * @param crop_width 302 * address of cropped image width[out] 303 * 304 * @param crop_height 305 * address of cropped image height[out] 306 * 307 * @param color_format 308 * address of color format(HAL format)[out] 309 * 310 * @return 311 * error code 312 */ 313 CSC_ERRORCODE csc_get_dst_format( 314 void *handle, 315 unsigned int *width, 316 unsigned int *height, 317 unsigned int *crop_left, 318 unsigned int *crop_top, 319 unsigned int *crop_width, 320 unsigned int *crop_height, 321 unsigned int *color_format, 322 unsigned int *cacheable); 323 324 /* 325 * Set destination format 326 * Don't call each converting time. 327 * Pls call this function as below. 328 * 1. first converting time 329 * 2. format is changed 330 * 331 * @param handle 332 * CSC handle[in] 333 * 334 * @param width 335 * image width[in] 336 * 337 * @param height 338 * image height[in] 339 * 340 * @param crop_left 341 * image left crop size[in] 342 * 343 * @param crop_top 344 * image top crop size[in] 345 * 346 * @param crop_width 347 * cropped image width[in] 348 * 349 * @param crop_height 350 * cropped image height[in] 351 * 352 * @param color_format 353 * destination color format(HAL format)[in] 354 * 355 * @return 356 * error code 357 */ 358 CSC_ERRORCODE csc_set_dst_format( 359 void *handle, 360 unsigned int width, 361 unsigned int height, 362 unsigned int crop_left, 363 unsigned int crop_top, 364 unsigned int crop_width, 365 unsigned int crop_height, 366 unsigned int color_format, 367 unsigned int cacheable); 368 369 /* 370 * Setup source buffer 371 * set_format func should be called before this this func. 372 * 373 * @param handle 374 * CSC handle[in] 375 * 376 * @param src_buffer 377 * source buffer pointer array[in] 378 * 379 * @param y 380 * y or RGB destination pointer[in] 381 * 382 * @param u 383 * u or uv destination pointer[in] 384 * 385 * @param v 386 * v or none destination pointer[in] 387 * 388 * @return 389 * error code 390 */ 391 CSC_ERRORCODE csc_set_src_buffer( 392 void *handle, 393 void *addr[CSC_MAX_PLANES]); 394 395 /* 396 * Setup destination buffer 397 * 398 * @param handle 399 * CSC handle[in] 400 * 401 * @param y 402 * y or RGB destination pointer[in] 403 * 404 * @param u 405 * u or uv destination pointer[in] 406 * 407 * @param v 408 * v or none destination pointer[in] 409 * 410 * @return 411 * error code 412 */ 413 CSC_ERRORCODE csc_set_dst_buffer( 414 void *handle, 415 void *addr[CSC_MAX_PLANES]); 416 417 /* 418 * Convert color space with presetup color format 419 * 420 * @param handle 421 * CSC handle[in] 422 * 423 * @return 424 * error code 425 */ 426 CSC_ERRORCODE csc_convert( 427 void *handle); 428 429 #ifdef __cplusplus 430 } 431 #endif 432 433 #endif 434