www.pudn.com > motiotest.rar > tskVideoInput.c


/* 
 *  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. 
 *   
 */ 
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
 
#include "seeddm642.h" 
#include "seedvpm642_vcapparams.h" 
 
#include "edc.h"                    
#include "saa7121.h"     
#include "appMain.h" 
#include "appThreads.h" 
#include "tskVideoInput.h" 
#include "prepost.h" 
 
 
 
ScomBufChannels MsgInput; 
FVID_Frame *capFrameBuf; 
unsigned char InData[0x97E00]; 
 
/*-----------------------------------------------------------*/ 
/* heap IDs defined in the BIOS configuration file           */ 
/*-----------------------------------------------------------*/ 
//extern MBX_Obj VP1CAPTURE; 
extern int EXTERNALHEAP; 
FVID_Handle capChanCh1; 
 
void tskVideoInputInit() 
{ 
     
    int status;     
    SEEDVPM642_vCapParamsChan.segId = EXTERNALHEAP ;//EXTERNALHEAP; 
    SEEDVPM642_vCapParamsTVP5150.hI2C = SEEDVPM642_I2C_hI2C; /*打开驱动程序*/   
 
	/******************************************************/ 
    /* initialization of capture driver                   */ 
    /******************************************************/ 
	/*打开第一通路*/ 
	capChanCh1  = FVID_create(	"/VP1ACAPTURE/A/1",  
            				    IOM_INPUT,  
            				    &status,  
            				    (Ptr)&SEEDVPM642_vCapParamsChan,  
            				    NULL);   	 
    /******************************************************/ 
    /* configure video encoder 			                  */ 
    /******************************************************/ 
    /*配置第一通路的TVP5150*/ 
    FVID_control( capChanCh1,  
    			  VPORT_CMD_EDC_BASE+EDC_CONFIG,  
        		  (Ptr)&SEEDVPM642_vCapParamsTVP5150);	 
 
 
} 
 
 
/*-----------------------------------------------------------*/ 
/*Start the capturing                                        */ 
/*-----------------------------------------------------------*/ 
void tskVideoInputStart()  
{ 
	FVID_control(capChanCh1, VPORT_CMD_START, NULL); 
} 
 
 
/*-----------------------------------------------------------*/ 
/* handle video capture, scaling and re-format               */ 
/*-----------------------------------------------------------*/ 
void tskVideoInput() 
{ 
    SCOM_Handle fromInputtoProc,fromProctoInput; 
    char *outBuf[3]; 
    char *inBuf[3]; 
     
    fromInputtoProc = SCOM_open("INTOPROC"); 
    fromProctoInput = SCOM_open("PROCTOIN"); 
 
	FVID_alloc(capChanCh1, &capFrameBuf); 
 
 	while(1) 
 	{	 
 		inBuf[0]  = capFrameBuf->frame.iFrm.y1; 
        inBuf[1]  = capFrameBuf->frame.iFrm.cb1; 
        inBuf[2]  = capFrameBuf->frame.iFrm.cr1; 
 
        outBuf[0] =  (char *)(&InData[0]); 
        outBuf[1] =  (char *)(&InData[0x65400]); 
        outBuf[2] =  (char *)(&InData[0x7E900]); 
 
        yuv422to420(inBuf,outBuf, 720, 576); 
	 	MsgInput.bufChannel = &InData[0]; 
        /*-----------------------------------------------------------*/ 
	   	/* Send message to process task with pointers to captured frame*/ 
	   	/*-----------------------------------------------------------*/ 
        SCOM_putMsg(fromInputtoProc, &MsgInput); 
	 
		/*-----------------------------------------------------------*/ 
	   	/* Wait for the message from the process task                */ 
	   	/*-----------------------------------------------------------*/ 
        SCOM_getMsg(fromProctoInput, SYS_FOREVER); 
        	 
        /*-----------------------------------------------------------*/ 
        /* Capture a new frame.                                      */ 
        /*-----------------------------------------------------------*/ 
       	FVID_exchange(capChanCh1, &capFrameBuf); 
	 	 
	 }	     
}