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

📄 source.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.                     */
/*   c<2003> - <2008>                                                           */
/*   The Software is provided "AS IS" without any warranty of any kind,         */
/*   express, implied, statutory or otherwise.                                  */
/********************************************************************************/

//----------------------------------------------------------------------------------------------------
// ID Code      : Source.c No.0000
// Update Note  : 
//----------------------------------------------------------------------------------------------------

#define __SOURCE__

#include "Common\Header\Include.h"

#if(_SCALER_SERIES_TYPE == _RTD2472D_SERIES)

// V010 Patch Note (19) : Modify Source Scan Handler.
//--------------------------------------------------
// Description  : Measure Source type
// Input Value  : None
// Output Value : Return _TRUE if succeed
//--------------------------------------------------
bit CSourceHandler(void)
{
    if(GET_INPUTSOURCE_TYPE() == _SOURCE_NONE)
    {
        if(CSourceScanHandler())
        {
//1231 sephinroth
#if(_SCALER_TYPE == _RTD2545LR)

            if(GET_INPUTSOURCE_TYPE() == _SOURCE_VGA)
            {
                ucDdcSdaCnt = 0;
                CScalerSetByte(_FIFO_FREQUENCY_22, 0x03);

                CScalerPageSelect(_PAGE1);
                CScalerSetByte(_P1_M2PLL_M_E0, 0x69);
                CScalerSetByte(_P1_M2PLL_N_E1, 0x13);
                CScalerSetByte(_P1_M2PLL_CRNT_E4, 0x72);
                CScalerSetByte(_P1_M2PLL_WD_E5, 0x18);

                CScalerPageSelect(_PAGEF);
                CScalerSetByte(_PF_MCU_CONTORL_CD, 0x08);

                CScalerPageSelect(_PAGED);
                CScalerSetByte(_PD_ADC_DCC_CONTROL_1_BC, 0x00);
            }
            else
            {
                CScalerSetByte(_FIFO_FREQUENCY_22, 0x00);

                CScalerPageSelect(_PAGE1);
                CScalerSetByte(_P1_M2PLL_M_E0, 0x01);
                CScalerSetByte(_P1_M2PLL_N_E1, 0x3F);
                CScalerSetByte(_P1_M2PLL_CRNT_E4, 0xFF);
                CScalerSetByte(_P1_M2PLL_WD_E5, 0x58);

                CScalerPageSelect(_PAGEF);
                CScalerSetByte(_PF_MCU_CONTORL_CD, 0x3E);

                CScalerPageSelect(_PAGED);
                CScalerSetByte(_PD_ADC_DCC_CONTROL_1_BC, 0xCA);
            }

#endif

            CEepromSaveGlobalData0();
            return _TRUE;
        }
        else
        {
            return _FALSE;
        }
    }

    return _TRUE;
}

//--------------------------------------------------
// Description  : Scan all input port and select active port
// Input Value  : None
// Output Value : Return _TRUE if the selected input source is exist
//--------------------------------------------------
bit CSourceScanHandler(void)
{
    if(GET_INPUT_SOURCE_SEARCH())
    {
        g_ucSearchIndex = stSystemData.SearchIndex;
        g_ucSearchTimes = GET_INPUTPORT_SEARCH_TIMES(g_ucSearchIndex);
        g_ucSearchFinish = 0;
        CLR_INPUT_SOURCE_SEARCH();
    }

    // Scan same source until search time was zero.
    //1217 sephinroth
    if((g_ucSearchTimes > 0))// && (((GET_INPUT_PORT(g_ucSearchIndex) == _D0_INPUT_PORT) && (!bD0_CONNECT)) || ((GET_INPUT_PORT(g_ucSearchIndex) == _A0_INPUT_PORT))))
    {
        if((GET_INPUT_PORT(g_ucSearchIndex) == _D0_INPUT_PORT) && (bD0_CONNECT))
        {
            g_ucSearchTimes = 1;
        }

        if(CSourceScanInputPort())
        {
            g_ucSearchTimes -= 1;
            return _TRUE;
        }
        else
        {
            g_ucSearchTimes -= 1;
            SET_INPUTSOURCE_TYPE(_SOURCE_NONE);
        }
    }
    else
    {
        CSourceSwitchPortSetting();

        if(g_ucSearchFinish >= sizeof(tINPUT_PORT)) // Scan finish with no signal.
        {
            CScalerCodeW(tSCALER_RESET_TABLE);
            SET_SEARCH_FINISH();
        }
    }

    return _FALSE;
}


//--------------------------------------------------
// Description  : Check connect pin and scan all input port to obtain if the signal is available
// Input Value  : None
// Output Value : Return _TRUE if the selected input source is exist
//--------------------------------------------------
bit CSourceScanInputPort(void)
{
    if(GET_INPUTPORT_TYPE(g_ucSearchIndex) != _NO_PORT)
    {

        if(g_ucSearchTimes == GET_INPUTPORT_SEARCH_TIMES(g_ucSearchIndex))
        {
            CScalerCodeW(tSCALER_RESET_TABLE);
            SET_TMDS_INITIAL();
        }

        switch(GET_INPUT_PORT(g_ucSearchIndex))
        {
           /********************/
            case _D0_INPUT_PORT:
           /********************/

#if((_D0_INPUT_PORT_TYPE == _D0_DVI_PORT) || (_D0_INPUT_PORT_TYPE == _D0_HDMI_PORT)||(_D0_INPUT_PORT_TYPE == _D0_DP_PORT))
            if(1)//(!GET_FACTORY_MODE()) || ((GET_FACTORY_MODE()) && (GET_INPUTSOURCE_STATUS() == _SOURCE_DVI)))
            {
                if(CSyncScanInputPortDVI())
                {
                    SET_INPUTSOURCE_STATUS(_SOURCE_DVI);
                    return _TRUE;
                }
                else
                {
                    break;
                }
            }
            else
            {
                break;
            }
#endif

            break;


           /********************/
            case _D1_INPUT_PORT:
           /********************/

 

#if((_D1_INPUT_PORT_TYPE == _D1_DVI_PORT) || (_D1_INPUT_PORT_TYPE == _D1_HDMI_PORT)||(_D1_INPUT_PORT_TYPE == _D1_DP_PORT))

                if(CSyncScanInputPortDVI())
                {
                    SET_INPUTSOURCE_STATUS(_SOURCE_DVI);
                    return _TRUE;
                }
                else
                {
                    break;
                }

#endif

            break;


           /********************/
            case _A0_INPUT_PORT:
           /********************/

#if((_A0_INPUT_PORT_TYPE == _A0_VGA_PORT) || (_A0_INPUT_PORT_TYPE == _A0_YPBPR_PORT))
                if(CSyncScanInputPortVGA())   
                {
                    SET_INPUTSOURCE_STATUS(_SOURCE_VGA);
                    return _TRUE;
                }
                else
                {
                    break;
                }
#endif
            break;


           /********************/
            case _A1_INPUT_PORT:
           /********************/

#if((_A1_INPUT_PORT_TYPE == _A1_VGA_PORT) || (_A1_INPUT_PORT_TYPE == _A1_YPBPR_PORT))

                if(CSyncScanInputPortVGA())
                {
                    return _TRUE;
                }
                else
                {
                    break;
                }

#endif
            break;


           /********************/
            case _VI_INPUT_PORT:
           /********************/

#if(_VI_INPUT_PORT_TYPE == _VI_VIDEO8_PORT)
                if(CVideoIsExist())
                {
                    return _TRUE;
                }
                else
                {
                    break;
                }
#endif

            default:
                break;
        }
    }

    SET_INPUTSOURCE_TYPE(_SOURCE_NONE);
    return _FALSE;
}

//--------------------------------------------------
// Description  : Switch Input Port Setting
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CSourceSwitchPortSetting(void)
{
    BYTE cnt = 0;
    BYTE ucOldIndex = 0;

    CLR_SEARCH_FINISH();

    ucOldIndex = g_ucSearchIndex;

    switch(GET_SOURCE_STATE())
    {
        case _SOURCE_AUTO_CHANGE_STATE:     // Auto Change Input Source by search priority in the same group.
/*
            if(GET_FIRST_INPUT_PORT_SEARCH())
            {
                CSourceSwitchFirstInputPort();
                CLR_FIRST_INPUT_PORT_SEARCH();
                break;
            }
*/
            do
            {
                g_ucSearchIndex = (g_ucSearchIndex + 1) % (sizeof(tINPUT_PORT));
                g_ucSearchTimes = GET_INPUTPORT_SEARCH_TIMES(g_ucSearchIndex);
                g_ucSearchFinish++;

                if(GET_INPUTPORT_GROUP(g_ucSearchIndex) == GET_INPUTPORT_GROUP(ucOldIndex))
                {
                    if(GET_INPUTPORT_TYPE(g_ucSearchIndex) != _NO_PORT)
                    {
                        break;
                    }
                }

            }while(cnt++ < sizeof(tINPUT_PORT));
            break;


        case _CLR_AUTO_CHANGE_STATE:        // Disable Auto Change Input Source.
            SET_SEARCH_FINISH();
            break;


        case _SWITCH_INPUT_SOURCE_STATE:    // Switch Input Source by search priority without group limit.
            g_ucSearchIndex = (g_ucSearchIndex + 1) % (sizeof(tINPUT_PORT));
            g_ucSearchTimes = GET_INPUTPORT_SEARCH_TIMES(g_ucSearchIndex);
            g_ucSearchFinish++;
            break;
    }
}
/*
//--------------------------------------------------
// Description  : Switch to the First Priority of Input Port in the same group
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CSourceSwitchFirstInputPort(void)
{
    BYTE cnt = 0;

    for(cnt=_SEARCH_POL_0; cnt<sizeof(tINPUT_PORT); cnt++)
    {
        if(GET_INPUTPORT_GROUP(cnt) == GET_INPUTPORT_GROUP(g_ucSearchIndex))
        {
            if(cnt != g_ucSearchIndex)
            {
                break;
            }
        }
    }

    if(cnt < sizeof(tINPUT_PORT))
    {
        g_ucSearchIndex = cnt;
    }

    g_ucSearchTimes = GET_INPUTPORT_SEARCH_TIMES(g_ucSearchIndex);
    g_ucSearchFinish = 0;
}
*/
//--------------------------------------------------
// Description  : Switch Input Port
// Input Value  : Input port type
// Output Value : Return _TRUE if the selected input port is exist
//--------------------------------------------------
bit CSourceSwitchInputPort(BYTE inputport)
{
    BYTE cnt = 0;

    for(cnt=0;cnt<sizeof(tINPUT_PORT);cnt++)
    {
        if((GET_INPUT_PORT(cnt) == inputport) && (GET_INPUTPORT_TYPE(cnt) != _NO_PORT))
        {
            stSystemData.SearchIndex = cnt;
            SET_INPUT_SOURCE_SEARCH();
            //SET_SOURCE_STATE(_CLR_AUTO_CHANGE_STATE);
            return _TRUE;
        }
    }

    return _FALSE;
}

//--------------------------------------------------
// Description      : Switch Input Source
// Input Value      : None
// Output Value     : None
//--------------------------------------------------
/*
void CSourceSwitchInputSource(void)
{
    CLR_SEARCH_FINISH();

    g_ucSearchIndex = (g_ucSearchIndex + 1) % (sizeof(tINPUT_PORT));
    CModeResetMode();
    SET_SOURCE_STATE(_SWITCH_INPUT_SOURCE_STATE);
}
*/
//--------------------------------------------------
// Description  : Initial source setting, we have to run this at firmware startup
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CSourceInitialSetting(void)
{
    CLR_INPUT_SEARCH_INITIAL();
    SET_INPUT_SOURCE_SEARCH();
    SET_SOURCE_STATE(_SOURCE_AUTO_CHANGE_STATE);
    SET_INPUTSOURCE_TYPE(_SOURCE_NONE);
    CSourceInitialConnect();
}

//--------------------------------------------------
// Description  : Initial Connect setting
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CSourceInitialConnect(void)
{
#ifdef _A0_PORT
    SET_PRE_A0_CONNECT(bA0_CONNECT);
#endif

#ifdef _A1_PORT
    SET_PRE_A1_CONNECT(bA1_CONNECT);
#endif

#if((_HDMI_SUPPORT == _ON) || (_TMDS_SUPPORT == _ON))

#ifdef _D0_PORT
    SET_PRE_D0_CONNECT(bD0_CONNECT);
#endif

#ifdef _D1_PORT
    SET_PRE_D1_CONNECT(bD1_CONNECT);
#endif

#endif
}

//--------------------------------------------------
// Description  : Save the Search Index and Input Source to Eeprom
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CSourceSaveSearchData(void)
{
    stSystemData.SearchIndex = g_ucSearchIndex;
    CEepromSaveSystemData();
}

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

⌨️ 快捷键说明

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