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
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 */
67unsigned 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 */
79unsigned int omx_2_hal_pixel_format(
80    unsigned int omx_format);
81
82/*
83 * Init CSC handle
84 *
85 * @return
86 *   csc handle
87 */
88void *csc_init(
89    CSC_METHOD method);
90
91/*
92 * Deinit CSC handle
93 *
94 * @param handle
95 *   CSC handle[in]
96 *
97 * @return
98 *   error code
99 */
100CSC_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 */
115CSC_ERRORCODE csc_get_method(
116    void           *handle,
117    CSC_METHOD     *method);
118
119/*
120 * Set hw property
121 *
122 * @param handle
123 *   CSC handle[in]
124 *
125 * @param property
126 *   csc hw property[in]
127 *
128 * @param value
129 *   csc hw property value[in]
130 *
131 * @return
132 *   csc handle
133 */
134CSC_ERRORCODE csc_set_hw_property(
135    void                *handle,
136    CSC_HW_PROPERTY_TYPE property,
137    int                  value);
138
139/*
140 * Get source format.
141 *
142 * @param handle
143 *   CSC handle[in]
144 *
145 * @param width
146 *   address of image width[out]
147 *
148 * @param height
149 *   address of image height[out]
150 *
151 * @param crop_left
152 *   address of image left crop size[out]
153 *
154 * @param crop_top
155 *   address of image top crop size[out]
156 *
157 * @param crop_width
158 *   address of cropped image width[out]
159 *
160 * @param crop_height
161 *   address of cropped image height[out]
162 *
163 * @param color_format
164 *   address of source color format(HAL format)[out]
165 *
166 * @return
167 *   error code
168 */
169CSC_ERRORCODE csc_get_src_format(
170    void           *handle,
171    unsigned int   *width,
172    unsigned int   *height,
173    unsigned int   *crop_left,
174    unsigned int   *crop_top,
175    unsigned int   *crop_width,
176    unsigned int   *crop_height,
177    unsigned int   *color_format,
178    unsigned int   *cacheable);
179
180/*
181 * Set source format.
182 * Don't call each converting time.
183 * Pls call this function as below.
184 *   1. first converting time
185 *   2. format is changed
186 *
187 * @param handle
188 *   CSC handle[in]
189 *
190 * @param width
191 *   image width[in]
192 *
193 * @param height
194 *   image height[in]
195 *
196 * @param crop_left
197 *   image left crop size[in]
198 *
199 * @param crop_top
200 *   image top crop size[in]
201 *
202 * @param crop_width
203 *   cropped image width[in]
204 *
205 * @param crop_height
206 *   cropped image height[in]
207 *
208 * @param color_format
209 *   source color format(HAL format)[in]
210 *
211 * @return
212 *   error code
213 */
214CSC_ERRORCODE csc_set_src_format(
215    void           *handle,
216    unsigned int    width,
217    unsigned int    height,
218    unsigned int    crop_left,
219    unsigned int    crop_top,
220    unsigned int    crop_width,
221    unsigned int    crop_height,
222    unsigned int    color_format,
223    unsigned int    cacheable);
224
225/*
226 * Get destination format.
227 *
228 * @param handle
229 *   CSC handle[in]
230 *
231 * @param width
232 *   address of image width[out]
233 *
234 * @param height
235 *   address of image height[out]
236 *
237 * @param crop_left
238 *   address of image left crop size[out]
239 *
240 * @param crop_top
241 *   address of image top crop size[out]
242 *
243 * @param crop_width
244 *   address of cropped image width[out]
245 *
246 * @param crop_height
247 *   address of cropped image height[out]
248 *
249 * @param color_format
250 *   address of color format(HAL format)[out]
251 *
252 * @return
253 *   error code
254 */
255CSC_ERRORCODE csc_get_dst_format(
256    void           *handle,
257    unsigned int   *width,
258    unsigned int   *height,
259    unsigned int   *crop_left,
260    unsigned int   *crop_top,
261    unsigned int   *crop_width,
262    unsigned int   *crop_height,
263    unsigned int   *color_format,
264    unsigned int   *cacheable);
265
266/*
267 * Set destination format
268 * Don't call each converting time.
269 * Pls call this function as below.
270 *   1. first converting time
271 *   2. format is changed
272 *
273 * @param handle
274 *   CSC handle[in]
275 *
276 * @param width
277 *   image width[in]
278 *
279 * @param height
280 *   image height[in]
281 *
282 * @param crop_left
283 *   image left crop size[in]
284 *
285 * @param crop_top
286 *   image top crop size[in]
287 *
288 * @param crop_width
289 *   cropped image width[in]
290 *
291 * @param crop_height
292 *   cropped image height[in]
293 *
294 * @param color_format
295 *   destination color format(HAL format)[in]
296 *
297 * @return
298 *   error code
299 */
300CSC_ERRORCODE csc_set_dst_format(
301    void           *handle,
302    unsigned int    width,
303    unsigned int    height,
304    unsigned int    crop_left,
305    unsigned int    crop_top,
306    unsigned int    crop_width,
307    unsigned int    crop_height,
308    unsigned int    color_format,
309    unsigned int    cacheable);
310
311/*
312 * Setup source buffer
313 * set_format func should be called before this this func.
314 *
315 * @param handle
316 *   CSC handle[in]
317 *
318 * @param src_buffer
319 *   source buffer pointer array[in]
320 *
321 * @param y
322 *   y or RGB destination pointer[in]
323 *
324 * @param u
325 *   u or uv destination pointer[in]
326 *
327 * @param v
328 *   v or none destination pointer[in]
329 *
330 * @return
331 *   error code
332 */
333CSC_ERRORCODE csc_set_src_buffer(
334    void *handle,
335    void *addr[CSC_MAX_PLANES]);
336
337/*
338 * Setup destination buffer
339 *
340 * @param handle
341 *   CSC handle[in]
342 *
343 * @param y
344 *   y or RGB destination pointer[in]
345 *
346 * @param u
347 *   u or uv destination pointer[in]
348 *
349 * @param v
350 *   v or none destination pointer[in]
351 *
352 * @return
353 *   error code
354 */
355CSC_ERRORCODE csc_set_dst_buffer(
356    void *handle,
357    void *addr[CSC_MAX_PLANES]);
358
359/*
360 * Convert color space with presetup color format
361 *
362 * @param handle
363 *   CSC handle[in]
364 *
365 * @return
366 *   error code
367 */
368CSC_ERRORCODE csc_convert(
369    void *handle);
370
371#ifdef __cplusplus
372}
373#endif
374
375#endif
376