13 #include "xf86PciInfo.h"
20 #include <linux/types.h>
21 #include <linux/version.h>
23 /*#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
24 #include <video/XGIfb.h>
26 #include <linux/XGIfb.h>
44 #include "vb_struct.h"
50 #define IndexMask 0xff
51 #ifndef XGI_MASK_DUAL_CHIP
52 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
57 BOOLEAN XGI_IsLCDDualLink(PVB_DEVICE_INFO pVBInfo);
58 BOOLEAN XGI_SetCRT2Group301(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
59 BOOLEAN XGI_BacklightByDrv(PVB_DEVICE_INFO pVBInfo);
61 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo);
62 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo);
63 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo);
64 BOOLEAN XGI_AjustCRT2Rate(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,USHORT *i, PVB_DEVICE_INFO pVBInfo);
65 BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
66 BOOLEAN XGI_GetLCDInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
67 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo ) ;
68 BOOLEAN XGI_BridgeIsOn(PVB_DEVICE_INFO pVBInfo);
69 UCHAR XGI_GetModePtr( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
70 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
71 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
72 USHORT XGI_GetResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
73 USHORT XGI_GetColorDepth(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
74 USHORT XGI_GetVGAHT2(PVB_DEVICE_INFO pVBInfo);
75 USHORT XGI_GetVCLK2Ptr(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
76 void XGI_VBLongWait(PVB_DEVICE_INFO pVBInfo);
77 void XGI_SaveCRT2Info(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo);
78 void XGI_GetCRT2Data(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
79 void XGI_GetCRT2ResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
80 void XGI_PreSetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
81 void XGI_SetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
82 void XGI_SetLockRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
83 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
84 void XGI_SetGroup2(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
85 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
86 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
87 void XGI_SetGroup5(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
88 void* XGI_GetLcdPtr(USHORT BX, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
89 void* XGI_GetTVPtr(USHORT BX, USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
90 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo);
91 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
92 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
93 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
94 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
95 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo);
96 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo);
97 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo);
98 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo);
100 void XGI_DisplayOn(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
101 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
102 void XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
103 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
104 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
105 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
106 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
107 void XGI_UpdateXG21CRTC(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo, USHORT RefreshRateTableIndex);
108 void XGI_WaitDisply(PVB_DEVICE_INFO pVBInfo);
109 void XGI_SenseCRT1(PVB_DEVICE_INFO pVBInfo);
110 void XGI_SetSeqRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
111 void XGI_SetMiscRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
112 void XGI_SetCRTCRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
113 void XGI_SetATTRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
114 void XGI_SetGRCRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
115 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo);
117 void XGI_SetSync(USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
118 void XGI_SetCRT1CRTC(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
119 void XGI_SetCRT1Timing_H(PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
120 void XGI_SetCRT1Timing_V(USHORT ModeIdIndex,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);
121 void XGI_SetCRT1DE(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
122 void XGI_SetCRT1VCLK(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
123 void XGI_SetCRT1FIFO(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
124 void XGI_SetCRT1ModeRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
125 void XGI_SetVCLKState(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
127 void XGI_LoadDAC(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
128 void XGI_WriteDAC(USHORT dl, USHORT ah, USHORT al, USHORT dh, PVB_DEVICE_INFO pVBInfo);
129 /*void XGI_ClearBuffer(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);*/
130 void XGI_SetLCDAGroup(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
131 void XGI_GetLVDSResInfo( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
132 void XGI_GetLVDSData(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
133 void XGI_ModCRT1Regs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
134 void XGI_SetLVDSRegs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
135 void XGI_UpdateModeInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
136 void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
137 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo);
138 void XGI_GetVBInfo(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
139 void XGI_GetTVInfo(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
140 void XGI_SetCRT2ECLK( USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
141 void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
142 void XGI_GetLCDSync(USHORT* HSyncWidth, USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo);
143 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
144 void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
145 void XGI_SetCRT2VCLK(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
146 void XGI_OEM310Setting(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
147 void XGI_SetDelayComp(PVB_DEVICE_INFO pVBInfo);
148 void XGI_SetLCDCap(PVB_DEVICE_INFO pVBInfo);
149 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
150 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
151 void SetSpectrum(PVB_DEVICE_INFO pVBInfo);
152 void XGI_SetAntiFlicker(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
153 void XGI_SetEdgeEnhance(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
154 void XGI_SetPhaseIncr(PVB_DEVICE_INFO pVBInfo);
155 void XGI_SetYFilter(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
156 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo);
157 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo );
158 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
159 void XGI_CloseCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
160 void XGI_OpenCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
161 void XGI_GetRAMDAC2DATA(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
162 void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
163 void XGI_LockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
164 void XGINew_EnableCRT2(PVB_DEVICE_INFO pVBInfo);
165 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo);
166 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo);
167 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo );
168 void XGI_GetLCDVCLKPtr(UCHAR* di_0,UCHAR *di_1, PVB_DEVICE_INFO pVBInfo);
169 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
170 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo);
171 USHORT XGI_GetLCDCapPtr(PVB_DEVICE_INFO pVBInfo);
172 USHORT XGI_GetLCDCapPtr1(PVB_DEVICE_INFO pVBInfo);
173 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo);
174 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
175 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
176 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo);
177 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo);
178 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
179 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
180 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
181 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
182 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
183 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
184 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo );
186 extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
188 /* [Billy] 2007/05/17 For CH7007 */
189 extern UCHAR CH7007TVReg_UNTSC[][8],CH7007TVReg_ONTSC[][8],CH7007TVReg_UPAL[][8],CH7007TVReg_OPAL[][8];
190 extern UCHAR CH7007TVCRT1UNTSC_H[][10],CH7007TVCRT1ONTSC_H[][10],CH7007TVCRT1UPAL_H[][10],CH7007TVCRT1OPAL_H[][10] ;
191 extern UCHAR CH7007TVCRT1UNTSC_V[][10],CH7007TVCRT1ONTSC_V[][10],CH7007TVCRT1UPAL_V[][10],CH7007TVCRT1OPAL_V[][10] ;
192 extern UCHAR XGI7007_CHTVVCLKUNTSC[],XGI7007_CHTVVCLKONTSC[],XGI7007_CHTVVCLKUPAL[],XGI7007_CHTVVCLKOPAL[];
194 extern BOOLEAN XGI_XG21CheckCH7007TVMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo ) ;
195 extern void SetCH7007Regs(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo ) ;
196 extern VP_STATUS TurnOnCH7007(PHW_DEVICE_EXTENSION pHWDE) ;
197 extern VP_STATUS TurnOffCH7007(PHW_DEVICE_EXTENSION pHWDE) ;
198 extern BOOLEAN IsCH7007TVMode(PVB_DEVICE_INFO pVBInfo) ;
201 /* USHORT XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
207 USHORT XGINew_MDA_DAC[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
208 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
209 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
210 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
211 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
212 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
213 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
214 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F};
216 USHORT XGINew_CGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
217 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
218 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
219 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
220 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
221 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
222 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
223 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
225 USHORT XGINew_EGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15,
226 0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35,
227 0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D,
228 0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D,
229 0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17,
230 0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37,
231 0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F,
232 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
234 USHORT XGINew_VGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
235 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
236 0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18,
237 0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F,
239 0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F,
240 0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00,
241 0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18,
242 0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04,
243 0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10,
244 0x0B,0x0C,0x0D,0x0F,0x10};
247 /* --------------------------------------------------------------------- */
248 /* Function : InitTo330Pointer */
252 /* --------------------------------------------------------------------- */
253 void InitTo330Pointer( UCHAR ChipType ,PVB_DEVICE_INFO pVBInfo)
255 pVBInfo->SModeIDTable = (XGI_StStruct *) XGI330_SModeIDTable ;
256 pVBInfo->StandTable = (XGI_StandTableStruct *) XGI330_StandTable ;
257 pVBInfo->EModeIDTable = (XGI_ExtStruct *) XGI330_EModeIDTable ;
258 pVBInfo->RefIndex = (XGI_Ext2Struct *) XGI330_RefIndex ;
259 pVBInfo->XGINEWUB_CRT1Table = (XGI_CRT1TableStruct *) XGI_CRT1Table ;
261 /* add for new UNIVGABIOS */
262 /* XGINew_UBLCDDataTable = (XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
263 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
266 if ( ChipType >= XG40 )
268 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI340New_MCLKData ;
269 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI340_ECLKData ;
273 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI330New_MCLKData ;
274 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI330_ECLKData ;
277 pVBInfo->VCLKData = (XGI_VCLKDataStruct *) XGI_VCLKData ;
278 pVBInfo->VBVCLKData = (XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
279 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
280 pVBInfo->StResInfo = (XGI_StResInfoStruct *) XGI330_StResInfo ;
281 pVBInfo->ModeResInfo = (XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
283 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
284 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
285 pVBInfo->pSR07 = &XGI330_SR07 ;
286 pVBInfo->LCDResInfo = 0 ;
287 pVBInfo->LCDTypeInfo = 0 ;
288 pVBInfo->LCDInfo = 0 ;
289 pVBInfo->VBInfo = 0 ;
293 pVBInfo->SR15 = XGI340_SR13 ;
294 pVBInfo->CR40 = XGI340_cr41 ;
295 pVBInfo->SR25 = XGI330_sr25 ;
296 pVBInfo->pSR31 = &XGI330_sr31 ;
297 pVBInfo->pSR32 = &XGI330_sr32 ;
298 pVBInfo->CR6B = XGI340_CR6B ;
299 pVBInfo->CR6E = XGI340_CR6E ;
300 pVBInfo->CR6F = XGI340_CR6F ;
301 pVBInfo->CR89 = XGI340_CR89 ;
302 pVBInfo->AGPReg = XGI340_AGPReg ;
303 pVBInfo->SR16 = XGI340_SR16 ;
304 pVBInfo->pCRCF = &XG40_CRCF ;
305 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
308 pVBInfo->CR49 = XGI330_CR49 ;
309 pVBInfo->pSR1F = &XGI330_SR1F ;
310 pVBInfo->pSR21 = &XGI330_SR21 ;
311 pVBInfo->pSR22 = &XGI330_SR22 ;
312 pVBInfo->pSR23 = &XGI330_SR23 ;
313 pVBInfo->pSR24 = &XGI330_SR24 ;
314 pVBInfo->pSR33 = &XGI330_SR33 ;
318 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
319 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
320 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
321 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
322 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
323 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
324 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
325 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
326 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
327 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
329 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
330 pVBInfo->PALTiming = XGI330_PALTiming ;
331 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
332 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
333 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
334 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
335 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
336 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
337 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
338 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
339 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
340 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
341 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
342 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
345 pVBInfo->TimingH = (XGI_TimingHStruct *) XGI_TimingH ;
346 pVBInfo->TimingV = (XGI_TimingVStruct *) XGI_TimingV ;
347 pVBInfo->UpdateCRT1 = (XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
349 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
350 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
351 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
352 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
354 /* 310 customization related */
355 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
356 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
358 pVBInfo->LCDCapList = XGI_LCDCapList ;
360 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
361 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
363 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
364 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
367 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
369 if ( ChipType >= XG20 )
370 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
372 if ( ChipType == XG27 )
374 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI27New_MCLKData ;
375 pVBInfo->CR40 = XGI27_cr41 ;
376 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
377 pVBInfo->pSR36 = &XG27_SR36 ;
378 pVBInfo->pCR8F = &XG27_CR8F ;
379 pVBInfo->pCRD0 = XG27_CRD0 ;
380 pVBInfo->pCRDE = XG27_CRDE ;
381 pVBInfo->pSR40 = &XG27_SR40 ;
382 pVBInfo->pSR41 = &XG27_SR41 ;
386 if ( ChipType >= XG20 )
388 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
389 pVBInfo->pCR2E = &XG21_CR2E ;
390 pVBInfo->pCR2F = &XG21_CR2F ;
391 pVBInfo->pCR46 = &XG21_CR46 ;
392 pVBInfo->pCR47 = &XG21_CR47 ;
402 /* --------------------------------------------------------------------- */
403 /* Function : XGISetModeNew */
407 /* --------------------------------------------------------------------- */
408 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo )
411 /* PUCHAR pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
412 VB_DEVICE_INFO VBINF;
413 PVB_DEVICE_INFO pVBInfo = &VBINF;
414 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
415 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
416 pVBInfo->IF_DEF_LVDS = 0 ;
417 pVBInfo->IF_DEF_CH7005 = 0 ;
418 pVBInfo->IF_DEF_LCDA = 1 ;
419 pVBInfo->IF_DEF_CH7017 = 0 ;
420 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
421 pVBInfo->IF_DEF_VideoCapture = 0 ;
422 pVBInfo->IF_DEF_ScaleLCD = 0 ;
423 pVBInfo->IF_DEF_OEMUtil = 0 ;
424 pVBInfo->IF_DEF_PWD = 0 ;
427 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
429 pVBInfo->IF_DEF_YPbPr = 0 ;
430 pVBInfo->IF_DEF_HiVision = 0 ;
431 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
432 pVBInfo->VBType = 0 ; /*set VBType default 0*/
434 else if ( HwDeviceExtension->jChipType >= XG40 )
436 pVBInfo->IF_DEF_YPbPr = 1 ;
437 pVBInfo->IF_DEF_HiVision = 1 ;
438 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
442 pVBInfo->IF_DEF_YPbPr = 1 ;
443 pVBInfo->IF_DEF_HiVision = 1 ;
444 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
447 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
448 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
449 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
450 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
451 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
452 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
453 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
454 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
455 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
456 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
457 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
458 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
459 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
460 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
461 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
462 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
463 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
464 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
466 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
468 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
470 pVBInfo->IF_DEF_LVDS = 1 ;
473 if ( HwDeviceExtension->jChipType == XG27 )
475 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
477 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
479 pVBInfo->IF_DEF_LVDS = 1 ;
484 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
485 XGI_GetVBType( pVBInfo ) ;
487 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
489 ReadVBIOSTablData( HwDeviceExtension->jChipType , pVBInfo) ;
493 ModeNo = ModeNo & 0x7F ;
494 /* XGINew_flag_clearbuffer = 0 ; */
498 XGINew_flag_clearbuffer = 1 ;
501 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
503 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
504 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
506 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
508 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
510 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
512 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
513 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
514 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
515 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
516 /* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
518 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
520 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
522 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
524 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
529 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
531 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
532 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
534 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
539 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
541 switch( HwDeviceExtension->ujVBChipID )
544 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
548 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
556 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
557 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
558 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
559 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
564 if ( pVBInfo->IF_DEF_CH7007 == 1 )
567 VideoDebugPrint((0, "XGISetModeNew: pVBIfo->IF_DEF_CH7007==1\n"));
568 pVBInfo->VBType = VB_CH7007 ;
569 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
570 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
571 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
572 if( !(XGI_XG21CheckCH7007TVMode(ModeNo, ModeIdIndex, pVBInfo )) )
580 if ( pVBInfo->IF_DEF_LVDS == 1 )
582 if ( !XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo) )
588 if ( ModeNo <= 0x13 )
590 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
594 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
597 pVBInfo->SetFlag = 0 ;
598 if ( pVBInfo->IF_DEF_CH7007 != 1 )
600 pVBInfo->VBInfo = DisableCRT2Display ;
604 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
606 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
608 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
610 if( HwDeviceExtension->jChipType == XG21 )
611 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
617 if ( ModeNo <= 0x13 )
619 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
623 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
625 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
626 pVBInfo->SetFlag = 0x00 ;
627 pVBInfo->VBInfo = DisableCRT2Display ;
628 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
633 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
634 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
635 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
638 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
640 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
642 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
649 /* --------------------------------------------------------------------- */
650 /* Function : XGI_SetCRT1Group */
654 /* --------------------------------------------------------------------- */
655 void XGI_SetCRT1Group( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
657 USHORT StandTableIndex ,
658 RefreshRateTableIndex ,
662 USHORT XGINew_P3cc = pVBInfo->P3cc;
664 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
665 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
666 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
667 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
668 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
669 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
670 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
671 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
672 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
673 XGI_ClearExt1Regs(pVBInfo) ;
675 /* if ( pVBInfo->IF_DEF_ExpLink ) */
676 if ( HwDeviceExtension->jChipType == XG27 )
678 if ( pVBInfo->IF_DEF_LVDS == 0 )
680 XGI_SetDefaultVCLK( pVBInfo ) ;
684 temp = ~ProgrammingCRT2 ;
685 pVBInfo->SetFlag &= temp ;
686 pVBInfo->SelectCRT2Rate = 0 ;
688 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
690 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
692 pVBInfo->SetFlag |= ProgrammingCRT2 ;
696 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
697 if ( RefreshRateTableIndex != 0xFFFF )
699 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
700 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
701 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
702 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
703 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
706 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
707 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
709 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
711 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
712 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
713 b3CC =(UCHAR) XGINew_GetReg2(XGINew_P3cc) ;
714 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
716 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
718 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
719 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
720 b3CC = (UCHAR)XGINew_GetReg2(XGINew_P3cc) ;
721 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
725 if ( HwDeviceExtension->jChipType >= XG21 )
727 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
731 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
732 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
733 /* XG21 CRT1 Timing */
734 if ( HwDeviceExtension->jChipType == XG27 )
735 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
737 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
739 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
741 if ( HwDeviceExtension->jChipType == XG27 )
742 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
744 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
746 if ( pVBInfo->IF_DEF_LVDS == 1 )
748 if ( HwDeviceExtension->jChipType == XG27 )
749 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
751 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
753 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
757 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
758 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
759 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
762 /* XGI_LoadCharacter(); //dif ifdef TVFont */
764 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
765 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
767 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/14 */
769 VideoDebugPrint((0, "XGI_SetCRT1Group: VBInfo->IF_DEF_CH7007==1\n"));
770 SetCH7007Regs(HwDeviceExtension, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo ) ; /* 07/05/28 */
776 /* --------------------------------------------------------------------- */
777 /* Function : XGI_GetModePtr */
781 /* --------------------------------------------------------------------- */
782 UCHAR XGI_GetModePtr( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
786 if ( ModeNo <= 0x13 )
787 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
790 if ( pVBInfo->ModeType <= 0x02 )
791 index = 0x1B ; /* 02 -> ModeEGA */
795 return( index ) ; /* Get pVBInfo->StandTable index */
799 /* --------------------------------------------------------------------- */
800 /* Function : XGI_SetBIOSData */
804 /* --------------------------------------------------------------------- */
805 /*UCHAR XGI_SetBIOSData( USHORT ModeNo , USHORT ModeIdIndex )
811 /* --------------------------------------------------------------------- */
812 /* Function : XGI_ClearBankRegs */
816 /* --------------------------------------------------------------------- */
817 /*UCHAR XGI_ClearBankRegs( USHORT ModeNo , USHORT ModeIdIndex )
823 /* --------------------------------------------------------------------- */
824 /* Function : XGI_SetSeqRegs */
828 /* --------------------------------------------------------------------- */
829 void XGI_SetSeqRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
837 if ( ModeNo <= 0x13 )
838 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
840 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
842 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
843 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
846 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
852 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
854 if ( pVBInfo->VBInfo & SetInSlaveMode )
859 tempah |= 0x20 ; /* screen off */
860 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
862 for( i = 02 ; i <= 04 ; i++ )
864 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
865 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
870 /* --------------------------------------------------------------------- */
871 /* Function : XGI_SetMiscRegs */
875 /* --------------------------------------------------------------------- */
876 void XGI_SetMiscRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
880 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
882 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
884 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
891 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
895 /* --------------------------------------------------------------------- */
896 /* Function : XGI_SetCRTCRegs */
900 /* --------------------------------------------------------------------- */
901 void XGI_SetCRTCRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
906 CRTCdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
908 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
910 for( i = 0 ; i <= 0x18 ; i++ )
912 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
913 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
916 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
918 if ( pVBInfo->VBInfo & SetInSlaveMode )
920 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
922 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
930 /* --------------------------------------------------------------------- */
935 /* --------------------------------------------------------------------- */
936 void XGI_SetATTRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
942 if ( ModeNo <= 0x13 )
943 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
945 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
947 for( i = 0 ; i <= 0x13 ; i++ )
949 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
950 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
954 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
958 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
960 if ( pVBInfo->VBInfo & SetInSlaveMode )
967 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
968 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
969 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
972 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
973 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
974 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
975 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
976 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
980 /* --------------------------------------------------------------------- */
981 /* Function : XGI_SetGRCRegs */
985 /* --------------------------------------------------------------------- */
986 void XGI_SetGRCRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
991 for( i = 0 ; i <= 0x08 ; i++ )
993 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
994 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
997 if ( pVBInfo->ModeType > ModeVGA )
999 GRdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3ce , 0x05 ) ;
1000 GRdata &= 0xBF ; /* 256 color disable */
1001 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
1006 /* --------------------------------------------------------------------- */
1007 /* Function : XGI_ClearExt1Regs */
1011 /* --------------------------------------------------------------------- */
1012 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo)
1016 for( i = 0x0A ; i <= 0x0E ; i++ )
1017 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
1021 /* --------------------------------------------------------------------- */
1022 /* Function : XGI_SetDefaultVCLK */
1026 /* --------------------------------------------------------------------- */
1027 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo )
1030 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
1031 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
1032 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
1034 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
1035 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
1036 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
1038 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
1043 /* --------------------------------------------------------------------- */
1044 /* Function : XGI_GetRatePtrCRT2 */
1048 /* --------------------------------------------------------------------- */
1049 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
1051 SHORT LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
1052 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
1054 USHORT RefreshRateTableIndex , i ,
1055 modeflag , index , temp ;
1057 if ( ModeNo <= 0x13 )
1059 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1063 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1066 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1068 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1070 if ( modeflag & HalfDCLK )
1075 if ( ModeNo < 0x14 )
1078 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1079 index = index >> pVBInfo->SelectCRT2Rate ;
1082 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1088 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1090 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1092 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1098 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1100 if( pVBInfo->IF_DEF_LVDS == 0 )
1102 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1103 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1105 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1119 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1120 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1121 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1124 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1129 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1130 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1134 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1135 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1136 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1140 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1141 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1150 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1152 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1153 temp &= ModeInfoFlag ;
1154 if ( temp < pVBInfo->ModeType )
1159 } while( index != 0xFFFF ) ;
1160 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1162 if ( pVBInfo->VBInfo & SetInSlaveMode )
1164 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1165 if ( temp & InterlaceMode )
1172 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1174 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1176 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1180 /* --------------------------------------------------------------------- */
1181 /* Function : XGI_AjustCRT2Rate */
1185 /* --------------------------------------------------------------------- */
1186 BOOLEAN XGI_AjustCRT2Rate( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , USHORT *i, PVB_DEVICE_INFO pVBInfo )
1194 if ( ModeNo <= 0x13 )
1196 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1200 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1203 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1204 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1207 if ( pVBInfo->IF_DEF_LVDS == 0 )
1209 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1211 tempax |= SupportRAMDAC2 ;
1213 if ( pVBInfo->VBType & VB_XGI301C )
1214 tempax |= SupportCRT2in301C ;
1217 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1219 tempax |= SupportLCD ;
1221 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1223 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1225 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1237 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1239 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1241 tempax |= SupportYPbPr ;
1242 if ( pVBInfo->VBInfo & SetInSlaveMode )
1256 tempax |= SupportHiVisionTV ;
1257 if ( pVBInfo->VBInfo & SetInSlaveMode )
1264 if ( pVBInfo->SetFlag & TVSimuMode )
1275 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1277 tempax |= SupportTV ;
1279 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1281 tempax |= SupportTV1024 ;
1284 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1286 if ( modeflag & NoSupportSimuTV )
1288 if ( pVBInfo->VBInfo & SetInSlaveMode )
1290 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1302 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1304 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1306 tempax |= SupportCHTV ;
1310 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1312 tempax |= SupportLCD ;
1314 if ( resinfo > 0x08 )
1315 return( 0 ) ; /* 1024x768 */
1317 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1319 if ( resinfo > 0x07 )
1320 return( 0 ) ; /* 800x600 */
1322 if ( resinfo == 0x04 )
1323 return( 0 ) ; /* 512x384 */
1328 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1330 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1331 if ( infoflag & tempax )
1339 for( ( *i ) = 0 ; ; ( *i )++ )
1341 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1342 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1347 if ( infoflag & tempax )
1356 /* --------------------------------------------------------------------- */
1357 /* Function : XGI_SetSync */
1361 /* --------------------------------------------------------------------- */
1362 void XGI_SetSync(USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1367 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1371 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1375 /* --------------------------------------------------------------------- */
1376 /* Function : XGI_SetCRT1CRTC */
1380 /* --------------------------------------------------------------------- */
1381 void XGI_SetCRT1CRTC( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1388 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1389 index = index&IndexMask ;
1391 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1393 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1395 for( i = 0 ; i < 8 ; i++ )
1396 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1398 for( i = 0 ; i < 7 ; i++ )
1399 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1401 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1405 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1408 if( pVBInfo->ModeType > 0x03 )
1409 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1413 /* --------------------------------------------------------------------- */
1414 /* Function : XGI_SetCRT1Timing_H */
1418 /* --------------------------------------------------------------------- */
1419 void XGI_SetCRT1Timing_H( PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1421 UCHAR data , data1, pushax;
1424 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1425 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1426 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1428 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ; /* unlock cr0-7 */
1430 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1432 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1433 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1435 for( i = 0x01 ; i <= 0x04 ; i++ )
1437 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
1438 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 1 ) , data ) ;
1441 for( i = 0x05 ; i <= 0x06 ; i++ )
1443 data = pVBInfo->TimingH[ 0 ].data[ i ];
1444 XGINew_SetReg1( pVBInfo->P3c4 ,( USHORT )( i + 6 ) , data ) ;
1447 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1449 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1452 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1454 if ( HwDeviceExtension->jChipType >= XG20 )
1456 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x04 ) ;
1458 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1459 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x05 ) ;
1466 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0c ) ;
1468 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1473 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1474 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1480 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1485 /* --------------------------------------------------------------------- */
1486 /* Function : XGI_SetCRT1Timing_V */
1490 /* --------------------------------------------------------------------- */
1491 void XGI_SetCRT1Timing_V( USHORT ModeIdIndex , USHORT ModeNo,PVB_DEVICE_INFO pVBInfo )
1496 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1497 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1498 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1500 for( i = 0x00 ; i <= 0x01 ; i++ )
1502 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1503 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 6 ) , data ) ;
1506 for( i = 0x02 ; i <= 0x03 ; i++ )
1508 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1509 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x0e ) , data ) ;
1512 for( i = 0x04 ; i <= 0x05 ; i++ )
1514 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1515 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x11 ) , data ) ;
1518 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0a ) ;
1520 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1523 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1525 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1529 if ( ModeNo <= 0x13 )
1530 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1532 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1534 i &= DoubleScanMode ;
1538 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x09 ) ;
1541 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1545 /* --------------------------------------------------------------------- */
1546 /* Function : XGI_SetXG21CRTC */
1547 /* Input : Stand or enhance CRTC table */
1548 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1549 /* Description : Set LCD timing */
1550 /* --------------------------------------------------------------------- */
1551 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1553 UCHAR StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1554 USHORT Temp1, Temp2, Temp3 ;
1556 if ( ModeNo <= 0x13 )
1558 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1559 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1560 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1561 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1562 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1564 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1565 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1566 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1567 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1568 Tempdx <<= 2 ; /* Tempdx << 2 */
1569 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1570 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1572 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1573 Tempbx = Tempax ; /* Tempbx=Tempax */
1574 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1575 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1576 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1577 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1578 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1579 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1580 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1581 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1583 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] UCHAR -> USHORT */
1584 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1585 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1586 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1587 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1589 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1590 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1591 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1592 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1593 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1594 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1595 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1596 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1597 Tempax = (UCHAR)Temp2 ; /* Tempax[7:0]: VRE[7:0] */
1598 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1599 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1600 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1601 Tempbx = (UCHAR)Temp1 ; /* Tempbx[1:0]: VRS[10:9] */
1602 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1604 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1608 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1609 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1610 Tempcx = Tempax ; /* Tempcx: HRS */
1611 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1613 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1614 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1615 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1616 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1617 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1619 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1620 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1622 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1623 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1624 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1625 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1627 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1628 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1630 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1631 if( Tempax < Tempcx ) /* HRE < HRS */
1632 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1635 Tempax = (UCHAR)Temp2 ; /* Tempax: HRE[7:0] */
1636 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1637 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1638 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1639 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1640 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1642 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1643 Tempbx = Tempax ; /* Tempbx: VRS */
1644 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1645 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1646 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1647 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1648 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1649 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1650 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1651 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1653 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1654 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1655 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1657 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1658 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1659 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1660 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1662 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1663 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1665 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1666 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1667 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1668 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1669 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1670 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1671 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1672 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1674 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1675 if ( Tempax < Temp3 ) /* VRE < VRS */
1676 Temp2 |= 0x20 ; /* VRE + 0x20 */
1679 Tempax = (UCHAR)Temp2 ; /* Tempax: VRE[7:0] */
1680 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1681 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1682 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1683 Tempbx = (UCHAR)Temp1 ;
1684 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1686 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1690 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1692 USHORT StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1694 if ( ModeNo <= 0x13 )
1696 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1697 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1698 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1699 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1700 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1702 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1703 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1704 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1705 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1706 Tempdx <<= 2 ; /* Tempdx << 2 */
1707 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1708 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1710 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1711 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1712 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1713 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1714 Tempbx = Tempax ; /* Tempbx=CR07 */
1715 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1717 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1718 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1719 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1722 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1723 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1724 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1725 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1726 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1727 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1728 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1729 Tempax = (UCHAR)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1730 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1731 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1732 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1733 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1737 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1738 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1739 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1740 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1742 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1743 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1744 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1746 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1747 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1748 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1750 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1751 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1752 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1753 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1755 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1756 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1758 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1759 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1760 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1761 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1763 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1764 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1765 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1766 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1767 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1768 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1770 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1771 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1773 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1774 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1775 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1776 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1777 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1778 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1779 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1780 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1781 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1782 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1783 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1786 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1787 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1788 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1789 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1790 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1791 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1792 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1793 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1794 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1796 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1797 Tempbx |= 0x20 ; /* VRE + 0x20 */
1799 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1800 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1801 Tempax = Tempcx >> 8;
1802 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1807 /* --------------------------------------------------------------------- */
1808 /* Function : XGI_SetXG21LCD */
1810 /* Output : FCLK duty cycle, FCLK delay compensation */
1811 /* Description : All values set zero */
1812 /* --------------------------------------------------------------------- */
1813 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1815 USHORT Data , Temp , b3CC ;
1818 XGI_P3cc = pVBInfo->P3cc ;
1820 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1821 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1822 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1823 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1824 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1826 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1827 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1828 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1829 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1832 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1836 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1837 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1840 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1842 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1843 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1845 if ( ModeNo <= 0x13 )
1847 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1849 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1851 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1855 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1856 if ( Data & 0x4000 )
1857 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1858 if ( Data & 0x8000 )
1859 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1863 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1865 USHORT Data , Temp , b3CC ;
1868 XGI_P3cc = pVBInfo->P3cc ;
1870 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1871 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1872 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1873 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1875 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1876 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1878 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1879 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1882 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1884 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1885 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1886 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1887 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1890 XGI_SetXG27FPBits(pVBInfo);
1892 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1894 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1895 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1897 if ( ModeNo <= 0x13 )
1899 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1901 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1903 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1907 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1908 if ( Data & 0x4000 )
1909 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1910 if ( Data & 0x8000 )
1911 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1915 /* --------------------------------------------------------------------- */
1916 /* Function : XGI_UpdateXG21CRTC */
1918 /* Output : CRT1 CRTC */
1919 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1920 /* --------------------------------------------------------------------- */
1921 void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT RefreshRateTableIndex )
1925 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1926 if ( ModeNo <= 0x13 )
1928 for( i = 0 ; i < 12 ; i++ )
1930 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1936 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1938 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1940 else if ( ModeNo == 0x2F )
1942 else if ( ModeNo == 0x50 )
1944 else if ( ModeNo == 0x59 )
1950 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1951 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1952 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1953 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1958 /* --------------------------------------------------------------------- */
1959 /* Function : XGI_SetCRT1DE */
1963 /* --------------------------------------------------------------------- */
1964 void XGI_SetCRT1DE( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo,USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1975 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1977 if ( ModeNo <= 0x13 )
1979 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1980 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1981 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1985 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1986 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1987 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1990 if ( modeflag & HalfDCLK )
1991 tempax = tempax >> 1 ;
1993 if ( ModeNo > 0x13 )
1995 if ( modeflag & HalfDCLK )
1996 tempax = tempax << 1 ;
1998 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2000 if ( temp & InterlaceMode )
2001 tempbx = tempbx >> 1 ;
2003 if ( modeflag & DoubleScanMode )
2004 tempbx = tempbx << 1 ;
2009 /* if ( !( modeflag & Charx8Dot ) ) */
2016 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
2017 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
2019 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
2020 XGINew_SetReg1( pVBInfo->P3d4 , 0x01 , ( USHORT )( tempcx & 0xff ) ) ;
2021 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x0b , ~0x0c , ( USHORT )( ( tempcx & 0x0ff00 ) >> 10 ) ) ;
2022 XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , ( USHORT )( tempbx & 0xff ) ) ;
2024 tempbx = tempbx >> 8 ;
2026 if ( tempbx & 0x01 )
2029 if ( tempbx & 0x02 )
2032 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
2033 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x07 ) ;
2037 if ( tempbx & 0x04 )
2040 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
2041 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
2045 /* --------------------------------------------------------------------- */
2046 /* Function : XGI_GetResInfo */
2050 /* --------------------------------------------------------------------- */
2051 USHORT XGI_GetResInfo(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
2055 if ( ModeNo <= 0x13 )
2057 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2061 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2063 return( resindex ) ;
2067 /* --------------------------------------------------------------------- */
2068 /* Function : XGI_SetCRT1Offset */
2072 /* --------------------------------------------------------------------- */
2073 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2083 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2085 temp = pVBInfo->ScreenOffset[ temp ] ;
2087 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2088 temp2 &= InterlaceMode ;
2093 temp2 = pVBInfo->ModeType - ModeEGA ;
2119 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2120 temp = temp * temp2 + temp2 / 2 ;
2125 DisplayUnit = temp ;
2127 temp = temp >> 8 ; /* ah */
2129 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2132 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2134 temp =( UCHAR )temp2 ;
2135 temp &= 0xFF ; /* al */
2136 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2138 /* SetDisplayUnit */
2139 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2140 temp2 &= InterlaceMode ;
2144 DisplayUnit = DisplayUnit << 5 ;
2145 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2146 al = DisplayUnit & 0x00ff ;
2152 if ( HwDeviceExtension->jChipType >= XG20 )
2153 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2156 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2160 /* --------------------------------------------------------------------- */
2161 /* Function : XGI_SetCRT1VCLK */
2165 /* --------------------------------------------------------------------- */
2166 void XGI_SetCRT1VCLK( USHORT ModeNo , USHORT ModeIdIndex ,
2167 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2169 UCHAR index , data ;
2172 if ( pVBInfo->IF_DEF_LVDS == 1 )
2174 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2175 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2176 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2177 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2178 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2179 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2181 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2183 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2184 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2185 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2186 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2187 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2188 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2189 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2190 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2194 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2195 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2196 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2197 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2198 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2199 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2202 if ( HwDeviceExtension->jChipType >= XG20 )
2204 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2206 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2207 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2208 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2215 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2221 /* --------------------------------------------------------------------- */
2222 /* Function : XGI_SetCRT1FIFO */
2226 /* --------------------------------------------------------------------- */
2227 void XGI_SetCRT1FIFO( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2231 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2233 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2235 if ( ModeNo > 0x13 )
2237 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2238 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2240 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2241 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2243 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2247 if (HwDeviceExtension->jChipType == XG27)
2249 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2250 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2252 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2256 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2257 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2259 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2263 if (HwDeviceExtension->jChipType == XG21)
2265 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2270 /* --------------------------------------------------------------------- */
2271 /* Function : XGI_SetCRT1ModeRegs */
2275 /* --------------------------------------------------------------------- */
2276 void XGI_SetCRT1ModeRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension ,
2277 USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2287 if ( ModeNo > 0x13 )
2289 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2290 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2293 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2295 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2296 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2298 if ( ModeNo > 0x13 )
2305 if ( ModeNo > 0x13 )
2307 if ( pVBInfo->ModeType > 0x02 )
2310 data3 = pVBInfo->ModeType - ModeVGA ;
2311 data3 = data3 << 2 ;
2316 data &= InterlaceMode ;
2321 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2322 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2323 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2324 if ( ModeNo <= 0x13 )
2325 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2327 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2330 if ( infoflag & InterlaceMode )
2334 else if ( xres == 1280 )
2338 data2 = data & 0x00FF ;
2339 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2340 data2 = ( data & 0xFF00 ) >> 8 ;
2341 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2343 if( modeflag & HalfDCLK )
2344 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2348 if ( modeflag & LineCompareOff )
2351 if ( ModeNo > 0x13 )
2353 if ( pVBInfo->ModeType == ModeEGA )
2357 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2359 if ( pVBInfo->ModeType != ModeText )
2361 data = data ^ 0x60 ;
2362 if ( pVBInfo->ModeType != ModeEGA )
2364 data = data ^ 0xA0 ;
2367 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2369 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2371 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2372 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2373 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2375 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2377 if (HwDeviceExtension->jChipType == XG27 )
2383 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2384 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2387 if (HwDeviceExtension->jChipType >= XG20 )
2393 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2394 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2402 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2408 /* --------------------------------------------------------------------- */
2409 /* Function : XGI_SetVCLKState */
2413 /* --------------------------------------------------------------------- */
2414 void XGI_SetVCLKState( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2422 if ( ModeNo <= 0x13 )
2426 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2427 index &= IndexMask ;
2428 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2431 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2434 data |= 0x0c ; /* VCLK > 200 */
2436 if ( HwDeviceExtension->jChipType >= XG20 )
2437 data &= ~0x04 ; /* 2 pixel mode */
2439 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2441 if ( HwDeviceExtension->jChipType < XG20 )
2443 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2447 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2450 /* Jong for Adavantech LCD ripple issue
2451 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2453 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2455 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2457 else if ( VCLK > 260 )
2462 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2463 if (HwDeviceExtension->jChipType >= XG27 )
2465 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2472 /* --------------------------------------------------------------------- */
2473 /* Function : XGI_VesaLowResolution */
2477 /* --------------------------------------------------------------------- */
2478 /*void XGI_VesaLowResolution( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo)
2482 if ( ModeNo > 0x13 )
2483 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2485 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2487 if ( ModeNo > 0x13 )
2489 if ( modeflag & DoubleScanMode )
2491 if ( modeflag & HalfDCLK )
2493 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2495 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2497 if ( pVBInfo->VBInfo & SetInSlaveMode )
2499 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2500 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2505 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2506 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2511 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2515 /* --------------------------------------------------------------------- */
2516 /* Function : XGI_LoadDAC */
2520 /* --------------------------------------------------------------------- */
2521 void XGI_LoadDAC( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2523 USHORT data , data2 , time ,
2524 i , j , k , m , n , o ,
2525 si , di , bx , dl , al , ah , dh ,
2528 if ( ModeNo <= 0x13 )
2529 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2531 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2533 data &= DACInfoFlag ;
2537 table = XGINew_MDA_DAC ;
2538 else if ( data == 0x08 )
2539 table = XGINew_CGA_DAC ;
2540 else if ( data == 0x10 )
2541 table = XGINew_EGA_DAC ;
2542 else if ( data == 0x18 )
2545 table = XGINew_VGA_DAC ;
2553 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2554 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2556 for( i = 0 ; i < j ; i++ )
2560 for( k = 0 ; k < 3 ; k++ )
2570 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2577 for( i = 16 ; i < 32 ; i++ )
2581 for( k = 0 ; k < 3 ; k++ )
2582 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2587 for( m = 0 ; m < 9 ; m++ )
2593 for( n = 0 ; n < 3 ; n++ )
2595 for( o = 0 ; o < 5 ; o++ )
2601 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2606 for( o = 0 ; o < 3 ; o++ )
2612 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2624 /* --------------------------------------------------------------------- */
2625 /* Function : XGI_WriteDAC */
2629 /* --------------------------------------------------------------------- */
2630 void XGI_WriteDAC( USHORT dl , USHORT ah , USHORT al , USHORT dh,PVB_DEVICE_INFO pVBInfo )
2632 USHORT temp , bh , bl ;
2655 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )dh ) ;
2656 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bh ) ;
2657 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bl ) ;
2661 /* --------------------------------------------------------------------- */
2662 /* Function : XGI_ClearBuffer */
2666 /* --------------------------------------------------------------------- */
2667 void XGI_ClearBuffer( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo, PVB_DEVICE_INFO pVBInfo)
2669 PVOID VideoMemoryAddress = ( PVOID )HwDeviceExtension->pjVideoMemoryAddress ;
2670 ULONG AdapterMemorySize = ( ULONG )HwDeviceExtension->ulVideoMemorySize ;
2676 if ( pVBInfo->ModeType >= ModeEGA )
2678 if ( ModeNo > 0x13 )
2680 AdapterMemorySize = 0x40000 ; /* clear 256k */
2681 /* GetDRAMSize( HwDeviceExtension ) ; */
2682 XGI_SetMemory( VideoMemoryAddress , AdapterMemorySize , 0 ) ;
2687 pBuffer = VideoMemoryAddress ;
2688 for( i = 0 ; i < 0x4000 ; i++ )
2689 pBuffer[ i ] = 0x0000 ;
2695 pBuffer = VideoMemoryAddress ;
2696 if ( pVBInfo->ModeType < ModeCGA )
2699 for ( i = 0 ; i < 0x4000 ; i++ )
2700 pBuffer[ i ] = 0x0720 ;
2704 XGI_SetMemory( VideoMemoryAddress , 0x8000 , 0 ) ;
2709 /* --------------------------------------------------------------------- */
2710 /* Function : XGI_SetLCDAGroup */
2714 /* --------------------------------------------------------------------- */
2715 void XGI_SetLCDAGroup( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2717 USHORT RefreshRateTableIndex ;
2720 /* pVBInfo->SelectCRT2Rate = 0 ; */
2722 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2723 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2724 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2725 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2726 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2727 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2728 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2732 /* --------------------------------------------------------------------- */
2733 /* Function : XGI_GetLVDSResInfo */
2737 /* --------------------------------------------------------------------- */
2738 void XGI_GetLVDSResInfo( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2740 USHORT resindex , xres , yres , modeflag ;
2742 if ( ModeNo <= 0x13 )
2744 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2748 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2752 /* if ( ModeNo > 0x13 ) */
2753 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2755 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2757 if ( ModeNo <= 0x13 )
2759 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2763 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2766 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2768 if ( ModeNo <= 0x13 )
2770 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2771 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2775 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2776 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2778 if ( ModeNo > 0x13 )
2780 if ( modeflag & HalfDCLK )
2783 if ( modeflag & DoubleScanMode )
2786 /* if ( modeflag & Charx8Dot ) */
2793 pVBInfo->VGAHDE = xres ;
2794 pVBInfo->HDE = xres ;
2795 pVBInfo->VGAVDE = yres ;
2796 pVBInfo->VDE = yres ;
2800 /* --------------------------------------------------------------------- */
2801 /* Function : XGI_GetLVDSData */
2805 /* --------------------------------------------------------------------- */
2806 void XGI_GetLVDSData( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2809 XGI330_LVDSDataStruct *LCDPtr = NULL ;
2810 XGI330_CHTVDataStruct *TVPtr = NULL ;
2814 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2816 LCDPtr = ( XGI330_LVDSDataStruct * )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo) ;
2817 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2818 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2819 pVBInfo->HT = LCDPtr->LCDHT ;
2820 pVBInfo->VT = LCDPtr->LCDVT ;
2822 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2824 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2826 TVPtr = ( XGI330_CHTVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2827 pVBInfo->VGAHT = TVPtr->VGAHT ;
2828 pVBInfo->VGAVT = TVPtr->VGAVT ;
2829 pVBInfo->HT = TVPtr->LCDHT ;
2830 pVBInfo->VT = TVPtr->LCDVT ;
2834 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2836 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2838 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2840 pVBInfo->HDE = 1024 ;
2841 pVBInfo->VDE = 768 ;
2843 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2845 pVBInfo->HDE = 1280 ;
2846 pVBInfo->VDE = 1024 ;
2848 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2850 pVBInfo->HDE = 1400 ;
2851 pVBInfo->VDE = 1050 ;
2855 pVBInfo->HDE = 1600 ;
2856 pVBInfo->VDE = 1200 ;
2863 /* --------------------------------------------------------------------- */
2864 /* Function : XGI_ModCRT1Regs */
2868 /* --------------------------------------------------------------------- */
2869 void XGI_ModCRT1Regs( USHORT ModeNo , USHORT ModeIdIndex ,
2870 USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2874 XGI_LVDSCRT1HDataStruct *LCDPtr = NULL ;
2875 XGI_LVDSCRT1VDataStruct *LCDPtr1 =NULL ;
2876 /* XGI330_CHTVDataStruct *TVPtr = NULL ; */
2877 XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2878 XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2880 if( ModeNo <= 0x13 )
2881 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2883 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2885 index= index & IndexMask ;
2887 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2891 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2893 LCDPtr = ( XGI_LVDSCRT1HDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2895 for( i = 0 ; i < 8 ; i++ )
2896 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2899 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2901 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2903 CH7007TV_TimingHPtr = ( XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2905 for( i = 0 ; i < 8 ; i++ )
2906 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2910 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2912 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2913 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2916 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2918 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2920 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2921 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2926 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2928 LCDPtr1 = ( XGI_LVDSCRT1VDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2929 for( i = 0 ; i < 7 ; i++ )
2930 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2933 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2935 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2937 CH7007TV_TimingVPtr = ( XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2939 for( i = 0 ; i < 7 ; i++ )
2940 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2943 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2945 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2946 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2949 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2951 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2953 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2954 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2955 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2963 /* --------------------------------------------------------------------- */
2964 /* Function : XGI_SetLVDSRegs */
2968 /* --------------------------------------------------------------------- */
2969 void XGI_SetLVDSRegs( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2971 USHORT tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
2972 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2973 XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2974 XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2976 if ( ModeNo > 0x13 )
2977 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2979 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2981 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2983 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2985 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2988 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2991 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2994 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2995 LCDPtr1 = ( XGI330_LCDDataDesStruct2 * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2997 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
3000 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
3005 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
3010 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
3015 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
3026 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
3028 pVBInfo->HDE=tempax;
3029 pVBInfo->VDE=tempbx;
3030 pVBInfo->VGAHDE=tempax;
3031 pVBInfo->VGAVDE=tempbx;
3034 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
3036 tempax=pVBInfo->HDE;
3037 tempbx=pVBInfo->VDE;
3040 tempax = pVBInfo->HT ;
3042 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3043 tempbx = LCDPtr1->LCDHDES ;
3045 tempbx = LCDPtr->LCDHDES ;
3047 tempcx = pVBInfo->HDE ;
3048 tempbx = tempbx & 0x0fff ;
3051 if ( tempcx >= tempax )
3054 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
3056 tempcx = tempcx >> 3 ;
3057 tempbx = tempbx >> 3 ;
3059 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , ( USHORT )( tempbx & 0xff ) ) ;
3060 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , ( USHORT )( tempcx & 0xff ) ) ;
3062 tempax = pVBInfo->HT ;
3064 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3065 tempbx = LCDPtr1->LCDHRS ;
3067 tempbx = LCDPtr->LCDHRS ;
3071 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3072 tempcx = LCDPtr1->LCDHSync ;
3076 if ( tempcx >= tempax )
3079 tempax = tempbx & 0x07 ;
3080 tempax = tempax >> 5 ;
3081 tempcx = tempcx >> 3 ;
3082 tempbx = tempbx >> 3 ;
3087 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
3088 XGINew_SetReg1( pVBInfo->Part1Port , 0x14 , ( USHORT )( tempbx & 0xff ) ) ;
3090 tempax = pVBInfo->VT ;
3091 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3092 tempbx = LCDPtr1->LCDVDES ;
3094 tempbx = LCDPtr->LCDVDES ;
3095 tempcx = pVBInfo->VDE ;
3097 tempbx = tempbx & 0x0fff ;
3099 if ( tempcx >= tempax )
3102 XGINew_SetReg1( pVBInfo->Part1Port , 0x1b , ( USHORT )( tempbx & 0xff ) ) ;
3103 XGINew_SetReg1( pVBInfo->Part1Port , 0x1c , ( USHORT )( tempcx & 0xff ) ) ;
3105 tempbx = ( tempbx >> 8 ) & 0x07 ;
3106 tempcx = ( tempcx >> 8 ) & 0x07 ;
3108 XGINew_SetReg1( pVBInfo->Part1Port , 0x1d , ( USHORT )( ( tempcx << 3 ) | tempbx ) ) ;
3110 tempax = pVBInfo->VT ;
3111 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3112 tempbx = LCDPtr1->LCDVRS ;
3114 tempbx = LCDPtr->LCDVRS ;
3116 /* tempbx = tempbx >> 4 ; */
3119 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3120 tempcx = LCDPtr1->LCDVSync ;
3123 if ( tempcx >= tempax )
3126 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , ( USHORT )( tempbx & 0xff ) ) ;
3127 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , ~0x0f , ( USHORT )( tempcx & 0x0f ) ) ;
3129 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3131 tempbx = pVBInfo->VGAVDE ;
3132 if ( tempbx != pVBInfo->VDE )
3135 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3138 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3140 tempcx = pVBInfo->VGAVT ;
3141 tempbx = pVBInfo->VDE ;
3142 tempax = pVBInfo->VGAVDE ;
3145 temp = tempax ; /* 0430 ylshieh */
3146 temp1 = ( temp << 18 ) / tempbx ;
3148 tempdx = ( USHORT )( ( temp << 18 ) % tempbx ) ;
3156 XGINew_SetReg1( pVBInfo->Part1Port , 0x37 , ( USHORT )( temp2 & 0xff ) ) ;
3157 XGINew_SetReg1( pVBInfo->Part1Port , 0x36 , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3159 tempbx = ( USHORT )( temp2 >> 16 ) ;
3160 tempax = tempbx & 0x03 ;
3162 tempbx = pVBInfo->VGAVDE ;
3163 if ( tempbx == pVBInfo->VDE )
3166 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3168 if ( pVBInfo->VBType & VB_XGI301C )
3171 XGINew_SetReg1( pVBInfo->Part4Port , 0x3c , ( USHORT )( temp2 & 0xff ) ) ;
3172 XGINew_SetReg1( pVBInfo->Part4Port , 0x3b , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3173 tempbx = ( USHORT )( temp2 >> 16 ) ;
3174 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x3a , ~0xc0 , ( USHORT )( ( tempbx & 0xff ) << 6 ) ) ;
3176 tempcx = pVBInfo->VGAVDE ;
3177 if ( tempcx == pVBInfo->VDE )
3178 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3180 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3183 tempcx = pVBInfo->VGAHDE ;
3184 tempbx = pVBInfo->HDE ;
3186 temp1 = tempcx << 16 ;
3188 tempax = ( USHORT )( temp1 / tempbx ) ;
3190 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3194 temp1 = pVBInfo->VGAHDE << 16 ;
3197 temp3 = temp3 << 16 ;
3200 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3202 tempax = ( USHORT )( temp3 & 0xff ) ;
3203 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3205 temp1 = pVBInfo->VGAVDE << 18 ;
3206 temp1 = temp1 / push3 ;
3207 tempbx = ( USHORT )( temp1 & 0xffff ) ;
3209 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3212 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
3213 tempax |= ( USHORT )( ( temp3 >> 8 ) & 0x07 ) ;
3214 XGINew_SetReg1( pVBInfo->Part1Port , 0x20 , ( USHORT )( tempax & 0xff ) ) ;
3215 XGINew_SetReg1( pVBInfo->Part1Port , 0x21 , ( USHORT )( tempbx & 0xff ) ) ;
3217 temp3 = temp3 >> 16 ;
3219 if ( modeflag & HalfDCLK )
3220 temp3 = temp3 >> 1 ;
3222 XGINew_SetReg1(pVBInfo->Part1Port , 0x22 , ( USHORT )( ( temp3 >> 8 ) & 0xff ) ) ;
3223 XGINew_SetReg1(pVBInfo->Part1Port , 0x23 , ( USHORT )( temp3 & 0xff ) ) ;
3229 /* --------------------------------------------------------------------- */
3230 /* Function : XGI_SetCRT2ECLK */
3234 /* --------------------------------------------------------------------- */
3235 void XGI_SetCRT2ECLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
3237 UCHAR di_0 , di_1 , tempal ;
3240 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3241 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3242 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3244 for( i = 0 ; i < 4 ; i++ )
3246 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , ~0x30 , ( USHORT )( 0x10 * i ) ) ;
3247 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3249 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3250 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3252 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3254 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3255 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3259 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3260 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3266 /* --------------------------------------------------------------------- */
3267 /* Function : XGI_UpdateModeInfo */
3271 /* --------------------------------------------------------------------- */
3272 void XGI_UpdateModeInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
3280 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3284 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3286 if ( !( temp & 0x20 ) )
3288 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3291 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3292 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3294 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3296 if ( !( temp & 0x40 ) )
3297 tempcl |= ActiveCRT1 ;
3301 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3304 if ( !( temp == 0x08 ) )
3306 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3307 if ( tempax & 0x04 )
3308 tempcl = tempcl | ActiveLCD ;
3312 if ( !( tempcl & ActiveLCD ) )
3314 tempcl |= ActiveCRT2 ;
3317 tempcl |= ActiveLCD ;
3321 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3323 if( !( temp & 0x08 ) )
3324 tempch |= ActiveAVideo ;
3326 if ( !( temp & 0x04 ) )
3327 tempch |= ActiveSVideo ;
3330 tempch |= ActiveSCART ;
3332 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3335 tempch |= ActiveHiTV ;
3338 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3340 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3343 tempch |= ActiveYPbPr ;
3347 tempcl |= ActiveTV ;
3351 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3352 if ( tempcl & ActiveLCD )
3354 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3356 if ( temp & ActiveTV )
3357 tempcl |= ActiveTV ;
3361 tempbl = ~ModeSwitchStatus ;
3362 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3364 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3365 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3374 /* --------------------------------------------------------------------- */
3375 /* Function : XGI_GetVGAType */
3379 /* --------------------------------------------------------------------- */
3380 void XGI_GetVGAType( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3383 if ( HwDeviceExtension->jChipType >= XG20 )
3385 pVBInfo->Set_VGAType = XG20;
3387 else if ( HwDeviceExtension->jChipType >= XG40 )
3389 pVBInfo->Set_VGAType = VGA_XGI340 ;
3392 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3396 /* --------------------------------------------------------------------- */
3397 /* Function : XGI_GetVBType */
3401 /* --------------------------------------------------------------------- */
3402 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo)
3404 USHORT flag , tempbx , tempah ;
3406 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3408 pVBInfo->VBType = VB_CH7007 ;
3411 if ( pVBInfo->IF_DEF_LVDS == 0 )
3413 tempbx = VB_XGI302B ;
3414 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3417 tempbx = VB_XGI301 ;
3418 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3421 tempbx = VB_XGI301B ;
3424 tempbx = VB_XGI301C ;
3427 tempbx = VB_XGI301LV ;
3430 tempbx = VB_XGI302LV ;
3431 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3432 if ( tempah != 0xFF )
3433 tempbx = VB_XGI301C ;
3438 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3440 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3442 if ( !( flag & 0x02 ) )
3443 tempbx = tempbx | VB_NoLCD ;
3447 pVBInfo->VBType = tempbx ;
3450 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3451 pVBInfo->VBType = VB_CH7017 ;
3453 pVBInfo->VBType = VB_LVDS_NS ;
3459 /* --------------------------------------------------------------------- */
3460 /* Function : XGI_GetVBInfo */
3464 /* --------------------------------------------------------------------- */
3465 void XGI_GetVBInfo( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
3473 if ( ModeNo <= 0x13 )
3475 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3479 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3482 pVBInfo->SetFlag = 0 ;
3483 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3486 if ( pVBInfo->VBType & 0xFFFF )
3488 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3489 tempbx = tempbx | temp ;
3490 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3493 tempax = temp << 8 ;
3494 tempbx = tempbx | tempax ;
3495 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3496 temp = 0xFFFF ^ temp ;
3499 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3501 if ( pVBInfo->IF_DEF_LCDA == 1 )
3504 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3506 if ( pVBInfo->IF_DEF_LVDS == 0 )
3508 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3509 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3511 if ( temp & EnableDualEdge )
3513 tempbx |= SetCRT2ToDualEdge ;
3515 if ( temp & SetToLCDA )
3516 tempbx |= SetCRT2ToLCDA ;
3520 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3522 if ( pVBInfo->VBType & VB_CH7017 )
3524 if ( temp & EnableDualEdge )
3526 tempbx |= SetCRT2ToDualEdge ;
3528 if ( temp & SetToLCDA )
3529 tempbx |= SetCRT2ToLCDA ;
3536 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3538 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3539 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3541 if ( temp & SetYPbPr ) /* temp = CR38 */
3543 if ( pVBInfo->IF_DEF_HiVision == 1 )
3545 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3547 tempbx |= SetCRT2ToHiVisionTV ;
3549 if ( temp != YPbPrMode1080i ) {
3550 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3551 tempbx |= SetCRT2ToYPbPr ; }
3554 /* tempbx |= SetCRT2ToYPbPr ; */
3559 tempax = push ; /* restore CR31 */
3561 if ( pVBInfo->IF_DEF_LVDS == 0 )
3563 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3565 if ( pVBInfo->IF_DEF_HiVision == 1 )
3572 if ( pVBInfo->IF_DEF_HiVision == 1 )
3578 else /* 3nd party chip */
3580 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3581 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3582 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3584 temp = SetCRT2ToTV ;
3587 temp = SetCRT2ToLCD ;
3590 if ( !( tempbx & temp ) )
3592 tempax |= DisableCRT2Display ;
3596 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3598 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3600 if ( tempbx & SetCRT2ToLCDA )
3602 if ( tempbx & SetSimuScanMode )
3603 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3605 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3611 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3613 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3615 if ( tempbx & SetCRT2ToRAMDAC )
3617 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3618 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3622 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3625 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3627 if ( tempbx & SetCRT2ToLCD )
3629 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3630 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3634 if ( tempbx & SetCRT2ToSCART )
3636 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3637 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3640 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3642 if ( tempbx & SetCRT2ToYPbPr )
3643 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3646 if ( pVBInfo->IF_DEF_HiVision == 1 )
3648 if ( tempbx & SetCRT2ToHiVisionTV )
3649 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3652 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3654 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3655 tempbx = DisableCRT2Display ;
3658 if ( !( tempbx & DisableCRT2Display ) )
3660 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3662 if ( pVBInfo->IF_DEF_LCDA == 1 )
3664 if ( !( tempbx & SetCRT2ToLCDA ) )
3665 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3668 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3670 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3671 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3672 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3673 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3677 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3679 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3680 pVBInfo->SetFlag |= EnableVCMode ;
3687 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3688 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3690 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3691 pVBInfo->SetFlag |= ReserveTVOption ;
3696 pVBInfo->VBInfo = tempbx ;
3700 /* --------------------------------------------------------------------- */
3701 /* Function : XGI_GetTVInfo */
3705 /* --------------------------------------------------------------------- */
3706 void XGI_GetTVInfo( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo )
3717 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3719 if ( ModeNo <= 0x13 )
3721 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3722 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3726 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3727 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3730 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3732 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3734 if ( tempbx & SetPALTV )
3736 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3737 if ( tempbx & SetPALMTV )
3738 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3741 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3743 if ( pVBInfo->IF_DEF_LVDS == 0 )
3745 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3746 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3748 if ( temp2 & 0x02 ) //PAL-M
3749 tempbx &= ( ~SetPALTV ) ;
3754 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3756 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3758 if ( tempbx & TVOverScan )
3759 tempbx |= SetCHTVOverScan ;
3762 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3764 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3766 if ( tempbx & TVOverScan )
3768 tempbx |= SetCHTVOverScan ;
3773 if ( pVBInfo->IF_DEF_LVDS == 0 )
3775 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3776 tempbx |= SetPALTV ;
3779 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3781 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3783 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3784 index1 &= YPbPrMode ;
3786 if ( index1 == YPbPrMode525i )
3787 tempbx |= SetYPbPrMode525i ;
3789 if ( index1 == YPbPrMode525p )
3790 tempbx = tempbx | SetYPbPrMode525p;
3791 if ( index1 == YPbPrMode750p)
3792 tempbx = tempbx | SetYPbPrMode750p;
3796 if ( pVBInfo->IF_DEF_HiVision == 1 )
3798 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3800 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3804 if ( pVBInfo->IF_DEF_LVDS == 0 )
3806 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3807 tempbx |= TVSimuMode ;
3809 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3810 tempbx |= NTSC1024x768 ;
3812 tempbx |= RPLLDIV2XO ;
3814 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3816 if ( pVBInfo->VBInfo & SetInSlaveMode )
3817 tempbx &=( ~RPLLDIV2XO ) ;
3821 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3822 tempbx &= ( ~RPLLDIV2XO ) ;
3823 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3825 if ( tempbx & TVSimuMode )
3826 tempbx &= ( ~RPLLDIV2XO ) ;
3831 pVBInfo->TVInfo = tempbx ;
3835 /* --------------------------------------------------------------------- */
3836 /* Function : XGI_GetLCDInfo */
3840 /* --------------------------------------------------------------------- */
3841 BOOLEAN XGI_GetLCDInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
3850 pVBInfo->LCDResInfo = 0 ;
3851 pVBInfo->LCDTypeInfo = 0 ;
3852 pVBInfo->LCDInfo = 0 ;
3854 if ( ModeNo <= 0x13 )
3856 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3860 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3861 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3864 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3865 tempbx = temp & 0x0F ;
3868 tempbx = Panel1024x768 ; /* default */
3870 /* LCD75 [2003/8/22] Vicent */
3871 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3873 if ( pVBInfo->VBInfo & DriverMode )
3875 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3876 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3879 tempax = tempax >> 4 ;
3881 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3884 tempbx |= PanelRef75Hz ;
3886 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3889 tempbx |= PanelRef75Hz ;
3894 pVBInfo->LCDResInfo = tempbx ;
3898 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3900 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3903 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3910 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3912 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3914 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3915 temp &= ~EnableScalingLCD ;
3919 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3921 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3923 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3925 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3927 tempbx |= SetLCDDualLink ;
3931 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3933 if ( tempax & LCDDualLink )
3935 tempbx |= SetLCDDualLink ;
3939 if ( pVBInfo->IF_DEF_LVDS == 0 )
3941 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3942 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3946 if ( tempax & LCDBToA )
3948 tempbx |= SetLCDBToA ;
3952 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3954 if ( modeflag & HalfDCLK )
3956 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3957 if ( !( tempbx & SetLCDtoNonExpanding ) )
3959 tempbx |= EnableLVDSDDA ;
3963 if ( ModeNo > 0x13 )
3965 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3969 tempbx |= EnableLVDSDDA ;
3977 if ( pVBInfo->VBInfo & SetInSlaveMode )
3979 if ( pVBInfo->VBInfo & SetNotSimuMode )
3981 tempbx |= LCDVESATiming ;
3986 tempbx |= LCDVESATiming ;
3989 pVBInfo->LCDInfo = tempbx ;
3991 if ( pVBInfo->IF_DEF_PWD == 1 )
3993 if ( pVBInfo->LCDInfo & SetPWDEnable )
3995 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3997 if ( !( tempax & PWDEnable ) )
3999 pVBInfo->LCDInfo &= ~SetPWDEnable ;
4005 if ( pVBInfo->IF_DEF_LVDS == 0 )
4007 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
4009 if ( pVBInfo->VBInfo & SetInSlaveMode )
4011 if ( !( tempax & LockLCDBToA ) )
4013 if ( ModeNo <= 0x13 )
4015 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
4016 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
4024 if ( pVBInfo->IF_DEF_LVDS == 0 )
4026 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
4028 if ( pVBInfo->VBInfo & SetInSlaveMode )
4030 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
4032 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
4033 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
4044 /* --------------------------------------------------------------------- */
4045 /* Function : XGI_SearchModeID */
4049 /* --------------------------------------------------------------------- */
4050 BOOLEAN XGI_SearchModeID( USHORT ModeNo , USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
4058 if ( ModeNo <= 0x13 )
4060 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
4061 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4063 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == ModeNo )
4065 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == 0xFF )
4069 VGA_INFO = ( PUCHAR )MK_FP( 0 , 0x489 ) ;
4071 if ( ModeNo == 0x07 )
4073 if ( ( *VGA_INFO & 0x10 ) != 0 )
4074 ( *ModeIdIndex )++ ; /* 400 lines */
4075 /* else 350 lines */
4080 if ( ( *VGA_INFO & 0x80 ) == 0 )
4082 ( *ModeIdIndex )++ ;
4083 if ( ( *VGA_INFO & 0x10 ) != 0 )
4084 ( *ModeIdIndex )++ ; /* 400 lines */
4085 /* else 350 lines */
4087 /* else 200 lines */
4092 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4093 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4095 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == ModeNo )
4097 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == 0xFF )
4109 if ( ModeNo <= 0x13 )
4111 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
4112 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4114 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == ModeNo )
4116 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == 0xFF )
4120 if ( ModeNo == 0x07 )
4121 ( *ModeIdIndex )++ ; /* 400 lines */
4124 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4125 /* else 350 lines */
4129 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4130 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4132 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == ModeNo )
4134 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == 0xFF )
4141 #ifdef LINUX /* chiawen for linux solution */
4145 if ( ModeNo <= 0x13 )
4147 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
4148 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4150 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == ModeNo )
4152 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == 0xFF )
4156 if ( ModeNo == 0x07 )
4157 ( *ModeIdIndex )++ ; /* 400 lines */
4160 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4161 /* else 350 lines */
4165 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4166 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4168 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == ModeNo )
4170 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == 0xFF )
4183 /* win2000 MM adapter not support standard mode! */
4185 /* --------------------------------------------------------------------- */
4190 /* --------------------------------------------------------------------- */
4191 BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4199 /* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4200 ( HwDeviceExtension->jChipType == XGI_650M ) )
4205 if ( ModeNo <= 0x13 )
4207 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4210 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4213 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4215 memorysize = modeflag & MemoryInfoFlag ;
4216 memorysize = memorysize > MemorySizeShift ;
4217 memorysize++ ; /* Get memory size */
4219 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4222 if ( HwDeviceExtension->jChipType == XG40 )
4224 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4225 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4229 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4234 else if ( HwDeviceExtension->jChipType == XG42 )
4236 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4237 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4242 else if ( HwDeviceExtension->jChipType == XG45 )
4244 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4245 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4249 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4255 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4260 if ( temp < memorysize )
4267 /* --------------------------------------------------------------------- */
4268 /* Function : XGINew_IsLowResolution */
4272 /* --------------------------------------------------------------------- */
4273 /*void XGINew_IsLowResolution( USHORT ModeNo , USHORT ModeIdIndex, BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4278 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4280 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4282 if ( ModeNo > 0x13 )
4284 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4285 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4287 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4289 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4290 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4292 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4299 /* --------------------------------------------------------------------- */
4300 /* Function : XGI_DisplayOn */
4304 /* --------------------------------------------------------------------- */
4305 void XGI_DisplayOn( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4308 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4309 if ( pXGIHWDE->jChipType == XG21 )
4311 if ( pVBInfo->IF_DEF_LVDS == 1 )
4313 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4315 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4316 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4318 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4320 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4322 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4323 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4327 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4332 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4335 if ( IsCH7007TVMode( pVBInfo ) )
4337 TurnOnCH7007(pXGIHWDE->pDevice) ; /* 07/05/28 */
4344 if ( pXGIHWDE->jChipType == XG27 )
4346 if ( pVBInfo->IF_DEF_LVDS == 1 )
4348 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4350 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4351 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4353 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4355 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4357 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4358 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4362 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4369 /* --------------------------------------------------------------------- */
4370 /* Function : XGI_DisplayOff */
4374 /* --------------------------------------------------------------------- */
4375 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4378 if ( pXGIHWDE->jChipType == XG21 )
4380 if ( pVBInfo->IF_DEF_LVDS == 1 )
4382 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4383 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4387 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4391 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4393 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4396 TurnOffCH7007(pXGIHWDE->pDevice) ; /* 07/05/28 */
4402 if ( pXGIHWDE->jChipType == XG27 )
4404 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4406 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4407 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4410 if ( pVBInfo->IF_DEF_LVDS == 0 )
4412 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4416 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4420 /* --------------------------------------------------------------------- */
4421 /* Function : XGI_WaitDisply */
4424 /* Description : chiawen for sensecrt1 */
4425 /* --------------------------------------------------------------------- */
4426 void XGI_WaitDisply( PVB_DEVICE_INFO pVBInfo )
4428 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4431 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4435 /* --------------------------------------------------------------------- */
4436 /* Function : XGI_SenseCRT1 */
4440 /* --------------------------------------------------------------------- */
4442 void XGI_SenseCRT1( PVB_DEVICE_INFO pVBInfo )
4444 UCHAR CRTCData[ 17 ] = { 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4445 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4446 0x04 , 0x00 , 0x00 , 0x05 , 0x00 } ;
4448 UCHAR SR01 = 0 , SR1F = 0 , SR07 = 0 , SR06 = 0 ;
4450 UCHAR CR17 , CR63 , SR31 ;
4452 UCHAR DAC_TEST_PARMS[ 3 ] = { 0x0F , 0x0F , 0x0F } ;
4455 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4457 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4458 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4459 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) | 0x02 ) ) ;
4461 SR31 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) ;
4462 CR63 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
4463 SR01 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4465 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , ( UCHAR )( SR01 & 0xDF ) ) ;
4466 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , ( UCHAR )( CR63 & 0xBF ) ) ;
4468 CR17 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
4469 XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , ( UCHAR )( CR17 | 0x80 ) ) ;
4471 SR1F = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
4472 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR )( SR1F | 0x04 ) ) ;
4474 SR07 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x07 ) ;
4475 XGINew_SetReg1( pVBInfo->P3c4 , 0x07 , ( UCHAR )( SR07 & 0xFB ) ) ;
4476 SR06 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x06 ) ;
4477 XGINew_SetReg1( pVBInfo->P3c4 , 0x06 , ( UCHAR )( SR06 & 0xC3 ) ) ;
4479 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4481 for( i = 0 ; i < 8 ; i++ )
4482 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )i , CRTCData[ i ] ) ;
4484 for( i = 8 ; i < 11 ; i++ )
4485 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 8 ) , CRTCData[ i ] ) ;
4487 for( i = 11 ; i < 13 ; i++ )
4488 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 4 ) , CRTCData[ i ] ) ;
4490 for( i = 13 ; i < 16 ; i++ )
4491 XGINew_SetReg1( pVBInfo->P3c4 , ( USHORT )( i - 3 ) , CRTCData[ i ] ) ;
4493 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , ( UCHAR )( CRTCData[ 16 ] & 0xE0 ) ) ;
4495 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4496 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4497 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4499 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4501 for( i = 0 ; i < 256 ; i++ )
4503 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 0 ] ) ;
4504 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 1 ] ) ;
4505 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 2 ] ) ;
4508 XGI_VBLongWait( pVBInfo ) ;
4509 XGI_VBLongWait( pVBInfo ) ;
4510 XGI_VBLongWait( pVBInfo ) ;
4512 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4514 XGI_WaitDisply( pVBInfo ) ;
4515 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4519 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4523 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4526 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4527 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4529 for( i = 0 ; i < 256 ; i++ )
4531 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4532 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4533 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4536 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4537 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4538 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4540 /* [2004/05/11] Vicent */
4541 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) & 0xFD ) ) ;
4542 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR ) SR1F ) ;
4550 /* --------------------------------------------------------------------- */
4551 /* Function : INT1AReturnCode */
4555 /* --------------------------------------------------------------------- */
4556 int INT1AReturnCode( union REGS regs )
4560 /* printf( "Error to find pci device!\n" ) ; */
4569 printf( "Function not support\n" ) ;
4572 printf( "bad vendor id\n" ) ;
4575 printf( "device not found\n" ) ;
4578 printf( "bad register number\n" ) ;
4581 printf( "set failed\n" ) ;
4584 printf( "buffer too small" ) ;
4593 /* --------------------------------------------------------------------- */
4594 /* Function : FindPCIIOBase */
4598 /* --------------------------------------------------------------------- */
4599 unsigned FindPCIIOBase( unsigned index , unsigned deviceid )
4603 regs.h.ah = 0xb1 ; /* PCI_FUNCTION_ID */
4604 regs.h.al = 0x02 ; /* FIND_PCI_DEVICE */
4605 regs.x.cx = deviceid ;
4606 regs.x.dx = 0x1039 ;
4607 regs.x.si = index ; /* find n-th device */
4609 int86( 0x1A , ®s , ®s ) ;
4611 if ( INT1AReturnCode( regs ) != 0 )
4614 /* regs.h.bh bus number */
4615 /* regs.h.bl device number */
4616 regs.h.ah = 0xb1 ; /* PCI_FUNCTION_ID */
4617 regs.h.al = 0x09 ; /* READ_CONFIG_WORD */
4618 regs.x.cx = deviceid ;
4619 regs.x.dx = 0x1039 ;
4620 regs.x.di = 0x18 ; /* register number */
4621 int86( 0x1A , ®s , ®s ) ;
4623 if ( INT1AReturnCode( regs ) != 0 )
4626 return( regs.x.cx ) ;
4634 /* --------------------------------------------------------------------- */
4635 /* Function : main */
4639 /* --------------------------------------------------------------------- */
4640 void main(int argc, char *argv[])
4642 XGI_HW_DEVICE_INFO HwDeviceExtension ;
4646 /* HwDeviceExtension.pjVirtualRomBase =(PUCHAR) MK_FP(0xC000,0); */
4647 /* HwDeviceExtension.pjVideoMemoryAddress = (PUCHAR)MK_FP(0xA000,0); */
4650 HwDeviceExtension.pjIOAddress = ( FindPCIIOBase( 0 ,0x6300 ) & 0xFF80 ) + 0x30 ;
4651 HwDeviceExtension.jChipType = XGI_340 ;
4655 /* HwDeviceExtension.pjIOAddress = ( FindPCIIOBase( 0 , 0x5315 ) & 0xFF80 ) + 0x30 ; */
4657 HwDeviceExtension.pjIOAddress = ( FindPCIIOBase( 0 , 0x330 ) & 0xFF80 ) + 0x30 ;
4658 HwDeviceExtension.jChipType = XGI_340 ;
4661 HwDeviceExtension.ujVBChipID = VB_CHIP_301 ;
4662 StrCpy(HwDeviceExtension.szVBIOSVer , "0.84" ) ;
4663 HwDeviceExtension.bSkipDramSizing = FALSE ;
4664 HwDeviceExtension.ulVideoMemorySize = 0 ;
4668 ModeNo = atoi( argv[ 1 ] ) ;
4673 /* ModeNo = 0x37 ; 1024x768x 4bpp */
4674 /* ModeNo = 0x38 ; 1024x768x 8bpp */
4675 /* ModeNo = 0x4A ; 1024x768x 16bpp */
4676 /* ModeNo = 0x47 ; 800x600x 16bpp */
4679 /* XGIInitNew( &HwDeviceExtension ) ; */
4680 XGISetModeNew( &HwDeviceExtension , ModeNo ) ;
4685 /* --------------------------------------------------------------------- */
4686 /* Function : XGI_WaitDisplay */
4690 /* --------------------------------------------------------------------- */
4691 void XGI_WaitDisplay( PVB_DEVICE_INFO pVBInfo )
4693 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4695 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4701 /* --------------------------------------------------------------------- */
4702 /* Function : XGI_SetCRT2Group301 */
4706 /* --------------------------------------------------------------------- */
4707 BOOLEAN XGI_SetCRT2Group301( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
4711 RefreshRateTableIndex ;
4713 tempbx=pVBInfo->VBInfo ;
4714 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4715 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4716 pVBInfo->SelectCRT2Rate = 4 ;
4717 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4718 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4719 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4720 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4721 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4722 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4723 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4724 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4725 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4726 XGI_SetTap4Regs(pVBInfo) ;
4727 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4728 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4729 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4730 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4731 XGI_AutoThreshold( pVBInfo) ;
4736 /* --------------------------------------------------------------------- */
4737 /* Function : XGI_AutoThreshold */
4741 /* --------------------------------------------------------------------- */
4742 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo )
4744 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4745 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4749 /* --------------------------------------------------------------------- */
4750 /* Function : XGI_SaveCRT2Info */
4754 /* --------------------------------------------------------------------- */
4755 void XGI_SaveCRT2Info( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo)
4760 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4761 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4762 temp2 = ~( SetInSlaveMode >> 8 ) ;
4763 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4767 /* --------------------------------------------------------------------- */
4768 /* Function : XGI_GetCRT2ResInfo */
4772 /* --------------------------------------------------------------------- */
4773 void XGI_GetCRT2ResInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
4780 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4781 if ( ModeNo <= 0x13 )
4783 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4784 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4785 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4789 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4790 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4791 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4793 /* if ( pVBInfo->IF_DEF_FSTN )
4801 if ( modeflag & HalfDCLK )
4804 if ( modeflag & DoubleScanMode )
4809 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4811 if ( pVBInfo->IF_DEF_LVDS == 0 )
4813 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4815 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4822 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4826 else if ( yres == 350 )
4829 if ( pVBInfo->LCDInfo & LCDVESATiming )
4836 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4838 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4840 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4844 else if ( yres == 400 )
4846 else if ( yres == 480 )
4857 pVBInfo->VGAHDE = xres ;
4858 pVBInfo->HDE = xres ;
4859 pVBInfo->VGAVDE = yres ;
4860 pVBInfo->VDE = yres ;
4864 /* --------------------------------------------------------------------- */
4865 /* Function : XGI_IsLCDDualLink */
4869 /* --------------------------------------------------------------------- */
4870 BOOLEAN XGI_IsLCDDualLink( PVB_DEVICE_INFO pVBInfo )
4873 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4880 /* --------------------------------------------------------------------- */
4881 /* Function : XGI_GetCRT2Data */
4885 /* --------------------------------------------------------------------- */
4886 void XGI_GetCRT2Data( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4893 XGI_LCDDataStruct *LCDPtr = NULL ;
4894 XGI_TVDataStruct *TVPtr = NULL ;
4896 if ( ModeNo <= 0x13 )
4898 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4899 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4903 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4904 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4907 pVBInfo->NewFlickerMode = 0 ;
4908 pVBInfo->RVBHRS = 50 ;
4910 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4912 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4918 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4920 LCDPtr = (XGI_LCDDataStruct* )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4922 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4923 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4924 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4925 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4926 pVBInfo->HT = LCDPtr->LCDHT ;
4927 pVBInfo->VT = LCDPtr->LCDVT ;
4929 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4934 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4936 if ( pVBInfo->VGAVDE == 357 )
4938 else if ( pVBInfo->VGAVDE == 420 )
4940 else if ( pVBInfo->VGAVDE == 525 )
4942 else if ( pVBInfo->VGAVDE == 600 )
4944 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4945 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4952 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4957 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4960 if ( pVBInfo->VGAVDE == 360 )
4962 else if ( pVBInfo->VGAVDE == 375 )
4964 else if ( pVBInfo->VGAVDE == 405 )
4969 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4974 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4977 if ( pVBInfo->VGAVDE == 350 )
4979 else if ( pVBInfo->VGAVDE == 400 )
4981 else if ( pVBInfo->VGAVDE == 1024 )
4986 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4991 if ( pVBInfo->VGAVDE == 1024 )
4997 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
5000 tempbx = 1200 ; /* alan 10/14/2003 */
5001 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5003 if ( pVBInfo->VGAVDE == 350 )
5005 else if ( pVBInfo->VGAVDE == 400 )
5010 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5012 tempax = pVBInfo->VGAHDE ;
5013 tempbx = pVBInfo->VGAVDE ;
5016 pVBInfo->HDE = tempax ;
5017 pVBInfo->VDE = tempbx ;
5021 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
5024 TVPtr = ( XGI_TVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
5026 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
5027 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
5028 pVBInfo->VGAHT = TVPtr->VGAHT ;
5029 pVBInfo->VGAVT = TVPtr->VGAVT ;
5030 pVBInfo->HDE = TVPtr->TVHDE ;
5031 pVBInfo->VDE = TVPtr->TVVDE ;
5032 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
5033 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
5035 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5037 if ( resinfo == 0x08 )
5038 pVBInfo->NewFlickerMode = 0x40 ;
5039 else if ( resinfo == 0x09 )
5040 pVBInfo->NewFlickerMode = 0x40 ;
5041 else if ( resinfo == 0x12 )
5042 pVBInfo->NewFlickerMode = 0x40 ;
5044 if ( pVBInfo->VGAVDE == 350 )
5045 pVBInfo->TVInfo |= TVSimuMode ;
5047 tempax = ExtHiTVHT ;
5048 tempbx = ExtHiTVVT ;
5050 if ( pVBInfo->VBInfo & SetInSlaveMode )
5052 if ( pVBInfo->TVInfo & TVSimuMode )
5057 if ( !( modeflag & Charx8Dot ) )
5059 tempax = StHiTextTVHT ;
5060 tempbx = StHiTextTVVT ;
5065 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5067 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5069 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
5070 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
5073 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5075 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
5076 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
5078 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5080 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
5081 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
5082 if ( pVBInfo->TVInfo & NTSC1024x768 )
5083 tempax = NTSC1024x768HT ;
5090 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5094 if ( pVBInfo->TVInfo & NTSC1024x768 )
5095 tempax = NTSC1024x768HT ;
5099 pVBInfo->HT = tempax ;
5100 pVBInfo->VT = tempbx ;
5106 /* --------------------------------------------------------------------- */
5107 /* Function : XGI_SetCRT2VCLK */
5111 /* --------------------------------------------------------------------- */
5112 void XGI_SetCRT2VCLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5118 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
5119 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
5120 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
5122 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
5124 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
5125 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
5126 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
5129 { /* 301b/302b/301lv/302lv */
5130 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
5131 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
5134 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
5136 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5137 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
5139 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
5143 /* --------------------------------------------------------------------- */
5144 /* Function : XGI_GETLCDVCLKPtr */
5146 /* Output : al -> VCLK Index */
5148 /* --------------------------------------------------------------------- */
5149 void XGI_GetLCDVCLKPtr( UCHAR* di_0 , UCHAR *di_1, PVB_DEVICE_INFO pVBInfo )
5153 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
5155 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
5157 if ( pVBInfo->LCDInfo & EnableScalingLCD )
5161 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
5162 index = XGI_GetLCDCapPtr1( pVBInfo) ;
5164 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5166 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
5167 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
5171 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
5172 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
5179 /* --------------------------------------------------------------------- */
5180 /* Function : XGI_GetVCLKPtr */
5184 /* --------------------------------------------------------------------- */
5185 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
5195 UCHAR *CHTVVCLKPtr = NULL ;
5197 if ( ModeNo <= 0x13 )
5198 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5200 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5203 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
5205 index = XGI_GetLCDCapPtr(pVBInfo) ;
5206 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
5208 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
5212 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
5214 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
5216 tempal = HiTVVCLKDIV2;
5217 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
5219 if(pVBInfo->TVInfo & TVSimuMode)
5221 tempal = HiTVSimuVCLK;
5222 if(!(modeflag & Charx8Dot))
5223 tempal = HiTVTextVCLK;
5229 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5231 tempal = YPbPr750pVCLK ;
5235 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5237 tempal = YPbPr525pVCLK ;
5241 tempal = NTSC1024VCLK ;
5243 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
5245 tempal = TVVCLKDIV2 ;
5246 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
5250 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5254 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
5257 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5259 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5260 *tempal = *tempal & 0x1F;
5263 if(pVBInfo->TVInfo & SetPALTV)
5264 tempbx = tempbx + 2;
5265 if(pVBInfo->TVInfo & SetCHTVOverScan)
5267 tempbx = tempbx << 1;
5271 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
5273 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
5274 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
5276 if( ModeNo <= 0x13 )
5278 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5282 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5285 tempal = tempal & 0x0F;
5288 if(pVBInfo->TVInfo & SetPALTV)
5290 tempbx = tempbx + 2;
5292 if(pVBInfo->TVInfo & SetCHTVOverScan)
5296 /** tempbx = tempbx << 1; CH7007 ? **/
5298 /*[Billy]07/05/29 CH7007*/
5299 if ( pVBInfo->IF_DEF_CH7007 == 1 )
5304 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
5307 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5310 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5313 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5325 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5328 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5331 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5334 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5341 tempal = CHTVVCLKPtr[ tempal ] ;
5347 tempal = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ;
5348 tempal = tempal >> 2 ;
5351 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5352 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5354 if ( ModeNo <= 0x13 )
5357 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5362 /* --------------------------------------------------------------------- */
5363 /* Function : XGI_GetVCLKLen */
5367 /* --------------------------------------------------------------------- */
5368 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo)
5370 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5372 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5373 *di_0 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2B ;
5374 *di_1 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2C ;
5376 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5378 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5380 *di_0 = ( UCHAR )XGI_VBVCLKData[ tempal ].SR2B ;
5381 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5386 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5387 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5392 /* --------------------------------------------------------------------- */
5393 /* Function : XGI_SetCRT2Offset */
5397 /* --------------------------------------------------------------------- */
5398 void XGI_SetCRT2Offset( USHORT ModeNo ,
5399 USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5404 if ( pVBInfo->VBInfo & SetInSlaveMode )
5409 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5410 temp = ( UCHAR )( offset & 0xFF ) ;
5411 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5412 temp =( UCHAR)( ( offset & 0xFF00 ) >> 8 ) ;
5413 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , temp ) ;
5414 temp =( UCHAR )( ( ( offset >> 3 ) & 0xFF ) + 1 ) ;
5415 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5419 /* --------------------------------------------------------------------- */
5420 /* Function : XGI_GetOffset */
5424 /* --------------------------------------------------------------------- */
5425 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
5432 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5434 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5435 if ( ModeNo <= 0x14 )
5438 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5441 index = ( modeinfo >> 8 ) & 0xFF ;
5443 temp = pVBInfo->ScreenOffset[ index ] ;
5445 if ( infoflag & InterlaceMode )
5450 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5452 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5454 temp = ModeNo - 0x7C ;
5455 colordepth = ColorDepth[ temp ] ;
5457 if ( infoflag & InterlaceMode )
5461 return( temp * colordepth ) ;
5464 return( temp * colordepth ) ;
5468 /* --------------------------------------------------------------------- */
5469 /* Function : XGI_SetCRT2FIFO */
5473 /* --------------------------------------------------------------------- */
5474 void XGI_SetCRT2FIFO( PVB_DEVICE_INFO pVBInfo)
5476 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5477 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5481 /* --------------------------------------------------------------------- */
5482 /* Function : XGI_PreSetGroup1 */
5486 /* --------------------------------------------------------------------- */
5487 void XGI_PreSetGroup1(USHORT ModeNo , USHORT ModeIdIndex ,PXGI_HW_DEVICE_INFO HwDeviceExtension,
5488 USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5494 if ( ModeNo > 0x13 )
5496 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5497 CRT1Index &= IndexMask ;
5498 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5501 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5502 XGI_SetCRT2FIFO(pVBInfo) ;
5503 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5505 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5507 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5510 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5511 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5515 /* --------------------------------------------------------------------- */
5516 /* Function : XGI_SetGroup1 */
5520 /* --------------------------------------------------------------------- */
5521 void XGI_SetGroup1( USHORT ModeNo , USHORT ModeIdIndex ,
5522 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5533 if ( ModeNo > 0x13 )
5535 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5536 CRT1Index &= IndexMask ;
5537 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5540 if ( ModeNo <= 0x13 )
5542 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5546 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5549 /* bainy change table name */
5550 if ( modeflag & HalfDCLK )
5552 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5553 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5554 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5555 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5556 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5557 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5558 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5559 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5560 tempcx = tempcx >> 1 ;
5561 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5564 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5566 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5567 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5568 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5569 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5571 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5572 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5573 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5579 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5580 tempcx = pVBInfo->VGAHT / 2 ;
5582 temp = tempbx & 0x00FF ;
5584 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5588 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5589 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5590 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5591 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5592 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5593 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5594 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5595 pushbx = pVBInfo->VGAHDE + 16 ;
5596 tempcx = tempcx >> 1 ;
5597 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5600 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5602 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5603 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5604 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5605 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5607 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5608 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5609 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5614 if ( tempcx > pVBInfo->VGAHT )
5615 tempcx = pVBInfo->VGAHT ;
5617 temp = tempbx & 0x00FF ;
5618 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5621 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5623 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5624 tempax |= ( tempbx & 0xFF00 ) ;
5625 temp = ( tempax & 0xFF00 ) >> 8 ;
5626 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5627 temp = tempcx & 0x00FF ;
5628 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5629 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5630 temp = tempcx & 0x00FF ;
5632 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5634 if ( pVBInfo->VBInfo & 0x0C )
5640 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5641 tempbx = pVBInfo->VGAVDE - 1 ;
5642 temp = tempbx & 0x00FF ;
5643 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5644 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5645 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5646 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5648 tempax = pVBInfo->VGAVDE ;
5649 tempbx = pVBInfo->VGAVDE ;
5650 tempcx = pVBInfo->VGAVT ;
5651 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5652 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5654 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5656 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5657 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5665 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5670 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5671 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5674 temp = tempbx & 0x00FF ;
5675 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5676 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5677 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5678 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5681 if ( modeflag & DoubleScanMode )
5684 if ( modeflag & HalfDCLK )
5687 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5691 /* --------------------------------------------------------------------- */
5692 /* Function : XGI_SetLockRegs */
5696 /* --------------------------------------------------------------------- */
5697 void XGI_SetLockRegs( USHORT ModeNo , USHORT ModeIdIndex ,
5698 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5710 if ( ModeNo <= 0x13 )
5712 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5713 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5717 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5718 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5719 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5720 CRT1Index &= IndexMask;
5723 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5728 temp = 0xFF ; /* set MAX HT */
5729 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5730 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5734 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5735 modeflag |= Charx8Dot ;
5737 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5739 if ( modeflag & HalfDCLK )
5740 tempax = tempax >> 1 ;
5742 tempax = ( tempax / tempcx ) - 1 ;
5743 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5744 temp = tempax & 0x00FF ;
5745 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5747 temp = ( tempbx & 0xFF00 ) >> 8 ;
5749 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5751 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5754 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5756 if ( pVBInfo->VBType & VB_XGI301LV )
5758 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5770 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5771 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5773 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5774 { /* 030226 bainy */
5775 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5776 tempax = pVBInfo->VGAHT ;
5778 tempax = XGI_GetVGAHT2( pVBInfo) ;
5781 if ( tempax >= pVBInfo->VGAHT )
5783 tempax = pVBInfo->VGAHT ;
5786 if ( modeflag & HalfDCLK )
5788 tempax = tempax >> 1 ;
5791 tempax = ( tempax / tempcx ) - 5 ;
5792 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5793 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5795 temp = ( tempbx & 0x00FF ) - 1 ;
5796 if ( !( modeflag & HalfDCLK ) )
5799 if ( pVBInfo->TVInfo & TVSimuMode )
5802 if ( ModeNo > 0x13 )
5809 /* tempcx = tempbx & 0x00FF ; */
5810 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5811 tempcx = ( tempcx + tempbx ) >> 1 ;
5812 temp = ( tempcx & 0x00FF ) + 2 ;
5814 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5817 if ( !( modeflag & HalfDCLK ) )
5819 if ( ( modeflag & Charx8Dot ) )
5822 if ( pVBInfo->VGAHDE >= 800 )
5831 if ( !( modeflag & HalfDCLK ) )
5834 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5836 if( pVBInfo->VGAHDE >= 800 )
5839 if ( pVBInfo->ModeType == ModeEGA )
5841 if ( pVBInfo->VGAVDE == 1024 )
5844 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5851 if ( pVBInfo->VGAHDE >= 1280 )
5853 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5855 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5867 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5868 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5870 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5872 if ( pVBInfo->TVInfo & TVSimuMode )
5874 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5876 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5877 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5880 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5882 if ( pVBInfo->TVInfo & SetNTSCTV )
5884 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5885 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5889 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5890 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5891 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5895 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5897 if ( pVBInfo->TVInfo & SetNTSCTV )
5899 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5900 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5904 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5905 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5906 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5910 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5912 if ( pVBInfo->TVInfo & SetNTSCTV )
5914 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5915 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5919 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5920 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5926 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5927 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5928 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5930 tempbx = pVBInfo->VGAVT ;
5933 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5935 if ( tempbx == 357 )
5937 if ( tempbx == 360 )
5939 if ( tempbx == 375 )
5941 if ( tempbx == 405 )
5943 if ( tempbx == 525 )
5948 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5950 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5952 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5954 if ( tempbx == 350 )
5956 if ( tempbx == 480 )
5962 temp = tempbx & 0x00FF ;
5964 temp = tempbx & 0x00FF ;
5965 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5968 temp = tempbx & 0x00FF ;
5969 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5971 if ( tempbx & 0x0100 )
5978 if ( modeflag & DoubleScanMode )
5983 if ( tempbx & 0x0200 )
5988 temp = ( tempax & 0xFF00 ) >> 8 ;
5989 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5991 if ( tempbx & 0x0400 )
5996 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5999 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
6000 tempax = tempax >> 2 ;
6001 push1 = tempax ; /* push ax */
6003 if ( resinfo != 0x09 )
6005 tempax = tempax << 1 ;
6009 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6011 if ( pVBInfo->VBType & VB_XGI301LV )
6013 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6017 if ( pVBInfo->TVInfo & TVSimuMode )
6019 if ( pVBInfo->TVInfo & SetPALTV )
6021 if ( pVBInfo->VBType & VB_XGI301LV )
6023 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6037 if ( pVBInfo->TVInfo & TVSimuMode )
6039 if ( pVBInfo->TVInfo & SetPALTV )
6041 if ( pVBInfo->VBType & VB_XGI301LV )
6043 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6052 tempax = tempax >> 2 ;
6055 push1 = tempax ; /* push ax */
6057 if ( ( pVBInfo->TVInfo & SetPALTV ) )
6059 if ( tempbx <= 513 )
6061 if ( tempax >= 513 )
6068 temp = tempbx & 0x00FF ;
6069 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
6071 temp = tempbx & 0x00FF ;
6072 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
6074 if ( tempbx & 0x0100 )
6079 if ( tempbx & 0x0200 )
6081 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
6086 if ( tempbx & 0x0100 )
6091 if ( tempbx & 0x0200 )
6096 if ( tempbx & 0x0400 )
6101 tempbx = push1 ; /* pop ax */
6102 temp = tempbx & 0x00FF ;
6104 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
6106 if ( tempbx & 0x0010 )
6111 temp = tempcx & 0x00FF ;
6112 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
6113 temp = ( tempcx & 0x0FF00 ) >> 8 ;
6114 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
6116 temp = ( tempax & 0xFF00 ) >> 8 ;
6118 temp = ( temp >> 1 ) & 0x09 ;
6120 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6123 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
6124 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
6125 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
6127 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
6132 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
6138 /* --------------------------------------------------------------------- */
6139 /* Function : XGI_SetGroup2 */
6143 /* --------------------------------------------------------------------- */
6144 void XGI_SetGroup2( USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex,
6145 PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
6158 UCHAR *TimingPoint ;
6166 if ( ModeNo <= 0x13 )
6168 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6169 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6170 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
6174 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6175 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6176 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
6181 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
6184 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6187 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
6190 if ( !( pVBInfo->TVInfo & SetPALTV ) )
6193 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6196 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6199 tempax = ( tempax & 0xff00 ) >> 8 ;
6201 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
6202 TimingPoint = pVBInfo->NTSCTiming ;
6204 if ( pVBInfo->TVInfo & SetPALTV )
6206 TimingPoint = pVBInfo->PALTiming ;
6209 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6211 TimingPoint = pVBInfo->HiTVExtTiming ;
6213 if ( pVBInfo->VBInfo & SetInSlaveMode )
6214 TimingPoint = pVBInfo->HiTVSt2Timing ;
6216 if ( pVBInfo->SetFlag & TVSimuMode )
6217 TimingPoint = pVBInfo->HiTVSt1Timing ;
6219 if ( !(modeflag & Charx8Dot) )
6220 TimingPoint = pVBInfo->HiTVTextTiming ;
6223 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6225 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6226 TimingPoint = pVBInfo->YPbPr525iTiming ;
6228 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6229 TimingPoint = pVBInfo->YPbPr525pTiming ;
6231 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6232 TimingPoint = pVBInfo->YPbPr750pTiming ;
6235 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
6237 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6240 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
6242 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
6245 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6247 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
6250 temp = pVBInfo->NewFlickerMode ;
6252 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
6254 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6257 if ( pVBInfo->TVInfo & SetPALTV )
6262 if ( pVBInfo->VDE <= tempax )
6264 tempax -= pVBInfo->VDE ;
6265 tempax = tempax >> 2 ;
6266 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
6268 temp = ( tempax & 0xFF00 ) >> 8 ;
6269 temp += ( USHORT )TimingPoint[ 0 ] ;
6271 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6273 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
6275 tempcx=pVBInfo->VGAHDE;
6276 if ( tempcx >= 1024 )
6278 temp = 0x17 ; /* NTSC */
6279 if ( pVBInfo->TVInfo & SetPALTV )
6280 temp = 0x19 ; /* PAL */
6285 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6287 temp = ( tempax & 0xFF00 ) >> 8 ;
6288 temp += TimingPoint[ 1 ] ;
6290 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6292 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
6294 tempcx = pVBInfo->VGAHDE ;
6295 if ( tempcx >= 1024 )
6297 temp = 0x1D ; /* NTSC */
6298 if ( pVBInfo->TVInfo & SetPALTV )
6299 temp = 0x52 ; /* PAL */
6303 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
6307 tempcx = pVBInfo->HT ;
6309 if ( XGI_IsLCDDualLink( pVBInfo ) )
6310 tempcx = tempcx >> 1 ;
6313 temp = tempcx & 0x00FF ;
6314 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6316 temp = ( tempcx & 0xFF00 ) >> 8 ;
6317 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6319 tempcx = pVBInfo->HT >> 1 ;
6320 push1 = tempcx ; /* push cx */
6323 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6328 temp = tempcx & 0x00FF ;
6330 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6332 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6335 temp = tempbx & 0x00FF ;
6336 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6337 temp = ( tempbx & 0xFF00 ) >> 8 ;
6339 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6343 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6349 temp = ( tempbx & 0x00FF ) << 4 ;
6350 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6353 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6354 temp = tempcx & 0x00FF ;
6355 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6356 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6357 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6360 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6365 temp = tempcx & 0xFF ;
6367 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6369 tempcx = push1 ; /* pop cx */
6371 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6373 temp = tempcx & 0x00FF ;
6375 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6379 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6381 tempax = XGI_GetVGAHT2( pVBInfo) ;
6382 tempcx = tempax - 1 ;
6384 temp = tempcx & 0x00FF ;
6385 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6387 tempbx = pVBInfo->VDE ;
6389 if ( pVBInfo->VGAVDE == 360 )
6391 if ( pVBInfo->VGAVDE == 375 )
6393 if ( pVBInfo->VGAVDE == 405 )
6396 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6398 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6400 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6401 tempbx = tempbx >> 1 ;
6404 tempbx = tempbx >> 1 ;
6408 temp = tempbx & 0x00FF ;
6410 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6412 if ( pVBInfo->VBType & VB_XGI301LV )
6414 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6416 if ( pVBInfo->VBInfo & SetInSlaveMode )
6418 if ( ModeNo == 0x2f )
6425 if ( pVBInfo->VBInfo & SetInSlaveMode )
6427 if ( ModeNo == 0x2f )
6433 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6435 temp = ( tempcx & 0xFF00 ) >> 8 ;
6436 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6438 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6440 if ( pVBInfo->VBType & VB_XGI301LV )
6442 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6446 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6453 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6458 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6460 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6462 tempbx = pVBInfo->VDE ;
6463 tempcx = tempbx - 2 ;
6465 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6467 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6468 tempbx = tempbx >> 1 ;
6471 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6474 if( tempcx & 0x0400 )
6477 if ( tempbx & 0x0400 )
6480 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6483 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6484 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6485 temp = ( tempbx - 3 ) & 0x00FF ;
6486 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6489 tempbx = tempbx & 0x00FF ;
6491 if ( !( modeflag & HalfDCLK ) )
6493 tempcx = pVBInfo->VGAHDE ;
6494 if ( tempcx >= pVBInfo->HDE )
6503 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6504 if(pVBInfo->VGAHDE>=1024)
6507 if(pVBInfo->VGAHDE>=1280)
6510 tempbx=tempbx&0xDFFF;
6515 if ( !( tempbx & 0x2000 ) )
6517 if ( modeflag & HalfDCLK )
6519 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6523 tempeax = pVBInfo->VGAHDE ;
6524 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6525 longtemp = tempeax * tempebx ;
6526 tempecx = tempcx & 0x00FF ;
6527 longtemp = longtemp / tempecx ;
6530 tempecx = 8 * 1024 ;
6532 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6534 tempecx = tempecx * 8 ;
6537 longtemp = longtemp * tempecx ;
6538 tempecx = pVBInfo->HDE ;
6539 temp2 = longtemp % tempecx ;
6540 tempeax = longtemp / tempecx ;
6546 tempax = ( USHORT )tempeax ;
6549 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6551 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6556 tempbx =( USHORT )( ( ( tempeax & 0x0000FF00 ) & 0x1F00 ) | ( tempbx & 0x00FF ) ) ;
6557 tempax =( USHORT )( ( ( tempeax & 0x000000FF ) << 8 ) | ( tempax & 0x00FF ) ) ;
6558 temp = ( tempax & 0xFF00 ) >> 8 ;
6562 temp = ( tempax & 0x00FF ) >> 8 ;
6565 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6566 temp = ( tempbx & 0xFF00 ) >> 8 ;
6567 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6568 temp = tempcx & 0x00FF ;
6570 if ( tempbx & 0x2000 )
6573 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6576 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6577 if ( pVBInfo->TVInfo & SetPALTV )
6588 temp = tempbx & 0x00FF ;
6589 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6590 temp = tempcx & 0x00FF ;
6591 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6593 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6595 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6597 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6601 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6604 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6608 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6609 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6610 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , ( USHORT )( temp - 3 ) ) ;
6612 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6614 if ( pVBInfo->TVInfo & NTSC1024x768 )
6616 TimingPoint = XGI_NTSC1024AdjTime ;
6617 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6619 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6621 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6625 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6626 if ( pVBInfo->VBType & VB_XGI301C )
6628 if ( pVBInfo->TVInfo & SetPALMTV )
6629 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6632 if ( pVBInfo->TVInfo & SetPALMTV )
6634 tempax = ( UCHAR )XGINew_GetReg1( pVBInfo->Part2Port , 0x01 ) ;
6636 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6638 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6639 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6642 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6644 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6646 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6650 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6657 /* --------------------------------------------------------------------- */
6658 /* Function : XGI_SetLCDRegs */
6662 /* --------------------------------------------------------------------- */
6663 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
6679 XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6682 if ( ModeNo <= 0x13 )
6684 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6685 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6689 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6690 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6691 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6692 CRT1Index &= IndexMask ;
6695 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6700 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6702 if ( XGI_IsLCDDualLink( pVBInfo ) )
6703 tempbx = tempbx >> 1 ;
6706 temp = tempbx & 0x00FF ;
6707 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6708 temp = ( tempbx & 0xFF00 ) >> 8 ;
6710 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6713 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6715 if ( pVBInfo->ModeType == ModeEGA )
6717 if ( pVBInfo->VGAHDE >= 1024 )
6720 if ( pVBInfo->LCDInfo & LCDVESATiming )
6726 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6727 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6730 temp = tempbx & 0x00FF ;
6731 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6732 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6733 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6735 tempcx = pVBInfo->VT - 1 ;
6736 push2 = tempcx + 1 ;
6737 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6738 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6739 temp = ( tempcx & 0xFF00 ) >> 8 ;
6741 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6742 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6743 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6744 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6745 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6747 /* Customized LCDB Des no add */
6749 LCDBDesPtr = ( XGI_LCDDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
6750 tempah = pVBInfo->LCDResInfo ;
6751 tempah &= PanelResInfo ;
6753 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6758 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6763 else if ( tempah == Panel1400x1050 )
6774 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6776 tempbx = pVBInfo->HDE ;
6777 tempcx = pVBInfo->VDE ;
6781 tempax = pVBInfo->VT ;
6782 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6783 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6784 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6785 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6786 tempbx = pVBInfo->LCDVDES ;
6789 if ( tempcx >= tempax )
6790 tempcx -= tempax ; /* lcdvdes */
6792 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6793 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6794 temp = tempcx & 0x00FF ;
6795 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6796 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6797 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6799 tempah = tempah << 3 ;
6801 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6804 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6806 tempax = pVBInfo->VT ;
6807 tempbx = pVBInfo->LCDVRS ;
6809 /* if ( SetLCD_Info & EnableScalingLCD ) */
6811 if ( tempcx >= tempax )
6814 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6815 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6816 temp = ( tempbx & 0xFF00 ) >> 8 ;
6818 temp |= ( tempcx & 0x000F ) ;
6819 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6821 tempax = pVBInfo->HT ;
6822 tempbx = pVBInfo->LCDHDES ;
6825 if ( XGI_IsLCDDualLink( pVBInfo ) )
6827 tempax = tempax >> 1 ;
6828 tempbx = tempbx >> 1 ;
6829 tempcx = tempcx >> 1 ;
6832 if ( pVBInfo->VBType & VB_XGI302LV )
6835 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6840 if ( tempcx >= tempax )
6843 temp = tempbx & 0x00FF ;
6844 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6845 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6846 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6847 temp = tempcx & 0x00FF ;
6848 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6849 temp = ( tempcx & 0xFF00 ) >> 8 ;
6850 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6853 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6855 tempax = pVBInfo->HT ;
6856 tempbx = pVBInfo->LCDHRS ;
6857 /* if ( SetLCD_Info & EnableScalingLCD) */
6858 if ( XGI_IsLCDDualLink( pVBInfo) )
6860 tempax = tempax >> 1 ;
6861 tempbx = tempbx >> 1 ;
6862 tempcx = tempcx >> 1 ;
6865 if ( pVBInfo->VBType & VB_XGI302LV )
6870 if ( tempcx >= tempax )
6873 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6874 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6876 temp = ( tempbx & 0xFF00 ) >> 8 ;
6878 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6879 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6880 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6882 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6884 if ( pVBInfo->VGAVDE == 525 )
6886 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6893 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6894 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6897 if ( pVBInfo->VGAVDE == 420 )
6899 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6905 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6911 /* --------------------------------------------------------------------- */
6912 /* Function : XGI_GetTap4Ptr */
6914 /* Output : di -> Tap4 Reg. Setting Pointer */
6916 /* --------------------------------------------------------------------- */
6917 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo)
6923 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6927 tempax = pVBInfo->VGAHDE ;
6928 tempbx = pVBInfo->HDE ;
6932 tempax = pVBInfo->VGAVDE ;
6933 tempbx = pVBInfo->VDE ;
6936 if ( tempax < tempbx )
6937 return &EnlargeTap4Timing[ 0 ] ;
6938 else if( tempax == tempbx )
6939 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6941 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6943 if ( pVBInfo->TVInfo & SetPALTV )
6944 Tap4TimingPtr = PALTap4Timing ;
6947 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6949 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6950 Tap4TimingPtr = YPbPr525iTap4Timing ;
6951 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6952 Tap4TimingPtr = YPbPr525pTap4Timing ;
6953 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6954 Tap4TimingPtr = YPbPr750pTap4Timing ;
6957 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6958 Tap4TimingPtr = HiTVTap4Timing ;
6961 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6963 if ( Tap4TimingPtr[ i ].DE == tempax )
6967 return &Tap4TimingPtr[ i ] ;
6971 /* --------------------------------------------------------------------- */
6972 /* Function : XGI_SetTap4Regs */
6976 /* --------------------------------------------------------------------- */
6977 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo)
6982 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6984 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6988 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6989 #else /* Tap4 Setting */
6991 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6992 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6993 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6995 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6997 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6998 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6999 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
7002 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
7003 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
7005 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
7009 /* --------------------------------------------------------------------- */
7010 /* Function : XGI_SetGroup3 */
7014 /* --------------------------------------------------------------------- */
7015 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
7023 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7027 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
7031 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
7032 if(pVBInfo->TVInfo&SetPALTV)
7034 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
7035 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
7039 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
7040 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
7043 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
7048 if(pVBInfo->TVInfo&SetPALMTV)
7050 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
7051 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
7052 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
7055 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
7057 if(pVBInfo->TVInfo & SetYPbPrMode525i)
7061 tempdi=pVBInfo->HiTVGroup3Data;
7062 if(pVBInfo->SetFlag&TVSimuMode)
7064 tempdi=pVBInfo->HiTVGroup3Simu;
7065 if(!(modeflag&Charx8Dot))
7067 tempdi=pVBInfo->HiTVGroup3Text;
7071 if(pVBInfo->TVInfo & SetYPbPrMode525p)
7073 tempdi=pVBInfo->Ren525pGroup3;
7075 if(pVBInfo->TVInfo & SetYPbPrMode750p)
7077 tempdi=pVBInfo->Ren750pGroup3;
7080 for(i=0;i<=0x3E;i++)
7082 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
7084 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
7086 if(pVBInfo->TVInfo & SetYPbPrMode525p)
7088 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
7093 } /* {end of XGI_SetGroup3} */
7096 /* --------------------------------------------------------------------- */
7097 /* Function : XGI_SetGroup4 */
7101 /* --------------------------------------------------------------------- */
7102 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7116 if ( ModeNo <= 0x13 )
7118 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
7122 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
7125 temp = pVBInfo->RVBHCFACT ;
7126 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
7128 tempbx = pVBInfo->RVBHCMAX ;
7129 temp = tempbx & 0x00FF ;
7130 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
7131 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
7132 tempcx = pVBInfo->VGAHT - 1 ;
7133 temp = tempcx & 0x00FF ;
7134 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
7136 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
7139 tempcx = pVBInfo->VGAVT - 1 ;
7140 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
7145 temp = tempcx & 0x00FF ;
7146 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
7147 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
7148 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
7149 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
7150 tempcx = pVBInfo->VBInfo ;
7151 tempbx = pVBInfo->VGAHDE ;
7153 if ( modeflag & HalfDCLK )
7155 tempbx = tempbx >> 1 ;
7158 if ( XGI_IsLCDDualLink( pVBInfo ) )
7159 tempbx = tempbx >> 1 ;
7161 if(tempcx&SetCRT2ToHiVisionTV)
7169 else if(tempcx&SetCRT2ToTV)
7178 if(pVBInfo->VBInfo&SetCRT2ToLCD)
7186 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
7189 if ( pVBInfo->VGAHDE == 1280 )
7191 if ( pVBInfo->VGAHDE == 1024 )
7194 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
7196 tempebx = pVBInfo->VDE ;
7198 if ( tempcx & SetCRT2ToHiVisionTV )
7200 if ( !( temp & 0xE000 ) )
7201 tempbx = tempbx >> 1 ;
7204 tempcx = pVBInfo->RVBHRS ;
7205 temp = tempcx & 0x00FF ;
7206 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
7208 tempeax = pVBInfo->VGAVDE ;
7212 if ( tempeax <= tempebx )
7214 tempcx=(tempcx&(~0x4000));
7215 tempeax = pVBInfo->VGAVDE ;
7219 tempeax -= tempebx ;
7223 templong = ( tempeax * 256 * 1024 ) % tempebx ;
7224 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
7227 if ( templong != 0 )
7233 temp = ( USHORT )( tempebx & 0x000000FF ) ;
7234 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
7236 temp = ( USHORT )( ( tempebx & 0x0000FF00 ) >> 8 ) ;
7237 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
7238 tempbx = ( USHORT )( tempebx >> 16 ) ;
7239 temp = tempbx & 0x00FF ;
7241 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
7242 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
7245 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7248 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
7249 tempax = pVBInfo->VGAHDE ;
7250 if ( modeflag & HalfDCLK )
7252 tempax = tempax >> 1 ;
7255 if ( XGI_IsLCDDualLink( pVBInfo ) )
7256 tempax = tempax >> 1 ;
7258 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
7259 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
7266 if ( pVBInfo->VGAHDE > 800 )
7268 if ( pVBInfo->VGAHDE == 1024 )
7269 tempax = ( tempax * 25 / 32 ) - 1 ;
7271 tempax = ( tempax * 20 / 32 ) - 1 ;
7277 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7279 if ( pVBInfo->VBType & VB_XGI301LV )
7281 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7283 if ( pVBInfo->VGAHDE > 800 )
7285 if ( pVBInfo->VGAHDE == 1024 )
7286 tempax = ( tempax * 25 / 32 ) - 1 ;
7288 tempax = ( tempax * 20 / 32 ) - 1 ;
7294 if ( pVBInfo->VGAHDE > 800 )
7296 if ( pVBInfo->VGAHDE == 1024 )
7297 tempax = ( tempax * 25 / 32 ) - 1 ;
7299 tempax = ( tempax * 20 / 32 ) - 1 ;
7305 temp = ( tempax & 0xFF00 ) >> 8 ;
7306 temp = ( ( temp & 0x0003 ) << 4 ) ;
7307 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
7308 temp = ( tempax & 0x00FF ) ;
7309 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7311 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7313 if ( pVBInfo->VGAHDE > 800 )
7315 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7320 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7322 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7325 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7326 temp &= ( ~0x0001 ) ;
7330 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7331 tempbx = pVBInfo->HT ;
7332 if ( XGI_IsLCDDualLink( pVBInfo ) )
7333 tempbx = tempbx >> 1 ;
7334 tempbx = ( tempbx >> 1 ) - 2 ;
7335 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7336 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7337 temp = tempbx & 0x00FF ;
7338 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7342 if ( pVBInfo->ISXPDOS == 0 )
7343 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7347 /* --------------------------------------------------------------------- */
7348 /* Function : XGI_SetGroup5 */
7352 /* --------------------------------------------------------------------- */
7353 void XGI_SetGroup5( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
7358 Pindex = pVBInfo->Part5Port ;
7359 Pdata = pVBInfo->Part5Port + 1 ;
7360 if ( pVBInfo->ModeType == ModeVGA )
7362 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7364 XGINew_EnableCRT2(pVBInfo) ;
7365 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7372 /* --------------------------------------------------------------------- */
7373 /* Function : XGI_GetLcdPtr */
7377 /* --------------------------------------------------------------------- */
7378 void* XGI_GetLcdPtr( USHORT BX , USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7388 XGI330_LCDDataTablStruct *tempdi = 0 ;
7393 if ( ModeNo <= 0x13 )
7395 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7396 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7400 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7401 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7404 tempal = tempal & 0x0f ;
7406 if ( tempbx <= 1 ) /* ExpLink */
7408 if ( ModeNo <= 0x13 )
7410 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7414 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7417 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7419 if ( ModeNo <= 0x13 )
7420 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7422 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7425 if ( tempbx & 0x01 )
7426 tempal = ( tempal >> 4 ) ;
7428 tempal = ( tempal & 0x0f ) ;
7431 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7433 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7435 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7436 tempcx = LCDDesDataLen2 ;
7437 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7438 tempcx = LVDSDesDataLen2 ;
7440 /* mov di, word ptr cs:LCDDataList[bx] */
7441 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7446 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7449 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7452 tempdi = XGI_EPLLCDDataPtr ;
7455 tempdi = XGI_EPLLCDDesDataPtr ;
7458 tempdi = XGI_LCDDataTable ;
7461 tempdi = XGI_LCDDesDataTable ;
7464 tempdi = XGI_EPLCHLCDRegPtr ;
7475 if ( tempdi == 0x00 ) /* OEMUtil */
7481 while( tempdi[ i ].PANELID != 0xff )
7483 tempdx = pVBInfo->LCDResInfo ;
7484 if ( tempbx & 0x0080 ) /* OEMUtil */
7486 tempbx &= ( ~0x0080 ) ;
7487 tempdx = pVBInfo->LCDTypeInfo ;
7490 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7491 tempdx &= ( ~PanelResInfo ) ;
7493 if ( tempdi[ i ].PANELID == tempdx )
7495 tempbx = tempdi[ i ].MASK ;
7496 tempdx = pVBInfo->LCDInfo ;
7498 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7499 tempdx |= SetLCDStdMode ;
7501 if ( modeflag & HalfDCLK )
7502 tempdx |= SetLCDLowResolution ;
7505 if ( tempbx == tempdi[ i ].CAP )
7513 switch( tempdi[ i ].DATAPTR )
7516 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7519 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7522 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7525 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7528 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7531 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7534 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7537 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7540 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7543 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7546 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7552 else if ( table == 1 )
7554 switch( tempdi[ i ].DATAPTR )
7557 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7560 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7563 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7566 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7569 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7572 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7575 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7578 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7581 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7584 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7587 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7593 else if ( table == 2 )
7595 switch( tempdi[ i ].DATAPTR )
7598 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7601 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7604 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7607 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7610 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7613 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7616 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7619 return &XGI_LVDSNoScalingData[ tempal ] ;
7622 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7625 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7628 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7631 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7634 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7640 else if ( table == 3 )
7642 switch( tempdi[ i ].DATAPTR )
7645 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7648 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7651 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7654 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7657 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7660 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7663 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7666 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7669 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7672 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7675 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7678 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7681 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7684 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7687 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7693 else if ( table == 4 )
7695 switch( tempdi[ i ].DATAPTR )
7698 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7701 return &XGI_StLCD1024x768Data[ tempal ] ;
7704 return &XGI_CetLCD1024x768Data[ tempal ] ;
7707 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7710 return &XGI_StLCD1280x1024Data[ tempal ] ;
7713 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7716 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7719 return &XGI_StLCD1400x1050Data[ tempal ] ;
7722 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7725 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7728 return &XGI_StLCD1600x1200Data[ tempal ] ;
7731 return &XGI_NoScalingData[ tempal ] ;
7734 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7737 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7740 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7743 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7746 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7749 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7752 return &XGI_NoScalingDatax75[ tempal ] ;
7758 else if ( table == 5 )
7760 switch( tempdi[ i ].DATAPTR )
7763 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7766 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7769 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7772 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7773 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7775 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7778 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7779 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7781 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7784 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7785 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7787 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7790 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7791 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7793 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7796 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7797 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7799 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7802 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7805 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7808 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7809 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7811 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7814 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7815 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7817 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7820 return &XGI_NoScalingDesData[ tempal ] ;
7823 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7826 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7829 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7832 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7833 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7835 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7838 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7839 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7841 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7844 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7845 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7847 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7850 return &XGI_NoScalingDesDatax75[ tempal ] ;
7856 else if ( table == 6 )
7858 switch( tempdi[ i ].DATAPTR )
7861 return &XGI_CH7017LV1024x768[ tempal ] ;
7864 return &XGI_CH7017LV1400x1050[ tempal ] ;
7874 /* --------------------------------------------------------------------- */
7875 /* Function : XGI_GetTVPtr */
7879 /* --------------------------------------------------------------------- */
7880 void* XGI_GetTVPtr (USHORT BX,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7882 USHORT i , tempdx , tempbx , tempal , modeflag , table ;
7883 XGI330_TVDataTablStruct *tempdi = 0 ;
7887 if ( ModeNo <= 0x13 )
7889 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7890 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7894 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7895 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7898 tempal = tempal & 0x3f ;
7904 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7905 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7907 tempdi = XGI_EPLCHTVCRT1Ptr;
7911 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7912 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7914 tempdi = XGI_EPLCHTVCRT1Ptr;
7918 tempdi = XGI_EPLCHTVDataPtr ;
7924 tempdi = XGI_TVDataTable ;
7930 tempdi = XGI_EPLCHTVRegPtr ;
7936 if ( tempdi == 0x00 ) /* OEMUtil */
7939 tempdx = pVBInfo->TVInfo ;
7941 if ( pVBInfo->VBInfo & SetInSlaveMode )
7942 tempdx = tempdx | SetTVLockMode ;
7944 if ( modeflag & HalfDCLK )
7945 tempdx = tempdx | SetTVLowResolution ;
7949 while( tempdi[ i ].MASK != 0xffff )
7951 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7956 if ( table == 0x00 ) /* 07/05/22 */
7959 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7961 switch( tempdi[ i ].DATAPTR )
7964 return &CH7007TVCRT1UNTSC_H[ tempal ] ;
7967 return &CH7007TVCRT1ONTSC_H[ tempal ] ;
7970 return &CH7007TVCRT1UPAL_H[ tempal ] ;
7973 return &CH7007TVCRT1OPAL_H[ tempal ] ;
7981 else if ( table == 0x01 )
7984 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7986 switch( tempdi[ i ].DATAPTR )
7989 return &CH7007TVCRT1UNTSC_V[ tempal ] ;
7992 return &CH7007TVCRT1ONTSC_V[ tempal ] ;
7995 return &CH7007TVCRT1UPAL_V[ tempal ] ;
7998 return &CH7007TVCRT1OPAL_V[ tempal ] ;
8006 else if ( table == 0x04 )
8008 switch( tempdi[ i ].DATAPTR )
8011 return &XGI_ExtPALData[ tempal ] ;
8014 return &XGI_ExtNTSCData[ tempal ] ;
8017 return &XGI_StPALData[ tempal ] ;
8020 return &XGI_StNTSCData[ tempal ] ;
8023 return &XGI_ExtHiTVData[ tempal ] ;
8026 return &XGI_St2HiTVData[ tempal ] ;
8029 return &XGI_ExtYPbPr525iData[ tempal ] ;
8032 return &XGI_ExtYPbPr525pData[ tempal ] ;
8035 return &XGI_ExtYPbPr750pData[ tempal ] ;
8038 return &XGI_StYPbPr525iData[ tempal ] ;
8041 return &XGI_StYPbPr525pData[ tempal ] ;
8044 return &XGI_StYPbPr750pData[ tempal ] ;
8046 case 12: /* avoid system hang */
8047 return &XGI_ExtNTSCData[ tempal ] ;
8050 return &XGI_St1HiTVData[ tempal ] ;
8056 else if( table == 0x02 )
8058 switch( tempdi[ i ].DATAPTR )
8061 return &XGI_CHTVUNTSCData[ tempal ] ;
8064 return &XGI_CHTVONTSCData[ tempal ] ;
8067 return &XGI_CHTVUPALData[ tempal ] ;
8070 return &XGI_CHTVOPALData[ tempal ] ;
8076 else if( table == 0x06 )
8079 if ( pVBInfo->IF_DEF_CH7007 == 1 )
8081 /* VideoDebugPrint((0, "XGI_GetTVPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
8082 switch( tempdi[ i ].DATAPTR )
8085 return &CH7007TVReg_UNTSC[ tempal ] ;
8088 return &CH7007TVReg_ONTSC[ tempal ] ;
8091 return &CH7007TVReg_UPAL[ tempal ] ;
8094 return &CH7007TVReg_OPAL[ tempal ] ;
8102 switch( tempdi[ i ].DATAPTR )
8105 return &XGI_CHTVRegUNTSC[ tempal ] ;
8108 return &XGI_CHTVRegONTSC[ tempal ] ;
8111 return &XGI_CHTVRegUPAL[ tempal ] ;
8114 return &XGI_CHTVRegOPAL[ tempal ] ;
8126 /* --------------------------------------------------------------------- */
8127 /* Function : XGI_BacklightByDrv */
8129 /* Output : TRUE -> Skip backlight control */
8131 /* --------------------------------------------------------------------- */
8132 BOOLEAN XGI_BacklightByDrv( PVB_DEVICE_INFO pVBInfo )
8136 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x3A ) ;
8137 if ( tempah & BacklightControlBit )
8144 /* --------------------------------------------------------------------- */
8145 /* Function : XGI_FirePWDDisable */
8148 /* Description : Turn off VDD & Backlight : Fire disable procedure */
8149 /* --------------------------------------------------------------------- */
8151 void XGI_FirePWDDisable( PVB_DEVICE_INFO pVBInfo )
8153 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
8157 /* --------------------------------------------------------------------- */
8158 /* Function : XGI_FirePWDEnable */
8161 /* Description : Turn on VDD & Backlight : Fire enable procedure */
8162 /* --------------------------------------------------------------------- */
8163 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo )
8165 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
8169 /* --------------------------------------------------------------------- */
8170 /* Function : XGI_EnableGatingCRT */
8174 /* --------------------------------------------------------------------- */
8175 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8177 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
8181 /* --------------------------------------------------------------------- */
8182 /* Function : XGI_DisableGatingCRT */
8186 /* --------------------------------------------------------------------- */
8187 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8190 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
8194 /* --------------------------------------------------------------------- */
8195 /* Function : XGI_SetPanelDelay */
8199 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8200 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
8201 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
8202 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
8203 /* --------------------------------------------------------------------- */
8204 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8208 index = XGI_GetLCDCapPtr(pVBInfo) ;
8211 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
8214 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
8217 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
8220 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
8224 /* --------------------------------------------------------------------- */
8225 /* Function : XGI_SetPanelPower */
8229 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
8230 /* = 0111b = 07h ; Backlight on, Power off */
8231 /* = 1011b = 0Bh ; Backlight off, Power on */
8232 /* = 1111b = 0Fh ; Backlight off, Power off */
8233 /* --------------------------------------------------------------------- */
8234 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8236 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8237 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
8239 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
8242 UCHAR XG21GPIODataTransfer(UCHAR ujDate)
8250 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
8251 ujRet |= (ujDate >> i) & 1;
8257 /*----------------------------------------------------------------------------*/
8259 /* bl[5] : LVDS signal */
8260 /* bl[1] : LVDS backlight */
8261 /* bl[0] : LVDS VDD */
8262 /*----------------------------------------------------------------------------*/
8263 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo)
8267 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8268 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
8270 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
8272 temp = XG21GPIODataTransfer(temp);
8274 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
8278 /*----------------------------------------------------------------------------*/
8280 /* bl[5] : LVDS signal */
8281 /* bl[1] : LVDS backlight */
8282 /* bl[0] : LVDS VDD */
8283 /*----------------------------------------------------------------------------*/
8284 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo)
8286 UCHAR CR4A,CRB4,temp;
8288 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8289 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
8291 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
8295 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
8296 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
8297 temp |= ((CRB4&0x04)<<3);
8300 /*----------------------------------------------------------------------------*/
8302 /* bl[5] : 1;LVDS signal on */
8303 /* bl[1] : 1;LVDS backlight on */
8304 /* bl[0] : 1:LVDS VDD on */
8305 /* bh: 100000b : clear bit 5, to set bit5 */
8306 /* 000010b : clear bit 1, to set bit1 */
8307 /* 000001b : clear bit 0, to set bit0 */
8308 /*----------------------------------------------------------------------------*/
8309 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8313 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8316 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
8320 temp = (tempbl>>4)&0x02;
8322 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8326 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
8328 temp = XG21GPIODataTransfer(temp);
8331 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
8334 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8337 USHORT tempbh0,tempbl0;
8348 temp = (tempbl>>4)&0x02;
8350 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8353 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
8355 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8359 tempbl <<= 2; /* GPIOC,GPIOD */
8360 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
8361 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
8364 /* --------------------------------------------------------------------- */
8365 USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo)
8369 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8370 if (index<sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct))
8377 /* --------------------------------------------------------------------- */
8378 /* Function : XGI_XG21SetPanelDelay */
8382 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8383 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
8384 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
8385 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
8386 /* --------------------------------------------------------------------- */
8387 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8391 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
8393 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8396 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8399 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8402 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8405 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8414 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8415 if ( ModeNo <= 0x13 )
8417 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8418 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8419 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8423 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8424 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8425 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8428 if ( !( modeflag & Charx8Dot ) )
8434 if ( ModeNo > 0x13 )
8436 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8440 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8446 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8447 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8450 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8453 if ( ModeNo > 0x13 )
8455 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8456 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8458 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8459 if ( colordepth > 2 )
8468 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo)
8472 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8473 temp = ( temp & 1 ) << 6;
8474 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8475 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8479 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo)
8483 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8484 temp = ( temp & 3 ) << 6;
8485 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8486 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8490 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8492 UCHAR temp,Miscdata;
8498 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8499 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8502 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8504 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8505 temp &= LCDPolarity;
8506 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8508 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8510 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8511 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8512 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8514 XGI_SetXG21FPBits(pVBInfo);
8515 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8516 if ( ModeNo <= 0x13 )
8518 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8519 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8520 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8524 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8525 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8526 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8529 if (!( modeflag & Charx8Dot ))
8530 xres = xres * 8 / 9;
8532 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8534 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8535 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8539 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8541 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8542 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8544 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8545 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8547 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8549 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8551 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8552 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8556 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8558 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8559 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8561 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8562 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8564 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8566 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8567 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8569 if (!( modeflag & Charx8Dot ))
8571 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8574 /* HT SR0B[1:0] CR00 */
8575 value = ( LVDSHT >> 3 ) - 5;
8576 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8577 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8579 /* HBS SR0B[5:4] CR02 */
8580 value = ( LVDSHBS >> 3 ) - 1;
8581 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8582 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8584 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8585 value = ( LVDSHBE >> 3 ) - 1;
8586 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8587 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8588 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8590 /* HRS SR0B[7:6] CR04 */
8591 value = ( LVDSHRS >> 3 ) + 2;
8592 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8593 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8595 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8597 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8598 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8600 /* HRE SR0C[2] CR05[4:0] */
8601 value = ( LVDSHRE >> 3 ) + 2;
8602 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8603 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8605 /* Panel HRE SR2F[7:2] */
8607 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8609 /* VT SR0A[0] CR07[5][0] CR06 */
8610 value = LVDSVT - 2 ;
8611 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8612 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8613 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8614 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8616 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8617 value = LVDSVBS - 1 ;
8618 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8619 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8620 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8621 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8623 /* VBE SR0A[4] CR16 */
8624 value = LVDSVBE - 1;
8625 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8626 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8628 /* VRS SR0A[3] CR7[7][2] CR10 */
8629 value = LVDSVRS - 1 ;
8630 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8631 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8632 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8633 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8635 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8636 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8637 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8638 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8640 /* VRE SR0A[5] CR11[3:0] */
8641 value = LVDSVRE - 1;
8642 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8643 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8645 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8646 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8648 for ( temp=0, value = 0; temp < 3; temp++)
8651 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8652 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8653 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8657 if (!( modeflag & Charx8Dot ))
8659 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8660 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8661 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8663 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8664 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8666 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8672 /* no shadow case */
8673 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8675 UCHAR temp,Miscdata;
8681 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8682 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8685 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8686 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8687 temp &= LCDPolarity;
8688 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8690 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8692 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8693 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8694 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8696 XGI_SetXG27FPBits(pVBInfo);
8697 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8698 if ( ModeNo <= 0x13 )
8700 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8701 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8702 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8706 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8707 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8708 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8711 if (!( modeflag & Charx8Dot ))
8712 xres = xres * 8 / 9;
8714 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8716 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8717 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8721 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8723 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8724 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8726 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8727 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8729 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8731 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8733 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8734 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8738 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8740 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8741 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8743 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8744 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8746 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8748 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8749 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8751 if (!( modeflag & Charx8Dot ))
8753 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8756 /* HT SR0B[1:0] CR00 */
8757 value = ( LVDSHT >> 3 ) - 5;
8758 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8759 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8761 /* HBS SR0B[5:4] CR02 */
8762 value = ( LVDSHBS >> 3 ) - 1;
8763 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8764 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8766 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8767 value = ( LVDSHBE >> 3 ) - 1;
8768 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8769 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8770 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8772 /* HRS SR0B[7:6] CR04 */
8773 value = ( LVDSHRS >> 3 ) + 2;
8774 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8775 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8777 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8779 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8780 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8782 /* HRE SR0C[2] CR05[4:0] */
8783 value = ( LVDSHRE >> 3 ) + 2;
8784 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8785 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8787 /* Panel HRE SR2F[7:2] */
8789 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8791 /* VT SR0A[0] CR07[5][0] CR06 */
8792 value = LVDSVT - 2 ;
8793 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8794 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8795 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8796 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8798 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8799 value = LVDSVBS - 1 ;
8800 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8801 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8802 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8803 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8805 /* VBE SR0A[4] CR16 */
8806 value = LVDSVBE - 1;
8807 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8808 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8810 /* VRS SR0A[3] CR7[7][2] CR10 */
8811 value = LVDSVRS - 1 ;
8812 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8813 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8814 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8815 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8817 /* Panel VRS SR35[2:0] SR34[7:0] */
8818 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8819 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8821 /* VRE SR0A[5] CR11[3:0] */
8822 value = LVDSVRE - 1;
8823 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8824 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8826 /* Panel VRE SR3F[7:2] */
8827 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8829 for ( temp=0, value = 0; temp < 3; temp++)
8832 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8833 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8834 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8838 if (!( modeflag & Charx8Dot ))
8840 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8841 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8842 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8844 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8845 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8847 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8853 /* --------------------------------------------------------------------- */
8854 /* Function : XGI_IsLCDON */
8856 /* Output : FALSE : Skip PSC Control */
8857 /* TRUE: Disable PSC */
8859 /* --------------------------------------------------------------------- */
8860 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo)
8864 tempax = pVBInfo->VBInfo ;
8865 if ( tempax & SetCRT2ToDualEdge )
8867 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8874 /* --------------------------------------------------------------------- */
8875 /* Function : XGI_EnablePWD */
8879 /* --------------------------------------------------------------------- */
8880 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo )
8885 index = XGI_GetLCDCapPtr(pVBInfo) ;
8886 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8887 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8888 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8889 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8890 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8891 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8892 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8896 /* --------------------------------------------------------------------- */
8897 /* Function : XGI_DisablePWD */
8901 /* --------------------------------------------------------------------- */
8902 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo )
8904 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8908 /* --------------------------------------------------------------------- */
8909 /* Function : XGI_DisableChISLCD */
8911 /* Output : FALSE -> Not LCD Mode */
8913 /* --------------------------------------------------------------------- */
8914 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo)
8919 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8920 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8922 if ( tempbx & ( EnableChA | DisableChA ) )
8924 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8928 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8931 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8938 /* --------------------------------------------------------------------- */
8939 /* Function : XGI_EnableChISLCD */
8941 /* Output : 0 -> Not LCD mode */
8943 /* --------------------------------------------------------------------- */
8944 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo)
8950 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8951 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8953 if ( tempbx & ( EnableChA | DisableChA ) )
8955 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8959 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8962 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8969 /* --------------------------------------------------------------------- */
8970 /* Function : XGI_GetLCDCapPtr */
8974 /* --------------------------------------------------------------------- */
8975 USHORT XGI_GetLCDCapPtr( PVB_DEVICE_INFO pVBInfo )
8982 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8983 tempal = tempah & 0x0F ;
8984 tempah = tempah & 0xF0 ;
8986 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8988 while( tempbl != 0xFF )
8990 if ( tempbl & 0x80 ) /* OEMUtil */
8993 tempbl = tempbl & ~( 0x80 ) ;
8996 if ( tempal == tempbl )
9001 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
9008 /* --------------------------------------------------------------------- */
9009 /* Function : XGI_GetLCDCapPtr1 */
9013 /* --------------------------------------------------------------------- */
9014 USHORT XGI_GetLCDCapPtr1( PVB_DEVICE_INFO pVBInfo )
9021 tempal = pVBInfo->LCDResInfo ;
9022 tempah = pVBInfo->LCDTypeInfo ;
9025 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
9027 while( tempbl != 0xFF )
9029 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
9035 if ( tempal == tempbl )
9039 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
9042 if ( tempbl == 0xFF )
9044 pVBInfo->LCDResInfo = Panel1024x768 ;
9045 pVBInfo->LCDTypeInfo = 0 ;
9053 /* --------------------------------------------------------------------- */
9054 /* Function : XGI_GetLCDSync */
9058 /* --------------------------------------------------------------------- */
9059 void XGI_GetLCDSync( USHORT* HSyncWidth , USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo )
9063 Index = XGI_GetLCDCapPtr(pVBInfo) ;
9064 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
9065 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
9072 /* --------------------------------------------------------------------- */
9073 /* Function : XGI_EnableBridge */
9077 /* --------------------------------------------------------------------- */
9078 void XGI_EnableBridge( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
9083 if ( pVBInfo->SetFlag == Win9xDOSMode )
9085 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9087 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
9090 else /* LVDS or CH7017 */
9095 if ( HwDeviceExtension->jChipType < XG40 )
9097 if ( !XGI_DisableChISLCD(pVBInfo) )
9099 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
9101 if ( pVBInfo->LCDInfo & SetPWDEnable )
9103 XGI_EnablePWD( pVBInfo);
9107 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
9108 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9119 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
9120 XGI_SetPanelDelay( 1,pVBInfo ) ;
9128 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9130 if ( !( pVBInfo->SetFlag & DisableChA ) )
9132 if ( pVBInfo->SetFlag & EnableChA )
9134 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
9138 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
9140 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
9145 if ( !( pVBInfo->SetFlag & DisableChB ) )
9147 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
9149 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
9151 if ( pVBInfo->VBInfo & SetInSlaveMode )
9153 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9156 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
9157 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
9160 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
9162 if ( !( tempah & 0x80 ) )
9163 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
9165 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
9169 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
9171 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
9172 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9174 if ( !XGI_DisableChISLCD(pVBInfo) )
9176 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
9177 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
9179 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
9185 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9189 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
9191 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9193 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9195 tempah = tempah & 0x40;
9196 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9197 tempah = tempah ^ 0xC0 ;
9199 if ( pVBInfo->SetFlag & DisableChB )
9202 if ( pVBInfo->SetFlag & DisableChA )
9205 if ( pVBInfo->SetFlag & EnableChB )
9208 if ( pVBInfo->SetFlag & EnableChA )
9215 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
9217 if ( pVBInfo->SetFlag & Win9xDOSMode )
9219 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
9223 if ( !( pVBInfo->SetFlag & DisableChA ) )
9225 XGI_VBLongWait( pVBInfo) ;
9226 if ( !( pVBInfo->SetFlag & GatingCRT ) )
9228 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9229 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
9230 XGI_VBLongWait( pVBInfo) ;
9236 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9237 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
9241 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
9242 if ( !( tempah & 0x80 ) )
9243 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
9245 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
9246 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
9250 if ( HwDeviceExtension->jChipType < XG40 )
9252 if ( !XGI_EnableChISLCD(pVBInfo) )
9254 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9256 if ( XGI_BacklightByDrv(pVBInfo) )
9263 if ( pVBInfo->LCDInfo & SetPWDEnable )
9265 XGI_FirePWDEnable(pVBInfo) ;
9269 XGI_SetPanelDelay( 2,pVBInfo ) ;
9271 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9274 tempbl = 0xFE ; /* turn on backlght */
9281 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9286 /* --------------------------------------------------------------------- */
9287 /* Function : XGI_DisableBridge */
9291 /* --------------------------------------------------------------------- */
9292 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
9299 if ( pVBInfo->SetFlag == Win9xDOSMode )
9303 if ( HwDeviceExtension->jChipType < XG40 )
9305 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
9307 if ( !XGI_IsLCDON(pVBInfo) )
9309 if ( pVBInfo->LCDInfo & SetPWDEnable )
9310 XGI_EnablePWD( pVBInfo) ;
9313 pVBInfo->LCDInfo &= ~SetPWDEnable ;
9314 XGI_DisablePWD(pVBInfo) ;
9315 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9317 tempbx = 0xFE ; /* not 01h */
9322 tempbx = 0xF7 ; /* not 08h */
9325 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
9326 XGI_SetPanelDelay( 3,pVBInfo ) ;
9328 } /* end if(!XGI_IsLCDON(pVBInfo)) */
9334 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
9336 if ( !XGI_IsLCDON(pVBInfo) )
9340 tempbx = XGINew_GetCH7005( 0x61 ) ;
9341 if ( tempbx < 0x01 ) //first time we power up
9342 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
9344 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
9350 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9353 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
9355 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9357 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9359 tempah = 0x7F; /* Disable Channel A */
9360 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9361 tempah = 0xBF ; /* Disable Channel B */
9363 if ( pVBInfo->SetFlag & DisableChB )
9364 tempah &= 0xBF ; /* force to disable Cahnnel */
9366 if ( pVBInfo->SetFlag & DisableChA )
9367 tempah &= 0x7F ; /* Force to disable Channel B */
9372 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
9374 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9376 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9377 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
9380 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
9382 if ( pVBInfo->SetFlag & GatingCRT )
9383 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9384 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9387 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9389 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9390 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
9393 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
9395 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
9396 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9398 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9399 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9400 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9402 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9403 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9405 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9406 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9407 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9408 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9413 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9415 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9416 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9417 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9420 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9421 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9427 if ( HwDeviceExtension->jChipType < XG40 )
9429 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9431 if ( pVBInfo->LCDInfo & SetPWDEnable )
9433 if ( pVBInfo->LCDInfo & SetPWDEnable )
9434 XGI_BacklightByDrv(pVBInfo) ;
9437 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9438 if ( pVBInfo->VBType & VB_XGI301LV )
9450 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9456 /* --------------------------------------------------------------------- */
9457 /* Function : XGI_GetTVPtrIndex */
9460 /* Description : bx 0 : ExtNTSC */
9472 /* --------------------------------------------------------------------- */
9473 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo )
9477 if ( pVBInfo->TVInfo & SetPALTV )
9479 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9481 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9483 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9485 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9487 if ( pVBInfo->TVInfo & TVSimuMode )
9494 /* --------------------------------------------------------------------- */
9495 /* Function : XGI_OEM310Setting */
9498 /* Description : Customized Param. for 301 */
9499 /* --------------------------------------------------------------------- */
9500 void XGI_OEM310Setting( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9502 if ( pVBInfo->SetFlag & Win9xDOSMode )
9506 XGI_SetDelayComp(pVBInfo) ;
9508 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9509 XGI_SetLCDCap(pVBInfo) ;
9511 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9514 XGI_SetPhaseIncr(pVBInfo) ;
9515 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9516 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9518 if ( pVBInfo->VBType&VB_XGI301)
9519 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9524 /* --------------------------------------------------------------------- */
9525 /* Function : XGI_SetDelayComp */
9529 /* --------------------------------------------------------------------- */
9530 void XGI_SetDelayComp( PVB_DEVICE_INFO pVBInfo )
9538 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9540 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9545 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9546 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9548 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9549 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9551 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9552 tempbl = tempbl >> 4 ;
9554 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9555 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9557 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9558 tempbl = CRT2Delay2 ;
9560 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9562 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9563 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9565 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9571 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9573 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9579 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9584 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9587 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9591 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9593 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9595 tempah = tempah << 4 ;
9596 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9602 /* --------------------------------------------------------------------- */
9603 /* Function : XGI_SetLCDCap */
9607 /* --------------------------------------------------------------------- */
9608 void XGI_SetLCDCap( PVB_DEVICE_INFO pVBInfo )
9612 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9614 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9616 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9617 { /* 301LV/302LV only */
9618 /* Set 301LV Capability */
9619 XGINew_SetReg1( pVBInfo->Part4Port , 0x24 , ( UCHAR )( tempcx & 0x1F ) ) ;
9622 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~( ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) >> 8 ) , ( USHORT )( ( tempcx & ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) ) >> 8 ) ) ;
9625 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9627 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9628 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9629 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9630 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9632 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9634 if ( tempcx & EnableSpectrum )
9635 SetSpectrum( pVBInfo) ;
9638 else /* LVDS,CH7017 */
9639 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9643 /* --------------------------------------------------------------------- */
9644 /* Function : XGI_SetLCDCap_A */
9648 /* --------------------------------------------------------------------- */
9649 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9653 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9655 if ( temp & LCDRGB18Bit )
9657 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x20 | ( tempcx & 0x00C0 ) ) ) ; /* Enable Dither */
9658 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9662 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x30 | ( tempcx & 0x00C0 ) ) ) ;
9663 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9667 if ( tempcx & EnableLCD24bpp ) // 24bits
9669 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x30|(tempcx&0x00C0)) );
9670 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9674 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x20|(tempcx&0x00C0)) );//Enable Dither
9675 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9681 /* --------------------------------------------------------------------- */
9682 /* Function : XGI_SetLCDCap_B */
9683 /* Input : cx -> LCD Capability */
9686 /* --------------------------------------------------------------------- */
9687 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9689 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9690 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x0c ) ) ;
9692 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x18 ) ) ; /* Enable Dither */
9696 /* --------------------------------------------------------------------- */
9697 /* Function : SetSpectrum */
9701 /* --------------------------------------------------------------------- */
9702 void SetSpectrum( PVB_DEVICE_INFO pVBInfo )
9706 index = XGI_GetLCDCapPtr(pVBInfo) ;
9708 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9709 XGI_LongWait(pVBInfo) ;
9710 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9711 XGI_LongWait(pVBInfo) ;
9713 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9714 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9715 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9716 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9717 XGI_LongWait(pVBInfo) ;
9718 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9722 /* --------------------------------------------------------------------- */
9723 /* Function : XGI_SetAntiFlicker */
9726 /* Description : Set TV Customized Param. */
9727 /* --------------------------------------------------------------------- */
9728 void XGI_SetAntiFlicker( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
9735 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9738 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9741 if ( ModeNo <= 0x13 )
9743 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9747 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9751 tempah = TVAntiFlickList[ tempbx ] ;
9752 tempah = tempah << 4 ;
9754 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9758 /* --------------------------------------------------------------------- */
9759 /* Function : XGI_SetEdgeEnhance */
9763 /* --------------------------------------------------------------------- */
9764 void XGI_SetEdgeEnhance( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
9772 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9775 if ( ModeNo <= 0x13 )
9777 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9781 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9785 tempah = TVEdgeList[ tempbx ] ;
9786 tempah = tempah << 5 ;
9788 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9792 /* --------------------------------------------------------------------- */
9793 /* Function : XGI_SetPhaseIncr */
9797 /* --------------------------------------------------------------------- */
9798 void XGI_SetPhaseIncr( PVB_DEVICE_INFO pVBInfo )
9807 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9808 tempData = TVPhaseList[ tempbx ] ;
9810 XGINew_SetReg1( pVBInfo->Part2Port , 0x31 , ( USHORT )( tempData & 0x000000FF ) ) ;
9811 XGINew_SetReg1( pVBInfo->Part2Port , 0x32 , ( USHORT )( ( tempData & 0x0000FF00 ) >> 8 ) ) ;
9812 XGINew_SetReg1( pVBInfo->Part2Port , 0x33 , ( USHORT )( ( tempData & 0x00FF0000 ) >> 16 ) ) ;
9813 XGINew_SetReg1( pVBInfo->Part2Port , 0x34 , ( USHORT )( ( tempData & 0xFF000000 ) >> 24 ) ) ;
9817 /* --------------------------------------------------------------------- */
9818 /* Function : XGI_SetYFilter */
9822 /* --------------------------------------------------------------------- */
9823 void XGI_SetYFilter( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9833 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9839 filterPtr = NTSCYFilter1 ;
9843 filterPtr = PALYFilter1 ;
9849 filterPtr = PALMYFilter1 ;
9853 filterPtr = PALNYFilter1 ;
9858 filterPtr = NTSCYFilter2 ;
9862 filterPtr = PALMYFilter2 ;
9866 filterPtr = PALNYFilter2 ;
9870 filterPtr = PALYFilter2 ;
9877 if ( ModeNo <= 0x13 )
9878 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9880 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9887 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9889 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9890 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9891 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9892 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9896 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9897 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9898 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9899 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9902 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9904 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9905 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9906 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9911 /* --------------------------------------------------------------------- */
9912 /* Function : XGI_GetTVPtrIndex2 */
9914 /* Output : bx 0 : NTSC */
9918 /* 4 : NTSC1024x768 */
9919 /* 5 : PAL-M 1024x768 */
9921 /* cl 0 : YFilter1 */
9924 /* 1 : 301B/302B/301LV/302LV */
9926 /* --------------------------------------------------------------------- */
9927 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo)
9933 if ( pVBInfo->TVInfo & SetPALTV )
9936 if ( pVBInfo->TVInfo & SetPALMTV )
9939 if ( pVBInfo->TVInfo & SetPALNTV )
9942 if ( pVBInfo->TVInfo & NTSC1024x768 )
9945 if ( pVBInfo->TVInfo & SetPALMTV )
9949 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9951 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9958 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9963 /* --------------------------------------------------------------------- */
9964 /* Function : XGI_SetCRT2ModeRegs */
9967 /* Description : Origin code for crt2group */
9968 /* --------------------------------------------------------------------- */
9969 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
9976 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9978 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9980 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9981 tempah &= ~0x10 ; /* BTRAMDAC */
9982 tempah |= 0x40 ; /* BTRAM */
9984 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9986 tempah=0x40; /* BTDRAM */
9987 if ( ModeNo > 0x13 )
9989 tempcl = pVBInfo->ModeType ;
9993 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9999 if ( pVBInfo->VBInfo & SetInSlaveMode )
10000 tempah ^= 0x50 ; /* BTDAC */
10005 if ( pVBInfo->VBInfo & DisableCRT2Display )
10010 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
10011 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
10013 tempcl = pVBInfo->ModeType ;
10014 if ( ModeNo > 0x13 )
10016 tempcl -= ModeVGA ;
10017 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
10019 tempah=(0x008>>tempcl) ;
10030 if ( pVBInfo->VBInfo & SetInSlaveMode )
10032 tempah = ( tempah ^ 0x050 ) ;
10037 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
10041 if ( pVBInfo->VBInfo & DisableCRT2Display )
10042 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10048 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
10050 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
10054 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10058 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
10064 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
10069 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
10072 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
10074 tempah = tempah ^ 0x05 ;
10075 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10076 tempah = tempah ^ 0x01 ;
10079 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
10081 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10084 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10088 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
10091 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
10093 tempah &= ( ~0x08 ) ;
10094 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
10100 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10102 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
10105 if ( ModeNo > 0x13 )
10107 if ( pVBInfo->VBInfo & DriverMode )
10108 tempah = tempah ^ 0x20 ;
10113 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
10116 if ( pVBInfo->LCDInfo & SetLCDDualLink )
10119 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10121 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
10123 if ( pVBInfo->TVInfo & RPLLDIV2XO )
10128 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
10131 if ( pVBInfo->LCDResInfo == Panel1280x960 )
10134 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
10137 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
10142 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
10145 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
10146 tempah |= 0x04 ; /* shampoo 0129 */
10149 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
10152 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
10154 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
10158 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
10162 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
10164 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
10167 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
10172 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
10175 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
10179 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
10181 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
10183 if ( pVBInfo->LCDInfo & SetLCDDualLink )
10185 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
10186 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
10192 /* --------------------------------------------------------------------- */
10193 /* Function : XGI_CloseCRTC */
10196 /* Description : */
10197 /* --------------------------------------------------------------------- */
10198 void XGI_CloseCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10204 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
10211 /* --------------------------------------------------------------------- */
10212 /* Function : XGI_OpenCRTC */
10215 /* Description : */
10216 /* --------------------------------------------------------------------- */
10217 void XGI_OpenCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10227 /* --------------------------------------------------------------------- */
10228 /* Function : XGI_GetRAMDAC2DATA */
10231 /* Description : */
10232 /* --------------------------------------------------------------------- */
10233 void XGI_GetRAMDAC2DATA(USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
10244 pVBInfo->RVBHCMAX = 1 ;
10245 pVBInfo->RVBHCFACT = 1 ;
10247 if ( ModeNo <= 0x13 )
10249 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
10250 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
10251 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
10252 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
10253 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
10257 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
10258 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
10259 CRT1Index &= IndexMask ;
10260 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 0 ] ;
10261 temp2 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] ;
10262 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
10263 tempbx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 8 ] ;
10264 tempcx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] << 8 ;
10266 tempcx = tempcx << 2 ;
10268 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
10271 if ( temp1 & 0x01 )
10274 if ( temp1 & 0x20 )
10278 if ( modeflag & Charx8Dot )
10283 pVBInfo->VGAHT = tempax ;
10284 pVBInfo->HT = tempax ;
10286 pVBInfo->VGAVT = tempbx ;
10287 pVBInfo->VT = tempbx ;
10292 /* --------------------------------------------------------------------- */
10293 /* Function : XGI_GetColorDepth */
10296 /* Description : */
10297 /* --------------------------------------------------------------------- */
10298 USHORT XGI_GetColorDepth(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
10300 USHORT ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
10304 if ( ModeNo <= 0x13 )
10306 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
10310 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
10313 index=(modeflag&ModeInfoFlag)-ModeEGA;
10318 return( ColorDepth[ index ] ) ;
10323 /* --------------------------------------------------------------------- */
10324 /* Function : XGI_UnLockCRT2 */
10327 /* Description : */
10328 /* --------------------------------------------------------------------- */
10329 void XGI_UnLockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10332 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
10337 /* --------------------------------------------------------------------- */
10338 /* Function : XGI_LockCRT2 */
10341 /* Description : */
10342 /* --------------------------------------------------------------------- */
10343 void XGI_LockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10346 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
10352 /* --------------------------------------------------------------------- */
10353 /* Function : XGINew_EnableCRT2 */
10356 /* Description : */
10357 /* --------------------------------------------------------------------- */
10358 void XGINew_EnableCRT2( PVB_DEVICE_INFO pVBInfo)
10360 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
10365 /* --------------------------------------------------------------------- */
10369 /* Description : */
10370 /* --------------------------------------------------------------------- */
10371 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo)
10380 //printk("XGINew_LCD_Wait_Time");
10382 for( i = 0 ; i < DelayTime ; i++ )
10384 for( j = 0 ; j < 66 ; j++ )
10387 temp = XGINew_GetReg3( 0x61 ) ;
10389 //temp &= 0x10000000;
10391 if ( temp == flag )
10402 /* --------------------------------------------------------------------- */
10403 /* Function : XGI_BridgeIsOn */
10406 /* Description : */
10407 /* --------------------------------------------------------------------- */
10408 BOOLEAN XGI_BridgeIsOn( PVB_DEVICE_INFO pVBInfo )
10412 if ( pVBInfo->IF_DEF_LVDS == 1 )
10418 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10419 if ( ( flag == 1 ) || ( flag == 2 ) )
10420 return( 1 ) ; /* 301b */
10428 /* --------------------------------------------------------------------- */
10429 /* Function : XGI_LongWait */
10432 /* Description : */
10433 /* --------------------------------------------------------------------- */
10434 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo)
10438 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10440 if ( !( i & 0xC0 ) )
10442 for( i = 0 ; i < 0xFFFF ; i++ )
10444 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10448 for( i = 0 ; i < 0xFFFF ; i++ )
10450 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10457 /* --------------------------------------------------------------------- */
10458 /* Function : XGI_VBLongWait */
10461 /* Description : */
10462 /* --------------------------------------------------------------------- */
10463 void XGI_VBLongWait( PVB_DEVICE_INFO pVBInfo )
10470 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10473 for( i = 0 ; i < 3 ; i++ )
10475 for( j = 0 ; j < 100 ; j++ )
10477 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10479 { /* VBWaitMode2 */
10480 if ( ( tempal & 0x08 ) )
10485 if ( !( tempal & 0x08 ) )
10491 { /* VBWaitMode1 */
10492 if ( !( tempal & 0x08 ) )
10497 if ( ( tempal & 0x08 ) )
10503 temp = temp ^ 0x01 ;
10508 XGI_LongWait(pVBInfo) ;
10516 /* --------------------------------------------------------------------- */
10517 /* Function : XGI_GetVGAHT2 */
10520 /* Description : */
10521 /* --------------------------------------------------------------------- */
10522 USHORT XGI_GetVGAHT2( PVB_DEVICE_INFO pVBInfo )
10527 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10528 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10529 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10531 return( ( USHORT )tempax ) ;
10535 /* --------------------------------------------------------------------- */
10536 /* Function : XGI_GetVCLK2Ptr */
10539 /* Description : */
10540 /* --------------------------------------------------------------------- */
10541 USHORT XGI_GetVCLK2Ptr( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
10545 USHORT LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10546 USHORT LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10547 USHORT LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10548 USHORT LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10549 USHORT LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10551 USHORT CRT2Index , VCLKIndex ;
10552 USHORT modeflag , resinfo ;
10553 UCHAR *CHTVVCLKPtr = NULL ;
10555 if ( ModeNo <= 0x13 )
10557 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10558 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10559 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10563 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10564 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10565 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10568 if ( pVBInfo->IF_DEF_LVDS == 0 )
10570 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10571 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10573 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10575 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10579 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10584 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10586 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10588 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10590 VCLKIndex = HiTVVCLKDIV2 ;
10598 VCLKIndex = HiTVVCLK ;
10605 if ( pVBInfo->SetFlag & TVSimuMode )
10607 if( modeflag & Charx8Dot )
10609 VCLKIndex = HiTVSimuVCLK ;
10617 VCLKIndex = HiTVTextVCLK ;
10625 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10627 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10629 VCLKIndex = YPbPr750pVCLK ;
10630 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10632 VCLKIndex = YPbPr525pVCLK ;
10633 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10635 VCLKIndex = YPbPr525iVCLK_2 ;
10636 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10637 VCLKIndex = YPbPr525iVCLK ;
10645 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10647 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10649 VCLKIndex = TVVCLKDIV2 ;
10657 VCLKIndex = TVVCLK ;
10668 VCLKIndex = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ; /* Port 3cch */
10669 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10670 if ( ModeNo > 0x13 )
10672 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10673 VCLKIndex &= IndexMask ;
10680 if ( ModeNo <= 0x13 )
10681 VCLKIndex = CRT2Index ;
10683 VCLKIndex = CRT2Index ;
10685 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10687 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10689 VCLKIndex &= 0x1f ;
10692 if ( pVBInfo->VBInfo & SetPALTV )
10695 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10701 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10704 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10707 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10710 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10716 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10721 VCLKIndex = VCLKIndex >> 6 ;
10722 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10723 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10724 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10725 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10727 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10730 /* VCLKIndex = VCLKIndex&IndexMask ; */
10734 return( VCLKIndex ) ;