📄 lcd_func.c
字号:
#define __FUNC__
#include "reg52.h"
#include "intrins.h"
#include "string.h"
#include "MAIN_DEF.H"
#include "CONFIG.H"
#include "ACCESS.H"
#if(MENU_TYPE == MENU_REL)
#include "OSD_REL.H"
#endif
#if(MENU_TYPE == MENU_KTC)
#include "OSD_KTC.H"
#endif
#include "LCD_COEF.H"
#include "LCD_MAIN.H"
#include "LCD_AUTO.H"
#include "LCD_FUNC.H"
#include "LCD_OSD.H"
#if (TV_CHIP != TV_NONE)
#include "TUNER.H"
#endif
void SetVolume()
{
stGUD3.VOLUME &= 0x1f;
#if (AUDIO_TYPE == AUDIO_SC7313)
Data[0] = 10;
Data[1] = ADDR_SC7313;
Data[2] = 0x7f; // Treble - 0 dB 01111111b
Data[3] = 0x6f; // Bass - 0 dB 01101111b
if (SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07) || SOURCE_DVI == (stGUD1.INPUT_SOURCE & 0x07))
Data[4] = 0x49; // Switch - 7.5 dB 01001001b chanel 2
else if (SOURCE_TV == (stGUD1.INPUT_SOURCE & 0x07))
Data[4] = 0x48; // Switch - 7.5 dB 01001000b chanel 1
else if(SOURCE_AV == (stGUD1.INPUT_SOURCE & 0x07) || SOURCE_SV == (stGUD1.INPUT_SOURCE & 0x07))
Data[4] = 0x4a; // Switch - 7.5 dB 01001010b chanel 3
else
Data[4] = 0x4a;
if (!bFreeRun && (stGUD3.VOLUME !=31))
{
Data[5] = 0xb4; // Front right - mutedB 10110100b
Data[6] = 0x94; // Front left - mutedB 10010100b
}
else
{
Data[5] = 0xbf; // Front right - mutedB 10110100b
Data[6] = 0x9f; // Front left - mutedB 10010100b
}
Data[7] = 0xff; // back right - mutedB 11111111b
Data[8] = 0xdf; // back right - mutedB 11011111b
Data[9] = 0x00 | (stGUD3.VOLUME << 1); // Volume - 0 dB 00xxxxx0b
I2CWrite(Data);
#endif
#if (AUDIO_TYPE == AUDIO_62429)
if (stGUD3.VOLUME != 31)
{
Data[0] = 42 + (unsigned int) 45 * (31 - stGUD3.VOLUME) / 31;
bAUDIO_PD = 1;
}
else
{
Data[0] = 0;
bAUDIO_PD = 0;
}
I2CWrite2(Data[0]);
#endif
}
void WriteGamma(unsigned char code *arrayR, unsigned char code *arrayG, unsigned char code *arrayB)
{
unsigned char n = 0;
RTDSetBit(COLOR_CTRL_5D, 0xfb, 0x10); // Disable GAMMA & Enable Access Channel
// GAMMA_RED
bRTD_SCSB = 0;
RTDSendAddr(RED_GAMMA_64, WRITE, N_INC);
do
{
RTDSendByte(arrayR[n]);
}
while (++n); // if n is 0xff, then n will be 0x00 after increased.
bRTD_SCLK = 0;
bRTD_SCLK = 1;
bRTD_SCSB = 1;
// GAMMA_GREEN
bRTD_SCSB = 0;
RTDSendAddr(GRN_GAMMA_65, WRITE, N_INC);
do
{
RTDSendByte(arrayG[n]);
}
while (++n);
bRTD_SCLK = 0;
bRTD_SCLK = 1;
bRTD_SCSB = 1;
//GAMMA_BLUE
bRTD_SCSB = 0;
RTDSendAddr(BLU_GAMMA_66, WRITE, N_INC);
do
{
RTDSendByte(arrayB[n]);
}
while (++n);
bRTD_SCLK = 0;
bRTD_SCLK = 1;
bRTD_SCSB = 1;
RTDSetBit(COLOR_CTRL_5D, 0xef, 0x04); // Enable GAMMA & Diable Access Channel
}
void WriteDither(unsigned char code *array)
{
unsigned char n;
RTDSetBit(COLOR_CTRL_5D, 0xb7, 0x68); // Enable DITHER & Enable Access Channels
bRTD_SCSB = 0;
RTDSendAddr(DITHER_PORT_67, WRITE, N_INC);
for (n = 0; n < 8; n++) RTDSendByte(array[n]);
bRTD_SCLK = 0;
bRTD_SCLK = 1;
bRTD_SCSB = 1;
RTDSetBit(COLOR_CTRL_5D, 0x1f, 0x88); // Enable DITHER & Disable Access Channels
}
void WriteSU_COEF(unsigned char code *arrayH, unsigned char code *arrayV)
{
unsigned char n;
RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0x01); // Enable H-Coeff access
bRTD_SCSB = 0;
RTDSendAddr(FILTER_PORT_1D, WRITE, N_INC);
for (n = 0; n < 128; n++) RTDSendByte(arrayH[n]);
bRTD_SCLK = 0;
bRTD_SCLK = 1;
bRTD_SCSB = 1;
RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0x03); // Enable V-Coeff access
bRTD_SCSB = 0;
RTDSendAddr(FILTER_PORT_1D, WRITE, N_INC);
for (n = 0; n < 128; n++) RTDSendByte(arrayV[n]);
bRTD_SCLK = 0;
bRTD_SCLK = 1;
bRTD_SCSB = 1;
RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0xc4); // Disable filter coefficient access
}
void Set_H_Position(void)
{
#if(AS_NON_FRAMESYNC)
RTDSetBit(ODD_CTRL_8E,0xef,0x00);
#endif
// if the backporch is far small then the standard one,
// it is possibile that even IHS_Delay decrease to zero still can't correct the H position
// so adjust the usIPH_ACT_STA first and turn back to original value later
if(stMUD.H_POSITION < ucH_Min_Margin)
{
usIPH_ACT_STA = usIPH_ACT_STA - (ucH_Min_Margin - stMUD.H_POSITION);
stMUD.H_POSITION = ucH_Min_Margin;
}
((unsigned int*)Data)[4] = usIPH_ACT_STA + (stMUD.CLOCK >> 1) - 64;
Wait_For_Event(EVENT_IEN_STOP);
Data[0] = 5;
Data[1] = Y_INC;
Data[2] = IPH_ACT_STA_06;
Data[3] = (unsigned char)((unsigned int*)Data)[4];
Data[4] = (unsigned char)(((unsigned int*)Data)[4] >> 8);
Data[5] = 0;
RTDWrite(Data);
// Update IHS delay according to phase
// Set_Phase(stMUD.PHASE & 0x7c);
//Data[0] = PROGRAM_HDELAY + (stMUD.H_POSITION - ucH_Min_Margin);
Data[12] = (stMUD.H_POSITION - ucH_Min_Margin) + PROGRAM_HDELAY;
RTDSetByte(IHS_DELAY_8D, Data[12]);
#if(AS_NON_FRAMESYNC)
if(bFrameSync && bStable)
RTDSetBit(ODD_CTRL_8E,0xef,0x10);
#endif
}
void Set_V_Position(void)
{
unsigned int usIV_Temp, usDV_Temp;
#if(AS_NON_FRAMESYNC)
RTDSetBit(ODD_CTRL_8E,0xef,0x00);
#endif
if (ucV_Max_Margin < stMUD.V_POSITION)
{
RTDSetByte(IVS_DELAY_8C, (PROGRAM_VDELAY + stMUD.V_POSITION - ucV_Max_Margin));
usIV_Temp = usIPV_ACT_STA + ucV_Max_Margin - 128;
usDV_Temp = (unsigned int)ucDV_Delay + ucV_Max_Margin - 128;
}
else
{
RTDSetByte(IVS_DELAY_8C, PROGRAM_VDELAY);
usIV_Temp = usIPV_ACT_STA + stMUD.V_POSITION - 128;
usDV_Temp = (unsigned int)ucDV_Delay + stMUD.V_POSITION - 128;
}
Wait_For_Event(EVENT_IEN_START);
Data[0] = 4;
Data[1] = N_INC;
Data[2] = IV_DV_LINES_38;
Data[3] = (unsigned char)usDV_Temp;
Data[4] = 5;
Data[5] = Y_INC;
Data[6] = IPV_ACT_STA_0A;
Data[7] = (unsigned char)usIV_Temp;
Data[8] = (unsigned char)(usIV_Temp >> 8);
Data[9] = 0;
RTDWrite(Data);
Wait_For_Event(EVENT_IEN_START);
RTDSetByte(STATUS0_01, 0x00); // Clear status
RTDSetByte(STATUS1_1F, 0x00); // Clear status
#if(AS_NON_FRAMESYNC)
if(bFrameSync && bStable)
RTDSetBit(ODD_CTRL_8E,0xef,0x10);
#endif
}
#if ( BOARD_TYPE > 19 ) //LVDS BOARD
void Set_Clock(void)
{
unsigned char ucM_Code, ucN_Code, ucTemp0, ucTemp1, ucResult;
// Issac :
// In this F/W, the frequency of PLL1 is fixed to 24.576*19/2=233.472MHz.
// Our goal is to find the best M/N settings of PLL2 according to the relationship below
// Best Fav = 233.472 * 32 / 31 = 241.003Mhz, and pixel rate = Fav * M / N
// Too small or large N code will cause larger jitter of ADC clock.
// In this F/W, I limite N code value between 16 and 31.
unsigned int usClock = usADC_Clock + (unsigned int)stMUD.CLOCK - 128; // Pixel clock number
unsigned long ulRate = (unsigned long)24576 * usClock / usStdHS; // Pixel clock in kHz
#if(AS_PLL_NONLOCK)
RTDSetBit(ODD_CTRL_8E,0xdf,0x00);
#endif
#if(AS_NON_FRAMESYNC)
RTDSetBit(ODD_CTRL_8E,0xef,0x00);
#endif
#if (TUNE_APLL)
RTDSetBit(DV_TOTAL_STATUS_3D, 0xdf, 0x00);//Disable PE Max Measurement
RTDSetByte(DV_TOTAL_STATUS_3D,0x40); //clear PE Max value
ucPE_Max = 0;
#endif
((unsigned int *)Data)[0] = 500;
ucM_Code = 0;
ucN_Code = 0;
ucResult = 0;
ucTemp0 = 7;
do
{
//Fav * PLL2_M / PLL2_N = ulRate
//PLL2_M = ulRate * PLL2_N / Fav;
ucTemp1 = ulRate * ucTemp0 / 253687;// (20/2 * 24.576 *32/31)
if (2 <= ucTemp1)
{ //Fav = ulRate * PLL2_N / PLL2_M
((unsigned long *)Data)[2] = ulRate * ucTemp0 / ucTemp1;
//(20/2 * 24.576 * 16)
((unsigned int *)Data)[1] = (unsigned long)393216000 / ((unsigned long *)Data)[2];
// > 31/2 = 15.5
if (1550 <= ((unsigned int *)Data)[1])
{
if (1570 >= ((unsigned int *)Data)[1])
{
ucN_Code = ucTemp0;
ucM_Code = ucTemp1;
break;
}
((unsigned int *)Data)[1] = ((unsigned int *)Data)[1] - 1550;
}
else //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -