hi3518e视频输入设备讲解
程序员文章站
2024-02-23 21:02:04
...
视频输入(VI)模块可工作在离线模式和在线模式。
离线模式是指 VI 写出数据到 DDR,然后与之绑定的模块从 DDR 读取数据。
工作在在线模式是指 VI 与 VPSS 之间的在线数据流传输,在此模式下 VI 不会写出到 DDR,而是直接把数据流送给 VPSS。
视频物理通道:硬件单元只包括1个VI视频物理通道Chn0,不存在次通道但是支持扩展通道。
视频扩展通道:主要实现缩放功能,其数据来源于物理通道,最多支持8个扩展通道。
掩码配置:?
DIS软件流程:调用DIS接口前必须使能VI 通道
打开设备和通道的代码举例
HI_S32 s32Ret;
VI_DEV ViDev = 0;
VI_CHN ViChn = 0;
VI_DEV_ATTR_S stDevAttr;
VI_CHN_ATTR_S stChnAttr;
stDevAttr.enIntfMode = VI_MODE_DIGITAL_CAMERA;
stDevAttr.enWorkMode = VI_WORK_MODE_1Multiplex;
stDevAttr.au32CompMask[0] = 0xFFF00000;
stDevAttr.au32CompMask[1] = 0x0;
stDevAttr.enScanMode = VI_SCAN_PROGRESSIVE;
stDevAttr.s32AdChnId[0] = -1;
stDevAttr.s32AdChnId[1] = -1;
stDevAttr.s32AdChnId[2] = -1;
stDevAttr.s32AdChnId[3] = -1;
stDevAttr.stDevRect.s32X = 0;
stDevAttr.stDevRect.s32Y = 0;
stDevAttr.stDevRect.u32Width = 1920;
stDevAttr.stDevRect.u32Height = 1080;
s32Ret = HI_MPI_VI_SetDevAttr(ViDev, &stDevAttr);
if (s32Ret != HI_SUCCESS)
{
printf("Set dev attributes failed with error code %#x!\n", s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_VI_EnableDev(ViDev);
if (s32Ret != HI_SUCCESS)
{
printf("Enable dev failed with error code %#x!\n", s32Ret);
return HI_FAILURE;
}
stChnAttr.stCapRest.s32X = 0;
stChnAttr.stCapRect.s32Y = 0;
stChnAttr.stCapRect.u32Width = 1920;
stChnAttr.stCapRect.u32Height = 1080;
stChnAttr.stDestSize.u32Width = 1920;
stChnAttr.stDestSize.u32Height = 1080;
stChnAttr.enCapSel = VI_CAPSEL_BOTH;
stChnAttr.enPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
stChnAttr.bMirror = HI_FALSE;
stChnAttr.bFlip = HI_FALSE;
stChnAttr.s32SrcFrameRate = -1;
stChnAttr.s32DstFrameRate = -1;
stChnAttr. enCompressMode = COMPRESS_MODE_NONE;
s32Ret = HI_MPI_VI_SetChnAttr(ViChn,&stChnAttr);
if (s32Ret != HI_SUCCESS)
{
printf("Set chn attributes failed with error code %#x!\n", s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_VI_EnableChn(ViChn);
if (s32Ret != HI_SUCCESS)
{
printf("Enable chn failed with error code %#x!\n", s32Ret);
return HI_FAILURE;
}
/* now, vi is capturing images, you can do something else ... */
s32Ret = HI_MPI_VI_DisableChn(ViChn);
if (s32Ret != HI_SUCCESS)
{
printf("Disable chn failed with error code %#x!\n", s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_VI_DisableDev(ViDev);
if (s32Ret != HI_SUCCESS)
{
printf("Disable dev failed with error code %#x!\n", s32Ret);
return HI_FAILURE;
}
推荐阅读