📄 26xx-init.c
字号:
/*
$Workfile: 26xx-init.c $
$Revision: 1.15 $
$Date: Sep 28 2005 19:57:32 $
*/
//******************************************************************
//
// Copyright (C) 2002. GENESIS MICROCHIP INC.
// All rights reserved. No part of this program may be reproduced.
//
// Genesis Microchip Corp., 2150 Gold Street
// Alviso, CA 95002 USA
// Genesis Microchip Inc., 165 Commerce Valley Dr. West
// Thornhill, Ontario, Canada, L3T 7V8
//
//================================================================
//
// MODULE: 26xx_init.c
//
//************************************************************************
#include "..\inc\all.h"
BYTE ROM FirmwareVersion[] = "26xx F/W V1.5 REL"; // firmware version string
void InitGM(void);
void InitGamma(void);
void NativeModeTest( void );
extern void far gmi_SetVEDIDHandler(void);
extern gmt_REG_BLOCK ROM SystemInitBlock[];
extern gmt_REG_BLOCK ROM PanelInitBlock[];
extern gmt_REG_BLOCK ROM PanelCommonBlock[];
#define DEBUG_INIT 1
#define DEBUG_INIT_EXTENDED 0
#if DEBUG_MSG && DEBUG_INIT
#define msg(a,b) gm_Print((const char far *)a,b)
#else
#define msg(a,b)
#endif
#if DEBUG_MSG && DEBUG_INIT_EXTENDED
#define msgx(a,b) gm_Print((const char far *)a,b)
#else
#define msgx(a,b)
#endif
//***************************************************************
// GSEL Constant definitions:
//***************************************************************
DWORD ROM gmc_SerialBaudRate= SERIAL_BAUD_RATE;
DWORD ROM gmc_T_CLK_KHZ = T_CLK_KHZ;
DWORD ROM gmc_CPU_CLK_KHZ = CPU_CLK_KHZ;
BYTE ROM gmc_CPU_SPEED = CPU_SPEED;
BYTE ROM gmc_CPU_WaitStates_NS = FLASH_SPEED_NS;
WORD ROM gmc_I2cSclk_Khz = I2C_SPEED;
DWORD ROM gmc_OCM_CLK_POWERDOWN = OCM_CLK_PWRDOWN_KHZ;
WORD ROM gmc_BrightnessPWMPort = BRIGHTNESS_PWM_PORT;
//BYTE ROM gmc_SPI_Clock_Sel = (SPI_DEFAULT_CLOCK_SEL << 4);
BYTE gmc_SPI_Clock_Sel = (SPI_DEFAULT_CLOCK_SEL << 4);
BYTE ROM gmc_ADC_OFFSET2_YUV_MIN_VALUE = 16;
BYTE ROM gmc_ADC_OFFSET2_Y_MAX_VALUE = 235;
BYTE ROM gmc_ADC_OFFSET2_UV_MAX_VALUE = 240;
WORD gmc_PanelWidth;
WORD gmc_PanelHeight;
WORD gmc_PanelVActiveStart;
WORD gmc_PanelVActiveEnd;
BYTE gmc_PanelDepth; // Add for panel array 0401
BYTE ROM gmc_IPHS_ActiveStart = IPHS_ActiveStart;
BYTE ROM gmc_IPVS_ActiveStart = IPVS_ActiveStart;
BYTE gmvb_CurrentPortMain = 0x00;
static void _near InitPanelParameters(void);
#ifdef ZERO_K_MAIN // gives cleaner display sometimes
WORD ROM gmc_EnableKMainOfZero = 1000; // min sclk freq to use ZERO_K_MAIN (units 100KHz) 0=disable feature
#endif
//***************************************************************
// Application Function.
// Prints the software revision and chip ID
//***************************************************************
void PrintVersion(void)
{
msg((const char *)FirmwareVersion,0);
msg(__TIME__" "__DATE__,0);
msg(PanelName,0);
msg("TCLK = %dMHz", T_CLK_MHZ);
msgx("IROM major: %d",gm_ISPGetParameter(gmd_IROM_MAJ_VERSION, NULL_PTR));
msgx("IROM minor: %d",gm_ISPGetParameter(gmd_IROM_MINOR_VERSION, NULL_PTR));
msgx("IROM build: %d",gm_ISPGetParameter(gmd_IROM_BUILDNO, NULL_PTR));
}
void ext_InitDdc2BiIrq(void);
//***************************************************************
// Application Function.
// Initializes System Parameters calling Driver functions.
//***************************************************************
void System_Init(void)
{
DWORD ddsInitFreqValue;
BYTE B_IsIntegrityCheckPassed = gmd_TRUE;
// For lower power consumption, oscillator AGC loop on.
gm_SetRegBitsByte(RCLK_PLL, AGCON);
gm_WriteRegByte(POWER_STATUS, BrownOutLevel);
InitNVRAM();
gm_WriteRegBlock(SystemInitBlock);
#if (NVRAM_USE_FLASH == 0)
// Using I2C NVRAM device
gm_I2cInitSW(5, NVRAM_GPIO_SCL, NVRAM_GPIO_SDA);
#endif
InitPanelParameters();
//Init DDDS_INITIAL_FREQ according to panel resolution
ddsInitFreqValue = (((DWORD)PanelMinHTotal*(DWORD)PanelTypVTotal)*60UL)/1000000UL; //in MHz
ddsInitFreqValue = (ddsInitFreqValue*4096*4096)/RCLK_MHZ;
gm_WriteRegDWord(DDDS_INITIAL_FREQ, ddsInitFreqValue);
gm_SetDisplayFreeRunMode();// quickly put display in free run.
// #if (NVRAM_USE_FLASH == 0)
#if 0 // Do not enable SPI cache anytime. Bug in Rev AA silicon
gm_WriteRegByte(SPI_CACHE_CTRL, SPI_CACHE_EN);
#endif
// Initialize SPI clock to correct frequency
gm_WriteRegByte( SPI_CONTROL, gmc_SPI_Clock_Sel );
// moved CLOCK_CONFIG out of SystemInitBlock so we can set individual bits
// in CLOCK_CONFIG, leaving OCM_CLKSEL undisturbed.
gm_SetRegBitsByte(CLOCK_CONFIG, IP_CLK_RGB | DP_CLK_DCLK);
//Set to maximum ADC sampling BW initially to prevent image is darker after AC power on issue.
gmvw_InputFilter[DEF_CHANNEL] = DEFAULT_FILTER;
// Need to replace to Calibrate ADC
// initialize chip ADC block
#if !(USE_ADC_CALIBRATION_ISR)
gm_AutoADCInitMain();
#endif
#if DEBUG_MSG
// Install the functions that powers Up/Down external devices(except panel)
gm_SetExtDevicesPowerUpMain(ExtPowerUp);
gm_SetExtDevicesPowerDownMain(ExtPowerDown);
#endif
#if USE_ACC_ACM
gm_InitACM(CMFineTableFleshTone, (BYTE const far *)CMIntpTableFleshTone, 0x01);
gm_InitACC(&ACCData);
#endif
#if USE_GAMMA
// initialize RGB output gamma table
InitGamma();
#endif
#if ENABLE_HDCP
HDCP_Init();
#endif
#ifdef _CUSTOMER_D_SPECIFIC_IN_52XX_
// Configure
//1) PWM2 as GPIO13, for Customer D Audio On/Off
//2) PWM1 for customer D Backlight based brightness control
Customer_D_ApplicationInit(); // Defination in customer D's file
#endif
#if defined(NVRAM_BLOCK_IntegrityCheck_WB_Used)
#if USE_NVRAM_INTEGRITY_CHECK
B_IsIntegrityCheckPassed = GetIntegrityCheckSettings();
if(B_IsIntegrityCheckPassed)
msgx("NVRAM integrity check passed", 0);
else
{
msg("NVRAM integrity check not passed", 0);
SaveIntegrityCheckSettings();
}
#else
msg("NVRAM integrity check disabled", 0);
#endif
#endif
#ifdef NVRAM_BLOCK_ColorTemp_WB_Used
InitColorTempSettings(B_IsIntegrityCheckPassed);
#endif
#ifdef UserPrefPowerOnTimes
ReadFactoryDependentSettings();
UserPrefPowerOnTimes++; //to increase time of powered-on
SaveFactoryDependentSettings();
msgx("Factory: MonitorOnTime_offset = %d", MonitorOnTime_offset);
msgx("Factory: BacklightOnTime = 0x%x hours", UserPrefBacklightOnTime);
msgx("Factory: MonitorOnTime = 0x%x hours", UserPrefMonitorOnTime);
msgx("Factory: UserPrefPowerOnTimes = %d time", UserPrefPowerOnTimes);
#endif
InitModeIndependentSettings(B_IsIntegrityCheckPassed);
AdjustAllModeIndependentSettings();
RestoreSystemInfoFromNVRAM(B_IsIntegrityCheckPassed);
InitializePresetModes(B_IsIntegrityCheckPassed);
InitADCCalibrationISR(B_IsIntegrityCheckPassed);
InitModeHandler();
#if DDCCI_CUSTOM_SUPPORT
// customers using non-compliant protocols may write their own
// "ddc2bi" interrupt handler which may be installed by defining
// DDCCI_SUPPORT (see inc\options.h)
ext_InitDdc2BiIrq();
#endif
#if THEFT_DETERRENCE_SUPPORT
DDC2Bi_IsTheftDeterrenceEnable();
#endif
#if USE_VEDID
gmi_SetVEDIDHandler();
#endif // USE_VEDID
// Run keypad scanning from ISR
StartGetKeyISR();
}
//******************************************************************
// FUNCTION : InitPanelParameters
// DESCRIPTION : Panel parameters below have been moved out of SystemInitBlock
// since panel parameters are now run time variables, and can not be
// initiaized with gm_WriteRegBlock routine.
// SYNTEX : void InitPanelParameters(void)
// PARAMETERS : none
// RETURN :
//******************************************************************
static void _near InitPanelParameters(void)
{
gmc_PanelWidth = PanelWidth;
gmc_PanelHeight = PanelHeight;
gmc_PanelVActiveStart = PanelVActiveStart;
gmc_PanelVActiveEnd = PanelVActiveEnd;
#if USING_PANEL_ARRAY
#ifdef PADDRIVE
gm_WriteRegByte(TIMING_CONFIG, PanelDClkDelay);
gm_WriteRegDWord(PADDRIVE, PanelPadDrive);
gm_WriteRegByte(DP_POLARITY, (Panel_Invert_DVS << DVS_INV_SHIFT) | (Panel_Invert_DHS << DHS_INV_SHIFT) | (Panel_Invert_DCLK << DCLK_INV_SHIFT) | (Panel_Invert_DEN << DEN_INV_SHIFT));
#endif
// Set up Display Registers
// program panel power up/down register first before program OP_ENABLE register for powr up.
// otherwise, there is the screen flashing problem
gm_WriteRegWord(PANEL_PWR_UP_T1, PowerUpPanelTiming);
gm_WriteRegWord(PANEL_PWR_DN_T1, PowerDownPanelTiming);
gm_WriteRegByte(OP_ENABLE, POWER_SEQ_EN | DCLK_EN | DCNTL_EN | DDATA_EN);
#ifdef D2PIXWIDE_SHIFT
gm_WriteRegByte(DISPLAY_CONTROL, PanelTwoPixelPerClk << D2PIXWIDE_SHIFT );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -