libhwjpeg: resolve compilation errors
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / include / exynos_blender.h
1 /*
2 * Copyright (C) 2013 The Android Open Source Project
3 * Copyright@ Samsung Electronics 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_blender.h
20 * \brief User's API for Exynos Blender library
21 * \author Eunseok Choi (es10.choi@samsung.com)
22 * \date 2013/09/21
23 *
24 * <b>Revision History: </b>
25 * - 2013.09.21 : Eunseok Choi (eunseok.choi@samsung.com) \n
26 * Create
27 *
28 */
29 #ifndef __EXYNOS_BLENDER_H__
30 #define __EXYNOS_BLENDER_H__
31
32 #include <linux/videodev2.h>
33
34 #define BL_MAX_PLANES 3
35
36 enum BL_DEVID {
37 DEV_UNSPECIFIED = 0,
38 DEV_G2D0, DEVID_G2D_END,
39 };
40
41 enum BL_OP_TYPE {
42 OP_SRC = 2,
43 OP_SRC_OVER = 4
44 };
45
46 enum BL_ROTATE {
47 ORIGIN,
48 ROT90 = 90,
49 ROT180 = 180,
50 ROT270 = 270
51 };
52
53 enum BL_SCALE {
54 NOSCALE,
55 NEAREST,
56 BILINEAR,
57 POLYPHASE
58 };
59
60 enum BL_REPEAT {
61 NOREPEAT,
62 NORMAL,
63 MIRROR = 3,
64 REFLECT = MIRROR,
65 CLAMP
66 };
67
68 enum BL_BLUESCREEN {
69 OPAQUE,
70 //! transparent mode. need bgcolor
71 TRANSP,
72 //! bluescreen mode. need bgcolor and bscolor
73 BLUSCR
74 };
75
76 struct bl_property {
77 enum BL_DEVID devid;
78 //! true: device open with NONBLOCK flag.
79 bool nonblock;
80 };
81
82 typedef void *bl_handle_t;
83
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87
88 /*!
89 * Create exynos_blender handle
90 *
91 * \ingroup exynos_blender
92 *
93 * \param prop
94 * blender property[in]
95 *
96 * \return
97 * exynos_blender handle
98 */
99 bl_handle_t exynos_bl_create(struct bl_property *prop);
100
101 /*!
102 * Destroy exynos_blender handle
103 *
104 * \ingroup exynos_blender
105 *
106 * \param handle
107 * exynos_blender handle[in]
108 */
109 void exynos_bl_destroy(bl_handle_t handle);
110
111 /*!
112 * Deactivate exynos_blender: g2d-specific for drm
113 *
114 * \ingroup exynos_blender
115 *
116 * \param handle
117 * exynos_blender handle[in]
118 *
119 * \param deact
120 * true: deactivate, false: activated (default)
121 *
122 * \return
123 * error code
124 */
125 int exynos_bl_deactivate(bl_handle_t handle, bool deact);
126
127 /*!
128 * Set color fill mode and src color
129 *
130 * \ingroup exynos_blender
131 *
132 * \param handle
133 * exynos_blender handle[in]
134 *
135 * \param enable
136 * true: color fill mode.
137 * if true, src_addr & src_format is ignored.
138 *
139 * \param color_argb8888
140 * 32-bit color value, 'a' is msb.
141 *
142 * \return
143 * error code
144 */
145 int exynos_bl_set_color_fill(
146 bl_handle_t handle,
147 bool enable,
148 uint32_t color_argb8888);
149
150 /*!
151 * Set rotate and flip
152 *
153 * \ingroup exynos_blender
154 *
155 * \param handle
156 * exynos_blender handle[in]
157 *
158 * \param rot
159 * 90/180/270: clockwise degree
160 *
161 * \param hflip
162 * true: hoizontal(y-axis) flip
163 *
164 * \param vflip
165 * true: vertical(x-axis) flip
166 *
167 * \return
168 * error code
169 */
170 int exynox_bl_set_rotate(
171 bl_handle_t handle,
172 enum BL_ROTATE rot,
173 bool hflip,
174 bool vflip);
175
176 /*!
177 * Set blend op mode
178 *
179 * \ingroup exynos_blender
180 *
181 * \param handle
182 * exynos_blender handle[in]
183 *
184 * \param op
185 * 2: SRC COPY (default), 4: SRC OVER
186 *
187 * \param premultiplied
188 * true: alpha premultiplied mode for src and dst
189 *
190 * \return
191 * error code
192 */
193 int exynos_bl_set_blend(
194 bl_handle_t handle,
195 enum BL_OP_TYPE op,
196 bool premultiplied);
197
198 /*!
199 * Set global alpha value
200 *
201 * \ingroup exynos_blender
202 *
203 * \param handle
204 * exynos_blender handle[in]
205 *
206 * \param enable
207 *
208 * \param g_alpha
209 * range: 0x0~0xff.
210 * 0x0 for transpranet, 0xff for opaque. (default '0xff')
211 *
212 * \return
213 * error code
214 */
215 int exynos_bl_set_galpha(
216 bl_handle_t handle,
217 bool enable,
218 unsigned char g_alpha);
219
220 /*!
221 * Set dither
222 *
223 * \ingroup exynos_blender
224 *
225 * \param handle
226 * exynos_blender handle[in]
227 *
228 * \param enable
229 * true: enable dithering effect
230 *
231 * \return
232 * error code
233 */
234 int exynos_bl_set_dither(bl_handle_t handle, bool enable);
235
236 /*!
237 * Set scaling ratio
238 *
239 * \ingroup exynos_blender
240 *
241 * \param handle
242 * exynos_blender handle[in]
243 *
244 * \param mode
245 * 1: nearest, 2: bilinear, 3: polyphase
246 *
247 * \param src_w
248 * src width in pixels of horizontal scale ratio
249 *
250 * \param dst_w
251 * dst width in pixels of horizontal scale ratio
252 *
253 * \param src_h
254 * src height in pixels of vertical scale ratio
255 *
256 * \param dst_h
257 * dst height in pixels of vertical scale ratio
258 *
259 * \return
260 * error code
261 */
262 int exynos_bl_set_scale(
263 bl_handle_t handle,
264 enum BL_SCALE mode,
265 uint32_t src_w,
266 uint32_t dst_w,
267 uint32_t src_h,
268 uint32_t dst_h);
269
270 /*!
271 * Set repeat mode
272 *
273 * \ingroup exynos_blender
274 *
275 * \param handle
276 * exynos_blender handle[in]
277 *
278 * \param mode
279 * 1: normal, 3: mirror(reflect), 4: clamp
280 *
281 * \return
282 * error code
283 */
284 int exynos_bl_set_repeat(bl_handle_t handle, enum BL_REPEAT mode);
285
286 /*!
287 * Set dst clip rect
288 *
289 * \ingroup exynos_blender
290 *
291 * \param handle
292 * exynos_blender handle[in]
293 *
294 * \param enable
295 * true: clip rect is inside of dst crop rect.
296 *
297 * \param x
298 * clip left
299 *
300 * \param y
301 * clip top
302 *
303 * \param width
304 * clip width
305 *
306 * \param height
307 * clip height
308 *
309 * \return
310 * error code
311 */
312 int exynos_bl_set_clip(
313 bl_handle_t handle,
314 bool enable,
315 uint32_t x,
316 uint32_t y,
317 uint32_t width,
318 uint32_t height);
319
320 /*!
321 * Set colorspace conversion spec
322 *
323 * \ingroup exynos_blender
324 *
325 * \param handle
326 * exynos_blender handle[in]
327 *
328 * \param enable
329 * true: user-defined, false: auto
330 *
331 * \param space
332 * V4L2_COLORSPACE_SMPTE170M: 601, V4L2_COLORSPACE_REC709: 709
333 *
334 * \param wide
335 * true: wide, false: narrow
336 *
337 * \return
338 * error code
339 */
340 int exynos_bl_set_csc_spec(
341 bl_handle_t handle,
342 bool enable,
343 enum v4l2_colorspace space,
344 bool wide);
345
346 /*!
347 * Set src image format
348 *
349 * \ingroup exynos_blender
350 *
351 * \param handle
352 * exynos_blender handle[in]
353 *
354 * \param width
355 * full width in pixels
356 *
357 * \param height
358 * full height in pixels
359 *
360 * \param crop_x
361 * left of src rect
362 *
363 * \param crop_y
364 * top of src rect
365 *
366 * \param crop_width
367 * width of src rect
368 *
369 * \param crop_height
370 * height of src rect
371 *
372 * \return
373 * error code
374 */
375 int exynos_bl_set_src_format(
376 bl_handle_t handle,
377 unsigned int width,
378 unsigned int height,
379 unsigned int crop_x,
380 unsigned int crop_y,
381 unsigned int crop_width,
382 unsigned int crop_height,
383 unsigned int v4l2_colorformat);
384
385 /*!
386 * Set dst image format
387 *
388 * \ingroup exynos_blender
389 *
390 * \param handle
391 * exynos_blender handle[in]
392 *
393 * \param width
394 * full width in pixels
395 *
396 * \param height
397 * full height in pixels
398 *
399 * \param crop_x
400 * left of dst rect
401 *
402 * \param crop_y
403 * top of dst rect
404 *
405 * \param crop_width
406 * width of dst rect
407 *
408 * \param crop_height
409 * height of dst rect
410 *
411 * \return
412 * error code
413 */
414 int exynos_bl_set_dst_format(
415 bl_handle_t handle,
416 unsigned int width,
417 unsigned int height,
418 unsigned int crop_x,
419 unsigned int crop_y,
420 unsigned int crop_width,
421 unsigned int crop_height,
422 unsigned int v4l2_colorformat);
423
424 /*!
425 * Set src buffer
426 *
427 * \ingroup exynos_blender
428 *
429 * \param handle
430 * exynos_blender handle[in]
431 *
432 * \param addr[]
433 * base address: userptr(ion or malloc), ion_fd: dmabuf
434 *
435 * \param type
436 * V4L2_MEMORY_USERPTR: 2, V4L2_MEMORY_DMABUF: 4
437 *
438 * \return
439 * error code
440 */
441 int exynos_bl_set_src_addr(
442 bl_handle_t handle,
443 void *addr[BL_MAX_PLANES],
444 enum v4l2_memory type);
445
446 /*!
447 * Set dst buffer
448 *
449 * \ingroup exynos_blender
450 *
451 * \param handle
452 * exynos_blender handle[in]
453 *
454 * \param addr[]
455 * base address: userptr(ion or malloc), fd: dmabuf(ion)
456 *
457 * \param type
458 * V4L2_MEMORY_USERPTR: 2, V4L2_MEMORY_DMABUF: 4
459 *
460 * \return
461 * error code
462 */
463 int exynos_bl_set_dst_addr(
464 bl_handle_t handle,
465 void *addr[BL_MAX_PLANES],
466 enum v4l2_memory type);
467
468 /*!
469 * Start blending single frame
470 *
471 * \ingroup exynos_blender
472 *
473 * \param handle
474 * exynos_blender handle[in]
475 *
476 * \return
477 * error code
478 */
479 int exynos_bl_do_blend(bl_handle_t handle);
480
481 /*!
482 * Start 2-step(scaling & rotation) blending single frame
483 *
484 * \ingroup exynos_blender
485 *
486 * \return
487 * error code
488 */
489 int exynos_bl_do_blend_fast(bl_handle_t handle);
490
491 #ifdef __cplusplus
492 }
493 #endif
494
495 #endif // __EXYNOS_BLENER_H__