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

📄 l1_system.c

📁 dz3000_51.0.0.4.rar
💻 C
📖 第 1 页 / 共 4 页
字号:
/********************************************************************************
  Copyright (c) 2001 Sunplus Technology Co., Ltd.
  Module Name:  l1_system.c
  Function   :  Level-1 function
  Environment:  Keil C51 Compiler
  Creation   :  2001/10/25 Max Hsu
***********************************************************************************/

//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "main.h"
//#include "badcoor.h"
#include "aviheader.h"
#include "sensor.h"
#include "storage.h"
#include "dosusr.h"
#include "option.h"
#include "cardlink.h"
#include "image.h"
#include "sdramhw.h"
#include "quantdef.h"
#include "uiflow.h"

#include "timer.h"
//patch3.2@ada@0401 For Multi-Frame Play Back
#include "initio.h"
#include "dosvar.h"

//richie@si0426
#include "sidcinit.h"
//andrew@patch4.3@0606
#include "previewadjust.h"
#include "ui.h"
//Joe@2003.2.25 10:11 add begin
#include "JoeToEvb.h"
//Joe@2003.2.25 10:11 add end
//=============================================================================
//Symbol
//=============================================================================
//-----------------------------------------------------------------------------
//Constant
//-----------------------------------------------------------------------------
//patch4.3@richie@ra0603 begin
//Preview

//patch4.3@richie@ra0603 end
//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
//version4.0 richie@ps0503
xdata	USHORT	G_usPostJpegWidth = 320;
xdata	USHORT	G_usPostJpegHeight = 240;

//patch4.4.1@richie@noncompress
xdata	UCHAR	G_ucNonCompFlag;

//pathc4.3@richie@zo0608 begin
sfr MemStretch = 0x8E;
xdata UCHAR G_ucZoomFactor =10;
//patch5.0@richie@sdram mapping
//patch4.5@richie@smooth zoom begin
xdata USHORT G_usZoomX = 0;
//patch4.5@richie@smooth zoom end
//pathc4.3@richie@zo0608 end
extern xdata ULONG G_AutoTimeInSec;
extern xdata UCHAR isFirstRun;
//=============================================================================
//Program
//=============================================================================
//-----------------------------------------------------------------------------
//L1_InitSPCA533
//-----------------------------------------------------------------------------
/*
routine description:
		Initialization of the SPCA533 chip in various operation mode
arguments:
 		cammode	- 0: power-on initialization
 				  1: preview mode initialization
  				  2: DSC mode
  				  3: VideoClip mode
  				  4: PC-camera mode
 				  5: Playback mode
return value:
		0x00	- success
		0x01	- module 'GLOBAL' initialization error
		0x02	- module 'CPU'    initialization error
		0x03	- module 'SDRAM'  initialization error
		0x04	- module 'FRONT'  initialization error
		0x05	- module 'LCDTV'  initialization error
		0x06	- module 'Audio'  initialization error
*/

//version4.0@andrew@0513

UCHAR L1_InitSPCA533(UCHAR CamMode) USING_0
{
	UCHAR error;

	error=0;

        //PRINT_L1("        L1_InitSPCA533: Enter.\n");
        //The following are platform independent initialization
	//implemented by L2 functions
	if(!L2_InitGlobal(CamMode)) error = 0x01;
	if(!L2_InitCPU(CamMode))	error = 0x02;
	if(!L2_InitSDRAM(CamMode))	error = 0x03;
   	if(!L2_InitFront(CamMode))	error = 0x04;
	if(!L2_InitCDSP(CamMode))	error = 0x05;
 	if(!L2_InitLCDTV(CamMode))	error = 0x06;
//	if(!L2_InitAudio(CamMode))	error = 0x07;
	if(!L2_InitUSB(CamMode))	error = 0x08;

#if AAA_OPTION
       // andrew
	if(!L2_InitAEAW(CamMode))	error = 0x09;
#endif
	L2_SetCamMode(CamMode);

	//richie@ae0226
	if(!L2_InitCustom(CamMode))     error = 0x0A;

	//PRINT_L1("        L1_InitSPCA533: Exit.\n");

	return error;
}


//-----------------------------------------------------------------------------
//L1_InitPreview
//-----------------------------------------------------------------------------
// Preview mode related settings those are not handled by L2_InitXXX
//
// 1. Noremal  preview:
// 2. X2 digital zoom preview

