3 #include <linux/types.h>
4 #include <linux/version.h>
10 #include "vb_struct.h"
16 #define IndexMask 0xff
17 #ifndef XGI_MASK_DUAL_CHIP
18 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
23 unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo);
24 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
25 struct xgi_hw_device_info *HwDeviceExtension,
26 struct vb_device_info *pVBInfo);
27 unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo);
29 unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo);
30 unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo);
31 unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo);
32 unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
33 unsigned short ModeIdIndex,
34 unsigned short RefreshRateTableIndex,
35 unsigned short *i, struct vb_device_info *pVBInfo);
36 unsigned char XGI_SearchModeID(unsigned short ModeNo,
37 unsigned short *ModeIdIndex,
38 struct vb_device_info *pVBInfo);
39 unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
40 unsigned short ModeIdIndex,
41 struct vb_device_info *pVBInfo);
42 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
43 unsigned short ModeNo);
44 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo);
45 unsigned char XGI_GetModePtr(unsigned short ModeNo,
46 unsigned short ModeIdIndex,
47 struct vb_device_info *pVBInfo);
48 unsigned short XGI_GetOffset(unsigned short ModeNo,
49 unsigned short ModeIdIndex,
50 unsigned short RefreshRateTableIndex,
51 struct xgi_hw_device_info *HwDeviceExtension,
52 struct vb_device_info *pVBInfo);
53 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
54 unsigned short ModeNo,
55 unsigned short ModeIdIndex,
56 struct vb_device_info *pVBInfo);
57 unsigned short XGI_GetResInfo(unsigned short ModeNo,
58 unsigned short ModeIdIndex,
59 struct vb_device_info *pVBInfo);
60 unsigned short XGI_GetColorDepth(unsigned short ModeNo,
61 unsigned short ModeIdIndex,
62 struct vb_device_info *pVBInfo);
63 unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo);
64 unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
65 unsigned short ModeIdIndex,
66 unsigned short RefreshRateTableIndex,
67 struct xgi_hw_device_info *HwDeviceExtension,
68 struct vb_device_info *pVBInfo);
69 void XGI_VBLongWait(struct vb_device_info *pVBInfo);
70 void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo);
71 void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
72 void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
73 void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
74 void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
75 void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
76 void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
77 void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
78 void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
79 void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
80 void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
81 void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
82 void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
83 void XGI_FirePWDEnable(struct vb_device_info *pVBInfo);
84 void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
85 void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
86 void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo);
87 void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, struct vb_device_info *pVBInfo);
88 void XGI_EnablePWD(struct vb_device_info *pVBInfo);
89 void XGI_DisablePWD(struct vb_device_info *pVBInfo);
90 void XGI_AutoThreshold(struct vb_device_info *pVBInfo);
91 void XGI_SetTap4Regs(struct vb_device_info *pVBInfo);
93 void XGI_DisplayOn(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
94 void XGI_DisplayOff(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
95 void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
96 void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
97 void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
98 void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
99 void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
100 void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex);
101 void XGI_WaitDisply(struct vb_device_info *pVBInfo);
102 void XGI_SenseCRT1(struct vb_device_info *pVBInfo);
103 void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
104 void XGI_SetMiscRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
105 void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
106 void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
107 void XGI_SetGRCRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
108 void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo);
110 void XGI_SetSync(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
111 void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension);
112 void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension);
113 void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo, struct vb_device_info *pVBInfo);
114 void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
115 void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
116 void XGI_SetCRT1FIFO(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
117 void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
118 void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
120 void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
121 void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al, unsigned short dh, struct vb_device_info *pVBInfo);
122 /*void XGI_ClearBuffer(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, struct vb_device_info *pVBInfo);*/
123 void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
124 void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
125 struct vb_device_info *pVBInfo);
126 void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
127 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo);
128 void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
129 unsigned short RefreshRateTableIndex,
130 struct xgi_hw_device_info *HwDeviceExtension,
131 struct vb_device_info *pVBInfo);
132 void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
133 void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
134 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
135 void XGI_GetVBType(struct vb_device_info *pVBInfo);
136 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
137 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
138 void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
139 void InitTo330Pointer(unsigned char, struct vb_device_info *pVBInfo);
140 void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, struct vb_device_info *pVBInfo);
141 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
142 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
143 void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
144 void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
145 void XGI_SetDelayComp(struct vb_device_info *pVBInfo);
146 void XGI_SetLCDCap(struct vb_device_info *pVBInfo);
147 void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo);
148 void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo);
149 void SetSpectrum(struct vb_device_info *pVBInfo);
150 void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
151 void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
152 void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo);
153 void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
154 void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char* tempcl,
155 unsigned char *tempch, struct vb_device_info *pVBInfo);
156 unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo);
157 void XGI_SetCRT2ModeRegs(unsigned short ModeNo, struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
158 void XGI_CloseCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
159 void XGI_OpenCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
160 void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
161 void XGI_UnLockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
162 void XGI_LockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
163 void XGINew_EnableCRT2(struct vb_device_info *pVBInfo);
164 void XGINew_LCD_Wait_Time(unsigned char DelayTime, struct vb_device_info *pVBInfo);
165 void XGI_LongWait(struct vb_device_info *pVBInfo);
166 void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
167 void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
168 struct vb_device_info *pVBInfo);
169 unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
170 unsigned short ModeNo,
171 unsigned short ModeIdIndex,
172 struct vb_device_info *pVBInfo);
173 void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
174 unsigned char *di_1, struct vb_device_info *pVBInfo);
175 unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo);
176 unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo);
177 struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo);
178 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo);
179 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo);
180 unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo);
181 unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo);
182 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
183 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
184 void XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo);
185 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
186 void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
187 void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
188 unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo);
190 extern void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVBInfo);
192 /* unsigned short XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
195 static unsigned short XGINew_MDA_DAC[] = {
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
198 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
199 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
202 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
203 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
205 static unsigned short XGINew_CGA_DAC[] = {
206 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
207 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
208 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
209 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
210 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
211 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
212 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
213 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
215 static unsigned short XGINew_EGA_DAC[] = {
216 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
217 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
218 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
219 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
220 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
221 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
222 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
223 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
225 static unsigned short XGINew_VGA_DAC[] = {
226 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
227 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
228 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
229 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
230 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
231 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
232 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
233 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
234 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
235 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
238 /* --------------------------------------------------------------------- */
239 /* Function : InitTo330Pointer */
243 /* --------------------------------------------------------------------- */
244 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
246 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable ;
247 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable ;
248 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable ;
249 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex ;
250 pVBInfo->XGINEWUB_CRT1Table = (struct XGI_CRT1TableStruct *) XGI_CRT1Table ;
252 /* add for new UNIVGABIOS */
253 /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
254 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
257 if ( ChipType >= XG40 )
259 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
260 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
264 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI330New_MCLKData;
265 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI330_ECLKData;
268 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData ;
269 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
270 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
271 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo ;
272 pVBInfo->ModeResInfo = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
274 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
275 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
276 pVBInfo->pSR07 = &XGI330_SR07 ;
277 pVBInfo->LCDResInfo = 0 ;
278 pVBInfo->LCDTypeInfo = 0 ;
279 pVBInfo->LCDInfo = 0 ;
280 pVBInfo->VBInfo = 0 ;
284 pVBInfo->SR15 = XGI340_SR13 ;
285 pVBInfo->CR40 = XGI340_cr41 ;
286 pVBInfo->SR25 = XGI330_sr25 ;
287 pVBInfo->pSR31 = &XGI330_sr31 ;
288 pVBInfo->pSR32 = &XGI330_sr32 ;
289 pVBInfo->CR6B = XGI340_CR6B ;
290 pVBInfo->CR6E = XGI340_CR6E ;
291 pVBInfo->CR6F = XGI340_CR6F ;
292 pVBInfo->CR89 = XGI340_CR89 ;
293 pVBInfo->AGPReg = XGI340_AGPReg ;
294 pVBInfo->SR16 = XGI340_SR16 ;
295 pVBInfo->pCRCF = &XG40_CRCF ;
296 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
299 pVBInfo->CR49 = XGI330_CR49 ;
300 pVBInfo->pSR1F = &XGI330_SR1F ;
301 pVBInfo->pSR21 = &XGI330_SR21 ;
302 pVBInfo->pSR22 = &XGI330_SR22 ;
303 pVBInfo->pSR23 = &XGI330_SR23 ;
304 pVBInfo->pSR24 = &XGI330_SR24 ;
305 pVBInfo->pSR33 = &XGI330_SR33 ;
309 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
310 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
311 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
312 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
313 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
314 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
315 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
316 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
317 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
318 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
320 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
321 pVBInfo->PALTiming = XGI330_PALTiming ;
322 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
323 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
324 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
325 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
326 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
327 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
328 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
329 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
330 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
331 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
332 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
333 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
336 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH ;
337 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV ;
338 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
340 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
341 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
342 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
343 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
345 /* 310 customization related */
346 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
347 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
349 pVBInfo->LCDCapList = XGI_LCDCapList ;
351 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
352 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
354 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
355 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
358 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
360 if ( ChipType >= XG20 )
361 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
363 if ( ChipType == XG27 )
365 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
366 pVBInfo->CR40 = XGI27_cr41 ;
367 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
368 pVBInfo->pSR36 = &XG27_SR36 ;
369 pVBInfo->pCR8F = &XG27_CR8F ;
370 pVBInfo->pCRD0 = XG27_CRD0 ;
371 pVBInfo->pCRDE = XG27_CRDE ;
372 pVBInfo->pSR40 = &XG27_SR40 ;
373 pVBInfo->pSR41 = &XG27_SR41 ;
377 if ( ChipType >= XG20 )
379 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
380 pVBInfo->pCR2E = &XG21_CR2E ;
381 pVBInfo->pCR2F = &XG21_CR2F ;
382 pVBInfo->pCR46 = &XG21_CR46 ;
383 pVBInfo->pCR47 = &XG21_CR47 ;
393 /* --------------------------------------------------------------------- */
394 /* Function : XGISetModeNew */
398 /* --------------------------------------------------------------------- */
399 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
400 unsigned short ModeNo)
402 unsigned short ModeIdIndex ;
403 /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
404 struct vb_device_info VBINF;
405 struct vb_device_info *pVBInfo = &VBINF;
406 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
407 pVBInfo->BaseAddr = (unsigned long)HwDeviceExtension->pjIOAddress ;
408 pVBInfo->IF_DEF_LVDS = 0 ;
409 pVBInfo->IF_DEF_CH7005 = 0 ;
410 pVBInfo->IF_DEF_LCDA = 1 ;
411 pVBInfo->IF_DEF_CH7017 = 0 ;
412 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
413 pVBInfo->IF_DEF_VideoCapture = 0 ;
414 pVBInfo->IF_DEF_ScaleLCD = 0 ;
415 pVBInfo->IF_DEF_OEMUtil = 0 ;
416 pVBInfo->IF_DEF_PWD = 0 ;
419 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
421 pVBInfo->IF_DEF_YPbPr = 0 ;
422 pVBInfo->IF_DEF_HiVision = 0 ;
423 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
424 pVBInfo->VBType = 0 ; /*set VBType default 0*/
426 else if ( HwDeviceExtension->jChipType >= XG40 )
428 pVBInfo->IF_DEF_YPbPr = 1 ;
429 pVBInfo->IF_DEF_HiVision = 1 ;
430 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
434 pVBInfo->IF_DEF_YPbPr = 1 ;
435 pVBInfo->IF_DEF_HiVision = 1 ;
436 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
439 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
440 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
441 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
442 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
443 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
444 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
445 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
446 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
447 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
448 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
449 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
450 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
451 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
452 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
453 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
454 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
455 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
456 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
458 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
460 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
462 pVBInfo->IF_DEF_LVDS = 1 ;
465 if ( HwDeviceExtension->jChipType == XG27 )
467 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
469 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
471 pVBInfo->IF_DEF_LVDS = 1 ;
476 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
477 XGI_GetVBType( pVBInfo ) ;
479 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
482 ModeNo = ModeNo & 0x7F ;
483 /* XGINew_flag_clearbuffer = 0 ; */
487 XGINew_flag_clearbuffer = 1 ;
490 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
492 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
493 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
495 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
497 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
499 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
501 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
502 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
503 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
504 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
505 /* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
507 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
509 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
511 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
513 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
518 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
520 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
521 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
523 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
528 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
530 switch( HwDeviceExtension->ujVBChipID )
533 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
537 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
545 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
546 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
547 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
548 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
552 if (pVBInfo->IF_DEF_LVDS == 1)
553 if (!XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo))
556 if ( ModeNo <= 0x13 )
558 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
562 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
565 pVBInfo->SetFlag = 0 ;
566 if ( pVBInfo->IF_DEF_CH7007 != 1 )
568 pVBInfo->VBInfo = DisableCRT2Display ;
572 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
574 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
576 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
578 if( HwDeviceExtension->jChipType == XG21 )
579 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
585 if ( ModeNo <= 0x13 )
587 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
591 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
593 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
594 pVBInfo->SetFlag = 0x00 ;
595 pVBInfo->VBInfo = DisableCRT2Display ;
596 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
601 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
602 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
603 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
606 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
608 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
610 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
617 /* --------------------------------------------------------------------- */
618 /* Function : XGI_SetCRT1Group */
622 /* --------------------------------------------------------------------- */
623 void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
624 unsigned short ModeNo,
625 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
627 unsigned short StandTableIndex ,
628 RefreshRateTableIndex ,
632 unsigned short XGINew_P3cc = pVBInfo->P3cc;
634 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
635 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
636 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
637 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
638 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
639 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
640 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
641 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
642 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
643 XGI_ClearExt1Regs(pVBInfo) ;
645 /* if ( pVBInfo->IF_DEF_ExpLink ) */
646 if ( HwDeviceExtension->jChipType == XG27 )
648 if ( pVBInfo->IF_DEF_LVDS == 0 )
650 XGI_SetDefaultVCLK( pVBInfo ) ;
654 temp = ~ProgrammingCRT2 ;
655 pVBInfo->SetFlag &= temp ;
656 pVBInfo->SelectCRT2Rate = 0 ;
658 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
660 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
662 pVBInfo->SetFlag |= ProgrammingCRT2 ;
666 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
667 if ( RefreshRateTableIndex != 0xFFFF )
669 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
670 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
671 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
672 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
673 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
676 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
677 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
679 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
681 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
682 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
683 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc) ;
684 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
686 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
688 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
689 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
690 b3CC = (unsigned char)XGINew_GetReg2(XGINew_P3cc) ;
691 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
695 if ( HwDeviceExtension->jChipType >= XG21 )
697 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
701 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
702 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
703 /* XG21 CRT1 Timing */
704 if ( HwDeviceExtension->jChipType == XG27 )
705 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
707 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
709 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
711 if ( HwDeviceExtension->jChipType == XG27 )
712 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
714 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
716 if ( pVBInfo->IF_DEF_LVDS == 1 )
718 if ( HwDeviceExtension->jChipType == XG27 )
719 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
721 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
723 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
727 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
728 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
729 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
732 /* XGI_LoadCharacter(); //dif ifdef TVFont */
734 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
735 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
739 /* --------------------------------------------------------------------- */
740 /* Function : XGI_GetModePtr */
744 /* --------------------------------------------------------------------- */
745 unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
746 struct vb_device_info *pVBInfo)
748 unsigned char index ;
750 if ( ModeNo <= 0x13 )
751 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
754 if ( pVBInfo->ModeType <= 0x02 )
755 index = 0x1B ; /* 02 -> ModeEGA */
759 return( index ) ; /* Get pVBInfo->StandTable index */
763 /* --------------------------------------------------------------------- */
764 /* Function : XGI_SetBIOSData */
768 /* --------------------------------------------------------------------- */
769 /*unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex)
775 /* --------------------------------------------------------------------- */
776 /* Function : XGI_ClearBankRegs */
780 /* --------------------------------------------------------------------- */
781 /*unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex)
787 /* --------------------------------------------------------------------- */
788 /* Function : XGI_SetSeqRegs */
792 /* --------------------------------------------------------------------- */
793 void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
794 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
796 unsigned char tempah ,
802 if ( ModeNo <= 0x13 )
803 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
805 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
807 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
808 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
811 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
817 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
819 if ( pVBInfo->VBInfo & SetInSlaveMode )
824 tempah |= 0x20 ; /* screen off */
825 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
827 for( i = 02 ; i <= 04 ; i++ )
829 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
830 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
835 /* --------------------------------------------------------------------- */
836 /* Function : XGI_SetMiscRegs */
840 /* --------------------------------------------------------------------- */
841 void XGI_SetMiscRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
843 unsigned char Miscdata ;
845 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
847 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
849 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
856 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
860 /* --------------------------------------------------------------------- */
861 /* Function : XGI_SetCRTCRegs */
865 /* --------------------------------------------------------------------- */
866 void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
867 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
869 unsigned char CRTCdata ;
872 CRTCdata = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
874 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
876 for( i = 0 ; i <= 0x18 ; i++ )
878 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
879 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
882 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
884 if ( pVBInfo->VBInfo & SetInSlaveMode )
886 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
888 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
896 /* --------------------------------------------------------------------- */
901 /* --------------------------------------------------------------------- */
902 void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
903 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
905 unsigned char ARdata ;
906 unsigned short i, modeflag;
908 if ( ModeNo <= 0x13 )
909 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
911 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
913 for( i = 0 ; i <= 0x13 ; i++ )
915 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
916 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
920 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
924 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
926 if ( pVBInfo->VBInfo & SetInSlaveMode )
933 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
934 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
935 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
938 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
939 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
940 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
941 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
942 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
946 /* --------------------------------------------------------------------- */
947 /* Function : XGI_SetGRCRegs */
951 /* --------------------------------------------------------------------- */
952 void XGI_SetGRCRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
954 unsigned char GRdata ;
957 for( i = 0 ; i <= 0x08 ; i++ )
959 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
960 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
963 if ( pVBInfo->ModeType > ModeVGA )
965 GRdata = (unsigned char)XGINew_GetReg1(pVBInfo->P3ce, 0x05);
966 GRdata &= 0xBF ; /* 256 color disable */
967 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
972 /* --------------------------------------------------------------------- */
973 /* Function : XGI_ClearExt1Regs */
977 /* --------------------------------------------------------------------- */
978 void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
982 for( i = 0x0A ; i <= 0x0E ; i++ )
983 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
987 /* --------------------------------------------------------------------- */
988 /* Function : XGI_SetDefaultVCLK */
992 /* --------------------------------------------------------------------- */
993 unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
996 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
997 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
998 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
1000 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
1001 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
1002 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
1004 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
1009 /* --------------------------------------------------------------------- */
1010 /* Function : XGI_GetRatePtrCRT2 */
1014 /* --------------------------------------------------------------------- */
1015 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
1016 unsigned short ModeNo,
1017 unsigned short ModeIdIndex,
1018 struct vb_device_info *pVBInfo)
1020 short LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
1021 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
1023 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
1025 if ( ModeNo <= 0x13 )
1027 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1031 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1034 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1036 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1038 if ( modeflag & HalfDCLK )
1043 if ( ModeNo < 0x14 )
1046 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1047 index = index >> pVBInfo->SelectCRT2Rate ;
1050 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1056 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1058 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1060 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1066 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1068 if( pVBInfo->IF_DEF_LVDS == 0 )
1070 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1071 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1073 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1087 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1088 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1089 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1092 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1097 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1098 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1102 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1103 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1104 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1108 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1109 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1118 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1120 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1121 temp &= ModeInfoFlag ;
1122 if ( temp < pVBInfo->ModeType )
1127 } while( index != 0xFFFF ) ;
1128 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1130 if ( pVBInfo->VBInfo & SetInSlaveMode )
1132 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1133 if ( temp & InterlaceMode )
1140 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1142 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1144 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1148 /* --------------------------------------------------------------------- */
1149 /* Function : XGI_AjustCRT2Rate */
1153 /* --------------------------------------------------------------------- */
1154 unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, unsigned short ModeIdIndex,
1155 unsigned short RefreshRateTableIndex,
1156 unsigned short *i, struct vb_device_info *pVBInfo)
1158 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
1160 if ( ModeNo <= 0x13 )
1162 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1166 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1169 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1170 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1173 if ( pVBInfo->IF_DEF_LVDS == 0 )
1175 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1177 tempax |= SupportRAMDAC2 ;
1179 if ( pVBInfo->VBType & VB_XGI301C )
1180 tempax |= SupportCRT2in301C ;
1183 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1185 tempax |= SupportLCD ;
1187 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1189 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1191 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1203 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1205 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1207 tempax |= SupportYPbPr ;
1208 if ( pVBInfo->VBInfo & SetInSlaveMode )
1222 tempax |= SupportHiVisionTV ;
1223 if ( pVBInfo->VBInfo & SetInSlaveMode )
1230 if ( pVBInfo->SetFlag & TVSimuMode )
1241 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1243 tempax |= SupportTV ;
1245 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1247 tempax |= SupportTV1024 ;
1250 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1252 if ( modeflag & NoSupportSimuTV )
1254 if ( pVBInfo->VBInfo & SetInSlaveMode )
1256 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1268 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1270 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1272 tempax |= SupportCHTV ;
1276 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1278 tempax |= SupportLCD ;
1280 if ( resinfo > 0x08 )
1281 return( 0 ) ; /* 1024x768 */
1283 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1285 if ( resinfo > 0x07 )
1286 return( 0 ) ; /* 800x600 */
1288 if ( resinfo == 0x04 )
1289 return( 0 ) ; /* 512x384 */
1294 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1296 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1297 if ( infoflag & tempax )
1305 for( ( *i ) = 0 ; ; ( *i )++ )
1307 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1308 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1313 if ( infoflag & tempax )
1322 /* --------------------------------------------------------------------- */
1323 /* Function : XGI_SetSync */
1327 /* --------------------------------------------------------------------- */
1328 void XGI_SetSync(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
1330 unsigned short sync ,
1333 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1337 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1341 /* --------------------------------------------------------------------- */
1342 /* Function : XGI_SetCRT1CRTC */
1346 /* --------------------------------------------------------------------- */
1347 void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1348 unsigned short RefreshRateTableIndex,
1349 struct vb_device_info *pVBInfo,
1350 struct xgi_hw_device_info *HwDeviceExtension)
1352 unsigned char index, data;
1355 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1356 index = index&IndexMask ;
1358 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1360 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1362 for( i = 0 ; i < 8 ; i++ )
1363 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1365 for( i = 0 ; i < 7 ; i++ )
1366 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1368 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1372 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1375 if( pVBInfo->ModeType > 0x03 )
1376 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1380 /* --------------------------------------------------------------------- */
1381 /* Function : XGI_SetCRT1Timing_H */
1385 /* --------------------------------------------------------------------- */
1386 void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension)
1388 unsigned char data, data1, pushax;
1389 unsigned short i, j;
1391 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1392 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1393 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1395 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
1397 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1399 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1400 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1402 for( i = 0x01 ; i <= 0x04 ; i++ )
1404 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
1405 XGINew_SetReg1( pVBInfo->P3d4, (unsigned short)(i + 1), data);
1408 for( i = 0x05 ; i <= 0x06 ; i++ )
1410 data = pVBInfo->TimingH[ 0 ].data[ i ];
1411 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short)(i + 6), data);
1414 j = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1416 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1419 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1421 if ( HwDeviceExtension->jChipType >= XG20 )
1423 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x04);
1425 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1426 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x05);
1433 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0c);
1435 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1440 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1441 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1447 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1452 /* --------------------------------------------------------------------- */
1453 /* Function : XGI_SetCRT1Timing_V */
1457 /* --------------------------------------------------------------------- */
1458 void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
1459 unsigned short ModeNo,
1460 struct vb_device_info *pVBInfo)
1463 unsigned short i, j;
1465 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1466 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1467 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1469 for( i = 0x00 ; i <= 0x01 ; i++ )
1471 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1472 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 6), data);
1475 for( i = 0x02 ; i <= 0x03 ; i++ )
1477 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1478 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 0x0e), data);
1481 for( i = 0x04 ; i <= 0x05 ; i++ )
1483 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1484 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 0x11), data);
1487 j = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0a);
1489 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1492 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1494 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1498 if ( ModeNo <= 0x13 )
1499 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1501 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1503 i &= DoubleScanMode ;
1507 j = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x09);
1510 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1514 /* --------------------------------------------------------------------- */
1515 /* Function : XGI_SetXG21CRTC */
1516 /* Input : Stand or enhance CRTC table */
1517 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1518 /* Description : Set LCD timing */
1519 /* --------------------------------------------------------------------- */
1520 void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1521 unsigned short RefreshRateTableIndex,
1522 struct vb_device_info *pVBInfo)
1524 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1525 unsigned short Temp1, Temp2, Temp3;
1527 if ( ModeNo <= 0x13 )
1529 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1530 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1531 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1532 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1533 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1535 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1536 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1537 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1538 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1539 Tempdx <<= 2 ; /* Tempdx << 2 */
1540 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1541 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1543 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1544 Tempbx = Tempax ; /* Tempbx=Tempax */
1545 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1546 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1547 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1548 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1549 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1550 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1551 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1552 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1554 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
1555 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1556 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1557 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1558 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1560 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1561 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1562 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1563 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1564 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1565 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1566 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1567 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1568 Tempax = (unsigned char)Temp2; /* Tempax[7:0]: VRE[7:0] */
1569 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1570 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1571 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1572 Tempbx = (unsigned char)Temp1; /* Tempbx[1:0]: VRS[10:9] */
1573 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1575 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1579 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1580 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1581 Tempcx = Tempax ; /* Tempcx: HRS */
1582 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1584 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1585 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1586 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1587 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1588 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1590 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1591 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1593 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1594 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1595 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1596 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1598 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1599 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1601 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1602 if( Tempax < Tempcx ) /* HRE < HRS */
1603 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1606 Tempax = (unsigned char)Temp2; /* Tempax: HRE[7:0] */
1607 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1608 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1609 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1610 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1611 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1613 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1614 Tempbx = Tempax ; /* Tempbx: VRS */
1615 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1616 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1617 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1618 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1619 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1620 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1621 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1622 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1624 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1625 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1626 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1628 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1629 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1630 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1631 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1633 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1634 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1636 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1637 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1638 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1639 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1640 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1641 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1642 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1643 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1645 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1646 if ( Tempax < Temp3 ) /* VRE < VRS */
1647 Temp2 |= 0x20 ; /* VRE + 0x20 */
1650 Tempax = (unsigned char)Temp2; /* Tempax: VRE[7:0] */
1651 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1652 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1653 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1654 Tempbx = (unsigned char)Temp1;
1655 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1657 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1661 void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1662 unsigned short RefreshRateTableIndex,
1663 struct vb_device_info *pVBInfo)
1665 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1667 if ( ModeNo <= 0x13 )
1669 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1670 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1671 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1672 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1673 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1675 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1676 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1677 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1678 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1679 Tempdx <<= 2 ; /* Tempdx << 2 */
1680 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1681 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1683 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1684 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1685 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1686 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1687 Tempbx = Tempax ; /* Tempbx=CR07 */
1688 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1690 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1691 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1692 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1695 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1696 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1697 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1698 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1699 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1700 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1701 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1702 Tempax = (unsigned char)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1703 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1704 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1705 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1706 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1710 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1711 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1712 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1713 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1715 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1716 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1717 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1719 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1720 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1721 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1723 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1724 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1725 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1726 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1728 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1729 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1731 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1732 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1733 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1734 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1736 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1737 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1738 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1739 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1740 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1741 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1743 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1744 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1746 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1747 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1748 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1749 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1750 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1751 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1752 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1753 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1754 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1755 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1756 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1759 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1760 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1761 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1762 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1763 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1764 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1765 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1766 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1767 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1769 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1770 Tempbx |= 0x20 ; /* VRE + 0x20 */
1772 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1773 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1774 Tempax = Tempcx >> 8;
1775 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1780 /* --------------------------------------------------------------------- */
1781 /* Function : XGI_SetXG21LCD */
1783 /* Output : FCLK duty cycle, FCLK delay compensation */
1784 /* Description : All values set zero */
1785 /* --------------------------------------------------------------------- */
1786 void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
1787 unsigned short RefreshRateTableIndex,
1788 unsigned short ModeNo)
1790 unsigned short Data, Temp, b3CC;
1791 unsigned short XGI_P3cc;
1793 XGI_P3cc = pVBInfo->P3cc ;
1795 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1796 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1797 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1798 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1799 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1801 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1802 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1803 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1804 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1807 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1811 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1812 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1815 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1817 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1818 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1820 if ( ModeNo <= 0x13 )
1822 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1824 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1826 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1830 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1831 if ( Data & 0x4000 )
1832 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1833 if ( Data & 0x8000 )
1834 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1838 void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
1839 unsigned short RefreshRateTableIndex,
1840 unsigned short ModeNo)
1842 unsigned short Data , Temp , b3CC ;
1843 unsigned short XGI_P3cc ;
1845 XGI_P3cc = pVBInfo->P3cc ;
1847 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1848 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1849 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1850 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1852 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1853 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1855 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1856 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1859 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1861 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1862 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1863 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1864 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1867 XGI_SetXG27FPBits(pVBInfo);
1869 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1871 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1872 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1874 if ( ModeNo <= 0x13 )
1876 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1878 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1880 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1884 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1885 if ( Data & 0x4000 )
1886 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1887 if ( Data & 0x8000 )
1888 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1892 /* --------------------------------------------------------------------- */
1893 /* Function : XGI_UpdateXG21CRTC */
1895 /* Output : CRT1 CRTC */
1896 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1897 /* --------------------------------------------------------------------- */
1898 void XGI_UpdateXG21CRTC(unsigned short ModeNo,
1899 struct vb_device_info *pVBInfo,
1900 unsigned short RefreshRateTableIndex)
1904 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1905 if ( ModeNo <= 0x13 )
1907 for( i = 0 ; i < 12 ; i++ )
1909 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1915 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1917 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1919 else if ( ModeNo == 0x2F )
1921 else if ( ModeNo == 0x50 )
1923 else if ( ModeNo == 0x59 )
1929 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1930 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1931 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1932 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1937 /* --------------------------------------------------------------------- */
1938 /* Function : XGI_SetCRT1DE */
1942 /* --------------------------------------------------------------------- */
1943 void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1944 unsigned short ModeNo,
1945 unsigned short ModeIdIndex,
1946 unsigned short RefreshRateTableIndex,
1947 struct vb_device_info *pVBInfo)
1949 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1953 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1955 if ( ModeNo <= 0x13 )
1957 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1958 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1959 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1963 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1964 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1965 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1968 if ( modeflag & HalfDCLK )
1969 tempax = tempax >> 1 ;
1971 if ( ModeNo > 0x13 )
1973 if ( modeflag & HalfDCLK )
1974 tempax = tempax << 1 ;
1976 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1978 if ( temp & InterlaceMode )
1979 tempbx = tempbx >> 1 ;
1981 if ( modeflag & DoubleScanMode )
1982 tempbx = tempbx << 1 ;
1987 /* if ( !( modeflag & Charx8Dot ) ) */
1994 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1995 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1997 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
1998 XGINew_SetReg1(pVBInfo->P3d4, 0x01, (unsigned short)(tempcx & 0xff));
1999 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0b, ~0x0c, (unsigned short)((tempcx & 0x0ff00) >> 10));
2000 XGINew_SetReg1(pVBInfo->P3d4, 0x12, (unsigned short)(tempbx & 0xff));
2002 tempbx = tempbx >> 8 ;
2004 if ( tempbx & 0x01 )
2007 if ( tempbx & 0x02 )
2010 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
2011 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x07);
2015 if ( tempbx & 0x04 )
2018 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
2019 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
2023 /* --------------------------------------------------------------------- */
2024 /* Function : XGI_GetResInfo */
2028 /* --------------------------------------------------------------------- */
2029 unsigned short XGI_GetResInfo(unsigned short ModeNo,
2030 unsigned short ModeIdIndex,
2031 struct vb_device_info *pVBInfo)
2033 unsigned short resindex;
2035 if ( ModeNo <= 0x13 )
2037 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2041 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2043 return( resindex ) ;
2047 /* --------------------------------------------------------------------- */
2048 /* Function : XGI_SetCRT1Offset */
2052 /* --------------------------------------------------------------------- */
2053 void XGI_SetCRT1Offset(unsigned short ModeNo,
2054 unsigned short ModeIdIndex,
2055 unsigned short RefreshRateTableIndex,
2056 struct xgi_hw_device_info *HwDeviceExtension,
2057 struct vb_device_info *pVBInfo)
2059 unsigned short temp ,
2067 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2069 temp = pVBInfo->ScreenOffset[ temp ] ;
2071 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2072 temp2 &= InterlaceMode ;
2077 temp2 = pVBInfo->ModeType - ModeEGA ;
2103 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2104 temp = temp * temp2 + temp2 / 2 ;
2109 DisplayUnit = temp ;
2111 temp = temp >> 8 ; /* ah */
2113 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2116 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2118 temp = (unsigned char)temp2;
2119 temp &= 0xFF ; /* al */
2120 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2122 /* SetDisplayUnit */
2123 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2124 temp2 &= InterlaceMode ;
2128 DisplayUnit = DisplayUnit << 5 ;
2129 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2130 al = DisplayUnit & 0x00ff ;
2136 if ( HwDeviceExtension->jChipType >= XG20 )
2137 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2140 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2144 /* --------------------------------------------------------------------- */
2145 /* Function : XGI_SetCRT1VCLK */
2149 /* --------------------------------------------------------------------- */
2150 void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2151 struct xgi_hw_device_info *HwDeviceExtension,
2152 unsigned short RefreshRateTableIndex,
2153 struct vb_device_info *pVBInfo)
2155 unsigned char index, data;
2156 unsigned short vclkindex ;
2158 if ( pVBInfo->IF_DEF_LVDS == 1 )
2160 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2161 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2162 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2163 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2164 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2165 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2167 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2169 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2170 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2171 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2172 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2173 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2174 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2175 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2176 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2180 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2181 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2182 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2183 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2184 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2185 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2188 if ( HwDeviceExtension->jChipType >= XG20 )
2190 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2192 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2193 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2194 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2201 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2207 /* --------------------------------------------------------------------- */
2208 /* Function : XGI_SetCRT1FIFO */
2212 /* --------------------------------------------------------------------- */
2213 void XGI_SetCRT1FIFO(unsigned short ModeNo,
2214 struct xgi_hw_device_info *HwDeviceExtension,
2215 struct vb_device_info *pVBInfo)
2217 unsigned short data ;
2219 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2221 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2223 if ( ModeNo > 0x13 )
2225 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2226 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2228 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2229 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2231 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2235 if (HwDeviceExtension->jChipType == XG27)
2237 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2238 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2240 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2244 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2245 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2247 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2251 if (HwDeviceExtension->jChipType == XG21)
2253 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2258 /* --------------------------------------------------------------------- */
2259 /* Function : XGI_SetCRT1ModeRegs */
2263 /* --------------------------------------------------------------------- */
2264 void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
2265 unsigned short ModeNo, unsigned short ModeIdIndex,
2266 unsigned short RefreshRateTableIndex,
2267 struct vb_device_info *pVBInfo)
2269 unsigned short data ,
2277 if ( ModeNo > 0x13 )
2279 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2280 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2283 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2285 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2286 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2288 if ( ModeNo > 0x13 )
2295 if ( ModeNo > 0x13 )
2297 if ( pVBInfo->ModeType > 0x02 )
2300 data3 = pVBInfo->ModeType - ModeVGA ;
2301 data3 = data3 << 2 ;
2306 data &= InterlaceMode ;
2311 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2312 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2313 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2314 if ( ModeNo <= 0x13 )
2315 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2317 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2320 if ( infoflag & InterlaceMode )
2324 else if ( xres == 1280 )
2328 data2 = data & 0x00FF ;
2329 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2330 data2 = ( data & 0xFF00 ) >> 8 ;
2331 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2333 if( modeflag & HalfDCLK )
2334 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2338 if ( modeflag & LineCompareOff )
2341 if ( ModeNo > 0x13 )
2343 if ( pVBInfo->ModeType == ModeEGA )
2347 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2349 if ( pVBInfo->ModeType != ModeText )
2351 data = data ^ 0x60 ;
2352 if ( pVBInfo->ModeType != ModeEGA )
2354 data = data ^ 0xA0 ;
2357 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2359 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2361 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2362 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2363 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2365 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2367 if (HwDeviceExtension->jChipType == XG27 )
2373 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2374 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2377 if (HwDeviceExtension->jChipType >= XG20 )
2383 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2384 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2392 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2398 /* --------------------------------------------------------------------- */
2399 /* Function : XGI_SetVCLKState */
2403 /* --------------------------------------------------------------------- */
2404 void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
2405 unsigned short ModeNo,
2406 unsigned short RefreshRateTableIndex,
2407 struct vb_device_info *pVBInfo)
2409 unsigned short data ,
2413 unsigned char index;
2415 if ( ModeNo <= 0x13 )
2419 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2420 index &= IndexMask ;
2421 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2424 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2427 data |= 0x0c ; /* VCLK > 200 */
2429 if ( HwDeviceExtension->jChipType >= XG20 )
2430 data &= ~0x04 ; /* 2 pixel mode */
2432 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2434 if ( HwDeviceExtension->jChipType < XG20 )
2436 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2440 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2443 /* Jong for Adavantech LCD ripple issue
2444 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2446 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2448 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2450 else if ( VCLK > 260 )
2455 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2456 if (HwDeviceExtension->jChipType >= XG27 )
2458 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2465 /* --------------------------------------------------------------------- */
2466 /* Function : XGI_VesaLowResolution */
2470 /* --------------------------------------------------------------------- */
2471 /*void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2473 unsigned short modeflag;
2475 if ( ModeNo > 0x13 )
2476 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2478 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2480 if ( ModeNo > 0x13 )
2482 if ( modeflag & DoubleScanMode )
2484 if ( modeflag & HalfDCLK )
2486 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2488 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2490 if ( pVBInfo->VBInfo & SetInSlaveMode )
2492 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2493 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2498 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2499 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2504 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2508 /* --------------------------------------------------------------------- */
2509 /* Function : XGI_LoadDAC */
2513 /* --------------------------------------------------------------------- */
2514 void XGI_LoadDAC(unsigned short ModeNo,
2515 unsigned short ModeIdIndex,
2516 struct vb_device_info *pVBInfo)
2518 unsigned short data , data2 , time ,
2519 i , j , k , m , n , o ,
2520 si , di , bx , dl , al , ah , dh ,
2523 if ( ModeNo <= 0x13 )
2524 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2526 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2528 data &= DACInfoFlag ;
2532 table = XGINew_MDA_DAC ;
2533 else if ( data == 0x08 )
2534 table = XGINew_CGA_DAC ;
2535 else if ( data == 0x10 )
2536 table = XGINew_EGA_DAC ;
2537 else if ( data == 0x18 )
2540 table = XGINew_VGA_DAC ;
2548 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2549 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2551 for( i = 0 ; i < j ; i++ )
2555 for( k = 0 ; k < 3 ; k++ )
2565 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2572 for( i = 16 ; i < 32 ; i++ )
2576 for( k = 0 ; k < 3 ; k++ )
2577 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2582 for( m = 0 ; m < 9 ; m++ )
2588 for( n = 0 ; n < 3 ; n++ )
2590 for( o = 0 ; o < 5 ; o++ )
2596 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2601 for( o = 0 ; o < 3 ; o++ )
2607 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2619 /* --------------------------------------------------------------------- */
2620 /* Function : XGI_WriteDAC */
2624 /* --------------------------------------------------------------------- */
2625 void XGI_WriteDAC(unsigned short dl, unsigned short ah,
2626 unsigned short al, unsigned short dh,
2627 struct vb_device_info *pVBInfo)
2629 unsigned short temp , bh , bl ;
2652 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)dh);
2653 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)bh);
2654 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)bl);
2657 /* --------------------------------------------------------------------- */
2658 /* Function : XGI_SetLCDAGroup */
2662 /* --------------------------------------------------------------------- */
2663 void XGI_SetLCDAGroup(unsigned short ModeNo,
2664 unsigned short ModeIdIndex,
2665 struct xgi_hw_device_info *HwDeviceExtension,
2666 struct vb_device_info *pVBInfo)
2668 unsigned short RefreshRateTableIndex ;
2669 /* unsigned short temp ; */
2671 /* pVBInfo->SelectCRT2Rate = 0 ; */
2673 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2674 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2675 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2676 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2677 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2678 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2679 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2683 /* --------------------------------------------------------------------- */
2684 /* Function : XGI_GetLVDSResInfo */
2688 /* --------------------------------------------------------------------- */
2689 void XGI_GetLVDSResInfo(unsigned short ModeNo,
2690 unsigned short ModeIdIndex,
2691 struct vb_device_info *pVBInfo)
2693 unsigned short resindex , xres , yres , modeflag ;
2695 if ( ModeNo <= 0x13 )
2697 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2701 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2705 /* if ( ModeNo > 0x13 ) */
2706 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2708 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2710 if ( ModeNo <= 0x13 )
2712 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2716 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2719 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2721 if ( ModeNo <= 0x13 )
2723 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2724 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2728 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2729 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2731 if ( ModeNo > 0x13 )
2733 if ( modeflag & HalfDCLK )
2736 if ( modeflag & DoubleScanMode )
2739 /* if ( modeflag & Charx8Dot ) */
2746 pVBInfo->VGAHDE = xres ;
2747 pVBInfo->HDE = xres ;
2748 pVBInfo->VGAVDE = yres ;
2749 pVBInfo->VDE = yres ;
2753 /* --------------------------------------------------------------------- */
2754 /* Function : XGI_GetLVDSData */
2758 /* --------------------------------------------------------------------- */
2759 void XGI_GetLVDSData(unsigned short ModeNo,
2760 unsigned short ModeIdIndex,
2761 unsigned short RefreshRateTableIndex,
2762 struct vb_device_info *pVBInfo)
2764 unsigned short tempbx ;
2765 struct XGI330_LVDSDataStruct *LCDPtr = NULL ;
2766 struct XGI330_CHTVDataStruct *TVPtr = NULL ;
2770 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2772 LCDPtr = (struct XGI330_LVDSDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2773 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2774 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2775 pVBInfo->HT = LCDPtr->LCDHT ;
2776 pVBInfo->VT = LCDPtr->LCDVT ;
2778 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2780 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2782 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2783 pVBInfo->VGAHT = TVPtr->VGAHT ;
2784 pVBInfo->VGAVT = TVPtr->VGAVT ;
2785 pVBInfo->HT = TVPtr->LCDHT ;
2786 pVBInfo->VT = TVPtr->LCDVT ;
2790 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2792 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2794 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2796 pVBInfo->HDE = 1024 ;
2797 pVBInfo->VDE = 768 ;
2799 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2801 pVBInfo->HDE = 1280 ;
2802 pVBInfo->VDE = 1024 ;
2804 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2806 pVBInfo->HDE = 1400 ;
2807 pVBInfo->VDE = 1050 ;
2811 pVBInfo->HDE = 1600 ;
2812 pVBInfo->VDE = 1200 ;
2819 /* --------------------------------------------------------------------- */
2820 /* Function : XGI_ModCRT1Regs */
2824 /* --------------------------------------------------------------------- */
2825 void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2826 unsigned short RefreshRateTableIndex,
2827 struct xgi_hw_device_info *HwDeviceExtension,
2828 struct vb_device_info *pVBInfo)
2830 unsigned char index;
2831 unsigned short tempbx , i ;
2832 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2833 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2834 /* struct XGI330_CHTVDataStruct *TVPtr = NULL ; */
2835 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2836 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2838 if( ModeNo <= 0x13 )
2839 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2841 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2843 index= index & IndexMask ;
2845 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2849 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2851 LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2853 for( i = 0 ; i < 8 ; i++ )
2854 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2857 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2859 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2861 CH7007TV_TimingHPtr = (struct XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2863 for( i = 0 ; i < 8 ; i++ )
2864 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2868 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2870 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2871 TVPtr = ( struct XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2874 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2876 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2878 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2879 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2884 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2886 LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2887 for( i = 0 ; i < 7 ; i++ )
2888 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2891 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2893 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2895 CH7007TV_TimingVPtr = (struct XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2897 for( i = 0 ; i < 7 ; i++ )
2898 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2901 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2903 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2904 TVPtr = ( struct XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2907 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2909 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2911 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2912 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2913 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2921 /* --------------------------------------------------------------------- */
2922 /* Function : XGI_SetLVDSRegs */
2926 /* --------------------------------------------------------------------- */
2927 void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2928 unsigned short RefreshRateTableIndex,
2929 struct vb_device_info *pVBInfo)
2931 unsigned short tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
2932 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2933 struct XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2934 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2936 if ( ModeNo > 0x13 )
2937 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2939 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2941 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2943 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2945 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2948 LCDPtr = (struct XGI330_LCDDataDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2951 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == NULL ) )
2954 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2955 LCDPtr1 = (struct XGI330_LCDDataDesStruct2 *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2957 LCDPtr = (struct XGI330_LCDDataDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2960 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
2965 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2970 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2975 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2986 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
2988 pVBInfo->HDE=tempax;
2989 pVBInfo->VDE=tempbx;
2990 pVBInfo->VGAHDE=tempax;
2991 pVBInfo->VGAVDE=tempbx;
2994 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
2996 tempax=pVBInfo->HDE;
2997 tempbx=pVBInfo->VDE;
3000 tempax = pVBInfo->HT ;
3002 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3003 tempbx = LCDPtr1->LCDHDES ;
3005 tempbx = LCDPtr->LCDHDES ;
3007 tempcx = pVBInfo->HDE ;
3008 tempbx = tempbx & 0x0fff ;
3011 if ( tempcx >= tempax )
3014 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
3016 tempcx = tempcx >> 3 ;
3017 tempbx = tempbx >> 3 ;
3019 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, (unsigned short)(tempbx & 0xff));
3020 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, (unsigned short)(tempcx & 0xff));
3022 tempax = pVBInfo->HT ;
3024 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3025 tempbx = LCDPtr1->LCDHRS ;
3027 tempbx = LCDPtr->LCDHRS ;
3031 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3032 tempcx = LCDPtr1->LCDHSync ;
3036 if ( tempcx >= tempax )
3039 tempax = tempbx & 0x07 ;
3040 tempax = tempax >> 5 ;
3041 tempcx = tempcx >> 3 ;
3042 tempbx = tempbx >> 3 ;
3047 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
3048 XGINew_SetReg1(pVBInfo->Part1Port, 0x14, (unsigned short)(tempbx & 0xff));
3050 tempax = pVBInfo->VT ;
3051 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3052 tempbx = LCDPtr1->LCDVDES ;
3054 tempbx = LCDPtr->LCDVDES ;
3055 tempcx = pVBInfo->VDE ;
3057 tempbx = tempbx & 0x0fff ;
3059 if ( tempcx >= tempax )
3062 XGINew_SetReg1(pVBInfo->Part1Port, 0x1b, (unsigned short)(tempbx & 0xff));
3063 XGINew_SetReg1(pVBInfo->Part1Port, 0x1c, (unsigned short)(tempcx & 0xff));
3065 tempbx = ( tempbx >> 8 ) & 0x07 ;
3066 tempcx = ( tempcx >> 8 ) & 0x07 ;
3068 XGINew_SetReg1(pVBInfo->Part1Port, 0x1d, (unsigned short)((tempcx << 3) | tempbx));
3070 tempax = pVBInfo->VT ;
3071 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3072 tempbx = LCDPtr1->LCDVRS ;
3074 tempbx = LCDPtr->LCDVRS ;
3076 /* tempbx = tempbx >> 4 ; */
3079 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3080 tempcx = LCDPtr1->LCDVSync ;
3083 if ( tempcx >= tempax )
3086 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, (unsigned short)(tempbx & 0xff));
3087 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f, (unsigned short)(tempcx & 0x0f));
3089 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3091 tempbx = pVBInfo->VGAVDE ;
3092 if ( tempbx != pVBInfo->VDE )
3095 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3098 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3100 tempcx = pVBInfo->VGAVT ;
3101 tempbx = pVBInfo->VDE ;
3102 tempax = pVBInfo->VGAVDE ;
3105 temp = tempax ; /* 0430 ylshieh */
3106 temp1 = ( temp << 18 ) / tempbx ;
3108 tempdx = (unsigned short)((temp << 18) % tempbx);
3116 XGINew_SetReg1(pVBInfo->Part1Port, 0x37, (unsigned short)(temp2 & 0xff));
3117 XGINew_SetReg1(pVBInfo->Part1Port, 0x36, (unsigned short)((temp2 >> 8) & 0xff));
3119 tempbx = (unsigned short)(temp2 >> 16);
3120 tempax = tempbx & 0x03 ;
3122 tempbx = pVBInfo->VGAVDE ;
3123 if ( tempbx == pVBInfo->VDE )
3126 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3128 if ( pVBInfo->VBType & VB_XGI301C )
3131 XGINew_SetReg1(pVBInfo->Part4Port, 0x3c, (unsigned short)(temp2 & 0xff));
3132 XGINew_SetReg1(pVBInfo->Part4Port, 0x3b, (unsigned short)((temp2 >> 8) & 0xff));
3133 tempbx = (unsigned short)(temp2 >> 16);
3134 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x3a, ~0xc0, (unsigned short)((tempbx & 0xff) << 6));
3136 tempcx = pVBInfo->VGAVDE ;
3137 if ( tempcx == pVBInfo->VDE )
3138 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3140 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3143 tempcx = pVBInfo->VGAHDE ;
3144 tempbx = pVBInfo->HDE ;
3146 temp1 = tempcx << 16 ;
3148 tempax = (unsigned short)(temp1 / tempbx);
3150 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3154 temp1 = pVBInfo->VGAHDE << 16 ;
3157 temp3 = temp3 << 16 ;
3160 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3162 tempax = (unsigned short)(temp3 & 0xff);
3163 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3165 temp1 = pVBInfo->VGAVDE << 18 ;
3166 temp1 = temp1 / push3 ;
3167 tempbx = (unsigned short)(temp1 & 0xffff);
3169 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3172 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
3173 tempax |= (unsigned short)((temp3 >> 8) & 0x07);
3174 XGINew_SetReg1(pVBInfo->Part1Port, 0x20, (unsigned short)(tempax & 0xff));
3175 XGINew_SetReg1(pVBInfo->Part1Port, 0x21, (unsigned short)(tempbx & 0xff));
3177 temp3 = temp3 >> 16 ;
3179 if ( modeflag & HalfDCLK )
3180 temp3 = temp3 >> 1 ;
3182 XGINew_SetReg1(pVBInfo->Part1Port , 0x22, (unsigned short)((temp3 >> 8) & 0xff));
3183 XGINew_SetReg1(pVBInfo->Part1Port , 0x23, (unsigned short)(temp3 & 0xff));
3189 /* --------------------------------------------------------------------- */
3190 /* Function : XGI_SetCRT2ECLK */
3194 /* --------------------------------------------------------------------- */
3195 void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
3197 unsigned char di_0, di_1, tempal;
3200 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3201 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3202 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3204 for( i = 0 ; i < 4 ; i++ )
3206 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, ~0x30, (unsigned short)(0x10 * i));
3207 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3209 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3210 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3212 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3214 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3215 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3219 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3220 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3226 /* --------------------------------------------------------------------- */
3227 /* Function : XGI_UpdateModeInfo */
3231 /* --------------------------------------------------------------------- */
3232 void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
3234 unsigned short tempcl ,
3240 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3244 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3246 if ( !( temp & 0x20 ) )
3248 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3251 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3252 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3254 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3256 if ( !( temp & 0x40 ) )
3257 tempcl |= ActiveCRT1 ;
3261 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3264 if ( !( temp == 0x08 ) )
3266 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3267 if ( tempax & 0x04 )
3268 tempcl = tempcl | ActiveLCD ;
3272 if ( !( tempcl & ActiveLCD ) )
3274 tempcl |= ActiveCRT2 ;
3277 tempcl |= ActiveLCD ;
3281 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3283 if( !( temp & 0x08 ) )
3284 tempch |= ActiveAVideo ;
3286 if ( !( temp & 0x04 ) )
3287 tempch |= ActiveSVideo ;
3290 tempch |= ActiveSCART ;
3292 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3295 tempch |= ActiveHiTV ;
3298 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3300 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3303 tempch |= ActiveYPbPr ;
3307 tempcl |= ActiveTV ;
3311 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3312 if ( tempcl & ActiveLCD )
3314 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3316 if ( temp & ActiveTV )
3317 tempcl |= ActiveTV ;
3321 tempbl = ~ModeSwitchStatus ;
3322 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3324 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3325 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3334 /* --------------------------------------------------------------------- */
3335 /* Function : XGI_GetVGAType */
3339 /* --------------------------------------------------------------------- */
3340 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
3343 if ( HwDeviceExtension->jChipType >= XG20 )
3345 pVBInfo->Set_VGAType = XG20;
3347 else if ( HwDeviceExtension->jChipType >= XG40 )
3349 pVBInfo->Set_VGAType = VGA_XGI340 ;
3352 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3356 /* --------------------------------------------------------------------- */
3357 /* Function : XGI_GetVBType */
3361 /* --------------------------------------------------------------------- */
3362 void XGI_GetVBType(struct vb_device_info *pVBInfo)
3364 unsigned short flag , tempbx , tempah ;
3366 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3368 pVBInfo->VBType = VB_CH7007 ;
3371 if ( pVBInfo->IF_DEF_LVDS == 0 )
3373 tempbx = VB_XGI302B ;
3374 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3377 tempbx = VB_XGI301 ;
3378 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3381 tempbx = VB_XGI301B ;
3384 tempbx = VB_XGI301C ;
3387 tempbx = VB_XGI301LV ;
3390 tempbx = VB_XGI302LV ;
3391 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3392 if ( tempah != 0xFF )
3393 tempbx = VB_XGI301C ;
3398 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3400 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3402 if ( !( flag & 0x02 ) )
3403 tempbx = tempbx | VB_NoLCD ;
3407 pVBInfo->VBType = tempbx ;
3410 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3411 pVBInfo->VBType = VB_CH7017 ;
3413 pVBInfo->VBType = VB_LVDS_NS ;
3419 /* --------------------------------------------------------------------- */
3420 /* Function : XGI_GetVBInfo */
3424 /* --------------------------------------------------------------------- */
3425 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
3427 unsigned short tempax ,
3433 if ( ModeNo <= 0x13 )
3435 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3439 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3442 pVBInfo->SetFlag = 0 ;
3443 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3446 if ( pVBInfo->VBType & 0xFFFF )
3448 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3449 tempbx = tempbx | temp ;
3450 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3453 tempax = temp << 8 ;
3454 tempbx = tempbx | tempax ;
3455 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3456 temp = 0xFFFF ^ temp ;
3459 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3461 if ( pVBInfo->IF_DEF_LCDA == 1 )
3464 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3466 if ( pVBInfo->IF_DEF_LVDS == 0 )
3468 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3469 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3471 if ( temp & EnableDualEdge )
3473 tempbx |= SetCRT2ToDualEdge ;
3475 if ( temp & SetToLCDA )
3476 tempbx |= SetCRT2ToLCDA ;
3480 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3482 if ( pVBInfo->VBType & VB_CH7017 )
3484 if ( temp & EnableDualEdge )
3486 tempbx |= SetCRT2ToDualEdge ;
3488 if ( temp & SetToLCDA )
3489 tempbx |= SetCRT2ToLCDA ;
3496 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3498 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3499 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3501 if ( temp & SetYPbPr ) /* temp = CR38 */
3503 if ( pVBInfo->IF_DEF_HiVision == 1 )
3505 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3507 tempbx |= SetCRT2ToHiVisionTV ;
3509 if ( temp != YPbPrMode1080i ) {
3510 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3511 tempbx |= SetCRT2ToYPbPr ; }
3514 /* tempbx |= SetCRT2ToYPbPr ; */
3519 tempax = push ; /* restore CR31 */
3521 if ( pVBInfo->IF_DEF_LVDS == 0 )
3523 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3525 if ( pVBInfo->IF_DEF_HiVision == 1 )
3532 if ( pVBInfo->IF_DEF_HiVision == 1 )
3538 else /* 3nd party chip */
3540 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3541 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3542 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3544 temp = SetCRT2ToTV ;
3547 temp = SetCRT2ToLCD ;
3550 if ( !( tempbx & temp ) )
3552 tempax |= DisableCRT2Display ;
3556 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3558 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3560 if ( tempbx & SetCRT2ToLCDA )
3562 if ( tempbx & SetSimuScanMode )
3563 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3565 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3571 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3573 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3575 if ( tempbx & SetCRT2ToRAMDAC )
3577 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3578 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3582 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3585 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3587 if ( tempbx & SetCRT2ToLCD )
3589 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3590 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3594 if ( tempbx & SetCRT2ToSCART )
3596 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3597 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3600 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3602 if ( tempbx & SetCRT2ToYPbPr )
3603 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3606 if ( pVBInfo->IF_DEF_HiVision == 1 )
3608 if ( tempbx & SetCRT2ToHiVisionTV )
3609 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3612 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3614 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3615 tempbx = DisableCRT2Display ;
3618 if ( !( tempbx & DisableCRT2Display ) )
3620 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3622 if ( pVBInfo->IF_DEF_LCDA == 1 )
3624 if ( !( tempbx & SetCRT2ToLCDA ) )
3625 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3628 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3630 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3631 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3632 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3633 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3637 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3639 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3640 pVBInfo->SetFlag |= EnableVCMode ;
3647 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3648 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3650 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3651 pVBInfo->SetFlag |= ReserveTVOption ;
3656 pVBInfo->VBInfo = tempbx ;
3660 /* --------------------------------------------------------------------- */
3661 /* Function : XGI_GetTVInfo */
3665 /* --------------------------------------------------------------------- */
3666 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
3668 unsigned short temp ,
3677 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3679 if ( ModeNo <= 0x13 )
3681 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3682 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3686 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3687 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3690 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3692 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3694 if ( tempbx & SetPALTV )
3696 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3697 if ( tempbx & SetPALMTV )
3698 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3701 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3703 if ( pVBInfo->IF_DEF_LVDS == 0 )
3705 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3706 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3708 if ( temp2 & 0x02 ) //PAL-M
3709 tempbx &= ( ~SetPALTV ) ;
3714 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3716 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3718 if ( tempbx & TVOverScan )
3719 tempbx |= SetCHTVOverScan ;
3722 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3724 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3726 if ( tempbx & TVOverScan )
3728 tempbx |= SetCHTVOverScan ;
3733 if ( pVBInfo->IF_DEF_LVDS == 0 )
3735 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3736 tempbx |= SetPALTV ;
3739 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3741 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3743 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3744 index1 &= YPbPrMode ;
3746 if ( index1 == YPbPrMode525i )
3747 tempbx |= SetYPbPrMode525i ;
3749 if ( index1 == YPbPrMode525p )
3750 tempbx = tempbx | SetYPbPrMode525p;
3751 if ( index1 == YPbPrMode750p)
3752 tempbx = tempbx | SetYPbPrMode750p;
3756 if ( pVBInfo->IF_DEF_HiVision == 1 )
3758 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3760 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3764 if ( pVBInfo->IF_DEF_LVDS == 0 )
3766 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3767 tempbx |= TVSimuMode ;
3769 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3770 tempbx |= NTSC1024x768 ;
3772 tempbx |= RPLLDIV2XO ;
3774 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3776 if ( pVBInfo->VBInfo & SetInSlaveMode )
3777 tempbx &=( ~RPLLDIV2XO ) ;
3781 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3782 tempbx &= ( ~RPLLDIV2XO ) ;
3783 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3785 if ( tempbx & TVSimuMode )
3786 tempbx &= ( ~RPLLDIV2XO ) ;
3791 pVBInfo->TVInfo = tempbx ;
3795 /* --------------------------------------------------------------------- */
3796 /* Function : XGI_GetLCDInfo */
3800 /* --------------------------------------------------------------------- */
3801 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3802 struct vb_device_info *pVBInfo)
3804 unsigned short temp ,
3811 pVBInfo->LCDResInfo = 0 ;
3812 pVBInfo->LCDTypeInfo = 0 ;
3813 pVBInfo->LCDInfo = 0 ;
3815 if ( ModeNo <= 0x13 )
3817 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3821 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3822 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3825 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3826 tempbx = temp & 0x0F ;
3829 tempbx = Panel1024x768 ; /* default */
3831 /* LCD75 [2003/8/22] Vicent */
3832 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3834 if ( pVBInfo->VBInfo & DriverMode )
3836 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3837 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3840 tempax = tempax >> 4 ;
3842 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3845 tempbx |= PanelRef75Hz ;
3847 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3850 tempbx |= PanelRef75Hz ;
3855 pVBInfo->LCDResInfo = tempbx ;
3859 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3861 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3864 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3871 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3873 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3875 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3876 temp &= ~EnableScalingLCD ;
3880 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3882 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3884 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3886 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3888 tempbx |= SetLCDDualLink ;
3892 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3894 if ( tempax & LCDDualLink )
3896 tempbx |= SetLCDDualLink ;
3900 if ( pVBInfo->IF_DEF_LVDS == 0 )
3902 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3903 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3907 if ( tempax & LCDBToA )
3909 tempbx |= SetLCDBToA ;
3913 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3915 if ( modeflag & HalfDCLK )
3917 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3918 if ( !( tempbx & SetLCDtoNonExpanding ) )
3920 tempbx |= EnableLVDSDDA ;
3924 if ( ModeNo > 0x13 )
3926 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3930 tempbx |= EnableLVDSDDA ;
3938 if ( pVBInfo->VBInfo & SetInSlaveMode )
3940 if ( pVBInfo->VBInfo & SetNotSimuMode )
3942 tempbx |= LCDVESATiming ;
3947 tempbx |= LCDVESATiming ;
3950 pVBInfo->LCDInfo = tempbx ;
3952 if ( pVBInfo->IF_DEF_PWD == 1 )
3954 if ( pVBInfo->LCDInfo & SetPWDEnable )
3956 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3958 if ( !( tempax & PWDEnable ) )
3960 pVBInfo->LCDInfo &= ~SetPWDEnable ;
3966 if ( pVBInfo->IF_DEF_LVDS == 0 )
3968 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3970 if ( pVBInfo->VBInfo & SetInSlaveMode )
3972 if ( !( tempax & LockLCDBToA ) )
3974 if ( ModeNo <= 0x13 )
3976 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
3977 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
3985 if ( pVBInfo->IF_DEF_LVDS == 0 )
3987 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3989 if ( pVBInfo->VBInfo & SetInSlaveMode )
3991 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
3993 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3994 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
4005 /* --------------------------------------------------------------------- */
4006 /* Function : XGI_SearchModeID */
4010 /* --------------------------------------------------------------------- */
4011 unsigned char XGI_SearchModeID(unsigned short ModeNo,
4012 unsigned short *ModeIdIndex,
4013 struct vb_device_info *pVBInfo)
4018 #ifdef LINUX /* chiawen for linux solution */
4022 if ( ModeNo <= 0x13 )
4024 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(struct XGI_StStruct);(*ModeIdIndex)++) */
4025 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4027 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
4029 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
4033 if ( ModeNo == 0x07 )
4034 ( *ModeIdIndex )++ ; /* 400 lines */
4037 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4038 /* else 350 lines */
4042 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(struct XGI_ExtStruct);(*ModeIdIndex)++) */
4043 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4045 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
4047 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
4060 /* win2000 MM adapter not support standard mode! */
4063 /* --------------------------------------------------------------------- */
4068 /* --------------------------------------------------------------------- */
4069 static unsigned char XGINew_CheckMemorySize(
4070 struct xgi_hw_device_info *HwDeviceExtension,
4071 unsigned short ModeNo,
4072 unsigned short ModeIdIndex,
4073 struct vb_device_info *pVBInfo)
4075 unsigned short memorysize ,
4081 /* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4082 ( HwDeviceExtension->jChipType == XGI_650M ) )
4087 if ( ModeNo <= 0x13 )
4089 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4092 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4095 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4097 memorysize = modeflag & MemoryInfoFlag ;
4098 memorysize = memorysize > MemorySizeShift ;
4099 memorysize++ ; /* Get memory size */
4101 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4104 if ( HwDeviceExtension->jChipType == XG40 )
4106 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4107 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4111 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4116 else if ( HwDeviceExtension->jChipType == XG42 )
4118 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4119 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4124 else if ( HwDeviceExtension->jChipType == XG45 )
4126 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4127 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4131 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4137 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4142 if (temp < memorysize)
4149 /* --------------------------------------------------------------------- */
4150 /* Function : XGINew_IsLowResolution */
4154 /* --------------------------------------------------------------------- */
4155 /*void XGINew_IsLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
4157 unsigned short data ;
4158 unsigned short ModeFlag ;
4160 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4162 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4164 if ( ModeNo > 0x13 )
4166 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4167 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4169 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4171 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4172 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4174 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4181 /* --------------------------------------------------------------------- */
4182 /* Function : XGI_DisplayOn */
4186 /* --------------------------------------------------------------------- */
4187 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, struct vb_device_info *pVBInfo)
4190 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4191 if ( pXGIHWDE->jChipType == XG21 )
4193 if ( pVBInfo->IF_DEF_LVDS == 1 )
4195 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4197 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4198 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4200 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4202 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4204 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4205 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4209 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4214 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4220 if ( pXGIHWDE->jChipType == XG27 )
4222 if ( pVBInfo->IF_DEF_LVDS == 1 )
4224 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4226 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4227 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4229 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4231 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4233 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4234 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4238 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4245 /* --------------------------------------------------------------------- */
4246 /* Function : XGI_DisplayOff */
4250 /* --------------------------------------------------------------------- */
4251 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, struct vb_device_info *pVBInfo)
4254 if ( pXGIHWDE->jChipType == XG21 )
4256 if ( pVBInfo->IF_DEF_LVDS == 1 )
4258 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4259 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4263 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4267 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4269 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4275 if ( pXGIHWDE->jChipType == XG27 )
4277 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4279 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4280 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4283 if ( pVBInfo->IF_DEF_LVDS == 0 )
4285 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4289 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4293 /* --------------------------------------------------------------------- */
4294 /* Function : XGI_WaitDisply */
4297 /* Description : chiawen for sensecrt1 */
4298 /* --------------------------------------------------------------------- */
4299 void XGI_WaitDisply(struct vb_device_info *pVBInfo)
4301 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4304 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4308 /* --------------------------------------------------------------------- */
4309 /* Function : XGI_SenseCRT1 */
4313 /* --------------------------------------------------------------------- */
4315 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
4317 unsigned char CRTCData[17] = {
4318 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4319 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4320 0x04 , 0x00 , 0x00 , 0x05 , 0x00 };
4322 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
4324 unsigned char CR17, CR63, SR31;
4325 unsigned short temp ;
4326 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F } ;
4329 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4331 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4332 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4333 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char)(XGINew_GetReg1(pVBInfo->P3d4, 0x53) | 0x02));
4335 SR31 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x31);
4336 CR63 = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x63);
4337 SR01 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x01);
4339 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char)(SR01 & 0xDF));
4340 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char)(CR63 & 0xBF));
4342 CR17 = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x17);
4343 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char)(CR17 | 0x80)) ;
4345 SR1F = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
4346 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char)(SR1F | 0x04));
4348 SR07 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x07);
4349 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char)(SR07 & 0xFB));
4350 SR06 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x06);
4351 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char)(SR06 & 0xC3));
4353 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4355 for( i = 0 ; i < 8 ; i++ )
4356 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)i, CRTCData[i]);
4358 for( i = 8 ; i < 11 ; i++ )
4359 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 8), CRTCData[i]);
4361 for( i = 11 ; i < 13 ; i++ )
4362 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 4), CRTCData[i]);
4364 for( i = 13 ; i < 16 ; i++ )
4365 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short)(i - 3), CRTCData[i]);
4367 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char)(CRTCData[16] & 0xE0));
4369 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4370 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4371 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4373 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4375 for( i = 0 ; i < 256 ; i++ )
4377 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[0]);
4378 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[1]);
4379 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[2]);
4382 XGI_VBLongWait( pVBInfo ) ;
4383 XGI_VBLongWait( pVBInfo ) ;
4384 XGI_VBLongWait( pVBInfo ) ;
4386 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4388 XGI_WaitDisply( pVBInfo ) ;
4389 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4393 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4397 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4400 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4401 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4403 for( i = 0 ; i < 256 ; i++ )
4405 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4406 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4407 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4410 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4411 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4412 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4414 /* [2004/05/11] Vicent */
4415 XGINew_SetReg1(pVBInfo->P3d4, 0x53,
4416 (unsigned char)(XGINew_GetReg1(pVBInfo->P3d4, 0x53) & 0xFD));
4417 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char)SR1F);
4422 /* --------------------------------------------------------------------- */
4423 /* Function : XGI_WaitDisplay */
4427 /* --------------------------------------------------------------------- */
4428 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4430 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4432 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4437 /* --------------------------------------------------------------------- */
4438 /* Function : XGI_SetCRT2Group301 */
4442 /* --------------------------------------------------------------------- */
4443 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
4444 struct xgi_hw_device_info *HwDeviceExtension,
4445 struct vb_device_info *pVBInfo)
4447 unsigned short tempbx ,
4449 RefreshRateTableIndex ;
4451 tempbx=pVBInfo->VBInfo ;
4452 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4453 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4454 pVBInfo->SelectCRT2Rate = 4 ;
4455 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4456 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4457 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4458 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4459 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4460 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4461 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4462 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4463 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4464 XGI_SetTap4Regs(pVBInfo) ;
4465 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4466 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4467 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4468 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4469 XGI_AutoThreshold( pVBInfo) ;
4474 /* --------------------------------------------------------------------- */
4475 /* Function : XGI_AutoThreshold */
4479 /* --------------------------------------------------------------------- */
4480 void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4482 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4483 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4487 /* --------------------------------------------------------------------- */
4488 /* Function : XGI_SaveCRT2Info */
4492 /* --------------------------------------------------------------------- */
4493 void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
4495 unsigned short temp1 ,
4498 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4499 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4500 temp2 = ~( SetInSlaveMode >> 8 ) ;
4501 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4505 /* --------------------------------------------------------------------- */
4506 /* Function : XGI_GetCRT2ResInfo */
4510 /* --------------------------------------------------------------------- */
4511 void XGI_GetCRT2ResInfo(unsigned short ModeNo,
4512 unsigned short ModeIdIndex,
4513 struct vb_device_info *pVBInfo)
4515 unsigned short xres ,
4520 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4521 if ( ModeNo <= 0x13 )
4523 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4524 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4525 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4529 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4530 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4531 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4533 /* if ( pVBInfo->IF_DEF_FSTN )
4541 if ( modeflag & HalfDCLK )
4544 if ( modeflag & DoubleScanMode )
4549 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4551 if ( pVBInfo->IF_DEF_LVDS == 0 )
4553 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4555 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4562 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4566 else if ( yres == 350 )
4569 if ( pVBInfo->LCDInfo & LCDVESATiming )
4576 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4578 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4580 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4584 else if ( yres == 400 )
4586 else if ( yres == 480 )
4597 pVBInfo->VGAHDE = xres ;
4598 pVBInfo->HDE = xres ;
4599 pVBInfo->VGAVDE = yres ;
4600 pVBInfo->VDE = yres ;
4604 /* --------------------------------------------------------------------- */
4605 /* Function : XGI_IsLCDDualLink */
4609 /* --------------------------------------------------------------------- */
4610 unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
4613 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4620 /* --------------------------------------------------------------------- */
4621 /* Function : XGI_GetCRT2Data */
4625 /* --------------------------------------------------------------------- */
4626 void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
4628 unsigned short tempax = 0,
4633 struct XGI_LCDDataStruct *LCDPtr = NULL ;
4634 struct XGI_TVDataStruct *TVPtr = NULL ;
4636 if ( ModeNo <= 0x13 )
4638 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4639 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4643 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4644 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4647 pVBInfo->NewFlickerMode = 0 ;
4648 pVBInfo->RVBHRS = 50 ;
4650 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4652 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4658 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4660 LCDPtr = (struct XGI_LCDDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4662 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4663 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4664 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4665 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4666 pVBInfo->HT = LCDPtr->LCDHT ;
4667 pVBInfo->VT = LCDPtr->LCDVT ;
4669 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4674 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4676 if ( pVBInfo->VGAVDE == 357 )
4678 else if ( pVBInfo->VGAVDE == 420 )
4680 else if ( pVBInfo->VGAVDE == 525 )
4682 else if ( pVBInfo->VGAVDE == 600 )
4684 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4685 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4692 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4697 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4700 if ( pVBInfo->VGAVDE == 360 )
4702 else if ( pVBInfo->VGAVDE == 375 )
4704 else if ( pVBInfo->VGAVDE == 405 )
4709 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4714 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4717 if ( pVBInfo->VGAVDE == 350 )
4719 else if ( pVBInfo->VGAVDE == 400 )
4721 else if ( pVBInfo->VGAVDE == 1024 )
4726 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4731 if ( pVBInfo->VGAVDE == 1024 )
4737 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4740 tempbx = 1200 ; /* alan 10/14/2003 */
4741 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4743 if ( pVBInfo->VGAVDE == 350 )
4745 else if ( pVBInfo->VGAVDE == 400 )
4750 if ( pVBInfo->LCDInfo & LCDNonExpanding )
4752 tempax = pVBInfo->VGAHDE ;
4753 tempbx = pVBInfo->VGAVDE ;
4756 pVBInfo->HDE = tempax ;
4757 pVBInfo->VDE = tempbx ;
4761 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
4764 TVPtr = (struct XGI_TVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4766 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
4767 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
4768 pVBInfo->VGAHT = TVPtr->VGAHT ;
4769 pVBInfo->VGAVT = TVPtr->VGAVT ;
4770 pVBInfo->HDE = TVPtr->TVHDE ;
4771 pVBInfo->VDE = TVPtr->TVVDE ;
4772 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
4773 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
4775 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
4777 if ( resinfo == 0x08 )
4778 pVBInfo->NewFlickerMode = 0x40 ;
4779 else if ( resinfo == 0x09 )
4780 pVBInfo->NewFlickerMode = 0x40 ;
4781 else if ( resinfo == 0x12 )
4782 pVBInfo->NewFlickerMode = 0x40 ;
4784 if ( pVBInfo->VGAVDE == 350 )
4785 pVBInfo->TVInfo |= TVSimuMode ;
4787 tempax = ExtHiTVHT ;
4788 tempbx = ExtHiTVVT ;
4790 if ( pVBInfo->VBInfo & SetInSlaveMode )
4792 if ( pVBInfo->TVInfo & TVSimuMode )
4797 if ( !( modeflag & Charx8Dot ) )
4799 tempax = StHiTextTVHT ;
4800 tempbx = StHiTextTVVT ;
4805 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
4807 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4809 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
4810 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
4813 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4815 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
4816 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
4818 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
4820 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
4821 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
4822 if ( pVBInfo->TVInfo & NTSC1024x768 )
4823 tempax = NTSC1024x768HT ;
4830 if ( !( pVBInfo->TVInfo & SetPALTV ) )
4834 if ( pVBInfo->TVInfo & NTSC1024x768 )
4835 tempax = NTSC1024x768HT ;
4839 pVBInfo->HT = tempax ;
4840 pVBInfo->VT = tempbx ;
4846 /* --------------------------------------------------------------------- */
4847 /* Function : XGI_SetCRT2VCLK */
4851 /* --------------------------------------------------------------------- */
4852 void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
4854 unsigned char di_0, di_1, tempal;
4856 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
4857 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
4858 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
4860 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
4862 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
4863 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
4864 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
4867 { /* 301b/302b/301lv/302lv */
4868 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
4869 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
4872 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
4874 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4875 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
4877 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
4881 /* --------------------------------------------------------------------- */
4882 /* Function : XGI_GETLCDVCLKPtr */
4884 /* Output : al -> VCLK Index */
4886 /* --------------------------------------------------------------------- */
4887 void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
4888 struct vb_device_info *pVBInfo)
4890 unsigned short index ;
4892 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4894 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
4896 if ( pVBInfo->LCDInfo & EnableScalingLCD )
4900 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
4901 index = XGI_GetLCDCapPtr1( pVBInfo) ;
4903 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4905 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
4906 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
4910 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
4911 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
4918 /* --------------------------------------------------------------------- */
4919 /* Function : XGI_GetVCLKPtr */
4923 /* --------------------------------------------------------------------- */
4924 unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
4925 unsigned short ModeNo, unsigned short ModeIdIndex,
4926 struct vb_device_info *pVBInfo)
4929 unsigned short index ,
4931 unsigned short tempbx ;
4932 unsigned char tempal;
4933 unsigned char *CHTVVCLKPtr = NULL;
4935 if ( ModeNo <= 0x13 )
4936 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4938 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4941 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
4943 index = XGI_GetLCDCapPtr(pVBInfo) ;
4944 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
4946 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4950 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
4952 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
4954 tempal = HiTVVCLKDIV2;
4955 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
4957 if(pVBInfo->TVInfo & TVSimuMode)
4959 tempal = HiTVSimuVCLK;
4960 if(!(modeflag & Charx8Dot))
4961 tempal = HiTVTextVCLK;
4967 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4969 tempal = YPbPr750pVCLK ;
4973 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4975 tempal = YPbPr525pVCLK ;
4979 tempal = NTSC1024VCLK ;
4981 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
4983 tempal = TVVCLKDIV2 ;
4984 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
4988 if ( pVBInfo->VBInfo & SetCRT2ToTV )
4992 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
4995 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4997 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4998 *tempal = *tempal & 0x1F;
5001 if(pVBInfo->TVInfo & SetPALTV)
5002 tempbx = tempbx + 2;
5003 if(pVBInfo->TVInfo & SetCHTVOverScan)
5005 tempbx = tempbx << 1;
5009 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
5011 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
5012 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
5014 if( ModeNo <= 0x13 )
5016 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5020 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5023 tempal = tempal & 0x0F;
5026 if(pVBInfo->TVInfo & SetPALTV)
5028 tempbx = tempbx + 2;
5030 if(pVBInfo->TVInfo & SetCHTVOverScan)
5034 /** tempbx = tempbx << 1; CH7007 ? **/
5036 /*[Billy]07/05/29 CH7007*/
5037 if ( pVBInfo->IF_DEF_CH7007 == 1 )
5042 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
5045 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5048 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5051 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5063 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5066 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5069 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5072 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5079 tempal = CHTVVCLKPtr[ tempal ] ;
5085 tempal = (unsigned char)XGINew_GetReg2((pVBInfo->P3ca + 0x02));
5086 tempal = tempal >> 2 ;
5089 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5090 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5092 if ( ModeNo <= 0x13 )
5095 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5100 /* --------------------------------------------------------------------- */
5101 /* Function : XGI_GetVCLKLen */
5105 /* --------------------------------------------------------------------- */
5106 void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
5107 unsigned char *di_1, struct vb_device_info *pVBInfo)
5109 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5111 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5112 *di_0 = (unsigned char)XGI_CH7007VCLKData[tempal].SR2B;
5113 *di_1 = (unsigned char)XGI_CH7007VCLKData[tempal].SR2C;
5115 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5117 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5119 *di_0 = (unsigned char)XGI_VBVCLKData[tempal].SR2B;
5120 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5125 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5126 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5131 /* --------------------------------------------------------------------- */
5132 /* Function : XGI_SetCRT2Offset */
5136 /* --------------------------------------------------------------------- */
5137 static void XGI_SetCRT2Offset(unsigned short ModeNo,
5138 unsigned short ModeIdIndex,
5139 unsigned short RefreshRateTableIndex,
5140 struct xgi_hw_device_info *HwDeviceExtension,
5141 struct vb_device_info *pVBInfo)
5143 unsigned short offset ;
5146 if ( pVBInfo->VBInfo & SetInSlaveMode )
5151 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5152 temp = (unsigned char)(offset & 0xFF);
5153 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5154 temp = (unsigned char)((offset & 0xFF00) >> 8);
5155 XGINew_SetReg1(pVBInfo->Part1Port , 0x09 , temp);
5156 temp = (unsigned char)(((offset >> 3) & 0xFF) + 1) ;
5157 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
5161 /* --------------------------------------------------------------------- */
5162 /* Function : XGI_GetOffset */
5166 /* --------------------------------------------------------------------- */
5167 unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
5169 unsigned short temp ,
5174 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5176 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5177 if ( ModeNo <= 0x14 )
5180 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5183 index = ( modeinfo >> 8 ) & 0xFF ;
5185 temp = pVBInfo->ScreenOffset[ index ] ;
5187 if ( infoflag & InterlaceMode )
5192 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5194 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5196 temp = ModeNo - 0x7C ;
5197 colordepth = ColorDepth[ temp ] ;
5199 if ( infoflag & InterlaceMode )
5203 return( temp * colordepth ) ;
5206 return( temp * colordepth ) ;
5210 /* --------------------------------------------------------------------- */
5211 /* Function : XGI_SetCRT2FIFO */
5215 /* --------------------------------------------------------------------- */
5216 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
5218 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5219 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5223 /* --------------------------------------------------------------------- */
5224 /* Function : XGI_PreSetGroup1 */
5228 /* --------------------------------------------------------------------- */
5229 void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
5230 struct xgi_hw_device_info *HwDeviceExtension,
5231 unsigned short RefreshRateTableIndex,
5232 struct vb_device_info *pVBInfo)
5234 unsigned short tempcx = 0 ,
5238 if ( ModeNo > 0x13 )
5240 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5241 CRT1Index &= IndexMask ;
5242 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5245 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5246 XGI_SetCRT2FIFO(pVBInfo) ;
5247 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5249 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5251 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5254 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5255 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5259 /* --------------------------------------------------------------------- */
5260 /* Function : XGI_SetGroup1 */
5264 /* --------------------------------------------------------------------- */
5265 void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
5266 struct xgi_hw_device_info *HwDeviceExtension,
5267 unsigned short RefreshRateTableIndex,
5268 struct vb_device_info *pVBInfo)
5270 unsigned short temp = 0 ,
5279 if ( ModeNo > 0x13 )
5281 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5282 CRT1Index &= IndexMask ;
5283 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5286 if ( ModeNo <= 0x13 )
5288 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5292 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5295 /* bainy change table name */
5296 if ( modeflag & HalfDCLK )
5298 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5299 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5300 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5301 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5302 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5303 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5304 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5305 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5306 tempcx = tempcx >> 1 ;
5307 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5310 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5312 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5313 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5314 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5315 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5317 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5318 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5319 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5325 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5326 tempcx = pVBInfo->VGAHT / 2 ;
5328 temp = tempbx & 0x00FF ;
5330 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5334 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5335 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5336 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5337 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5338 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5339 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5340 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5341 pushbx = pVBInfo->VGAHDE + 16 ;
5342 tempcx = tempcx >> 1 ;
5343 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5346 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5348 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5349 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5350 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5351 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5353 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5354 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5355 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5360 if ( tempcx > pVBInfo->VGAHT )
5361 tempcx = pVBInfo->VGAHT ;
5363 temp = tempbx & 0x00FF ;
5364 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5367 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5369 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5370 tempax |= ( tempbx & 0xFF00 ) ;
5371 temp = ( tempax & 0xFF00 ) >> 8 ;
5372 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5373 temp = tempcx & 0x00FF ;
5374 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5375 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5376 temp = tempcx & 0x00FF ;
5378 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5380 if ( pVBInfo->VBInfo & 0x0C )
5386 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5387 tempbx = pVBInfo->VGAVDE - 1 ;
5388 temp = tempbx & 0x00FF ;
5389 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5390 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5391 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5392 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5394 tempax = pVBInfo->VGAVDE ;
5395 tempbx = pVBInfo->VGAVDE ;
5396 tempcx = pVBInfo->VGAVT ;
5397 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5398 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5400 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5402 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5403 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5411 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5416 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5417 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5420 temp = tempbx & 0x00FF ;
5421 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5422 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5423 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5424 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5427 if ( modeflag & DoubleScanMode )
5430 if ( modeflag & HalfDCLK )
5433 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5437 /* --------------------------------------------------------------------- */
5438 /* Function : XGI_SetLockRegs */
5442 /* --------------------------------------------------------------------- */
5443 void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5444 struct xgi_hw_device_info *HwDeviceExtension,
5445 unsigned short RefreshRateTableIndex,
5446 struct vb_device_info *pVBInfo)
5448 unsigned short push1 ,
5458 if ( ModeNo <= 0x13 )
5460 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5461 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5465 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5466 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5467 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5468 CRT1Index &= IndexMask;
5471 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5476 temp = 0xFF ; /* set MAX HT */
5477 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5478 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5482 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5483 modeflag |= Charx8Dot ;
5485 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5487 if ( modeflag & HalfDCLK )
5488 tempax = tempax >> 1 ;
5490 tempax = ( tempax / tempcx ) - 1 ;
5491 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5492 temp = tempax & 0x00FF ;
5493 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5495 temp = ( tempbx & 0xFF00 ) >> 8 ;
5497 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5499 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5502 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5504 if ( pVBInfo->VBType & VB_XGI301LV )
5506 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5518 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5519 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5521 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5522 { /* 030226 bainy */
5523 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5524 tempax = pVBInfo->VGAHT ;
5526 tempax = XGI_GetVGAHT2( pVBInfo) ;
5529 if ( tempax >= pVBInfo->VGAHT )
5531 tempax = pVBInfo->VGAHT ;
5534 if ( modeflag & HalfDCLK )
5536 tempax = tempax >> 1 ;
5539 tempax = ( tempax / tempcx ) - 5 ;
5540 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5541 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5543 temp = ( tempbx & 0x00FF ) - 1 ;
5544 if ( !( modeflag & HalfDCLK ) )
5547 if ( pVBInfo->TVInfo & TVSimuMode )
5550 if ( ModeNo > 0x13 )
5557 /* tempcx = tempbx & 0x00FF ; */
5558 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5559 tempcx = ( tempcx + tempbx ) >> 1 ;
5560 temp = ( tempcx & 0x00FF ) + 2 ;
5562 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5565 if ( !( modeflag & HalfDCLK ) )
5567 if ( ( modeflag & Charx8Dot ) )
5570 if ( pVBInfo->VGAHDE >= 800 )
5579 if ( !( modeflag & HalfDCLK ) )
5582 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5584 if( pVBInfo->VGAHDE >= 800 )
5587 if ( pVBInfo->ModeType == ModeEGA )
5589 if ( pVBInfo->VGAVDE == 1024 )
5592 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5599 if ( pVBInfo->VGAHDE >= 1280 )
5601 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5603 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5615 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5616 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5618 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5620 if ( pVBInfo->TVInfo & TVSimuMode )
5622 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5624 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5625 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5628 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5630 if ( pVBInfo->TVInfo & SetNTSCTV )
5632 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5633 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5637 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5638 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5639 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5643 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5645 if ( pVBInfo->TVInfo & SetNTSCTV )
5647 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5648 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5652 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5653 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5654 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5658 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5660 if ( pVBInfo->TVInfo & SetNTSCTV )
5662 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5663 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5667 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5668 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5674 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5675 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5676 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5678 tempbx = pVBInfo->VGAVT ;
5681 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5683 if ( tempbx == 357 )
5685 if ( tempbx == 360 )
5687 if ( tempbx == 375 )
5689 if ( tempbx == 405 )
5691 if ( tempbx == 525 )
5696 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5698 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5700 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5702 if ( tempbx == 350 )
5704 if ( tempbx == 480 )
5710 temp = tempbx & 0x00FF ;
5712 temp = tempbx & 0x00FF ;
5713 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5716 temp = tempbx & 0x00FF ;
5717 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5719 if ( tempbx & 0x0100 )
5726 if ( modeflag & DoubleScanMode )
5731 if ( tempbx & 0x0200 )
5736 temp = ( tempax & 0xFF00 ) >> 8 ;
5737 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5739 if ( tempbx & 0x0400 )
5744 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5747 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
5748 tempax = tempax >> 2 ;
5749 push1 = tempax ; /* push ax */
5751 if ( resinfo != 0x09 )
5753 tempax = tempax << 1 ;
5757 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5759 if ( pVBInfo->VBType & VB_XGI301LV )
5761 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
5765 if ( pVBInfo->TVInfo & TVSimuMode )
5767 if ( pVBInfo->TVInfo & SetPALTV )
5769 if ( pVBInfo->VBType & VB_XGI301LV )
5771 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5785 if ( pVBInfo->TVInfo & TVSimuMode )
5787 if ( pVBInfo->TVInfo & SetPALTV )
5789 if ( pVBInfo->VBType & VB_XGI301LV )
5791 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5800 tempax = tempax >> 2 ;
5803 push1 = tempax ; /* push ax */
5805 if ( ( pVBInfo->TVInfo & SetPALTV ) )
5807 if ( tempbx <= 513 )
5809 if ( tempax >= 513 )
5816 temp = tempbx & 0x00FF ;
5817 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5819 temp = tempbx & 0x00FF ;
5820 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5822 if ( tempbx & 0x0100 )
5827 if ( tempbx & 0x0200 )
5829 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
5834 if ( tempbx & 0x0100 )
5839 if ( tempbx & 0x0200 )
5844 if ( tempbx & 0x0400 )
5849 tempbx = push1 ; /* pop ax */
5850 temp = tempbx & 0x00FF ;
5852 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
5854 if ( tempbx & 0x0010 )
5859 temp = tempcx & 0x00FF ;
5860 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
5861 temp = ( tempcx & 0x0FF00 ) >> 8 ;
5862 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
5864 temp = ( tempax & 0xFF00 ) >> 8 ;
5866 temp = ( temp >> 1 ) & 0x09 ;
5868 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5871 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
5872 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
5873 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
5875 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
5880 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
5886 /* --------------------------------------------------------------------- */
5887 /* Function : XGI_SetGroup2 */
5891 /* --------------------------------------------------------------------- */
5892 void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,
5893 struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
5906 unsigned char *TimingPoint ;
5908 unsigned long longtemp ,
5914 if ( ModeNo <= 0x13 )
5916 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5917 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5918 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5922 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5923 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5924 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
5929 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
5932 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
5935 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
5938 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5941 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5944 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
5947 tempax = ( tempax & 0xff00 ) >> 8 ;
5949 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
5950 TimingPoint = pVBInfo->NTSCTiming ;
5952 if ( pVBInfo->TVInfo & SetPALTV )
5954 TimingPoint = pVBInfo->PALTiming ;
5957 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5959 TimingPoint = pVBInfo->HiTVExtTiming ;
5961 if ( pVBInfo->VBInfo & SetInSlaveMode )
5962 TimingPoint = pVBInfo->HiTVSt2Timing ;
5964 if ( pVBInfo->SetFlag & TVSimuMode )
5965 TimingPoint = pVBInfo->HiTVSt1Timing ;
5967 if ( !(modeflag & Charx8Dot) )
5968 TimingPoint = pVBInfo->HiTVTextTiming ;
5971 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5973 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5974 TimingPoint = pVBInfo->YPbPr525iTiming ;
5976 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5977 TimingPoint = pVBInfo->YPbPr525pTiming ;
5979 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5980 TimingPoint = pVBInfo->YPbPr750pTiming ;
5983 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
5985 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
5988 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
5990 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
5993 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5995 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
5998 temp = pVBInfo->NewFlickerMode ;
6000 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
6002 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6005 if ( pVBInfo->TVInfo & SetPALTV )
6010 if ( pVBInfo->VDE <= tempax )
6012 tempax -= pVBInfo->VDE ;
6013 tempax = tempax >> 2 ;
6014 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
6016 temp = ( tempax & 0xFF00 ) >> 8 ;
6017 temp += (unsigned short)TimingPoint[0];
6019 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6021 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
6023 tempcx=pVBInfo->VGAHDE;
6024 if ( tempcx >= 1024 )
6026 temp = 0x17 ; /* NTSC */
6027 if ( pVBInfo->TVInfo & SetPALTV )
6028 temp = 0x19 ; /* PAL */
6033 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6035 temp = ( tempax & 0xFF00 ) >> 8 ;
6036 temp += TimingPoint[ 1 ] ;
6038 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6040 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
6042 tempcx = pVBInfo->VGAHDE ;
6043 if ( tempcx >= 1024 )
6045 temp = 0x1D ; /* NTSC */
6046 if ( pVBInfo->TVInfo & SetPALTV )
6047 temp = 0x52 ; /* PAL */
6051 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
6055 tempcx = pVBInfo->HT ;
6057 if ( XGI_IsLCDDualLink( pVBInfo ) )
6058 tempcx = tempcx >> 1 ;
6061 temp = tempcx & 0x00FF ;
6062 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6064 temp = ( tempcx & 0xFF00 ) >> 8 ;
6065 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6067 tempcx = pVBInfo->HT >> 1 ;
6068 push1 = tempcx ; /* push cx */
6071 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6076 temp = tempcx & 0x00FF ;
6078 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6080 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6083 temp = tempbx & 0x00FF ;
6084 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6085 temp = ( tempbx & 0xFF00 ) >> 8 ;
6087 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6091 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6097 temp = ( tempbx & 0x00FF ) << 4 ;
6098 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6101 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6102 temp = tempcx & 0x00FF ;
6103 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6104 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6105 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6108 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6113 temp = tempcx & 0xFF ;
6115 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6117 tempcx = push1 ; /* pop cx */
6119 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6121 temp = tempcx & 0x00FF ;
6123 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6127 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6129 tempax = XGI_GetVGAHT2( pVBInfo) ;
6130 tempcx = tempax - 1 ;
6132 temp = tempcx & 0x00FF ;
6133 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6135 tempbx = pVBInfo->VDE ;
6137 if ( pVBInfo->VGAVDE == 360 )
6139 if ( pVBInfo->VGAVDE == 375 )
6141 if ( pVBInfo->VGAVDE == 405 )
6144 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6146 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6148 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6149 tempbx = tempbx >> 1 ;
6152 tempbx = tempbx >> 1 ;
6156 temp = tempbx & 0x00FF ;
6158 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6160 if ( pVBInfo->VBType & VB_XGI301LV )
6162 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6164 if ( pVBInfo->VBInfo & SetInSlaveMode )
6166 if ( ModeNo == 0x2f )
6173 if ( pVBInfo->VBInfo & SetInSlaveMode )
6175 if ( ModeNo == 0x2f )
6181 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6183 temp = ( tempcx & 0xFF00 ) >> 8 ;
6184 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6186 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6188 if ( pVBInfo->VBType & VB_XGI301LV )
6190 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6194 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6201 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6206 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6208 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6210 tempbx = pVBInfo->VDE ;
6211 tempcx = tempbx - 2 ;
6213 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6215 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6216 tempbx = tempbx >> 1 ;
6219 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6222 if( tempcx & 0x0400 )
6225 if ( tempbx & 0x0400 )
6228 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6231 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6232 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6233 temp = ( tempbx - 3 ) & 0x00FF ;
6234 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6237 tempbx = tempbx & 0x00FF ;
6239 if ( !( modeflag & HalfDCLK ) )
6241 tempcx = pVBInfo->VGAHDE ;
6242 if ( tempcx >= pVBInfo->HDE )
6251 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6252 if(pVBInfo->VGAHDE>=1024)
6255 if(pVBInfo->VGAHDE>=1280)
6258 tempbx=tempbx&0xDFFF;
6263 if ( !( tempbx & 0x2000 ) )
6265 if ( modeflag & HalfDCLK )
6267 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6271 tempeax = pVBInfo->VGAHDE ;
6272 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6273 longtemp = tempeax * tempebx ;
6274 tempecx = tempcx & 0x00FF ;
6275 longtemp = longtemp / tempecx ;
6278 tempecx = 8 * 1024 ;
6280 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6282 tempecx = tempecx * 8 ;
6285 longtemp = longtemp * tempecx ;
6286 tempecx = pVBInfo->HDE ;
6287 temp2 = longtemp % tempecx ;
6288 tempeax = longtemp / tempecx ;
6294 tempax = (unsigned short)tempeax;
6297 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6299 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6304 tempbx = (unsigned short)(((tempeax & 0x0000FF00) & 0x1F00) | (tempbx & 0x00FF));
6305 tempax = (unsigned short)(((tempeax & 0x000000FF) << 8) | (tempax & 0x00FF));
6306 temp = ( tempax & 0xFF00 ) >> 8 ;
6310 temp = ( tempax & 0x00FF ) >> 8 ;
6313 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6314 temp = ( tempbx & 0xFF00 ) >> 8 ;
6315 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6316 temp = tempcx & 0x00FF ;
6318 if ( tempbx & 0x2000 )
6321 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6324 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6325 if ( pVBInfo->TVInfo & SetPALTV )
6336 temp = tempbx & 0x00FF ;
6337 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6338 temp = tempcx & 0x00FF ;
6339 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6341 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6343 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6345 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6349 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6352 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6356 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6357 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6358 XGINew_SetReg1( pVBInfo->Part2Port , 0x43, (unsigned short)( temp - 3 ) ) ;
6360 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6362 if ( pVBInfo->TVInfo & NTSC1024x768 )
6364 TimingPoint = XGI_NTSC1024AdjTime ;
6365 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6367 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6369 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6373 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6374 if ( pVBInfo->VBType & VB_XGI301C )
6376 if ( pVBInfo->TVInfo & SetPALMTV )
6377 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6380 if ( pVBInfo->TVInfo & SetPALMTV )
6382 tempax = (unsigned char)XGINew_GetReg1(pVBInfo->Part2Port, 0x01);
6384 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6386 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6387 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6390 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6392 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6394 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6398 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6405 /* --------------------------------------------------------------------- */
6406 /* Function : XGI_SetLCDRegs */
6410 /* --------------------------------------------------------------------- */
6411 void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
6413 unsigned short push1 ,
6427 struct XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6430 if ( ModeNo <= 0x13 )
6432 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6433 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6437 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6438 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6439 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6440 CRT1Index &= IndexMask ;
6443 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6448 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6450 if ( XGI_IsLCDDualLink( pVBInfo ) )
6451 tempbx = tempbx >> 1 ;
6454 temp = tempbx & 0x00FF ;
6455 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6456 temp = ( tempbx & 0xFF00 ) >> 8 ;
6458 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6461 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6463 if ( pVBInfo->ModeType == ModeEGA )
6465 if ( pVBInfo->VGAHDE >= 1024 )
6468 if ( pVBInfo->LCDInfo & LCDVESATiming )
6474 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6475 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6478 temp = tempbx & 0x00FF ;
6479 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6480 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6481 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6483 tempcx = pVBInfo->VT - 1 ;
6484 push2 = tempcx + 1 ;
6485 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6486 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6487 temp = ( tempcx & 0xFF00 ) >> 8 ;
6489 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6490 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6491 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6492 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6493 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6495 /* Customized LCDB Des no add */
6497 LCDBDesPtr = (struct XGI_LCDDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6498 tempah = pVBInfo->LCDResInfo ;
6499 tempah &= PanelResInfo ;
6501 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6506 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6511 else if ( tempah == Panel1400x1050 )
6522 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6524 tempbx = pVBInfo->HDE ;
6525 tempcx = pVBInfo->VDE ;
6529 tempax = pVBInfo->VT ;
6530 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6531 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6532 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6533 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6534 tempbx = pVBInfo->LCDVDES ;
6537 if ( tempcx >= tempax )
6538 tempcx -= tempax ; /* lcdvdes */
6540 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6541 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6542 temp = tempcx & 0x00FF ;
6543 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6544 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6545 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6547 tempah = tempah << 3 ;
6549 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6552 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6554 tempax = pVBInfo->VT ;
6555 tempbx = pVBInfo->LCDVRS ;
6557 /* if ( SetLCD_Info & EnableScalingLCD ) */
6559 if ( tempcx >= tempax )
6562 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6563 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6564 temp = ( tempbx & 0xFF00 ) >> 8 ;
6566 temp |= ( tempcx & 0x000F ) ;
6567 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6569 tempax = pVBInfo->HT ;
6570 tempbx = pVBInfo->LCDHDES ;
6573 if ( XGI_IsLCDDualLink( pVBInfo ) )
6575 tempax = tempax >> 1 ;
6576 tempbx = tempbx >> 1 ;
6577 tempcx = tempcx >> 1 ;
6580 if ( pVBInfo->VBType & VB_XGI302LV )
6583 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6588 if ( tempcx >= tempax )
6591 temp = tempbx & 0x00FF ;
6592 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6593 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6594 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6595 temp = tempcx & 0x00FF ;
6596 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6597 temp = ( tempcx & 0xFF00 ) >> 8 ;
6598 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6601 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6603 tempax = pVBInfo->HT ;
6604 tempbx = pVBInfo->LCDHRS ;
6605 /* if ( SetLCD_Info & EnableScalingLCD) */
6606 if ( XGI_IsLCDDualLink( pVBInfo) )
6608 tempax = tempax >> 1 ;
6609 tempbx = tempbx >> 1 ;
6610 tempcx = tempcx >> 1 ;
6613 if ( pVBInfo->VBType & VB_XGI302LV )
6618 if ( tempcx >= tempax )
6621 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6622 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6624 temp = ( tempbx & 0xFF00 ) >> 8 ;
6626 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6627 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6628 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6630 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6632 if ( pVBInfo->VGAVDE == 525 )
6634 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6641 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6642 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6645 if ( pVBInfo->VGAVDE == 420 )
6647 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6653 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6659 /* --------------------------------------------------------------------- */
6660 /* Function : XGI_GetTap4Ptr */
6662 /* Output : di -> Tap4 Reg. Setting Pointer */
6664 /* --------------------------------------------------------------------- */
6665 struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
6666 struct vb_device_info *pVBInfo)
6668 unsigned short tempax ,
6672 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6676 tempax = pVBInfo->VGAHDE ;
6677 tempbx = pVBInfo->HDE ;
6681 tempax = pVBInfo->VGAVDE ;
6682 tempbx = pVBInfo->VDE ;
6685 if ( tempax < tempbx )
6686 return &EnlargeTap4Timing[ 0 ] ;
6687 else if( tempax == tempbx )
6688 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6690 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6692 if ( pVBInfo->TVInfo & SetPALTV )
6693 Tap4TimingPtr = PALTap4Timing ;
6696 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6698 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6699 Tap4TimingPtr = YPbPr525iTap4Timing ;
6700 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6701 Tap4TimingPtr = YPbPr525pTap4Timing ;
6702 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6703 Tap4TimingPtr = YPbPr750pTap4Timing ;
6706 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6707 Tap4TimingPtr = HiTVTap4Timing ;
6710 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6712 if ( Tap4TimingPtr[ i ].DE == tempax )
6716 return &Tap4TimingPtr[ i ] ;
6720 /* --------------------------------------------------------------------- */
6721 /* Function : XGI_SetTap4Regs */
6725 /* --------------------------------------------------------------------- */
6726 void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
6731 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6733 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6737 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6738 #else /* Tap4 Setting */
6740 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6741 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6742 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6744 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6746 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6747 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6748 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6751 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6752 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
6754 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
6758 /* --------------------------------------------------------------------- */
6759 /* Function : XGI_SetGroup3 */
6763 /* --------------------------------------------------------------------- */
6764 void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6767 unsigned char *tempdi;
6768 unsigned short modeflag;
6772 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6776 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6780 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
6781 if(pVBInfo->TVInfo&SetPALTV)
6783 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6784 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6788 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
6789 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
6792 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
6797 if(pVBInfo->TVInfo&SetPALMTV)
6799 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6800 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6801 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
6804 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
6806 if(pVBInfo->TVInfo & SetYPbPrMode525i)
6810 tempdi=pVBInfo->HiTVGroup3Data;
6811 if(pVBInfo->SetFlag&TVSimuMode)
6813 tempdi=pVBInfo->HiTVGroup3Simu;
6814 if(!(modeflag&Charx8Dot))
6816 tempdi=pVBInfo->HiTVGroup3Text;
6820 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6822 tempdi=pVBInfo->Ren525pGroup3;
6824 if(pVBInfo->TVInfo & SetYPbPrMode750p)
6826 tempdi=pVBInfo->Ren750pGroup3;
6829 for(i=0;i<=0x3E;i++)
6831 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
6833 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
6835 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6837 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
6842 } /* {end of XGI_SetGroup3} */
6845 /* --------------------------------------------------------------------- */
6846 /* Function : XGI_SetGroup4 */
6850 /* --------------------------------------------------------------------- */
6851 void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
6853 unsigned short tempax ,
6860 unsigned long tempebx ,
6865 if ( ModeNo <= 0x13 )
6867 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6871 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6874 temp = pVBInfo->RVBHCFACT ;
6875 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
6877 tempbx = pVBInfo->RVBHCMAX ;
6878 temp = tempbx & 0x00FF ;
6879 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
6880 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
6881 tempcx = pVBInfo->VGAHT - 1 ;
6882 temp = tempcx & 0x00FF ;
6883 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
6885 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
6888 tempcx = pVBInfo->VGAVT - 1 ;
6889 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6894 temp = tempcx & 0x00FF ;
6895 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
6896 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
6897 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
6898 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
6899 tempcx = pVBInfo->VBInfo ;
6900 tempbx = pVBInfo->VGAHDE ;
6902 if ( modeflag & HalfDCLK )
6904 tempbx = tempbx >> 1 ;
6907 if ( XGI_IsLCDDualLink( pVBInfo ) )
6908 tempbx = tempbx >> 1 ;
6910 if(tempcx&SetCRT2ToHiVisionTV)
6918 else if(tempcx&SetCRT2ToTV)
6927 if(pVBInfo->VBInfo&SetCRT2ToLCD)
6935 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6938 if ( pVBInfo->VGAHDE == 1280 )
6940 if ( pVBInfo->VGAHDE == 1024 )
6943 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
6945 tempebx = pVBInfo->VDE ;
6947 if ( tempcx & SetCRT2ToHiVisionTV )
6949 if ( !( temp & 0xE000 ) )
6950 tempbx = tempbx >> 1 ;
6953 tempcx = pVBInfo->RVBHRS ;
6954 temp = tempcx & 0x00FF ;
6955 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
6957 tempeax = pVBInfo->VGAVDE ;
6961 if ( tempeax <= tempebx )
6963 tempcx=(tempcx&(~0x4000));
6964 tempeax = pVBInfo->VGAVDE ;
6968 tempeax -= tempebx ;
6972 templong = ( tempeax * 256 * 1024 ) % tempebx ;
6973 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
6976 if ( templong != 0 )
6982 temp = (unsigned short)(tempebx & 0x000000FF);
6983 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
6985 temp = (unsigned short)((tempebx & 0x0000FF00) >> 8);
6986 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
6987 tempbx = (unsigned short)(tempebx >> 16);
6988 temp = tempbx & 0x00FF ;
6990 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
6991 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
6994 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6997 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
6998 tempax = pVBInfo->VGAHDE ;
6999 if ( modeflag & HalfDCLK )
7001 tempax = tempax >> 1 ;
7004 if ( XGI_IsLCDDualLink( pVBInfo ) )
7005 tempax = tempax >> 1 ;
7007 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
7008 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
7015 if ( pVBInfo->VGAHDE > 800 )
7017 if ( pVBInfo->VGAHDE == 1024 )
7018 tempax = ( tempax * 25 / 32 ) - 1 ;
7020 tempax = ( tempax * 20 / 32 ) - 1 ;
7026 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7028 if ( pVBInfo->VBType & VB_XGI301LV )
7030 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7032 if ( pVBInfo->VGAHDE > 800 )
7034 if ( pVBInfo->VGAHDE == 1024 )
7035 tempax = ( tempax * 25 / 32 ) - 1 ;
7037 tempax = ( tempax * 20 / 32 ) - 1 ;
7043 if ( pVBInfo->VGAHDE > 800 )
7045 if ( pVBInfo->VGAHDE == 1024 )
7046 tempax = ( tempax * 25 / 32 ) - 1 ;
7048 tempax = ( tempax * 20 / 32 ) - 1 ;
7054 temp = ( tempax & 0xFF00 ) >> 8 ;
7055 temp = ( ( temp & 0x0003 ) << 4 ) ;
7056 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
7057 temp = ( tempax & 0x00FF ) ;
7058 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7060 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7062 if ( pVBInfo->VGAHDE > 800 )
7064 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7069 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7071 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7074 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7075 temp &= ( ~0x0001 ) ;
7079 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7080 tempbx = pVBInfo->HT ;
7081 if ( XGI_IsLCDDualLink( pVBInfo ) )
7082 tempbx = tempbx >> 1 ;
7083 tempbx = ( tempbx >> 1 ) - 2 ;
7084 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7085 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7086 temp = tempbx & 0x00FF ;
7087 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7091 if ( pVBInfo->ISXPDOS == 0 )
7092 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7096 /* --------------------------------------------------------------------- */
7097 /* Function : XGI_SetGroup5 */
7101 /* --------------------------------------------------------------------- */
7102 void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
7104 unsigned short Pindex ,
7107 Pindex = pVBInfo->Part5Port ;
7108 Pdata = pVBInfo->Part5Port + 1 ;
7109 if ( pVBInfo->ModeType == ModeVGA )
7111 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7113 XGINew_EnableCRT2(pVBInfo) ;
7114 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7121 /* --------------------------------------------------------------------- */
7122 /* Function : XGI_GetLcdPtr */
7126 /* --------------------------------------------------------------------- */
7127 void *XGI_GetLcdPtr(unsigned short BX,
7128 unsigned short ModeNo,
7129 unsigned short ModeIdIndex,
7130 unsigned short RefreshRateTableIndex,
7131 struct vb_device_info *pVBInfo)
7141 struct XGI330_LCDDataTablStruct *tempdi = NULL;
7146 if ( ModeNo <= 0x13 )
7148 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7149 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7153 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7154 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7157 tempal = tempal & 0x0f ;
7159 if ( tempbx <= 1 ) /* ExpLink */
7161 if ( ModeNo <= 0x13 )
7163 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7167 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7170 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7172 if ( ModeNo <= 0x13 )
7173 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7175 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7178 if ( tempbx & 0x01 )
7179 tempal = ( tempal >> 4 ) ;
7181 tempal = ( tempal & 0x0f ) ;
7184 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7186 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7188 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7189 tempcx = LCDDesDataLen2 ;
7190 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7191 tempcx = LVDSDesDataLen2 ;
7193 /* mov di, word ptr cs:LCDDataList[bx] */
7194 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7199 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7202 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7205 tempdi = XGI_EPLLCDDataPtr ;
7208 tempdi = XGI_EPLLCDDesDataPtr ;
7211 tempdi = XGI_LCDDataTable ;
7214 tempdi = XGI_LCDDesDataTable ;
7217 tempdi = XGI_EPLCHLCDRegPtr ;
7228 if ( tempdi == NULL ) /* OEMUtil */
7234 while( tempdi[ i ].PANELID != 0xff )
7236 tempdx = pVBInfo->LCDResInfo ;
7237 if ( tempbx & 0x0080 ) /* OEMUtil */
7239 tempbx &= ( ~0x0080 ) ;
7240 tempdx = pVBInfo->LCDTypeInfo ;
7243 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7244 tempdx &= ( ~PanelResInfo ) ;
7246 if ( tempdi[ i ].PANELID == tempdx )
7248 tempbx = tempdi[ i ].MASK ;
7249 tempdx = pVBInfo->LCDInfo ;
7251 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7252 tempdx |= SetLCDStdMode ;
7254 if ( modeflag & HalfDCLK )
7255 tempdx |= SetLCDLowResolution ;
7258 if ( tempbx == tempdi[ i ].CAP )
7266 switch( tempdi[ i ].DATAPTR )
7269 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7272 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7275 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7278 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7281 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7284 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7287 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7290 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7293 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7296 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7299 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7305 else if ( table == 1 )
7307 switch( tempdi[ i ].DATAPTR )
7310 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7313 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7316 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7319 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7322 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7325 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7328 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7331 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7334 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7337 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7340 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7346 else if ( table == 2 )
7348 switch( tempdi[ i ].DATAPTR )
7351 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7354 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7357 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7360 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7363 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7366 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7369 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7372 return &XGI_LVDSNoScalingData[ tempal ] ;
7375 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7378 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7381 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7384 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7387 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7393 else if ( table == 3 )
7395 switch( tempdi[ i ].DATAPTR )
7398 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7401 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7404 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7407 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7410 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7413 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7416 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7419 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7422 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7425 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7428 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7431 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7434 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7437 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7440 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7446 else if ( table == 4 )
7448 switch( tempdi[ i ].DATAPTR )
7451 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7454 return &XGI_StLCD1024x768Data[ tempal ] ;
7457 return &XGI_CetLCD1024x768Data[ tempal ] ;
7460 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7463 return &XGI_StLCD1280x1024Data[ tempal ] ;
7466 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7469 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7472 return &XGI_StLCD1400x1050Data[ tempal ] ;
7475 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7478 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7481 return &XGI_StLCD1600x1200Data[ tempal ] ;
7484 return &XGI_NoScalingData[ tempal ] ;
7487 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7490 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7493 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7496 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7499 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7502 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7505 return &XGI_NoScalingDatax75[ tempal ] ;
7511 else if ( table == 5 )
7513 switch( tempdi[ i ].DATAPTR )
7516 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7519 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7522 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7525 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7526 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7528 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7531 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7532 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7534 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7537 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7538 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7540 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7543 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7544 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7546 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7549 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7550 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7552 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7555 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7558 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7561 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7562 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7564 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7567 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7568 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7570 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7573 return &XGI_NoScalingDesData[ tempal ] ;
7576 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7579 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7582 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7585 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7586 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7588 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7591 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7592 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7594 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7597 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7598 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7600 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7603 return &XGI_NoScalingDesDatax75[ tempal ] ;
7609 else if ( table == 6 )
7611 switch( tempdi[ i ].DATAPTR )
7614 return &XGI_CH7017LV1024x768[ tempal ] ;
7617 return &XGI_CH7017LV1400x1050[ tempal ] ;
7627 /* --------------------------------------------------------------------- */
7628 /* Function : XGI_GetTVPtr */
7632 /* --------------------------------------------------------------------- */
7633 void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
7634 unsigned short ModeIdIndex,
7635 unsigned short RefreshRateTableIndex,
7636 struct vb_device_info *pVBInfo)
7638 unsigned short i , tempdx , tempbx , tempal , modeflag , table ;
7639 struct XGI330_TVDataTablStruct *tempdi = NULL;
7643 if ( ModeNo <= 0x13 )
7645 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7646 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7650 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7651 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7654 tempal = tempal & 0x3f ;
7660 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
7661 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7663 tempdi = XGI_EPLCHTVCRT1Ptr;
7667 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
7668 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7670 tempdi = XGI_EPLCHTVCRT1Ptr;
7674 tempdi = XGI_EPLCHTVDataPtr ;
7680 tempdi = XGI_TVDataTable ;
7686 tempdi = XGI_EPLCHTVRegPtr ;
7692 if ( tempdi == NULL ) /* OEMUtil */
7695 tempdx = pVBInfo->TVInfo ;
7697 if ( pVBInfo->VBInfo & SetInSlaveMode )
7698 tempdx = tempdx | SetTVLockMode ;
7700 if ( modeflag & HalfDCLK )
7701 tempdx = tempdx | SetTVLowResolution ;
7705 while( tempdi[ i ].MASK != 0xffff )
7707 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7712 if ( table == 0x00 ) /* 07/05/22 */
7715 else if ( table == 0x01 )
7718 else if ( table == 0x04 )
7720 switch( tempdi[ i ].DATAPTR )
7723 return &XGI_ExtPALData[ tempal ] ;
7726 return &XGI_ExtNTSCData[ tempal ] ;
7729 return &XGI_StPALData[ tempal ] ;
7732 return &XGI_StNTSCData[ tempal ] ;
7735 return &XGI_ExtHiTVData[ tempal ] ;
7738 return &XGI_St2HiTVData[ tempal ] ;
7741 return &XGI_ExtYPbPr525iData[ tempal ] ;
7744 return &XGI_ExtYPbPr525pData[ tempal ] ;
7747 return &XGI_ExtYPbPr750pData[ tempal ] ;
7750 return &XGI_StYPbPr525iData[ tempal ] ;
7753 return &XGI_StYPbPr525pData[ tempal ] ;
7756 return &XGI_StYPbPr750pData[ tempal ] ;
7758 case 12: /* avoid system hang */
7759 return &XGI_ExtNTSCData[ tempal ] ;
7762 return &XGI_St1HiTVData[ tempal ] ;
7768 else if( table == 0x02 )
7770 switch( tempdi[ i ].DATAPTR )
7773 return &XGI_CHTVUNTSCData[ tempal ] ;
7776 return &XGI_CHTVONTSCData[ tempal ] ;
7779 return &XGI_CHTVUPALData[ tempal ] ;
7782 return &XGI_CHTVOPALData[ tempal ] ;
7788 else if( table == 0x06 )
7795 /* --------------------------------------------------------------------- */
7796 /* Function : XGI_BacklightByDrv */
7798 /* Output : 1 -> Skip backlight control */
7800 /* --------------------------------------------------------------------- */
7801 unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
7803 unsigned char tempah ;
7805 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x3A) ;
7806 if (tempah & BacklightControlBit)
7813 /* --------------------------------------------------------------------- */
7814 /* Function : XGI_FirePWDDisable */
7817 /* Description : Turn off VDD & Backlight : Fire disable procedure */
7818 /* --------------------------------------------------------------------- */
7820 void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
7822 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
7826 /* --------------------------------------------------------------------- */
7827 /* Function : XGI_FirePWDEnable */
7830 /* Description : Turn on VDD & Backlight : Fire enable procedure */
7831 /* --------------------------------------------------------------------- */
7832 void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
7834 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
7838 /* --------------------------------------------------------------------- */
7839 /* Function : XGI_EnableGatingCRT */
7843 /* --------------------------------------------------------------------- */
7844 void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
7846 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
7850 /* --------------------------------------------------------------------- */
7851 /* Function : XGI_DisableGatingCRT */
7855 /* --------------------------------------------------------------------- */
7856 void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
7859 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
7863 /* --------------------------------------------------------------------- */
7864 /* Function : XGI_SetPanelDelay */
7868 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7869 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7870 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7871 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7872 /* --------------------------------------------------------------------- */
7873 void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
7875 unsigned short index ;
7877 index = XGI_GetLCDCapPtr(pVBInfo) ;
7880 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
7883 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
7886 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
7889 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
7893 /* --------------------------------------------------------------------- */
7894 /* Function : XGI_SetPanelPower */
7898 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
7899 /* = 0111b = 07h ; Backlight on, Power off */
7900 /* = 1011b = 0Bh ; Backlight off, Power on */
7901 /* = 1111b = 0Fh ; Backlight off, Power off */
7902 /* --------------------------------------------------------------------- */
7903 void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, struct vb_device_info *pVBInfo)
7905 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7906 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
7908 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
7911 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
7913 unsigned char ujRet = 0;
7914 unsigned char i = 0;
7919 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
7920 ujRet |= (ujDate >> i) & 1;
7926 /*----------------------------------------------------------------------------*/
7928 /* bl[5] : LVDS signal */
7929 /* bl[1] : LVDS backlight */
7930 /* bl[0] : LVDS VDD */
7931 /*----------------------------------------------------------------------------*/
7932 unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
7934 unsigned char CR4A, temp;
7936 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7937 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
7939 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7941 temp = XG21GPIODataTransfer(temp);
7943 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7947 /*----------------------------------------------------------------------------*/
7949 /* bl[5] : LVDS signal */
7950 /* bl[1] : LVDS backlight */
7951 /* bl[0] : LVDS VDD */
7952 /*----------------------------------------------------------------------------*/
7953 unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
7955 unsigned char CR4A, CRB4, temp;
7957 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7958 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
7960 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7964 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7965 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
7966 temp |= ((CRB4&0x04)<<3);
7969 /*----------------------------------------------------------------------------*/
7971 /* bl[5] : 1;LVDS signal on */
7972 /* bl[1] : 1;LVDS backlight on */
7973 /* bl[0] : 1:LVDS VDD on */
7974 /* bh: 100000b : clear bit 5, to set bit5 */
7975 /* 000010b : clear bit 1, to set bit1 */
7976 /* 000001b : clear bit 0, to set bit0 */
7977 /*----------------------------------------------------------------------------*/
7978 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo)
7980 unsigned char CR4A, temp;
7982 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7985 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7989 temp = (tempbl>>4)&0x02;
7991 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7995 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7997 temp = XG21GPIODataTransfer(temp);
8000 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
8003 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo)
8005 unsigned char CR4A, temp;
8006 unsigned short tempbh0, tempbl0;
8017 temp = (tempbl>>4)&0x02;
8019 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8022 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
8024 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8028 tempbl <<= 2; /* GPIOC,GPIOD */
8029 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
8030 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
8033 /* --------------------------------------------------------------------- */
8034 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
8036 unsigned short index ;
8038 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8039 if (index < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct))
8044 /* --------------------------------------------------------------------- */
8045 /* Function : XGI_XG21SetPanelDelay */
8049 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8050 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
8051 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
8052 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
8053 /* --------------------------------------------------------------------- */
8054 void XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
8056 unsigned short index ;
8058 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
8060 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8063 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8066 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8069 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8072 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
8073 unsigned short ModeIdIndex,
8074 struct vb_device_info *pVBInfo)
8076 unsigned short xres ,
8083 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8084 if ( ModeNo <= 0x13 )
8086 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8087 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8088 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8092 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8093 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8094 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8097 if ( !( modeflag & Charx8Dot ) )
8103 if ( ModeNo > 0x13 )
8105 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8109 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8115 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8116 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8119 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8122 if ( ModeNo > 0x13 )
8124 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8125 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8127 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8136 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
8140 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8141 temp = ( temp & 1 ) << 6;
8142 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8143 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8147 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
8151 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8152 temp = ( temp & 3 ) << 6;
8153 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8154 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8158 void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
8159 struct vb_device_info *pVBInfo)
8161 unsigned char temp, Miscdata;
8162 unsigned short xres ,
8167 unsigned short LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8168 unsigned short LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8169 unsigned short value;
8171 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8173 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8)) >> 8);
8174 temp &= LCDPolarity;
8175 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc) ;
8177 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8179 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity) ;
8180 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8181 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8183 XGI_SetXG21FPBits(pVBInfo);
8184 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8185 if ( ModeNo <= 0x13 )
8187 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8188 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8189 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8193 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8194 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8195 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8198 if (!( modeflag & Charx8Dot ))
8199 xres = xres * 8 / 9;
8201 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8203 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8204 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8208 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8210 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8211 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8213 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8214 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8216 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8218 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8220 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8221 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8225 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8227 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8228 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8230 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8231 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8233 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8235 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11) ;
8236 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8238 if (!( modeflag & Charx8Dot ))
8240 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8243 /* HT SR0B[1:0] CR00 */
8244 value = ( LVDSHT >> 3 ) - 5;
8245 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8246 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8248 /* HBS SR0B[5:4] CR02 */
8249 value = ( LVDSHBS >> 3 ) - 1;
8250 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8251 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8253 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8254 value = ( LVDSHBE >> 3 ) - 1;
8255 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8256 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8257 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8259 /* HRS SR0B[7:6] CR04 */
8260 value = ( LVDSHRS >> 3 ) + 2;
8261 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8262 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8264 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8266 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8267 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8269 /* HRE SR0C[2] CR05[4:0] */
8270 value = ( LVDSHRE >> 3 ) + 2;
8271 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8272 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8274 /* Panel HRE SR2F[7:2] */
8276 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8278 /* VT SR0A[0] CR07[5][0] CR06 */
8279 value = LVDSVT - 2 ;
8280 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8281 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8282 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8283 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8285 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8286 value = LVDSVBS - 1 ;
8287 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8288 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8289 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8290 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8292 /* VBE SR0A[4] CR16 */
8293 value = LVDSVBE - 1;
8294 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8295 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8297 /* VRS SR0A[3] CR7[7][2] CR10 */
8298 value = LVDSVRS - 1 ;
8299 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8300 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8301 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8302 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8304 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8305 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8306 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8307 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8309 /* VRE SR0A[5] CR11[3:0] */
8310 value = LVDSVRE - 1;
8311 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8312 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8314 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8315 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8317 for ( temp=0, value = 0; temp < 3; temp++)
8320 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8321 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8322 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8326 if (!( modeflag & Charx8Dot ))
8328 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8329 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8330 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8332 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8333 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8335 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8341 /* no shadow case */
8342 void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
8343 struct vb_device_info *pVBInfo)
8345 unsigned char temp, Miscdata;
8346 unsigned short xres ,
8351 unsigned short LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8352 unsigned short LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8353 unsigned short value;
8355 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8356 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8)) >> 8);
8357 temp &= LCDPolarity;
8358 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
8360 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8362 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity) ;
8363 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8364 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8366 XGI_SetXG27FPBits(pVBInfo);
8367 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8368 if ( ModeNo <= 0x13 )
8370 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8371 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8372 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8376 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8377 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8378 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8381 if (!( modeflag & Charx8Dot ))
8382 xres = xres * 8 / 9;
8384 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8386 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8387 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8391 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8393 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8394 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8396 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8397 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8399 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8401 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8403 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8404 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8408 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8410 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8411 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8413 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8414 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8416 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8418 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11) ;
8419 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8421 if (!( modeflag & Charx8Dot ))
8423 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8426 /* HT SR0B[1:0] CR00 */
8427 value = ( LVDSHT >> 3 ) - 5;
8428 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8429 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8431 /* HBS SR0B[5:4] CR02 */
8432 value = ( LVDSHBS >> 3 ) - 1;
8433 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8434 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8436 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8437 value = ( LVDSHBE >> 3 ) - 1;
8438 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8439 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8440 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8442 /* HRS SR0B[7:6] CR04 */
8443 value = ( LVDSHRS >> 3 ) + 2;
8444 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8445 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8447 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8449 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8450 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8452 /* HRE SR0C[2] CR05[4:0] */
8453 value = ( LVDSHRE >> 3 ) + 2;
8454 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8455 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8457 /* Panel HRE SR2F[7:2] */
8459 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8461 /* VT SR0A[0] CR07[5][0] CR06 */
8462 value = LVDSVT - 2 ;
8463 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8464 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8465 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8466 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8468 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8469 value = LVDSVBS - 1 ;
8470 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8471 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8472 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8473 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8475 /* VBE SR0A[4] CR16 */
8476 value = LVDSVBE - 1;
8477 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8478 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8480 /* VRS SR0A[3] CR7[7][2] CR10 */
8481 value = LVDSVRS - 1 ;
8482 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8483 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8484 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8485 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8487 /* Panel VRS SR35[2:0] SR34[7:0] */
8488 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8489 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8491 /* VRE SR0A[5] CR11[3:0] */
8492 value = LVDSVRE - 1;
8493 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8494 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8496 /* Panel VRE SR3F[7:2] */
8497 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8499 for ( temp=0, value = 0; temp < 3; temp++)
8502 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8503 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8504 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8508 if (!( modeflag & Charx8Dot ))
8510 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8511 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8512 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8514 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8515 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8517 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8523 /* --------------------------------------------------------------------- */
8524 /* Function : XGI_IsLCDON */
8526 /* Output : 0 : Skip PSC Control */
8527 /* 1: Disable PSC */
8529 /* --------------------------------------------------------------------- */
8530 unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
8532 unsigned short tempax ;
8534 tempax = pVBInfo->VBInfo ;
8535 if ( tempax & SetCRT2ToDualEdge )
8537 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8544 /* --------------------------------------------------------------------- */
8545 /* Function : XGI_EnablePWD */
8549 /* --------------------------------------------------------------------- */
8550 void XGI_EnablePWD(struct vb_device_info *pVBInfo)
8552 unsigned short index ,
8555 index = XGI_GetLCDCapPtr(pVBInfo) ;
8556 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8557 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8558 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8559 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8560 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8561 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8562 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8566 /* --------------------------------------------------------------------- */
8567 /* Function : XGI_DisablePWD */
8571 /* --------------------------------------------------------------------- */
8572 void XGI_DisablePWD(struct vb_device_info *pVBInfo)
8574 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8578 /* --------------------------------------------------------------------- */
8579 /* Function : XGI_DisableChISLCD */
8581 /* Output : 0 -> Not LCD Mode */
8583 /* --------------------------------------------------------------------- */
8584 unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
8586 unsigned short tempbx ,
8589 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8590 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
8592 if ( tempbx & ( EnableChA | DisableChA ) )
8594 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8598 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8601 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8608 /* --------------------------------------------------------------------- */
8609 /* Function : XGI_EnableChISLCD */
8611 /* Output : 0 -> Not LCD mode */
8613 /* --------------------------------------------------------------------- */
8614 unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
8616 unsigned short tempbx ,
8620 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8621 tempah = ~( (unsigned short)XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8623 if ( tempbx & ( EnableChA | DisableChA ) )
8625 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8629 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8632 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8639 /* --------------------------------------------------------------------- */
8640 /* Function : XGI_GetLCDCapPtr */
8644 /* --------------------------------------------------------------------- */
8645 unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
8647 unsigned char tempal ,
8652 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8653 tempal = tempah & 0x0F ;
8654 tempah = tempah & 0xF0 ;
8656 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8658 while( tempbl != 0xFF )
8660 if ( tempbl & 0x80 ) /* OEMUtil */
8663 tempbl = tempbl & ~( 0x80 ) ;
8666 if ( tempal == tempbl )
8671 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8678 /* --------------------------------------------------------------------- */
8679 /* Function : XGI_GetLCDCapPtr1 */
8683 /* --------------------------------------------------------------------- */
8684 unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
8686 unsigned short tempah ,
8691 tempal = pVBInfo->LCDResInfo ;
8692 tempah = pVBInfo->LCDTypeInfo ;
8695 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
8697 while( tempbl != 0xFF )
8699 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
8705 if ( tempal == tempbl )
8709 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8712 if ( tempbl == 0xFF )
8714 pVBInfo->LCDResInfo = Panel1024x768 ;
8715 pVBInfo->LCDTypeInfo = 0 ;
8723 /* --------------------------------------------------------------------- */
8724 /* Function : XGI_GetLCDSync */
8728 /* --------------------------------------------------------------------- */
8729 void XGI_GetLCDSync(unsigned short *HSyncWidth , unsigned short *VSyncWidth,
8730 struct vb_device_info *pVBInfo)
8732 unsigned short Index ;
8734 Index = XGI_GetLCDCapPtr(pVBInfo) ;
8735 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
8736 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
8743 /* --------------------------------------------------------------------- */
8744 /* Function : XGI_EnableBridge */
8748 /* --------------------------------------------------------------------- */
8749 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
8751 unsigned short tempbl ,
8754 if ( pVBInfo->SetFlag == Win9xDOSMode )
8756 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8758 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8761 else /* LVDS or CH7017 */
8766 if ( HwDeviceExtension->jChipType < XG40 )
8768 if ( !XGI_DisableChISLCD(pVBInfo) )
8770 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8772 if ( pVBInfo->LCDInfo & SetPWDEnable )
8774 XGI_EnablePWD( pVBInfo);
8778 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
8779 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8790 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
8791 XGI_SetPanelDelay( 1,pVBInfo ) ;
8799 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8801 if ( !( pVBInfo->SetFlag & DisableChA ) )
8803 if ( pVBInfo->SetFlag & EnableChA )
8805 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
8809 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
8811 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
8816 if ( !( pVBInfo->SetFlag & DisableChB ) )
8818 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
8820 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x32);
8822 if ( pVBInfo->VBInfo & SetInSlaveMode )
8824 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
8827 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
8828 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
8830 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->Part1Port, 0x2E);
8832 if ( !( tempah & 0x80 ) )
8833 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8835 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
8839 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
8841 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
8842 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8844 if ( !XGI_DisableChISLCD(pVBInfo) )
8846 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8847 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
8849 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
8855 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
8859 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
8861 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8863 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8865 tempah = tempah & 0x40;
8866 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8867 tempah = tempah ^ 0xC0 ;
8869 if ( pVBInfo->SetFlag & DisableChB )
8872 if ( pVBInfo->SetFlag & DisableChA )
8875 if ( pVBInfo->SetFlag & EnableChB )
8878 if ( pVBInfo->SetFlag & EnableChA )
8885 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
8887 if ( pVBInfo->SetFlag & Win9xDOSMode )
8889 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8893 if ( !( pVBInfo->SetFlag & DisableChA ) )
8895 XGI_VBLongWait( pVBInfo) ;
8896 if ( !( pVBInfo->SetFlag & GatingCRT ) )
8898 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8899 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8900 XGI_VBLongWait( pVBInfo) ;
8906 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
8907 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
8911 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->Part1Port, 0x2E);
8912 if ( !( tempah & 0x80 ) )
8913 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8915 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
8916 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
8920 if ( HwDeviceExtension->jChipType < XG40 )
8922 if ( !XGI_EnableChISLCD(pVBInfo) )
8924 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
8926 if ( XGI_BacklightByDrv(pVBInfo) )
8933 if ( pVBInfo->LCDInfo & SetPWDEnable )
8935 XGI_FirePWDEnable(pVBInfo) ;
8939 XGI_SetPanelDelay( 2,pVBInfo ) ;
8941 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8944 tempbl = 0xFE ; /* turn on backlght */
8951 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
8956 /* --------------------------------------------------------------------- */
8957 /* Function : XGI_DisableBridge */
8961 /* --------------------------------------------------------------------- */
8962 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
8964 unsigned short tempax ,
8969 if ( pVBInfo->SetFlag == Win9xDOSMode )
8973 if ( HwDeviceExtension->jChipType < XG40 )
8975 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8977 if ( !XGI_IsLCDON(pVBInfo) )
8979 if ( pVBInfo->LCDInfo & SetPWDEnable )
8980 XGI_EnablePWD( pVBInfo) ;
8983 pVBInfo->LCDInfo &= ~SetPWDEnable ;
8984 XGI_DisablePWD(pVBInfo) ;
8985 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8987 tempbx = 0xFE ; /* not 01h */
8992 tempbx = 0xF7 ; /* not 08h */
8995 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
8996 XGI_SetPanelDelay( 3,pVBInfo ) ;
8998 } /* end if(!XGI_IsLCDON(pVBInfo)) */
9004 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
9006 if ( !XGI_IsLCDON(pVBInfo) )
9010 tempbx = XGINew_GetCH7005( 0x61 ) ;
9011 if ( tempbx < 0x01 ) //first time we power up
9012 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
9014 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
9020 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9023 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
9025 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9027 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9029 tempah = 0x7F; /* Disable Channel A */
9030 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9031 tempah = 0xBF ; /* Disable Channel B */
9033 if ( pVBInfo->SetFlag & DisableChB )
9034 tempah &= 0xBF ; /* force to disable Cahnnel */
9036 if ( pVBInfo->SetFlag & DisableChA )
9037 tempah &= 0x7F ; /* Force to disable Channel B */
9042 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
9044 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9046 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9047 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
9050 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
9052 if ( pVBInfo->SetFlag & GatingCRT )
9053 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9054 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9057 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9059 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9060 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
9063 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
9065 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
9066 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9068 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9069 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9070 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9072 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9073 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9075 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9076 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9077 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9078 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9083 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9085 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9086 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9087 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9090 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9091 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9097 if ( HwDeviceExtension->jChipType < XG40 )
9099 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9101 if ( pVBInfo->LCDInfo & SetPWDEnable )
9103 if ( pVBInfo->LCDInfo & SetPWDEnable )
9104 XGI_BacklightByDrv(pVBInfo) ;
9107 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9108 if ( pVBInfo->VBType & VB_XGI301LV )
9120 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9126 /* --------------------------------------------------------------------- */
9127 /* Function : XGI_GetTVPtrIndex */
9130 /* Description : bx 0 : ExtNTSC */
9142 /* --------------------------------------------------------------------- */
9143 unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
9145 unsigned short tempbx = 0 ;
9147 if ( pVBInfo->TVInfo & SetPALTV )
9149 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9151 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9153 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9155 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9157 if ( pVBInfo->TVInfo & TVSimuMode )
9164 /* --------------------------------------------------------------------- */
9165 /* Function : XGI_OEM310Setting */
9168 /* Description : Customized Param. for 301 */
9169 /* --------------------------------------------------------------------- */
9170 void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9172 if ( pVBInfo->SetFlag & Win9xDOSMode )
9176 XGI_SetDelayComp(pVBInfo) ;
9178 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9179 XGI_SetLCDCap(pVBInfo) ;
9181 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9184 XGI_SetPhaseIncr(pVBInfo) ;
9185 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9186 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9188 if ( pVBInfo->VBType&VB_XGI301)
9189 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9194 /* --------------------------------------------------------------------- */
9195 /* Function : XGI_SetDelayComp */
9199 /* --------------------------------------------------------------------- */
9200 void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
9202 unsigned short index ;
9204 unsigned char tempah ,
9208 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9210 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9215 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9216 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9218 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9219 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9221 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9222 tempbl = tempbl >> 4 ;
9224 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9225 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9227 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9228 tempbl = CRT2Delay2 ;
9230 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9232 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9233 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9235 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9241 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9243 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9249 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9254 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9257 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9261 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9263 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9265 tempah = tempah << 4 ;
9266 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9272 /* --------------------------------------------------------------------- */
9273 /* Function : XGI_SetLCDCap */
9277 /* --------------------------------------------------------------------- */
9278 void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
9280 unsigned short tempcx ;
9282 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9284 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9286 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9287 { /* 301LV/302LV only */
9288 /* Set 301LV Capability */
9289 XGINew_SetReg1(pVBInfo->Part4Port, 0x24, (unsigned char)(tempcx & 0x1F));
9292 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
9293 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
9294 (unsigned short)((tempcx & (EnableVBCLKDRVLOW | EnablePLLSPLOW)) >> 8));
9297 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9299 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9300 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9301 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9302 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9304 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9306 if ( tempcx & EnableSpectrum )
9307 SetSpectrum( pVBInfo) ;
9310 else /* LVDS,CH7017 */
9311 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9315 /* --------------------------------------------------------------------- */
9316 /* Function : XGI_SetLCDCap_A */
9320 /* --------------------------------------------------------------------- */
9321 void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
9323 unsigned short temp ;
9325 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9327 if ( temp & LCDRGB18Bit )
9329 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
9330 (unsigned short)(0x20 | (tempcx & 0x00C0))); /* Enable Dither */
9331 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9335 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
9336 (unsigned short)(0x30 | (tempcx & 0x00C0)));
9337 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9341 if ( tempcx & EnableLCD24bpp ) // 24bits
9343 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(unsigned short)(0x30|(tempcx&0x00C0)) );
9344 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9348 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(unsigned short)(0x20|(tempcx&0x00C0)) ); // Enable Dither
9349 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9355 /* --------------------------------------------------------------------- */
9356 /* Function : XGI_SetLCDCap_B */
9357 /* Input : cx -> LCD Capability */
9360 /* --------------------------------------------------------------------- */
9361 void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
9363 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9364 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
9365 (unsigned short)(((tempcx & 0x00ff) >> 6) | 0x0c));
9367 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
9368 (unsigned short)(((tempcx & 0x00ff) >> 6) | 0x18)); /* Enable Dither */
9372 /* --------------------------------------------------------------------- */
9373 /* Function : SetSpectrum */
9377 /* --------------------------------------------------------------------- */
9378 void SetSpectrum(struct vb_device_info *pVBInfo)
9380 unsigned short index ;
9382 index = XGI_GetLCDCapPtr(pVBInfo) ;
9384 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9385 XGI_LongWait(pVBInfo) ;
9386 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9387 XGI_LongWait(pVBInfo) ;
9389 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9390 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9391 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9392 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9393 XGI_LongWait(pVBInfo) ;
9394 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9398 /* --------------------------------------------------------------------- */
9399 /* Function : XGI_SetAntiFlicker */
9402 /* Description : Set TV Customized Param. */
9403 /* --------------------------------------------------------------------- */
9404 void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
9405 struct vb_device_info *pVBInfo)
9407 unsigned short tempbx ,
9410 unsigned char tempah ;
9412 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9415 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9418 if ( ModeNo <= 0x13 )
9420 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9424 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9428 tempah = TVAntiFlickList[ tempbx ] ;
9429 tempah = tempah << 4 ;
9431 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9435 /* --------------------------------------------------------------------- */
9436 /* Function : XGI_SetEdgeEnhance */
9440 /* --------------------------------------------------------------------- */
9441 void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9443 unsigned short tempbx ,
9446 unsigned char tempah ;
9449 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9452 if ( ModeNo <= 0x13 )
9454 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9458 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9462 tempah = TVEdgeList[ tempbx ] ;
9463 tempah = tempah << 5 ;
9465 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9469 /* --------------------------------------------------------------------- */
9470 /* Function : XGI_SetPhaseIncr */
9474 /* --------------------------------------------------------------------- */
9475 void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
9477 unsigned short tempbx ;
9479 unsigned char tempcl ,
9482 unsigned long tempData ;
9484 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9485 tempData = TVPhaseList[ tempbx ] ;
9487 XGINew_SetReg1(pVBInfo->Part2Port, 0x31,
9488 (unsigned short)(tempData & 0x000000FF));
9489 XGINew_SetReg1(pVBInfo->Part2Port, 0x32,
9490 (unsigned short)((tempData & 0x0000FF00) >> 8));
9491 XGINew_SetReg1(pVBInfo->Part2Port, 0x33,
9492 (unsigned short)((tempData & 0x00FF0000) >> 16));
9493 XGINew_SetReg1(pVBInfo->Part2Port, 0x34,
9494 (unsigned short)((tempData & 0xFF000000) >> 24));
9498 /* --------------------------------------------------------------------- */
9499 /* Function : XGI_SetYFilter */
9503 /* --------------------------------------------------------------------- */
9504 void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
9505 struct vb_device_info *pVBInfo)
9507 unsigned short tempbx ,
9510 unsigned char tempcl ,
9515 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9521 filterPtr = NTSCYFilter1 ;
9525 filterPtr = PALYFilter1 ;
9531 filterPtr = PALMYFilter1 ;
9535 filterPtr = PALNYFilter1 ;
9540 filterPtr = NTSCYFilter2 ;
9544 filterPtr = PALMYFilter2 ;
9548 filterPtr = PALNYFilter2 ;
9552 filterPtr = PALYFilter2 ;
9559 if ( ModeNo <= 0x13 )
9560 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9562 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9569 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9571 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9572 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9573 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9574 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9578 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9579 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9580 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9581 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9584 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9586 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9587 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9588 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9593 /* --------------------------------------------------------------------- */
9594 /* Function : XGI_GetTVPtrIndex2 */
9596 /* Output : bx 0 : NTSC */
9600 /* 4 : NTSC1024x768 */
9601 /* 5 : PAL-M 1024x768 */
9603 /* cl 0 : YFilter1 */
9606 /* 1 : 301B/302B/301LV/302LV */
9608 /* --------------------------------------------------------------------- */
9609 void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
9610 unsigned char *tempch, struct vb_device_info *pVBInfo)
9616 if ( pVBInfo->TVInfo & SetPALTV )
9619 if ( pVBInfo->TVInfo & SetPALMTV )
9622 if ( pVBInfo->TVInfo & SetPALNTV )
9625 if ( pVBInfo->TVInfo & NTSC1024x768 )
9628 if ( pVBInfo->TVInfo & SetPALMTV )
9632 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9634 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9641 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9646 /* --------------------------------------------------------------------- */
9647 /* Function : XGI_SetCRT2ModeRegs */
9650 /* Description : Origin code for crt2group */
9651 /* --------------------------------------------------------------------- */
9652 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
9653 struct xgi_hw_device_info *HwDeviceExtension,
9654 struct vb_device_info *pVBInfo)
9656 unsigned short tempbl ;
9659 unsigned char tempah ;
9661 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9663 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9665 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9666 tempah &= ~0x10 ; /* BTRAMDAC */
9667 tempah |= 0x40 ; /* BTRAM */
9669 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9671 tempah=0x40; /* BTDRAM */
9672 if ( ModeNo > 0x13 )
9674 tempcl = pVBInfo->ModeType ;
9678 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9684 if ( pVBInfo->VBInfo & SetInSlaveMode )
9685 tempah ^= 0x50 ; /* BTDAC */
9690 if ( pVBInfo->VBInfo & DisableCRT2Display )
9695 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9696 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9698 tempcl = pVBInfo->ModeType ;
9699 if ( ModeNo > 0x13 )
9702 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
9704 tempah=(0x008>>tempcl) ;
9715 if ( pVBInfo->VBInfo & SetInSlaveMode )
9717 tempah = ( tempah ^ 0x050 ) ;
9722 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9726 if ( pVBInfo->VBInfo & DisableCRT2Display )
9727 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9733 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9735 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
9739 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9743 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9749 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9754 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
9757 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9759 tempah = tempah ^ 0x05 ;
9760 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
9761 tempah = tempah ^ 0x01 ;
9764 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9766 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9769 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9773 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9776 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9778 tempah &= ( ~0x08 ) ;
9779 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
9785 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9787 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
9790 if ( ModeNo > 0x13 )
9792 if ( pVBInfo->VBInfo & DriverMode )
9793 tempah = tempah ^ 0x20 ;
9798 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
9801 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9804 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9806 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
9808 if ( pVBInfo->TVInfo & RPLLDIV2XO )
9813 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
9816 if ( pVBInfo->LCDResInfo == Panel1280x960 )
9819 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
9822 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9827 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9830 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9831 tempah |= 0x04 ; /* shampoo 0129 */
9834 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
9837 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9839 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9843 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
9847 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9849 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9852 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
9857 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9860 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9864 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
9866 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9868 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9870 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
9871 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
9877 /* --------------------------------------------------------------------- */
9878 /* Function : XGI_CloseCRTC */
9882 /* --------------------------------------------------------------------- */
9883 void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
9885 unsigned short tempbx ;
9889 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9896 /* --------------------------------------------------------------------- */
9897 /* Function : XGI_OpenCRTC */
9901 /* --------------------------------------------------------------------- */
9902 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
9904 unsigned short tempbx ;
9912 /* --------------------------------------------------------------------- */
9913 /* Function : XGI_GetRAMDAC2DATA */
9917 /* --------------------------------------------------------------------- */
9918 void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
9920 unsigned short tempax ,
9929 pVBInfo->RVBHCMAX = 1 ;
9930 pVBInfo->RVBHCFACT = 1 ;
9932 if ( ModeNo <= 0x13 )
9934 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9935 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
9936 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
9937 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
9938 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
9942 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9943 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
9944 CRT1Index &= IndexMask ;
9945 temp1 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
9946 temp2 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
9947 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
9948 tempbx = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
9949 tempcx = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
9951 tempcx = tempcx << 2 ;
9953 temp1 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
9963 if ( modeflag & Charx8Dot )
9968 pVBInfo->VGAHT = tempax ;
9969 pVBInfo->HT = tempax ;
9971 pVBInfo->VGAVT = tempbx ;
9972 pVBInfo->VT = tempbx ;
9977 /* --------------------------------------------------------------------- */
9978 /* Function : XGI_GetColorDepth */
9982 /* --------------------------------------------------------------------- */
9983 unsigned short XGI_GetColorDepth(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9985 unsigned short ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
9987 unsigned short modeflag ;
9989 if ( ModeNo <= 0x13 )
9991 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9995 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9998 index=(modeflag&ModeInfoFlag)-ModeEGA;
10003 return( ColorDepth[ index ] ) ;
10008 /* --------------------------------------------------------------------- */
10009 /* Function : XGI_UnLockCRT2 */
10012 /* Description : */
10013 /* --------------------------------------------------------------------- */
10014 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
10017 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
10022 /* --------------------------------------------------------------------- */
10023 /* Function : XGI_LockCRT2 */
10026 /* Description : */
10027 /* --------------------------------------------------------------------- */
10028 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
10031 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
10037 /* --------------------------------------------------------------------- */
10038 /* Function : XGINew_EnableCRT2 */
10041 /* Description : */
10042 /* --------------------------------------------------------------------- */
10043 void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
10045 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
10050 /* --------------------------------------------------------------------- */
10054 /* Description : */
10055 /* --------------------------------------------------------------------- */
10056 void XGINew_LCD_Wait_Time(unsigned char DelayTime, struct vb_device_info *pVBInfo)
10061 unsigned long temp ,
10065 //printk("XGINew_LCD_Wait_Time");
10067 for( i = 0 ; i < DelayTime ; i++ )
10069 for( j = 0 ; j < 66 ; j++ )
10072 temp = XGINew_GetReg3( 0x61 ) ;
10074 //temp &= 0x10000000;
10076 if ( temp == flag )
10087 /* --------------------------------------------------------------------- */
10088 /* Function : XGI_BridgeIsOn */
10091 /* Description : */
10092 /* --------------------------------------------------------------------- */
10093 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
10095 unsigned short flag ;
10097 if ( pVBInfo->IF_DEF_LVDS == 1 )
10103 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10104 if ( ( flag == 1 ) || ( flag == 2 ) )
10105 return( 1 ) ; /* 301b */
10113 /* --------------------------------------------------------------------- */
10114 /* Function : XGI_LongWait */
10117 /* Description : */
10118 /* --------------------------------------------------------------------- */
10119 void XGI_LongWait(struct vb_device_info *pVBInfo)
10123 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10125 if ( !( i & 0xC0 ) )
10127 for( i = 0 ; i < 0xFFFF ; i++ )
10129 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10133 for( i = 0 ; i < 0xFFFF ; i++ )
10135 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10142 /* --------------------------------------------------------------------- */
10143 /* Function : XGI_VBLongWait */
10146 /* Description : */
10147 /* --------------------------------------------------------------------- */
10148 void XGI_VBLongWait(struct vb_device_info *pVBInfo)
10150 unsigned short tempal ,
10155 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10158 for( i = 0 ; i < 3 ; i++ )
10160 for( j = 0 ; j < 100 ; j++ )
10162 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10164 { /* VBWaitMode2 */
10165 if ( ( tempal & 0x08 ) )
10170 if ( !( tempal & 0x08 ) )
10176 { /* VBWaitMode1 */
10177 if ( !( tempal & 0x08 ) )
10182 if ( ( tempal & 0x08 ) )
10188 temp = temp ^ 0x01 ;
10193 XGI_LongWait(pVBInfo) ;
10201 /* --------------------------------------------------------------------- */
10202 /* Function : XGI_GetVGAHT2 */
10205 /* Description : */
10206 /* --------------------------------------------------------------------- */
10207 unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
10209 unsigned long tempax ,
10212 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10213 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10214 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10216 return( (unsigned short)tempax ) ;
10220 /* --------------------------------------------------------------------- */
10221 /* Function : XGI_GetVCLK2Ptr */
10224 /* Description : */
10225 /* --------------------------------------------------------------------- */
10226 unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
10227 unsigned short ModeIdIndex,
10228 unsigned short RefreshRateTableIndex,
10229 struct xgi_hw_device_info *HwDeviceExtension,
10230 struct vb_device_info *pVBInfo)
10232 unsigned short tempbx ;
10234 unsigned short LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10235 unsigned short LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10236 unsigned short LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10237 unsigned short LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10238 unsigned short LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10240 unsigned short CRT2Index , VCLKIndex ;
10241 unsigned short modeflag , resinfo ;
10242 unsigned char *CHTVVCLKPtr = NULL ;
10244 if ( ModeNo <= 0x13 )
10246 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10247 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10248 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10252 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10253 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10254 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10257 if ( pVBInfo->IF_DEF_LVDS == 0 )
10259 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10260 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10262 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10264 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10268 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10273 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10275 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10277 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10279 VCLKIndex = HiTVVCLKDIV2 ;
10287 VCLKIndex = HiTVVCLK ;
10294 if ( pVBInfo->SetFlag & TVSimuMode )
10296 if( modeflag & Charx8Dot )
10298 VCLKIndex = HiTVSimuVCLK ;
10306 VCLKIndex = HiTVTextVCLK ;
10314 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10316 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10318 VCLKIndex = YPbPr750pVCLK ;
10319 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10321 VCLKIndex = YPbPr525pVCLK ;
10322 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10324 VCLKIndex = YPbPr525iVCLK_2 ;
10325 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10326 VCLKIndex = YPbPr525iVCLK ;
10334 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10336 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10338 VCLKIndex = TVVCLKDIV2 ;
10346 VCLKIndex = TVVCLK ;
10357 VCLKIndex = (unsigned char)XGINew_GetReg2((pVBInfo->P3ca + 0x02)); /* Port 3cch */
10358 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10359 if ( ModeNo > 0x13 )
10361 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10362 VCLKIndex &= IndexMask ;
10369 if ( ModeNo <= 0x13 )
10370 VCLKIndex = CRT2Index ;
10372 VCLKIndex = CRT2Index ;
10374 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10376 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10378 VCLKIndex &= 0x1f ;
10381 if ( pVBInfo->VBInfo & SetPALTV )
10384 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10390 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10393 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10396 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10399 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10405 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10410 VCLKIndex = VCLKIndex >> 6 ;
10411 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10412 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10413 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10414 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10416 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10419 /* VCLKIndex = VCLKIndex&IndexMask ; */
10423 return( VCLKIndex ) ;