8 #include <linux/types.h>
9 #include <linux/version.h>
16 #include "vb_struct.h"
22 #define IndexMask 0xff
23 #ifndef XGI_MASK_DUAL_CHIP
24 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
29 BOOLEAN XGI_IsLCDDualLink(PVB_DEVICE_INFO pVBInfo);
30 BOOLEAN XGI_SetCRT2Group301(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
31 BOOLEAN XGI_BacklightByDrv(PVB_DEVICE_INFO pVBInfo);
33 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo);
34 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo);
35 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo);
36 BOOLEAN XGI_AjustCRT2Rate(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,USHORT *i, PVB_DEVICE_INFO pVBInfo);
37 BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
38 BOOLEAN XGI_GetLCDInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
39 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo ) ;
40 BOOLEAN XGI_BridgeIsOn(PVB_DEVICE_INFO pVBInfo);
41 UCHAR XGI_GetModePtr( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
42 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
43 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
44 USHORT XGI_GetResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
45 USHORT XGI_GetColorDepth(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
46 USHORT XGI_GetVGAHT2(PVB_DEVICE_INFO pVBInfo);
47 USHORT XGI_GetVCLK2Ptr(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
48 void XGI_VBLongWait(PVB_DEVICE_INFO pVBInfo);
49 void XGI_SaveCRT2Info(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo);
50 void XGI_GetCRT2Data(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
51 void XGI_GetCRT2ResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
52 void XGI_PreSetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
53 void XGI_SetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
54 void XGI_SetLockRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
55 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
56 void XGI_SetGroup2(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
57 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
58 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
59 void XGI_SetGroup5(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
60 void* XGI_GetLcdPtr(USHORT BX, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
61 void* XGI_GetTVPtr(USHORT BX, USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
62 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo);
63 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
64 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
65 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
66 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
67 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo);
68 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo);
69 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo);
70 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo);
72 void XGI_DisplayOn(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
73 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
74 void XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
75 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
76 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
77 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
78 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
79 void XGI_UpdateXG21CRTC(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo, USHORT RefreshRateTableIndex);
80 void XGI_WaitDisply(PVB_DEVICE_INFO pVBInfo);
81 void XGI_SenseCRT1(PVB_DEVICE_INFO pVBInfo);
82 void XGI_SetSeqRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
83 void XGI_SetMiscRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
84 void XGI_SetCRTCRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
85 void XGI_SetATTRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
86 void XGI_SetGRCRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
87 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo);
89 void XGI_SetSync(USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
90 void XGI_SetCRT1CRTC(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
91 void XGI_SetCRT1Timing_H(PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
92 void XGI_SetCRT1Timing_V(USHORT ModeIdIndex,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);
93 void XGI_SetCRT1DE(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
94 void XGI_SetCRT1VCLK(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
95 void XGI_SetCRT1FIFO(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
96 void XGI_SetCRT1ModeRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
97 void XGI_SetVCLKState(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
99 void XGI_LoadDAC(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
100 void XGI_WriteDAC(USHORT dl, USHORT ah, USHORT al, USHORT dh, PVB_DEVICE_INFO pVBInfo);
101 /*void XGI_ClearBuffer(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);*/
102 void XGI_SetLCDAGroup(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
103 void XGI_GetLVDSResInfo( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
104 void XGI_GetLVDSData(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
105 void XGI_ModCRT1Regs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
106 void XGI_SetLVDSRegs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
107 void XGI_UpdateModeInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
108 void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
109 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo);
110 void XGI_GetVBInfo(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
111 void XGI_GetTVInfo(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
112 void XGI_SetCRT2ECLK( USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
113 void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
114 void XGI_GetLCDSync(USHORT* HSyncWidth, USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo);
115 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
116 void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
117 void XGI_SetCRT2VCLK(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
118 void XGI_OEM310Setting(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
119 void XGI_SetDelayComp(PVB_DEVICE_INFO pVBInfo);
120 void XGI_SetLCDCap(PVB_DEVICE_INFO pVBInfo);
121 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
122 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
123 void SetSpectrum(PVB_DEVICE_INFO pVBInfo);
124 void XGI_SetAntiFlicker(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
125 void XGI_SetEdgeEnhance(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
126 void XGI_SetPhaseIncr(PVB_DEVICE_INFO pVBInfo);
127 void XGI_SetYFilter(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
128 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo);
129 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo );
130 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
131 void XGI_CloseCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
132 void XGI_OpenCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
133 void XGI_GetRAMDAC2DATA(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
134 void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
135 void XGI_LockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
136 void XGINew_EnableCRT2(PVB_DEVICE_INFO pVBInfo);
137 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo);
138 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo);
139 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo );
140 void XGI_GetLCDVCLKPtr(UCHAR* di_0,UCHAR *di_1, PVB_DEVICE_INFO pVBInfo);
141 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
142 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo);
143 USHORT XGI_GetLCDCapPtr(PVB_DEVICE_INFO pVBInfo);
144 USHORT XGI_GetLCDCapPtr1(PVB_DEVICE_INFO pVBInfo);
145 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo);
146 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
147 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
148 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo);
149 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo);
150 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
151 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
152 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
153 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
154 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
155 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
156 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo );
158 extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
160 /* USHORT XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
166 USHORT XGINew_MDA_DAC[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
167 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
168 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
169 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
170 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
171 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
172 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
173 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F};
175 USHORT XGINew_CGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
176 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
177 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
178 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
179 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
180 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
181 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
182 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
184 USHORT XGINew_EGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15,
185 0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35,
186 0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D,
187 0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D,
188 0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17,
189 0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37,
190 0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F,
191 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
193 USHORT XGINew_VGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
194 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
195 0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18,
196 0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F,
198 0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F,
199 0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00,
200 0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18,
201 0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04,
202 0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10,
203 0x0B,0x0C,0x0D,0x0F,0x10};
206 /* --------------------------------------------------------------------- */
207 /* Function : InitTo330Pointer */
211 /* --------------------------------------------------------------------- */
212 void InitTo330Pointer( UCHAR ChipType ,PVB_DEVICE_INFO pVBInfo)
214 pVBInfo->SModeIDTable = (XGI_StStruct *) XGI330_SModeIDTable ;
215 pVBInfo->StandTable = (XGI_StandTableStruct *) XGI330_StandTable ;
216 pVBInfo->EModeIDTable = (XGI_ExtStruct *) XGI330_EModeIDTable ;
217 pVBInfo->RefIndex = (XGI_Ext2Struct *) XGI330_RefIndex ;
218 pVBInfo->XGINEWUB_CRT1Table = (XGI_CRT1TableStruct *) XGI_CRT1Table ;
220 /* add for new UNIVGABIOS */
221 /* XGINew_UBLCDDataTable = (XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
222 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
225 if ( ChipType >= XG40 )
227 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI340New_MCLKData ;
228 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI340_ECLKData ;
232 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI330New_MCLKData ;
233 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI330_ECLKData ;
236 pVBInfo->VCLKData = (XGI_VCLKDataStruct *) XGI_VCLKData ;
237 pVBInfo->VBVCLKData = (XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
238 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
239 pVBInfo->StResInfo = (XGI_StResInfoStruct *) XGI330_StResInfo ;
240 pVBInfo->ModeResInfo = (XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
242 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
243 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
244 pVBInfo->pSR07 = &XGI330_SR07 ;
245 pVBInfo->LCDResInfo = 0 ;
246 pVBInfo->LCDTypeInfo = 0 ;
247 pVBInfo->LCDInfo = 0 ;
248 pVBInfo->VBInfo = 0 ;
252 pVBInfo->SR15 = XGI340_SR13 ;
253 pVBInfo->CR40 = XGI340_cr41 ;
254 pVBInfo->SR25 = XGI330_sr25 ;
255 pVBInfo->pSR31 = &XGI330_sr31 ;
256 pVBInfo->pSR32 = &XGI330_sr32 ;
257 pVBInfo->CR6B = XGI340_CR6B ;
258 pVBInfo->CR6E = XGI340_CR6E ;
259 pVBInfo->CR6F = XGI340_CR6F ;
260 pVBInfo->CR89 = XGI340_CR89 ;
261 pVBInfo->AGPReg = XGI340_AGPReg ;
262 pVBInfo->SR16 = XGI340_SR16 ;
263 pVBInfo->pCRCF = &XG40_CRCF ;
264 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
267 pVBInfo->CR49 = XGI330_CR49 ;
268 pVBInfo->pSR1F = &XGI330_SR1F ;
269 pVBInfo->pSR21 = &XGI330_SR21 ;
270 pVBInfo->pSR22 = &XGI330_SR22 ;
271 pVBInfo->pSR23 = &XGI330_SR23 ;
272 pVBInfo->pSR24 = &XGI330_SR24 ;
273 pVBInfo->pSR33 = &XGI330_SR33 ;
277 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
278 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
279 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
280 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
281 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
282 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
283 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
284 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
285 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
286 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
288 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
289 pVBInfo->PALTiming = XGI330_PALTiming ;
290 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
291 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
292 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
293 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
294 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
295 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
296 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
297 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
298 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
299 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
300 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
301 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
304 pVBInfo->TimingH = (XGI_TimingHStruct *) XGI_TimingH ;
305 pVBInfo->TimingV = (XGI_TimingVStruct *) XGI_TimingV ;
306 pVBInfo->UpdateCRT1 = (XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
308 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
309 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
310 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
311 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
313 /* 310 customization related */
314 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
315 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
317 pVBInfo->LCDCapList = XGI_LCDCapList ;
319 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
320 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
322 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
323 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
326 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
328 if ( ChipType >= XG20 )
329 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
331 if ( ChipType == XG27 )
333 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI27New_MCLKData ;
334 pVBInfo->CR40 = XGI27_cr41 ;
335 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
336 pVBInfo->pSR36 = &XG27_SR36 ;
337 pVBInfo->pCR8F = &XG27_CR8F ;
338 pVBInfo->pCRD0 = XG27_CRD0 ;
339 pVBInfo->pCRDE = XG27_CRDE ;
340 pVBInfo->pSR40 = &XG27_SR40 ;
341 pVBInfo->pSR41 = &XG27_SR41 ;
345 if ( ChipType >= XG20 )
347 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
348 pVBInfo->pCR2E = &XG21_CR2E ;
349 pVBInfo->pCR2F = &XG21_CR2F ;
350 pVBInfo->pCR46 = &XG21_CR46 ;
351 pVBInfo->pCR47 = &XG21_CR47 ;
361 /* --------------------------------------------------------------------- */
362 /* Function : XGISetModeNew */
366 /* --------------------------------------------------------------------- */
367 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo )
370 /* PUCHAR pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
371 VB_DEVICE_INFO VBINF;
372 PVB_DEVICE_INFO pVBInfo = &VBINF;
373 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
374 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
375 pVBInfo->IF_DEF_LVDS = 0 ;
376 pVBInfo->IF_DEF_CH7005 = 0 ;
377 pVBInfo->IF_DEF_LCDA = 1 ;
378 pVBInfo->IF_DEF_CH7017 = 0 ;
379 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
380 pVBInfo->IF_DEF_VideoCapture = 0 ;
381 pVBInfo->IF_DEF_ScaleLCD = 0 ;
382 pVBInfo->IF_DEF_OEMUtil = 0 ;
383 pVBInfo->IF_DEF_PWD = 0 ;
386 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
388 pVBInfo->IF_DEF_YPbPr = 0 ;
389 pVBInfo->IF_DEF_HiVision = 0 ;
390 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
391 pVBInfo->VBType = 0 ; /*set VBType default 0*/
393 else if ( HwDeviceExtension->jChipType >= XG40 )
395 pVBInfo->IF_DEF_YPbPr = 1 ;
396 pVBInfo->IF_DEF_HiVision = 1 ;
397 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
401 pVBInfo->IF_DEF_YPbPr = 1 ;
402 pVBInfo->IF_DEF_HiVision = 1 ;
403 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
406 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
407 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
408 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
409 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
410 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
411 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
412 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
413 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
414 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
415 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
416 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
417 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
418 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
419 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
420 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
421 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
422 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
423 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
425 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
427 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
429 pVBInfo->IF_DEF_LVDS = 1 ;
432 if ( HwDeviceExtension->jChipType == XG27 )
434 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
436 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
438 pVBInfo->IF_DEF_LVDS = 1 ;
443 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
444 XGI_GetVBType( pVBInfo ) ;
446 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
449 ModeNo = ModeNo & 0x7F ;
450 /* XGINew_flag_clearbuffer = 0 ; */
454 XGINew_flag_clearbuffer = 1 ;
457 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
459 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
460 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
462 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
464 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
466 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
468 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
469 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
470 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
471 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
472 /* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
474 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
476 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
478 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
480 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
485 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
487 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
488 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
490 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
495 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
497 switch( HwDeviceExtension->ujVBChipID )
500 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
504 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
512 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
513 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
514 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
515 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
521 if ( pVBInfo->IF_DEF_LVDS == 1 )
523 if ( !XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo) )
529 if ( ModeNo <= 0x13 )
531 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
535 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
538 pVBInfo->SetFlag = 0 ;
539 if ( pVBInfo->IF_DEF_CH7007 != 1 )
541 pVBInfo->VBInfo = DisableCRT2Display ;
545 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
547 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
549 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
551 if( HwDeviceExtension->jChipType == XG21 )
552 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
558 if ( ModeNo <= 0x13 )
560 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
564 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
566 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
567 pVBInfo->SetFlag = 0x00 ;
568 pVBInfo->VBInfo = DisableCRT2Display ;
569 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
574 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
575 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
576 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
579 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
581 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
583 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
590 /* --------------------------------------------------------------------- */
591 /* Function : XGI_SetCRT1Group */
595 /* --------------------------------------------------------------------- */
596 void XGI_SetCRT1Group( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
598 USHORT StandTableIndex ,
599 RefreshRateTableIndex ,
603 USHORT XGINew_P3cc = pVBInfo->P3cc;
605 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
606 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
607 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
608 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
609 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
610 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
611 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
612 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
613 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
614 XGI_ClearExt1Regs(pVBInfo) ;
616 /* if ( pVBInfo->IF_DEF_ExpLink ) */
617 if ( HwDeviceExtension->jChipType == XG27 )
619 if ( pVBInfo->IF_DEF_LVDS == 0 )
621 XGI_SetDefaultVCLK( pVBInfo ) ;
625 temp = ~ProgrammingCRT2 ;
626 pVBInfo->SetFlag &= temp ;
627 pVBInfo->SelectCRT2Rate = 0 ;
629 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
631 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
633 pVBInfo->SetFlag |= ProgrammingCRT2 ;
637 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
638 if ( RefreshRateTableIndex != 0xFFFF )
640 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
641 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
642 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
643 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
644 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
647 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
648 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
650 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
652 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
653 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
654 b3CC =(UCHAR) XGINew_GetReg2(XGINew_P3cc) ;
655 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
657 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
659 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
660 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
661 b3CC = (UCHAR)XGINew_GetReg2(XGINew_P3cc) ;
662 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
666 if ( HwDeviceExtension->jChipType >= XG21 )
668 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
672 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
673 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
674 /* XG21 CRT1 Timing */
675 if ( HwDeviceExtension->jChipType == XG27 )
676 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
678 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
680 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
682 if ( HwDeviceExtension->jChipType == XG27 )
683 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
685 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
687 if ( pVBInfo->IF_DEF_LVDS == 1 )
689 if ( HwDeviceExtension->jChipType == XG27 )
690 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
692 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
694 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
698 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
699 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
700 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
703 /* XGI_LoadCharacter(); //dif ifdef TVFont */
705 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
706 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
710 /* --------------------------------------------------------------------- */
711 /* Function : XGI_GetModePtr */
715 /* --------------------------------------------------------------------- */
716 UCHAR XGI_GetModePtr( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
720 if ( ModeNo <= 0x13 )
721 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
724 if ( pVBInfo->ModeType <= 0x02 )
725 index = 0x1B ; /* 02 -> ModeEGA */
729 return( index ) ; /* Get pVBInfo->StandTable index */
733 /* --------------------------------------------------------------------- */
734 /* Function : XGI_SetBIOSData */
738 /* --------------------------------------------------------------------- */
739 /*UCHAR XGI_SetBIOSData( USHORT ModeNo , USHORT ModeIdIndex )
745 /* --------------------------------------------------------------------- */
746 /* Function : XGI_ClearBankRegs */
750 /* --------------------------------------------------------------------- */
751 /*UCHAR XGI_ClearBankRegs( USHORT ModeNo , USHORT ModeIdIndex )
757 /* --------------------------------------------------------------------- */
758 /* Function : XGI_SetSeqRegs */
762 /* --------------------------------------------------------------------- */
763 void XGI_SetSeqRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
771 if ( ModeNo <= 0x13 )
772 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
774 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
776 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
777 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
780 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
786 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
788 if ( pVBInfo->VBInfo & SetInSlaveMode )
793 tempah |= 0x20 ; /* screen off */
794 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
796 for( i = 02 ; i <= 04 ; i++ )
798 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
799 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
804 /* --------------------------------------------------------------------- */
805 /* Function : XGI_SetMiscRegs */
809 /* --------------------------------------------------------------------- */
810 void XGI_SetMiscRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
814 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
816 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
818 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
825 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
829 /* --------------------------------------------------------------------- */
830 /* Function : XGI_SetCRTCRegs */
834 /* --------------------------------------------------------------------- */
835 void XGI_SetCRTCRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
840 CRTCdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
842 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
844 for( i = 0 ; i <= 0x18 ; i++ )
846 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
847 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
850 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
852 if ( pVBInfo->VBInfo & SetInSlaveMode )
854 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
856 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
864 /* --------------------------------------------------------------------- */
869 /* --------------------------------------------------------------------- */
870 void XGI_SetATTRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
876 if ( ModeNo <= 0x13 )
877 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
879 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
881 for( i = 0 ; i <= 0x13 ; i++ )
883 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
884 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
888 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
892 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
894 if ( pVBInfo->VBInfo & SetInSlaveMode )
901 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
902 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
903 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
906 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
907 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
908 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
909 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
910 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
914 /* --------------------------------------------------------------------- */
915 /* Function : XGI_SetGRCRegs */
919 /* --------------------------------------------------------------------- */
920 void XGI_SetGRCRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
925 for( i = 0 ; i <= 0x08 ; i++ )
927 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
928 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
931 if ( pVBInfo->ModeType > ModeVGA )
933 GRdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3ce , 0x05 ) ;
934 GRdata &= 0xBF ; /* 256 color disable */
935 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
940 /* --------------------------------------------------------------------- */
941 /* Function : XGI_ClearExt1Regs */
945 /* --------------------------------------------------------------------- */
946 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo)
950 for( i = 0x0A ; i <= 0x0E ; i++ )
951 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
955 /* --------------------------------------------------------------------- */
956 /* Function : XGI_SetDefaultVCLK */
960 /* --------------------------------------------------------------------- */
961 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo )
964 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
965 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
966 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
968 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
969 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
970 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
972 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
977 /* --------------------------------------------------------------------- */
978 /* Function : XGI_GetRatePtrCRT2 */
982 /* --------------------------------------------------------------------- */
983 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
985 SHORT LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
986 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
988 USHORT RefreshRateTableIndex , i ,
989 modeflag , index , temp ;
991 if ( ModeNo <= 0x13 )
993 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
997 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1000 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1002 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1004 if ( modeflag & HalfDCLK )
1009 if ( ModeNo < 0x14 )
1012 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1013 index = index >> pVBInfo->SelectCRT2Rate ;
1016 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1022 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1024 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1026 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1032 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1034 if( pVBInfo->IF_DEF_LVDS == 0 )
1036 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1037 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1039 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1053 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1054 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1055 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1058 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1063 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1064 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1068 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1069 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1070 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1074 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1075 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1084 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1086 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1087 temp &= ModeInfoFlag ;
1088 if ( temp < pVBInfo->ModeType )
1093 } while( index != 0xFFFF ) ;
1094 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1096 if ( pVBInfo->VBInfo & SetInSlaveMode )
1098 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1099 if ( temp & InterlaceMode )
1106 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1108 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1110 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1114 /* --------------------------------------------------------------------- */
1115 /* Function : XGI_AjustCRT2Rate */
1119 /* --------------------------------------------------------------------- */
1120 BOOLEAN XGI_AjustCRT2Rate( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , USHORT *i, PVB_DEVICE_INFO pVBInfo )
1128 if ( ModeNo <= 0x13 )
1130 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1134 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1137 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1138 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1141 if ( pVBInfo->IF_DEF_LVDS == 0 )
1143 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1145 tempax |= SupportRAMDAC2 ;
1147 if ( pVBInfo->VBType & VB_XGI301C )
1148 tempax |= SupportCRT2in301C ;
1151 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1153 tempax |= SupportLCD ;
1155 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1157 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1159 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1171 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1173 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1175 tempax |= SupportYPbPr ;
1176 if ( pVBInfo->VBInfo & SetInSlaveMode )
1190 tempax |= SupportHiVisionTV ;
1191 if ( pVBInfo->VBInfo & SetInSlaveMode )
1198 if ( pVBInfo->SetFlag & TVSimuMode )
1209 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1211 tempax |= SupportTV ;
1213 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1215 tempax |= SupportTV1024 ;
1218 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1220 if ( modeflag & NoSupportSimuTV )
1222 if ( pVBInfo->VBInfo & SetInSlaveMode )
1224 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1236 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1238 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1240 tempax |= SupportCHTV ;
1244 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1246 tempax |= SupportLCD ;
1248 if ( resinfo > 0x08 )
1249 return( 0 ) ; /* 1024x768 */
1251 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1253 if ( resinfo > 0x07 )
1254 return( 0 ) ; /* 800x600 */
1256 if ( resinfo == 0x04 )
1257 return( 0 ) ; /* 512x384 */
1262 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1264 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1265 if ( infoflag & tempax )
1273 for( ( *i ) = 0 ; ; ( *i )++ )
1275 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1276 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1281 if ( infoflag & tempax )
1290 /* --------------------------------------------------------------------- */
1291 /* Function : XGI_SetSync */
1295 /* --------------------------------------------------------------------- */
1296 void XGI_SetSync(USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1301 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1305 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1309 /* --------------------------------------------------------------------- */
1310 /* Function : XGI_SetCRT1CRTC */
1314 /* --------------------------------------------------------------------- */
1315 void XGI_SetCRT1CRTC( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1322 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1323 index = index&IndexMask ;
1325 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1327 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1329 for( i = 0 ; i < 8 ; i++ )
1330 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1332 for( i = 0 ; i < 7 ; i++ )
1333 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1335 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1339 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1342 if( pVBInfo->ModeType > 0x03 )
1343 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1347 /* --------------------------------------------------------------------- */
1348 /* Function : XGI_SetCRT1Timing_H */
1352 /* --------------------------------------------------------------------- */
1353 void XGI_SetCRT1Timing_H( PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1355 UCHAR data , data1, pushax;
1358 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1359 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1360 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1362 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ; /* unlock cr0-7 */
1364 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1366 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1367 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1369 for( i = 0x01 ; i <= 0x04 ; i++ )
1371 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
1372 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 1 ) , data ) ;
1375 for( i = 0x05 ; i <= 0x06 ; i++ )
1377 data = pVBInfo->TimingH[ 0 ].data[ i ];
1378 XGINew_SetReg1( pVBInfo->P3c4 ,( USHORT )( i + 6 ) , data ) ;
1381 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1383 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1386 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1388 if ( HwDeviceExtension->jChipType >= XG20 )
1390 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x04 ) ;
1392 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1393 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x05 ) ;
1400 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0c ) ;
1402 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1407 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1408 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1414 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1419 /* --------------------------------------------------------------------- */
1420 /* Function : XGI_SetCRT1Timing_V */
1424 /* --------------------------------------------------------------------- */
1425 void XGI_SetCRT1Timing_V( USHORT ModeIdIndex , USHORT ModeNo,PVB_DEVICE_INFO pVBInfo )
1430 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1431 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1432 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1434 for( i = 0x00 ; i <= 0x01 ; i++ )
1436 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1437 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 6 ) , data ) ;
1440 for( i = 0x02 ; i <= 0x03 ; i++ )
1442 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1443 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x0e ) , data ) ;
1446 for( i = 0x04 ; i <= 0x05 ; i++ )
1448 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1449 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x11 ) , data ) ;
1452 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0a ) ;
1454 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1457 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1459 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1463 if ( ModeNo <= 0x13 )
1464 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1466 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1468 i &= DoubleScanMode ;
1472 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x09 ) ;
1475 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1479 /* --------------------------------------------------------------------- */
1480 /* Function : XGI_SetXG21CRTC */
1481 /* Input : Stand or enhance CRTC table */
1482 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1483 /* Description : Set LCD timing */
1484 /* --------------------------------------------------------------------- */
1485 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1487 UCHAR StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1488 USHORT Temp1, Temp2, Temp3 ;
1490 if ( ModeNo <= 0x13 )
1492 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1493 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1494 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1495 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1496 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1498 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1499 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1500 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1501 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1502 Tempdx <<= 2 ; /* Tempdx << 2 */
1503 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1504 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1506 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1507 Tempbx = Tempax ; /* Tempbx=Tempax */
1508 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1509 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1510 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1511 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1512 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1513 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1514 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1515 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1517 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] UCHAR -> USHORT */
1518 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1519 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1520 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1521 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1523 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1524 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1525 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1526 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1527 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1528 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1529 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1530 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1531 Tempax = (UCHAR)Temp2 ; /* Tempax[7:0]: VRE[7:0] */
1532 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1533 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1534 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1535 Tempbx = (UCHAR)Temp1 ; /* Tempbx[1:0]: VRS[10:9] */
1536 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1538 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1542 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1543 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1544 Tempcx = Tempax ; /* Tempcx: HRS */
1545 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1547 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1548 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1549 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1550 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1551 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1553 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1554 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1556 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1557 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1558 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1559 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1561 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1562 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1564 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1565 if( Tempax < Tempcx ) /* HRE < HRS */
1566 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1569 Tempax = (UCHAR)Temp2 ; /* Tempax: HRE[7:0] */
1570 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1571 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1572 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1573 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1574 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1576 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1577 Tempbx = Tempax ; /* Tempbx: VRS */
1578 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1579 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1580 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1581 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1582 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1583 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1584 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1585 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1587 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1588 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1589 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1591 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1592 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1593 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1594 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1596 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1597 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1599 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1600 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1601 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1602 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1603 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1604 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1605 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1606 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1608 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1609 if ( Tempax < Temp3 ) /* VRE < VRS */
1610 Temp2 |= 0x20 ; /* VRE + 0x20 */
1613 Tempax = (UCHAR)Temp2 ; /* Tempax: VRE[7:0] */
1614 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1615 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1616 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1617 Tempbx = (UCHAR)Temp1 ;
1618 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1620 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1624 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1626 USHORT StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1628 if ( ModeNo <= 0x13 )
1630 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1631 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1632 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1633 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1634 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1636 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1637 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1638 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1639 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1640 Tempdx <<= 2 ; /* Tempdx << 2 */
1641 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1642 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1644 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1645 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1646 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1647 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1648 Tempbx = Tempax ; /* Tempbx=CR07 */
1649 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1651 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1652 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1653 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1656 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1657 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1658 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1659 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1660 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1661 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1662 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1663 Tempax = (UCHAR)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1664 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1665 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1666 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1667 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1671 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1672 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1673 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1674 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1676 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1677 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1678 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1680 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1681 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1682 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1684 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1685 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1686 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1687 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1689 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1690 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1692 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1693 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1694 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1695 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1697 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1698 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1699 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1700 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1701 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1702 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1704 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1705 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1707 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1708 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1709 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1710 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1711 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1712 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1713 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1714 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1715 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1716 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1717 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1720 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1721 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1722 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1723 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1724 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1725 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1726 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1727 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1728 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1730 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1731 Tempbx |= 0x20 ; /* VRE + 0x20 */
1733 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1734 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1735 Tempax = Tempcx >> 8;
1736 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1741 /* --------------------------------------------------------------------- */
1742 /* Function : XGI_SetXG21LCD */
1744 /* Output : FCLK duty cycle, FCLK delay compensation */
1745 /* Description : All values set zero */
1746 /* --------------------------------------------------------------------- */
1747 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1749 USHORT Data , Temp , b3CC ;
1752 XGI_P3cc = pVBInfo->P3cc ;
1754 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1755 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1756 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1757 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1758 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1760 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1761 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1762 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1763 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1766 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1770 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1771 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1774 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1776 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1777 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1779 if ( ModeNo <= 0x13 )
1781 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1783 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1785 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1789 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1790 if ( Data & 0x4000 )
1791 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1792 if ( Data & 0x8000 )
1793 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1797 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1799 USHORT Data , Temp , b3CC ;
1802 XGI_P3cc = pVBInfo->P3cc ;
1804 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1805 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1806 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1807 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1809 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1810 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1812 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1813 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1816 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1818 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1819 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1820 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1821 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1824 XGI_SetXG27FPBits(pVBInfo);
1826 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1828 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1829 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1831 if ( ModeNo <= 0x13 )
1833 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1835 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1837 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1841 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1842 if ( Data & 0x4000 )
1843 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1844 if ( Data & 0x8000 )
1845 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1849 /* --------------------------------------------------------------------- */
1850 /* Function : XGI_UpdateXG21CRTC */
1852 /* Output : CRT1 CRTC */
1853 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1854 /* --------------------------------------------------------------------- */
1855 void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT RefreshRateTableIndex )
1859 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1860 if ( ModeNo <= 0x13 )
1862 for( i = 0 ; i < 12 ; i++ )
1864 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1870 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1872 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1874 else if ( ModeNo == 0x2F )
1876 else if ( ModeNo == 0x50 )
1878 else if ( ModeNo == 0x59 )
1884 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1885 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1886 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1887 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1892 /* --------------------------------------------------------------------- */
1893 /* Function : XGI_SetCRT1DE */
1897 /* --------------------------------------------------------------------- */
1898 void XGI_SetCRT1DE( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo,USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1909 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1911 if ( ModeNo <= 0x13 )
1913 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1914 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1915 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1919 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1920 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1921 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1924 if ( modeflag & HalfDCLK )
1925 tempax = tempax >> 1 ;
1927 if ( ModeNo > 0x13 )
1929 if ( modeflag & HalfDCLK )
1930 tempax = tempax << 1 ;
1932 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1934 if ( temp & InterlaceMode )
1935 tempbx = tempbx >> 1 ;
1937 if ( modeflag & DoubleScanMode )
1938 tempbx = tempbx << 1 ;
1943 /* if ( !( modeflag & Charx8Dot ) ) */
1950 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1951 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1953 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
1954 XGINew_SetReg1( pVBInfo->P3d4 , 0x01 , ( USHORT )( tempcx & 0xff ) ) ;
1955 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x0b , ~0x0c , ( USHORT )( ( tempcx & 0x0ff00 ) >> 10 ) ) ;
1956 XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , ( USHORT )( tempbx & 0xff ) ) ;
1958 tempbx = tempbx >> 8 ;
1960 if ( tempbx & 0x01 )
1963 if ( tempbx & 0x02 )
1966 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
1967 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x07 ) ;
1971 if ( tempbx & 0x04 )
1974 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
1975 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
1979 /* --------------------------------------------------------------------- */
1980 /* Function : XGI_GetResInfo */
1984 /* --------------------------------------------------------------------- */
1985 USHORT XGI_GetResInfo(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
1989 if ( ModeNo <= 0x13 )
1991 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
1995 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
1997 return( resindex ) ;
2001 /* --------------------------------------------------------------------- */
2002 /* Function : XGI_SetCRT1Offset */
2006 /* --------------------------------------------------------------------- */
2007 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2017 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2019 temp = pVBInfo->ScreenOffset[ temp ] ;
2021 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2022 temp2 &= InterlaceMode ;
2027 temp2 = pVBInfo->ModeType - ModeEGA ;
2053 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2054 temp = temp * temp2 + temp2 / 2 ;
2059 DisplayUnit = temp ;
2061 temp = temp >> 8 ; /* ah */
2063 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2066 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2068 temp =( UCHAR )temp2 ;
2069 temp &= 0xFF ; /* al */
2070 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2072 /* SetDisplayUnit */
2073 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2074 temp2 &= InterlaceMode ;
2078 DisplayUnit = DisplayUnit << 5 ;
2079 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2080 al = DisplayUnit & 0x00ff ;
2086 if ( HwDeviceExtension->jChipType >= XG20 )
2087 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2090 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2094 /* --------------------------------------------------------------------- */
2095 /* Function : XGI_SetCRT1VCLK */
2099 /* --------------------------------------------------------------------- */
2100 void XGI_SetCRT1VCLK( USHORT ModeNo , USHORT ModeIdIndex ,
2101 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2103 UCHAR index , data ;
2106 if ( pVBInfo->IF_DEF_LVDS == 1 )
2108 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2109 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2110 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2111 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2112 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2113 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2115 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2117 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2118 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2119 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2120 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2121 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2122 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2123 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2124 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2128 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2129 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2130 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2131 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2132 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2133 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2136 if ( HwDeviceExtension->jChipType >= XG20 )
2138 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2140 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2141 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2142 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2149 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2155 /* --------------------------------------------------------------------- */
2156 /* Function : XGI_SetCRT1FIFO */
2160 /* --------------------------------------------------------------------- */
2161 void XGI_SetCRT1FIFO( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2165 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2167 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2169 if ( ModeNo > 0x13 )
2171 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2172 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2174 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2175 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2177 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2181 if (HwDeviceExtension->jChipType == XG27)
2183 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2184 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2186 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2190 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2191 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2193 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2197 if (HwDeviceExtension->jChipType == XG21)
2199 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2204 /* --------------------------------------------------------------------- */
2205 /* Function : XGI_SetCRT1ModeRegs */
2209 /* --------------------------------------------------------------------- */
2210 void XGI_SetCRT1ModeRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension ,
2211 USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2221 if ( ModeNo > 0x13 )
2223 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2224 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2227 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2229 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2230 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2232 if ( ModeNo > 0x13 )
2239 if ( ModeNo > 0x13 )
2241 if ( pVBInfo->ModeType > 0x02 )
2244 data3 = pVBInfo->ModeType - ModeVGA ;
2245 data3 = data3 << 2 ;
2250 data &= InterlaceMode ;
2255 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2256 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2257 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2258 if ( ModeNo <= 0x13 )
2259 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2261 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2264 if ( infoflag & InterlaceMode )
2268 else if ( xres == 1280 )
2272 data2 = data & 0x00FF ;
2273 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2274 data2 = ( data & 0xFF00 ) >> 8 ;
2275 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2277 if( modeflag & HalfDCLK )
2278 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2282 if ( modeflag & LineCompareOff )
2285 if ( ModeNo > 0x13 )
2287 if ( pVBInfo->ModeType == ModeEGA )
2291 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2293 if ( pVBInfo->ModeType != ModeText )
2295 data = data ^ 0x60 ;
2296 if ( pVBInfo->ModeType != ModeEGA )
2298 data = data ^ 0xA0 ;
2301 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2303 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2305 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2306 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2307 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2309 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2311 if (HwDeviceExtension->jChipType == XG27 )
2317 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2318 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2321 if (HwDeviceExtension->jChipType >= XG20 )
2327 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2328 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2336 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2342 /* --------------------------------------------------------------------- */
2343 /* Function : XGI_SetVCLKState */
2347 /* --------------------------------------------------------------------- */
2348 void XGI_SetVCLKState( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2356 if ( ModeNo <= 0x13 )
2360 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2361 index &= IndexMask ;
2362 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2365 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2368 data |= 0x0c ; /* VCLK > 200 */
2370 if ( HwDeviceExtension->jChipType >= XG20 )
2371 data &= ~0x04 ; /* 2 pixel mode */
2373 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2375 if ( HwDeviceExtension->jChipType < XG20 )
2377 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2381 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2384 /* Jong for Adavantech LCD ripple issue
2385 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2387 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2389 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2391 else if ( VCLK > 260 )
2396 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2397 if (HwDeviceExtension->jChipType >= XG27 )
2399 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2406 /* --------------------------------------------------------------------- */
2407 /* Function : XGI_VesaLowResolution */
2411 /* --------------------------------------------------------------------- */
2412 /*void XGI_VesaLowResolution( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo)
2416 if ( ModeNo > 0x13 )
2417 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2419 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2421 if ( ModeNo > 0x13 )
2423 if ( modeflag & DoubleScanMode )
2425 if ( modeflag & HalfDCLK )
2427 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2429 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2431 if ( pVBInfo->VBInfo & SetInSlaveMode )
2433 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2434 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2439 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2440 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2445 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2449 /* --------------------------------------------------------------------- */
2450 /* Function : XGI_LoadDAC */
2454 /* --------------------------------------------------------------------- */
2455 void XGI_LoadDAC( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2457 USHORT data , data2 , time ,
2458 i , j , k , m , n , o ,
2459 si , di , bx , dl , al , ah , dh ,
2462 if ( ModeNo <= 0x13 )
2463 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2465 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2467 data &= DACInfoFlag ;
2471 table = XGINew_MDA_DAC ;
2472 else if ( data == 0x08 )
2473 table = XGINew_CGA_DAC ;
2474 else if ( data == 0x10 )
2475 table = XGINew_EGA_DAC ;
2476 else if ( data == 0x18 )
2479 table = XGINew_VGA_DAC ;
2487 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2488 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2490 for( i = 0 ; i < j ; i++ )
2494 for( k = 0 ; k < 3 ; k++ )
2504 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2511 for( i = 16 ; i < 32 ; i++ )
2515 for( k = 0 ; k < 3 ; k++ )
2516 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2521 for( m = 0 ; m < 9 ; m++ )
2527 for( n = 0 ; n < 3 ; n++ )
2529 for( o = 0 ; o < 5 ; o++ )
2535 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2540 for( o = 0 ; o < 3 ; o++ )
2546 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2558 /* --------------------------------------------------------------------- */
2559 /* Function : XGI_WriteDAC */
2563 /* --------------------------------------------------------------------- */
2564 void XGI_WriteDAC( USHORT dl , USHORT ah , USHORT al , USHORT dh,PVB_DEVICE_INFO pVBInfo )
2566 USHORT temp , bh , bl ;
2589 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )dh ) ;
2590 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bh ) ;
2591 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bl ) ;
2595 /* --------------------------------------------------------------------- */
2596 /* Function : XGI_ClearBuffer */
2600 /* --------------------------------------------------------------------- */
2601 void XGI_ClearBuffer( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo, PVB_DEVICE_INFO pVBInfo)
2603 PVOID VideoMemoryAddress = ( PVOID )HwDeviceExtension->pjVideoMemoryAddress ;
2604 ULONG AdapterMemorySize = ( ULONG )HwDeviceExtension->ulVideoMemorySize ;
2608 if ( pVBInfo->ModeType >= ModeEGA )
2610 if ( ModeNo > 0x13 )
2612 AdapterMemorySize = 0x40000 ; /* clear 256k */
2613 /* GetDRAMSize( HwDeviceExtension ) ; */
2614 XGI_SetMemory( VideoMemoryAddress , AdapterMemorySize , 0 ) ;
2619 pBuffer = VideoMemoryAddress ;
2620 for( i = 0 ; i < 0x4000 ; i++ )
2621 pBuffer[ i ] = 0x0000 ;
2627 pBuffer = VideoMemoryAddress ;
2628 if ( pVBInfo->ModeType < ModeCGA )
2631 for ( i = 0 ; i < 0x4000 ; i++ )
2632 pBuffer[ i ] = 0x0720 ;
2636 XGI_SetMemory( VideoMemoryAddress , 0x8000 , 0 ) ;
2641 /* --------------------------------------------------------------------- */
2642 /* Function : XGI_SetLCDAGroup */
2646 /* --------------------------------------------------------------------- */
2647 void XGI_SetLCDAGroup( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2649 USHORT RefreshRateTableIndex ;
2652 /* pVBInfo->SelectCRT2Rate = 0 ; */
2654 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2655 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2656 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2657 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2658 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2659 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2660 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2664 /* --------------------------------------------------------------------- */
2665 /* Function : XGI_GetLVDSResInfo */
2669 /* --------------------------------------------------------------------- */
2670 void XGI_GetLVDSResInfo( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2672 USHORT resindex , xres , yres , modeflag ;
2674 if ( ModeNo <= 0x13 )
2676 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2680 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2684 /* if ( ModeNo > 0x13 ) */
2685 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2687 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2689 if ( ModeNo <= 0x13 )
2691 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2695 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2698 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2700 if ( ModeNo <= 0x13 )
2702 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2703 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2707 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2708 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2710 if ( ModeNo > 0x13 )
2712 if ( modeflag & HalfDCLK )
2715 if ( modeflag & DoubleScanMode )
2718 /* if ( modeflag & Charx8Dot ) */
2725 pVBInfo->VGAHDE = xres ;
2726 pVBInfo->HDE = xres ;
2727 pVBInfo->VGAVDE = yres ;
2728 pVBInfo->VDE = yres ;
2732 /* --------------------------------------------------------------------- */
2733 /* Function : XGI_GetLVDSData */
2737 /* --------------------------------------------------------------------- */
2738 void XGI_GetLVDSData( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2741 XGI330_LVDSDataStruct *LCDPtr = NULL ;
2742 XGI330_CHTVDataStruct *TVPtr = NULL ;
2746 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2748 LCDPtr = ( XGI330_LVDSDataStruct * )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo) ;
2749 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2750 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2751 pVBInfo->HT = LCDPtr->LCDHT ;
2752 pVBInfo->VT = LCDPtr->LCDVT ;
2754 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2756 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2758 TVPtr = ( XGI330_CHTVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2759 pVBInfo->VGAHT = TVPtr->VGAHT ;
2760 pVBInfo->VGAVT = TVPtr->VGAVT ;
2761 pVBInfo->HT = TVPtr->LCDHT ;
2762 pVBInfo->VT = TVPtr->LCDVT ;
2766 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2768 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2770 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2772 pVBInfo->HDE = 1024 ;
2773 pVBInfo->VDE = 768 ;
2775 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2777 pVBInfo->HDE = 1280 ;
2778 pVBInfo->VDE = 1024 ;
2780 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2782 pVBInfo->HDE = 1400 ;
2783 pVBInfo->VDE = 1050 ;
2787 pVBInfo->HDE = 1600 ;
2788 pVBInfo->VDE = 1200 ;
2795 /* --------------------------------------------------------------------- */
2796 /* Function : XGI_ModCRT1Regs */
2800 /* --------------------------------------------------------------------- */
2801 void XGI_ModCRT1Regs( USHORT ModeNo , USHORT ModeIdIndex ,
2802 USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2806 XGI_LVDSCRT1HDataStruct *LCDPtr = NULL ;
2807 XGI_LVDSCRT1VDataStruct *LCDPtr1 =NULL ;
2808 /* XGI330_CHTVDataStruct *TVPtr = NULL ; */
2809 XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2810 XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2812 if( ModeNo <= 0x13 )
2813 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2815 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2817 index= index & IndexMask ;
2819 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2823 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2825 LCDPtr = ( XGI_LVDSCRT1HDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2827 for( i = 0 ; i < 8 ; i++ )
2828 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2831 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2833 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2835 CH7007TV_TimingHPtr = ( XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2837 for( i = 0 ; i < 8 ; i++ )
2838 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2842 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2844 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2845 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2848 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2850 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2852 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2853 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2858 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2860 LCDPtr1 = ( XGI_LVDSCRT1VDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2861 for( i = 0 ; i < 7 ; i++ )
2862 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2865 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2867 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2869 CH7007TV_TimingVPtr = ( XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2871 for( i = 0 ; i < 7 ; i++ )
2872 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2875 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2877 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2878 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2881 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2883 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2885 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2886 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2887 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2895 /* --------------------------------------------------------------------- */
2896 /* Function : XGI_SetLVDSRegs */
2900 /* --------------------------------------------------------------------- */
2901 void XGI_SetLVDSRegs( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2903 USHORT tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
2904 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2905 XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2906 XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2908 if ( ModeNo > 0x13 )
2909 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2911 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2913 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2915 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2917 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2920 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2923 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2926 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2927 LCDPtr1 = ( XGI330_LCDDataDesStruct2 * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2929 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2932 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
2937 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2942 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2947 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2958 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
2960 pVBInfo->HDE=tempax;
2961 pVBInfo->VDE=tempbx;
2962 pVBInfo->VGAHDE=tempax;
2963 pVBInfo->VGAVDE=tempbx;
2966 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
2968 tempax=pVBInfo->HDE;
2969 tempbx=pVBInfo->VDE;
2972 tempax = pVBInfo->HT ;
2974 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2975 tempbx = LCDPtr1->LCDHDES ;
2977 tempbx = LCDPtr->LCDHDES ;
2979 tempcx = pVBInfo->HDE ;
2980 tempbx = tempbx & 0x0fff ;
2983 if ( tempcx >= tempax )
2986 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
2988 tempcx = tempcx >> 3 ;
2989 tempbx = tempbx >> 3 ;
2991 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , ( USHORT )( tempbx & 0xff ) ) ;
2992 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , ( USHORT )( tempcx & 0xff ) ) ;
2994 tempax = pVBInfo->HT ;
2996 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2997 tempbx = LCDPtr1->LCDHRS ;
2999 tempbx = LCDPtr->LCDHRS ;
3003 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3004 tempcx = LCDPtr1->LCDHSync ;
3008 if ( tempcx >= tempax )
3011 tempax = tempbx & 0x07 ;
3012 tempax = tempax >> 5 ;
3013 tempcx = tempcx >> 3 ;
3014 tempbx = tempbx >> 3 ;
3019 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
3020 XGINew_SetReg1( pVBInfo->Part1Port , 0x14 , ( USHORT )( tempbx & 0xff ) ) ;
3022 tempax = pVBInfo->VT ;
3023 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3024 tempbx = LCDPtr1->LCDVDES ;
3026 tempbx = LCDPtr->LCDVDES ;
3027 tempcx = pVBInfo->VDE ;
3029 tempbx = tempbx & 0x0fff ;
3031 if ( tempcx >= tempax )
3034 XGINew_SetReg1( pVBInfo->Part1Port , 0x1b , ( USHORT )( tempbx & 0xff ) ) ;
3035 XGINew_SetReg1( pVBInfo->Part1Port , 0x1c , ( USHORT )( tempcx & 0xff ) ) ;
3037 tempbx = ( tempbx >> 8 ) & 0x07 ;
3038 tempcx = ( tempcx >> 8 ) & 0x07 ;
3040 XGINew_SetReg1( pVBInfo->Part1Port , 0x1d , ( USHORT )( ( tempcx << 3 ) | tempbx ) ) ;
3042 tempax = pVBInfo->VT ;
3043 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3044 tempbx = LCDPtr1->LCDVRS ;
3046 tempbx = LCDPtr->LCDVRS ;
3048 /* tempbx = tempbx >> 4 ; */
3051 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3052 tempcx = LCDPtr1->LCDVSync ;
3055 if ( tempcx >= tempax )
3058 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , ( USHORT )( tempbx & 0xff ) ) ;
3059 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , ~0x0f , ( USHORT )( tempcx & 0x0f ) ) ;
3061 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3063 tempbx = pVBInfo->VGAVDE ;
3064 if ( tempbx != pVBInfo->VDE )
3067 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3070 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3072 tempcx = pVBInfo->VGAVT ;
3073 tempbx = pVBInfo->VDE ;
3074 tempax = pVBInfo->VGAVDE ;
3077 temp = tempax ; /* 0430 ylshieh */
3078 temp1 = ( temp << 18 ) / tempbx ;
3080 tempdx = ( USHORT )( ( temp << 18 ) % tempbx ) ;
3088 XGINew_SetReg1( pVBInfo->Part1Port , 0x37 , ( USHORT )( temp2 & 0xff ) ) ;
3089 XGINew_SetReg1( pVBInfo->Part1Port , 0x36 , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3091 tempbx = ( USHORT )( temp2 >> 16 ) ;
3092 tempax = tempbx & 0x03 ;
3094 tempbx = pVBInfo->VGAVDE ;
3095 if ( tempbx == pVBInfo->VDE )
3098 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3100 if ( pVBInfo->VBType & VB_XGI301C )
3103 XGINew_SetReg1( pVBInfo->Part4Port , 0x3c , ( USHORT )( temp2 & 0xff ) ) ;
3104 XGINew_SetReg1( pVBInfo->Part4Port , 0x3b , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3105 tempbx = ( USHORT )( temp2 >> 16 ) ;
3106 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x3a , ~0xc0 , ( USHORT )( ( tempbx & 0xff ) << 6 ) ) ;
3108 tempcx = pVBInfo->VGAVDE ;
3109 if ( tempcx == pVBInfo->VDE )
3110 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3112 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3115 tempcx = pVBInfo->VGAHDE ;
3116 tempbx = pVBInfo->HDE ;
3118 temp1 = tempcx << 16 ;
3120 tempax = ( USHORT )( temp1 / tempbx ) ;
3122 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3126 temp1 = pVBInfo->VGAHDE << 16 ;
3129 temp3 = temp3 << 16 ;
3132 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3134 tempax = ( USHORT )( temp3 & 0xff ) ;
3135 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3137 temp1 = pVBInfo->VGAVDE << 18 ;
3138 temp1 = temp1 / push3 ;
3139 tempbx = ( USHORT )( temp1 & 0xffff ) ;
3141 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3144 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
3145 tempax |= ( USHORT )( ( temp3 >> 8 ) & 0x07 ) ;
3146 XGINew_SetReg1( pVBInfo->Part1Port , 0x20 , ( USHORT )( tempax & 0xff ) ) ;
3147 XGINew_SetReg1( pVBInfo->Part1Port , 0x21 , ( USHORT )( tempbx & 0xff ) ) ;
3149 temp3 = temp3 >> 16 ;
3151 if ( modeflag & HalfDCLK )
3152 temp3 = temp3 >> 1 ;
3154 XGINew_SetReg1(pVBInfo->Part1Port , 0x22 , ( USHORT )( ( temp3 >> 8 ) & 0xff ) ) ;
3155 XGINew_SetReg1(pVBInfo->Part1Port , 0x23 , ( USHORT )( temp3 & 0xff ) ) ;
3161 /* --------------------------------------------------------------------- */
3162 /* Function : XGI_SetCRT2ECLK */
3166 /* --------------------------------------------------------------------- */
3167 void XGI_SetCRT2ECLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
3169 UCHAR di_0 , di_1 , tempal ;
3172 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3173 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3174 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3176 for( i = 0 ; i < 4 ; i++ )
3178 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , ~0x30 , ( USHORT )( 0x10 * i ) ) ;
3179 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3181 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3182 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3184 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3186 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3187 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3191 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3192 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3198 /* --------------------------------------------------------------------- */
3199 /* Function : XGI_UpdateModeInfo */
3203 /* --------------------------------------------------------------------- */
3204 void XGI_UpdateModeInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
3212 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3216 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3218 if ( !( temp & 0x20 ) )
3220 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3223 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3224 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3226 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3228 if ( !( temp & 0x40 ) )
3229 tempcl |= ActiveCRT1 ;
3233 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3236 if ( !( temp == 0x08 ) )
3238 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3239 if ( tempax & 0x04 )
3240 tempcl = tempcl | ActiveLCD ;
3244 if ( !( tempcl & ActiveLCD ) )
3246 tempcl |= ActiveCRT2 ;
3249 tempcl |= ActiveLCD ;
3253 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3255 if( !( temp & 0x08 ) )
3256 tempch |= ActiveAVideo ;
3258 if ( !( temp & 0x04 ) )
3259 tempch |= ActiveSVideo ;
3262 tempch |= ActiveSCART ;
3264 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3267 tempch |= ActiveHiTV ;
3270 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3272 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3275 tempch |= ActiveYPbPr ;
3279 tempcl |= ActiveTV ;
3283 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3284 if ( tempcl & ActiveLCD )
3286 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3288 if ( temp & ActiveTV )
3289 tempcl |= ActiveTV ;
3293 tempbl = ~ModeSwitchStatus ;
3294 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3296 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3297 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3306 /* --------------------------------------------------------------------- */
3307 /* Function : XGI_GetVGAType */
3311 /* --------------------------------------------------------------------- */
3312 void XGI_GetVGAType( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3315 if ( HwDeviceExtension->jChipType >= XG20 )
3317 pVBInfo->Set_VGAType = XG20;
3319 else if ( HwDeviceExtension->jChipType >= XG40 )
3321 pVBInfo->Set_VGAType = VGA_XGI340 ;
3324 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3328 /* --------------------------------------------------------------------- */
3329 /* Function : XGI_GetVBType */
3333 /* --------------------------------------------------------------------- */
3334 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo)
3336 USHORT flag , tempbx , tempah ;
3338 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3340 pVBInfo->VBType = VB_CH7007 ;
3343 if ( pVBInfo->IF_DEF_LVDS == 0 )
3345 tempbx = VB_XGI302B ;
3346 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3349 tempbx = VB_XGI301 ;
3350 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3353 tempbx = VB_XGI301B ;
3356 tempbx = VB_XGI301C ;
3359 tempbx = VB_XGI301LV ;
3362 tempbx = VB_XGI302LV ;
3363 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3364 if ( tempah != 0xFF )
3365 tempbx = VB_XGI301C ;
3370 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3372 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3374 if ( !( flag & 0x02 ) )
3375 tempbx = tempbx | VB_NoLCD ;
3379 pVBInfo->VBType = tempbx ;
3382 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3383 pVBInfo->VBType = VB_CH7017 ;
3385 pVBInfo->VBType = VB_LVDS_NS ;
3391 /* --------------------------------------------------------------------- */
3392 /* Function : XGI_GetVBInfo */
3396 /* --------------------------------------------------------------------- */
3397 void XGI_GetVBInfo( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
3405 if ( ModeNo <= 0x13 )
3407 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3411 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3414 pVBInfo->SetFlag = 0 ;
3415 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3418 if ( pVBInfo->VBType & 0xFFFF )
3420 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3421 tempbx = tempbx | temp ;
3422 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3425 tempax = temp << 8 ;
3426 tempbx = tempbx | tempax ;
3427 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3428 temp = 0xFFFF ^ temp ;
3431 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3433 if ( pVBInfo->IF_DEF_LCDA == 1 )
3436 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3438 if ( pVBInfo->IF_DEF_LVDS == 0 )
3440 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3441 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3443 if ( temp & EnableDualEdge )
3445 tempbx |= SetCRT2ToDualEdge ;
3447 if ( temp & SetToLCDA )
3448 tempbx |= SetCRT2ToLCDA ;
3452 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3454 if ( pVBInfo->VBType & VB_CH7017 )
3456 if ( temp & EnableDualEdge )
3458 tempbx |= SetCRT2ToDualEdge ;
3460 if ( temp & SetToLCDA )
3461 tempbx |= SetCRT2ToLCDA ;
3468 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3470 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3471 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3473 if ( temp & SetYPbPr ) /* temp = CR38 */
3475 if ( pVBInfo->IF_DEF_HiVision == 1 )
3477 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3479 tempbx |= SetCRT2ToHiVisionTV ;
3481 if ( temp != YPbPrMode1080i ) {
3482 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3483 tempbx |= SetCRT2ToYPbPr ; }
3486 /* tempbx |= SetCRT2ToYPbPr ; */
3491 tempax = push ; /* restore CR31 */
3493 if ( pVBInfo->IF_DEF_LVDS == 0 )
3495 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3497 if ( pVBInfo->IF_DEF_HiVision == 1 )
3504 if ( pVBInfo->IF_DEF_HiVision == 1 )
3510 else /* 3nd party chip */
3512 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3513 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3514 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3516 temp = SetCRT2ToTV ;
3519 temp = SetCRT2ToLCD ;
3522 if ( !( tempbx & temp ) )
3524 tempax |= DisableCRT2Display ;
3528 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3530 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3532 if ( tempbx & SetCRT2ToLCDA )
3534 if ( tempbx & SetSimuScanMode )
3535 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3537 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3543 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3545 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3547 if ( tempbx & SetCRT2ToRAMDAC )
3549 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3550 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3554 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3557 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3559 if ( tempbx & SetCRT2ToLCD )
3561 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3562 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3566 if ( tempbx & SetCRT2ToSCART )
3568 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3569 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3572 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3574 if ( tempbx & SetCRT2ToYPbPr )
3575 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3578 if ( pVBInfo->IF_DEF_HiVision == 1 )
3580 if ( tempbx & SetCRT2ToHiVisionTV )
3581 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3584 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3586 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3587 tempbx = DisableCRT2Display ;
3590 if ( !( tempbx & DisableCRT2Display ) )
3592 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3594 if ( pVBInfo->IF_DEF_LCDA == 1 )
3596 if ( !( tempbx & SetCRT2ToLCDA ) )
3597 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3600 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3602 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3603 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3604 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3605 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3609 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3611 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3612 pVBInfo->SetFlag |= EnableVCMode ;
3619 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3620 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3622 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3623 pVBInfo->SetFlag |= ReserveTVOption ;
3628 pVBInfo->VBInfo = tempbx ;
3632 /* --------------------------------------------------------------------- */
3633 /* Function : XGI_GetTVInfo */
3637 /* --------------------------------------------------------------------- */
3638 void XGI_GetTVInfo( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo )
3649 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3651 if ( ModeNo <= 0x13 )
3653 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3654 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3658 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3659 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3662 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3664 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3666 if ( tempbx & SetPALTV )
3668 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3669 if ( tempbx & SetPALMTV )
3670 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3673 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3675 if ( pVBInfo->IF_DEF_LVDS == 0 )
3677 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3678 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3680 if ( temp2 & 0x02 ) //PAL-M
3681 tempbx &= ( ~SetPALTV ) ;
3686 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3688 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3690 if ( tempbx & TVOverScan )
3691 tempbx |= SetCHTVOverScan ;
3694 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3696 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3698 if ( tempbx & TVOverScan )
3700 tempbx |= SetCHTVOverScan ;
3705 if ( pVBInfo->IF_DEF_LVDS == 0 )
3707 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3708 tempbx |= SetPALTV ;
3711 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3713 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3715 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3716 index1 &= YPbPrMode ;
3718 if ( index1 == YPbPrMode525i )
3719 tempbx |= SetYPbPrMode525i ;
3721 if ( index1 == YPbPrMode525p )
3722 tempbx = tempbx | SetYPbPrMode525p;
3723 if ( index1 == YPbPrMode750p)
3724 tempbx = tempbx | SetYPbPrMode750p;
3728 if ( pVBInfo->IF_DEF_HiVision == 1 )
3730 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3732 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3736 if ( pVBInfo->IF_DEF_LVDS == 0 )
3738 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3739 tempbx |= TVSimuMode ;
3741 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3742 tempbx |= NTSC1024x768 ;
3744 tempbx |= RPLLDIV2XO ;
3746 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3748 if ( pVBInfo->VBInfo & SetInSlaveMode )
3749 tempbx &=( ~RPLLDIV2XO ) ;
3753 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3754 tempbx &= ( ~RPLLDIV2XO ) ;
3755 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3757 if ( tempbx & TVSimuMode )
3758 tempbx &= ( ~RPLLDIV2XO ) ;
3763 pVBInfo->TVInfo = tempbx ;
3767 /* --------------------------------------------------------------------- */
3768 /* Function : XGI_GetLCDInfo */
3772 /* --------------------------------------------------------------------- */
3773 BOOLEAN XGI_GetLCDInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
3782 pVBInfo->LCDResInfo = 0 ;
3783 pVBInfo->LCDTypeInfo = 0 ;
3784 pVBInfo->LCDInfo = 0 ;
3786 if ( ModeNo <= 0x13 )
3788 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3792 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3793 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3796 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3797 tempbx = temp & 0x0F ;
3800 tempbx = Panel1024x768 ; /* default */
3802 /* LCD75 [2003/8/22] Vicent */
3803 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3805 if ( pVBInfo->VBInfo & DriverMode )
3807 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3808 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3811 tempax = tempax >> 4 ;
3813 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3816 tempbx |= PanelRef75Hz ;
3818 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3821 tempbx |= PanelRef75Hz ;
3826 pVBInfo->LCDResInfo = tempbx ;
3830 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3832 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3835 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3842 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3844 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3846 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3847 temp &= ~EnableScalingLCD ;
3851 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3853 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3855 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3857 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3859 tempbx |= SetLCDDualLink ;
3863 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3865 if ( tempax & LCDDualLink )
3867 tempbx |= SetLCDDualLink ;
3871 if ( pVBInfo->IF_DEF_LVDS == 0 )
3873 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3874 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3878 if ( tempax & LCDBToA )
3880 tempbx |= SetLCDBToA ;
3884 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3886 if ( modeflag & HalfDCLK )
3888 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3889 if ( !( tempbx & SetLCDtoNonExpanding ) )
3891 tempbx |= EnableLVDSDDA ;
3895 if ( ModeNo > 0x13 )
3897 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3901 tempbx |= EnableLVDSDDA ;
3909 if ( pVBInfo->VBInfo & SetInSlaveMode )
3911 if ( pVBInfo->VBInfo & SetNotSimuMode )
3913 tempbx |= LCDVESATiming ;
3918 tempbx |= LCDVESATiming ;
3921 pVBInfo->LCDInfo = tempbx ;
3923 if ( pVBInfo->IF_DEF_PWD == 1 )
3925 if ( pVBInfo->LCDInfo & SetPWDEnable )
3927 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3929 if ( !( tempax & PWDEnable ) )
3931 pVBInfo->LCDInfo &= ~SetPWDEnable ;
3937 if ( pVBInfo->IF_DEF_LVDS == 0 )
3939 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3941 if ( pVBInfo->VBInfo & SetInSlaveMode )
3943 if ( !( tempax & LockLCDBToA ) )
3945 if ( ModeNo <= 0x13 )
3947 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
3948 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
3956 if ( pVBInfo->IF_DEF_LVDS == 0 )
3958 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3960 if ( pVBInfo->VBInfo & SetInSlaveMode )
3962 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
3964 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3965 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3976 /* --------------------------------------------------------------------- */
3977 /* Function : XGI_SearchModeID */
3981 /* --------------------------------------------------------------------- */
3982 BOOLEAN XGI_SearchModeID( USHORT ModeNo , USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
3987 #ifdef LINUX /* chiawen for linux solution */
3991 if ( ModeNo <= 0x13 )
3993 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
3994 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
3996 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == ModeNo )
3998 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == 0xFF )
4002 if ( ModeNo == 0x07 )
4003 ( *ModeIdIndex )++ ; /* 400 lines */
4006 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4007 /* else 350 lines */
4011 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4012 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4014 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == ModeNo )
4016 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == 0xFF )
4029 /* win2000 MM adapter not support standard mode! */
4031 /* --------------------------------------------------------------------- */
4036 /* --------------------------------------------------------------------- */
4037 BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4045 /* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4046 ( HwDeviceExtension->jChipType == XGI_650M ) )
4051 if ( ModeNo <= 0x13 )
4053 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4056 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4059 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4061 memorysize = modeflag & MemoryInfoFlag ;
4062 memorysize = memorysize > MemorySizeShift ;
4063 memorysize++ ; /* Get memory size */
4065 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4068 if ( HwDeviceExtension->jChipType == XG40 )
4070 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4071 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4075 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4080 else if ( HwDeviceExtension->jChipType == XG42 )
4082 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4083 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4088 else if ( HwDeviceExtension->jChipType == XG45 )
4090 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4091 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4095 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4101 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4106 if ( temp < memorysize )
4113 /* --------------------------------------------------------------------- */
4114 /* Function : XGINew_IsLowResolution */
4118 /* --------------------------------------------------------------------- */
4119 /*void XGINew_IsLowResolution( USHORT ModeNo , USHORT ModeIdIndex, BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4124 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4126 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4128 if ( ModeNo > 0x13 )
4130 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4131 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4133 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4135 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4136 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4138 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4145 /* --------------------------------------------------------------------- */
4146 /* Function : XGI_DisplayOn */
4150 /* --------------------------------------------------------------------- */
4151 void XGI_DisplayOn( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4154 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4155 if ( pXGIHWDE->jChipType == XG21 )
4157 if ( pVBInfo->IF_DEF_LVDS == 1 )
4159 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4161 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4162 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4164 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4166 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4168 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4169 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4173 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4178 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4184 if ( pXGIHWDE->jChipType == XG27 )
4186 if ( pVBInfo->IF_DEF_LVDS == 1 )
4188 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4190 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4191 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4193 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4195 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4197 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4198 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4202 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4209 /* --------------------------------------------------------------------- */
4210 /* Function : XGI_DisplayOff */
4214 /* --------------------------------------------------------------------- */
4215 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4218 if ( pXGIHWDE->jChipType == XG21 )
4220 if ( pVBInfo->IF_DEF_LVDS == 1 )
4222 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4223 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4227 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4231 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4233 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4239 if ( pXGIHWDE->jChipType == XG27 )
4241 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4243 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4244 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4247 if ( pVBInfo->IF_DEF_LVDS == 0 )
4249 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4253 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4257 /* --------------------------------------------------------------------- */
4258 /* Function : XGI_WaitDisply */
4261 /* Description : chiawen for sensecrt1 */
4262 /* --------------------------------------------------------------------- */
4263 void XGI_WaitDisply( PVB_DEVICE_INFO pVBInfo )
4265 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4268 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4272 /* --------------------------------------------------------------------- */
4273 /* Function : XGI_SenseCRT1 */
4277 /* --------------------------------------------------------------------- */
4279 void XGI_SenseCRT1( PVB_DEVICE_INFO pVBInfo )
4281 UCHAR CRTCData[ 17 ] = { 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4282 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4283 0x04 , 0x00 , 0x00 , 0x05 , 0x00 } ;
4285 UCHAR SR01 = 0 , SR1F = 0 , SR07 = 0 , SR06 = 0 ;
4287 UCHAR CR17 , CR63 , SR31 ;
4289 UCHAR DAC_TEST_PARMS[ 3 ] = { 0x0F , 0x0F , 0x0F } ;
4292 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4294 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4295 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4296 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) | 0x02 ) ) ;
4298 SR31 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) ;
4299 CR63 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
4300 SR01 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4302 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , ( UCHAR )( SR01 & 0xDF ) ) ;
4303 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , ( UCHAR )( CR63 & 0xBF ) ) ;
4305 CR17 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
4306 XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , ( UCHAR )( CR17 | 0x80 ) ) ;
4308 SR1F = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
4309 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR )( SR1F | 0x04 ) ) ;
4311 SR07 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x07 ) ;
4312 XGINew_SetReg1( pVBInfo->P3c4 , 0x07 , ( UCHAR )( SR07 & 0xFB ) ) ;
4313 SR06 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x06 ) ;
4314 XGINew_SetReg1( pVBInfo->P3c4 , 0x06 , ( UCHAR )( SR06 & 0xC3 ) ) ;
4316 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4318 for( i = 0 ; i < 8 ; i++ )
4319 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )i , CRTCData[ i ] ) ;
4321 for( i = 8 ; i < 11 ; i++ )
4322 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 8 ) , CRTCData[ i ] ) ;
4324 for( i = 11 ; i < 13 ; i++ )
4325 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 4 ) , CRTCData[ i ] ) ;
4327 for( i = 13 ; i < 16 ; i++ )
4328 XGINew_SetReg1( pVBInfo->P3c4 , ( USHORT )( i - 3 ) , CRTCData[ i ] ) ;
4330 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , ( UCHAR )( CRTCData[ 16 ] & 0xE0 ) ) ;
4332 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4333 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4334 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4336 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4338 for( i = 0 ; i < 256 ; i++ )
4340 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 0 ] ) ;
4341 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 1 ] ) ;
4342 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 2 ] ) ;
4345 XGI_VBLongWait( pVBInfo ) ;
4346 XGI_VBLongWait( pVBInfo ) ;
4347 XGI_VBLongWait( pVBInfo ) ;
4349 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4351 XGI_WaitDisply( pVBInfo ) ;
4352 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4356 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4360 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4363 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4364 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4366 for( i = 0 ; i < 256 ; i++ )
4368 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4369 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4370 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4373 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4374 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4375 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4377 /* [2004/05/11] Vicent */
4378 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) & 0xFD ) ) ;
4379 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR ) SR1F ) ;
4391 /* --------------------------------------------------------------------- */
4392 /* Function : XGI_WaitDisplay */
4396 /* --------------------------------------------------------------------- */
4397 void XGI_WaitDisplay( PVB_DEVICE_INFO pVBInfo )
4399 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4401 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4407 /* --------------------------------------------------------------------- */
4408 /* Function : XGI_SetCRT2Group301 */
4412 /* --------------------------------------------------------------------- */
4413 BOOLEAN XGI_SetCRT2Group301( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
4417 RefreshRateTableIndex ;
4419 tempbx=pVBInfo->VBInfo ;
4420 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4421 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4422 pVBInfo->SelectCRT2Rate = 4 ;
4423 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4424 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4425 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4426 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4427 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4428 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4429 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4430 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4431 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4432 XGI_SetTap4Regs(pVBInfo) ;
4433 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4434 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4435 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4436 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4437 XGI_AutoThreshold( pVBInfo) ;
4442 /* --------------------------------------------------------------------- */
4443 /* Function : XGI_AutoThreshold */
4447 /* --------------------------------------------------------------------- */
4448 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo )
4450 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4451 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4455 /* --------------------------------------------------------------------- */
4456 /* Function : XGI_SaveCRT2Info */
4460 /* --------------------------------------------------------------------- */
4461 void XGI_SaveCRT2Info( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo)
4466 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4467 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4468 temp2 = ~( SetInSlaveMode >> 8 ) ;
4469 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4473 /* --------------------------------------------------------------------- */
4474 /* Function : XGI_GetCRT2ResInfo */
4478 /* --------------------------------------------------------------------- */
4479 void XGI_GetCRT2ResInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
4486 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4487 if ( ModeNo <= 0x13 )
4489 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4490 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4491 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4495 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4496 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4497 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4499 /* if ( pVBInfo->IF_DEF_FSTN )
4507 if ( modeflag & HalfDCLK )
4510 if ( modeflag & DoubleScanMode )
4515 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4517 if ( pVBInfo->IF_DEF_LVDS == 0 )
4519 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4521 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4528 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4532 else if ( yres == 350 )
4535 if ( pVBInfo->LCDInfo & LCDVESATiming )
4542 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4544 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4546 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4550 else if ( yres == 400 )
4552 else if ( yres == 480 )
4563 pVBInfo->VGAHDE = xres ;
4564 pVBInfo->HDE = xres ;
4565 pVBInfo->VGAVDE = yres ;
4566 pVBInfo->VDE = yres ;
4570 /* --------------------------------------------------------------------- */
4571 /* Function : XGI_IsLCDDualLink */
4575 /* --------------------------------------------------------------------- */
4576 BOOLEAN XGI_IsLCDDualLink( PVB_DEVICE_INFO pVBInfo )
4579 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4586 /* --------------------------------------------------------------------- */
4587 /* Function : XGI_GetCRT2Data */
4591 /* --------------------------------------------------------------------- */
4592 void XGI_GetCRT2Data( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4599 XGI_LCDDataStruct *LCDPtr = NULL ;
4600 XGI_TVDataStruct *TVPtr = NULL ;
4602 if ( ModeNo <= 0x13 )
4604 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4605 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4609 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4610 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4613 pVBInfo->NewFlickerMode = 0 ;
4614 pVBInfo->RVBHRS = 50 ;
4616 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4618 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4624 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4626 LCDPtr = (XGI_LCDDataStruct* )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4628 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4629 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4630 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4631 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4632 pVBInfo->HT = LCDPtr->LCDHT ;
4633 pVBInfo->VT = LCDPtr->LCDVT ;
4635 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4640 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4642 if ( pVBInfo->VGAVDE == 357 )
4644 else if ( pVBInfo->VGAVDE == 420 )
4646 else if ( pVBInfo->VGAVDE == 525 )
4648 else if ( pVBInfo->VGAVDE == 600 )
4650 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4651 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4658 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4663 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4666 if ( pVBInfo->VGAVDE == 360 )
4668 else if ( pVBInfo->VGAVDE == 375 )
4670 else if ( pVBInfo->VGAVDE == 405 )
4675 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4680 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4683 if ( pVBInfo->VGAVDE == 350 )
4685 else if ( pVBInfo->VGAVDE == 400 )
4687 else if ( pVBInfo->VGAVDE == 1024 )
4692 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4697 if ( pVBInfo->VGAVDE == 1024 )
4703 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4706 tempbx = 1200 ; /* alan 10/14/2003 */
4707 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4709 if ( pVBInfo->VGAVDE == 350 )
4711 else if ( pVBInfo->VGAVDE == 400 )
4716 if ( pVBInfo->LCDInfo & LCDNonExpanding )
4718 tempax = pVBInfo->VGAHDE ;
4719 tempbx = pVBInfo->VGAVDE ;
4722 pVBInfo->HDE = tempax ;
4723 pVBInfo->VDE = tempbx ;
4727 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
4730 TVPtr = ( XGI_TVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4732 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
4733 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
4734 pVBInfo->VGAHT = TVPtr->VGAHT ;
4735 pVBInfo->VGAVT = TVPtr->VGAVT ;
4736 pVBInfo->HDE = TVPtr->TVHDE ;
4737 pVBInfo->VDE = TVPtr->TVVDE ;
4738 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
4739 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
4741 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
4743 if ( resinfo == 0x08 )
4744 pVBInfo->NewFlickerMode = 0x40 ;
4745 else if ( resinfo == 0x09 )
4746 pVBInfo->NewFlickerMode = 0x40 ;
4747 else if ( resinfo == 0x12 )
4748 pVBInfo->NewFlickerMode = 0x40 ;
4750 if ( pVBInfo->VGAVDE == 350 )
4751 pVBInfo->TVInfo |= TVSimuMode ;
4753 tempax = ExtHiTVHT ;
4754 tempbx = ExtHiTVVT ;
4756 if ( pVBInfo->VBInfo & SetInSlaveMode )
4758 if ( pVBInfo->TVInfo & TVSimuMode )
4763 if ( !( modeflag & Charx8Dot ) )
4765 tempax = StHiTextTVHT ;
4766 tempbx = StHiTextTVVT ;
4771 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
4773 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4775 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
4776 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
4779 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4781 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
4782 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
4784 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
4786 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
4787 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
4788 if ( pVBInfo->TVInfo & NTSC1024x768 )
4789 tempax = NTSC1024x768HT ;
4796 if ( !( pVBInfo->TVInfo & SetPALTV ) )
4800 if ( pVBInfo->TVInfo & NTSC1024x768 )
4801 tempax = NTSC1024x768HT ;
4805 pVBInfo->HT = tempax ;
4806 pVBInfo->VT = tempbx ;
4812 /* --------------------------------------------------------------------- */
4813 /* Function : XGI_SetCRT2VCLK */
4817 /* --------------------------------------------------------------------- */
4818 void XGI_SetCRT2VCLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4824 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
4825 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
4826 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
4828 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
4830 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
4831 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
4832 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
4835 { /* 301b/302b/301lv/302lv */
4836 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
4837 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
4840 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
4842 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4843 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
4845 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
4849 /* --------------------------------------------------------------------- */
4850 /* Function : XGI_GETLCDVCLKPtr */
4852 /* Output : al -> VCLK Index */
4854 /* --------------------------------------------------------------------- */
4855 void XGI_GetLCDVCLKPtr( UCHAR* di_0 , UCHAR *di_1, PVB_DEVICE_INFO pVBInfo )
4859 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4861 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
4863 if ( pVBInfo->LCDInfo & EnableScalingLCD )
4867 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
4868 index = XGI_GetLCDCapPtr1( pVBInfo) ;
4870 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4872 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
4873 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
4877 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
4878 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
4885 /* --------------------------------------------------------------------- */
4886 /* Function : XGI_GetVCLKPtr */
4890 /* --------------------------------------------------------------------- */
4891 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
4898 UCHAR *CHTVVCLKPtr = NULL ;
4900 if ( ModeNo <= 0x13 )
4901 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4903 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4906 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
4908 index = XGI_GetLCDCapPtr(pVBInfo) ;
4909 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
4911 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4915 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
4917 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
4919 tempal = HiTVVCLKDIV2;
4920 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
4922 if(pVBInfo->TVInfo & TVSimuMode)
4924 tempal = HiTVSimuVCLK;
4925 if(!(modeflag & Charx8Dot))
4926 tempal = HiTVTextVCLK;
4932 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4934 tempal = YPbPr750pVCLK ;
4938 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4940 tempal = YPbPr525pVCLK ;
4944 tempal = NTSC1024VCLK ;
4946 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
4948 tempal = TVVCLKDIV2 ;
4949 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
4953 if ( pVBInfo->VBInfo & SetCRT2ToTV )
4957 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
4960 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4962 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4963 *tempal = *tempal & 0x1F;
4966 if(pVBInfo->TVInfo & SetPALTV)
4967 tempbx = tempbx + 2;
4968 if(pVBInfo->TVInfo & SetCHTVOverScan)
4970 tempbx = tempbx << 1;
4974 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
4976 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4977 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
4979 if( ModeNo <= 0x13 )
4981 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
4985 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4988 tempal = tempal & 0x0F;
4991 if(pVBInfo->TVInfo & SetPALTV)
4993 tempbx = tempbx + 2;
4995 if(pVBInfo->TVInfo & SetCHTVOverScan)
4999 /** tempbx = tempbx << 1; CH7007 ? **/
5001 /*[Billy]07/05/29 CH7007*/
5002 if ( pVBInfo->IF_DEF_CH7007 == 1 )
5007 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
5010 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5013 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5016 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5028 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5031 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5034 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5037 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5044 tempal = CHTVVCLKPtr[ tempal ] ;
5050 tempal = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ;
5051 tempal = tempal >> 2 ;
5054 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5055 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5057 if ( ModeNo <= 0x13 )
5060 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5065 /* --------------------------------------------------------------------- */
5066 /* Function : XGI_GetVCLKLen */
5070 /* --------------------------------------------------------------------- */
5071 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo)
5073 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5075 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5076 *di_0 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2B ;
5077 *di_1 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2C ;
5079 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5081 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5083 *di_0 = ( UCHAR )XGI_VBVCLKData[ tempal ].SR2B ;
5084 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5089 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5090 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5095 /* --------------------------------------------------------------------- */
5096 /* Function : XGI_SetCRT2Offset */
5100 /* --------------------------------------------------------------------- */
5101 void XGI_SetCRT2Offset( USHORT ModeNo ,
5102 USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5107 if ( pVBInfo->VBInfo & SetInSlaveMode )
5112 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5113 temp = ( UCHAR )( offset & 0xFF ) ;
5114 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5115 temp =( UCHAR)( ( offset & 0xFF00 ) >> 8 ) ;
5116 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , temp ) ;
5117 temp =( UCHAR )( ( ( offset >> 3 ) & 0xFF ) + 1 ) ;
5118 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5122 /* --------------------------------------------------------------------- */
5123 /* Function : XGI_GetOffset */
5127 /* --------------------------------------------------------------------- */
5128 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
5135 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5137 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5138 if ( ModeNo <= 0x14 )
5141 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5144 index = ( modeinfo >> 8 ) & 0xFF ;
5146 temp = pVBInfo->ScreenOffset[ index ] ;
5148 if ( infoflag & InterlaceMode )
5153 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5155 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5157 temp = ModeNo - 0x7C ;
5158 colordepth = ColorDepth[ temp ] ;
5160 if ( infoflag & InterlaceMode )
5164 return( temp * colordepth ) ;
5167 return( temp * colordepth ) ;
5171 /* --------------------------------------------------------------------- */
5172 /* Function : XGI_SetCRT2FIFO */
5176 /* --------------------------------------------------------------------- */
5177 void XGI_SetCRT2FIFO( PVB_DEVICE_INFO pVBInfo)
5179 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5180 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5184 /* --------------------------------------------------------------------- */
5185 /* Function : XGI_PreSetGroup1 */
5189 /* --------------------------------------------------------------------- */
5190 void XGI_PreSetGroup1(USHORT ModeNo , USHORT ModeIdIndex ,PXGI_HW_DEVICE_INFO HwDeviceExtension,
5191 USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5197 if ( ModeNo > 0x13 )
5199 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5200 CRT1Index &= IndexMask ;
5201 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5204 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5205 XGI_SetCRT2FIFO(pVBInfo) ;
5206 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5208 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5210 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5213 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5214 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5218 /* --------------------------------------------------------------------- */
5219 /* Function : XGI_SetGroup1 */
5223 /* --------------------------------------------------------------------- */
5224 void XGI_SetGroup1( USHORT ModeNo , USHORT ModeIdIndex ,
5225 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5236 if ( ModeNo > 0x13 )
5238 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5239 CRT1Index &= IndexMask ;
5240 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5243 if ( ModeNo <= 0x13 )
5245 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5249 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5252 /* bainy change table name */
5253 if ( modeflag & HalfDCLK )
5255 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5256 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5257 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5258 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5259 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5260 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5261 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5262 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5263 tempcx = tempcx >> 1 ;
5264 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5267 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5269 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5270 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5271 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5272 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5274 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5275 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5276 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5282 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5283 tempcx = pVBInfo->VGAHT / 2 ;
5285 temp = tempbx & 0x00FF ;
5287 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5291 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5292 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5293 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5294 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5295 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5296 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5297 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5298 pushbx = pVBInfo->VGAHDE + 16 ;
5299 tempcx = tempcx >> 1 ;
5300 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5303 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5305 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5306 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5307 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5308 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5310 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5311 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5312 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5317 if ( tempcx > pVBInfo->VGAHT )
5318 tempcx = pVBInfo->VGAHT ;
5320 temp = tempbx & 0x00FF ;
5321 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5324 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5326 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5327 tempax |= ( tempbx & 0xFF00 ) ;
5328 temp = ( tempax & 0xFF00 ) >> 8 ;
5329 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5330 temp = tempcx & 0x00FF ;
5331 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5332 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5333 temp = tempcx & 0x00FF ;
5335 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5337 if ( pVBInfo->VBInfo & 0x0C )
5343 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5344 tempbx = pVBInfo->VGAVDE - 1 ;
5345 temp = tempbx & 0x00FF ;
5346 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5347 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5348 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5349 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5351 tempax = pVBInfo->VGAVDE ;
5352 tempbx = pVBInfo->VGAVDE ;
5353 tempcx = pVBInfo->VGAVT ;
5354 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5355 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5357 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5359 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5360 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5368 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5373 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5374 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5377 temp = tempbx & 0x00FF ;
5378 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5379 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5380 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5381 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5384 if ( modeflag & DoubleScanMode )
5387 if ( modeflag & HalfDCLK )
5390 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5394 /* --------------------------------------------------------------------- */
5395 /* Function : XGI_SetLockRegs */
5399 /* --------------------------------------------------------------------- */
5400 void XGI_SetLockRegs( USHORT ModeNo , USHORT ModeIdIndex ,
5401 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5413 if ( ModeNo <= 0x13 )
5415 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5416 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5420 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5421 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5422 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5423 CRT1Index &= IndexMask;
5426 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5431 temp = 0xFF ; /* set MAX HT */
5432 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5433 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5437 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5438 modeflag |= Charx8Dot ;
5440 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5442 if ( modeflag & HalfDCLK )
5443 tempax = tempax >> 1 ;
5445 tempax = ( tempax / tempcx ) - 1 ;
5446 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5447 temp = tempax & 0x00FF ;
5448 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5450 temp = ( tempbx & 0xFF00 ) >> 8 ;
5452 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5454 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5457 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5459 if ( pVBInfo->VBType & VB_XGI301LV )
5461 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5473 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5474 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5476 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5477 { /* 030226 bainy */
5478 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5479 tempax = pVBInfo->VGAHT ;
5481 tempax = XGI_GetVGAHT2( pVBInfo) ;
5484 if ( tempax >= pVBInfo->VGAHT )
5486 tempax = pVBInfo->VGAHT ;
5489 if ( modeflag & HalfDCLK )
5491 tempax = tempax >> 1 ;
5494 tempax = ( tempax / tempcx ) - 5 ;
5495 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5496 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5498 temp = ( tempbx & 0x00FF ) - 1 ;
5499 if ( !( modeflag & HalfDCLK ) )
5502 if ( pVBInfo->TVInfo & TVSimuMode )
5505 if ( ModeNo > 0x13 )
5512 /* tempcx = tempbx & 0x00FF ; */
5513 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5514 tempcx = ( tempcx + tempbx ) >> 1 ;
5515 temp = ( tempcx & 0x00FF ) + 2 ;
5517 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5520 if ( !( modeflag & HalfDCLK ) )
5522 if ( ( modeflag & Charx8Dot ) )
5525 if ( pVBInfo->VGAHDE >= 800 )
5534 if ( !( modeflag & HalfDCLK ) )
5537 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5539 if( pVBInfo->VGAHDE >= 800 )
5542 if ( pVBInfo->ModeType == ModeEGA )
5544 if ( pVBInfo->VGAVDE == 1024 )
5547 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5554 if ( pVBInfo->VGAHDE >= 1280 )
5556 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5558 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5570 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5571 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5573 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5575 if ( pVBInfo->TVInfo & TVSimuMode )
5577 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5579 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5580 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5583 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5585 if ( pVBInfo->TVInfo & SetNTSCTV )
5587 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5588 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5592 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5593 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5594 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5598 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5600 if ( pVBInfo->TVInfo & SetNTSCTV )
5602 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5603 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5607 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5608 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5609 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5613 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5615 if ( pVBInfo->TVInfo & SetNTSCTV )
5617 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5618 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5622 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5623 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5629 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5630 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5631 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5633 tempbx = pVBInfo->VGAVT ;
5636 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5638 if ( tempbx == 357 )
5640 if ( tempbx == 360 )
5642 if ( tempbx == 375 )
5644 if ( tempbx == 405 )
5646 if ( tempbx == 525 )
5651 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5653 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5655 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5657 if ( tempbx == 350 )
5659 if ( tempbx == 480 )
5665 temp = tempbx & 0x00FF ;
5667 temp = tempbx & 0x00FF ;
5668 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5671 temp = tempbx & 0x00FF ;
5672 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5674 if ( tempbx & 0x0100 )
5681 if ( modeflag & DoubleScanMode )
5686 if ( tempbx & 0x0200 )
5691 temp = ( tempax & 0xFF00 ) >> 8 ;
5692 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5694 if ( tempbx & 0x0400 )
5699 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5702 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
5703 tempax = tempax >> 2 ;
5704 push1 = tempax ; /* push ax */
5706 if ( resinfo != 0x09 )
5708 tempax = tempax << 1 ;
5712 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5714 if ( pVBInfo->VBType & VB_XGI301LV )
5716 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
5720 if ( pVBInfo->TVInfo & TVSimuMode )
5722 if ( pVBInfo->TVInfo & SetPALTV )
5724 if ( pVBInfo->VBType & VB_XGI301LV )
5726 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5740 if ( pVBInfo->TVInfo & TVSimuMode )
5742 if ( pVBInfo->TVInfo & SetPALTV )
5744 if ( pVBInfo->VBType & VB_XGI301LV )
5746 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5755 tempax = tempax >> 2 ;
5758 push1 = tempax ; /* push ax */
5760 if ( ( pVBInfo->TVInfo & SetPALTV ) )
5762 if ( tempbx <= 513 )
5764 if ( tempax >= 513 )
5771 temp = tempbx & 0x00FF ;
5772 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5774 temp = tempbx & 0x00FF ;
5775 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5777 if ( tempbx & 0x0100 )
5782 if ( tempbx & 0x0200 )
5784 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
5789 if ( tempbx & 0x0100 )
5794 if ( tempbx & 0x0200 )
5799 if ( tempbx & 0x0400 )
5804 tempbx = push1 ; /* pop ax */
5805 temp = tempbx & 0x00FF ;
5807 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
5809 if ( tempbx & 0x0010 )
5814 temp = tempcx & 0x00FF ;
5815 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
5816 temp = ( tempcx & 0x0FF00 ) >> 8 ;
5817 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
5819 temp = ( tempax & 0xFF00 ) >> 8 ;
5821 temp = ( temp >> 1 ) & 0x09 ;
5823 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5826 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
5827 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
5828 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
5830 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
5835 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
5841 /* --------------------------------------------------------------------- */
5842 /* Function : XGI_SetGroup2 */
5846 /* --------------------------------------------------------------------- */
5847 void XGI_SetGroup2( USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex,
5848 PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5861 UCHAR *TimingPoint ;
5869 if ( ModeNo <= 0x13 )
5871 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5872 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5873 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5877 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5878 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5879 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
5884 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
5887 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
5890 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
5893 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5896 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5899 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
5902 tempax = ( tempax & 0xff00 ) >> 8 ;
5904 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
5905 TimingPoint = pVBInfo->NTSCTiming ;
5907 if ( pVBInfo->TVInfo & SetPALTV )
5909 TimingPoint = pVBInfo->PALTiming ;
5912 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5914 TimingPoint = pVBInfo->HiTVExtTiming ;
5916 if ( pVBInfo->VBInfo & SetInSlaveMode )
5917 TimingPoint = pVBInfo->HiTVSt2Timing ;
5919 if ( pVBInfo->SetFlag & TVSimuMode )
5920 TimingPoint = pVBInfo->HiTVSt1Timing ;
5922 if ( !(modeflag & Charx8Dot) )
5923 TimingPoint = pVBInfo->HiTVTextTiming ;
5926 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5928 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5929 TimingPoint = pVBInfo->YPbPr525iTiming ;
5931 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5932 TimingPoint = pVBInfo->YPbPr525pTiming ;
5934 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5935 TimingPoint = pVBInfo->YPbPr750pTiming ;
5938 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
5940 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
5943 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
5945 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
5948 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5950 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
5953 temp = pVBInfo->NewFlickerMode ;
5955 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
5957 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5960 if ( pVBInfo->TVInfo & SetPALTV )
5965 if ( pVBInfo->VDE <= tempax )
5967 tempax -= pVBInfo->VDE ;
5968 tempax = tempax >> 2 ;
5969 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
5971 temp = ( tempax & 0xFF00 ) >> 8 ;
5972 temp += ( USHORT )TimingPoint[ 0 ] ;
5974 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5976 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
5978 tempcx=pVBInfo->VGAHDE;
5979 if ( tempcx >= 1024 )
5981 temp = 0x17 ; /* NTSC */
5982 if ( pVBInfo->TVInfo & SetPALTV )
5983 temp = 0x19 ; /* PAL */
5988 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
5990 temp = ( tempax & 0xFF00 ) >> 8 ;
5991 temp += TimingPoint[ 1 ] ;
5993 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5995 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
5997 tempcx = pVBInfo->VGAHDE ;
5998 if ( tempcx >= 1024 )
6000 temp = 0x1D ; /* NTSC */
6001 if ( pVBInfo->TVInfo & SetPALTV )
6002 temp = 0x52 ; /* PAL */
6006 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
6010 tempcx = pVBInfo->HT ;
6012 if ( XGI_IsLCDDualLink( pVBInfo ) )
6013 tempcx = tempcx >> 1 ;
6016 temp = tempcx & 0x00FF ;
6017 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6019 temp = ( tempcx & 0xFF00 ) >> 8 ;
6020 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6022 tempcx = pVBInfo->HT >> 1 ;
6023 push1 = tempcx ; /* push cx */
6026 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6031 temp = tempcx & 0x00FF ;
6033 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6035 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6038 temp = tempbx & 0x00FF ;
6039 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6040 temp = ( tempbx & 0xFF00 ) >> 8 ;
6042 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6046 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6052 temp = ( tempbx & 0x00FF ) << 4 ;
6053 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6056 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6057 temp = tempcx & 0x00FF ;
6058 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6059 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6060 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6063 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6068 temp = tempcx & 0xFF ;
6070 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6072 tempcx = push1 ; /* pop cx */
6074 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6076 temp = tempcx & 0x00FF ;
6078 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6082 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6084 tempax = XGI_GetVGAHT2( pVBInfo) ;
6085 tempcx = tempax - 1 ;
6087 temp = tempcx & 0x00FF ;
6088 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6090 tempbx = pVBInfo->VDE ;
6092 if ( pVBInfo->VGAVDE == 360 )
6094 if ( pVBInfo->VGAVDE == 375 )
6096 if ( pVBInfo->VGAVDE == 405 )
6099 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6101 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6103 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6104 tempbx = tempbx >> 1 ;
6107 tempbx = tempbx >> 1 ;
6111 temp = tempbx & 0x00FF ;
6113 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6115 if ( pVBInfo->VBType & VB_XGI301LV )
6117 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6119 if ( pVBInfo->VBInfo & SetInSlaveMode )
6121 if ( ModeNo == 0x2f )
6128 if ( pVBInfo->VBInfo & SetInSlaveMode )
6130 if ( ModeNo == 0x2f )
6136 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6138 temp = ( tempcx & 0xFF00 ) >> 8 ;
6139 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6141 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6143 if ( pVBInfo->VBType & VB_XGI301LV )
6145 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6149 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6156 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6161 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6163 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6165 tempbx = pVBInfo->VDE ;
6166 tempcx = tempbx - 2 ;
6168 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6170 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6171 tempbx = tempbx >> 1 ;
6174 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6177 if( tempcx & 0x0400 )
6180 if ( tempbx & 0x0400 )
6183 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6186 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6187 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6188 temp = ( tempbx - 3 ) & 0x00FF ;
6189 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6192 tempbx = tempbx & 0x00FF ;
6194 if ( !( modeflag & HalfDCLK ) )
6196 tempcx = pVBInfo->VGAHDE ;
6197 if ( tempcx >= pVBInfo->HDE )
6206 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6207 if(pVBInfo->VGAHDE>=1024)
6210 if(pVBInfo->VGAHDE>=1280)
6213 tempbx=tempbx&0xDFFF;
6218 if ( !( tempbx & 0x2000 ) )
6220 if ( modeflag & HalfDCLK )
6222 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6226 tempeax = pVBInfo->VGAHDE ;
6227 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6228 longtemp = tempeax * tempebx ;
6229 tempecx = tempcx & 0x00FF ;
6230 longtemp = longtemp / tempecx ;
6233 tempecx = 8 * 1024 ;
6235 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6237 tempecx = tempecx * 8 ;
6240 longtemp = longtemp * tempecx ;
6241 tempecx = pVBInfo->HDE ;
6242 temp2 = longtemp % tempecx ;
6243 tempeax = longtemp / tempecx ;
6249 tempax = ( USHORT )tempeax ;
6252 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6254 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6259 tempbx =( USHORT )( ( ( tempeax & 0x0000FF00 ) & 0x1F00 ) | ( tempbx & 0x00FF ) ) ;
6260 tempax =( USHORT )( ( ( tempeax & 0x000000FF ) << 8 ) | ( tempax & 0x00FF ) ) ;
6261 temp = ( tempax & 0xFF00 ) >> 8 ;
6265 temp = ( tempax & 0x00FF ) >> 8 ;
6268 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6269 temp = ( tempbx & 0xFF00 ) >> 8 ;
6270 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6271 temp = tempcx & 0x00FF ;
6273 if ( tempbx & 0x2000 )
6276 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6279 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6280 if ( pVBInfo->TVInfo & SetPALTV )
6291 temp = tempbx & 0x00FF ;
6292 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6293 temp = tempcx & 0x00FF ;
6294 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6296 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6298 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6300 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6304 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6307 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6311 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6312 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6313 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , ( USHORT )( temp - 3 ) ) ;
6315 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6317 if ( pVBInfo->TVInfo & NTSC1024x768 )
6319 TimingPoint = XGI_NTSC1024AdjTime ;
6320 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6322 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6324 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6328 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6329 if ( pVBInfo->VBType & VB_XGI301C )
6331 if ( pVBInfo->TVInfo & SetPALMTV )
6332 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6335 if ( pVBInfo->TVInfo & SetPALMTV )
6337 tempax = ( UCHAR )XGINew_GetReg1( pVBInfo->Part2Port , 0x01 ) ;
6339 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6341 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6342 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6345 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6347 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6349 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6353 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6360 /* --------------------------------------------------------------------- */
6361 /* Function : XGI_SetLCDRegs */
6365 /* --------------------------------------------------------------------- */
6366 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
6382 XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6385 if ( ModeNo <= 0x13 )
6387 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6388 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6392 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6393 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6394 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6395 CRT1Index &= IndexMask ;
6398 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6403 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6405 if ( XGI_IsLCDDualLink( pVBInfo ) )
6406 tempbx = tempbx >> 1 ;
6409 temp = tempbx & 0x00FF ;
6410 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6411 temp = ( tempbx & 0xFF00 ) >> 8 ;
6413 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6416 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6418 if ( pVBInfo->ModeType == ModeEGA )
6420 if ( pVBInfo->VGAHDE >= 1024 )
6423 if ( pVBInfo->LCDInfo & LCDVESATiming )
6429 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6430 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6433 temp = tempbx & 0x00FF ;
6434 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6435 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6436 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6438 tempcx = pVBInfo->VT - 1 ;
6439 push2 = tempcx + 1 ;
6440 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6441 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6442 temp = ( tempcx & 0xFF00 ) >> 8 ;
6444 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6445 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6446 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6447 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6448 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6450 /* Customized LCDB Des no add */
6452 LCDBDesPtr = ( XGI_LCDDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
6453 tempah = pVBInfo->LCDResInfo ;
6454 tempah &= PanelResInfo ;
6456 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6461 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6466 else if ( tempah == Panel1400x1050 )
6477 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6479 tempbx = pVBInfo->HDE ;
6480 tempcx = pVBInfo->VDE ;
6484 tempax = pVBInfo->VT ;
6485 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6486 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6487 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6488 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6489 tempbx = pVBInfo->LCDVDES ;
6492 if ( tempcx >= tempax )
6493 tempcx -= tempax ; /* lcdvdes */
6495 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6496 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6497 temp = tempcx & 0x00FF ;
6498 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6499 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6500 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6502 tempah = tempah << 3 ;
6504 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6507 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6509 tempax = pVBInfo->VT ;
6510 tempbx = pVBInfo->LCDVRS ;
6512 /* if ( SetLCD_Info & EnableScalingLCD ) */
6514 if ( tempcx >= tempax )
6517 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6518 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6519 temp = ( tempbx & 0xFF00 ) >> 8 ;
6521 temp |= ( tempcx & 0x000F ) ;
6522 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6524 tempax = pVBInfo->HT ;
6525 tempbx = pVBInfo->LCDHDES ;
6528 if ( XGI_IsLCDDualLink( pVBInfo ) )
6530 tempax = tempax >> 1 ;
6531 tempbx = tempbx >> 1 ;
6532 tempcx = tempcx >> 1 ;
6535 if ( pVBInfo->VBType & VB_XGI302LV )
6538 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6543 if ( tempcx >= tempax )
6546 temp = tempbx & 0x00FF ;
6547 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6548 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6549 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6550 temp = tempcx & 0x00FF ;
6551 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6552 temp = ( tempcx & 0xFF00 ) >> 8 ;
6553 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6556 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6558 tempax = pVBInfo->HT ;
6559 tempbx = pVBInfo->LCDHRS ;
6560 /* if ( SetLCD_Info & EnableScalingLCD) */
6561 if ( XGI_IsLCDDualLink( pVBInfo) )
6563 tempax = tempax >> 1 ;
6564 tempbx = tempbx >> 1 ;
6565 tempcx = tempcx >> 1 ;
6568 if ( pVBInfo->VBType & VB_XGI302LV )
6573 if ( tempcx >= tempax )
6576 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6577 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6579 temp = ( tempbx & 0xFF00 ) >> 8 ;
6581 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6582 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6583 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6585 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6587 if ( pVBInfo->VGAVDE == 525 )
6589 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6596 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6597 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6600 if ( pVBInfo->VGAVDE == 420 )
6602 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6608 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6614 /* --------------------------------------------------------------------- */
6615 /* Function : XGI_GetTap4Ptr */
6617 /* Output : di -> Tap4 Reg. Setting Pointer */
6619 /* --------------------------------------------------------------------- */
6620 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo)
6626 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6630 tempax = pVBInfo->VGAHDE ;
6631 tempbx = pVBInfo->HDE ;
6635 tempax = pVBInfo->VGAVDE ;
6636 tempbx = pVBInfo->VDE ;
6639 if ( tempax < tempbx )
6640 return &EnlargeTap4Timing[ 0 ] ;
6641 else if( tempax == tempbx )
6642 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6644 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6646 if ( pVBInfo->TVInfo & SetPALTV )
6647 Tap4TimingPtr = PALTap4Timing ;
6650 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6652 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6653 Tap4TimingPtr = YPbPr525iTap4Timing ;
6654 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6655 Tap4TimingPtr = YPbPr525pTap4Timing ;
6656 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6657 Tap4TimingPtr = YPbPr750pTap4Timing ;
6660 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6661 Tap4TimingPtr = HiTVTap4Timing ;
6664 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6666 if ( Tap4TimingPtr[ i ].DE == tempax )
6670 return &Tap4TimingPtr[ i ] ;
6674 /* --------------------------------------------------------------------- */
6675 /* Function : XGI_SetTap4Regs */
6679 /* --------------------------------------------------------------------- */
6680 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo)
6685 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6687 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6691 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6692 #else /* Tap4 Setting */
6694 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6695 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6696 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6698 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6700 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6701 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6702 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6705 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6706 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
6708 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
6712 /* --------------------------------------------------------------------- */
6713 /* Function : XGI_SetGroup3 */
6717 /* --------------------------------------------------------------------- */
6718 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
6726 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6730 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6734 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
6735 if(pVBInfo->TVInfo&SetPALTV)
6737 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6738 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6742 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
6743 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
6746 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
6751 if(pVBInfo->TVInfo&SetPALMTV)
6753 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6754 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6755 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
6758 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
6760 if(pVBInfo->TVInfo & SetYPbPrMode525i)
6764 tempdi=pVBInfo->HiTVGroup3Data;
6765 if(pVBInfo->SetFlag&TVSimuMode)
6767 tempdi=pVBInfo->HiTVGroup3Simu;
6768 if(!(modeflag&Charx8Dot))
6770 tempdi=pVBInfo->HiTVGroup3Text;
6774 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6776 tempdi=pVBInfo->Ren525pGroup3;
6778 if(pVBInfo->TVInfo & SetYPbPrMode750p)
6780 tempdi=pVBInfo->Ren750pGroup3;
6783 for(i=0;i<=0x3E;i++)
6785 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
6787 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
6789 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6791 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
6796 } /* {end of XGI_SetGroup3} */
6799 /* --------------------------------------------------------------------- */
6800 /* Function : XGI_SetGroup4 */
6804 /* --------------------------------------------------------------------- */
6805 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
6819 if ( ModeNo <= 0x13 )
6821 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6825 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6828 temp = pVBInfo->RVBHCFACT ;
6829 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
6831 tempbx = pVBInfo->RVBHCMAX ;
6832 temp = tempbx & 0x00FF ;
6833 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
6834 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
6835 tempcx = pVBInfo->VGAHT - 1 ;
6836 temp = tempcx & 0x00FF ;
6837 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
6839 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
6842 tempcx = pVBInfo->VGAVT - 1 ;
6843 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6848 temp = tempcx & 0x00FF ;
6849 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
6850 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
6851 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
6852 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
6853 tempcx = pVBInfo->VBInfo ;
6854 tempbx = pVBInfo->VGAHDE ;
6856 if ( modeflag & HalfDCLK )
6858 tempbx = tempbx >> 1 ;
6861 if ( XGI_IsLCDDualLink( pVBInfo ) )
6862 tempbx = tempbx >> 1 ;
6864 if(tempcx&SetCRT2ToHiVisionTV)
6872 else if(tempcx&SetCRT2ToTV)
6881 if(pVBInfo->VBInfo&SetCRT2ToLCD)
6889 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6892 if ( pVBInfo->VGAHDE == 1280 )
6894 if ( pVBInfo->VGAHDE == 1024 )
6897 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
6899 tempebx = pVBInfo->VDE ;
6901 if ( tempcx & SetCRT2ToHiVisionTV )
6903 if ( !( temp & 0xE000 ) )
6904 tempbx = tempbx >> 1 ;
6907 tempcx = pVBInfo->RVBHRS ;
6908 temp = tempcx & 0x00FF ;
6909 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
6911 tempeax = pVBInfo->VGAVDE ;
6915 if ( tempeax <= tempebx )
6917 tempcx=(tempcx&(~0x4000));
6918 tempeax = pVBInfo->VGAVDE ;
6922 tempeax -= tempebx ;
6926 templong = ( tempeax * 256 * 1024 ) % tempebx ;
6927 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
6930 if ( templong != 0 )
6936 temp = ( USHORT )( tempebx & 0x000000FF ) ;
6937 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
6939 temp = ( USHORT )( ( tempebx & 0x0000FF00 ) >> 8 ) ;
6940 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
6941 tempbx = ( USHORT )( tempebx >> 16 ) ;
6942 temp = tempbx & 0x00FF ;
6944 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
6945 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
6948 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6951 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
6952 tempax = pVBInfo->VGAHDE ;
6953 if ( modeflag & HalfDCLK )
6955 tempax = tempax >> 1 ;
6958 if ( XGI_IsLCDDualLink( pVBInfo ) )
6959 tempax = tempax >> 1 ;
6961 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6962 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
6969 if ( pVBInfo->VGAHDE > 800 )
6971 if ( pVBInfo->VGAHDE == 1024 )
6972 tempax = ( tempax * 25 / 32 ) - 1 ;
6974 tempax = ( tempax * 20 / 32 ) - 1 ;
6980 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
6982 if ( pVBInfo->VBType & VB_XGI301LV )
6984 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6986 if ( pVBInfo->VGAHDE > 800 )
6988 if ( pVBInfo->VGAHDE == 1024 )
6989 tempax = ( tempax * 25 / 32 ) - 1 ;
6991 tempax = ( tempax * 20 / 32 ) - 1 ;
6997 if ( pVBInfo->VGAHDE > 800 )
6999 if ( pVBInfo->VGAHDE == 1024 )
7000 tempax = ( tempax * 25 / 32 ) - 1 ;
7002 tempax = ( tempax * 20 / 32 ) - 1 ;
7008 temp = ( tempax & 0xFF00 ) >> 8 ;
7009 temp = ( ( temp & 0x0003 ) << 4 ) ;
7010 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
7011 temp = ( tempax & 0x00FF ) ;
7012 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7014 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7016 if ( pVBInfo->VGAHDE > 800 )
7018 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7023 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7025 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7028 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7029 temp &= ( ~0x0001 ) ;
7033 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7034 tempbx = pVBInfo->HT ;
7035 if ( XGI_IsLCDDualLink( pVBInfo ) )
7036 tempbx = tempbx >> 1 ;
7037 tempbx = ( tempbx >> 1 ) - 2 ;
7038 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7039 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7040 temp = tempbx & 0x00FF ;
7041 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7045 if ( pVBInfo->ISXPDOS == 0 )
7046 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7050 /* --------------------------------------------------------------------- */
7051 /* Function : XGI_SetGroup5 */
7055 /* --------------------------------------------------------------------- */
7056 void XGI_SetGroup5( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
7061 Pindex = pVBInfo->Part5Port ;
7062 Pdata = pVBInfo->Part5Port + 1 ;
7063 if ( pVBInfo->ModeType == ModeVGA )
7065 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7067 XGINew_EnableCRT2(pVBInfo) ;
7068 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7075 /* --------------------------------------------------------------------- */
7076 /* Function : XGI_GetLcdPtr */
7080 /* --------------------------------------------------------------------- */
7081 void* XGI_GetLcdPtr( USHORT BX , USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7091 XGI330_LCDDataTablStruct *tempdi = 0 ;
7096 if ( ModeNo <= 0x13 )
7098 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7099 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7103 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7104 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7107 tempal = tempal & 0x0f ;
7109 if ( tempbx <= 1 ) /* ExpLink */
7111 if ( ModeNo <= 0x13 )
7113 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7117 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7120 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7122 if ( ModeNo <= 0x13 )
7123 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7125 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7128 if ( tempbx & 0x01 )
7129 tempal = ( tempal >> 4 ) ;
7131 tempal = ( tempal & 0x0f ) ;
7134 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7136 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7138 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7139 tempcx = LCDDesDataLen2 ;
7140 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7141 tempcx = LVDSDesDataLen2 ;
7143 /* mov di, word ptr cs:LCDDataList[bx] */
7144 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7149 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7152 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7155 tempdi = XGI_EPLLCDDataPtr ;
7158 tempdi = XGI_EPLLCDDesDataPtr ;
7161 tempdi = XGI_LCDDataTable ;
7164 tempdi = XGI_LCDDesDataTable ;
7167 tempdi = XGI_EPLCHLCDRegPtr ;
7178 if ( tempdi == 0x00 ) /* OEMUtil */
7184 while( tempdi[ i ].PANELID != 0xff )
7186 tempdx = pVBInfo->LCDResInfo ;
7187 if ( tempbx & 0x0080 ) /* OEMUtil */
7189 tempbx &= ( ~0x0080 ) ;
7190 tempdx = pVBInfo->LCDTypeInfo ;
7193 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7194 tempdx &= ( ~PanelResInfo ) ;
7196 if ( tempdi[ i ].PANELID == tempdx )
7198 tempbx = tempdi[ i ].MASK ;
7199 tempdx = pVBInfo->LCDInfo ;
7201 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7202 tempdx |= SetLCDStdMode ;
7204 if ( modeflag & HalfDCLK )
7205 tempdx |= SetLCDLowResolution ;
7208 if ( tempbx == tempdi[ i ].CAP )
7216 switch( tempdi[ i ].DATAPTR )
7219 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7222 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7225 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7228 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7231 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7234 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7237 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7240 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7243 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7246 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7249 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7255 else if ( table == 1 )
7257 switch( tempdi[ i ].DATAPTR )
7260 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7263 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7266 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7269 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7272 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7275 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7278 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7281 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7284 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7287 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7290 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7296 else if ( table == 2 )
7298 switch( tempdi[ i ].DATAPTR )
7301 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7304 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7307 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7310 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7313 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7316 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7319 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7322 return &XGI_LVDSNoScalingData[ tempal ] ;
7325 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7328 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7331 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7334 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7337 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7343 else if ( table == 3 )
7345 switch( tempdi[ i ].DATAPTR )
7348 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7351 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7354 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7357 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7360 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7363 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7366 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7369 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7372 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7375 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7378 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7381 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7384 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7387 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7390 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7396 else if ( table == 4 )
7398 switch( tempdi[ i ].DATAPTR )
7401 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7404 return &XGI_StLCD1024x768Data[ tempal ] ;
7407 return &XGI_CetLCD1024x768Data[ tempal ] ;
7410 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7413 return &XGI_StLCD1280x1024Data[ tempal ] ;
7416 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7419 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7422 return &XGI_StLCD1400x1050Data[ tempal ] ;
7425 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7428 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7431 return &XGI_StLCD1600x1200Data[ tempal ] ;
7434 return &XGI_NoScalingData[ tempal ] ;
7437 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7440 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7443 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7446 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7449 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7452 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7455 return &XGI_NoScalingDatax75[ tempal ] ;
7461 else if ( table == 5 )
7463 switch( tempdi[ i ].DATAPTR )
7466 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7469 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7472 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7475 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7476 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7478 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7481 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7482 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7484 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7487 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7488 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7490 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7493 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7494 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7496 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7499 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7500 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7502 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7505 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7508 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7511 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7512 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7514 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7517 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7518 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7520 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7523 return &XGI_NoScalingDesData[ tempal ] ;
7526 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7529 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7532 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7535 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7536 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7538 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7541 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7542 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7544 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7547 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7548 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7550 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7553 return &XGI_NoScalingDesDatax75[ tempal ] ;
7559 else if ( table == 6 )
7561 switch( tempdi[ i ].DATAPTR )
7564 return &XGI_CH7017LV1024x768[ tempal ] ;
7567 return &XGI_CH7017LV1400x1050[ tempal ] ;
7577 /* --------------------------------------------------------------------- */
7578 /* Function : XGI_GetTVPtr */
7582 /* --------------------------------------------------------------------- */
7583 void* XGI_GetTVPtr (USHORT BX,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7585 USHORT i , tempdx , tempbx , tempal , modeflag , table ;
7586 XGI330_TVDataTablStruct *tempdi = 0 ;
7590 if ( ModeNo <= 0x13 )
7592 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7593 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7597 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7598 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7601 tempal = tempal & 0x3f ;
7607 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7608 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7610 tempdi = XGI_EPLCHTVCRT1Ptr;
7614 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7615 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7617 tempdi = XGI_EPLCHTVCRT1Ptr;
7621 tempdi = XGI_EPLCHTVDataPtr ;
7627 tempdi = XGI_TVDataTable ;
7633 tempdi = XGI_EPLCHTVRegPtr ;
7639 if ( tempdi == 0x00 ) /* OEMUtil */
7642 tempdx = pVBInfo->TVInfo ;
7644 if ( pVBInfo->VBInfo & SetInSlaveMode )
7645 tempdx = tempdx | SetTVLockMode ;
7647 if ( modeflag & HalfDCLK )
7648 tempdx = tempdx | SetTVLowResolution ;
7652 while( tempdi[ i ].MASK != 0xffff )
7654 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7659 if ( table == 0x00 ) /* 07/05/22 */
7662 else if ( table == 0x01 )
7665 else if ( table == 0x04 )
7667 switch( tempdi[ i ].DATAPTR )
7670 return &XGI_ExtPALData[ tempal ] ;
7673 return &XGI_ExtNTSCData[ tempal ] ;
7676 return &XGI_StPALData[ tempal ] ;
7679 return &XGI_StNTSCData[ tempal ] ;
7682 return &XGI_ExtHiTVData[ tempal ] ;
7685 return &XGI_St2HiTVData[ tempal ] ;
7688 return &XGI_ExtYPbPr525iData[ tempal ] ;
7691 return &XGI_ExtYPbPr525pData[ tempal ] ;
7694 return &XGI_ExtYPbPr750pData[ tempal ] ;
7697 return &XGI_StYPbPr525iData[ tempal ] ;
7700 return &XGI_StYPbPr525pData[ tempal ] ;
7703 return &XGI_StYPbPr750pData[ tempal ] ;
7705 case 12: /* avoid system hang */
7706 return &XGI_ExtNTSCData[ tempal ] ;
7709 return &XGI_St1HiTVData[ tempal ] ;
7715 else if( table == 0x02 )
7717 switch( tempdi[ i ].DATAPTR )
7720 return &XGI_CHTVUNTSCData[ tempal ] ;
7723 return &XGI_CHTVONTSCData[ tempal ] ;
7726 return &XGI_CHTVUPALData[ tempal ] ;
7729 return &XGI_CHTVOPALData[ tempal ] ;
7735 else if( table == 0x06 )
7742 /* --------------------------------------------------------------------- */
7743 /* Function : XGI_BacklightByDrv */
7745 /* Output : TRUE -> Skip backlight control */
7747 /* --------------------------------------------------------------------- */
7748 BOOLEAN XGI_BacklightByDrv( PVB_DEVICE_INFO pVBInfo )
7752 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x3A ) ;
7753 if ( tempah & BacklightControlBit )
7760 /* --------------------------------------------------------------------- */
7761 /* Function : XGI_FirePWDDisable */
7764 /* Description : Turn off VDD & Backlight : Fire disable procedure */
7765 /* --------------------------------------------------------------------- */
7767 void XGI_FirePWDDisable( PVB_DEVICE_INFO pVBInfo )
7769 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
7773 /* --------------------------------------------------------------------- */
7774 /* Function : XGI_FirePWDEnable */
7777 /* Description : Turn on VDD & Backlight : Fire enable procedure */
7778 /* --------------------------------------------------------------------- */
7779 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo )
7781 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
7785 /* --------------------------------------------------------------------- */
7786 /* Function : XGI_EnableGatingCRT */
7790 /* --------------------------------------------------------------------- */
7791 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7793 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
7797 /* --------------------------------------------------------------------- */
7798 /* Function : XGI_DisableGatingCRT */
7802 /* --------------------------------------------------------------------- */
7803 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7806 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
7810 /* --------------------------------------------------------------------- */
7811 /* Function : XGI_SetPanelDelay */
7815 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7816 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7817 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7818 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7819 /* --------------------------------------------------------------------- */
7820 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7824 index = XGI_GetLCDCapPtr(pVBInfo) ;
7827 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
7830 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
7833 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
7836 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
7840 /* --------------------------------------------------------------------- */
7841 /* Function : XGI_SetPanelPower */
7845 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
7846 /* = 0111b = 07h ; Backlight on, Power off */
7847 /* = 1011b = 0Bh ; Backlight off, Power on */
7848 /* = 1111b = 0Fh ; Backlight off, Power off */
7849 /* --------------------------------------------------------------------- */
7850 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7852 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7853 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
7855 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
7858 UCHAR XG21GPIODataTransfer(UCHAR ujDate)
7866 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
7867 ujRet |= (ujDate >> i) & 1;
7873 /*----------------------------------------------------------------------------*/
7875 /* bl[5] : LVDS signal */
7876 /* bl[1] : LVDS backlight */
7877 /* bl[0] : LVDS VDD */
7878 /*----------------------------------------------------------------------------*/
7879 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7883 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7884 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
7886 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7888 temp = XG21GPIODataTransfer(temp);
7890 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7894 /*----------------------------------------------------------------------------*/
7896 /* bl[5] : LVDS signal */
7897 /* bl[1] : LVDS backlight */
7898 /* bl[0] : LVDS VDD */
7899 /*----------------------------------------------------------------------------*/
7900 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7902 UCHAR CR4A,CRB4,temp;
7904 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7905 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
7907 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7911 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7912 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
7913 temp |= ((CRB4&0x04)<<3);
7916 /*----------------------------------------------------------------------------*/
7918 /* bl[5] : 1;LVDS signal on */
7919 /* bl[1] : 1;LVDS backlight on */
7920 /* bl[0] : 1:LVDS VDD on */
7921 /* bh: 100000b : clear bit 5, to set bit5 */
7922 /* 000010b : clear bit 1, to set bit1 */
7923 /* 000001b : clear bit 0, to set bit0 */
7924 /*----------------------------------------------------------------------------*/
7925 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7929 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7932 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7936 temp = (tempbl>>4)&0x02;
7938 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7942 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7944 temp = XG21GPIODataTransfer(temp);
7947 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
7950 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7953 USHORT tempbh0,tempbl0;
7964 temp = (tempbl>>4)&0x02;
7966 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7969 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
7971 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7975 tempbl <<= 2; /* GPIOC,GPIOD */
7976 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7977 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
7980 /* --------------------------------------------------------------------- */
7981 USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo)
7985 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
7986 if (index<sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct))
7993 /* --------------------------------------------------------------------- */
7994 /* Function : XGI_XG21SetPanelDelay */
7998 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7999 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
8000 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
8001 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
8002 /* --------------------------------------------------------------------- */
8003 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8007 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
8009 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8012 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8015 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8018 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8021 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8030 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8031 if ( ModeNo <= 0x13 )
8033 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8034 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8035 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8039 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8040 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8041 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8044 if ( !( modeflag & Charx8Dot ) )
8050 if ( ModeNo > 0x13 )
8052 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8056 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8062 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8063 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8066 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8069 if ( ModeNo > 0x13 )
8071 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8072 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8074 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8075 if ( colordepth > 2 )
8084 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo)
8088 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8089 temp = ( temp & 1 ) << 6;
8090 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8091 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8095 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo)
8099 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8100 temp = ( temp & 3 ) << 6;
8101 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8102 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8106 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8108 UCHAR temp,Miscdata;
8114 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8115 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8118 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8120 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8121 temp &= LCDPolarity;
8122 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8124 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8126 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8127 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8128 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8130 XGI_SetXG21FPBits(pVBInfo);
8131 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8132 if ( ModeNo <= 0x13 )
8134 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8135 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8136 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8140 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8141 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8142 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8145 if (!( modeflag & Charx8Dot ))
8146 xres = xres * 8 / 9;
8148 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8150 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8151 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8155 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8157 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8158 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8160 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8161 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8163 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8165 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8167 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8168 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8172 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8174 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8175 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8177 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8178 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8180 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8182 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8183 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8185 if (!( modeflag & Charx8Dot ))
8187 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8190 /* HT SR0B[1:0] CR00 */
8191 value = ( LVDSHT >> 3 ) - 5;
8192 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8193 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8195 /* HBS SR0B[5:4] CR02 */
8196 value = ( LVDSHBS >> 3 ) - 1;
8197 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8198 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8200 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8201 value = ( LVDSHBE >> 3 ) - 1;
8202 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8203 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8204 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8206 /* HRS SR0B[7:6] CR04 */
8207 value = ( LVDSHRS >> 3 ) + 2;
8208 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8209 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8211 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8213 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8214 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8216 /* HRE SR0C[2] CR05[4:0] */
8217 value = ( LVDSHRE >> 3 ) + 2;
8218 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8219 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8221 /* Panel HRE SR2F[7:2] */
8223 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8225 /* VT SR0A[0] CR07[5][0] CR06 */
8226 value = LVDSVT - 2 ;
8227 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8228 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8229 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8230 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8232 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8233 value = LVDSVBS - 1 ;
8234 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8235 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8236 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8237 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8239 /* VBE SR0A[4] CR16 */
8240 value = LVDSVBE - 1;
8241 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8242 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8244 /* VRS SR0A[3] CR7[7][2] CR10 */
8245 value = LVDSVRS - 1 ;
8246 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8247 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8248 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8249 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8251 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8252 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8253 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8254 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8256 /* VRE SR0A[5] CR11[3:0] */
8257 value = LVDSVRE - 1;
8258 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8259 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8261 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8262 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8264 for ( temp=0, value = 0; temp < 3; temp++)
8267 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8268 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8269 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8273 if (!( modeflag & Charx8Dot ))
8275 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8276 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8277 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8279 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8280 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8282 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8288 /* no shadow case */
8289 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8291 UCHAR temp,Miscdata;
8297 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8298 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8301 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8302 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8303 temp &= LCDPolarity;
8304 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8306 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8308 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8309 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8310 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8312 XGI_SetXG27FPBits(pVBInfo);
8313 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8314 if ( ModeNo <= 0x13 )
8316 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8317 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8318 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8322 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8323 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8324 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8327 if (!( modeflag & Charx8Dot ))
8328 xres = xres * 8 / 9;
8330 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8332 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8333 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8337 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8339 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8340 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8342 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8343 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8345 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8347 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8349 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8350 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8354 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8356 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8357 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8359 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8360 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8362 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8364 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8365 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8367 if (!( modeflag & Charx8Dot ))
8369 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8372 /* HT SR0B[1:0] CR00 */
8373 value = ( LVDSHT >> 3 ) - 5;
8374 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8375 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8377 /* HBS SR0B[5:4] CR02 */
8378 value = ( LVDSHBS >> 3 ) - 1;
8379 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8380 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8382 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8383 value = ( LVDSHBE >> 3 ) - 1;
8384 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8385 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8386 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8388 /* HRS SR0B[7:6] CR04 */
8389 value = ( LVDSHRS >> 3 ) + 2;
8390 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8391 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8393 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8395 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8396 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8398 /* HRE SR0C[2] CR05[4:0] */
8399 value = ( LVDSHRE >> 3 ) + 2;
8400 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8401 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8403 /* Panel HRE SR2F[7:2] */
8405 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8407 /* VT SR0A[0] CR07[5][0] CR06 */
8408 value = LVDSVT - 2 ;
8409 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8410 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8411 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8412 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8414 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8415 value = LVDSVBS - 1 ;
8416 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8417 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8418 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8419 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8421 /* VBE SR0A[4] CR16 */
8422 value = LVDSVBE - 1;
8423 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8424 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8426 /* VRS SR0A[3] CR7[7][2] CR10 */
8427 value = LVDSVRS - 1 ;
8428 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8429 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8430 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8431 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8433 /* Panel VRS SR35[2:0] SR34[7:0] */
8434 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8435 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8437 /* VRE SR0A[5] CR11[3:0] */
8438 value = LVDSVRE - 1;
8439 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8440 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8442 /* Panel VRE SR3F[7:2] */
8443 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8445 for ( temp=0, value = 0; temp < 3; temp++)
8448 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8449 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8450 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8454 if (!( modeflag & Charx8Dot ))
8456 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8457 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8458 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8460 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8461 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8463 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8469 /* --------------------------------------------------------------------- */
8470 /* Function : XGI_IsLCDON */
8472 /* Output : FALSE : Skip PSC Control */
8473 /* TRUE: Disable PSC */
8475 /* --------------------------------------------------------------------- */
8476 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo)
8480 tempax = pVBInfo->VBInfo ;
8481 if ( tempax & SetCRT2ToDualEdge )
8483 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8490 /* --------------------------------------------------------------------- */
8491 /* Function : XGI_EnablePWD */
8495 /* --------------------------------------------------------------------- */
8496 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo )
8501 index = XGI_GetLCDCapPtr(pVBInfo) ;
8502 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8503 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8504 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8505 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8506 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8507 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8508 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8512 /* --------------------------------------------------------------------- */
8513 /* Function : XGI_DisablePWD */
8517 /* --------------------------------------------------------------------- */
8518 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo )
8520 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8524 /* --------------------------------------------------------------------- */
8525 /* Function : XGI_DisableChISLCD */
8527 /* Output : FALSE -> Not LCD Mode */
8529 /* --------------------------------------------------------------------- */
8530 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo)
8535 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8536 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8538 if ( tempbx & ( EnableChA | DisableChA ) )
8540 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8544 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8547 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8554 /* --------------------------------------------------------------------- */
8555 /* Function : XGI_EnableChISLCD */
8557 /* Output : 0 -> Not LCD mode */
8559 /* --------------------------------------------------------------------- */
8560 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo)
8566 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8567 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8569 if ( tempbx & ( EnableChA | DisableChA ) )
8571 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8575 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8578 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8585 /* --------------------------------------------------------------------- */
8586 /* Function : XGI_GetLCDCapPtr */
8590 /* --------------------------------------------------------------------- */
8591 USHORT XGI_GetLCDCapPtr( PVB_DEVICE_INFO pVBInfo )
8598 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8599 tempal = tempah & 0x0F ;
8600 tempah = tempah & 0xF0 ;
8602 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8604 while( tempbl != 0xFF )
8606 if ( tempbl & 0x80 ) /* OEMUtil */
8609 tempbl = tempbl & ~( 0x80 ) ;
8612 if ( tempal == tempbl )
8617 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8624 /* --------------------------------------------------------------------- */
8625 /* Function : XGI_GetLCDCapPtr1 */
8629 /* --------------------------------------------------------------------- */
8630 USHORT XGI_GetLCDCapPtr1( PVB_DEVICE_INFO pVBInfo )
8637 tempal = pVBInfo->LCDResInfo ;
8638 tempah = pVBInfo->LCDTypeInfo ;
8641 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
8643 while( tempbl != 0xFF )
8645 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
8651 if ( tempal == tempbl )
8655 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8658 if ( tempbl == 0xFF )
8660 pVBInfo->LCDResInfo = Panel1024x768 ;
8661 pVBInfo->LCDTypeInfo = 0 ;
8669 /* --------------------------------------------------------------------- */
8670 /* Function : XGI_GetLCDSync */
8674 /* --------------------------------------------------------------------- */
8675 void XGI_GetLCDSync( USHORT* HSyncWidth , USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo )
8679 Index = XGI_GetLCDCapPtr(pVBInfo) ;
8680 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
8681 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
8688 /* --------------------------------------------------------------------- */
8689 /* Function : XGI_EnableBridge */
8693 /* --------------------------------------------------------------------- */
8694 void XGI_EnableBridge( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
8699 if ( pVBInfo->SetFlag == Win9xDOSMode )
8701 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8703 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8706 else /* LVDS or CH7017 */
8711 if ( HwDeviceExtension->jChipType < XG40 )
8713 if ( !XGI_DisableChISLCD(pVBInfo) )
8715 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8717 if ( pVBInfo->LCDInfo & SetPWDEnable )
8719 XGI_EnablePWD( pVBInfo);
8723 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
8724 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8735 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
8736 XGI_SetPanelDelay( 1,pVBInfo ) ;
8744 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8746 if ( !( pVBInfo->SetFlag & DisableChA ) )
8748 if ( pVBInfo->SetFlag & EnableChA )
8750 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
8754 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
8756 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
8761 if ( !( pVBInfo->SetFlag & DisableChB ) )
8763 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
8765 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
8767 if ( pVBInfo->VBInfo & SetInSlaveMode )
8769 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
8772 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
8773 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
8776 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8778 if ( !( tempah & 0x80 ) )
8779 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8781 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
8785 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
8787 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
8788 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8790 if ( !XGI_DisableChISLCD(pVBInfo) )
8792 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8793 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
8795 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
8801 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
8805 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
8807 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8809 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8811 tempah = tempah & 0x40;
8812 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8813 tempah = tempah ^ 0xC0 ;
8815 if ( pVBInfo->SetFlag & DisableChB )
8818 if ( pVBInfo->SetFlag & DisableChA )
8821 if ( pVBInfo->SetFlag & EnableChB )
8824 if ( pVBInfo->SetFlag & EnableChA )
8831 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
8833 if ( pVBInfo->SetFlag & Win9xDOSMode )
8835 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8839 if ( !( pVBInfo->SetFlag & DisableChA ) )
8841 XGI_VBLongWait( pVBInfo) ;
8842 if ( !( pVBInfo->SetFlag & GatingCRT ) )
8844 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8845 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8846 XGI_VBLongWait( pVBInfo) ;
8852 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
8853 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
8857 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8858 if ( !( tempah & 0x80 ) )
8859 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8861 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
8862 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
8866 if ( HwDeviceExtension->jChipType < XG40 )
8868 if ( !XGI_EnableChISLCD(pVBInfo) )
8870 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
8872 if ( XGI_BacklightByDrv(pVBInfo) )
8879 if ( pVBInfo->LCDInfo & SetPWDEnable )
8881 XGI_FirePWDEnable(pVBInfo) ;
8885 XGI_SetPanelDelay( 2,pVBInfo ) ;
8887 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8890 tempbl = 0xFE ; /* turn on backlght */
8897 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
8902 /* --------------------------------------------------------------------- */
8903 /* Function : XGI_DisableBridge */
8907 /* --------------------------------------------------------------------- */
8908 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8915 if ( pVBInfo->SetFlag == Win9xDOSMode )
8919 if ( HwDeviceExtension->jChipType < XG40 )
8921 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8923 if ( !XGI_IsLCDON(pVBInfo) )
8925 if ( pVBInfo->LCDInfo & SetPWDEnable )
8926 XGI_EnablePWD( pVBInfo) ;
8929 pVBInfo->LCDInfo &= ~SetPWDEnable ;
8930 XGI_DisablePWD(pVBInfo) ;
8931 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8933 tempbx = 0xFE ; /* not 01h */
8938 tempbx = 0xF7 ; /* not 08h */
8941 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
8942 XGI_SetPanelDelay( 3,pVBInfo ) ;
8944 } /* end if(!XGI_IsLCDON(pVBInfo)) */
8950 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8952 if ( !XGI_IsLCDON(pVBInfo) )
8956 tempbx = XGINew_GetCH7005( 0x61 ) ;
8957 if ( tempbx < 0x01 ) //first time we power up
8958 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
8960 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
8966 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8969 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
8971 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8973 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8975 tempah = 0x7F; /* Disable Channel A */
8976 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
8977 tempah = 0xBF ; /* Disable Channel B */
8979 if ( pVBInfo->SetFlag & DisableChB )
8980 tempah &= 0xBF ; /* force to disable Cahnnel */
8982 if ( pVBInfo->SetFlag & DisableChA )
8983 tempah &= 0x7F ; /* Force to disable Channel B */
8988 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
8990 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8992 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
8993 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
8996 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
8998 if ( pVBInfo->SetFlag & GatingCRT )
8999 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9000 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9003 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9005 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9006 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
9009 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
9011 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
9012 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9014 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9015 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9016 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9018 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9019 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9021 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9022 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9023 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9024 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9029 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9031 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9032 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9033 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9036 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9037 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9043 if ( HwDeviceExtension->jChipType < XG40 )
9045 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9047 if ( pVBInfo->LCDInfo & SetPWDEnable )
9049 if ( pVBInfo->LCDInfo & SetPWDEnable )
9050 XGI_BacklightByDrv(pVBInfo) ;
9053 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9054 if ( pVBInfo->VBType & VB_XGI301LV )
9066 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9072 /* --------------------------------------------------------------------- */
9073 /* Function : XGI_GetTVPtrIndex */
9076 /* Description : bx 0 : ExtNTSC */
9088 /* --------------------------------------------------------------------- */
9089 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo )
9093 if ( pVBInfo->TVInfo & SetPALTV )
9095 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9097 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9099 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9101 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9103 if ( pVBInfo->TVInfo & TVSimuMode )
9110 /* --------------------------------------------------------------------- */
9111 /* Function : XGI_OEM310Setting */
9114 /* Description : Customized Param. for 301 */
9115 /* --------------------------------------------------------------------- */
9116 void XGI_OEM310Setting( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9118 if ( pVBInfo->SetFlag & Win9xDOSMode )
9122 XGI_SetDelayComp(pVBInfo) ;
9124 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9125 XGI_SetLCDCap(pVBInfo) ;
9127 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9130 XGI_SetPhaseIncr(pVBInfo) ;
9131 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9132 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9134 if ( pVBInfo->VBType&VB_XGI301)
9135 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9140 /* --------------------------------------------------------------------- */
9141 /* Function : XGI_SetDelayComp */
9145 /* --------------------------------------------------------------------- */
9146 void XGI_SetDelayComp( PVB_DEVICE_INFO pVBInfo )
9154 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9156 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9161 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9162 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9164 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9165 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9167 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9168 tempbl = tempbl >> 4 ;
9170 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9171 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9173 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9174 tempbl = CRT2Delay2 ;
9176 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9178 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9179 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9181 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9187 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9189 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9195 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9200 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9203 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9207 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9209 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9211 tempah = tempah << 4 ;
9212 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9218 /* --------------------------------------------------------------------- */
9219 /* Function : XGI_SetLCDCap */
9223 /* --------------------------------------------------------------------- */
9224 void XGI_SetLCDCap( PVB_DEVICE_INFO pVBInfo )
9228 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9230 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9232 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9233 { /* 301LV/302LV only */
9234 /* Set 301LV Capability */
9235 XGINew_SetReg1( pVBInfo->Part4Port , 0x24 , ( UCHAR )( tempcx & 0x1F ) ) ;
9238 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~( ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) >> 8 ) , ( USHORT )( ( tempcx & ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) ) >> 8 ) ) ;
9241 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9243 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9244 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9245 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9246 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9248 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9250 if ( tempcx & EnableSpectrum )
9251 SetSpectrum( pVBInfo) ;
9254 else /* LVDS,CH7017 */
9255 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9259 /* --------------------------------------------------------------------- */
9260 /* Function : XGI_SetLCDCap_A */
9264 /* --------------------------------------------------------------------- */
9265 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9269 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9271 if ( temp & LCDRGB18Bit )
9273 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x20 | ( tempcx & 0x00C0 ) ) ) ; /* Enable Dither */
9274 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9278 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x30 | ( tempcx & 0x00C0 ) ) ) ;
9279 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9283 if ( tempcx & EnableLCD24bpp ) // 24bits
9285 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x30|(tempcx&0x00C0)) );
9286 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9290 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x20|(tempcx&0x00C0)) );//Enable Dither
9291 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9297 /* --------------------------------------------------------------------- */
9298 /* Function : XGI_SetLCDCap_B */
9299 /* Input : cx -> LCD Capability */
9302 /* --------------------------------------------------------------------- */
9303 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9305 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9306 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x0c ) ) ;
9308 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x18 ) ) ; /* Enable Dither */
9312 /* --------------------------------------------------------------------- */
9313 /* Function : SetSpectrum */
9317 /* --------------------------------------------------------------------- */
9318 void SetSpectrum( PVB_DEVICE_INFO pVBInfo )
9322 index = XGI_GetLCDCapPtr(pVBInfo) ;
9324 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9325 XGI_LongWait(pVBInfo) ;
9326 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9327 XGI_LongWait(pVBInfo) ;
9329 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9330 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9331 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9332 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9333 XGI_LongWait(pVBInfo) ;
9334 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9338 /* --------------------------------------------------------------------- */
9339 /* Function : XGI_SetAntiFlicker */
9342 /* Description : Set TV Customized Param. */
9343 /* --------------------------------------------------------------------- */
9344 void XGI_SetAntiFlicker( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
9351 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9354 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9357 if ( ModeNo <= 0x13 )
9359 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9363 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9367 tempah = TVAntiFlickList[ tempbx ] ;
9368 tempah = tempah << 4 ;
9370 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9374 /* --------------------------------------------------------------------- */
9375 /* Function : XGI_SetEdgeEnhance */
9379 /* --------------------------------------------------------------------- */
9380 void XGI_SetEdgeEnhance( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
9388 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9391 if ( ModeNo <= 0x13 )
9393 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9397 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9401 tempah = TVEdgeList[ tempbx ] ;
9402 tempah = tempah << 5 ;
9404 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9408 /* --------------------------------------------------------------------- */
9409 /* Function : XGI_SetPhaseIncr */
9413 /* --------------------------------------------------------------------- */
9414 void XGI_SetPhaseIncr( PVB_DEVICE_INFO pVBInfo )
9423 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9424 tempData = TVPhaseList[ tempbx ] ;
9426 XGINew_SetReg1( pVBInfo->Part2Port , 0x31 , ( USHORT )( tempData & 0x000000FF ) ) ;
9427 XGINew_SetReg1( pVBInfo->Part2Port , 0x32 , ( USHORT )( ( tempData & 0x0000FF00 ) >> 8 ) ) ;
9428 XGINew_SetReg1( pVBInfo->Part2Port , 0x33 , ( USHORT )( ( tempData & 0x00FF0000 ) >> 16 ) ) ;
9429 XGINew_SetReg1( pVBInfo->Part2Port , 0x34 , ( USHORT )( ( tempData & 0xFF000000 ) >> 24 ) ) ;
9433 /* --------------------------------------------------------------------- */
9434 /* Function : XGI_SetYFilter */
9438 /* --------------------------------------------------------------------- */
9439 void XGI_SetYFilter( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9449 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9455 filterPtr = NTSCYFilter1 ;
9459 filterPtr = PALYFilter1 ;
9465 filterPtr = PALMYFilter1 ;
9469 filterPtr = PALNYFilter1 ;
9474 filterPtr = NTSCYFilter2 ;
9478 filterPtr = PALMYFilter2 ;
9482 filterPtr = PALNYFilter2 ;
9486 filterPtr = PALYFilter2 ;
9493 if ( ModeNo <= 0x13 )
9494 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9496 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9503 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9505 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9506 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9507 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9508 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9512 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9513 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9514 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9515 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9518 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9520 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9521 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9522 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9527 /* --------------------------------------------------------------------- */
9528 /* Function : XGI_GetTVPtrIndex2 */
9530 /* Output : bx 0 : NTSC */
9534 /* 4 : NTSC1024x768 */
9535 /* 5 : PAL-M 1024x768 */
9537 /* cl 0 : YFilter1 */
9540 /* 1 : 301B/302B/301LV/302LV */
9542 /* --------------------------------------------------------------------- */
9543 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo)
9549 if ( pVBInfo->TVInfo & SetPALTV )
9552 if ( pVBInfo->TVInfo & SetPALMTV )
9555 if ( pVBInfo->TVInfo & SetPALNTV )
9558 if ( pVBInfo->TVInfo & NTSC1024x768 )
9561 if ( pVBInfo->TVInfo & SetPALMTV )
9565 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9567 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9574 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9579 /* --------------------------------------------------------------------- */
9580 /* Function : XGI_SetCRT2ModeRegs */
9583 /* Description : Origin code for crt2group */
9584 /* --------------------------------------------------------------------- */
9585 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
9592 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9594 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9596 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9597 tempah &= ~0x10 ; /* BTRAMDAC */
9598 tempah |= 0x40 ; /* BTRAM */
9600 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9602 tempah=0x40; /* BTDRAM */
9603 if ( ModeNo > 0x13 )
9605 tempcl = pVBInfo->ModeType ;
9609 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9615 if ( pVBInfo->VBInfo & SetInSlaveMode )
9616 tempah ^= 0x50 ; /* BTDAC */
9621 if ( pVBInfo->VBInfo & DisableCRT2Display )
9626 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9627 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9629 tempcl = pVBInfo->ModeType ;
9630 if ( ModeNo > 0x13 )
9633 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
9635 tempah=(0x008>>tempcl) ;
9646 if ( pVBInfo->VBInfo & SetInSlaveMode )
9648 tempah = ( tempah ^ 0x050 ) ;
9653 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9657 if ( pVBInfo->VBInfo & DisableCRT2Display )
9658 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9664 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9666 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
9670 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9674 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9680 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9685 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
9688 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9690 tempah = tempah ^ 0x05 ;
9691 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
9692 tempah = tempah ^ 0x01 ;
9695 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9697 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9700 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9704 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9707 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9709 tempah &= ( ~0x08 ) ;
9710 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
9716 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9718 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
9721 if ( ModeNo > 0x13 )
9723 if ( pVBInfo->VBInfo & DriverMode )
9724 tempah = tempah ^ 0x20 ;
9729 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
9732 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9735 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9737 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
9739 if ( pVBInfo->TVInfo & RPLLDIV2XO )
9744 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
9747 if ( pVBInfo->LCDResInfo == Panel1280x960 )
9750 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
9753 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9758 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9761 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9762 tempah |= 0x04 ; /* shampoo 0129 */
9765 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
9768 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9770 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9774 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
9778 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9780 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9783 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
9788 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9791 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9795 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
9797 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9799 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9801 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
9802 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
9808 /* --------------------------------------------------------------------- */
9809 /* Function : XGI_CloseCRTC */
9813 /* --------------------------------------------------------------------- */
9814 void XGI_CloseCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9820 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9827 /* --------------------------------------------------------------------- */
9828 /* Function : XGI_OpenCRTC */
9832 /* --------------------------------------------------------------------- */
9833 void XGI_OpenCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9843 /* --------------------------------------------------------------------- */
9844 /* Function : XGI_GetRAMDAC2DATA */
9848 /* --------------------------------------------------------------------- */
9849 void XGI_GetRAMDAC2DATA(USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
9860 pVBInfo->RVBHCMAX = 1 ;
9861 pVBInfo->RVBHCFACT = 1 ;
9863 if ( ModeNo <= 0x13 )
9865 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9866 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
9867 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
9868 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
9869 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
9873 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9874 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
9875 CRT1Index &= IndexMask ;
9876 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 0 ] ;
9877 temp2 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] ;
9878 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
9879 tempbx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 8 ] ;
9880 tempcx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] << 8 ;
9882 tempcx = tempcx << 2 ;
9884 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
9894 if ( modeflag & Charx8Dot )
9899 pVBInfo->VGAHT = tempax ;
9900 pVBInfo->HT = tempax ;
9902 pVBInfo->VGAVT = tempbx ;
9903 pVBInfo->VT = tempbx ;
9908 /* --------------------------------------------------------------------- */
9909 /* Function : XGI_GetColorDepth */
9913 /* --------------------------------------------------------------------- */
9914 USHORT XGI_GetColorDepth(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9916 USHORT ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
9920 if ( ModeNo <= 0x13 )
9922 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9926 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9929 index=(modeflag&ModeInfoFlag)-ModeEGA;
9934 return( ColorDepth[ index ] ) ;
9939 /* --------------------------------------------------------------------- */
9940 /* Function : XGI_UnLockCRT2 */
9944 /* --------------------------------------------------------------------- */
9945 void XGI_UnLockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9948 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
9953 /* --------------------------------------------------------------------- */
9954 /* Function : XGI_LockCRT2 */
9958 /* --------------------------------------------------------------------- */
9959 void XGI_LockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9962 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
9968 /* --------------------------------------------------------------------- */
9969 /* Function : XGINew_EnableCRT2 */
9973 /* --------------------------------------------------------------------- */
9974 void XGINew_EnableCRT2( PVB_DEVICE_INFO pVBInfo)
9976 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
9981 /* --------------------------------------------------------------------- */
9986 /* --------------------------------------------------------------------- */
9987 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo)
9996 //printk("XGINew_LCD_Wait_Time");
9998 for( i = 0 ; i < DelayTime ; i++ )
10000 for( j = 0 ; j < 66 ; j++ )
10003 temp = XGINew_GetReg3( 0x61 ) ;
10005 //temp &= 0x10000000;
10007 if ( temp == flag )
10018 /* --------------------------------------------------------------------- */
10019 /* Function : XGI_BridgeIsOn */
10022 /* Description : */
10023 /* --------------------------------------------------------------------- */
10024 BOOLEAN XGI_BridgeIsOn( PVB_DEVICE_INFO pVBInfo )
10028 if ( pVBInfo->IF_DEF_LVDS == 1 )
10034 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10035 if ( ( flag == 1 ) || ( flag == 2 ) )
10036 return( 1 ) ; /* 301b */
10044 /* --------------------------------------------------------------------- */
10045 /* Function : XGI_LongWait */
10048 /* Description : */
10049 /* --------------------------------------------------------------------- */
10050 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo)
10054 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10056 if ( !( i & 0xC0 ) )
10058 for( i = 0 ; i < 0xFFFF ; i++ )
10060 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10064 for( i = 0 ; i < 0xFFFF ; i++ )
10066 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10073 /* --------------------------------------------------------------------- */
10074 /* Function : XGI_VBLongWait */
10077 /* Description : */
10078 /* --------------------------------------------------------------------- */
10079 void XGI_VBLongWait( PVB_DEVICE_INFO pVBInfo )
10086 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10089 for( i = 0 ; i < 3 ; i++ )
10091 for( j = 0 ; j < 100 ; j++ )
10093 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10095 { /* VBWaitMode2 */
10096 if ( ( tempal & 0x08 ) )
10101 if ( !( tempal & 0x08 ) )
10107 { /* VBWaitMode1 */
10108 if ( !( tempal & 0x08 ) )
10113 if ( ( tempal & 0x08 ) )
10119 temp = temp ^ 0x01 ;
10124 XGI_LongWait(pVBInfo) ;
10132 /* --------------------------------------------------------------------- */
10133 /* Function : XGI_GetVGAHT2 */
10136 /* Description : */
10137 /* --------------------------------------------------------------------- */
10138 USHORT XGI_GetVGAHT2( PVB_DEVICE_INFO pVBInfo )
10143 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10144 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10145 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10147 return( ( USHORT )tempax ) ;
10151 /* --------------------------------------------------------------------- */
10152 /* Function : XGI_GetVCLK2Ptr */
10155 /* Description : */
10156 /* --------------------------------------------------------------------- */
10157 USHORT XGI_GetVCLK2Ptr( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
10161 USHORT LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10162 USHORT LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10163 USHORT LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10164 USHORT LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10165 USHORT LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10167 USHORT CRT2Index , VCLKIndex ;
10168 USHORT modeflag , resinfo ;
10169 UCHAR *CHTVVCLKPtr = NULL ;
10171 if ( ModeNo <= 0x13 )
10173 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10174 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10175 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10179 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10180 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10181 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10184 if ( pVBInfo->IF_DEF_LVDS == 0 )
10186 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10187 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10189 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10191 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10195 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10200 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10202 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10204 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10206 VCLKIndex = HiTVVCLKDIV2 ;
10214 VCLKIndex = HiTVVCLK ;
10221 if ( pVBInfo->SetFlag & TVSimuMode )
10223 if( modeflag & Charx8Dot )
10225 VCLKIndex = HiTVSimuVCLK ;
10233 VCLKIndex = HiTVTextVCLK ;
10241 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10243 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10245 VCLKIndex = YPbPr750pVCLK ;
10246 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10248 VCLKIndex = YPbPr525pVCLK ;
10249 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10251 VCLKIndex = YPbPr525iVCLK_2 ;
10252 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10253 VCLKIndex = YPbPr525iVCLK ;
10261 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10263 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10265 VCLKIndex = TVVCLKDIV2 ;
10273 VCLKIndex = TVVCLK ;
10284 VCLKIndex = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ; /* Port 3cch */
10285 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10286 if ( ModeNo > 0x13 )
10288 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10289 VCLKIndex &= IndexMask ;
10296 if ( ModeNo <= 0x13 )
10297 VCLKIndex = CRT2Index ;
10299 VCLKIndex = CRT2Index ;
10301 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10303 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10305 VCLKIndex &= 0x1f ;
10308 if ( pVBInfo->VBInfo & SetPALTV )
10311 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10317 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10320 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10323 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10326 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10332 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10337 VCLKIndex = VCLKIndex >> 6 ;
10338 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10339 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10340 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10341 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10343 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10346 /* VCLKIndex = VCLKIndex&IndexMask ; */
10350 return( VCLKIndex ) ;