2 * Copyright (C) 2013 The Android Open Source Project
3 * Copyright@ Samsung Electronics Co. LTD
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * \file exynos_scaler.c
20 * \brief header file for Scaler HAL
21 * \author Sunyoung Kang (sy0816.kang@samsung.com)
24 * <b>Revision History: </b>
25 * - 2013.02.01 : Sunyoung Kang (sy0816.kang@samsung.com) \n
28 * - 2013.04.26 : Cho KyongHo (pullip.cho@samsung.com \n
33 #ifndef _EXYNOS_SCALER_H_
34 #define _EXYNOS_SCALER_H_
37 #include <linux/videodev2.h>
38 #include <linux/videodev2_exynos_media.h>
41 #include "exynos_format.h"
42 #include "exynos_v4l2.h"
43 #include "exynos_gscaler.h"
45 #define SC_DEV_NODE "/dev/video"
46 #define SC_NODE(x) (50 + x)
48 #define SC_NUM_OF_PLANES (3)
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')
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)
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)
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)
83 // libgscaler's internal use only
84 typedef enum _HW_SCAL_ID
{
91 // argument of non-blocking api
92 typedef exynos_mpp_img exynos_sc_img
;
99 * Create libscaler handle
101 * \ingroup exynos_scaler
109 void *exynos_sc_create(int dev_num
);
112 * Destroy libscaler handle
114 * \ingroup exynos_scaler
117 * libscaler handle[in]
119 int exynos_sc_destroy(void *handle
);
122 * Convert color space with presetup color format
124 * \ingroup exynos_scaler
127 * libscaler handle[in]
132 int exynos_sc_convert(void *handle
);
135 * Convert color space with presetup color format
137 * \ingroup exynos_scaler
143 * csc narrow/wide property
145 * \param v4l2_colorspace
146 * csc equation property
149 * denoise filter info
154 int exynos_sc_set_csc_property(
156 unsigned int csc_range
,
157 unsigned int v4l2_colorspace
,
158 unsigned int filter
);
163 * \ingroup exynos_scaler
166 * libscaler handle[in]
175 * image left crop size[in]
178 * image top crop size[in]
181 * cropped image width[in]
184 * cropped image height[in]
186 * \param v4l2_colorformat
195 * \param premultiplied
196 * pre-multiplied format[in]
201 int exynos_sc_set_src_format(
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
);
215 * Set destination format.
217 * \ingroup exynos_scaler
220 * libscaler handle[in]
229 * image left crop size[in]
232 * image top crop size[in]
235 * cropped image width[in]
238 * cropped image height[in]
240 * \param v4l2_colorformat
249 * \param premultiplied
250 * pre-multiplied format[in]
255 int exynos_sc_set_dst_format(
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
);
271 * \ingroup exynos_scaler
274 * libscaler handle[in]
277 * buffer pointer array[in]
282 * \param acquireFenceFd
283 * acquire fence fd for the buffer or -1[in]
289 int exynos_sc_set_src_addr(
291 void *addr
[SC_NUM_OF_PLANES
],
296 * Set destination buffer
299 * libscaler handle[in]
302 * buffer pointer array[in]
307 * \param acquireFenceFd
308 * acquire fence fd for the buffer or -1[in]
313 int exynos_sc_set_dst_addr(
315 void *addr
[SC_NUM_OF_PLANES
],
322 * \ingroup exynos_scaler
325 * libscaler handle[in]
328 * image rotation. It should be multiple of 90[in]
331 * image flip_horizontal[in]
334 * image flip_vertical[in]
339 int exynos_sc_set_rotation(
345 ////// non-blocking /////
347 void *exynos_sc_create_exclusive(
351 int exynos_sc_csc_exclusive(void *handle
,
352 unsigned int range_full
,
353 unsigned int v4l2_colorspace
);
355 int exynos_sc_config_exclusive(
357 exynos_sc_img
*src_img
,
358 exynos_sc_img
*dst_img
);
360 int exynos_sc_run_exclusive(
362 exynos_sc_img
*src_img
,
363 exynos_sc_img
*dst_img
);
365 void *exynos_sc_create_blend_exclusive(
369 int exynos_sc_config_blend_exclusive(
371 exynos_sc_img
*src_img
,
372 exynos_sc_img
*dst_img
,
373 struct SrcBlendInfo
*srcblendinfo
);
375 int exynos_sc_wait_frame_done_exclusive
378 int exynos_sc_stop_exclusive
381 int exynos_sc_free_and_close
385 /******************************************************************************
386 ******** API for Copy Pixels between RGB data ********************************
387 ******************************************************************************/
390 * Description of an image for both of the source and the destination.
392 * \ingroup exynos_scaler
394 struct exynos_sc_pxinfo_img
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
407 * Description of a pixel copy
409 * \ingroup exynos_scaler
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
420 * Pixel format definition for pixel copy
422 * \ingroup exynos_scaler
425 EXYNOS_SC_FMT_RGB32
= 0x10,
427 EXYNOS_SC_FMT_RGB565
,
428 EXYNOS_SC_FMT_RGB555X
,
429 EXYNOS_SC_FMT_RGB444
,
433 * Copy pixel data from RGB to RGB
435 * \ingroup exynos_scaler
438 * information for pixel data copy [in]
441 * Scaler H/W instance number. Starts from 0 [in]
444 * true on success in copying pixel data.
447 #ifdef SCALER_USE_M2M1SHOT
448 bool exynos_sc_copy_pixels(
449 struct exynos_sc_pxinfo
*pxinfo
,
456 #endif /* _EXYNOS_SCALER_H_ */