📄 initio.c
字号:
/*++
Copyright (c) 2001 Sunplus Technology Co., Ltd.
Module Name:
initio.c
Abstract:
Module related to chip initialization
Environment:
Keil C51 Compiler
Revision History:
08/28/2001 Chi-Yeh Tsai created
--*/
//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "sensor.h"
#include "lcdtv.h"
#include "initio.h"
#include "main.h"
#include "quantdef.h"
#include "storage.h"
#include "bulkout.h"
#include "usbmsdc2.h"
#include "usbsidc.h"
#include "pima.h"
#include "ui.h"
#include "power.h"
#include "setmode.h"
#include "sdram.h"
#include "ctlsetup.h"
#include "cardlink.h"
#include "infodata.h"
#include "audio.h"
#include "image.h"
#include "quant.h"
// WWW1
#include "exifhdr.h"
#include "exiffunc.h" //ada@0222
#include "exifvar.h" //ada@0222
#include "timer.h"
#include "uiflow.h"
#include "playback.h"
//version4.0@ada@0513 for Card Write Protect
#include "cardusr.h"
//patch4.2@richie@ds0503
#include "dramfunc.h"
//patch4.3@andrewl@0606
#include "l1_3a.h"
//patch4.5@yichang@badpixel begin
#include "dosvar.h"
//patch4.5@richie@vender info begin
#include "scsistr.h"
/*
extern code UCHAR K_ScsiVendorInformation[];
extern code UCHAR K_ScsiProductIdentification[];
extern code UCHAR K_ScsiProductRevisionLevel[];
*/
//patch4.5@richie@vender info end
//patch4.5@yichang@badpixel end
extern unsigned char G_OLD_PICTURE_WB_Flag; ///hx@2003,4.14 add for old picture
extern xdata UCHAR G_FlashStatus;
extern xdata UCHAR old_Audeokey;//wendy@2004/8/28
//=============================================================================
//Symbol
//=============================================================================
void INITIO_StorageInitialize(void);
//-----------------------------------------------------------------------------
//Constant
//-----------------------------------------------------------------------------
code UCHAR Text_ResetDateTime[] = //ada@0222
{
0x30,0x30,0x30,0x30,0x3a,0x30,0x30,0x3a,0x30,0x30,
// 0 0 0 0 : 0 0 : 0 0
0x20,0x30,0x30,0x3a,0x30,0x30,0x3a,0x30,0x30,0x00
// 0 0 : 0 0 : 0 0 null
};
//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
xdata UCHAR G_ucSensorType;
xdata UCHAR G_ucSensorSize;
xdata UCHAR G_ucDscIndex;
xdata UCHAR G_ucClipIndex;
xdata UCHAR G_ucPccameraIndex; //cch
xdata UCHAR G_ucDscIndexMax;
xdata UCHAR G_ucClipIndexMax;
xdata UCHAR G_ucPccameraIndexMax; //cch@10/15
xdata UCHAR PlaybackFlag;//wendy@2004/9/8
//patch5.0@richie@avi size begin
xdata USHORT G_usVideoClip_Width;
xdata USHORT G_usVideoClip_Height;
//patch5.0@richie@avi size end
//patch4.3@yichang@0611 for version B/C chip co-exist
sfr MemStretch = 0x8E;
sbit PWR_DET = P3^4;
//version4.0 richie@ps0503
extern xdata USHORT G_usPostJpegWidth;
extern xdata USHORT G_usPostJpegHeight;
extern xdata UCHAR G_KeepPressPowerOn;
//version4.3@richie@zo
extern xdata UCHAR G_ucZoomFactor;
//patch5.0@richie@sdram mapping
//patch4.5@richie@smooth zoom begin
extern xdata USHORT G_usZoomX;
//patch4.5@richie@smooth zoom end
extern xdata USHORT G_usZoomOSDTimer;
//patch4.4.1@richie@noncompress
extern xdata UCHAR G_ucNonCompFlag;
//patch4.4.1@richie@noncompress
//herb for TVoutput debug @03/04/18 start
extern xdata UCHAR avi_play;
extern xdata UCHAR SmallSizeAvi;
//herb for TVoutput debug @03/04/18 end
//herb for Playback bug @03/04/21 start
extern xdata UCHAR reset_display;
//herb for Playback bug @03/04/21 end
//Joe@2003.2.19 15:09 begin
#include "JoeToEvb.h"
#define K_CUSTOMER_FIRMWARE_VERSION ((USHORT)0x0504) // 1.0.0
extern xdata USHORT G_AutoTimeInSec;
void L2_TurnOnOffDisplayFrist(void);//wendy@2004/3/17
//Joe@2003.2.19 15:09 end
//=============================================================================
//Program
//=============================================================================
//-----------------------------------------------------------------------------
//INITIO_BadPixel
//-----------------------------------------------------------------------------
//patch4.5@yichang@badpixel begin
#if (NANDF_OPTION == 1 && CARD_OPTION == 1)
void INITIO_BadPixel(void) USING_0
{
UCHAR blockNum, startBlock, pageNum, pageCnt;
ULONG addr;
USHORT i;
//Reading badpixel coordinate to K_SDRAM_BadPixelCoordBufAddr for full-frame mode
startBlock = 0;
blockNum = 1;
pageNum = 0;
//pageCnt = 14; //7K
pageCnt = (UCHAR)((ULONG)K_SDRAM_BadPixelCoordBufSize/(ULONG)256);
//printf("pageCnt=%bx\n",pageCnt);
for(i=startBlock;i<(blockNum + startBlock);i++)
{
addr = K_SDRAM_BadPixelCoordBufAddr + (ULONG)(i-startBlock)*(G_Card_BlockSize/2);
NANDF_AccessReserveBlock(K_NANDF_Reserve_FlashToDram, i, pageNum, pageCnt,addr );
}
}
#endif
//patch4.5@yichang@badpixel end
extern void OB_ModeKeyOnLeft(void);
void INITIO_OBAdjust(void)
{
UCHAR isSel=0,isUp=0;
GET_SELKEY(isSel);
GET_UPKEY(isUp);
if(isSel && isUp)
OB_ModeKeyOnLeft();
}
//-----------------------------------------------------------------------------
//INITIO_Initialize
//-----------------------------------------------------------------------------
//patch3.2@ada@0401 For Date & Time Update
void ChangeTable(int);//patch4.4@jhyu@50/60HzTable
xdata UCHAR isFirstRun;
extern xdata int EV12_index;
void INITIO_Initialize(void) USING_0
/*++
Routine Description:
initialize system
Arguments:
none
Return Value:
none
--*/
{
//Joe@2003.2.27 16:04 add begin
UCHAR temp_key;
// UCHAR version[9];
UCHAR FOSD_H_num, FOSD_V_num;
//Joe@2003.2.27 16:04 add end
INIT_RS232;
// DbgPrint("INITIO_Initialize: Enter\n");
//Joe@2003.2.19 add 15:08 begin
UI_InitialGPIO(); //GPIO initialization
/* close for Davis:patch1.01
//davis2004/11/26 add for reset LCD begin
L2_SetGPIOBit(15,1); //LCD_BACKLIGHT
DELAY_100ms();
L2_SetGPIOBit(15,0); //LCD_BACKLIGHT
//davis2004/11/26 add for reset LCD end------------------------
//*/
//UI_PowerOnOffDetect(1);
// UI_Buzzer();
UI_SensorPowerOnOff(1);
L2_SetGPIOBit(16,1);//Davis:patch3.01 open
L2_TurnOnOffDisplayFrist();
L2_CtrlScreen(1);//wendy@2004/9/8
UI_ClearFOSD(25, 8, 0x08);
L2_SetGPIOBit(15,0); //LCD_BACKLIGHT
//DELAY_1s();
//DELAY_1s();
//Joe@2003.2.19 add 15:08 end
INITIO_GlobalInitialize();
//DbgPrint("INITIO_Initialize: Global variables initialization OK\n");
L1_InitPowerOn();
//DbgPrint("INITIO_Initialize: L1_InitPowerOn OK\n");
UI_LCDReset();//wendy@2004/9/24
if (PWR_DET == 0)
{
L2_SetGPIOBit(14,1); //Go on the following program
G_KeepPressPowerOn = 1;
UI_BusyLed(1);
}
//Joe@2003.2.27 16:06 add begin
FOSDtoDRAM(K_FOSD_Start_Bank, K_FOSD_Total_Bank, K_SDRAM_CharFontBufAddr);
GOSDtoDRAM(K_GRAFFONT_Width, K_GRAFFONT_Height, K_GOSD_Start_Bank, K_GOSD_Total_Bank, K_SDRAM_GrafFontBufAddr);
UI_GetFOSDSize(&FOSD_H_num, &FOSD_V_num);
//patch5.04@Joe@2003.5.13 20:21 add begin
// L2_SetFOSDIndex(FOSD_V_num/2,FOSD_H_num/2-1,0x3a);
// L2_SetFOSDAttr(FOSD_V_num/2,FOSD_H_num/2-1, UI_MENU_BG_COLOR_ON | UI_MENU_TITLE_TEXT_COLOR);
// L2_SetFOSDIndex(FOSD_V_num/2,FOSD_H_num/2,0x3b);
// L2_SetFOSDAttr(FOSD_V_num/2,FOSD_H_num/2, UI_MENU_BG_COLOR_ON | UI_MENU_TITLE_TEXT_COLOR);
isFirstRun=1;
EV12_index=0x30;//Davis:patch3.10 add for outdoor indoor value
L1_InitPlayback();
UI_SetMenuPalette();
L2_SetColorPalette(1, 0, 0, 0);
//DELAY_1s();
//CopySunplusIcon();
//L2_CtrlScreen(1);
//DELAY_1s();
// set the displayed address and size
L2_SetBFBAddr(K_SDRAM_ImagePlaybackDisplayBufAddr);
L2_SetBFBSize(G_DSPHsize,G_DSPVsize);
// set display buffer index is equal to B frame buffer index
L2_SetDisplayMode(0x00, 0x10);
//UI_PreviewInit();
//L2_TurnOnOffDisplayFrist();
//L2_TurnOnOffDisplay1(1);
//richie@0109 swap
//ClearScreen;
L2_CtrlScreen(1);//wendy@2004/9/8
UI_ClearFOSD(25, 8, 0x08);
UI_PrintOSDString("Please Wait...", FOSD_H_num/2-6, FOSD_V_num/2, UI_MENU_BG_COLOR_ON | UI_MENU_TITLE_TEXT_COLOR);
DELAY_1s();
L2_SetGPIOBit(15,1); //LCD_BACKLIGHT
INITIO_CpuInitialize();
// DbgPrint("INITIO_Initialize: INITIO_CpuInitialize OK\n");
INITIO_UsbInitialize();
//DbgPrint("INITIO_Initialize: INITIO_UsbInitialize OK\n");
INITIO_DramInitialize();
// DbgPrint("INITIO_Initialize: INITIO_DramInitialize OK\n");
//patch4.2@ada@0527 for q table
//INITIO_JpegInitialize(K_Qxx);
INITIO_JpegInitialize();
//DbgPrint("INITIO_Initialize: INITIO_JpegInitialize OK\n");
// L2_TurnOnOffDisplay(1);
INITIO_StorageInitialize();
DbgPrint("INITIO_Initialize: INITIO_StorageInitialize OK\n");
SENSOR_Initialize();
DbgPrint("INITIO_Initialize: SENSOR_Initialize OK\n");
UI_Initialize();
DbgPrint("INITIO_Initialize: UI_Initialize OK\n");
#if (AUDIO_OPTION == 1)
AUDIO_Initialize();
DbgPrint("INITIO_Initialize: AUDIO_Initialize OK\n");
#endif
#if (POWER_OPTION == 1)
POWER_Initialize();
DbgPrint("INITIO_Initialize: POWER_Initialize OK\n");
#endif
INITIO_GetProductInfo();
DbgPrint("INITIO_Initialize: INITIO_GetProductInfo OK\n");
//Joe@2003.2.27 16:32 add begin
UI_Read_NAND_UiParameters();
//Joe@2003.2.27 16:32 add end
INITIO_OBAdjust();//Davis:patch4.0.0.4_2005/Jun/30 add
//Joe@2003.2.27 16:36 add begin
//Dectec USB pluging
#if (TURNKEY_OPTION == 1)
L2_ConfigGPIOBit(18,0);
L2_GetGPIOBit(18,&temp_key);
#else
L2_ConfigGPIOBit(1,0);
L2_GetGPIOBit(1,&temp_key);
#endif
if (temp_key == 0)
{
G_UI_USBConnect = K_UI_USB_CONNECT;
L2_SetGPIOBit(14,0); //Power off
}
else
{
G_UI_USBConnect = K_UI_USB_DISCONNECT;
}
#if(ROTARY_OPTION == 1)
switch(UI_Get_Hardware_Keypad2())
{
case K_RotarySwitchMode0:
G_KeyState = K_UI_BUTTON_PREVIEW_SWITCH;
break;
case K_RotarySwitchMode2:
G_KeyState = K_UI_BUTTON_PLAY_SWITCH;
break;
default: //unknown mode for future use
G_KeyState = K_UI_BUTTON_PREVIEW_SWITCH;
break;
}
#endif
//-------------------Davis:patch_2005/Apr/09 begin
G_KeyState = K_UI_BUTTON_PREVIEW_SWITCH;
//-------------------Davis:patch_2005/Apr/09 end
if (G_UI_USBConnect == K_UI_USB_CONNECT)
{
G_KeyState = K_UI_BUTTON_PCCAM_SWITCH; // lqf@05/05/23,add
UI_SendMessage(G_KeyState, K_UI_GPIO_USB_KEYPRESS);
UI_BusyLed(1);
UI_UsbDPlusPullHigh(1); //Pull high resistor on D+ is on
TIMER0_Stop();
G_Timer0StopFlag = 1;
}
else
{
UI_SendMessage(G_KeyState, K_UI_GPIO_KEYPRESS);
UI_BusyLed(0);
UI_UsbDPlusPullHigh(0); //Pull high resistor on D+ is on
TIMER0_Start();
G_Timer0StopFlag = 0;
}
//Joe@2003.2.27 16:38 add end
//ada@0401 For Date & Time Update
// USR_UpdateRtcTime();
//Joe@2003.2.27 16:47 mask begin
//ada@0415 test ui
//TIMER0_Start();
//Joe@2003.2.27 16:47 mask end
//Joe@2003.2.27 16:47 mask begin
//yichang@patch4.3@0611
//L1_InitPlayback();
//Joe@2003.2.27 16:47 mask end
//Joe@2003.2.27 16:33 mask begin
/*
//Load 2 banks of font-based OSD data
FOSDtoDRAM(K_FOSD_Start_Bank, K_FOSD_Total_Bank, K_SDRAM_CharFontBufAddr);
//Load 3 banks of graphic-based OSD data
GOSDtoDRAM(K_GRAFFONT_Width, K_GRAFFONT_Height, K_GOSD_Start_Bank, K_GOSD_Total_Bank, K_SDRAM_GrafFontBufAddr);
*/
//Joe@2003.2.27 16:33 mask end
//patch4.4@yichang@badpixel begin
#if (NANDF_OPTION == 1 && CARD_OPTION == 1)
INITIO_BadPixel();
#endif
//patch4.4@yichang@badpixel end
DbgPrint("INITIO_Initialize: Exit\n");
}
//-----------------------------------------------------------------------------
//INITIO_DisplayInitialize
//-----------------------------------------------------------------------------
void INITIO_DisplayInitialize(void) USING_0
{
UCHAR tmp;
//patch4.3@yichang@0611 for version B/C chip co-exist
tmp = MemStretch;
MemStretch = 0x01;
//patch4.1@yichang@0517 for no-STNLCD->TV out
XBYTE[0x2D20] = 0x40;
MemStretch = tmp;
//yichang@0503 for different display device
switch(G_DisplayType)
{
case K_DISPLAY_CompTvNtsc:
case K_DISPLAY_Ccir656Ntsc:
case K_DISPLAY_Ccir601Ntsc8:
case K_DISPLAY_Ccir601Ntsc16:
case K_DISPLAY_Tc015Treb1: //patch5.2.1@cwh@Toppoly TC015TREB1; add G_DisplayType == 17 option
G_DSPHsize = K_DISPLAY_TvNtscWidth;
G_DSPVsize = K_DISPLAY_TvNtscHeight;
G_TmbWidth = K_TmbTvNtscNineWidth;
G_TmbHeight = K_TmbTvNtscNineHeight;
G_TmbHGap = K_TmbTvNtscXGap;
G_TmbVGap = K_TmbTvNtscYGap;
break;
case K_DISPLAY_CompTvPal:
case K_DISPLAY_Ccir656Pal:
case K_DISPLAY_Ccir601Pal8:
case K_DISPLAY_Ccir601Pal16:
G_DSPHsize = K_DISPLAY_TvPalWidth;
G_DSPVsize = K_DISPLAY_TvPalHeight;
G_TmbWidth = K_TmbTvPalNineWidth;
G_TmbHeight = K_TmbTvPalNineHeight;
G_TmbHGap = K_TmbTvPalXGap;
G_TmbVGap = K_TmbTvPalYGap;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -