2 * Copyright (C) 2013 Samsung Electronics Co.Ltd
4 * Inki Dae <inki.dae@samsung.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
29 #define G2D_PLANE_MAX_NR 2
31 enum e_g2d_color_mode
{
33 G2D_COLOR_FMT_XRGB8888
,
34 G2D_COLOR_FMT_ARGB8888
,
36 G2D_COLOR_FMT_XRGB1555
,
37 G2D_COLOR_FMT_ARGB1555
,
38 G2D_COLOR_FMT_XRGB4444
,
39 G2D_COLOR_FMT_ARGB4444
,
40 G2D_COLOR_FMT_PRGB888
,
41 G2D_COLOR_FMT_YCbCr444
,
42 G2D_COLOR_FMT_YCbCr422
,
43 G2D_COLOR_FMT_YCbCr420
,
46 /* Luminance 8bit: gray color */
52 G2D_COLOR_FMT_MASK
, /* VER4.1 */
55 G2D_ORDER_AXRGB
= (0 << 4), /* VER4.1 */
56 G2D_ORDER_RGBAX
= (1 << 4), /* VER4.1 */
57 G2D_ORDER_AXBGR
= (2 << 4), /* VER4.1 */
58 G2D_ORDER_BGRAX
= (3 << 4), /* VER4.1 */
59 G2D_ORDER_MASK
= (3 << 4), /* VER4.1 */
61 /* Number of YCbCr plane */
62 G2D_YCbCr_1PLANE
= (0 << 8), /* VER4.1 */
63 G2D_YCbCr_2PLANE
= (1 << 8), /* VER4.1 */
64 G2D_YCbCr_PLANE_MASK
= (3 << 8), /* VER4.1 */
67 G2D_YCbCr_ORDER_CrY1CbY0
= (0 << 12), /* VER4.1 */
68 G2D_YCbCr_ORDER_CbY1CrY0
= (1 << 12), /* VER4.1 */
69 G2D_YCbCr_ORDER_Y1CrY0Cb
= (2 << 12), /* VER4.1 */
70 G2D_YCbCr_ORDER_Y1CbY0Cr
= (3 << 12), /* VER4.1 */
71 G2D_YCbCr_ORDER_CrCb
= G2D_YCbCr_ORDER_CrY1CbY0
, /* VER4.1 */
72 G2D_YCbCr_ORDER_CbCr
= G2D_YCbCr_ORDER_CbY1CrY0
, /* VER4.1 */
73 G2D_YCbCr_ORDER_MASK
= (3 < 12), /* VER4.1 */
76 G2D_CSC_601
= (0 << 16), /* VER4.1 */
77 G2D_CSC_709
= (1 << 16), /* VER4.1 */
78 G2D_CSC_MASK
= (1 << 16), /* VER4.1 */
80 /* Valid value range of YCbCr */
81 G2D_YCbCr_RANGE_NARROW
= (0 << 17), /* VER4.1 */
82 G2D_YCbCr_RANGE_WIDE
= (1 << 17), /* VER4.1 */
83 G2D_YCbCr_RANGE_MASK
= (1 << 17), /* VER4.1 */
85 G2D_COLOR_MODE_MASK
= 0xFFFFFFFF,
88 enum e_g2d_select_mode
{
89 G2D_SELECT_MODE_NORMAL
= (0 << 0),
90 G2D_SELECT_MODE_FGCOLOR
= (1 << 0),
91 G2D_SELECT_MODE_BGCOLOR
= (2 << 0),
94 enum e_g2d_repeat_mode
{
95 G2D_REPEAT_MODE_REPEAT
,
97 G2D_REPEAT_MODE_REFLECT
,
98 G2D_REPEAT_MODE_CLAMP
,
102 enum e_g2d_scale_mode
{
103 G2D_SCALE_MODE_NONE
= 0,
104 G2D_SCALE_MODE_NEAREST
,
105 G2D_SCALE_MODE_BILINEAR
,
109 enum e_g2d_buf_type
{
115 enum e_g2d_rop3_type
{
119 G2D_ROP3_MASK
= 0xFF,
122 enum e_g2d_select_alpha_src
{
123 G2D_SELECT_SRC_FOR_ALPHA_BLEND
, /* VER4.1 */
124 G2D_SELECT_ROP_FOR_ALPHA_BLEND
, /* VER4.1 */
127 enum e_g2d_transparent_mode
{
128 G2D_TRANSPARENT_MODE_OPAQUE
,
129 G2D_TRANSPARENT_MODE_TRANSPARENT
,
130 G2D_TRANSPARENT_MODE_BLUESCREEN
,
131 G2D_TRANSPARENT_MODE_MAX
,
134 enum e_g2d_color_key_mode
{
135 G2D_COLORKEY_MODE_DISABLE
= 0,
136 G2D_COLORKEY_MODE_SRC_RGBA
= (1<<0),
137 G2D_COLORKEY_MODE_DST_RGBA
= (1<<1),
138 G2D_COLORKEY_MODE_SRC_YCbCr
= (1<<2), /* VER4.1 */
139 G2D_COLORKEY_MODE_DST_YCbCr
= (1<<3), /* VER4.1 */
140 G2D_COLORKEY_MODE_MASK
= 15,
143 enum e_g2d_alpha_blend_mode
{
144 G2D_ALPHA_BLEND_MODE_DISABLE
,
145 G2D_ALPHA_BLEND_MODE_ENABLE
,
146 G2D_ALPHA_BLEND_MODE_FADING
, /* VER3.0 */
147 G2D_ALPHA_BLEND_MODE_MAX
,
155 G2D_OP_INTERPOLATE
= 0x04,
156 G2D_OP_DISJOINT_CLEAR
= 0x10,
157 G2D_OP_DISJOINT_SRC
= 0x11,
158 G2D_OP_DISJOINT_DST
= 0x12,
159 G2D_OP_CONJOINT_CLEAR
= 0x20,
160 G2D_OP_CONJOINT_SRC
= 0x21,
161 G2D_OP_CONJOINT_DST
= 0x22,
165 * The G2D_COEFF_MODE_DST_{COLOR,ALPHA} modes both use the ALPHA_REG(0x618)
166 * register. The registers fields are as follows:
167 * bits 31:8 = color value (RGB order)
168 * bits 7:0 = alpha value
170 enum e_g2d_coeff_mode
{
173 G2D_COEFF_MODE_SRC_ALPHA
,
174 G2D_COEFF_MODE_SRC_COLOR
,
175 G2D_COEFF_MODE_DST_ALPHA
,
176 G2D_COEFF_MODE_DST_COLOR
,
177 /* Global Alpha : Set by ALPHA_REG(0x618) */
178 G2D_COEFF_MODE_GB_ALPHA
,
179 /* Global Color and Alpha : Set by ALPHA_REG(0x618) */
180 G2D_COEFF_MODE_GB_COLOR
,
181 /* (1-SRC alpha)/DST Alpha */
182 G2D_COEFF_MODE_DISJOINT_S
,
183 /* (1-DST alpha)/SRC Alpha */
184 G2D_COEFF_MODE_DISJOINT_D
,
185 /* SRC alpha/DST alpha */
186 G2D_COEFF_MODE_CONJOINT_S
,
187 /* DST alpha/SRC alpha */
188 G2D_COEFF_MODE_CONJOINT_D
,
189 /* DST alpha/SRC alpha */
193 enum e_g2d_acoeff_mode
{
194 G2D_ACOEFF_MODE_A
, /* alpha */
195 G2D_ACOEFF_MODE_APGA
, /* alpha + global alpha */
196 G2D_ACOEFF_MODE_AMGA
, /* alpha * global alpha */
200 union g2d_point_val
{
204 * Coordinate of Source Image
205 * Range: 0 ~ 8000 (Requirement: SrcLeftX < SrcRightX)
206 * In YCbCr 422 and YCbCr 420 format with even number.
210 * Y Coordinate of Source Image
211 * Range: 0 ~ 8000 (Requirement: SrcTopY < SrcBottomY)
212 * In YCbCr 420 format with even number.
221 enum e_g2d_rop3_type unmasked_rop3
:8;
222 enum e_g2d_rop3_type masked_rop3
:8;
223 unsigned int reserved
:16;
227 union g2d_bitblt_cmd_val
{
231 unsigned int mask_rop4_en
:1;
232 unsigned int masking_en
:1;
233 enum e_g2d_select_alpha_src rop4_alpha_en
:1;
234 unsigned int dither_en
:1;
236 unsigned int resolved1
:4;
238 unsigned int cw_en
:4;
240 enum e_g2d_transparent_mode transparent_mode
:4;
242 enum e_g2d_color_key_mode color_key_mode
:4;
244 enum e_g2d_alpha_blend_mode alpha_blend_mode
:4;
246 unsigned int src_pre_multiply
:1;
247 unsigned int pat_pre_multiply
:1;
248 unsigned int dst_pre_multiply
:1;
249 unsigned int dst_depre_multiply
:1;
251 unsigned int fast_solid_color_fill_en
:1;
252 unsigned int reserved
:3;
256 union g2d_blend_func_val
{
260 enum e_g2d_coeff_mode src_coeff
:4;
261 enum e_g2d_acoeff_mode src_coeff_src_a
:2;
262 enum e_g2d_acoeff_mode src_coeff_dst_a
:2;
263 enum e_g2d_coeff_mode dst_coeff
:4;
264 enum e_g2d_acoeff_mode dst_coeff_src_a
:2;
265 enum e_g2d_acoeff_mode dst_coeff_dst_a
:2;
267 unsigned int inv_src_color_coeff
:1;
268 unsigned int resoled1
:1;
269 unsigned int inv_dst_color_coeff
:1;
270 unsigned int resoled2
:1;
272 unsigned int lighten_en
:1;
273 unsigned int darken_en
:1;
274 unsigned int win_ce_src_over_en
:2;
276 unsigned int reserved
:8;
281 enum e_g2d_select_mode select_mode
;
282 enum e_g2d_color_mode color_mode
;
283 enum e_g2d_repeat_mode repeat_mode
;
284 enum e_g2d_scale_mode scale_mode
;
287 unsigned char rotate_90
;
290 unsigned char component_alpha
;
294 unsigned int need_free
;
296 enum e_g2d_buf_type buf_type
;
297 unsigned int bo
[G2D_PLANE_MAX_NR
];
298 struct drm_exynos_g2d_userptr user_ptr
[G2D_PLANE_MAX_NR
];
299 void *mapped_ptr
[G2D_PLANE_MAX_NR
];
304 struct g2d_context
*g2d_init(int fd
);
305 void g2d_fini(struct g2d_context
*ctx
);
306 void g2d_config_event(struct g2d_context
*ctx
, void *userdata
);
307 int g2d_exec(struct g2d_context
*ctx
);
308 int g2d_solid_fill(struct g2d_context
*ctx
, struct g2d_image
*img
,
309 unsigned int x
, unsigned int y
, unsigned int w
,
311 int g2d_copy(struct g2d_context
*ctx
, struct g2d_image
*src
,
312 struct g2d_image
*dst
, unsigned int src_x
,
313 unsigned int src_y
, unsigned int dst_x
, unsigned int dst_y
,
314 unsigned int w
, unsigned int h
);
315 int g2d_move(struct g2d_context
*ctx
, struct g2d_image
*img
,
316 unsigned int src_x
, unsigned int src_y
, unsigned int dst_x
,
317 unsigned dst_y
, unsigned int w
, unsigned int h
);
318 int g2d_copy_with_scale(struct g2d_context
*ctx
, struct g2d_image
*src
,
319 struct g2d_image
*dst
, unsigned int src_x
,
320 unsigned int src_y
, unsigned int src_w
,
321 unsigned int src_h
, unsigned int dst_x
,
322 unsigned int dst_y
, unsigned int dst_w
,
323 unsigned int dst_h
, unsigned int negative
);
324 int g2d_blend(struct g2d_context
*ctx
, struct g2d_image
*src
,
325 struct g2d_image
*dst
, unsigned int src_x
,
326 unsigned int src_y
, unsigned int dst_x
, unsigned int dst_y
,
327 unsigned int w
, unsigned int h
, enum e_g2d_op op
);
328 int g2d_scale_and_blend(struct g2d_context
*ctx
, struct g2d_image
*src
,
329 struct g2d_image
*dst
, unsigned int src_x
, unsigned int src_y
,
330 unsigned int src_w
, unsigned int src_h
, unsigned int dst_x
,
331 unsigned int dst_y
, unsigned int dst_w
, unsigned int dst_h
,
333 #endif /* _FIMG2D_H_ */