示例#1
0
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));
            }
        }
	}
}
示例#2
0
static void video_InputDestroy()
{
	int nDev = 0;
	int i = 0, ii = 0;

    for(ii = 0; ii < MAX_CAM_CH; ii += 4) {
        if(VIMAP_Get(ii, &nDev, NULL) < 0) {
            continue;
        }

        for(i = 0; i < 4; ++i) {
            DVR_ASSERT(HI_MPI_VI_DisableChn(nDev, i));
        }
        DVR_ASSERT(HI_MPI_VI_Disable(nDev));
    }
}
示例#3
0
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));
	}
}
示例#4
0
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;
			}
		}
	}
}