static void video_DisplayD1(int nVoDev, int nChn, unsigned char bDisplay) { static int s_nDispViDev = -1; static int s_nDispViChn = -1; VI_CHN_ATTR_S stViChnAttr; if(bDisplay){ int i = 0; for(i = 0; i < MAX_CAM_CH; ++i){ DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, i)); } } if(bDisplay){ static int s_nLastFull = -1; // prevent to bind twice if(-1 == s_nLastFull || nChn != s_nLastFull){ int fd = open(VIDEO_DEV, O_RDWR); VIDEO_TRACE("%s fd = %d", __func__, fd); if(fd > 0){ // set ad configuration video_preview_t stPreview = {0}; stPreview.chn = nChn; // switch to this channel @ ad ioctl(fd, VIDEO_DRV_SET_LIVE_CHN, &stPreview); close(fd); fd = -1; } } // unbind last full channel first if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){ DVR_ASSERT(HI_MPI_VI_UnBindOutput(s_nDispViDev, s_nDispViChn, nVoDev, MAX_CAM_CH)); } // bind to d1 special live connect s_nDispViDev = 2; s_nDispViChn = 0; DVR_ASSERT(HI_MPI_VO_ClearChnBuffer(nVoDev, MAX_CAM_CH, HI_TRUE)); if(s_stVideo.nLossStat & (1<<nChn)){ DVR_ASSERT(HI_MPI_VO_SENDFRAME(nVoDev, MAX_CAM_CH, VIDEO_GetUserPic(nChn))); }else{ DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); VI_D1_ATTR_CONF(&stViChnAttr); DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_BindOutput(s_nDispViDev, s_nDispViChn, nVoDev, MAX_CAM_CH)); } usleep(40000); DVR_ASSERT(HI_MPI_VO_ChnShow(nVoDev, MAX_CAM_CH)); video_CheckDigitalZoomD1(nChn); }else{ if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){ DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, MAX_CAM_CH)); // printf("unbind output (%d,%d) to (%d,%d)", s_nDispViDev, s_nDispViChn, nVoDev, MAX_CAM_CH); DVR_ASSERT(HI_MPI_VI_UnBindOutput(s_nDispViDev, s_nDispViChn, nVoDev, MAX_CAM_CH)); DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); VI_CIF_ATTR_CONF(&stViChnAttr); DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); s_nDispViDev = -1; s_nDispViChn = -1; } } }
static void video_InputInit() { // int i = 0; // init sdk { VI_PUB_ATTR_S stViDevAttr; VI_CHN_ATTR_S stViChnAttr; // vi0 1-16 ch cif input 1d1 // vi2 1-16 ch d1 input mutex d1 live //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // vi0 stViDevAttr.enInputMode = VI_MODE_BT656; stViDevAttr.enWorkMode = VI_WORK_MODE_1D1; stViDevAttr.enViNorm = (VIDEO_IS_PAL() ? VIDEO_ENCODING_MODE_PAL : VIDEO_ENCODING_MODE_NTSC); // channel attribute stViChnAttr.stCapRect.s32X = 0; stViChnAttr.stCapRect.s32Y = 0; stViChnAttr.stCapRect.u32Width = VI_CIF_WIDTH; stViChnAttr.stCapRect.u32Height = 8 * VI_CIF_HEIGHT + 7 * 2; // half field height combo frame stViChnAttr.bChromaResample = HI_FALSE; stViChnAttr.enCapSel = VI_CAPSEL_BOTH; stViChnAttr.bDownScale = HI_FALSE; stViChnAttr.bHighPri = HI_FALSE; stViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; DVR_ASSERT(HI_MPI_VI_Disable(0)); DVR_ASSERT(HI_MPI_VI_SetPubAttr(0, &stViDevAttr)); DVR_ASSERT(HI_MPI_VI_Enable(0)); DVR_ASSERT(HI_MPI_VI_SetChnAttr(0, 0, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_EnableChn(0, 0)); DVR_ASSERT(HI_MPI_VI_SetSrcFrameRate(0, 0, MAX_CIF_LIVE_FPS)); DVR_ASSERT(HI_MPI_VI_SetFrameRate(0, 0, MAX_CIF_LIVE_FPS)); //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // vi2 must be d1 stViChnAttr.enCapSel = VI_CAPSEL_BOTH; stViChnAttr.bDownScale = HI_FALSE; stViChnAttr.stCapRect.s32Y = 0; stViChnAttr.stCapRect.u32Height = VIDEO_IS_PAL() ? 288 : 240; stViChnAttr.bChromaResample = HI_FALSE; stViChnAttr.bHighPri = HI_FALSE; VI_CIF_ATTR_CONF(&stViChnAttr); // vi2 DVR_ASSERT(HI_MPI_VI_Disable(2)); DVR_ASSERT(HI_MPI_VI_SetPubAttr(2, &stViDevAttr)); DVR_ASSERT(HI_MPI_VI_Enable(2)); DVR_ASSERT(HI_MPI_VI_SetChnAttr(2, 0, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_EnableChn(2, 0)); DVR_ASSERT(HI_MPI_VI_SetSrcFrameRate(2, 0, MAX_D1_LIVE_FPS)); DVR_ASSERT(HI_MPI_VI_SetFrameRate(2, 0, MAX_D1_LIVE_FPS)); } }
HI_S32 SampleEnableVi(VI_DEV ViDev,VI_CHN ViChn, VI_PUB_ATTR_S *pViPubAttr,VI_CHN_ATTR_S *pViChnAttr) { HI_S32 s32Ret; s32Ret = HI_MPI_VI_SetPubAttr(ViDev, pViPubAttr); if (HI_SUCCESS != s32Ret) { printf("set VI attribute failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VI_SetChnAttr(ViDev, ViChn, pViChnAttr); if (HI_SUCCESS != s32Ret) { printf("set VI Chn attribute failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VI_Enable(ViDev); if (HI_SUCCESS != s32Ret) { printf("set VI enable failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VI_EnableChn(ViDev, ViChn); if (HI_SUCCESS != s32Ret) { printf("set VI Chn enable failed 0x%x!\n",s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
HI_S32 PCIV_Slave_StartVi(PCIV_MSGHEAD_S *pMsg) { HI_S32 s32Ret; VI_DEV viDev; VI_CHN viChn; PCIV_VICMD_CREATE_S *pCmd = (PCIV_VICMD_CREATE_S *)pMsg->cMsgBody; PCIV_VICMD_ECHO_S *pCmdEcho = (PCIV_VICMD_ECHO_S *)pMsg->cMsgBody; /* Start the VI first */ viDev = pCmd->viDev; viChn = pCmd->viChn; s32Ret = HI_MPI_VI_SetChnAttr(viDev, viChn, &pCmd->stAttr); HI_ASSERT((HI_SUCCESS == s32Ret)); s32Ret = HI_MPI_VI_EnableChn(viDev, viChn); HI_ASSERT((HI_SUCCESS == s32Ret)); /* Echo the cmd */ pMsg->enMsgType = PCIV_MSGTYPE_CMDECHO; pMsg->enDevType = PCIV_DEVTYPE_VICHN; pMsg->u32Target = 0; pMsg->u32MsgLen = sizeof(PCIV_VICMD_ECHO_S); pCmdEcho->viDev = viDev; pCmdEcho->viChn = viChn; pCmdEcho->s32Echo = HI_SUCCESS; s32Ret = PCIV_SendMsg(0, PCIV_MSGPORT_USERCMD, pMsg); HI_ASSERT((HI_FAILURE != s32Ret)); return HI_SUCCESS; }
/***************************************************************************** * function : star vi chn *****************************************************************************/ static HI_S32 s32ViStartChn(VI_CHN ViChn, VI_ATTR_S * pstViAttr) { HI_S32 s32Ret; VI_CHN_ATTR_S * pstChnAttr; if (NULL == pstViAttr) { printf("Func %s() Line[%d], parament is null\n", __FUNCTION__, __LINE__); return HI_FAILURE; } pstChnAttr = pstViAttr->pstChnAttr; s32Ret = HI_MPI_VI_SetChnAttr(ViChn, pstChnAttr); if (s32Ret != HI_SUCCESS) { printf("failed with %#x!\n", s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VI_EnableChn(ViChn); if (s32Ret != HI_SUCCESS) { printf("failed with %#x!\n", s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
static void video_DisplayD1(int nVoDev, int nChn, unsigned char bDisplay) { static int s_nDispViDev = -1; static int s_nDispViChn = -1; static int s_nDispVoChn = -1; VI_CHN_ATTR_S stViChnAttr; // input reset // dont try to change input the original setting of d1 channel if(bDisplay){ if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){ if(s_nDispVoChn >= MAX_D1_CNT){ DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); VI_CIF_ATTR_CONF(&stViChnAttr); DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); } DVR_ASSERT(HI_MPI_VO_SetChnField(nVoDev, nChn, VO_FIELD_BOTTOM)); } if(nChn >= MAX_D1_CNT){ if(0 == VIMAP_Get(nChn, &s_nDispViDev, &s_nDispViChn)){ DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); VI_D1_ATTR_CONF(&stViChnAttr); DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); s_nDispVoChn = nChn; } } DVR_ASSERT(HI_MPI_VO_SetChnField(nVoDev, nChn, VO_FIELD_BOTH)); }else{ if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){ if(nChn >= MAX_D1_CNT){ // reset field setting DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); VI_CIF_ATTR_CONF(&stViChnAttr); DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); s_nDispViDev = -1; s_nDispViChn = -1; } s_nDispVoChn = -1; } DVR_ASSERT(HI_MPI_VO_SetChnField(nVoDev, nChn, VO_FIELD_BOTTOM)); } }
HI_S32 SAMPLE_COMM_VI_ChangeMixCap(VI_CHN ViChn,HI_BOOL bMixCap,HI_U32 FrameRate) { VI_CHN_ATTR_S stChnAttr,stChnMinorAttr; HI_S32 S32Ret = HI_SUCCESS; S32Ret = HI_MPI_VI_GetChnAttr(ViChn, &stChnAttr); if(HI_SUCCESS!= S32Ret) { SAMPLE_PRT( "HI_MPI_VI_GetChnAttr failed"); } if(HI_TRUE == bMixCap) { memcpy(&stChnMinorAttr, &stChnAttr, sizeof(VI_CHN_ATTR_S)); stChnMinorAttr.stDestSize.u32Width = D1_WIDTH / 2; stChnAttr.s32FrameRate = FrameRate; S32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr); if (HI_SUCCESS != S32Ret) { SAMPLE_PRT("call HI_MPI_VI_SetChnAttr failed with %#x\n", S32Ret); return HI_FAILURE; } S32Ret = HI_MPI_VI_SetChnMinorAttr(ViChn, &stChnMinorAttr); if (HI_SUCCESS != S32Ret) { SAMPLE_PRT("call HI_MPI_VI_SetChnMinorAttr failed with %#x\n", S32Ret); return HI_FAILURE; } } else { stChnAttr.s32FrameRate = stChnAttr.s32SrcFrameRate; S32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr); if (HI_SUCCESS != S32Ret) { SAMPLE_PRT("call HI_MPI_VI_SetChnAttr failed with %#x\n", S32Ret); return HI_FAILURE; } } return HI_SUCCESS; }
HI_S32 SampleEnableVi4HD1(HI_VOID) { HI_U32 i,j; VI_PUB_ATTR_S ViAttr; VI_CHN_ATTR_S ViChnAttr; memset(&ViAttr,0,sizeof(VI_PUB_ATTR_S)); memset(&ViChnAttr,0,sizeof(VI_CHN_ATTR_S)); ViAttr.enInputMode = VI_MODE_BT656; ViAttr.enWorkMode = VI_WORK_MODE_2D1; ViChnAttr.bDownScale = HI_FALSE; ViChnAttr.bHighPri = 0; ViChnAttr.enCapSel = VI_CAPSEL_BOTTOM; ViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; ViChnAttr.stCapRect.s32X = 0; ViChnAttr.stCapRect.s32Y = 0; ViChnAttr.stCapRect.u32Width = 704; ViChnAttr.stCapRect.u32Height = 288; for(i=0;i<2;i++) { if (HI_SUCCESS!=HI_MPI_VI_SetPubAttr(i,&ViAttr)) { printf("HI_MPI_VI_SetPubAttr faild!\n"); return HI_FAILURE; } if (HI_SUCCESS!=HI_MPI_VI_Enable(i)) { printf("HI_MPI_VI_Enable faild!\n"); return HI_FAILURE; } for(j=0;j<2;j++) { if (HI_SUCCESS!=HI_MPI_VI_SetChnAttr(i,j,&ViChnAttr)) { printf("HI_MPI_VI_SetChnAttr faild!\n"); return HI_FAILURE; } if (HI_SUCCESS!=HI_MPI_VI_EnableChn(i,j)) { printf("HI_MPI_VI_EnableChn faild!\n"); return HI_FAILURE; } } } return HI_SUCCESS; }
static void video_InputInit() { int i = 0, ii = 0; // init sdk { int nDev = 0; int nChnCnt = 0; VI_PUB_ATTR_S stViDevAttr; VI_CHN_ATTR_S stViChnAttr; int const vi_fps = (VIDEO_IS_PAL() ? 25 : 30); // vi0 1-4 ch cif input 4d1 // vi2 5-8 ch d1 input 4d1 // device attributes stViDevAttr.enInputMode = VI_MODE_BT656; stViDevAttr.enWorkMode = VI_WORK_MODE_4D1; stViDevAttr.enViNorm = (VIDEO_IS_PAL() ? VIDEO_ENCODING_MODE_PAL : VIDEO_ENCODING_MODE_NTSC); // channel attributes stViChnAttr.stCapRect.s32Y = 0; stViChnAttr.stCapRect.u32Height = (VIDEO_IS_PAL() ? 288 : 240); stViChnAttr.bHighPri = HI_FALSE; stViChnAttr.bChromaResample = HI_FALSE; stViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; VI_CIF_ATTR_CONF(&stViChnAttr); for(ii = 0; ii < MAX_CAM_CH; ii += 4) { if(VIMAP_Get(ii, &nDev, NULL) < 0) { continue; } DVR_ASSERT(HI_MPI_VI_Disable(nDev)); DVR_ASSERT(HI_MPI_VI_SetPubAttr(nDev, &stViDevAttr)); DVR_ASSERT(HI_MPI_VI_Enable(nDev)); for(i = 0; i < 4; ++i) { if(nChnCnt++ < MAX_D1_CNT){ VI_D1_ATTR_CONF(&stViChnAttr); }else{ VI_CIF_ATTR_CONF(&stViChnAttr); } DVR_ASSERT(HI_MPI_VI_SetChnAttr(nDev, i, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_EnableChn(nDev, i)); DVR_ASSERT(HI_MPI_VI_SetSrcFrameRate(nDev, i, vi_fps)); DVR_ASSERT(HI_MPI_VI_SetFrameRate(nDev, i, vi_fps)); } } } }
/***************************************************************************** * function : star vi chn *****************************************************************************/ HI_S32 SAMPLE_COMM_VI_StartChn(VI_CHN ViChn, RECT_S *pstCapRect, SIZE_S *pstTarSize, SAMPLE_VI_MODE_E enViMode, SAMPLE_VI_CHN_SET_E enViChnSet) { HI_S32 s32Ret; VI_CHN_ATTR_S stChnAttr; /* step 5: config & start vicap dev */ memcpy(&stChnAttr.stCapRect, pstCapRect, sizeof(RECT_S)); if (SAMPLE_VI_MODE_16_Cif == enViMode) { stChnAttr.enCapSel = VI_CAPSEL_BOTTOM; } else { stChnAttr.enCapSel = VI_CAPSEL_BOTH; } /* to show scale. this is a sample only, we want to show dist_size = D1 only */ stChnAttr.stDestSize.u32Width = pstTarSize->u32Width; stChnAttr.stDestSize.u32Height = pstTarSize->u32Height; stChnAttr.enPixFormat = SAMPLE_PIXEL_FORMAT; /* sp420 or sp422 */ stChnAttr.bMirror = (VI_CHN_SET_MIRROR == enViChnSet)?HI_TRUE:HI_FALSE; stChnAttr.bFlip = (VI_CHN_SET_FILP == enViChnSet)?HI_TRUE:HI_FALSE; stChnAttr.bChromaResample = HI_FALSE; stChnAttr.s32SrcFrameRate = -1; stChnAttr.s32FrameRate = -1; s32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VI_EnableChn(ViChn); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
HI_S32 SAMPLE_COMM_VI_ChangeDestSize(VI_CHN ViChn, HI_U32 u32Width, HI_U32 u32Height) { VI_CHN_ATTR_S stChnAttr; HI_S32 S32Ret = HI_SUCCESS; S32Ret = HI_MPI_VI_GetChnAttr(ViChn, &stChnAttr); if(HI_SUCCESS!= S32Ret) { SAMPLE_PRT( "HI_MPI_VI_GetChnAttr failed\n"); } stChnAttr.stDestSize.u32Width = u32Width; stChnAttr.stDestSize.u32Height = u32Height; S32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr); if(HI_SUCCESS!= S32Ret) { SAMPLE_PRT( "HI_MPI_VI_SetChnAttr failed\n"); } return HI_SUCCESS; }
static void video_InputInit() { int ii, jj; VI_PUB_ATTR_S stViDevAttr; VI_CHN_ATTR_S stViChnAttr; // vi0 1-4 ch cif input 4d1 // vi1 5-8 ch cif input 4d1 // vi2 9-12 ch cif input 4d1 // vi3 13-16 ch cif input 4d1 //////////////////////////////////////////////////////////////// // vi stViDevAttr.enInputMode = VI_MODE_BT656; stViDevAttr.enWorkMode = VI_WORK_MODE_4D1; stViDevAttr.enViNorm = (VIDEO_IS_PAL() ? VIDEO_ENCODING_MODE_PAL : VIDEO_ENCODING_MODE_NTSC); // 4d1 input stViChnAttr.stCapRect.u32Width = 704; stViChnAttr.stCapRect.u32Height = VI_CIF_HEIGHT; stViChnAttr.stCapRect.s32X = VI_X_OFFSET; stViChnAttr.stCapRect.s32Y = 0; stViChnAttr.bChromaResample = HI_FALSE; stViChnAttr.enCapSel = VO_FIELD_BOTTOM; stViChnAttr.bDownScale = HI_TRUE; stViChnAttr.bHighPri = HI_FALSE; stViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; for(ii = 0; ii < 4; ii ++) { // interface DVR_ASSERT(HI_MPI_VI_Disable(ii)); DVR_ASSERT(HI_MPI_VI_SetPubAttr(ii, &stViDevAttr)); DVR_ASSERT(HI_MPI_VI_Enable(ii)); for(jj = 0; jj < 4; jj ++) { DVR_ASSERT(HI_MPI_VI_SetChnAttr(ii, jj, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_EnableChn(ii, jj)); DVR_ASSERT(HI_MPI_VI_SetSrcFrameRate(ii, jj, MAX_CIF_LIVE_FPS)); DVR_ASSERT(HI_MPI_VI_SetFrameRate(ii, jj, MAX_CIF_LIVE_FPS)); } } }
HI_S32 PCIV_Test_Slave_StartVi(VI_DEV viDev, VI_CHN viChn) { HI_S32 s32Ret; VI_PUB_ATTR_S ViAttr; VI_CHN_ATTR_S ViChnAttr; memset(&ViAttr,0,sizeof(VI_PUB_ATTR_S)); memset(&ViChnAttr,0,sizeof(VI_CHN_ATTR_S)); ViAttr.enInputMode = VI_MODE_BT656; ViAttr.enWorkMode = VI_WORK_MODE_2D1; ViAttr.u32AdType = AD_2815; ViAttr.enViNorm = VIDEO_ENCODING_MODE_PAL; ViChnAttr.stCapRect.u32Width = 704; ViChnAttr.stCapRect.u32Height = 288; ViChnAttr.stCapRect.s32X = 8; ViChnAttr.stCapRect.s32Y = 0; ViChnAttr.enCapSel = VI_CAPSEL_BOTTOM; ViChnAttr.bDownScale = HI_TRUE; ViChnAttr.bChromaResample = HI_FALSE; ViChnAttr.enViPixFormat = PCIV_TEST_VI_PIXEL_FORMAT; /* VI device may be enabled, so we don't care the result */ HI_MPI_VI_SetPubAttr(viDev, &ViAttr); HI_MPI_VI_Enable(viDev); s32Ret = HI_MPI_VI_SetChnAttr(viDev, viChn, &ViChnAttr); HI_ASSERT(HI_SUCCESS == s32Ret); s32Ret = HI_MPI_VI_EnableChn(viDev, viChn); HI_ASSERT(HI_SUCCESS == s32Ret); return 0; }
/***************************************************************************** * function : star vi according to product type * only for Hi3520D MixCap *****************************************************************************/ HI_S32 SAMPLE_COMM_VI_MixCap_Start(SAMPLE_VI_MODE_E enViMode, VIDEO_NORM_E enNorm) { VI_DEV ViDev; VI_CHN ViChn; HI_S32 i; HI_S32 s32Ret; SAMPLE_VI_PARAM_S stViParam; VI_CHN_ATTR_S stChnAttr,stChnMinorAttr; /*** get parameter from Sample_Vi_Mode ***/ s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam); if (HI_SUCCESS !=s32Ret) { SAMPLE_PRT("vi get param failed!\n"); return HI_FAILURE; } /*** Start AD ***/ s32Ret = SAMPLE_COMM_VI_ADStart(enViMode, enNorm); if (HI_SUCCESS !=s32Ret) { SAMPLE_PRT("Start AD failed!\n"); return HI_FAILURE; } /*** Start VI Dev ***/ for(i=0; i<stViParam.s32ViDevCnt; i++) { ViDev = i * stViParam.s32ViDevInterval; s32Ret = SAMPLE_COMM_VI_StartDev(ViDev, enViMode); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_VI_StartDev failed with %#x\n", s32Ret); return HI_FAILURE; } } /*** Start VI Chn ***/ for(i=0; i<stViParam.s32ViChnCnt; i++) { ViChn = i * stViParam.s32ViChnInterval; stChnAttr.stCapRect.s32X = 0; stChnAttr.stCapRect.s32Y = 0; stChnAttr.enCapSel = VI_CAPSEL_BOTH; stChnAttr.enPixFormat = SAMPLE_PIXEL_FORMAT; /* sp420 or sp422 */ stChnAttr.bMirror = HI_FALSE; stChnAttr.bFlip = HI_FALSE; stChnAttr.bChromaResample = HI_FALSE; stChnAttr.s32SrcFrameRate = -1; stChnAttr.s32FrameRate = -1; stChnAttr.stCapRect.u32Width= D1_WIDTH; stChnAttr.stCapRect.u32Height= (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480; stChnAttr.stDestSize.u32Width= D1_WIDTH; stChnAttr.stDestSize.u32Height= (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480; memcpy(&stChnMinorAttr, &stChnAttr, sizeof(VI_CHN_ATTR_S)); stChnMinorAttr.stDestSize.u32Width= D1_WIDTH / 2; stChnMinorAttr.stDestSize.u32Height= (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480; stChnAttr.s32SrcFrameRate = (VIDEO_ENCODING_MODE_PAL== enNorm)?25:30; stChnAttr.s32FrameRate = 6; s32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("call HI_MPI_VI_SetChnAttr failed with %#x\n", s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VI_SetChnMinorAttr(ViChn, &stChnMinorAttr); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("call HI_MPI_VI_SetChnMinorAttr failed with %#x\n", s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VI_EnableChn(ViChn); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("HI_MPI_VI_EnableChn failed with %#x!\n", s32Ret); return HI_FAILURE; } } return HI_SUCCESS; }
HI_S32 SampleInitViMScreen(HI_U32 ScreenCnt) { HI_U32 i,j,tmp; ScreenCnt = (ScreenCnt == 9 ? 8 : ScreenCnt); VI_PUB_ATTR_S ViAttr; VI_CHN_ATTR_S ViChnAttr[ScreenCnt]; memset(&ViAttr, 0, sizeof(VI_PUB_ATTR_S)); memset(ViChnAttr, 0, ScreenCnt * sizeof(VI_CHN_ATTR_S)); ViAttr.enInputMode = VI_MODE_BT656; ViAttr.enWorkMode = VI_WORK_MODE_2D1; switch (ScreenCnt) { case 1 : { ViChnAttr[0].bDownScale = HI_FALSE; ViChnAttr[0].bHighPri = 0; ViChnAttr[0].enCapSel = VI_CAPSEL_BOTH; ViChnAttr[0].enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; ViChnAttr[0].stCapRect.s32X = 0; ViChnAttr[0].stCapRect.s32Y = 0; ViChnAttr[0].stCapRect.u32Width = g_u32ScreenWidth; ViChnAttr[0].stCapRect.u32Height = g_u32ScreenHeight/2; break; } case 4 : /* fall through */ case 8 : { for (i = 0; i < ScreenCnt; i++) { ViChnAttr[i].bDownScale = HI_TRUE; ViChnAttr[i].bHighPri = 0; ViChnAttr[i].enCapSel = VI_CAPSEL_BOTTOM; ViChnAttr[i].enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; ViChnAttr[i].stCapRect.s32X = 0; ViChnAttr[i].stCapRect.s32Y = 0; ViChnAttr[i].stCapRect.u32Width = g_u32ScreenWidth; ViChnAttr[i].stCapRect.u32Height = g_u32ScreenHeight/2; } break; } default: printf("Unsupport screen num %d!\n", ScreenCnt); return HI_FAILURE; } if (1 == ScreenCnt) { tmp = 1; }else { tmp = ScreenCnt/2; } for (i = 0; i < tmp; i++) { if (HI_SUCCESS != HI_MPI_VI_SetPubAttr(i, &ViAttr)) { return HI_FAILURE; } if (HI_SUCCESS != HI_MPI_VI_Enable(i)) { return HI_FAILURE; } for(j = 0; j < 2; j++) { if (HI_SUCCESS != HI_MPI_VI_SetChnAttr(i,j,&ViChnAttr[i*2+j])) { return HI_FAILURE; } if (HI_SUCCESS != HI_MPI_VI_EnableChn(i,j)) { return HI_FAILURE; } } } return HI_SUCCESS; }
/***************************************************************************** * function : star vi chn *****************************************************************************/ HI_S32 SAMPLE_COMM_VI_StartChn(VI_CHN ViChn, RECT_S *pstCapRect, SIZE_S *pstTarSize, SAMPLE_VI_CONFIG_S* pstViConfig) { HI_S32 s32Ret; VI_CHN_ATTR_S stChnAttr; ROTATE_E enRotate = ROTATE_NONE; SAMPLE_VI_CHN_SET_E enViChnSet = VI_CHN_SET_NORMAL; if (pstViConfig) { enViChnSet = pstViConfig->enViChnSet; enRotate = pstViConfig->enRotate; } /* step 5: config & start vicap dev */ memcpy(&stChnAttr.stCapRect, pstCapRect, sizeof(RECT_S)); stChnAttr.enCapSel = VI_CAPSEL_BOTH; /* to show scale. this is a sample only, we want to show dist_size = D1 only */ stChnAttr.stDestSize.u32Width = pstTarSize->u32Width; stChnAttr.stDestSize.u32Height = pstTarSize->u32Height; stChnAttr.enPixFormat = SAMPLE_PIXEL_FORMAT; /* sp420 or sp422 */ stChnAttr.bMirror = HI_FALSE; stChnAttr.bFlip = HI_FALSE; switch (enViChnSet) { case VI_CHN_SET_MIRROR: stChnAttr.bMirror = HI_TRUE; break; case VI_CHN_SET_FLIP: stChnAttr.bFlip = HI_TRUE; break; case VI_CHN_SET_FLIP_MIRROR: stChnAttr.bMirror = HI_TRUE; stChnAttr.bFlip = HI_TRUE; break; default: break; } stChnAttr.bChromaResample = HI_FALSE; stChnAttr.s32SrcFrameRate = 30; stChnAttr.s32FrameRate = 30; s32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } if (ROTATE_NONE != enRotate) { s32Ret = HI_MPI_VI_SetRotate(ViChn, enRotate); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("HI_MPI_VI_SetRotate failed with %#x!\n", s32Ret); return HI_FAILURE; } } s32Ret = HI_MPI_VI_EnableChn(ViChn); if (s32Ret != HI_SUCCESS) { SAMPLE_PRT("failed with %#x!\n", s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
/****************************************************************************** * function : Start BT1120 720P vi/vo/venc ******************************************************************************/ HI_S32 SAMPLE_COMM_IVE_BT1120_720P_PreView(SAMPLE_IVE_VI_VO_CONFIG_S *pstViVoConfig, HI_BOOL bOpenVi,HI_BOOL bOpenViExt,HI_BOOL bOpenVo,HI_BOOL bOpenVenc,HI_BOOL bOpenVpss,HI_U32 u32VpssChnNum) { HI_U32 u32ViChnCnt = 1; VB_CONF_S stVbConf; VO_DEV VoDev = SAMPLE_VO_DEV_DSD0; VI_CHN ViChn = 0; VI_CHN ViExtChn = 1; VO_PUB_ATTR_S stVoPubAttr; SAMPLE_VO_MODE_E enVoMode = VO_MODE_1MUX; PIC_SIZE_E enPicSize = pstViVoConfig->enPicSize; VI_EXT_CHN_ATTR_S stExtChnAttr; HI_S32 s32Ret = HI_SUCCESS; HI_U32 u32BlkSize; SIZE_S stSize; VO_LAYER VoLayer = 0; VO_VIDEO_LAYER_ATTR_S stLayerAttr; SAMPLE_VI_CONFIG_S *pstViConfig = &(pstViVoConfig->stViConfig); VENC_CHN VencChn = 0; HI_U32 u32ViDepth = 4; VI_CHN_ATTR_S stChnAttr; HI_U32 u32VpssGrpCnt = 1; VPSS_CHN aVpssChn[2] = {VPSS_CHN0, VPSS_CHN3}; VPSS_GRP_ATTR_S stVpssGrpAttr; SIZE_S astSize[2]; memset(&stVbConf,0,sizeof(VB_CONF_S)); u32BlkSize = SAMPLE_COMM_SYS_CalcPicVbBlkSize(pstViVoConfig->enNorm, enPicSize, SAMPLE_PIXEL_FORMAT, SAMPLE_SYS_ALIGN_WIDTH); stVbConf.u32MaxPoolCnt = 64; /*ddr0 video buffer*/ stVbConf.astCommPool[0].u32BlkSize = u32BlkSize; stVbConf.astCommPool[0].u32BlkCnt = u32ViChnCnt * 3; if ((HI_TRUE == bOpenViExt) || (HI_TRUE == bOpenVpss)) { u32BlkSize = SAMPLE_COMM_SYS_CalcPicVbBlkSize(pstViVoConfig->enNorm,PIC_CIF, SAMPLE_PIXEL_FORMAT, SAMPLE_SYS_ALIGN_WIDTH); stVbConf.astCommPool[1].u32BlkSize = u32BlkSize; stVbConf.astCommPool[1].u32BlkCnt = 3; } // mpp system init. s32Ret = SAMPLE_COMM_SYS_Init(&stVbConf); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_SYS_Init fail,Error(%#x)\n", s32Ret); goto END_720P_0; } if (HI_TRUE == bOpenVi) { s32Ret = SAMPLE_COMM_VI_StartVi(pstViConfig); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_VI_StartVi fail,Error(%#x)\n",s32Ret); goto END_720P_0; } s32Ret = HI_MPI_VI_SetFrameDepth(ViChn,u32ViDepth); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VI_SetFrameDepth fail,ViChn(%d),Error(%#x)\n",ViChn,s32Ret); goto END_720P_1; } s32Ret = HI_MPI_VI_GetChnAttr(ViChn,&stChnAttr); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VI_GetChnAttr fail,ViChn(%d),Error(%#x)\n",ViChn,s32Ret); goto END_720P_1; } //Set Vi frame rate,because vi from BT1120 is 720P@30 stChnAttr.s32SrcFrameRate = 3; stChnAttr.s32DstFrameRate = 1; s32Ret = HI_MPI_VI_SetChnAttr(ViChn,&stChnAttr); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VI_SetChnAttr,ViChn(%d),Error(%#x)\n",ViChn,s32Ret); goto END_720P_1; } } //Open vi ext chn if (HI_TRUE == bOpenViExt) { stExtChnAttr.enPixFormat = SAMPLE_PIXEL_FORMAT; stExtChnAttr.s32BindChn = ViChn; stExtChnAttr.stDestSize.u32Width = 352; stExtChnAttr.stDestSize.u32Height = 288; stExtChnAttr.s32DstFrameRate = -1; stExtChnAttr.s32SrcFrameRate = -1; stExtChnAttr.enCompressMode = COMPRESS_MODE_NONE; s32Ret = HI_MPI_VI_SetExtChnAttr(ViExtChn, &stExtChnAttr); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VI_SetExtChnAttr fail,ViChn(%d),Error(%#x)\n",ViExtChn,s32Ret); goto END_720P_1; } s32Ret = HI_MPI_VI_EnableChn(ViExtChn); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VI_EnableChn fail,ViChn(%d),Error(%#x)\n",ViExtChn,s32Ret); goto END_720P_1; } s32Ret = HI_MPI_VI_SetFrameDepth(ViExtChn,u32ViDepth); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VI_SetFrameDepth fail,ViChn(%d),Error(%#x)\n",ViExtChn,s32Ret); goto END_720P_1; } } //Open vo if (HI_TRUE == bOpenVo) { s32Ret = SAMPLE_COMM_SYS_GetPicSize(pstViVoConfig->enNorm, enPicSize, &stSize); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_SYS_GetPicSize fail,Error(%#x)\n",s32Ret); goto END_720P_2; } stVoPubAttr.enIntfType = pstViVoConfig->enVoIntfType; //hi3518e Vo only suppurt pal //if(VO_INTF_BT1120 == pstViVoConfig->enVoIntfType) //{ // stVoPubAttr.enIntfSync = /*VO_OUTPUT_720P60*/VO_OUTPUT_1080P30; //} // if(SAMPLE_VI_MODE_BT1120_1080P == pstViVoConfig->stViConfig.enViMode) // { // stVoPubAttr.enIntfSync = VO_OUTPUT_1080P30; // } //else if(SAMPLE_VI_MODE_BT1120_720P == pstViVoConfig->stViConfig.enViMode) // { // stVoPubAttr.enIntfSync = VO_OUTPUT_720P60; // } // else { stVoPubAttr.enIntfSync = VO_OUTPUT_PAL; } stVoPubAttr.u32BgColor = 0x000000ff; /* In HD, this item should be set to HI_FALSE */ s32Ret = SAMPLE_COMM_VO_StartDev(VoDev, &stVoPubAttr); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_VO_StartDevLayer fail,VoDev(%d),Error(%#x)!\n",VoDev,s32Ret); goto END_720P_2; } stLayerAttr.bClusterMode = HI_FALSE; stLayerAttr.bDoubleFrame = HI_FALSE; stLayerAttr.enPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; memcpy(&stLayerAttr.stImageSize,&stSize,sizeof(stSize)); stLayerAttr.u32DispFrmRt = 60 ; stLayerAttr.stDispRect.s32X = 0; stLayerAttr.stDispRect.s32Y = 0; if((stVoPubAttr.enIntfSync == VO_OUTPUT_720P60) || (stVoPubAttr.enIntfSync == VO_OUTPUT_1080P30)) { stLayerAttr.stDispRect.u32Width = stSize.u32Width; stLayerAttr.stDispRect.u32Height = stSize.u32Height; } else if(stVoPubAttr.enIntfSync == VO_OUTPUT_PAL) { stLayerAttr.stDispRect.u32Width = 720; stLayerAttr.stDispRect.u32Height = 576; } s32Ret = SAMPLE_COMM_VO_StartLayer(VoLayer, &stLayerAttr, HI_TRUE); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_VO_StartLayer fail,VoLayer(%d),Error(%#x)\n",VoLayer,s32Ret); goto END_720P_3; } s32Ret = SAMPLE_COMM_VO_StartChn(VoDev, enVoMode); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_VO_StartChn fail,VoDev(%d),Error(%#x)\n",VoDev,s32Ret); goto END_720P_4; } } if (HI_TRUE == bOpenVenc) { s32Ret = SAMPLE_COMM_VENC_Start(VencChn, PT_H264, pstViVoConfig->enNorm, enPicSize, SAMPLE_RC_CBR,0); if(s32Ret != HI_SUCCESS) { SAMPLE_PRT("SAMPLE_COMM_VENC_Start fail,VencChn(%d),Error(%#x)\n",VencChn,s32Ret); goto END_720P_5; } s32Ret = SAMPLE_COMM_VENC_StartGetStream(1); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_VENC_StartGetStream fail,Error(%#x)\n",s32Ret); goto END_720P_6; } } if (HI_TRUE == bOpenVpss) { s32Ret = SAMPLE_COMM_SYS_GetPicSize(pstViVoConfig->enNorm, enPicSize, &astSize[0]); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_SYS_GetPicSize fail,Error(%#x)\n",s32Ret); goto END_720P_6; } astSize[1].u32Width = 352; astSize[1].u32Height = 288; SAMPLE_COMM_IVE_VpssGrpAttr(u32VpssGrpCnt, &stVpssGrpAttr, &stSize); s32Ret = SAMPLE_COMM_IVE_VpssStart(u32VpssGrpCnt, astSize, aVpssChn, u32VpssChnNum, &stVpssGrpAttr); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("SAMPLE_COMM_IVE_VpssStart fail,Error(%#x)\n",s32Ret); goto END_720P_6; } } return s32Ret; //END_720P_7: //if (HI_TRUE == bOpenVpss) //{ // SAMPLE_COMM_IVE_StopVpss(u32VpssGrpCnt,u32VpssChnNum); //} END_720P_6: if (HI_TRUE == bOpenVenc) { SAMPLE_COMM_VENC_Stop(VencChn); } END_720P_5: if (HI_TRUE == bOpenVo) { SAMPLE_COMM_VO_StopChn(VoDev, enVoMode); } END_720P_4: if (HI_TRUE == bOpenVo) { SAMPLE_COMM_VO_StopLayer(VoLayer); } END_720P_3: if (HI_TRUE == bOpenVo) { SAMPLE_COMM_VO_StopDev(VoDev); } END_720P_2: if(HI_TRUE == bOpenViExt) { (HI_VOID)HI_MPI_VI_DisableChn(ViExtChn); } END_720P_1: if (HI_TRUE == bOpenVi) { SAMPLE_COMM_VI_StopVi(pstViConfig); } END_720P_0: SAMPLE_COMM_SYS_Exit(); return s32Ret; }
static void video_DisplayD1(int nVoDev, int nChn, unsigned char bDisplay) { int i = 0, ii = 0; static int s_nDispViDev = -1; static int s_nDispViChn = -1; VI_CHN_ATTR_S stViChnAttr; if(bDisplay){ for(i = 0; i < VIDEO_GetMaxDiv(); ++i){ DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, i)); } } if(bDisplay){ // unbind last full channel first if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){ DVR_ASSERT(HI_MPI_VI_UnBindOutput(s_nDispViDev, s_nDispViChn, nVoDev, SPECIAL_D1_CH)); } DVR_ASSERT(HI_MPI_VO_ClearChnBuffer(nVoDev, SPECIAL_D1_CH, HI_TRUE)); if(nChn < 16){ int fd = open(VIDEO_DEV, O_RDWR); if(fd > 0){ // set ad configuration video_preview_t stPreview = {0}; stPreview.chn = nChn; // switch to this channel @ ad ioctl(fd, VIDEO_DRV_SET_LIVE_CHN, &stPreview); close(fd); fd = -1; } // redefine device s_nDispViDev = 1; s_nDispViChn = 0; }else if(nChn < 24){ // reset field to both not downscale if(0 == VIMAP_Get(nChn, &s_nDispViDev, &s_nDispViChn)){ } }else{ ; } if(s_stVideo.nLossStat & (1<<nChn)){ // VIDEO_TRACE("Send User Pic"); DVR_ASSERT(HI_MPI_VO_SENDFRAME(nVoDev, SPECIAL_D1_CH, VIDEO_GetUserPic(nChn))); }else{ DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); VI_D1_ATTR_CONF(&stViChnAttr); DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_BindOutput(s_nDispViDev, s_nDispViChn, nVoDev, SPECIAL_D1_CH)); usleep(40000); } DVR_ASSERT(HI_MPI_VO_ChnShow(nVoDev, SPECIAL_D1_CH)); }else{ if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){ DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); VI_CIF_ATTR_CONF(&stViChnAttr); DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_UnBindOutput(s_nDispViDev, s_nDispViChn, nVoDev, SPECIAL_D1_CH)); DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, SPECIAL_D1_CH)); if(nVoDev > 0){ s_nDispViDev = -1; s_nDispViChn = -1; } } } }
static void video_InputInit() { int i = 0; // init sdk { VI_PUB_ATTR_S stViDevAttr; VI_CHN_ATTR_S stViChnAttr; // vi0 1-16 ch cif input 1d1 // vi1 1-16 ch selecting input 1d1 // vi2 17-20 ch d1 input 4d1 // vi3 21-24 ch d1 input 4d1 //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // vi0 stViDevAttr.enInputMode = VI_MODE_BT656; stViDevAttr.enWorkMode = VI_WORK_MODE_1D1; stViDevAttr.enViNorm = (VIDEO_IS_PAL() ? VIDEO_ENCODING_MODE_PAL : VIDEO_ENCODING_MODE_NTSC); // channel attribute stViChnAttr.stCapRect.s32X = 0; stViChnAttr.stCapRect.s32Y = 0; stViChnAttr.stCapRect.u32Width = VI_CIF_WIDTH; stViChnAttr.stCapRect.u32Height = 8 * VI_CIF_HEIGHT + 7 * 2; // half field height combo frame stViChnAttr.bChromaResample = HI_FALSE; stViChnAttr.enCapSel = VI_CAPSEL_BOTH; stViChnAttr.bDownScale = HI_FALSE; stViChnAttr.bHighPri = HI_FALSE; stViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; DVR_ASSERT(HI_MPI_VI_Disable(0)); DVR_ASSERT(HI_MPI_VI_SetPubAttr(0, &stViDevAttr)); DVR_ASSERT(HI_MPI_VI_Enable(0)); DVR_ASSERT(HI_MPI_VI_SetChnAttr(0, 0, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_EnableChn(0, 0)); DVR_ASSERT(HI_MPI_VI_SetSrcFrameRate(0, 0, MAX_CIF_LIVE_FPS)); //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // vi1 stViDevAttr.enInputMode = VI_MODE_BT656; stViDevAttr.enWorkMode = VI_WORK_MODE_1D1; stViDevAttr.enViNorm = (VIDEO_IS_PAL() ? VIDEO_ENCODING_MODE_PAL : VIDEO_ENCODING_MODE_NTSC); // channel attribute stViChnAttr.stCapRect.u32Width = 704; stViChnAttr.stCapRect.u32Height = VI_CIF_HEIGHT; stViChnAttr.stCapRect.s32X = 8; stViChnAttr.stCapRect.s32Y = 0; stViChnAttr.bChromaResample = HI_FALSE; stViChnAttr.enCapSel = VI_CAPSEL_BOTH; stViChnAttr.bDownScale = HI_FALSE; stViChnAttr.bHighPri = HI_FALSE; stViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; // interface DVR_ASSERT(HI_MPI_VI_Disable(1)); DVR_ASSERT(HI_MPI_VI_SetPubAttr(1, &stViDevAttr)); DVR_ASSERT(HI_MPI_VI_Enable(1)); DVR_ASSERT(HI_MPI_VI_SetChnAttr(1, 0, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_EnableChn(1, 0)); DVR_ASSERT(HI_MPI_VI_SetSrcFrameRate(1, 0, MAX_D1_LIVE_FPS)); //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // vi2 stViDevAttr.enInputMode = VI_MODE_BT656; stViDevAttr.enWorkMode = VI_WORK_MODE_4D1; stViDevAttr.enViNorm = (VIDEO_IS_PAL() ? VIDEO_ENCODING_MODE_PAL : VIDEO_ENCODING_MODE_NTSC); // cif input stViChnAttr.stCapRect.u32Width = 704; stViChnAttr.stCapRect.u32Height = VI_CIF_HEIGHT; stViChnAttr.stCapRect.s32X = 8; stViChnAttr.stCapRect.s32Y = 0; stViChnAttr.bChromaResample = HI_FALSE; stViChnAttr.enCapSel = VI_CAPSEL_BOTTOM; stViChnAttr.bDownScale = HI_TRUE; stViChnAttr.bHighPri = HI_FALSE; stViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; // interface DVR_ASSERT(HI_MPI_VI_Disable(2)); DVR_ASSERT(HI_MPI_VI_SetPubAttr(2, &stViDevAttr)); DVR_ASSERT(HI_MPI_VI_Enable(2)); for(i = 0; i < 4; ++i){ DVR_ASSERT(HI_MPI_VI_SetChnAttr(2, i, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_EnableChn(2, i)); DVR_ASSERT(HI_MPI_VI_SetSrcFrameRate(2, i, MAX_CIF_LIVE_FPS)); } //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // vi3 stViDevAttr.enInputMode = VI_MODE_BT656; stViDevAttr.enWorkMode = VI_WORK_MODE_4D1; stViDevAttr.enViNorm = (VIDEO_IS_PAL() ? VIDEO_ENCODING_MODE_PAL : VIDEO_ENCODING_MODE_NTSC); // cif input stViChnAttr.stCapRect.u32Width = 704; stViChnAttr.stCapRect.u32Height = VI_CIF_HEIGHT; stViChnAttr.stCapRect.s32X = 8; stViChnAttr.stCapRect.s32Y = 0; stViChnAttr.bChromaResample = HI_FALSE; stViChnAttr.enCapSel = VI_CAPSEL_BOTTOM; stViChnAttr.bDownScale = HI_TRUE; stViChnAttr.bHighPri = HI_FALSE; stViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420; // interface DVR_ASSERT(HI_MPI_VI_Disable(3)); DVR_ASSERT(HI_MPI_VI_SetPubAttr(3, &stViDevAttr)); DVR_ASSERT(HI_MPI_VI_Enable(3)); for(i = 0; i < 4; ++i){ DVR_ASSERT(HI_MPI_VI_SetChnAttr(3, i, &stViChnAttr)); DVR_ASSERT(HI_MPI_VI_EnableChn(3, i)); DVR_ASSERT(HI_MPI_VI_SetSrcFrameRate(3, i, MAX_CIF_LIVE_FPS)); } } }