3 #include <linux/types.h>
4 #include <linux/version.h>
10 #include "vb_struct.h"
16 #define IndexMask 0xff
17 #ifndef XGI_MASK_DUAL_CHIP
18 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
23 BOOLEAN XGI_IsLCDDualLink(PVB_DEVICE_INFO pVBInfo);
24 BOOLEAN XGI_SetCRT2Group301(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
25 BOOLEAN XGI_BacklightByDrv(PVB_DEVICE_INFO pVBInfo);
27 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo);
28 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo);
29 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo);
30 BOOLEAN XGI_AjustCRT2Rate(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,USHORT *i, PVB_DEVICE_INFO pVBInfo);
31 BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
32 BOOLEAN XGI_GetLCDInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
33 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo ) ;
34 BOOLEAN XGI_BridgeIsOn(PVB_DEVICE_INFO pVBInfo);
35 UCHAR XGI_GetModePtr( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
36 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
37 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
38 USHORT XGI_GetResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
39 USHORT XGI_GetColorDepth(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
40 USHORT XGI_GetVGAHT2(PVB_DEVICE_INFO pVBInfo);
41 USHORT XGI_GetVCLK2Ptr(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
42 void XGI_VBLongWait(PVB_DEVICE_INFO pVBInfo);
43 void XGI_SaveCRT2Info(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo);
44 void XGI_GetCRT2Data(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
45 void XGI_GetCRT2ResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
46 void XGI_PreSetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
47 void XGI_SetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
48 void XGI_SetLockRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
49 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
50 void XGI_SetGroup2(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
51 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
52 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
53 void XGI_SetGroup5(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
54 void* XGI_GetLcdPtr(USHORT BX, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
55 void* XGI_GetTVPtr(USHORT BX, USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
56 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo);
57 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
58 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
59 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
60 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
61 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo);
62 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo);
63 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo);
64 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo);
66 void XGI_DisplayOn(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
67 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
68 void XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
69 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
70 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
71 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
72 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
73 void XGI_UpdateXG21CRTC(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo, USHORT RefreshRateTableIndex);
74 void XGI_WaitDisply(PVB_DEVICE_INFO pVBInfo);
75 void XGI_SenseCRT1(PVB_DEVICE_INFO pVBInfo);
76 void XGI_SetSeqRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
77 void XGI_SetMiscRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
78 void XGI_SetCRTCRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
79 void XGI_SetATTRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
80 void XGI_SetGRCRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
81 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo);
83 void XGI_SetSync(USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
84 void XGI_SetCRT1CRTC(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
85 void XGI_SetCRT1Timing_H(PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
86 void XGI_SetCRT1Timing_V(USHORT ModeIdIndex,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);
87 void XGI_SetCRT1DE(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
88 void XGI_SetCRT1VCLK(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
89 void XGI_SetCRT1FIFO(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
90 void XGI_SetCRT1ModeRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
91 void XGI_SetVCLKState(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
93 void XGI_LoadDAC(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
94 void XGI_WriteDAC(USHORT dl, USHORT ah, USHORT al, USHORT dh, PVB_DEVICE_INFO pVBInfo);
95 /*void XGI_ClearBuffer(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);*/
96 void XGI_SetLCDAGroup(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
97 void XGI_GetLVDSResInfo( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
98 void XGI_GetLVDSData(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
99 void XGI_ModCRT1Regs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
100 void XGI_SetLVDSRegs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
101 void XGI_UpdateModeInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
102 void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
103 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo);
104 void XGI_GetVBInfo(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
105 void XGI_GetTVInfo(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
106 void XGI_SetCRT2ECLK( USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
107 void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
108 void XGI_GetLCDSync(USHORT* HSyncWidth, USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo);
109 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
110 void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
111 void XGI_SetCRT2VCLK(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
112 void XGI_OEM310Setting(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
113 void XGI_SetDelayComp(PVB_DEVICE_INFO pVBInfo);
114 void XGI_SetLCDCap(PVB_DEVICE_INFO pVBInfo);
115 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
116 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
117 void SetSpectrum(PVB_DEVICE_INFO pVBInfo);
118 void XGI_SetAntiFlicker(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
119 void XGI_SetEdgeEnhance(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
120 void XGI_SetPhaseIncr(PVB_DEVICE_INFO pVBInfo);
121 void XGI_SetYFilter(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
122 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo);
123 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo );
124 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
125 void XGI_CloseCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
126 void XGI_OpenCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
127 void XGI_GetRAMDAC2DATA(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
128 void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
129 void XGI_LockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
130 void XGINew_EnableCRT2(PVB_DEVICE_INFO pVBInfo);
131 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo);
132 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo);
133 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo );
134 void XGI_GetLCDVCLKPtr(UCHAR* di_0,UCHAR *di_1, PVB_DEVICE_INFO pVBInfo);
135 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
136 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo);
137 USHORT XGI_GetLCDCapPtr(PVB_DEVICE_INFO pVBInfo);
138 USHORT XGI_GetLCDCapPtr1(PVB_DEVICE_INFO pVBInfo);
139 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo);
140 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
141 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
142 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo);
143 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo);
144 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
145 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
146 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
147 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
148 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
149 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
150 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo );
152 extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
154 /* USHORT XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
160 USHORT XGINew_MDA_DAC[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
161 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
162 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
163 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
164 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
165 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
166 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
167 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F};
169 USHORT XGINew_CGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
170 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
171 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
172 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
173 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
174 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
175 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
176 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
178 USHORT XGINew_EGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15,
179 0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35,
180 0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D,
181 0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D,
182 0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17,
183 0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37,
184 0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F,
185 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
187 USHORT XGINew_VGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
188 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
189 0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18,
190 0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F,
192 0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F,
193 0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00,
194 0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18,
195 0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04,
196 0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10,
197 0x0B,0x0C,0x0D,0x0F,0x10};
200 /* --------------------------------------------------------------------- */
201 /* Function : InitTo330Pointer */
205 /* --------------------------------------------------------------------- */
206 void InitTo330Pointer( UCHAR ChipType ,PVB_DEVICE_INFO pVBInfo)
208 pVBInfo->SModeIDTable = (XGI_StStruct *) XGI330_SModeIDTable ;
209 pVBInfo->StandTable = (XGI_StandTableStruct *) XGI330_StandTable ;
210 pVBInfo->EModeIDTable = (XGI_ExtStruct *) XGI330_EModeIDTable ;
211 pVBInfo->RefIndex = (XGI_Ext2Struct *) XGI330_RefIndex ;
212 pVBInfo->XGINEWUB_CRT1Table = (XGI_CRT1TableStruct *) XGI_CRT1Table ;
214 /* add for new UNIVGABIOS */
215 /* XGINew_UBLCDDataTable = (XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
216 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
219 if ( ChipType >= XG40 )
221 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI340New_MCLKData ;
222 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI340_ECLKData ;
226 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI330New_MCLKData ;
227 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI330_ECLKData ;
230 pVBInfo->VCLKData = (XGI_VCLKDataStruct *) XGI_VCLKData ;
231 pVBInfo->VBVCLKData = (XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
232 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
233 pVBInfo->StResInfo = (XGI_StResInfoStruct *) XGI330_StResInfo ;
234 pVBInfo->ModeResInfo = (XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
236 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
237 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
238 pVBInfo->pSR07 = &XGI330_SR07 ;
239 pVBInfo->LCDResInfo = 0 ;
240 pVBInfo->LCDTypeInfo = 0 ;
241 pVBInfo->LCDInfo = 0 ;
242 pVBInfo->VBInfo = 0 ;
246 pVBInfo->SR15 = XGI340_SR13 ;
247 pVBInfo->CR40 = XGI340_cr41 ;
248 pVBInfo->SR25 = XGI330_sr25 ;
249 pVBInfo->pSR31 = &XGI330_sr31 ;
250 pVBInfo->pSR32 = &XGI330_sr32 ;
251 pVBInfo->CR6B = XGI340_CR6B ;
252 pVBInfo->CR6E = XGI340_CR6E ;
253 pVBInfo->CR6F = XGI340_CR6F ;
254 pVBInfo->CR89 = XGI340_CR89 ;
255 pVBInfo->AGPReg = XGI340_AGPReg ;
256 pVBInfo->SR16 = XGI340_SR16 ;
257 pVBInfo->pCRCF = &XG40_CRCF ;
258 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
261 pVBInfo->CR49 = XGI330_CR49 ;
262 pVBInfo->pSR1F = &XGI330_SR1F ;
263 pVBInfo->pSR21 = &XGI330_SR21 ;
264 pVBInfo->pSR22 = &XGI330_SR22 ;
265 pVBInfo->pSR23 = &XGI330_SR23 ;
266 pVBInfo->pSR24 = &XGI330_SR24 ;
267 pVBInfo->pSR33 = &XGI330_SR33 ;
271 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
272 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
273 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
274 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
275 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
276 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
277 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
278 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
279 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
280 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
282 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
283 pVBInfo->PALTiming = XGI330_PALTiming ;
284 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
285 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
286 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
287 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
288 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
289 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
290 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
291 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
292 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
293 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
294 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
295 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
298 pVBInfo->TimingH = (XGI_TimingHStruct *) XGI_TimingH ;
299 pVBInfo->TimingV = (XGI_TimingVStruct *) XGI_TimingV ;
300 pVBInfo->UpdateCRT1 = (XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
302 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
303 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
304 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
305 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
307 /* 310 customization related */
308 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
309 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
311 pVBInfo->LCDCapList = XGI_LCDCapList ;
313 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
314 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
316 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
317 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
320 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
322 if ( ChipType >= XG20 )
323 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
325 if ( ChipType == XG27 )
327 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI27New_MCLKData ;
328 pVBInfo->CR40 = XGI27_cr41 ;
329 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
330 pVBInfo->pSR36 = &XG27_SR36 ;
331 pVBInfo->pCR8F = &XG27_CR8F ;
332 pVBInfo->pCRD0 = XG27_CRD0 ;
333 pVBInfo->pCRDE = XG27_CRDE ;
334 pVBInfo->pSR40 = &XG27_SR40 ;
335 pVBInfo->pSR41 = &XG27_SR41 ;
339 if ( ChipType >= XG20 )
341 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
342 pVBInfo->pCR2E = &XG21_CR2E ;
343 pVBInfo->pCR2F = &XG21_CR2F ;
344 pVBInfo->pCR46 = &XG21_CR46 ;
345 pVBInfo->pCR47 = &XG21_CR47 ;
355 /* --------------------------------------------------------------------- */
356 /* Function : XGISetModeNew */
360 /* --------------------------------------------------------------------- */
361 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo )
364 /* PUCHAR pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
365 VB_DEVICE_INFO VBINF;
366 PVB_DEVICE_INFO pVBInfo = &VBINF;
367 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
368 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
369 pVBInfo->IF_DEF_LVDS = 0 ;
370 pVBInfo->IF_DEF_CH7005 = 0 ;
371 pVBInfo->IF_DEF_LCDA = 1 ;
372 pVBInfo->IF_DEF_CH7017 = 0 ;
373 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
374 pVBInfo->IF_DEF_VideoCapture = 0 ;
375 pVBInfo->IF_DEF_ScaleLCD = 0 ;
376 pVBInfo->IF_DEF_OEMUtil = 0 ;
377 pVBInfo->IF_DEF_PWD = 0 ;
380 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
382 pVBInfo->IF_DEF_YPbPr = 0 ;
383 pVBInfo->IF_DEF_HiVision = 0 ;
384 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
385 pVBInfo->VBType = 0 ; /*set VBType default 0*/
387 else if ( HwDeviceExtension->jChipType >= XG40 )
389 pVBInfo->IF_DEF_YPbPr = 1 ;
390 pVBInfo->IF_DEF_HiVision = 1 ;
391 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
395 pVBInfo->IF_DEF_YPbPr = 1 ;
396 pVBInfo->IF_DEF_HiVision = 1 ;
397 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
400 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
401 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
402 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
403 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
404 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
405 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
406 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
407 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
408 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
409 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
410 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
411 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
412 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
413 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
414 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
415 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
416 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
417 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
419 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
421 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
423 pVBInfo->IF_DEF_LVDS = 1 ;
426 if ( HwDeviceExtension->jChipType == XG27 )
428 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
430 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
432 pVBInfo->IF_DEF_LVDS = 1 ;
437 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
438 XGI_GetVBType( pVBInfo ) ;
440 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
443 ModeNo = ModeNo & 0x7F ;
444 /* XGINew_flag_clearbuffer = 0 ; */
448 XGINew_flag_clearbuffer = 1 ;
451 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
453 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
454 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
456 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
458 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
460 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
462 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
463 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
464 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
465 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
466 /* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
468 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
470 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
472 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
474 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
479 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
481 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
482 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
484 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
489 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
491 switch( HwDeviceExtension->ujVBChipID )
494 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
498 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
506 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
507 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
508 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
509 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
513 if (pVBInfo->IF_DEF_LVDS == 1)
514 if (!XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo))
517 if ( ModeNo <= 0x13 )
519 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
523 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
526 pVBInfo->SetFlag = 0 ;
527 if ( pVBInfo->IF_DEF_CH7007 != 1 )
529 pVBInfo->VBInfo = DisableCRT2Display ;
533 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
535 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
537 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
539 if( HwDeviceExtension->jChipType == XG21 )
540 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
546 if ( ModeNo <= 0x13 )
548 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
552 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
554 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
555 pVBInfo->SetFlag = 0x00 ;
556 pVBInfo->VBInfo = DisableCRT2Display ;
557 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
562 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
563 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
564 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
567 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
569 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
571 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
578 /* --------------------------------------------------------------------- */
579 /* Function : XGI_SetCRT1Group */
583 /* --------------------------------------------------------------------- */
584 void XGI_SetCRT1Group( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
586 USHORT StandTableIndex ,
587 RefreshRateTableIndex ,
591 USHORT XGINew_P3cc = pVBInfo->P3cc;
593 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
594 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
595 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
596 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
597 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
598 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
599 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
600 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
601 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
602 XGI_ClearExt1Regs(pVBInfo) ;
604 /* if ( pVBInfo->IF_DEF_ExpLink ) */
605 if ( HwDeviceExtension->jChipType == XG27 )
607 if ( pVBInfo->IF_DEF_LVDS == 0 )
609 XGI_SetDefaultVCLK( pVBInfo ) ;
613 temp = ~ProgrammingCRT2 ;
614 pVBInfo->SetFlag &= temp ;
615 pVBInfo->SelectCRT2Rate = 0 ;
617 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
619 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
621 pVBInfo->SetFlag |= ProgrammingCRT2 ;
625 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
626 if ( RefreshRateTableIndex != 0xFFFF )
628 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
629 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
630 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
631 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
632 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
635 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
636 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
638 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
640 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
641 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
642 b3CC =(UCHAR) XGINew_GetReg2(XGINew_P3cc) ;
643 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
645 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
647 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
648 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
649 b3CC = (UCHAR)XGINew_GetReg2(XGINew_P3cc) ;
650 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
654 if ( HwDeviceExtension->jChipType >= XG21 )
656 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
660 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
661 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
662 /* XG21 CRT1 Timing */
663 if ( HwDeviceExtension->jChipType == XG27 )
664 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
666 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
668 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
670 if ( HwDeviceExtension->jChipType == XG27 )
671 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
673 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
675 if ( pVBInfo->IF_DEF_LVDS == 1 )
677 if ( HwDeviceExtension->jChipType == XG27 )
678 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
680 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
682 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
686 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
687 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
688 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
691 /* XGI_LoadCharacter(); //dif ifdef TVFont */
693 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
694 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
698 /* --------------------------------------------------------------------- */
699 /* Function : XGI_GetModePtr */
703 /* --------------------------------------------------------------------- */
704 UCHAR XGI_GetModePtr( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
708 if ( ModeNo <= 0x13 )
709 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
712 if ( pVBInfo->ModeType <= 0x02 )
713 index = 0x1B ; /* 02 -> ModeEGA */
717 return( index ) ; /* Get pVBInfo->StandTable index */
721 /* --------------------------------------------------------------------- */
722 /* Function : XGI_SetBIOSData */
726 /* --------------------------------------------------------------------- */
727 /*UCHAR XGI_SetBIOSData( USHORT ModeNo , USHORT ModeIdIndex )
733 /* --------------------------------------------------------------------- */
734 /* Function : XGI_ClearBankRegs */
738 /* --------------------------------------------------------------------- */
739 /*UCHAR XGI_ClearBankRegs( USHORT ModeNo , USHORT ModeIdIndex )
745 /* --------------------------------------------------------------------- */
746 /* Function : XGI_SetSeqRegs */
750 /* --------------------------------------------------------------------- */
751 void XGI_SetSeqRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
759 if ( ModeNo <= 0x13 )
760 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
762 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
764 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
765 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
768 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
774 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
776 if ( pVBInfo->VBInfo & SetInSlaveMode )
781 tempah |= 0x20 ; /* screen off */
782 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
784 for( i = 02 ; i <= 04 ; i++ )
786 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
787 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
792 /* --------------------------------------------------------------------- */
793 /* Function : XGI_SetMiscRegs */
797 /* --------------------------------------------------------------------- */
798 void XGI_SetMiscRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
802 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
804 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
806 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
813 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
817 /* --------------------------------------------------------------------- */
818 /* Function : XGI_SetCRTCRegs */
822 /* --------------------------------------------------------------------- */
823 void XGI_SetCRTCRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
828 CRTCdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
830 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
832 for( i = 0 ; i <= 0x18 ; i++ )
834 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
835 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
838 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
840 if ( pVBInfo->VBInfo & SetInSlaveMode )
842 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
844 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
852 /* --------------------------------------------------------------------- */
857 /* --------------------------------------------------------------------- */
858 void XGI_SetATTRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
864 if ( ModeNo <= 0x13 )
865 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
867 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
869 for( i = 0 ; i <= 0x13 ; i++ )
871 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
872 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
876 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
880 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
882 if ( pVBInfo->VBInfo & SetInSlaveMode )
889 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
890 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
891 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
894 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
895 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
896 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
897 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
898 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
902 /* --------------------------------------------------------------------- */
903 /* Function : XGI_SetGRCRegs */
907 /* --------------------------------------------------------------------- */
908 void XGI_SetGRCRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
913 for( i = 0 ; i <= 0x08 ; i++ )
915 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
916 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
919 if ( pVBInfo->ModeType > ModeVGA )
921 GRdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3ce , 0x05 ) ;
922 GRdata &= 0xBF ; /* 256 color disable */
923 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
928 /* --------------------------------------------------------------------- */
929 /* Function : XGI_ClearExt1Regs */
933 /* --------------------------------------------------------------------- */
934 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo)
938 for( i = 0x0A ; i <= 0x0E ; i++ )
939 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
943 /* --------------------------------------------------------------------- */
944 /* Function : XGI_SetDefaultVCLK */
948 /* --------------------------------------------------------------------- */
949 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo )
952 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
953 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
954 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
956 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
957 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
958 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
960 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
965 /* --------------------------------------------------------------------- */
966 /* Function : XGI_GetRatePtrCRT2 */
970 /* --------------------------------------------------------------------- */
971 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
973 SHORT LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
974 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
976 USHORT RefreshRateTableIndex , i ,
977 modeflag , index , temp ;
979 if ( ModeNo <= 0x13 )
981 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
985 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
988 if ( pVBInfo->IF_DEF_CH7005 == 1 )
990 if ( pVBInfo->VBInfo & SetCRT2ToTV )
992 if ( modeflag & HalfDCLK )
1000 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1001 index = index >> pVBInfo->SelectCRT2Rate ;
1004 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1010 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1012 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1014 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1020 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1022 if( pVBInfo->IF_DEF_LVDS == 0 )
1024 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1025 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1027 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1041 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1042 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1043 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1046 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1051 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1052 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1056 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1057 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1058 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1062 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1063 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1072 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1074 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1075 temp &= ModeInfoFlag ;
1076 if ( temp < pVBInfo->ModeType )
1081 } while( index != 0xFFFF ) ;
1082 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1084 if ( pVBInfo->VBInfo & SetInSlaveMode )
1086 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1087 if ( temp & InterlaceMode )
1094 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1096 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1098 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1102 /* --------------------------------------------------------------------- */
1103 /* Function : XGI_AjustCRT2Rate */
1107 /* --------------------------------------------------------------------- */
1108 BOOLEAN XGI_AjustCRT2Rate( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , USHORT *i, PVB_DEVICE_INFO pVBInfo )
1116 if ( ModeNo <= 0x13 )
1118 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1122 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1125 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1126 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1129 if ( pVBInfo->IF_DEF_LVDS == 0 )
1131 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1133 tempax |= SupportRAMDAC2 ;
1135 if ( pVBInfo->VBType & VB_XGI301C )
1136 tempax |= SupportCRT2in301C ;
1139 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1141 tempax |= SupportLCD ;
1143 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1145 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1147 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1159 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1161 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1163 tempax |= SupportYPbPr ;
1164 if ( pVBInfo->VBInfo & SetInSlaveMode )
1178 tempax |= SupportHiVisionTV ;
1179 if ( pVBInfo->VBInfo & SetInSlaveMode )
1186 if ( pVBInfo->SetFlag & TVSimuMode )
1197 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1199 tempax |= SupportTV ;
1201 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1203 tempax |= SupportTV1024 ;
1206 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1208 if ( modeflag & NoSupportSimuTV )
1210 if ( pVBInfo->VBInfo & SetInSlaveMode )
1212 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1224 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1226 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1228 tempax |= SupportCHTV ;
1232 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1234 tempax |= SupportLCD ;
1236 if ( resinfo > 0x08 )
1237 return( 0 ) ; /* 1024x768 */
1239 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1241 if ( resinfo > 0x07 )
1242 return( 0 ) ; /* 800x600 */
1244 if ( resinfo == 0x04 )
1245 return( 0 ) ; /* 512x384 */
1250 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1252 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1253 if ( infoflag & tempax )
1261 for( ( *i ) = 0 ; ; ( *i )++ )
1263 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1264 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1269 if ( infoflag & tempax )
1278 /* --------------------------------------------------------------------- */
1279 /* Function : XGI_SetSync */
1283 /* --------------------------------------------------------------------- */
1284 void XGI_SetSync(USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1289 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1293 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1297 /* --------------------------------------------------------------------- */
1298 /* Function : XGI_SetCRT1CRTC */
1302 /* --------------------------------------------------------------------- */
1303 void XGI_SetCRT1CRTC( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1310 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1311 index = index&IndexMask ;
1313 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1315 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1317 for( i = 0 ; i < 8 ; i++ )
1318 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1320 for( i = 0 ; i < 7 ; i++ )
1321 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1323 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1327 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1330 if( pVBInfo->ModeType > 0x03 )
1331 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1335 /* --------------------------------------------------------------------- */
1336 /* Function : XGI_SetCRT1Timing_H */
1340 /* --------------------------------------------------------------------- */
1341 void XGI_SetCRT1Timing_H( PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1343 UCHAR data , data1, pushax;
1346 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1347 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1348 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1350 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ; /* unlock cr0-7 */
1352 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1354 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1355 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1357 for( i = 0x01 ; i <= 0x04 ; i++ )
1359 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
1360 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 1 ) , data ) ;
1363 for( i = 0x05 ; i <= 0x06 ; i++ )
1365 data = pVBInfo->TimingH[ 0 ].data[ i ];
1366 XGINew_SetReg1( pVBInfo->P3c4 ,( USHORT )( i + 6 ) , data ) ;
1369 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1371 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1374 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1376 if ( HwDeviceExtension->jChipType >= XG20 )
1378 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x04 ) ;
1380 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1381 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x05 ) ;
1388 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0c ) ;
1390 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1395 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1396 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1402 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1407 /* --------------------------------------------------------------------- */
1408 /* Function : XGI_SetCRT1Timing_V */
1412 /* --------------------------------------------------------------------- */
1413 void XGI_SetCRT1Timing_V( USHORT ModeIdIndex , USHORT ModeNo,PVB_DEVICE_INFO pVBInfo )
1418 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1419 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1420 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1422 for( i = 0x00 ; i <= 0x01 ; i++ )
1424 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1425 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 6 ) , data ) ;
1428 for( i = 0x02 ; i <= 0x03 ; i++ )
1430 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1431 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x0e ) , data ) ;
1434 for( i = 0x04 ; i <= 0x05 ; i++ )
1436 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1437 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x11 ) , data ) ;
1440 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0a ) ;
1442 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1445 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1447 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1451 if ( ModeNo <= 0x13 )
1452 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1454 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1456 i &= DoubleScanMode ;
1460 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x09 ) ;
1463 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1467 /* --------------------------------------------------------------------- */
1468 /* Function : XGI_SetXG21CRTC */
1469 /* Input : Stand or enhance CRTC table */
1470 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1471 /* Description : Set LCD timing */
1472 /* --------------------------------------------------------------------- */
1473 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1475 UCHAR StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1476 USHORT Temp1, Temp2, Temp3 ;
1478 if ( ModeNo <= 0x13 )
1480 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1481 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1482 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1483 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1484 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1486 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1487 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1488 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1489 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1490 Tempdx <<= 2 ; /* Tempdx << 2 */
1491 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1492 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1494 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1495 Tempbx = Tempax ; /* Tempbx=Tempax */
1496 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1497 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1498 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1499 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1500 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1501 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1502 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1503 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1505 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] UCHAR -> USHORT */
1506 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1507 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1508 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1509 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1511 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1512 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1513 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1514 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1515 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1516 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1517 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1518 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1519 Tempax = (UCHAR)Temp2 ; /* Tempax[7:0]: VRE[7:0] */
1520 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1521 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1522 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1523 Tempbx = (UCHAR)Temp1 ; /* Tempbx[1:0]: VRS[10:9] */
1524 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1526 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1530 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1531 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1532 Tempcx = Tempax ; /* Tempcx: HRS */
1533 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1535 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1536 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1537 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1538 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1539 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1541 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1542 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1544 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1545 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1546 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1547 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1549 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1550 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1552 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1553 if( Tempax < Tempcx ) /* HRE < HRS */
1554 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1557 Tempax = (UCHAR)Temp2 ; /* Tempax: HRE[7:0] */
1558 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1559 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1560 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1561 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1562 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1564 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1565 Tempbx = Tempax ; /* Tempbx: VRS */
1566 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1567 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1568 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1569 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1570 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1571 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1572 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1573 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1575 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1576 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1577 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1579 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1580 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1581 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1582 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1584 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1585 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1587 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1588 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1589 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1590 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1591 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1592 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1593 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1594 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1596 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1597 if ( Tempax < Temp3 ) /* VRE < VRS */
1598 Temp2 |= 0x20 ; /* VRE + 0x20 */
1601 Tempax = (UCHAR)Temp2 ; /* Tempax: VRE[7:0] */
1602 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1603 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1604 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1605 Tempbx = (UCHAR)Temp1 ;
1606 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1608 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1612 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1614 USHORT StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1616 if ( ModeNo <= 0x13 )
1618 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1619 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1620 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1621 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1622 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1624 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1625 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1626 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1627 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1628 Tempdx <<= 2 ; /* Tempdx << 2 */
1629 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1630 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1632 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1633 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1634 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1635 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1636 Tempbx = Tempax ; /* Tempbx=CR07 */
1637 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1639 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1640 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1641 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1644 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1645 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1646 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1647 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1648 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1649 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1650 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1651 Tempax = (UCHAR)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1652 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1653 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1654 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1655 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1659 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1660 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1661 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1662 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1664 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1665 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1666 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1668 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1669 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1670 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1672 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1673 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1674 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1675 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1677 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1678 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1680 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1681 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1682 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1683 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1685 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1686 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1687 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1688 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1689 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1690 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1692 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1693 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1695 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1696 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1697 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1698 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1699 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1700 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1701 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1702 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1703 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1704 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1705 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1708 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1709 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1710 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1711 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1712 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1713 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1714 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1715 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1716 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1718 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1719 Tempbx |= 0x20 ; /* VRE + 0x20 */
1721 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1722 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1723 Tempax = Tempcx >> 8;
1724 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1729 /* --------------------------------------------------------------------- */
1730 /* Function : XGI_SetXG21LCD */
1732 /* Output : FCLK duty cycle, FCLK delay compensation */
1733 /* Description : All values set zero */
1734 /* --------------------------------------------------------------------- */
1735 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1737 USHORT Data , Temp , b3CC ;
1740 XGI_P3cc = pVBInfo->P3cc ;
1742 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1743 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1744 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1745 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1746 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1748 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1749 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1750 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1751 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1754 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1758 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1759 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1762 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1764 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1765 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1767 if ( ModeNo <= 0x13 )
1769 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1771 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1773 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1777 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1778 if ( Data & 0x4000 )
1779 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1780 if ( Data & 0x8000 )
1781 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1785 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1787 USHORT Data , Temp , b3CC ;
1790 XGI_P3cc = pVBInfo->P3cc ;
1792 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1793 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1794 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1795 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1797 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1798 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1800 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1801 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1804 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1806 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1807 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1808 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1809 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1812 XGI_SetXG27FPBits(pVBInfo);
1814 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1816 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1817 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1819 if ( ModeNo <= 0x13 )
1821 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1823 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1825 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1829 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1830 if ( Data & 0x4000 )
1831 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1832 if ( Data & 0x8000 )
1833 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1837 /* --------------------------------------------------------------------- */
1838 /* Function : XGI_UpdateXG21CRTC */
1840 /* Output : CRT1 CRTC */
1841 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1842 /* --------------------------------------------------------------------- */
1843 void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT RefreshRateTableIndex )
1847 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1848 if ( ModeNo <= 0x13 )
1850 for( i = 0 ; i < 12 ; i++ )
1852 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1858 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1860 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1862 else if ( ModeNo == 0x2F )
1864 else if ( ModeNo == 0x50 )
1866 else if ( ModeNo == 0x59 )
1872 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1873 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1874 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1875 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1880 /* --------------------------------------------------------------------- */
1881 /* Function : XGI_SetCRT1DE */
1885 /* --------------------------------------------------------------------- */
1886 void XGI_SetCRT1DE( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo,USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1897 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1899 if ( ModeNo <= 0x13 )
1901 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1902 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1903 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1907 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1908 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1909 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1912 if ( modeflag & HalfDCLK )
1913 tempax = tempax >> 1 ;
1915 if ( ModeNo > 0x13 )
1917 if ( modeflag & HalfDCLK )
1918 tempax = tempax << 1 ;
1920 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1922 if ( temp & InterlaceMode )
1923 tempbx = tempbx >> 1 ;
1925 if ( modeflag & DoubleScanMode )
1926 tempbx = tempbx << 1 ;
1931 /* if ( !( modeflag & Charx8Dot ) ) */
1938 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1939 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1941 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
1942 XGINew_SetReg1( pVBInfo->P3d4 , 0x01 , ( USHORT )( tempcx & 0xff ) ) ;
1943 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x0b , ~0x0c , ( USHORT )( ( tempcx & 0x0ff00 ) >> 10 ) ) ;
1944 XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , ( USHORT )( tempbx & 0xff ) ) ;
1946 tempbx = tempbx >> 8 ;
1948 if ( tempbx & 0x01 )
1951 if ( tempbx & 0x02 )
1954 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
1955 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x07 ) ;
1959 if ( tempbx & 0x04 )
1962 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
1963 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
1967 /* --------------------------------------------------------------------- */
1968 /* Function : XGI_GetResInfo */
1972 /* --------------------------------------------------------------------- */
1973 USHORT XGI_GetResInfo(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
1977 if ( ModeNo <= 0x13 )
1979 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
1983 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
1985 return( resindex ) ;
1989 /* --------------------------------------------------------------------- */
1990 /* Function : XGI_SetCRT1Offset */
1994 /* --------------------------------------------------------------------- */
1995 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2005 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2007 temp = pVBInfo->ScreenOffset[ temp ] ;
2009 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2010 temp2 &= InterlaceMode ;
2015 temp2 = pVBInfo->ModeType - ModeEGA ;
2041 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2042 temp = temp * temp2 + temp2 / 2 ;
2047 DisplayUnit = temp ;
2049 temp = temp >> 8 ; /* ah */
2051 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2054 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2056 temp =( UCHAR )temp2 ;
2057 temp &= 0xFF ; /* al */
2058 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2060 /* SetDisplayUnit */
2061 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2062 temp2 &= InterlaceMode ;
2066 DisplayUnit = DisplayUnit << 5 ;
2067 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2068 al = DisplayUnit & 0x00ff ;
2074 if ( HwDeviceExtension->jChipType >= XG20 )
2075 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2078 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2082 /* --------------------------------------------------------------------- */
2083 /* Function : XGI_SetCRT1VCLK */
2087 /* --------------------------------------------------------------------- */
2088 void XGI_SetCRT1VCLK( USHORT ModeNo , USHORT ModeIdIndex ,
2089 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2091 UCHAR index , data ;
2094 if ( pVBInfo->IF_DEF_LVDS == 1 )
2096 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2097 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2098 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2099 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2100 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2101 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2103 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2105 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2106 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2107 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2108 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2109 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2110 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2111 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2112 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2116 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2117 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2118 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2119 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2120 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2121 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2124 if ( HwDeviceExtension->jChipType >= XG20 )
2126 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2128 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2129 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2130 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2137 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2143 /* --------------------------------------------------------------------- */
2144 /* Function : XGI_SetCRT1FIFO */
2148 /* --------------------------------------------------------------------- */
2149 void XGI_SetCRT1FIFO( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2153 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2155 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2157 if ( ModeNo > 0x13 )
2159 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2160 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2162 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2163 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2165 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2169 if (HwDeviceExtension->jChipType == XG27)
2171 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2172 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2174 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2178 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2179 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2181 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2185 if (HwDeviceExtension->jChipType == XG21)
2187 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2192 /* --------------------------------------------------------------------- */
2193 /* Function : XGI_SetCRT1ModeRegs */
2197 /* --------------------------------------------------------------------- */
2198 void XGI_SetCRT1ModeRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension ,
2199 USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2209 if ( ModeNo > 0x13 )
2211 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2212 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2215 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2217 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2218 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2220 if ( ModeNo > 0x13 )
2227 if ( ModeNo > 0x13 )
2229 if ( pVBInfo->ModeType > 0x02 )
2232 data3 = pVBInfo->ModeType - ModeVGA ;
2233 data3 = data3 << 2 ;
2238 data &= InterlaceMode ;
2243 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2244 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2245 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2246 if ( ModeNo <= 0x13 )
2247 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2249 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2252 if ( infoflag & InterlaceMode )
2256 else if ( xres == 1280 )
2260 data2 = data & 0x00FF ;
2261 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2262 data2 = ( data & 0xFF00 ) >> 8 ;
2263 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2265 if( modeflag & HalfDCLK )
2266 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2270 if ( modeflag & LineCompareOff )
2273 if ( ModeNo > 0x13 )
2275 if ( pVBInfo->ModeType == ModeEGA )
2279 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2281 if ( pVBInfo->ModeType != ModeText )
2283 data = data ^ 0x60 ;
2284 if ( pVBInfo->ModeType != ModeEGA )
2286 data = data ^ 0xA0 ;
2289 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2291 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2293 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2294 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2295 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2297 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2299 if (HwDeviceExtension->jChipType == XG27 )
2305 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2306 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2309 if (HwDeviceExtension->jChipType >= XG20 )
2315 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2316 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2324 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2330 /* --------------------------------------------------------------------- */
2331 /* Function : XGI_SetVCLKState */
2335 /* --------------------------------------------------------------------- */
2336 void XGI_SetVCLKState( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2344 if ( ModeNo <= 0x13 )
2348 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2349 index &= IndexMask ;
2350 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2353 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2356 data |= 0x0c ; /* VCLK > 200 */
2358 if ( HwDeviceExtension->jChipType >= XG20 )
2359 data &= ~0x04 ; /* 2 pixel mode */
2361 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2363 if ( HwDeviceExtension->jChipType < XG20 )
2365 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2369 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2372 /* Jong for Adavantech LCD ripple issue
2373 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2375 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2377 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2379 else if ( VCLK > 260 )
2384 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2385 if (HwDeviceExtension->jChipType >= XG27 )
2387 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2394 /* --------------------------------------------------------------------- */
2395 /* Function : XGI_VesaLowResolution */
2399 /* --------------------------------------------------------------------- */
2400 /*void XGI_VesaLowResolution( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo)
2404 if ( ModeNo > 0x13 )
2405 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2407 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2409 if ( ModeNo > 0x13 )
2411 if ( modeflag & DoubleScanMode )
2413 if ( modeflag & HalfDCLK )
2415 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2417 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2419 if ( pVBInfo->VBInfo & SetInSlaveMode )
2421 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2422 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2427 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2428 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2433 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2437 /* --------------------------------------------------------------------- */
2438 /* Function : XGI_LoadDAC */
2442 /* --------------------------------------------------------------------- */
2443 void XGI_LoadDAC( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2445 USHORT data , data2 , time ,
2446 i , j , k , m , n , o ,
2447 si , di , bx , dl , al , ah , dh ,
2450 if ( ModeNo <= 0x13 )
2451 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2453 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2455 data &= DACInfoFlag ;
2459 table = XGINew_MDA_DAC ;
2460 else if ( data == 0x08 )
2461 table = XGINew_CGA_DAC ;
2462 else if ( data == 0x10 )
2463 table = XGINew_EGA_DAC ;
2464 else if ( data == 0x18 )
2467 table = XGINew_VGA_DAC ;
2475 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2476 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2478 for( i = 0 ; i < j ; i++ )
2482 for( k = 0 ; k < 3 ; k++ )
2492 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2499 for( i = 16 ; i < 32 ; i++ )
2503 for( k = 0 ; k < 3 ; k++ )
2504 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2509 for( m = 0 ; m < 9 ; m++ )
2515 for( n = 0 ; n < 3 ; n++ )
2517 for( o = 0 ; o < 5 ; o++ )
2523 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2528 for( o = 0 ; o < 3 ; o++ )
2534 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2546 /* --------------------------------------------------------------------- */
2547 /* Function : XGI_WriteDAC */
2551 /* --------------------------------------------------------------------- */
2552 void XGI_WriteDAC( USHORT dl , USHORT ah , USHORT al , USHORT dh,PVB_DEVICE_INFO pVBInfo )
2554 USHORT temp , bh , bl ;
2577 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )dh ) ;
2578 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bh ) ;
2579 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bl ) ;
2583 /* --------------------------------------------------------------------- */
2584 /* Function : XGI_ClearBuffer */
2588 /* --------------------------------------------------------------------- */
2589 void XGI_ClearBuffer( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo, PVB_DEVICE_INFO pVBInfo)
2591 PVOID VideoMemoryAddress = ( PVOID )HwDeviceExtension->pjVideoMemoryAddress ;
2592 ULONG AdapterMemorySize = ( ULONG )HwDeviceExtension->ulVideoMemorySize ;
2596 if ( pVBInfo->ModeType >= ModeEGA )
2598 if ( ModeNo > 0x13 )
2600 AdapterMemorySize = 0x40000 ; /* clear 256k */
2601 /* GetDRAMSize( HwDeviceExtension ) ; */
2602 memset(VideoMemoryAddress, 0, AdapterMemorySize);
2607 pBuffer = VideoMemoryAddress ;
2608 for( i = 0 ; i < 0x4000 ; i++ )
2609 pBuffer[ i ] = 0x0000 ;
2615 pBuffer = VideoMemoryAddress ;
2616 if ( pVBInfo->ModeType < ModeCGA )
2619 for ( i = 0 ; i < 0x4000 ; i++ )
2620 pBuffer[ i ] = 0x0720 ;
2624 memset(VideoMemoryAddress , 0, 0x8000);
2629 /* --------------------------------------------------------------------- */
2630 /* Function : XGI_SetLCDAGroup */
2634 /* --------------------------------------------------------------------- */
2635 void XGI_SetLCDAGroup( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2637 USHORT RefreshRateTableIndex ;
2640 /* pVBInfo->SelectCRT2Rate = 0 ; */
2642 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2643 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2644 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2645 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2646 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2647 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2648 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2652 /* --------------------------------------------------------------------- */
2653 /* Function : XGI_GetLVDSResInfo */
2657 /* --------------------------------------------------------------------- */
2658 void XGI_GetLVDSResInfo( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2660 USHORT resindex , xres , yres , modeflag ;
2662 if ( ModeNo <= 0x13 )
2664 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2668 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2672 /* if ( ModeNo > 0x13 ) */
2673 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2675 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2677 if ( ModeNo <= 0x13 )
2679 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2683 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2686 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2688 if ( ModeNo <= 0x13 )
2690 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2691 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2695 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2696 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2698 if ( ModeNo > 0x13 )
2700 if ( modeflag & HalfDCLK )
2703 if ( modeflag & DoubleScanMode )
2706 /* if ( modeflag & Charx8Dot ) */
2713 pVBInfo->VGAHDE = xres ;
2714 pVBInfo->HDE = xres ;
2715 pVBInfo->VGAVDE = yres ;
2716 pVBInfo->VDE = yres ;
2720 /* --------------------------------------------------------------------- */
2721 /* Function : XGI_GetLVDSData */
2725 /* --------------------------------------------------------------------- */
2726 void XGI_GetLVDSData( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2729 XGI330_LVDSDataStruct *LCDPtr = NULL ;
2730 XGI330_CHTVDataStruct *TVPtr = NULL ;
2734 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2736 LCDPtr = ( XGI330_LVDSDataStruct * )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo) ;
2737 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2738 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2739 pVBInfo->HT = LCDPtr->LCDHT ;
2740 pVBInfo->VT = LCDPtr->LCDVT ;
2742 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2744 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2746 TVPtr = ( XGI330_CHTVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2747 pVBInfo->VGAHT = TVPtr->VGAHT ;
2748 pVBInfo->VGAVT = TVPtr->VGAVT ;
2749 pVBInfo->HT = TVPtr->LCDHT ;
2750 pVBInfo->VT = TVPtr->LCDVT ;
2754 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2756 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2758 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2760 pVBInfo->HDE = 1024 ;
2761 pVBInfo->VDE = 768 ;
2763 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2765 pVBInfo->HDE = 1280 ;
2766 pVBInfo->VDE = 1024 ;
2768 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2770 pVBInfo->HDE = 1400 ;
2771 pVBInfo->VDE = 1050 ;
2775 pVBInfo->HDE = 1600 ;
2776 pVBInfo->VDE = 1200 ;
2783 /* --------------------------------------------------------------------- */
2784 /* Function : XGI_ModCRT1Regs */
2788 /* --------------------------------------------------------------------- */
2789 void XGI_ModCRT1Regs( USHORT ModeNo , USHORT ModeIdIndex ,
2790 USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2794 XGI_LVDSCRT1HDataStruct *LCDPtr = NULL ;
2795 XGI_LVDSCRT1VDataStruct *LCDPtr1 =NULL ;
2796 /* XGI330_CHTVDataStruct *TVPtr = NULL ; */
2797 XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2798 XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2800 if( ModeNo <= 0x13 )
2801 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2803 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2805 index= index & IndexMask ;
2807 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2811 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2813 LCDPtr = ( XGI_LVDSCRT1HDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2815 for( i = 0 ; i < 8 ; i++ )
2816 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2819 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2821 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2823 CH7007TV_TimingHPtr = ( XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2825 for( i = 0 ; i < 8 ; i++ )
2826 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2830 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2832 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2833 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2836 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2838 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2840 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2841 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2846 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2848 LCDPtr1 = ( XGI_LVDSCRT1VDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2849 for( i = 0 ; i < 7 ; i++ )
2850 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2853 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2855 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2857 CH7007TV_TimingVPtr = ( XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2859 for( i = 0 ; i < 7 ; i++ )
2860 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2863 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2865 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2866 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2869 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2871 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2873 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2874 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2875 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2883 /* --------------------------------------------------------------------- */
2884 /* Function : XGI_SetLVDSRegs */
2888 /* --------------------------------------------------------------------- */
2889 void XGI_SetLVDSRegs( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2891 USHORT tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
2892 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2893 XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2894 XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2896 if ( ModeNo > 0x13 )
2897 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2899 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2901 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2903 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2905 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2908 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2911 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2914 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2915 LCDPtr1 = ( XGI330_LCDDataDesStruct2 * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2917 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2920 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
2925 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2930 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2935 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2946 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
2948 pVBInfo->HDE=tempax;
2949 pVBInfo->VDE=tempbx;
2950 pVBInfo->VGAHDE=tempax;
2951 pVBInfo->VGAVDE=tempbx;
2954 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
2956 tempax=pVBInfo->HDE;
2957 tempbx=pVBInfo->VDE;
2960 tempax = pVBInfo->HT ;
2962 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2963 tempbx = LCDPtr1->LCDHDES ;
2965 tempbx = LCDPtr->LCDHDES ;
2967 tempcx = pVBInfo->HDE ;
2968 tempbx = tempbx & 0x0fff ;
2971 if ( tempcx >= tempax )
2974 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
2976 tempcx = tempcx >> 3 ;
2977 tempbx = tempbx >> 3 ;
2979 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , ( USHORT )( tempbx & 0xff ) ) ;
2980 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , ( USHORT )( tempcx & 0xff ) ) ;
2982 tempax = pVBInfo->HT ;
2984 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2985 tempbx = LCDPtr1->LCDHRS ;
2987 tempbx = LCDPtr->LCDHRS ;
2991 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2992 tempcx = LCDPtr1->LCDHSync ;
2996 if ( tempcx >= tempax )
2999 tempax = tempbx & 0x07 ;
3000 tempax = tempax >> 5 ;
3001 tempcx = tempcx >> 3 ;
3002 tempbx = tempbx >> 3 ;
3007 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
3008 XGINew_SetReg1( pVBInfo->Part1Port , 0x14 , ( USHORT )( tempbx & 0xff ) ) ;
3010 tempax = pVBInfo->VT ;
3011 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3012 tempbx = LCDPtr1->LCDVDES ;
3014 tempbx = LCDPtr->LCDVDES ;
3015 tempcx = pVBInfo->VDE ;
3017 tempbx = tempbx & 0x0fff ;
3019 if ( tempcx >= tempax )
3022 XGINew_SetReg1( pVBInfo->Part1Port , 0x1b , ( USHORT )( tempbx & 0xff ) ) ;
3023 XGINew_SetReg1( pVBInfo->Part1Port , 0x1c , ( USHORT )( tempcx & 0xff ) ) ;
3025 tempbx = ( tempbx >> 8 ) & 0x07 ;
3026 tempcx = ( tempcx >> 8 ) & 0x07 ;
3028 XGINew_SetReg1( pVBInfo->Part1Port , 0x1d , ( USHORT )( ( tempcx << 3 ) | tempbx ) ) ;
3030 tempax = pVBInfo->VT ;
3031 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3032 tempbx = LCDPtr1->LCDVRS ;
3034 tempbx = LCDPtr->LCDVRS ;
3036 /* tempbx = tempbx >> 4 ; */
3039 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3040 tempcx = LCDPtr1->LCDVSync ;
3043 if ( tempcx >= tempax )
3046 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , ( USHORT )( tempbx & 0xff ) ) ;
3047 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , ~0x0f , ( USHORT )( tempcx & 0x0f ) ) ;
3049 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3051 tempbx = pVBInfo->VGAVDE ;
3052 if ( tempbx != pVBInfo->VDE )
3055 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3058 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3060 tempcx = pVBInfo->VGAVT ;
3061 tempbx = pVBInfo->VDE ;
3062 tempax = pVBInfo->VGAVDE ;
3065 temp = tempax ; /* 0430 ylshieh */
3066 temp1 = ( temp << 18 ) / tempbx ;
3068 tempdx = ( USHORT )( ( temp << 18 ) % tempbx ) ;
3076 XGINew_SetReg1( pVBInfo->Part1Port , 0x37 , ( USHORT )( temp2 & 0xff ) ) ;
3077 XGINew_SetReg1( pVBInfo->Part1Port , 0x36 , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3079 tempbx = ( USHORT )( temp2 >> 16 ) ;
3080 tempax = tempbx & 0x03 ;
3082 tempbx = pVBInfo->VGAVDE ;
3083 if ( tempbx == pVBInfo->VDE )
3086 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3088 if ( pVBInfo->VBType & VB_XGI301C )
3091 XGINew_SetReg1( pVBInfo->Part4Port , 0x3c , ( USHORT )( temp2 & 0xff ) ) ;
3092 XGINew_SetReg1( pVBInfo->Part4Port , 0x3b , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3093 tempbx = ( USHORT )( temp2 >> 16 ) ;
3094 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x3a , ~0xc0 , ( USHORT )( ( tempbx & 0xff ) << 6 ) ) ;
3096 tempcx = pVBInfo->VGAVDE ;
3097 if ( tempcx == pVBInfo->VDE )
3098 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3100 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3103 tempcx = pVBInfo->VGAHDE ;
3104 tempbx = pVBInfo->HDE ;
3106 temp1 = tempcx << 16 ;
3108 tempax = ( USHORT )( temp1 / tempbx ) ;
3110 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3114 temp1 = pVBInfo->VGAHDE << 16 ;
3117 temp3 = temp3 << 16 ;
3120 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3122 tempax = ( USHORT )( temp3 & 0xff ) ;
3123 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3125 temp1 = pVBInfo->VGAVDE << 18 ;
3126 temp1 = temp1 / push3 ;
3127 tempbx = ( USHORT )( temp1 & 0xffff ) ;
3129 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3132 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
3133 tempax |= ( USHORT )( ( temp3 >> 8 ) & 0x07 ) ;
3134 XGINew_SetReg1( pVBInfo->Part1Port , 0x20 , ( USHORT )( tempax & 0xff ) ) ;
3135 XGINew_SetReg1( pVBInfo->Part1Port , 0x21 , ( USHORT )( tempbx & 0xff ) ) ;
3137 temp3 = temp3 >> 16 ;
3139 if ( modeflag & HalfDCLK )
3140 temp3 = temp3 >> 1 ;
3142 XGINew_SetReg1(pVBInfo->Part1Port , 0x22 , ( USHORT )( ( temp3 >> 8 ) & 0xff ) ) ;
3143 XGINew_SetReg1(pVBInfo->Part1Port , 0x23 , ( USHORT )( temp3 & 0xff ) ) ;
3149 /* --------------------------------------------------------------------- */
3150 /* Function : XGI_SetCRT2ECLK */
3154 /* --------------------------------------------------------------------- */
3155 void XGI_SetCRT2ECLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
3157 UCHAR di_0 , di_1 , tempal ;
3160 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3161 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3162 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3164 for( i = 0 ; i < 4 ; i++ )
3166 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , ~0x30 , ( USHORT )( 0x10 * i ) ) ;
3167 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3169 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3170 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3172 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3174 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3175 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3179 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3180 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3186 /* --------------------------------------------------------------------- */
3187 /* Function : XGI_UpdateModeInfo */
3191 /* --------------------------------------------------------------------- */
3192 void XGI_UpdateModeInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
3200 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3204 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3206 if ( !( temp & 0x20 ) )
3208 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3211 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3212 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3214 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3216 if ( !( temp & 0x40 ) )
3217 tempcl |= ActiveCRT1 ;
3221 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3224 if ( !( temp == 0x08 ) )
3226 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3227 if ( tempax & 0x04 )
3228 tempcl = tempcl | ActiveLCD ;
3232 if ( !( tempcl & ActiveLCD ) )
3234 tempcl |= ActiveCRT2 ;
3237 tempcl |= ActiveLCD ;
3241 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3243 if( !( temp & 0x08 ) )
3244 tempch |= ActiveAVideo ;
3246 if ( !( temp & 0x04 ) )
3247 tempch |= ActiveSVideo ;
3250 tempch |= ActiveSCART ;
3252 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3255 tempch |= ActiveHiTV ;
3258 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3260 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3263 tempch |= ActiveYPbPr ;
3267 tempcl |= ActiveTV ;
3271 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3272 if ( tempcl & ActiveLCD )
3274 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3276 if ( temp & ActiveTV )
3277 tempcl |= ActiveTV ;
3281 tempbl = ~ModeSwitchStatus ;
3282 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3284 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3285 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3294 /* --------------------------------------------------------------------- */
3295 /* Function : XGI_GetVGAType */
3299 /* --------------------------------------------------------------------- */
3300 void XGI_GetVGAType( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3303 if ( HwDeviceExtension->jChipType >= XG20 )
3305 pVBInfo->Set_VGAType = XG20;
3307 else if ( HwDeviceExtension->jChipType >= XG40 )
3309 pVBInfo->Set_VGAType = VGA_XGI340 ;
3312 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3316 /* --------------------------------------------------------------------- */
3317 /* Function : XGI_GetVBType */
3321 /* --------------------------------------------------------------------- */
3322 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo)
3324 USHORT flag , tempbx , tempah ;
3326 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3328 pVBInfo->VBType = VB_CH7007 ;
3331 if ( pVBInfo->IF_DEF_LVDS == 0 )
3333 tempbx = VB_XGI302B ;
3334 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3337 tempbx = VB_XGI301 ;
3338 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3341 tempbx = VB_XGI301B ;
3344 tempbx = VB_XGI301C ;
3347 tempbx = VB_XGI301LV ;
3350 tempbx = VB_XGI302LV ;
3351 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3352 if ( tempah != 0xFF )
3353 tempbx = VB_XGI301C ;
3358 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3360 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3362 if ( !( flag & 0x02 ) )
3363 tempbx = tempbx | VB_NoLCD ;
3367 pVBInfo->VBType = tempbx ;
3370 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3371 pVBInfo->VBType = VB_CH7017 ;
3373 pVBInfo->VBType = VB_LVDS_NS ;
3379 /* --------------------------------------------------------------------- */
3380 /* Function : XGI_GetVBInfo */
3384 /* --------------------------------------------------------------------- */
3385 void XGI_GetVBInfo( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
3393 if ( ModeNo <= 0x13 )
3395 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3399 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3402 pVBInfo->SetFlag = 0 ;
3403 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3406 if ( pVBInfo->VBType & 0xFFFF )
3408 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3409 tempbx = tempbx | temp ;
3410 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3413 tempax = temp << 8 ;
3414 tempbx = tempbx | tempax ;
3415 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3416 temp = 0xFFFF ^ temp ;
3419 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3421 if ( pVBInfo->IF_DEF_LCDA == 1 )
3424 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3426 if ( pVBInfo->IF_DEF_LVDS == 0 )
3428 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3429 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3431 if ( temp & EnableDualEdge )
3433 tempbx |= SetCRT2ToDualEdge ;
3435 if ( temp & SetToLCDA )
3436 tempbx |= SetCRT2ToLCDA ;
3440 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3442 if ( pVBInfo->VBType & VB_CH7017 )
3444 if ( temp & EnableDualEdge )
3446 tempbx |= SetCRT2ToDualEdge ;
3448 if ( temp & SetToLCDA )
3449 tempbx |= SetCRT2ToLCDA ;
3456 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3458 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3459 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3461 if ( temp & SetYPbPr ) /* temp = CR38 */
3463 if ( pVBInfo->IF_DEF_HiVision == 1 )
3465 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3467 tempbx |= SetCRT2ToHiVisionTV ;
3469 if ( temp != YPbPrMode1080i ) {
3470 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3471 tempbx |= SetCRT2ToYPbPr ; }
3474 /* tempbx |= SetCRT2ToYPbPr ; */
3479 tempax = push ; /* restore CR31 */
3481 if ( pVBInfo->IF_DEF_LVDS == 0 )
3483 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3485 if ( pVBInfo->IF_DEF_HiVision == 1 )
3492 if ( pVBInfo->IF_DEF_HiVision == 1 )
3498 else /* 3nd party chip */
3500 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3501 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3502 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3504 temp = SetCRT2ToTV ;
3507 temp = SetCRT2ToLCD ;
3510 if ( !( tempbx & temp ) )
3512 tempax |= DisableCRT2Display ;
3516 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3518 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3520 if ( tempbx & SetCRT2ToLCDA )
3522 if ( tempbx & SetSimuScanMode )
3523 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3525 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3531 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3533 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3535 if ( tempbx & SetCRT2ToRAMDAC )
3537 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3538 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3542 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3545 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3547 if ( tempbx & SetCRT2ToLCD )
3549 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3550 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3554 if ( tempbx & SetCRT2ToSCART )
3556 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3557 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3560 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3562 if ( tempbx & SetCRT2ToYPbPr )
3563 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3566 if ( pVBInfo->IF_DEF_HiVision == 1 )
3568 if ( tempbx & SetCRT2ToHiVisionTV )
3569 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3572 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3574 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3575 tempbx = DisableCRT2Display ;
3578 if ( !( tempbx & DisableCRT2Display ) )
3580 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3582 if ( pVBInfo->IF_DEF_LCDA == 1 )
3584 if ( !( tempbx & SetCRT2ToLCDA ) )
3585 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3588 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3590 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3591 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3592 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3593 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3597 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3599 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3600 pVBInfo->SetFlag |= EnableVCMode ;
3607 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3608 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3610 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3611 pVBInfo->SetFlag |= ReserveTVOption ;
3616 pVBInfo->VBInfo = tempbx ;
3620 /* --------------------------------------------------------------------- */
3621 /* Function : XGI_GetTVInfo */
3625 /* --------------------------------------------------------------------- */
3626 void XGI_GetTVInfo( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo )
3637 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3639 if ( ModeNo <= 0x13 )
3641 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3642 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3646 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3647 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3650 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3652 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3654 if ( tempbx & SetPALTV )
3656 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3657 if ( tempbx & SetPALMTV )
3658 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3661 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3663 if ( pVBInfo->IF_DEF_LVDS == 0 )
3665 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3666 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3668 if ( temp2 & 0x02 ) //PAL-M
3669 tempbx &= ( ~SetPALTV ) ;
3674 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3676 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3678 if ( tempbx & TVOverScan )
3679 tempbx |= SetCHTVOverScan ;
3682 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3684 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3686 if ( tempbx & TVOverScan )
3688 tempbx |= SetCHTVOverScan ;
3693 if ( pVBInfo->IF_DEF_LVDS == 0 )
3695 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3696 tempbx |= SetPALTV ;
3699 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3701 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3703 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3704 index1 &= YPbPrMode ;
3706 if ( index1 == YPbPrMode525i )
3707 tempbx |= SetYPbPrMode525i ;
3709 if ( index1 == YPbPrMode525p )
3710 tempbx = tempbx | SetYPbPrMode525p;
3711 if ( index1 == YPbPrMode750p)
3712 tempbx = tempbx | SetYPbPrMode750p;
3716 if ( pVBInfo->IF_DEF_HiVision == 1 )
3718 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3720 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3724 if ( pVBInfo->IF_DEF_LVDS == 0 )
3726 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3727 tempbx |= TVSimuMode ;
3729 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3730 tempbx |= NTSC1024x768 ;
3732 tempbx |= RPLLDIV2XO ;
3734 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3736 if ( pVBInfo->VBInfo & SetInSlaveMode )
3737 tempbx &=( ~RPLLDIV2XO ) ;
3741 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3742 tempbx &= ( ~RPLLDIV2XO ) ;
3743 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3745 if ( tempbx & TVSimuMode )
3746 tempbx &= ( ~RPLLDIV2XO ) ;
3751 pVBInfo->TVInfo = tempbx ;
3755 /* --------------------------------------------------------------------- */
3756 /* Function : XGI_GetLCDInfo */
3760 /* --------------------------------------------------------------------- */
3761 BOOLEAN XGI_GetLCDInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
3770 pVBInfo->LCDResInfo = 0 ;
3771 pVBInfo->LCDTypeInfo = 0 ;
3772 pVBInfo->LCDInfo = 0 ;
3774 if ( ModeNo <= 0x13 )
3776 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3780 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3781 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3784 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3785 tempbx = temp & 0x0F ;
3788 tempbx = Panel1024x768 ; /* default */
3790 /* LCD75 [2003/8/22] Vicent */
3791 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3793 if ( pVBInfo->VBInfo & DriverMode )
3795 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3796 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3799 tempax = tempax >> 4 ;
3801 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3804 tempbx |= PanelRef75Hz ;
3806 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3809 tempbx |= PanelRef75Hz ;
3814 pVBInfo->LCDResInfo = tempbx ;
3818 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3820 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3823 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3830 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3832 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3834 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3835 temp &= ~EnableScalingLCD ;
3839 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3841 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3843 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3845 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3847 tempbx |= SetLCDDualLink ;
3851 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3853 if ( tempax & LCDDualLink )
3855 tempbx |= SetLCDDualLink ;
3859 if ( pVBInfo->IF_DEF_LVDS == 0 )
3861 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3862 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3866 if ( tempax & LCDBToA )
3868 tempbx |= SetLCDBToA ;
3872 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3874 if ( modeflag & HalfDCLK )
3876 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3877 if ( !( tempbx & SetLCDtoNonExpanding ) )
3879 tempbx |= EnableLVDSDDA ;
3883 if ( ModeNo > 0x13 )
3885 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3889 tempbx |= EnableLVDSDDA ;
3897 if ( pVBInfo->VBInfo & SetInSlaveMode )
3899 if ( pVBInfo->VBInfo & SetNotSimuMode )
3901 tempbx |= LCDVESATiming ;
3906 tempbx |= LCDVESATiming ;
3909 pVBInfo->LCDInfo = tempbx ;
3911 if ( pVBInfo->IF_DEF_PWD == 1 )
3913 if ( pVBInfo->LCDInfo & SetPWDEnable )
3915 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3917 if ( !( tempax & PWDEnable ) )
3919 pVBInfo->LCDInfo &= ~SetPWDEnable ;
3925 if ( pVBInfo->IF_DEF_LVDS == 0 )
3927 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3929 if ( pVBInfo->VBInfo & SetInSlaveMode )
3931 if ( !( tempax & LockLCDBToA ) )
3933 if ( ModeNo <= 0x13 )
3935 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
3936 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
3944 if ( pVBInfo->IF_DEF_LVDS == 0 )
3946 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3948 if ( pVBInfo->VBInfo & SetInSlaveMode )
3950 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
3952 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3953 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3964 /* --------------------------------------------------------------------- */
3965 /* Function : XGI_SearchModeID */
3969 /* --------------------------------------------------------------------- */
3970 BOOLEAN XGI_SearchModeID( USHORT ModeNo , USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
3975 #ifdef LINUX /* chiawen for linux solution */
3979 if ( ModeNo <= 0x13 )
3981 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
3982 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
3984 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3986 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3990 if ( ModeNo == 0x07 )
3991 ( *ModeIdIndex )++ ; /* 400 lines */
3994 ( *ModeIdIndex ) += 2 ; /* 400 lines */
3995 /* else 350 lines */
3999 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4000 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4002 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
4004 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
4017 /* win2000 MM adapter not support standard mode! */
4019 /* --------------------------------------------------------------------- */
4024 /* --------------------------------------------------------------------- */
4025 BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4033 /* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4034 ( HwDeviceExtension->jChipType == XGI_650M ) )
4039 if ( ModeNo <= 0x13 )
4041 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4044 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4047 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4049 memorysize = modeflag & MemoryInfoFlag ;
4050 memorysize = memorysize > MemorySizeShift ;
4051 memorysize++ ; /* Get memory size */
4053 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4056 if ( HwDeviceExtension->jChipType == XG40 )
4058 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4059 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4063 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4068 else if ( HwDeviceExtension->jChipType == XG42 )
4070 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4071 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4076 else if ( HwDeviceExtension->jChipType == XG45 )
4078 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4079 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4083 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4089 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4094 if (temp < memorysize)
4101 /* --------------------------------------------------------------------- */
4102 /* Function : XGINew_IsLowResolution */
4106 /* --------------------------------------------------------------------- */
4107 /*void XGINew_IsLowResolution( USHORT ModeNo , USHORT ModeIdIndex, BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4112 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4114 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4116 if ( ModeNo > 0x13 )
4118 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4119 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4121 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4123 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4124 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4126 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4133 /* --------------------------------------------------------------------- */
4134 /* Function : XGI_DisplayOn */
4138 /* --------------------------------------------------------------------- */
4139 void XGI_DisplayOn( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4142 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4143 if ( pXGIHWDE->jChipType == XG21 )
4145 if ( pVBInfo->IF_DEF_LVDS == 1 )
4147 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4149 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4150 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4152 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4154 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4156 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4157 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4161 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4166 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4172 if ( pXGIHWDE->jChipType == XG27 )
4174 if ( pVBInfo->IF_DEF_LVDS == 1 )
4176 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4178 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4179 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4181 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4183 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4185 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4186 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4190 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4197 /* --------------------------------------------------------------------- */
4198 /* Function : XGI_DisplayOff */
4202 /* --------------------------------------------------------------------- */
4203 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4206 if ( pXGIHWDE->jChipType == XG21 )
4208 if ( pVBInfo->IF_DEF_LVDS == 1 )
4210 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4211 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4215 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4219 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4221 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4227 if ( pXGIHWDE->jChipType == XG27 )
4229 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4231 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4232 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4235 if ( pVBInfo->IF_DEF_LVDS == 0 )
4237 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4241 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4245 /* --------------------------------------------------------------------- */
4246 /* Function : XGI_WaitDisply */
4249 /* Description : chiawen for sensecrt1 */
4250 /* --------------------------------------------------------------------- */
4251 void XGI_WaitDisply( PVB_DEVICE_INFO pVBInfo )
4253 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4256 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4260 /* --------------------------------------------------------------------- */
4261 /* Function : XGI_SenseCRT1 */
4265 /* --------------------------------------------------------------------- */
4267 void XGI_SenseCRT1( PVB_DEVICE_INFO pVBInfo )
4269 UCHAR CRTCData[ 17 ] = { 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4270 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4271 0x04 , 0x00 , 0x00 , 0x05 , 0x00 } ;
4273 UCHAR SR01 = 0 , SR1F = 0 , SR07 = 0 , SR06 = 0 ;
4275 UCHAR CR17 , CR63 , SR31 ;
4277 UCHAR DAC_TEST_PARMS[ 3 ] = { 0x0F , 0x0F , 0x0F } ;
4280 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4282 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4283 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4284 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) | 0x02 ) ) ;
4286 SR31 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) ;
4287 CR63 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
4288 SR01 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4290 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , ( UCHAR )( SR01 & 0xDF ) ) ;
4291 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , ( UCHAR )( CR63 & 0xBF ) ) ;
4293 CR17 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
4294 XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , ( UCHAR )( CR17 | 0x80 ) ) ;
4296 SR1F = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
4297 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR )( SR1F | 0x04 ) ) ;
4299 SR07 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x07 ) ;
4300 XGINew_SetReg1( pVBInfo->P3c4 , 0x07 , ( UCHAR )( SR07 & 0xFB ) ) ;
4301 SR06 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x06 ) ;
4302 XGINew_SetReg1( pVBInfo->P3c4 , 0x06 , ( UCHAR )( SR06 & 0xC3 ) ) ;
4304 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4306 for( i = 0 ; i < 8 ; i++ )
4307 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )i , CRTCData[ i ] ) ;
4309 for( i = 8 ; i < 11 ; i++ )
4310 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 8 ) , CRTCData[ i ] ) ;
4312 for( i = 11 ; i < 13 ; i++ )
4313 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 4 ) , CRTCData[ i ] ) ;
4315 for( i = 13 ; i < 16 ; i++ )
4316 XGINew_SetReg1( pVBInfo->P3c4 , ( USHORT )( i - 3 ) , CRTCData[ i ] ) ;
4318 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , ( UCHAR )( CRTCData[ 16 ] & 0xE0 ) ) ;
4320 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4321 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4322 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4324 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4326 for( i = 0 ; i < 256 ; i++ )
4328 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 0 ] ) ;
4329 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 1 ] ) ;
4330 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 2 ] ) ;
4333 XGI_VBLongWait( pVBInfo ) ;
4334 XGI_VBLongWait( pVBInfo ) ;
4335 XGI_VBLongWait( pVBInfo ) ;
4337 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4339 XGI_WaitDisply( pVBInfo ) ;
4340 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4344 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4348 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4351 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4352 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4354 for( i = 0 ; i < 256 ; i++ )
4356 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4357 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4358 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4361 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4362 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4363 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4365 /* [2004/05/11] Vicent */
4366 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) & 0xFD ) ) ;
4367 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR ) SR1F ) ;
4379 /* --------------------------------------------------------------------- */
4380 /* Function : XGI_WaitDisplay */
4384 /* --------------------------------------------------------------------- */
4385 void XGI_WaitDisplay( PVB_DEVICE_INFO pVBInfo )
4387 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4389 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4395 /* --------------------------------------------------------------------- */
4396 /* Function : XGI_SetCRT2Group301 */
4400 /* --------------------------------------------------------------------- */
4401 BOOLEAN XGI_SetCRT2Group301( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
4405 RefreshRateTableIndex ;
4407 tempbx=pVBInfo->VBInfo ;
4408 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4409 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4410 pVBInfo->SelectCRT2Rate = 4 ;
4411 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4412 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4413 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4414 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4415 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4416 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4417 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4418 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4419 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4420 XGI_SetTap4Regs(pVBInfo) ;
4421 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4422 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4423 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4424 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4425 XGI_AutoThreshold( pVBInfo) ;
4430 /* --------------------------------------------------------------------- */
4431 /* Function : XGI_AutoThreshold */
4435 /* --------------------------------------------------------------------- */
4436 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo )
4438 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4439 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4443 /* --------------------------------------------------------------------- */
4444 /* Function : XGI_SaveCRT2Info */
4448 /* --------------------------------------------------------------------- */
4449 void XGI_SaveCRT2Info( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo)
4454 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4455 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4456 temp2 = ~( SetInSlaveMode >> 8 ) ;
4457 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4461 /* --------------------------------------------------------------------- */
4462 /* Function : XGI_GetCRT2ResInfo */
4466 /* --------------------------------------------------------------------- */
4467 void XGI_GetCRT2ResInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
4474 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4475 if ( ModeNo <= 0x13 )
4477 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4478 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4479 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4483 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4484 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4485 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4487 /* if ( pVBInfo->IF_DEF_FSTN )
4495 if ( modeflag & HalfDCLK )
4498 if ( modeflag & DoubleScanMode )
4503 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4505 if ( pVBInfo->IF_DEF_LVDS == 0 )
4507 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4509 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4516 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4520 else if ( yres == 350 )
4523 if ( pVBInfo->LCDInfo & LCDVESATiming )
4530 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4532 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4534 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4538 else if ( yres == 400 )
4540 else if ( yres == 480 )
4551 pVBInfo->VGAHDE = xres ;
4552 pVBInfo->HDE = xres ;
4553 pVBInfo->VGAVDE = yres ;
4554 pVBInfo->VDE = yres ;
4558 /* --------------------------------------------------------------------- */
4559 /* Function : XGI_IsLCDDualLink */
4563 /* --------------------------------------------------------------------- */
4564 BOOLEAN XGI_IsLCDDualLink( PVB_DEVICE_INFO pVBInfo )
4567 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4574 /* --------------------------------------------------------------------- */
4575 /* Function : XGI_GetCRT2Data */
4579 /* --------------------------------------------------------------------- */
4580 void XGI_GetCRT2Data( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4587 XGI_LCDDataStruct *LCDPtr = NULL ;
4588 XGI_TVDataStruct *TVPtr = NULL ;
4590 if ( ModeNo <= 0x13 )
4592 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4593 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4597 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4598 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4601 pVBInfo->NewFlickerMode = 0 ;
4602 pVBInfo->RVBHRS = 50 ;
4604 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4606 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4612 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4614 LCDPtr = (XGI_LCDDataStruct* )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4616 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4617 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4618 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4619 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4620 pVBInfo->HT = LCDPtr->LCDHT ;
4621 pVBInfo->VT = LCDPtr->LCDVT ;
4623 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4628 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4630 if ( pVBInfo->VGAVDE == 357 )
4632 else if ( pVBInfo->VGAVDE == 420 )
4634 else if ( pVBInfo->VGAVDE == 525 )
4636 else if ( pVBInfo->VGAVDE == 600 )
4638 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4639 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4646 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4651 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4654 if ( pVBInfo->VGAVDE == 360 )
4656 else if ( pVBInfo->VGAVDE == 375 )
4658 else if ( pVBInfo->VGAVDE == 405 )
4663 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4668 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4671 if ( pVBInfo->VGAVDE == 350 )
4673 else if ( pVBInfo->VGAVDE == 400 )
4675 else if ( pVBInfo->VGAVDE == 1024 )
4680 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4685 if ( pVBInfo->VGAVDE == 1024 )
4691 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4694 tempbx = 1200 ; /* alan 10/14/2003 */
4695 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4697 if ( pVBInfo->VGAVDE == 350 )
4699 else if ( pVBInfo->VGAVDE == 400 )
4704 if ( pVBInfo->LCDInfo & LCDNonExpanding )
4706 tempax = pVBInfo->VGAHDE ;
4707 tempbx = pVBInfo->VGAVDE ;
4710 pVBInfo->HDE = tempax ;
4711 pVBInfo->VDE = tempbx ;
4715 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
4718 TVPtr = ( XGI_TVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4720 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
4721 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
4722 pVBInfo->VGAHT = TVPtr->VGAHT ;
4723 pVBInfo->VGAVT = TVPtr->VGAVT ;
4724 pVBInfo->HDE = TVPtr->TVHDE ;
4725 pVBInfo->VDE = TVPtr->TVVDE ;
4726 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
4727 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
4729 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
4731 if ( resinfo == 0x08 )
4732 pVBInfo->NewFlickerMode = 0x40 ;
4733 else if ( resinfo == 0x09 )
4734 pVBInfo->NewFlickerMode = 0x40 ;
4735 else if ( resinfo == 0x12 )
4736 pVBInfo->NewFlickerMode = 0x40 ;
4738 if ( pVBInfo->VGAVDE == 350 )
4739 pVBInfo->TVInfo |= TVSimuMode ;
4741 tempax = ExtHiTVHT ;
4742 tempbx = ExtHiTVVT ;
4744 if ( pVBInfo->VBInfo & SetInSlaveMode )
4746 if ( pVBInfo->TVInfo & TVSimuMode )
4751 if ( !( modeflag & Charx8Dot ) )
4753 tempax = StHiTextTVHT ;
4754 tempbx = StHiTextTVVT ;
4759 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
4761 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4763 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
4764 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
4767 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4769 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
4770 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
4772 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
4774 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
4775 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
4776 if ( pVBInfo->TVInfo & NTSC1024x768 )
4777 tempax = NTSC1024x768HT ;
4784 if ( !( pVBInfo->TVInfo & SetPALTV ) )
4788 if ( pVBInfo->TVInfo & NTSC1024x768 )
4789 tempax = NTSC1024x768HT ;
4793 pVBInfo->HT = tempax ;
4794 pVBInfo->VT = tempbx ;
4800 /* --------------------------------------------------------------------- */
4801 /* Function : XGI_SetCRT2VCLK */
4805 /* --------------------------------------------------------------------- */
4806 void XGI_SetCRT2VCLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4812 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
4813 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
4814 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
4816 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
4818 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
4819 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
4820 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
4823 { /* 301b/302b/301lv/302lv */
4824 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
4825 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
4828 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
4830 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4831 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
4833 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
4837 /* --------------------------------------------------------------------- */
4838 /* Function : XGI_GETLCDVCLKPtr */
4840 /* Output : al -> VCLK Index */
4842 /* --------------------------------------------------------------------- */
4843 void XGI_GetLCDVCLKPtr( UCHAR* di_0 , UCHAR *di_1, PVB_DEVICE_INFO pVBInfo )
4847 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4849 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
4851 if ( pVBInfo->LCDInfo & EnableScalingLCD )
4855 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
4856 index = XGI_GetLCDCapPtr1( pVBInfo) ;
4858 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4860 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
4861 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
4865 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
4866 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
4873 /* --------------------------------------------------------------------- */
4874 /* Function : XGI_GetVCLKPtr */
4878 /* --------------------------------------------------------------------- */
4879 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
4886 UCHAR *CHTVVCLKPtr = NULL ;
4888 if ( ModeNo <= 0x13 )
4889 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4891 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4894 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
4896 index = XGI_GetLCDCapPtr(pVBInfo) ;
4897 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
4899 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4903 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
4905 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
4907 tempal = HiTVVCLKDIV2;
4908 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
4910 if(pVBInfo->TVInfo & TVSimuMode)
4912 tempal = HiTVSimuVCLK;
4913 if(!(modeflag & Charx8Dot))
4914 tempal = HiTVTextVCLK;
4920 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4922 tempal = YPbPr750pVCLK ;
4926 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4928 tempal = YPbPr525pVCLK ;
4932 tempal = NTSC1024VCLK ;
4934 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
4936 tempal = TVVCLKDIV2 ;
4937 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
4941 if ( pVBInfo->VBInfo & SetCRT2ToTV )
4945 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
4948 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4950 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4951 *tempal = *tempal & 0x1F;
4954 if(pVBInfo->TVInfo & SetPALTV)
4955 tempbx = tempbx + 2;
4956 if(pVBInfo->TVInfo & SetCHTVOverScan)
4958 tempbx = tempbx << 1;
4962 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
4964 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4965 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
4967 if( ModeNo <= 0x13 )
4969 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
4973 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4976 tempal = tempal & 0x0F;
4979 if(pVBInfo->TVInfo & SetPALTV)
4981 tempbx = tempbx + 2;
4983 if(pVBInfo->TVInfo & SetCHTVOverScan)
4987 /** tempbx = tempbx << 1; CH7007 ? **/
4989 /*[Billy]07/05/29 CH7007*/
4990 if ( pVBInfo->IF_DEF_CH7007 == 1 )
4995 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
4998 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5001 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5004 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5016 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5019 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5022 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5025 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5032 tempal = CHTVVCLKPtr[ tempal ] ;
5038 tempal = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ;
5039 tempal = tempal >> 2 ;
5042 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5043 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5045 if ( ModeNo <= 0x13 )
5048 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5053 /* --------------------------------------------------------------------- */
5054 /* Function : XGI_GetVCLKLen */
5058 /* --------------------------------------------------------------------- */
5059 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo)
5061 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5063 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5064 *di_0 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2B ;
5065 *di_1 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2C ;
5067 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5069 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5071 *di_0 = ( UCHAR )XGI_VBVCLKData[ tempal ].SR2B ;
5072 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5077 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5078 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5083 /* --------------------------------------------------------------------- */
5084 /* Function : XGI_SetCRT2Offset */
5088 /* --------------------------------------------------------------------- */
5089 void XGI_SetCRT2Offset( USHORT ModeNo ,
5090 USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5095 if ( pVBInfo->VBInfo & SetInSlaveMode )
5100 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5101 temp = ( UCHAR )( offset & 0xFF ) ;
5102 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5103 temp =( UCHAR)( ( offset & 0xFF00 ) >> 8 ) ;
5104 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , temp ) ;
5105 temp =( UCHAR )( ( ( offset >> 3 ) & 0xFF ) + 1 ) ;
5106 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5110 /* --------------------------------------------------------------------- */
5111 /* Function : XGI_GetOffset */
5115 /* --------------------------------------------------------------------- */
5116 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
5123 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5125 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5126 if ( ModeNo <= 0x14 )
5129 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5132 index = ( modeinfo >> 8 ) & 0xFF ;
5134 temp = pVBInfo->ScreenOffset[ index ] ;
5136 if ( infoflag & InterlaceMode )
5141 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5143 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5145 temp = ModeNo - 0x7C ;
5146 colordepth = ColorDepth[ temp ] ;
5148 if ( infoflag & InterlaceMode )
5152 return( temp * colordepth ) ;
5155 return( temp * colordepth ) ;
5159 /* --------------------------------------------------------------------- */
5160 /* Function : XGI_SetCRT2FIFO */
5164 /* --------------------------------------------------------------------- */
5165 void XGI_SetCRT2FIFO( PVB_DEVICE_INFO pVBInfo)
5167 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5168 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5172 /* --------------------------------------------------------------------- */
5173 /* Function : XGI_PreSetGroup1 */
5177 /* --------------------------------------------------------------------- */
5178 void XGI_PreSetGroup1(USHORT ModeNo , USHORT ModeIdIndex ,PXGI_HW_DEVICE_INFO HwDeviceExtension,
5179 USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5185 if ( ModeNo > 0x13 )
5187 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5188 CRT1Index &= IndexMask ;
5189 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5192 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5193 XGI_SetCRT2FIFO(pVBInfo) ;
5194 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5196 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5198 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5201 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5202 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5206 /* --------------------------------------------------------------------- */
5207 /* Function : XGI_SetGroup1 */
5211 /* --------------------------------------------------------------------- */
5212 void XGI_SetGroup1( USHORT ModeNo , USHORT ModeIdIndex ,
5213 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5224 if ( ModeNo > 0x13 )
5226 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5227 CRT1Index &= IndexMask ;
5228 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5231 if ( ModeNo <= 0x13 )
5233 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5237 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5240 /* bainy change table name */
5241 if ( modeflag & HalfDCLK )
5243 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5244 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5245 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5246 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5247 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5248 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5249 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5250 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5251 tempcx = tempcx >> 1 ;
5252 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5255 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5257 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5258 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5259 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5260 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5262 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5263 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5264 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5270 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5271 tempcx = pVBInfo->VGAHT / 2 ;
5273 temp = tempbx & 0x00FF ;
5275 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5279 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5280 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5281 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5282 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5283 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5284 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5285 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5286 pushbx = pVBInfo->VGAHDE + 16 ;
5287 tempcx = tempcx >> 1 ;
5288 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5291 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5293 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5294 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5295 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5296 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5298 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5299 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5300 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5305 if ( tempcx > pVBInfo->VGAHT )
5306 tempcx = pVBInfo->VGAHT ;
5308 temp = tempbx & 0x00FF ;
5309 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5312 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5314 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5315 tempax |= ( tempbx & 0xFF00 ) ;
5316 temp = ( tempax & 0xFF00 ) >> 8 ;
5317 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5318 temp = tempcx & 0x00FF ;
5319 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5320 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5321 temp = tempcx & 0x00FF ;
5323 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5325 if ( pVBInfo->VBInfo & 0x0C )
5331 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5332 tempbx = pVBInfo->VGAVDE - 1 ;
5333 temp = tempbx & 0x00FF ;
5334 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5335 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5336 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5337 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5339 tempax = pVBInfo->VGAVDE ;
5340 tempbx = pVBInfo->VGAVDE ;
5341 tempcx = pVBInfo->VGAVT ;
5342 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5343 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5345 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5347 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5348 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5356 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5361 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5362 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5365 temp = tempbx & 0x00FF ;
5366 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5367 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5368 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5369 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5372 if ( modeflag & DoubleScanMode )
5375 if ( modeflag & HalfDCLK )
5378 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5382 /* --------------------------------------------------------------------- */
5383 /* Function : XGI_SetLockRegs */
5387 /* --------------------------------------------------------------------- */
5388 void XGI_SetLockRegs( USHORT ModeNo , USHORT ModeIdIndex ,
5389 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5401 if ( ModeNo <= 0x13 )
5403 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5404 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5408 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5409 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5410 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5411 CRT1Index &= IndexMask;
5414 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5419 temp = 0xFF ; /* set MAX HT */
5420 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5421 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5425 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5426 modeflag |= Charx8Dot ;
5428 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5430 if ( modeflag & HalfDCLK )
5431 tempax = tempax >> 1 ;
5433 tempax = ( tempax / tempcx ) - 1 ;
5434 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5435 temp = tempax & 0x00FF ;
5436 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5438 temp = ( tempbx & 0xFF00 ) >> 8 ;
5440 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5442 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5445 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5447 if ( pVBInfo->VBType & VB_XGI301LV )
5449 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5461 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5462 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5464 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5465 { /* 030226 bainy */
5466 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5467 tempax = pVBInfo->VGAHT ;
5469 tempax = XGI_GetVGAHT2( pVBInfo) ;
5472 if ( tempax >= pVBInfo->VGAHT )
5474 tempax = pVBInfo->VGAHT ;
5477 if ( modeflag & HalfDCLK )
5479 tempax = tempax >> 1 ;
5482 tempax = ( tempax / tempcx ) - 5 ;
5483 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5484 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5486 temp = ( tempbx & 0x00FF ) - 1 ;
5487 if ( !( modeflag & HalfDCLK ) )
5490 if ( pVBInfo->TVInfo & TVSimuMode )
5493 if ( ModeNo > 0x13 )
5500 /* tempcx = tempbx & 0x00FF ; */
5501 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5502 tempcx = ( tempcx + tempbx ) >> 1 ;
5503 temp = ( tempcx & 0x00FF ) + 2 ;
5505 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5508 if ( !( modeflag & HalfDCLK ) )
5510 if ( ( modeflag & Charx8Dot ) )
5513 if ( pVBInfo->VGAHDE >= 800 )
5522 if ( !( modeflag & HalfDCLK ) )
5525 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5527 if( pVBInfo->VGAHDE >= 800 )
5530 if ( pVBInfo->ModeType == ModeEGA )
5532 if ( pVBInfo->VGAVDE == 1024 )
5535 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5542 if ( pVBInfo->VGAHDE >= 1280 )
5544 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5546 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5558 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5559 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5561 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5563 if ( pVBInfo->TVInfo & TVSimuMode )
5565 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5567 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5568 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5571 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5573 if ( pVBInfo->TVInfo & SetNTSCTV )
5575 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5576 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5580 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5581 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5582 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5586 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5588 if ( pVBInfo->TVInfo & SetNTSCTV )
5590 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5591 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5595 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5596 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5597 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5601 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5603 if ( pVBInfo->TVInfo & SetNTSCTV )
5605 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5606 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5610 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5611 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5617 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5618 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5619 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5621 tempbx = pVBInfo->VGAVT ;
5624 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5626 if ( tempbx == 357 )
5628 if ( tempbx == 360 )
5630 if ( tempbx == 375 )
5632 if ( tempbx == 405 )
5634 if ( tempbx == 525 )
5639 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5641 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5643 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5645 if ( tempbx == 350 )
5647 if ( tempbx == 480 )
5653 temp = tempbx & 0x00FF ;
5655 temp = tempbx & 0x00FF ;
5656 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5659 temp = tempbx & 0x00FF ;
5660 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5662 if ( tempbx & 0x0100 )
5669 if ( modeflag & DoubleScanMode )
5674 if ( tempbx & 0x0200 )
5679 temp = ( tempax & 0xFF00 ) >> 8 ;
5680 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5682 if ( tempbx & 0x0400 )
5687 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5690 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
5691 tempax = tempax >> 2 ;
5692 push1 = tempax ; /* push ax */
5694 if ( resinfo != 0x09 )
5696 tempax = tempax << 1 ;
5700 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5702 if ( pVBInfo->VBType & VB_XGI301LV )
5704 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
5708 if ( pVBInfo->TVInfo & TVSimuMode )
5710 if ( pVBInfo->TVInfo & SetPALTV )
5712 if ( pVBInfo->VBType & VB_XGI301LV )
5714 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5728 if ( pVBInfo->TVInfo & TVSimuMode )
5730 if ( pVBInfo->TVInfo & SetPALTV )
5732 if ( pVBInfo->VBType & VB_XGI301LV )
5734 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5743 tempax = tempax >> 2 ;
5746 push1 = tempax ; /* push ax */
5748 if ( ( pVBInfo->TVInfo & SetPALTV ) )
5750 if ( tempbx <= 513 )
5752 if ( tempax >= 513 )
5759 temp = tempbx & 0x00FF ;
5760 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5762 temp = tempbx & 0x00FF ;
5763 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5765 if ( tempbx & 0x0100 )
5770 if ( tempbx & 0x0200 )
5772 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
5777 if ( tempbx & 0x0100 )
5782 if ( tempbx & 0x0200 )
5787 if ( tempbx & 0x0400 )
5792 tempbx = push1 ; /* pop ax */
5793 temp = tempbx & 0x00FF ;
5795 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
5797 if ( tempbx & 0x0010 )
5802 temp = tempcx & 0x00FF ;
5803 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
5804 temp = ( tempcx & 0x0FF00 ) >> 8 ;
5805 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
5807 temp = ( tempax & 0xFF00 ) >> 8 ;
5809 temp = ( temp >> 1 ) & 0x09 ;
5811 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5814 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
5815 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
5816 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
5818 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
5823 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
5829 /* --------------------------------------------------------------------- */
5830 /* Function : XGI_SetGroup2 */
5834 /* --------------------------------------------------------------------- */
5835 void XGI_SetGroup2( USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex,
5836 PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5849 UCHAR *TimingPoint ;
5857 if ( ModeNo <= 0x13 )
5859 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5860 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5861 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5865 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5866 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5867 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
5872 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
5875 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
5878 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
5881 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5884 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5887 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
5890 tempax = ( tempax & 0xff00 ) >> 8 ;
5892 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
5893 TimingPoint = pVBInfo->NTSCTiming ;
5895 if ( pVBInfo->TVInfo & SetPALTV )
5897 TimingPoint = pVBInfo->PALTiming ;
5900 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5902 TimingPoint = pVBInfo->HiTVExtTiming ;
5904 if ( pVBInfo->VBInfo & SetInSlaveMode )
5905 TimingPoint = pVBInfo->HiTVSt2Timing ;
5907 if ( pVBInfo->SetFlag & TVSimuMode )
5908 TimingPoint = pVBInfo->HiTVSt1Timing ;
5910 if ( !(modeflag & Charx8Dot) )
5911 TimingPoint = pVBInfo->HiTVTextTiming ;
5914 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5916 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5917 TimingPoint = pVBInfo->YPbPr525iTiming ;
5919 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5920 TimingPoint = pVBInfo->YPbPr525pTiming ;
5922 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5923 TimingPoint = pVBInfo->YPbPr750pTiming ;
5926 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
5928 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
5931 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
5933 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
5936 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5938 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
5941 temp = pVBInfo->NewFlickerMode ;
5943 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
5945 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5948 if ( pVBInfo->TVInfo & SetPALTV )
5953 if ( pVBInfo->VDE <= tempax )
5955 tempax -= pVBInfo->VDE ;
5956 tempax = tempax >> 2 ;
5957 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
5959 temp = ( tempax & 0xFF00 ) >> 8 ;
5960 temp += ( USHORT )TimingPoint[ 0 ] ;
5962 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5964 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
5966 tempcx=pVBInfo->VGAHDE;
5967 if ( tempcx >= 1024 )
5969 temp = 0x17 ; /* NTSC */
5970 if ( pVBInfo->TVInfo & SetPALTV )
5971 temp = 0x19 ; /* PAL */
5976 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
5978 temp = ( tempax & 0xFF00 ) >> 8 ;
5979 temp += TimingPoint[ 1 ] ;
5981 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5983 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
5985 tempcx = pVBInfo->VGAHDE ;
5986 if ( tempcx >= 1024 )
5988 temp = 0x1D ; /* NTSC */
5989 if ( pVBInfo->TVInfo & SetPALTV )
5990 temp = 0x52 ; /* PAL */
5994 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
5998 tempcx = pVBInfo->HT ;
6000 if ( XGI_IsLCDDualLink( pVBInfo ) )
6001 tempcx = tempcx >> 1 ;
6004 temp = tempcx & 0x00FF ;
6005 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6007 temp = ( tempcx & 0xFF00 ) >> 8 ;
6008 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6010 tempcx = pVBInfo->HT >> 1 ;
6011 push1 = tempcx ; /* push cx */
6014 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6019 temp = tempcx & 0x00FF ;
6021 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6023 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6026 temp = tempbx & 0x00FF ;
6027 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6028 temp = ( tempbx & 0xFF00 ) >> 8 ;
6030 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6034 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6040 temp = ( tempbx & 0x00FF ) << 4 ;
6041 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6044 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6045 temp = tempcx & 0x00FF ;
6046 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6047 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6048 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6051 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6056 temp = tempcx & 0xFF ;
6058 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6060 tempcx = push1 ; /* pop cx */
6062 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6064 temp = tempcx & 0x00FF ;
6066 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6070 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6072 tempax = XGI_GetVGAHT2( pVBInfo) ;
6073 tempcx = tempax - 1 ;
6075 temp = tempcx & 0x00FF ;
6076 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6078 tempbx = pVBInfo->VDE ;
6080 if ( pVBInfo->VGAVDE == 360 )
6082 if ( pVBInfo->VGAVDE == 375 )
6084 if ( pVBInfo->VGAVDE == 405 )
6087 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6089 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6091 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6092 tempbx = tempbx >> 1 ;
6095 tempbx = tempbx >> 1 ;
6099 temp = tempbx & 0x00FF ;
6101 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6103 if ( pVBInfo->VBType & VB_XGI301LV )
6105 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6107 if ( pVBInfo->VBInfo & SetInSlaveMode )
6109 if ( ModeNo == 0x2f )
6116 if ( pVBInfo->VBInfo & SetInSlaveMode )
6118 if ( ModeNo == 0x2f )
6124 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6126 temp = ( tempcx & 0xFF00 ) >> 8 ;
6127 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6129 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6131 if ( pVBInfo->VBType & VB_XGI301LV )
6133 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6137 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6144 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6149 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6151 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6153 tempbx = pVBInfo->VDE ;
6154 tempcx = tempbx - 2 ;
6156 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6158 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6159 tempbx = tempbx >> 1 ;
6162 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6165 if( tempcx & 0x0400 )
6168 if ( tempbx & 0x0400 )
6171 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6174 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6175 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6176 temp = ( tempbx - 3 ) & 0x00FF ;
6177 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6180 tempbx = tempbx & 0x00FF ;
6182 if ( !( modeflag & HalfDCLK ) )
6184 tempcx = pVBInfo->VGAHDE ;
6185 if ( tempcx >= pVBInfo->HDE )
6194 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6195 if(pVBInfo->VGAHDE>=1024)
6198 if(pVBInfo->VGAHDE>=1280)
6201 tempbx=tempbx&0xDFFF;
6206 if ( !( tempbx & 0x2000 ) )
6208 if ( modeflag & HalfDCLK )
6210 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6214 tempeax = pVBInfo->VGAHDE ;
6215 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6216 longtemp = tempeax * tempebx ;
6217 tempecx = tempcx & 0x00FF ;
6218 longtemp = longtemp / tempecx ;
6221 tempecx = 8 * 1024 ;
6223 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6225 tempecx = tempecx * 8 ;
6228 longtemp = longtemp * tempecx ;
6229 tempecx = pVBInfo->HDE ;
6230 temp2 = longtemp % tempecx ;
6231 tempeax = longtemp / tempecx ;
6237 tempax = ( USHORT )tempeax ;
6240 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6242 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6247 tempbx =( USHORT )( ( ( tempeax & 0x0000FF00 ) & 0x1F00 ) | ( tempbx & 0x00FF ) ) ;
6248 tempax =( USHORT )( ( ( tempeax & 0x000000FF ) << 8 ) | ( tempax & 0x00FF ) ) ;
6249 temp = ( tempax & 0xFF00 ) >> 8 ;
6253 temp = ( tempax & 0x00FF ) >> 8 ;
6256 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6257 temp = ( tempbx & 0xFF00 ) >> 8 ;
6258 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6259 temp = tempcx & 0x00FF ;
6261 if ( tempbx & 0x2000 )
6264 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6267 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6268 if ( pVBInfo->TVInfo & SetPALTV )
6279 temp = tempbx & 0x00FF ;
6280 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6281 temp = tempcx & 0x00FF ;
6282 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6284 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6286 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6288 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6292 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6295 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6299 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6300 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6301 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , ( USHORT )( temp - 3 ) ) ;
6303 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6305 if ( pVBInfo->TVInfo & NTSC1024x768 )
6307 TimingPoint = XGI_NTSC1024AdjTime ;
6308 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6310 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6312 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6316 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6317 if ( pVBInfo->VBType & VB_XGI301C )
6319 if ( pVBInfo->TVInfo & SetPALMTV )
6320 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6323 if ( pVBInfo->TVInfo & SetPALMTV )
6325 tempax = ( UCHAR )XGINew_GetReg1( pVBInfo->Part2Port , 0x01 ) ;
6327 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6329 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6330 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6333 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6335 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6337 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6341 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6348 /* --------------------------------------------------------------------- */
6349 /* Function : XGI_SetLCDRegs */
6353 /* --------------------------------------------------------------------- */
6354 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
6370 XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6373 if ( ModeNo <= 0x13 )
6375 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6376 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6380 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6381 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6382 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6383 CRT1Index &= IndexMask ;
6386 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6391 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6393 if ( XGI_IsLCDDualLink( pVBInfo ) )
6394 tempbx = tempbx >> 1 ;
6397 temp = tempbx & 0x00FF ;
6398 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6399 temp = ( tempbx & 0xFF00 ) >> 8 ;
6401 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6404 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6406 if ( pVBInfo->ModeType == ModeEGA )
6408 if ( pVBInfo->VGAHDE >= 1024 )
6411 if ( pVBInfo->LCDInfo & LCDVESATiming )
6417 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6418 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6421 temp = tempbx & 0x00FF ;
6422 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6423 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6424 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6426 tempcx = pVBInfo->VT - 1 ;
6427 push2 = tempcx + 1 ;
6428 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6429 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6430 temp = ( tempcx & 0xFF00 ) >> 8 ;
6432 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6433 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6434 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6435 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6436 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6438 /* Customized LCDB Des no add */
6440 LCDBDesPtr = ( XGI_LCDDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
6441 tempah = pVBInfo->LCDResInfo ;
6442 tempah &= PanelResInfo ;
6444 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6449 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6454 else if ( tempah == Panel1400x1050 )
6465 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6467 tempbx = pVBInfo->HDE ;
6468 tempcx = pVBInfo->VDE ;
6472 tempax = pVBInfo->VT ;
6473 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6474 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6475 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6476 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6477 tempbx = pVBInfo->LCDVDES ;
6480 if ( tempcx >= tempax )
6481 tempcx -= tempax ; /* lcdvdes */
6483 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6484 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6485 temp = tempcx & 0x00FF ;
6486 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6487 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6488 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6490 tempah = tempah << 3 ;
6492 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6495 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6497 tempax = pVBInfo->VT ;
6498 tempbx = pVBInfo->LCDVRS ;
6500 /* if ( SetLCD_Info & EnableScalingLCD ) */
6502 if ( tempcx >= tempax )
6505 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6506 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6507 temp = ( tempbx & 0xFF00 ) >> 8 ;
6509 temp |= ( tempcx & 0x000F ) ;
6510 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6512 tempax = pVBInfo->HT ;
6513 tempbx = pVBInfo->LCDHDES ;
6516 if ( XGI_IsLCDDualLink( pVBInfo ) )
6518 tempax = tempax >> 1 ;
6519 tempbx = tempbx >> 1 ;
6520 tempcx = tempcx >> 1 ;
6523 if ( pVBInfo->VBType & VB_XGI302LV )
6526 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6531 if ( tempcx >= tempax )
6534 temp = tempbx & 0x00FF ;
6535 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6536 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6537 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6538 temp = tempcx & 0x00FF ;
6539 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6540 temp = ( tempcx & 0xFF00 ) >> 8 ;
6541 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6544 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6546 tempax = pVBInfo->HT ;
6547 tempbx = pVBInfo->LCDHRS ;
6548 /* if ( SetLCD_Info & EnableScalingLCD) */
6549 if ( XGI_IsLCDDualLink( pVBInfo) )
6551 tempax = tempax >> 1 ;
6552 tempbx = tempbx >> 1 ;
6553 tempcx = tempcx >> 1 ;
6556 if ( pVBInfo->VBType & VB_XGI302LV )
6561 if ( tempcx >= tempax )
6564 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6565 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6567 temp = ( tempbx & 0xFF00 ) >> 8 ;
6569 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6570 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6571 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6573 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6575 if ( pVBInfo->VGAVDE == 525 )
6577 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6584 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6585 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6588 if ( pVBInfo->VGAVDE == 420 )
6590 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6596 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6602 /* --------------------------------------------------------------------- */
6603 /* Function : XGI_GetTap4Ptr */
6605 /* Output : di -> Tap4 Reg. Setting Pointer */
6607 /* --------------------------------------------------------------------- */
6608 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo)
6614 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6618 tempax = pVBInfo->VGAHDE ;
6619 tempbx = pVBInfo->HDE ;
6623 tempax = pVBInfo->VGAVDE ;
6624 tempbx = pVBInfo->VDE ;
6627 if ( tempax < tempbx )
6628 return &EnlargeTap4Timing[ 0 ] ;
6629 else if( tempax == tempbx )
6630 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6632 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6634 if ( pVBInfo->TVInfo & SetPALTV )
6635 Tap4TimingPtr = PALTap4Timing ;
6638 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6640 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6641 Tap4TimingPtr = YPbPr525iTap4Timing ;
6642 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6643 Tap4TimingPtr = YPbPr525pTap4Timing ;
6644 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6645 Tap4TimingPtr = YPbPr750pTap4Timing ;
6648 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6649 Tap4TimingPtr = HiTVTap4Timing ;
6652 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6654 if ( Tap4TimingPtr[ i ].DE == tempax )
6658 return &Tap4TimingPtr[ i ] ;
6662 /* --------------------------------------------------------------------- */
6663 /* Function : XGI_SetTap4Regs */
6667 /* --------------------------------------------------------------------- */
6668 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo)
6673 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6675 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6679 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6680 #else /* Tap4 Setting */
6682 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6683 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6684 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6686 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6688 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6689 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6690 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6693 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6694 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
6696 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
6700 /* --------------------------------------------------------------------- */
6701 /* Function : XGI_SetGroup3 */
6705 /* --------------------------------------------------------------------- */
6706 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
6714 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6718 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6722 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
6723 if(pVBInfo->TVInfo&SetPALTV)
6725 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6726 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6730 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
6731 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
6734 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
6739 if(pVBInfo->TVInfo&SetPALMTV)
6741 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6742 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6743 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
6746 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
6748 if(pVBInfo->TVInfo & SetYPbPrMode525i)
6752 tempdi=pVBInfo->HiTVGroup3Data;
6753 if(pVBInfo->SetFlag&TVSimuMode)
6755 tempdi=pVBInfo->HiTVGroup3Simu;
6756 if(!(modeflag&Charx8Dot))
6758 tempdi=pVBInfo->HiTVGroup3Text;
6762 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6764 tempdi=pVBInfo->Ren525pGroup3;
6766 if(pVBInfo->TVInfo & SetYPbPrMode750p)
6768 tempdi=pVBInfo->Ren750pGroup3;
6771 for(i=0;i<=0x3E;i++)
6773 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
6775 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
6777 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6779 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
6784 } /* {end of XGI_SetGroup3} */
6787 /* --------------------------------------------------------------------- */
6788 /* Function : XGI_SetGroup4 */
6792 /* --------------------------------------------------------------------- */
6793 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
6807 if ( ModeNo <= 0x13 )
6809 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6813 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6816 temp = pVBInfo->RVBHCFACT ;
6817 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
6819 tempbx = pVBInfo->RVBHCMAX ;
6820 temp = tempbx & 0x00FF ;
6821 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
6822 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
6823 tempcx = pVBInfo->VGAHT - 1 ;
6824 temp = tempcx & 0x00FF ;
6825 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
6827 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
6830 tempcx = pVBInfo->VGAVT - 1 ;
6831 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6836 temp = tempcx & 0x00FF ;
6837 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
6838 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
6839 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
6840 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
6841 tempcx = pVBInfo->VBInfo ;
6842 tempbx = pVBInfo->VGAHDE ;
6844 if ( modeflag & HalfDCLK )
6846 tempbx = tempbx >> 1 ;
6849 if ( XGI_IsLCDDualLink( pVBInfo ) )
6850 tempbx = tempbx >> 1 ;
6852 if(tempcx&SetCRT2ToHiVisionTV)
6860 else if(tempcx&SetCRT2ToTV)
6869 if(pVBInfo->VBInfo&SetCRT2ToLCD)
6877 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6880 if ( pVBInfo->VGAHDE == 1280 )
6882 if ( pVBInfo->VGAHDE == 1024 )
6885 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
6887 tempebx = pVBInfo->VDE ;
6889 if ( tempcx & SetCRT2ToHiVisionTV )
6891 if ( !( temp & 0xE000 ) )
6892 tempbx = tempbx >> 1 ;
6895 tempcx = pVBInfo->RVBHRS ;
6896 temp = tempcx & 0x00FF ;
6897 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
6899 tempeax = pVBInfo->VGAVDE ;
6903 if ( tempeax <= tempebx )
6905 tempcx=(tempcx&(~0x4000));
6906 tempeax = pVBInfo->VGAVDE ;
6910 tempeax -= tempebx ;
6914 templong = ( tempeax * 256 * 1024 ) % tempebx ;
6915 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
6918 if ( templong != 0 )
6924 temp = ( USHORT )( tempebx & 0x000000FF ) ;
6925 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
6927 temp = ( USHORT )( ( tempebx & 0x0000FF00 ) >> 8 ) ;
6928 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
6929 tempbx = ( USHORT )( tempebx >> 16 ) ;
6930 temp = tempbx & 0x00FF ;
6932 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
6933 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
6936 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6939 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
6940 tempax = pVBInfo->VGAHDE ;
6941 if ( modeflag & HalfDCLK )
6943 tempax = tempax >> 1 ;
6946 if ( XGI_IsLCDDualLink( pVBInfo ) )
6947 tempax = tempax >> 1 ;
6949 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6950 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
6957 if ( pVBInfo->VGAHDE > 800 )
6959 if ( pVBInfo->VGAHDE == 1024 )
6960 tempax = ( tempax * 25 / 32 ) - 1 ;
6962 tempax = ( tempax * 20 / 32 ) - 1 ;
6968 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
6970 if ( pVBInfo->VBType & VB_XGI301LV )
6972 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6974 if ( pVBInfo->VGAHDE > 800 )
6976 if ( pVBInfo->VGAHDE == 1024 )
6977 tempax = ( tempax * 25 / 32 ) - 1 ;
6979 tempax = ( tempax * 20 / 32 ) - 1 ;
6985 if ( pVBInfo->VGAHDE > 800 )
6987 if ( pVBInfo->VGAHDE == 1024 )
6988 tempax = ( tempax * 25 / 32 ) - 1 ;
6990 tempax = ( tempax * 20 / 32 ) - 1 ;
6996 temp = ( tempax & 0xFF00 ) >> 8 ;
6997 temp = ( ( temp & 0x0003 ) << 4 ) ;
6998 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
6999 temp = ( tempax & 0x00FF ) ;
7000 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7002 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7004 if ( pVBInfo->VGAHDE > 800 )
7006 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7011 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7013 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7016 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7017 temp &= ( ~0x0001 ) ;
7021 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7022 tempbx = pVBInfo->HT ;
7023 if ( XGI_IsLCDDualLink( pVBInfo ) )
7024 tempbx = tempbx >> 1 ;
7025 tempbx = ( tempbx >> 1 ) - 2 ;
7026 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7027 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7028 temp = tempbx & 0x00FF ;
7029 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7033 if ( pVBInfo->ISXPDOS == 0 )
7034 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7038 /* --------------------------------------------------------------------- */
7039 /* Function : XGI_SetGroup5 */
7043 /* --------------------------------------------------------------------- */
7044 void XGI_SetGroup5( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
7049 Pindex = pVBInfo->Part5Port ;
7050 Pdata = pVBInfo->Part5Port + 1 ;
7051 if ( pVBInfo->ModeType == ModeVGA )
7053 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7055 XGINew_EnableCRT2(pVBInfo) ;
7056 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7063 /* --------------------------------------------------------------------- */
7064 /* Function : XGI_GetLcdPtr */
7068 /* --------------------------------------------------------------------- */
7069 void* XGI_GetLcdPtr( USHORT BX , USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7079 XGI330_LCDDataTablStruct *tempdi = 0 ;
7084 if ( ModeNo <= 0x13 )
7086 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7087 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7091 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7092 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7095 tempal = tempal & 0x0f ;
7097 if ( tempbx <= 1 ) /* ExpLink */
7099 if ( ModeNo <= 0x13 )
7101 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7105 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7108 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7110 if ( ModeNo <= 0x13 )
7111 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7113 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7116 if ( tempbx & 0x01 )
7117 tempal = ( tempal >> 4 ) ;
7119 tempal = ( tempal & 0x0f ) ;
7122 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7124 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7126 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7127 tempcx = LCDDesDataLen2 ;
7128 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7129 tempcx = LVDSDesDataLen2 ;
7131 /* mov di, word ptr cs:LCDDataList[bx] */
7132 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7137 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7140 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7143 tempdi = XGI_EPLLCDDataPtr ;
7146 tempdi = XGI_EPLLCDDesDataPtr ;
7149 tempdi = XGI_LCDDataTable ;
7152 tempdi = XGI_LCDDesDataTable ;
7155 tempdi = XGI_EPLCHLCDRegPtr ;
7166 if ( tempdi == 0x00 ) /* OEMUtil */
7172 while( tempdi[ i ].PANELID != 0xff )
7174 tempdx = pVBInfo->LCDResInfo ;
7175 if ( tempbx & 0x0080 ) /* OEMUtil */
7177 tempbx &= ( ~0x0080 ) ;
7178 tempdx = pVBInfo->LCDTypeInfo ;
7181 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7182 tempdx &= ( ~PanelResInfo ) ;
7184 if ( tempdi[ i ].PANELID == tempdx )
7186 tempbx = tempdi[ i ].MASK ;
7187 tempdx = pVBInfo->LCDInfo ;
7189 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7190 tempdx |= SetLCDStdMode ;
7192 if ( modeflag & HalfDCLK )
7193 tempdx |= SetLCDLowResolution ;
7196 if ( tempbx == tempdi[ i ].CAP )
7204 switch( tempdi[ i ].DATAPTR )
7207 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7210 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7213 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7216 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7219 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7222 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7225 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7228 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7231 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7234 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7237 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7243 else if ( table == 1 )
7245 switch( tempdi[ i ].DATAPTR )
7248 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7251 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7254 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7257 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7260 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7263 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7266 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7269 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7272 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7275 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7278 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7284 else if ( table == 2 )
7286 switch( tempdi[ i ].DATAPTR )
7289 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7292 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7295 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7298 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7301 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7304 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7307 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7310 return &XGI_LVDSNoScalingData[ tempal ] ;
7313 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7316 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7319 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7322 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7325 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7331 else if ( table == 3 )
7333 switch( tempdi[ i ].DATAPTR )
7336 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7339 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7342 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7345 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7348 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7351 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7354 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7357 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7360 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7363 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7366 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7369 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7372 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7375 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7378 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7384 else if ( table == 4 )
7386 switch( tempdi[ i ].DATAPTR )
7389 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7392 return &XGI_StLCD1024x768Data[ tempal ] ;
7395 return &XGI_CetLCD1024x768Data[ tempal ] ;
7398 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7401 return &XGI_StLCD1280x1024Data[ tempal ] ;
7404 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7407 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7410 return &XGI_StLCD1400x1050Data[ tempal ] ;
7413 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7416 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7419 return &XGI_StLCD1600x1200Data[ tempal ] ;
7422 return &XGI_NoScalingData[ tempal ] ;
7425 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7428 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7431 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7434 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7437 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7440 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7443 return &XGI_NoScalingDatax75[ tempal ] ;
7449 else if ( table == 5 )
7451 switch( tempdi[ i ].DATAPTR )
7454 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7457 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7460 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7463 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7464 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7466 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7469 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7470 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7472 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7475 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7476 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7478 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7481 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7482 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7484 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7487 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7488 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7490 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7493 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7496 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7499 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7500 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7502 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7505 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7506 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7508 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7511 return &XGI_NoScalingDesData[ tempal ] ;
7514 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7517 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7520 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7523 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7524 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7526 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7529 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7530 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7532 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7535 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7536 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7538 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7541 return &XGI_NoScalingDesDatax75[ tempal ] ;
7547 else if ( table == 6 )
7549 switch( tempdi[ i ].DATAPTR )
7552 return &XGI_CH7017LV1024x768[ tempal ] ;
7555 return &XGI_CH7017LV1400x1050[ tempal ] ;
7565 /* --------------------------------------------------------------------- */
7566 /* Function : XGI_GetTVPtr */
7570 /* --------------------------------------------------------------------- */
7571 void* XGI_GetTVPtr (USHORT BX,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7573 USHORT i , tempdx , tempbx , tempal , modeflag , table ;
7574 XGI330_TVDataTablStruct *tempdi = 0 ;
7578 if ( ModeNo <= 0x13 )
7580 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7581 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7585 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7586 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7589 tempal = tempal & 0x3f ;
7595 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7596 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7598 tempdi = XGI_EPLCHTVCRT1Ptr;
7602 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7603 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7605 tempdi = XGI_EPLCHTVCRT1Ptr;
7609 tempdi = XGI_EPLCHTVDataPtr ;
7615 tempdi = XGI_TVDataTable ;
7621 tempdi = XGI_EPLCHTVRegPtr ;
7627 if ( tempdi == 0x00 ) /* OEMUtil */
7630 tempdx = pVBInfo->TVInfo ;
7632 if ( pVBInfo->VBInfo & SetInSlaveMode )
7633 tempdx = tempdx | SetTVLockMode ;
7635 if ( modeflag & HalfDCLK )
7636 tempdx = tempdx | SetTVLowResolution ;
7640 while( tempdi[ i ].MASK != 0xffff )
7642 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7647 if ( table == 0x00 ) /* 07/05/22 */
7650 else if ( table == 0x01 )
7653 else if ( table == 0x04 )
7655 switch( tempdi[ i ].DATAPTR )
7658 return &XGI_ExtPALData[ tempal ] ;
7661 return &XGI_ExtNTSCData[ tempal ] ;
7664 return &XGI_StPALData[ tempal ] ;
7667 return &XGI_StNTSCData[ tempal ] ;
7670 return &XGI_ExtHiTVData[ tempal ] ;
7673 return &XGI_St2HiTVData[ tempal ] ;
7676 return &XGI_ExtYPbPr525iData[ tempal ] ;
7679 return &XGI_ExtYPbPr525pData[ tempal ] ;
7682 return &XGI_ExtYPbPr750pData[ tempal ] ;
7685 return &XGI_StYPbPr525iData[ tempal ] ;
7688 return &XGI_StYPbPr525pData[ tempal ] ;
7691 return &XGI_StYPbPr750pData[ tempal ] ;
7693 case 12: /* avoid system hang */
7694 return &XGI_ExtNTSCData[ tempal ] ;
7697 return &XGI_St1HiTVData[ tempal ] ;
7703 else if( table == 0x02 )
7705 switch( tempdi[ i ].DATAPTR )
7708 return &XGI_CHTVUNTSCData[ tempal ] ;
7711 return &XGI_CHTVONTSCData[ tempal ] ;
7714 return &XGI_CHTVUPALData[ tempal ] ;
7717 return &XGI_CHTVOPALData[ tempal ] ;
7723 else if( table == 0x06 )
7730 /* --------------------------------------------------------------------- */
7731 /* Function : XGI_BacklightByDrv */
7733 /* Output : 1 -> Skip backlight control */
7735 /* --------------------------------------------------------------------- */
7736 BOOLEAN XGI_BacklightByDrv( PVB_DEVICE_INFO pVBInfo )
7740 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x3A ) ;
7741 if (tempah & BacklightControlBit)
7748 /* --------------------------------------------------------------------- */
7749 /* Function : XGI_FirePWDDisable */
7752 /* Description : Turn off VDD & Backlight : Fire disable procedure */
7753 /* --------------------------------------------------------------------- */
7755 void XGI_FirePWDDisable( PVB_DEVICE_INFO pVBInfo )
7757 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
7761 /* --------------------------------------------------------------------- */
7762 /* Function : XGI_FirePWDEnable */
7765 /* Description : Turn on VDD & Backlight : Fire enable procedure */
7766 /* --------------------------------------------------------------------- */
7767 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo )
7769 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
7773 /* --------------------------------------------------------------------- */
7774 /* Function : XGI_EnableGatingCRT */
7778 /* --------------------------------------------------------------------- */
7779 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7781 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
7785 /* --------------------------------------------------------------------- */
7786 /* Function : XGI_DisableGatingCRT */
7790 /* --------------------------------------------------------------------- */
7791 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7794 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
7798 /* --------------------------------------------------------------------- */
7799 /* Function : XGI_SetPanelDelay */
7803 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7804 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7805 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7806 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7807 /* --------------------------------------------------------------------- */
7808 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7812 index = XGI_GetLCDCapPtr(pVBInfo) ;
7815 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
7818 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
7821 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
7824 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
7828 /* --------------------------------------------------------------------- */
7829 /* Function : XGI_SetPanelPower */
7833 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
7834 /* = 0111b = 07h ; Backlight on, Power off */
7835 /* = 1011b = 0Bh ; Backlight off, Power on */
7836 /* = 1111b = 0Fh ; Backlight off, Power off */
7837 /* --------------------------------------------------------------------- */
7838 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7840 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7841 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
7843 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
7846 UCHAR XG21GPIODataTransfer(UCHAR ujDate)
7854 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
7855 ujRet |= (ujDate >> i) & 1;
7861 /*----------------------------------------------------------------------------*/
7863 /* bl[5] : LVDS signal */
7864 /* bl[1] : LVDS backlight */
7865 /* bl[0] : LVDS VDD */
7866 /*----------------------------------------------------------------------------*/
7867 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7871 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7872 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
7874 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7876 temp = XG21GPIODataTransfer(temp);
7878 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7882 /*----------------------------------------------------------------------------*/
7884 /* bl[5] : LVDS signal */
7885 /* bl[1] : LVDS backlight */
7886 /* bl[0] : LVDS VDD */
7887 /*----------------------------------------------------------------------------*/
7888 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7890 UCHAR CR4A,CRB4,temp;
7892 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7893 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
7895 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7899 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7900 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
7901 temp |= ((CRB4&0x04)<<3);
7904 /*----------------------------------------------------------------------------*/
7906 /* bl[5] : 1;LVDS signal on */
7907 /* bl[1] : 1;LVDS backlight on */
7908 /* bl[0] : 1:LVDS VDD on */
7909 /* bh: 100000b : clear bit 5, to set bit5 */
7910 /* 000010b : clear bit 1, to set bit1 */
7911 /* 000001b : clear bit 0, to set bit0 */
7912 /*----------------------------------------------------------------------------*/
7913 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7917 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7920 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7924 temp = (tempbl>>4)&0x02;
7926 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7930 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7932 temp = XG21GPIODataTransfer(temp);
7935 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
7938 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7941 USHORT tempbh0,tempbl0;
7952 temp = (tempbl>>4)&0x02;
7954 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7957 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
7959 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7963 tempbl <<= 2; /* GPIOC,GPIOD */
7964 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7965 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
7968 /* --------------------------------------------------------------------- */
7969 USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo)
7973 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
7974 if (index<sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct))
7981 /* --------------------------------------------------------------------- */
7982 /* Function : XGI_XG21SetPanelDelay */
7986 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7987 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7988 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7989 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7990 /* --------------------------------------------------------------------- */
7991 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7995 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
7997 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8000 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8003 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8006 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8009 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8018 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8019 if ( ModeNo <= 0x13 )
8021 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8022 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8023 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8027 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8028 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8029 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8032 if ( !( modeflag & Charx8Dot ) )
8038 if ( ModeNo > 0x13 )
8040 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8044 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8050 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8051 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8054 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8057 if ( ModeNo > 0x13 )
8059 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8060 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8062 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8071 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo)
8075 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8076 temp = ( temp & 1 ) << 6;
8077 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8078 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8082 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo)
8086 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8087 temp = ( temp & 3 ) << 6;
8088 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8089 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8093 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8095 UCHAR temp,Miscdata;
8101 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8102 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8105 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8107 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8108 temp &= LCDPolarity;
8109 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8111 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8113 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8114 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8115 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8117 XGI_SetXG21FPBits(pVBInfo);
8118 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8119 if ( ModeNo <= 0x13 )
8121 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8122 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8123 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8127 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8128 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8129 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8132 if (!( modeflag & Charx8Dot ))
8133 xres = xres * 8 / 9;
8135 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8137 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8138 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8142 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8144 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8145 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8147 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8148 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8150 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8152 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8154 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8155 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8159 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8161 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8162 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8164 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8165 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8167 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8169 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8170 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8172 if (!( modeflag & Charx8Dot ))
8174 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8177 /* HT SR0B[1:0] CR00 */
8178 value = ( LVDSHT >> 3 ) - 5;
8179 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8180 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8182 /* HBS SR0B[5:4] CR02 */
8183 value = ( LVDSHBS >> 3 ) - 1;
8184 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8185 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8187 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8188 value = ( LVDSHBE >> 3 ) - 1;
8189 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8190 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8191 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8193 /* HRS SR0B[7:6] CR04 */
8194 value = ( LVDSHRS >> 3 ) + 2;
8195 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8196 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8198 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8200 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8201 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8203 /* HRE SR0C[2] CR05[4:0] */
8204 value = ( LVDSHRE >> 3 ) + 2;
8205 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8206 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8208 /* Panel HRE SR2F[7:2] */
8210 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8212 /* VT SR0A[0] CR07[5][0] CR06 */
8213 value = LVDSVT - 2 ;
8214 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8215 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8216 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8217 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8219 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8220 value = LVDSVBS - 1 ;
8221 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8222 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8223 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8224 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8226 /* VBE SR0A[4] CR16 */
8227 value = LVDSVBE - 1;
8228 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8229 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8231 /* VRS SR0A[3] CR7[7][2] CR10 */
8232 value = LVDSVRS - 1 ;
8233 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8234 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8235 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8236 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8238 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8239 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8240 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8241 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8243 /* VRE SR0A[5] CR11[3:0] */
8244 value = LVDSVRE - 1;
8245 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8246 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8248 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8249 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8251 for ( temp=0, value = 0; temp < 3; temp++)
8254 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8255 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8256 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8260 if (!( modeflag & Charx8Dot ))
8262 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8263 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8264 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8266 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8267 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8269 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8275 /* no shadow case */
8276 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8278 UCHAR temp,Miscdata;
8284 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8285 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8288 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8289 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8290 temp &= LCDPolarity;
8291 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8293 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8295 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8296 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8297 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8299 XGI_SetXG27FPBits(pVBInfo);
8300 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8301 if ( ModeNo <= 0x13 )
8303 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8304 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8305 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8309 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8310 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8311 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8314 if (!( modeflag & Charx8Dot ))
8315 xres = xres * 8 / 9;
8317 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8319 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8320 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8324 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8326 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8327 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8329 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8330 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8332 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8334 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8336 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8337 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8341 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8343 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8344 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8346 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8347 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8349 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8351 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8352 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8354 if (!( modeflag & Charx8Dot ))
8356 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8359 /* HT SR0B[1:0] CR00 */
8360 value = ( LVDSHT >> 3 ) - 5;
8361 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8362 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8364 /* HBS SR0B[5:4] CR02 */
8365 value = ( LVDSHBS >> 3 ) - 1;
8366 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8367 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8369 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8370 value = ( LVDSHBE >> 3 ) - 1;
8371 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8372 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8373 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8375 /* HRS SR0B[7:6] CR04 */
8376 value = ( LVDSHRS >> 3 ) + 2;
8377 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8378 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8380 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8382 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8383 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8385 /* HRE SR0C[2] CR05[4:0] */
8386 value = ( LVDSHRE >> 3 ) + 2;
8387 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8388 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8390 /* Panel HRE SR2F[7:2] */
8392 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8394 /* VT SR0A[0] CR07[5][0] CR06 */
8395 value = LVDSVT - 2 ;
8396 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8397 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8398 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8399 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8401 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8402 value = LVDSVBS - 1 ;
8403 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8404 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8405 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8406 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8408 /* VBE SR0A[4] CR16 */
8409 value = LVDSVBE - 1;
8410 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8411 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8413 /* VRS SR0A[3] CR7[7][2] CR10 */
8414 value = LVDSVRS - 1 ;
8415 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8416 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8417 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8418 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8420 /* Panel VRS SR35[2:0] SR34[7:0] */
8421 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8422 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8424 /* VRE SR0A[5] CR11[3:0] */
8425 value = LVDSVRE - 1;
8426 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8427 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8429 /* Panel VRE SR3F[7:2] */
8430 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8432 for ( temp=0, value = 0; temp < 3; temp++)
8435 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8436 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8437 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8441 if (!( modeflag & Charx8Dot ))
8443 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8444 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8445 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8447 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8448 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8450 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8456 /* --------------------------------------------------------------------- */
8457 /* Function : XGI_IsLCDON */
8459 /* Output : 0 : Skip PSC Control */
8460 /* 1: Disable PSC */
8462 /* --------------------------------------------------------------------- */
8463 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo)
8467 tempax = pVBInfo->VBInfo ;
8468 if ( tempax & SetCRT2ToDualEdge )
8470 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8477 /* --------------------------------------------------------------------- */
8478 /* Function : XGI_EnablePWD */
8482 /* --------------------------------------------------------------------- */
8483 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo )
8488 index = XGI_GetLCDCapPtr(pVBInfo) ;
8489 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8490 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8491 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8492 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8493 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8494 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8495 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8499 /* --------------------------------------------------------------------- */
8500 /* Function : XGI_DisablePWD */
8504 /* --------------------------------------------------------------------- */
8505 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo )
8507 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8511 /* --------------------------------------------------------------------- */
8512 /* Function : XGI_DisableChISLCD */
8514 /* Output : 0 -> Not LCD Mode */
8516 /* --------------------------------------------------------------------- */
8517 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo)
8522 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8523 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8525 if ( tempbx & ( EnableChA | DisableChA ) )
8527 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8531 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8534 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8541 /* --------------------------------------------------------------------- */
8542 /* Function : XGI_EnableChISLCD */
8544 /* Output : 0 -> Not LCD mode */
8546 /* --------------------------------------------------------------------- */
8547 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo)
8553 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8554 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8556 if ( tempbx & ( EnableChA | DisableChA ) )
8558 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8562 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8565 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8572 /* --------------------------------------------------------------------- */
8573 /* Function : XGI_GetLCDCapPtr */
8577 /* --------------------------------------------------------------------- */
8578 USHORT XGI_GetLCDCapPtr( PVB_DEVICE_INFO pVBInfo )
8585 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8586 tempal = tempah & 0x0F ;
8587 tempah = tempah & 0xF0 ;
8589 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8591 while( tempbl != 0xFF )
8593 if ( tempbl & 0x80 ) /* OEMUtil */
8596 tempbl = tempbl & ~( 0x80 ) ;
8599 if ( tempal == tempbl )
8604 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8611 /* --------------------------------------------------------------------- */
8612 /* Function : XGI_GetLCDCapPtr1 */
8616 /* --------------------------------------------------------------------- */
8617 USHORT XGI_GetLCDCapPtr1( PVB_DEVICE_INFO pVBInfo )
8624 tempal = pVBInfo->LCDResInfo ;
8625 tempah = pVBInfo->LCDTypeInfo ;
8628 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
8630 while( tempbl != 0xFF )
8632 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
8638 if ( tempal == tempbl )
8642 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8645 if ( tempbl == 0xFF )
8647 pVBInfo->LCDResInfo = Panel1024x768 ;
8648 pVBInfo->LCDTypeInfo = 0 ;
8656 /* --------------------------------------------------------------------- */
8657 /* Function : XGI_GetLCDSync */
8661 /* --------------------------------------------------------------------- */
8662 void XGI_GetLCDSync( USHORT* HSyncWidth , USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo )
8666 Index = XGI_GetLCDCapPtr(pVBInfo) ;
8667 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
8668 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
8675 /* --------------------------------------------------------------------- */
8676 /* Function : XGI_EnableBridge */
8680 /* --------------------------------------------------------------------- */
8681 void XGI_EnableBridge( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
8686 if ( pVBInfo->SetFlag == Win9xDOSMode )
8688 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8690 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8693 else /* LVDS or CH7017 */
8698 if ( HwDeviceExtension->jChipType < XG40 )
8700 if ( !XGI_DisableChISLCD(pVBInfo) )
8702 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8704 if ( pVBInfo->LCDInfo & SetPWDEnable )
8706 XGI_EnablePWD( pVBInfo);
8710 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
8711 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8722 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
8723 XGI_SetPanelDelay( 1,pVBInfo ) ;
8731 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8733 if ( !( pVBInfo->SetFlag & DisableChA ) )
8735 if ( pVBInfo->SetFlag & EnableChA )
8737 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
8741 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
8743 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
8748 if ( !( pVBInfo->SetFlag & DisableChB ) )
8750 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
8752 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
8754 if ( pVBInfo->VBInfo & SetInSlaveMode )
8756 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
8759 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
8760 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
8763 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8765 if ( !( tempah & 0x80 ) )
8766 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8768 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
8772 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
8774 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
8775 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8777 if ( !XGI_DisableChISLCD(pVBInfo) )
8779 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8780 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
8782 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
8788 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
8792 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
8794 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8796 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8798 tempah = tempah & 0x40;
8799 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8800 tempah = tempah ^ 0xC0 ;
8802 if ( pVBInfo->SetFlag & DisableChB )
8805 if ( pVBInfo->SetFlag & DisableChA )
8808 if ( pVBInfo->SetFlag & EnableChB )
8811 if ( pVBInfo->SetFlag & EnableChA )
8818 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
8820 if ( pVBInfo->SetFlag & Win9xDOSMode )
8822 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8826 if ( !( pVBInfo->SetFlag & DisableChA ) )
8828 XGI_VBLongWait( pVBInfo) ;
8829 if ( !( pVBInfo->SetFlag & GatingCRT ) )
8831 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8832 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8833 XGI_VBLongWait( pVBInfo) ;
8839 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
8840 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
8844 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8845 if ( !( tempah & 0x80 ) )
8846 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8848 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
8849 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
8853 if ( HwDeviceExtension->jChipType < XG40 )
8855 if ( !XGI_EnableChISLCD(pVBInfo) )
8857 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
8859 if ( XGI_BacklightByDrv(pVBInfo) )
8866 if ( pVBInfo->LCDInfo & SetPWDEnable )
8868 XGI_FirePWDEnable(pVBInfo) ;
8872 XGI_SetPanelDelay( 2,pVBInfo ) ;
8874 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8877 tempbl = 0xFE ; /* turn on backlght */
8884 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
8889 /* --------------------------------------------------------------------- */
8890 /* Function : XGI_DisableBridge */
8894 /* --------------------------------------------------------------------- */
8895 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8902 if ( pVBInfo->SetFlag == Win9xDOSMode )
8906 if ( HwDeviceExtension->jChipType < XG40 )
8908 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8910 if ( !XGI_IsLCDON(pVBInfo) )
8912 if ( pVBInfo->LCDInfo & SetPWDEnable )
8913 XGI_EnablePWD( pVBInfo) ;
8916 pVBInfo->LCDInfo &= ~SetPWDEnable ;
8917 XGI_DisablePWD(pVBInfo) ;
8918 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8920 tempbx = 0xFE ; /* not 01h */
8925 tempbx = 0xF7 ; /* not 08h */
8928 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
8929 XGI_SetPanelDelay( 3,pVBInfo ) ;
8931 } /* end if(!XGI_IsLCDON(pVBInfo)) */
8937 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8939 if ( !XGI_IsLCDON(pVBInfo) )
8943 tempbx = XGINew_GetCH7005( 0x61 ) ;
8944 if ( tempbx < 0x01 ) //first time we power up
8945 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
8947 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
8953 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8956 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
8958 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8960 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8962 tempah = 0x7F; /* Disable Channel A */
8963 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
8964 tempah = 0xBF ; /* Disable Channel B */
8966 if ( pVBInfo->SetFlag & DisableChB )
8967 tempah &= 0xBF ; /* force to disable Cahnnel */
8969 if ( pVBInfo->SetFlag & DisableChA )
8970 tempah &= 0x7F ; /* Force to disable Channel B */
8975 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
8977 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8979 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
8980 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
8983 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
8985 if ( pVBInfo->SetFlag & GatingCRT )
8986 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8987 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
8990 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8992 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
8993 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
8996 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
8998 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
8999 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9001 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9002 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9003 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9005 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9006 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9008 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9009 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9010 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9011 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9016 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9018 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9019 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9020 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9023 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9024 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9030 if ( HwDeviceExtension->jChipType < XG40 )
9032 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9034 if ( pVBInfo->LCDInfo & SetPWDEnable )
9036 if ( pVBInfo->LCDInfo & SetPWDEnable )
9037 XGI_BacklightByDrv(pVBInfo) ;
9040 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9041 if ( pVBInfo->VBType & VB_XGI301LV )
9053 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9059 /* --------------------------------------------------------------------- */
9060 /* Function : XGI_GetTVPtrIndex */
9063 /* Description : bx 0 : ExtNTSC */
9075 /* --------------------------------------------------------------------- */
9076 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo )
9080 if ( pVBInfo->TVInfo & SetPALTV )
9082 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9084 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9086 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9088 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9090 if ( pVBInfo->TVInfo & TVSimuMode )
9097 /* --------------------------------------------------------------------- */
9098 /* Function : XGI_OEM310Setting */
9101 /* Description : Customized Param. for 301 */
9102 /* --------------------------------------------------------------------- */
9103 void XGI_OEM310Setting( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9105 if ( pVBInfo->SetFlag & Win9xDOSMode )
9109 XGI_SetDelayComp(pVBInfo) ;
9111 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9112 XGI_SetLCDCap(pVBInfo) ;
9114 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9117 XGI_SetPhaseIncr(pVBInfo) ;
9118 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9119 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9121 if ( pVBInfo->VBType&VB_XGI301)
9122 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9127 /* --------------------------------------------------------------------- */
9128 /* Function : XGI_SetDelayComp */
9132 /* --------------------------------------------------------------------- */
9133 void XGI_SetDelayComp( PVB_DEVICE_INFO pVBInfo )
9141 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9143 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9148 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9149 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9151 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9152 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9154 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9155 tempbl = tempbl >> 4 ;
9157 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9158 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9160 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9161 tempbl = CRT2Delay2 ;
9163 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9165 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9166 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9168 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9174 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9176 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9182 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9187 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9190 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9194 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9196 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9198 tempah = tempah << 4 ;
9199 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9205 /* --------------------------------------------------------------------- */
9206 /* Function : XGI_SetLCDCap */
9210 /* --------------------------------------------------------------------- */
9211 void XGI_SetLCDCap( PVB_DEVICE_INFO pVBInfo )
9215 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9217 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9219 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9220 { /* 301LV/302LV only */
9221 /* Set 301LV Capability */
9222 XGINew_SetReg1( pVBInfo->Part4Port , 0x24 , ( UCHAR )( tempcx & 0x1F ) ) ;
9225 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~( ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) >> 8 ) , ( USHORT )( ( tempcx & ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) ) >> 8 ) ) ;
9228 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9230 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9231 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9232 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9233 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9235 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9237 if ( tempcx & EnableSpectrum )
9238 SetSpectrum( pVBInfo) ;
9241 else /* LVDS,CH7017 */
9242 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9246 /* --------------------------------------------------------------------- */
9247 /* Function : XGI_SetLCDCap_A */
9251 /* --------------------------------------------------------------------- */
9252 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9256 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9258 if ( temp & LCDRGB18Bit )
9260 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x20 | ( tempcx & 0x00C0 ) ) ) ; /* Enable Dither */
9261 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9265 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x30 | ( tempcx & 0x00C0 ) ) ) ;
9266 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9270 if ( tempcx & EnableLCD24bpp ) // 24bits
9272 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x30|(tempcx&0x00C0)) );
9273 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9277 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x20|(tempcx&0x00C0)) );//Enable Dither
9278 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9284 /* --------------------------------------------------------------------- */
9285 /* Function : XGI_SetLCDCap_B */
9286 /* Input : cx -> LCD Capability */
9289 /* --------------------------------------------------------------------- */
9290 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9292 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9293 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x0c ) ) ;
9295 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x18 ) ) ; /* Enable Dither */
9299 /* --------------------------------------------------------------------- */
9300 /* Function : SetSpectrum */
9304 /* --------------------------------------------------------------------- */
9305 void SetSpectrum( PVB_DEVICE_INFO pVBInfo )
9309 index = XGI_GetLCDCapPtr(pVBInfo) ;
9311 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9312 XGI_LongWait(pVBInfo) ;
9313 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9314 XGI_LongWait(pVBInfo) ;
9316 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9317 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9318 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9319 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9320 XGI_LongWait(pVBInfo) ;
9321 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9325 /* --------------------------------------------------------------------- */
9326 /* Function : XGI_SetAntiFlicker */
9329 /* Description : Set TV Customized Param. */
9330 /* --------------------------------------------------------------------- */
9331 void XGI_SetAntiFlicker( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
9338 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9341 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9344 if ( ModeNo <= 0x13 )
9346 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9350 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9354 tempah = TVAntiFlickList[ tempbx ] ;
9355 tempah = tempah << 4 ;
9357 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9361 /* --------------------------------------------------------------------- */
9362 /* Function : XGI_SetEdgeEnhance */
9366 /* --------------------------------------------------------------------- */
9367 void XGI_SetEdgeEnhance( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
9375 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9378 if ( ModeNo <= 0x13 )
9380 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9384 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9388 tempah = TVEdgeList[ tempbx ] ;
9389 tempah = tempah << 5 ;
9391 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9395 /* --------------------------------------------------------------------- */
9396 /* Function : XGI_SetPhaseIncr */
9400 /* --------------------------------------------------------------------- */
9401 void XGI_SetPhaseIncr( PVB_DEVICE_INFO pVBInfo )
9410 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9411 tempData = TVPhaseList[ tempbx ] ;
9413 XGINew_SetReg1( pVBInfo->Part2Port , 0x31 , ( USHORT )( tempData & 0x000000FF ) ) ;
9414 XGINew_SetReg1( pVBInfo->Part2Port , 0x32 , ( USHORT )( ( tempData & 0x0000FF00 ) >> 8 ) ) ;
9415 XGINew_SetReg1( pVBInfo->Part2Port , 0x33 , ( USHORT )( ( tempData & 0x00FF0000 ) >> 16 ) ) ;
9416 XGINew_SetReg1( pVBInfo->Part2Port , 0x34 , ( USHORT )( ( tempData & 0xFF000000 ) >> 24 ) ) ;
9420 /* --------------------------------------------------------------------- */
9421 /* Function : XGI_SetYFilter */
9425 /* --------------------------------------------------------------------- */
9426 void XGI_SetYFilter( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9436 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9442 filterPtr = NTSCYFilter1 ;
9446 filterPtr = PALYFilter1 ;
9452 filterPtr = PALMYFilter1 ;
9456 filterPtr = PALNYFilter1 ;
9461 filterPtr = NTSCYFilter2 ;
9465 filterPtr = PALMYFilter2 ;
9469 filterPtr = PALNYFilter2 ;
9473 filterPtr = PALYFilter2 ;
9480 if ( ModeNo <= 0x13 )
9481 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9483 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9490 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9492 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9493 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9494 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9495 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9499 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9500 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9501 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9502 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9505 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9507 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9508 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9509 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9514 /* --------------------------------------------------------------------- */
9515 /* Function : XGI_GetTVPtrIndex2 */
9517 /* Output : bx 0 : NTSC */
9521 /* 4 : NTSC1024x768 */
9522 /* 5 : PAL-M 1024x768 */
9524 /* cl 0 : YFilter1 */
9527 /* 1 : 301B/302B/301LV/302LV */
9529 /* --------------------------------------------------------------------- */
9530 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo)
9536 if ( pVBInfo->TVInfo & SetPALTV )
9539 if ( pVBInfo->TVInfo & SetPALMTV )
9542 if ( pVBInfo->TVInfo & SetPALNTV )
9545 if ( pVBInfo->TVInfo & NTSC1024x768 )
9548 if ( pVBInfo->TVInfo & SetPALMTV )
9552 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9554 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9561 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9566 /* --------------------------------------------------------------------- */
9567 /* Function : XGI_SetCRT2ModeRegs */
9570 /* Description : Origin code for crt2group */
9571 /* --------------------------------------------------------------------- */
9572 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
9579 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9581 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9583 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9584 tempah &= ~0x10 ; /* BTRAMDAC */
9585 tempah |= 0x40 ; /* BTRAM */
9587 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9589 tempah=0x40; /* BTDRAM */
9590 if ( ModeNo > 0x13 )
9592 tempcl = pVBInfo->ModeType ;
9596 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9602 if ( pVBInfo->VBInfo & SetInSlaveMode )
9603 tempah ^= 0x50 ; /* BTDAC */
9608 if ( pVBInfo->VBInfo & DisableCRT2Display )
9613 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9614 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9616 tempcl = pVBInfo->ModeType ;
9617 if ( ModeNo > 0x13 )
9620 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
9622 tempah=(0x008>>tempcl) ;
9633 if ( pVBInfo->VBInfo & SetInSlaveMode )
9635 tempah = ( tempah ^ 0x050 ) ;
9640 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9644 if ( pVBInfo->VBInfo & DisableCRT2Display )
9645 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9651 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9653 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
9657 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9661 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9667 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9672 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
9675 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9677 tempah = tempah ^ 0x05 ;
9678 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
9679 tempah = tempah ^ 0x01 ;
9682 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9684 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9687 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9691 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9694 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9696 tempah &= ( ~0x08 ) ;
9697 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
9703 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9705 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
9708 if ( ModeNo > 0x13 )
9710 if ( pVBInfo->VBInfo & DriverMode )
9711 tempah = tempah ^ 0x20 ;
9716 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
9719 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9722 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9724 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
9726 if ( pVBInfo->TVInfo & RPLLDIV2XO )
9731 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
9734 if ( pVBInfo->LCDResInfo == Panel1280x960 )
9737 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
9740 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9745 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9748 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9749 tempah |= 0x04 ; /* shampoo 0129 */
9752 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
9755 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9757 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9761 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
9765 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9767 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9770 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
9775 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9778 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9782 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
9784 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9786 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9788 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
9789 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
9795 /* --------------------------------------------------------------------- */
9796 /* Function : XGI_CloseCRTC */
9800 /* --------------------------------------------------------------------- */
9801 void XGI_CloseCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9807 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9814 /* --------------------------------------------------------------------- */
9815 /* Function : XGI_OpenCRTC */
9819 /* --------------------------------------------------------------------- */
9820 void XGI_OpenCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9830 /* --------------------------------------------------------------------- */
9831 /* Function : XGI_GetRAMDAC2DATA */
9835 /* --------------------------------------------------------------------- */
9836 void XGI_GetRAMDAC2DATA(USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
9847 pVBInfo->RVBHCMAX = 1 ;
9848 pVBInfo->RVBHCFACT = 1 ;
9850 if ( ModeNo <= 0x13 )
9852 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9853 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
9854 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
9855 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
9856 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
9860 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9861 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
9862 CRT1Index &= IndexMask ;
9863 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 0 ] ;
9864 temp2 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] ;
9865 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
9866 tempbx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 8 ] ;
9867 tempcx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] << 8 ;
9869 tempcx = tempcx << 2 ;
9871 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
9881 if ( modeflag & Charx8Dot )
9886 pVBInfo->VGAHT = tempax ;
9887 pVBInfo->HT = tempax ;
9889 pVBInfo->VGAVT = tempbx ;
9890 pVBInfo->VT = tempbx ;
9895 /* --------------------------------------------------------------------- */
9896 /* Function : XGI_GetColorDepth */
9900 /* --------------------------------------------------------------------- */
9901 USHORT XGI_GetColorDepth(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9903 USHORT ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
9907 if ( ModeNo <= 0x13 )
9909 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9913 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9916 index=(modeflag&ModeInfoFlag)-ModeEGA;
9921 return( ColorDepth[ index ] ) ;
9926 /* --------------------------------------------------------------------- */
9927 /* Function : XGI_UnLockCRT2 */
9931 /* --------------------------------------------------------------------- */
9932 void XGI_UnLockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9935 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
9940 /* --------------------------------------------------------------------- */
9941 /* Function : XGI_LockCRT2 */
9945 /* --------------------------------------------------------------------- */
9946 void XGI_LockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9949 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
9955 /* --------------------------------------------------------------------- */
9956 /* Function : XGINew_EnableCRT2 */
9960 /* --------------------------------------------------------------------- */
9961 void XGINew_EnableCRT2( PVB_DEVICE_INFO pVBInfo)
9963 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
9968 /* --------------------------------------------------------------------- */
9973 /* --------------------------------------------------------------------- */
9974 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo)
9983 //printk("XGINew_LCD_Wait_Time");
9985 for( i = 0 ; i < DelayTime ; i++ )
9987 for( j = 0 ; j < 66 ; j++ )
9990 temp = XGINew_GetReg3( 0x61 ) ;
9992 //temp &= 0x10000000;
10005 /* --------------------------------------------------------------------- */
10006 /* Function : XGI_BridgeIsOn */
10009 /* Description : */
10010 /* --------------------------------------------------------------------- */
10011 BOOLEAN XGI_BridgeIsOn( PVB_DEVICE_INFO pVBInfo )
10015 if ( pVBInfo->IF_DEF_LVDS == 1 )
10021 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10022 if ( ( flag == 1 ) || ( flag == 2 ) )
10023 return( 1 ) ; /* 301b */
10031 /* --------------------------------------------------------------------- */
10032 /* Function : XGI_LongWait */
10035 /* Description : */
10036 /* --------------------------------------------------------------------- */
10037 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo)
10041 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10043 if ( !( i & 0xC0 ) )
10045 for( i = 0 ; i < 0xFFFF ; i++ )
10047 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10051 for( i = 0 ; i < 0xFFFF ; i++ )
10053 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10060 /* --------------------------------------------------------------------- */
10061 /* Function : XGI_VBLongWait */
10064 /* Description : */
10065 /* --------------------------------------------------------------------- */
10066 void XGI_VBLongWait( PVB_DEVICE_INFO pVBInfo )
10073 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10076 for( i = 0 ; i < 3 ; i++ )
10078 for( j = 0 ; j < 100 ; j++ )
10080 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10082 { /* VBWaitMode2 */
10083 if ( ( tempal & 0x08 ) )
10088 if ( !( tempal & 0x08 ) )
10094 { /* VBWaitMode1 */
10095 if ( !( tempal & 0x08 ) )
10100 if ( ( tempal & 0x08 ) )
10106 temp = temp ^ 0x01 ;
10111 XGI_LongWait(pVBInfo) ;
10119 /* --------------------------------------------------------------------- */
10120 /* Function : XGI_GetVGAHT2 */
10123 /* Description : */
10124 /* --------------------------------------------------------------------- */
10125 USHORT XGI_GetVGAHT2( PVB_DEVICE_INFO pVBInfo )
10130 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10131 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10132 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10134 return( ( USHORT )tempax ) ;
10138 /* --------------------------------------------------------------------- */
10139 /* Function : XGI_GetVCLK2Ptr */
10142 /* Description : */
10143 /* --------------------------------------------------------------------- */
10144 USHORT XGI_GetVCLK2Ptr( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
10148 USHORT LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10149 USHORT LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10150 USHORT LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10151 USHORT LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10152 USHORT LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10154 USHORT CRT2Index , VCLKIndex ;
10155 USHORT modeflag , resinfo ;
10156 UCHAR *CHTVVCLKPtr = NULL ;
10158 if ( ModeNo <= 0x13 )
10160 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10161 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10162 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10166 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10167 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10168 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10171 if ( pVBInfo->IF_DEF_LVDS == 0 )
10173 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10174 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10176 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10178 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10182 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10187 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10189 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10191 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10193 VCLKIndex = HiTVVCLKDIV2 ;
10201 VCLKIndex = HiTVVCLK ;
10208 if ( pVBInfo->SetFlag & TVSimuMode )
10210 if( modeflag & Charx8Dot )
10212 VCLKIndex = HiTVSimuVCLK ;
10220 VCLKIndex = HiTVTextVCLK ;
10228 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10230 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10232 VCLKIndex = YPbPr750pVCLK ;
10233 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10235 VCLKIndex = YPbPr525pVCLK ;
10236 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10238 VCLKIndex = YPbPr525iVCLK_2 ;
10239 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10240 VCLKIndex = YPbPr525iVCLK ;
10248 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10250 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10252 VCLKIndex = TVVCLKDIV2 ;
10260 VCLKIndex = TVVCLK ;
10271 VCLKIndex = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ; /* Port 3cch */
10272 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10273 if ( ModeNo > 0x13 )
10275 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10276 VCLKIndex &= IndexMask ;
10283 if ( ModeNo <= 0x13 )
10284 VCLKIndex = CRT2Index ;
10286 VCLKIndex = CRT2Index ;
10288 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10290 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10292 VCLKIndex &= 0x1f ;
10295 if ( pVBInfo->VBInfo & SetPALTV )
10298 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10304 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10307 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10310 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10313 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10319 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10324 VCLKIndex = VCLKIndex >> 6 ;
10325 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10326 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10327 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10328 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10330 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10333 /* VCLKIndex = VCLKIndex&IndexMask ; */
10337 return( VCLKIndex ) ;