-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_comm_sys.c
804 lines (609 loc) · 21.1 KB
/
sample_comm_sys.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include <pthread.h>
#include <math.h>
#include <unistd.h>
#include <signal.h>
#include <sys/mman.h>
#include "sample_comm.h"
static HI_S32 s_s32SampleMemDev = -1;
#define SAMPLE_MEM_DEV_OPEN if (s_s32SampleMemDev <= 0)\
{\
s_s32SampleMemDev = open("/dev/mem", O_RDWR|O_SYNC);\
if (s_s32SampleMemDev < 0)\
{\
perror("Open dev/mem error");\
return NULL;\
}\
}\
HI_VOID * SAMPLE_SYS_IOMmap(HI_U64 u64PhyAddr, HI_U32 u32Size) {
HI_U32 u32Diff;
HI_U64 u64PagePhy;
HI_U8 * pPageAddr;
HI_UL ulPageSize;
SAMPLE_MEM_DEV_OPEN;
/**********************************************************
PageSize will be 0 when u32size is 0 and u32Diff is 0,
and then mmap will be error (error: Invalid argument)
***********************************************************/
if (!u32Size) {
printf("Func: %s u32Size can't be 0.\n", __FUNCTION__);
return NULL;
}
/* The mmap address should align with page */
u64PagePhy = u64PhyAddr & 0xfffffffffffff000ULL;
u32Diff = u64PhyAddr - u64PagePhy;
/* The mmap size shuld be mutliples of 1024 */
ulPageSize = ((u32Size + u32Diff - 1) & 0xfffff000UL) + 0x1000;
pPageAddr = mmap ((void *)0, ulPageSize, PROT_READ|PROT_WRITE,
MAP_SHARED, s_s32SampleMemDev, u64PagePhy);
if (MAP_FAILED == pPageAddr ) {
perror("mmap error");
return NULL;
}
return (HI_VOID *) (pPageAddr + u32Diff);
}
HI_S32 SAMPLE_SYS_Munmap(HI_VOID* pVirAddr, HI_U32 u32Size) {
HI_U64 u64PageAddr;
HI_U32 u32PageSize;
HI_U32 u32Diff;
u64PageAddr = (((HI_UL)pVirAddr) & 0xfffffffffffff000ULL);
u32Diff = (HI_UL)pVirAddr - u64PageAddr;
u32PageSize = ((u32Size + u32Diff - 1) & 0xfffff000UL) + 0x1000;
return munmap((HI_VOID*)(HI_UL)u64PageAddr, u32PageSize);
}
HI_S32 SAMPLE_SYS_SetReg(HI_U64 u64Addr, HI_U32 u32Value) {
HI_U32 *pu32RegAddr = NULL;
HI_U32 u32MapLen = sizeof(u32Value);
pu32RegAddr = (HI_U32 *)SAMPLE_SYS_IOMmap(u64Addr, u32MapLen);
if(NULL == pu32RegAddr) {
return HI_FAILURE;
}
*pu32RegAddr = u32Value;
return SAMPLE_SYS_Munmap(pu32RegAddr, u32MapLen);
}
HI_S32 SAMPLE_SYS_GetReg(HI_U64 u64Addr, HI_U32 *pu32Value) {
HI_U32 *pu32RegAddr = NULL;
HI_U32 u32MapLen;
if (NULL == pu32Value) {
return HI_ERR_SYS_NULL_PTR;
}
u32MapLen = sizeof(*pu32Value);
pu32RegAddr = (HI_U32 *)SAMPLE_SYS_IOMmap(u64Addr, u32MapLen);
if(NULL == pu32RegAddr) {
return HI_FAILURE;
}
*pu32Value = *pu32RegAddr;
return SAMPLE_SYS_Munmap(pu32RegAddr, u32MapLen);
}
/******************************************************************************
* function : get picture size(w*h), according enPicSize
******************************************************************************/
HI_S32 SAMPLE_COMM_SYS_GetPicSize(PIC_SIZE_E enPicSize, SIZE_S* pstSize) {
switch (enPicSize) {
case PIC_CIF: /* 352 * 288 */
pstSize->u32Width = 352;
pstSize->u32Height = 288;
break;
case PIC_360P: /* 640 * 360 */
pstSize->u32Width = 640;
pstSize->u32Height = 360;
break;
case PIC_D1_PAL: /* 720 * 576 */
pstSize->u32Width = 720;
pstSize->u32Height = 576;
break;
case PIC_D1_NTSC: /* 720 * 480 */
pstSize->u32Width = 720;
pstSize->u32Height = 480;
break;
case PIC_720P: /* 1280 * 720 */
pstSize->u32Width = 1280;
pstSize->u32Height = 720;
break;
case PIC_1080P: /* 1920 * 1080 */
pstSize->u32Width = 1920;
pstSize->u32Height = 1080;
break;
case PIC_2592x1520:
pstSize->u32Width = 2592;
pstSize->u32Height = 1520;
break;
case PIC_2592x1944:
pstSize->u32Width = 2592;
pstSize->u32Height = 1944;
break;
case PIC_2592x1536:
pstSize->u32Width = 2592;
pstSize->u32Height = 1536;
break;
case PIC_2716x1524:
pstSize->u32Width = 2716;
pstSize->u32Height = 1524;
break;
case PIC_3840x2160:
pstSize->u32Width = 3840;
pstSize->u32Height = 2160;
break;
case PIC_3000x3000:
pstSize->u32Width = 3000;
pstSize->u32Height = 3000;
break;
case PIC_4000x3000:
pstSize->u32Width = 4000;
pstSize->u32Height = 3000;
break;
case PIC_4096x2160:
pstSize->u32Width = 4096;
pstSize->u32Height = 2160;
break;
case PIC_7680x4320:
pstSize->u32Width = 7680;
pstSize->u32Height = 4320;
break;
case PIC_3840x8640:
pstSize->u32Width = 3840;
pstSize->u32Height = 8640;
break;
case PIC_2688x1536:
pstSize->u32Width = 2688;
pstSize->u32Height = 1536;
break;
default:
return HI_FAILURE;
}
return HI_SUCCESS;
}
/******************************************************************************
* function : Set system memory location
******************************************************************************/
HI_S32 SAMPLE_COMM_SYS_MemConfig(HI_VOID) {
HI_S32 i, j;
HI_S32 s32Ret = HI_SUCCESS;
HI_CHAR* pcMmzName = NULL;
MPP_CHN_S stMppChn;
/*config memory for vi*/
for (i = 0; i < VI_MAX_PIPE_NUM; i++) {
for (j = 0; j < VI_MAX_CHN_NUM; j++) {
stMppChn.enModId = HI_ID_VI;
stMppChn.s32DevId = i;
stMppChn.s32ChnId = j;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret) {
SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
return HI_FAILURE;
}
}
}
/*config memory for avs */
for (i = 0; i < AVS_MAX_GRP_NUM; i++) {
stMppChn.enModId = HI_ID_AVS;
stMppChn.s32DevId = i;
stMppChn.s32ChnId = 0;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret) {
SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
return HI_FAILURE;
}
}
/*config memory for vpss */
for (i = 0; i < VPSS_MAX_GRP_NUM; i++) {
stMppChn.enModId = HI_ID_VPSS;
stMppChn.s32DevId = i;
stMppChn.s32ChnId = 0;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret) {
SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
return HI_FAILURE;
}
}
/*config memory for venc */
for (i = 0; i < VENC_MAX_CHN_NUM; i++) {
stMppChn.enModId = HI_ID_VENC;
stMppChn.s32DevId = 0;
stMppChn.s32ChnId = i;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret) {
SAMPLE_PRT("HI_MPI_SYS_SetMemConf ERR !\n");
return HI_FAILURE;
}
}
/*config memory for vo*/
for (i = 0; i < VO_MAX_LAYER_NUM; i++) {
for (j = 0; j < VO_MAX_CHN_NUM; j++) {
stMppChn.enModId = HI_ID_VO;
stMppChn.s32DevId = i;
stMppChn.s32ChnId = j;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret) {
SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
return HI_FAILURE;
}
}
}
/*config memory for vdec */
for (i = 0; i < VDEC_MAX_CHN_NUM; i++) {
stMppChn.enModId = HI_ID_VDEC;
stMppChn.s32DevId = 0;
stMppChn.s32ChnId = i;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret) {
SAMPLE_PRT("HI_MPI_SYS_SetMemConf ERR !\n");
return HI_FAILURE;
}
}
return s32Ret;
}
/******************************************************************************
* function : vb init & MPI system init
******************************************************************************/
HI_S32 SAMPLE_COMM_SYS_Init(VB_CONFIG_S* pstVbConfig) {
HI_S32 s32Ret = HI_FAILURE;
HI_MPI_SYS_Exit();
HI_MPI_VB_Exit();
if (NULL == pstVbConfig) {
SAMPLE_PRT("input parameter is null, it is invaild!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_VB_SetConfig(pstVbConfig);
if (HI_SUCCESS != s32Ret) {
SAMPLE_PRT("HI_MPI_VB_SetConf failed!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_VB_Init();
if (HI_SUCCESS != s32Ret) {
SAMPLE_PRT("HI_MPI_VB_Init failed!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_SYS_Init();
if (HI_SUCCESS != s32Ret) {
SAMPLE_PRT("HI_MPI_SYS_Init failed!\n");
HI_MPI_VB_Exit();
return HI_FAILURE;
}
return HI_SUCCESS;
}
/******************************************************************************
* function : vb init with VbSupplement & MPI system init
******************************************************************************/
HI_S32 SAMPLE_COMM_SYS_InitWithVbSupplement(VB_CONFIG_S* pstVbConf, HI_U32 u32SupplementConfig) {
VB_SUPPLEMENT_CONFIG_S stSupplementConf = {0};
HI_S32 s32Ret = HI_FAILURE;
HI_MPI_SYS_Exit();
HI_MPI_VB_Exit();
if (NULL == pstVbConf) {
SAMPLE_PRT("input parameter is null, it is invaild!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_VB_SetConfig(pstVbConf);
if (HI_SUCCESS != s32Ret) {
SAMPLE_PRT("HI_MPI_VB_SetConf failed!\n");
return HI_FAILURE;
}
stSupplementConf.u32SupplementConfig = u32SupplementConfig;
s32Ret = HI_MPI_VB_SetSupplementConfig(&stSupplementConf);
if (HI_SUCCESS != s32Ret) {
SAMPLE_PRT("HI_MPI_VB_SetSupplementConf failed!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_VB_Init();
if (HI_SUCCESS != s32Ret) {
SAMPLE_PRT("HI_MPI_VB_Init failed!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_SYS_Init();
if (HI_SUCCESS != s32Ret) {
SAMPLE_PRT("HI_MPI_SYS_Init failed!\n");
return HI_FAILURE;
}
return HI_SUCCESS;
}
/******************************************************************************
* function : vb exit & MPI system exit
******************************************************************************/
HI_VOID SAMPLE_COMM_SYS_Exit(void) {
SAMPLE_COMM_VO_Exit();
HI_MPI_SYS_Exit();
HI_MPI_VB_ExitModCommPool(VB_UID_VDEC);
HI_MPI_VB_Exit();
return;
}
HI_S32 SAMPLE_COMM_VI_Bind_VO(VI_PIPE ViPipe, VI_CHN ViChn, VO_LAYER VoLayer, VO_CHN VoChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_UnBind_VO(VI_PIPE ViPipe, VI_CHN ViChn, VO_LAYER VoLayer, VO_CHN VoChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_Bind_VPSS(VI_PIPE ViPipe, VI_CHN ViChn, VPSS_GRP VpssGrp) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_UnBind_VPSS(VI_PIPE ViPipe, VI_CHN ViChn, VPSS_GRP VpssGrp) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_Bind_VENC(VI_PIPE ViPipe, VI_CHN ViChn, VENC_CHN VencChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_UnBind_VENC(VI_PIPE ViPipe, VI_CHN ViChn, VENC_CHN VencChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_Bind_AVS(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, AVS_GRP AvsGrp, AVS_PIPE AvsPipe) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_AVS;
stDestChn.s32DevId = AvsGrp;
stDestChn.s32ChnId = AvsPipe;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VPSS-AVS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_UnBind_AVS(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, AVS_GRP AvsGrp, AVS_PIPE AvsPipe) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_AVS;
stDestChn.s32DevId = AvsGrp;
stDestChn.s32ChnId = AvsPipe;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VPSS-AVS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_Bind_VO(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VO_LAYER VoLayer, VO_CHN VoChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VPSS-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_UnBind_VO(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VO_LAYER VoLayer, VO_CHN VoChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VPSS-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_Bind_VENC(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VENC_CHN VencChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VPSS-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_UnBind_VENC(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VENC_CHN VencChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VPSS-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_Bind_AVS(AVS_GRP AvsSrcGrp, AVS_CHN AvsSrcChn, AVS_GRP AvsDestGrp, AVS_CHN AvsDestChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsSrcGrp;
stSrcChn.s32ChnId = AvsSrcChn;
stDestChn.enModId = HI_ID_AVS;
stDestChn.s32DevId = AvsDestGrp;
stDestChn.s32ChnId = AvsDestChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(AVS-AVS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_UnBind_AVS(AVS_GRP AvsSrcGrp, AVS_CHN AvsSrcChn, AVS_GRP AvsDestGrp, AVS_CHN AvsDestChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsSrcGrp;
stSrcChn.s32ChnId = AvsSrcChn;
stDestChn.enModId = HI_ID_AVS;
stDestChn.s32DevId = AvsDestGrp;
stDestChn.s32ChnId = AvsDestChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(AVS-AVS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_Bind_VPSS(AVS_GRP AvsGrp, AVS_CHN AvsChn, VPSS_GRP VpssGrp) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(AVS-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_UnBind_VPSS(AVS_GRP AvsGrp, AVS_CHN AvsChn, VPSS_GRP VpssGrp) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(AVS-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_Bind_VENC(AVS_GRP AvsGrp, AVS_CHN AvsChn, VENC_CHN VencChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(AVS-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_UnBind_VENC(AVS_GRP AvsGrp, AVS_CHN AvsChn, VENC_CHN VencChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(AVS-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_Bind_VO(AVS_GRP AvsGrp, AVS_CHN AvsChn, VO_LAYER VoLayer, VO_CHN VoChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(AVS-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_UnBind_VO(AVS_GRP AvsGrp, AVS_CHN AvsChn, VO_LAYER VoLayer, VO_CHN VoChn) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(AVS-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VDEC_Bind_VPSS(VDEC_CHN VdecChn, VPSS_GRP VpssGrp) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VDEC;
stSrcChn.s32DevId = 0;
stSrcChn.s32ChnId = VdecChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VDEC-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VDEC_UnBind_VPSS(VDEC_CHN VdecChn, VPSS_GRP VpssGrp) {
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VDEC;
stSrcChn.s32DevId = 0;
stSrcChn.s32ChnId = VdecChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VDEC-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VO_Bind_VO(VO_LAYER SrcVoLayer, VO_CHN SrcVoChn, VO_LAYER DstVoLayer, VO_CHN DstVoChn) {
MPP_CHN_S stSrcChn, stDestChn;
stSrcChn.enModId = HI_ID_VO;
stSrcChn.s32DevId = SrcVoLayer;
stSrcChn.s32ChnId = SrcVoChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = DstVoLayer;
stDestChn.s32ChnId = DstVoChn;
return HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
}
HI_S32 SAMPLE_COMM_VO_UnBind_VO(VO_LAYER DstVoLayer, VO_CHN DstVoChn) {
MPP_CHN_S stDestChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = DstVoLayer;
stDestChn.s32ChnId = DstVoChn;
return HI_MPI_SYS_UnBind(NULL, &stDestChn);
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */