⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 video_adjust.c

📁 sample on embedded linux
💻 C
字号:
#include "hi_common_api.h"#include "video_comm.h"#include "tw2834.h"#define HI_VI_CHN0 0#define HI_VO_CHN0 0HI_U16 mode = D1;HI_U16 g_videoNorm = NTSC;VENC_FORMAT_E format = VENC_FORMAT_H264;/* 0 PAL , 1: NTSC */static VIDEO_NORM_E get_VideoNorm(void){    HI_S32 fd = -1;    static VIDEO_NORM_E norm = 0;     int ret;    fd = open("/dev/misc/tw2834dev", O_RDWR, 0);    if( fd < 0 )    {        perror("tw2834\n");        return VIDEO_ENCODING_MODE_PAL;    }    if ((ret = ioctl( fd, TW2834_GETNORM, &norm )) < 0)    {        norm = VIDEO_ENCODING_MODE_PAL;  /* default PAL */        printf("ERROR when get 5150 norm. ERR:%#x\n", ret);    }        close(fd);    return norm;}/*** PAL/NTSC adjust by itself*/HI_S32 set_vad(HI_S32 normal){    static HI_S32 fd = -1;    int ret;    fd = open("/dev/misc/tw2834", O_RDWR, 0);    if( fd < 0 )    {        perror("open tw2834 failed\n");        return HI_FAILURE;    }    if ((ret = ioctl( fd, TW2834_SETNORM, &normal )) < 0)    {        printf("tw2834 set mode failed: %x\n", ret);               return HI_FAILURE;    }    close(fd);    return HI_SUCCESS;    }HI_S32 set_vda(int norm){    static HI_S32 fd = -1;    int ret;    int norm2set;    fd = open("/dev/misc/adv7179", O_RDWR, 0);    if( fd < 0 )    {        perror("adv7179");        return HI_FAILURE;    }    if(norm==0)        norm2set = VIDEO_MODE_656_PAL;     else        norm2set = VIDEO_MODE_656_NTSC;     if ((ret = ioctl(fd, ENCODER_SET_NORM, norm2set )) < 0)    {        printf("adv7179 set normal failed: %#x\n", ret);        return HI_FAILURE;    }    close(fd);    return HI_SUCCESS;}int main(void){    HI_S32 tmp;    HI_S32 hiRet;    /*adjust the A/D by it self*/    g_videoNorm = get_VideoNorm();        /* config VI public attribute*/    hiRet = ViPubConfig(mode, g_videoNorm, format);    	if (HI_SUCCESS != hiRet)	{	    printf ("vi public atr config failed\n");        HI_VENC_Close();	    return hiRet;	}        /*config VI channel attribute*/    hiRet = ViChnConfig(mode, g_videoNorm, 0);	if (HI_SUCCESS != hiRet)	{	    printf ("vi chn atr config failed\n");        HI_VENC_Close();	    return hiRet;	}    /*config D/A device*/    hiRet = DAconfig(g_videoNorm);	if (HI_SUCCESS != hiRet)	{	    printf ("DAconfig failed\n");        HI_VENC_Close();	    return hiRet;	}    /*config VO public attribute*/    hiRet = VoPubConfig(g_videoNorm);	if (HI_SUCCESS != hiRet)	{	    printf ("vo public attr config failed\n");        HI_VENC_Close();	    return hiRet;	}    /*config VO channel attribute*/    hiRet = VoChnConfig(g_videoNorm, 0);	if (HI_SUCCESS != hiRet)	{	    printf ("vo chn atr config failed\n");        HI_VENC_Close();	    return hiRet;	}    /*enable VI2VO*/    hiRet = HI_VI_EnVi2Vo(HI_VI_CHN0, HI_VO_CHN0, HI_TRUE);    if (HI_SUCCESS != hiRet)	{	    printf ("envi2vo chn atr config failed\n");        HI_VENC_Close();	    return hiRet;	}    scanf ("%d\n", &tmp);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -