📄 testpattern.c
字号:
/*
$Workfile: testpattern.c $
$Revision: 1.29 $
$Date: Aug 23 2006 23:21:40 $
*/
//******************************************************************
//
// 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: testpattern.c
//
// USAGE : This module contains TestPattern Handler and related functions
//
//************************************************************************
#include "math.h"
#include "inc\all.h"
#define DEBUG_PATTERN 0
#if DEBUG_PATTERN && DEBUG_MSG
#define msg(a,b) gm_Print((const char far *)a,b)
#else
#define msg(a,b)
#endif
#if USE_TEST_PATTERN
BYTE B_DisableTestPattern = 0;
BYTE B_BypassSave;
BYTE SoftPowerReInitforTestPattern=1;
//local define
typedef struct TestPatternStatusFlag
{
WORD IsPatternStarted : 1;
WORD IsPatternEnded : 1;
} PatternFlagsType;
//testpattern table - max 16 patterns
#ifndef RSDS_PANEL
BYTE ROM TestPatternTable[]=
{
0x31,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,
0x26,0x8f,0x8f,0x8f,
0x29,0x00,0x00,0x00,
0x31,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,
0x26,0x8f,0x8f,0x8f,
0x29,0x00,0x00,0x00,
0x31,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,
0x26,0x8f,0x8f,0x8f,
0x29,0x00,0x00,0x00,
0x31,0x00,0x00,0x00,
0x34,0x00,0x00,0x00,
0x26,0x8f,0x8f,0x8f,
0x29,0x00,0x00,0x00,
};
#else
BYTE ROM TestPatternTable[]=
{
0x7f,0x20,0x7f,0x00,
0x00,0x00,0xff,0x00,
0x00,0xff,0x00,0x00,
0x00,0xff,0xff,0x00,
0xff,0x00,0x00,0x00,
0xff,0x00,0xff,0x00,
0xff,0xff,0x00,0x00,
0xff,0xff,0xff,0x00,
0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0x00,
0x00,0xff,0x00,0x00,
0x00,0xff,0xff,0x00,
0xff,0x00,0x00,0x00,
0xff,0x00,0xff,0x00,
0xff,0xff,0x00,0x00,
0xff,0xff,0xff,0x00,
};
#endif
// global variables used in this file.
static PatternFlagsType PatternFlag;
static BYTE patternIndex = 0;
static DWORD lastTime = 0;
// functions used only in this file .
static __near StartCondition (void);
static BYTE __near EndCondition (void);
static void __near RestoreRegValuesAfterSourceFreeRun(void);
void TestPattern_Handler (void)
{
StartCondition();
// if the start condition is present
if (SystemFlags.TestPatternRunning)
{
if(PatternFlag.IsPatternStarted && SoftPowerReInitforTestPattern)
{
SoftPowerReInitforTestPattern=0;
gm_SetDisplayFreeRunMode();
#ifndef RSDS_PANEL
gm_SetSrcFreeRunMode();
gm_WriteRegWord(SRC_VTOTAL, 0x00);
#endif
//PDR:9600
// assuming there could be an active signal on the analog port, set
// the sync detection to the opposite of what is detected. Othwerwise
// the SDDS will be effected by the active sync.
if(InputPortSyncArray[gmvb_CurrentPortMain].B_SyncType == gmd_DSS_SYNC)
gm_SetRegBitsByte(CSYNC_CONTROL, CSYNC_EN);
}
// while the end condition is not present
if(labs(gm_ReadSystemTime() - lastTime) < (PatternTransitionTime*1000))
{
return;
}
#ifdef PHOENIX_U
if(gm_ReadRegByte(ADC_CONTROL) & SOG_EN)
gm_ClearRegBitsByte(ADC_CONTROL, SOG_EN); //Fixed blanking issue when swith to testpattern from Video/component port.
if(gm_ReadRegByte(DISPLAY_CONTROL1) & 0x01)
gm_WriteRegByte(DISPLAY_CONTROL1, 0x00);
//While PWRUP_CTRL is set to 0x10 or 0x11, sometimes it will cause testpattern display blanking.
//As a result, let's just turn it off during Test Pattern display mode.
gm_ClearRegBitsByte(DVI_CONFIG, PWRUP_CTRL);
//In shrink mode, IPV_ACT_LENGTH/WIDTH are modified, we should change it back to correct value during test pattern mode.
gm_WriteRegWord(IPV_ACT_LENGTH, PanelHeight);
gm_WriteRegWord(IPH_ACT_WIDTH, PanelWidth);
#endif
msg("time %d",(WORD)labs(gm_ReadSystemTime() - lastTime));
lastTime = gm_ReadSystemTime();
#ifndef RSDS_PANEL
msg("index = %d",patternIndex);
gm_WriteRegByte(PATGEN_CONTROL, TestPatternTable[patternIndex++]);
gm_WriteRegByte(PATGEN_BLUE, TestPatternTable[patternIndex++]);
gm_WriteRegByte(PATGEN_GRN, TestPatternTable[patternIndex++]);
gm_WriteRegByte(PATGEN_RED, TestPatternTable[patternIndex++]);
#else
gm_WriteRegByte(BKGND_RED, TestPatternTable[patternIndex++]);
gm_WriteRegByte(BKGND_GRN, TestPatternTable[patternIndex++]);
gm_WriteRegByte(BKGND_BLU, TestPatternTable[patternIndex++]);
patternIndex++;//dummy increase to reuse the same array structure
#endif
//to update programmed registers
gm_ForceUpdate();
if(patternIndex>=MaxNoOfPatterns*4)
{
patternIndex = 0;
}
} // if(SystemFlags.TestPatternRunning)
else
{
if(EndCondition() == gmd_TRUE)
{
//save testpattern end status in NVRAM
UserPrefTestPatternStatus = 0;
SaveModeIndependentSettings();
GlobalVariablesInit();
#ifndef RSDS_PANEL
gm_WriteRegByte(PATGEN_CONTROL, 0); // Disable PatGen on exit
#else
gm_WriteRegByte(BKGND_RED, 0x00);
gm_WriteRegByte(BKGND_GRN, 0x00);
gm_WriteRegByte(BKGND_BLU, 0x00);
#endif
//restore the reg values after src free run while exiting Aging mode
RestoreRegValuesAfterSourceFreeRun();
//force mode change
gm_ForceModeSwitching();
}
}
}
static __near StartCondition (void)
{
if(SystemFlags.TestPatternRunning || UserPrefTestPatternStatus)
{
if(!PatternFlag.IsPatternStarted)
{
msg("Enter START CONDITION: UserPrefTestPatternStatus=%d", UserPrefTestPatternStatus);
//reset pattern index
patternIndex = 0;
lastTime = 0;
B_BypassSave=gm_ReadRegByte(BYPASS);
//setup free run
//SDDS_INIT_FREQ is modified during modesetup when display on.
//If SDDS_INIT_FREQ is modified to very high frequency,
//it results in very high SDDS frequency during SDDS OPEN LOOP enable.
//In the case, it causes flicker in Test Pattern.
//So, we change back SDDS_INITIAL_FREQ back to initialization value.
gm_WriteRegDWord(SDDS_INITIAL_FREQ, SDDS_INIT_FREQ_VAL),
gm_SetDisplayFreeRunMode();
#ifndef RSDS_PANEL
gm_SetSrcFreeRunMode();
gm_WriteRegWord(SRC_VTOTAL, 0x00);
#endif
// assuming there could be an active signal on the analog port, set
// the sync detection to the opposite of what is detected. Othwerwise
// the SDDS will be effected by the active sync.
if(InputPortSyncArray[gmvb_CurrentPortMain].B_SyncType == gmd_DSS_SYNC)
gm_SetRegBitsByte(CSYNC_CONTROL, CSYNC_EN);
//save testpattern start status in NVRAM
UserPrefTestPatternStatus = 1;
SaveModeIndependentSettings();
//reset flag
PatternFlag.IsPatternStarted = 1;
PatternFlag.IsPatternEnded = 0;
if(UserPrefTestPatternStatus)
{// if starting from NVRAM, assume it's by key.
SystemFlags.TestPatternRunning = gmd_TRUE;
SystemFlags.TestPatternActiveFromKey = gmd_TRUE;
// on power up, OSD in default state. Sending a MTO_MODE_CHANGE
// will trigger the OE_AnyEvent that's in the default state
// to check the TestPatternRunning flag and to goto the
// TestPatternAging state.
SendMsg(&OsdQ, MTO_MODE_CHANGE);
}
}
}
return;
}
static BYTE __near EndCondition (void)
{
if((!PatternFlag.IsPatternEnded) && PatternFlag.IsPatternStarted)
{
msg("END CONDITION: ",0);
PatternFlag.IsPatternEnded = 1;
PatternFlag.IsPatternStarted = 0;
UserPrefTestPatternStatus = 0;
return gmd_TRUE;
}
else
return gmd_FALSE;
}
static void __near RestoreRegValuesAfterSourceFreeRun(void)
{
//SRC_VTOTAL, to clear value
gm_WriteRegWord(SRC_VTOTAL, 0x00);
//CLOCK_CONFIG, to change DP_CLKSEL only
gm_SetRegBitsByte(CLOCK_CONFIG, DP_CLK_DCLK);
//IP_CONTROL, to set ADC as default input
gm_WriteRegByte(IP_CONTROL, IP_SOURCE_RGB | IP_RUN_EN);
//DDS_CONTROL, to clear
gm_ClearRegBitsByte(DDS_CONTROL, FORCE_SDDS_OPLOOP);
//BYPASS, reset to normal
gm_WriteRegByte(BYPASS, B_BypassSave);
gm_WriteRegByte(CSYNC_CONTROL, HSRAW_DIS);
gm_WriteRegWord(IPH_ACT_START, IPHS_ActiveStart);
gm_WriteRegWord(IPV_ACT_START_ODD, IPVS_ActiveStart);
//disable display to avoid the screen glitch problem.
// gm_ClearRegBitsByte(OP_ENABLE, DDATA_EN);
// turn current port back on.
InitModeHandler();
}
//******************************************************************
// DESCRIPTION : Toggle InternalTestPatterns flag,
// Usually, this function should be called by when using keypad
// to invoke internal test pattern
// SYNTEX : void InternalTestPatterns(void)
// PARAMETERS : none
// RETURN : None
//******************************************************************
void InternalTestPatterns(void)
{
SystemFlags.TestPatternRunning = !(SystemFlags.TestPatternRunning);
SystemFlags.TestPatternActiveFromKey = 1;
msg("Toggle InternalTestPattern: SystemFlags.TestPatternRunning = 0x%x",SystemFlags.TestPatternRunning);
}
//******************************************************************
// DESCRIPTION : EnableTestPatterns, call this function when using non-keypad
// events such as NoSync, NoCable to invoke internal test pattern.
// SYNTEX : void EnableTestPatterns(void)
// PARAMETERS : none
// RETURN : None
//******************************************************************
void EnableTestPatterns(void)
{
SystemFlags.TestPatternRunning = gmd_TRUE;
SystemFlags.TestPatternActiveFromKey = 0;
msg("Enable InternalTestPattern: SystemFlags.TestPatternRunning=0x%x",SystemFlags.TestPatternRunning);
}
//******************************************************************
// DESCRIPTION : DisableTestPatterns, call this function to disable internal test pattern
// SYNTEX : void DisableTestPatterns(void)
// PARAMETERS : none
// RETURN : None
//******************************************************************
void DisableTestPatterns(void)
{
SystemFlags.TestPatternRunning = gmd_FALSE;
msg("Disable InternalTestPattern: SystemFlags.TestPatternRunning=0x%x",SystemFlags.TestPatternRunning);
}
#else
// tabbed OSD calls InternalTestPatterns, so to save having to recompile the
// WB project, provide a dummy stub here when USE_TEST_PATTERN is disabled.
BYTE B_DisableTestPattern = 1;
void InternalTestPatterns(void)
{
//SystemFlags.TestPatternActiveFromKey = 1;
SystemFlags.TestPatternRunning = gmd_FALSE;
}
#endif // USE_TEST_PATTERN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -