libhwjpeg: resolve compilation errors
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / include / exynos_scaler.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_scaler.c
20 * \brief header file for Scaler HAL
21 * \author Sunyoung Kang (sy0816.kang@samsung.com)
22 * \date 2013/02/01
23 *
24 * <b>Revision History: </b>
25 * - 2013.02.01 : Sunyoung Kang (sy0816.kang@samsung.com) \n
26 * Create
27 *
28 * - 2013.04.26 : Cho KyongHo (pullip.cho@samsung.com \n
29 * Library rewrite
30 *
31 */
32
33 #ifndef _EXYNOS_SCALER_H_
34 #define _EXYNOS_SCALER_H_
35
36
37 #include <linux/videodev2.h>
38 #include <linux/videodev2_exynos_media.h>
39 #include <stdbool.h>
40
41 #include "exynos_format.h"
42 #include "exynos_v4l2.h"
43 #include "exynos_gscaler.h"
44
45 #define SC_DEV_NODE "/dev/video"
46 #define SC_NODE(x) (50 + x)
47
48 #define SC_NUM_OF_PLANES (3)
49
50 #define V4L2_PIX_FMT_NV12_RGB32 v4l2_fourcc('N', 'V', '1', 'R')
51 #define V4L2_PIX_FMT_NV12N_RGB32 v4l2_fourcc('N', 'N', '1', 'R')
52 #define V4L2_PIX_FMT_NV12M_RGB32 v4l2_fourcc('N', 'V', 'R', 'G')
53 #define V4L2_PIX_FMT_NV12M_BGR32 v4l2_fourcc('N', 'V', 'B', 'G')
54 #define V4L2_PIX_FMT_NV12M_RGB565 v4l2_fourcc('N', 'V', 'R', '6')
55 #define V4L2_PIX_FMT_NV12M_RGB444 v4l2_fourcc('N', 'V', 'R', '4')
56 #define V4L2_PIX_FMT_NV12M_RGB555X v4l2_fourcc('N', 'V', 'R', '5')
57 #define V4L2_PIX_FMT_NV12MT_16X16_RGB32 v4l2_fourcc('V', 'M', 'R', 'G')
58 #define V4L2_PIX_FMT_NV21M_RGB32 v4l2_fourcc('V', 'N', 'R', 'G')
59 #define V4L2_PIX_FMT_NV21M_BGR32 v4l2_fourcc('V', 'N', 'B', 'G')
60 #define V4L2_PIX_FMT_NV21_RGB32 v4l2_fourcc('V', 'N', '1', 'R')
61 #define V4L2_PIX_FMT_YVU420_RGB32 v4l2_fourcc('Y', 'V', 'R', 'G')
62
63 #define V4L2_CID_2D_SRC_BLEND_SET_FMT (V4L2_CID_EXYNOS_BASE + 116)
64 #define V4L2_CID_2D_SRC_BLEND_SET_H_POS (V4L2_CID_EXYNOS_BASE + 117)
65 #define V4L2_CID_2D_SRC_BLEND_SET_V_POS (V4L2_CID_EXYNOS_BASE + 118)
66 #define V4L2_CID_2D_SRC_BLEND_FMT_PREMULTI (V4L2_CID_EXYNOS_BASE + 119)
67 #define V4L2_CID_2D_SRC_BLEND_SET_STRIDE (V4L2_CID_EXYNOS_BASE + 120)
68 #define V4L2_CID_2D_SRC_BLEND_SET_WIDTH (V4L2_CID_EXYNOS_BASE + 121)
69 #define V4L2_CID_2D_SRC_BLEND_SET_HEIGHT (V4L2_CID_EXYNOS_BASE + 122)
70
71 #ifdef SCALER_USE_LOCAL_CID
72 #define V4L2_CID_GLOBAL_ALPHA (V4L2_CID_EXYNOS_BASE + 1)
73 #define V4L2_CID_2D_BLEND_OP (V4L2_CID_EXYNOS_BASE + 103)
74 #define V4L2_CID_2D_COLOR_FILL (V4L2_CID_EXYNOS_BASE + 104)
75 #define V4L2_CID_2D_DITH (V4L2_CID_EXYNOS_BASE + 105)
76 #define V4L2_CID_2D_FMT_PREMULTI (V4L2_CID_EXYNOS_BASE + 106)
77 #endif
78
79 #define LIBSC_V4L2_CID_DNOISE_FT (V4L2_CID_EXYNOS_BASE + 150)
80 #define LIBSC_M2M1SHOT_OP_FILTER_SHIFT (28)
81 #define LIBSC_M2M1SHOT_OP_FILTER_MASK (0xf << 28)
82
83 // libgscaler's internal use only
84 typedef enum _HW_SCAL_ID {
85 HW_SCAL0 = 4,
86 HW_SCAL1,
87 HW_SCAL2,
88 HW_SCAL_MAX,
89 } HW_SCAL_ID;
90
91 // argument of non-blocking api
92 typedef exynos_mpp_img exynos_sc_img;
93
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97
98 /*!
99 * Create libscaler handle
100 *
101 * \ingroup exynos_scaler
102 *
103 * \param dev_num
104 * scaler dev_num[in]
105 *
106 * \return
107 * libscaler handle
108 */
109 void *exynos_sc_create(int dev_num);
110
111 /*!
112 * Destroy libscaler handle
113 *
114 * \ingroup exynos_scaler
115 *
116 * \param handle
117 * libscaler handle[in]
118 */
119 int exynos_sc_destroy(void *handle);
120
121 /*!
122 * Convert color space with presetup color format
123 *
124 * \ingroup exynos_scaler
125 *
126 * \param handle
127 * libscaler handle[in]
128 *
129 * \return
130 * error code
131 */
132 int exynos_sc_convert(void *handle);
133
134 /*!
135 * Convert color space with presetup color format
136 *
137 * \ingroup exynos_scaler
138 *
139 * \param handle
140 * libscaler handle
141 *
142 * \param csc_range
143 * csc narrow/wide property
144 *
145 * \param v4l2_colorspace
146 * csc equation property
147 *
148 * \param filter
149 * denoise filter info
150 *
151 * \return
152 * error code
153 */
154 int exynos_sc_set_csc_property(
155 void *handle,
156 unsigned int csc_range,
157 unsigned int v4l2_colorspace,
158 unsigned int filter);
159
160 /*!
161 * Set source format.
162 *
163 * \ingroup exynos_scaler
164 *
165 * \param handle
166 * libscaler handle[in]
167 *
168 * \param width
169 * image width[in]
170 *
171 * \param height
172 * image height[in]
173 *
174 * \param crop_left
175 * image left crop size[in]
176 *
177 * \param crop_top
178 * image top crop size[in]
179 *
180 * \param crop_width
181 * cropped image width[in]
182 *
183 * \param crop_height
184 * cropped image height[in]
185 *
186 * \param v4l2_colorformat
187 * color format[in]
188 *
189 * \param cacheable
190 * ccacheable[in]
191 *
192 * \param mode_drm
193 * mode_drm[in]
194 *
195 * \param premultiplied
196 * pre-multiplied format[in]
197 *
198 * \return
199 * error code
200 */
201 int exynos_sc_set_src_format(
202 void *handle,
203 unsigned int width,
204 unsigned int height,
205 unsigned int crop_left,
206 unsigned int crop_top,
207 unsigned int crop_width,
208 unsigned int crop_height,
209 unsigned int v4l2_colorformat,
210 unsigned int cacheable,
211 unsigned int mode_drm,
212 unsigned int premultiplied);
213
214 /*!
215 * Set destination format.
216 *
217 * \ingroup exynos_scaler
218 *
219 * \param handle
220 * libscaler handle[in]
221 *
222 * \param width
223 * image width[in]
224 *
225 * \param height
226 * image height[in]
227 *
228 * \param crop_left
229 * image left crop size[in]
230 *
231 * \param crop_top
232 * image top crop size[in]
233 *
234 * \param crop_width
235 * cropped image width[in]
236 *
237 * \param crop_height
238 * cropped image height[in]
239 *
240 * \param v4l2_colorformat
241 * color format[in]
242 *
243 * \param cacheable
244 * ccacheable[in]
245 *
246 * \param mode_drm
247 * mode_drm[in]
248 *
249 * \param premultiplied
250 * pre-multiplied format[in]
251 *
252 * \return
253 * error code
254 */
255 int exynos_sc_set_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 v4l2_colorformat,
264 unsigned int cacheable,
265 unsigned int mode_drm,
266 unsigned int premultiplied);
267
268 /*!
269 * Set source buffer
270 *
271 * \ingroup exynos_scaler
272 *
273 * \param handle
274 * libscaler handle[in]
275 *
276 * \param addr
277 * buffer pointer array[in]
278 *
279 * \param mem_type
280 * memory type[in]
281 *
282 * \param acquireFenceFd
283 * acquire fence fd for the buffer or -1[in]
284 *
285 * \return
286 * error code
287 */
288
289 int exynos_sc_set_src_addr(
290 void *handle,
291 void *addr[SC_NUM_OF_PLANES],
292 int mem_type,
293 int acquireFenceFd);
294
295 /*!
296 * Set destination buffer
297 *
298 * \param handle
299 * libscaler handle[in]
300 *
301 * \param addr
302 * buffer pointer array[in]
303 *
304 * \param mem_type
305 * memory type[in]
306 *
307 * \param acquireFenceFd
308 * acquire fence fd for the buffer or -1[in]
309 *
310 * \return
311 * error code
312 */
313 int exynos_sc_set_dst_addr(
314 void *handle,
315 void *addr[SC_NUM_OF_PLANES],
316 int mem_type,
317 int acquireFenceFd);
318
319 /*!
320 * Set rotation.
321 *
322 * \ingroup exynos_scaler
323 *
324 * \param handle
325 * libscaler handle[in]
326 *
327 * \param rot
328 * image rotation. It should be multiple of 90[in]
329 *
330 * \param flip_h
331 * image flip_horizontal[in]
332 *
333 * \param flip_v
334 * image flip_vertical[in]
335 *
336 * \return
337 * error code
338 */
339 int exynos_sc_set_rotation(
340 void *handle,
341 int rot,
342 int flip_h,
343 int flip_v);
344
345 ////// non-blocking /////
346
347 void *exynos_sc_create_exclusive(
348 int dev_num,
349 int allow_drm);
350
351 int exynos_sc_csc_exclusive(void *handle,
352 unsigned int range_full,
353 unsigned int v4l2_colorspace);
354
355 int exynos_sc_config_exclusive(
356 void *handle,
357 exynos_sc_img *src_img,
358 exynos_sc_img *dst_img);
359
360 int exynos_sc_run_exclusive(
361 void *handle,
362 exynos_sc_img *src_img,
363 exynos_sc_img *dst_img);
364
365 void *exynos_sc_create_blend_exclusive(
366 int dev_num,
367 int allow_drm);
368
369 int exynos_sc_config_blend_exclusive(
370 void *handle,
371 exynos_sc_img *src_img,
372 exynos_sc_img *dst_img,
373 struct SrcBlendInfo *srcblendinfo);
374
375 int exynos_sc_wait_frame_done_exclusive
376 (void *handle);
377
378 int exynos_sc_stop_exclusive
379 (void *handle);
380
381 int exynos_sc_free_and_close
382 (void *handle);
383
384
385 /******************************************************************************
386 ******** API for Copy Pixels between RGB data ********************************
387 ******************************************************************************/
388
389 /*!
390 * Description of an image for both of the source and the destination.
391 *
392 * \ingroup exynos_scaler
393 */
394 struct exynos_sc_pxinfo_img
395 {
396 void *addr;
397 unsigned int width;
398 unsigned int height;
399 unsigned int crop_left;
400 unsigned int crop_top;
401 unsigned int crop_width;
402 unsigned int crop_height;
403 unsigned int pxfmt; // enum EXYNOS_SC_FMT_PXINFO
404 };
405
406 /*!
407 * Description of a pixel copy
408 *
409 * \ingroup exynos_scaler
410 */
411 struct exynos_sc_pxinfo {
412 struct exynos_sc_pxinfo_img src;
413 struct exynos_sc_pxinfo_img dst;
414 unsigned short rotate; // 0 ~ 360
415 char hflip; // non-zero value for hflip
416 char vflip; // non-zero value for vflip
417 };
418
419 /*!
420 * Pixel format definition for pixel copy
421 *
422 * \ingroup exynos_scaler
423 */
424 enum SC_FMT_PXINFO {
425 EXYNOS_SC_FMT_RGB32 = 0x10,
426 EXYNOS_SC_FMT_BGR32,
427 EXYNOS_SC_FMT_RGB565,
428 EXYNOS_SC_FMT_RGB555X,
429 EXYNOS_SC_FMT_RGB444,
430 };
431
432 /*!
433 * Copy pixel data from RGB to RGB
434 *
435 * \ingroup exynos_scaler
436 *
437 * \param pxinfo
438 * information for pixel data copy [in]
439 *
440 * \param dev_num
441 * Scaler H/W instance number. Starts from 0 [in]
442 *
443 * \return
444 * true on success in copying pixel data.
445 * false on failure.
446 */
447 #ifdef SCALER_USE_M2M1SHOT
448 bool exynos_sc_copy_pixels(
449 struct exynos_sc_pxinfo *pxinfo,
450 int dev_num);
451 #endif
452 #ifdef __cplusplus
453 }
454 #endif
455
456 #endif /* _EXYNOS_SCALER_H_ */