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

📄 src_ctrl.c

📁 Realtek 公司的RTD2523A芯片原厂source code,没有被修改过的。
💻 C
字号:
#define __SOURCECTRL__

#include "Header\INCLUDE.H"


bit Source_Control(unsigned char Notify)
{
    if (NOTIFY_MENU_KEY == Notify)  Select_Next_Input();

    if ((stGUD1.INPUT_SOURCE & 0x07) != ucInputSrc)
    {
        stGUD1.INPUT_SOURCE = (stGUD1.INPUT_SOURCE & 0xf8) | (ucInputSrc & 0x07);
        Save_GUD1();
        
        ucModeCnt   = MODE_DETECT_FREQ;     // Reset Input Mode Detector

        Reset_Mode();

        Init_Input_Source();
        Measure_Mode();

        return _TRUE;
    }
    
    return _FALSE;
}

void Change_Source(unsigned char source)
{
    if (SOURCE_MAX < source)    return;
    
    if (SOURCE_VGA == source)
    {
        ucInputSrc  = SOURCE_VGA;
    }
    else if (SOURCE_DVI == source)
    {
#if (TMDS_ENABLE) 
        ucInputSrc  = SOURCE_DVI;
#else
        ucInputSrc  = SOURCE_VGA;
#endif
    }
    else if (SOURCE_AV == source || SOURCE_SV == source)
    {
#if (VIDEO_CHIP != VDC_NONE)
        ucInputSrc  = source;   // SOURCE_AV or SOURCE_SV      
#else
        ucInputSrc  = SOURCE_VGA;
#endif
    }
    else if (SOURCE_YUV == source)
    {
#if (VIDEO_CHIP == VDC_SAA7118)
        ucInputSrc  = source;   // SOURCE_YUV
#else
        ucInputSrc  = SOURCE_VGA;
#endif
    }
    else
    {
#if (TV_CHIP != TV_NONE)
        ucInputSrc = source;    // SOURCE_TV
#else
        ucInputSrc = SOURCE_VGA;
#endif
    }
}

void Select_Next_Input(void)
{
    if (SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07))
    {
#if (TMDS_ENABLE) 
        Change_Source(SOURCE_DVI);
#else
        Change_Source(SOURCE_AV);
#endif
    }
    else if (SOURCE_DVI == (stGUD1.INPUT_SOURCE & 0x07))
        Change_Source(SOURCE_AV);
    else if (SOURCE_AV == (stGUD1.INPUT_SOURCE & 0x07))
        Change_Source(SOURCE_SV);
    else if (SOURCE_SV == (stGUD1.INPUT_SOURCE & 0x07))
    {
#if (VIDEO_CHIP == VDC_SAA7118)
        Change_Source(SOURCE_YUV);
#else
        Change_Source(SOURCE_TV);
#endif
    }
    else if (SOURCE_YUV == (stGUD1.INPUT_SOURCE & 0x07))
    {
        Change_Source(SOURCE_TV);
    }
    else
    {
        Change_Source(SOURCE_VGA);
    }
}

