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

📄 power.c

📁 realtek LCD monitor, TV开发源代码
💻 C
字号:
//**********************************************************************************************************
//  The  Software  is  proprietary,  confidential,  and  valuable to Realtek Semiconductor
//  Corporation  ("Realtek").  All  rights, including but not limited  to  copyrights,
//  patents,  trademarks, trade secrets, mask work rights, and other similar rights and interests,
//  are reserved to Realtek. Without  prior  written  consent  from  Realtek,  copying, reproduction,
//  modification,  distribution,  or  otherwise  is strictly prohibited. The Software  shall  be
//  kept  strictly  in  confidence,  and  shall  not be  disclosed to or otherwise accessed by
//  any third party. @ <2003> - <2008>   The Software is provided "AS IS" without any warranty of any kind,
//  express, implied, statutory or otherwise.
//**********************************************************************************************************
//----------------------------------------------------------------------------------------------------
// ID Code      : Power.c No.0000
// Update Note  :
//----------------------------------------------------------------------------------------------------

#define __POWER__

#include "Common\Header\Include.h"

#if(_SCALER_SERIES_TYPE == _RTD2472D_SERIES)


//--------------------------------------------------
// Description  : Check if the power status changed
// Input Value  : None
// Output Value : Return _TRUE if power status is changed, _FALSE if not
//--------------------------------------------------
bit CPowerHandler(void)
{
    if(GET_POWERSWITCH())
    {
#if(_TOUCH_SENSOR == _ON)
        CKeyBuzzerBeep();
#endif
        CPowerControl();
        CLR_POWERSWITCH();

        return _TRUE;
    }

    return _FALSE;
}

//--------------------------------------------------
// Description  : Execute power up/down process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerControl(void)
{
    CModeResetMode();
    if(GET_POWERSTATUS())       // Power Down Process
    {
        SET_LASTPOWER_STATUS(_OFF);

        LEDG_OFF();
        LEDO_OFF();
        bVOLUME_MUTE = _ON;//ryan 081127 audio
#if(_AUDIO_SUPPORT == _ON)
        CAdjustAudioMute(_ON);
        CAdjustAudioPower(_OFF);
#endif
#if(_TOUCH_SENSOR == _ON)
        CKeyOneTouchSensorLedOff();
#endif
        CLR_POWERSTATUS();
        CPowerPanelOff();
        CPowerADCAPLLOff();
        CPowerLVDSOff();
        CPowerDPLLOff();
        CPowerPWMOff();
        CScalerDisableDisplayTiming();
        CPowerTMDSOff();

#if(_MCU_TYPE == _REALTEK_EMBEDDED)
        CMcuSelectFlashClk(_XTAL_CLK); //yc 20080415
        CTimerDelayXms(10);
#endif

        CPowerM2PLLOff();//cyyeh 20080326
#if((_SCALER_TYPE == _RTD2545LR) || (_SCALER_TYPE == _RTD247xRD) || (_SCALER_TYPE == _RTD248xRD))
        CPowerMPLLOff(); // cyyeh 20080611
#endif

        CScalerPageSelect(_PAGE0);
#if(_MCU_TYPE == _REALTEK_EMBEDDED)
        CScalerSetBit(_P0_ADC_POWER_C6, ~(_BIT6 | _BIT5 | _BIT4 ), _BIT3);//0917 sephinroth
#else
//1126 sephinroth
        CScalerSetBit(_P0_ADC_POWER_C6, ~(_BIT6 | _BIT5 | _BIT4 | _BIT3), 0);
#if(_PCB_TYPE == _RTD2545LR_QISDA_PCB)
        MCU_PIN_SHARE2_FF02         = 0x0E;
#endif

#endif
        CScalerSetByte(_P0_HS_SCHMITT_TRIGGER_CTRL_F4, 0x00);//0917 sephinroth

        CScalerPageSelect(_PAGEB);
        CScalerSetByte(_PB_DP_PWR_CTL_B4,0x00);
        CScalerSetByte(_PB_DP_Z0_CALIBRATION_B6,0x00);
        CScalerSetByte(_PB_DP_RESERVED_01_BB, 0x00); //0917 sephinroth

        CScalerSetByte(_HOST_CTRL_01, 0x46);

    }
    else    // Power Up Process
    {
#if(_PCB_TYPE == _RTD2545LR_QISDA_PCB)
        MCU_PIN_SHARE2_FF02         = 0x1E;
#endif
        SET_POWERSTATUS();
        SET_LASTPOWER_STATUS(_ON);
        CScalerInitial();

#if(_MCU_TYPE == _REALTEK_EMBEDDED)
        MCU_SCA_INF_ADDR_FFF4 = 0x01; //DDC_addr- Host Ctrl
        MCU_SCA_INF_DATA_FFF5 = 0x00; //DDC_data - Disable power-saving mode
        CTimerDelayXms(10);//cyyeh 20080128
        CMcuSelectFlashClk(_FLASH_CLK);
#endif

        CMainUserInitial();

    }

    CEepromSaveGlobalData0();
    CEepromSaveSystemData();

}

