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