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 void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
128 unsigned short RefreshRateTableIndex,
129 struct xgi_hw_device_info *HwDeviceExtension,
130 struct vb_device_info *pVBInfo);
131 void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
132 void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
133 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
134 void XGI_GetVBType(struct vb_device_info *pVBInfo);
135 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
136 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
137 void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
138 void InitTo330Pointer(unsigned char, struct vb_device_info *pVBInfo);
139 void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, struct vb_device_info *pVBInfo);
140 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
141 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
142 void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
143 void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
144 void XGI_SetDelayComp(struct vb_device_info *pVBInfo);
145 void XGI_SetLCDCap(struct vb_device_info *pVBInfo);
146 void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo);
147 void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo);
148 void SetSpectrum(struct vb_device_info *pVBInfo);
149 void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
150 void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
151 void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo);
152 void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
153 void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char* tempcl,
154 unsigned char *tempch, struct vb_device_info *pVBInfo);
155 unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo);
156 void XGI_SetCRT2ModeRegs(unsigned short ModeNo, struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
157 void XGI_CloseCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
158 void XGI_OpenCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
159 void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
160 void XGI_UnLockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
161 void XGI_LockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
162 void XGINew_EnableCRT2(struct vb_device_info *pVBInfo);
163 void XGINew_LCD_Wait_Time(unsigned char DelayTime, struct vb_device_info *pVBInfo);
164 void XGI_LongWait(struct vb_device_info *pVBInfo);
165 void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
166 void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
167 struct vb_device_info *pVBInfo);
168 unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
169 unsigned short ModeNo,
170 unsigned short ModeIdIndex,
171 struct vb_device_info *pVBInfo);
172 void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
173 unsigned char *di_1, struct vb_device_info *pVBInfo);
174 unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo);
175 unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo);
176 struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo);
177 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo);
178 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo);
179 unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo);
180 unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo);
181 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
182 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
183 void XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo);
184 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
185 void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
186 void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
187 unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo);
189 extern void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVBInfo);
191 /* unsigned short XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
194 unsigned short XGINew_MDA_DAC[] = {
195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
196 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
197 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
198 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
200 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
201 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
202 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
204 unsigned short XGINew_CGA_DAC[] = {
205 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
206 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
207 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
208 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
209 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
210 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
211 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
212 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
214 unsigned short XGINew_EGA_DAC[] = {
215 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
216 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
217 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
218 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
219 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
220 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
221 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
222 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
224 unsigned short XGINew_VGA_DAC[] = {
225 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
226 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
227 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
228 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
229 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
230 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
231 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
232 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
233 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
234 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
237 /* --------------------------------------------------------------------- */
238 /* Function : InitTo330Pointer */
242 /* --------------------------------------------------------------------- */
243 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
245 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable ;
246 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable ;
247 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable ;
248 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex ;
249 pVBInfo->XGINEWUB_CRT1Table = (struct XGI_CRT1TableStruct *) XGI_CRT1Table ;
251 /* add for new UNIVGABIOS */
252 /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
253 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
256 if ( ChipType >= XG40 )
258 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
259 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
263 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI330New_MCLKData;
264 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI330_ECLKData;
267 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData ;
268 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
269 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
270 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo ;
271 pVBInfo->ModeResInfo = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
273 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
274 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
275 pVBInfo->pSR07 = &XGI330_SR07 ;
276 pVBInfo->LCDResInfo = 0 ;
277 pVBInfo->LCDTypeInfo = 0 ;
278 pVBInfo->LCDInfo = 0 ;
279 pVBInfo->VBInfo = 0 ;
283 pVBInfo->SR15 = XGI340_SR13 ;
284 pVBInfo->CR40 = XGI340_cr41 ;
285 pVBInfo->SR25 = XGI330_sr25 ;
286 pVBInfo->pSR31 = &XGI330_sr31 ;
287 pVBInfo->pSR32 = &XGI330_sr32 ;
288 pVBInfo->CR6B = XGI340_CR6B ;
289 pVBInfo->CR6E = XGI340_CR6E ;
290 pVBInfo->CR6F = XGI340_CR6F ;
291 pVBInfo->CR89 = XGI340_CR89 ;
292 pVBInfo->AGPReg = XGI340_AGPReg ;
293 pVBInfo->SR16 = XGI340_SR16 ;
294 pVBInfo->pCRCF = &XG40_CRCF ;
295 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
298 pVBInfo->CR49 = XGI330_CR49 ;
299 pVBInfo->pSR1F = &XGI330_SR1F ;
300 pVBInfo->pSR21 = &XGI330_SR21 ;
301 pVBInfo->pSR22 = &XGI330_SR22 ;
302 pVBInfo->pSR23 = &XGI330_SR23 ;
303 pVBInfo->pSR24 = &XGI330_SR24 ;
304 pVBInfo->pSR33 = &XGI330_SR33 ;
308 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
309 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
310 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
311 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
312 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
313 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
314 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
315 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
316 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
317 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
319 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
320 pVBInfo->PALTiming = XGI330_PALTiming ;
321 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
322 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
323 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
324 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
325 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
326 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
327 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
328 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
329 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
330 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
331 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
332 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
335 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH ;
336 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV ;
337 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
339 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
340 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
341 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
342 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
344 /* 310 customization related */
345 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
346 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
348 pVBInfo->LCDCapList = XGI_LCDCapList ;
350 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
351 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
353 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
354 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
357 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
359 if ( ChipType >= XG20 )
360 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
362 if ( ChipType == XG27 )
364 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
365 pVBInfo->CR40 = XGI27_cr41 ;
366 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
367 pVBInfo->pSR36 = &XG27_SR36 ;
368 pVBInfo->pCR8F = &XG27_CR8F ;
369 pVBInfo->pCRD0 = XG27_CRD0 ;
370 pVBInfo->pCRDE = XG27_CRDE ;
371 pVBInfo->pSR40 = &XG27_SR40 ;
372 pVBInfo->pSR41 = &XG27_SR41 ;
376 if ( ChipType >= XG20 )
378 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
379 pVBInfo->pCR2E = &XG21_CR2E ;
380 pVBInfo->pCR2F = &XG21_CR2F ;
381 pVBInfo->pCR46 = &XG21_CR46 ;
382 pVBInfo->pCR47 = &XG21_CR47 ;
392 /* --------------------------------------------------------------------- */
393 /* Function : XGISetModeNew */
397 /* --------------------------------------------------------------------- */
398 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
399 unsigned short ModeNo)
401 unsigned short ModeIdIndex ;
402 /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
403 struct vb_device_info VBINF;
404 struct vb_device_info *pVBInfo = &VBINF;
405 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
406 pVBInfo->BaseAddr = (unsigned long)HwDeviceExtension->pjIOAddress ;
407 pVBInfo->IF_DEF_LVDS = 0 ;
408 pVBInfo->IF_DEF_CH7005 = 0 ;
409 pVBInfo->IF_DEF_LCDA = 1 ;
410 pVBInfo->IF_DEF_CH7017 = 0 ;
411 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
412 pVBInfo->IF_DEF_VideoCapture = 0 ;
413 pVBInfo->IF_DEF_ScaleLCD = 0 ;
414 pVBInfo->IF_DEF_OEMUtil = 0 ;
415 pVBInfo->IF_DEF_PWD = 0 ;
418 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
420 pVBInfo->IF_DEF_YPbPr = 0 ;
421 pVBInfo->IF_DEF_HiVision = 0 ;
422 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
423 pVBInfo->VBType = 0 ; /*set VBType default 0*/
425 else if ( HwDeviceExtension->jChipType >= XG40 )
427 pVBInfo->IF_DEF_YPbPr = 1 ;
428 pVBInfo->IF_DEF_HiVision = 1 ;
429 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
433 pVBInfo->IF_DEF_YPbPr = 1 ;
434 pVBInfo->IF_DEF_HiVision = 1 ;
435 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
438 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
439 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
440 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
441 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
442 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
443 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
444 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
445 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
446 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
447 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
448 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
449 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
450 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
451 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
452 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
453 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
454 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
455 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
457 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
459 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
461 pVBInfo->IF_DEF_LVDS = 1 ;
464 if ( HwDeviceExtension->jChipType == XG27 )
466 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
468 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
470 pVBInfo->IF_DEF_LVDS = 1 ;
475 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
476 XGI_GetVBType( pVBInfo ) ;
478 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
481 ModeNo = ModeNo & 0x7F ;
482 /* XGINew_flag_clearbuffer = 0 ; */
486 XGINew_flag_clearbuffer = 1 ;
489 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
491 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
492 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
494 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
496 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
498 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
500 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
501 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
502 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
503 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
504 /* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
506 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
508 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
510 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
512 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
517 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
519 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
520 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
522 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
527 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
529 switch( HwDeviceExtension->ujVBChipID )
532 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
536 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
544 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
545 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
546 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
547 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
551 if (pVBInfo->IF_DEF_LVDS == 1)
552 if (!XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo))
555 if ( ModeNo <= 0x13 )
557 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
561 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
564 pVBInfo->SetFlag = 0 ;
565 if ( pVBInfo->IF_DEF_CH7007 != 1 )
567 pVBInfo->VBInfo = DisableCRT2Display ;
571 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
573 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
575 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
577 if( HwDeviceExtension->jChipType == XG21 )
578 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
584 if ( ModeNo <= 0x13 )
586 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
590 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
592 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
593 pVBInfo->SetFlag = 0x00 ;
594 pVBInfo->VBInfo = DisableCRT2Display ;
595 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
600 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
601 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
602 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
605 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
607 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
609 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
616 /* --------------------------------------------------------------------- */
617 /* Function : XGI_SetCRT1Group */
621 /* --------------------------------------------------------------------- */
622 void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
623 unsigned short ModeNo,
624 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
626 unsigned short StandTableIndex ,
627 RefreshRateTableIndex ,
631 unsigned short XGINew_P3cc = pVBInfo->P3cc;
633 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
634 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
635 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
636 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
637 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
638 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
639 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
640 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
641 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
642 XGI_ClearExt1Regs(pVBInfo) ;
644 /* if ( pVBInfo->IF_DEF_ExpLink ) */
645 if ( HwDeviceExtension->jChipType == XG27 )
647 if ( pVBInfo->IF_DEF_LVDS == 0 )
649 XGI_SetDefaultVCLK( pVBInfo ) ;
653 temp = ~ProgrammingCRT2 ;
654 pVBInfo->SetFlag &= temp ;
655 pVBInfo->SelectCRT2Rate = 0 ;
657 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
659 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
661 pVBInfo->SetFlag |= ProgrammingCRT2 ;
665 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
666 if ( RefreshRateTableIndex != 0xFFFF )
668 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
669 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
670 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
671 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
672 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
675 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
676 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
678 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
680 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
681 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
682 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc) ;
683 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
685 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
687 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
688 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
689 b3CC = (unsigned char)XGINew_GetReg2(XGINew_P3cc) ;
690 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
694 if ( HwDeviceExtension->jChipType >= XG21 )
696 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
700 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
701 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
702 /* XG21 CRT1 Timing */
703 if ( HwDeviceExtension->jChipType == XG27 )
704 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
706 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
708 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
710 if ( HwDeviceExtension->jChipType == XG27 )
711 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
713 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
715 if ( pVBInfo->IF_DEF_LVDS == 1 )
717 if ( HwDeviceExtension->jChipType == XG27 )
718 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
720 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
722 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
726 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
727 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
728 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
731 /* XGI_LoadCharacter(); //dif ifdef TVFont */
733 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
734 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
738 /* --------------------------------------------------------------------- */
739 /* Function : XGI_GetModePtr */
743 /* --------------------------------------------------------------------- */
744 unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
745 struct vb_device_info *pVBInfo)
747 unsigned char index ;
749 if ( ModeNo <= 0x13 )
750 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
753 if ( pVBInfo->ModeType <= 0x02 )
754 index = 0x1B ; /* 02 -> ModeEGA */
758 return( index ) ; /* Get pVBInfo->StandTable index */
762 /* --------------------------------------------------------------------- */
763 /* Function : XGI_SetBIOSData */
767 /* --------------------------------------------------------------------- */
768 /*unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex)
774 /* --------------------------------------------------------------------- */
775 /* Function : XGI_ClearBankRegs */
779 /* --------------------------------------------------------------------- */
780 /*unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex)
786 /* --------------------------------------------------------------------- */
787 /* Function : XGI_SetSeqRegs */
791 /* --------------------------------------------------------------------- */
792 void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
793 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
795 unsigned char tempah ,
801 if ( ModeNo <= 0x13 )
802 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
804 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
806 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
807 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
810 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
816 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
818 if ( pVBInfo->VBInfo & SetInSlaveMode )
823 tempah |= 0x20 ; /* screen off */
824 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
826 for( i = 02 ; i <= 04 ; i++ )
828 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
829 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
834 /* --------------------------------------------------------------------- */
835 /* Function : XGI_SetMiscRegs */
839 /* --------------------------------------------------------------------- */
840 void XGI_SetMiscRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
842 unsigned char Miscdata ;
844 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
846 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
848 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
855 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
859 /* --------------------------------------------------------------------- */
860 /* Function : XGI_SetCRTCRegs */
864 /* --------------------------------------------------------------------- */
865 void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
866 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
868 unsigned char CRTCdata ;
871 CRTCdata = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
873 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
875 for( i = 0 ; i <= 0x18 ; i++ )
877 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
878 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
881 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
883 if ( pVBInfo->VBInfo & SetInSlaveMode )
885 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
887 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
895 /* --------------------------------------------------------------------- */
900 /* --------------------------------------------------------------------- */
901 void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
902 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
904 unsigned char ARdata ;
905 unsigned short i, modeflag;
907 if ( ModeNo <= 0x13 )
908 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
910 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
912 for( i = 0 ; i <= 0x13 ; i++ )
914 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
915 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
919 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
923 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
925 if ( pVBInfo->VBInfo & SetInSlaveMode )
932 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
933 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
934 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
937 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
938 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
939 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
940 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
941 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
945 /* --------------------------------------------------------------------- */
946 /* Function : XGI_SetGRCRegs */
950 /* --------------------------------------------------------------------- */
951 void XGI_SetGRCRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
953 unsigned char GRdata ;
956 for( i = 0 ; i <= 0x08 ; i++ )
958 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
959 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
962 if ( pVBInfo->ModeType > ModeVGA )
964 GRdata = (unsigned char)XGINew_GetReg1(pVBInfo->P3ce, 0x05);
965 GRdata &= 0xBF ; /* 256 color disable */
966 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
971 /* --------------------------------------------------------------------- */
972 /* Function : XGI_ClearExt1Regs */
976 /* --------------------------------------------------------------------- */
977 void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
981 for( i = 0x0A ; i <= 0x0E ; i++ )
982 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
986 /* --------------------------------------------------------------------- */
987 /* Function : XGI_SetDefaultVCLK */
991 /* --------------------------------------------------------------------- */
992 unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
995 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
996 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
997 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
999 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
1000 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
1001 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
1003 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
1008 /* --------------------------------------------------------------------- */
1009 /* Function : XGI_GetRatePtrCRT2 */
1013 /* --------------------------------------------------------------------- */
1014 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
1015 unsigned short ModeNo,
1016 unsigned short ModeIdIndex,
1017 struct vb_device_info *pVBInfo)
1019 short LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
1020 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
1022 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
1024 if ( ModeNo <= 0x13 )
1026 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1030 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1033 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1035 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1037 if ( modeflag & HalfDCLK )
1042 if ( ModeNo < 0x14 )
1045 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1046 index = index >> pVBInfo->SelectCRT2Rate ;
1049 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1055 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1057 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1059 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1065 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1067 if( pVBInfo->IF_DEF_LVDS == 0 )
1069 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1070 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1072 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1086 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1087 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1088 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1091 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1096 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1097 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1101 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1102 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1103 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1107 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1108 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1117 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1119 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1120 temp &= ModeInfoFlag ;
1121 if ( temp < pVBInfo->ModeType )
1126 } while( index != 0xFFFF ) ;
1127 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1129 if ( pVBInfo->VBInfo & SetInSlaveMode )
1131 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1132 if ( temp & InterlaceMode )
1139 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1141 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1143 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1147 /* --------------------------------------------------------------------- */
1148 /* Function : XGI_AjustCRT2Rate */
1152 /* --------------------------------------------------------------------- */
1153 unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, unsigned short ModeIdIndex,
1154 unsigned short RefreshRateTableIndex,
1155 unsigned short *i, struct vb_device_info *pVBInfo)
1157 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
1159 if ( ModeNo <= 0x13 )
1161 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1165 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1168 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1169 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1172 if ( pVBInfo->IF_DEF_LVDS == 0 )
1174 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1176 tempax |= SupportRAMDAC2 ;
1178 if ( pVBInfo->VBType & VB_XGI301C )
1179 tempax |= SupportCRT2in301C ;
1182 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1184 tempax |= SupportLCD ;
1186 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1188 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1190 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1202 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1204 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1206 tempax |= SupportYPbPr ;
1207 if ( pVBInfo->VBInfo & SetInSlaveMode )
1221 tempax |= SupportHiVisionTV ;
1222 if ( pVBInfo->VBInfo & SetInSlaveMode )
1229 if ( pVBInfo->SetFlag & TVSimuMode )
1240 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1242 tempax |= SupportTV ;
1244 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1246 tempax |= SupportTV1024 ;
1249 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1251 if ( modeflag & NoSupportSimuTV )
1253 if ( pVBInfo->VBInfo & SetInSlaveMode )
1255 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1267 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1269 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1271 tempax |= SupportCHTV ;
1275 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1277 tempax |= SupportLCD ;
1279 if ( resinfo > 0x08 )
1280 return( 0 ) ; /* 1024x768 */
1282 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1284 if ( resinfo > 0x07 )
1285 return( 0 ) ; /* 800x600 */
1287 if ( resinfo == 0x04 )
1288 return( 0 ) ; /* 512x384 */
1293 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1295 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1296 if ( infoflag & tempax )
1304 for( ( *i ) = 0 ; ; ( *i )++ )
1306 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1307 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1312 if ( infoflag & tempax )
1321 /* --------------------------------------------------------------------- */
1322 /* Function : XGI_SetSync */
1326 /* --------------------------------------------------------------------- */
1327 void XGI_SetSync(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
1329 unsigned short sync ,
1332 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1336 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1340 /* --------------------------------------------------------------------- */
1341 /* Function : XGI_SetCRT1CRTC */
1345 /* --------------------------------------------------------------------- */
1346 void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1347 unsigned short RefreshRateTableIndex,
1348 struct vb_device_info *pVBInfo,
1349 struct xgi_hw_device_info *HwDeviceExtension)
1351 unsigned char index, data;
1354 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1355 index = index&IndexMask ;
1357 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1359 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1361 for( i = 0 ; i < 8 ; i++ )
1362 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1364 for( i = 0 ; i < 7 ; i++ )
1365 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1367 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1371 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1374 if( pVBInfo->ModeType > 0x03 )
1375 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1379 /* --------------------------------------------------------------------- */
1380 /* Function : XGI_SetCRT1Timing_H */
1384 /* --------------------------------------------------------------------- */
1385 void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension)
1387 unsigned char data, data1, pushax;
1388 unsigned short i, j;
1390 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1391 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1392 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1394 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
1396 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1398 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1399 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1401 for( i = 0x01 ; i <= 0x04 ; i++ )
1403 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
1404 XGINew_SetReg1( pVBInfo->P3d4, (unsigned short)(i + 1), data);
1407 for( i = 0x05 ; i <= 0x06 ; i++ )
1409 data = pVBInfo->TimingH[ 0 ].data[ i ];
1410 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short)(i + 6), data);
1413 j = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1415 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1418 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1420 if ( HwDeviceExtension->jChipType >= XG20 )
1422 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x04);
1424 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1425 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x05);
1432 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0c);
1434 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1439 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1440 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1446 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1451 /* --------------------------------------------------------------------- */
1452 /* Function : XGI_SetCRT1Timing_V */
1456 /* --------------------------------------------------------------------- */
1457 void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
1458 unsigned short ModeNo,
1459 struct vb_device_info *pVBInfo)
1462 unsigned short i, j;
1464 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1465 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1466 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1468 for( i = 0x00 ; i <= 0x01 ; i++ )
1470 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1471 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 6), data);
1474 for( i = 0x02 ; i <= 0x03 ; i++ )
1476 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1477 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 0x0e), data);
1480 for( i = 0x04 ; i <= 0x05 ; i++ )
1482 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1483 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 0x11), data);
1486 j = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0a);
1488 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1491 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1493 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1497 if ( ModeNo <= 0x13 )
1498 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1500 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1502 i &= DoubleScanMode ;
1506 j = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x09);
1509 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1513 /* --------------------------------------------------------------------- */
1514 /* Function : XGI_SetXG21CRTC */
1515 /* Input : Stand or enhance CRTC table */
1516 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1517 /* Description : Set LCD timing */
1518 /* --------------------------------------------------------------------- */
1519 void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1520 unsigned short RefreshRateTableIndex,
1521 struct vb_device_info *pVBInfo)
1523 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1524 unsigned short Temp1, Temp2, Temp3;
1526 if ( ModeNo <= 0x13 )
1528 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1529 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1530 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1531 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1532 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1534 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1535 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1536 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1537 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1538 Tempdx <<= 2 ; /* Tempdx << 2 */
1539 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1540 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1542 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1543 Tempbx = Tempax ; /* Tempbx=Tempax */
1544 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1545 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1546 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1547 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1548 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1549 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1550 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1551 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1553 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
1554 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1555 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1556 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1557 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1559 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1560 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1561 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1562 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1563 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1564 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1565 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1566 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1567 Tempax = (unsigned char)Temp2; /* Tempax[7:0]: VRE[7:0] */
1568 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1569 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1570 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1571 Tempbx = (unsigned char)Temp1; /* Tempbx[1:0]: VRS[10:9] */
1572 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1574 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1578 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1579 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1580 Tempcx = Tempax ; /* Tempcx: HRS */
1581 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1583 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1584 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1585 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1586 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1587 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1589 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1590 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1592 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1593 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1594 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1595 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1597 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1598 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1600 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1601 if( Tempax < Tempcx ) /* HRE < HRS */
1602 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1605 Tempax = (unsigned char)Temp2; /* Tempax: HRE[7:0] */
1606 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1607 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1608 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1609 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1610 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1612 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1613 Tempbx = Tempax ; /* Tempbx: VRS */
1614 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1615 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1616 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1617 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1618 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1619 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1620 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1621 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1623 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1624 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1625 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1627 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1628 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1629 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1630 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1632 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1633 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1635 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1636 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1637 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1638 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1639 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1640 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1641 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1642 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1644 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1645 if ( Tempax < Temp3 ) /* VRE < VRS */
1646 Temp2 |= 0x20 ; /* VRE + 0x20 */
1649 Tempax = (unsigned char)Temp2; /* Tempax: VRE[7:0] */
1650 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1651 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1652 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1653 Tempbx = (unsigned char)Temp1;
1654 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1656 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1660 void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1661 unsigned short RefreshRateTableIndex,
1662 struct vb_device_info *pVBInfo)
1664 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1666 if ( ModeNo <= 0x13 )
1668 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1669 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1670 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1671 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1672 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1674 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1675 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1676 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1677 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1678 Tempdx <<= 2 ; /* Tempdx << 2 */
1679 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1680 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1682 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1683 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1684 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1685 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1686 Tempbx = Tempax ; /* Tempbx=CR07 */
1687 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1689 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1690 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1691 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1694 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1695 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1696 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1697 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1698 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1699 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1700 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1701 Tempax = (unsigned char)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1702 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1703 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1704 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1705 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1709 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1710 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1711 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1712 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1714 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1715 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1716 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1718 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1719 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1720 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1722 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1723 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1724 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1725 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1727 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1728 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1730 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1731 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1732 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1733 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1735 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1736 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1737 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1738 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1739 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1740 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1742 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1743 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1745 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1746 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1747 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1748 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1749 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1750 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1751 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1752 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1753 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1754 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1755 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1758 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1759 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1760 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1761 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1762 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1763 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1764 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1765 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1766 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1768 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1769 Tempbx |= 0x20 ; /* VRE + 0x20 */
1771 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1772 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1773 Tempax = Tempcx >> 8;
1774 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1779 /* --------------------------------------------------------------------- */
1780 /* Function : XGI_SetXG21LCD */
1782 /* Output : FCLK duty cycle, FCLK delay compensation */
1783 /* Description : All values set zero */
1784 /* --------------------------------------------------------------------- */
1785 void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
1786 unsigned short RefreshRateTableIndex,
1787 unsigned short ModeNo)
1789 unsigned short Data, Temp, b3CC;
1790 unsigned short XGI_P3cc;
1792 XGI_P3cc = pVBInfo->P3cc ;
1794 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1795 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1796 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1797 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1798 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1800 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1801 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1802 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1803 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1806 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1810 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1811 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1814 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1816 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1817 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1819 if ( ModeNo <= 0x13 )
1821 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1823 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1825 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1829 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1830 if ( Data & 0x4000 )
1831 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1832 if ( Data & 0x8000 )
1833 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1837 void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
1838 unsigned short RefreshRateTableIndex,
1839 unsigned short ModeNo)
1841 unsigned short Data , Temp , b3CC ;
1842 unsigned short XGI_P3cc ;
1844 XGI_P3cc = pVBInfo->P3cc ;
1846 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1847 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1848 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1849 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1851 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1852 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1854 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1855 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1858 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1860 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1861 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1862 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1863 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1866 XGI_SetXG27FPBits(pVBInfo);
1868 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1870 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1871 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1873 if ( ModeNo <= 0x13 )
1875 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1877 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1879 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1883 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1884 if ( Data & 0x4000 )
1885 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1886 if ( Data & 0x8000 )
1887 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1891 /* --------------------------------------------------------------------- */
1892 /* Function : XGI_UpdateXG21CRTC */
1894 /* Output : CRT1 CRTC */
1895 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1896 /* --------------------------------------------------------------------- */
1897 void XGI_UpdateXG21CRTC(unsigned short ModeNo,
1898 struct vb_device_info *pVBInfo,
1899 unsigned short RefreshRateTableIndex)
1903 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1904 if ( ModeNo <= 0x13 )
1906 for( i = 0 ; i < 12 ; i++ )
1908 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1914 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1916 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1918 else if ( ModeNo == 0x2F )
1920 else if ( ModeNo == 0x50 )
1922 else if ( ModeNo == 0x59 )
1928 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1929 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1930 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1931 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1936 /* --------------------------------------------------------------------- */
1937 /* Function : XGI_SetCRT1DE */
1941 /* --------------------------------------------------------------------- */
1942 void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1943 unsigned short ModeNo,
1944 unsigned short ModeIdIndex,
1945 unsigned short RefreshRateTableIndex,
1946 struct vb_device_info *pVBInfo)
1948 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1952 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1954 if ( ModeNo <= 0x13 )
1956 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1957 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1958 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1962 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1963 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1964 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1967 if ( modeflag & HalfDCLK )
1968 tempax = tempax >> 1 ;
1970 if ( ModeNo > 0x13 )
1972 if ( modeflag & HalfDCLK )
1973 tempax = tempax << 1 ;
1975 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1977 if ( temp & InterlaceMode )
1978 tempbx = tempbx >> 1 ;
1980 if ( modeflag & DoubleScanMode )
1981 tempbx = tempbx << 1 ;
1986 /* if ( !( modeflag & Charx8Dot ) ) */
1993 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1994 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1996 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
1997 XGINew_SetReg1(pVBInfo->P3d4, 0x01, (unsigned short)(tempcx & 0xff));
1998 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0b, ~0x0c, (unsigned short)((tempcx & 0x0ff00) >> 10));
1999 XGINew_SetReg1(pVBInfo->P3d4, 0x12, (unsigned short)(tempbx & 0xff));
2001 tempbx = tempbx >> 8 ;
2003 if ( tempbx & 0x01 )
2006 if ( tempbx & 0x02 )
2009 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
2010 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x07);
2014 if ( tempbx & 0x04 )
2017 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
2018 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
2022 /* --------------------------------------------------------------------- */
2023 /* Function : XGI_GetResInfo */
2027 /* --------------------------------------------------------------------- */
2028 unsigned short XGI_GetResInfo(unsigned short ModeNo,
2029 unsigned short ModeIdIndex,
2030 struct vb_device_info *pVBInfo)
2032 unsigned short resindex;
2034 if ( ModeNo <= 0x13 )
2036 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2040 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2042 return( resindex ) ;
2046 /* --------------------------------------------------------------------- */
2047 /* Function : XGI_SetCRT1Offset */
2051 /* --------------------------------------------------------------------- */
2052 void XGI_SetCRT1Offset(unsigned short ModeNo,
2053 unsigned short ModeIdIndex,
2054 unsigned short RefreshRateTableIndex,
2055 struct xgi_hw_device_info *HwDeviceExtension,
2056 struct vb_device_info *pVBInfo)
2058 unsigned short temp ,
2066 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2068 temp = pVBInfo->ScreenOffset[ temp ] ;
2070 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2071 temp2 &= InterlaceMode ;
2076 temp2 = pVBInfo->ModeType - ModeEGA ;
2102 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2103 temp = temp * temp2 + temp2 / 2 ;
2108 DisplayUnit = temp ;
2110 temp = temp >> 8 ; /* ah */
2112 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2115 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2117 temp = (unsigned char)temp2;
2118 temp &= 0xFF ; /* al */
2119 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2121 /* SetDisplayUnit */
2122 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2123 temp2 &= InterlaceMode ;
2127 DisplayUnit = DisplayUnit << 5 ;
2128 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2129 al = DisplayUnit & 0x00ff ;
2135 if ( HwDeviceExtension->jChipType >= XG20 )
2136 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2139 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2143 /* --------------------------------------------------------------------- */
2144 /* Function : XGI_SetCRT1VCLK */
2148 /* --------------------------------------------------------------------- */
2149 void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2150 struct xgi_hw_device_info *HwDeviceExtension,
2151 unsigned short RefreshRateTableIndex,
2152 struct vb_device_info *pVBInfo)
2154 unsigned char index, data;
2155 unsigned short vclkindex ;
2157 if ( pVBInfo->IF_DEF_LVDS == 1 )
2159 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2160 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2161 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2162 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2163 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2164 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2166 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2168 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2169 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2170 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2171 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2172 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2173 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2174 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2175 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2179 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2180 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2181 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2182 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2183 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2184 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2187 if ( HwDeviceExtension->jChipType >= XG20 )
2189 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2191 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2192 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2193 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2200 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2206 /* --------------------------------------------------------------------- */
2207 /* Function : XGI_SetCRT1FIFO */
2211 /* --------------------------------------------------------------------- */
2212 void XGI_SetCRT1FIFO(unsigned short ModeNo,
2213 struct xgi_hw_device_info *HwDeviceExtension,
2214 struct vb_device_info *pVBInfo)
2216 unsigned short data ;
2218 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2220 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2222 if ( ModeNo > 0x13 )
2224 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2225 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2227 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2228 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2230 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2234 if (HwDeviceExtension->jChipType == XG27)
2236 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2237 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2239 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2243 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2244 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2246 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2250 if (HwDeviceExtension->jChipType == XG21)
2252 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2257 /* --------------------------------------------------------------------- */
2258 /* Function : XGI_SetCRT1ModeRegs */
2262 /* --------------------------------------------------------------------- */
2263 void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
2264 unsigned short ModeNo, unsigned short ModeIdIndex,
2265 unsigned short RefreshRateTableIndex,
2266 struct vb_device_info *pVBInfo)
2268 unsigned short data ,
2276 if ( ModeNo > 0x13 )
2278 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2279 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2282 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2284 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2285 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2287 if ( ModeNo > 0x13 )
2294 if ( ModeNo > 0x13 )
2296 if ( pVBInfo->ModeType > 0x02 )
2299 data3 = pVBInfo->ModeType - ModeVGA ;
2300 data3 = data3 << 2 ;
2305 data &= InterlaceMode ;
2310 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2311 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2312 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2313 if ( ModeNo <= 0x13 )
2314 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2316 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2319 if ( infoflag & InterlaceMode )
2323 else if ( xres == 1280 )
2327 data2 = data & 0x00FF ;
2328 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2329 data2 = ( data & 0xFF00 ) >> 8 ;
2330 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2332 if( modeflag & HalfDCLK )
2333 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2337 if ( modeflag & LineCompareOff )
2340 if ( ModeNo > 0x13 )
2342 if ( pVBInfo->ModeType == ModeEGA )
2346 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2348 if ( pVBInfo->ModeType != ModeText )
2350 data = data ^ 0x60 ;
2351 if ( pVBInfo->ModeType != ModeEGA )
2353 data = data ^ 0xA0 ;
2356 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2358 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2360 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2361 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2362 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2364 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2366 if (HwDeviceExtension->jChipType == XG27 )
2372 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2373 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2376 if (HwDeviceExtension->jChipType >= XG20 )
2382 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2383 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2391 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2397 /* --------------------------------------------------------------------- */
2398 /* Function : XGI_SetVCLKState */
2402 /* --------------------------------------------------------------------- */
2403 void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
2404 unsigned short ModeNo,
2405 unsigned short RefreshRateTableIndex,
2406 struct vb_device_info *pVBInfo)
2408 unsigned short data ,
2412 unsigned char index;
2414 if ( ModeNo <= 0x13 )
2418 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2419 index &= IndexMask ;
2420 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2423 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2426 data |= 0x0c ; /* VCLK > 200 */
2428 if ( HwDeviceExtension->jChipType >= XG20 )
2429 data &= ~0x04 ; /* 2 pixel mode */
2431 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2433 if ( HwDeviceExtension->jChipType < XG20 )
2435 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2439 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2442 /* Jong for Adavantech LCD ripple issue
2443 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2445 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2447 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2449 else if ( VCLK > 260 )
2454 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2455 if (HwDeviceExtension->jChipType >= XG27 )
2457 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2464 /* --------------------------------------------------------------------- */
2465 /* Function : XGI_VesaLowResolution */
2469 /* --------------------------------------------------------------------- */
2470 /*void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2472 unsigned short modeflag;
2474 if ( ModeNo > 0x13 )
2475 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2477 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2479 if ( ModeNo > 0x13 )
2481 if ( modeflag & DoubleScanMode )
2483 if ( modeflag & HalfDCLK )
2485 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2487 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2489 if ( pVBInfo->VBInfo & SetInSlaveMode )
2491 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2492 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2497 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2498 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2503 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2507 /* --------------------------------------------------------------------- */
2508 /* Function : XGI_LoadDAC */
2512 /* --------------------------------------------------------------------- */
2513 void XGI_LoadDAC(unsigned short ModeNo,
2514 unsigned short ModeIdIndex,
2515 struct vb_device_info *pVBInfo)
2517 unsigned short data , data2 , time ,
2518 i , j , k , m , n , o ,
2519 si , di , bx , dl , al , ah , dh ,
2522 if ( ModeNo <= 0x13 )
2523 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2525 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2527 data &= DACInfoFlag ;
2531 table = XGINew_MDA_DAC ;
2532 else if ( data == 0x08 )
2533 table = XGINew_CGA_DAC ;
2534 else if ( data == 0x10 )
2535 table = XGINew_EGA_DAC ;
2536 else if ( data == 0x18 )
2539 table = XGINew_VGA_DAC ;
2547 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2548 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2550 for( i = 0 ; i < j ; i++ )
2554 for( k = 0 ; k < 3 ; k++ )
2564 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2571 for( i = 16 ; i < 32 ; i++ )
2575 for( k = 0 ; k < 3 ; k++ )
2576 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2581 for( m = 0 ; m < 9 ; m++ )
2587 for( n = 0 ; n < 3 ; n++ )
2589 for( o = 0 ; o < 5 ; o++ )
2595 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2600 for( o = 0 ; o < 3 ; o++ )
2606 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2618 /* --------------------------------------------------------------------- */
2619 /* Function : XGI_WriteDAC */
2623 /* --------------------------------------------------------------------- */
2624 void XGI_WriteDAC(unsigned short dl, unsigned short ah,
2625 unsigned short al, unsigned short dh,
2626 struct vb_device_info *pVBInfo)
2628 unsigned short temp , bh , bl ;
2651 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)dh);
2652 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)bh);
2653 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)bl);
2656 /* --------------------------------------------------------------------- */
2657 /* Function : XGI_SetLCDAGroup */
2661 /* --------------------------------------------------------------------- */
2662 void XGI_SetLCDAGroup(unsigned short ModeNo,
2663 unsigned short ModeIdIndex,
2664 struct xgi_hw_device_info *HwDeviceExtension,
2665 struct vb_device_info *pVBInfo)
2667 unsigned short RefreshRateTableIndex ;
2668 /* unsigned short temp ; */
2670 /* pVBInfo->SelectCRT2Rate = 0 ; */
2672 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2673 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2674 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2675 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2676 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2677 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2678 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2682 /* --------------------------------------------------------------------- */
2683 /* Function : XGI_GetLVDSResInfo */
2687 /* --------------------------------------------------------------------- */
2688 void XGI_GetLVDSResInfo(unsigned short ModeNo,
2689 unsigned short ModeIdIndex,
2690 struct vb_device_info *pVBInfo)
2692 unsigned short resindex , xres , yres , modeflag ;
2694 if ( ModeNo <= 0x13 )
2696 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2700 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2704 /* if ( ModeNo > 0x13 ) */
2705 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2707 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2709 if ( ModeNo <= 0x13 )
2711 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2715 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2718 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2720 if ( ModeNo <= 0x13 )
2722 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2723 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2727 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2728 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2730 if ( ModeNo > 0x13 )
2732 if ( modeflag & HalfDCLK )
2735 if ( modeflag & DoubleScanMode )
2738 /* if ( modeflag & Charx8Dot ) */
2745 pVBInfo->VGAHDE = xres ;
2746 pVBInfo->HDE = xres ;
2747 pVBInfo->VGAVDE = yres ;
2748 pVBInfo->VDE = yres ;
2752 /* --------------------------------------------------------------------- */
2753 /* Function : XGI_GetLVDSData */
2757 /* --------------------------------------------------------------------- */
2758 void XGI_GetLVDSData(unsigned short ModeNo,
2759 unsigned short ModeIdIndex,
2760 unsigned short RefreshRateTableIndex,
2761 struct vb_device_info *pVBInfo)
2763 unsigned short tempbx ;
2764 struct XGI330_LVDSDataStruct *LCDPtr = NULL ;
2765 struct XGI330_CHTVDataStruct *TVPtr = NULL ;
2769 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2771 LCDPtr = (struct XGI330_LVDSDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2772 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2773 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2774 pVBInfo->HT = LCDPtr->LCDHT ;
2775 pVBInfo->VT = LCDPtr->LCDVT ;
2777 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2779 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2781 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2782 pVBInfo->VGAHT = TVPtr->VGAHT ;
2783 pVBInfo->VGAVT = TVPtr->VGAVT ;
2784 pVBInfo->HT = TVPtr->LCDHT ;
2785 pVBInfo->VT = TVPtr->LCDVT ;
2789 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2791 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2793 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2795 pVBInfo->HDE = 1024 ;
2796 pVBInfo->VDE = 768 ;
2798 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2800 pVBInfo->HDE = 1280 ;
2801 pVBInfo->VDE = 1024 ;
2803 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2805 pVBInfo->HDE = 1400 ;
2806 pVBInfo->VDE = 1050 ;
2810 pVBInfo->HDE = 1600 ;
2811 pVBInfo->VDE = 1200 ;
2818 /* --------------------------------------------------------------------- */
2819 /* Function : XGI_ModCRT1Regs */
2823 /* --------------------------------------------------------------------- */
2824 void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2825 unsigned short RefreshRateTableIndex,
2826 struct xgi_hw_device_info *HwDeviceExtension,
2827 struct vb_device_info *pVBInfo)
2829 unsigned char index;
2830 unsigned short tempbx , i ;
2831 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2832 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2833 /* struct XGI330_CHTVDataStruct *TVPtr = NULL ; */
2834 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2835 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2837 if( ModeNo <= 0x13 )
2838 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2840 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2842 index= index & IndexMask ;
2844 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2848 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2850 LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2852 for( i = 0 ; i < 8 ; i++ )
2853 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2856 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2858 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2860 CH7007TV_TimingHPtr = (struct XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2862 for( i = 0 ; i < 8 ; i++ )
2863 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2867 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2869 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2870 TVPtr = ( struct XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2873 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2875 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2877 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2878 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2883 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2885 LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2886 for( i = 0 ; i < 7 ; i++ )
2887 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2890 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2892 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2894 CH7007TV_TimingVPtr = (struct XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2896 for( i = 0 ; i < 7 ; i++ )
2897 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2900 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2902 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2903 TVPtr = ( struct XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2906 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2908 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2910 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2911 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2912 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2920 /* --------------------------------------------------------------------- */
2921 /* Function : XGI_SetLVDSRegs */
2925 /* --------------------------------------------------------------------- */
2926 void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2927 unsigned short RefreshRateTableIndex,
2928 struct vb_device_info *pVBInfo)
2930 unsigned short tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
2931 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2932 struct XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2933 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2935 if ( ModeNo > 0x13 )
2936 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2938 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2940 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2942 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2944 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2947 LCDPtr = (struct XGI330_LCDDataDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2950 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2953 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2954 LCDPtr1 = (struct XGI330_LCDDataDesStruct2 *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2956 LCDPtr = (struct XGI330_LCDDataDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2959 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
2964 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2969 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2974 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2985 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
2987 pVBInfo->HDE=tempax;
2988 pVBInfo->VDE=tempbx;
2989 pVBInfo->VGAHDE=tempax;
2990 pVBInfo->VGAVDE=tempbx;
2993 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
2995 tempax=pVBInfo->HDE;
2996 tempbx=pVBInfo->VDE;
2999 tempax = pVBInfo->HT ;
3001 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3002 tempbx = LCDPtr1->LCDHDES ;
3004 tempbx = LCDPtr->LCDHDES ;
3006 tempcx = pVBInfo->HDE ;
3007 tempbx = tempbx & 0x0fff ;
3010 if ( tempcx >= tempax )
3013 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
3015 tempcx = tempcx >> 3 ;
3016 tempbx = tempbx >> 3 ;
3018 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, (unsigned short)(tempbx & 0xff));
3019 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, (unsigned short)(tempcx & 0xff));
3021 tempax = pVBInfo->HT ;
3023 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3024 tempbx = LCDPtr1->LCDHRS ;
3026 tempbx = LCDPtr->LCDHRS ;
3030 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3031 tempcx = LCDPtr1->LCDHSync ;
3035 if ( tempcx >= tempax )
3038 tempax = tempbx & 0x07 ;
3039 tempax = tempax >> 5 ;
3040 tempcx = tempcx >> 3 ;
3041 tempbx = tempbx >> 3 ;
3046 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
3047 XGINew_SetReg1(pVBInfo->Part1Port, 0x14, (unsigned short)(tempbx & 0xff));
3049 tempax = pVBInfo->VT ;
3050 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3051 tempbx = LCDPtr1->LCDVDES ;
3053 tempbx = LCDPtr->LCDVDES ;
3054 tempcx = pVBInfo->VDE ;
3056 tempbx = tempbx & 0x0fff ;
3058 if ( tempcx >= tempax )
3061 XGINew_SetReg1(pVBInfo->Part1Port, 0x1b, (unsigned short)(tempbx & 0xff));
3062 XGINew_SetReg1(pVBInfo->Part1Port, 0x1c, (unsigned short)(tempcx & 0xff));
3064 tempbx = ( tempbx >> 8 ) & 0x07 ;
3065 tempcx = ( tempcx >> 8 ) & 0x07 ;
3067 XGINew_SetReg1(pVBInfo->Part1Port, 0x1d, (unsigned short)((tempcx << 3) | tempbx));
3069 tempax = pVBInfo->VT ;
3070 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3071 tempbx = LCDPtr1->LCDVRS ;
3073 tempbx = LCDPtr->LCDVRS ;
3075 /* tempbx = tempbx >> 4 ; */
3078 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3079 tempcx = LCDPtr1->LCDVSync ;
3082 if ( tempcx >= tempax )
3085 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, (unsigned short)(tempbx & 0xff));
3086 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f, (unsigned short)(tempcx & 0x0f));
3088 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3090 tempbx = pVBInfo->VGAVDE ;
3091 if ( tempbx != pVBInfo->VDE )
3094 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3097 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3099 tempcx = pVBInfo->VGAVT ;
3100 tempbx = pVBInfo->VDE ;
3101 tempax = pVBInfo->VGAVDE ;
3104 temp = tempax ; /* 0430 ylshieh */
3105 temp1 = ( temp << 18 ) / tempbx ;
3107 tempdx = (unsigned short)((temp << 18) % tempbx);
3115 XGINew_SetReg1(pVBInfo->Part1Port, 0x37, (unsigned short)(temp2 & 0xff));
3116 XGINew_SetReg1(pVBInfo->Part1Port, 0x36, (unsigned short)((temp2 >> 8) & 0xff));
3118 tempbx = (unsigned short)(temp2 >> 16);
3119 tempax = tempbx & 0x03 ;
3121 tempbx = pVBInfo->VGAVDE ;
3122 if ( tempbx == pVBInfo->VDE )
3125 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3127 if ( pVBInfo->VBType & VB_XGI301C )
3130 XGINew_SetReg1(pVBInfo->Part4Port, 0x3c, (unsigned short)(temp2 & 0xff));
3131 XGINew_SetReg1(pVBInfo->Part4Port, 0x3b, (unsigned short)((temp2 >> 8) & 0xff));
3132 tempbx = (unsigned short)(temp2 >> 16);
3133 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x3a, ~0xc0, (unsigned short)((tempbx & 0xff) << 6));
3135 tempcx = pVBInfo->VGAVDE ;
3136 if ( tempcx == pVBInfo->VDE )
3137 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3139 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3142 tempcx = pVBInfo->VGAHDE ;
3143 tempbx = pVBInfo->HDE ;
3145 temp1 = tempcx << 16 ;
3147 tempax = (unsigned short)(temp1 / tempbx);
3149 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3153 temp1 = pVBInfo->VGAHDE << 16 ;
3156 temp3 = temp3 << 16 ;
3159 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3161 tempax = (unsigned short)(temp3 & 0xff);
3162 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3164 temp1 = pVBInfo->VGAVDE << 18 ;
3165 temp1 = temp1 / push3 ;
3166 tempbx = (unsigned short)(temp1 & 0xffff);
3168 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3171 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
3172 tempax |= (unsigned short)((temp3 >> 8) & 0x07);
3173 XGINew_SetReg1(pVBInfo->Part1Port, 0x20, (unsigned short)(tempax & 0xff));
3174 XGINew_SetReg1(pVBInfo->Part1Port, 0x21, (unsigned short)(tempbx & 0xff));
3176 temp3 = temp3 >> 16 ;
3178 if ( modeflag & HalfDCLK )
3179 temp3 = temp3 >> 1 ;
3181 XGINew_SetReg1(pVBInfo->Part1Port , 0x22, (unsigned short)((temp3 >> 8) & 0xff));
3182 XGINew_SetReg1(pVBInfo->Part1Port , 0x23, (unsigned short)(temp3 & 0xff));
3188 /* --------------------------------------------------------------------- */
3189 /* Function : XGI_SetCRT2ECLK */
3193 /* --------------------------------------------------------------------- */
3194 void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
3196 unsigned char di_0, di_1, tempal;
3199 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3200 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3201 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3203 for( i = 0 ; i < 4 ; i++ )
3205 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, ~0x30, (unsigned short)(0x10 * i));
3206 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3208 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3209 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3211 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3213 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3214 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3218 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3219 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3225 /* --------------------------------------------------------------------- */
3226 /* Function : XGI_UpdateModeInfo */
3230 /* --------------------------------------------------------------------- */
3231 void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
3233 unsigned short tempcl ,
3239 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3243 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3245 if ( !( temp & 0x20 ) )
3247 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3250 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3251 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3253 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3255 if ( !( temp & 0x40 ) )
3256 tempcl |= ActiveCRT1 ;
3260 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3263 if ( !( temp == 0x08 ) )
3265 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3266 if ( tempax & 0x04 )
3267 tempcl = tempcl | ActiveLCD ;
3271 if ( !( tempcl & ActiveLCD ) )
3273 tempcl |= ActiveCRT2 ;
3276 tempcl |= ActiveLCD ;
3280 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3282 if( !( temp & 0x08 ) )
3283 tempch |= ActiveAVideo ;
3285 if ( !( temp & 0x04 ) )
3286 tempch |= ActiveSVideo ;
3289 tempch |= ActiveSCART ;
3291 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3294 tempch |= ActiveHiTV ;
3297 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3299 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3302 tempch |= ActiveYPbPr ;
3306 tempcl |= ActiveTV ;
3310 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3311 if ( tempcl & ActiveLCD )
3313 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3315 if ( temp & ActiveTV )
3316 tempcl |= ActiveTV ;
3320 tempbl = ~ModeSwitchStatus ;
3321 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3323 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3324 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3333 /* --------------------------------------------------------------------- */
3334 /* Function : XGI_GetVGAType */
3338 /* --------------------------------------------------------------------- */
3339 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
3342 if ( HwDeviceExtension->jChipType >= XG20 )
3344 pVBInfo->Set_VGAType = XG20;
3346 else if ( HwDeviceExtension->jChipType >= XG40 )
3348 pVBInfo->Set_VGAType = VGA_XGI340 ;
3351 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3355 /* --------------------------------------------------------------------- */
3356 /* Function : XGI_GetVBType */
3360 /* --------------------------------------------------------------------- */
3361 void XGI_GetVBType(struct vb_device_info *pVBInfo)
3363 unsigned short flag , tempbx , tempah ;
3365 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3367 pVBInfo->VBType = VB_CH7007 ;
3370 if ( pVBInfo->IF_DEF_LVDS == 0 )
3372 tempbx = VB_XGI302B ;
3373 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3376 tempbx = VB_XGI301 ;
3377 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3380 tempbx = VB_XGI301B ;
3383 tempbx = VB_XGI301C ;
3386 tempbx = VB_XGI301LV ;
3389 tempbx = VB_XGI302LV ;
3390 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3391 if ( tempah != 0xFF )
3392 tempbx = VB_XGI301C ;
3397 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3399 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3401 if ( !( flag & 0x02 ) )
3402 tempbx = tempbx | VB_NoLCD ;
3406 pVBInfo->VBType = tempbx ;
3409 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3410 pVBInfo->VBType = VB_CH7017 ;
3412 pVBInfo->VBType = VB_LVDS_NS ;
3418 /* --------------------------------------------------------------------- */
3419 /* Function : XGI_GetVBInfo */
3423 /* --------------------------------------------------------------------- */
3424 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
3426 unsigned short tempax ,
3432 if ( ModeNo <= 0x13 )
3434 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3438 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3441 pVBInfo->SetFlag = 0 ;
3442 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3445 if ( pVBInfo->VBType & 0xFFFF )
3447 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3448 tempbx = tempbx | temp ;
3449 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3452 tempax = temp << 8 ;
3453 tempbx = tempbx | tempax ;
3454 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3455 temp = 0xFFFF ^ temp ;
3458 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3460 if ( pVBInfo->IF_DEF_LCDA == 1 )
3463 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3465 if ( pVBInfo->IF_DEF_LVDS == 0 )
3467 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3468 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3470 if ( temp & EnableDualEdge )
3472 tempbx |= SetCRT2ToDualEdge ;
3474 if ( temp & SetToLCDA )
3475 tempbx |= SetCRT2ToLCDA ;
3479 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3481 if ( pVBInfo->VBType & VB_CH7017 )
3483 if ( temp & EnableDualEdge )
3485 tempbx |= SetCRT2ToDualEdge ;
3487 if ( temp & SetToLCDA )
3488 tempbx |= SetCRT2ToLCDA ;
3495 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3497 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3498 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3500 if ( temp & SetYPbPr ) /* temp = CR38 */
3502 if ( pVBInfo->IF_DEF_HiVision == 1 )
3504 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3506 tempbx |= SetCRT2ToHiVisionTV ;
3508 if ( temp != YPbPrMode1080i ) {
3509 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3510 tempbx |= SetCRT2ToYPbPr ; }
3513 /* tempbx |= SetCRT2ToYPbPr ; */
3518 tempax = push ; /* restore CR31 */
3520 if ( pVBInfo->IF_DEF_LVDS == 0 )
3522 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3524 if ( pVBInfo->IF_DEF_HiVision == 1 )
3531 if ( pVBInfo->IF_DEF_HiVision == 1 )
3537 else /* 3nd party chip */
3539 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3540 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3541 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3543 temp = SetCRT2ToTV ;
3546 temp = SetCRT2ToLCD ;
3549 if ( !( tempbx & temp ) )
3551 tempax |= DisableCRT2Display ;
3555 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3557 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3559 if ( tempbx & SetCRT2ToLCDA )
3561 if ( tempbx & SetSimuScanMode )
3562 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3564 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3570 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3572 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3574 if ( tempbx & SetCRT2ToRAMDAC )
3576 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3577 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3581 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3584 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3586 if ( tempbx & SetCRT2ToLCD )
3588 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3589 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3593 if ( tempbx & SetCRT2ToSCART )
3595 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3596 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3599 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3601 if ( tempbx & SetCRT2ToYPbPr )
3602 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3605 if ( pVBInfo->IF_DEF_HiVision == 1 )
3607 if ( tempbx & SetCRT2ToHiVisionTV )
3608 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3611 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3613 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3614 tempbx = DisableCRT2Display ;
3617 if ( !( tempbx & DisableCRT2Display ) )
3619 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3621 if ( pVBInfo->IF_DEF_LCDA == 1 )
3623 if ( !( tempbx & SetCRT2ToLCDA ) )
3624 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3627 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3629 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3630 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3631 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3632 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3636 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3638 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3639 pVBInfo->SetFlag |= EnableVCMode ;
3646 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3647 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3649 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3650 pVBInfo->SetFlag |= ReserveTVOption ;
3655 pVBInfo->VBInfo = tempbx ;
3659 /* --------------------------------------------------------------------- */
3660 /* Function : XGI_GetTVInfo */
3664 /* --------------------------------------------------------------------- */
3665 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
3667 unsigned short temp ,
3676 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3678 if ( ModeNo <= 0x13 )
3680 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3681 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3685 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3686 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3689 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3691 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3693 if ( tempbx & SetPALTV )
3695 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3696 if ( tempbx & SetPALMTV )
3697 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3700 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3702 if ( pVBInfo->IF_DEF_LVDS == 0 )
3704 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3705 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3707 if ( temp2 & 0x02 ) //PAL-M
3708 tempbx &= ( ~SetPALTV ) ;
3713 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3715 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3717 if ( tempbx & TVOverScan )
3718 tempbx |= SetCHTVOverScan ;
3721 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3723 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3725 if ( tempbx & TVOverScan )
3727 tempbx |= SetCHTVOverScan ;
3732 if ( pVBInfo->IF_DEF_LVDS == 0 )
3734 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3735 tempbx |= SetPALTV ;
3738 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3740 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3742 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3743 index1 &= YPbPrMode ;
3745 if ( index1 == YPbPrMode525i )
3746 tempbx |= SetYPbPrMode525i ;
3748 if ( index1 == YPbPrMode525p )
3749 tempbx = tempbx | SetYPbPrMode525p;
3750 if ( index1 == YPbPrMode750p)
3751 tempbx = tempbx | SetYPbPrMode750p;
3755 if ( pVBInfo->IF_DEF_HiVision == 1 )
3757 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3759 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3763 if ( pVBInfo->IF_DEF_LVDS == 0 )
3765 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3766 tempbx |= TVSimuMode ;
3768 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3769 tempbx |= NTSC1024x768 ;
3771 tempbx |= RPLLDIV2XO ;
3773 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3775 if ( pVBInfo->VBInfo & SetInSlaveMode )
3776 tempbx &=( ~RPLLDIV2XO ) ;
3780 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3781 tempbx &= ( ~RPLLDIV2XO ) ;
3782 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3784 if ( tempbx & TVSimuMode )
3785 tempbx &= ( ~RPLLDIV2XO ) ;
3790 pVBInfo->TVInfo = tempbx ;
3794 /* --------------------------------------------------------------------- */
3795 /* Function : XGI_GetLCDInfo */
3799 /* --------------------------------------------------------------------- */
3800 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3801 struct vb_device_info *pVBInfo)
3803 unsigned short temp ,
3810 pVBInfo->LCDResInfo = 0 ;
3811 pVBInfo->LCDTypeInfo = 0 ;
3812 pVBInfo->LCDInfo = 0 ;
3814 if ( ModeNo <= 0x13 )
3816 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3820 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3821 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3824 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3825 tempbx = temp & 0x0F ;
3828 tempbx = Panel1024x768 ; /* default */
3830 /* LCD75 [2003/8/22] Vicent */
3831 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3833 if ( pVBInfo->VBInfo & DriverMode )
3835 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3836 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3839 tempax = tempax >> 4 ;
3841 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3844 tempbx |= PanelRef75Hz ;
3846 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3849 tempbx |= PanelRef75Hz ;
3854 pVBInfo->LCDResInfo = tempbx ;
3858 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3860 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3863 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3870 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3872 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3874 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3875 temp &= ~EnableScalingLCD ;
3879 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3881 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3883 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3885 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3887 tempbx |= SetLCDDualLink ;
3891 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3893 if ( tempax & LCDDualLink )
3895 tempbx |= SetLCDDualLink ;
3899 if ( pVBInfo->IF_DEF_LVDS == 0 )
3901 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3902 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3906 if ( tempax & LCDBToA )
3908 tempbx |= SetLCDBToA ;
3912 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3914 if ( modeflag & HalfDCLK )
3916 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3917 if ( !( tempbx & SetLCDtoNonExpanding ) )
3919 tempbx |= EnableLVDSDDA ;
3923 if ( ModeNo > 0x13 )
3925 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3929 tempbx |= EnableLVDSDDA ;
3937 if ( pVBInfo->VBInfo & SetInSlaveMode )
3939 if ( pVBInfo->VBInfo & SetNotSimuMode )
3941 tempbx |= LCDVESATiming ;
3946 tempbx |= LCDVESATiming ;
3949 pVBInfo->LCDInfo = tempbx ;
3951 if ( pVBInfo->IF_DEF_PWD == 1 )
3953 if ( pVBInfo->LCDInfo & SetPWDEnable )
3955 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3957 if ( !( tempax & PWDEnable ) )
3959 pVBInfo->LCDInfo &= ~SetPWDEnable ;
3965 if ( pVBInfo->IF_DEF_LVDS == 0 )
3967 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3969 if ( pVBInfo->VBInfo & SetInSlaveMode )
3971 if ( !( tempax & LockLCDBToA ) )
3973 if ( ModeNo <= 0x13 )
3975 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
3976 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
3984 if ( pVBInfo->IF_DEF_LVDS == 0 )
3986 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3988 if ( pVBInfo->VBInfo & SetInSlaveMode )
3990 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
3992 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3993 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
4004 /* --------------------------------------------------------------------- */
4005 /* Function : XGI_SearchModeID */
4009 /* --------------------------------------------------------------------- */
4010 unsigned char XGI_SearchModeID(unsigned short ModeNo,
4011 unsigned short *ModeIdIndex,
4012 struct vb_device_info *pVBInfo)
4017 #ifdef LINUX /* chiawen for linux solution */
4021 if ( ModeNo <= 0x13 )
4023 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(struct XGI_StStruct);(*ModeIdIndex)++) */
4024 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4026 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
4028 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
4032 if ( ModeNo == 0x07 )
4033 ( *ModeIdIndex )++ ; /* 400 lines */
4036 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4037 /* else 350 lines */
4041 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(struct XGI_ExtStruct);(*ModeIdIndex)++) */
4042 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4044 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
4046 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
4059 /* win2000 MM adapter not support standard mode! */
4061 /* --------------------------------------------------------------------- */
4066 /* --------------------------------------------------------------------- */
4067 unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtension,
4068 unsigned short ModeNo,
4069 unsigned short ModeIdIndex,
4070 struct vb_device_info *pVBInfo)
4072 unsigned short memorysize ,
4078 /* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4079 ( HwDeviceExtension->jChipType == XGI_650M ) )
4084 if ( ModeNo <= 0x13 )
4086 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4089 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4092 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4094 memorysize = modeflag & MemoryInfoFlag ;
4095 memorysize = memorysize > MemorySizeShift ;
4096 memorysize++ ; /* Get memory size */
4098 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4101 if ( HwDeviceExtension->jChipType == XG40 )
4103 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4104 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4108 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4113 else if ( HwDeviceExtension->jChipType == XG42 )
4115 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4116 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4121 else if ( HwDeviceExtension->jChipType == XG45 )
4123 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4124 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4128 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4134 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4139 if (temp < memorysize)
4146 /* --------------------------------------------------------------------- */
4147 /* Function : XGINew_IsLowResolution */
4151 /* --------------------------------------------------------------------- */
4152 /*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)
4154 unsigned short data ;
4155 unsigned short ModeFlag ;
4157 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4159 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4161 if ( ModeNo > 0x13 )
4163 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4164 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4166 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4168 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4169 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4171 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4178 /* --------------------------------------------------------------------- */
4179 /* Function : XGI_DisplayOn */
4183 /* --------------------------------------------------------------------- */
4184 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, struct vb_device_info *pVBInfo)
4187 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4188 if ( pXGIHWDE->jChipType == XG21 )
4190 if ( pVBInfo->IF_DEF_LVDS == 1 )
4192 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4194 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4195 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4197 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4199 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4201 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4202 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4206 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4211 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4217 if ( pXGIHWDE->jChipType == XG27 )
4219 if ( pVBInfo->IF_DEF_LVDS == 1 )
4221 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4223 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4224 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4226 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4228 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4230 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4231 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4235 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4242 /* --------------------------------------------------------------------- */
4243 /* Function : XGI_DisplayOff */
4247 /* --------------------------------------------------------------------- */
4248 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, struct vb_device_info *pVBInfo)
4251 if ( pXGIHWDE->jChipType == XG21 )
4253 if ( pVBInfo->IF_DEF_LVDS == 1 )
4255 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4256 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4260 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4264 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4266 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4272 if ( pXGIHWDE->jChipType == XG27 )
4274 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4276 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4277 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4280 if ( pVBInfo->IF_DEF_LVDS == 0 )
4282 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4286 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4290 /* --------------------------------------------------------------------- */
4291 /* Function : XGI_WaitDisply */
4294 /* Description : chiawen for sensecrt1 */
4295 /* --------------------------------------------------------------------- */
4296 void XGI_WaitDisply(struct vb_device_info *pVBInfo)
4298 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4301 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4305 /* --------------------------------------------------------------------- */
4306 /* Function : XGI_SenseCRT1 */
4310 /* --------------------------------------------------------------------- */
4312 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
4314 unsigned char CRTCData[17] = {
4315 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4316 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4317 0x04 , 0x00 , 0x00 , 0x05 , 0x00 };
4319 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
4321 unsigned char CR17, CR63, SR31;
4322 unsigned short temp ;
4323 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F } ;
4326 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4328 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4329 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4330 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char)(XGINew_GetReg1(pVBInfo->P3d4, 0x53) | 0x02));
4332 SR31 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x31);
4333 CR63 = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x63);
4334 SR01 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x01);
4336 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char)(SR01 & 0xDF));
4337 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char)(CR63 & 0xBF));
4339 CR17 = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x17);
4340 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char)(CR17 | 0x80)) ;
4342 SR1F = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
4343 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char)(SR1F | 0x04));
4345 SR07 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x07);
4346 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char)(SR07 & 0xFB));
4347 SR06 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x06);
4348 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char)(SR06 & 0xC3));
4350 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4352 for( i = 0 ; i < 8 ; i++ )
4353 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)i, CRTCData[i]);
4355 for( i = 8 ; i < 11 ; i++ )
4356 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 8), CRTCData[i]);
4358 for( i = 11 ; i < 13 ; i++ )
4359 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 4), CRTCData[i]);
4361 for( i = 13 ; i < 16 ; i++ )
4362 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short)(i - 3), CRTCData[i]);
4364 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char)(CRTCData[16] & 0xE0));
4366 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4367 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4368 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4370 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4372 for( i = 0 ; i < 256 ; i++ )
4374 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[0]);
4375 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[1]);
4376 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[2]);
4379 XGI_VBLongWait( pVBInfo ) ;
4380 XGI_VBLongWait( pVBInfo ) ;
4381 XGI_VBLongWait( pVBInfo ) ;
4383 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4385 XGI_WaitDisply( pVBInfo ) ;
4386 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4390 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4394 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4397 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4398 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4400 for( i = 0 ; i < 256 ; i++ )
4402 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4403 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4404 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4407 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4408 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4409 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4411 /* [2004/05/11] Vicent */
4412 XGINew_SetReg1(pVBInfo->P3d4, 0x53,
4413 (unsigned char)(XGINew_GetReg1(pVBInfo->P3d4, 0x53) & 0xFD));
4414 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char)SR1F);
4426 /* --------------------------------------------------------------------- */
4427 /* Function : XGI_WaitDisplay */
4431 /* --------------------------------------------------------------------- */
4432 void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4434 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4436 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4442 /* --------------------------------------------------------------------- */
4443 /* Function : XGI_SetCRT2Group301 */
4447 /* --------------------------------------------------------------------- */
4448 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
4449 struct xgi_hw_device_info *HwDeviceExtension,
4450 struct vb_device_info *pVBInfo)
4452 unsigned short tempbx ,
4454 RefreshRateTableIndex ;
4456 tempbx=pVBInfo->VBInfo ;
4457 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4458 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4459 pVBInfo->SelectCRT2Rate = 4 ;
4460 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4461 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4462 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4463 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4464 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4465 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4466 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4467 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4468 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4469 XGI_SetTap4Regs(pVBInfo) ;
4470 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4471 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4472 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4473 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4474 XGI_AutoThreshold( pVBInfo) ;
4479 /* --------------------------------------------------------------------- */
4480 /* Function : XGI_AutoThreshold */
4484 /* --------------------------------------------------------------------- */
4485 void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4487 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4488 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4492 /* --------------------------------------------------------------------- */
4493 /* Function : XGI_SaveCRT2Info */
4497 /* --------------------------------------------------------------------- */
4498 void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
4500 unsigned short temp1 ,
4503 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4504 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4505 temp2 = ~( SetInSlaveMode >> 8 ) ;
4506 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4510 /* --------------------------------------------------------------------- */
4511 /* Function : XGI_GetCRT2ResInfo */
4515 /* --------------------------------------------------------------------- */
4516 void XGI_GetCRT2ResInfo(unsigned short ModeNo,
4517 unsigned short ModeIdIndex,
4518 struct vb_device_info *pVBInfo)
4520 unsigned short xres ,
4525 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4526 if ( ModeNo <= 0x13 )
4528 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4529 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4530 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4534 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4535 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4536 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4538 /* if ( pVBInfo->IF_DEF_FSTN )
4546 if ( modeflag & HalfDCLK )
4549 if ( modeflag & DoubleScanMode )
4554 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4556 if ( pVBInfo->IF_DEF_LVDS == 0 )
4558 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4560 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4567 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4571 else if ( yres == 350 )
4574 if ( pVBInfo->LCDInfo & LCDVESATiming )
4581 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4583 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4585 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4589 else if ( yres == 400 )
4591 else if ( yres == 480 )
4602 pVBInfo->VGAHDE = xres ;
4603 pVBInfo->HDE = xres ;
4604 pVBInfo->VGAVDE = yres ;
4605 pVBInfo->VDE = yres ;
4609 /* --------------------------------------------------------------------- */
4610 /* Function : XGI_IsLCDDualLink */
4614 /* --------------------------------------------------------------------- */
4615 unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
4618 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4625 /* --------------------------------------------------------------------- */
4626 /* Function : XGI_GetCRT2Data */
4630 /* --------------------------------------------------------------------- */
4631 void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
4633 unsigned short tempax = 0,
4638 struct XGI_LCDDataStruct *LCDPtr = NULL ;
4639 struct XGI_TVDataStruct *TVPtr = NULL ;
4641 if ( ModeNo <= 0x13 )
4643 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4644 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4648 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4649 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4652 pVBInfo->NewFlickerMode = 0 ;
4653 pVBInfo->RVBHRS = 50 ;
4655 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4657 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4663 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4665 LCDPtr = (struct XGI_LCDDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4667 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4668 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4669 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4670 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4671 pVBInfo->HT = LCDPtr->LCDHT ;
4672 pVBInfo->VT = LCDPtr->LCDVT ;
4674 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4679 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4681 if ( pVBInfo->VGAVDE == 357 )
4683 else if ( pVBInfo->VGAVDE == 420 )
4685 else if ( pVBInfo->VGAVDE == 525 )
4687 else if ( pVBInfo->VGAVDE == 600 )
4689 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4690 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4697 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4702 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4705 if ( pVBInfo->VGAVDE == 360 )
4707 else if ( pVBInfo->VGAVDE == 375 )
4709 else if ( pVBInfo->VGAVDE == 405 )
4714 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4719 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4722 if ( pVBInfo->VGAVDE == 350 )
4724 else if ( pVBInfo->VGAVDE == 400 )
4726 else if ( pVBInfo->VGAVDE == 1024 )
4731 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4736 if ( pVBInfo->VGAVDE == 1024 )
4742 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4745 tempbx = 1200 ; /* alan 10/14/2003 */
4746 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4748 if ( pVBInfo->VGAVDE == 350 )
4750 else if ( pVBInfo->VGAVDE == 400 )
4755 if ( pVBInfo->LCDInfo & LCDNonExpanding )
4757 tempax = pVBInfo->VGAHDE ;
4758 tempbx = pVBInfo->VGAVDE ;
4761 pVBInfo->HDE = tempax ;
4762 pVBInfo->VDE = tempbx ;
4766 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
4769 TVPtr = (struct XGI_TVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4771 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
4772 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
4773 pVBInfo->VGAHT = TVPtr->VGAHT ;
4774 pVBInfo->VGAVT = TVPtr->VGAVT ;
4775 pVBInfo->HDE = TVPtr->TVHDE ;
4776 pVBInfo->VDE = TVPtr->TVVDE ;
4777 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
4778 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
4780 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
4782 if ( resinfo == 0x08 )
4783 pVBInfo->NewFlickerMode = 0x40 ;
4784 else if ( resinfo == 0x09 )
4785 pVBInfo->NewFlickerMode = 0x40 ;
4786 else if ( resinfo == 0x12 )
4787 pVBInfo->NewFlickerMode = 0x40 ;
4789 if ( pVBInfo->VGAVDE == 350 )
4790 pVBInfo->TVInfo |= TVSimuMode ;
4792 tempax = ExtHiTVHT ;
4793 tempbx = ExtHiTVVT ;
4795 if ( pVBInfo->VBInfo & SetInSlaveMode )
4797 if ( pVBInfo->TVInfo & TVSimuMode )
4802 if ( !( modeflag & Charx8Dot ) )
4804 tempax = StHiTextTVHT ;
4805 tempbx = StHiTextTVVT ;
4810 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
4812 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4814 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
4815 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
4818 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4820 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
4821 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
4823 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
4825 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
4826 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
4827 if ( pVBInfo->TVInfo & NTSC1024x768 )
4828 tempax = NTSC1024x768HT ;
4835 if ( !( pVBInfo->TVInfo & SetPALTV ) )
4839 if ( pVBInfo->TVInfo & NTSC1024x768 )
4840 tempax = NTSC1024x768HT ;
4844 pVBInfo->HT = tempax ;
4845 pVBInfo->VT = tempbx ;
4851 /* --------------------------------------------------------------------- */
4852 /* Function : XGI_SetCRT2VCLK */
4856 /* --------------------------------------------------------------------- */
4857 void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
4859 unsigned char di_0, di_1, tempal;
4861 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
4862 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
4863 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
4865 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
4867 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
4868 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
4869 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
4872 { /* 301b/302b/301lv/302lv */
4873 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
4874 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
4877 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
4879 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4880 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
4882 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
4886 /* --------------------------------------------------------------------- */
4887 /* Function : XGI_GETLCDVCLKPtr */
4889 /* Output : al -> VCLK Index */
4891 /* --------------------------------------------------------------------- */
4892 void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
4893 struct vb_device_info *pVBInfo)
4895 unsigned short index ;
4897 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4899 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
4901 if ( pVBInfo->LCDInfo & EnableScalingLCD )
4905 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
4906 index = XGI_GetLCDCapPtr1( pVBInfo) ;
4908 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4910 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
4911 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
4915 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
4916 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
4923 /* --------------------------------------------------------------------- */
4924 /* Function : XGI_GetVCLKPtr */
4928 /* --------------------------------------------------------------------- */
4929 unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
4930 unsigned short ModeNo, unsigned short ModeIdIndex,
4931 struct vb_device_info *pVBInfo)
4934 unsigned short index ,
4936 unsigned short tempbx ;
4937 unsigned char tempal;
4938 unsigned char *CHTVVCLKPtr = NULL;
4940 if ( ModeNo <= 0x13 )
4941 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4943 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4946 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
4948 index = XGI_GetLCDCapPtr(pVBInfo) ;
4949 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
4951 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4955 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
4957 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
4959 tempal = HiTVVCLKDIV2;
4960 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
4962 if(pVBInfo->TVInfo & TVSimuMode)
4964 tempal = HiTVSimuVCLK;
4965 if(!(modeflag & Charx8Dot))
4966 tempal = HiTVTextVCLK;
4972 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4974 tempal = YPbPr750pVCLK ;
4978 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4980 tempal = YPbPr525pVCLK ;
4984 tempal = NTSC1024VCLK ;
4986 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
4988 tempal = TVVCLKDIV2 ;
4989 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
4993 if ( pVBInfo->VBInfo & SetCRT2ToTV )
4997 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
5000 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5002 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5003 *tempal = *tempal & 0x1F;
5006 if(pVBInfo->TVInfo & SetPALTV)
5007 tempbx = tempbx + 2;
5008 if(pVBInfo->TVInfo & SetCHTVOverScan)
5010 tempbx = tempbx << 1;
5014 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
5016 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
5017 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
5019 if( ModeNo <= 0x13 )
5021 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5025 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5028 tempal = tempal & 0x0F;
5031 if(pVBInfo->TVInfo & SetPALTV)
5033 tempbx = tempbx + 2;
5035 if(pVBInfo->TVInfo & SetCHTVOverScan)
5039 /** tempbx = tempbx << 1; CH7007 ? **/
5041 /*[Billy]07/05/29 CH7007*/
5042 if ( pVBInfo->IF_DEF_CH7007 == 1 )
5047 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
5050 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5053 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5056 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5068 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5071 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5074 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5077 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5084 tempal = CHTVVCLKPtr[ tempal ] ;
5090 tempal = (unsigned char)XGINew_GetReg2((pVBInfo->P3ca + 0x02));
5091 tempal = tempal >> 2 ;
5094 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5095 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5097 if ( ModeNo <= 0x13 )
5100 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5105 /* --------------------------------------------------------------------- */
5106 /* Function : XGI_GetVCLKLen */
5110 /* --------------------------------------------------------------------- */
5111 void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
5112 unsigned char *di_1, struct vb_device_info *pVBInfo)
5114 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5116 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5117 *di_0 = (unsigned char)XGI_CH7007VCLKData[tempal].SR2B;
5118 *di_1 = (unsigned char)XGI_CH7007VCLKData[tempal].SR2C;
5120 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5122 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5124 *di_0 = (unsigned char)XGI_VBVCLKData[tempal].SR2B;
5125 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5130 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5131 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5136 /* --------------------------------------------------------------------- */
5137 /* Function : XGI_SetCRT2Offset */
5141 /* --------------------------------------------------------------------- */
5142 void XGI_SetCRT2Offset(unsigned short ModeNo,
5143 unsigned short ModeIdIndex,
5144 unsigned short RefreshRateTableIndex,
5145 struct xgi_hw_device_info *HwDeviceExtension,
5146 struct vb_device_info *pVBInfo)
5148 unsigned short offset ;
5151 if ( pVBInfo->VBInfo & SetInSlaveMode )
5156 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5157 temp = (unsigned char)(offset & 0xFF);
5158 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5159 temp = (unsigned char)((offset & 0xFF00) >> 8);
5160 XGINew_SetReg1(pVBInfo->Part1Port , 0x09 , temp);
5161 temp = (unsigned char)(((offset >> 3) & 0xFF) + 1) ;
5162 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
5166 /* --------------------------------------------------------------------- */
5167 /* Function : XGI_GetOffset */
5171 /* --------------------------------------------------------------------- */
5172 unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
5174 unsigned short temp ,
5179 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5181 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5182 if ( ModeNo <= 0x14 )
5185 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5188 index = ( modeinfo >> 8 ) & 0xFF ;
5190 temp = pVBInfo->ScreenOffset[ index ] ;
5192 if ( infoflag & InterlaceMode )
5197 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5199 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5201 temp = ModeNo - 0x7C ;
5202 colordepth = ColorDepth[ temp ] ;
5204 if ( infoflag & InterlaceMode )
5208 return( temp * colordepth ) ;
5211 return( temp * colordepth ) ;
5215 /* --------------------------------------------------------------------- */
5216 /* Function : XGI_SetCRT2FIFO */
5220 /* --------------------------------------------------------------------- */
5221 void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
5223 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5224 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5228 /* --------------------------------------------------------------------- */
5229 /* Function : XGI_PreSetGroup1 */
5233 /* --------------------------------------------------------------------- */
5234 void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
5235 struct xgi_hw_device_info *HwDeviceExtension,
5236 unsigned short RefreshRateTableIndex,
5237 struct vb_device_info *pVBInfo)
5239 unsigned short tempcx = 0 ,
5243 if ( ModeNo > 0x13 )
5245 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5246 CRT1Index &= IndexMask ;
5247 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5250 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5251 XGI_SetCRT2FIFO(pVBInfo) ;
5252 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5254 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5256 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5259 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5260 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5264 /* --------------------------------------------------------------------- */
5265 /* Function : XGI_SetGroup1 */
5269 /* --------------------------------------------------------------------- */
5270 void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
5271 struct xgi_hw_device_info *HwDeviceExtension,
5272 unsigned short RefreshRateTableIndex,
5273 struct vb_device_info *pVBInfo)
5275 unsigned short temp = 0 ,
5284 if ( ModeNo > 0x13 )
5286 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5287 CRT1Index &= IndexMask ;
5288 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5291 if ( ModeNo <= 0x13 )
5293 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5297 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5300 /* bainy change table name */
5301 if ( modeflag & HalfDCLK )
5303 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5304 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5305 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5306 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5307 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5308 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5309 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5310 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5311 tempcx = tempcx >> 1 ;
5312 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5315 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5317 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5318 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5319 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5320 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5322 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5323 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5324 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5330 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5331 tempcx = pVBInfo->VGAHT / 2 ;
5333 temp = tempbx & 0x00FF ;
5335 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5339 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5340 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5341 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5342 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5343 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5344 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5345 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5346 pushbx = pVBInfo->VGAHDE + 16 ;
5347 tempcx = tempcx >> 1 ;
5348 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5351 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5353 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5354 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5355 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5356 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5358 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5359 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5360 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5365 if ( tempcx > pVBInfo->VGAHT )
5366 tempcx = pVBInfo->VGAHT ;
5368 temp = tempbx & 0x00FF ;
5369 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5372 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5374 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5375 tempax |= ( tempbx & 0xFF00 ) ;
5376 temp = ( tempax & 0xFF00 ) >> 8 ;
5377 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5378 temp = tempcx & 0x00FF ;
5379 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5380 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5381 temp = tempcx & 0x00FF ;
5383 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5385 if ( pVBInfo->VBInfo & 0x0C )
5391 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5392 tempbx = pVBInfo->VGAVDE - 1 ;
5393 temp = tempbx & 0x00FF ;
5394 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5395 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5396 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5397 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5399 tempax = pVBInfo->VGAVDE ;
5400 tempbx = pVBInfo->VGAVDE ;
5401 tempcx = pVBInfo->VGAVT ;
5402 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5403 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5405 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5407 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5408 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5416 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5421 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5422 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5425 temp = tempbx & 0x00FF ;
5426 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5427 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5428 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5429 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5432 if ( modeflag & DoubleScanMode )
5435 if ( modeflag & HalfDCLK )
5438 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5442 /* --------------------------------------------------------------------- */
5443 /* Function : XGI_SetLockRegs */
5447 /* --------------------------------------------------------------------- */
5448 void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5449 struct xgi_hw_device_info *HwDeviceExtension,
5450 unsigned short RefreshRateTableIndex,
5451 struct vb_device_info *pVBInfo)
5453 unsigned short push1 ,
5463 if ( ModeNo <= 0x13 )
5465 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5466 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5470 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5471 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5472 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5473 CRT1Index &= IndexMask;
5476 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5481 temp = 0xFF ; /* set MAX HT */
5482 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5483 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5487 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5488 modeflag |= Charx8Dot ;
5490 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5492 if ( modeflag & HalfDCLK )
5493 tempax = tempax >> 1 ;
5495 tempax = ( tempax / tempcx ) - 1 ;
5496 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5497 temp = tempax & 0x00FF ;
5498 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5500 temp = ( tempbx & 0xFF00 ) >> 8 ;
5502 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5504 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5507 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5509 if ( pVBInfo->VBType & VB_XGI301LV )
5511 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5523 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5524 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5526 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5527 { /* 030226 bainy */
5528 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5529 tempax = pVBInfo->VGAHT ;
5531 tempax = XGI_GetVGAHT2( pVBInfo) ;
5534 if ( tempax >= pVBInfo->VGAHT )
5536 tempax = pVBInfo->VGAHT ;
5539 if ( modeflag & HalfDCLK )
5541 tempax = tempax >> 1 ;
5544 tempax = ( tempax / tempcx ) - 5 ;
5545 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5546 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5548 temp = ( tempbx & 0x00FF ) - 1 ;
5549 if ( !( modeflag & HalfDCLK ) )
5552 if ( pVBInfo->TVInfo & TVSimuMode )
5555 if ( ModeNo > 0x13 )
5562 /* tempcx = tempbx & 0x00FF ; */
5563 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5564 tempcx = ( tempcx + tempbx ) >> 1 ;
5565 temp = ( tempcx & 0x00FF ) + 2 ;
5567 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5570 if ( !( modeflag & HalfDCLK ) )
5572 if ( ( modeflag & Charx8Dot ) )
5575 if ( pVBInfo->VGAHDE >= 800 )
5584 if ( !( modeflag & HalfDCLK ) )
5587 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5589 if( pVBInfo->VGAHDE >= 800 )
5592 if ( pVBInfo->ModeType == ModeEGA )
5594 if ( pVBInfo->VGAVDE == 1024 )
5597 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5604 if ( pVBInfo->VGAHDE >= 1280 )
5606 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5608 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5620 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5621 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5623 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5625 if ( pVBInfo->TVInfo & TVSimuMode )
5627 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5629 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5630 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5633 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5635 if ( pVBInfo->TVInfo & SetNTSCTV )
5637 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5638 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5642 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5643 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5644 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5648 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5650 if ( pVBInfo->TVInfo & SetNTSCTV )
5652 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5653 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5657 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5658 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5659 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5663 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5665 if ( pVBInfo->TVInfo & SetNTSCTV )
5667 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5668 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5672 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5673 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5679 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5680 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5681 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5683 tempbx = pVBInfo->VGAVT ;
5686 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5688 if ( tempbx == 357 )
5690 if ( tempbx == 360 )
5692 if ( tempbx == 375 )
5694 if ( tempbx == 405 )
5696 if ( tempbx == 525 )
5701 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5703 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5705 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5707 if ( tempbx == 350 )
5709 if ( tempbx == 480 )
5715 temp = tempbx & 0x00FF ;
5717 temp = tempbx & 0x00FF ;
5718 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5721 temp = tempbx & 0x00FF ;
5722 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5724 if ( tempbx & 0x0100 )
5731 if ( modeflag & DoubleScanMode )
5736 if ( tempbx & 0x0200 )
5741 temp = ( tempax & 0xFF00 ) >> 8 ;
5742 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5744 if ( tempbx & 0x0400 )
5749 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5752 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
5753 tempax = tempax >> 2 ;
5754 push1 = tempax ; /* push ax */
5756 if ( resinfo != 0x09 )
5758 tempax = tempax << 1 ;
5762 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5764 if ( pVBInfo->VBType & VB_XGI301LV )
5766 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
5770 if ( pVBInfo->TVInfo & TVSimuMode )
5772 if ( pVBInfo->TVInfo & SetPALTV )
5774 if ( pVBInfo->VBType & VB_XGI301LV )
5776 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5790 if ( pVBInfo->TVInfo & TVSimuMode )
5792 if ( pVBInfo->TVInfo & SetPALTV )
5794 if ( pVBInfo->VBType & VB_XGI301LV )
5796 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5805 tempax = tempax >> 2 ;
5808 push1 = tempax ; /* push ax */
5810 if ( ( pVBInfo->TVInfo & SetPALTV ) )
5812 if ( tempbx <= 513 )
5814 if ( tempax >= 513 )
5821 temp = tempbx & 0x00FF ;
5822 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5824 temp = tempbx & 0x00FF ;
5825 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5827 if ( tempbx & 0x0100 )
5832 if ( tempbx & 0x0200 )
5834 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
5839 if ( tempbx & 0x0100 )
5844 if ( tempbx & 0x0200 )
5849 if ( tempbx & 0x0400 )
5854 tempbx = push1 ; /* pop ax */
5855 temp = tempbx & 0x00FF ;
5857 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
5859 if ( tempbx & 0x0010 )
5864 temp = tempcx & 0x00FF ;
5865 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
5866 temp = ( tempcx & 0x0FF00 ) >> 8 ;
5867 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
5869 temp = ( tempax & 0xFF00 ) >> 8 ;
5871 temp = ( temp >> 1 ) & 0x09 ;
5873 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5876 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
5877 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
5878 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
5880 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
5885 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
5891 /* --------------------------------------------------------------------- */
5892 /* Function : XGI_SetGroup2 */
5896 /* --------------------------------------------------------------------- */
5897 void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,
5898 struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
5911 unsigned char *TimingPoint ;
5913 unsigned long longtemp ,
5919 if ( ModeNo <= 0x13 )
5921 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5922 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5923 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5927 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5928 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5929 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
5934 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
5937 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
5940 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
5943 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5946 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5949 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
5952 tempax = ( tempax & 0xff00 ) >> 8 ;
5954 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
5955 TimingPoint = pVBInfo->NTSCTiming ;
5957 if ( pVBInfo->TVInfo & SetPALTV )
5959 TimingPoint = pVBInfo->PALTiming ;
5962 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5964 TimingPoint = pVBInfo->HiTVExtTiming ;
5966 if ( pVBInfo->VBInfo & SetInSlaveMode )
5967 TimingPoint = pVBInfo->HiTVSt2Timing ;
5969 if ( pVBInfo->SetFlag & TVSimuMode )
5970 TimingPoint = pVBInfo->HiTVSt1Timing ;
5972 if ( !(modeflag & Charx8Dot) )
5973 TimingPoint = pVBInfo->HiTVTextTiming ;
5976 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5978 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5979 TimingPoint = pVBInfo->YPbPr525iTiming ;
5981 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5982 TimingPoint = pVBInfo->YPbPr525pTiming ;
5984 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5985 TimingPoint = pVBInfo->YPbPr750pTiming ;
5988 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
5990 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
5993 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
5995 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
5998 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6000 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
6003 temp = pVBInfo->NewFlickerMode ;
6005 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
6007 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6010 if ( pVBInfo->TVInfo & SetPALTV )
6015 if ( pVBInfo->VDE <= tempax )
6017 tempax -= pVBInfo->VDE ;
6018 tempax = tempax >> 2 ;
6019 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
6021 temp = ( tempax & 0xFF00 ) >> 8 ;
6022 temp += (unsigned short)TimingPoint[0];
6024 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6026 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
6028 tempcx=pVBInfo->VGAHDE;
6029 if ( tempcx >= 1024 )
6031 temp = 0x17 ; /* NTSC */
6032 if ( pVBInfo->TVInfo & SetPALTV )
6033 temp = 0x19 ; /* PAL */
6038 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6040 temp = ( tempax & 0xFF00 ) >> 8 ;
6041 temp += TimingPoint[ 1 ] ;
6043 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6045 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
6047 tempcx = pVBInfo->VGAHDE ;
6048 if ( tempcx >= 1024 )
6050 temp = 0x1D ; /* NTSC */
6051 if ( pVBInfo->TVInfo & SetPALTV )
6052 temp = 0x52 ; /* PAL */
6056 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
6060 tempcx = pVBInfo->HT ;
6062 if ( XGI_IsLCDDualLink( pVBInfo ) )
6063 tempcx = tempcx >> 1 ;
6066 temp = tempcx & 0x00FF ;
6067 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6069 temp = ( tempcx & 0xFF00 ) >> 8 ;
6070 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6072 tempcx = pVBInfo->HT >> 1 ;
6073 push1 = tempcx ; /* push cx */
6076 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6081 temp = tempcx & 0x00FF ;
6083 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6085 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6088 temp = tempbx & 0x00FF ;
6089 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6090 temp = ( tempbx & 0xFF00 ) >> 8 ;
6092 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6096 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6102 temp = ( tempbx & 0x00FF ) << 4 ;
6103 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6106 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6107 temp = tempcx & 0x00FF ;
6108 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6109 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6110 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6113 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6118 temp = tempcx & 0xFF ;
6120 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6122 tempcx = push1 ; /* pop cx */
6124 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6126 temp = tempcx & 0x00FF ;
6128 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6132 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6134 tempax = XGI_GetVGAHT2( pVBInfo) ;
6135 tempcx = tempax - 1 ;
6137 temp = tempcx & 0x00FF ;
6138 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6140 tempbx = pVBInfo->VDE ;
6142 if ( pVBInfo->VGAVDE == 360 )
6144 if ( pVBInfo->VGAVDE == 375 )
6146 if ( pVBInfo->VGAVDE == 405 )
6149 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6151 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6153 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6154 tempbx = tempbx >> 1 ;
6157 tempbx = tempbx >> 1 ;
6161 temp = tempbx & 0x00FF ;
6163 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6165 if ( pVBInfo->VBType & VB_XGI301LV )
6167 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6169 if ( pVBInfo->VBInfo & SetInSlaveMode )
6171 if ( ModeNo == 0x2f )
6178 if ( pVBInfo->VBInfo & SetInSlaveMode )
6180 if ( ModeNo == 0x2f )
6186 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6188 temp = ( tempcx & 0xFF00 ) >> 8 ;
6189 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6191 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6193 if ( pVBInfo->VBType & VB_XGI301LV )
6195 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6199 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6206 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6211 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6213 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6215 tempbx = pVBInfo->VDE ;
6216 tempcx = tempbx - 2 ;
6218 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6220 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6221 tempbx = tempbx >> 1 ;
6224 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6227 if( tempcx & 0x0400 )
6230 if ( tempbx & 0x0400 )
6233 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6236 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6237 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6238 temp = ( tempbx - 3 ) & 0x00FF ;
6239 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6242 tempbx = tempbx & 0x00FF ;
6244 if ( !( modeflag & HalfDCLK ) )
6246 tempcx = pVBInfo->VGAHDE ;
6247 if ( tempcx >= pVBInfo->HDE )
6256 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6257 if(pVBInfo->VGAHDE>=1024)
6260 if(pVBInfo->VGAHDE>=1280)
6263 tempbx=tempbx&0xDFFF;
6268 if ( !( tempbx & 0x2000 ) )
6270 if ( modeflag & HalfDCLK )
6272 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6276 tempeax = pVBInfo->VGAHDE ;
6277 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6278 longtemp = tempeax * tempebx ;
6279 tempecx = tempcx & 0x00FF ;
6280 longtemp = longtemp / tempecx ;
6283 tempecx = 8 * 1024 ;
6285 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6287 tempecx = tempecx * 8 ;
6290 longtemp = longtemp * tempecx ;
6291 tempecx = pVBInfo->HDE ;
6292 temp2 = longtemp % tempecx ;
6293 tempeax = longtemp / tempecx ;
6299 tempax = (unsigned short)tempeax;
6302 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6304 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6309 tempbx = (unsigned short)(((tempeax & 0x0000FF00) & 0x1F00) | (tempbx & 0x00FF));
6310 tempax = (unsigned short)(((tempeax & 0x000000FF) << 8) | (tempax & 0x00FF));
6311 temp = ( tempax & 0xFF00 ) >> 8 ;
6315 temp = ( tempax & 0x00FF ) >> 8 ;
6318 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6319 temp = ( tempbx & 0xFF00 ) >> 8 ;
6320 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6321 temp = tempcx & 0x00FF ;
6323 if ( tempbx & 0x2000 )
6326 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6329 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6330 if ( pVBInfo->TVInfo & SetPALTV )
6341 temp = tempbx & 0x00FF ;
6342 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6343 temp = tempcx & 0x00FF ;
6344 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6346 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6348 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6350 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6354 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6357 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6361 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6362 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6363 XGINew_SetReg1( pVBInfo->Part2Port , 0x43, (unsigned short)( temp - 3 ) ) ;
6365 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6367 if ( pVBInfo->TVInfo & NTSC1024x768 )
6369 TimingPoint = XGI_NTSC1024AdjTime ;
6370 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6372 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6374 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6378 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6379 if ( pVBInfo->VBType & VB_XGI301C )
6381 if ( pVBInfo->TVInfo & SetPALMTV )
6382 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6385 if ( pVBInfo->TVInfo & SetPALMTV )
6387 tempax = (unsigned char)XGINew_GetReg1(pVBInfo->Part2Port, 0x01);
6389 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6391 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6392 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6395 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6397 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6399 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6403 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6410 /* --------------------------------------------------------------------- */
6411 /* Function : XGI_SetLCDRegs */
6415 /* --------------------------------------------------------------------- */
6416 void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
6418 unsigned short push1 ,
6432 struct XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6435 if ( ModeNo <= 0x13 )
6437 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6438 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6442 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6443 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6444 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6445 CRT1Index &= IndexMask ;
6448 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6453 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6455 if ( XGI_IsLCDDualLink( pVBInfo ) )
6456 tempbx = tempbx >> 1 ;
6459 temp = tempbx & 0x00FF ;
6460 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6461 temp = ( tempbx & 0xFF00 ) >> 8 ;
6463 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6466 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6468 if ( pVBInfo->ModeType == ModeEGA )
6470 if ( pVBInfo->VGAHDE >= 1024 )
6473 if ( pVBInfo->LCDInfo & LCDVESATiming )
6479 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6480 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6483 temp = tempbx & 0x00FF ;
6484 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6485 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6486 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6488 tempcx = pVBInfo->VT - 1 ;
6489 push2 = tempcx + 1 ;
6490 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6491 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6492 temp = ( tempcx & 0xFF00 ) >> 8 ;
6494 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6495 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6496 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6497 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6498 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6500 /* Customized LCDB Des no add */
6502 LCDBDesPtr = (struct XGI_LCDDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6503 tempah = pVBInfo->LCDResInfo ;
6504 tempah &= PanelResInfo ;
6506 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6511 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6516 else if ( tempah == Panel1400x1050 )
6527 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6529 tempbx = pVBInfo->HDE ;
6530 tempcx = pVBInfo->VDE ;
6534 tempax = pVBInfo->VT ;
6535 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6536 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6537 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6538 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6539 tempbx = pVBInfo->LCDVDES ;
6542 if ( tempcx >= tempax )
6543 tempcx -= tempax ; /* lcdvdes */
6545 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6546 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6547 temp = tempcx & 0x00FF ;
6548 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6549 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6550 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6552 tempah = tempah << 3 ;
6554 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6557 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6559 tempax = pVBInfo->VT ;
6560 tempbx = pVBInfo->LCDVRS ;
6562 /* if ( SetLCD_Info & EnableScalingLCD ) */
6564 if ( tempcx >= tempax )
6567 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6568 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6569 temp = ( tempbx & 0xFF00 ) >> 8 ;
6571 temp |= ( tempcx & 0x000F ) ;
6572 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6574 tempax = pVBInfo->HT ;
6575 tempbx = pVBInfo->LCDHDES ;
6578 if ( XGI_IsLCDDualLink( pVBInfo ) )
6580 tempax = tempax >> 1 ;
6581 tempbx = tempbx >> 1 ;
6582 tempcx = tempcx >> 1 ;
6585 if ( pVBInfo->VBType & VB_XGI302LV )
6588 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6593 if ( tempcx >= tempax )
6596 temp = tempbx & 0x00FF ;
6597 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6598 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6599 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6600 temp = tempcx & 0x00FF ;
6601 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6602 temp = ( tempcx & 0xFF00 ) >> 8 ;
6603 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6606 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6608 tempax = pVBInfo->HT ;
6609 tempbx = pVBInfo->LCDHRS ;
6610 /* if ( SetLCD_Info & EnableScalingLCD) */
6611 if ( XGI_IsLCDDualLink( pVBInfo) )
6613 tempax = tempax >> 1 ;
6614 tempbx = tempbx >> 1 ;
6615 tempcx = tempcx >> 1 ;
6618 if ( pVBInfo->VBType & VB_XGI302LV )
6623 if ( tempcx >= tempax )
6626 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6627 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6629 temp = ( tempbx & 0xFF00 ) >> 8 ;
6631 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6632 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6633 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6635 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6637 if ( pVBInfo->VGAVDE == 525 )
6639 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6646 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6647 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6650 if ( pVBInfo->VGAVDE == 420 )
6652 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6658 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6664 /* --------------------------------------------------------------------- */
6665 /* Function : XGI_GetTap4Ptr */
6667 /* Output : di -> Tap4 Reg. Setting Pointer */
6669 /* --------------------------------------------------------------------- */
6670 struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
6671 struct vb_device_info *pVBInfo)
6673 unsigned short tempax ,
6677 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6681 tempax = pVBInfo->VGAHDE ;
6682 tempbx = pVBInfo->HDE ;
6686 tempax = pVBInfo->VGAVDE ;
6687 tempbx = pVBInfo->VDE ;
6690 if ( tempax < tempbx )
6691 return &EnlargeTap4Timing[ 0 ] ;
6692 else if( tempax == tempbx )
6693 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6695 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6697 if ( pVBInfo->TVInfo & SetPALTV )
6698 Tap4TimingPtr = PALTap4Timing ;
6701 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6703 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6704 Tap4TimingPtr = YPbPr525iTap4Timing ;
6705 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6706 Tap4TimingPtr = YPbPr525pTap4Timing ;
6707 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6708 Tap4TimingPtr = YPbPr750pTap4Timing ;
6711 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6712 Tap4TimingPtr = HiTVTap4Timing ;
6715 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6717 if ( Tap4TimingPtr[ i ].DE == tempax )
6721 return &Tap4TimingPtr[ i ] ;
6725 /* --------------------------------------------------------------------- */
6726 /* Function : XGI_SetTap4Regs */
6730 /* --------------------------------------------------------------------- */
6731 void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
6736 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6738 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6742 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6743 #else /* Tap4 Setting */
6745 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6746 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6747 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6749 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6751 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6752 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6753 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6756 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6757 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
6759 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
6763 /* --------------------------------------------------------------------- */
6764 /* Function : XGI_SetGroup3 */
6768 /* --------------------------------------------------------------------- */
6769 void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6772 unsigned char *tempdi;
6773 unsigned short modeflag;
6777 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6781 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6785 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
6786 if(pVBInfo->TVInfo&SetPALTV)
6788 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6789 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6793 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
6794 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
6797 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
6802 if(pVBInfo->TVInfo&SetPALMTV)
6804 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6805 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6806 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
6809 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
6811 if(pVBInfo->TVInfo & SetYPbPrMode525i)
6815 tempdi=pVBInfo->HiTVGroup3Data;
6816 if(pVBInfo->SetFlag&TVSimuMode)
6818 tempdi=pVBInfo->HiTVGroup3Simu;
6819 if(!(modeflag&Charx8Dot))
6821 tempdi=pVBInfo->HiTVGroup3Text;
6825 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6827 tempdi=pVBInfo->Ren525pGroup3;
6829 if(pVBInfo->TVInfo & SetYPbPrMode750p)
6831 tempdi=pVBInfo->Ren750pGroup3;
6834 for(i=0;i<=0x3E;i++)
6836 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
6838 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
6840 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6842 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
6847 } /* {end of XGI_SetGroup3} */
6850 /* --------------------------------------------------------------------- */
6851 /* Function : XGI_SetGroup4 */
6855 /* --------------------------------------------------------------------- */
6856 void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
6858 unsigned short tempax ,
6865 unsigned long tempebx ,
6870 if ( ModeNo <= 0x13 )
6872 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6876 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6879 temp = pVBInfo->RVBHCFACT ;
6880 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
6882 tempbx = pVBInfo->RVBHCMAX ;
6883 temp = tempbx & 0x00FF ;
6884 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
6885 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
6886 tempcx = pVBInfo->VGAHT - 1 ;
6887 temp = tempcx & 0x00FF ;
6888 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
6890 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
6893 tempcx = pVBInfo->VGAVT - 1 ;
6894 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6899 temp = tempcx & 0x00FF ;
6900 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
6901 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
6902 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
6903 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
6904 tempcx = pVBInfo->VBInfo ;
6905 tempbx = pVBInfo->VGAHDE ;
6907 if ( modeflag & HalfDCLK )
6909 tempbx = tempbx >> 1 ;
6912 if ( XGI_IsLCDDualLink( pVBInfo ) )
6913 tempbx = tempbx >> 1 ;
6915 if(tempcx&SetCRT2ToHiVisionTV)
6923 else if(tempcx&SetCRT2ToTV)
6932 if(pVBInfo->VBInfo&SetCRT2ToLCD)
6940 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6943 if ( pVBInfo->VGAHDE == 1280 )
6945 if ( pVBInfo->VGAHDE == 1024 )
6948 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
6950 tempebx = pVBInfo->VDE ;
6952 if ( tempcx & SetCRT2ToHiVisionTV )
6954 if ( !( temp & 0xE000 ) )
6955 tempbx = tempbx >> 1 ;
6958 tempcx = pVBInfo->RVBHRS ;
6959 temp = tempcx & 0x00FF ;
6960 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
6962 tempeax = pVBInfo->VGAVDE ;
6966 if ( tempeax <= tempebx )
6968 tempcx=(tempcx&(~0x4000));
6969 tempeax = pVBInfo->VGAVDE ;
6973 tempeax -= tempebx ;
6977 templong = ( tempeax * 256 * 1024 ) % tempebx ;
6978 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
6981 if ( templong != 0 )
6987 temp = (unsigned short)(tempebx & 0x000000FF);
6988 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
6990 temp = (unsigned short)((tempebx & 0x0000FF00) >> 8);
6991 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
6992 tempbx = (unsigned short)(tempebx >> 16);
6993 temp = tempbx & 0x00FF ;
6995 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
6996 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
6999 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7002 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
7003 tempax = pVBInfo->VGAHDE ;
7004 if ( modeflag & HalfDCLK )
7006 tempax = tempax >> 1 ;
7009 if ( XGI_IsLCDDualLink( pVBInfo ) )
7010 tempax = tempax >> 1 ;
7012 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
7013 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
7020 if ( pVBInfo->VGAHDE > 800 )
7022 if ( pVBInfo->VGAHDE == 1024 )
7023 tempax = ( tempax * 25 / 32 ) - 1 ;
7025 tempax = ( tempax * 20 / 32 ) - 1 ;
7031 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7033 if ( pVBInfo->VBType & VB_XGI301LV )
7035 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7037 if ( pVBInfo->VGAHDE > 800 )
7039 if ( pVBInfo->VGAHDE == 1024 )
7040 tempax = ( tempax * 25 / 32 ) - 1 ;
7042 tempax = ( tempax * 20 / 32 ) - 1 ;
7048 if ( pVBInfo->VGAHDE > 800 )
7050 if ( pVBInfo->VGAHDE == 1024 )
7051 tempax = ( tempax * 25 / 32 ) - 1 ;
7053 tempax = ( tempax * 20 / 32 ) - 1 ;
7059 temp = ( tempax & 0xFF00 ) >> 8 ;
7060 temp = ( ( temp & 0x0003 ) << 4 ) ;
7061 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
7062 temp = ( tempax & 0x00FF ) ;
7063 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7065 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7067 if ( pVBInfo->VGAHDE > 800 )
7069 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7074 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7076 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7079 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7080 temp &= ( ~0x0001 ) ;
7084 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7085 tempbx = pVBInfo->HT ;
7086 if ( XGI_IsLCDDualLink( pVBInfo ) )
7087 tempbx = tempbx >> 1 ;
7088 tempbx = ( tempbx >> 1 ) - 2 ;
7089 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7090 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7091 temp = tempbx & 0x00FF ;
7092 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7096 if ( pVBInfo->ISXPDOS == 0 )
7097 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7101 /* --------------------------------------------------------------------- */
7102 /* Function : XGI_SetGroup5 */
7106 /* --------------------------------------------------------------------- */
7107 void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
7109 unsigned short Pindex ,
7112 Pindex = pVBInfo->Part5Port ;
7113 Pdata = pVBInfo->Part5Port + 1 ;
7114 if ( pVBInfo->ModeType == ModeVGA )
7116 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7118 XGINew_EnableCRT2(pVBInfo) ;
7119 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7126 /* --------------------------------------------------------------------- */
7127 /* Function : XGI_GetLcdPtr */
7131 /* --------------------------------------------------------------------- */
7132 void *XGI_GetLcdPtr(unsigned short BX,
7133 unsigned short ModeNo,
7134 unsigned short ModeIdIndex,
7135 unsigned short RefreshRateTableIndex,
7136 struct vb_device_info *pVBInfo)
7146 struct XGI330_LCDDataTablStruct *tempdi = 0 ;
7151 if ( ModeNo <= 0x13 )
7153 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7154 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7158 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7159 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7162 tempal = tempal & 0x0f ;
7164 if ( tempbx <= 1 ) /* ExpLink */
7166 if ( ModeNo <= 0x13 )
7168 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7172 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7175 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7177 if ( ModeNo <= 0x13 )
7178 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7180 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7183 if ( tempbx & 0x01 )
7184 tempal = ( tempal >> 4 ) ;
7186 tempal = ( tempal & 0x0f ) ;
7189 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7191 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7193 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7194 tempcx = LCDDesDataLen2 ;
7195 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7196 tempcx = LVDSDesDataLen2 ;
7198 /* mov di, word ptr cs:LCDDataList[bx] */
7199 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7204 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7207 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7210 tempdi = XGI_EPLLCDDataPtr ;
7213 tempdi = XGI_EPLLCDDesDataPtr ;
7216 tempdi = XGI_LCDDataTable ;
7219 tempdi = XGI_LCDDesDataTable ;
7222 tempdi = XGI_EPLCHLCDRegPtr ;
7233 if ( tempdi == 0x00 ) /* OEMUtil */
7239 while( tempdi[ i ].PANELID != 0xff )
7241 tempdx = pVBInfo->LCDResInfo ;
7242 if ( tempbx & 0x0080 ) /* OEMUtil */
7244 tempbx &= ( ~0x0080 ) ;
7245 tempdx = pVBInfo->LCDTypeInfo ;
7248 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7249 tempdx &= ( ~PanelResInfo ) ;
7251 if ( tempdi[ i ].PANELID == tempdx )
7253 tempbx = tempdi[ i ].MASK ;
7254 tempdx = pVBInfo->LCDInfo ;
7256 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7257 tempdx |= SetLCDStdMode ;
7259 if ( modeflag & HalfDCLK )
7260 tempdx |= SetLCDLowResolution ;
7263 if ( tempbx == tempdi[ i ].CAP )
7271 switch( tempdi[ i ].DATAPTR )
7274 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7277 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7280 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7283 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7286 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7289 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7292 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7295 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7298 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7301 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7304 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7310 else if ( table == 1 )
7312 switch( tempdi[ i ].DATAPTR )
7315 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7318 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7321 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7324 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7327 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7330 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7333 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7336 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7339 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7342 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7345 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7351 else if ( table == 2 )
7353 switch( tempdi[ i ].DATAPTR )
7356 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7359 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7362 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7365 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7368 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7371 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7374 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7377 return &XGI_LVDSNoScalingData[ tempal ] ;
7380 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7383 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7386 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7389 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7392 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7398 else if ( table == 3 )
7400 switch( tempdi[ i ].DATAPTR )
7403 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7406 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7409 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7412 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7415 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7418 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7421 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7424 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7427 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7430 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7433 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7436 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7439 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7442 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7445 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7451 else if ( table == 4 )
7453 switch( tempdi[ i ].DATAPTR )
7456 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7459 return &XGI_StLCD1024x768Data[ tempal ] ;
7462 return &XGI_CetLCD1024x768Data[ tempal ] ;
7465 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7468 return &XGI_StLCD1280x1024Data[ tempal ] ;
7471 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7474 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7477 return &XGI_StLCD1400x1050Data[ tempal ] ;
7480 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7483 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7486 return &XGI_StLCD1600x1200Data[ tempal ] ;
7489 return &XGI_NoScalingData[ tempal ] ;
7492 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7495 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7498 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7501 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7504 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7507 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7510 return &XGI_NoScalingDatax75[ tempal ] ;
7516 else if ( table == 5 )
7518 switch( tempdi[ i ].DATAPTR )
7521 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7524 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7527 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7530 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7531 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7533 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7536 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7537 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7539 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7542 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7543 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7545 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7548 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7549 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7551 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7554 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7555 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7557 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7560 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7563 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7566 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7567 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7569 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7572 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7573 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7575 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7578 return &XGI_NoScalingDesData[ tempal ] ;
7581 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7584 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7587 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7590 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7591 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7593 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7596 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7597 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7599 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7602 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7603 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7605 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7608 return &XGI_NoScalingDesDatax75[ tempal ] ;
7614 else if ( table == 6 )
7616 switch( tempdi[ i ].DATAPTR )
7619 return &XGI_CH7017LV1024x768[ tempal ] ;
7622 return &XGI_CH7017LV1400x1050[ tempal ] ;
7632 /* --------------------------------------------------------------------- */
7633 /* Function : XGI_GetTVPtr */
7637 /* --------------------------------------------------------------------- */
7638 void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
7639 unsigned short ModeIdIndex,
7640 unsigned short RefreshRateTableIndex,
7641 struct vb_device_info *pVBInfo)
7643 unsigned short i , tempdx , tempbx , tempal , modeflag , table ;
7644 struct XGI330_TVDataTablStruct *tempdi = 0 ;
7648 if ( ModeNo <= 0x13 )
7650 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7651 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7655 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7656 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7659 tempal = tempal & 0x3f ;
7665 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7666 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7668 tempdi = XGI_EPLCHTVCRT1Ptr;
7672 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7673 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7675 tempdi = XGI_EPLCHTVCRT1Ptr;
7679 tempdi = XGI_EPLCHTVDataPtr ;
7685 tempdi = XGI_TVDataTable ;
7691 tempdi = XGI_EPLCHTVRegPtr ;
7697 if ( tempdi == 0x00 ) /* OEMUtil */
7700 tempdx = pVBInfo->TVInfo ;
7702 if ( pVBInfo->VBInfo & SetInSlaveMode )
7703 tempdx = tempdx | SetTVLockMode ;
7705 if ( modeflag & HalfDCLK )
7706 tempdx = tempdx | SetTVLowResolution ;
7710 while( tempdi[ i ].MASK != 0xffff )
7712 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7717 if ( table == 0x00 ) /* 07/05/22 */
7720 else if ( table == 0x01 )
7723 else if ( table == 0x04 )
7725 switch( tempdi[ i ].DATAPTR )
7728 return &XGI_ExtPALData[ tempal ] ;
7731 return &XGI_ExtNTSCData[ tempal ] ;
7734 return &XGI_StPALData[ tempal ] ;
7737 return &XGI_StNTSCData[ tempal ] ;
7740 return &XGI_ExtHiTVData[ tempal ] ;
7743 return &XGI_St2HiTVData[ tempal ] ;
7746 return &XGI_ExtYPbPr525iData[ tempal ] ;
7749 return &XGI_ExtYPbPr525pData[ tempal ] ;
7752 return &XGI_ExtYPbPr750pData[ tempal ] ;
7755 return &XGI_StYPbPr525iData[ tempal ] ;
7758 return &XGI_StYPbPr525pData[ tempal ] ;
7761 return &XGI_StYPbPr750pData[ tempal ] ;
7763 case 12: /* avoid system hang */
7764 return &XGI_ExtNTSCData[ tempal ] ;
7767 return &XGI_St1HiTVData[ tempal ] ;
7773 else if( table == 0x02 )
7775 switch( tempdi[ i ].DATAPTR )
7778 return &XGI_CHTVUNTSCData[ tempal ] ;
7781 return &XGI_CHTVONTSCData[ tempal ] ;
7784 return &XGI_CHTVUPALData[ tempal ] ;
7787 return &XGI_CHTVOPALData[ tempal ] ;
7793 else if( table == 0x06 )
7800 /* --------------------------------------------------------------------- */
7801 /* Function : XGI_BacklightByDrv */
7803 /* Output : 1 -> Skip backlight control */
7805 /* --------------------------------------------------------------------- */
7806 unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
7808 unsigned char tempah ;
7810 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x3A) ;
7811 if (tempah & BacklightControlBit)
7818 /* --------------------------------------------------------------------- */
7819 /* Function : XGI_FirePWDDisable */
7822 /* Description : Turn off VDD & Backlight : Fire disable procedure */
7823 /* --------------------------------------------------------------------- */
7825 void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
7827 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
7831 /* --------------------------------------------------------------------- */
7832 /* Function : XGI_FirePWDEnable */
7835 /* Description : Turn on VDD & Backlight : Fire enable procedure */
7836 /* --------------------------------------------------------------------- */
7837 void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
7839 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
7843 /* --------------------------------------------------------------------- */
7844 /* Function : XGI_EnableGatingCRT */
7848 /* --------------------------------------------------------------------- */
7849 void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
7851 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
7855 /* --------------------------------------------------------------------- */
7856 /* Function : XGI_DisableGatingCRT */
7860 /* --------------------------------------------------------------------- */
7861 void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
7864 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
7868 /* --------------------------------------------------------------------- */
7869 /* Function : XGI_SetPanelDelay */
7873 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7874 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7875 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7876 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7877 /* --------------------------------------------------------------------- */
7878 void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
7880 unsigned short index ;
7882 index = XGI_GetLCDCapPtr(pVBInfo) ;
7885 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
7888 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
7891 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
7894 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
7898 /* --------------------------------------------------------------------- */
7899 /* Function : XGI_SetPanelPower */
7903 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
7904 /* = 0111b = 07h ; Backlight on, Power off */
7905 /* = 1011b = 0Bh ; Backlight off, Power on */
7906 /* = 1111b = 0Fh ; Backlight off, Power off */
7907 /* --------------------------------------------------------------------- */
7908 void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, struct vb_device_info *pVBInfo)
7910 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7911 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
7913 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
7916 unsigned char XG21GPIODataTransfer(unsigned char ujDate)
7918 unsigned char ujRet = 0;
7919 unsigned char i = 0;
7924 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
7925 ujRet |= (ujDate >> i) & 1;
7931 /*----------------------------------------------------------------------------*/
7933 /* bl[5] : LVDS signal */
7934 /* bl[1] : LVDS backlight */
7935 /* bl[0] : LVDS VDD */
7936 /*----------------------------------------------------------------------------*/
7937 unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
7939 unsigned char CR4A, temp;
7941 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7942 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
7944 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7946 temp = XG21GPIODataTransfer(temp);
7948 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7952 /*----------------------------------------------------------------------------*/
7954 /* bl[5] : LVDS signal */
7955 /* bl[1] : LVDS backlight */
7956 /* bl[0] : LVDS VDD */
7957 /*----------------------------------------------------------------------------*/
7958 unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
7960 unsigned char CR4A, CRB4, temp;
7962 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7963 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
7965 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7969 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7970 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
7971 temp |= ((CRB4&0x04)<<3);
7974 /*----------------------------------------------------------------------------*/
7976 /* bl[5] : 1;LVDS signal on */
7977 /* bl[1] : 1;LVDS backlight on */
7978 /* bl[0] : 1:LVDS VDD on */
7979 /* bh: 100000b : clear bit 5, to set bit5 */
7980 /* 000010b : clear bit 1, to set bit1 */
7981 /* 000001b : clear bit 0, to set bit0 */
7982 /*----------------------------------------------------------------------------*/
7983 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo)
7985 unsigned char CR4A, temp;
7987 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7990 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7994 temp = (tempbl>>4)&0x02;
7996 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8000 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
8002 temp = XG21GPIODataTransfer(temp);
8005 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
8008 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo)
8010 unsigned char CR4A, temp;
8011 unsigned short tempbh0, tempbl0;
8022 temp = (tempbl>>4)&0x02;
8024 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8027 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
8029 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8033 tempbl <<= 2; /* GPIOC,GPIOD */
8034 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
8035 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
8038 /* --------------------------------------------------------------------- */
8039 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
8041 unsigned short index ;
8043 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8044 if (index < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct))
8049 /* --------------------------------------------------------------------- */
8050 /* Function : XGI_XG21SetPanelDelay */
8054 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8055 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
8056 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
8057 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
8058 /* --------------------------------------------------------------------- */
8059 void XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
8061 unsigned short index ;
8063 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
8065 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8068 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8071 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8074 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8077 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
8078 unsigned short ModeIdIndex,
8079 struct vb_device_info *pVBInfo)
8081 unsigned short xres ,
8088 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8089 if ( ModeNo <= 0x13 )
8091 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8092 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8093 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8097 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8098 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8099 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8102 if ( !( modeflag & Charx8Dot ) )
8108 if ( ModeNo > 0x13 )
8110 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8114 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8120 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8121 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8124 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8127 if ( ModeNo > 0x13 )
8129 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8130 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8132 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8141 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
8145 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8146 temp = ( temp & 1 ) << 6;
8147 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8148 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8152 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
8156 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8157 temp = ( temp & 3 ) << 6;
8158 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8159 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8163 void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
8164 struct vb_device_info *pVBInfo)
8166 unsigned char temp, Miscdata;
8167 unsigned short xres ,
8172 unsigned short LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8173 unsigned short LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8174 unsigned short value;
8176 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8178 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8)) >> 8);
8179 temp &= LCDPolarity;
8180 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc) ;
8182 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8184 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity) ;
8185 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8186 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8188 XGI_SetXG21FPBits(pVBInfo);
8189 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8190 if ( ModeNo <= 0x13 )
8192 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8193 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8194 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8198 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8199 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8200 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8203 if (!( modeflag & Charx8Dot ))
8204 xres = xres * 8 / 9;
8206 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8208 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8209 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8213 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8215 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8216 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8218 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8219 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8221 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8223 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8225 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8226 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8230 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8232 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8233 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8235 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8236 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8238 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8240 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11) ;
8241 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8243 if (!( modeflag & Charx8Dot ))
8245 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8248 /* HT SR0B[1:0] CR00 */
8249 value = ( LVDSHT >> 3 ) - 5;
8250 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8251 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8253 /* HBS SR0B[5:4] CR02 */
8254 value = ( LVDSHBS >> 3 ) - 1;
8255 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8256 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8258 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8259 value = ( LVDSHBE >> 3 ) - 1;
8260 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8261 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8262 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8264 /* HRS SR0B[7:6] CR04 */
8265 value = ( LVDSHRS >> 3 ) + 2;
8266 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8267 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8269 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8271 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8272 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8274 /* HRE SR0C[2] CR05[4:0] */
8275 value = ( LVDSHRE >> 3 ) + 2;
8276 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8277 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8279 /* Panel HRE SR2F[7:2] */
8281 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8283 /* VT SR0A[0] CR07[5][0] CR06 */
8284 value = LVDSVT - 2 ;
8285 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8286 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8287 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8288 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8290 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8291 value = LVDSVBS - 1 ;
8292 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8293 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8294 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8295 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8297 /* VBE SR0A[4] CR16 */
8298 value = LVDSVBE - 1;
8299 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8300 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8302 /* VRS SR0A[3] CR7[7][2] CR10 */
8303 value = LVDSVRS - 1 ;
8304 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8305 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8306 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8307 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8309 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8310 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8311 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8312 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8314 /* VRE SR0A[5] CR11[3:0] */
8315 value = LVDSVRE - 1;
8316 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8317 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8319 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8320 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8322 for ( temp=0, value = 0; temp < 3; temp++)
8325 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8326 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8327 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8331 if (!( modeflag & Charx8Dot ))
8333 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8334 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8335 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8337 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8338 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8340 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8346 /* no shadow case */
8347 void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
8348 struct vb_device_info *pVBInfo)
8350 unsigned char temp, Miscdata;
8351 unsigned short xres ,
8356 unsigned short LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8357 unsigned short LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8358 unsigned short value;
8360 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8361 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8)) >> 8);
8362 temp &= LCDPolarity;
8363 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
8365 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8367 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity) ;
8368 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8369 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8371 XGI_SetXG27FPBits(pVBInfo);
8372 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8373 if ( ModeNo <= 0x13 )
8375 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8376 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8377 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8381 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8382 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8383 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8386 if (!( modeflag & Charx8Dot ))
8387 xres = xres * 8 / 9;
8389 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8391 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8392 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8396 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8398 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8399 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8401 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8402 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8404 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8406 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8408 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8409 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8413 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8415 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8416 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8418 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8419 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8421 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8423 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11) ;
8424 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8426 if (!( modeflag & Charx8Dot ))
8428 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8431 /* HT SR0B[1:0] CR00 */
8432 value = ( LVDSHT >> 3 ) - 5;
8433 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8434 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8436 /* HBS SR0B[5:4] CR02 */
8437 value = ( LVDSHBS >> 3 ) - 1;
8438 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8439 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8441 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8442 value = ( LVDSHBE >> 3 ) - 1;
8443 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8444 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8445 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8447 /* HRS SR0B[7:6] CR04 */
8448 value = ( LVDSHRS >> 3 ) + 2;
8449 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8450 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8452 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8454 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8455 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8457 /* HRE SR0C[2] CR05[4:0] */
8458 value = ( LVDSHRE >> 3 ) + 2;
8459 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8460 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8462 /* Panel HRE SR2F[7:2] */
8464 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8466 /* VT SR0A[0] CR07[5][0] CR06 */
8467 value = LVDSVT - 2 ;
8468 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8469 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8470 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8471 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8473 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8474 value = LVDSVBS - 1 ;
8475 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8476 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8477 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8478 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8480 /* VBE SR0A[4] CR16 */
8481 value = LVDSVBE - 1;
8482 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8483 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8485 /* VRS SR0A[3] CR7[7][2] CR10 */
8486 value = LVDSVRS - 1 ;
8487 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8488 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8489 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8490 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8492 /* Panel VRS SR35[2:0] SR34[7:0] */
8493 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8494 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8496 /* VRE SR0A[5] CR11[3:0] */
8497 value = LVDSVRE - 1;
8498 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8499 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8501 /* Panel VRE SR3F[7:2] */
8502 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8504 for ( temp=0, value = 0; temp < 3; temp++)
8507 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8508 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8509 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8513 if (!( modeflag & Charx8Dot ))
8515 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8516 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8517 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8519 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8520 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8522 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8528 /* --------------------------------------------------------------------- */
8529 /* Function : XGI_IsLCDON */
8531 /* Output : 0 : Skip PSC Control */
8532 /* 1: Disable PSC */
8534 /* --------------------------------------------------------------------- */
8535 unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
8537 unsigned short tempax ;
8539 tempax = pVBInfo->VBInfo ;
8540 if ( tempax & SetCRT2ToDualEdge )
8542 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8549 /* --------------------------------------------------------------------- */
8550 /* Function : XGI_EnablePWD */
8554 /* --------------------------------------------------------------------- */
8555 void XGI_EnablePWD(struct vb_device_info *pVBInfo)
8557 unsigned short index ,
8560 index = XGI_GetLCDCapPtr(pVBInfo) ;
8561 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8562 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8563 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8564 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8565 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8566 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8567 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8571 /* --------------------------------------------------------------------- */
8572 /* Function : XGI_DisablePWD */
8576 /* --------------------------------------------------------------------- */
8577 void XGI_DisablePWD(struct vb_device_info *pVBInfo)
8579 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8583 /* --------------------------------------------------------------------- */
8584 /* Function : XGI_DisableChISLCD */
8586 /* Output : 0 -> Not LCD Mode */
8588 /* --------------------------------------------------------------------- */
8589 unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
8591 unsigned short tempbx ,
8594 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8595 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
8597 if ( tempbx & ( EnableChA | DisableChA ) )
8599 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8603 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8606 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8613 /* --------------------------------------------------------------------- */
8614 /* Function : XGI_EnableChISLCD */
8616 /* Output : 0 -> Not LCD mode */
8618 /* --------------------------------------------------------------------- */
8619 unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
8621 unsigned short tempbx ,
8625 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8626 tempah = ~( (unsigned short)XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8628 if ( tempbx & ( EnableChA | DisableChA ) )
8630 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8634 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8637 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8644 /* --------------------------------------------------------------------- */
8645 /* Function : XGI_GetLCDCapPtr */
8649 /* --------------------------------------------------------------------- */
8650 unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
8652 unsigned char tempal ,
8657 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8658 tempal = tempah & 0x0F ;
8659 tempah = tempah & 0xF0 ;
8661 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8663 while( tempbl != 0xFF )
8665 if ( tempbl & 0x80 ) /* OEMUtil */
8668 tempbl = tempbl & ~( 0x80 ) ;
8671 if ( tempal == tempbl )
8676 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8683 /* --------------------------------------------------------------------- */
8684 /* Function : XGI_GetLCDCapPtr1 */
8688 /* --------------------------------------------------------------------- */
8689 unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
8691 unsigned short tempah ,
8696 tempal = pVBInfo->LCDResInfo ;
8697 tempah = pVBInfo->LCDTypeInfo ;
8700 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
8702 while( tempbl != 0xFF )
8704 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
8710 if ( tempal == tempbl )
8714 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8717 if ( tempbl == 0xFF )
8719 pVBInfo->LCDResInfo = Panel1024x768 ;
8720 pVBInfo->LCDTypeInfo = 0 ;
8728 /* --------------------------------------------------------------------- */
8729 /* Function : XGI_GetLCDSync */
8733 /* --------------------------------------------------------------------- */
8734 void XGI_GetLCDSync(unsigned short *HSyncWidth , unsigned short *VSyncWidth,
8735 struct vb_device_info *pVBInfo)
8737 unsigned short Index ;
8739 Index = XGI_GetLCDCapPtr(pVBInfo) ;
8740 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
8741 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
8748 /* --------------------------------------------------------------------- */
8749 /* Function : XGI_EnableBridge */
8753 /* --------------------------------------------------------------------- */
8754 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
8756 unsigned short tempbl ,
8759 if ( pVBInfo->SetFlag == Win9xDOSMode )
8761 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8763 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8766 else /* LVDS or CH7017 */
8771 if ( HwDeviceExtension->jChipType < XG40 )
8773 if ( !XGI_DisableChISLCD(pVBInfo) )
8775 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8777 if ( pVBInfo->LCDInfo & SetPWDEnable )
8779 XGI_EnablePWD( pVBInfo);
8783 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
8784 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8795 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
8796 XGI_SetPanelDelay( 1,pVBInfo ) ;
8804 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8806 if ( !( pVBInfo->SetFlag & DisableChA ) )
8808 if ( pVBInfo->SetFlag & EnableChA )
8810 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
8814 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
8816 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
8821 if ( !( pVBInfo->SetFlag & DisableChB ) )
8823 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
8825 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x32);
8827 if ( pVBInfo->VBInfo & SetInSlaveMode )
8829 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
8832 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
8833 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
8835 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->Part1Port, 0x2E);
8837 if ( !( tempah & 0x80 ) )
8838 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8840 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
8844 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
8846 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
8847 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8849 if ( !XGI_DisableChISLCD(pVBInfo) )
8851 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8852 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
8854 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
8860 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
8864 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
8866 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8868 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8870 tempah = tempah & 0x40;
8871 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8872 tempah = tempah ^ 0xC0 ;
8874 if ( pVBInfo->SetFlag & DisableChB )
8877 if ( pVBInfo->SetFlag & DisableChA )
8880 if ( pVBInfo->SetFlag & EnableChB )
8883 if ( pVBInfo->SetFlag & EnableChA )
8890 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
8892 if ( pVBInfo->SetFlag & Win9xDOSMode )
8894 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8898 if ( !( pVBInfo->SetFlag & DisableChA ) )
8900 XGI_VBLongWait( pVBInfo) ;
8901 if ( !( pVBInfo->SetFlag & GatingCRT ) )
8903 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8904 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8905 XGI_VBLongWait( pVBInfo) ;
8911 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
8912 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
8916 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->Part1Port, 0x2E);
8917 if ( !( tempah & 0x80 ) )
8918 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8920 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
8921 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
8925 if ( HwDeviceExtension->jChipType < XG40 )
8927 if ( !XGI_EnableChISLCD(pVBInfo) )
8929 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
8931 if ( XGI_BacklightByDrv(pVBInfo) )
8938 if ( pVBInfo->LCDInfo & SetPWDEnable )
8940 XGI_FirePWDEnable(pVBInfo) ;
8944 XGI_SetPanelDelay( 2,pVBInfo ) ;
8946 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8949 tempbl = 0xFE ; /* turn on backlght */
8956 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
8961 /* --------------------------------------------------------------------- */
8962 /* Function : XGI_DisableBridge */
8966 /* --------------------------------------------------------------------- */
8967 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
8969 unsigned short tempax ,
8974 if ( pVBInfo->SetFlag == Win9xDOSMode )
8978 if ( HwDeviceExtension->jChipType < XG40 )
8980 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8982 if ( !XGI_IsLCDON(pVBInfo) )
8984 if ( pVBInfo->LCDInfo & SetPWDEnable )
8985 XGI_EnablePWD( pVBInfo) ;
8988 pVBInfo->LCDInfo &= ~SetPWDEnable ;
8989 XGI_DisablePWD(pVBInfo) ;
8990 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8992 tempbx = 0xFE ; /* not 01h */
8997 tempbx = 0xF7 ; /* not 08h */
9000 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
9001 XGI_SetPanelDelay( 3,pVBInfo ) ;
9003 } /* end if(!XGI_IsLCDON(pVBInfo)) */
9009 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
9011 if ( !XGI_IsLCDON(pVBInfo) )
9015 tempbx = XGINew_GetCH7005( 0x61 ) ;
9016 if ( tempbx < 0x01 ) //first time we power up
9017 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
9019 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
9025 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9028 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
9030 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9032 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9034 tempah = 0x7F; /* Disable Channel A */
9035 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9036 tempah = 0xBF ; /* Disable Channel B */
9038 if ( pVBInfo->SetFlag & DisableChB )
9039 tempah &= 0xBF ; /* force to disable Cahnnel */
9041 if ( pVBInfo->SetFlag & DisableChA )
9042 tempah &= 0x7F ; /* Force to disable Channel B */
9047 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
9049 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9051 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9052 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
9055 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
9057 if ( pVBInfo->SetFlag & GatingCRT )
9058 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9059 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9062 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9064 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9065 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
9068 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
9070 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
9071 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9073 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9074 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9075 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9077 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9078 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9080 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9081 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9082 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9083 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9088 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9090 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9091 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9092 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9095 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9096 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9102 if ( HwDeviceExtension->jChipType < XG40 )
9104 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9106 if ( pVBInfo->LCDInfo & SetPWDEnable )
9108 if ( pVBInfo->LCDInfo & SetPWDEnable )
9109 XGI_BacklightByDrv(pVBInfo) ;
9112 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9113 if ( pVBInfo->VBType & VB_XGI301LV )
9125 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9131 /* --------------------------------------------------------------------- */
9132 /* Function : XGI_GetTVPtrIndex */
9135 /* Description : bx 0 : ExtNTSC */
9147 /* --------------------------------------------------------------------- */
9148 unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
9150 unsigned short tempbx = 0 ;
9152 if ( pVBInfo->TVInfo & SetPALTV )
9154 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9156 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9158 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9160 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9162 if ( pVBInfo->TVInfo & TVSimuMode )
9169 /* --------------------------------------------------------------------- */
9170 /* Function : XGI_OEM310Setting */
9173 /* Description : Customized Param. for 301 */
9174 /* --------------------------------------------------------------------- */
9175 void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9177 if ( pVBInfo->SetFlag & Win9xDOSMode )
9181 XGI_SetDelayComp(pVBInfo) ;
9183 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9184 XGI_SetLCDCap(pVBInfo) ;
9186 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9189 XGI_SetPhaseIncr(pVBInfo) ;
9190 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9191 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9193 if ( pVBInfo->VBType&VB_XGI301)
9194 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9199 /* --------------------------------------------------------------------- */
9200 /* Function : XGI_SetDelayComp */
9204 /* --------------------------------------------------------------------- */
9205 void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
9207 unsigned short index ;
9209 unsigned char tempah ,
9213 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9215 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9220 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9221 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9223 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9224 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9226 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9227 tempbl = tempbl >> 4 ;
9229 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9230 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9232 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9233 tempbl = CRT2Delay2 ;
9235 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9237 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9238 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9240 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9246 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9248 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9254 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9259 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9262 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9266 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9268 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9270 tempah = tempah << 4 ;
9271 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9277 /* --------------------------------------------------------------------- */
9278 /* Function : XGI_SetLCDCap */
9282 /* --------------------------------------------------------------------- */
9283 void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
9285 unsigned short tempcx ;
9287 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9289 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9291 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9292 { /* 301LV/302LV only */
9293 /* Set 301LV Capability */
9294 XGINew_SetReg1(pVBInfo->Part4Port, 0x24, (unsigned char)(tempcx & 0x1F));
9297 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
9298 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
9299 (unsigned short)((tempcx & (EnableVBCLKDRVLOW | EnablePLLSPLOW)) >> 8));
9302 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9304 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9305 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9306 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9307 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9309 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9311 if ( tempcx & EnableSpectrum )
9312 SetSpectrum( pVBInfo) ;
9315 else /* LVDS,CH7017 */
9316 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9320 /* --------------------------------------------------------------------- */
9321 /* Function : XGI_SetLCDCap_A */
9325 /* --------------------------------------------------------------------- */
9326 void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
9328 unsigned short temp ;
9330 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9332 if ( temp & LCDRGB18Bit )
9334 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
9335 (unsigned short)(0x20 | (tempcx & 0x00C0))); /* Enable Dither */
9336 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9340 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
9341 (unsigned short)(0x30 | (tempcx & 0x00C0)));
9342 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9346 if ( tempcx & EnableLCD24bpp ) // 24bits
9348 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(unsigned short)(0x30|(tempcx&0x00C0)) );
9349 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9353 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(unsigned short)(0x20|(tempcx&0x00C0)) ); // Enable Dither
9354 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9360 /* --------------------------------------------------------------------- */
9361 /* Function : XGI_SetLCDCap_B */
9362 /* Input : cx -> LCD Capability */
9365 /* --------------------------------------------------------------------- */
9366 void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
9368 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9369 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
9370 (unsigned short)(((tempcx & 0x00ff) >> 6) | 0x0c));
9372 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
9373 (unsigned short)(((tempcx & 0x00ff) >> 6) | 0x18)); /* Enable Dither */
9377 /* --------------------------------------------------------------------- */
9378 /* Function : SetSpectrum */
9382 /* --------------------------------------------------------------------- */
9383 void SetSpectrum(struct vb_device_info *pVBInfo)
9385 unsigned short index ;
9387 index = XGI_GetLCDCapPtr(pVBInfo) ;
9389 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9390 XGI_LongWait(pVBInfo) ;
9391 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9392 XGI_LongWait(pVBInfo) ;
9394 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9395 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9396 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9397 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9398 XGI_LongWait(pVBInfo) ;
9399 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9403 /* --------------------------------------------------------------------- */
9404 /* Function : XGI_SetAntiFlicker */
9407 /* Description : Set TV Customized Param. */
9408 /* --------------------------------------------------------------------- */
9409 void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
9410 struct vb_device_info *pVBInfo)
9412 unsigned short tempbx ,
9415 unsigned char tempah ;
9417 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9420 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9423 if ( ModeNo <= 0x13 )
9425 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9429 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9433 tempah = TVAntiFlickList[ tempbx ] ;
9434 tempah = tempah << 4 ;
9436 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9440 /* --------------------------------------------------------------------- */
9441 /* Function : XGI_SetEdgeEnhance */
9445 /* --------------------------------------------------------------------- */
9446 void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9448 unsigned short tempbx ,
9451 unsigned char tempah ;
9454 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9457 if ( ModeNo <= 0x13 )
9459 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9463 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9467 tempah = TVEdgeList[ tempbx ] ;
9468 tempah = tempah << 5 ;
9470 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9474 /* --------------------------------------------------------------------- */
9475 /* Function : XGI_SetPhaseIncr */
9479 /* --------------------------------------------------------------------- */
9480 void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
9482 unsigned short tempbx ;
9484 unsigned char tempcl ,
9487 unsigned long tempData ;
9489 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9490 tempData = TVPhaseList[ tempbx ] ;
9492 XGINew_SetReg1(pVBInfo->Part2Port, 0x31,
9493 (unsigned short)(tempData & 0x000000FF));
9494 XGINew_SetReg1(pVBInfo->Part2Port, 0x32,
9495 (unsigned short)((tempData & 0x0000FF00) >> 8));
9496 XGINew_SetReg1(pVBInfo->Part2Port, 0x33,
9497 (unsigned short)((tempData & 0x00FF0000) >> 16));
9498 XGINew_SetReg1(pVBInfo->Part2Port, 0x34,
9499 (unsigned short)((tempData & 0xFF000000) >> 24));
9503 /* --------------------------------------------------------------------- */
9504 /* Function : XGI_SetYFilter */
9508 /* --------------------------------------------------------------------- */
9509 void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
9510 struct vb_device_info *pVBInfo)
9512 unsigned short tempbx ,
9515 unsigned char tempcl ,
9520 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9526 filterPtr = NTSCYFilter1 ;
9530 filterPtr = PALYFilter1 ;
9536 filterPtr = PALMYFilter1 ;
9540 filterPtr = PALNYFilter1 ;
9545 filterPtr = NTSCYFilter2 ;
9549 filterPtr = PALMYFilter2 ;
9553 filterPtr = PALNYFilter2 ;
9557 filterPtr = PALYFilter2 ;
9564 if ( ModeNo <= 0x13 )
9565 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9567 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9574 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9576 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9577 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9578 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9579 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9583 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9584 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9585 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9586 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9589 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9591 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9592 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9593 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9598 /* --------------------------------------------------------------------- */
9599 /* Function : XGI_GetTVPtrIndex2 */
9601 /* Output : bx 0 : NTSC */
9605 /* 4 : NTSC1024x768 */
9606 /* 5 : PAL-M 1024x768 */
9608 /* cl 0 : YFilter1 */
9611 /* 1 : 301B/302B/301LV/302LV */
9613 /* --------------------------------------------------------------------- */
9614 void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
9615 unsigned char *tempch, struct vb_device_info *pVBInfo)
9621 if ( pVBInfo->TVInfo & SetPALTV )
9624 if ( pVBInfo->TVInfo & SetPALMTV )
9627 if ( pVBInfo->TVInfo & SetPALNTV )
9630 if ( pVBInfo->TVInfo & NTSC1024x768 )
9633 if ( pVBInfo->TVInfo & SetPALMTV )
9637 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9639 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9646 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9651 /* --------------------------------------------------------------------- */
9652 /* Function : XGI_SetCRT2ModeRegs */
9655 /* Description : Origin code for crt2group */
9656 /* --------------------------------------------------------------------- */
9657 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
9658 struct xgi_hw_device_info *HwDeviceExtension,
9659 struct vb_device_info *pVBInfo)
9661 unsigned short tempbl ;
9664 unsigned char tempah ;
9666 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9668 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9670 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9671 tempah &= ~0x10 ; /* BTRAMDAC */
9672 tempah |= 0x40 ; /* BTRAM */
9674 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9676 tempah=0x40; /* BTDRAM */
9677 if ( ModeNo > 0x13 )
9679 tempcl = pVBInfo->ModeType ;
9683 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9689 if ( pVBInfo->VBInfo & SetInSlaveMode )
9690 tempah ^= 0x50 ; /* BTDAC */
9695 if ( pVBInfo->VBInfo & DisableCRT2Display )
9700 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9701 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9703 tempcl = pVBInfo->ModeType ;
9704 if ( ModeNo > 0x13 )
9707 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
9709 tempah=(0x008>>tempcl) ;
9720 if ( pVBInfo->VBInfo & SetInSlaveMode )
9722 tempah = ( tempah ^ 0x050 ) ;
9727 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9731 if ( pVBInfo->VBInfo & DisableCRT2Display )
9732 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9738 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9740 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
9744 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9748 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9754 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9759 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
9762 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9764 tempah = tempah ^ 0x05 ;
9765 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
9766 tempah = tempah ^ 0x01 ;
9769 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9771 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9774 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9778 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9781 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9783 tempah &= ( ~0x08 ) ;
9784 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
9790 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9792 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
9795 if ( ModeNo > 0x13 )
9797 if ( pVBInfo->VBInfo & DriverMode )
9798 tempah = tempah ^ 0x20 ;
9803 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
9806 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9809 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9811 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
9813 if ( pVBInfo->TVInfo & RPLLDIV2XO )
9818 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
9821 if ( pVBInfo->LCDResInfo == Panel1280x960 )
9824 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
9827 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9832 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9835 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9836 tempah |= 0x04 ; /* shampoo 0129 */
9839 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
9842 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9844 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9848 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
9852 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9854 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9857 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
9862 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9865 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9869 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
9871 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9873 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9875 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
9876 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
9882 /* --------------------------------------------------------------------- */
9883 /* Function : XGI_CloseCRTC */
9887 /* --------------------------------------------------------------------- */
9888 void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
9890 unsigned short tempbx ;
9894 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9901 /* --------------------------------------------------------------------- */
9902 /* Function : XGI_OpenCRTC */
9906 /* --------------------------------------------------------------------- */
9907 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
9909 unsigned short tempbx ;
9917 /* --------------------------------------------------------------------- */
9918 /* Function : XGI_GetRAMDAC2DATA */
9922 /* --------------------------------------------------------------------- */
9923 void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
9925 unsigned short tempax ,
9934 pVBInfo->RVBHCMAX = 1 ;
9935 pVBInfo->RVBHCFACT = 1 ;
9937 if ( ModeNo <= 0x13 )
9939 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9940 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
9941 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
9942 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
9943 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
9947 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9948 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
9949 CRT1Index &= IndexMask ;
9950 temp1 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
9951 temp2 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
9952 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
9953 tempbx = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
9954 tempcx = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
9956 tempcx = tempcx << 2 ;
9958 temp1 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
9968 if ( modeflag & Charx8Dot )
9973 pVBInfo->VGAHT = tempax ;
9974 pVBInfo->HT = tempax ;
9976 pVBInfo->VGAVT = tempbx ;
9977 pVBInfo->VT = tempbx ;
9982 /* --------------------------------------------------------------------- */
9983 /* Function : XGI_GetColorDepth */
9987 /* --------------------------------------------------------------------- */
9988 unsigned short XGI_GetColorDepth(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9990 unsigned short ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
9992 unsigned short modeflag ;
9994 if ( ModeNo <= 0x13 )
9996 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
10000 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
10003 index=(modeflag&ModeInfoFlag)-ModeEGA;
10008 return( ColorDepth[ index ] ) ;
10013 /* --------------------------------------------------------------------- */
10014 /* Function : XGI_UnLockCRT2 */
10017 /* Description : */
10018 /* --------------------------------------------------------------------- */
10019 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
10022 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
10027 /* --------------------------------------------------------------------- */
10028 /* Function : XGI_LockCRT2 */
10031 /* Description : */
10032 /* --------------------------------------------------------------------- */
10033 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
10036 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
10042 /* --------------------------------------------------------------------- */
10043 /* Function : XGINew_EnableCRT2 */
10046 /* Description : */
10047 /* --------------------------------------------------------------------- */
10048 void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
10050 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
10055 /* --------------------------------------------------------------------- */
10059 /* Description : */
10060 /* --------------------------------------------------------------------- */
10061 void XGINew_LCD_Wait_Time(unsigned char DelayTime, struct vb_device_info *pVBInfo)
10066 unsigned long temp ,
10070 //printk("XGINew_LCD_Wait_Time");
10072 for( i = 0 ; i < DelayTime ; i++ )
10074 for( j = 0 ; j < 66 ; j++ )
10077 temp = XGINew_GetReg3( 0x61 ) ;
10079 //temp &= 0x10000000;
10081 if ( temp == flag )
10092 /* --------------------------------------------------------------------- */
10093 /* Function : XGI_BridgeIsOn */
10096 /* Description : */
10097 /* --------------------------------------------------------------------- */
10098 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
10100 unsigned short flag ;
10102 if ( pVBInfo->IF_DEF_LVDS == 1 )
10108 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10109 if ( ( flag == 1 ) || ( flag == 2 ) )
10110 return( 1 ) ; /* 301b */
10118 /* --------------------------------------------------------------------- */
10119 /* Function : XGI_LongWait */
10122 /* Description : */
10123 /* --------------------------------------------------------------------- */
10124 void XGI_LongWait(struct vb_device_info *pVBInfo)
10128 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10130 if ( !( i & 0xC0 ) )
10132 for( i = 0 ; i < 0xFFFF ; i++ )
10134 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10138 for( i = 0 ; i < 0xFFFF ; i++ )
10140 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10147 /* --------------------------------------------------------------------- */
10148 /* Function : XGI_VBLongWait */
10151 /* Description : */
10152 /* --------------------------------------------------------------------- */
10153 void XGI_VBLongWait(struct vb_device_info *pVBInfo)
10155 unsigned short tempal ,
10160 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10163 for( i = 0 ; i < 3 ; i++ )
10165 for( j = 0 ; j < 100 ; j++ )
10167 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10169 { /* VBWaitMode2 */
10170 if ( ( tempal & 0x08 ) )
10175 if ( !( tempal & 0x08 ) )
10181 { /* VBWaitMode1 */
10182 if ( !( tempal & 0x08 ) )
10187 if ( ( tempal & 0x08 ) )
10193 temp = temp ^ 0x01 ;
10198 XGI_LongWait(pVBInfo) ;
10206 /* --------------------------------------------------------------------- */
10207 /* Function : XGI_GetVGAHT2 */
10210 /* Description : */
10211 /* --------------------------------------------------------------------- */
10212 unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
10214 unsigned long tempax ,
10217 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10218 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10219 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10221 return( (unsigned short)tempax ) ;
10225 /* --------------------------------------------------------------------- */
10226 /* Function : XGI_GetVCLK2Ptr */
10229 /* Description : */
10230 /* --------------------------------------------------------------------- */
10231 unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
10232 unsigned short ModeIdIndex,
10233 unsigned short RefreshRateTableIndex,
10234 struct xgi_hw_device_info *HwDeviceExtension,
10235 struct vb_device_info *pVBInfo)
10237 unsigned short tempbx ;
10239 unsigned short LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10240 unsigned short LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10241 unsigned short LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10242 unsigned short LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10243 unsigned short LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10245 unsigned short CRT2Index , VCLKIndex ;
10246 unsigned short modeflag , resinfo ;
10247 unsigned char *CHTVVCLKPtr = NULL ;
10249 if ( ModeNo <= 0x13 )
10251 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10252 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10253 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10257 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10258 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10259 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10262 if ( pVBInfo->IF_DEF_LVDS == 0 )
10264 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10265 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10267 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10269 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10273 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10278 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10280 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10282 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10284 VCLKIndex = HiTVVCLKDIV2 ;
10292 VCLKIndex = HiTVVCLK ;
10299 if ( pVBInfo->SetFlag & TVSimuMode )
10301 if( modeflag & Charx8Dot )
10303 VCLKIndex = HiTVSimuVCLK ;
10311 VCLKIndex = HiTVTextVCLK ;
10319 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10321 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10323 VCLKIndex = YPbPr750pVCLK ;
10324 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10326 VCLKIndex = YPbPr525pVCLK ;
10327 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10329 VCLKIndex = YPbPr525iVCLK_2 ;
10330 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10331 VCLKIndex = YPbPr525iVCLK ;
10339 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10341 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10343 VCLKIndex = TVVCLKDIV2 ;
10351 VCLKIndex = TVVCLK ;
10362 VCLKIndex = (unsigned char)XGINew_GetReg2((pVBInfo->P3ca + 0x02)); /* Port 3cch */
10363 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10364 if ( ModeNo > 0x13 )
10366 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10367 VCLKIndex &= IndexMask ;
10374 if ( ModeNo <= 0x13 )
10375 VCLKIndex = CRT2Index ;
10377 VCLKIndex = CRT2Index ;
10379 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10381 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10383 VCLKIndex &= 0x1f ;
10386 if ( pVBInfo->VBInfo & SetPALTV )
10389 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10395 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10398 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10401 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10404 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10410 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10415 VCLKIndex = VCLKIndex >> 6 ;
10416 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10417 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10418 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10419 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10421 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10424 /* VCLKIndex = VCLKIndex&IndexMask ; */
10428 return( VCLKIndex ) ;