#if (SOURCE_AUTO_SCAN)
void Source_Auto_Scan(void)
{
    Data[0] = stGUD1.INPUT_SOURCE & 0x07; 
    
    if ((Data[0] == MASTER_SOURCE) || (Data[0] == SLAVE_SOURCE) || (Data[0] == THIRD_SOURCE)) 
    {
        bSourceScanEnable = !bSourceScanEnable;
    }
	
    if (!bSourceScanEnable)
    {
        Mode_Detector();
    }
    else if (bStable)
    {
#if (!SOURCE_PRIORITY)
        // Issac :
        // Original source-scan function is designed by Forster.
        // By setting SOURCE_PRIORITY to 0, you can just search other source ONLY when current source has no singal.
        if (MODE_NOSIGNAL != ucMode_Curr)
        {
            ucSource_Times  = 0;

            RTDSetByte(SYNC_CTRL_4A, 0x00);

            if ((SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07)) && (SYNC_SS != ucSync_Type))
                RTDSetByte(SYNC_POR_4C, 0x22);
            else
                RTDSetByte(SYNC_POR_4C, 0x02);
         
            return;
        }
#endif

        if (SOURCE_VGA == ucNext_Source)
        {
            RTDSetByte(SYNC_CTRL_4A, 0x00);
            Delay_Xms(1);

            RTDRead(SYNC_CTRL_4A, 1, N_INC);

            Data[1] = Data[0] & 0x20;

#if (!SOURCE_PRIORITY)

            if (0 == Data[1] && MODE_NOSIGNAL == ucMode_Curr)
            {
                unsigned char   ucTemp0, ucTemp1;

                RTDRead(VGIP_SIGINV_05, 1, N_INC);
                ucTemp0 = Data[0];
                RTDRead(SYNC_CTRL_4B, 1, N_INC);
                ucTemp1 = Data[0];

                RTDSetByte(VGIP_SIGINV_05, 0x40);
                RTDSetByte(SYNC_CTRL_4B, 0x57);
                RTDSetByte(SYNC_POR_4C, 0x22);

                Data[1] = 40;
                do
                {
                    Delay_Xms(1);
                    RTDRead(SYNC_POR_4C, 1, N_INC);
                }
                while ((Data[0] & 0x02) && --Data[1]);

                if (Data[1])
                {
                    RTDRead(SYNC_POR_4C, 7, Y_INC);
                    Data[7] = Data[5];
                    Data[6] = Data[6] & 0x0f;
                    Data[5] = Data[3];
                    Data[4] = Data[4] & 0x87;
                    Data[3] = Data[1];
                    Data[2] = Data[2] & 0x8f;

                    if (0x07ff <= ((unsigned int *)Data)[1] || 0x07ff <= ((unsigned int *)Data)[2] 
                        || 0 == ((unsigned int *)Data)[1] || 0 == ((unsigned int *)Data)[2]
                        || (((unsigned int *)Data)[3] * 7) > ((unsigned int *)Data)[1])
                    {
                        Data[1] = 0x00; // No SOG signal
                    }
                    else
                    {
                        Data[1] = 0x20; // SOG signal found
                    }
                }
                // Restore CR[05][4B] settings
                RTDSetByte(VGIP_SIGINV_05, ucTemp0);
                RTDSetByte(SYNC_CTRL_4B, ucTemp1);
            }
#endif

        }
        else if (SOURCE_DVI == ucNext_Source)
        {
            RTDSetByte(SYNC_CTRL_4A, 0x03);
            RTDSetByte(SYNC_POR_4C, 0x02);

            RTDSetByte(STATUS0_01, 0x00);
            
            Data[1] = 40;
            do
            {
                Delay_Xms(1);

                RTDRead(STATUS0_01, 1, N_INC);

                if (bFrameSync && (Data[0] & 0x63))
                {
                    Data[1] = 0;
                    break;
                }

                RTDRead(SYNC_POR_4C, 1, N_INC);
            }
            while ((Data[0] & 0x02) && --Data[1]);

            if (Data[1])
            {
                RTDRead(SYNC_POR_4C, 5, Y_INC);

                Data[1] = ((Data[2] | Data[4]) & 0x80) ? 0 : 1;
            }
        }
        else
        {
#if (VIDEO_CHIP != VDC_NONE)
            // Not tested yet
            I2CWrite(V_ENABLE);
            I2CWrite(SOURCE_AV == ucNext_Source ? AV_DETECT : SV_DETECT);
            I2CRead(ADDR_VIDEO, 0x1f, 0x01);  
            Data[1] = Data[0] & 0x40;
#else
            Data[1] = 0;
#endif
        }

        if (Data[1])
        {
#if (SOURCE_PRIORITY)
            if (ucSource_Times < (1 * VGA_SEARCH_TIMES))
#else
            if (ucSource_Times < (4 * VGA_SEARCH_TIMES))
#endif
                ucSource_Times += 1;
            else
            {
                ucInputSrc      = ucNext_Source;
                ucNext_Source   = MASTER_SOURCE; 
                ucSource_Times  = 0;
            }
        }
        else
        {
            ucSource_Times  = 0;
            
            ucNext_Source   = (ucNext_Source == MASTER_SOURCE) ? SLAVE_SOURCE 
                : (ucNext_Source == SLAVE_SOURCE ) ? THIRD_SOURCE : MASTER_SOURCE;
        }
        
        RTDSetByte(SYNC_CTRL_4A, 0x00);

        if ((SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07)) && (SYNC_SS != ucSync_Type))
            RTDSetByte(SYNC_POR_4C, 0x22);
        else
            RTDSetByte(SYNC_POR_4C, 0x02);
    }
}
#endif

⌨️ 快捷键说明

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