xref: /OK3568_Linux_fs/external/linux-rga/samples/im2d_slt/sources/rga_im2d_slt.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2021 Rockchip Electronics Co., Ltd.
3  * Authors:
4  *  Cerf Yu <cerf.yu@rock-chips.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #define LOG_NDEBUG 0
20 #undef LOG_TAG
21 #define LOG_TAG "rga_im2d_slt"
22 
23 #include <stdint.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <sys/types.h>
27 #include <math.h>
28 #include <fcntl.h>
29 #include <memory.h>
30 #include <pthread.h>
31 
32 #if LIBDRM
33 #include "drm_alloc.h"
34 #include "xf86drm.h"
35 #endif
36 
37 #include "RockchipRga.h"
38 #include "im2d_api/im2d.hpp"
39 #include "RgaUtils.h"
40 
41 #include "dma_alloc.h"
42 #include "drm_alloc.h"
43 
44 #include "slt_config.h"
45 
46 enum {
47     FILL_BUFF  = 0,
48     EMPTY_BUFF = 1
49 };
50 
51 typedef struct private_data {
52     int id;
53     const char *name;
54     int mode;
55     unsigned int num;
56 
57     int width;
58     int height;
59     int format;
60 
61     int rd_mode;
62     int core;
63     int priority;
64 
65     int result;
66 } private_data_t;
67 
get_buf_size_by_w_h_f(int w,int h,int f)68 static int get_buf_size_by_w_h_f(int w, int h, int f) {
69     float bpp = get_bpp_from_format(f);
70     int size = 0;
71 
72     size = (int)w * h * bpp;
73     return size;
74 }
75 
read_image_from_path(void * buf,const char * path,int f,int sw,int sh,int index,int mode)76 int read_image_from_path(void *buf, const char *path, int f, int sw, int sh, int index, int mode) {
77     const char *inputFilePath = "%s/in%dw%d-h%d-%s.bin";
78     const char *inputFbcFilePath = "%s/in%dw%d-h%d-%s-fbc.bin";
79     char filePath[100];
80 
81     snprintf(filePath, 100, (mode == IM_FBC_MODE) ? inputFbcFilePath : inputFilePath,
82              path, index, sw, sh, translate_format_str(f));
83 
84     FILE *file = fopen(filePath, "rb");
85     if (!file) {
86         fprintf(stderr, "Could not open %s\n", filePath);
87         return -EINVAL;
88     }
89 
90     if (mode == IM_FBC_MODE)
91         fread(buf, get_buf_size_by_w_h_f(sw, sh, f) * 1.5, 1, file);
92     else
93         fread(buf, get_buf_size_by_w_h_f(sw, sh, f), 1, file);
94 
95     fclose(file);
96 
97     return 0;
98 }
99 
write_image_to_path(void * buf,const char * path,int f,int sw,int sh,int index,int mode)100 static int write_image_to_path(void *buf, const char *path, int f, int sw, int sh, int index, int mode) {
101     const char *outputFilePath = "%s/out%dw%d-h%d-%s.bin";
102     const char *outputFbcFilePath = "%s/out%dw%d-h%d-%s-fbc.bin";
103     char filePath[100];
104 
105     snprintf(filePath, 100, (mode == IM_FBC_MODE) ? outputFbcFilePath : outputFilePath,
106              path, index, sw, sh, translate_format_str(f));
107 
108     FILE *file = fopen(filePath, "wb+");
109     if (!file) {
110         fprintf(stderr, "Could not open %s\n", filePath);
111         return false;
112     } else {
113         fprintf(stderr, "open %s and write ok\n", filePath);
114     }
115 
116     if (mode == IM_FBC_MODE)
117         fwrite(buf, get_buf_size_by_w_h_f(sw, sh, f) * 1.5, 1, file);
118     else
119         fwrite(buf, get_buf_size_by_w_h_f(sw, sh, f), 1, file);
120 
121     fclose(file);
122 
123     return 0;
124 }
125 
126 #if IM2D_SLT_GRAPHICBUFFER_EN
127 #include <ui/GraphicBuffer.h>
128 
129 /*
130  *   In order to be compatible with different android versions,
131  * some gralloc usage is defined here.
132  *   The correct usage should be to refer to the corresponding header file:
133  *   Android 12 and above: #include "hardware/gralloc_rockchip.h"
134  *   Android 11 and below: #include "hardware/gralloc.h"
135  */
136 #define GRALLOC_USAGE_PRIVATE_11                (1ULL << 56)
137 #define RK_GRALLOC_USAGE_WITHIN_4G              GRALLOC_USAGE_PRIVATE_11
138 #define RK_GRALLOC_USAGE_RGA_ACCESS             RK_GRALLOC_USAGE_WITHIN_4G
139 
GraphicBuffer_Init(int width,int height,int format,bool use_rga2,bool cacheable)140 sp<GraphicBuffer> GraphicBuffer_Init(int width, int height,int format, bool use_rga2, bool cacheable) {
141     uint64_t usage = 0;
142 
143     if (cacheable)
144         usage |= GRALLOC_USAGE_SW_READ_OFTEN;
145 
146     if (use_rga2)
147         usage |= RK_GRALLOC_USAGE_WITHIN_4G;
148 
149     sp<GraphicBuffer> gb(new GraphicBuffer(width, height, format, 0, usage));
150 
151     if (gb->initCheck()) {
152         /*
153          * The lower version of gralloc (gralloc-0.3) does not support 64-bit usage,
154          * so it needs to be truncated externally to 32-bit. And don't need 4G usage.
155          */
156         printf("graphicbuffer re-alloc 32-bit usage\n");
157         gb = sp<GraphicBuffer>(new GraphicBuffer(width, height, format, (int)usage));
158         if (gb->initCheck()) {
159             printf("GraphicBuffer check error : %s\n",strerror(errno));
160             return NULL;
161         }
162     }
163 
164     return gb;
165 }
166 
167 /* Write data to buffer or init buffer. */
GraphicBuffer_Fill(sp<GraphicBuffer> gb,int width,int height,int format,int flag,int index,int mode)168 int GraphicBuffer_Fill(sp<GraphicBuffer> gb, int width, int height,int format, int flag, int index, int mode) {
169     int ret = 0;
170        char* buf = NULL;
171     size_t buf_size;
172     ret = gb->lock(GRALLOC_USAGE_SW_READ_OFTEN, (void**)&buf);
173     if (ret) {
174         printf("lock buffer error : %s\n",strerror(errno));
175         return -1;
176     }
177 
178     buf_size = width * height * get_bpp_from_format(format);
179     if (mode == IM_FBC_MODE)
180         buf_size = buf_size * 1.5;
181 
182     if(flag) {
183         memset(buf, index, buf_size);
184     } else {
185         ret = read_image_from_path(buf, IM2D_SLT_DEFAULT_INPUT_PATH, format, width, height, index, mode);
186         if (ret != 0) {
187             printf ("open file %s \n", "fault");
188             memset(buf, index, buf_size);
189             ret = -1;
190             goto unlock;
191         }
192     }
193 
194 unlock:
195     ret = gb->unlock();
196        if (ret) {
197         printf("unlock buffer error : %s\n",strerror(errno));
198         return -1;
199     }
200 
201     return ret;
202 }
203 #endif
204 
205 /******************************************************************************/
pthread_rga_run(void * args)206 void *pthread_rga_run(void *args) {
207     int ret = 0, time = 0;
208     unsigned int num;
209     int srcWidth,srcHeight,srcFormat;
210     int dstWidth,dstHeight,dstFormat;
211 
212     char *src_va, *dst_va;
213 #if IM2D_SLT_DRM_BUFFER_EN
214     struct drm_object drm_src, drm_dst;
215 #elif IM2D_SLT_GRAPHICBUFFER_EN
216     sp<GraphicBuffer> src_buf;
217     sp<GraphicBuffer> dst_buf;
218 #elif IM2D_SLT_RK_DMA_HEAP_EN
219     int src_fd, dst_fd;
220     rga_buffer_handle_t src_handle, dst_handle;
221 #endif
222 
223     rga_buffer_t src;
224     rga_buffer_t dst;
225     im_rect src_rect;
226     im_rect dst_rect;
227 
228     private_data_t *data = (private_data_t *)args;
229 
230     num = data->num;
231 
232     srcWidth = data->width;
233     srcHeight = data->height;
234     srcFormat = data->format;
235 
236     dstWidth = data->width;
237     dstHeight = data->height;
238     dstFormat = data->format;
239 
240     memset(&src, 0x0, sizeof(src));
241     memset(&dst, 0x0, sizeof(dst));
242     memset(&src_rect, 0x0, sizeof(src_rect));
243     memset(&dst_rect, 0x0, sizeof(dst_rect));
244 
245     do {
246         time++;
247 
248 #if IM2D_SLT_DRM_BUFFER_EN
249         if (data->rd_mode != IM_FBC_MODE) {
250             drm_src.drm_buf = (uint8_t *)drm_buf_alloc(srcWidth, srcHeight, get_bpp_from_format(srcFormat) * 8,
251                                                        &drm_src.drm_buffer_fd, &drm_src.drm_buffer_handle,
252                                                        &drm_src.actual_size, IM2D_SLT_BUFFER_PHY_EN ? ROCKCHIP_BO_CONTIG : 0);
253             drm_dst.drm_buf = (uint8_t *)drm_buf_alloc(dstWidth, dstHeight, get_bpp_from_format(dstFormat) * 8,
254                                                        &drm_dst.drm_buffer_fd, &drm_dst.drm_buffer_handle,
255                                                        &drm_dst.actual_size, IM2D_SLT_BUFFER_PHY_EN ? ROCKCHIP_BO_CONTIG : 0);
256 
257             src_va = (char *)drm_src.drm_buf;
258             dst_va = (char *)drm_dst.drm_buf;
259 
260             ret = read_image_from_path(src_va, IM2D_SLT_DEFAULT_INPUT_PATH,
261                                        srcFormat, srcWidth, srcHeight, 0, data->rd_mode);
262             if (ret != 0) {
263                 printf ("ID[%d] %s open file %s \n", data->id, data->name, "fault");
264                 goto NORMAL_ERR;
265             }
266 
267             memset(dst_va, 0xff, dstWidth * dstHeight * get_bpp_from_format(dstFormat));
268         } else {
269             drm_src.drm_buf = (uint8_t *)drm_buf_alloc(srcWidth, srcHeight * 1.5, get_bpp_from_format(srcFormat) * 8,
270                                                        &drm_src.drm_buffer_fd, &drm_src.drm_buffer_handle,
271                                                        &drm_src.actual_size, IM2D_SLT_BUFFER_PHY_EN ? ROCKCHIP_BO_CONTIG : 0);
272             drm_dst.drm_buf = (uint8_t *)drm_buf_alloc(dstWidth, dstHeight * 1.5, get_bpp_from_format(dstFormat) * 8,
273                                                        &drm_dst.drm_buffer_fd, &drm_dst.drm_buffer_handle,
274                                                        &drm_dst.actual_size, IM2D_SLT_BUFFER_PHY_EN ? ROCKCHIP_BO_CONTIG : 0);
275 
276             src_va = (char *)drm_src.drm_buf;
277             dst_va = (char *)drm_dst.drm_buf;
278 
279             ret = read_image_from_path(src_va, IM2D_SLT_DEFAULT_INPUT_PATH,
280                                        srcFormat, srcWidth, srcHeight, 0, data->rd_mode);
281             if (ret != 0) {
282                 printf ("ID[%d] %s open file %s \n", data->id, data->name, "fault");
283                 goto NORMAL_ERR;
284             }
285 
286             memset(dst_va, 0xff, dstWidth * dstHeight * 1.5 * get_bpp_from_format(dstFormat));
287         }
288 
289         src = wrapbuffer_fd(drm_src.drm_buffer_fd, srcWidth, srcHeight, srcFormat);
290         dst = wrapbuffer_fd(drm_dst.drm_buffer_fd, dstWidth, dstHeight, dstFormat);
291         if (src.width == 0 || dst.width == 0) {
292             printf("%s", imStrError());
293             goto NORMAL_ERR;
294         }
295 #elif IM2D_SLT_GRAPHICBUFFER_EN
296         if (data->rd_mode == IM_FBC_MODE) {
297             src_buf = GraphicBuffer_Init(srcWidth, srcHeight * 1.5, srcFormat,
298                                          data->core == IM_SCHEDULER_RGA2_CORE0 ? true : false, IM2D_SLT_BUFFER_CACHEABLE);
299             dst_buf = GraphicBuffer_Init(dstWidth, dstHeight * 1.5, dstFormat,
300                                          data->core == IM_SCHEDULER_RGA2_CORE0 ? true : false, IM2D_SLT_BUFFER_CACHEABLE);
301         } else {
302             src_buf = GraphicBuffer_Init(srcWidth, srcHeight, srcFormat,
303                                          data->core == IM_SCHEDULER_RGA2_CORE0 ? true : false, IM2D_SLT_BUFFER_CACHEABLE);
304             dst_buf = GraphicBuffer_Init(dstWidth, dstHeight, dstFormat,
305                                          data->core == IM_SCHEDULER_RGA2_CORE0 ? true : false, IM2D_SLT_BUFFER_CACHEABLE);
306         }
307         if (src_buf == NULL || dst_buf == NULL) {
308             printf("GraphicBuff init error!\n");
309             goto NORMAL_ERR;
310         }
311 
312         if(-1 == GraphicBuffer_Fill(src_buf, srcWidth, srcHeight, srcFormat, FILL_BUFF, 0, data->rd_mode)) {
313             printf("%s, src write Graphicbuffer error!\n", __FUNCTION__);
314             goto NORMAL_ERR;
315         }
316         if(-1 == GraphicBuffer_Fill(dst_buf, dstWidth, dstHeight, dstFormat, EMPTY_BUFF, 0xff, data->rd_mode)) {
317             printf("%s, dst write Graphicbuffer error!\n", __FUNCTION__);
318             goto NORMAL_ERR;
319         }
320 
321         src = wrapbuffer_GraphicBuffer(src_buf);
322         src = wrapbuffer_fd(src.fd, srcWidth, srcHeight, srcFormat);
323         dst = wrapbuffer_GraphicBuffer(dst_buf);
324         dst = wrapbuffer_fd(dst.fd, dstWidth, dstHeight, dstFormat);
325         /* If it is in fbc mode, because the height of the alloc memory
326          * is modified, it needs to be corrected here */
327         if (data->rd_mode == IM_FBC_MODE) {
328             src.height  = srcHeight;
329             src.hstride = srcHeight;
330             dst.height  = dstHeight;
331             dst.hstride = dstHeight;
332         }
333         if (src.width == 0 || dst.width == 0) {
334             printf("%s", imStrError());
335         }
336 #elif IM2D_SLT_RK_DMA_HEAP_EN
337         ret = dma_buf_alloc(srcWidth, srcHeight, srcFormat, &src_fd, (void **)&src_va);
338         if (ret < 0) {
339             printf("ID[%d] %s alloc src dma_buf failed!\n", data->id, data->name);
340             goto NORMAL_ERR;
341         }
342 
343         ret = dma_buf_alloc(dstWidth, dstHeight, dstFormat, &dst_fd, (void **)&dst_va);
344         if (ret < 0) {
345             printf("ID[%d] %s alloc dst dma_buf failed!\n", data->id, data->name);
346             goto NORMAL_ERR;
347         }
348 
349         dma_sync_device_to_cpu(src_fd);
350         dma_sync_device_to_cpu(dst_fd);
351 
352         ret = read_image_from_path(src_va, IM2D_SLT_DEFAULT_INPUT_PATH,
353                                     srcFormat, srcWidth, srcHeight, 0, data->rd_mode);
354         if (ret != 0) {
355             printf ("ID[%d] %s open file %s \n", data->id, data->name, "fault");
356             goto NORMAL_ERR;
357         }
358 
359         memset(dst_va, 0xff, dstWidth * dstHeight * get_bpp_from_format(dstFormat));
360 
361         dma_sync_cpu_to_device(src_fd);
362         dma_sync_cpu_to_device(dst_fd);
363 
364         src_handle = importbuffer_fd(src_fd, srcWidth, srcHeight, srcFormat);
365         if (src_handle <= 0) {
366             printf("ID[%d] %s import src dma_buf failed!\n", data->id, data->name);
367             goto NORMAL_ERR;
368         }
369         dst_handle = importbuffer_fd(dst_fd, dstWidth, dstHeight, dstFormat);
370         if (dst_handle <= 0) {
371             printf("ID[%d] %s import dst dma_buf failed!\n", data->id, data->name);
372             releasebuffer_handle(src_handle);
373             goto NORMAL_ERR;
374         }
375 
376         src = wrapbuffer_handle(src_handle, srcWidth, srcHeight, srcFormat);
377         dst = wrapbuffer_handle(dst_handle, dstWidth, dstHeight, dstFormat);
378         if (src.width == 0 || dst.width == 0) {
379             printf("%s", imStrError());
380 
381             releasebuffer_handle(src_handle);
382             releasebuffer_handle(dst_handle);
383             goto NORMAL_ERR;
384         }
385 #endif
386 
387         ret = imcheck(src, dst, src_rect, dst_rect);
388         if (ret != IM_STATUS_NOERROR) {
389             printf("ID[%d]: %s check %d time error! %s", data->id, data->name, time, imStrError((IM_STATUS)ret));
390 
391             goto NORMAL_ERR;
392         }
393 
394         imconfig(IM_CONFIG_SCHEDULER_CORE, data->core);
395         imconfig(IM_CONFIG_PRIORITY, data->priority);
396 
397         src.rd_mode = data->rd_mode;
398         dst.rd_mode = data->rd_mode;
399 
400         ret = imcopy(src, dst);
401         if (ret == IM_STATUS_SUCCESS) {
402             printf("ID[%d]: %s imcopy %d time success!\n", data->id, data->name, time);
403 
404 #if IM2D_SLT_GRAPHICBUFFER_EN
405             ret = src_buf->lock(GRALLOC_USAGE_SW_READ_OFTEN, (void**)&src_va);
406             if (ret) {
407                 printf("lock src_buf error : %s\n",strerror(errno));
408                 goto NORMAL_ERR;
409             }
410 
411             ret = dst_buf->lock(GRALLOC_USAGE_SW_READ_OFTEN, (void**)&dst_va);
412             if (ret) {
413                 printf("lock dst_buf error : %s\n",strerror(errno));
414                 goto NORMAL_ERR;
415             }
416 #elif IM2D_SLT_RK_DMA_HEAP_EN
417             dma_sync_device_to_cpu(src_fd);
418             dma_sync_device_to_cpu(dst_fd);
419 #endif
420 
421             ret = memcmp(src_va, dst_va, dst.wstride * dst.hstride * get_bpp_from_format(dst.format));
422             if (ret < 0) {
423                 printf("ID[%d]: %s check buffer %d time error!\n", data->id, data->name, time);
424                 printf("src: %x %x %x %x\n", (int)src_va[0], (int)src_va[1], (int)src_va[2], (int)src_va[3]);
425                 printf("dst: %x %x %x %x\n", (int)dst_va[0], (int)dst_va[1], (int)dst_va[2], (int)dst_va[3]);
426                 write_image_to_path(dst_va, IM2D_SLT_DEFAULT_OUTPUT_PATH,
427                                     dst.format, dst.wstride, dst.hstride, data->id + 1, dst.rd_mode);
428                 write_image_to_path(src_va, IM2D_SLT_DEFAULT_OUTPUT_PATH,
429                                     src.format, src.wstride, src.hstride, data->id + 2, src.rd_mode);
430 
431                 goto CHECK_ERR;
432             } else {
433                 printf("ID[%d]: %s check buffer %d time success!\n", data->id, data->name, time);
434             }
435 
436 #if IM2D_SLT_GRAPHICBUFFER_EN
437             ret = src_buf->unlock();
438             if (ret) {
439                 printf("unlock src_buf error : %s\n",strerror(errno));
440                 goto NORMAL_ERR;
441             }
442 
443             ret = dst_buf->unlock();
444             if (ret) {
445                 printf("unlock dst_buf error : %s\n",strerror(errno));
446                 goto NORMAL_ERR;
447             }
448 #endif
449         } else {
450             printf("ID[%d]: %s run %d time error!, %s\n", data->id, data->name, time, imStrError((IM_STATUS)ret));
451             goto NORMAL_ERR;
452         }
453 
454 #if IM2D_SLT_DRM_BUFFER_EN
455         drm_buf_destroy(drm_src.drm_buffer_fd, drm_src.drm_buffer_handle,
456                         drm_src.drm_buf, drm_src.actual_size);
457         drm_buf_destroy(drm_dst.drm_buffer_fd, drm_dst.drm_buffer_handle,
458                         drm_dst.drm_buf, drm_dst.actual_size);
459 #elif IM2D_SLT_RK_DMA_HEAP_EN
460         releasebuffer_handle(src_handle);
461         releasebuffer_handle(dst_handle);
462 
463         dma_buf_free(srcWidth, srcHeight, srcFormat, &src_fd, (void *)src_va);
464         dma_buf_free(dstWidth, dstHeight, dstFormat, &dst_fd, (void *)dst_va);
465 #endif
466     } while (data->mode && --num);
467 
468 #if IM2D_SLT_THREAD_EN
469     data->result = 0;
470     pthread_exit(NULL);
471 
472 NORMAL_ERR:
473     data->result = -1;
474     pthread_exit(NULL);
475 CHECK_ERR:
476     data->result = -2;
477     pthread_exit(NULL);
478 #else
479     data->result = 0;
480     return NULL;
481 
482 NORMAL_ERR:
483     data->result = -1;
484     return NULL;
485 CHECK_ERR:
486     data->result = -2;
487     return NULL;
488 #endif
489 }
490 
main()491 int main() {
492     int pthread_num = 0;
493     pthread_t tdSyncID[IM2D_SLT_THREAD_MAX];
494     private_data_t data[IM2D_SLT_THREAD_MAX];
495 
496     memset(&data, 0x0, sizeof(private_data_t) * IM2D_SLT_THREAD_MAX);
497     printf("-------------------------------------------------\n");
498 
499 #if IM2D_SLT_TEST_RGA3_0_EN
500     pthread_num++;
501     data[pthread_num].id = pthread_num;
502     data[pthread_num].name = "RGA3_core0";
503     data[pthread_num].mode = IM2D_SLT_WHILE_EN;
504     data[pthread_num].num = IM2D_SLT_WHILE_NUM;
505     data[pthread_num].width = IM2D_SLT_DEFAULT_WIDTH;
506     data[pthread_num].height = IM2D_SLT_DEFAULT_HEIGHT;
507     data[pthread_num].format = IM2D_SLT_DEFAULT_FORMAT;
508     data[pthread_num].rd_mode = IM_RASTER_MODE;
509     data[pthread_num].core = IM_SCHEDULER_RGA3_CORE0;
510     data[pthread_num].priority = 1;
511 #endif
512 
513 #if IM2D_SLT_TEST_RGA3_1_EN
514     pthread_num++;
515     data[pthread_num].id = pthread_num;
516     data[pthread_num].name = "RGA3_core1";
517     data[pthread_num].mode = IM2D_SLT_WHILE_EN;
518     data[pthread_num].num = IM2D_SLT_WHILE_NUM;
519     data[pthread_num].width = IM2D_SLT_DEFAULT_WIDTH;
520     data[pthread_num].height = IM2D_SLT_DEFAULT_HEIGHT;
521     data[pthread_num].format = IM2D_SLT_DEFAULT_FORMAT;
522     data[pthread_num].rd_mode = IM_RASTER_MODE;
523     data[pthread_num].core = IM_SCHEDULER_RGA3_CORE1;
524     data[pthread_num].priority = 1;
525 #endif
526 
527 #if IM2D_SLT_TEST_RGA2_EN
528     pthread_num++;
529     data[pthread_num].id = pthread_num;
530     data[pthread_num].name = "RGA2";
531     data[pthread_num].mode = IM2D_SLT_WHILE_EN;
532     data[pthread_num].num = IM2D_SLT_WHILE_NUM;
533     data[pthread_num].width = IM2D_SLT_DEFAULT_WIDTH;
534     data[pthread_num].height = IM2D_SLT_DEFAULT_HEIGHT;
535     data[pthread_num].format = IM2D_SLT_DEFAULT_FORMAT;
536     data[pthread_num].rd_mode = IM_RASTER_MODE;
537     data[pthread_num].core = IM_SCHEDULER_RGA2_CORE0;
538     data[pthread_num].priority = 1;
539 #endif
540 
541 #if IM2D_SLT_TEST_RGA3_0_FBC_EN
542     pthread_num++;
543     data[pthread_num].id = pthread_num;
544     data[pthread_num].name = "RGA3_core0_fbc";
545     data[pthread_num].mode = IM2D_SLT_WHILE_EN;
546     data[pthread_num].num = IM2D_SLT_WHILE_NUM;
547     data[pthread_num].width = IM2D_SLT_DEFAULT_WIDTH;
548     data[pthread_num].height = IM2D_SLT_DEFAULT_HEIGHT;
549     data[pthread_num].format = IM2D_SLT_DEFAULT_FORMAT;
550     data[pthread_num].rd_mode = IM_FBC_MODE;
551     data[pthread_num].core = IM_SCHEDULER_RGA3_CORE0;
552     data[pthread_num].priority = 1;
553 #endif
554 
555 #if IM2D_SLT_TEST_RGA3_1_FBC_EN
556     pthread_num++;
557     data[pthread_num].id = pthread_num;
558     data[pthread_num].name = "RGA3_core1_fbc";
559     data[pthread_num].mode = IM2D_SLT_WHILE_EN;
560     data[pthread_num].num = IM2D_SLT_WHILE_NUM;
561     data[pthread_num].width = IM2D_SLT_DEFAULT_WIDTH;
562     data[pthread_num].height = IM2D_SLT_DEFAULT_HEIGHT;
563     data[pthread_num].format = IM2D_SLT_DEFAULT_FORMAT;
564     data[pthread_num].rd_mode = IM_FBC_MODE;
565     data[pthread_num].core = IM_SCHEDULER_RGA3_CORE1;
566     data[pthread_num].priority = 1;
567 #endif
568 
569 #if IM2D_SLT_THREAD_EN
570     for (int i = 1; i <= pthread_num; i++) {
571         pthread_create(&tdSyncID[i], NULL, pthread_rga_run, (void *)(&data[i]));
572         printf("creat Sync pthread[0x%lx] = %d, id = %d\n", tdSyncID[i], i, data[i].id);
573     }
574 
575     for (int i = 1; i <= pthread_num; i++) {
576         pthread_join(tdSyncID[i], NULL);
577         if (data[i].result < 0) {
578             printf("ID[%d] case '%s' is faile!\n", data[i].id, data[i].name);
579             printf("-------------------------------------------------\n");
580             printf("im2d api slt fail!\n");
581             return -1;
582         }
583     }
584 
585     printf("-------------------------------------------------\n");
586     printf("im2d api slt success!\n");
587 
588     return 0;
589 #else
590     (void)(tdSyncID);
591 
592     for (int i = 1; i <= pthread_num; i++) {
593         pthread_rga_run((void *)(&data[i]));
594         printf("ID[%d] %s run end!\n", data[i].id, data[i].name);
595         if (data[i].result < 0) {
596             printf("ID[%d] case '%s' is faile!\n", data[i].id, data[i].name);
597             return -1;
598         }
599     }
600 
601     printf("-------------------------------------------------\n");
602     printf("im2d api slt success!\n");
603 
604     return 0;
605 #endif
606 }
607 
608