//--------------------------------------------------
// Description  : Set panel on process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerPanelOn(void)
{
    if(GET_PANELPOWERSTATUS() == _OFF)
    {
        CPowerPanelPowerOn();
        CTimerDelayXms(_PANEL_POWER_ON_T2);
        CPowerDisplayPortOn();
        CScalerEnableDisplayOutput();
        CTimerDelayXms(_PANEL_POWER_ON_T3);
    }

    CPowerLightPowerOn();
    CMiscClearStatusRegister();
}

//--------------------------------------------------
// Description  : Set panel off process
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerPanelOff(void)
{
    CPowerLightPowerOff();

    CTimerDelayXms(_PANEL_POWER_OFF_T4);
    //     CScalerDisableDisplayOutput();
    CPowerDisplayPortOff();
    CTimerDelayXms(_PANEL_POWER_OFF_T5);
    CPowerPanelPowerOff();

    // The delay below is to prevent from short period between panel OFF and next ON
    CTimerDelayXms(_PANEL_POWER_OFF_T6);
}

//--------------------------------------------------
// Description  : Set panel power on
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerPanelPowerOn(void)
{
    PANELPOWER_UP();
    SET_PANELPOWERSTATUS();
}

//--------------------------------------------------
// Description  : Set panel power off
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerPanelPowerOff(void)
{
    PANELPOWER_DOWN();
    CLR_PANELPOWERSTATUS();
}

//--------------------------------------------------
// Description  : Set backlight power on
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerLightPowerOn(void)
{
    LIGHTPOWER_UP();
    SET_LIGHTPOWERSTATUS();
}

//--------------------------------------------------
// Description  : Set backlight power off
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerLightPowerOff(void)
{
    LIGHTPOWER_DOWN();
    CLR_LIGHTPOWERSTATUS();
}
//--------------------------------------------------
// Description  : Power on display port
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerDisplayPortOn(void)
{

#if((_PANEL_STYLE == _PANEL_TTL) || (_PANEL_STYLE == _PANEL_LVDS))

    CPowerLVDSOn();

#endif


#if(_PANEL_STYLE == _PANEL_RSDS)

    CPowerRSDSOn();

#endif

}

//--------------------------------------------------
// Description  : Power off display port
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerDisplayPortOff(void)
{

#if((_PANEL_STYLE == _PANEL_TTL) || (_PANEL_STYLE == _PANEL_LVDS))

    CPowerLVDSOff();

#endif // End of #if(_PANEL_STYLE == _PANEL_TTL)


#if(_PANEL_STYLE == _PANEL_RSDS)

    CPowerRSDSOff();

#endif // End of #if(_PANEL_STYLE == _PANEL_RSDS)

}


//cyyeh 20080505
//--------------------------------------------------
// Description  : Power on LVDS
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerLVDSOn(void)
{
    if((bit)(_DISP_OUTPUT_PORT))
    {
        CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_LVDS_CTRL0_A0, 0x70);
    }
    else
    {
        //LVDS from even port, if from odd port, the below value should be 0x20
        CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_LVDS_CTRL0_A0, 0x70);
    }

}

