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

📄 dcr_type_3.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      : DCR.c No.0000
// Update Note  :
//
//----------------------------------------------------------------------------------------------------

#define __DCR_TYPE_3__

#include "Common\Header\Include.h"

#if(_DCR_MODE == _DCR_TYPE_3)

code BYTE DCC_PAGE0[] =
{
    0x00,  0x00,  0x00,  0x00,
    0x00,  0xFF,  0x00,  0x00,
    0x00,
};

#define _PWM_MIN        95
#define _PWM_low        135
#define _PWM_high       180
#define _PWM_MAX        255

void CDcrInitial(void)
{
    unsigned char i;

    CAdjustNormalizeFactor(stDisplayInfo.DHWidth, stDisplayInfo.DVHeight);  // Normalize factor
     CScalerPageSelect(_PAGE7);
    if(!CScalerGetBit(_P7_DCC_CTRL0_C7, _BIT7)) // no use dcc
    {
        CScalerSetByte(_P7_DCC_CTRL1_C8, 0x00); // disable DCC gain
        CScalerSetByte(_P7_DCC_CTRL0_C7, 0x40); // Y_formula 1, page0
        CScalerSetByte(_P7_DCC_ACCESS_PORT_C9, 0x03);
        for (i=0; i<9; i++)                     // page0 setting
            CScalerSetByte(_P7_DCC_DATA_PORT_CA, DCC_PAGE0[i]);
    }
    else    // use dcc color type
    {
        CScalerSetBit(_P7_DCC_CTRL0_C7, ~(_BIT2 | _BIT1 | _BIT0), 0x00);    // BWL_EXP off page0

        CScalerSetByte(_P7_DCC_ACCESS_PORT_C9, 0x03);               // BBE off
        CScalerSetByte(_P7_DCC_DATA_PORT_CA, 0x00);

        CScalerSetByte(_P7_DCC_ACCESS_PORT_C9, 0x05);               // RH0/RH1 limiter off
        CScalerRead(_P7_DCC_DATA_PORT_CA, 1, pData, _NON_AUTOINC);
        pData[0] = pData[0] & 0x0f;
        CScalerSetByte(_P7_DCC_ACCESS_PORT_C9, 0x05);
        CScalerSetByte(_P7_DCC_DATA_PORT_CA, pData[0]);

        CScalerSetByte(_P7_DCC_ACCESS_PORT_C9, 0x07);
        CScalerSetByte(_P7_DCC_DATA_PORT_CA, 0x00);             // Y_MAX_LB =0, special detect
        CScalerSetByte(_P7_DCC_DATA_PORT_CA, 0xFF);             // Y_MIN_HB = 0xff, special detect
    }
                                                            // daniel DCR add 070531
    ucDcrCnt = 1;                                           // reset counter
    ucDcrTargetPre = _PWM_high + 10;                        // diff from the 4 value
    ucDcrTemp = _PWM_low + 5;                                   // diff from the 4 value
    ucDcrTimer = 0;
}

void CDcrDcr3(void)
{
    unsigned char s_percentage, s0_s6_total;        // daniel 20070626
    bit target_change;
    unsigned char diff = 0;

    CScalerPageSelect(_PAGE7);

    CScalerSetBit(_P7_DCC_CTRL0_C7, ~_BIT7, _BIT7); // enable DCC
    CScalerSetBit(_P7_DCC_CTRL0_C7, ~(_BIT1 | _BIT0), 0x00);    // page0
    CScalerSetByte(_P7_DCC_ACCESS_PORT_C9, 0x0C);
    CScalerRead(_P7_DCC_DATA_PORT_CA, 11, pData, _NON_AUTOINC);

//  Y_MAX_VAL = pData[2];   Y_MIN_VAL = pData[3];   S0_VALUE  = pData[4];

    s0_s6_total = pData[4] + pData[5] + pData[6] + pData[7] + pData[8] + pData[9] + pData[10];  // daniel 20070626
    s_percentage = (WORD)pData[4] * 100 / 255;              // S0_VALUE %

    if(s_percentage < 80)
    {
        if((bit)CScalerGetBit(_VGIP_CTRL_10, _BIT1))
        {
            if(pData[3] > 252)                      // Y_MIN_VAL > 252
                pData[0] = _PWM_MAX;
            else
                pData[0] = _PWM_high;
        }
        else                        // analog input
        {
            if(pData[3] > 215)                  // Y_MIN_VAL > 215
                pData[0] = _PWM_MAX;
            else if(s0_s6_total <= 1)           // daniel 20070626
                pData[0] = _PWM_MAX;            // daniel 20070626
            else
                pData[0] = _PWM_high;
        }

    }
    else if(s_percentage < 90)
    {
        if(pData[2] > 220)                          // Y_MAX_VAL > 220
            pData[0] = _PWM_high;
        else
            pData[0] = _PWM_low;
    }
    else
    {
        if((bit)CScalerGetBit(_VGIP_CTRL_10, _BIT1))
        {
            if(pData[2] < 4)                        // Y_MAX_VAL < 4
                pData[0] = _PWM_MIN;
            else if(pData[2] > 220)                 // Y_MAX_VAL > 220
                pData[0] = _PWM_high;
            else
                pData[0] = _PWM_low;
        }
        else                    // analog input
        {
            if(pData[2] < 10)                       // Y_MAX_VAL < 10
                pData[0] = _PWM_MIN;
            else if(pData[2] > 220)                 // Y_MAX_VAL > 220
                pData[0] = _PWM_high;
            else
                pData[0] = _PWM_low;
        }

    }
    ucDcrPwm = pData[0];

// ------- step by step PWM -------------//

    pData[1] = ucDcrCurrentPWM;

    if(ucDcrTemp == ucDcrPwm)                       // target_pre = target_now
        target_change = 0;
    else
    {
        target_change = 1;
        ucDcrCnt = 1;
    }

//****************************************************************
// Suppose 1 -> 400 takes 8sec (DCR3 runs every 20msec).
// usDcrStep inidicate how many ucDcrCnt counts, then PWM +/- 1
//****************************************************************
    if(target_change)
    {
        if(pData[1] > ucDcrPwm)             // current > target_now
        {
            diff = pData[1] - ucDcrPwm;
            usDcrStep = 4000 / diff;            // how many ucDcrCnt, then PWM +/- 1
        }
        else
        {
            diff = ucDcrPwm - pData[1];
            usDcrStep = 4000 / diff;
        }
    }

    if(pData[1] == ucDcrPwm)
    {
        pData[1] = pData[1];
        ucDcrCnt = 1;
    }
    else if(((ucDcrTargetPre == _PWM_MAX) && (ucDcrPwm == _PWM_MIN)) ||
            ((ucDcrTargetPre1 == _PWM_MAX) && (ucDcrTargetPre != _PWM_MIN) && (ucDcrPwm == _PWM_MIN)) ) // test
    {
        if(ucDcrCnt % ((usDcrStep / 10) * 2) == 0)      // 16s      MAX-MIN
        {
            CTimerDelayXms((usDcrStep % 10)* 2 * 2);
            pData[1] = pData[1] - 1;
        }
    }
    else if(pData[1] > ucDcrPwm)
    {
        if(ucDcrCnt % (usDcrStep / 10) == 0)                // 8s
        {
            CTimerDelayXms((usDcrStep % 10)* 2);
            pData[1] = pData[1] - 1;
        }
    }
    else if(((ucDcrTargetPre == _PWM_MIN) && (ucDcrPwm == _PWM_MAX)) ||
            ((ucDcrTargetPre1 == _PWM_MIN) && (ucDcrTargetPre != _PWM_MAX) && (ucDcrPwm == _PWM_MAX)) ) // test
    {
        if(ucDcrCnt % ((usDcrStep / 10) * 2) == 0)      // 16s      MIN-MAX
        {
            CTimerDelayXms((usDcrStep % 10)* 2 * 2);
            pData[1] = pData[1] + 1;
        }
    }
    else                                        // pData[1] < ucDcrPwm
    {

        if(ucDcrCnt % (usDcrStep / 10) == 0)                // 8s
        {
            CTimerDelayXms((usDcrStep % 10)* 2);
            pData[1] = pData[1] + 1;
        }

    }

    ucDcrCurrentPWM  = pData[1];
    CAdjustBacklight(pData[1]);

    if(target_change)
    {
        ucDcrTargetPre1 = ucDcrTargetPre;
        ucDcrTargetPre = ucDcrTemp;
        ucDcrTemp = ucDcrPwm;
    }

    ucDcrCnt = ucDcrCnt + 1;
}

#endif // End of #if(_DCR_MODE == _DCR_TYPE_3)



⌨️ 快捷键说明

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