?? vportcap.c
字號:
VP_FSETH(vpCaptureHandle, VPCTL, VPHLT, VP_VPCTL_VPHLT_CLEAR);
/* .............. */
/* enable capture */
/* .............. */
/* set VCEN bit to enable capture,使能VCB口 */
VP_FSETH(vpCaptureHandle, VCBCTL, VCEN, VP_VCBCTL_VCEN_ENABLE);
/* clear BLKCAP in VCB_CTL to enable capture DMA events */
VP_FSETH(vpCaptureHandle, VCBCTL, BLKCAP,VP_VCBCTL_BLKCAP_CLEAR);
return (vpCaptureHandle);
}
VP_Handle bt656_8bit_ncfc( int portNumber)//VP0,VP1,VP2通道A初始化函數(shù)
{
/* Open video port for capture ,打開一個視頻端口*/
vpCaptureHandle = VP_open(portNumber, VP_OPEN_RESET);
if(vpCaptureHandle == INV)
{
return (VP_Handle)0xffff;
}
/* Enable video port functionality in VP Peripheral Control Reg(PCR),使能視頻端口*/
VP_FSETH(vpCaptureHandle, PCR, PEREN, VP_PCR_PEREN_ENABLE);
/* ..................... */
/* Enable all interrupts */
/* ..................... */
/*便能VCA的中斷源*/
/* Enable capture overrun interrupt(COVRA) for VP channel A */
VP_FSETH(vpCaptureHandle, VPIE, COVRA, VP_VPIE_COVRA_ENABLE);
/* Enable capture complete interrupt(CCMPA) for VP channel A */
VP_FSETH(vpCaptureHandle, VPIE, CCMPA, VP_VPIE_CCMPA_ENABLE);
/* Enable channel synchronization error interrupt(SERRA) for */
/* VP channel A */
VP_FSETH(vpCaptureHandle, VPIE, SERRA, VP_VPIE_SERRA_ENABLE);
/* Enable short field detect interrupt(SFDA) for VP channel A */
VP_FSETH(vpCaptureHandle, VPIE, SFDA, VP_VPIE_SFDA_ENABLE);
/* Enable video port global interrupt enable */
VP_FSETH(vpCaptureHandle, VPIE, VIE, VP_VPIE_VIE_ENABLE);
/* ...................... */
/* Setup all other fields */
/* ...................... */
/* Enable short field detect,使能缺場探測*/
VP_FSETH(vpCaptureHandle, VCACTL, SFDE, VP_VCACTL_SFDE_ENABLE);
/* Set last pixel to be captured in Field1 (VCA_STOP1 reg) */
/*設(shè)置第一場的最后一個像素的Y軸與X軸的坐標(biāo)*/
VP_RSETH(vpCaptureHandle, VCASTOP1,VP_VCASTOP1_RMK(VCA_YSTOP1, VCA_XSTOP1));
/* Set last pixel to be captured in Field2 (VCA_STOP2 reg) */
/*設(shè)置第二場的最后一個像素的Y軸與X軸的坐標(biāo)*/
VP_RSETH(vpCaptureHandle, VCASTOP2,VP_VCASTOP2_RMK(VCA_YSTOP2, VCA_XSTOP2));
/* Set first pixel to be captured in Field1 (VCA_STRT1 reg) */
/*設(shè)置第一場的第一個像素的Y軸與X軸的坐標(biāo)*/
VP_RSETH(vpCaptureHandle, VCASTRT1, VP_VCASTRT1_RMK(VCA_YSTART1,VP_VCASTRT1_SSE_ENABLE, VCA_XSTART1));
/* Set first pixel to be captured in Field2 (VCA_STRT2 reg) */
/*設(shè)置第二場的第一個像素的Y軸與X軸的坐標(biāo)*/
VP_RSETH(vpCaptureHandle, VCASTRT2,VP_VCASTRT2_RMK(VCA_YSTART2, VCA_XSTART2));
/* Set threshold values ,設(shè)置EDMA啟動的門限*/
VP_RSETH(vpCaptureHandle, VCATHRLD,VP_VCATHRLD_RMK(VCA_THRLD_FIELD2, VCA_THRLD_FIELD1));
/* Set capture event.register values,設(shè)置一場的需要的EDMA的次數(shù) */
VP_RSETH(vpCaptureHandle, VCAEVTCT,VP_VCAEVTCT_RMK(VCA_CAPEVT2,VCA_CAPEVT1));
/* Vertical interrupts (VCA_INT) are not enabled in this example. */
/* Set CMODE to 8.bit BT.656,采用BT656格式的數(shù)據(jù)流 */
VP_FSETH(vpCaptureHandle, VCACTL, CMODE, VP_VCACTL_CMODE_BT656B);
/* Set non.continuous frame capture,設(shè)置為電視顯示格式的采集,即不連續(xù)的采集,
CON/FRAME/CF2/CF1的值為0100 */
VP_FSETH(vpCaptureHandle, VCACTL, CON, VP_VCACTL_CON_DISABLE);
VP_FSETH(vpCaptureHandle, VCACTL, FRAME, VP_VCACTL_FRAME_FRMCAP);
VP_FSETH(vpCaptureHandle, VCACTL, CF2, VP_VCACTL_CF2_NONE);
VP_FSETH(vpCaptureHandle, VCACTL, CF1, VP_VCACTL_CF1_NONE);
/* Let FLDD and FINV to be their defaults */
/* Set VRST to end of vertical blanking,VCOUNT復(fù)位在場消隱之后 */
VP_FSETH(vpCaptureHandle, VCACTL, VRST, VP_VCACTL_VRST_V0EAV);
/* Set HRST to start of horizontal blanking,行計數(shù)復(fù)位在EAV之后 */
VP_FSETH(vpCaptureHandle, VCACTL, HRST, VP_VCACTL_HRST_OF(0));
/* 10.bit pack mode(10BPK bit) in this 8.bit example */
/* No (1/2) scaling and no chroma re.sampling in this example */
/*初始化EDMA通路,由portNumber判斷需要配置哪個DMA通道*/
if(portNumber==0)
IRQ_enable(IRQ_EVT_VINT1);
else if(portNumber==1)
IRQ_enable(IRQ_EVT_VINT1);
else
IRQ_enable(IRQ_EVT_VINT2);
/* Enable video port interrupts */
IRQ_enable(vpCaptureHandle->eventId);
/*根據(jù)標(biāo)志位判斷需要設(shè)置的EDMA通路 Setup Y, Cb and Cr EDMA channels */
if (portNumber==0)
setupVPCapChaAEDMA0(portNumber);
else if(portNumber==1)
setupVPCapChaAEDMA1(portNumber);
else if(portNumber==2&WV==0)
setupVPCapChaAEDMA2(portNumber);
/* Clear VPHLT in VP_CTL to make video port function,清除VPHLT位?
使能其它位 */
VP_FSETH(vpCaptureHandle, VPCTL, VPHLT, VP_VPCTL_VPHLT_CLEAR);
/* .............. */
/* enable capture */
/* .............. */
/* set VCEN bit to enable capture,使能VCA口 */
VP_FSETH(vpCaptureHandle, VCACTL, VCEN, VP_VCACTL_VCEN_ENABLE);
/* clear BLKCAP in VCA_CTL to enable capture DMA events */
VP_FSETH(vpCaptureHandle, VCACTL, BLKCAP,VP_VCACTL_BLKCAP_CLEAR);
return (vpCaptureHandle);
}
/*******************************************************************/
/* Function : bt656_capture_start */
/* Input(s) : VP_handle */
/* Description : Configures given video port for 8.bit BT.656 non. */
/* continuos frame capture on channel A. */
/*******************************************************************/
void bt656_capture_start(VP_Handle videoHandle)
{
}
/*................................................................ */
/* Function : VPCapChaAIsr */
/* Description : This capture ISR clears FRMC to continue capture */
/* in this non.continuous mode and also clears other */
/* status bits. */
/*................................................................ */
interrupt void VPCapChaAIsr(void)
{
Uint32 vpis = 0;
/* Get video port status register value */
vpis = VP_RGETH(vpCaptureHandle, VPIS);
if(vpis & _VP_VPIS_CCMPA_MASK) /* capture complete */
{
/* Clear frame complete bit in VCX_CTL to continue capture in non-continuous mode*/
VP_FSETH(vpCaptureHandle, VCASTAT, FRMC,VP_VCASTAT_FRMC_CLEAR);
/* Clear CCMPA to enable next frame complete interrupts*/
VP_FSETH(vpCaptureHandle, VPIS, CCMPA,VP_VPIS_CCMPA_CLEAR);
capChaAFrameCount++; /* increment captured frame count */
capNewFrame = 1;
}
if(vpis & _VP_VPIS_COVRA_MASK) /* overrun error */
{
capChaAOverrun++;
VP_FSETH(vpCaptureHandle, VPIS, COVRA,VP_VPIS_COVRA_CLEAR);
}
if(vpis & _VP_VPIS_SERRA_MASK) /* synchronization error */
{
capChaASyncError++;
VP_FSETH(vpCaptureHandle, VPIS, SERRA,VP_VPIS_SERRA_CLEAR);
}
if(vpis & _VP_VPIS_SFDA_MASK) /* short field detect */
{
capChaAShortFieldDetect++;
VP_FSETH(vpCaptureHandle, VPIS, SFDA, VP_VPIS_SFDA_CLEAR);
}
if(vpis & _VP_VPIS_LFDA_MASK) /* long field detect */
{
capChaALongFieldDetect++;
VP_FSETH(vpCaptureHandle, VPIS, LFDA, VP_VPIS_LFDA_CLEAR);
}
}
interrupt void cap1(void)
{
Uint32 vpis = 0;
/* Get video port status register value */
vpis = VP_RGETH(vpCaptureHandle, VPIS);
if(vpis & _VP_VPIS_CCMPA_MASK) /* capture complete */
{
/* Clear frame complete bit in VCX_CTL to continue capture in non-continuous mode*/
VP_FSETH(vpCaptureHandle, VCASTAT, FRMC,VP_VCASTAT_FRMC_CLEAR);
/* Clear CCMPA to enable next frame complete interrupts*/
VP_FSETH(vpCaptureHandle, VPIS, CCMPA,VP_VPIS_CCMPA_CLEAR);
capChaAFrameCount++; /* increment captured frame count */
capNewFrame1 = 1;
}
if(vpis & _VP_VPIS_COVRA_MASK) /* overrun error */
{
capChaAOverrun++;
VP_FSETH(vpCaptureHandle, VPIS, COVRA,VP_VPIS_COVRA_CLEAR);
}
if(vpis & _VP_VPIS_SERRA_MASK) /* synchronization error */
{
capChaASyncError++;
VP_FSETH(vpCaptureHandle, VPIS, SERRA,VP_VPIS_SERRA_CLEAR);
}
if(vpis & _VP_VPIS_SFDA_MASK) /* short field detect */
{
capChaAShortFieldDetect++;
VP_FSETH(vpCaptureHandle, VPIS, SFDA, VP_VPIS_SFDA_CLEAR);
}
if(vpis & _VP_VPIS_LFDA_MASK) /* long field detect */
{
capChaALongFieldDetect++;
VP_FSETH(vpCaptureHandle, VPIS, LFDA, VP_VPIS_LFDA_CLEAR);
}
}
interrupt void cap2(void)
{
if(WV==0)
{
Uint32 vpis = 0;
/* Get video port status register value */
vpis = VP_RGETH(vpCaptureHandle, VPIS);
if(vpis & _VP_VPIS_CCMPA_MASK) /* capture complete */
{
/* Clear frame complete bit in VCX_CTL to continue capture in non-continuous mode*/
VP_FSETH(vpCaptureHandle, VCASTAT, FRMC,VP_VCASTAT_FRMC_CLEAR);
/* Clear CCMPA to enable next frame complete interrupts*/
VP_FSETH(vpCaptureHandle, VPIS, CCMPA,VP_VPIS_CCMPA_CLEAR);
capChaAFrameCount++; /* increment captured frame count */
capNewFrame2 = 1;
}
if(vpis & _VP_VPIS_COVRA_MASK) /* overrun error */
{
capChaAOverrun++;
VP_FSETH(vpCaptureHandle, VPIS, COVRA,VP_VPIS_COVRA_CLEAR);
}
if(vpis & _VP_VPIS_SERRA_MASK) /* synchronization error */
{
capChaASyncError++;
VP_FSETH(vpCaptureHandle, VPIS, SERRA,VP_VPIS_SERRA_CLEAR);
}
if(vpis & _VP_VPIS_SFDA_MASK) /* short field detect */
{
capChaAShortFieldDetect++;
VP_FSETH(vpCaptureHandle, VPIS, SFDA, VP_VPIS_SFDA_CLEAR);
}
if(vpis & _VP_VPIS_LFDA_MASK) /* long field detect */
{
capChaALongFieldDetect++;
VP_FSETH(vpCaptureHandle, VPIS, LFDA, VP_VPIS_LFDA_CLEAR);
}
}
if(WV==1)
{
Uint32 vpis = 0;
/* Get video port status register value */
vpis = VP_RGETH(vpCaptureHandle, VPIS);
if(vpis & _VP_VPIS_CCMPB_MASK) /* capture complete */
{
/* Clear frame complete bit in VCX_CTL to continue capture in non-continuous mode*/
VP_FSETH(vpCaptureHandle, VCBSTAT, FRMC,VP_VCBSTAT_FRMC_CLEAR);
/* Clear CCMPA to enable next frame complete interrupts*/
VP_FSETH(vpCaptureHandle, VPIS, CCMPB,VP_VPIS_CCMPA_CLEAR);
capChaAFrameCount++; /* increment captured frame count */
capNewFrame3 = 1;
}
if(vpis & _VP_VPIS_COVRB_MASK) /* overrun error */
{
capChaAOverrun++;
VP_FSETH(vpCaptureHandle, VPIS, COVRB,VP_VPIS_COVRB_CLEAR);
}
if(vpis & _VP_VPIS_SERRA_MASK) /* synchronization error */
{
capChaASyncError++;
VP_FSETH(vpCaptureHandle, VPIS, SERRB,VP_VPIS_SERRB_CLEAR);
}
if(vpis & _VP_VPIS_SFDA_MASK) /* short field detect */
{
capChaAShortFieldDetect++;
VP_FSETH(vpCaptureHandle, VPIS, SFDB, VP_VPIS_SFDB_CLEAR);
}
if(vpis & _VP_VPIS_LFDA_MASK) /* long field detect */
{
capChaALongFieldDetect++;
VP_FSETH(vpCaptureHandle, VPIS, LFDB, VP_VPIS_LFDB_CLEAR);
}
}
}
/*................................................................ */
/* Function : setupVPCapChaAEDMA(Int32 portNumber) */
/* Input(s) : portNumber, video port number i.e. 0, 1 or 2. */
/* Description : Sets up EDMA channels for Y, U, V events for */
/* channel A capture. */
/*功能描述:將為Y,U,V建立EDMA的通路*/
/*................................................................ */
void setupVPCapChaAEDMA0(int portNumber)//初始化VP0視頻口的B通路對應(yīng)的DMA通道
{
Int32 YEvent, UEvent, VEvent;
/* get channelA Y, U, V EDMA event numbers,選擇觸發(fā)事件 */
switch(portNumber)
{
/*確定相應(yīng)的DMA通路*/
case VP_DEV0:
YEvent = EDMA_CHA_VP0EVTYA;
UEvent = EDMA_CHA_VP0EVTUA;
VEvent = EDMA_CHA_VP0EVTVA;
break;
case VP_DEV1:
YEvent = EDMA_CHA_VP1EVTYA;
UEvent = EDMA_CHA_VP1EVTUA;
VEvent = EDMA_CHA_VP1EVTVA;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -