Jian Cao | b9fb3ed | 2019-04-16 16:51:27 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2014 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * This source code is subject to the terms and conditions defined in the |
| 5 | * file 'LICENSE' which is part of this source code package. |
| 6 | * |
| 7 | * Description: |
| 8 | */ |
| 9 | |
| 10 | #include <stdio.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <unistd.h> |
| 13 | #include <fcntl.h> |
| 14 | #include <malloc.h> |
| 15 | #include <string.h> |
| 16 | #include <sys/time.h> /* for gettimeofday() */ |
| 17 | #include "ge2d_port.h" |
| 18 | #include "aml_ge2d.h" |
| 19 | |
| 20 | /* #define FILE_DATA */ |
| 21 | static char SRC1_FILE_NAME[64] = "./fb1.rgb32"; |
| 22 | static char SRC2_FILE_NAME[64] = "./fb2.rgb32"; |
| 23 | static char DST_FILE_NAME[64] = "./out1.rgb32"; |
| 24 | |
| 25 | static int SX_SRC1 = 1920; |
| 26 | static int SY_SRC1 = 1080; |
| 27 | static int SX_SRC2 = 1920; |
| 28 | static int SY_SRC2 = 1080; |
| 29 | static int SX_DST = 1920; |
| 30 | static int SY_DST = 1080; |
| 31 | |
| 32 | static int src1_rect_x = 0; |
| 33 | static int src1_rect_y = 0; |
| 34 | static int src1_rect_w = 1920; |
| 35 | static int src1_rect_h = 1080; |
| 36 | static int src2_rect_x = 0; |
| 37 | static int src2_rect_y = 0; |
| 38 | static int src2_rect_w = 1920; |
| 39 | static int src2_rect_h = 1080; |
| 40 | static int dst_rect_x = 0; |
| 41 | static int dst_rect_y = 0; |
| 42 | static int dst_rect_w = 1920; |
| 43 | static int dst_rect_h = 1080; |
| 44 | static int rect_color = 0xff0000ff; |
| 45 | static int SRC1_PIXFORMAT = PIXEL_FORMAT_RGBA_8888; |
| 46 | static int SRC2_PIXFORMAT = PIXEL_FORMAT_RGBA_8888; |
| 47 | static int DST_PIXFORMAT = PIXEL_FORMAT_YV12; |
| 48 | static int src1_mem_alloc_type = AML_GE2D_MEM_DMABUF; |
| 49 | static int src2_mem_alloc_type = AML_GE2D_MEM_DMABUF; |
| 50 | static int dst_mem_alloc_type = AML_GE2D_MEM_DMABUF; |
| 51 | static int dst_canvas_alloc = 0; |
| 52 | static int src1_canvas_alloc = 1; |
| 53 | static int src2_canvas_alloc = 1; |
| 54 | static int OP = AML_GE2D_STRETCHBLIT; |
| 55 | static int src1_layer_mode = 0; |
| 56 | static int src2_layer_mode = 0; |
| 57 | static int gb1_alpha = 0xff; |
| 58 | static int gb2_alpha = 0xff; |
| 59 | static int cap_attr; |
| 60 | aml_ge2d_t amlge2d; |
| 61 | |
| 62 | static void set_ge2dinfo(aml_ge2d_info_t *pge2dinfo) |
| 63 | { |
| 64 | pge2dinfo->src_info[0].canvas_w = SX_SRC1; |
| 65 | pge2dinfo->src_info[0].canvas_h = SY_SRC1; |
| 66 | pge2dinfo->src_info[0].format = SRC1_PIXFORMAT; |
| 67 | |
| 68 | pge2dinfo->src_info[1].canvas_w = SX_SRC2; |
| 69 | pge2dinfo->src_info[1].canvas_h = SY_SRC2; |
| 70 | pge2dinfo->src_info[1].format = SRC2_PIXFORMAT; |
| 71 | |
| 72 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 73 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 74 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 75 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 76 | pge2dinfo->offset = 0; |
| 77 | pge2dinfo->ge2d_op = OP; |
| 78 | pge2dinfo->blend_mode = BLEND_MODE_PREMULTIPLIED; |
| 79 | |
| 80 | switch (pge2dinfo->ge2d_op) |
| 81 | { |
| 82 | case AML_GE2D_FILLRECTANGLE: |
| 83 | pge2dinfo->src_info[0].memtype = GE2D_CANVAS_TYPE_INVALID; |
| 84 | pge2dinfo->src_info[1].memtype = GE2D_CANVAS_TYPE_INVALID; |
| 85 | pge2dinfo->dst_info.memtype = dst_canvas_alloc == 1 ? GE2D_CANVAS_ALLOC : GE2D_CANVAS_OSD0; |
| 86 | break; |
| 87 | case AML_GE2D_BLIT: |
| 88 | case AML_GE2D_STRETCHBLIT: |
| 89 | /* if not need alloc, set to GE2D_CANVAS_TYPE_INVALID |
| 90 | * otherwise set to GE2D_CANVAS_ALLOC |
| 91 | */ |
| 92 | pge2dinfo->src_info[0].memtype = src1_canvas_alloc == 1 ? GE2D_CANVAS_ALLOC : GE2D_CANVAS_OSD0;; |
| 93 | pge2dinfo->src_info[1].memtype = GE2D_CANVAS_TYPE_INVALID; |
| 94 | pge2dinfo->dst_info.memtype = dst_canvas_alloc == 1 ? GE2D_CANVAS_ALLOC : GE2D_CANVAS_OSD0; |
| 95 | break; |
| 96 | case AML_GE2D_BLEND: |
| 97 | pge2dinfo->src_info[0].memtype = src1_canvas_alloc == 1 ? GE2D_CANVAS_ALLOC : GE2D_CANVAS_OSD0;; |
| 98 | pge2dinfo->src_info[1].memtype = src2_canvas_alloc == 1 ? GE2D_CANVAS_ALLOC : GE2D_CANVAS_OSD0;; |
| 99 | pge2dinfo->dst_info.memtype = dst_canvas_alloc == 1 ? GE2D_CANVAS_ALLOC : GE2D_CANVAS_OSD0; |
| 100 | break; |
| 101 | default: |
| 102 | E_GE2D("not support ge2d op,exit test!\n"); |
| 103 | break; |
| 104 | } |
| 105 | /*set to AML_GE2D_MEM_DMABUF or AML_GE2D_MEM_ION*/ |
| 106 | pge2dinfo->src_info[0].mem_alloc_type = src1_mem_alloc_type; |
| 107 | pge2dinfo->src_info[1].mem_alloc_type = src2_mem_alloc_type; |
| 108 | pge2dinfo->dst_info.mem_alloc_type = dst_mem_alloc_type; |
| 109 | } |
| 110 | |
| 111 | static void print_usage(void) |
| 112 | { |
| 113 | int i; |
| 114 | printf ("Usage: ge2d_feature_test [options]\n\n"); |
| 115 | printf ("Options:\n\n"); |
| 116 | printf (" --op <0:fillrect, 1:blend, 2:strechblit, 3:blit> ge2d operation case.\n"); |
| 117 | printf (" --size <WxH> define src1/src2/dst size.\n"); |
| 118 | printf (" --src1_memtype <0: ion, 1: dmabuf> define memory alloc type.\n"); |
| 119 | printf (" --src2_memtype <0: ion, 1: dmabuf> define memory alloc type.\n"); |
| 120 | printf (" --dst_memtype <0: ion, 1: dmabuf> define memory alloc type.\n"); |
| 121 | printf (" --src1_format <num> define src format.\n"); |
| 122 | printf (" --src2_format <num> define src2 format.\n"); |
| 123 | printf (" --dst_format <num> define dst format.\n"); |
| 124 | printf (" --src1_size <WxH> define src size.\n"); |
| 125 | printf (" --src2_size <WxH> define src2 size.\n"); |
| 126 | printf (" --dst_size <WxH> define dst size.\n"); |
| 127 | printf (" --src1_file <name> define src file.\n"); |
| 128 | printf (" --src2_file <name> define src2 file.\n"); |
| 129 | printf (" --dst_file <name> define dst file.\n"); |
| 130 | printf (" --src1_canvas_alloc <num> define whether src need alloc mem 0:GE2D_CANVAS_OSD0 1:GE2D_CANVAS_ALLOC.\n"); |
| 131 | printf (" --src2_canvas_alloc <num> defien whether src2 need alloc mem 0:GE2D_CANVAS_OSD0 1:GE2D_CANVAS_ALLOC.\n"); |
| 132 | printf (" --src1_rect <x_y_w_h> define src rect.\n"); |
| 133 | printf (" --src2_rect <x_y_w_h> define src2 rect.\n"); |
| 134 | printf (" --dst_rect <x_y_w_h> define dst rect.\n"); |
| 135 | printf (" --bo1 <layer_mode_num> define src1_layer_mode.\n"); |
| 136 | printf (" --bo2 <layer_mode_num> define src2_layer_mode.\n"); |
| 137 | printf (" --gb1 <gb1_alpha> define src1 global alpha.\n"); |
| 138 | printf (" --gb2 <gb2_alpha> define src2 global alpha.\n"); |
| 139 | printf (" --strechblit <x0_y0_w_h-x1_y1_w1_h1> define strechblit info.\n"); |
| 140 | printf (" --fillrect <color_x_y_w_h> define fillrect info, color in rgba format.\n"); |
| 141 | printf (" --help Print usage information.\n"); |
| 142 | printf ("\n"); |
| 143 | } |
| 144 | |
| 145 | static int parse_command_line(int argc, char *argv[]) |
| 146 | { |
| 147 | int i; |
| 148 | /* parse command line */ |
| 149 | for (i = 1; i < argc; i++) { |
| 150 | if (strncmp (argv[i], "--", 2) == 0) { |
| 151 | if (strcmp (argv[i] + 2, "help") == 0) { |
| 152 | print_usage(); |
| 153 | return ge2d_fail; |
| 154 | } |
| 155 | else if (strcmp (argv[i] + 2, "op") == 0 && ++i < argc && |
| 156 | sscanf (argv[i], "%d", &OP) == 1) { |
| 157 | continue; |
| 158 | } |
| 159 | else if (strcmp (argv[i] + 2, "src1_memtype") == 0 && ++i < argc && |
| 160 | sscanf (argv[i], "%d", &src1_mem_alloc_type) == 1) { |
| 161 | continue; |
| 162 | } |
| 163 | else if (strcmp (argv[i] + 2, "src2_memtype") == 0 && ++i < argc && |
| 164 | sscanf (argv[i], "%d", &src2_mem_alloc_type) == 1) { |
| 165 | continue; |
| 166 | } |
| 167 | else if (strcmp (argv[i] + 2, "dst_memtype") == 0 && ++i < argc && |
| 168 | sscanf (argv[i], "%d", &dst_mem_alloc_type) == 1) { |
| 169 | continue; |
| 170 | } |
| 171 | else if (strcmp (argv[i] + 2, "bo1") == 0 && ++i < argc && |
| 172 | sscanf (argv[i], "%d", &src1_layer_mode) == 1) { |
| 173 | continue; |
| 174 | } |
| 175 | else if (strcmp (argv[i] + 2, "bo2") == 0 && ++i < argc && |
| 176 | sscanf (argv[i], "%d", &src2_layer_mode) == 1) { |
| 177 | continue; |
| 178 | } |
| 179 | else if (strcmp (argv[i] + 2, "gb1") == 0 && ++i < argc && |
| 180 | sscanf (argv[i], "%d", &gb1_alpha) == 1) { |
| 181 | continue; |
| 182 | } |
| 183 | else if (strcmp (argv[i] + 2, "gb2") == 0 && ++i < argc && |
| 184 | sscanf (argv[i], "%d", &gb2_alpha) == 1) { |
| 185 | continue; |
| 186 | } |
| 187 | else if (strcmp (argv[i] + 2, "src1_format") == 0 && ++i < argc && |
| 188 | sscanf (argv[i], "%d", &SRC1_PIXFORMAT) == 1) { |
| 189 | continue; |
| 190 | } |
| 191 | else if (strcmp (argv[i] + 2, "src2_format") == 0 && ++i < argc && |
| 192 | sscanf (argv[i], "%d", &SRC2_PIXFORMAT) == 1) { |
| 193 | continue; |
| 194 | } |
| 195 | else if (strcmp (argv[i] + 2, "dst_format") == 0 && ++i < argc && |
| 196 | sscanf (argv[i], "%d", &DST_PIXFORMAT) == 1) { |
| 197 | continue; |
| 198 | } |
| 199 | else if (strcmp (argv[i] + 2, "size") == 0 && ++i < argc && |
| 200 | sscanf (argv[i], "%dx%d", &SX_SRC1, &SY_SRC1) == 2) { |
| 201 | SX_SRC2 = SX_DST = SX_SRC1; |
| 202 | SY_SRC2 = SY_DST = SY_SRC1; |
| 203 | continue; |
| 204 | } |
| 205 | else if (strcmp (argv[i] + 2, "dst_size") == 0 && ++i < argc && |
| 206 | sscanf (argv[i], "%dx%d", &SX_DST, &SY_DST) == 2) { |
| 207 | continue; |
| 208 | } |
| 209 | else if (strcmp (argv[i] + 2, "src1_size") == 0 && ++i < argc && |
| 210 | sscanf (argv[i], "%dx%d", &SX_SRC1, &SY_SRC1) == 2) { |
| 211 | continue; |
| 212 | } |
| 213 | else if (strcmp (argv[i] + 2, "src2_size") == 0 && ++i < argc && |
| 214 | sscanf (argv[i], "%dx%d", &SX_SRC2, &SY_SRC2) == 2) { |
| 215 | continue; |
| 216 | } |
| 217 | else if (strcmp (argv[i] + 2, "src1_rect") == 0 && ++i < argc && |
| 218 | sscanf (argv[i], "%d_%d_%d_%d", |
| 219 | &src1_rect_x, &src1_rect_y, &src1_rect_w, &src1_rect_h) == 4) { |
| 220 | continue; |
| 221 | } |
| 222 | else if (strcmp (argv[i] + 2, "src2_rect") == 0 && ++i < argc && |
| 223 | sscanf (argv[i], "%d_%d_%d_%d", |
| 224 | &src2_rect_x, &src2_rect_y, &src2_rect_w, &src2_rect_h) == 4) { |
| 225 | continue; |
| 226 | } |
| 227 | else if (strcmp (argv[i] + 2, "dst_rect") == 0 && ++i < argc && |
| 228 | sscanf (argv[i], "%d_%d_%d_%d", |
| 229 | &dst_rect_x, &dst_rect_y, &dst_rect_w, &dst_rect_h) == 4) { |
| 230 | continue; |
| 231 | } |
| 232 | else if (strcmp (argv[i] + 2, "strechblit") == 0 && ++i < argc && |
| 233 | sscanf (argv[i], "%d_%d_%d_%d-%d_%d_%d_%d", |
| 234 | &src1_rect_x, &src1_rect_y, &src1_rect_w, &src1_rect_h, |
| 235 | &dst_rect_x, &dst_rect_y, &dst_rect_w, &dst_rect_h) == 8) { |
| 236 | continue; |
| 237 | } |
| 238 | else if (strcmp (argv[i] + 2, "fillrect") == 0 && ++i < argc && |
| 239 | sscanf (argv[i], "%x_%d_%d_%d_%d", |
| 240 | &rect_color, &dst_rect_x, &dst_rect_y, &dst_rect_w, &dst_rect_h) == 5) { |
| 241 | continue; |
| 242 | } |
| 243 | else if (strcmp (argv[i] + 2, "src1_file") == 0 && ++i < argc && |
| 244 | sscanf (argv[i], "%s", &SRC1_FILE_NAME) == 1) { |
| 245 | continue; |
| 246 | } |
| 247 | else if (strcmp (argv[i] + 2, "src2_file") == 0 && ++i < argc && |
| 248 | sscanf (argv[i], "%s", &SRC2_FILE_NAME) == 1) { |
| 249 | continue; |
| 250 | } |
| 251 | else if (strcmp (argv[i] + 2, "dst_file") == 0 && ++i < argc && |
| 252 | sscanf (argv[i], "%s", &DST_FILE_NAME) == 1) { |
| 253 | dst_canvas_alloc = 1; |
| 254 | continue; |
| 255 | } |
| 256 | else if (strcmp (argv[i] + 2, "src1_canvas_alloc") == 0 && ++i < argc && |
| 257 | sscanf (argv[i], "%d", &src1_canvas_alloc) == 1) { |
| 258 | continue; |
| 259 | } |
| 260 | else if (strcmp (argv[i] + 2, "src2_canvas_alloc") == 0 && ++i < argc && |
| 261 | sscanf (argv[i], "%d", &src2_canvas_alloc) == 1) { |
| 262 | continue; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | return ge2d_success; |
| 267 | } |
| 268 | |
| 269 | |
| 270 | int aml_read_file_src1(const char* url , aml_ge2d_info_t *pge2dinfo) |
| 271 | { |
| 272 | int fd = -1; |
| 273 | int length = 0; |
| 274 | int read_num = 0; |
| 275 | if (amlge2d.src_size == 0) |
| 276 | return 0; |
| 277 | |
| 278 | fd = open(url,O_RDONLY ); |
| 279 | if (fd < 0) { |
| 280 | E_GE2D("read source file:%s open error\n",url); |
| 281 | return ge2d_fail; |
| 282 | } |
| 283 | |
| 284 | amlge2d.src_data = (char*)malloc(amlge2d.src_size); |
| 285 | if (!amlge2d.src_data) { |
| 286 | E_GE2D("malloc for src_data failed\n"); |
| 287 | return ge2d_fail; |
| 288 | } |
| 289 | |
| 290 | read_num = read(fd,amlge2d.src_data,amlge2d.src_size); |
| 291 | if (read_num <= 0) { |
| 292 | E_GE2D("read file read_num=%d error\n",read_num); |
| 293 | return ge2d_fail; |
| 294 | } |
| 295 | |
| 296 | memcpy(pge2dinfo->src_info[0].vaddr, amlge2d.src_data, amlge2d.src_size); |
| 297 | close(fd); |
| 298 | return ge2d_success; |
| 299 | } |
| 300 | |
| 301 | int aml_read_file_src2(const char* url , aml_ge2d_info_t *pge2dinfo) |
| 302 | { |
| 303 | int fd = -1; |
| 304 | int length = 0; |
| 305 | int read_num = 0; |
| 306 | if (amlge2d.src2_size == 0) |
| 307 | return 0; |
| 308 | |
| 309 | fd = open(url,O_RDONLY ); |
| 310 | if (fd < 0) { |
| 311 | E_GE2D("read source file:%s open error\n",url); |
| 312 | return ge2d_fail; |
| 313 | } |
| 314 | |
| 315 | amlge2d.src2_data = (char*)malloc(amlge2d.src2_size); |
| 316 | if (!amlge2d.src2_data) { |
| 317 | E_GE2D("malloc for src_data failed\n"); |
| 318 | return ge2d_fail; |
| 319 | } |
| 320 | |
| 321 | read_num = read(fd,amlge2d.src2_data,amlge2d.src2_size); |
| 322 | if (read_num <= 0) { |
| 323 | E_GE2D("read file read_num=%d error\n",read_num); |
| 324 | return ge2d_fail; |
| 325 | } |
| 326 | |
| 327 | memcpy(pge2dinfo->src_info[1].vaddr, amlge2d.src2_data, amlge2d.src2_size); |
| 328 | close(fd); |
| 329 | return ge2d_success; |
| 330 | } |
| 331 | |
| 332 | int aml_write_file(const char* url , aml_ge2d_info_t *pge2dinfo) |
| 333 | { |
| 334 | int fd = -1; |
| 335 | int length = 0; |
| 336 | int write_num = 0; |
| 337 | unsigned int *value; |
| 338 | if (amlge2d.dst_size == 0) |
| 339 | return 0; |
| 340 | if ((GE2D_CANVAS_OSD0 == pge2dinfo->dst_info.memtype) |
| 341 | || (GE2D_CANVAS_OSD1 == pge2dinfo->dst_info.memtype)) |
| 342 | return 0; |
| 343 | |
| 344 | fd = open(url,O_RDWR | O_CREAT,0660); |
| 345 | if (fd < 0) { |
| 346 | E_GE2D("write file:%s open error\n",url); |
| 347 | return ge2d_fail; |
| 348 | } |
| 349 | |
| 350 | amlge2d.dst_data = (char*)malloc(amlge2d.dst_size); |
| 351 | if (!amlge2d.dst_data) { |
| 352 | E_GE2D("malloc for dst_data failed\n"); |
| 353 | return ge2d_fail; |
| 354 | } |
| 355 | |
| 356 | memcpy(amlge2d.dst_data,pge2dinfo->dst_info.vaddr,amlge2d.dst_size); |
| 357 | printf("pixel: 0x%2x, 0x%2x,0x%2x,0x%2x, 0x%2x,0x%2x,0x%2x,0x%2x\n", |
| 358 | amlge2d.dst_data[0], |
| 359 | amlge2d.dst_data[1], |
| 360 | amlge2d.dst_data[2], |
| 361 | amlge2d.dst_data[3], |
| 362 | amlge2d.dst_data[4], |
| 363 | amlge2d.dst_data[5], |
| 364 | amlge2d.dst_data[6], |
| 365 | amlge2d.dst_data[7]); |
| 366 | write_num = write(fd,amlge2d.dst_data,amlge2d.dst_size); |
| 367 | if (write_num <= 0) { |
| 368 | E_GE2D("write file write_num=%d error\n",write_num); |
| 369 | } |
| 370 | close(fd); |
| 371 | return ge2d_success; |
| 372 | } |
| 373 | |
| 374 | |
| 375 | static int do_fill_rectangle(aml_ge2d_info_t *pge2dinfo) |
| 376 | { |
| 377 | int ret = -1; |
| 378 | char code; |
| 379 | |
| 380 | printf("do_fill_rectangle test case:\n"); |
| 381 | |
| 382 | pge2dinfo->color = rect_color; |
| 383 | pge2dinfo->dst_info.rect.x = dst_rect_x; |
| 384 | pge2dinfo->dst_info.rect.y = dst_rect_x; |
| 385 | pge2dinfo->dst_info.rect.w = dst_rect_w; |
| 386 | pge2dinfo->dst_info.rect.h = dst_rect_h; |
| 387 | ret = aml_ge2d_process(pge2dinfo); |
| 388 | #if 0 |
| 389 | sleep(5); |
| 390 | |
| 391 | printf("please enter any key do rotation test[90]\n"); |
| 392 | code = getc(stdin); |
| 393 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_180; |
| 394 | ret = aml_ge2d_process(pge2dinfo); |
| 395 | #endif |
| 396 | if (ret < 0) |
| 397 | printf("%s failed\n", __func__); |
| 398 | return ret; |
| 399 | } |
| 400 | |
| 401 | |
| 402 | static int do_blend(aml_ge2d_info_t *pge2dinfo) |
| 403 | { |
| 404 | int ret = -1; |
| 405 | char code = 0; |
| 406 | int shared_fd_bakup; |
| 407 | unsigned long offset_bakup = 0; |
| 408 | printf("do_blend test case:\n"); |
| 409 | |
| 410 | if (cap_attr == 0x1) { |
| 411 | /* do blend src1 blend src2(dst) to dst */ |
| 412 | printf("one step blend\n"); |
| 413 | ret = aml_read_file_src1(SRC1_FILE_NAME,pge2dinfo); |
| 414 | if (ret < 0) |
| 415 | return ge2d_fail; |
| 416 | ret = aml_read_file_src2(SRC2_FILE_NAME,pge2dinfo); |
| 417 | if (ret < 0) |
| 418 | return ge2d_fail; |
| 419 | |
| 420 | pge2dinfo->src_info[0].rect.x = src1_rect_x; |
| 421 | pge2dinfo->src_info[0].rect.y = src1_rect_y; |
| 422 | pge2dinfo->src_info[0].rect.w = src1_rect_w; |
| 423 | pge2dinfo->src_info[0].rect.h = src1_rect_h; |
| 424 | pge2dinfo->src_info[0].fill_color_en = 0; |
| 425 | |
| 426 | pge2dinfo->src_info[1].rect.x = src2_rect_x; |
| 427 | pge2dinfo->src_info[1].rect.y = src2_rect_y; |
| 428 | pge2dinfo->src_info[1].rect.w = src2_rect_w; |
| 429 | pge2dinfo->src_info[1].rect.h = src2_rect_h; |
| 430 | pge2dinfo->src_info[1].fill_color_en = 0; |
| 431 | if ((src2_layer_mode == LAYER_MODE_NON) && (src1_layer_mode == LAYER_MODE_PREMULTIPLIED)) |
| 432 | pge2dinfo->src_info[0].format = PIXEL_FORMAT_RGBX_8888; |
| 433 | |
| 434 | pge2dinfo->dst_info.rect.x = dst_rect_x; |
| 435 | pge2dinfo->dst_info.rect.y = dst_rect_y; |
| 436 | pge2dinfo->dst_info.rect.w = dst_rect_w; |
| 437 | pge2dinfo->dst_info.rect.h = dst_rect_h; |
| 438 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 439 | |
| 440 | pge2dinfo->src_info[0].layer_mode = src1_layer_mode; |
| 441 | pge2dinfo->src_info[1].layer_mode = src2_layer_mode; |
| 442 | pge2dinfo->src_info[0].plane_alpha = gb1_alpha; |
| 443 | pge2dinfo->src_info[1].plane_alpha = gb2_alpha; |
| 444 | ret = aml_ge2d_process(pge2dinfo); |
| 445 | } else { |
| 446 | if (((gb1_alpha != 0xff) |
| 447 | && (gb2_alpha != 0xff))){ |
| 448 | printf("two steps blend,two plane alpha\n"); |
| 449 | |
| 450 | if (src2_layer_mode == LAYER_MODE_COVERAGE) { |
| 451 | printf("two steps blend,src2 LAYER_MODE_COVERAGE\n"); |
| 452 | ret = aml_read_file_src1(SRC2_FILE_NAME,pge2dinfo); |
| 453 | if (ret < 0) |
| 454 | return ge2d_fail; |
| 455 | |
| 456 | /* both plane alpha, do 2 steps */ |
| 457 | /* step 1: strechbilt */ |
| 458 | pge2dinfo->ge2d_op = AML_GE2D_BLEND; |
| 459 | /* src2 do strechbilt to dst */ |
| 460 | pge2dinfo->src_info[0].canvas_w = SX_SRC1; |
| 461 | pge2dinfo->src_info[0].canvas_h = SY_SRC1; |
| 462 | pge2dinfo->src_info[0].format = SRC1_PIXFORMAT; |
| 463 | pge2dinfo->src_info[0].rect.x = 0; |
| 464 | pge2dinfo->src_info[0].rect.y = 0; |
| 465 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 466 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 467 | pge2dinfo->src_info[0].fill_color_en = 0; |
| 468 | |
| 469 | pge2dinfo->src_info[1].canvas_w = SX_DST; |
| 470 | pge2dinfo->src_info[1].canvas_h = SY_DST; |
| 471 | pge2dinfo->src_info[1].format = DST_PIXFORMAT; |
| 472 | pge2dinfo->src_info[1].rect.x = 0; |
| 473 | pge2dinfo->src_info[1].rect.y = 0; |
| 474 | pge2dinfo->src_info[1].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 475 | pge2dinfo->src_info[1].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 476 | pge2dinfo->src_info[1].fill_color_en = 1; |
| 477 | pge2dinfo->src_info[1].def_color = 0x00; |
| 478 | |
| 479 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 480 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 481 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 482 | pge2dinfo->dst_info.rect.x = 0; |
| 483 | pge2dinfo->dst_info.rect.y = 0; |
| 484 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 485 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 486 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 487 | |
| 488 | pge2dinfo->src_info[0].layer_mode = LAYER_MODE_COVERAGE; |
| 489 | pge2dinfo->src_info[1].layer_mode = LAYER_MODE_COVERAGE; |
| 490 | pge2dinfo->src_info[0].plane_alpha = gb2_alpha; |
| 491 | pge2dinfo->src_info[1].plane_alpha = 0xff; |
| 492 | ret = aml_ge2d_process(pge2dinfo); |
| 493 | ret = aml_read_file_src1(SRC1_FILE_NAME,pge2dinfo); |
| 494 | if (ret < 0) |
| 495 | return ge2d_fail; |
| 496 | |
| 497 | /* step2: blend src1 blend src2(dst) to dst */ |
| 498 | pge2dinfo->ge2d_op = AML_GE2D_BLEND; |
| 499 | |
| 500 | pge2dinfo->src_info[0].canvas_w = SX_SRC1; |
| 501 | pge2dinfo->src_info[0].canvas_h = SY_SRC1; |
| 502 | pge2dinfo->src_info[0].format = SRC1_PIXFORMAT; |
| 503 | pge2dinfo->src_info[0].rect.x = 0; |
| 504 | pge2dinfo->src_info[0].rect.y = 0; |
| 505 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 506 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 507 | pge2dinfo->src_info[0].fill_color_en = 0; |
| 508 | |
| 509 | pge2dinfo->src_info[1].canvas_w = pge2dinfo->dst_info.canvas_w; |
| 510 | pge2dinfo->src_info[1].canvas_h = pge2dinfo->dst_info.canvas_h; |
| 511 | pge2dinfo->src_info[1].format = pge2dinfo->dst_info.format; |
| 512 | pge2dinfo->src_info[1].rect.x = pge2dinfo->dst_info.rect.x; |
| 513 | pge2dinfo->src_info[1].rect.y = pge2dinfo->dst_info.rect.y; |
| 514 | pge2dinfo->src_info[1].rect.w = pge2dinfo->dst_info.rect.w; |
| 515 | pge2dinfo->src_info[1].rect.h = pge2dinfo->dst_info.rect.h; |
| 516 | pge2dinfo->src_info[1].shared_fd = pge2dinfo->dst_info.shared_fd; |
| 517 | pge2dinfo->src_info[1].offset = pge2dinfo->dst_info.offset; |
| 518 | pge2dinfo->src_info[1].fill_color_en = 0; |
| 519 | |
| 520 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 521 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 522 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 523 | pge2dinfo->dst_info.rect.x = 0; |
| 524 | pge2dinfo->dst_info.rect.y = 0; |
| 525 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 526 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 527 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 528 | |
| 529 | pge2dinfo->src_info[0].layer_mode = src1_layer_mode; |
| 530 | pge2dinfo->src_info[1].layer_mode = src2_layer_mode; |
| 531 | pge2dinfo->src_info[0].plane_alpha = gb1_alpha; |
| 532 | pge2dinfo->src_info[1].plane_alpha = gb2_alpha; |
| 533 | ret = aml_ge2d_process(pge2dinfo); |
| 534 | } else { |
| 535 | ret = aml_read_file_src1(SRC1_FILE_NAME,pge2dinfo); |
| 536 | if (ret < 0) |
| 537 | return ge2d_fail; |
| 538 | ret = aml_read_file_src2(SRC2_FILE_NAME,pge2dinfo); |
| 539 | if (ret < 0) |
| 540 | return ge2d_fail; |
| 541 | printf("two step: strechbilt+blend\n"); |
| 542 | /* both plane alpha, do 2 steps */ |
| 543 | /* step 1: strechbilt */ |
| 544 | pge2dinfo->ge2d_op = AML_GE2D_STRETCHBLIT; |
| 545 | /* src2 do strechbilt to dst */ |
| 546 | pge2dinfo->src_info[0].canvas_w = SX_SRC2; |
| 547 | pge2dinfo->src_info[0].canvas_h = SY_SRC2; |
| 548 | pge2dinfo->src_info[0].format = SRC2_PIXFORMAT; |
| 549 | pge2dinfo->src_info[0].rect.x = 0; |
| 550 | pge2dinfo->src_info[0].rect.y = 0; |
| 551 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 552 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 553 | |
| 554 | shared_fd_bakup = pge2dinfo->src_info[0].shared_fd; |
| 555 | offset_bakup = pge2dinfo->src_info[0].offset; |
| 556 | pge2dinfo->src_info[0].shared_fd = pge2dinfo->src_info[1].shared_fd; |
| 557 | pge2dinfo->src_info[0].offset = pge2dinfo->src_info[1].offset; |
| 558 | |
| 559 | pge2dinfo->src_info[0].layer_mode = src2_layer_mode; |
| 560 | pge2dinfo->src_info[0].plane_alpha = gb2_alpha; |
| 561 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 562 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 563 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 564 | pge2dinfo->dst_info.rect.x = 0; |
| 565 | pge2dinfo->dst_info.rect.y = 0; |
| 566 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 567 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 568 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 569 | ret = aml_ge2d_process(pge2dinfo); |
| 570 | |
| 571 | /* step2: blend src1 blend src2(dst) to dst */ |
| 572 | pge2dinfo->ge2d_op = AML_GE2D_BLEND; |
| 573 | |
| 574 | pge2dinfo->src_info[0].canvas_w = SX_SRC1; |
| 575 | pge2dinfo->src_info[0].canvas_h = SY_SRC1; |
| 576 | pge2dinfo->src_info[0].format = SRC1_PIXFORMAT; |
| 577 | pge2dinfo->src_info[0].rect.x = 0; |
| 578 | pge2dinfo->src_info[0].rect.y = 0; |
| 579 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 580 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 581 | pge2dinfo->src_info[0].shared_fd = shared_fd_bakup; |
| 582 | pge2dinfo->src_info[0].offset = offset_bakup; |
| 583 | pge2dinfo->src_info[0].fill_color_en = 0; |
| 584 | |
| 585 | pge2dinfo->src_info[1].canvas_w = pge2dinfo->dst_info.canvas_w; |
| 586 | pge2dinfo->src_info[1].canvas_h = pge2dinfo->dst_info.canvas_h; |
| 587 | pge2dinfo->src_info[1].format = pge2dinfo->dst_info.format; |
| 588 | pge2dinfo->src_info[1].rect.x = pge2dinfo->dst_info.rect.x; |
| 589 | pge2dinfo->src_info[1].rect.y = pge2dinfo->dst_info.rect.y; |
| 590 | pge2dinfo->src_info[1].rect.w = pge2dinfo->dst_info.rect.w; |
| 591 | pge2dinfo->src_info[1].rect.h = pge2dinfo->dst_info.rect.h; |
| 592 | pge2dinfo->src_info[1].shared_fd = pge2dinfo->dst_info.shared_fd; |
| 593 | pge2dinfo->src_info[1].offset = pge2dinfo->dst_info.offset; |
| 594 | pge2dinfo->src_info[1].fill_color_en = 0; |
| 595 | |
| 596 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 597 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 598 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 599 | pge2dinfo->dst_info.rect.x = 0; |
| 600 | pge2dinfo->dst_info.rect.y = 0; |
| 601 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 602 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 603 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 604 | |
| 605 | pge2dinfo->src_info[0].layer_mode = src1_layer_mode; |
| 606 | pge2dinfo->src_info[1].layer_mode = src2_layer_mode; |
| 607 | pge2dinfo->src_info[0].plane_alpha = gb1_alpha; |
| 608 | pge2dinfo->src_info[1].plane_alpha = gb2_alpha; |
| 609 | ret = aml_ge2d_process(pge2dinfo); |
| 610 | } |
| 611 | } else if (src2_layer_mode == LAYER_MODE_COVERAGE){ |
| 612 | printf("two steps blend,src2 LAYER_MODE_COVERAGE: two blend\n"); |
| 613 | ret = aml_read_file_src1(SRC2_FILE_NAME,pge2dinfo); |
| 614 | if (ret < 0) |
| 615 | return ge2d_fail; |
| 616 | /* both plane alpha, do 2 steps */ |
| 617 | /* step 1: strechbilt */ |
| 618 | pge2dinfo->ge2d_op = AML_GE2D_BLEND; |
| 619 | /* src2 do strechbilt to dst */ |
| 620 | pge2dinfo->src_info[0].canvas_w = SX_SRC1; |
| 621 | pge2dinfo->src_info[0].canvas_h = SY_SRC1; |
| 622 | pge2dinfo->src_info[0].format = SRC1_PIXFORMAT; |
| 623 | pge2dinfo->src_info[0].rect.x = 0; |
| 624 | pge2dinfo->src_info[0].rect.y = 0; |
| 625 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 626 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 627 | pge2dinfo->src_info[0].fill_color_en = 0; |
| 628 | |
| 629 | pge2dinfo->src_info[1].canvas_w = SX_DST; |
| 630 | pge2dinfo->src_info[1].canvas_h = SY_DST; |
| 631 | pge2dinfo->src_info[1].format = DST_PIXFORMAT; |
| 632 | pge2dinfo->src_info[1].rect.x = 0; |
| 633 | pge2dinfo->src_info[1].rect.y = 0; |
| 634 | pge2dinfo->src_info[1].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 635 | pge2dinfo->src_info[1].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 636 | pge2dinfo->src_info[1].fill_color_en = 1; |
| 637 | pge2dinfo->src_info[1].def_color = 0x00; |
| 638 | |
| 639 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 640 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 641 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 642 | pge2dinfo->dst_info.rect.x = 0; |
| 643 | pge2dinfo->dst_info.rect.y = 0; |
| 644 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 645 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 646 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 647 | |
| 648 | pge2dinfo->src_info[0].layer_mode = LAYER_MODE_COVERAGE; |
| 649 | pge2dinfo->src_info[1].layer_mode = LAYER_MODE_COVERAGE; |
| 650 | pge2dinfo->src_info[0].plane_alpha = gb2_alpha; |
| 651 | pge2dinfo->src_info[1].plane_alpha = 0xff; |
| 652 | ret = aml_ge2d_process(pge2dinfo); |
| 653 | ret = aml_read_file_src1(SRC1_FILE_NAME,pge2dinfo); |
| 654 | if (ret < 0) |
| 655 | return ge2d_fail; |
| 656 | /* step2: blend src1 blend src2(dst) to dst */ |
| 657 | pge2dinfo->ge2d_op = AML_GE2D_BLEND; |
| 658 | |
| 659 | pge2dinfo->src_info[0].canvas_w = SX_SRC1; |
| 660 | pge2dinfo->src_info[0].canvas_h = SY_SRC1; |
| 661 | pge2dinfo->src_info[0].format = SRC1_PIXFORMAT; |
| 662 | pge2dinfo->src_info[0].rect.x = 0; |
| 663 | pge2dinfo->src_info[0].rect.y = 0; |
| 664 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 665 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 666 | pge2dinfo->src_info[0].fill_color_en = 0; |
| 667 | |
| 668 | pge2dinfo->src_info[1].canvas_w = pge2dinfo->dst_info.canvas_w; |
| 669 | pge2dinfo->src_info[1].canvas_h = pge2dinfo->dst_info.canvas_h; |
| 670 | pge2dinfo->src_info[1].format = pge2dinfo->dst_info.format; |
| 671 | pge2dinfo->src_info[1].rect.x = pge2dinfo->dst_info.rect.x; |
| 672 | pge2dinfo->src_info[1].rect.y = pge2dinfo->dst_info.rect.y; |
| 673 | pge2dinfo->src_info[1].rect.w = pge2dinfo->dst_info.rect.w; |
| 674 | pge2dinfo->src_info[1].rect.h = pge2dinfo->dst_info.rect.h; |
| 675 | pge2dinfo->src_info[1].shared_fd = pge2dinfo->dst_info.shared_fd; |
| 676 | pge2dinfo->src_info[1].offset = pge2dinfo->dst_info.offset; |
| 677 | pge2dinfo->src_info[1].fill_color_en = 0; |
| 678 | |
| 679 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 680 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 681 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 682 | pge2dinfo->dst_info.rect.x = 0; |
| 683 | pge2dinfo->dst_info.rect.y = 0; |
| 684 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 685 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 686 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 687 | |
| 688 | pge2dinfo->src_info[0].layer_mode = src1_layer_mode; |
| 689 | pge2dinfo->src_info[1].layer_mode = src2_layer_mode; |
| 690 | pge2dinfo->src_info[0].plane_alpha = gb1_alpha; |
| 691 | pge2dinfo->src_info[1].plane_alpha = gb2_alpha; |
| 692 | ret = aml_ge2d_process(pge2dinfo); |
| 693 | } else if ((src2_layer_mode == LAYER_MODE_NON) |
| 694 | && (src1_layer_mode != LAYER_MODE_PREMULTIPLIED)){ |
| 695 | printf("two steps blend,src2 LAYER_MODE_NON:strechbilt+blend\n"); |
| 696 | ret = aml_read_file_src1(SRC1_FILE_NAME,pge2dinfo); |
| 697 | if (ret < 0) |
| 698 | return ge2d_fail; |
| 699 | ret = aml_read_file_src2(SRC2_FILE_NAME,pge2dinfo); |
| 700 | if (ret < 0) |
| 701 | return ge2d_fail; |
| 702 | /* both plane alpha, do 2 steps */ |
| 703 | /* step 1: strechbilt */ |
| 704 | pge2dinfo->ge2d_op = AML_GE2D_STRETCHBLIT; |
| 705 | /* src2 do strechbilt to dst */ |
| 706 | pge2dinfo->src_info[0].canvas_w = SX_SRC2; |
| 707 | pge2dinfo->src_info[0].canvas_h = SY_SRC2; |
| 708 | pge2dinfo->src_info[0].format = SRC2_PIXFORMAT; |
| 709 | pge2dinfo->src_info[0].rect.x = 0; |
| 710 | pge2dinfo->src_info[0].rect.y = 0; |
| 711 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 712 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 713 | |
| 714 | shared_fd_bakup = pge2dinfo->src_info[0].shared_fd; |
| 715 | offset_bakup = pge2dinfo->src_info[0].offset; |
| 716 | pge2dinfo->src_info[0].shared_fd = pge2dinfo->src_info[1].shared_fd; |
| 717 | pge2dinfo->src_info[0].offset = pge2dinfo->src_info[1].offset; |
| 718 | pge2dinfo->src_info[0].layer_mode = src2_layer_mode; |
| 719 | pge2dinfo->src_info[0].plane_alpha = 0xff; |
| 720 | pge2dinfo->src_info[0].format = PIXEL_FORMAT_RGBX_8888; |
| 721 | |
| 722 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 723 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 724 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 725 | pge2dinfo->dst_info.rect.x = 0; |
| 726 | pge2dinfo->dst_info.rect.y = 0; |
| 727 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 728 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 729 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 730 | ret = aml_ge2d_process(pge2dinfo); |
| 731 | |
| 732 | /* step2: blend src1 blend src2(dst) to dst */ |
| 733 | pge2dinfo->ge2d_op = AML_GE2D_BLEND; |
| 734 | |
| 735 | pge2dinfo->src_info[0].canvas_w = SX_SRC1; |
| 736 | pge2dinfo->src_info[0].canvas_h = SY_SRC1; |
| 737 | pge2dinfo->src_info[0].format = SRC1_PIXFORMAT; |
| 738 | pge2dinfo->src_info[0].rect.x = 0; |
| 739 | pge2dinfo->src_info[0].rect.y = 0; |
| 740 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 741 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 742 | pge2dinfo->src_info[0].shared_fd = shared_fd_bakup; |
| 743 | pge2dinfo->src_info[0].offset = offset_bakup; |
| 744 | pge2dinfo->src_info[0].fill_color_en = 0; |
| 745 | |
| 746 | pge2dinfo->src_info[1].canvas_w = pge2dinfo->dst_info.canvas_w; |
| 747 | pge2dinfo->src_info[1].canvas_h = pge2dinfo->dst_info.canvas_h; |
| 748 | pge2dinfo->src_info[1].format = pge2dinfo->dst_info.format; |
| 749 | pge2dinfo->src_info[1].rect.x = pge2dinfo->dst_info.rect.x; |
| 750 | pge2dinfo->src_info[1].rect.y = pge2dinfo->dst_info.rect.y; |
| 751 | pge2dinfo->src_info[1].rect.w = pge2dinfo->dst_info.rect.w; |
| 752 | pge2dinfo->src_info[1].rect.h = pge2dinfo->dst_info.rect.h; |
| 753 | pge2dinfo->src_info[1].shared_fd = pge2dinfo->dst_info.shared_fd; |
| 754 | pge2dinfo->src_info[1].offset = pge2dinfo->dst_info.offset; |
| 755 | pge2dinfo->src_info[1].fill_color_en = 0; |
| 756 | |
| 757 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 758 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 759 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 760 | pge2dinfo->dst_info.rect.x = 0; |
| 761 | pge2dinfo->dst_info.rect.y = 0; |
| 762 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 763 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 764 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 765 | printf("two steps blend,src1_layer_mode=%d,src2_layer_mode=%d\n",src1_layer_mode,src2_layer_mode); |
| 766 | |
| 767 | pge2dinfo->src_info[0].layer_mode = src1_layer_mode; |
| 768 | pge2dinfo->src_info[1].layer_mode = src2_layer_mode; |
| 769 | pge2dinfo->src_info[0].plane_alpha = gb1_alpha; |
| 770 | pge2dinfo->src_info[1].plane_alpha = gb2_alpha; |
| 771 | ret = aml_ge2d_process(pge2dinfo); |
| 772 | } else { |
| 773 | /* do blend src1 blend src2(dst) to dst */ |
| 774 | printf("one step blend\n"); |
| 775 | ret = aml_read_file_src1(SRC1_FILE_NAME,pge2dinfo); |
| 776 | if (ret < 0) |
| 777 | return ge2d_fail; |
| 778 | ret = aml_read_file_src2(SRC2_FILE_NAME,pge2dinfo); |
| 779 | if (ret < 0) |
| 780 | return ge2d_fail; |
| 781 | pge2dinfo->src_info[0].canvas_w = SX_SRC1; |
| 782 | pge2dinfo->src_info[0].canvas_h = SY_SRC1; |
| 783 | pge2dinfo->src_info[0].format = SRC1_PIXFORMAT; |
| 784 | pge2dinfo->src_info[0].rect.x = 0; |
| 785 | pge2dinfo->src_info[0].rect.y = 0; |
| 786 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 787 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 788 | pge2dinfo->src_info[0].fill_color_en = 0; |
| 789 | |
| 790 | pge2dinfo->src_info[1].canvas_w = SX_SRC2; |
| 791 | pge2dinfo->src_info[1].canvas_h = SY_SRC2; |
| 792 | pge2dinfo->src_info[1].format = SRC2_PIXFORMAT; |
| 793 | pge2dinfo->src_info[1].rect.x = 0; |
| 794 | pge2dinfo->src_info[1].rect.y = 0; |
| 795 | pge2dinfo->src_info[1].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 796 | pge2dinfo->src_info[1].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 797 | pge2dinfo->src_info[1].fill_color_en = 0; |
| 798 | if (src2_layer_mode == LAYER_MODE_NON) |
| 799 | pge2dinfo->src_info[0].format = PIXEL_FORMAT_RGBX_8888; |
| 800 | pge2dinfo->dst_info.canvas_w = SX_DST; |
| 801 | pge2dinfo->dst_info.canvas_h = SY_DST; |
| 802 | pge2dinfo->dst_info.format = DST_PIXFORMAT; |
| 803 | pge2dinfo->dst_info.rect.x = 0; |
| 804 | pge2dinfo->dst_info.rect.y = 0; |
| 805 | pge2dinfo->dst_info.rect.w = pge2dinfo->src_info[0].canvas_w; |
| 806 | pge2dinfo->dst_info.rect.h = pge2dinfo->src_info[0].canvas_h; |
| 807 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 808 | |
| 809 | pge2dinfo->src_info[0].layer_mode = src1_layer_mode; |
| 810 | pge2dinfo->src_info[1].layer_mode = src2_layer_mode; |
| 811 | pge2dinfo->src_info[0].plane_alpha = gb1_alpha; |
| 812 | pge2dinfo->src_info[1].plane_alpha = gb2_alpha; |
| 813 | ret = aml_ge2d_process(pge2dinfo); |
| 814 | } |
| 815 | } |
| 816 | if (ret < 0) |
| 817 | printf("%s failed\n", __func__); |
| 818 | return ret; |
| 819 | } |
| 820 | |
| 821 | |
| 822 | static int do_strechblit(aml_ge2d_info_t *pge2dinfo) |
| 823 | { |
| 824 | int ret = -1; |
| 825 | char code = 0; |
| 826 | printf("do_strechblit test case:\n"); |
| 827 | ret = aml_read_file_src1(SRC1_FILE_NAME,pge2dinfo); |
| 828 | if (ret < 0) |
| 829 | return ge2d_fail; |
| 830 | |
| 831 | pge2dinfo->src_info[0].rect.x = src1_rect_x; |
| 832 | pge2dinfo->src_info[0].rect.y = src1_rect_y; |
| 833 | pge2dinfo->src_info[0].rect.w = src1_rect_w; |
| 834 | pge2dinfo->src_info[0].rect.h = src1_rect_h; |
| 835 | pge2dinfo->dst_info.rect.x = dst_rect_x; |
| 836 | pge2dinfo->dst_info.rect.y = dst_rect_y; |
| 837 | pge2dinfo->dst_info.rect.w = dst_rect_w; |
| 838 | pge2dinfo->dst_info.rect.h = dst_rect_h; |
| 839 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 840 | pge2dinfo->src_info[0].layer_mode = src1_layer_mode; |
| 841 | pge2dinfo->src_info[0].plane_alpha = gb1_alpha; |
| 842 | |
| 843 | ret = aml_ge2d_process(pge2dinfo); |
| 844 | #if 0 |
| 845 | sleep(5); |
| 846 | |
| 847 | printf("please enter any key do rotation test[90]\n"); |
| 848 | code = getc(stdin); |
| 849 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_90; |
| 850 | ret = aml_ge2d_process(pge2dinfo); |
| 851 | #endif |
| 852 | if (ret < 0) |
| 853 | printf("%s failed\n", __func__); |
| 854 | return ret; |
| 855 | |
| 856 | } |
| 857 | |
| 858 | static int do_blit(aml_ge2d_info_t *pge2dinfo) |
| 859 | { |
| 860 | int ret = -1; |
| 861 | char code = 0; |
| 862 | printf("do_blit test case:\n"); |
| 863 | ret = aml_read_file_src1(SRC1_FILE_NAME,pge2dinfo); |
| 864 | if (ret < 0) |
| 865 | return ge2d_fail; |
| 866 | |
| 867 | pge2dinfo->src_info[0].rect.x = src1_rect_x; |
| 868 | pge2dinfo->src_info[0].rect.y = src1_rect_y; |
| 869 | pge2dinfo->src_info[0].rect.w = src1_rect_w; |
| 870 | pge2dinfo->src_info[0].rect.h = src1_rect_h; |
| 871 | pge2dinfo->dst_info.rect.x = dst_rect_x; |
| 872 | pge2dinfo->dst_info.rect.y = dst_rect_y; |
| 873 | |
| 874 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_0; |
| 875 | pge2dinfo->src_info[0].layer_mode = src1_layer_mode; |
| 876 | pge2dinfo->src_info[0].plane_alpha = gb1_alpha; |
| 877 | |
| 878 | ret = aml_ge2d_process(pge2dinfo); |
| 879 | #if 0 |
| 880 | sleep(5); |
| 881 | |
| 882 | printf("please enter any key do rotation test[90]\n"); |
| 883 | code = getc(stdin); |
| 884 | pge2dinfo->dst_info.rotation = GE2D_ROTATION_90; |
| 885 | pge2dinfo->src_info[0].rect.x = 0; |
| 886 | pge2dinfo->src_info[0].rect.y = 0; |
| 887 | pge2dinfo->src_info[0].rect.w = pge2dinfo->src_info[0].canvas_w; |
| 888 | pge2dinfo->src_info[0].rect.h = pge2dinfo->src_info[0].canvas_h; |
| 889 | pge2dinfo->dst_info.rect.x = 0; |
| 890 | pge2dinfo->dst_info.rect.y = 0; |
| 891 | |
| 892 | ret = aml_ge2d_process(pge2dinfo); |
| 893 | #endif |
| 894 | if (ret < 0) |
| 895 | printf("%s failed\n", __func__); |
| 896 | return ret; |
| 897 | } |
| 898 | |
| 899 | int main(int argc, char **argv) |
| 900 | { |
| 901 | int ret = -1; |
| 902 | int i = 0; |
| 903 | unsigned long stime; |
| 904 | memset(&amlge2d,0x0,sizeof(aml_ge2d_t)); |
| 905 | memset(&(amlge2d.ge2dinfo.src_info[0]), 0, sizeof(buffer_info_t)); |
| 906 | memset(&(amlge2d.ge2dinfo.src_info[1]), 0, sizeof(buffer_info_t)); |
| 907 | memset(&(amlge2d.ge2dinfo.dst_info), 0, sizeof(buffer_info_t)); |
| 908 | cap_attr = 0; |
| 909 | ret = parse_command_line(argc,argv); |
| 910 | if (ret == ge2d_fail) |
| 911 | return ge2d_success; |
| 912 | |
| 913 | set_ge2dinfo(&amlge2d.ge2dinfo); |
| 914 | |
| 915 | ret = aml_ge2d_init(); |
| 916 | if (ret < 0) |
| 917 | return ge2d_fail; |
| 918 | cap_attr = aml_ge2d_get_cap(); |
| 919 | |
| 920 | ret = aml_ge2d_mem_alloc(&amlge2d); |
| 921 | if (ret < 0) |
| 922 | goto exit; |
| 923 | #if 0 |
| 924 | /* if dma_buf and used fd alloc other driver */ |
| 925 | /* set dma buf fd */ |
| 926 | amlge2d.ge2dinfo.src_info[0].shared_fd = dma_fd; |
| 927 | amlge2d.ge2dinfo.src_info[0].memtype = GE2D_CANVAS_ALLOC; |
| 928 | #endif |
| 929 | |
| 930 | switch (amlge2d.ge2dinfo.ge2d_op) |
| 931 | { |
| 932 | case AML_GE2D_FILLRECTANGLE: |
| 933 | ret = do_fill_rectangle(&amlge2d.ge2dinfo); |
| 934 | break; |
| 935 | case AML_GE2D_BLEND: |
| 936 | ret = do_blend(&amlge2d.ge2dinfo); |
| 937 | break; |
| 938 | case AML_GE2D_STRETCHBLIT: |
| 939 | ret = do_strechblit(&amlge2d.ge2dinfo); |
| 940 | break; |
| 941 | case AML_GE2D_BLIT: |
| 942 | ret = do_blit(&amlge2d.ge2dinfo); |
| 943 | break; |
| 944 | default: |
| 945 | E_GE2D("not support ge2d op,exit test!\n"); |
| 946 | break; |
| 947 | } |
| 948 | if (ret < 0) |
| 949 | goto exit; |
| 950 | ret = aml_write_file(DST_FILE_NAME,&amlge2d.ge2dinfo); |
| 951 | if (ret < 0) |
| 952 | goto exit; |
| 953 | exit: |
| 954 | if (amlge2d.src_data) { |
| 955 | free(amlge2d.src_data); |
| 956 | amlge2d.src_data = NULL; |
| 957 | } |
| 958 | if (amlge2d.src2_data) { |
| 959 | free(amlge2d.src2_data); |
| 960 | amlge2d.src2_data = NULL; |
| 961 | } |
| 962 | if (amlge2d.dst_data) { |
| 963 | free(amlge2d.dst_data); |
| 964 | amlge2d.dst_data = NULL; |
| 965 | } |
| 966 | aml_ge2d_mem_free(&amlge2d); |
| 967 | aml_ge2d_exit(); |
| 968 | printf("ge2d feature_test exit!!!\n"); |
| 969 | return ge2d_success; |
| 970 | } |