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

📄 mst705Ȧ

📁 MST705源代码
💻
字号:
#define _POWER_C_

#include "types.h"
#include "board.h"
#include "global.h"
#include "ms_reg.h"
#include "panel.h"
#include "misc.h"
#include "ms_rwreg.h"
#include "mstar.h"
#include "DEBUG.h"
#include "msOsd.h"
#include "Tda7052.h"
#include "devvd.h"
#include "menudef.h"

#define TurnOffOSD		1

void Power_TurnOffPanel(void);
void Power_PowerOffSystem(void);
extern void PanelReversal(BYTE Position);

//=============================================
// Control system power status
// caller : main()
void Power_PowerHandler(void)
{
	if (ForcePowerSavingFlag)
    {
    	Clr_ForcePowerSavingFlag(); // clear force power saving flag
      	if (!PowerSavingFlag)
      	{ printMsg("enter power saving");
      	  Power_PowerOffSystem();
      	}
    }
}

void Power_PowerOnSystem(void)
{
    Power_TurnOffPanel();
    msPowerUp();
    Clr_PowerSavingFlag();

    Set_InputTimingChangeFlag();
    SrcFlags|=SyncLoss;

    Clr_SleepTimeoutFlag();
    g_uwSleepTimeCounter=0;
    g_ucSleepTime=SleepTimeOff;

    Clr_ForcePowerONFlag();
    Clr_EnableONTimeFlag();

#if TV_ENABLE
    if (IsTVInUse())
        Set_ChannelChangFlag();
#endif

    Set_ShowSourceFlag();
    hw_SetTunerOn();
}

void Power_PowerOffSystem(void)
{
	Power_TurnOffPanel();
  	msPowerDown();
  	Set_PowerSavingFlag();
  	Clr_InputTimingChangeFlag();
	Clr_FactoryModeFlag();
  	g_ucOsdCounter=0;
  	g_ucPowerDownCounter=0;

  	Clr_EnableOFFTimeFlag();

  	Clr_SleepTimeoutFlag();
  	g_uwSleepTimeCounter=0;
  	g_ucSleepTime=SleepTimeOff;

  	Clr_OsdTimeoutFlag();

       Clr_ChannelChangFlag();
       #if Enable_Logo_Display
       Clr_DrawLogoFlag();
       ucLogoDisplayCounter=0;
       #endif

 	hw_SetTunerOff();
}

void Power_TurnOnGreenLed(void)
{
	hw_SetGreenLed();
}
void Power_TurnOffGreenLed(void)
{
	hw_ClrGreenLed();
}
void BacklitOn(void)
{
#if (CCFL_FUNCTION)
	BYTE ucBank;
	  ucBank = msReadByte(BK0_00_REGBK);
	msWriteByte(BK0_00_REGBK, REG_BANK4_LVDS_CCFL);
	msWriteByte(BK4_6B, 0x80);
	msWriteByte(BK4_9A, 0xCF);
	
#if CCFL_BURST_MODE
	msWriteByte(BK4_6E, 0x0D);
#else
	msWriteByte(BK4_6E, 0x0C);
#endif
	
	if(!(g_VdInfo.wVideoStatus& VD_VSYNC_50HZ))
		msWriteByte(BK4_AC, 0x61);
	else
		msWriteByte(BK4_AC, 0x81);
	
	//W0481 90
	msWriteByte(BK4_81, 0x90);
	//W0482 90
	msWriteByte(BK4_82, 0x90);
	msWriteByte(BK4_6D, 0x03);	//add
	msWriteByte(BK4_6B, 0x00);
	msWriteByte(BK0_00_REGBK, ucBank);
#else
	hw_SetBlacklit();					// Turn on backlight
#endif
}
void BacklitOff(void)
{
#if (CCFL_FUNCTION)
	BYTE ucBank;
	  ucBank = msReadByte(BK0_00_REGBK);
		msWriteByte(BK0_00_REGBK,REG_BANK4_LVDS_CCFL);
		msWriteByte(BK4_6B, 0x80);
		msWriteByte(BK4_6D, 0x00);
		msWriteByte(BK4_6E, 0x05);
		msWriteByte(BK4_6B, 0x00);
		msWriteByte(BK0_00_REGBK, ucBank);
#else
		hw_ClrBlacklit();					// Turn off panel VDD
#endif
}
void Power_TurnOnPanel(void)
{
    printMsg("Power_TurnOnPanel");
    b_turnonpannelflagbit=1;
#if (PANEL_DIGITAL_TCON||PANEL_ANALOG_TCON)  //LSP2006-5-9
    msWriteByte(BK0_00_REGBK, REG_BANK7_CHIPTOP);
    msWriteByteMask(BK7_09_CHIPTOP, 0x00, 0x30); //Turn STVR/STHL
    msWriteByteMask(BK7_0E_CHIPTOP, 0x00, 0x01); //Turn STVR/STHL
    msWriteByte(BK0_00_REGBK, REG_BANK4_LVDS_CCFL);
    msWriteByte(BK4_27, 0x00); //Turn on VCOMOUT
    msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU);	// Switch to Bank 1 for TCON control
    msWriteByte(BK1_D0_PTC_MODE1, SET_PTC_MODE1);		// Enable TCON
    msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);			// Switch to Bank 0


    #if PANEL_ANALOG_TCON
    msWriteByte(BK0_00_REGBK, REG_BANK7_CHIPTOP);
    msWriteByteMask(BK7_06_CHIPTOP, 0x0F, 0x0F); //Increase VGH/VGL driving
    msWriteByteMask(BK7_0B_CHIPTOP, 0x00, 0x06); //Turn VGH/VGL
    Delay1ms_AGC_Processor(500);  //must delay after turn on VGH/VGL
    #endif
