libhwjpeg: resolve compilation errors
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / include / exynos_gscaler.h
1 /*
2 *
3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*!
19 * \file exynos_gscaler.h
20 * \brief header file for Gscaler HAL
21 * \author ShinWon Lee (shinwon.lee@samsung.com)
22 * \date 2012/01/09
23 *
24 * <b>Revision History: </b>
25 * - 2012/01/09 : ShinWon Lee(shinwon.lee@samsung.com) \n
26 * Create
27 *
28 * - 2012/02/07 : ShinWon Lee(shinwon.lee@samsung.com) \n
29 * Change file name to exynos_gscaler.h
30 *
31 * - 2012/02/09 : Sangwoo, Parkk(sw5771.park@samsung.com) \n
32 * Use Multiple Gscaler by Multiple Process
33 *
34 * - 2012/02/20 : Sangwoo, Park(sw5771.park@samsung.com) \n
35 * Add exynos_gsc_set_rotation() API
36 *
37 * - 2012/02/20 : ShinWon Lee(shinwon.lee@samsung.com) \n
38 * Add size constrain
39 *
40 */
41
42 /*!
43 * \defgroup exynos_gscaler
44 * \brief API for gscaler
45 * \addtogroup Exynos
46 */
47 #include "Exynos_log.h"
48
49 #ifndef EXYNOS_GSCALER_H_
50 #define EXYNOS_GSCALER_H_
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 //#define EXYNOS_GSC_TRACE 1
57 #ifdef EXYNOS_GSC_TRACE
58 #define EXYNOS_GSC_LOG_TAG "Exynos_gscaler"
59 #define Exynos_gsc_In() Exynos_Log(EXYNOS_DEV_LOG_DEBUG, EXYNOS_GSC_LOG_TAG, "%s In , Line: %d", __FUNCTION__, __LINE__)
60 #define Exynos_gsc_Out() Exynos_Log(EXYNOS_DEV_LOG_DEBUG, EXYNOS_GSC_LOG_TAG, "%s Out , Line: %d", __FUNCTION__, __LINE__)
61 #else
62 #define Exynos_gsc_In() ((void *)0)
63 #define Exynos_gsc_Out() ((void *)0)
64 #endif
65
66 typedef struct {
67 uint32_t x;
68 uint32_t y;
69 uint32_t w;
70 uint32_t h;
71 uint32_t fw;
72 uint32_t fh;
73 uint32_t format;
74 unsigned long yaddr;
75 unsigned long uaddr;
76 unsigned long vaddr;
77 uint32_t rot;
78 uint32_t cacheable;
79 uint32_t drmMode;
80 uint32_t narrowRgb;
81 int acquireFenceFd;
82 int releaseFenceFd;
83 int mem_type;
84 uint32_t pre_multi;
85 #ifdef USES_VR_FRONT_BUFFER
86 uint32_t use_sync;
87 #endif
88 } exynos_mpp_img;
89
90 enum SRC_BL_OP {
91 /* [0, 0] */
92 SRC_BL_OP_CLR = 1,
93 /* [Sa, Sc] */
94 SRC_BL_OP_SRC,
95 /* [Da, Dc] */
96 SRC_BL_OP_DST,
97 /* [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] */
98 SRC_BL_OP_SRC_OVER,
99 /* [Sa + (1 - Sa)*Da, Rc = Dc + (1 - Da)*Sc] */
100 SRC_BL_OP_DST_OVER,
101 /* [Sa * Da, Sc * Da] */
102 SRC_BL_OP_SRC_IN,
103 /* [Sa * Da, Sa * Dc] */
104 SRC_BL_OP_DST_IN,
105 /* [Sa * (1 - Da), Sc * (1 - Da)] */
106 SRC_BL_OP_SRC_OUT,
107 /* [Da * (1 - Sa), Dc * (1 - Sa)] */
108 SRC_BL_OP_DST_OUT,
109 /* [Da, Sc * Da + (1 - Sa) * Dc] */
110 SRC_BL_OP_SRC_ATOP,
111 /* [Sa, Sc * (1 - Da) + Sa * Dc ] */
112 SRC_BL_OP_DST_ATOP,
113 /* [-(Sa * Da), Sc * (1 - Da) + (1 - Sa) * Dc] */
114 SRC_BL_OP_XOR,
115 /* [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + min(Sc, Dc)] */
116 SRC_BL_OP_DARKEN,
117 /* [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)] */
118 SRC_BL_OP_LIGHTEN,
119 /** [Sa * Da, Sc * Dc] */
120 SRC_BL_OP_MULTIPLY,
121 /* [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] */
122 SRC_BL_OP_SCREEN,
123 /* Saturate(S + D) */
124 SRC_BL_OP_ADD
125 };
126
127 enum colorspace {
128 COLORSPACE_SMPTE170M,
129 COLORSPACE_SMPTE240M,
130 COLORSPACE_REC709,
131 COLORSPACE_BT878,
132 COLORSPACE_470_SYSTEM_M,
133 COLORSPACE_470_SYSTEM_BG,
134 COLORSPACE_JPEG,
135 COLORSPACE_SRGB,
136 };
137
138 struct SrcGlobalAlpha {
139 uint32_t enable;
140 unsigned int val;
141 };
142
143 struct CSC_Spec{
144 uint32_t enable; // set 'true' for user-defined
145 enum colorspace space;
146 uint32_t wide;
147 };
148
149 struct SrcBlendInfo {
150 enum SRC_BL_OP blop;
151 unsigned int srcblendfmt;
152 unsigned int srcblendhpos;
153 unsigned int srcblendvpos;
154 unsigned int srcblendpremulti;
155 unsigned int srcblendstride;
156 unsigned int srcblendwidth;
157 unsigned int srcblendheight;
158 struct SrcGlobalAlpha globalalpha;
159 struct CSC_Spec cscspec;
160 };
161
162 /*
163 * Create libgscaler handle.
164 * Gscaler dev_num is dynamically changed.
165 *
166 * \ingroup exynos_gscaler
167 *
168 * \return
169 * libgscaler handle
170 */
171 void *exynos_gsc_create(
172 void);
173
174 /*!
175 * Create exclusive libgscaler handle.
176 * Other module can't use dev_num of Gscaler.
177 *
178 * \ingroup exynos_gscaler
179 *
180 * \param dev_num
181 * gscaler dev_num[in]
182 * \param gsc_mode
183 *It should be set to GSC_M2M_MODE or GSC_OUTPUT_MODE.
184 *
185 *\param out_mode
186 *It should be set to GSC_OUT_FIMD or GSC_OUT_TV.
187 *
188 * \return
189 * libgscaler handle
190 */
191 void *exynos_gsc_create_exclusive(
192 int dev_num,
193 int gsc_mode,
194 int out_mode,
195 int allow_drm);
196
197 /*!
198 * Destroy libgscaler handle
199 *
200 * \ingroup exynos_gscaler
201 *
202 * \param handle
203 * libgscaler handle[in]
204 */
205 void exynos_gsc_destroy(
206 void *handle);
207
208 /*!
209 * Set csc equation property
210 *
211 * \ingroup exynos_gscaler
212 *
213 * \param handle
214 * libgscaler handle[in]
215 *
216 * \param eq_auto
217 * csc mode (0: user, 1: auto)[in]
218 *
219 * \param range_full
220 * csc range (0: narrow, 1: full)[in]
221 *
222 * \param v4l2_colorspace
223 * ITU_R v4l2 colorspace(1: 601, 3: 709)[in]
224 */
225 int exynos_gsc_set_csc_property(
226 void *handle,
227 unsigned int eq_auto,
228 unsigned int range_full,
229 unsigned int v4l2_colorspace);
230
231 /*!
232 * Set source format.
233 *
234 * \ingroup exynos_gscaler
235 *
236 * \param handle
237 * libgscaler handle[in]
238 *
239 * \param width
240 * image width[in]
241 *
242 * \param height
243 * image height[in]
244 *
245 * \param crop_left
246 * image left crop size[in]
247 *
248 * \param crop_top
249 * image top crop size[in]
250 *
251 * \param crop_width
252 * cropped image width[in]
253 *
254 * \param crop_height
255 * cropped image height[in]
256 *
257 * \param v4l2_colorformat
258 * color format[in]
259 *
260 * \param cacheable
261 * ccacheable[in]
262 *
263 * \param mode_drm
264 * mode_drm[in]
265 *
266 * \return
267 * error code
268 */
269 int exynos_gsc_set_src_format(
270 void *handle,
271 unsigned int width,
272 unsigned int height,
273 unsigned int crop_left,
274 unsigned int crop_top,
275 unsigned int crop_width,
276 unsigned int crop_height,
277 unsigned int v4l2_colorformat,
278 unsigned int cacheable,
279 unsigned int mode_drm);
280
281 /*!
282 * Set destination format.
283 *
284 * \ingroup exynos_gscaler
285 *
286 * \param handle
287 * libgscaler handle[in]
288 *
289 * \param width
290 * image width[in]
291 *
292 * \param height
293 * image height[in]
294 *
295 * \param crop_left
296 * image left crop size[in]
297 *
298 * \param crop_top
299 * image top crop size[in]
300 *
301 * \param crop_width
302 * cropped image width[in]
303 *
304 * \param crop_height
305 * cropped image height[in]
306 *
307 * \param v4l2_colorformat
308 * color format[in]
309 *
310 * \param cacheable
311 * ccacheable[in]
312 *
313 * \param mode_drm
314 * mode_drm[in]
315 *
316 * \return
317 * error code
318 */
319 int exynos_gsc_set_dst_format(
320 void *handle,
321 unsigned int width,
322 unsigned int height,
323 unsigned int crop_left,
324 unsigned int crop_top,
325 unsigned int crop_width,
326 unsigned int crop_height,
327 unsigned int v4l2_colorformat,
328 unsigned int cacheable,
329 unsigned int mode_drm);
330
331 /*!
332 * Set rotation.
333 *
334 * \ingroup exynos_gscaler
335 *
336 * \param handle
337 * libgscaler handle[in]
338 *
339 * \param rotation
340 * image rotation. It should be multiple of 90[in]
341 *
342 * \param flip_horizontal
343 * image flip_horizontal[in]
344 *
345 * \param flip_vertical
346 * image flip_vertical[in]
347 *
348 * \return
349 * error code
350 */
351 int exynos_gsc_set_rotation(
352 void *handle,
353 int rotation,
354 int flip_horizontal,
355 int flip_vertical);
356
357 /*!
358 * Set source buffer
359 *
360 * \ingroup exynos_gscaler
361 *
362 * \param handle
363 * libgscaler handle[in]
364 *
365 * \param addr
366 * buffer pointer array[in]
367 *
368 * \param acquireFenceFd
369 * acquire fence fd for the buffer or -1[in]
370 *
371 * \return
372 * error code
373 */
374 int exynos_gsc_set_src_addr(
375 void *handle,
376 void *addr[3],
377 int mem_type,
378 int acquireFenceFd);
379
380 /*!
381 * Set destination buffer
382 *
383 * \param handle
384 * libgscaler handle[in]
385 *
386 * \param addr
387 * buffer pointer array[in]
388 *
389 * \param acquireFenceFd
390 * acquire fence fd for the buffer or -1[in]
391 *
392 * \return
393 * error code
394 */
395 int exynos_gsc_set_dst_addr(
396 void *handle,
397 void *addr[3],
398 int mem_type,
399 int acquireFenceFd);
400
401 /*!
402 * Convert color space with presetup color format
403 *
404 * \ingroup exynos_gscaler
405 *
406 * \param handle
407 * libgscaler handle[in]
408 *
409 * \return
410 * error code
411 */
412 int exynos_gsc_convert(
413 void *handle);
414
415 /*
416 * API for setting GSC subdev crop
417 * Used in OTF mode
418 */
419 int exynos_gsc_subdev_s_crop(
420 void *handle,
421 exynos_mpp_img *src_img,
422 exynos_mpp_img *dst_img);
423
424 /*
425 *api for setting the GSC config.
426 It configures the GSC for given config
427 */
428 int exynos_gsc_config_exclusive(
429 void *handle,
430 exynos_mpp_img *src_img,
431 exynos_mpp_img *dst_img);
432
433 /*
434 *api for GSC-OUT run.
435 It queues the srcBuf to GSC and deques a buf from driver.
436 It should be called after configuring the GSC.
437 */
438 int exynos_gsc_run_exclusive(
439 void *handle,
440 exynos_mpp_img *src_img,
441 exynos_mpp_img *dst_img);
442
443 /*!
444 * Create exclusive libgscaler blend handle.
445 * Other module can't use dev_num of Gscaler.
446 *
447 * \ingroup exynos_gscaler
448 *
449 * \param dev_num
450 * gscaler dev_num[in]
451 * \param gsc_mode
452 * \return
453 * libgscaler handle
454 */
455 void *exynos_gsc_create_blend_exclusive(
456 int dev_num,
457 int gsc_mode,
458 int out_mode,
459 int allow_drm);
460
461 /*
462 *api for setting the GSC blend config.
463 It configures the GSC for given config
464 */
465 int exynos_gsc_config_blend_exclusive(
466 void *handle,
467 exynos_mpp_img *src_img,
468 exynos_mpp_img *dst_img,
469 struct SrcBlendInfo *srcblendinfo);
470
471 /*
472 * Blocks until the current frame is done processing.
473 */
474 int exynos_gsc_wait_frame_done_exclusive
475 (void *handle);
476
477 /*
478 *api for GSC stop.
479 It stops the GSC OUT streaming.
480 */
481 int exynos_gsc_stop_exclusive
482 (void *handle);
483
484 /*
485 *api for GSC free_and_close.
486 */
487 int exynos_gsc_free_and_close
488 (void *handle);
489
490 enum {
491 GSC_M2M_MODE = 0,
492 GSC_OUTPUT_MODE,
493 GSC_CAPTURE_MODE,
494 GSC_RESERVED_MODE,
495 };
496
497 /*flag info */
498 enum {
499 GSC_DUMMY = 0,
500 GSC_OUT_FIMD,
501 GSC_OUT_TV,
502 GSC_RESERVED,
503 };
504
505 enum {
506 GSC_DONE_CNG_CFG = 0,
507 GSC_NEED_CNG_CFG,
508 };
509
510 enum {
511 GSC_MEM_MMAP = 1,
512 GSC_MEM_USERPTR,
513 GSC_MEM_OVERLAY,
514 GSC_MEM_DMABUF,
515 };
516
517 #ifdef __cplusplus
518 }
519 #endif
520
521 #endif /*EXYNOS_GSCALER_H_*/