⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 601cman.c

📁 视频601芯片的驱动源码,你可以完全掌控该芯片了,对于其它多媒体芯片的设计具有参考价值
💻 C
📖 第 1 页 / 共 4 页
字号:
/*------------------------------------------------------------------------

$Workfile: 601CMAN.C $
$Date: 6/20/97 3:44p $
$Revision: 51 $
* Purpose:	
*			This module contains all the API calls needed to interface 
*			with the VxD to perform specific tasks like video capture  
*			and playback.
* Notes:       
*
*
$History: 601CMAN.C $
 * 
 * *****************  Version 51  *****************
 * User: Stevel       Date: 6/20/97    Time: 3:44p
 * Updated in $/601cman
 * Add VxD error report variable for 601test.
 * Add support to turn Blue Screen Err report on/off.
 * 
 * *****************  Version 50  *****************
 * User: Stevel       Date: 4/18/97    Time: 1:18p
 * Updated in $/601cman
 * Add a new function VideoIoConfig().
 * 
 * *****************  Version 49  *****************
 * User: Stevel       Date: 1/14/97    Time: 11:55a
 * Updated in $/601cman
 * Make the new reentry checking compatible with old application.
 * 
 * *****************  Version 48  *****************
 * User: Stevel       Date: 1/10/97    Time: 6:23p
 * Updated in $/601cman
 * Export DLL version string for 601test.
 * 
 * *****************  Version 47  *****************
 * User: Stevel       Date: 1/07/97    Time: 6:28p
 * Updated in $/601cman
 * Add code to prevent multiple applications sharing the same VxD.
 * 
 * *****************  Version 46  *****************
 * User: Stevel       Date: 12/12/96   Time: 12:57p
 * Updated in $/601cman
 * Add code to make sure the current directory is always pointing to the
 * installed Videolab Bin Directory before loading in the BW config. file.
 * 
 * *****************  Version 45  *****************
 * User: Stevel       Date: 12/11/96   Time: 6:59p
 * Updated in $/601cman
 * Add Application to driver interface for Scene Detection.
 * 
 * *****************  Version 44  *****************
 * User: Stevel       Date: 12/11/96   Time: 3:12p
 * Updated in $/601cman
 * Add support to enable/disable Scene Change.
 * 
 * *****************  Version 43  *****************
 * User: Stevel       Date: 12/10/96   Time: 6:33p
 * Updated in $/601cman
 * Add debug code
 * 
 * *****************  Version 42  *****************
 * User: Stevel       Date: 12/10/96   Time: 4:41p
 * Updated in $/601cman
 * Add code to support Special Effect and Scene Detection
 * 
 * *****************  Version 41  *****************
 * User: Az           Date: 12/10/96   Time: 1:37p
 * Updated in $/601cman
 * Undone the previous change.
 * 
 * *****************  Version 40  *****************
 * User: Az           Date: 12/10/96   Time: 1:34p
 * Updated in $/601cman
 * Temporary change for debugging: scene detection flag is 
 * set to 1 in "init" structure for BWC. In future this will be done
 * through user graphic interface.
 * 
 * *****************  Version 39  *****************
 * User: Stevel       Date: 12/06/96   Time: 9:19a
 * Updated in $/601cman
 * Fix a bug in BWCalculation(). The Actual Bpp was calculated wrong by
 * using the frame width instead of field width.
 * 
 * *****************  Version 38  *****************
 * User: Stevel       Date: 12/03/96   Time: 3:46p
 * Updated in $/601cman
 * Add code to report field size to the B.W. calculator.
 * 
 * *****************  Version 37  *****************
 * User: Dstarr       Date: 10/25/96   Time: 1:47p
 * Updated in $/601cman
 * Put bits per pixel into the dsp compression ratio register so the DSP
 * can see it.
 * 
 * *****************  Version 36  *****************
 * User: Stevel       Date: 10/18/96   Time: 4:09p
 * Updated in $/601cman
 * Minor code change.
 * 
 * *****************  Version 35  *****************
 * User: Stevel       Date: 10/18/96   Time: 3:47p
 * Updated in $/601cman
 * Modify Capture API to config BWC from BW.CFG file.
 * 
 * *****************  Version 34  *****************
 * User: Stevel       Date: 8/26/96    Time: 2:10p
 * Updated in $/601cman
 * Ninor change in the Stop() function.
 * 
 * *****************  Version 33  *****************
 * User: Stevel       Date: 8/24/96    Time: 6:55p
 * Updated in $/601cman
 * Add VITC support.
 * 
 * *****************  Version 32  *****************
 * User: Stevel       Date: 7/29/96    Time: 4:57p
 * Updated in $/601cman
 * Get rid of RGB constant in BashBoard().
 * 
 * *****************  Version 31  *****************
 * User: Stevel       Date: 7/29/96    Time: 2:43p
 * Updated in $/601cman
 * Fix the bug of using the wrong constant RGB_OUT in BashBoard().
 * 
 * *****************  Version 30  *****************
 * User: Stevel       Date: 7/25/96    Time: 8:04p
 * Updated in $/601cman
 * Minor changes in VideoIOConfig() and BashBoard() to support RGB video
 * output.
 * 
 * *****************  Version 29  *****************
 * User: Stevel       Date: 7/24/96    Time: 8:43p
 * Updated in $/601cman
 * Minor code change for FF and REW.
 * 
 * *****************  Version 28  *****************
 * User: Stevel       Date: 7/15/96    Time: 11:30a
 * Updated in $/601cman
 * Modidify all the memory capture/playback, file capture/playback, color
 * ramp diag functions to return a full error report structure.
 * This structure is defined in "601error.h".
 * 
 * *****************  Version 27  *****************
 * User: Stevel       Date: 7/11/96    Time: 6:03p
 * Updated in $/601cman
 * Minor changes to support PAUSE.
 * 
 * *****************  Version 26  *****************
 * User: Stevel       Date: 7/09/96    Time: 1:41p
 * Updated in $/601cman
 * Add code to support Rewind.
 * 
 * *****************  Version 25  *****************
 * User: Stevel       Date: 7/06/96    Time: 4:30p
 * Updated in $/601cman
 * Modify to support  Fast Forward and Rewind.
 * 
 * *****************  Version 24  *****************
 * User: Stevel       Date: 7/02/96    Time: 9:20p
 * Updated in $/601cman
 * Fix B.W. calculation counter reset problem during playback.
 * 
 * *****************  Version 23  *****************
 * User: Stevel       Date: 7/02/96    Time: 12:39p
 * Updated in $/601cman
 * Add a new function to report the run time status during capture and
 * playback.
 * 
 * *****************  Version 22  *****************
 * User: Dstarr       Date: 7/01/96    Time: 9:21a
 * Updated in $/601cman
 * Support Cropping registers, conditional out a test function, remove
 * some unused variable to get a clean compile.
 * 
 * 
 * *****************  Version 21  *****************
 * User: Stevel       Date: 6/23/96    Time: 9:23p
 * Updated in $/601cman
 * Add changes to support run time Bin Width Calculation.
 * 
 * *****************  Version 20  *****************
 * User: Stevel       Date: 6/06/96    Time: 1:48p
 * Updated in $/601cman
 * Modify functions to support new wavelet_init function.
 * 
 * *****************  Version 19  *****************
 * User: Stevel       Date: 5/17/96    Time: 5:21p
 * Updated in $/601cman
 * Demo version.
 * 
 * *****************  Version 18  *****************
 * User: Stevel       Date: 5/10/96    Time: 10:40a
 * Updated in $/601cman
 * Add new parameters to ColorRampDiag(), MemCaptureDiag(),
 * MemPlayBackDiag().
 * 
 * *****************  Version 17  *****************
 * User: Stevel       Date: 5/04/96    Time: 7:49p
 * Updated in $/601cman
 * Add 2 second delay in Capture() routine to make file capture work
 * better !
 * 
 * *****************  Version 16  *****************
 * User: Dstarr       Date: 5/03/96    Time: 4:12p
 * Updated in $/601cman
 * Digital Video Support
 * 
 * *****************  Version 15  *****************
 * User: Stevel       Date: 4/30/96    Time: 7:29p
 * Updated in $/601cman
 * Add a new TimeOut function.
 * Initialize CapVideo structure in HwConfig4Diag().
 * 
 * *****************  Version 14  *****************
 * User: Stevel       Date: 4/26/96    Time: 6:25p
 * Updated in $/601cman
 * Fix a bug in HWConfig4Diag().
 * 
 * *****************  Version 13  *****************
 * User: Stevel       Date: 4/20/96    Time: 11:24a
 * Updated in $/601cman
 * Add B.W. init. in MemCaptureDiag().
 * 
 * *****************  Version 12  *****************
 * User: Stevel       Date: 4/15/96    Time: 7:42p
 * Updated in $/601cman
 * Add a new function GerBuildDriverInfo() to export the time and date
 * stamp of the VxD and DLL.
 * 
 * *****************  Version 11  *****************
 * User: Stevel       Date: 4/14/96    Time: 5:28p
 * Updated in $/601cman
 * Add a new API to load compress data into host memory for decode.
 * 
 * *****************  Version 10  *****************
 * User: Stevel       Date: 4/10/96    Time: 3:38p
 * Updated in $/601cman
 * Add new function HwConfig4Diag() for 601test.
 * 
 * *****************  Version 9  *****************
 * User: Stevel       Date: 4/09/96    Time: 7:34p
 * Updated in $/601cman
 * Program the right H.W. setup for Color Ramp, Memory Capture/Playback
 * diagnostic test. 
 * 
 * *****************  Version 8  *****************
 * User: Stevel       Date: 4/05/96    Time: 6:39p
 * Updated in $/601cman
 * Fix a bug in HwConfig() to program the ADV601 HW reset.
 * 
 * *****************  Version 7  *****************
 * User: Stevel       Date: 3/26/96    Time: 3:39p
 * Updated in $/601cman
 * 
 * *****************  Version 6  *****************
 * User: Stevel       Date: 3/22/96    Time: 3:41p
 * Updated in $/601cman
 * Add  Call back function support for Window applications.
 * 
 * *****************  Version 5  *****************
 * User: Dstarr       Date: 3/13/96    Time: 5:23p
 * Updated in $/601cman
 * Checked out in lab.  601test played beauty thru this dll.  Added pragma
 * to supress "inconsistant use of dllimport.  Export assumed" warning.
 * This program never imports and always exports.
 * 
 * *****************  Version 4  *****************
 * User: Stevel       Date: 3/12/96    Time: 2:37p
 * Updated in $/601cman
 * Add DLLEXPORT keyword to export all functions for diagnostic test.
 * Add a new function BashBoard() to setup HW for capture and 
 * playback.
 * 
 * *****************  Version 3  *****************
 * User: Stevel       Date: 3/11/96    Time: 7:24p
 * Updated in $/601cman
 * Minor changes on InitBWCalculator(), SetCaptureCfg() and
 * WriteBWCoeff().
 * Rename ReadBWCoeff() to Read601Statistic()
 * 
 * *****************  Version 1  *****************
 * User: Stevel       Date: 3/06/96    Time: 5:37p
 * Created in $/601cman
 * Initial release

  
    This code and information is provided "as is" without warranty of any
    kind, either expressed or implied, including but not limited to the
    implied warranties of merchantability and/or fitness for a particular
    purpose.
  
    1995 Analog Devices, Inc. 
  
-------------------------------------------------------------------------*/