void L1_InitPreview(UCHAR OnOff) USING_0
//patch5.03@Joe@2003.4.16 13:55 modify end
{
        USHORT postCdspWidth, postCdspHeight;
        //patch4.4@yichang@for valid signal begin
        UCHAR i;
        //patch4.4@yichang@for valid signal end

        //printf ("    L1_initPreview (initialization): Enter.\n");

        //version4.0@yichang@0513
        XBYTE[0x21a6] = 0;      // disable color brightness/contrast boost
	//patch4.5@richie@hue
  	XBYTE[0x21ac] &= 0xFE; 			// disable color saturation boost

	//patch5.03@Joe@2003.4.16 13:56 add begin
	if(OnOff > 0)
	{
		//Joe@2003.2.24 16:06 add begin
		L2_TurnOnOffDisplay(0);
		//Joe@2003.2.24 16:07 add end
	}
	//patch5.03@Joe@2003.4.16 13:56 add end

	//patch5.04@Joe@2003.5.14 9:40 mask begin
	/*
        //patch4.4@yichang@for valid signal begin
        while(((XBYTE[0x2DA0] & 0x04) == 0x04))
        {
                L2_CtrlScreen(2);
        }
        //patch4.4@yichang@for valid signal end
        */
        //patch5.04@Joe@2003.5.14 9:40 mask end
	if((G_KeyState >=K_UI_BUTTON_PLAY_SWITCH &&G_KeyState <0xff) && isFirstRun==0)	//add  for debug
	{}
	else{
		L2_SetDisplayType(G_DisplayType);
		isFirstRun=0;
	}

	  L2_SetCamMode(0);
        L2_SetImageType(1);             //YUV422

        if(G_DisplayType==0)
                L2_SetDisplayMode(1, 1); //enable the frame rate conversion, TV's frame rate is higher
        else
                L2_SetDisplayMode(1, 1); //sensor's frame rate is slower

        L2_SetAFBAddr(K_SDRAM_PreviewBufAddrA);       /* Restore the A-frame buffer address */
        L2_SetBFBAddr(K_SDRAM_PreviewBufAddrB);       /* Restore the B-frame buffer address */

        L2_WaitVD(0, 1);

//patch4.3@richie@ra0603 begin
	//patch4.3@richie@zo begin
	//if(G_PVZFactor==0) //Normal preview
	//{
                postCdspWidth = (G_MHSize - K_Preview_Adjust_Width) - 16;   //16 pixel for H-CDSP
                if(postCdspWidth > (480-16))
                        postCdspWidth = 480-16;

		//patch4.3@richie@zo
                //if(postCdspWidth > G_DSPHsize)
	        //	postCdspWidth = G_DSPHsize;
		#ifdef STNLCD
		postCdspWidth = postCdspWidth - 70;
		#endif

                postCdspHeight = (G_MVSize - K_Preview_Adjust_Height) - 13; //13 line for V-CDSP
                L2_SetFrontImgOffsetm((K_Preview_Adjust_Width >> 2) << 1, (K_Preview_Adjust_Height >> 2) << 1);
                L2_SetFrontImgSizem(G_MHSize - K_Preview_Adjust_Width, G_MVSize - K_Preview_Adjust_Height);
//patch5.0@richie@sdram mapping begin
		//patch4.5@richie@view range (remove '+ 16' of second parameter)
                L2_SetCDSPScale(G_MHSize - K_Preview_Adjust_Width, postCdspWidth);
		//printf("postCdspWidth = %d,postCdspHeight = %d\n",postCdspWidth,postCdspHeight);
//patch5.0@richie@sdram mapping end
                //PRINT_L1("        Normal preview\n");
        //}
	/*
   	else  //X2 digital zoom
	{
                postCdspWidth = (G_MHSize - K_Preview_Adjust_Width) >> 1;          //16 pixel for H-CDSP
                if(postCdspWidth > (480-16))
                        postCdspWidth = 480-16;

                if(postCdspWidth > G_DSPHsize)
                        postCdspWidth = G_DSPHsize;

                postCdspHeight = (G_MVSize - K_Preview_Adjust_Height) >> 1;         //13 line for V-CDSP
                L2_SetFrontImgOffsetm(((G_MHSize - (K_Preview_Adjust_Width >> 1)) >> 3) << 1, ((G_MVSize - (K_Preview_Adjust_Height >> 1)) >> 3) << 1);
                L2_SetFrontImgSizem(((G_MHSize - K_Preview_Adjust_Width) >> 1) + 16, ((G_MVSize - K_Preview_Adjust_Height) >> 1) + 13);
                L2_SetCDSPScale(((G_MHSize - K_Preview_Adjust_Width) >> 1) + 16, postCdspWidth + 16);
                //PRINT_L1("       2X preview\n");
	}
	*/
	//patch4.3@richie@zo end

//patch4.3@richie@ra0603 end

        /*
        if(G_PVZFactor==0) //Normal preview
	{
                postCdspWidth = 336 - 16;       //16 pixel for H-CDSP
                postCdspHeight = G_MVSize - 13; //13 line for V-CDSP
                L2_SetFrontImgOffsetm(0, 0);
                L2_SetFrontImgSizem(G_MHSize, G_MVSize);
                L2_SetCDSPScale(G_MHSize, postCdspWidth + 16);
                //PRINT_L1("        Normal preview\n");
        }
   	else  //X2 digital zoom
	{
                postCdspWidth = G_MHSize >> 1;          //16 pixel for H-CDSP
                postCdspHeight = G_MVSize >> 1;         //13 line for V-CDSP
                L2_SetFrontImgOffsetm((G_MHSize >> 3) << 1, (G_MVSize >> 3) << 1);
                L2_SetFrontImgSizem((G_MHSize >> 1) + 16, (G_MVSize >> 1) + 13);
                L2_SetCDSPScale((G_MHSize >> 1) + 16, postCdspWidth + 16);
                //PRINT_L1("       2X preview\n");
	}
        */
        L2_SetACDSPWidth(postCdspWidth);
        L2_SetBCDSPWidth(postCdspWidth);
        L2_SetRCDSPWidth(postCdspWidth);
        L2_SetAFBSize(postCdspWidth, postCdspHeight);
        L2_SetBFBSize(postCdspWidth, postCdspHeight);
	//patch4.3@richie@zo marked
        //L2_SetDisplaySrcImgSize(postCdspWidth, postCdspHeight, G_DisplayType);
	//patch4.3@richie@zo
	L1_DisplayZoomIn(G_ucZoomFactor);

	//patch4.2@yichang@0520 for fix version4.1 bug of turning off display
	//L2_TurnOnOffDisplay(1);
	if ((XBYTE[0x2B00] & 0x01) == 0x00)
        {
        	L2_SetCMOSPreview();   //set the CMOS sensor back to decimation mode
                L2_WaitVD(0, 1);
        }

        L1_InitSPCA533(1);

        //patch4.4@yichang@for valid signal begin
        for(i=0;i<100;i++)
//                DELAY_1ms();//wendy@2004/8/14
		DELAY_10ms();

        //patch5.04@Joe@2003.5.14 9:41 mask begin
        /*
        while(((XBYTE[0x2DA0] & 0x04) == 0x04))
        {
                L2_CtrlScreen(1);
        }
        */
        //patch5.04@Joe@2003.5.14 9:41 mask end
        //patch4.4@yichang@for valid signal end

        //patch4.2@yichang@0520 for fix version4.1 bug of turning off display

        //patch5.03@Joe@2003.4.16 13:57 add begin
        if (OnOff > 0)
        	L2_TurnOnOffDisplay(1);
        //patch5.03@Joe@2003.4.16 13:57 add end

        //PRINT_L1("    L1_InitPreview: Exit.\n");
}



