📄 mstar.c
字号:
{ mStar_WriteByte(REGBK, REGBANKADC); // switch to ADC bank
mStar_WriteByte(CLPLACE, 0x10); // set clamping start position
mStar_WriteByte(CLDUR, 0x8); // set clamping width
mStar_WriteByte(FCOEF, 0x9);
mStar_WriteByte(VCOCTRL, 0x15);//D); // set VOC
mStar_WriteByte(SOG_LVL, 0x10); // set SOG level
mStar_WriteByte(PLLCTRLV, 0x95);//x49);//0x00);
// DVI setting
mStar_WriteByte(DVI_PHR, 0);//0x03);
mStar_WriteByte(DVI_PHG, 0);//0x01);
mStar_WriteByte(DVI_PHB, 0);//0x57);
mStar_WriteByte(DVI_ERST, 0);//0x22);
mStar_WriteByte(DVI_ERTH, 0x02);//0x0A);//0x20); // DVI threshold
mStar_WriteByte(TESTEN, TSTEN_B);//0x22);
#if NewChip
//jon add for new chip with Mstar Tsu16ak for B version
mStar_WriteByte(0x3D, 0x10);
#endif
mStar_WriteByte(TESTA0, 0x20);//0x22);
mStar_WriteByte(TESTMOD,0x10);//0x22);
#if PanelLVDS
mStar_WriteByte(TST_REG, 0xBF);//0x22);
#else
mStar_WriteByte(TST_REG, 0);//0x22);
#endif
#if ChipID>=ChipBB
mStar_WriteByte(TESTA2, 0x00);
mStar_WriteByte(0x36, 0x10);
mStar_WriteByte(0x33, 0x40);
#elif ChipID==ChipBA
mStar_WriteByte(TESTA2, 0x04);
mStar_WriteByte(0x36, 0x20);
mStar_WriteByte(0x33, 0x40);
#elif ChipID==ChipNone
mStar_WriteByte(TESTA2, 0x80);
#endif
mStar_WriteByte(TESTEN, 0);//0x22);
mStar_WriteByte(REGBK, REGBANKSCALER); // switch to scaler bank
}
//*******************************************************************
// Function Name: mStar_InitTCON
//
// Decscription: Initialize TCON bank registers according panel type
//
// callee: mStar_WriteByte(), mStar_WriteWord in ms_rwreg.c
//
// caller: mStar_Init() in mStar.c
//*******************************************************************
void mStar_InitTCON(void)
{
#if PanelLVDS // for LVDS Panel
mStar_WriteByte(REGBK, REGBANKTCON);
mStar_WriteByte(OFC1, 2); // Enable Early end function
// mStar_WriteWord(G9VST_H, 7);
// mStar_WriteWord(G9VEND_H, 0x705);
// mStar_WriteByte(G9CTRL, 0x4);
mStar_WriteWord(GAVST_H, GPOA_VStart);
mStar_WriteWord(GAVEND_H, GPOA_VEnd);
mStar_WriteByte(GACTRL, GPOA_Control);
mStar_WriteByte(REGBK, REGBANKSCALER);
#elif PanelRSDS
mStar_WriteByte(REGBK, REGBANKTCON);
#if PanelQDIRSDS
mStar_WriteByte(OFC1, 0x01);
mStar_WriteByte(OFC2, 0x11);
#elif PanelCPTRSDS
mStar_WriteByte(OFC1, 0x01);
mStar_WriteByte(OFC2, 0x11);
#elif PanelAURSDS
mStar_WriteByte(OFC1, 0x01);
mStar_WriteByte(OFC2, 0x11);
#else
mStar_WriteByte(OFC1, 0x43);
mStar_WriteByte(OFC2, 0x11);
mStar_WriteByte(OFC1, TCON_Format1);
mStar_WriteByte(OFC2, (ESPP_B&ESP_AfterData)|(ESP_Offset<<4)|
(OSPP_B&OSP_AfterData)|OSP_Offset);
#endif
#if PanelAURSDS
mStar_WriteByte(ODPC, PanelOESPCurrent<<6|PanelOEGCurrent<<4); // setup output driving current
mStar_WriteByte(ODC, PanelEINVCurrent<<6|PanelOINVCurrent<<4|0x03); // setup output driving current
#elif PanelQDIRSDS
mStar_WriteByte(ODPC, PanelOESPCurrent<<6|PanelOEGCurrent<<4); // setup output driving current
mStar_WriteByte(ODC, PanelEINVCurrent<<6|PanelOINVCurrent<<4); // setup output driving current
#elif PanelCPTRSDS
mStar_WriteByte(ODPC, PanelOESPCurrent<<6|PanelOEGCurrent<<4); // setup output driving current
mStar_WriteByte(ODC, PanelEINVCurrent<<6|PanelOINVCurrent<<4); // setup output driving current
#else
mStar_WriteByte(ODPC, PanelOESPCurrent<<6|PanelOEGCurrent<<4); // setup output driving current
mStar_WriteByte(ODC, PanelEINVCurrent<<6|PanelOINVCurrent<<4); // setup output driving current
#endif
mStar_WriteByte(IFCTRL, OuputFormat|BIT6);//0x28);
// POL
mStar_WriteWord(G0VST_H, GPO0_VStart);
mStar_WriteWord(G0VEND_H, GPO0_VEnd);
mStar_WriteWord(G0HST_H, GPO0_HStart);
mStar_WriteWord(G0HEND_H, GPO0_HEnd);
mStar_WriteByte(G0CTRL, GPO0_Control);
// LP
mStar_WriteWord(G1VST_H, GPO1_VStart);
mStar_WriteWord(G1VEND_H, GPO1_VEnd);
mStar_WriteWord(G1HST_H, GPO1_HStart);
mStar_WriteWord(G1HEND_H, GPO1_HEnd);
mStar_WriteByte(G1CTRL, GPO1_Control);
// STV
mStar_WriteWord(G2VST_H, GPO2_VStart);
mStar_WriteWord(G2VEND_H, GPO2_VEnd);
mStar_WriteWord(G2HST_H, GPO2_HStart);
mStar_WriteWord(G2HEND_H, GPO2_HEnd);
mStar_WriteByte(G2CTRL, GPO2_Control);
// CLKV
mStar_WriteWord(G3VST_H, GPO3_VStart);
mStar_WriteWord(G3VEND_H, GPO3_VEnd);
mStar_WriteWord(G3HST_H, GPO3_HStart);
mStar_WriteWord(G3HEND_H, GPO3_HEnd);
mStar_WriteByte(G3CTRL, GPO3_Control);
// OE
mStar_WriteWord(G4VST_H, GPO4_VStart);
mStar_WriteWord(G4VEND_H, GPO4_VEnd);
mStar_WriteWord(G4HST_H, GPO4_HStart);
mStar_WriteWord(G4HEND_H, GPO4_HEnd);
mStar_WriteByte(G4CTRL, GPO4_Control);
// PVS
mStar_WriteWord(G9VST_H, GPO9_VStart);
mStar_WriteWord(G9VEND_H, GPO9_VEnd);
mStar_WriteWord(G9HST_H, GPO9_HStart);
mStar_WriteWord(G9HEND_H, GPO9_HEnd);
mStar_WriteByte(G9CTRL, GPO9_Control);
mStar_WriteByte(REGBK, REGBANKSCALER);
#endif
}
#if 0
BYTE code Pattern0[]=
{ 0x0C, 0x00, 0x10, 0x10, 0x10, 0x3F, 0x3F, 0x3F, 0x00, 0x00, 0x00
};
void mStar_SetupPattern(void)
{ BYTE i;
mStar_WriteByte(OSDRA, 0x15);
for (i=0; i<sizeof(Pattern0); i++)
mStar_WriteByte(OSDRD, Pattern0[i]);
}
#endif
//*******************************************************************
// Function Name: mStar_SetScalingFilter
//
// Decscription: Setup scaling filter for sharpness function
//
// callee: mStar_WriteByte() in ms_rwreg.c
//
// caller: mStar_SetupMode() in mStar.c
//*******************************************************************
#if ChipID==ChipNone
BYTE code FilterTbl[4][6]=
{ // SHF SFV HDSUSG HDSUSL VDSUSG VDSUSL
// 56 57 58 59 5A 5B 5C 5D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0
{ 0xAA, 0x11, 0x44, 0x06, 0x22, 0x01}, // U
{ 0xAA, 0x11, 0x33, 0x06, 0x22, 0x01}, // Win1
{ 0x99, 0x11, 0x66, 0x06, 0x22, 0x01}, // Win2
};
#else
BYTE code FilterTbl[4][8]=
{ // SHF SFV HDSUSG HDSUSL VDSUSG VDSUSL
// 56 57 58 59 5A 5B 5C 5D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0
{ 0x55, 0x11, 0x00, 0x06, 0x22, 0x01, 0x00, 0x00}, // U
{ 0x55, 0x11, 0x11, 0x06, 0x22, 0x01, 0x00, 0x00}, // Win1
{ 0x33, 0x11, 0x00, 0x06, 0x22, 0x01, 0x01, 0xAA}, // Win2
};
#endif
void mStar_SetScalingFilter(BYTE filter)
{ BYTE i;
for (i=0; i<sizeof(FilterTbl)/4; i++)
mStar_WriteByte(SFH+i, FilterTbl[filter][i]);
}
//*******************************************************************
// Function Name: mStar_SetUserPref
//
// Decscription: Restore user setting from NVRAM
//
// callee: mStar_WriteByte() in ms_rwreg.c
//
// caller: mStar_SetupMode() in mStar.c
//*******************************************************************
void mStar_SetUserPref(void)
{ // Restore contrast & color temperature setting
mStar_AdjustContrast(UserPrefContrast);
mStar_AdjustBrightness(UserPrefBrightness);
// Restore other settings here
}
#if ChipID==ChipBB
void CheckLineBuffer(void)
{ WORD lineLength;
BYTE regByte=mStar_ReadByte(LVSST_H);
BYTE regByte2=mStar_ReadByte(OSCCTRL1);
mStar_WriteByte(LVSST_H, regByte|BIT7);
Delay1ms(20);
lineLength=mStar_ReadWord(LSLW_H);
if (lineLength>0x7FF)
{ lineLength=mStar_ReadWord(LFRST_H)+lineLength-0x7FF;
mStar_WriteByte(OSCCTRL1, regByte2&0xFC);
mStar_WriteWord(LRSV_H, 0x7FF);
mStar_WriteWord(LFRST_H, lineLength);
Delay1ms(30);
mStar_WriteByte(OSCCTRL1, regByte2);
}
mStar_WriteByte(LVSST_H, regByte);
}
#endif
#ifdef LG17LVDS
void FixShortLine_LG(void)
{BYTE regValue1,regValue2;
BYTE i;
BYTE shortlineH,shortlineL;
BYTE temp;
WORD shortline;
BYTE temp2;
ForceDelay1ms(80);
regValue1 = mStar_ReadByte(OSCCTRL1);
regValue2 = mStar_ReadByte(LPLL_M);
mStar_WriteByte(OSCCTRL1, 0x00); // set mode-0.
mStar_WriteByte(LPLL_M, regValue2 & 0xbf); // turn SSC off.
ForceDelay1ms(80);
for (i = 0; i < 10; i++) {
do {
shortlineH = mStar_ReadByte(0x94);
shortlineL = mStar_ReadByte(0x93);
temp = mStar_ReadByte(0x94);
shortline = mStar_ReadWord(0x94);
} while (shortlineH != temp);
if((abs(shortline-0x4ea)<0x30))
{
temp2 = mStar_ReadByte(LPLL_SET_L) ;
mStar_WriteByte(LPLL_SET_L, temp2);
temp2 = mStar_ReadByte(LPLL_SET_M) ;
mStar_WriteByte(LPLL_SET_M, (temp2+1));
temp2 = mStar_ReadByte(LPLL_SET_H) ;
mStar_WriteByte(LPLL_SET_H, temp2);
ForceDelay1ms(80);
}
}
mStar_WriteByte(OSCCTRL1, regValue1); // restore OSCTRL1.
mStar_WriteByte(LPLL_M, regValue2); // restore SSC setting.
}
#endif
//jon add imformation with QDI panel
#if PanelQDI17L
void FixShortLine()
{ BYTE regValue;
DWORD Value;
WORD sclk;
WORD HTValue;
WORD HTV1;
WORD LSSV1;//,LSSV2;
WORD LSLWV1;
mStar_WriteByte(LVSST_H, 0x80); // for read data more stable
if ((abs(mStar_ReadWord(0x92)-0x3ff)) < 0x10) //0x92 Locking Short Line Vertical Position
{
mStar_WriteByte(0xd6,mStar_ReadByte(0xd6)+1);
mStar_WriteByte(0xd7,mStar_ReadByte(0xd7));
sclk=GetVSyncTime()*6;
Delay1ms(sclk);
}
mStar_WriteByte(LVSST_H, 0x00);
//LSSV1 = mStar_ReadWord(LVSST_H); // OK
regValue=mStar_ReadByte(OSCCTRL1);
mStar_WriteByte(OSCCTRL1, 0x00); //
mStar_WriteByte(0xd3, 0x08);
//LSSV2 = mStar_ReadWord(0x96); NG
sclk=GetVSyncTime()*6;
Delay1ms(sclk);
HTV1 = mStar_ReadWord(HDTOT_H) + 1;
//HDTOT[10:0] Output Horizontal total
//. 53fh Recommended value for XGA output (power on default value is 3)
//. 697h Recommended value for SXGA output
//HTV1 = mStar_ReadWord(LVSST_H);
//SYSHPeriod2 = mStar_ReadWord(LVSST_H);
LSSV1 = mStar_ReadWord(LVSST_H);// Locking Vertical Total Line Number
LSLWV1 = mStar_ReadWord(LSLW_H); //Locking Short Line Width
Value = (DWORD)((DWORD)(LSSV1-0x400)*(DWORD)HTV1)+LSLWV1;//+(DWORD)((DWORD)(mStar_ReadWord(HDTOT_H))-0x500);
//SYSHPeriod = Value;//(Value >> 16) & 0xFFFF;
HTValue = HTV1-0x500;
Value += (DWORD)HTValue;
Value %= 0x1000;
printData("Value %d ", Value) ; //dragon 0608 .
//Giotto=LSLWV1;
#if 1 // 20030804
//if ( (abs(Value-0xe20)) < 400)
//if ( (abs(Value-0xea0)) < 60 || (abs(Value-0xa00)) < 80 || (abs(Value-0x6a0)) < 80)//(abs(Value-0x6a0)) < 60)
// if ( (Value>3684 && Value<3830) || (Value>2465 && Value<2640) || (Value>1616 && Value<1776))//(abs(Value-0x6a0)) < 60)
//if ( (Value>3684 && Value<4000) || (Value>2465 && Value<2640) || (Value>1616 && Value<1776))//(abs(Value-0x6a0)) < 60)
if ( (Value>3670 && Value<4000) || (Value>2465 && Value<2640) || (Value>1616 && Value<2100))//(abs(Value-0x6a0)) < 60) //dragon 0617
mStar_WriteWord(DEVEND_H, 0x400); //barry0604
//Output DE Vertical END
else
mStar_WriteWord(DEVEND_H, 0x3ff);
#endif
//mStar_WriteWord(DEVEND_H, 0x400);
// mStar_WriteByte(0xd3, 0x48);
// mStar_WriteByte(0xd3, 0x08); //dragon 0616.
mStar_WriteByte(OSCCTRL1, regValue); //
}
#endif // PanelQDI17L
//jon add
#if Giotto
void CheckLineBuffer(void) //ASW 0721 solve dos-mode line-buffer over
{ WORD lineLength;
BYTE regByte=mStar_ReadByte(LVSST_H);
BYTE regByte2=mStar_ReadByte(OSCCTRL1);
mStar_WriteByte(LVSST_H, regByte|BIT7);
Delay1ms(45);
lineLength=mStar_ReadWord(LSLW_H);
if (lineLength>0x7F0)
{ lineLength=mStar_ReadWord(LFRST_H)+lineLength-0x7F0;
mStar_WriteByte(OSCCTRL1, regByte2&0xFC);
mStar_WriteWord(LRSV_H, 0x7F0);
mStar_WriteWord(LFRST_H, lineLength);
Delay1ms(45);
mStar_WriteByte(OSCCTRL1, regByte2);
}
mStar_WriteByte(LVSST_H, regByte);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -