• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) Rockchip Electronics Co., Ltd.
4  *
5  * Author:
6  *	Huang Lee <Putin.li@rock-chips.com>
7  */
8 
9 #include "rga_hw_config.h"
10 
11 const uint32_t rga3_raster_format[] = {
12 	RGA2_FORMAT_RGBA_8888,
13 	RGA2_FORMAT_BGRA_8888,
14 	RGA2_FORMAT_RGB_888,
15 	RGA2_FORMAT_BGR_888,
16 	RGA2_FORMAT_RGB_565,
17 	RGA2_FORMAT_BGR_565,
18 	RGA2_FORMAT_YCbCr_422_SP,
19 	RGA2_FORMAT_YCbCr_420_SP,
20 	RGA2_FORMAT_YCrCb_422_SP,
21 	RGA2_FORMAT_YCrCb_420_SP,
22 	RGA2_FORMAT_YVYU_422,
23 	RGA2_FORMAT_VYUY_422,
24 	RGA2_FORMAT_YUYV_422,
25 	RGA2_FORMAT_UYVY_422,
26 	RGA2_FORMAT_YCbCr_420_SP_10B,
27 	RGA2_FORMAT_YCrCb_420_SP_10B,
28 	RGA2_FORMAT_YCbCr_422_SP_10B,
29 	RGA2_FORMAT_YCrCb_422_SP_10B,
30 };
31 
32 const uint32_t rga3_fbcd_format[] = {
33 	RGA2_FORMAT_RGBA_8888,
34 	RGA2_FORMAT_BGRA_8888,
35 	RGA2_FORMAT_RGB_888,
36 	RGA2_FORMAT_BGR_888,
37 	RGA2_FORMAT_RGB_565,
38 	RGA2_FORMAT_BGR_565,
39 	RGA2_FORMAT_YCbCr_422_SP,
40 	RGA2_FORMAT_YCbCr_420_SP,
41 	RGA2_FORMAT_YCrCb_422_SP,
42 	RGA2_FORMAT_YCrCb_420_SP,
43 	RGA2_FORMAT_YCbCr_420_SP_10B,
44 	RGA2_FORMAT_YCrCb_420_SP_10B,
45 	RGA2_FORMAT_YCbCr_422_SP_10B,
46 	RGA2_FORMAT_YCrCb_422_SP_10B,
47 };
48 
49 const uint32_t rga3_tile_format[] = {
50 	RGA2_FORMAT_YCbCr_422_SP,
51 	RGA2_FORMAT_YCbCr_420_SP,
52 	RGA2_FORMAT_YCrCb_422_SP,
53 	RGA2_FORMAT_YCrCb_420_SP,
54 	RGA2_FORMAT_YCbCr_420_SP_10B,
55 	RGA2_FORMAT_YCrCb_420_SP_10B,
56 	RGA2_FORMAT_YCbCr_422_SP_10B,
57 	RGA2_FORMAT_YCrCb_422_SP_10B,
58 };
59 
60 const uint32_t rga2e_raster_format[] = {
61 	RGA2_FORMAT_RGBA_8888,
62 	RGA2_FORMAT_RGBX_8888,
63 	RGA2_FORMAT_BGRA_8888,
64 	RGA2_FORMAT_BGRX_8888,
65 	RGA2_FORMAT_RGB_888,
66 	RGA2_FORMAT_BGR_888,
67 	RGA2_FORMAT_RGB_565,
68 	RGA2_FORMAT_BGR_565,
69 	RGA2_FORMAT_YCbCr_422_P,
70 	RGA2_FORMAT_YCbCr_420_P,
71 	RGA2_FORMAT_YCrCb_422_P,
72 	RGA2_FORMAT_YCrCb_420_P,
73 	RGA2_FORMAT_YCbCr_422_SP,
74 	RGA2_FORMAT_YCbCr_420_SP,
75 	RGA2_FORMAT_YCrCb_422_SP,
76 	RGA2_FORMAT_YCrCb_420_SP,
77 	RGA2_FORMAT_YVYU_422,
78 	RGA2_FORMAT_VYUY_422,
79 	RGA2_FORMAT_YUYV_422,
80 	RGA2_FORMAT_UYVY_422,
81 	RGA2_FORMAT_YCbCr_420_SP_10B,
82 	RGA2_FORMAT_YCrCb_420_SP_10B,
83 	RGA2_FORMAT_YCbCr_422_SP_10B,
84 	RGA2_FORMAT_YCrCb_422_SP_10B,
85 	RGA2_FORMAT_Y4,
86 	RGA2_FORMAT_YCbCr_400,
87 	RGA2_FORMAT_RGBA_5551,
88 	RGA2_FORMAT_BGRA_5551,
89 	RGA2_FORMAT_RGBA_4444,
90 	RGA2_FORMAT_BGRA_4444,
91 	RGA2_FORMAT_XRGB_8888,
92 	RGA2_FORMAT_XBGR_8888,
93 	RGA2_FORMAT_BPP_1,
94 	RGA2_FORMAT_BPP_2,
95 	RGA2_FORMAT_BPP_4,
96 	RGA2_FORMAT_BPP_8,
97 	RGA2_FORMAT_ARGB_8888,
98 	RGA2_FORMAT_ARGB_5551,
99 	RGA2_FORMAT_ARGB_4444,
100 	RGA2_FORMAT_ABGR_8888,
101 	RGA2_FORMAT_ABGR_5551,
102 	RGA2_FORMAT_ABGR_4444,
103 };
104 
105 const struct rga_win_data rga3_win_data[] = {
106 	{
107 		.name = "rga3-win0",
108 		.raster_formats = rga3_raster_format,
109 		.num_of_raster_formats = ARRAY_SIZE(rga3_raster_format),
110 		.fbc_formats = rga3_fbcd_format,
111 		.num_of_fbc_formats = ARRAY_SIZE(rga3_fbcd_format),
112 		.tile_formats = rga3_tile_format,
113 		.num_of_tile_formats = ARRAY_SIZE(rga3_tile_format),
114 		.supported_rotations = RGA_MODE_ROTATE_MASK,
115 		.scale_up_mode = RGA_SCALE_UP_BIC,
116 		.scale_down_mode = RGA_SCALE_DOWN_AVG,
117 		.rd_mode = RGA_RASTER_MODE | RGA_FBC_MODE | RGA_TILE_MODE,
118 
119 	},
120 
121 	{
122 		.name = "rga3-win1",
123 		.raster_formats = rga3_raster_format,
124 		.num_of_raster_formats = ARRAY_SIZE(rga3_raster_format),
125 		.fbc_formats = rga3_fbcd_format,
126 		.num_of_fbc_formats = ARRAY_SIZE(rga3_fbcd_format),
127 		.tile_formats = rga3_tile_format,
128 		.num_of_tile_formats = ARRAY_SIZE(rga3_tile_format),
129 		.supported_rotations = RGA_MODE_ROTATE_MASK,
130 		.scale_up_mode = RGA_SCALE_UP_BIC,
131 		.scale_down_mode = RGA_SCALE_DOWN_AVG,
132 		.rd_mode = RGA_RASTER_MODE | RGA_FBC_MODE | RGA_TILE_MODE,
133 
134 	},
135 
136 	{
137 		.name = "rga3-wr",
138 		.raster_formats = rga3_raster_format,
139 		.num_of_raster_formats = ARRAY_SIZE(rga3_raster_format),
140 		.fbc_formats = rga3_fbcd_format,
141 		.num_of_fbc_formats = ARRAY_SIZE(rga3_fbcd_format),
142 		.tile_formats = rga3_tile_format,
143 		.num_of_tile_formats = ARRAY_SIZE(rga3_tile_format),
144 		.supported_rotations = 0,
145 		.scale_up_mode = RGA_SCALE_UP_NONE,
146 		.scale_down_mode = RGA_SCALE_DOWN_NONE,
147 		.rd_mode = RGA_RASTER_MODE | RGA_FBC_MODE | RGA_TILE_MODE,
148 
149 	},
150 };
151 
152 const struct rga_win_data rga2e_win_data[] = {
153 	{
154 		.name = "rga2e-src0",
155 		.raster_formats = rga2e_raster_format,
156 		.num_of_raster_formats = ARRAY_SIZE(rga2e_raster_format),
157 		.supported_rotations = RGA_MODE_ROTATE_MASK,
158 		.scale_up_mode = RGA_SCALE_UP_BIC,
159 		.scale_down_mode = RGA_SCALE_DOWN_AVG,
160 		.rd_mode = RGA_RASTER_MODE,
161 
162 	},
163 
164 	{
165 		.name = "rga2e-src1",
166 		.raster_formats = rga2e_raster_format,
167 		.num_of_raster_formats = ARRAY_SIZE(rga2e_raster_format),
168 		.supported_rotations = RGA_MODE_ROTATE_MASK,
169 		.scale_up_mode = RGA_SCALE_UP_BIC,
170 		.scale_down_mode = RGA_SCALE_DOWN_AVG,
171 		.rd_mode = RGA_RASTER_MODE,
172 
173 	},
174 
175 	{
176 		.name = "rga2-dst",
177 		.raster_formats = rga2e_raster_format,
178 		.num_of_raster_formats = ARRAY_SIZE(rga2e_raster_format),
179 		.supported_rotations = 0,
180 		.scale_up_mode = RGA_SCALE_UP_NONE,
181 		.scale_down_mode = RGA_SCALE_DOWN_NONE,
182 		.rd_mode = RGA_RASTER_MODE,
183 
184 	},
185 };
186 
187 const struct rga_hw_data rga3_data = {
188 	.version = 0,
189 	.min_input = { 128, 128 },
190 	.min_output = { 128, 128 },
191 	.max_input = { 8176, 8176 },
192 	.max_output = { 8128, 8128 },
193 
194 	.win = rga3_win_data,
195 	.win_size = ARRAY_SIZE(rga3_win_data),
196 	/* 1 << factor mean real factor */
197 	.max_upscale_factor = 3,
198 	.max_downscale_factor = 3,
199 
200 	.feature = RGA_COLOR_KEY,
201 	.csc_r2y_mode = RGA_MODE_CSC_BT601L |
202 		RGA_MODE_CSC_BT601F | RGA_MODE_CSC_BT709 |
203 		RGA_MODE_CSC_BT2020,
204 	.csc_y2r_mode = RGA_MODE_CSC_BT601L |
205 		RGA_MODE_CSC_BT601F | RGA_MODE_CSC_BT709 |
206 		RGA_MODE_CSC_BT2020,
207 };
208 
209 const struct rga_hw_data rga2e_data = {
210 	.version = 0,
211 	.min_input = { 0, 0 },
212 	.min_output = { 0, 0 },
213 	.max_input = { 8192, 8192 },
214 	.max_output = { 4096, 4096 },
215 
216 	.win = rga2e_win_data,
217 	.win_size = ARRAY_SIZE(rga2e_win_data),
218 	/* 1 << factor mean real factor */
219 	.max_upscale_factor = 4,
220 	.max_downscale_factor = 4,
221 
222 	.feature = RGA_COLOR_FILL | RGA_COLOR_PALETTE |
223 			RGA_COLOR_KEY | RGA_ROP_CALCULATE |
224 			RGA_NN_QUANTIZE | RGA_DITHER,
225 	.csc_r2y_mode = RGA_MODE_CSC_BT601L | RGA_MODE_CSC_BT601F |
226 					RGA_MODE_CSC_BT709,
227 	.csc_y2r_mode = RGA_MODE_CSC_BT601L | RGA_MODE_CSC_BT601F |
228 					RGA_MODE_CSC_BT709,
229 };
230 
231 
user_format_convert(uint32_t * df,uint32_t sf)232 void user_format_convert(uint32_t *df, uint32_t sf)
233 {
234 	switch (sf) {
235 	case 0x0:
236 		*df = RGA2_FORMAT_RGBA_8888;
237 		break;
238 	case 0x1:
239 		*df = RGA2_FORMAT_RGBX_8888;
240 		break;
241 	case 0x2:
242 		*df = RGA2_FORMAT_RGB_888;
243 		break;
244 	case 0x3:
245 		*df = RGA2_FORMAT_BGRA_8888;
246 		break;
247 	case 0x4:
248 		*df = RGA2_FORMAT_RGB_565;
249 		break;
250 	case 0x5:
251 		*df = RGA2_FORMAT_RGBA_5551;
252 		break;
253 	case 0x6:
254 		*df = RGA2_FORMAT_RGBA_4444;
255 		break;
256 	case 0x7:
257 		*df = RGA2_FORMAT_BGR_888;
258 		break;
259 	case 0x16:
260 		*df = RGA2_FORMAT_BGRX_8888;
261 		break;
262 	case 0x8:
263 		*df = RGA2_FORMAT_YCbCr_422_SP;
264 		break;
265 	case 0x9:
266 		*df = RGA2_FORMAT_YCbCr_422_P;
267 		break;
268 	case 0xa:
269 		*df = RGA2_FORMAT_YCbCr_420_SP;
270 		break;
271 	case 0xb:
272 		*df = RGA2_FORMAT_YCbCr_420_P;
273 		break;
274 	case 0xc:
275 		*df = RGA2_FORMAT_YCrCb_422_SP;
276 		break;
277 	case 0xd:
278 		*df = RGA2_FORMAT_YCrCb_422_P;
279 		break;
280 	case 0xe:
281 		*df = RGA2_FORMAT_YCrCb_420_SP;
282 		break;
283 	case 0xf:
284 		*df = RGA2_FORMAT_YCrCb_420_P;
285 		break;
286 
287 	case 0x10:
288 		*df = RGA2_FORMAT_BPP_1;
289 		break;
290 	case 0x11:
291 		*df = RGA2_FORMAT_BPP_2;
292 		break;
293 	case 0x12:
294 		*df = RGA2_FORMAT_BPP_4;
295 		break;
296 	case 0x13:
297 		*df = RGA2_FORMAT_BPP_8;
298 		break;
299 
300 	case 0x14:
301 		*df = RGA2_FORMAT_Y4;
302 		break;
303 	case 0x15:
304 		*df = RGA2_FORMAT_YCbCr_400;
305 		break;
306 
307 	case 0x18:
308 		*df = RGA2_FORMAT_YVYU_422;
309 		break;
310 	case 0x19:
311 		*df = RGA2_FORMAT_YVYU_420;
312 		break;
313 	case 0x1a:
314 		*df = RGA2_FORMAT_VYUY_422;
315 		break;
316 	case 0x1b:
317 		*df = RGA2_FORMAT_VYUY_420;
318 		break;
319 	case 0x1c:
320 		*df = RGA2_FORMAT_YUYV_422;
321 		break;
322 	case 0x1d:
323 		*df = RGA2_FORMAT_YUYV_420;
324 		break;
325 	case 0x1e:
326 		*df = RGA2_FORMAT_UYVY_422;
327 		break;
328 	case 0x1f:
329 		*df = RGA2_FORMAT_UYVY_420;
330 		break;
331 
332 	case 0x20:
333 		*df = RGA2_FORMAT_YCbCr_420_SP_10B;
334 		break;
335 	case 0x21:
336 		*df = RGA2_FORMAT_YCrCb_420_SP_10B;
337 		break;
338 	case 0x22:
339 		*df = RGA2_FORMAT_YCbCr_422_SP_10B;
340 		break;
341 	case 0x23:
342 		*df = RGA2_FORMAT_YCrCb_422_SP_10B;
343 		break;
344 
345 	case 0x24:
346 		*df = RGA2_FORMAT_BGR_565;
347 		break;
348 	case 0x25:
349 		*df = RGA2_FORMAT_BGRA_5551;
350 		break;
351 	case 0x26:
352 		*df = RGA2_FORMAT_BGRA_4444;
353 		break;
354 
355 	case 0x28:
356 		*df = RGA2_FORMAT_ARGB_8888;
357 		break;
358 	case 0x29:
359 		*df = RGA2_FORMAT_XRGB_8888;
360 		break;
361 	case 0x2a:
362 		*df = RGA2_FORMAT_ARGB_5551;
363 		break;
364 	case 0x2b:
365 		*df = RGA2_FORMAT_ARGB_4444;
366 		break;
367 	case 0x2c:
368 		*df = RGA2_FORMAT_ABGR_8888;
369 		break;
370 	case 0x2d:
371 		*df = RGA2_FORMAT_XBGR_8888;
372 		break;
373 	case 0x2e:
374 		*df = RGA2_FORMAT_ABGR_5551;
375 		break;
376 	case 0x2f:
377 		*df = RGA2_FORMAT_ABGR_4444;
378 		break;
379 	}
380 }
381