Jiho Chang | 47bd953 | 2012-03-24 05:56:11 +0900 | [diff] [blame] | 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@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 | |
SeungBeom Kim | f77a2a9 | 2012-07-20 16:44:11 +0900 | [diff] [blame] | 37 | #define CSC_MAX_PLANES 3 |
| 38 | |
Jiho Chang | 47bd953 | 2012-03-24 05:56:11 +0900 | [diff] [blame] | 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, |
Jiho Chang | 3b54084 | 2012-04-26 13:39:20 -0700 | [diff] [blame] | 50 | CSC_METHOD_HW |
Jiho Chang | 47bd953 | 2012-03-24 05:56:11 +0900 | [diff] [blame] | 51 | } CSC_METHOD; |
| 52 | |
Jiho Chang | 3b54084 | 2012-04-26 13:39:20 -0700 | [diff] [blame] | 53 | typedef enum _CSC_HW_PROPERTY_TYPE { |
| 54 | CSC_HW_PROPERTY_FIXED_NODE = 0, |
| 55 | CSC_HW_PROPERTY_MODE_DRM, |
| 56 | } CSC_HW_PROPERTY_TYPE; |
| 57 | |
Jiho Chang | 47bd953 | 2012-03-24 05:56:11 +0900 | [diff] [blame] | 58 | /* |
| 59 | * change hal pixel format to omx pixel format |
| 60 | * |
| 61 | * @param hal_format |
| 62 | * hal pixel format[in] |
| 63 | * |
| 64 | * @return |
| 65 | * omx pixel format |
| 66 | */ |
| 67 | unsigned int hal_2_omx_pixel_format( |
| 68 | unsigned int hal_format); |
| 69 | |
| 70 | /* |
| 71 | * change omx pixel format to hal pixel format |
| 72 | * |
| 73 | * @param hal_format |
| 74 | * omx pixel format[in] |
| 75 | * |
| 76 | * @return |
| 77 | * hal pixel format |
| 78 | */ |
| 79 | unsigned int omx_2_hal_pixel_format( |
| 80 | unsigned int omx_format); |
| 81 | |
| 82 | /* |
| 83 | * Init CSC handle |
| 84 | * |
| 85 | * @return |
| 86 | * csc handle |
| 87 | */ |
| 88 | void *csc_init( |
Jiho Chang | 3b54084 | 2012-04-26 13:39:20 -0700 | [diff] [blame] | 89 | CSC_METHOD method); |
Jiho Chang | 47bd953 | 2012-03-24 05:56:11 +0900 | [diff] [blame] | 90 | |
| 91 | /* |
| 92 | * Deinit CSC handle |
| 93 | * |
| 94 | * @param handle |
| 95 | * CSC handle[in] |
| 96 | * |
| 97 | * @return |
| 98 | * error code |
| 99 | */ |
| 100 | CSC_ERRORCODE csc_deinit( |
| 101 | void *handle); |
| 102 | |
| 103 | /* |
| 104 | * get color space converter method |
| 105 | * |
| 106 | * @param handle |
| 107 | * CSC handle[in] |
| 108 | * |
| 109 | * @param method |
| 110 | * CSC method[out] |
| 111 | * |
| 112 | * @return |
| 113 | * error code |
| 114 | */ |
| 115 | CSC_ERRORCODE csc_get_method( |
| 116 | void *handle, |
| 117 | CSC_METHOD *method); |
| 118 | |
| 119 | /* |
Greg Hackmann | 4f74fda | 2013-01-08 12:30:39 -0800 | [diff] [blame^] | 120 | * set color space converter method |
| 121 | * |
| 122 | * @param handle |
| 123 | * CSC handle[in] |
| 124 | * |
| 125 | * @param method |
| 126 | * CSC method[in] |
| 127 | * |
| 128 | * @return |
| 129 | * error code |
| 130 | */ |
| 131 | CSC_ERRORCODE csc_set_method( |
| 132 | void *handle, |
| 133 | CSC_METHOD method); |
| 134 | |
| 135 | /* |
Jiho Chang | 3b54084 | 2012-04-26 13:39:20 -0700 | [diff] [blame] | 136 | * Set hw property |
| 137 | * |
| 138 | * @param handle |
| 139 | * CSC handle[in] |
| 140 | * |
| 141 | * @param property |
| 142 | * csc hw property[in] |
| 143 | * |
| 144 | * @param value |
| 145 | * csc hw property value[in] |
| 146 | * |
| 147 | * @return |
| 148 | * csc handle |
| 149 | */ |
| 150 | CSC_ERRORCODE csc_set_hw_property( |
| 151 | void *handle, |
| 152 | CSC_HW_PROPERTY_TYPE property, |
| 153 | int value); |
| 154 | |
| 155 | /* |
Jiho Chang | 47bd953 | 2012-03-24 05:56:11 +0900 | [diff] [blame] | 156 | * Get source format. |
| 157 | * |
| 158 | * @param handle |
| 159 | * CSC handle[in] |
| 160 | * |
| 161 | * @param width |
| 162 | * address of image width[out] |
| 163 | * |
| 164 | * @param height |
| 165 | * address of image height[out] |
| 166 | * |
| 167 | * @param crop_left |
| 168 | * address of image left crop size[out] |
| 169 | * |
| 170 | * @param crop_top |
| 171 | * address of image top crop size[out] |
| 172 | * |
| 173 | * @param crop_width |
| 174 | * address of cropped image width[out] |
| 175 | * |
| 176 | * @param crop_height |
| 177 | * address of cropped image height[out] |
| 178 | * |
| 179 | * @param color_format |
| 180 | * address of source color format(HAL format)[out] |
| 181 | * |
| 182 | * @return |
| 183 | * error code |
| 184 | */ |
| 185 | CSC_ERRORCODE csc_get_src_format( |
| 186 | void *handle, |
| 187 | unsigned int *width, |
| 188 | unsigned int *height, |
| 189 | unsigned int *crop_left, |
| 190 | unsigned int *crop_top, |
| 191 | unsigned int *crop_width, |
| 192 | unsigned int *crop_height, |
| 193 | unsigned int *color_format, |
| 194 | unsigned int *cacheable); |
| 195 | |
| 196 | /* |
| 197 | * Set source format. |
| 198 | * Don't call each converting time. |
| 199 | * Pls call this function as below. |
| 200 | * 1. first converting time |
| 201 | * 2. format is changed |
| 202 | * |
| 203 | * @param handle |
| 204 | * CSC handle[in] |
| 205 | * |
| 206 | * @param width |
| 207 | * image width[in] |
| 208 | * |
| 209 | * @param height |
| 210 | * image height[in] |
| 211 | * |
| 212 | * @param crop_left |
| 213 | * image left crop size[in] |
| 214 | * |
| 215 | * @param crop_top |
| 216 | * image top crop size[in] |
| 217 | * |
| 218 | * @param crop_width |
| 219 | * cropped image width[in] |
| 220 | * |
| 221 | * @param crop_height |
| 222 | * cropped image height[in] |
| 223 | * |
| 224 | * @param color_format |
| 225 | * source color format(HAL format)[in] |
| 226 | * |
| 227 | * @return |
| 228 | * error code |
| 229 | */ |
| 230 | CSC_ERRORCODE csc_set_src_format( |
| 231 | void *handle, |
| 232 | unsigned int width, |
| 233 | unsigned int height, |
| 234 | unsigned int crop_left, |
| 235 | unsigned int crop_top, |
| 236 | unsigned int crop_width, |
| 237 | unsigned int crop_height, |
| 238 | unsigned int color_format, |
| 239 | unsigned int cacheable); |
| 240 | |
| 241 | /* |
| 242 | * Get destination format. |
| 243 | * |
| 244 | * @param handle |
| 245 | * CSC handle[in] |
| 246 | * |
| 247 | * @param width |
| 248 | * address of image width[out] |
| 249 | * |
| 250 | * @param height |
| 251 | * address of image height[out] |
| 252 | * |
| 253 | * @param crop_left |
| 254 | * address of image left crop size[out] |
| 255 | * |
| 256 | * @param crop_top |
| 257 | * address of image top crop size[out] |
| 258 | * |
| 259 | * @param crop_width |
| 260 | * address of cropped image width[out] |
| 261 | * |
| 262 | * @param crop_height |
| 263 | * address of cropped image height[out] |
| 264 | * |
| 265 | * @param color_format |
| 266 | * address of color format(HAL format)[out] |
| 267 | * |
| 268 | * @return |
| 269 | * error code |
| 270 | */ |
| 271 | CSC_ERRORCODE csc_get_dst_format( |
| 272 | void *handle, |
| 273 | unsigned int *width, |
| 274 | unsigned int *height, |
| 275 | unsigned int *crop_left, |
| 276 | unsigned int *crop_top, |
| 277 | unsigned int *crop_width, |
| 278 | unsigned int *crop_height, |
| 279 | unsigned int *color_format, |
| 280 | unsigned int *cacheable); |
| 281 | |
| 282 | /* |
| 283 | * Set destination format |
| 284 | * Don't call each converting time. |
| 285 | * Pls call this function as below. |
| 286 | * 1. first converting time |
| 287 | * 2. format is changed |
| 288 | * |
| 289 | * @param handle |
| 290 | * CSC handle[in] |
| 291 | * |
| 292 | * @param width |
| 293 | * image width[in] |
| 294 | * |
| 295 | * @param height |
| 296 | * image height[in] |
| 297 | * |
| 298 | * @param crop_left |
| 299 | * image left crop size[in] |
| 300 | * |
| 301 | * @param crop_top |
| 302 | * image top crop size[in] |
| 303 | * |
| 304 | * @param crop_width |
| 305 | * cropped image width[in] |
| 306 | * |
| 307 | * @param crop_height |
| 308 | * cropped image height[in] |
| 309 | * |
| 310 | * @param color_format |
| 311 | * destination color format(HAL format)[in] |
| 312 | * |
| 313 | * @return |
| 314 | * error code |
| 315 | */ |
| 316 | CSC_ERRORCODE csc_set_dst_format( |
| 317 | void *handle, |
| 318 | unsigned int width, |
| 319 | unsigned int height, |
| 320 | unsigned int crop_left, |
| 321 | unsigned int crop_top, |
| 322 | unsigned int crop_width, |
| 323 | unsigned int crop_height, |
| 324 | unsigned int color_format, |
| 325 | unsigned int cacheable); |
| 326 | |
| 327 | /* |
| 328 | * Setup source buffer |
| 329 | * set_format func should be called before this this func. |
| 330 | * |
| 331 | * @param handle |
| 332 | * CSC handle[in] |
| 333 | * |
| 334 | * @param src_buffer |
| 335 | * source buffer pointer array[in] |
| 336 | * |
| 337 | * @param y |
| 338 | * y or RGB destination pointer[in] |
| 339 | * |
| 340 | * @param u |
| 341 | * u or uv destination pointer[in] |
| 342 | * |
| 343 | * @param v |
| 344 | * v or none destination pointer[in] |
| 345 | * |
| 346 | * @return |
| 347 | * error code |
| 348 | */ |
| 349 | CSC_ERRORCODE csc_set_src_buffer( |
SeungBeom Kim | f77a2a9 | 2012-07-20 16:44:11 +0900 | [diff] [blame] | 350 | void *handle, |
| 351 | void *addr[CSC_MAX_PLANES]); |
Jiho Chang | 47bd953 | 2012-03-24 05:56:11 +0900 | [diff] [blame] | 352 | |
| 353 | /* |
| 354 | * Setup destination buffer |
| 355 | * |
| 356 | * @param handle |
| 357 | * CSC handle[in] |
| 358 | * |
| 359 | * @param y |
| 360 | * y or RGB destination pointer[in] |
| 361 | * |
| 362 | * @param u |
| 363 | * u or uv destination pointer[in] |
| 364 | * |
| 365 | * @param v |
| 366 | * v or none destination pointer[in] |
| 367 | * |
| 368 | * @return |
| 369 | * error code |
| 370 | */ |
| 371 | CSC_ERRORCODE csc_set_dst_buffer( |
SeungBeom Kim | f77a2a9 | 2012-07-20 16:44:11 +0900 | [diff] [blame] | 372 | void *handle, |
| 373 | void *addr[CSC_MAX_PLANES]); |
Jiho Chang | 47bd953 | 2012-03-24 05:56:11 +0900 | [diff] [blame] | 374 | |
| 375 | /* |
| 376 | * Convert color space with presetup color format |
| 377 | * |
| 378 | * @param handle |
| 379 | * CSC handle[in] |
| 380 | * |
| 381 | * @return |
| 382 | * error code |
| 383 | */ |
| 384 | CSC_ERRORCODE csc_convert( |
| 385 | void *handle); |
| 386 | |
| 387 | #ifdef __cplusplus |
| 388 | } |
| 389 | #endif |
| 390 | |
| 391 | #endif |