xref: /OK3568_Linux_fs/external/rockit/mpi/example/mod/test_mpi_gdc.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2022 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #undef DBG_MOD_ID
19 #define DBG_MOD_ID       RK_ID_GDC
20 
21 #include <unistd.h>
22 #include <pthread.h>
23 #include <stdlib.h>
24 #include <cstdio>
25 #include <cerrno>
26 #include <cstring>
27 
28 #include "rk_type.h"
29 #include "rk_debug.h"
30 #include "rk_mpi_gdc.h"
31 #include "rk_mpi_mb.h"
32 #include "rk_mpi_sys.h"
33 #include "rk_mpi_cal.h"
34 #include "rk_mpi_vo.h"
35 #include "rk_comm_vo.h"
36 
37 #include "test_comm_argparse.h"
38 
39 // for vo
40 #define RK35XX_VO_DEV_HD0 0
41 #define RK35XX_VO_DEV_HD1 1
42 #define RK35XX_VO_GDC_CHN 0
43 #define RK35XX_VOP_LAYER_CLUSTER_0 0
44 #define RK35XX_VOP_LAYER_CLUSTER_1 2
45 #define RK35XX_VOP_LAYER_ESMART_0 4
46 #define RK35XX_VOP_LAYER_ESMART_1 5
47 #define RK35XX_VOP_LAYER_SMART_0 6
48 #define RK35XX_VOP_LAYER_SMART_1 7
49 
50 #define RK35XX_VO_LINE_CHN 127
51 
52 RK_U16 gau16PointColor[9] = {
53     0x8000 | 0x44c4,  // red
54     0x8000 | 0x1234,  // blue
55     0x8000 | 0x7fff,  // white
56     0x8000 | 0x7322,
57     0x8000 | 0x5433,
58     0x8000 | 0x6544,
59     0x8000 | 0x7644,
60     0x8000 | 0x8744,
61     0x8000 | 0x9844
62 };
63 
64 typedef enum _TestGdcDeskCeilMode {
65     TEST_GDC_DESK_CEIL_MODE_1P_ADD_1     = 0,
66     TEST_GDC_DESK_CEIL_MODE_2P           = 1,
67     TEST_GDC_DESK_CEIL_MODE_1_ADD_3      = 2,
68     TEST_GDC_DESK_CEIL_MODE_1_ADD_4      = 3,
69     TEST_GDC_DESK_CEIL_MODE_1P_ADD_6     = 4,
70     TEST_GDC_DESK_CEIL_MODE_1_ADD_8      = 5,
71     TEST_GDC_DESK_CEIL_MODE_BUTT
72 } TestGdcDeskCeilMode;
73 
74 typedef enum _TestGdcWallMode {
75     TEST_GDC_WALL_MODE_1P                = 0,
76     TEST_GDC_WALL_MODE_1P_ADD_3          = 1,
77     TEST_GDC_WALL_MODE_1P_ADD_4          = 2,
78     TEST_GDC_WALL_MODE_1P_ADD_8          = 3,
79     TEST_GDC_WALL_MODE_BUTT
80 } TestGdcWallMode;
81 
82 typedef struct _rkMpiGdcCtx {
83     const char *srcFilePath;
84     RK_S32  s32LoopCount;
85     RK_S32  s32JobNum;
86     RK_S32  s32TaskSum;
87     RK_S32  s32TaskType;
88     RK_S32  s32TaskMode;
89     RK_S32  u32SrcWidth;
90     RK_S32  u32SrcHeight;
91     RK_S32  u32SrcVirWidth;
92     RK_S32  u32SrcVirHeight;
93     RK_S32  u32LineWidth;
94     RK_S32  u32LineHeight;
95     RK_S32  s32SrcCompressMode;
96     RK_S32  s32SrcPixFormat;
97     RK_S32  u32DstWidth;
98     RK_S32  u32DstHeight;
99     RK_S32  s32DstCompressMode;
100     RK_S32  s32DstPixFormat;
101     RK_S32  s32JobIdx;
102     RK_U32  u32SrcSize;
103     RK_U32  u32ShowPoint;
104     RK_U32  u32ChangeParam;
105     RK_U32  u32PointLen;
106     MB_POOL inPool;
107     TestGdcDeskCeilMode enDeskCeilMode;
108     TestGdcWallMode enWallMode;
109     FISHEYE_JOB_CONFIG_S stFisheyeJobConfig;
110     GDC_TASK_ATTR_S stTask;
111     FISHEYE_ATTR_S stFisheyeAttr;
112     POINT_S *pastDstPoint;
113     POINT_S *pastSrcPoint;
114     // for vo
115     VO_CHN_ATTR_S stChnAttr;
116     VO_VIDEO_LAYER_ATTR_S stLayerAttr;
117     VO_LAYER s32VoLayer;
118     VO_DEV s32VoDev;
119     VO_CHN s32VoChn;
120     VO_INTF_SYNC_E stVoOutputResolution;
121     RK_S32 u32VoWidth;
122     RK_S32 u32VoHeight;
123     RECT_S stChnRect;
124 } TEST_GDC_CTX_S;
125 
126 typedef enum _rkGdcChangeType {
127     TEST_GDC_CHANGE_TYPE_VIEW_MODE,
128     TEST_GDC_CHANGE_TYPE_IN_RADIUS,
129     TEST_GDC_CHANGE_TYPE_OUT_RADIUS,
130     TEST_GDC_CHANGE_TYPE_PAN,
131     TEST_GDC_CHANGE_TYPE_TILT,
132     TEST_GDC_CHANGE_TYPE_HOR_ZOOM,
133     TEST_GDC_CHANGE_TYPE_VER_ZOOM,
134     TEST_GDC_CHANGE_TYPE_ALL
135 } TEST_GDC_CHANGE_TYPE;
136 
create_vo(TEST_GDC_CTX_S * ctx,RK_U32 u32Ch)137 static RK_S32 create_vo(TEST_GDC_CTX_S *ctx, RK_U32 u32Ch) {
138     /* Enable VO */
139     VO_PUB_ATTR_S VoPubAttr;
140     RK_S32 s32Ret = RK_SUCCESS;
141     VO_LAYER VoLayer = ctx->s32VoLayer;
142     VO_DEV VoDev = ctx->s32VoDev;
143 
144     memset(&VoPubAttr, 0, sizeof(VO_PUB_ATTR_S));
145 
146     s32Ret = RK_MPI_VO_GetPubAttr(VoDev, &VoPubAttr);
147     if (s32Ret != RK_SUCCESS) {
148         return s32Ret;
149     }
150 
151     VoPubAttr.enIntfType = VO_INTF_HDMI;
152     VoPubAttr.enIntfSync = ctx->stVoOutputResolution;
153 
154     s32Ret = RK_MPI_VO_SetPubAttr(VoDev, &VoPubAttr);
155     if (s32Ret != RK_SUCCESS) {
156         return s32Ret;
157     }
158     s32Ret = RK_MPI_VO_Enable(VoDev);
159     if (s32Ret != RK_SUCCESS) {
160         return s32Ret;
161     }
162 
163     s32Ret = RK_MPI_VO_SetLayerAttr(VoLayer, &ctx->stLayerAttr);
164     if (s32Ret != RK_SUCCESS) {
165         RK_LOGE("RK_MPI_VO_SetLayerAttr failed,s32Ret:%d\n", s32Ret);
166         return RK_FAILURE;
167     }
168 
169     s32Ret = RK_MPI_VO_BindLayer(VoLayer, VoDev, VO_LAYER_MODE_VIDEO);
170     if (s32Ret != RK_SUCCESS) {
171         RK_LOGE("RK_MPI_VO_BindLayer failed,s32Ret:%d\n", s32Ret);
172         return RK_FAILURE;
173     }
174 
175 
176     s32Ret = RK_MPI_VO_EnableLayer(VoLayer);
177     if (s32Ret != RK_SUCCESS) {
178         RK_LOGE("RK_MPI_VO_EnableLayer failed,s32Ret:%d\n", s32Ret);
179         return RK_FAILURE;
180     }
181 
182     s32Ret = RK_MPI_VO_SetChnAttr(VoLayer, u32Ch, &ctx->stChnAttr);
183     if (s32Ret != RK_SUCCESS) {
184         RK_LOGE("set chn Attr failed,s32Ret:%d\n", s32Ret);
185         return RK_FAILURE;
186     }
187 
188     return s32Ret;
189 }
190 
191 #if 0
192 RK_S32 unit_test_mpi_gdc(TEST_GDC_CTX_S *ctx) {
193     RK_S32 s32Ret = RK_SUCCESS;
194     pthread_t tids[GDC_MAX_JOB_NUM];
195     TEST_GDC_CTX_S tmpCtx[GDC_MAX_JOB_NUM];
196 
197     for (RK_S32 jobIndex = 0; jobIndex < ctx->s32JobNum; jobIndex++) {
198         memcpy(&(tmpCtx[jobIndex]), ctx, sizeof(TEST_GDC_CTX_S));
199         pthread_create(&tids[jobIndex], 0, unit_test_gdc_counts, reinterpret_cast<void *>(&tmpCtx[jobIndex]));
200         ctx->s32JobIdx++;
201     }
202 
203     for (RK_S32 jobIndex = 0; jobIndex < ctx->s32JobNum; jobIndex++) {
204         pthread_join(tids[jobIndex], RK_NULL);
205     }
206 
207     return s32Ret;
208 }
209 #endif
read_with_pixel_width(RK_U8 * pBuf,RK_U32 u32Width,RK_U32 u32VirHeight,RK_U32 u32VirWidth,RK_U32 u32PixWidth,FILE * fp)210 static RK_S32 read_with_pixel_width(RK_U8 *pBuf, RK_U32 u32Width, RK_U32 u32VirHeight,
211                                      RK_U32 u32VirWidth, RK_U32 u32PixWidth, FILE *fp) {
212     RK_U32 u32Row;
213     RK_S32 s32ReadSize;
214 
215     for (u32Row = 0; u32Row < u32VirHeight; u32Row++) {
216         s32ReadSize = fread(pBuf + u32Row * u32VirWidth * u32PixWidth, 1, u32Width * u32PixWidth, fp);
217         if (s32ReadSize != u32Width * u32PixWidth) {
218             RK_LOGE("read file failed expect %d vs %d\n",
219                       u32Width * u32PixWidth, s32ReadSize);
220             return RK_FAILURE;
221         }
222     }
223 
224     return RK_SUCCESS;
225 }
226 
read_image(RK_U8 * pVirAddr,RK_U32 u32Width,RK_U32 u32Height,RK_U32 u32VirWidth,RK_U32 u32VirHeight,RK_U32 u32PixFormat,FILE * fp)227 static RK_S32 read_image(RK_U8 *pVirAddr, RK_U32 u32Width, RK_U32 u32Height,
228                             RK_U32 u32VirWidth, RK_U32 u32VirHeight, RK_U32 u32PixFormat, FILE *fp) {
229     RK_U32 u32Row = 0;
230     RK_U32 u32ReadSize = 0;
231     RK_S32 s32Ret = RK_SUCCESS;
232 
233     RK_U8 *pBufy = pVirAddr;
234     RK_U8 *pBufu = pBufy + u32VirWidth * u32VirHeight;
235     RK_U8 *pBufv = pBufu + u32VirWidth * u32VirHeight / 4;
236 
237     switch (u32PixFormat) {
238         case RK_FMT_YUV420SP:
239         case RK_FMT_YUV420SP_VU: {
240             for (u32Row = 0; u32Row < u32VirHeight; u32Row++) {
241                 u32ReadSize = fread(pBufy + u32Row * u32VirWidth, 1, u32Width, fp);
242                 if (u32ReadSize != u32Width) {
243                      return RK_FAILURE;
244                 }
245             }
246 
247             for (u32Row = 0; u32Row < u32VirHeight / 2; u32Row++) {
248                 u32ReadSize = fread(pBufu + u32Row * u32VirWidth, 1, u32Width, fp);
249                 if (u32ReadSize != u32Width) {
250                     return RK_FAILURE;
251                 }
252             }
253         } break;
254         case RK_FMT_RGB888:
255         case RK_FMT_BGR888: {
256             s32Ret = read_with_pixel_width(pBufy, u32Width, u32VirHeight, u32VirWidth, 3, fp);
257         } break;
258         default : {
259             RK_LOGE("read image do not support fmt %d\n", u32PixFormat);
260             return RK_FAILURE;
261         } break;
262     }
263 
264     return s32Ret;
265 }
266 
unit_test_gdc_get_size(TEST_GDC_CTX_S * ctx)267 RK_U32 unit_test_gdc_get_size(TEST_GDC_CTX_S *ctx) {
268     RK_S32 s32Ret = RK_SUCCESS;
269     PIC_BUF_ATTR_S stPicBufAttr;
270     MB_PIC_CAL_S   stMbPicCalResult;
271 
272     if (ctx->u32SrcVirWidth == 0) {
273         ctx->u32SrcVirWidth = ctx->u32SrcWidth;
274     }
275     if (ctx->u32SrcVirHeight == 0) {
276         ctx->u32SrcVirHeight = ctx->u32SrcHeight;
277     }
278 
279     stPicBufAttr.u32Width = ctx->u32SrcVirWidth;
280     stPicBufAttr.u32Height = ctx->u32SrcVirHeight;
281     stPicBufAttr.enPixelFormat = (PIXEL_FORMAT_E)ctx->s32SrcPixFormat;
282     stPicBufAttr.enCompMode = (COMPRESS_MODE_E)ctx->s32SrcCompressMode;
283     s32Ret = RK_MPI_CAL_COMM_GetPicBufferSize(&stPicBufAttr, &stMbPicCalResult);
284     if (s32Ret != RK_SUCCESS) {
285         RK_LOGE("get picture buffer size failed. err 0x%x", s32Ret);
286         return s32Ret;
287     }
288 
289     return stMbPicCalResult.u32MBSize;
290 }
291 
test_mpi_gdc_change_parameter(TEST_GDC_CTX_S * ctx,RK_S32 index,TEST_GDC_CHANGE_TYPE type)292 RK_VOID test_mpi_gdc_change_parameter(TEST_GDC_CTX_S *ctx, RK_S32 index, TEST_GDC_CHANGE_TYPE type) {
293     FISHEYE_REGION_ATTR_S regionAttr;
294     memcpy(&regionAttr, &ctx->stFisheyeAttr.astFishEyeRegionAttr[index], sizeof(FISHEYE_REGION_ATTR_S));
295 
296     switch (type) {
297         case TEST_GDC_CHANGE_TYPE_VIEW_MODE:
298         break;
299         case TEST_GDC_CHANGE_TYPE_IN_RADIUS:
300         break;
301         case TEST_GDC_CHANGE_TYPE_OUT_RADIUS:
302         break;
303         case TEST_GDC_CHANGE_TYPE_PAN:
304             if (regionAttr.u32Pan < 360)
305                 regionAttr.u32Pan++;
306             else
307                 regionAttr.u32Pan = 0;
308         break;
309         case TEST_GDC_CHANGE_TYPE_TILT:
310             if (regionAttr.u32Tilt < 360)
311                 regionAttr.u32Tilt++;
312             else
313                 regionAttr.u32Tilt = 0;
314         break;
315         case TEST_GDC_CHANGE_TYPE_HOR_ZOOM:
316             if (regionAttr.u32HorZoom < 4095)
317                 regionAttr.u32HorZoom++;
318             else
319                 regionAttr.u32HorZoom = 1;
320         break;
321         case TEST_GDC_CHANGE_TYPE_VER_ZOOM:
322             if (regionAttr.u32VerZoom < 4095)
323                 regionAttr.u32VerZoom++;
324             else
325                 regionAttr.u32VerZoom = 1;
326         break;
327         case TEST_GDC_CHANGE_TYPE_ALL:
328         break;
329     }
330     memcpy(&ctx->stFisheyeAttr.astFishEyeRegionAttr[index], &regionAttr, sizeof(FISHEYE_REGION_ATTR_S));
331 }
332 
test_mpi_gdc_get_src_point(TEST_GDC_CTX_S * ctx)333 RK_VOID test_mpi_gdc_get_src_point(TEST_GDC_CTX_S *ctx) {
334     RK_S32 s32Ret;
335     for (RK_U32 region = 1; region < ctx->stFisheyeAttr.u32RegionNum; region++) {
336         GDC_FISHEYE_POINT_QUERY_ATTR_S stQuery;
337         POINT_S stDstPoint, stSrcPoint;
338         memset(&stQuery, 0, sizeof(sizeof(FISHEYE_ATTR_S)));
339         stQuery.pstFishEyeAttr = &ctx->stFisheyeAttr;
340         stQuery.u32RegionIndex = region;
341         stDstPoint.s32X = 0;
342         stDstPoint.s32Y = 540;
343         s32Ret = RK_MPI_GDC_FisheyePosQueryDst2Src(&stQuery, &ctx->stTask.stImgIn, &stDstPoint, &stSrcPoint);
344         if (s32Ret != RK_SUCCESS) {
345             RK_LOGE("RK_MPI_GDC_FisheyePosQueryDst2Src err:0x%x!", s32Ret);
346         }
347         RK_LOGD("region:%d dst:%d,%d src:%d,%d", region, stDstPoint.s32X, stDstPoint.s32Y,
348                                                  stSrcPoint.s32X, stSrcPoint.s32Y);
349     }
350 }
351 
test_mpi_gdc_get_pano_point(TEST_GDC_CTX_S * ctx)352 RK_VOID test_mpi_gdc_get_pano_point(TEST_GDC_CTX_S *ctx) {
353     RK_S32 s32Ret;
354     for (RK_U32 region = 1; region < ctx->stFisheyeAttr.u32RegionNum; region++) {
355         GDC_FISHEYE_POINT_QUERY_ATTR_S stQuery;
356         POINT_S stDstPoint, stPanoPoint;
357         memset(&stQuery, 0, sizeof(sizeof(FISHEYE_ATTR_S)));
358         stQuery.pstFishEyeAttr = &ctx->stFisheyeAttr;
359         stQuery.u32RegionIndex = region;
360         stDstPoint.s32X = 0;
361         stDstPoint.s32Y = 540;
362         s32Ret = RK_MPI_GDC_FisheyePosQueryDst2Pano(&stQuery, &ctx->stTask.stImgIn, 0, &stDstPoint, &stPanoPoint);
363         if (s32Ret != RK_SUCCESS) {
364             RK_LOGE("RK_MPI_GDC_FisheyePosQueryDst2Pano err:0x%x!", s32Ret);
365         }
366         RK_LOGD("region:%d dst:%d,%d pano:%d,%d", region, stDstPoint.s32X, stDstPoint.s32Y,
367                                                   stPanoPoint.s32X, stPanoPoint.s32Y);
368     }
369 }
370 
test_mpi_gdc_get_src_point_array(TEST_GDC_CTX_S * ctx,RK_U32 region)371 RK_S32 test_mpi_gdc_get_src_point_array(TEST_GDC_CTX_S *ctx, RK_U32 region) {
372     RK_S32 s32Ret;
373     RK_FLOAT step;
374     RK_U32 w = ctx->stFisheyeAttr.astFishEyeRegionAttr[region].stOutRect.u32Width;
375     RK_U32 h = ctx->stFisheyeAttr.astFishEyeRegionAttr[region].stOutRect.u32Height;
376 
377     ctx->u32PointLen = ctx->u32PointLen > ((w + h) * 2) ? (w + h) * 2 : ctx->u32PointLen;
378     step = (RK_FLOAT)((w + h) * 2) / ctx->u32PointLen;
379 
380     for (RK_U32 i = 0; i < ctx->u32PointLen; i++) {
381         if ((step * i) <= w) {
382             ctx->pastDstPoint[i].s32X = step * i;
383             ctx->pastDstPoint[i].s32Y = 0;
384         } else if ((step * i) <= (w + h)) {
385             ctx->pastDstPoint[i].s32X = (w - 1);
386             ctx->pastDstPoint[i].s32Y = (step * i - w);
387             // printf("22 region:%d i%d= %d,%d\n", region, i, ctx->pastDstPoint[i].s32X, ctx->pastDstPoint[i].s32Y);
388         } else if ((step * i) <= (2 * w + h)) {
389             ctx->pastDstPoint[i].s32X = 2 * w + h - step * i;
390             ctx->pastDstPoint[i].s32Y = h - 1;
391             // printf("33 region:%d i%d=%d\n", region, i, ctx->pastDstPoint[i].s32X);
392         } else {
393             ctx->pastDstPoint[i].s32X = 0;
394             ctx->pastDstPoint[i].s32Y = (2 * (w + h)- step * i);
395             // printf("44 region:%d i%d=%d\n", region, i, ctx->pastDstPoint[i].s32Y);
396         }
397     }
398 
399     // get the array
400     GDC_FISHEYE_POINT_QUERY_ATTR_S stQuery;
401     memset(&stQuery, 0, sizeof(sizeof(FISHEYE_ATTR_S)));
402     stQuery.pstFishEyeAttr = &ctx->stFisheyeAttr;
403     stQuery.u32RegionIndex = region;
404     s32Ret = RK_MPI_GDC_FisheyePosQueryDst2SrcArray(&stQuery, &ctx->stTask.stImgIn, ctx->u32PointLen,
405                                                     ctx->pastDstPoint, ctx->pastSrcPoint);
406     if (s32Ret != RK_SUCCESS) {
407         RK_LOGE("RK_MPI_GDC_FisheyePosQueryDst2SrcArray err:0x%x!", s32Ret);
408     }
409 
410     return s32Ret;
411 }
412 
test_mpi_gdc_get_pano_point_array(TEST_GDC_CTX_S * ctx,RK_U32 region,RK_U32 pano_region)413 RK_S32 test_mpi_gdc_get_pano_point_array(TEST_GDC_CTX_S *ctx, RK_U32 region, RK_U32 pano_region) {
414     RK_S32 s32Ret;
415     RK_FLOAT step;
416     RK_U32 w = ctx->stFisheyeAttr.astFishEyeRegionAttr[region].stOutRect.u32Width;
417     RK_U32 h = ctx->stFisheyeAttr.astFishEyeRegionAttr[region].stOutRect.u32Height;
418 
419     ctx->u32PointLen = ctx->u32PointLen > ((w + h) * 2) ? (w + h) * 2 : ctx->u32PointLen;
420     step = (RK_FLOAT)((w + h) * 2) / ctx->u32PointLen;
421 
422     for (RK_U32 i = 0; i < ctx->u32PointLen; i++) {
423         if ((step * i) <= w) {
424             ctx->pastDstPoint[i].s32X = step * i;
425             ctx->pastDstPoint[i].s32Y = 0;
426         } else if ((step * i) <= (w + h)) {
427             ctx->pastDstPoint[i].s32X = (w - 1);
428             ctx->pastDstPoint[i].s32Y = (step * i - w);
429             // printf("22 region:%d i%d= %d,%d\n", region, i, ctx->pastDstPoint[i].s32X, ctx->pastDstPoint[i].s32Y);
430         } else if ((step * i) <= (2 * w + h)) {
431             ctx->pastDstPoint[i].s32X = 2 * w + h - step * i;
432             ctx->pastDstPoint[i].s32Y = h - 1;
433             // printf("33 region:%d i%d=%d\n", region, i, ctx->pastDstPoint[i].s32X);
434         } else {
435             ctx->pastDstPoint[i].s32X = 0;
436             ctx->pastDstPoint[i].s32Y = (2 * (w + h)- step * i);
437             // printf("44 region:%d i%d=%d\n", region, i, ctx->pastDstPoint[i].s32Y);
438         }
439     }
440 
441     // get the array
442     GDC_FISHEYE_POINT_QUERY_ATTR_S stQuery;
443     memset(&stQuery, 0, sizeof(sizeof(FISHEYE_ATTR_S)));
444     stQuery.pstFishEyeAttr = &ctx->stFisheyeAttr;
445     stQuery.u32RegionIndex = region;
446     s32Ret = RK_MPI_GDC_FisheyePosQueryDst2PanoArray(&stQuery, &ctx->stTask.stImgIn, pano_region, ctx->u32PointLen,
447                                                      ctx->pastDstPoint, ctx->pastSrcPoint);
448     if (s32Ret != RK_SUCCESS) {
449         RK_LOGE("RK_MPI_GDC_FisheyePosQueryDst2PanoArray err:0x%x!", s32Ret);
450     }
451 
452     return s32Ret;
453 }
454 
test_mpi_gdc_desktop_ceil_mount_1p_add_1(TEST_GDC_CTX_S * ctx)455 RK_VOID test_mpi_gdc_desktop_ceil_mount_1p_add_1(TEST_GDC_CTX_S *ctx) {
456     RK_S32 index = 0;
457     RK_U32 fishOptParam_originX, fishOptParam_originY;
458     fishOptParam_originX = 4132;
459     fishOptParam_originY = 4169;
460     RK_U32 outWidthBase = 1920;
461     RK_U32 outHeightBase = 360;
462     RK_U32 outYBase = 720;
463 
464     if (ctx->u32SrcWidth == 1920 && ctx->u32SrcHeight == 1080) {
465         outWidthBase = 1920;
466         outHeightBase = 360;
467         outYBase = ctx->u32SrcHeight - outHeightBase;
468     } else if (ctx->u32SrcWidth == 2560 && ctx->u32SrcHeight == 1440) {
469         outWidthBase = 2560;
470         outHeightBase = 480;
471         outYBase = ctx->u32SrcHeight - outHeightBase;
472     } else if (ctx->u32SrcWidth == 3840 && ctx->u32SrcHeight == 2160) {
473         outWidthBase = 3840;
474         outHeightBase = 720;
475         outYBase = ctx->u32SrcHeight - outHeightBase;
476     } else if (ctx->u32SrcWidth == 7680 && ctx->u32SrcHeight == 4320) {
477         outWidthBase = 7680;
478         outHeightBase = 1440;
479         outYBase = ctx->u32SrcHeight - outHeightBase;
480     }
481 
482     ctx->stFisheyeAttr.bEnable = RK_TRUE;
483     ctx->stFisheyeAttr.bLMF = RK_FALSE;
484     ctx->stFisheyeAttr.bBgColor = RK_TRUE;
485     ctx->stFisheyeAttr.u32BgColor = 0;
486     ctx->stFisheyeAttr.s32HorOffset = ((fishOptParam_originX >> 3) - 512);
487     ctx->stFisheyeAttr.s32VerOffset = ((fishOptParam_originY >> 3) - 512);
488     ctx->stFisheyeAttr.u32TrapezoidCoef = 0;
489     ctx->stFisheyeAttr.s32FanStrength = 0;
490     // ctx->stFisheyeAttr.enMountMode = FISHEYE_WALL_MOUNT;
491 
492     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
493 
494     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
495     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
496     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
497     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
498     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
499     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
500     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
501     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
502     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
503     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outYBase;
504     index++;
505 
506     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_360_PANORAMA;
507     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
508     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
509     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
510     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
511     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
512     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
513     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
514     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outYBase;
515     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
516     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
517     index++;
518 
519     ctx->stFisheyeAttr.u32RegionNum = index;
520 }
521 
test_mpi_gdc_desktop_ceil_mount_1_add_3(TEST_GDC_CTX_S * ctx)522 RK_VOID test_mpi_gdc_desktop_ceil_mount_1_add_3(TEST_GDC_CTX_S *ctx) {
523     RK_S32 index = 0;
524     RK_U32 fishOptParam_originX, fishOptParam_originY;
525     fishOptParam_originX = 4132;
526     fishOptParam_originY = 4169;
527     RK_U32 outWidthBase = 640;
528     RK_U32 outHeightBase = 360;
529 
530     if (ctx->u32SrcWidth == 1920 && ctx->u32SrcHeight == 1080) {
531         outWidthBase = 960;
532         outHeightBase = 540;
533     } else if (ctx->u32SrcWidth == 2560 && ctx->u32SrcHeight == 1440) {
534         outWidthBase = 1280;
535         outHeightBase = 720;
536     } else if (ctx->u32SrcWidth == 3840 && ctx->u32SrcHeight == 2160) {
537         outWidthBase = 1920;
538         outHeightBase = 1080;
539     } else if (ctx->u32SrcWidth == 7680 && ctx->u32SrcHeight == 4320) {
540         outWidthBase = 3840;
541         outHeightBase = 2160;
542     }
543 
544     ctx->stFisheyeAttr.bEnable = RK_TRUE;
545     ctx->stFisheyeAttr.bLMF = RK_FALSE;
546     ctx->stFisheyeAttr.bBgColor = RK_TRUE;
547     ctx->stFisheyeAttr.u32BgColor = 0;
548     ctx->stFisheyeAttr.s32HorOffset = ((fishOptParam_originX >> 3) - 512);
549     ctx->stFisheyeAttr.s32VerOffset = ((fishOptParam_originY >> 3) - 512);
550     ctx->stFisheyeAttr.u32TrapezoidCoef = 0;
551     ctx->stFisheyeAttr.s32FanStrength = 0;
552     // ctx->stFisheyeAttr.enMountMode = FISHEYE_WALL_MOUNT;
553 
554     if (ctx->u32ShowPoint == 1)
555         ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_NO_TRANSFORMATION;
556     else
557         ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_360_PANORAMA;
558     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
559     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
560     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
561     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
562     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
563     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
564     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
565     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
566     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
567     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
568     index++;
569 
570     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
571     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
572     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
573     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 120; /* RW; Range: [0, 360] */
574     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
575     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
576     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
577     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
578     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
579     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
580     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
581     index++;
582 
583     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
584     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
585     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
586     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 240; /* RW; Range: [0, 360] */
587     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
588     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
589     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
590     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
591     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
592     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
593     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
594     index++;
595 
596     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
597     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
598     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
599     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 0; /* RW; Range: [0, 360] */
600     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
601     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
602     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
603     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
604     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
605     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
606     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
607     index++;
608 
609     // ctx->stFisheyeAttr.u32RegionNum = index;
610 }
611 
test_mpi_gdc_desktop_ceil_mount_1_add_8(TEST_GDC_CTX_S * ctx)612 RK_VOID test_mpi_gdc_desktop_ceil_mount_1_add_8(TEST_GDC_CTX_S *ctx) {
613     RK_S32 index = 0;
614     RK_U32 fishOptParam_originX, fishOptParam_originY;
615     fishOptParam_originX = 4132;
616     fishOptParam_originY = 4169;
617     RK_U32 outWidthBase = 640;
618     RK_U32 outHeightBase = 360;
619 
620     if (ctx->u32SrcWidth == 1920 && ctx->u32SrcHeight == 1080) {
621         outWidthBase = 640;
622         outHeightBase = 360;
623     } else if (ctx->u32SrcWidth == 2560 && ctx->u32SrcHeight == 1440) {
624         outWidthBase = 848;
625         outHeightBase = 480;
626     } else if (ctx->u32SrcWidth == 3840 && ctx->u32SrcHeight == 2160) {
627         outWidthBase = 1280;
628         outHeightBase = 720;
629     } else if (ctx->u32SrcWidth == 7680 && ctx->u32SrcHeight == 4320) {
630         outWidthBase = 2560;
631         outHeightBase = 1440;
632     }
633 
634     ctx->stFisheyeAttr.bEnable = RK_TRUE;
635     ctx->stFisheyeAttr.bLMF = RK_FALSE;
636     ctx->stFisheyeAttr.bBgColor = RK_TRUE;
637     ctx->stFisheyeAttr.u32BgColor = 0;
638     ctx->stFisheyeAttr.s32HorOffset = ((fishOptParam_originX >> 3) - 512);
639     ctx->stFisheyeAttr.s32VerOffset = ((fishOptParam_originY >> 3) - 512);
640     ctx->stFisheyeAttr.u32TrapezoidCoef = 0;
641     ctx->stFisheyeAttr.s32FanStrength = 0;
642     // ctx->stFisheyeAttr.enMountMode = FISHEYE_WALL_MOUNT;
643 
644     // 0
645     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
646     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
647     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
648     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 0; /* RW; Range: [0, 360] */
649     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
650     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
651     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
652     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
653     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
654     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
655     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
656     index++;
657 
658     // 1
659     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
660     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
661     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
662     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 45; /* RW; Range: [0, 360] */
663     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
664     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
665     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
666     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
667     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
668     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
669     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
670     index++;
671 
672     // 2
673     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
674     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
675     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
676     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 90; /* RW; Range: [0, 360] */
677     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
678     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
679     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
680     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase * 2;
681     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
682     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
683     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
684     index++;
685 
686     // 3
687     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
688     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
689     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
690     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 135; /* RW; Range: [0, 360] */
691     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
692     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
693     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
694     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
695     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
696     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
697     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
698     index++;
699 
700     // 4
701     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
702     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
703     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
704     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
705     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
706     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
707     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
708     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase * 2;
709     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
710     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
711     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
712     index++;
713 
714     // 5
715     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
716     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
717     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
718     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
719     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
720     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
721     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
722     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
723     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase * 2;
724     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
725     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
726     index++;
727 
728     // 6
729     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
730     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
731     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
732     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 225; /* RW; Range: [0, 360] */
733     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
734     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
735     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
736     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
737     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase * 2;
738     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
739     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
740     index++;
741 
742     // 7
743     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
744     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
745     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
746     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 270; /* RW; Range: [0, 360] */
747     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
748     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
749     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
750     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase * 2;
751     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase * 2;
752     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
753     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
754     index++;
755 
756     // 8
757     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_NO_TRANSFORMATION;
758     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
759     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
760     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 315; /* RW; Range: [0, 360] */
761     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 98; /* RW; Range: [0, 360] */
762     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
763     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
764     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
765     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
766     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
767     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
768     index++;
769 
770     ctx->stFisheyeAttr.u32RegionNum = index;
771 }
772 
test_mpi_gdc_desktop_ceil_mount_2p(TEST_GDC_CTX_S * ctx)773 RK_VOID test_mpi_gdc_desktop_ceil_mount_2p(TEST_GDC_CTX_S *ctx) {
774     RK_S32 index = 0;
775     RK_U32 fishOptParam_originX, fishOptParam_originY;
776     fishOptParam_originX = 4132;
777     fishOptParam_originY = 4169;
778     RK_U32 outWidthBase = 1920;
779     RK_U32 outHeightBase = 540;
780 
781     if (ctx->u32SrcWidth == 1920 && ctx->u32SrcHeight == 1080) {
782         outWidthBase = 1920;
783         outHeightBase = 540;
784     } else if (ctx->u32SrcWidth == 2560 && ctx->u32SrcHeight == 1440) {
785         outWidthBase = 2560;
786         outHeightBase = 720;
787     } else if (ctx->u32SrcWidth == 3840 && ctx->u32SrcHeight == 2160) {
788         outWidthBase = 3840;
789         outHeightBase = 1080;
790     } else if (ctx->u32SrcWidth == 7680 && ctx->u32SrcHeight == 4320) {
791         outWidthBase = 7680;
792         outHeightBase = 2160;
793     }
794 
795     ctx->stFisheyeAttr.bEnable = RK_TRUE;
796     ctx->stFisheyeAttr.bLMF = RK_FALSE;
797     ctx->stFisheyeAttr.bBgColor = RK_TRUE;
798     ctx->stFisheyeAttr.u32BgColor = 0;
799     ctx->stFisheyeAttr.s32HorOffset = ((fishOptParam_originX >> 3) - 512);
800     ctx->stFisheyeAttr.s32VerOffset = ((fishOptParam_originY >> 3) - 512);
801     ctx->stFisheyeAttr.u32TrapezoidCoef = 0;
802     ctx->stFisheyeAttr.s32FanStrength = 0;
803     // ctx->stFisheyeAttr.enMountMode = FISHEYE_WALL_MOUNT;
804 
805     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_360_PANORAMA;
806 
807     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
808     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
809     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 0; /* RW; Range: [0, 360] */
810     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
811     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 2047; /* RW; Range: [1, 4095] */
812     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
813     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
814     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
815     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
816     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
817     index++;
818 
819     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_360_PANORAMA;
820     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
821     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 474; /* RW; out radius of gdc correction region */
822     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
823     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
824     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 2047; /* RW; Range: [1, 4095] */
825     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
826     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
827     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
828     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
829     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
830     index++;
831 
832     ctx->stFisheyeAttr.u32RegionNum = index;
833 }
834 
test_mpi_gdc_desktop_mount(TEST_GDC_CTX_S * ctx)835 RK_VOID test_mpi_gdc_desktop_mount(TEST_GDC_CTX_S *ctx) {
836     switch (ctx->enDeskCeilMode) {
837         case TEST_GDC_DESK_CEIL_MODE_1P_ADD_1:
838             test_mpi_gdc_desktop_ceil_mount_1p_add_1(ctx);
839         break;
840         case TEST_GDC_DESK_CEIL_MODE_1_ADD_3:
841             test_mpi_gdc_desktop_ceil_mount_1_add_3(ctx);
842         break;
843         case TEST_GDC_DESK_CEIL_MODE_1_ADD_8:
844             test_mpi_gdc_desktop_ceil_mount_1_add_8(ctx);
845         break;
846          case TEST_GDC_DESK_CEIL_MODE_2P:
847             test_mpi_gdc_desktop_ceil_mount_2p(ctx);
848         break;
849         default:
850             RK_LOGE("not support this mode:%d", ctx->enDeskCeilMode);
851         break;
852     }
853 }
854 
test_mpi_gdc_ceiling_mount(TEST_GDC_CTX_S * ctx)855 RK_VOID test_mpi_gdc_ceiling_mount(TEST_GDC_CTX_S *ctx) {
856     test_mpi_gdc_desktop_mount(ctx);
857 }
858 
test_mpi_gdc_wall_mount_1p_add_3(TEST_GDC_CTX_S * ctx)859 RK_VOID test_mpi_gdc_wall_mount_1p_add_3(TEST_GDC_CTX_S *ctx) {
860     RK_S32 index = 0;
861     RK_U32 fishOptParam_originX, fishOptParam_originY;
862     fishOptParam_originX = 4364;
863     fishOptParam_originY = 4136;
864     RK_U32 outWidthBase = 640;
865     RK_U32 outHeightBase = 360;
866 
867     if (ctx->u32SrcWidth == 1920 && ctx->u32SrcHeight == 1080) {
868         outWidthBase = 960;
869         outHeightBase = 540;
870     } else if (ctx->u32SrcWidth == 2560 && ctx->u32SrcHeight == 1440) {
871         outWidthBase = 1280;
872         outHeightBase = 720;
873     } else if (ctx->u32SrcWidth == 3840 && ctx->u32SrcHeight == 2160) {
874         outWidthBase = 1920;
875         outHeightBase = 1080;
876     } else if (ctx->u32SrcWidth == 7680 && ctx->u32SrcHeight == 4320) {
877         outWidthBase = 3840;
878         outHeightBase = 2160;
879     }
880 
881     ctx->stFisheyeAttr.bEnable = RK_TRUE;
882     ctx->stFisheyeAttr.bLMF = RK_FALSE;
883     ctx->stFisheyeAttr.bBgColor = RK_TRUE;
884     ctx->stFisheyeAttr.u32BgColor = 0;
885     ctx->stFisheyeAttr.s32HorOffset = ((fishOptParam_originX >> 3) - 512);
886     ctx->stFisheyeAttr.s32VerOffset = ((fishOptParam_originY >> 3) - 512);
887     ctx->stFisheyeAttr.u32TrapezoidCoef = 0;
888     ctx->stFisheyeAttr.s32FanStrength = 0;
889     // ctx->stFisheyeAttr.enMountMode = FISHEYE_WALL_MOUNT;
890     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_180_PANORAMA;
891     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
892     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
893     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
894     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
895     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
896     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
897     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
898     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
899     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
900     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
901     index++;
902 
903     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
904     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
905     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
906     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
907     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
908     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
909     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
910     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
911     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
912     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
913     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
914     index++;
915 
916     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
917     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
918     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
919     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
920     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 207; /* RW; Range: [0, 360] */
921     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
922     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
923     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
924     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
925     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
926     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
927     index++;
928 
929     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
930     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
931     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
932     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
933     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 153; /* RW; Range: [0, 360] */
934     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
935     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
936     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
937     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
938     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
939     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
940     index++;
941 
942     // ctx->stFisheyeAttr.u32RegionNum = index;
943 }
944 
test_mpi_gdc_wall_mount_1p_add_8(TEST_GDC_CTX_S * ctx)945 RK_VOID test_mpi_gdc_wall_mount_1p_add_8(TEST_GDC_CTX_S *ctx) {
946     RK_S32 index = 0;
947     RK_U32 fishOptParam_originX, fishOptParam_originY;
948     fishOptParam_originX = 4364;
949     fishOptParam_originY = 4136;
950     RK_U32 outWidthBase = 640;
951     RK_U32 outHeightBase = 360;
952 
953     if (ctx->u32SrcWidth == 1920 && ctx->u32SrcHeight == 1080) {
954         outWidthBase = 640;
955         outHeightBase = 360;
956     } else if (ctx->u32SrcWidth == 2560 && ctx->u32SrcHeight == 1440) {
957         outWidthBase = 848;
958         outHeightBase = 480;
959     } else if (ctx->u32SrcWidth == 3840 && ctx->u32SrcHeight == 2160) {
960         outWidthBase = 1280;
961         outHeightBase = 720;
962     } else if (ctx->u32SrcWidth == 7680 && ctx->u32SrcHeight == 4320) {
963         outWidthBase = 2560;
964         outHeightBase = 1440;
965     }
966 
967     ctx->stFisheyeAttr.bEnable = RK_TRUE;
968     ctx->stFisheyeAttr.bLMF = RK_FALSE;
969     ctx->stFisheyeAttr.bBgColor = RK_TRUE;
970     ctx->stFisheyeAttr.u32BgColor = 0;
971     ctx->stFisheyeAttr.s32HorOffset = ((fishOptParam_originX >> 3) - 512);
972     ctx->stFisheyeAttr.s32VerOffset = ((fishOptParam_originY >> 3) - 512);
973     ctx->stFisheyeAttr.u32TrapezoidCoef = 0;
974     ctx->stFisheyeAttr.s32FanStrength = 0;
975     // ctx->stFisheyeAttr.enMountMode = FISHEYE_WALL_MOUNT;
976 
977     // 0
978     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
979     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
980     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
981     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 153; /* RW; Range: [0, 360] */
982     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 153; /* RW; Range: [0, 360] */
983     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
984     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
985     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
986     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
987     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
988     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
989     index++;
990 
991     // 1
992     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
993     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
994     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
995     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 153; /* RW; Range: [0, 360] */
996     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
997     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
998     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
999     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
1000     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
1001     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
1002     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
1003     index++;
1004 
1005     // 2
1006     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
1007     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
1008     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
1009     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 153; /* RW; Range: [0, 360] */
1010     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 207; /* RW; Range: [0, 360] */
1011     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
1012     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
1013     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase * 2;
1014     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = 0;
1015     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
1016     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
1017     index++;
1018 
1019     // 3
1020     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
1021     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
1022     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
1023     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
1024     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 207; /* RW; Range: [0, 360] */
1025     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
1026     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
1027     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
1028     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
1029     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
1030     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
1031     index++;
1032 
1033     // 4 scale
1034     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_180_PANORAMA;
1035     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
1036     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
1037     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
1038     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
1039     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
1040     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
1041     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
1042     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
1043     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
1044     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
1045     index++;
1046 
1047     // 5
1048     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
1049     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
1050     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
1051     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 180; /* RW; Range: [0, 360] */
1052     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 153; /* RW; Range: [0, 360] */
1053     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
1054     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
1055     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase * 2;
1056     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase;
1057     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
1058     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
1059     index++;
1060 
1061     // 6
1062     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
1063     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
1064     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
1065     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 207; /* RW; Range: [0, 360] */
1066     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 153; /* RW; Range: [0, 360] */
1067     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
1068     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
1069     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = 0; /* RW; out Imge rectangle attribute */
1070     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase * 2;
1071     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
1072     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
1073     index++;
1074 
1075     // 7
1076     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
1077     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
1078     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
1079     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 207; /* RW; Range: [0, 360] */
1080     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 180; /* RW; Range: [0, 360] */
1081     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
1082     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
1083     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase; /* RW; out Imge rectangle attribute */
1084     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase * 2;
1085     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
1086     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
1087     index++;
1088 
1089     // 8
1090     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].enViewMode = FISHEYE_VIEW_NORMAL;
1091     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32InRadius = 0; /* RW; inner radius of gdc correction region */
1092     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32OutRadius = 442; /* RW; out radius of gdc correction region */
1093     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Pan = 207; /* RW; Range: [0, 360] */
1094     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32Tilt = 207; /* RW; Range: [0, 360] */
1095     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32HorZoom = 4095; /* RW; Range: [1, 4095] */
1096     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].u32VerZoom = 4095; /* RW; Range: [1, 4095] */
1097     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32X = outWidthBase * 2;
1098     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.s32Y = outHeightBase * 2;
1099     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Width = outWidthBase;
1100     ctx->stFisheyeAttr.astFishEyeRegionAttr[index].stOutRect.u32Height = outHeightBase;
1101     index++;
1102 
1103     ctx->stFisheyeAttr.u32RegionNum = index;
1104 }
1105 
test_mpi_gdc_wall_mount(TEST_GDC_CTX_S * ctx)1106 RK_VOID test_mpi_gdc_wall_mount(TEST_GDC_CTX_S *ctx) {
1107     switch (ctx->enWallMode) {
1108         case TEST_GDC_WALL_MODE_1P_ADD_3:
1109             test_mpi_gdc_wall_mount_1p_add_3(ctx);
1110         break;
1111         case TEST_GDC_WALL_MODE_1P_ADD_8:
1112             test_mpi_gdc_wall_mount_1p_add_8(ctx);
1113         break;
1114         default:
1115             RK_LOGE("not support this mode:%d", ctx->enWallMode);
1116         break;
1117     }
1118 }
1119 
test_mpi_gdc_xy_in_valid(RK_U32 xy,RK_U32 max,RK_S32 op)1120 static RK_BOOL test_mpi_gdc_xy_in_valid(RK_U32 xy, RK_U32 max, RK_S32 op) {
1121      RK_S32 result = xy + op;
1122      if (result < max && result >= 0)
1123          return RK_TRUE;
1124      else
1125          return RK_FALSE;
1126 }
1127 
1128 // tmp code
test_mpi_gdc_api(TEST_GDC_CTX_S * ctx)1129 RK_S32 test_mpi_gdc_api(TEST_GDC_CTX_S *ctx) {
1130     RK_S32 s32Ret;
1131     GDC_HANDLE hHandle = -1;
1132     void *pSrcData = RK_NULL;
1133     RK_S32 loopCount = 0;
1134     FILE *pFile = NULL;
1135     RK_U32 u32ReadSize = 0;
1136     MB_POOL_CONFIG_S stMbPoolCfg;
1137     VIDEO_FRAME_INFO_S stFrame;
1138     VIDEO_FRAME_INFO_S stLineFrame;
1139     VO_FRAME_INFO_S voLineFrame;
1140     MB_BLK pLineMbBlk;
1141 
1142     memset(&stFrame, 0, sizeof(VIDEO_FRAME_INFO_S));
1143     memset(&stMbPoolCfg, 0, sizeof(MB_POOL_CONFIG_S));
1144 
1145     ctx->u32SrcSize = unit_test_gdc_get_size(ctx);
1146     stMbPoolCfg.u64MBSize = ctx->u32SrcSize;
1147     stMbPoolCfg.u32MBCnt = 4;
1148     stMbPoolCfg.enAllocType = MB_ALLOC_TYPE_DMA;
1149     ctx->inPool = RK_MPI_MB_CreatePool(&stMbPoolCfg);
1150 
1151     pFile = fopen(ctx->srcFilePath, "rb+");
1152     if (pFile == RK_NULL) {
1153         RK_LOGE("open path %s failed because %s", ctx->srcFilePath, strerror(errno));
1154         goto __FAILED;
1155     }
1156 
1157     // vo init and create
1158     ctx->s32VoLayer = RK35XX_VOP_LAYER_CLUSTER_0;
1159     ctx->s32VoDev = RK35XX_VO_DEV_HD0;
1160     ctx->s32VoChn = RK35XX_VO_GDC_CHN;
1161     ctx->stLayerAttr.enPixFormat = RK_FMT_BGR888;
1162     ctx->stLayerAttr.stDispRect.s32X = 0;
1163     ctx->stLayerAttr.stDispRect.s32Y = 0;
1164     ctx->stLayerAttr.u32DispFrmRt = 30;
1165     ctx->stLayerAttr.stDispRect.u32Width = ctx->u32VoWidth;
1166     ctx->stLayerAttr.stDispRect.u32Height = ctx->u32VoHeight;
1167     ctx->stLayerAttr.stImageSize.u32Width = ctx->u32VoWidth;
1168     ctx->stLayerAttr.stImageSize.u32Height = ctx->u32VoHeight;
1169 
1170     ctx->stChnAttr.stRect.s32X = ctx->stChnRect.s32X;
1171     ctx->stChnAttr.stRect.s32Y = ctx->stChnRect.s32Y;
1172     ctx->stChnAttr.stRect.u32Width = ctx->stChnRect.u32Width;
1173     ctx->stChnAttr.stRect.u32Height = ctx->stChnRect.u32Height;
1174     ctx->stChnAttr.u32Priority = 0;
1175     ctx->stChnAttr.u32FgAlpha = 128;
1176     ctx->stChnAttr.u32BgAlpha = 0;
1177     // ctx->stChnAttr.bGdc = RK_TRUE;  // reserve
1178 
1179     s32Ret = create_vo(ctx, ctx->s32VoChn);
1180     if (s32Ret != RK_SUCCESS) {
1181         RK_LOGE("create vo dev:%d failed:0x%x", ctx->s32VoDev, s32Ret);
1182         goto __FAILED;
1183     }
1184     // enable vo
1185     s32Ret = RK_MPI_VO_EnableChn(ctx->s32VoLayer, ctx->s32VoChn);
1186     if (s32Ret != RK_SUCCESS) {
1187         RK_LOGE("Enalbe vo chn failed, s32Ret = %d", s32Ret);
1188         goto __FAILED;
1189     }
1190     // test vo chn127 for show line
1191     if (ctx->u32ShowPoint) {
1192         /*ctx->u32LineWidth = 640;
1193         ctx->u32LineHeight = 480;*/
1194         RK_MPI_VO_CreateGraphicsFrameBuffer(ctx->u32LineWidth, ctx->u32LineHeight, RK_FMT_BGRA5551, &pLineMbBlk);
1195         stLineFrame.stVFrame.u32Width = ctx->u32LineWidth;
1196         stLineFrame.stVFrame.u32Height = ctx->u32LineHeight;
1197         stLineFrame.stVFrame.u32VirWidth = ctx->u32LineWidth;
1198         stLineFrame.stVFrame.u32VirHeight = ctx->u32LineHeight;
1199         stLineFrame.stVFrame.enPixelFormat = RK_FMT_BGRA5551;
1200         stLineFrame.stVFrame.enCompressMode = COMPRESS_MODE_NONE;
1201         stLineFrame.stVFrame.pMbBlk = pLineMbBlk;
1202 
1203         ctx->stChnAttr.stRect.s32X = 0;
1204         ctx->stChnAttr.stRect.s32Y = 0;
1205         ctx->stChnAttr.stRect.u32Width = 960;
1206         ctx->stChnAttr.stRect.u32Height = 540;
1207         ctx->stChnAttr.u32Priority = RK35XX_VO_LINE_CHN;
1208         ctx->stChnAttr.u32FgAlpha = 255;
1209         ctx->stChnAttr.u32BgAlpha = 0;
1210         // ctx->stChnAttr.bGdc = RK_FALSE;  // reserve
1211         s32Ret = RK_MPI_VO_SetChnAttr(ctx->s32VoLayer, RK35XX_VO_LINE_CHN, &ctx->stChnAttr);
1212         if (s32Ret != RK_SUCCESS) {
1213             RK_LOGE("set chn Attr failed,s32Ret:%d\n", s32Ret);
1214             return RK_FAILURE;
1215         }
1216         s32Ret = RK_MPI_VO_EnableChn(ctx->s32VoLayer, RK35XX_VO_LINE_CHN);
1217         if (s32Ret != RK_SUCCESS) {
1218             RK_LOGE("Enalbe vo chn failed, s32Ret = %d", s32Ret);
1219             goto __FAILED;
1220         }
1221     }
1222 
1223     // gdc test config
1224     if (ctx->stFisheyeAttr.enMountMode == FISHEYE_DESKTOP_MOUNT) {
1225         test_mpi_gdc_desktop_mount(ctx);
1226     } else if (ctx->stFisheyeAttr.enMountMode == FISHEYE_CEILING_MOUNT) {
1227         test_mpi_gdc_ceiling_mount(ctx);
1228     } else if (ctx->stFisheyeAttr.enMountMode == FISHEYE_WALL_MOUNT) {
1229         test_mpi_gdc_wall_mount(ctx);
1230     } else {
1231         RK_LOGE("not support this mount = %d", ctx->stFisheyeAttr.enMountMode);
1232         goto __FAILED;
1233     }
1234 
1235     while (1) {
1236         // img in
1237         ctx->stTask.stImgIn.stVFrame.pMbBlk = RK_MPI_MB_GetMB(ctx->inPool, ctx->u32SrcSize, RK_TRUE);
1238         if (RK_NULL == ctx->stTask.stImgIn.stVFrame.pMbBlk) {
1239             usleep(10000llu);
1240             continue;
1241         }
1242         ctx->stTask.stImgIn.stVFrame.u32Width = ctx->u32SrcWidth;
1243         ctx->stTask.stImgIn.stVFrame.u32Height = ctx->u32SrcHeight;
1244         ctx->stTask.stImgIn.stVFrame.u32VirWidth = ctx->u32SrcVirWidth;
1245         ctx->stTask.stImgIn.stVFrame.u32VirHeight = ctx->u32SrcVirHeight;
1246         ctx->stTask.stImgIn.stVFrame.enPixelFormat = (PIXEL_FORMAT_E)ctx->s32SrcPixFormat;
1247         ctx->stTask.stImgIn.stVFrame.u32FrameFlag = 0;
1248         ctx->stTask.stImgIn.stVFrame.enCompressMode = (COMPRESS_MODE_E)ctx->s32SrcCompressMode;
1249         // img out
1250         ctx->stTask.stImgOut.stVFrame.u32Width = ctx->u32DstWidth;
1251         ctx->stTask.stImgOut.stVFrame.u32Height = ctx->u32DstHeight;
1252         ctx->stTask.stImgOut.stVFrame.u32VirWidth = ctx->u32DstWidth;
1253         ctx->stTask.stImgOut.stVFrame.u32VirHeight = ctx->u32DstHeight;
1254         ctx->stTask.stImgOut.stVFrame.enPixelFormat = (PIXEL_FORMAT_E)ctx->s32SrcPixFormat;
1255         ctx->stTask.stImgOut.stVFrame.u32FrameFlag = 0;
1256         ctx->stTask.stImgOut.stVFrame.enCompressMode = (COMPRESS_MODE_E)ctx->s32SrcCompressMode;
1257         ctx->stTask.stImgOut.stVFrame.pMbBlk = ctx->stTask.stImgIn.stVFrame.pMbBlk;
1258         // usleep(100*1000);
1259 
1260         // test_mpi_gdc_get_src_point(ctx);
1261         // test_mpi_gdc_get_pano_point(ctx);
1262 
1263         // read image
1264         pSrcData = RK_MPI_MB_Handle2VirAddr(ctx->stTask.stImgIn.stVFrame.pMbBlk);
1265         if (ctx->s32SrcCompressMode == COMPRESS_AFBC_16x16) {
1266             if (fread(pSrcData, 1, ctx->u32SrcSize, pFile) != ctx->u32SrcSize)
1267                 s32Ret = RK_FAILURE;
1268             else
1269                 s32Ret = RK_SUCCESS;
1270         } else {
1271             s32Ret = read_image(reinterpret_cast<RK_U8 *>(pSrcData), ctx->u32SrcWidth, ctx->u32SrcHeight,
1272                                 ctx->u32SrcVirWidth, ctx->u32SrcVirHeight, ctx->s32SrcPixFormat, pFile);
1273         }
1274 
1275         if (s32Ret != RK_SUCCESS) {
1276             if (loopCount < ctx->s32LoopCount) {
1277                 fseek(pFile, 0L, SEEK_SET);
1278                 // RK_LOGI("seek:%d", loopCount);
1279                 RK_MPI_MB_ReleaseMB(ctx->stTask.stImgIn.stVFrame.pMbBlk);
1280                 continue;
1281             } else {
1282                 RK_LOGD("loop:%d end!", loopCount);
1283                 break;
1284             }
1285         }
1286         RK_MPI_SYS_MmzFlushCache(ctx->stTask.stImgIn.stVFrame.pMbBlk, RK_FALSE);
1287         RK_LOGD("gdc loop:%d!", loopCount);
1288 #if 1
1289         // test gdc
1290         s32Ret = RK_MPI_GDC_BeginJob(&hHandle);
1291         if (s32Ret != RK_SUCCESS) {
1292             RK_LOGE("RK_MPI_GDC_BeginJob err:0x%x!", s32Ret);
1293             goto __FAILED;
1294         }
1295         s32Ret = RK_MPI_GDC_SetConfig(hHandle, &ctx->stFisheyeJobConfig);
1296         if (s32Ret != RK_SUCCESS) {
1297             RK_MPI_GDC_CancelJob(hHandle);
1298             RK_LOGE("RK_MPI_GDC_SetConfig err:0x%x!", s32Ret);
1299             goto __FAILED;
1300         }
1301         for (RK_S32 multi = 0; multi < ctx->s32TaskSum; multi++) {
1302             s32Ret = RK_MPI_GDC_AddCorrectionTask(hHandle, &ctx->stTask, &ctx->stFisheyeAttr);
1303             if (s32Ret != RK_SUCCESS) {
1304                 RK_MPI_GDC_CancelJob(hHandle);
1305                 RK_LOGE("RK_MPI_GDC_AddCorrectionTask err:0x%x!", s32Ret);
1306                 goto __FAILED;
1307             }
1308             // ctx->stTask.u64TaskId = 0;
1309         }
1310 #if 0  // test multi diff task
1311         ctx->stTask.u64TaskId = ctx->stTask.u64TaskId + 10;
1312         s32Ret = RK_MPI_GDC_AddCorrectionTask(hHandle, &ctx->stTask, &ctx->stFisheyeAttr);
1313         if (s32Ret != RK_SUCCESS) {
1314             RK_MPI_GDC_CancelJob(hHandle);
1315             RK_LOGE("RK_MPI_GDC_AddCorrectionTask err:0x%x!", s32Ret);
1316             goto __FAILED;
1317         }
1318 #endif
1319         if (ctx->u32ChangeParam) {
1320             test_mpi_gdc_change_parameter(ctx, 1, TEST_GDC_CHANGE_TYPE_PAN);
1321             test_mpi_gdc_change_parameter(ctx, 2, TEST_GDC_CHANGE_TYPE_TILT);
1322             test_mpi_gdc_change_parameter(ctx, 3, TEST_GDC_CHANGE_TYPE_HOR_ZOOM);
1323             test_mpi_gdc_change_parameter(ctx, 3, TEST_GDC_CHANGE_TYPE_VER_ZOOM);
1324         }
1325 
1326         s32Ret = RK_MPI_GDC_EndJob(hHandle);
1327         if (s32Ret != RK_SUCCESS) {
1328             RK_MPI_GDC_CancelJob(hHandle);
1329             RK_LOGE("RK_MPI_GDC_EndJob err:0x%x!", s32Ret);
1330             goto __FAILED;
1331         }
1332 #endif
1333         // gdc out show to vo
1334         stFrame.stVFrame = ctx->stTask.stImgOut.stVFrame;
1335 
1336         s32Ret = RK_MPI_VO_SendFrame(ctx->s32VoLayer, ctx->s32VoChn, &stFrame, -1);
1337         if (s32Ret != RK_SUCCESS) {
1338             RK_LOGE("RK_MPI_VO_SendFrame failed ret:0x%x", s32Ret);
1339             RK_MPI_VO_DestroyGraphicsFrameBuffer(ctx->stTask.stImgIn.stVFrame.pMbBlk);
1340         }
1341         // test chn 127 show point chain
1342         if (ctx->u32ShowPoint && (loopCount == 0 || ctx->u32ChangeParam)) {
1343             if (ctx->u32ChangeParam) {
1344                 memset(RK_MPI_MB_Handle2VirAddr(pLineMbBlk), 0x0, ctx->u32LineWidth * ctx->u32LineHeight * 2);
1345                 RK_MPI_SYS_MmzFlushCache(pLineMbBlk, RK_FALSE);
1346             }
1347             RK_U16 *pLineData = (RK_U16 *)RK_MPI_MB_Handle2VirAddr(pLineMbBlk);
1348             if (ctx->u32ShowPoint == 1) {
1349                 RK_U32 x, y;
1350                 for (RK_U32 region = 1; region < ctx->stFisheyeAttr.u32RegionNum; region++) {
1351                     if (ctx->stFisheyeAttr.enMountMode == FISHEYE_WALL_MOUNT) {  // pano
1352                         test_mpi_gdc_get_pano_point_array(ctx, region, 0);
1353                         for (RK_U32 l = 0; l < ctx->u32PointLen; l++) {
1354                             x = ctx->pastSrcPoint[l].s32X *
1355                                 (ctx->u32LineWidth / ctx->stFisheyeAttr.astFishEyeRegionAttr[0].stOutRect.u32Width);
1356                             y = ctx->pastSrcPoint[l].s32Y *
1357                                 (ctx->u32LineHeight / ctx->stFisheyeAttr.astFishEyeRegionAttr[0].stOutRect.u32Height);
1358                             if (test_mpi_gdc_xy_in_valid(y * ctx->u32LineWidth + x,
1359                                                          ctx->u32LineWidth * ctx->u32LineHeight, 0))
1360                                 pLineData[y * ctx->u32LineWidth + x] = gau16PointColor[region - 1];
1361                         }
1362                     } else {  // src
1363                         test_mpi_gdc_get_src_point_array(ctx, region);
1364                         for (RK_U32 l = 0; l < ctx->u32PointLen; l++) {
1365                             x = ctx->pastSrcPoint[l].s32X / (ctx->u32SrcWidth / ctx->u32LineWidth);
1366                             y = ctx->pastSrcPoint[l].s32Y / (ctx->u32SrcHeight / ctx->u32LineHeight);
1367                             if (test_mpi_gdc_xy_in_valid(y * ctx->u32LineWidth + x,
1368                                                          ctx->u32LineWidth * ctx->u32LineHeight, 0))
1369                                 pLineData[y * ctx->u32LineWidth + x] = gau16PointColor[region - 1];
1370                         }
1371                     }
1372                 }
1373             }
1374             RK_MPI_SYS_MmzFlushCache(pLineMbBlk, RK_FALSE);
1375             s32Ret = RK_MPI_VO_SendFrame(ctx->s32VoLayer, RK35XX_VO_LINE_CHN, &stLineFrame, -1);
1376             if (s32Ret != RK_SUCCESS) {
1377                 RK_LOGE("RK_MPI_VO_SendFrame failed ret:0x%x", s32Ret);
1378                 RK_MPI_VO_DestroyGraphicsFrameBuffer(pLineMbBlk);
1379             }
1380         }
1381         RK_MPI_MB_ReleaseMB(ctx->stTask.stImgIn.stVFrame.pMbBlk);
1382 
1383         loopCount++;
1384         if (loopCount >= ctx->s32LoopCount) {
1385             RK_LOGD("gdc loop:%d end!", loopCount);
1386             break;
1387         }
1388         usleep(1*1000);
1389     }
1390 
1391 __FAILED:
1392     // disable vo
1393     RK_MPI_VO_ClearChnBuffer(ctx->s32VoLayer, ctx->s32VoChn, RK_TRUE);
1394     RK_MPI_VO_DisableChn(ctx->s32VoLayer, ctx->s32VoChn);
1395     if (ctx->u32ShowPoint) {
1396         RK_MPI_VO_ReleaseGfxFrameBuffer(ctx->s32VoLayer, RK35XX_VO_LINE_CHN);
1397         RK_MPI_VO_ClearChnBuffer(ctx->s32VoLayer, RK35XX_VO_LINE_CHN, RK_TRUE);
1398         RK_MPI_VO_DisableChn(ctx->s32VoLayer, RK35XX_VO_LINE_CHN);
1399     }
1400     RK_MPI_VO_DisableLayer(ctx->s32VoLayer);
1401     RK_MPI_VO_DisableLayer(RK35XX_VOP_LAYER_ESMART_0);
1402     RK_MPI_VO_DisableLayer(RK35XX_VOP_LAYER_ESMART_1);
1403     RK_MPI_VO_DisableLayer(RK35XX_VOP_LAYER_SMART_0);
1404     RK_MPI_VO_DisableLayer(RK35XX_VOP_LAYER_SMART_1);
1405     RK_MPI_VO_Disable(ctx->s32VoDev);
1406 
1407     RK_LOGE("exit err:0x%x!", s32Ret);
1408     RK_MPI_GDC_StopJob(hHandle);
1409     RK_MPI_MB_DestroyPool(ctx->inPool);
1410 
1411     if (pFile) {
1412         fclose(pFile);
1413     }
1414 
1415     return s32Ret;
1416 }
1417 
1418 static const char *const usages[] = {
1419     "./rk_mpi_gdc_test -i /data/fisheye_in_s1920_h1080_w1920_14.yuv -w 1920 -h 1080  -f 6 -l 1000"
1420     " --region_num 4 --show_point 1 --point_len 6000 --change_param 0",
1421     NULL,
1422 };
1423 
mpi_gdc_test_show_options(const TEST_GDC_CTX_S * ctx)1424 static void mpi_gdc_test_show_options(const TEST_GDC_CTX_S *ctx) {
1425     RK_PRINT("cmd parse result:\n");
1426     RK_PRINT("input  file name       : %s\n", ctx->srcFilePath);
1427     RK_PRINT("src width              : %d\n", ctx->u32SrcWidth);
1428     RK_PRINT("src height             : %d\n", ctx->u32SrcHeight);
1429     RK_PRINT("dst width              : %d\n", ctx->u32DstWidth);
1430     RK_PRINT("dst height             : %d\n", ctx->u32DstHeight);
1431     RK_PRINT("line width             : %d\n", ctx->u32LineWidth);
1432     RK_PRINT("line height            : %d\n", ctx->u32LineHeight);
1433     RK_PRINT("loop count             : %d\n", ctx->s32LoopCount);
1434     RK_PRINT("src pixel format       : %d\n", ctx->s32SrcPixFormat);
1435     RK_PRINT("compress mode          : %d\n", ctx->s32SrcCompressMode);
1436     RK_PRINT("task_id                : %d\n", ctx->stTask.u64TaskId);
1437     RK_PRINT("task_sum               : %d\n", ctx->s32TaskSum);
1438     RK_PRINT("stepx                  : %d\n", ctx->stTask.au64privateData[0]);
1439     RK_PRINT("stepy                  : %d\n", ctx->stTask.au64privateData[1]);
1440     RK_PRINT("regionNum              : %d\n", ctx->stFisheyeAttr.u32RegionNum);
1441     RK_PRINT("mount mode             : %d\n", ctx->stFisheyeAttr.enMountMode);
1442     RK_PRINT("desk/ceil mode         : %d\n", ctx->enDeskCeilMode);
1443     RK_PRINT("wall mode              : %d\n", ctx->enWallMode);
1444     RK_PRINT("show_point             : %d\n", ctx->u32ShowPoint);
1445     RK_PRINT("point_len              : %d\n", ctx->u32PointLen);
1446     RK_PRINT("change param           : %d\n", ctx->u32ChangeParam);
1447     RK_PRINT("vo out resolution      : %d\n", ctx->stVoOutputResolution);
1448     RK_PRINT("vo chn rect x          : %d\n", ctx->stChnRect.s32X);
1449     RK_PRINT("vo chn rect y          : %d\n", ctx->stChnRect.s32Y);
1450     RK_PRINT("vo chn rect w          : %d\n", ctx->stChnRect.u32Width);
1451     RK_PRINT("vo chn rect h          : %d\n", ctx->stChnRect.u32Height);
1452 
1453     return;
1454 }
1455 
main(int argc,const char ** argv)1456 int main(int argc, const char **argv) {
1457     RK_S32 s32Ret = RK_SUCCESS;
1458     TEST_GDC_CTX_S *ctx;
1459     ctx = (TEST_GDC_CTX_S *)calloc(1, sizeof(TEST_GDC_CTX_S));
1460     if (!ctx) {
1461         RK_LOGE("calloc gdc ctx fail!");
1462         return 0;
1463     }
1464 
1465     //  set default params.
1466     ctx->s32LoopCount = 1;
1467     ctx->stFisheyeAttr.u32RegionNum = 4;
1468     ctx->s32TaskSum = 1;
1469     ctx->u32ChangeParam = 0;
1470     ctx->u32PointLen = 3000;
1471     ctx->stFisheyeAttr.enMountMode = FISHEYE_WALL_MOUNT;
1472     ctx->enWallMode = TEST_GDC_WALL_MODE_1P_ADD_3;
1473     ctx->enDeskCeilMode = TEST_GDC_DESK_CEIL_MODE_1_ADD_3;
1474     ctx->stVoOutputResolution = VO_OUTPUT_1080P30;
1475     ctx->u32VoWidth = 1920;
1476     ctx->u32VoHeight = 1080;
1477     ctx->stChnRect.s32X = 0;
1478     ctx->stChnRect.s32Y = 0;
1479     ctx->stChnRect.u32Width = 1920;
1480     ctx->stChnRect.u32Height = 1080;
1481 
1482     struct argparse_option options[] = {
1483         OPT_HELP(),
1484         OPT_GROUP("basic options:"),
1485         OPT_STRING('i', "input",  &(ctx->srcFilePath),
1486                    "input file name. <required>", NULL, 0, 0),
1487         OPT_INTEGER('w', "src_width", &(ctx->u32SrcWidth),
1488                     "input source width. <required>", NULL, 0, 0),
1489         OPT_INTEGER('h', "src_height", &(ctx->u32SrcHeight),
1490                     "input source height. <required>", NULL, 0, 0),
1491         OPT_INTEGER('W', "dst_width", &(ctx->u32DstWidth),
1492                     "output img width.default(src_width)", NULL, 0, 0),
1493         OPT_INTEGER('H', "dst_height", &(ctx->u32DstHeight),
1494                     "output img height.default(src_height).", NULL, 0, 0),
1495         OPT_INTEGER('\0', "line_width", &(ctx->u32LineWidth),
1496                     "line img width.(default src_width;range(0, src_width))", NULL, 0, 0),
1497         OPT_INTEGER('\0', "line_height", &(ctx->u32LineHeight),
1498                     "line img height.(default src_height;range(0, src_height)).", NULL, 0, 0),
1499         OPT_INTEGER('f', "pixel_format", &(ctx->s32SrcPixFormat),
1500                     "input source pixel format. default 0; (0:NV12 6:NV21).", NULL, 0, 0),
1501         OPT_INTEGER('l', "loop_count", &(ctx->s32LoopCount),
1502                     "loop running count. default(1)", NULL, 0, 0),
1503         OPT_INTEGER('\0', "src_compress_mode", &(ctx->s32SrcCompressMode),
1504                     "set input compressmode(default 0; 0:MODE_NONE 1:AFBC_16x16)", NULL, 0, 0),
1505         OPT_INTEGER('\0', "task_id", &(ctx->stTask.u64TaskId),
1506                     "set task id(default 0; 0:auto alloc task id >0:specify the task id)", NULL, 0, 0),
1507         OPT_INTEGER('\0', "stepx", &(ctx->stTask.au64privateData[0]),
1508                      "set step x(default 0)", NULL, 0, 0),
1509         OPT_INTEGER('\0', "stepy", &(ctx->stTask.au64privateData[1]),
1510                      "set step y(default 0)", NULL, 0, 0),
1511         OPT_INTEGER('\0', "region_num", &(ctx->stFisheyeAttr.u32RegionNum),
1512                      "set region num(default 4(1+3))", NULL, 0, 0),
1513         OPT_INTEGER('\0', "mount_type", &(ctx->stFisheyeAttr.enMountMode),
1514                      "set mount type(default 2;(0:desktop mount 1:ceiling mount 2:wall mount))", NULL, 0, 0),
1515         OPT_INTEGER('\0', "desk_ceil_mode", &(ctx->enDeskCeilMode),
1516                       "set desk or ceil mode(default 2;(0:1p+1 1:2p 2:1+3 3:1+4(not implement)"
1517                       "4:1p+6(not implement) 5:1+8))", NULL, 0, 0),
1518         OPT_INTEGER('\0', "wall_mode", &(ctx->enWallMode),
1519                       "set wall moode(default 1;(0:1p(not implement) 1:1p+3 2:1p+4(not implement)"
1520                       "3:1p+8))", NULL, 0, 0),
1521         OPT_INTEGER('\0', "task_sum", &(ctx->s32TaskSum),
1522                      "set test task sum(default 1)", NULL, 0, 0),
1523         OPT_INTEGER('\0', "show_point", &(ctx->u32ShowPoint),
1524                      "set show point chain(default 0; 0:no show point chain 1:show with scale"
1525                      "2:show with pano(not unrealized))", NULL, 0, 0),
1526         OPT_INTEGER('\0', "change_param", &(ctx->u32ChangeParam),
1527                      "set change param test(default 0)", NULL, 0, 0),
1528         OPT_INTEGER('\0', "point_len", &(ctx->u32PointLen),
1529                      "set point len(default 3000, when ctx->u32ShowPoint > 0 valid;"
1530                      "range:[0, line image perimeter])", NULL, 0, 0),
1531         OPT_INTEGER('\0', "vo_resolution", &(ctx->stVoOutputResolution),
1532                      "set change param test(default 4;(4:1080p30 10:1080p60 31:3840*2160p30"
1533                      "41:7680*4320p30))", NULL, 0, 0),
1534         OPT_INTEGER('\0', "vo_chn_x", &(ctx->stChnRect.s32X),
1535                     "vo chn attr rect x.default(0)", NULL, 0, 0),
1536         OPT_INTEGER('\0', "vo_chn_y", &(ctx->stChnRect.s32Y),
1537                     "vo chn attr rect y.default(0).", NULL, 0, 0),
1538         OPT_INTEGER('\0', "vo_chn_w", &(ctx->stChnRect.u32Width),
1539                     "vo chn attr rect w.default(1920)", NULL, 0, 0),
1540         OPT_INTEGER('\0', "vo_chn_h", &(ctx->stChnRect.u32Height),
1541                     "vo chn attr rect h.default(1080).", NULL, 0, 0),
1542         OPT_END(),
1543     };
1544 
1545     struct argparse argparse;
1546     argparse_init(&argparse, options, usages, 0);
1547     argparse_describe(&argparse, "\nselect a test case to run.",
1548                                  "\nuse --help for details.");
1549 
1550     argc = argparse_parse(&argparse, argc, argv);
1551 
1552     if (ctx->u32DstWidth == 0)
1553         ctx->u32DstWidth = ctx->u32SrcWidth;
1554     if (ctx->u32DstHeight == 0)
1555         ctx->u32DstHeight = ctx->u32SrcHeight;
1556 
1557     if (ctx->u32LineWidth == 0)
1558         ctx->u32LineWidth = ctx->u32SrcWidth;
1559     if (ctx->u32LineHeight == 0)
1560         ctx->u32LineHeight = ctx->u32SrcHeight;
1561 
1562     if (ctx->stVoOutputResolution == 31) {
1563         ctx->u32VoWidth = 3840;
1564         ctx->u32VoHeight = 2160;
1565     } else if (ctx->stVoOutputResolution >= VO_OUTPUT_7680x4320_24 &&
1566                ctx->stVoOutputResolution <= VO_OUTPUT_7680x4320_60) {
1567         ctx->u32VoWidth = 7680;
1568         ctx->u32VoHeight = 4320;
1569     }
1570 
1571     mpi_gdc_test_show_options(ctx);
1572     if (ctx->srcFilePath == RK_NULL ||
1573         ctx->u32SrcWidth <= 0 ||
1574         ctx->u32SrcHeight <= 0) {
1575         argparse_usage(&argparse);
1576         goto __FAILED;
1577     }
1578 
1579     if (ctx->u32ShowPoint && ctx->u32PointLen) {
1580         ctx->pastDstPoint = (POINT_S *)malloc(sizeof(POINT_S) * ctx->u32PointLen);
1581         ctx->pastSrcPoint = (POINT_S *)malloc(sizeof(POINT_S) * ctx->u32PointLen);
1582     }
1583 
1584     s32Ret = RK_MPI_SYS_Init();
1585     if (s32Ret != RK_SUCCESS) {
1586         goto __FAILED;
1587     }
1588     test_mpi_gdc_api(ctx);
1589     s32Ret = RK_MPI_SYS_Exit();
1590     if (s32Ret != RK_SUCCESS) {
1591         goto __FAILED;
1592     }
1593     RK_LOGD("gdc test done!");
1594 
1595 __FAILED:
1596     if (ctx->pastDstPoint)
1597         free(ctx->pastDstPoint);
1598     if (ctx->pastSrcPoint)
1599         free(ctx->pastSrcPoint);
1600     if (ctx)
1601         free(ctx);
1602 
1603     return 0;
1604 }
1605