#include <windows.h>			  
#include <stdio.h>
#include "601error.h"
#include "globsym.h"
#include "vlab.h"
#include "i2c.h"
#include "bw.h"
#include "amcc.h"
#include "adv601.h"
#include "vxdmsg.h"
#include "601cman.h"
#include "saa7111.h"
#include "adv7175.h"
#include "fixedbw.h"
#include "callback.h"
#include "globsym.h"
#include "vitc.h"
#include "bwmod.h"

#pragma warning(disable : 4273)       /*dll export assumed warning.  We are
                                    a dll, we always export and never import */ 


#pragma data_seg(".sdata")
int		LoadDllCnt=0;
#pragma data_seg()


///////////////////////////////////////////////////////////////////////////
// Default Sum of Square values of the Color Bar. This statistic for 
// is used for debuging run time B.W. calculator. By feeding these 
// statistic into the run time B.W. calculator routine "BWCalculation",
// we can make the B.W.Calculator output the same Bin Width Coefficeients
// repeatly ! 
///////////////////////////////////////////////////////////////////////////
unsigned short SumOfSq[NBLOCKS]=
{
	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0003,0x0002,0x0001,0x0000,
	0x0000,0x0000,0x0000,0x0000,0x0000,0x0009,0x0009,0x0004,0x0000,0x0000,
	0x0000,0x0000,0x0000,0x0000,0x0011,0x0017,0x000F,0x0000,0x0000,0x0000,
	0x0000,0x0000,0x0000,0x000B,0x0020,0x0019,0x0000,0x0000,0x0000,0x0736,
	0x014A,0x0197
};
/*
    ADV601 Cropping Registers.  For the start registers = 0 and the
    end registers = 0x3FF, the ADV601 encodes the entire video field,
    which is what 9 out of 10 applications want.  See data sheet pg 24.
    Otherwise, video outside the cropping area should encode as solid
    black.  The DLL init procedure sets these to 0 and 3ff.  Programs can
    modify the values as desired.  Wavelet init() will load what ever it finds
    here into the ADV601.
*/

  int hstart;
  int hend;
  int vstart;
  int vend;
  int dsp_bpp;

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Global Variables 
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CRITICAL_SECTION	gCriticalSection;   // Initialized in DllMain().
int					LoadVxDFlg=0;
EV601 *	*			p601Info;
CapVideoCfg			CapVideo;
byte				Def_FIFO_Thre;
CaptureCfg			CapConfig;

