video.c
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:7k
- /*
- * Copyright 2003 by Texas Instruments Incorporated.
- * All rights reserved. Property of Texas Instruments Incorporated.
- * Restricted rights to use, duplicate or disclose this code are
- * granted through contract.
- *
- */
- /* "@(#) DDK 1.10.00.23 07-02-03 (ddk-b12)" */
- #include <std.h>
- #include <tsk.h>
- #include <sem.h>
- #include <gio.h>
- #include <csl_dat.h>
- #include <csl_cache.h>
- #include <fvid.h>
- #include <edc.h>
- #include <vport.h>
- #include <vportcap.h>
- #include <vportdis.h>
- #include "saa7121.h"
- #include <saa7115.h>
- #include <evmdm642.h>
- #include "vcapparams.h"
- #include "vdisparams.h"
- /* heap IDs defined in the BIOS configuration file */
- extern Int EXTERNALHEAP;
- #include "ICETEK-DM642-C.h"
- extern unsigned int m_uVideoStatus,m_bFreeze;
- extern unsigned char m_dbFrameY[SIMGWIDTH*SIMGHEIGHT];
- extern unsigned char m_dbFrameU[SIMGWIDTH1*SIMGHEIGHT1];
- extern unsigned char m_dbFrameV[SIMGWIDTH1*SIMGHEIGHT1];
- /*
- * ======== main ========
- */
- main()
- {
- ICETEKDM642CInit();
- /******************************************************/
- /* open CSL DAT module for fast copy */
- /******************************************************/
- CSL_init();
- CACHE_clean(CACHE_L2ALL, 0, 0);
- CACHE_setL2Mode(CACHE_256KCACHE);
- CACHE_enableCaching(CACHE_EMIFA_CE00);
- CACHE_enableCaching(CACHE_EMIFA_CE01);
- DAT_open(DAT_CHAANY, DAT_PRI_LOW, DAT_OPEN_2D);
- }
- /*
- * ======== tskVideoLoopback ========
- * video loopback function.
- */
- void tskVideoLoopback()
- {
- Int i;
- unsigned int m_nID;
- Int status;
- FVID_Handle disChan;
- Int frames = 0;
- FVID_Frame *disFrameBuf;
- Int numLinesDis = EVMDM642_vDisParamsChan.imgVSizeFld1;
- Int numLinesCap = EVMDM642_vCapParamsChan.fldYStop1 -
- EVMDM642_vCapParamsChan.fldYStrt1+1;
-
- Int numLines = (numLinesDis > numLinesCap) ? numLinesCap : numLinesDis;
- FVID_Handle capChan;
- Int numPixels = EVMDM642_vCapParamsChan.fldXStop1 -
- EVMDM642_vCapParamsChan.fldXStrt1+1;
- FVID_Frame *capFrameBuf;
- Int capLinePitch = EVMDM642_vCapParamsChan.fldXStop1 -
- EVMDM642_vCapParamsChan.fldXStrt1+1;
- Int disLinePitch = EVMDM642_vDisParamsChan.imgHSizeFld1;
- numLines *= 2; /* both fields */
- /******************************************************/
- /* allocate both capture and display frame buffers */
- /* in external heap memory */
- /******************************************************/
- EVMDM642_vCapParamsChan.segId = EXTERNALHEAP;
- EVMDM642_vDisParamsChan.segId = EXTERNALHEAP;
- EVMDM642_vDisParamsSAA7121.hI2C = EVMDM642_I2C_hI2C;
- EVMDM642_vCapParamsSAA7115.hI2C = EVMDM642_I2C_hI2C;
- /******************************************************/
- /* initialization of capture driver */
- /******************************************************/
- capChan = FVID_create("/VP0CAPTURE/A/0",
- IOM_INPUT, &status, (Ptr)&EVMDM642_vCapParamsChan, NULL);
- /******************************************************/
- /* initialization of display driver */
- /******************************************************/
- disChan = FVID_create("/VP2DISPLAY/1", IOM_OUTPUT,
- &status, (Ptr)&EVMDM642_vDisParamsChan, NULL);
-
- /******************************************************/
- /* configure video encoder & decoder */
- /******************************************************/
- FVID_control(disChan, VPORT_CMD_EDC_BASE + EDC_CONFIG,
- (Ptr)&EVMDM642_vDisParamsSAA7121);
- FVID_control(capChan, VPORT_CMD_EDC_BASE + EDC_CONFIG,
- (Ptr)&EVMDM642_vCapParamsSAA7115);
- /******************************************************/
- /* start capture & display operation */
- /******************************************************/
- FVID_control(disChan, VPORT_CMD_START, NULL);
- FVID_control(capChan, VPORT_CMD_START, NULL);
-
- /********************************************************/
- /* request a frame buffer from display & capture driver */
- /********************************************************/
- FVID_alloc(disChan, &disFrameBuf);
- FVID_alloc(capChan, &capFrameBuf);
- frames ++;
- while ( 1 )
- {
- switch ( m_uVideoStatus )
- {
- case FREEZE:
- DAT_copy2d(DAT_2D2D,
- m_dbFrameY,
- disFrameBuf->frame.iFrm.y1,
- numPixels,
- numLines,
- numPixels);
- DAT_copy2d(DAT_2D2D,
- m_dbFrameV,
- disFrameBuf->frame.iFrm.cb1,
- numPixels>>1,
- numLines,
- numPixels>>1);
- DAT_copy2d(DAT_2D2D,
- m_dbFrameU,
- disFrameBuf->frame.iFrm.cr1,
- numPixels>>1,
- numLines,
- numPixels>>1);
- if ( !m_bFreeze )
- {
- ICETEKDM642CYUVRGB();
- m_bFreeze=1;
- }
- break;
- case LOOPBACK:
- default:
- DAT_copy2d(DAT_2D2D,
- capFrameBuf->frame.iFrm.y1,
- disFrameBuf->frame.iFrm.y1,
- numPixels,
- numLines,
- numPixels);
- DAT_copy2d(DAT_2D2D,
- capFrameBuf->frame.iFrm.y1,
- m_dbFrameY,
- numPixels,
- numLines,
- numPixels);
- DAT_copy2d(DAT_2D2D,
- capFrameBuf->frame.iFrm.cb1,
- disFrameBuf->frame.iFrm.cb1,
- numPixels>>1,
- numLines,
- numPixels>>1);
- DAT_copy2d(DAT_2D2D,
- capFrameBuf->frame.iFrm.cb1,
- m_dbFrameV,
- numPixels>>1,
- numLines,
- numPixels>>1);
- DAT_copy2d(DAT_2D2D,
- capFrameBuf->frame.iFrm.cr1,
- disFrameBuf->frame.iFrm.cr1,
- numPixels>>1,
- numLines,
- numPixels>>1);
- DAT_copy2d(DAT_2D2D,
- capFrameBuf->frame.iFrm.cr1,
- m_dbFrameU,
- numPixels>>1,
- numLines,
- numPixels>>1);
- m_bFreeze=0;
- break;
- }
- DAT_wait(DAT_XFRID_WAITALL);
- FVID_exchange(capChan, &capFrameBuf);
- FVID_exchange(disChan, &disFrameBuf);
- frames ++;
- }
- }