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

📄 mstar.c

📁 完整的软件学习--显示器驱动视频软件
💻 C
📖 第 1 页 / 共 5 页
字号:
    else if (SrcInputType==Input_Analog2)
      regByte|=AMUX_B;
    mStar_WriteByte(REGBK, REGBANKADC);
    mStar_WriteByte(TESTEN, TSTEN_B);
    mStar_WriteByte(TESTA5, regByte);
    mStar_WriteByte(TESTA6, 0xF8);//0xE8);
#if (!PanelAUEN05&&(PanelAUEG01|PanelAUEG01_v2))
    mStar_WriteByte(TESTMOD, 0x08);//0x40);
#endif  
    mStar_WriteByte(TESTEN, 0);
    mStar_WriteByte(REGBK, REGBANKSCALER);
  }
  mStar_WriteByte(PDMD, PDDS_B|0x2|VDD2LOW);// power down chip except mode detection //2005-11-12 Update
#else
  mStar_WriteByte(PDMD, PDDS_B|0x3|VDD2LOW);// power down chip except mode detection //2005-11-12 Update
#endif
}

//*******************************************************************
// Function Name: mStar_InitADC
//
// Decscription: Initialize ADC bank registers
//
// callee: mStar_WriteByte() in ms_rwreg.c
//
// caller: mStar_Init() in mStar.c
//*******************************************************************
void mStar_InitADC(void)
{ 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);
  mStar_WriteByte(TESTA0, 0x20);//0x22);

/*  
#if (!PanelAUEN05&&!PanelAUEG01&&!PanelAUEG01_v2) //tony 20040117
  mStar_WriteByte(TESTMOD, 0x06);//0x08);//10);//0x22); //xxxx 20031118
#else
  mStar_WriteByte(TESTMOD, 0x10);//0x08);//10);//0x22); //xxxx 20031118
#endif
*/
#if (PanelCMO170E5|PanelM170E5)// by Max @Feb-07-2005
  mStar_WriteByte(TESTMOD, 0x12);
#else
  mStar_WriteByte(TESTMOD, 0x10);
#endif


#if ChipID>=ChipBB
  mStar_WriteByte(TESTA2, 0x00);
  mStar_WriteByte(0x36, 0x00);//0x10);//by Max @ Jan-24-2005
  mStar_WriteByte(0x33, 0x40);//Albert 20031009
#elif ChipID==ChipBA
  mStar_WriteByte(TESTA2, 0x04);
  mStar_WriteByte(0x36, 0x20);
#endif

#if NEWIC_18A
  mStar_WriteByte(0x3E, 0x83);
#elif NEWIC_18B
  mStar_WriteByte(0x3D, 0x10);
#endif

#if MSTMCU
	//for MCU ADC control
	#if GPIOKEY
  	mStar_WriteByte(0x62,0x60);///Enable SAR0
	#else
  	mStar_WriteByte(0x62, 0x06);//Enable SAR0,SAR1,SAR2
	#endif  
  	mStar_WriteByte(0x63, 0x05);    //   /     4);//(28.636/24) ~ 1.2MHz
  	mStar_WriteByte(0x60, 0x20);
	#if DoubleSpeed  
  		#if FLASHTYPE==FLASH_SST
 		mStar_WriteByte(0x66,0x37);
 		ForceDelay1ms(1);
 		mStar_WriteByte(0x66,0x3A);
 		ForceDelay1ms(1);
 		mStar_WriteByte(0x66,0x3B);
  		#else
 		mStar_WriteByte(0x66,0x27);
 		ForceDelay1ms(1);
 		mStar_WriteByte(0x66,0x2A);
 		ForceDelay1ms(1);
 		mStar_WriteByte(0x66,0x2B);
  		#endif
	#endif  
	#if SingleBoard
  	mStar_WriteByte(0x2F, 0x08); // ADC RB swap
	#endif
#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(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);

  mStar_WriteByte(OFC1, TCON_Format1);
  mStar_WriteByte(OFC2, (ESPP_B&ESP_AfterData) | (ESP_Offset<<4) |
  	                  (OSPP_B&OSP_AfterData) | OSP_Offset);

  mStar_WriteByte(ODPC, (PanelOESPCurrent<<6) | (PanelOEGCurrent<<4)); // setup output driving current
  mStar_WriteByte(ODC, (PanelEINVCurrent<<6) | (PanelOINVCurrent<<4)); // setup output driving current
  
#if PanelAUES05
  mStar_WriteByte(ODC, 0x03);