#endif


#if (PANEL_LVDS)
    msWriteByte(BK0_00_REGBK, REG_BANK4_LVDS_CCFL);  // switch to Bank 4
    msWriteByte(BK4_1E, 0x04);
    msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU); // switch to Bank 1
    msWriteByte(BK1_AC_EN_CDAC, 0x01);
#endif

    //Delay1ms(PanelOnTiming1);
    Delay1ms_AGC_Processor(PanelOnTiming1);

    hw_SetPanelPower();

    msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);			// Switch to Bank 0 for data output control
    msWriteByte(BK0_F4_TRISTATE, 0x00);				// Enable data output

    PanelReversal(g_VideoSetting.DOWN);

    //Delay1ms(PanelOnTiming2);
    Delay1ms_AGC_Processor(PanelOnTiming2);

    
    if (g_bInputTimingChangeFlag)
        Power_TurnOffPanel();
    else
    {
		BacklitOn();
        devAudioInputSelect();
        //if(!(g_VdInfo.wVideoStatus& VD_HSYNC_LOCKED))
        if((!(g_VdInfo.wVideoStatus& VD_HSYNC_LOCKED)&&IsVideoPortInUse())||((SyncLossState() || UnsupportedModeFlag)&&IsAnalogPortInUse()))
            SetAudioMute();
        else
        {
            if(!g_VideoSetting.MuteStatus)
            devAudioSetVolume(g_VideoSetting.volume);
        }
    }
}

void Power_TurnOffPanel(void)
{
    printMsg("Power_TurnOffPanel");
    SetAudioMute();
#if TurnOffOSD
    msWriteOSDByte(OSD_01_OSDDBC, 0x00); // disable osd double buffer
    msWriteOSDByte(OSD_0C_IOSDC1, 0);
    //msWriteOSDByte(BK0_01_DBFC, 0x0); // disable double buffer
    //msWriteByte(OCTRL2, msReadByte(OCTRL2)|BLKS_B);
    Delay4us();
#endif

	BacklitOff();
    Delay1ms(PanelOffTiming1);

#if (PANEL_DIGITAL_TCON||PANEL_ANALOG_TCON)
    msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU);			// Switch to Bank 1 for TCON control
    msWriteByte(BK1_D0_PTC_MODE1, (SET_PTC_MODE1&0x7F));		// Disable TCON
#endif

#if (PANEL_LVDS)
    msWriteByte(BK0_00_REGBK, REG_BANK4_LVDS_CCFL);  // switch to Bank 4
    msWriteByte(BK4_1E, 0x02);
    msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU);       // switch to Bank 1
    msWriteByte(BK1_AC_EN_CDAC, 0x00);
#endif

    PanelReversal(g_VideoSetting.DOWN);

    msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);			// Switch to Bank 0 for data output control
    msWriteByte(BK0_F4_TRISTATE, 0x1F);				// Disable data output

    Delay1ms(PanelOffTiming2);
    hw_ClrPanelPower();

#if PANEL_ANALOG_TCON
    msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU);			// Switch to Bank 1 for TCON control
    msWriteByte(BK1_4A, 0x0F);				// Turn off VGL and VGH
    msWriteByte(BK1_4B, 0x4C);
    msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);			// Switch to Bank 0
#endif

#if TurnOffOSD
    msWriteOSDByte(OSD_01_OSDDBC, 0x5); // enable double
#endif

    g_ucSyncMaxStableCounter=150;
}

⌨️ 快捷键说明

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