📄 scaler.c
字号:
/*==========================================
==========================================*/
#include "include.h"
/*==========================================
==========================================*/
#if PanelDepth == 6
#define DisplayColorDepth 0xff
#define DT158 PanelDethMode
#else
#define DisplayColorDepth 0x00
#define DT158 PanelDethMode
#endif
#if PanelTwoPixelPerClk == 1
#define DisplayBusWidth 0x00
#else
#define DisplayBusWidth 0xff
#endif
#if PanelSync_DE == 1
#define DisplaySyncMode 0xff
#else
#define DisplaySyncMode 0x00
#endif
#if PANEL == Topply_CarTV
#define DisplayControl (0x61 | (DisplayColorDepth & BIT_3) | (DisplayBusWidth & BIT_2) | (DisplaySyncMode & BIT_1))
#else
#define DisplayControl (0x61 | (DisplayColorDepth & BIT_3) | (DisplayBusWidth & BIT_2) | (DisplaySyncMode & BIT_1))
#endif
#define DT155 (unsigned char)PanelPadDrive
#define DT156 (unsigned char)(PanelPadDrive >> 8)|((~Panel_Invert_DVS & BIT_4) | (~Panel_Invert_DHS & BIT_5) | (~Panel_Invert_DCLK & BIT_6) | (~Panel_Invert_DEN & BIT_7))
#define DT61 ((Panel_Invert_DVS & BIT_0) | (Panel_Invert_DHS & BIT_1) | (Panel_Invert_DCLK & BIT_2) | (Panel_Invert_DEN & BIT_3))
/*
code unsigned short H_ActiveTab[]={
640,720,640,720,640,848,800,832,1024,1152,1152,1152,1280,1280,1600,1280,1280,756
};
code unsigned short V_ActiveTab[]={
350,350,400,400,480,480,600,624,768,864,870,900,960,1024,1200,720,768, 574
};
*/
code struct ActiveTbl Active_Tab[]={
{Re_0640x0350,640,350,800}, //0
{Re_0640x0400,640,400,800},
{Re_0720x0350,720,350,900},
{Re_0720x0400,720,400,900},
{Re_0640x0400_1,640,400,800},
{Re_0640x0480,640,480,800}, //5
{Re_0720x0480,720,480,900},
//{Re_0800x0600,825,600,1040},
{Re_0800x0600,800,600,1040},
{Re_0832x0624,832,624,1152},
{Re_0848x0480,848,480,1600},
{Re_1024x0768,1024,768,1344}, //10
{Re_1152x0864,1152,864,1600},
{Re_1152x0870,1152,870,1456},
{Re_1152x0900,1152,900,1504},
{Re_1280x0720,1280,720,1728},
{Re_1280x0960,1280,960,1800}, //15
{Re_1280x1024,1280,1024,1728},
{Re_1600x1200,1600,1200,1800},
{Re_0720x0576,720,576,944},
};
code unsigned char TCON_Tab[]={
// CPT_M170
/*
0x00,0x63,0x22,0x00,0x88,0x4a,0x12,0x00,0x10,0x80,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// OE
0x01,0x00,0x02,0x04,0xa0,0x04,0x20,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// CKV
0x01,0x00,0x02,0x04,0xc0,0x04,0xff,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// STV
0x01,0x00,0x02,0x00,0x80,0x02,0x80,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// POL
0x01,0x00,0x01,0x00,0x00,0x02,0x00,0x02,0x02,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
// TP
0x01,0x00,0x02,0x04,0x0c,0x05,0x14,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
*/
// AU_M170ES05
0x00,0x63,0x22,0x00,0x88,0x8f,0x00,0x07,0x13,0x80,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// OE
0x01,0x00,0x01,0x00,0xe0,0x03,0x14,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// CKV
0x01,0x00,0x01,0x00,0x00,0x04,0x14,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// STV
0x01,0x00,0x02,0x00,0x80,0x02,0x80,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// POL
0x01,0x00,0x01,0x00,0x00,0x02,0x00,0x02,0x02,0x50,0x00,0x00,0x00,0x00,0x00,0x00,
// TP
0x01,0x00,0x02,0x04,0x0c,0x05,0x14,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// CMO_M170ES05
/*
0x00,0x63,0x22,0x00,0x88,0x83,0x00,0x00,0x10,0x80,0x02,0x00,0x00,0x00,0x00,0x00,
// OE
0x01,0x00,0x02,0x04,0xbc,0x04,0x44,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// CKV
0x01,0x00,0x01,0x00,0xa0,0x04,0x20,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// STV
0x01,0x00,0x02,0x00,0x00,0x02,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// POL
0x01,0x00,0x01,0x00,0x80,0x02,0x80,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// TP
0x01,0x00,0x02,0x04,0x0c,0x05,0x14,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//GVON
0x01,0x00,0x02,0x04,0x30,0x03,0xc0,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//GVOFF
0x01,0x00,0x02,0x04,0x30,0x03,0xc0,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
// STV
0x01,0x00,0x02,0x00,0x00,0x02,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
*/
};
/*==========================================
==========================================*/
void UpdatePresetData(void)
{
code unsigned short UpdateSquenceTable[]={
0x002,0x008,
0x020,0x023,0x025,0x026,0x027,
0x02e,0x02f,0x030,0x031,
0x032,0x033,0x034,0x035,0x036,0x037,
0x060,0x064,0x065,0x066,
0x154,0x156,0x157,0x158,0x16a,0x16e,0x186,0x18d,0x1f1
};
/*==========================================
==========================================*/
code unsigned char D1024x768[]={
// 0x002, 0x008,
0x06, 0x04,
// 0x020, 0x023, 0x025, 0x026, 0x027,
0x81, 0x00, 0x00, 0x80, 0x11,
//#if DVImode == DEmode
// 0x02e, 0x02f, 0x030, 0x031,
// 0xe0, 0x01, 0xe0, 0x01,
//#else
// 0x02e, 0x02f, 0x030, 0x031,
0x20, 0x00, 0x00, 0x00,
//#endif
// 0x032, 0x033, 0x034, 0x035, 0x036, 0x037,
0xe0, 0x01, 0x88, 0x00, 0x80, 0x02,
// 0x060, 0x064, 0x065, 0x066,
0x00, 0x00, 0x00, 0x00,
// 0x154, 0x156, 0x157, 0x158, 0x16a, 0x16e, 0x186, 0x18d, 0x1f1
// 050511,Eason
// 0x00, DT156, 0x40, DT158, DT16A, 0x06, 0x00, 0x00, 0x2A
0x00, DT156, 0x40, DT158, DT16A, 0x06, 0x00, 0x00, 0x2A
};
unsigned char i;
// 050511,Eason
for(i=0; i<30; i++){
// for(i=0; i<29; i++){
WriteIIC563(UpdateSquenceTable[i],D1024x768[i]);
}
}
/*==========================================
==========================================*/
void InitScaler(void)
{
#if 0
unsigned char i;
code unsigned short InitTab[][2]={
{0x15B,(unsigned char)PanelTypVTotal},{0x15C,(unsigned char)(PanelTypVTotal>>8)}, // Display Vtotal
// 050526,Eason HSD190ME12 1280*1024 has lack top line problem but can solve flicker problem
// {0x15D,(unsigned char)PanelMinVSyncWidth+PanelMinVSyncBackPorch}, // Display V Pulse Width
{0x15D,(unsigned char)PanelMinVSyncWidth}, // Display V Pulse Width
{0x162,(unsigned char)PanelVActiveStart},
{0x163,(unsigned char)((PanelVActiveStart)>>8)}, // Display Background Window VBegin
{0x164,(unsigned char)PanelHeight},
{0x165,(unsigned char)((PanelHeight)>>8)}, // Display Background Window VLength
{0x16f,(unsigned char)PanelVActiveStart},
{0x170,(unsigned char)((PanelVActiveStart)>>8)}, // Display Active VBegin
{0x171,(unsigned char)PanelHeight},
{0x172,(unsigned char)((PanelHeight)>>8)}, // Display VActive
{0x15E,(unsigned char)PanelMinHTotal},
{0x15F,(unsigned char)(PanelMinHTotal>>8)}, // Display Htotal
{0x160,(unsigned char)PanelMinHSyncWidth}, // Display H Pulse Width
{0x166,(unsigned char)PanelHActiveStart},
{0x167,(unsigned char)(PanelHActiveStart>>8)}, // Display Background Window HBegin
{0x168,(unsigned char)PanelWidth},
{0x169,(unsigned char)(PanelWidth>>8)}, // Display Backgroun Window HWidth
{0x173,(unsigned char)PanelHActiveStart},
{0x174,(unsigned char)(PanelHActiveStart>>8)}, // Display Active HBegin
{0x175,(unsigned char)PanelWidth},
{0x176,(unsigned char)(PanelWidth>>8)}, // Display HActive
{0x070,0x08}, // VSO output&Enable Brightness PWM
{0x072,0x00}, // Sync Processor Ctrl: Bypass Sync Control
{0x196,0x14}, // Sync Processor Ctrl: Select Raw_hs
{0x197,0x82}, // Sync Processor Ctrl2
{0x021,0x0c}, // Clamp Pulse
{0x022,0x83},
{0x012,0x00}, // SOG Slicer Ctrl
{0x18e,0x03}, //Clear FIFO interrupt
{0x18f,0x00}, //Disable FIFO interrupt
{0x1a3,0x2d}, //Hsync not present
{0x1a4,0x2d}, //Hsync present
{0x1a5,0x2d}, //Vsync not present
{0x1a6,0x2d}, //Vsync present
{0x1a7,0x08}, //Hcounter change threshold
{0x1a8,0x24}, //Vcounter change threshold
{0x1a9,0x3c}, // H/V interrupt enable1
{0x1aa,0x00}, // H/V interrupt enable2
{0x1ab,0x2f}, // H/V interrupt clear1
{0x1ac,0x1f}, // H/V interrupt clear2
{0x1d8,0x0a}, // sRGB static dither mode control
{0x199,0x01}, //Graphic Filed control
{0x01e,0xb8}, //DVI EquPLL BW
{0x0db,0x0c},
{0x0d5,0x01},
};
TCONInit();
for(i=0;i<sizeof InitTab/sizeof (unsigned short) /2;i++){
WriteIIC563(InitTab[i][0],InitTab[i][1]);
}
UpdatePresetData();
SetInterface();
WriteIIC563(0x00e,0xff);
WriteIIC563(0x150,DisplayControl);
WriteIIC563(0x154,0x02);
//Noise reduction
WriteIIC563(0x068,0x7a);
WriteIIC563(0x069,0x43);
WriteIIC563(0x06a,0x92);
WriteIIC563(0x06b,0x03);
//OSD blink control
WriteIIC563(0x0a0,0x12);
//LVDS bandwidth
// WriteIIC563(0x1f5,0x06);
WriteIIC563(0x1f5,0x16);
WriteIIC563(0x1f6,0x06);
WriteIIC563(0x1f7,0x00);
WriteIIC563(0x1f8,0x02);
//LVDS differential voltage
WriteIIC563(0x1b8,0x10);
// For ADCclock duty control jacky 20040607
WriteIIC563(0x0dc,0x50);
//-----------------------------
// For Vsync output jacky 20040605
//WriteIIC563(0x208,0x10);
//WriteIIC563(0x1b9,0x31);
//Sleep(20);
if(PanelInterface != TCON_TO_RSDS && PanelInterface != TCON_TO_TTL)
WriteIIC563(0x1b9,0x30);
else
WriteIIC563(0x1b9,0x31);
//-----------------------------
// For DVI bandwidth setting jacky 20040607
WriteIIC563(0x018,0x02); //DVI DPLL FSM mode select
WriteIIC563(0x019,0x03); //DVI DPLL FSM mode select
//-----------------------------
// For ADC R/G/B phase delay jacky 20040629
WriteIIC563(0x0d9,0x40);
WriteIIC563(0x0da,0x01);
//WriteIIC563(0x0d9,0x80);
//WriteIIC563(0x0da,0x03);
//-----------------------------
#else
unsigned char i;
code unsigned short InitTab[43][2]={
{0x15B,(unsigned char)PanelTypVTotal},
{0x15C,(unsigned char)(PanelTypVTotal>>8)}, // Display Vtotal
{0x15D,(unsigned char)PanelMinVSyncWidth}, // Display V Pulse Width
{0x162,(unsigned char)PanelVActiveStart},
{0x163,(unsigned char)(PanelVActiveStart>>8)}, // Display Background Window VBegin
{0x164,(unsigned char)PanelHeight},
{0x165,(unsigned char)(PanelHeight>>8)}, // Display Background Window VLength
{0x16f,(unsigned char)PanelVActiveStart},
{0x170,(unsigned char)(PanelVActiveStart>>8)}, // Display Active VBegin
{0x171,(unsigned char)PanelHeight},
{0x172,(unsigned char)(PanelHeight>>8)}, // Display VActive
{0x15E,(unsigned char)PanelMinHTotal},
{0x15F,(unsigned char)(PanelMinHTotal>>8)}, // Display Htotal
{0x160,(unsigned char)PanelMinHSyncWidth}, // Display H Pulse Width
{0x166,(unsigned char)PanelHActiveStart},
{0x167,(unsigned char)(PanelHActiveStart>>8)}, // Display Background Window HBegin
{0x168,(unsigned char)PanelWidth},
{0x169,(unsigned char)(PanelWidth>>8)}, // Display Backgroun Window HWidth
{0x173,(unsigned char)PanelHActiveStart},
{0x174,(unsigned char)(PanelHActiveStart>>8)}, // Display Active HBegin
{0x175,(unsigned char)PanelWidth},
{0x176,(unsigned char)(PanelWidth>>8)}, // Display HActive
{0x070,0x08}, // VSO output
{0x072,0x00}, // Sync Processor Ctrl: Bypass Sync Control
{0x196,0x14}, // Sync Processor Ctrl: Select Raw_hs
{0x197,0x82}, // Sync Processor Ctrl2
{0x021,0x4c}, // Clamp Pulse
{0x022,0x83},
{0x012,0x00}, // SOG Slicer Ctrl
{0x18e,0x03}, //Clear FIFO interrupt
{0x18f,0x00}, //Disable FIFO interrupt
{0x1a3,0x2d}, //Hsync not present
{0x1a4,0x2d}, //Hsync present
{0x1a5,0x2d}, //Vsync not present
{0x1a6,0x2d}, //Vsync present
{0x1a7,0x08}, //Hcounter change threshold
{0x1a8,0x24}, //Vcounter change threshold
{0x1a9,0x3c}, // H/V interrupt enable1
{0x1aa,0x00}, // H/V interrupt enable2
{0x1ab,0x2f}, // H/V interrupt clear1
{0x1ac,0x1f}, // H/V interrupt clear2
{0x1d8,0x0a}, // sRGB static dither mode control
{0x199,0x01}, //Graphic Filed control
};
TCONInit();
//WriteIIC563(0x1EF, 0x04); //NT68665 LVDS pad select, 00 for rsds
for(i=0;i<43;i++){
WriteIIC563(InitTab[i][0],InitTab[i][1]);
}
UpdatePresetData();
SetInterface();
WriteIIC563(0x00e,0xff);
// WriteIIC563(0x0f4,0x80);
WriteIIC563(0x150,DisplayControl);
WriteIIC563(0x154,0x02);
//Noise reduction
//Noise reduction
WriteIIC563(0x068,0x7a);
WriteIIC563(0x069,0x43);
WriteIIC563(0x06a,0xd2);
WriteIIC563(0x06b,0x03);
//OSD blink control
WriteIIC563(0x0a0,0x12);
//LVDS bandwidth
WriteIIC563(0x1f5,0x06);
WriteIIC563(0x1f6,0x00);
WriteIIC563(0x1f7,0xc0);
if(PanelInterface == TTL_TO_TCON) { //for module test
WriteIIC563(0x155,0x78);
WriteIIC563(0x156,0x88);
WriteIIC563(0x157,0x50);
}
//LVDS differential voltage
WriteIIC563(0x1b8,0x10);
// For ADCclock duty control jacky 20040607
WriteIIC563(0x0dc,0x50);
//-----------------------------
// For Vsync output jacky 20040605
//WriteIIC563(0x208,0x10);
//WriteIIC563(0x1b9,0x31);
//Sleep(20);
if(PanelInterface != TCON_TO_RSDS && PanelInterface != TCON_TO_TTL && PanelInterface != TTL_TO_TCON) {
//WriteIIC563(0x1b9,0x10);
WriteIIC563(0x1b9,0x04);
WriteIIC563(0x1EF,0x04); //ray,nt68665
}
else {
WriteIIC563(0x1b9,0x02);
WriteIIC563(0x1EF,0x00); //ray,nt68665
}
//-----------------------------
// For DVI bandwidth setting jacky 20040607
WriteIIC563(0x018,0x02); //DVI DPLL FSM mode select
WriteIIC563(0x019,0x03); //DVI DPLL FSM mode select
WriteIIC563(0x01d,0x1D); //DVI bandwidth
//WriteIIC563(0x01e,0xb8);
WriteIIC563(0x01e,0xB8); //nt68663A
WriteIIC563(0x146,0xf3);
//-----------------------------
// For ADC R/G/B phase delay jacky 20040629
WriteIIC563(0x0d9,0x00);
WriteIIC563(0x0da,0x00);
WriteIIC563(0x0d9,0x40);
WriteIIC563(0x0da,0x01);
WriteIIC563(0x0d9,0x80);
WriteIIC563(0x0da,0x00);
// For TQFP 64 pin channel swap jacky 20050121
//WriteIIC563(0x1f4,0x04);
// For HPLL Line counter set and initial
WriteIIC563(0x0db,0x0c);
WriteIIC563(0x0d5,0x01);
//-----------------------------
// For Fastmute
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -