• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21 #include <sys/ioctl.h>
22 #include <poll.h>
23 #include <sys/time.h>
24 #include <fcntl.h>
25 #include <errno.h>
26 #include <pthread.h>
27 #include <math.h>
28 #include <unistd.h>
29 #include <signal.h>
30 #include <sys/mman.h>
31 #include "sample_comm.h"
32 
33 #ifdef __cplusplus
34 #if __cplusplus
35 extern "C" {
36 #endif
37 #endif /* End of #ifdef __cplusplus */
38 
39 static HI_S32 s_s32SampleMemDev = -1;
40 #define SAMPLE_MEM_DEV_OPEN                                    \
41     if (s_s32SampleMemDev <= 0) {                              \
42         s_s32SampleMemDev = open("/dev/mem", O_RDWR | O_SYNC); \
43         if (s_s32SampleMemDev < 0) {                           \
44             perror("Open dev/mem error");                      \
45             return NULL;                                       \
46         }                                                      \
47     }
48 
SAMPLE_SYS_SIGNAL(void (* func)(int))49 HI_VOID SAMPLE_SYS_SIGNAL(void (*func)(int))
50 {
51 #if (!defined(__HuaweiLite__)) || defined(__OHOS__)
52     struct sigaction sa = { 0 };
53 
54     sa.sa_handler = func;
55     sa.sa_flags = 0;
56     sigaction(SIGINT, &sa, HI_NULL);
57     sigaction(SIGTERM, &sa, HI_NULL);
58 #endif
59 }
60 
SAMPLE_SYS_IOMmap(HI_U64 u64PhyAddr,HI_U32 u32Size)61 HI_VOID *SAMPLE_SYS_IOMmap(HI_U64 u64PhyAddr, HI_U32 u32Size)
62 {
63     HI_U32 u32Diff;
64     HI_U64 u64PagePhy;
65     HI_U8 *pPageAddr = HI_NULL;
66     HI_U32 u32PageSize;
67 
68     SAMPLE_MEM_DEV_OPEN;
69 
70     if (u32Size == 0) {
71         printf("Func: %s u32Size can't be 0.\n", __FUNCTION__);
72         return NULL;
73     }
74 
75     /* The mmap address should align with page */
76     u64PagePhy = u64PhyAddr & 0xfffffffffffff000ULL;
77     u32Diff = u64PhyAddr - u64PagePhy;
78 
79     /* The mmap size should be multiples of 1024 */
80     u32PageSize = ((u32Size + u32Diff - 1) & 0xfffff000UL) + 0x1000;
81 
82     pPageAddr = mmap((void *)0, u32PageSize, PROT_READ | PROT_WRITE, MAP_SHARED, s_s32SampleMemDev, u64PagePhy);
83     if (MAP_FAILED == pPageAddr) {
84         perror("mmap error");
85         return NULL;
86     }
87     return (HI_VOID *)(pPageAddr + u32Diff);
88 }
89 
SAMPLE_SYS_Munmap(HI_VOID * pVirAddr,HI_U32 u32Size)90 HI_S32 SAMPLE_SYS_Munmap(HI_VOID *pVirAddr, HI_U32 u32Size)
91 {
92     HI_U64 u64PageAddr;
93     HI_U32 u32PageSize;
94     HI_U32 u32Diff;
95 
96     u64PageAddr = (((HI_U64)(HI_UINTPTR_T)pVirAddr) & 0xfffffffffffff000ULL);
97     u32Diff = (HI_U32)(HI_UINTPTR_T)pVirAddr - u64PageAddr;
98     u32PageSize = ((u32Size + u32Diff - 1) & 0xfffff000UL) + 0x1000;
99 
100     return munmap((HI_VOID *)(HI_UINTPTR_T)u64PageAddr, u32PageSize);
101 }
102 
103 
SAMPLE_SYS_SetReg(HI_U64 u64Addr,HI_U32 u32Value)104 HI_S32 SAMPLE_SYS_SetReg(HI_U64 u64Addr, HI_U32 u32Value)
105 {
106     HI_U32 *pu32RegAddr = NULL;
107     HI_U32 u32MapLen = sizeof(u32Value);
108 
109     pu32RegAddr = (HI_U32 *)SAMPLE_SYS_IOMmap(u64Addr, u32MapLen);
110     if (pu32RegAddr == NULL) {
111         return HI_FAILURE;
112     }
113 
114     *pu32RegAddr = u32Value;
115 
116     return SAMPLE_SYS_Munmap(pu32RegAddr, u32MapLen);
117 }
118 
SAMPLE_SYS_GetReg(HI_U64 u64Addr,HI_U32 * pu32Value)119 HI_S32 SAMPLE_SYS_GetReg(HI_U64 u64Addr, HI_U32 *pu32Value)
120 {
121     HI_U32 *pu32RegAddr = NULL;
122     HI_U32 u32MapLen;
123 
124     if (pu32Value == NULL) {
125         return HI_ERR_SYS_NULL_PTR;
126     }
127 
128     u32MapLen = sizeof(*pu32Value);
129     pu32RegAddr = (HI_U32 *)SAMPLE_SYS_IOMmap(u64Addr, u32MapLen);
130     if (pu32RegAddr == NULL) {
131         return HI_FAILURE;
132     }
133 
134     *pu32Value = *pu32RegAddr;
135 
136     return SAMPLE_SYS_Munmap(pu32RegAddr, u32MapLen);
137 }
138 
SAMPLE_COMM_SYS_GetPicSize(PIC_SIZE_E enPicSize,SIZE_S * pstSize)139 HI_S32 SAMPLE_COMM_SYS_GetPicSize(PIC_SIZE_E enPicSize, SIZE_S *pstSize)
140 {
141     if (pstSize == NULL) {
142         SAMPLE_PRT("null pointer\n");
143         return HI_FAILURE;
144     }
145     switch (enPicSize) {
146         case PIC_D1_MIPI:
147             pstSize->u32Width  = 800; /* PIC_D1_MIPI width is 800 */
148             pstSize->u32Height = 480; /* PIC_D1_MIPI width is 480 */
149             break;
150 
151         case PIC_CIF:
152             pstSize->u32Width  = 352; /* PIC_CIF width is 352 */
153             pstSize->u32Height = 288; /* PIC_CIF height is 288 */
154             break;
155 
156         case PIC_360P:
157             pstSize->u32Width  = 640; /* PIC_360P width is 640 */
158             pstSize->u32Height = 360; /* PIC_360P height is 360 */
159             break;
160 
161         case PIC_D1_PAL:
162             pstSize->u32Width  = 720; /* PIC_D1_PAL width is 720 */
163             pstSize->u32Height = 576; /* PIC_D1_PAL height is 576 */
164             break;
165 
166         case PIC_720P:
167             pstSize->u32Width  = 1280; /* PIC_720P width is 1280 */
168             pstSize->u32Height = 720; /* PIC_720P height is 720 */
169             break;
170 
171         case PIC_1080P:
172             pstSize->u32Width = IMG_2M_WIDTH;
173             pstSize->u32Height = IMG_2M_HEIGHT;
174             break;
175 
176         case PIC_2592x1944:
177             pstSize->u32Width = IMG_5M_WIDTH;
178             pstSize->u32Height = IMG_5M_HEIGHT;
179             break;
180 
181         case PIC_2592x1536:
182             pstSize->u32Width = IMG_4M_WIDTH;
183             pstSize->u32Height = IMG_4M_HEIGHT;
184             break;
185 
186         default:
187             pstSize->u32Width = IMG_4M_WIDTH;
188             pstSize->u32Height = IMG_4M_HEIGHT;
189             break;
190     }
191 
192     return HI_SUCCESS;
193 }
194 
SAMPLE_COMM_SYS_MemConfig(HI_VOID)195 HI_S32 SAMPLE_COMM_SYS_MemConfig(HI_VOID)
196 {
197     HI_S32 i, j;
198     HI_S32 s32Ret = HI_SUCCESS;
199     HI_CHAR *pcMmzName = NULL;
200     MPP_CHN_S stMppChn;
201 
202     /* config memory for vi */
203     for (i = 0; i < VI_MAX_PIPE_NUM; i++) {
204         for (j = 0; j < VI_MAX_CHN_NUM; j++) {
205             stMppChn.enModId = HI_ID_VI;
206             stMppChn.s32DevId = i;
207             stMppChn.s32ChnId = j;
208             s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
209             if (s32Ret) {
210                 SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
211                 return HI_FAILURE;
212             }
213         }
214     }
215 
216     /* config memory for vpss */
217     for (i = 0; i < VPSS_MAX_GRP_NUM; i++) {
218         stMppChn.enModId = HI_ID_VPSS;
219         stMppChn.s32DevId = i;
220         stMppChn.s32ChnId = 0;
221         s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
222         if (s32Ret) {
223             SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
224             return HI_FAILURE;
225         }
226     }
227 
228     /* config memory for venc */
229     for (i = 0; i < VENC_MAX_CHN_NUM; i++) {
230         stMppChn.enModId = HI_ID_VENC;
231         stMppChn.s32DevId = 0;
232         stMppChn.s32ChnId = i;
233         s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
234         if (s32Ret) {
235             SAMPLE_PRT("HI_MPI_SYS_SetMemConf ERR !\n");
236             return HI_FAILURE;
237         }
238     }
239 
240     /* config memory for vo */
241     for (i = 0; i < VO_MAX_LAYER_NUM; i++) {
242         for (j = 0; j < VO_MAX_CHN_NUM; j++) {
243             stMppChn.enModId = HI_ID_VO;
244             stMppChn.s32DevId = i;
245             stMppChn.s32ChnId = j;
246             s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
247             if (s32Ret) {
248                 SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
249                 return HI_FAILURE;
250             }
251         }
252     }
253 
254     /* config memory for vdec */
255     for (i = 0; i < VDEC_MAX_CHN_NUM; i++) {
256         stMppChn.enModId = HI_ID_VDEC;
257         stMppChn.s32DevId = 0;
258         stMppChn.s32ChnId = i;
259         s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
260         if (s32Ret) {
261             SAMPLE_PRT("HI_MPI_SYS_SetMemConf ERR !\n");
262             return HI_FAILURE;
263         }
264     }
265 
266     return s32Ret;
267 }
268 
269 /* function : vb init & MPI system init */
SAMPLE_COMM_SYS_Init(VB_CONFIG_S * pstVbConfig)270 HI_S32 SAMPLE_COMM_SYS_Init(VB_CONFIG_S *pstVbConfig)
271 {
272     HI_S32 s32Ret = HI_FAILURE;
273 
274     HI_MPI_SYS_Exit();
275     HI_MPI_VB_Exit();
276 
277     if (pstVbConfig == NULL) {
278         SAMPLE_PRT("input parameter is null, it is invalid!\n");
279         return HI_FAILURE;
280     }
281 
282     s32Ret = HI_MPI_VB_SetConfig(pstVbConfig);
283     if (s32Ret != HI_SUCCESS) {
284         SAMPLE_PRT("HI_MPI_VB_SetConf failed!\n");
285         return HI_FAILURE;
286     }
287 
288     s32Ret = HI_MPI_VB_Init();
289     if (s32Ret != HI_SUCCESS) {
290         SAMPLE_PRT("HI_MPI_VB_Init failed!\n");
291         return HI_FAILURE;
292     }
293 
294     s32Ret = HI_MPI_SYS_Init();
295     if (s32Ret != HI_SUCCESS) {
296         SAMPLE_PRT("HI_MPI_SYS_Init failed!\n");
297         HI_MPI_VB_Exit();
298         return HI_FAILURE;
299     }
300 
301     return HI_SUCCESS;
302 }
303 
304 /* function : vb init with VbSupplement & MPI system init */
SAMPLE_COMM_SYS_InitWithVbSupplement(VB_CONFIG_S * pstVbConf,HI_U32 u32SupplementConfig)305 HI_S32 SAMPLE_COMM_SYS_InitWithVbSupplement(VB_CONFIG_S *pstVbConf, HI_U32 u32SupplementConfig)
306 {
307     VB_SUPPLEMENT_CONFIG_S stSupplementConf = { 0 };
308     HI_S32 s32Ret = HI_FAILURE;
309 
310     HI_MPI_SYS_Exit();
311     HI_MPI_VB_Exit();
312 
313     if (pstVbConf == NULL) {
314         SAMPLE_PRT("input parameter is null, it is invalid!\n");
315         return HI_FAILURE;
316     }
317 
318     s32Ret = HI_MPI_VB_SetConfig(pstVbConf);
319     if (s32Ret != HI_SUCCESS) {
320         SAMPLE_PRT("HI_MPI_VB_SetConf failed!\n");
321         return HI_FAILURE;
322     }
323 
324     stSupplementConf.u32SupplementConfig = u32SupplementConfig;
325 
326     s32Ret = HI_MPI_VB_SetSupplementConfig(&stSupplementConf);
327     if (s32Ret != HI_SUCCESS) {
328         SAMPLE_PRT("HI_MPI_VB_SetSupplementConf failed!\n");
329         return HI_FAILURE;
330     }
331 
332     s32Ret = HI_MPI_VB_Init();
333     if (s32Ret != HI_SUCCESS) {
334         SAMPLE_PRT("HI_MPI_VB_Init failed!\n");
335         return HI_FAILURE;
336     }
337 
338     s32Ret = HI_MPI_SYS_Init();
339     if (s32Ret != HI_SUCCESS) {
340         SAMPLE_PRT("HI_MPI_SYS_Init failed!\n");
341         HI_MPI_VB_Exit();
342         return HI_FAILURE;
343     }
344 
345     return HI_SUCCESS;
346 }
347 
348 /* function : vb exit & MPI system exit */
SAMPLE_COMM_SYS_Exit(void)349 HI_VOID SAMPLE_COMM_SYS_Exit(void)
350 {
351     HI_MPI_SYS_Exit();
352     HI_MPI_VB_ExitModCommPool(VB_UID_VDEC);
353     HI_MPI_VB_Exit();
354     return;
355 }
356 
SAMPLE_COMM_VI_Bind_VO(VI_PIPE ViPipe,VI_CHN ViChn,VO_LAYER VoLayer,VO_CHN VoChn)357 HI_S32 SAMPLE_COMM_VI_Bind_VO(VI_PIPE ViPipe, VI_CHN ViChn, VO_LAYER VoLayer, VO_CHN VoChn)
358 {
359     MPP_CHN_S stSrcChn;
360     MPP_CHN_S stDestChn;
361 
362     stSrcChn.enModId = HI_ID_VI;
363     stSrcChn.s32DevId = ViPipe;
364     stSrcChn.s32ChnId = ViChn;
365 
366     stDestChn.enModId = HI_ID_VO;
367     stDestChn.s32DevId = VoLayer;
368     stDestChn.s32ChnId = VoChn;
369 
370     CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VO)");
371 
372     return HI_SUCCESS;
373 }
374 
SAMPLE_COMM_VI_UnBind_VO(VI_PIPE ViPipe,VI_CHN ViChn,VO_LAYER VoLayer,VO_CHN VoChn)375 HI_S32 SAMPLE_COMM_VI_UnBind_VO(VI_PIPE ViPipe, VI_CHN ViChn, VO_LAYER VoLayer, VO_CHN VoChn)
376 {
377     MPP_CHN_S stSrcChn;
378     MPP_CHN_S stDestChn;
379 
380     stSrcChn.enModId = HI_ID_VI;
381     stSrcChn.s32DevId = ViPipe;
382     stSrcChn.s32ChnId = ViChn;
383 
384     stDestChn.enModId = HI_ID_VO;
385     stDestChn.s32DevId = VoLayer;
386     stDestChn.s32ChnId = VoChn;
387 
388     CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VO)");
389 
390     return HI_SUCCESS;
391 }
392 
SAMPLE_COMM_VI_Bind_VPSS(VI_PIPE ViPipe,VI_CHN ViChn,VPSS_GRP VpssGrp)393 HI_S32 SAMPLE_COMM_VI_Bind_VPSS(VI_PIPE ViPipe, VI_CHN ViChn, VPSS_GRP VpssGrp)
394 {
395     MPP_CHN_S stSrcChn;
396     MPP_CHN_S stDestChn;
397 
398     stSrcChn.enModId = HI_ID_VI;
399     stSrcChn.s32DevId = ViPipe;
400     stSrcChn.s32ChnId = ViChn;
401 
402     stDestChn.enModId = HI_ID_VPSS;
403     stDestChn.s32DevId = VpssGrp;
404     stDestChn.s32ChnId = 0;
405 
406     CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VPSS)");
407 
408     return HI_SUCCESS;
409 }
410 
SAMPLE_COMM_VI_UnBind_VPSS(VI_PIPE ViPipe,VI_CHN ViChn,VPSS_GRP VpssGrp)411 HI_S32 SAMPLE_COMM_VI_UnBind_VPSS(VI_PIPE ViPipe, VI_CHN ViChn, VPSS_GRP VpssGrp)
412 {
413     MPP_CHN_S stSrcChn;
414     MPP_CHN_S stDestChn;
415 
416     stSrcChn.enModId = HI_ID_VI;
417     stSrcChn.s32DevId = ViPipe;
418     stSrcChn.s32ChnId = ViChn;
419 
420     stDestChn.enModId = HI_ID_VPSS;
421     stDestChn.s32DevId = VpssGrp;
422     stDestChn.s32ChnId = 0;
423 
424     CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VPSS)");
425 
426     return HI_SUCCESS;
427 }
428 
SAMPLE_COMM_VI_Bind_VENC(VI_PIPE ViPipe,VI_CHN ViChn,VENC_CHN VencChn)429 HI_S32 SAMPLE_COMM_VI_Bind_VENC(VI_PIPE ViPipe, VI_CHN ViChn, VENC_CHN VencChn)
430 {
431     MPP_CHN_S stSrcChn;
432     MPP_CHN_S stDestChn;
433 
434     stSrcChn.enModId = HI_ID_VI;
435     stSrcChn.s32DevId = ViPipe;
436     stSrcChn.s32ChnId = ViChn;
437 
438     stDestChn.enModId = HI_ID_VENC;
439     stDestChn.s32DevId = 0;
440     stDestChn.s32ChnId = VencChn;
441 
442     CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VENC)");
443 
444     return HI_SUCCESS;
445 }
446 
SAMPLE_COMM_VI_UnBind_VENC(VI_PIPE ViPipe,VI_CHN ViChn,VENC_CHN VencChn)447 HI_S32 SAMPLE_COMM_VI_UnBind_VENC(VI_PIPE ViPipe, VI_CHN ViChn, VENC_CHN VencChn)
448 {
449     MPP_CHN_S stSrcChn;
450     MPP_CHN_S stDestChn;
451 
452     stSrcChn.enModId = HI_ID_VI;
453     stSrcChn.s32DevId = ViPipe;
454     stSrcChn.s32ChnId = ViChn;
455 
456     stDestChn.enModId = HI_ID_VENC;
457     stDestChn.s32DevId = 0;
458     stDestChn.s32ChnId = VencChn;
459 
460     CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VENC)");
461 
462     return HI_SUCCESS;
463 }
464 
SAMPLE_COMM_VPSS_Bind_VO(VPSS_GRP VpssGrp,VPSS_CHN VpssChn,VO_LAYER VoLayer,VO_CHN VoChn)465 HI_S32 SAMPLE_COMM_VPSS_Bind_VO(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VO_LAYER VoLayer, VO_CHN VoChn)
466 {
467     MPP_CHN_S stSrcChn;
468     MPP_CHN_S stDestChn;
469 
470     stSrcChn.enModId = HI_ID_VPSS;
471     stSrcChn.s32DevId = VpssGrp;
472     stSrcChn.s32ChnId = VpssChn;
473     stDestChn.enModId = HI_ID_VO;
474     stDestChn.s32DevId = VoLayer;
475     stDestChn.s32ChnId = VoChn;
476 
477     CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VPSS-VO)");
478 
479     return HI_SUCCESS;
480 }
481 
SAMPLE_COMM_VPSS_UnBind_VO(VPSS_GRP VpssGrp,VPSS_CHN VpssChn,VO_LAYER VoLayer,VO_CHN VoChn)482 HI_S32 SAMPLE_COMM_VPSS_UnBind_VO(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VO_LAYER VoLayer, VO_CHN VoChn)
483 {
484     MPP_CHN_S stSrcChn;
485     MPP_CHN_S stDestChn;
486 
487     stSrcChn.enModId = HI_ID_VPSS;
488     stSrcChn.s32DevId = VpssGrp;
489     stSrcChn.s32ChnId = VpssChn;
490     stDestChn.enModId = HI_ID_VO;
491     stDestChn.s32DevId = VoLayer;
492     stDestChn.s32ChnId = VoChn;
493 
494     CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VPSS-VO)");
495 
496     return HI_SUCCESS;
497 }
498 
SAMPLE_COMM_VPSS_Bind_VENC(VPSS_GRP VpssGrp,VPSS_CHN VpssChn,VENC_CHN VencChn)499 HI_S32 SAMPLE_COMM_VPSS_Bind_VENC(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VENC_CHN VencChn)
500 {
501     MPP_CHN_S stSrcChn;
502     MPP_CHN_S stDestChn;
503 
504     stSrcChn.enModId = HI_ID_VPSS;
505     stSrcChn.s32DevId = VpssGrp;
506     stSrcChn.s32ChnId = VpssChn;
507     stDestChn.enModId = HI_ID_VENC;
508     stDestChn.s32DevId = 0;
509     stDestChn.s32ChnId = VencChn;
510 
511     CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VPSS-VENC)");
512 
513     return HI_SUCCESS;
514 }
515 
SAMPLE_COMM_VPSS_UnBind_VENC(VPSS_GRP VpssGrp,VPSS_CHN VpssChn,VENC_CHN VencChn)516 HI_S32 SAMPLE_COMM_VPSS_UnBind_VENC(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VENC_CHN VencChn)
517 {
518     MPP_CHN_S stSrcChn;
519     MPP_CHN_S stDestChn;
520 
521     stSrcChn.enModId = HI_ID_VPSS;
522     stSrcChn.s32DevId = VpssGrp;
523     stSrcChn.s32ChnId = VpssChn;
524     stDestChn.enModId = HI_ID_VENC;
525     stDestChn.s32DevId = 0;
526     stDestChn.s32ChnId = VencChn;
527 
528     CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VPSS-VENC)");
529 
530     return HI_SUCCESS;
531 }
532 
SAMPLE_COMM_VDEC_Bind_VPSS(VDEC_CHN VdecChn,VPSS_GRP VpssGrp)533 HI_S32 SAMPLE_COMM_VDEC_Bind_VPSS(VDEC_CHN VdecChn, VPSS_GRP VpssGrp)
534 {
535     MPP_CHN_S stSrcChn;
536     MPP_CHN_S stDestChn;
537 
538     stSrcChn.enModId = HI_ID_VDEC;
539     stSrcChn.s32DevId = 0;
540     stSrcChn.s32ChnId = VdecChn;
541     stDestChn.enModId = HI_ID_VPSS;
542     stDestChn.s32DevId = VpssGrp;
543     stDestChn.s32ChnId = 0;
544 
545     CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VDEC-VPSS)");
546 
547     return HI_SUCCESS;
548 }
549 
SAMPLE_COMM_VDEC_UnBind_VPSS(VDEC_CHN VdecChn,VPSS_GRP VpssGrp)550 HI_S32 SAMPLE_COMM_VDEC_UnBind_VPSS(VDEC_CHN VdecChn, VPSS_GRP VpssGrp)
551 {
552     MPP_CHN_S stSrcChn;
553     MPP_CHN_S stDestChn;
554 
555     stSrcChn.enModId = HI_ID_VDEC;
556     stSrcChn.s32DevId = 0;
557     stSrcChn.s32ChnId = VdecChn;
558     stDestChn.enModId = HI_ID_VPSS;
559     stDestChn.s32DevId = VpssGrp;
560     stDestChn.s32ChnId = 0;
561 
562     CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VDEC-VPSS)");
563 
564     return HI_SUCCESS;
565 }
SAMPLE_COMM_VO_Bind_VO(VO_LAYER SrcVoLayer,VO_CHN SrcVoChn,VO_LAYER DstVoLayer,VO_CHN DstVoChn)566 HI_S32 SAMPLE_COMM_VO_Bind_VO(VO_LAYER SrcVoLayer, VO_CHN SrcVoChn, VO_LAYER DstVoLayer, VO_CHN DstVoChn)
567 {
568     MPP_CHN_S stSrcChn, stDestChn;
569     stSrcChn.enModId = HI_ID_VO;
570     stSrcChn.s32DevId = SrcVoLayer;
571     stSrcChn.s32ChnId = SrcVoChn;
572     stDestChn.enModId = HI_ID_VO;
573     stDestChn.s32DevId = DstVoLayer;
574     stDestChn.s32ChnId = DstVoChn;
575 
576     return HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
577 }
578 
SAMPLE_COMM_VO_UnBind_VO(VO_LAYER DstVoLayer,VO_CHN DstVoChn)579 HI_S32 SAMPLE_COMM_VO_UnBind_VO(VO_LAYER DstVoLayer, VO_CHN DstVoChn)
580 {
581     MPP_CHN_S stDestChn;
582     stDestChn.enModId = HI_ID_VO;
583     stDestChn.s32DevId = DstVoLayer;
584     stDestChn.s32ChnId = DstVoChn;
585 
586     return HI_MPI_SYS_UnBind(NULL, &stDestChn);
587 }
588 
589 
590 #ifdef __cplusplus
591 #if __cplusplus
592 }
593 #endif
594 #endif /* End of #ifdef __cplusplus */
595