//--------------------------------------------------
// Description  : Power off LVDS
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerLVDSOff(void)
{
//cyyeh 20080115
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_LVDS_CTRL0_A0, 0x40);

}




#if(_PANEL_STYLE == _PANEL_RSDS)
//--------------------------------------------------
// Description  : Power on RSDS
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerRSDSOn(void)
{
    CPowerLVDSOn();
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_CTRL0_00, 0xc6);//for 8-bit RSDS panel
    CTimerDelayXms(40);
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_CTRL0_00, 0x86);
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_RSDS_PWR_CTL_C3, 0x03);
   //2007_09_05_Edward
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_LVDS_CTRL0_A0, 0x70);
}

//--------------------------------------------------
// Description  : Power off RSDS
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerRSDSOff(void)
{
    //Issac 2007-01-05
    CPowerLVDSOff();
    CScalerSetBit(_VDISP_CTRL_28, ~_BIT1, _BIT1); // Force HS/VS/DEN/Data to 0
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_RSDS_PWR_CTL_C3, 0x00); //Even,Odd Port Power Off
    CTimerDelayXms(40);
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_CTRL0_00, 0x48); // TTL output 0
    CTimerDelayXms(40);
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_CTRL0_00, 0x42); // Back to HZ

    CScalerSetBit(_VDISP_CTRL_28, ~_BIT1, 0); // Release force
    //2007_09_05_Edward
    CScalerSetDataPortByte(_TCON_ADDR_PORT_8B, _TCON_LVDS_CTRL0_A0, 0x00);
}

#endif // End of #if(_PANEL_STYLE == _PANEL_RSDS)


//--------------------------------------------------
// Description  : Power on ADC and APLL
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerADCAPLLOn(void)
{
    CScalerPageSelect(_PAGE1);
    CScalerSetBit(_P1_PLL_WD_AF, ~_BIT0, 0x00);     // Power up PLL

    CScalerPageSelect(_PAGE0);
    CScalerSetBit(_P0_ADC_POWER_C6, ~(_BIT2 | _BIT1 | _BIT0), (_BIT2 | _BIT1 | _BIT0));    // Power up ADC
}

//--------------------------------------------------
// Description  : Power off ADC and APLL
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerADCAPLLOff(void)
{
    CScalerPageSelect(_PAGE1);
    CScalerSetBit(_P1_PLL_WD_AF, ~_BIT0, _BIT0);     // Power down PLL

    CScalerPageSelect(_PAGE0);
    CScalerSetBit(_P0_ADC_POWER_C6, ~(_BIT2 | _BIT1 | _BIT0), 0x00);    // Power down ADC
}

#if((_TMDS_SUPPORT == _ON) || (_HDMI_SUPPORT == _ON)||(_DP_SUPPORT == _ON))
//--------------------------------------------------
// Description  : Power on TMDS
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerTMDSOn(void)
{
    CScalerSetBit(_SYNC_CTRL_49, ~(_BIT1 | _BIT0), 0x00);
}
#endif

//--------------------------------------------------
// Description  : Power off TMDS
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerTMDSOff(void)
{
    CScalerPageSelect(_PAGE2);
    // V010 Patch Note (41) : Correct the TMDS setting for register definiendum.
    /*
    CScalerSetBit(_P2_Z0_CALIBRATION_CTRL_AC, ~_BIT6, 0x00);
    CScalerSetBit(_P2_TMDS_OUTPUT_CTRL_A6, ~_BIT7, 0x00);
    */
    CScalerSetBit(_P2_Z0_CALIBRATION_CTRL_AC, ~_BIT6, 0x00);
    CScalerSetBit(_P2_TMDS_OUTPUT_CTRL_A6, ~(_BIT7 | _BIT6 | _BIT5 | _BIT4 | _BIT3), 0x00);
}

