libhwjpeg: resolve compilation errors
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / include / csc.h
CommitLineData
5763fb39
T
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
34extern "C" {
35#endif
36
37#define CSC_MAX_PLANES 3
38
39typedef 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
48typedef enum _CSC_METHOD {
49 CSC_METHOD_SW = 0,
50 CSC_METHOD_HW
51} CSC_METHOD;
52
53typedef enum _CSC_HW_PROPERTY_TYPE {
54 CSC_HW_PROPERTY_FIXED_NODE = 0,
55 CSC_HW_PROPERTY_MODE_DRM,
56} CSC_HW_PROPERTY_TYPE;
57
58typedef enum _CSC_MEMTYPE {
59 CSC_MEMORY_MMAP = 1,
60 CSC_MEMORY_USERPTR,
61 CSC_MEMORY_OVERLAY,
62 CSC_MEMORY_DMABUF,
63 CSC_MEMORY_MFC,
64} CSC_MEMTYPE;
65
66typedef enum _CSC_HW_ID {
67 CSC_HW_GSC0 = 0,
68 CSC_HW_GSC1,
69 CSC_HW_GSC2,
70 CSC_HW_GSC3,
71 CSC_HW_SC0,
72 CSC_HW_SC1,
73 CSC_HW_SC2,
74 CSC_HW_MAX,
75} CSC_HW_ID;
76
77typedef enum _CSC_PLANE {
78 CSC_Y_PLANE = 0,
79 CSC_RGB_PLANE = 0,
80 CSC_U_PLANE = 1,
81 CSC_UV_PLANE = 1,
82 CSC_V_PLANE = 2
83} CSC_PLANE;
84
85typedef enum _CSC_HW_TYPE {
86 CSC_HW_TYPE_FIMC = 0,
87 CSC_HW_TYPE_GSCALER
88} CSC_HW_TYPE;
89
90typedef enum _CSC_EQ_MODE {
91 CSC_EQ_MODE_USER = 0,
92 CSC_EQ_MODE_AUTO
93} CSC_EQ_MODE;
94
95typedef enum _CSC_EQ_COLORSPACE {
96 CSC_EQ_COLORSPACE_SMPTE170M = 1,
97 CSC_EQ_COLORSPACE_SMPTE240M,
98 CSC_EQ_COLORSPACE_REC709,
99 CSC_EQ_COLORSPACE_BT878,
100 CSC_EQ_COLORSPACE_470_SYSTEM_M,
101 CSC_EQ_COLORSPACE_470_SYSTEM_BG
102} CSC_EQ_COLORSPACE;
103
104typedef enum _CSC_EQ_RANGE {
105 CSC_EQ_RANGE_NARROW = 0,
106 CSC_EQ_RANGE_FULL
107} CSC_EQ_RANGE;
108
109typedef enum _CSC_HW_FILTER {
110 CSC_FT_NONE = 0,
111 CSC_FT_BLUR,
112 CSC_FT_240,
113 CSC_FT_480,
114 CSC_FT_720,
115 CSC_FT_1080,
116 CSC_FT_MAX
117} CSC_HW_FILTER;
118
119typedef struct _CSC_FORMAT {
120 unsigned int width;
121 unsigned int height;
122 unsigned int crop_left;
123 unsigned int crop_top;
124 unsigned int crop_width;
125 unsigned int crop_height;
126 unsigned int color_format;
127 unsigned int cacheable;
128 unsigned int mode_drm;
129} CSC_FORMAT;
130
131typedef struct _CSC_BUFFER {
132 void *planes[CSC_MAX_PLANES];
133 int mem_type;
134} CSC_BUFFER;
135
136typedef struct _CSC_HW_PROPERTY {
137 int fixed_node;
138 int mode_drm;
139} CSC_HW_PROPERTY;
140
141typedef struct _CSC_HANDLE {
142 CSC_FORMAT dst_format;
143 CSC_FORMAT src_format;
144 CSC_BUFFER dst_buffer;
145 CSC_BUFFER src_buffer;
146 CSC_METHOD csc_method;
147 CSC_HW_TYPE csc_hw_type;
148 void *csc_hw_handle;
149 CSC_HW_PROPERTY hw_property;
150
151 /* CSC Equation */
152 CSC_EQ_MODE csc_mode;
153 CSC_EQ_RANGE csc_range;
154 CSC_EQ_COLORSPACE colorspace;
155
156 /* Denoising filter */
157 CSC_HW_FILTER filter;
158} CSC_HANDLE;
159
160/*
161 * change hal pixel format to omx pixel format
162 *
163 * @param hal_format
164 * hal pixel format[in]
165 *
166 * @return
167 * omx pixel format
168 */
169unsigned int hal_2_omx_pixel_format(
170 unsigned int hal_format);
171
172/*
173 * change omx pixel format to hal pixel format
174 *
175 * @param hal_format
176 * omx pixel format[in]
177 *
178 * @return
179 * hal pixel format
180 */
181unsigned int omx_2_hal_pixel_format(
182 unsigned int omx_format);
183
184/*
185 * Init CSC handle
186 *
187 * @return
188 * csc handle
189 */
190void *csc_init(
191 CSC_METHOD method);
192
193/*
194 * Deinit CSC handle
195 *
196 * @param handle
197 * CSC handle[in]
198 *
199 * @return
200 * error code
201 */
202CSC_ERRORCODE csc_deinit(
203 void *handle);
204
205/*
206 * get color space converter method
207 *
208 * @param handle
209 * CSC handle[in]
210 *
211 * @param method
212 * CSC method[out]
213 *
214 * @return
215 * error code
216 */
217CSC_ERRORCODE csc_get_method(
218 void *handle,
219 CSC_METHOD *method);
220
221/*
222 * set color space converter method
223 *
224 * @param handle
225 * CSC handle[in]
226 *
227 * @param method
228 * CSC method[in]
229 *
230 * @return
231 * error code
232 */
233CSC_ERRORCODE csc_set_method(
234 void *handle,
235 CSC_METHOD method);
236
237/*
238 * Set hw property
239 *
240 * @param handle
241 * CSC handle[in]
242 *
243 * @param property
244 * csc hw property[in]
245 *
246 * @param value
247 * csc hw property value[in]
248 *
249 * @return
250 * csc handle
251 */
252CSC_ERRORCODE csc_set_hw_property(
253 void *handle,
254 CSC_HW_PROPERTY_TYPE property,
255 int value);
256
257/*
258 * Get csc equation property.
259 *
260 * @param handle
261 * CSC handle[in]
262 *
263 * @param mode
264 * csc equation mode[out]
265 *
266 * @param colorspace
267 * csc color space[out]
268 *
269 * @param range
270 * csc equation range[out]
271 *
272 * @return
273 * error code
274 */
275CSC_ERRORCODE csc_get_eq_property(
276 void *handle,
277 CSC_EQ_MODE *csc_mode,
278 CSC_EQ_RANGE *csc_range,
279 CSC_EQ_COLORSPACE *colorspace);
280
281/*
282 * Set csc equation property.
283 *
284 * @param handle
285 * CSC handle[in]
286 *
287 * @param mode
288 * csc equation mode[in]
289 *
290 * @param colorspace
291 * csc color space[in]
292 *
293 * @param range
294 * csc equation range[in]
295 *
296 * @return
297 * error code
298 */
299CSC_ERRORCODE csc_set_eq_property(
300 void *handle,
301 CSC_EQ_MODE csc_mode,
302 CSC_EQ_RANGE csc_range,
303 CSC_EQ_COLORSPACE colorspace);
304
305/*
306 * Set csc filter property.
307 *
308 * @param handle
309 * CSC handle[in]
310 *
311 * @param filter
312 * csc filter info[in]
313 *
314 * @return
315 * error code
316 */
317CSC_ERRORCODE csc_set_filter_property(
318 void *handle,
319 CSC_HW_FILTER filter);
320
321/*
322 * Get source format.
323 *
324 * @param handle
325 * CSC handle[in]
326 *
327 * @param width
328 * address of image width[out]
329 *
330 * @param height
331 * address of image height[out]
332 *
333 * @param crop_left
334 * address of image left crop size[out]
335 *
336 * @param crop_top
337 * address of image top crop size[out]
338 *
339 * @param crop_width
340 * address of cropped image width[out]
341 *
342 * @param crop_height
343 * address of cropped image height[out]
344 *
345 * @param color_format
346 * address of source color format(HAL format)[out]
347 *
348 * @return
349 * error code
350 */
351CSC_ERRORCODE csc_get_src_format(
352 void *handle,
353 unsigned int *width,
354 unsigned int *height,
355 unsigned int *crop_left,
356 unsigned int *crop_top,
357 unsigned int *crop_width,
358 unsigned int *crop_height,
359 unsigned int *color_format,
360 unsigned int *cacheable);
361
362/*
363 * Set source format.
364 * Don't call each converting time.
365 * Pls call this function as below.
366 * 1. first converting time
367 * 2. format is changed
368 *
369 * @param handle
370 * CSC handle[in]
371 *
372 * @param width
373 * image width[in]
374 *
375 * @param height
376 * image height[in]
377 *
378 * @param crop_left
379 * image left crop size[in]
380 *
381 * @param crop_top
382 * image top crop size[in]
383 *
384 * @param crop_width
385 * cropped image width[in]
386 *
387 * @param crop_height
388 * cropped image height[in]
389 *
390 * @param color_format
391 * source color format(HAL format)[in]
392 *
393 * @return
394 * error code
395 */
396CSC_ERRORCODE csc_set_src_format(
397 void *handle,
398 unsigned int width,
399 unsigned int height,
400 unsigned int crop_left,
401 unsigned int crop_top,
402 unsigned int crop_width,
403 unsigned int crop_height,
404 unsigned int color_format,
405 unsigned int cacheable);
406
407/*
408 * Get destination format.
409 *
410 * @param handle
411 * CSC handle[in]
412 *
413 * @param width
414 * address of image width[out]
415 *
416 * @param height
417 * address of image height[out]
418 *
419 * @param crop_left
420 * address of image left crop size[out]
421 *
422 * @param crop_top
423 * address of image top crop size[out]
424 *
425 * @param crop_width
426 * address of cropped image width[out]
427 *
428 * @param crop_height
429 * address of cropped image height[out]
430 *
431 * @param color_format
432 * address of color format(HAL format)[out]
433 *
434 * @return
435 * error code
436 */
437CSC_ERRORCODE csc_get_dst_format(
438 void *handle,
439 unsigned int *width,
440 unsigned int *height,
441 unsigned int *crop_left,
442 unsigned int *crop_top,
443 unsigned int *crop_width,
444 unsigned int *crop_height,
445 unsigned int *color_format,
446 unsigned int *cacheable);
447
448/*
449 * Set destination format
450 * Don't call each converting time.
451 * Pls call this function as below.
452 * 1. first converting time
453 * 2. format is changed
454 *
455 * @param handle
456 * CSC handle[in]
457 *
458 * @param width
459 * image width[in]
460 *
461 * @param height
462 * image height[in]
463 *
464 * @param crop_left
465 * image left crop size[in]
466 *
467 * @param crop_top
468 * image top crop size[in]
469 *
470 * @param crop_width
471 * cropped image width[in]
472 *
473 * @param crop_height
474 * cropped image height[in]
475 *
476 * @param color_format
477 * destination color format(HAL format)[in]
478 *
479 * @return
480 * error code
481 */
482CSC_ERRORCODE csc_set_dst_format(
483 void *handle,
484 unsigned int width,
485 unsigned int height,
486 unsigned int crop_left,
487 unsigned int crop_top,
488 unsigned int crop_width,
489 unsigned int crop_height,
490 unsigned int color_format,
491 unsigned int cacheable);
492
493/*
494 * Setup source buffer
495 * set_format func should be called before this this func.
496 *
497 * @param handle
498 * CSC handle[in]
499 *
500 * @param src_buffer
501 * source buffer pointer array[in]
502 *
503 * @param y
504 * y or RGB destination pointer[in]
505 *
506 * @param u
507 * u or uv destination pointer[in]
508 *
509 * @param v
510 * v or none destination pointer[in]
511 *
512 * @return
513 * error code
514 */
515CSC_ERRORCODE csc_set_src_buffer(
516 void *handle,
517 void *addr[CSC_MAX_PLANES],
518 int mem_type);
519
520/*
521 * Setup destination buffer
522 *
523 * @param handle
524 * CSC handle[in]
525 *
526 * @param y
527 * y or RGB destination pointer[in]
528 *
529 * @param u
530 * u or uv destination pointer[in]
531 *
532 * @param v
533 * v or none destination pointer[in]
534 *
535 * @return
536 * error code
537 */
538CSC_ERRORCODE csc_set_dst_buffer(
539 void *handle,
540 void *addr[CSC_MAX_PLANES],
541 int mem_type);
542
543/*
544 * Convert color space with presetup color format
545 *
546 * @param handle
547 * CSC handle[in]
548 *
549 * @return
550 * error code
551 */
552CSC_ERRORCODE csc_convert(
553 void *handle);
554
555CSC_ERRORCODE csc_convert_with_rotation(
556 void *handle, int rotation, int flip_horizontal, int flip_vertical);
557
558#ifdef __cplusplus
559}
560#endif
561
562#endif