📄 scaler.c
字号:
//----------------------------------------------------------------------------------------------------
// ID Code : Scaler.c No.0003
// Update Note :
//
//----------------------------------------------------------------------------------------------------
#define __SCALER__
#include "Core\Header\Include.h"
//--------------------------------------------------
// Description : Get bytes from selected register in data port
// Input Value : ucAddr --> Access Port Address of register
// ucValue --> Data Port Address we want to Get
// ucLength --> Numbers of data we want to read
// pArray --> Pointer of the reading data array
// bAutoInc --> Address auto increasing select
// Output Value : None
//--------------------------------------------------
#if(_HDCP_SUPPORT == _ON)
void CScalerGetDataPortByte(BYTE ucAddr, BYTE ucValue, BYTE ucLength, BYTE *pArray, BIT bAutoInc)
{
if(ucLength > 0)
{
if((ucAddr == _SU_ACCESS_PORT_33) || (ucAddr == _HW_ACCESS_PORT_60)
|| (ucAddr == _CB_ACCESS_PORT_64) || (ucAddr == _PC_ACCESS_PORT_9A))
{
CScalerSetByte(ucAddr, 0x80);
ucValue = ucValue | 0x80;
}
CScalerSetByte(ucAddr, ucValue);
CScalerRead( ucAddr + 1, ucLength, pArray, bAutoInc);
}
}
#endif
//--------------------------------------------------
// Description : Initial settings for scaler
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CScalerInitial(void)
{
// Software reset for scaler
CScalerSetBit(_HOST_CTRL_01, ~_BIT0, _BIT0);
CTimerDelayXms(20);
CScalerSetBit(_HOST_CTRL_01, ~_BIT0, 0x00);
CScalerCodeW(tSCALER_POWERUP_INITIAL);
#if (_HDMI_SUPPORT == _ON)
CScalerCodeW(tSCALER_POWERUP_HDMI);
#else
CScalerCodeW(tSCALER_POWERUP_DVI);
#endif
CScalerReset();
#if(_HDCP_SUPPORT == _ON)
//bHPD = 0;//Hot Plug Detect Pull LOW
bHot_Plug = 1;//bHot_Plug = 0;
CAdjustHDCP();//HDCP1.0 for DVI
//bHPD = 1;//Hot Plug Detect Pull HIGH
CTimerDelayXms(100);//20070714 gary for HDMI compatibility problem
bHot_Plug = 0;//bHot_Plug = 1;
CTimerDelayXms(100);//CTimerDelayXms(1000);
#endif
//Alanli20070801###
}
//--------------------------------------------------
// Description : Reset scaler process
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CScalerReset(void)
{
CScalerCodeW(tSCALER_RESET_TABLE);
/*
CScalerCodeW(tSCALER_POWERUP_INITIAL);
#if (_HDMI_SUPPORT == _ON)
//if(CHdmiFormatDetect())//Input source is the HDMI format.
CScalerCodeW(tSCALER_POWERUP_HDMI);
//else//DVI
#else
CScalerCodeW(tSCALER_POWERUP_DVI);
#endif */
CMiscSetPinShare();
CAdjustDisableWatchDog(_WD_ALL);
CMiscClearStatusRegister();
CScalerInitialDisplayInterface();
CScalerInitialDisplayOutput();
CModeSetFreeRun();
if(GET_POWERSTATUS())
{
CScalerEnableDisplayOutput();
// OSD power up initial
CScalerCodeW(tOSD_POWERUP_INITIAL);
CAdjustTMDSErrorCorrectionOn();
//CAdjustColorPalette(tPALETTE_0);
COsdColorPalette(tPALETTE_0);
//CAdjustSRGB();
#if(_GAMMA_TYPE == _COMPACT_GAMMA_NORMAL_TABLE)
CAdjustGamma(_COMPACT_GAMMA_NORMAL_TABLE, tGAMMA_COMPACT1, tGAMMA_COMPACT1, tGAMMA_COMPACT1);
#elif(_GAMMA_TYPE == _FULL_GAMMA_NORMAL_TABLE)||(_GAMMA_TYPE == _FULL_GAMMA_COMPRESS_TABLE2)
CAdjustGammaTable(GET_GAMMA());
#endif
if(GET_18BIT_EN() == _DISP_18_BIT)
CAdjustDither(tDITHER_SEQ_TABLE_0, tDITHER_TABLE_10_TO_6);
else if(GET_18BIT_EN() == _DISP_24_BIT)
CAdjustDither(tDITHER_SEQ_TABLE_0, tDITHER_TABLE_10_TO_8);
CScalerSetBit(_IPH_ACT_WID_H_16, ~(_BIT6 | _BIT5 | _BIT4), 0x00);
//if(GET_INPUTSOURCE_TYPE() == _SOURCE_VGA)
// CScalerSetBit(_IPH_ACT_WID_H_16, ~(_BIT6 | _BIT5 | _BIT4), ((_ADC0_INPUT_SWAP_RG << 4) | (_ADC0_INPUT_SWAP_RB << 5)| (_ADC0_INPUT_SWAP_GB << 6)));
//else if(GET_INPUTSOURCE_TYPE() == _SOURCE_YPBPR)
// CScalerSetBit(_IPH_ACT_WID_H_16, ~(_BIT6 | _BIT5 | _BIT4), ((_ADC1_INPUT_SWAP_RG << 4) | (_ADC1_INPUT_SWAP_RB << 5)| (_ADC1_INPUT_SWAP_GB << 6)));
CAdjustBrightness();
CAdjustContrast();
// Load HDMI EDID to Chip
#if(0)//_HDMI_EDID == _ON)
CScalerPageSelect(_PAGE2);
CScalerSetBit(_P2_HDCP_PORT_CTRL_C2, ~_BIT1, 0x00);
CScalerCodeW(tHDMI_EDID_DATA);
#endif
#if(_OD_SUPPORT == _ON)
CMemoryLoadODLUT(_OD_TABLE_COMMON);
CMemorySDRAMReset();
#endif
}
else
{
CPowerDPLLOff();
//CScalerSetByte(_HOST_CTRL_01, 0x42);//731301
CScalerSetBit(_HOST_CTRL_01, ~_BIT1,(_BIT4 | _BIT1)); //V307 modify//731301
CScalerDisableDisplayOutput();
}
}
//--------------------------------------------------
// Description : Initial display interface for TTL, LVDS and RSDS
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CScalerInitialDisplayInterface(void)
{
BYTE ucLVDSMapTemp;
CScalerSetByte(_TCON_ADDR_PORT_8B, _TCON_LVDS_CTRL3_A3);
CScalerRead(_TCON_DATA_PORT_8C, 1, &ucLVDSMapTemp, _NON_AUTOINC);
ucLVDSMapTemp &= 0xFE;
if (!GET_LVDS_MAP()) // MAP2
ucLVDSMapTemp |= 0x01;
switch(GET_PNL_OUTPUT_BUS())
{
case _PANEL_TTL:
CScalerCodeW(tTTL_INITIAL);
break;
case _PANEL_LVDS:
CScalerCodeW(tLVDS_INITIAL);
break;
case _PANEL_RSDS:
CScalerCodeW(tLVDS_INITIAL);
CScalerCodeW(tRSDS_INITIAL);
//CScalerSetByte(_TCON_ADDR_PORT_8B, 0x02);
//CScalerSetByte(_TCON_DATA_PORT_8C, 0x40 | ((Panel[ucPanelSelect]->PanelStyle & 0xE0) >> 5));
//CScalerSetBit(_DISP_TIMING_46, ~_BIT0, _BIT0);
break;
}
// Set LVDS MAP
CScalerSetByte(_TCON_ADDR_PORT_8B, _TCON_LVDS_CTRL3_A3);
CScalerSetByte(_TCON_DATA_PORT_8C, ucLVDSMapTemp);
}
//--------------------------------------------------
// Description : Initial display output from Panel.h settings
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CScalerInitialDisplayOutput(void)
{
// Display signal control settings
BYTE ucTemp = 0x00;
if(GET_18BIT_EN() == _DISP_18_BIT)
{
ucTemp |= _BIT4;
}
if(GET_DOUBLE_PORT_EN() == _DISP_DOUBLE_PORT)
{
ucTemp |= _BIT2;
}
CScalerSetBit(_VDISP_CTRL_28, ~(_BIT4 | _BIT2), ucTemp);
CScalerSetByte(_VDISP_SIGINV_29, Panel[ucPanelSelect]->PanelConfig & (~_BIT3));
}
//--------------------------------------------------
// Description : Enable display output
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CScalerEnableDisplayOutput(void)
{
CScalerSetBit(_VDISP_CTRL_28, ~(_BIT6 | _BIT1), _BIT1);
CScalerSetBit(_VDISP_CTRL_28, ~_BIT0, _BIT0);
CScalerSetBit(_VDISP_CTRL_28, ~_BIT7, _BIT7);
CScalerSetBit(_VDISP_CTRL_28, ~_BIT7, 0x00);
}
//--------------------------------------------------
// Description : Disable display output
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CScalerDisableDisplayOutput(void)
{
if(GET_PNL_OUTPUT_BUS() == _PANEL_TTL)
{
CScalerSetBit(_VDISP_SIGINV_29, ~(_BIT2 | _BIT1 | _BIT0), 0x00);
}
CScalerSetBit(_VDISP_CTRL_28, ~(_BIT6 | _BIT1), _BIT6);
CScalerSetBit(_VDISP_CTRL_28, ~_BIT0, 0x00);
}
#if(_NONLINEAR_SCALING)
//--------------------------------------------------
// Description : Disable Nonlinear scale up function
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CScalerDisableNonlinearScaleUp(void)
{
((DWORD*) pData)[0] = 0; //Disable non linear scale up first
CScalerSetByte(_SU_ACCESS_PORT_33, 0x8c);
CScalerSetByte(_SU_ACCESS_PORT_33, 0x8c);
CScalerWrite(_SU_DATA_PORT_34, 4, pData, _NON_AUTOINC);
CScalerSetByte(_SU_ACCESS_PORT_33, 0x00);
}
//--------------------------------------------------
// Description : Disable Nonlinear scale down function
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CScalerDisableNonlinearScaleDown(void)
{
CScalerSetBit(_SCALE_DOWN_CTRL_23, 0xf7, 0x00);//disable non-linear scale down
}
//--------------------------------------------------
// Description : Progress the Nonlinear scale up
// Input Value :
// Option : Indicate whether scale up be acyivate now
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -