diff options
Diffstat (limited to 'exynos/exynos_fimg2d.h')
-rw-r--r-- | exynos/exynos_fimg2d.h | 322 |
1 files changed, 322 insertions, 0 deletions
diff --git a/exynos/exynos_fimg2d.h b/exynos/exynos_fimg2d.h new file mode 100644 index 00000000..f76f2a9f --- /dev/null +++ b/exynos/exynos_fimg2d.h | |||
@@ -0,0 +1,322 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2013 Samsung Electronics Co.Ltd | ||
3 | * Authors: | ||
4 | * Inki Dae <inki.dae@samsung.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #ifndef _FIMG2D_H_ | ||
14 | #define _FIMG2D_H_ | ||
15 | |||
16 | #define G2D_MAX_CMD_NR 64 | ||
17 | #define G2D_MAX_GEM_CMD_NR 64 | ||
18 | #define G2D_MAX_CMD_LIST_NR 64 | ||
19 | #define G2D_PLANE_MAX_NR 2 | ||
20 | |||
21 | enum e_g2d_color_mode { | ||
22 | /* COLOR FORMAT */ | ||
23 | G2D_COLOR_FMT_XRGB8888, | ||
24 | G2D_COLOR_FMT_ARGB8888, | ||
25 | G2D_COLOR_FMT_RGB565, | ||
26 | G2D_COLOR_FMT_XRGB1555, | ||
27 | G2D_COLOR_FMT_ARGB1555, | ||
28 | G2D_COLOR_FMT_XRGB4444, | ||
29 | G2D_COLOR_FMT_ARGB4444, | ||
30 | G2D_COLOR_FMT_PRGB888, | ||
31 | G2D_COLOR_FMT_YCbCr444, | ||
32 | G2D_COLOR_FMT_YCbCr422, | ||
33 | G2D_COLOR_FMT_YCbCr420, | ||
34 | /* alpha 8bit */ | ||
35 | G2D_COLOR_FMT_A8, | ||
36 | /* Luminance 8bit: gray color */ | ||
37 | G2D_COLOR_FMT_L8, | ||
38 | /* alpha 1bit */ | ||
39 | G2D_COLOR_FMT_A1, | ||
40 | /* alpha 4bit */ | ||
41 | G2D_COLOR_FMT_A4, | ||
42 | G2D_COLOR_FMT_MASK, /* VER4.1 */ | ||
43 | |||
44 | /* COLOR ORDER */ | ||
45 | G2D_ORDER_AXRGB = (0 << 4), /* VER4.1 */ | ||
46 | G2D_ORDER_RGBAX = (1 << 4), /* VER4.1 */ | ||
47 | G2D_ORDER_AXBGR = (2 << 4), /* VER4.1 */ | ||
48 | G2D_ORDER_BGRAX = (3 << 4), /* VER4.1 */ | ||
49 | G2D_ORDER_MASK = (3 << 4), /* VER4.1 */ | ||
50 | |||
51 | /* Number of YCbCr plane */ | ||
52 | G2D_YCbCr_1PLANE = (0 << 8), /* VER4.1 */ | ||
53 | G2D_YCbCr_2PLANE = (1 << 8), /* VER4.1 */ | ||
54 | G2D_YCbCr_PLANE_MASK = (3 << 8), /* VER4.1 */ | ||
55 | |||
56 | /* Order in YCbCr */ | ||
57 | G2D_YCbCr_ORDER_CrY1CbY0 = (0 << 12), /* VER4.1 */ | ||
58 | G2D_YCbCr_ORDER_CbY1CrY0 = (1 << 12), /* VER4.1 */ | ||
59 | G2D_YCbCr_ORDER_Y1CrY0Cb = (2 << 12), /* VER4.1 */ | ||
60 | G2D_YCbCr_ORDER_Y1CbY0Cr = (3 << 12), /* VER4.1 */ | ||
61 | G2D_YCbCr_ORDER_CrCb = G2D_YCbCr_ORDER_CrY1CbY0, /* VER4.1 */ | ||
62 | G2D_YCbCr_ORDER_CbCr = G2D_YCbCr_ORDER_CbY1CrY0, /* VER4.1 */ | ||
63 | G2D_YCbCr_ORDER_MASK = (3 < 12), /* VER4.1 */ | ||
64 | |||
65 | /* CSC */ | ||
66 | G2D_CSC_601 = (0 << 16), /* VER4.1 */ | ||
67 | G2D_CSC_709 = (1 << 16), /* VER4.1 */ | ||
68 | G2D_CSC_MASK = (1 << 16), /* VER4.1 */ | ||
69 | |||
70 | /* Valid value range of YCbCr */ | ||
71 | G2D_YCbCr_RANGE_NARROW = (0 << 17), /* VER4.1 */ | ||
72 | G2D_YCbCr_RANGE_WIDE = (1 << 17), /* VER4.1 */ | ||
73 | G2D_YCbCr_RANGE_MASK = (1 << 17), /* VER4.1 */ | ||
74 | |||
75 | G2D_COLOR_MODE_MASK = 0xFFFFFFFF, | ||
76 | }; | ||
77 | |||
78 | enum e_g2d_select_mode { | ||
79 | G2D_SELECT_MODE_NORMAL = (0 << 0), | ||
80 | G2D_SELECT_MODE_FGCOLOR = (1 << 0), | ||
81 | G2D_SELECT_MODE_BGCOLOR = (2 << 0), | ||
82 | }; | ||
83 | |||
84 | enum e_g2d_repeat_mode { | ||
85 | G2D_REPEAT_MODE_REPEAT, | ||
86 | G2D_REPEAT_MODE_PAD, | ||
87 | G2D_REPEAT_MODE_REFLECT, | ||
88 | G2D_REPEAT_MODE_CLAMP, | ||
89 | G2D_REPEAT_MODE_NONE, | ||
90 | }; | ||
91 | |||
92 | enum e_g2d_scale_mode { | ||
93 | G2D_SCALE_MODE_NONE = 0, | ||
94 | G2D_SCALE_MODE_NEAREST, | ||
95 | G2D_SCALE_MODE_BILINEAR, | ||
96 | G2D_SCALE_MODE_MAX, | ||
97 | }; | ||
98 | |||
99 | enum e_g2d_buf_type { | ||
100 | G2D_IMGBUF_COLOR, | ||
101 | G2D_IMGBUF_GEM, | ||
102 | G2D_IMGBUF_USERPTR, | ||
103 | }; | ||
104 | |||
105 | enum e_g2d_rop3_type { | ||
106 | G2D_ROP3_DST = 0xAA, | ||
107 | G2D_ROP3_SRC = 0xCC, | ||
108 | G2D_ROP3_3RD = 0xF0, | ||
109 | G2D_ROP3_MASK = 0xFF, | ||
110 | }; | ||
111 | |||
112 | enum e_g2d_select_alpha_src { | ||
113 | G2D_SELECT_SRC_FOR_ALPHA_BLEND, /* VER4.1 */ | ||
114 | G2D_SELECT_ROP_FOR_ALPHA_BLEND, /* VER4.1 */ | ||
115 | }; | ||
116 | |||
117 | enum e_g2d_transparent_mode { | ||
118 | G2D_TRANSPARENT_MODE_OPAQUE, | ||
119 | G2D_TRANSPARENT_MODE_TRANSPARENT, | ||
120 | G2D_TRANSPARENT_MODE_BLUESCREEN, | ||
121 | G2D_TRANSPARENT_MODE_MAX, | ||
122 | }; | ||
123 | |||
124 | enum e_g2d_color_key_mode { | ||
125 | G2D_COLORKEY_MODE_DISABLE = 0, | ||
126 | G2D_COLORKEY_MODE_SRC_RGBA = (1<<0), | ||
127 | G2D_COLORKEY_MODE_DST_RGBA = (1<<1), | ||
128 | G2D_COLORKEY_MODE_SRC_YCbCr = (1<<2), /* VER4.1 */ | ||
129 | G2D_COLORKEY_MODE_DST_YCbCr = (1<<3), /* VER4.1 */ | ||
130 | G2D_COLORKEY_MODE_MASK = 15, | ||
131 | }; | ||
132 | |||
133 | enum e_g2d_alpha_blend_mode { | ||
134 | G2D_ALPHA_BLEND_MODE_DISABLE, | ||
135 | G2D_ALPHA_BLEND_MODE_ENABLE, | ||
136 | G2D_ALPHA_BLEND_MODE_FADING, /* VER3.0 */ | ||
137 | G2D_ALPHA_BLEND_MODE_MAX, | ||
138 | }; | ||
139 | |||
140 | enum e_g2d_op { | ||
141 | G2D_OP_CLEAR = 0x00, | ||
142 | G2D_OP_SRC = 0x01, | ||
143 | G2D_OP_DST = 0x02, | ||
144 | G2D_OP_OVER = 0x03, | ||
145 | G2D_OP_INTERPOLATE = 0x04, | ||
146 | G2D_OP_DISJOINT_CLEAR = 0x10, | ||
147 | G2D_OP_DISJOINT_SRC = 0x11, | ||
148 | G2D_OP_DISJOINT_DST = 0x12, | ||
149 | G2D_OP_CONJOINT_CLEAR = 0x20, | ||
150 | G2D_OP_CONJOINT_SRC = 0x21, | ||
151 | G2D_OP_CONJOINT_DST = 0x22, | ||
152 | }; | ||
153 | |||
154 | enum e_g2d_coeff_mode { | ||
155 | G2D_COEFF_MODE_ONE, | ||
156 | G2D_COEFF_MODE_ZERO, | ||
157 | G2D_COEFF_MODE_SRC_ALPHA, | ||
158 | G2D_COEFF_MODE_SRC_COLOR, | ||
159 | G2D_COEFF_MODE_DST_ALPHA, | ||
160 | G2D_COEFF_MODE_DST_COLOR, | ||
161 | /* Global Alpha : Set by ALPHA_REG(0x618) */ | ||
162 | G2D_COEFF_MODE_GB_ALPHA, | ||
163 | /* Global Color : Set by ALPHA_REG(0x618) */ | ||
164 | G2D_COEFF_MODE_GB_COLOR, | ||
165 | /* (1-SRC alpha)/DST Alpha */ | ||
166 | G2D_COEFF_MODE_DISJOINT_S, | ||
167 | /* (1-DST alpha)/SRC Alpha */ | ||
168 | G2D_COEFF_MODE_DISJOINT_D, | ||
169 | /* SRC alpha/DST alpha */ | ||
170 | G2D_COEFF_MODE_CONJOINT_S, | ||
171 | /* DST alpha/SRC alpha */ | ||
172 | G2D_COEFF_MODE_CONJOINT_D, | ||
173 | /* DST alpha/SRC alpha */ | ||
174 | G2D_COEFF_MODE_MASK | ||
175 | }; | ||
176 | |||
177 | enum e_g2d_acoeff_mode { | ||
178 | G2D_ACOEFF_MODE_A, /* alpha */ | ||
179 | G2D_ACOEFF_MODE_APGA, /* alpha + global alpha */ | ||
180 | G2D_ACOEFF_MODE_AMGA, /* alpha * global alpha */ | ||
181 | G2D_ACOEFF_MODE_MASK | ||
182 | }; | ||
183 | |||
184 | union g2d_point_val { | ||
185 | unsigned int val; | ||
186 | struct { | ||
187 | /* | ||
188 | * Coordinate of Source Image | ||
189 | * Range: 0 ~ 8000 (Requirement: SrcLeftX < SrcRightX) | ||
190 | * In YCbCr 422 and YCbCr 420 format with even number. | ||
191 | */ | ||
192 | unsigned int x:16; | ||
193 | /* | ||
194 | * Y Coordinate of Source Image | ||
195 | * Range: 0 ~ 8000 (Requirement: SrcTopY < SrcBottomY) | ||
196 | * In YCbCr 420 format with even number. | ||
197 | */ | ||
198 | unsigned int y:16; | ||
199 | } data; | ||
200 | }; | ||
201 | |||
202 | union g2d_rop4_val { | ||
203 | unsigned int val; | ||
204 | struct { | ||
205 | enum e_g2d_rop3_type unmasked_rop3:8; | ||
206 | enum e_g2d_rop3_type masked_rop3:8; | ||
207 | unsigned int reserved:16; | ||
208 | } data; | ||
209 | }; | ||
210 | |||
211 | union g2d_bitblt_cmd_val { | ||
212 | unsigned int val; | ||
213 | struct { | ||
214 | /* [0:3] */ | ||
215 | unsigned int mask_rop4_en:1; | ||
216 | unsigned int masking_en:1; | ||
217 | enum e_g2d_select_alpha_src rop4_alpha_en:1; | ||
218 | unsigned int dither_en:1; | ||
219 | /* [4:7] */ | ||
220 | unsigned int resolved1:4; | ||
221 | /* [8:11] */ | ||
222 | unsigned int cw_en:4; | ||
223 | /* [12:15] */ | ||
224 | enum e_g2d_transparent_mode transparent_mode:4; | ||
225 | /* [16:19] */ | ||
226 | enum e_g2d_color_key_mode color_key_mode:4; | ||
227 | /* [20:23] */ | ||
228 | enum e_g2d_alpha_blend_mode alpha_blend_mode:4; | ||
229 | /* [24:27] */ | ||
230 | unsigned int src_pre_multiply:1; | ||
231 | unsigned int pat_pre_multiply:1; | ||
232 | unsigned int dst_pre_multiply:1; | ||
233 | unsigned int dst_depre_multiply:1; | ||
234 | /* [28:31] */ | ||
235 | unsigned int fast_solid_color_fill_en:1; | ||
236 | unsigned int reserved:3; | ||
237 | } data; | ||
238 | }; | ||
239 | |||
240 | union g2d_blend_func_val { | ||
241 | unsigned int val; | ||
242 | struct { | ||
243 | /* [0:15] */ | ||
244 | enum e_g2d_coeff_mode src_coeff:4; | ||
245 | enum e_g2d_acoeff_mode src_coeff_src_a:2; | ||
246 | enum e_g2d_acoeff_mode src_coeff_dst_a:2; | ||
247 | enum e_g2d_coeff_mode dst_coeff:4; | ||
248 | enum e_g2d_acoeff_mode dst_coeff_src_a:2; | ||
249 | enum e_g2d_acoeff_mode dst_coeff_dst_a:2; | ||
250 | /* [16:19] */ | ||
251 | unsigned int inv_src_color_coeff:1; | ||
252 | unsigned int resoled1:1; | ||
253 | unsigned int inv_dst_color_coeff:1; | ||
254 | unsigned int resoled2:1; | ||
255 | /* [20:23] */ | ||
256 | unsigned int lighten_en:1; | ||
257 | unsigned int darken_en:1; | ||
258 | unsigned int win_ce_src_over_en:2; | ||
259 | /* [24:31] */ | ||
260 | unsigned int reserved:8; | ||
261 | } data; | ||
262 | }; | ||
263 | |||
264 | struct g2d_image { | ||
265 | enum e_g2d_select_mode select_mode; | ||
266 | enum e_g2d_color_mode color_mode; | ||
267 | enum e_g2d_repeat_mode repeat_mode; | ||
268 | enum e_g2d_scale_mode scale_mode; | ||
269 | unsigned int xscale; | ||
270 | unsigned int yscale; | ||
271 | unsigned char rotate_90; | ||
272 | unsigned char x_dir; | ||
273 | unsigned char y_dir; | ||
274 | unsigned char component_alpha; | ||
275 | unsigned int width; | ||
276 | unsigned int height; | ||
277 | unsigned int stride; | ||
278 | unsigned int need_free; | ||
279 | unsigned int color; | ||
280 | enum e_g2d_buf_type buf_type; | ||
281 | unsigned int bo[G2D_PLANE_MAX_NR]; | ||
282 | struct drm_exynos_g2d_userptr user_ptr[G2D_PLANE_MAX_NR]; | ||
283 | void *mapped_ptr[G2D_PLANE_MAX_NR]; | ||
284 | }; | ||
285 | |||
286 | struct g2d_context { | ||
287 | int fd; | ||
288 | unsigned int major; | ||
289 | unsigned int minor; | ||
290 | struct drm_exynos_g2d_cmd cmd[G2D_MAX_CMD_NR]; | ||
291 | struct drm_exynos_g2d_cmd cmd_buf[G2D_MAX_GEM_CMD_NR]; | ||
292 | unsigned int cmd_nr; | ||
293 | unsigned int cmd_buf_nr; | ||
294 | unsigned int cmdlist_nr; | ||
295 | }; | ||
296 | |||
297 | struct g2d_context *g2d_init(int fd); | ||
298 | void g2d_fini(struct g2d_context *ctx); | ||
299 | int g2d_exec(struct g2d_context *ctx); | ||
300 | int g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img, | ||
301 | unsigned int x, unsigned int y, unsigned int w, | ||
302 | unsigned int h); | ||
303 | int g2d_copy(struct g2d_context *ctx, struct g2d_image *src, | ||
304 | struct g2d_image *dst, unsigned int src_x, | ||
305 | unsigned int src_y, unsigned int dst_x, unsigned int dst_y, | ||
306 | unsigned int w, unsigned int h); | ||
307 | int g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src, | ||
308 | struct g2d_image *dst, unsigned int src_x, | ||
309 | unsigned int src_y, unsigned int src_w, | ||
310 | unsigned int src_h, unsigned int dst_x, | ||
311 | unsigned int dst_y, unsigned int dst_w, | ||
312 | unsigned int dst_h, unsigned int negative); | ||
313 | int g2d_blend(struct g2d_context *ctx, struct g2d_image *src, | ||
314 | struct g2d_image *dst, unsigned int src_x, | ||
315 | unsigned int src_y, unsigned int dst_x, unsigned int dst_y, | ||
316 | unsigned int w, unsigned int h, enum e_g2d_op op); | ||
317 | int g2d_scale_and_blend(struct g2d_context *ctx, struct g2d_image *src, | ||
318 | struct g2d_image *dst, unsigned int src_x, unsigned int src_y, | ||
319 | unsigned int src_w, unsigned int src_h, unsigned int dst_x, | ||
320 | unsigned int dst_y, unsigned int dst_w, unsigned int dst_h, | ||
321 | enum e_g2d_op op); | ||
322 | #endif /* _FIMG2D_H_ */ | ||