//-----------------------------------------------------------------------------
//L1_InitPCCam
//-----------------------------------------------------------------------------
//PC-CAM mode related settings those are not handled by L2_InitXXX
void L1_InitPCCam(void) USING_0
{
        UCHAR revid;

//version4.0 richie@ps0503
        //USHORT postJpegWidth;
        //USHORT postJpegHeight;

//version4.0 richie@ps0503
	//G_usPostJpegWidth = 320;
        //G_usPostJpegHeight = 240;

//patch4.5@yichang@badpixel begin
#if (NANDF_OPTION == 1 && CARD_OPTION == 1)
        //Reading badpixel coordinate for sub-sample mode
        UCHAR blockNum, startBlock, pageNum, pageCnt;
        ULONG addr;
        USHORT badx, bady, tmp;
        USHORT i;
        USHORT offsetx, offsety;
	//UI_SensorPowerOnOff(1);//hx@test
        startBlock = 0;
        blockNum = 1;
        pageNum = 14;
        pageCnt = 2;
        offsetx = 45;
        offsety = 7;
//patch5.0@richie@sdram mapping begin
	for(i=startBlock;i<(blockNum + startBlock);i++)
        {
               addr =  (K_SDRAM_PreviewBufAddrB + K_SDRAM_PreviewBufSizeB) + (ULONG)(i-startBlock)*(G_Card_BlockSize/2);
	       NANDF_AccessReserveBlock(K_NANDF_Reserve_FlashToDram, i, pageNum, pageCnt,addr );

        }

        L2_SetSRAMDMA(0x0C00);
        L2_SetDRAMDMA(K_SDRAM_PreviewBufAddrB + K_SDRAM_PreviewBufSizeB);
        L2_DoDMA(0,1,1024,0,0);
//patch5.0@richie@sdram mapping end
        badx = bady = 0;
        L2_SetCDSPBadPixelMode(2);

        for(i=0;i<256;i++)
        {
                badx = XBYTE[0x1c00+i*4];
                tmp = (USHORT)(XBYTE[0x1c00+i*4+1] << 8);
                badx = tmp + badx;

                bady = XBYTE[0x1c00+i*4+2];
                tmp = (USHORT)(XBYTE[0x1c00+i*4+3] << 8);
                bady = tmp + bady;

⌨️ 快捷键说明

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