hi3520d-vio.rar

  • Kealin
    了解作者
  • C/C++
    开发工具
  • 11KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-04-01 15:56
    上传日期
海思官方提供的适用于Hi3520DV100 / Hi3520DV200的vio程序代码
hi3520d-vio.rar
  • vio
  • sample_vio.c
    77.8KB
  • pic_704_576_p420_novideo01.yuv
    594KB
  • Makefile
    609B
  • pic_704_576_p420_novideo02.yuv
    594KB
内容介绍
/****************************************************************************** A simple program of Hisilicon HI3520D video input and output implementation. Copyright (C), 2010-2011, Hisilicon Tech. Co., Ltd. ****************************************************************************** Modification: 2012-12 Created ******************************************************************************/ #ifdef __cplusplus #if __cplusplus extern "C"{ #endif #endif /* End of #ifdef __cplusplus */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <signal.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include "sample_comm.h" VIDEO_NORM_E gs_enNorm = VIDEO_ENCODING_MODE_PAL; SAMPLE_VIDEO_LOSS_S gs_stVideoLoss; HI_U32 gs_u32ViFrmRate = 0; /****************************************************************************** * function : show usage ******************************************************************************/ void SAMPLE_VIO_Usage(char *sPrgNm) { printf("Usage : %s <index>\n", sPrgNm); printf("index:\n"); printf("\t 0) VI:8*D1; VO:HD0(HDMI,VGA)+SD0(CVBS)+SD1 video preview.\n"); printf("\t 1) VI:1*1080p; VO:SD0(CVBS), HD0(HDMI,1080p@60 + VGA).\n"); printf("\t 2) VI:VI:8*2cif; VO:HD0(HDMI 720P50), WBC to SD0(CVBS) video preview.\n"); printf("\t 3) VI:VI:8*D1(6fps)/2cif(19fps); VO:HD0(HDMI 720P50)video preview\n"); printf("\t 4) VI: 1*D1, user picture; VO: SD0(CVBS) video preview.\n"); printf("\t 5) VI: 1*D1; VO:HD0(VGA) HD Zoom preview.\n"); printf("\t 6) VI: 1*D1; VO:SD0(CVBS) SD Zoom preview.\n"); printf("\t 7) VI: 4*720p; HD0(HDMI,1080p@50 + VGA). Only for Hi3520DV200\n"); return; } /****************************************************************************** * function : to process abnormal case ******************************************************************************/ void SAMPLE_VIO_HandleSig(HI_S32 signo) { if (SIGINT == signo || SIGTSTP == signo) { SAMPLE_COMM_SYS_Exit(); printf("\033[0;31mprogram termination abnormally!\033[0;39m\n"); } exit(-1); } /****************************************************************************** * function : video loss detect process * NOTE: If your ADC stop output signal when NoVideo, you can open VDET_USE_VI macro. ******************************************************************************/ void *SAMPLE_VI_AD26828_VLossDetProc(void *parg) { int fd; HI_S32 s32Ret, i, s32ChnPerDev; VI_DEV ViDev; VI_CHN ViChn; tw2865_video_loss video_loss; SAMPLE_VI_PARAM_S stViParam; SAMPLE_VIDEO_LOSS_S *ctl = (SAMPLE_VIDEO_LOSS_S*)parg; fd = open(CX26828_FILE, O_RDWR);//TW2865_FILE if (fd < 0) { printf("open %s fail\n", CX26828_FILE); ctl->bStart = HI_FALSE; return NULL; } s32Ret = SAMPLE_COMM_VI_Mode2Param(ctl->enViMode, &stViParam); if (HI_SUCCESS !=s32Ret) { SAMPLE_PRT("vi get param failed!\n"); return NULL; } s32ChnPerDev = stViParam.s32ViChnCnt / stViParam.s32ViDevCnt; while (ctl->bStart) { for (i = 0; i < stViParam.s32ViChnCnt; i++) { ViChn = i * stViParam.s32ViChnInterval; ViDev = SAMPLE_COMM_VI_GetDev(ctl->enViMode, ViChn); if (ViDev < 0) { SAMPLE_PRT("get vi dev failed !\n"); return NULL; } //video_loss.chip = stViParam.s32ViDevCnt; video_loss.chip = 0; video_loss.ch = ViChn % s32ChnPerDev; //printf("video_loss.chip %d, video_loss.ch %d\n",video_loss.chip,video_loss.ch ); ioctl(fd, CX26828_GET_VIDEO_LOSS, &video_loss); if (video_loss.is_lost) { printf("pic loss\n"); HI_MPI_VI_EnableUserPic(ViChn); } else { HI_MPI_VI_DisableUserPic(ViChn); } } usleep(500000); } close(fd); ctl->bStart = HI_FALSE; return NULL; } void *SAMPLE_VI_AD2865_VLossDetProc(void *parg) { int fd; HI_S32 s32Ret, i, s32ChnPerDev; VI_DEV ViDev; VI_CHN ViChn; tw2865_video_loss video_loss; SAMPLE_VI_PARAM_S stViParam; SAMPLE_VIDEO_LOSS_S *ctl = (SAMPLE_VIDEO_LOSS_S*)parg; fd = open(TW2865_FILE, O_RDWR);//TW2865_FILE if (fd < 0) { printf("open %s fail\n", TW2865_FILE); ctl->bStart = HI_FALSE; return NULL; } s32Ret = SAMPLE_COMM_VI_Mode2Param(ctl->enViMode, &stViParam); if (HI_SUCCESS !=s32Ret) { SAMPLE_PRT("vi get param failed!\n"); return NULL; } s32ChnPerDev = stViParam.s32ViChnCnt / stViParam.s32ViDevCnt; while (ctl->bStart) { for (i = 0; i < stViParam.s32ViChnCnt; i++) { ViChn = i * stViParam.s32ViChnInterval; ViDev = SAMPLE_COMM_VI_GetDev(ctl->enViMode, ViChn); if (ViDev < 0) { SAMPLE_PRT("get vi dev failed !\n"); return NULL; } //video_loss.chip = stViParam.s32ViDevCnt; video_loss.chip = 0; video_loss.ch = ViChn % s32ChnPerDev; //printf("video_loss.chip %d, video_loss.ch %d\n",video_loss.chip,video_loss.ch ); ioctl(fd, TW2865_GET_VIDEO_LOSS, &video_loss); if (video_loss.is_lost) { printf("pic loss\n"); HI_MPI_VI_EnableUserPic(ViChn); } else { HI_MPI_VI_DisableUserPic(ViChn); } } usleep(500000); } close(fd); ctl->bStart = HI_FALSE; return NULL; } //#define VDET_USE_VI #ifdef VDET_USE_VI static HI_S32 s_astViLastIntCnt[VIU_MAX_CHN_NUM] = {0}; void *SAMPLE_VI_VLossDetProc(void *parg) { VI_CHN ViChn; SAMPLE_VI_PARAM_S stViParam; HI_S32 s32Ret, i, s32ChnPerDev; VI_CHN_STAT_S stStat; SAMPLE_VIDEO_LOSS_S *ctl = (SAMPLE_VIDEO_LOSS_S*)parg; s32Ret = SAMPLE_COMM_VI_Mode2Param(ctl->enViMode, &stViParam); if (HI_SUCCESS !=s32Ret) { SAMPLE_PRT("vi get param failed!\n"); return NULL; } s32ChnPerDev = stViParam.s32ViChnCnt / stViParam.s32ViDevCnt; while (ctl->bStart) { for (i = 0; i < stViParam.s32ViChnCnt; i++) { ViChn = i * stViParam.s32ViChnInterval; s32Ret = HI_MPI_VI_Query(ViChn, &stStat); if (HI_SUCCESS !=s32Ret) { SAMPLE_PRT("HI_MPI_VI_Query failed with %#x!\n", s32Ret); return NULL; } if (stStat.u32IntCnt == s_astViLastIntCnt[i]) { printf("VI Chn (%d) int lost , int_cnt:%d \n", ViChn, stStat.u32IntCnt); HI_MPI_VI_EnableUserPic(ViChn); } else { HI_MPI_VI_DisableUserPic(ViChn); } s_astViLastIntCnt[i] = stStat.u32IntCnt; } usleep(500000); } ctl->bStart = HI_FALSE; return NULL; } #endif HI_S32 SAMPLE_VI_StartVLossDet(SAMPLE_VI_MODE_E enViMode) { HI_S32 s32Ret; gs_stVideoLoss.bStart= HI_TRUE; gs_stVideoLoss.enViMode = enViMode; #ifdef VDET_USE_VI s32Ret = pthread_create(&gs_stVideoLoss.Pid, 0, SAMPLE_VI_VLossDetProc, &gs_stVideoLoss); #else #ifdef DEMO s32Ret = pthread_create(&gs_stVideoLoss.Pid, 0, SAMPLE_VI_AD26828_VLossDetProc, &gs_stVideoLoss); #else s32Ret = pthread_create(&gs_stVideoLoss.Pid, 0, SAMPLE_VI_AD2865_VLossDetProc, &gs_stVideoLoss); #endif #endif if (HI_SUCCESS != s32Ret) {
评论
    相关推荐