//--------------------------------------------------
// Description  : Power off DPLL
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerDPLLOff(void)
{
    CScalerPageSelect(_PAGE1);
//Anderson 080125 for New DPLL of 2545LR, 247xRD, 248xRD Start
#if(_SCALER_TYPE == _RTD2472D)
    CScalerSetBit(_P1_DPLL_N_C0, ~_BIT7, _BIT7); // Power down DPLL
#elif((_SCALER_TYPE == _RTD2545LR) || (_SCALER_TYPE == _RTD247xRD) || (_SCALER_TYPE == _RTD248xRD))
    CScalerSetBit(_P1_DPLL_WD_C2, ~_BIT0, _BIT0); // Power down DPLL
#else
    No Setting !!
#endif  // End of #if(_SCALER_TYPE == _RTD2472D)
//Anderson 080125 for New DPLL of 2545LR, 247xRD, 248xRD End
}

//--------------------------------------------------
// Description  : Power on M2PLL
// Input Value  : None
// Output Value : None
//--------------------------------------------------
//V010 Modify 20080916 Start
void CPowerM2PLLOn(void)
{
    CScalerPageSelect(_PAGE1);

#if(_SCALER_TYPE == _RTD2472D)
    CScalerSetBit(_P1_MULTIPLY_PLL_CTRL3_E5, ~_BIT0, _BIT0); // Power up M2PLL
#elif((_SCALER_TYPE == _RTD2545LR) || (_SCALER_TYPE == _RTD247xRD) || (_SCALER_TYPE == _RTD248xRD))
    CScalerSetBit(_P1_M2PLL_WD_E5, ~_BIT0, 0); // Power up M2PLL
#else
   No Setting !!
#endif  // End of #if(_SCALER_TYPE == _RTD2472D)

}
//V010 Modify 20080916 End
//--------------------------------------------------
// Description  : Power off M2PLL
// Input Value  : None
// Output Value : None
//--------------------------------------------------
//cyyeh 20080326
void CPowerM2PLLOff(void)
{
    CScalerPageSelect(_PAGE1);

#if(_SCALER_TYPE == _RTD2472D)
    CScalerSetBit(_P1_MULTIPLY_PLL_CTRL3_E5, ~_BIT0, 0x00); // Power down M2PLL
#elif((_SCALER_TYPE == _RTD2545LR) || (_SCALER_TYPE == _RTD247xRD) || (_SCALER_TYPE == _RTD248xRD))
    CScalerSetBit(_P1_M2PLL_WD_E5, ~_BIT0, _BIT0); // Power down M2PLL
#else
   No Setting !!
#endif  // End of #if(_SCALER_TYPE == _RTD2472D)

}

//cyyeh 20080611
#if((_SCALER_TYPE == _RTD2545LR) || (_SCALER_TYPE == _RTD247xRD) || (_SCALER_TYPE == _RTD248xRD))
//--------------------------------------------------
// Description  : Power off MPLL
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerMPLLOff(void)
{
    CScalerPageSelect(_PAGE0);
    CScalerSetBit(_P0_MPLL_WD_F8,~(_BIT0),_BIT0);
}
#endif //End of if((_SCALER_TYPE == _RTD2545LR) || (_SCALER_TYPE == _RTD247xRD) || (_SCALER_TYPE == _RTD248xRD))

//--------------------------------------------------
// Description  : Power on PWM
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerPWMOn(void)
{
    pData[0] = 0x40;
    pData[1] = 0x02;
    pData[2] = 0x10;
    CScalerWrite(_OSD_ADDR_MSB_90, 3, pData, _AUTOINC);
}

//--------------------------------------------------
// Description  : Power off PWM
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CPowerPWMOff(void)
{
    pData[0] = 0x40;
    pData[1] = 0x02;
    pData[2] = 0x00;
    CScalerWrite(_OSD_ADDR_MSB_90, 3, pData, _AUTOINC);
}


#endif  // End of #if(_SCALER_SERIES_TYPE == _RTD2472D_SERIES)

//Anderson 071219 for 2545LR, 247xRD, 248xRD

⌨️ 快捷键说明

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