#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);
#elif PanelTTL
  mStar_WriteByte(REGBK, REGBANKTCON);

  mStar_WriteByte(OFC1, TCON_Format1);
	  mStar_WriteByte(OFC2, (ESPP_B&ESP_AfterData) | (ESP_Offset<<4) |
  	                  (OSPP_B&OSP_AfterData) | OSP_Offset);
	  
  mStar_WriteByte(ODPC, (PanelOESPCurrent<<6) | (PanelOEGCurrent<<4)); // setup output driving current
  mStar_WriteByte(ODC, (PanelEINVCurrent<<6) | (PanelOINVCurrent<<4)); // setup output driving current
  mStar_WriteByte(IFCTRL, OuputFormat);//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
}

//*******************************************************************
// 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)/5; i++)
  for (i=0; i<8; i++)	// sail modify 20040512
    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);
#if DisplayModeSelect//Max modify for ProView's require @Jan-11-2005
  if (UserPreDisplayMode==DisplayMode_Text)
  	Set_TextDisplayMode();
  else if (UserPreDisplayMode==DisplayMode_Web)
  	Set_WebDisplayMode();
  else if (UserPreDisplayMode==DisplayMode_Movie)
  	Set_MovieDisplayMode();
  else 
  	{
  	mStar_AdjustContrast(UserPrefContrast);
  	mStar_AdjustBrightness(UserPrefBrightness);
  	}
#endif
  // Restore other settings here
}

BYTE Check_Initial(void)
{
  WORD PLL_VALUE1;
  WORD PLL_VALUE2;

	PLL_VALUE1= mStar_ReadWord(LPLL_STEP_H);
	PLL_VALUE2= mStar_ReadWord(LPLL_SPAN_H);

	if (PLL_VALUE2==SSCSPAN && PLL_VALUE1==SSCSTEP) 
		return TRUE;
	else
		return FALSE;
}

#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(40);
  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(40);
      mStar_WriteByte(OSCCTRL1, regByte2);
    }
  mStar_WriteByte(LVSST_H, regByte);
}
#endif

#if PanelLGx08//PRV765_A_LG
//tony 20040116 for LG170E01 1 line Gitter
void ModeTrack(void)
{
	WORD ShortLine, OclkSet;
	BYTE temp,i=10;

    temp=mStar_ReadByte(OSCCTRL1);	
	mStar_WriteByte(OSCCTRL1, 0);		// set to 0 to get the short line value
	Delay1ms(100);
	ShortLine = mStar_ReadWord(LSLW_H);	// short line value (0x94,0x93)

	while((ShortLine>0x4c0)&&(ShortLine<0x520)&&(--i>0))
	{
		OclkSet = mStar_ReadWord(LPLL_SET_H); 	// in problem range, 													// change clock a little
		OclkSet--;
		mStar_WriteWord(LPLL_SET_H, OclkSet);
		mStar_WriteByte(OSCCTRL1, 0x63);		// enable Htotal tuningg
		Delay1ms(50);
		mStar_WriteByte(OSCCTRL1, 0);		// to get real short line value
		Delay1ms(50);
		ShortLine = mStar_ReadWord(LSLW_H);	// short line value (0x94,0x93)
		if(i==9)
		#if DEBUG_ENABLE	
		printMsg("short line");
		#endif
	}
	mStar_WriteByte(OSCCTRL1, temp);// set to original setting
}

//---------------------------------------------------------------------------------
#elif (PanelAUEN05|PanelAU150XN07|PanelCPT190EA03|PanelAUEG01|PanelAUEG01_v2|PanelAUEG01_v2)

#if (PanelAUEN05|PanelAUEG01)
#define MaxLineRange	610+50
#define MinLineRange	610-50
#elif PanelAU150XN07
#define MaxLineRange	170+50
#define MinLineRange	170-50
#elif PanelCPT190EA03
#define MaxLineRange	1450+140
#define MinLineRange	1450-140
#elif PanelAUEG01_v2
#define MaxLineRange 1185+135//PDateofPanel:041013//at up right corner
#define MinLineRange 1185-135
#define MaxLineRangeUL 730+30//PDateofPanel:040915//at up left corner
#define MinLineRangeUL 730-30
#endif

void ModeTrack(DWORD factor)
{ BYTE i, retry;
  WORD shortLine1, shortLine2;
  BYTE delayTime;
  WORD count;
  BYTE regValue1;//, regValue2;

  regValue1=mStar_ReadByte(LPLL_M);
  mStar_WriteByte(LPLL_M, regValue1&~BIT6); //Spread spectrum disable
  delayTime=GetVSyncTime()*4;

  for (i=0; i<35; i++)
    { mStar_ResetDClkPLL(); // reset output PLL to prevent PLL works abnormally
      Delay1ms(delayTime);
      count=0;
      retry=0;
      short

⌨️ 快捷键说明

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