///////////////////////////////////////////////////////////////////////////
// Variables used by Bin Width Calculator
///////////////////////////////////////////////////////////////////////////
BWCinit   			init_rec;
BWCinput  			in_rec;
BWCoutput 			out_rec;

//////////////////////////////////////
// Messages I/O control buffers
//////////////////////////////////////
PVOID				inBuf[1];			// buffer for passing handle to VxD
DWORD				RetInfo[4];			// buffer to receive data from VxD
DWORD				cbBytesReturned;	// count of bytes returned from VxD

//////////////////////////////////////
// PCI config and EV601 Reg. address
//////////////////////////////////////
PCI_INFO*			pPciInfo;
EV601 *				pEV601Info;
AMCC_OP_REGS *		pAmccOpRegs;

//////////////////////////////////////
// Thread serving variable
//////////////////////////////////////
HANDLE 				hThread;
HANDLE				hDevice;
DWORD				BWCcnt=0;
DWORD *				pVitcCode;			// Pointer to update VITC code in
										// ring 0.
DWORD *				pFieldNum;			// Pointer to update fast forward
										// or rewind field # in ring 0.

VITCINFO *			pVITCinfo;			// pointer to VITC info structure
int	*				pBWStatusFlg=NULL;	// Bin width calculator status 
										// flag	pointer from ring 0.

//////////////////////////////////////
// EV601 Registers 
//////////////////////////////////////
DWORD *				pI2CReg;			// pointer to I2C Register.
DWORD *				pInMailBox;			// Incoming Mail Box Register
DWORD *				p601SubAdrReg;		// ADV 601 Sub-Addr Register
DWORD *				p601DataReg;		// ADV 601 Data Register
DWORD *				p601FIFO;			// ADV 601 FIFO
DWORD *				p601IntReg;			// pointer to Interrupt Register.


//////////////////////////////////////
// Timer variable
//////////////////////////////////////
float				time;

//////////////////////////////////////
// Videolab directory
//////////////////////////////////////
char				VLabDir[512] = {"c:\\videolab\\bin"};

//////////////////////////////////////
// System Error Flag
//////////////////////////////////////
DWORD *			p601RTErr;
static	Error	ErrorReport;

//////////////////////////////////////
// Capture/Playback State variable
//////////////////////////////////////
int					CapPlyBkState=S_Stop;	

////////////////////////////////////////////////////
// Imported call back function from the application
////////////////////////////////////////////////////
VITCUPDATEPROC		VitcUpdateCallBack = NULL;
FFUPDATEPROC		FastForwardUpdateCallBack = NULL;
REWUPDATEPROC		RewindUpdateCallBack = NULL;
INTHALTPROC			IntHaltCallBack = NULL;
BWSTATRDYPROC		BwStatRdyCallBack = NULL;

////////////////////////////////////////////////////
// Compile Time and Date 
////////////////////////////////////////////////////
static  char build_date[30] = __DATE__;
static  char build_time[30] = __TIME__;
static  char dll_ver[30] = SZVERSION;
static  char *  dll_build_info[3] = {build_date, build_time, dll_ver};
static  char * * p_vxd_build_info;




//===========================================================================
// Inline funciton
//
// Time Delay
//
//===========================================================================
_inline void TimeOutInSec(word Sec)
{
    dword    t1, t2;

    t1=timeGetTime();
    while(1)
    {
        t2=timeGetTime();
        if ((t2 - t1)/1000 > Sec)
            break;
    }
}

//*********************************************************************************
//							HIGH LEVEL API

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -