Preface:
Hass multimedia processing platform (MPP) is divided into: a video input (VI), a video processing (VPSS), a video encoder (VENC), a video decoder (VDEC), video output (VO), Video Detection Analysis (VDA), the audio input (AI), an audio output (AO), the audio encoder (AENC), an audio decoder (ADEC), area management (the rEGION) modules. presented here video input module (VI). VI and is closely related to AD, AD output mode must correspond to the Hass VI, AD to correct the output transmitted to the Hisi device, it is necessary to understand the characteristics of the ADC own use. Further VI operation flow can be divided into:
- 0. Get the default parameters
- 1. Analyzing the number of ADC chip
- 2. Get the current that has been inserted through the camera resolution information IOC_VDEC_GET_INPUT_VIDEO_FMT
- 3. Calculate the buffer pool size
- 4. Initialize System mpp
- 5. Start ADC equipment
- 6. Start function VI
- 7. Set VI channel bonding relationship
- 8. Establish binding of VI and VPSS
Description:
Development board configuration:
Hisi: Hi3521A
the AD: NVP6134C a
camera: 720P, 1080P
show: HDMI bus, 1080P screen
(A) Basic features:
(1)NVP6134
Formats INPUT
- 4CH Connections Video INPUT
: CVBS / the COMET
: Universal 1M, and 2M. 3 /. 4 / 5M the NRT
the Output Formats
- BT.656 in the Output / BT.1120. 4: 2: 2 byte interleave the format with37.125 / 74.25 / 148.5 / 297MHz
- support the Format Sync Separate BT.601 (the CLK / H, the SYNC-V / 8'bitDATA)
support the Output Port Connections Video * 2, the Output Each Port Connections Video FormatSelectable
a maximum input 6134NVP chip support 4 data point, two 8-bit output port can be selected individually controlled, it may be blended as a 16-bit port.
(2) Hisi VI
Hi3521A BT.1120 chip has two interfaces, each interface followed BT.1120 VI corresponding to two devices, i.e., a first port corresponding to the VI Dev0 BT.1120 and the Dev1, the second port corresponding to the Dev2 BT.1120 and VI Dev3.4 a 1/2/4 VI D1,960H devices support multi mode input (BT.656 protocol), and 2-way multi mode 720P. 4 device supports 720P / 1080P HD input 1 (BT.1120 Protocol) In this case, the same interface BT1120 another Dev unavailable, i.e. DEV0, DEV1 can only available; DEV2, DEV3 can only use a .
I used here is the BT.656 mode, that is, four dev can be used alone, can support 1/2/4 D1,960H composite input mode (BT.656 protocol), and 2-way 720P composite mode.
(B) adaptive input
Adapted input is actually connected to input channels and the actual resolution of the camera camera to apply memory pool, and so on to set the input mode.
To implement the adaptive input IOC_VDEC_GET_INPUT_VIDEO_FMT can acquire a video input resolution, the number of input information like camera head.
The actual mechanism operating member is:
typedef struct _nvp6134_input_videofmt
{
unsigned int inputvideofmt[16];
unsigned int getvideofmt[16];
unsigned int geteqstage[16];
unsigned int getacpdata[16][8];
}nvp6134_input_videofmt;
Query the camera into large ones and resolution can be achieved:
int Check_NVP6134_VideoInputFMT(void)
{
int fd = -1;
int i = 0;
int l_s32Ret = 0;
nvp6134_input_videofmt stInputFMT;
bzero(&stInputFMT,sizeof(nvp6134_input_videofmt));
fd = open(NVP6134_FILE, O_RDWR);
if (fd < 0)
{
printf("[%s:%d] open nvp6134 (%s) fail\n", __func__, __LINE__, NVP6134_FILE);
return -1;
}
l_s32Ret = ioctl(fd, IOC_VDEC_GET_INPUT_VIDEO_FMT, &stInputFMT);
if(l_s32Ret < 0)
{
printf("[%s,%d][l_s32Ret:%d]\n",__FILE__,__LINE__,l_s32Ret);
}
close(fd);
for(i=0;i<16;i++)
{
printf("i=%d videofmt =0x%x \n",i,stInputFMT.getvideofmt[i]);
printf("i=%d inputvideofmt=0x%x \n\n",i,stInputFMT.inputvideofmt[i]);
}
return 0;
}
Getvideofmt resolution correspondence relationship may view the function of driving NVP6134
unsigned char nvp6134_vfmt_convert(unsigned char vdsts, unsigned char g_ck_fmt)
/*nvp6134b视频模式值转换*/
unsigned char nvp6134_vfmt_convert(unsigned char vdsts, unsigned char g_ck_fmt)
{
unsigned int ret;
switch(vdsts)
{
case 0x00: ret = 0x01; break; //cvbs ntsc
case 0x10: ret = 0x02; break; //cvbs pal
case 0x20: ret = 0x04; break; //720p ntsc
case 0x21: ret = 0x08; break; //720p pal
case 0x22: ret = 0x51; break; //720P@RT ntsc
case 0x23: ret = 0x52; break; //720P@RT pal
case 0x30: ret = 0x40; break; //1080p ntsc
case 0x31: ret = 0x80; break; //1080p pal
....
case 0x01:
case 0x02:
if((g_ck_fmt>>4) == 0x02) ret = 0x91; //AHD @ 3M RT-30P
else ret = 0x92; //AHD @ 3M RT-25P
break;
default:
case 0xFF: ret = 0x00; break; //not detects
}
return ret;
}
Perform functions such as to give the above:
/hi3520/app # ./nvp_6134_input_fmt_check
i=0 videofmt =0x0
i=0 inputvideofmt=0x0
i=1 videofmt =0x0
i=1 inputvideofmt=0x0
i=2 videofmt =0x0
i=2 inputvideofmt=0x0
i=3 videofmt =0x12
i=3 inputvideofmt=0x0
....
Can know the fourth inputs of a camera is the 720P. Then go to follow a path 720P camera input to initialize the MPP Hisi
(C) Basic operation flow
0. Get the default parameters
This is not necessary, except as a default parameter when the camera is not detected.
1. Analyzing the number of ADC chip
NVP6134 only support a maximum four input camera data, but can support HI3521A input camera 16, can be used simultaneously as the chips still have a plurality of ADC data input. Hass equipment for maximum support should be able to enter the four NVP6134.
2. Get input and camera resolution
Get current has been inserted through IOC_VDEC_GET_INPUT_VIDEO_FMT camera resolution information, that is, the content (B) described above adapted input
3. Calculate the buffer pool size
It can be used directly to calculate the official Interface SAMPLE_COMM_SYS_CalcPicVbBlkSize
4. Initialize System mpp
You can directly call SAMPLE_COMM_SYS_Init interface initialization.
5. Start ADC equipment
It should be noted: ADC must be provided here correspond Hisi VI below set, otherwise the data can not be normally transmitted.
I am here is to provide two-way output port 2 NVP6134 multiplexing, each corresponding to two channels of data output port, a total of four data, set as follows:
case SAMPLE_VI_MODE_6134_960H_720P_2MUX:
{
SAMPLE_PRT("SAMPLE_VI_MODE_6134_960H_720P_2MUX!!!\n");
for(i=0;i<chip_cnt*4;i++)
{
schnmode.ch = i;
schnmode.vformat = video_mode;
schnmode.chmode = NVP6134_VI_720P_2530;
ioctl(fd, IOC_VDEC_SET_CHNMODE, &schnmode);
}
for(i=0;i<chip_cnt;i++)
{
optmode.chipsel = i;
optmode.portsel = 2;
optmode.portmode = NVP6134_OUTMODE_2MUX_HD;
optmode.chid = 0;
ioctl(fd, IOC_VDEC_SET_OUTPORTMODE, &optmode);
optmode.portsel = 1;
optmode.portmode = NVP6134_OUTMODE_2MUX_HD;
optmode.chid = 1;
ioctl(fd, IOC_VDEC_SET_OUTPORTMODE, &optmode);
}
SAMPLE_PRT("[%s:%d] SET OK!!!\n", __func__, __LINE__);
break;
}
Structure analysis:
/**
* Argurments :
* portsel(port select->6134b[1,2],6134[0,1,2,3],6134C[1,2];)
* portmode(port mode select[1mux,2mux,4mux]),
* chid(channel id, 1mux[0,1,2,3], 2mux[0,1], 4mux[0])
**/
typedef struct _nvp6134_opt_mode
{
unsigned char chipsel;
unsigned char portsel;
unsigned char portmode;
unsigned char chid;
}nvp6134_opt_mode;
6. Start function VI
Here is the design and use dev0 dev1, two multiplexed mode
case SAMPLE_VI_MODE_8_720P:
case SAMPLE_VI_MODE_16_720P:
case SAMPLE_VI_MODE_8_1080P:
case SAMPLE_VI_MODE_4_1080P:
case SAMPLE_VI_MODE_2_720P:
memcpy(&stViDevAttr,&DEV_ATTR_6114_720P_2MUX_BASE,sizeof(stViDevAttr));
SAMPLE_COMM_VI_SetMask(ViDev,&stViDevAttr);
break;
default:
SAMPLE_PRT("vi input type[%d] is invalid!\n", enViMode);
return HI_FAILURE;
Device attributes are as follows:
VI_DEV_ATTR_S DEV_ATTR_6114_720P_2MUX_BASE =
{
/*接口模式*/
VI_MODE_BT656,
/*1、2、4路工作模式*/
VI_WORK_MODE_2Multiplex,
/* r_mask g_mask b_mask*/
{0xFF000000, 0x0},
/* 双沿输入时必须设置 */
VI_CLK_EDGE_SINGLE_UP,
/*AdChnId*/
{-1, -1, -1, -1},
/*enDataSeq, 仅支持YUV格式*/
VI_INPUT_DATA_YVYU,
/*同步信息,对应reg手册的如下配置, --bt1120时序无效*/
{
/*port_vsync port_vsync_neg port_hsync port_hsync_neg */
VI_VSYNC_FIELD, VI_VSYNC_NEG_HIGH, VI_HSYNC_VALID_SINGNAL,VI_HSYNC_NEG_HIGH,VI_VSYNC_VALID_SINGAL,VI_VSYNC_VALID_NEG_HIGH,
/*timing信息,对应reg手册的如下配置*/
/*hsync_hfb hsync_act hsync_hhb*/
{0, 0, 0,
/*vsync0_vhb vsync0_act vsync0_hhb*/
0, 0, 0,
/*vsync1_vhb vsync1_act vsync1_hhb*/
0, 0, 0}
},
/*使用内部ISP*/
VI_PATH_BYPASS,
/*输入数据类型*/
VI_DATA_TYPE_YUV
};
7. Set VI channel bonding relationship
Design is:
- The channels 0, respectively, bound to the WAY0 dev0, and Way1,
- The channels 2, 3, respectively, bound to the WAY0 dev1, and Way1,
The code is implemented as:
for(i=0,ViChn=0; i<stViParam.s32ViDevCnt; i++)
{
for(j=0;j<stViParam.s32ViChnCnt/2;j++,ViChn++)
{
s32Ret = HI_MPI_VI_GetChnBind(ViChn, &stChnBindAttr);
stChnBindAttr.ViDev=i;
stChnBindAttr.ViWay = ViChn%2;
if (HI_ERR_VI_FAILED_NOTBIND == s32Ret)
{
s32Ret = HI_MPI_VI_BindChn(ViChn, &stChnBindAttr);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("call HI_MPI_VI_BindChn failed with %#x\n", s32Ret);
return HI_FAILURE;
}
}
s32Ret = SAMPLE_COMM_VI_StartChn(ViChn, &stCapRect, &stTargetSize, enViMode, VI_CHN_SET_NORMAL);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("call SAMPLE_COMM_VI_StarChn failed with %#x\n", s32Ret);
return HI_FAILURE;
}
}
}
8. Turn VPSS and VI are bound to VPSS
/******************************************
step 4: start vpss and vi bind vpss
******************************************/
s32Ret = SAMPLE_COMM_SYS_GetPicSize(enNorm, PIC_HD720, &stSize);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_SYS_GetPicSize failed!\n");
goto END_4_720P_1;
}
memset(&stGrpAttr,0,sizeof(VPSS_GRP_ATTR_S));
stGrpAttr.u32MaxW = stSize.u32Width;
stGrpAttr.u32MaxH = stSize.u32Height;
stGrpAttr.bNrEn = HI_TRUE;
stGrpAttr.enDieMode = VPSS_DIE_MODE_NODIE;
stGrpAttr.enPixFmt = SAMPLE_PIXEL_FORMAT;
s32Ret = SAMPLE_COMM_VPSS_Start(s32VpssGrpCnt, &stSize, VPSS_MAX_CHN_NUM, &stGrpAttr);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Start Vpss failed!\n");
goto END_4_720P_1;
}
s32Ret = SAMPLE_COMM_VI_BindVpss(enViMode);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Vi bind Vpss failed!\n");
goto END_4_720P_2;
}
Results of the:
After proper initialization and binding properties are as follows:
/hi3520/app # cat /proc/umap/vi
[VIU] Version: [Hi3521A_MPP_V1.0.3.1 B010 Release], Build Time: [Apr 18 2016, 12:08:26]
-----MODULE PARAM--------------------------------------------------------------
detect_err_frame drop_err_frame stop_int_level max_cas_gap
10 0 0 28000
-----VI DEV ATTR---------------------------------------------------------------
Dev IntfM WkM ComMsk0 ComMsk1 CLKM AD0 AD1 AD2 AD3 Seq DPath DType DRev
0 BT656 2Mux ff 0 UP -1 -1 -1 -1 UYVY ByPass YUV N
1 BT656 2Mux ff00 0 UP -1 -1 -1 -1 UYVY ByPass YUV N
-----VI HIGH DEV ATTR---------------------------------------------------------------
Dev InputM WkM ComMsk0 ComMsk1 AD0 AD1 AD2 AD3 Seq CombM CompM ClkM Fix FldP DPath DType DRev
-----VI PHYCHN ATTR------------------------------------------------------------
PhyChn CapX CapY CapW CapH DstW DstH CapSel ScanM SkipM Mirror Flip IntEn PixFom SrcRat DstRat
0 0 0 1280 720 1280 720 both P SKIPNON N N Y sp420 -1 -1
1 0 0 1280 720 1280 720 both P SKIPNON N N Y sp420 -1 -1
2 0 0 1280 720 1280 720 both P SKIPNON N N Y sp420 -1 -1
3 0 0 1280 720 1280 720 both P SKIPNON N N Y sp420 -1 -1
-----VI PHYCHN MINOR ATTR------------------------------------------------------------
PhyChn CapX CapY CapW CapH DstW DstH CapSel ScanM Mirror Flip PixFom MixCap DwScal SrcRat DstRat
-----VI PHYCHN STATUS 1----------------------------------------------------------
PhyChn BindDev Way IntCnt VbFail LosInt TopLos BotLos BufCnt IntT SendT Field Stride
0 0 0 353 0 3 0 2 2 58 24 frm 1280
1 0 1 352 0 3 0 2 2 27 11 frm 1280
2 1 0 352 0 3 0 2 2 34 13 frm 1280
3 1 1 352 0 3 0 2 2 26 11 frm 1280
-----VI PHYCHN STATUS 2---------------------------------------------------------
PhyChn MaxIntT IntGapT MaxGapT OverCnt LIntCnt ThrCnt AutoDis CasAutD TmgErr ccErrN IntRat
0 58 40009 40021 0 0 1 0 0 0 3 24
1 47 40001 40010 0 0 1 0 0 0 3 25
2 52 40026 40026 0 0 1 0 0 0 3 24
3 55 40004 40086 0 0 1 0 0 0 3 24
-----VI CHN STATUS-------------------------------------------------------------
ViChn bEnUsrP FrmTime FrmRate SendCnt SwLost Depth
0 N 40010 25 350 0 0
1 N 40000 25 349 0 0
2 N 40025 25 349 0 0
3 N 40004 25 349 0 0
-----VI CHN CALL VGS STATUS 1-------------------------------------------------
ViChn UsrBgnNOk UsrCancel UsrEndOk UsrCbOk CvrBgnNOk CvrCancel CvrEndOk CvrCbOk
-----VI CHN CALL VGS STATUS 2-------------------------------------------------
ViChn OsdBgnNOk OsdCancel OsdEndOk OsdCbOk ScaleNOk SclCancel SclEndOk SclCbOk
/hi3520/app #
4 outputs is provided, the access of a camera following effects:
Display a little dirty, it will look, ha ha ~
This chapter from the frequency measurement engineering "catalog preface" to get the address provided
The first article in this column "catalog preface," lists the complete directory column, read by directory order to help your understanding.