GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / xgifb / vb_setmode.c
blob9d5d06c723cfe04ce71dc1cb080d9f24382b171c
2 #include <asm/io.h>
3 #include <linux/types.h>
4 #include <linux/version.h>
5 #include "XGIfb.h"
8 #include "vb_def.h"
9 #include "vgatypes.h"
10 #include "vb_struct.h"
11 #include "vb_util.h"
12 #include "vb_table.h"
16 #define IndexMask 0xff
17 #ifndef XGI_MASK_DUAL_CHIP
18 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
19 #endif
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 */
239 /* Input : */
240 /* Output : */
241 /* Description : */
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;
261 else
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 ;
280 pVBInfo->TVInfo = 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 ;
347 else
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 */
394 /* Input : */
395 /* Output : */
396 /* Description : */
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 ;
431 else
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 ) ;
479 if ( ModeNo & 0x80 )
481 ModeNo = ModeNo & 0x7F ;
482 /* XGINew_flag_clearbuffer = 0 ; */
484 /* else
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 ) ;
515 else
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 )
531 case VB_CHIP_301:
532 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
533 break ;
535 case VB_CHIP_302:
536 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
537 break ;
539 default:
540 break ;
544 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
545 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
546 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
547 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
548 } /* !XG20 */
549 else
551 if (pVBInfo->IF_DEF_LVDS == 1)
552 if (!XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo))
553 return 0;
555 if ( ModeNo <= 0x13 )
557 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
559 else
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 ;
588 else
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 ) ;
597 if ( temp == 0 )
598 return( 0 ) ;
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 ) ;
612 return 1;
616 /* --------------------------------------------------------------------- */
617 /* Function : XGI_SetCRT1Group */
618 /* Input : */
619 /* Output : */
620 /* Description : */
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 ,
628 b3CC ,
629 temp ;
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 ) ;
697 if ( temp & 0xA0 )
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 );
705 else
706 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
708 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
710 if ( HwDeviceExtension->jChipType == XG27 )
711 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
712 else
713 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
715 if ( pVBInfo->IF_DEF_LVDS == 1 )
717 if ( HwDeviceExtension->jChipType == XG27 )
718 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
719 else
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 */
740 /* Input : */
741 /* Output : */
742 /* Description : */
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 ;
751 else
753 if ( pVBInfo->ModeType <= 0x02 )
754 index = 0x1B ; /* 02 -> ModeEGA */
755 else
756 index = 0x0F ;
758 return( index ) ; /* Get pVBInfo->StandTable index */
762 /* --------------------------------------------------------------------- */
763 /* Function : XGI_SetBIOSData */
764 /* Input : */
765 /* Output : */
766 /* Description : */
767 /* --------------------------------------------------------------------- */
768 /*unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex)
770 return( 0 ) ;
774 /* --------------------------------------------------------------------- */
775 /* Function : XGI_ClearBankRegs */
776 /* Input : */
777 /* Output : */
778 /* Description : */
779 /* --------------------------------------------------------------------- */
780 /*unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex)
782 return( 0 ) ;
786 /* --------------------------------------------------------------------- */
787 /* Function : XGI_SetSeqRegs */
788 /* Input : */
789 /* Output : */
790 /* Description : */
791 /* --------------------------------------------------------------------- */
792 void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
793 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
795 unsigned char tempah ,
796 SRdata ;
798 unsigned short i ,
799 modeflag ;
801 if ( ModeNo <= 0x13 )
802 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
803 else
804 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
806 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
807 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
809 i = SetCRT2ToLCDA ;
810 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
812 tempah |= 0x01 ;
814 else
816 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
818 if ( pVBInfo->VBInfo & SetInSlaveMode )
819 tempah |= 0x01 ;
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 */
836 /* Input : */
837 /* Output : */
838 /* Description : */
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 )
850 Miscdata |= 0x0C ;
855 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
859 /* --------------------------------------------------------------------- */
860 /* Function : XGI_SetCRTCRegs */
861 /* Input : */
862 /* Output : */
863 /* Description : */
864 /* --------------------------------------------------------------------- */
865 void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
866 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
868 unsigned char CRTCdata ;
869 unsigned short i ;
871 CRTCdata = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
872 CRTCdata &= 0x7f ;
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 /* --------------------------------------------------------------------- */
896 /* Function : */
897 /* Input : */
898 /* Output : */
899 /* Description : */
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 ;
909 else
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 */
917 if ( i == 0x13 )
919 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
920 ARdata = 0 ;
921 else
923 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
925 if ( pVBInfo->VBInfo & SetInSlaveMode )
926 ARdata = 0 ;
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 */
947 /* Input : */
948 /* Output : */
949 /* Description : */
950 /* --------------------------------------------------------------------- */
951 void XGI_SetGRCRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
953 unsigned char GRdata ;
954 unsigned short i ;
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 */
973 /* Input : */
974 /* Output : */
975 /* Description : */
976 /* --------------------------------------------------------------------- */
977 void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
979 unsigned short i ;
981 for( i = 0x0A ; i <= 0x0E ; i++ )
982 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
986 /* --------------------------------------------------------------------- */
987 /* Function : XGI_SetDefaultVCLK */
988 /* Input : */
989 /* Output : */
990 /* Description : */
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 ) ;
1004 return( 0 ) ;
1008 /* --------------------------------------------------------------------- */
1009 /* Function : XGI_GetRatePtrCRT2 */
1010 /* Input : */
1011 /* Output : */
1012 /* Description : */
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 ;
1028 else
1030 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1033 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1035 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1037 if ( modeflag & HalfDCLK )
1038 return( 0 ) ;
1042 if ( ModeNo < 0x14 )
1043 return( 0xFFFF ) ;
1045 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1046 index = index >> pVBInfo->SelectCRT2Rate ;
1047 index &= 0x0F ;
1049 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1050 index = 0 ;
1052 if ( index > 0 )
1053 index-- ;
1055 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1057 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1059 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1061 index = 0 ;
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 */
1071 else
1072 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1074 if ( index > temp )
1076 index = temp ;
1079 else
1081 index = 0 ;
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 )
1093 index++;
1096 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1097 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1099 index++;
1101 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1102 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1103 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1105 index++;
1107 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1108 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1110 index++;
1114 i = 0 ;
1117 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1118 break ;
1119 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1120 temp &= ModeInfoFlag ;
1121 if ( temp < pVBInfo->ModeType )
1122 break ;
1123 i++ ;
1124 index-- ;
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 )
1134 i++ ;
1138 i-- ;
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 */
1149 /* Input : */
1150 /* Output : */
1151 /* Description : */
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 */
1163 else
1165 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1168 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1169 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1170 tempax = 0 ;
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 )
1192 if ( resinfo >= 9 )
1194 tempax = 0 ;
1195 return( 0 ) ;
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 )
1209 if ( resinfo == 4 )
1210 return( 0 ) ;
1212 if ( resinfo == 3 )
1213 return( 0 ) ;
1215 if ( resinfo > 7 )
1216 return( 0 ) ;
1219 else
1221 tempax |= SupportHiVisionTV ;
1222 if ( pVBInfo->VBInfo & SetInSlaveMode )
1224 if ( resinfo == 4 )
1225 return( 0 ) ;
1227 if ( resinfo == 3 )
1229 if ( pVBInfo->SetFlag & TVSimuMode )
1230 return( 0 ) ;
1233 if ( resinfo > 7 )
1234 return( 0 ) ;
1238 else
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 ) )
1257 return( 0 ) ;
1265 else /* for LVDS */
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 )
1298 return( 1 ) ;
1300 if ( ( *i ) == 0 )
1301 break ;
1304 for( ( *i ) = 0 ; ; ( *i )++ )
1306 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1307 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1309 return( 0 ) ;
1312 if ( infoflag & tempax )
1314 return( 1 ) ;
1317 return( 1 ) ;
1321 /* --------------------------------------------------------------------- */
1322 /* Function : XGI_SetSync */
1323 /* Input : */
1324 /* Output : */
1325 /* Description : */
1326 /* --------------------------------------------------------------------- */
1327 void XGI_SetSync(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
1329 unsigned short sync ,
1330 temp ;
1332 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1333 sync &= 0xC0 ;
1334 temp = 0x2F ;
1335 temp |= sync ;
1336 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1340 /* --------------------------------------------------------------------- */
1341 /* Function : XGI_SetCRT1CRTC */
1342 /* Input : */
1343 /* Output : */
1344 /* Description : */
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;
1352 unsigned short i;
1354 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1355 index = index&IndexMask ;
1357 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1358 data &= 0x7F ;
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 */
1381 /* Input : */
1382 /* Output : */
1383 /* Description : */
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 */
1395 data &= 0x7F ;
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);
1414 j &= 0x1F ;
1415 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1416 data &= 0xE0 ;
1417 data |= j ;
1418 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1420 if ( HwDeviceExtension->jChipType >= XG20 )
1422 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x04);
1423 data = data - 1 ;
1424 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1425 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x05);
1426 data1 = data ;
1427 data1 &= 0xE0 ;
1428 data &= 0x1F ;
1429 if ( data == 0 )
1431 pushax = data ;
1432 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0c);
1433 data &= 0xFB ;
1434 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1435 data = pushax ;
1437 data = data - 1 ;
1438 data |= data1 ;
1439 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1440 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1441 data = data >> 5 ;
1442 data = data + 3 ;
1443 if ( data > 7 )
1444 data = data - 7 ;
1445 data = data << 5 ;
1446 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1451 /* --------------------------------------------------------------------- */
1452 /* Function : XGI_SetCRT1Timing_V */
1453 /* Input : */
1454 /* Output : */
1455 /* Description : */
1456 /* --------------------------------------------------------------------- */
1457 void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
1458 unsigned short ModeNo,
1459 struct vb_device_info *pVBInfo)
1461 unsigned char data;
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);
1487 j &= 0xC0 ;
1488 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1489 data &= 0x3F ;
1490 data |= j ;
1491 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1493 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1494 data &= 0x80 ;
1495 data = data >> 2 ;
1497 if ( ModeNo <= 0x13 )
1498 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1499 else
1500 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1502 i &= DoubleScanMode ;
1503 if ( i )
1504 data |= 0x80 ;
1506 j = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x09);
1507 j &= 0x5F ;
1508 data |= j ;
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] */
1533 Tempcx = Tempax ;
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] */
1573 Tempax &= 0x7F ;
1574 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1576 else
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 */
1604 Temp2 &= 0xFF ;
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] */
1626 Tempax &= 0x80 ;
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] */
1631 Temp2 = Tempax ;
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 */
1648 Temp2 &= 0xFF ;
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] */
1655 Tempax &= 0x7F ;
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] */
1673 Tempcx = Tempax ;
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] */
1688 Tempax >>= 2;
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] */
1707 else
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 */
1781 /* Input : */
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 ) ;
1808 if ( Temp & 0x01 )
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);
1822 if ( b3CC & 0x40 )
1823 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1824 if ( b3CC & 0x80 )
1825 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1827 else
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);
1876 if ( b3CC & 0x40 )
1877 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1878 if ( b3CC & 0x80 )
1879 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1881 else
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 */
1893 /* Input : */
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)
1901 int i , index = -1;
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 )
1909 index = i ;
1912 else
1914 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1915 index = 12 ;
1916 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1917 index = 13 ;
1918 else if ( ModeNo == 0x2F )
1919 index = 14 ;
1920 else if ( ModeNo == 0x50 )
1921 index = 15 ;
1922 else if ( ModeNo == 0x59 )
1923 index = 16 ;
1926 if( index != -1 )
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 */
1938 /* Input : */
1939 /* Output : */
1940 /* Description : */
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;
1950 unsigned char data;
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 ;
1960 else
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 ;
1984 tempcx = 8 ;
1986 /* if ( !( modeflag & Charx8Dot ) ) */
1987 /* tempcx = 9 ; */
1989 tempax /= tempcx ;
1990 tempax -= 1 ;
1991 tempbx -= 1 ;
1992 tempcx = tempax ;
1993 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1994 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1995 data &= 0x7F ;
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));
2000 tempax = 0 ;
2001 tempbx = tempbx >> 8 ;
2003 if ( tempbx & 0x01 )
2004 tempax |= 0x02 ;
2006 if ( tempbx & 0x02 )
2007 tempax |= 0x40 ;
2009 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
2010 data = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x07);
2011 data &= 0xFF ;
2012 tempax = 0 ;
2014 if ( tempbx & 0x04 )
2015 tempax |= 0x02 ;
2017 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
2018 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
2022 /* --------------------------------------------------------------------- */
2023 /* Function : XGI_GetResInfo */
2024 /* Input : */
2025 /* Output : */
2026 /* Description : */
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 */
2038 else
2040 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2042 return( resindex ) ;
2046 /* --------------------------------------------------------------------- */
2047 /* Function : XGI_SetCRT1Offset */
2048 /* Input : */
2049 /* Output : */
2050 /* Description : */
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 ,
2059 ah ,
2060 al ,
2061 temp2 ,
2063 DisplayUnit ;
2065 /* GetOffset */
2066 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2067 temp = temp >> 8 ;
2068 temp = pVBInfo->ScreenOffset[ temp ] ;
2070 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2071 temp2 &= InterlaceMode ;
2073 if ( temp2 )
2074 temp = temp << 1;
2076 temp2 = pVBInfo->ModeType - ModeEGA ;
2078 switch( temp2 )
2080 case 0:
2081 temp2 = 1 ;
2082 break ;
2083 case 1:
2084 temp2 = 2 ;
2085 break ;
2086 case 2:
2087 temp2 = 4 ;
2088 break ;
2089 case 3:
2090 temp2 = 4 ;
2091 break ;
2092 case 4:
2093 temp2 = 6 ;
2094 break;
2095 case 5:
2096 temp2 = 8 ;
2097 break ;
2098 default:
2099 break ;
2102 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2103 temp = temp * temp2 + temp2 / 2 ;
2104 else
2105 temp *= temp2 ;
2107 /* SetOffset */
2108 DisplayUnit = temp ;
2109 temp2 = temp ;
2110 temp = temp >> 8 ; /* ah */
2111 temp &= 0x0F ;
2112 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2113 i &= 0xF0 ;
2114 i |= temp ;
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 ;
2124 if ( temp2 )
2125 DisplayUnit >>= 1 ;
2127 DisplayUnit = DisplayUnit << 5 ;
2128 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2129 al = DisplayUnit & 0x00ff ;
2130 if ( al == 0 )
2131 ah += 1 ;
2132 else
2133 ah += 2 ;
2135 if ( HwDeviceExtension->jChipType >= XG20 )
2136 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2137 ah -= 1 ;
2139 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2143 /* --------------------------------------------------------------------- */
2144 /* Function : XGI_SetCRT1VCLK */
2145 /* Input : */
2146 /* Output : */
2147 /* Description : */
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 ) ;
2177 else
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 ) ;
2194 index = data ;
2195 index &= 0xE0 ;
2196 data &= 0x1F ;
2197 data = data << 1 ;
2198 data += 1 ;
2199 data |= index ;
2200 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2206 /* --------------------------------------------------------------------- */
2207 /* Function : XGI_SetCRT1FIFO */
2208 /* Input : */
2209 /* Output : */
2210 /* Description : */
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 ) ;
2219 data &= 0xfe ;
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 ) ;
2226 data &= 0xC0 ;
2227 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2228 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2229 data |= 0x01 ;
2230 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2232 else
2234 if (HwDeviceExtension->jChipType == XG27)
2236 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2237 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2238 data &= 0xC0 ;
2239 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2241 else
2243 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2244 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2245 data &= 0xF0 ;
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 */
2259 /* Input : */
2260 /* Output : */
2261 /* Description : */
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 ,
2269 data2 ,
2270 data3 ,
2271 infoflag = 0 ,
2272 modeflag ,
2273 resindex ,
2274 xres ;
2276 if ( ModeNo > 0x13 )
2278 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2279 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2281 else
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 )
2288 data = infoflag ;
2289 else
2290 data = 0 ;
2292 data2 = 0 ;
2294 if ( ModeNo > 0x13 )
2296 if ( pVBInfo->ModeType > 0x02 )
2298 data2 |= 0x02 ;
2299 data3 = pVBInfo->ModeType - ModeVGA ;
2300 data3 = data3 << 2 ;
2301 data2 |= data3 ;
2305 data &= InterlaceMode ;
2307 if ( data )
2308 data2 |= 0x20 ;
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 ;
2315 else
2316 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2318 data = 0x0000 ;
2319 if ( infoflag & InterlaceMode )
2321 if ( xres == 1024 )
2322 data = 0x0035 ;
2323 else if ( xres == 1280 )
2324 data = 0x0048 ;
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 ) ;
2335 data2 = 0 ;
2337 if ( modeflag & LineCompareOff )
2338 data2 |= 0x08 ;
2340 if ( ModeNo > 0x13 )
2342 if ( pVBInfo->ModeType == ModeEGA )
2343 data2 |= 0x40 ;
2346 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2347 data = 0x60 ;
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 )
2368 if ( data & 0x40 )
2369 data = 0x2c ;
2370 else
2371 data = 0x6c ;
2372 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2373 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2375 else
2376 if (HwDeviceExtension->jChipType >= XG20 )
2378 if ( data & 0x40 )
2379 data = 0x33 ;
2380 else
2381 data = 0x73 ;
2382 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2383 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2385 else
2387 if ( data & 0x40 )
2388 data = 0x2c ;
2389 else
2390 data = 0x6c ;
2391 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2397 /* --------------------------------------------------------------------- */
2398 /* Function : XGI_SetVCLKState */
2399 /* Input : */
2400 /* Output : */
2401 /* Description : */
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 ,
2409 data2 = 0 ;
2410 short VCLK ;
2412 unsigned char index;
2414 if ( ModeNo <= 0x13 )
2415 VCLK = 0 ;
2416 else
2418 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2419 index &= IndexMask ;
2420 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2423 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2424 data &= 0xf3 ;
2425 if ( VCLK >= 200 )
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 ) ;
2436 data &= 0xE7 ;
2437 if ( VCLK < 200 )
2438 data |= 0x10 ;
2439 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2442 /* Jong for Adavantech LCD ripple issue
2443 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2444 data2 = 0x03 ;
2445 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2446 data2 = 0x02 ;
2447 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2448 data2 = 0x01 ;
2449 else if ( VCLK > 260 )
2450 data2 = 0x00 ;
2452 data2 = 0x00 ;
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 */
2466 /* Input : */
2467 /* Output : */
2468 /* Description : */
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 ;
2476 else
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 ) ;
2493 return ;
2497 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2498 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2499 return ;
2503 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2507 /* --------------------------------------------------------------------- */
2508 /* Function : XGI_LoadDAC */
2509 /* Input : */
2510 /* Output : */
2511 /* Description : */
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 ,
2520 *table = NULL ;
2522 if ( ModeNo <= 0x13 )
2523 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2524 else
2525 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2527 data &= DACInfoFlag ;
2528 time = 64 ;
2530 if ( data == 0x00 )
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 )
2538 time = 256 ;
2539 table = XGINew_VGA_DAC ;
2542 if ( time == 256 )
2543 j = 16 ;
2544 else
2545 j = time ;
2547 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2548 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2550 for( i = 0 ; i < j ; i++ )
2552 data = table[ i ] ;
2554 for( k = 0 ; k < 3 ; k++ )
2556 data2 = 0 ;
2558 if ( data & 0x01 )
2559 data2 = 0x2A ;
2561 if ( data & 0x02 )
2562 data2 += 0x15 ;
2564 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2565 data = data >> 2 ;
2569 if ( time == 256 )
2571 for( i = 16 ; i < 32 ; i++ )
2573 data = table[ i ] ;
2575 for( k = 0 ; k < 3 ; k++ )
2576 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2579 si = 32 ;
2581 for( m = 0 ; m < 9 ; m++ )
2583 di = si ;
2584 bx = si + 0x04 ;
2585 dl = 0 ;
2587 for( n = 0 ; n < 3 ; n++ )
2589 for( o = 0 ; o < 5 ; o++ )
2591 dh = table[ si ] ;
2592 ah = table[ di ] ;
2593 al = table[ bx ] ;
2594 si++ ;
2595 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2598 si -= 2 ;
2600 for( o = 0 ; o < 3 ; o++ )
2602 dh = table[ bx ] ;
2603 ah = table[ di ] ;
2604 al = table[ si ] ;
2605 si-- ;
2606 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2609 dl++ ;
2612 si += 5 ;
2618 /* --------------------------------------------------------------------- */
2619 /* Function : XGI_WriteDAC */
2620 /* Input : */
2621 /* Output : */
2622 /* Description : */
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 ;
2630 bh = ah ;
2631 bl = al ;
2633 if ( dl != 0 )
2635 temp = bh ;
2636 bh = dh ;
2637 dh = temp ;
2638 if ( dl == 1 )
2640 temp = bl ;
2641 bl = dh ;
2642 dh = temp ;
2644 else
2646 temp = bl ;
2647 bl = bh ;
2648 bh = temp ;
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 */
2658 /* Input : */
2659 /* Output : */
2660 /* Description : */
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 */
2684 /* Input : */
2685 /* Output : */
2686 /* Description : */
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 */
2698 else
2700 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2704 /* if ( ModeNo > 0x13 ) */
2705 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2706 /* else */
2707 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2709 if ( ModeNo <= 0x13 )
2711 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2713 else
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 ;
2725 else
2727 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2728 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2730 if ( ModeNo > 0x13 )
2732 if ( modeflag & HalfDCLK )
2733 xres = xres << 1 ;
2735 if ( modeflag & DoubleScanMode )
2736 yres = yres << 1 ;
2738 /* if ( modeflag & Charx8Dot ) */
2739 /* { */
2741 if ( xres == 720 )
2742 xres = 640 ;
2744 /* } */
2745 pVBInfo->VGAHDE = xres ;
2746 pVBInfo->HDE = xres ;
2747 pVBInfo->VGAVDE = yres ;
2748 pVBInfo->VDE = yres ;
2752 /* --------------------------------------------------------------------- */
2753 /* Function : XGI_GetLVDSData */
2754 /* Input : */
2755 /* Output : */
2756 /* Description : */
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 ;
2767 tempbx = 2 ;
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 ;
2808 else
2810 pVBInfo->HDE = 1600 ;
2811 pVBInfo->VDE = 1200 ;
2818 /* --------------------------------------------------------------------- */
2819 /* Function : XGI_ModCRT1Regs */
2820 /* Input : */
2821 /* Output : */
2822 /* Description : */
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 ;
2839 else
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 ) ) ) )
2846 tempbx = 0 ;
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 ) ;
2871 } */
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 ] ) ;
2881 tempbx = 1 ;
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 ) ;
2904 } */
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 */
2922 /* Input : */
2923 /* Output : */
2924 /* Description : */
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 ;
2937 else
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 )
2946 tempbx = 8 ;
2947 LCDPtr = (struct XGI330_LCDDataDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2950 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2952 tempbx = 3 ;
2953 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2954 LCDPtr1 = (struct XGI330_LCDDataDesStruct2 *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2955 else
2956 LCDPtr = (struct XGI330_LCDDataDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2959 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
2960 push1 = tempbx ;
2961 push2 = tempax ;
2963 /* GetLCDResInfo */
2964 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2966 tempax = 1024 ;
2967 tempbx = 768 ;
2969 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2971 tempax = 1280 ;
2972 tempbx = 1024 ;
2974 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2976 tempax = 1400 ;
2977 tempbx = 1050 ;
2979 else
2981 tempax = 1600 ;
2982 tempbx = 1200 ;
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 ;
3003 else
3004 tempbx = LCDPtr->LCDHDES ;
3006 tempcx = pVBInfo->HDE ;
3007 tempbx = tempbx & 0x0fff ;
3008 tempcx += tempbx ;
3010 if ( tempcx >= tempax )
3011 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 ;
3025 else
3026 tempbx = LCDPtr->LCDHRS ;
3028 tempcx = push2 ;
3030 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3031 tempcx = LCDPtr1->LCDHSync ;
3033 tempcx += tempbx ;
3035 if ( tempcx >= tempax )
3036 tempcx -= tempax ;
3038 tempax = tempbx & 0x07 ;
3039 tempax = tempax >> 5 ;
3040 tempcx = tempcx >> 3 ;
3041 tempbx = tempbx >> 3 ;
3043 tempcx &= 0x1f ;
3044 tempax |= tempcx ;
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 ;
3052 else
3053 tempbx = LCDPtr->LCDVDES ;
3054 tempcx = pVBInfo->VDE ;
3056 tempbx = tempbx & 0x0fff ;
3057 tempcx += tempbx ;
3058 if ( tempcx >= tempax )
3059 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 ;
3072 else
3073 tempbx = LCDPtr->LCDVRS ;
3075 /* tempbx = tempbx >> 4 ; */
3076 tempcx = push1 ;
3078 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3079 tempcx = LCDPtr1->LCDVSync ;
3081 tempcx += tempbx ;
3082 if ( tempcx >= tempax )
3083 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 )
3092 tempax |= 0x40 ;
3094 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3095 tempax |= 0x40 ;
3097 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3099 tempcx = pVBInfo->VGAVT ;
3100 tempbx = pVBInfo->VDE ;
3101 tempax = pVBInfo->VGAVDE ;
3102 tempcx -= tempax ;
3104 temp = tempax ; /* 0430 ylshieh */
3105 temp1 = ( temp << 18 ) / tempbx ;
3107 tempdx = (unsigned short)((temp << 18) % tempbx);
3109 if ( tempdx != 0 )
3110 temp1 += 1 ;
3112 temp2 = temp1 ;
3113 push3 = temp2 ;
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 )
3123 tempax |= 0x04 ;
3125 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3127 if ( pVBInfo->VBType & VB_XGI301C )
3129 temp2 = push3 ;
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 ) ;
3138 else
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 ) )
3150 tempax = 65535 ;
3152 temp3 = tempax ;
3153 temp1 = pVBInfo->VGAHDE << 16 ;
3155 temp1 /= temp3 ;
3156 temp3 = temp3 << 16 ;
3157 temp1 -= 1 ;
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 )
3169 tempbx -= 1 ;
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 */
3190 /* Input : */
3191 /* Output : */
3192 /* Description : */
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;
3197 int i ;
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 ) ;
3216 else
3218 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3219 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3225 /* --------------------------------------------------------------------- */
3226 /* Function : XGI_UpdateModeInfo */
3227 /* Input : */
3228 /* Output : */
3229 /* Description : */
3230 /* --------------------------------------------------------------------- */
3231 void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
3233 unsigned short tempcl ,
3234 tempch ,
3235 temp ,
3236 tempbl ,
3237 tempax ;
3239 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3241 tempcl = 0 ;
3242 tempch = 0 ;
3243 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3245 if ( !( temp & 0x20 ) )
3247 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3248 if ( temp & 0x80 )
3250 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3251 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3252 else
3253 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3255 if ( !( temp & 0x40 ) )
3256 tempcl |= ActiveCRT1 ;
3260 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3261 temp &= 0x0f ;
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 ;
3269 temp &= 0x05 ;
3271 if ( !( tempcl & ActiveLCD ) )
3272 if ( temp == 0x01 )
3273 tempcl |= ActiveCRT2 ;
3275 if ( temp == 0x04 )
3276 tempcl |= ActiveLCD ;
3278 if ( temp == 0x05 )
3280 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3282 if( !( temp & 0x08 ) )
3283 tempch |= ActiveAVideo ;
3285 if ( !( temp & 0x04 ) )
3286 tempch |= ActiveSVideo ;
3288 if ( temp & 0x02 )
3289 tempch |= ActiveSCART ;
3291 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3293 if ( temp & 0x01 )
3294 tempch |= ActiveHiTV ;
3297 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3299 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3301 if ( temp & 0x10 )
3302 tempch |= ActiveYPbPr ;
3305 if ( tempch != 0 )
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 ;
3319 temp = tempcl ;
3320 tempbl = ~ModeSwitchStatus ;
3321 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3323 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3324 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3326 else
3328 return ;
3333 /* --------------------------------------------------------------------- */
3334 /* Function : XGI_GetVGAType */
3335 /* Input : */
3336 /* Output : */
3337 /* Description : */
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 */
3357 /* Input : */
3358 /* Output : */
3359 /* Description : */
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 ;
3368 return;
3370 if ( pVBInfo->IF_DEF_LVDS == 0 )
3372 tempbx = VB_XGI302B ;
3373 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3374 if ( flag != 0x02 )
3376 tempbx = VB_XGI301 ;
3377 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3378 if ( flag >= 0xB0 )
3380 tempbx = VB_XGI301B ;
3381 if ( flag >= 0xC0 )
3383 tempbx = VB_XGI301C ;
3384 if ( flag >= 0xD0 )
3386 tempbx = VB_XGI301LV ;
3387 if ( flag >= 0xE0 )
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 ;
3411 else //LVDS
3412 pVBInfo->VBType = VB_LVDS_NS ;
3418 /* --------------------------------------------------------------------- */
3419 /* Function : XGI_GetVBInfo */
3420 /* Input : */
3421 /* Output : */
3422 /* Description : */
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 ,
3427 push ,
3428 tempbx ,
3429 temp ,
3430 modeflag ;
3432 if ( ModeNo <= 0x13 )
3434 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3436 else
3438 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3441 pVBInfo->SetFlag = 0 ;
3442 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3443 tempbx = 0 ;
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 ) ;
3450 push = temp ;
3451 push = push << 8 ;
3452 tempax = temp << 8 ;
3453 tempbx = tempbx | tempax ;
3454 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3455 temp = 0xFFFF ^ temp ;
3456 tempbx &= 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 */
3505 temp &= YPbPrMode ;
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 )
3525 temp = 0x09FC ;
3526 else
3527 temp = 0x097C ;
3529 else
3531 if ( pVBInfo->IF_DEF_HiVision == 1 )
3532 temp = 0x01FC ;
3533 else
3534 temp = 0x017C ;
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 ;
3545 else
3546 temp = SetCRT2ToLCD ;
3549 if ( !( tempbx & temp ) )
3551 tempax |= DisableCRT2Display ;
3552 tempbx = 0 ;
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 ) ) ;
3563 else
3564 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3569 /* shampoo add */
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 ) ) ;
3580 else
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 ) ) )
3634 if ( ModeNo <= 13 )
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 */
3661 /* Input : */
3662 /* Output : */
3663 /* Description : */
3664 /* --------------------------------------------------------------------- */
3665 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
3667 unsigned short temp ,
3668 tempbx = 0 ,
3669 resinfo = 0 ,
3670 modeflag ,
3671 index1 ;
3673 tempbx = 0 ;
3674 resinfo = 0 ;
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 */
3683 else
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 ) ;
3692 tempbx = temp;
3693 if ( tempbx & SetPALTV )
3695 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3696 if ( tempbx & SetPALMTV )
3697 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3699 else
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
3706 tempbx |= temp2 ;
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 )
3764 { /* shampoo */
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 ) ;
3778 else
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 */
3796 /* Input : */
3797 /* Output : */
3798 /* Description : */
3799 /* --------------------------------------------------------------------- */
3800 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3801 struct vb_device_info *pVBInfo)
3803 unsigned short temp ,
3804 tempax ,
3805 tempbx ,
3806 modeflag ,
3807 resinfo = 0 ,
3808 LCDIdIndex ;
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 // */
3818 else
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 ;
3827 if ( tempbx == 0 )
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 )
3837 tempax &= 0x0F ;
3838 else
3839 tempax = tempax >> 4 ;
3841 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3843 if ( tempax >= 3 )
3844 tempbx |= PanelRef75Hz ;
3846 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3848 if ( tempax >= 4 )
3849 tempbx |= PanelRef75Hz ;
3854 pVBInfo->LCDResInfo = tempbx ;
3856 /* End of LCD75 */
3858 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3860 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3863 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3865 return 0;
3868 tempbx = 0 ;
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 ;
3877 tempbx |= temp ;
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 ;
3921 else
3923 if ( ModeNo > 0x13 )
3925 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3927 if ( resinfo == 4 )
3928 { /* 512x384 */
3929 tempbx |= EnableLVDSDDA ;
3937 if ( pVBInfo->VBInfo & SetInSlaveMode )
3939 if ( pVBInfo->VBInfo & SetNotSimuMode )
3941 tempbx |= LCDVESATiming ;
3944 else
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;
4000 return( 1 ) ;
4004 /* --------------------------------------------------------------------- */
4005 /* Function : XGI_SearchModeID */
4006 /* Input : */
4007 /* Output : */
4008 /* Description : */
4009 /* --------------------------------------------------------------------- */
4010 unsigned char XGI_SearchModeID(unsigned short ModeNo,
4011 unsigned short *ModeIdIndex,
4012 struct vb_device_info *pVBInfo)
4018 if ( ModeNo <= 5 )
4019 ModeNo |= 1 ;
4020 if ( ModeNo <= 0x13 )
4022 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(struct XGI_StStruct);(*ModeIdIndex)++) */
4023 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4025 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
4026 break;
4027 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
4028 return 0;
4031 if ( ModeNo == 0x07 )
4032 ( *ModeIdIndex )++ ; /* 400 lines */
4034 if ( ModeNo <= 3 )
4035 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4036 /* else 350 lines */
4038 else
4040 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(struct XGI_ExtStruct);(*ModeIdIndex)++) */
4041 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4043 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
4044 break;
4045 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
4046 return 0;
4050 return 1;
4056 /* win2000 MM adapter not support standard mode! */
4058 /* --------------------------------------------------------------------- */
4059 /* Function : */
4060 /* Input : */
4061 /* Output : */
4062 /* Description : */
4063 /* --------------------------------------------------------------------- */
4064 unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtension,
4065 unsigned short ModeNo,
4066 unsigned short ModeIdIndex,
4067 struct vb_device_info *pVBInfo)
4069 unsigned short memorysize ,
4070 modeflag ,
4071 temp ,
4072 temp1 ,
4073 tmp ;
4075 /* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4076 ( HwDeviceExtension->jChipType == XGI_650M ) )
4078 return 1;
4079 } */
4081 if ( ModeNo <= 0x13 )
4083 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4085 else {
4086 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4089 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4091 memorysize = modeflag & MemoryInfoFlag ;
4092 memorysize = memorysize > MemorySizeShift ;
4093 memorysize++ ; /* Get memory size */
4095 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4096 tmp = temp ;
4098 if ( HwDeviceExtension->jChipType == XG40 )
4100 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4101 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4103 temp <<= 2 ;
4105 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4107 temp <<= 1 ;
4110 else if ( HwDeviceExtension->jChipType == XG42 )
4112 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4113 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4115 temp <<= 1 ;
4118 else if ( HwDeviceExtension->jChipType == XG45 )
4120 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4121 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4123 temp <<= 2 ;
4125 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4127 temp1 = temp ;
4128 temp <<= 1 ;
4129 temp += temp1 ;
4131 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4133 temp <<= 1 ;
4136 if (temp < memorysize)
4137 return 0;
4138 else
4139 return 1;
4143 /* --------------------------------------------------------------------- */
4144 /* Function : XGINew_IsLowResolution */
4145 /* Input : */
4146 /* Output : */
4147 /* Description : */
4148 /* --------------------------------------------------------------------- */
4149 /*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)
4151 unsigned short data ;
4152 unsigned short ModeFlag ;
4154 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4155 data &= 0x7F ;
4156 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4158 if ( ModeNo > 0x13 )
4160 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4161 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4163 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4164 data |= 0x80 ;
4165 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4166 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4167 data &= 0xF7 ;
4168 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4175 /* --------------------------------------------------------------------- */
4176 /* Function : XGI_DisplayOn */
4177 /* Input : */
4178 /* Output : */
4179 /* Description : */
4180 /* --------------------------------------------------------------------- */
4181 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, struct vb_device_info *pVBInfo)
4184 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4185 if ( pXGIHWDE->jChipType == XG21 )
4187 if ( pVBInfo->IF_DEF_LVDS == 1 )
4189 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4191 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4192 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4194 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4196 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4198 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4199 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4201 else
4203 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4208 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4214 if ( pXGIHWDE->jChipType == XG27 )
4216 if ( pVBInfo->IF_DEF_LVDS == 1 )
4218 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4220 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4221 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4223 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4225 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4227 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4228 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4230 else
4232 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4239 /* --------------------------------------------------------------------- */
4240 /* Function : XGI_DisplayOff */
4241 /* Input : */
4242 /* Output : */
4243 /* Description : */
4244 /* --------------------------------------------------------------------- */
4245 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, struct vb_device_info *pVBInfo)
4248 if ( pXGIHWDE->jChipType == XG21 )
4250 if ( pVBInfo->IF_DEF_LVDS == 1 )
4252 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4253 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4255 else
4257 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4261 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4263 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4269 if ( pXGIHWDE->jChipType == XG27 )
4271 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4273 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4274 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4277 if ( pVBInfo->IF_DEF_LVDS == 0 )
4279 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4283 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4287 /* --------------------------------------------------------------------- */
4288 /* Function : XGI_WaitDisply */
4289 /* Input : */
4290 /* Output : */
4291 /* Description : chiawen for sensecrt1 */
4292 /* --------------------------------------------------------------------- */
4293 void XGI_WaitDisply(struct vb_device_info *pVBInfo)
4295 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4296 break ;
4298 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4299 break ;
4302 /* --------------------------------------------------------------------- */
4303 /* Function : XGI_SenseCRT1 */
4304 /* Input : */
4305 /* Output : */
4306 /* Description : */
4307 /* --------------------------------------------------------------------- */
4309 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
4311 unsigned char CRTCData[17] = {
4312 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4313 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4314 0x04 , 0x00 , 0x00 , 0x05 , 0x00 };
4316 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
4318 unsigned char CR17, CR63, SR31;
4319 unsigned short temp ;
4320 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F } ;
4322 int i ;
4323 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4325 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4326 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4327 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char)(XGINew_GetReg1(pVBInfo->P3d4, 0x53) | 0x02));
4329 SR31 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x31);
4330 CR63 = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x63);
4331 SR01 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x01);
4333 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char)(SR01 & 0xDF));
4334 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char)(CR63 & 0xBF));
4336 CR17 = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x17);
4337 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char)(CR17 | 0x80)) ;
4339 SR1F = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
4340 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char)(SR1F | 0x04));
4342 SR07 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x07);
4343 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char)(SR07 & 0xFB));
4344 SR06 = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x06);
4345 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char)(SR06 & 0xC3));
4347 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4349 for( i = 0 ; i < 8 ; i++ )
4350 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)i, CRTCData[i]);
4352 for( i = 8 ; i < 11 ; i++ )
4353 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 8), CRTCData[i]);
4355 for( i = 11 ; i < 13 ; i++ )
4356 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 4), CRTCData[i]);
4358 for( i = 13 ; i < 16 ; i++ )
4359 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short)(i - 3), CRTCData[i]);
4361 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char)(CRTCData[16] & 0xE0));
4363 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4364 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4365 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4367 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4369 for( i = 0 ; i < 256 ; i++ )
4371 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[0]);
4372 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[1]);
4373 XGINew_SetReg3((pVBInfo->P3c8 + 1), (unsigned char)DAC_TEST_PARMS[2]);
4376 XGI_VBLongWait( pVBInfo ) ;
4377 XGI_VBLongWait( pVBInfo ) ;
4378 XGI_VBLongWait( pVBInfo ) ;
4380 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4382 XGI_WaitDisply( pVBInfo ) ;
4383 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4385 if( temp & 0x10 )
4387 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4389 else
4391 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4394 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4395 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4397 for( i = 0 ; i < 256 ; i++ )
4399 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4400 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4401 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4404 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4405 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4406 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4408 /* [2004/05/11] Vicent */
4409 XGINew_SetReg1(pVBInfo->P3d4, 0x53,
4410 (unsigned char)(XGINew_GetReg1(pVBInfo->P3d4, 0x53) & 0xFD));
4411 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char)SR1F);
4423 /* --------------------------------------------------------------------- */
4424 /* Function : XGI_WaitDisplay */
4425 /* Input : */
4426 /* Output : */
4427 /* Description : */
4428 /* --------------------------------------------------------------------- */
4429 void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4431 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4433 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4439 /* --------------------------------------------------------------------- */
4440 /* Function : XGI_SetCRT2Group301 */
4441 /* Input : */
4442 /* Output : */
4443 /* Description : */
4444 /* --------------------------------------------------------------------- */
4445 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
4446 struct xgi_hw_device_info *HwDeviceExtension,
4447 struct vb_device_info *pVBInfo)
4449 unsigned short tempbx ,
4450 ModeIdIndex ,
4451 RefreshRateTableIndex ;
4453 tempbx=pVBInfo->VBInfo ;
4454 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4455 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4456 pVBInfo->SelectCRT2Rate = 4 ;
4457 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4458 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4459 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4460 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4461 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4462 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4463 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4464 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4465 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4466 XGI_SetTap4Regs(pVBInfo) ;
4467 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4468 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4469 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4470 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4471 XGI_AutoThreshold( pVBInfo) ;
4472 return 1 ;
4476 /* --------------------------------------------------------------------- */
4477 /* Function : XGI_AutoThreshold */
4478 /* Input : */
4479 /* Output : */
4480 /* Description : */
4481 /* --------------------------------------------------------------------- */
4482 void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4484 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4485 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4489 /* --------------------------------------------------------------------- */
4490 /* Function : XGI_SaveCRT2Info */
4491 /* Input : */
4492 /* Output : */
4493 /* Description : */
4494 /* --------------------------------------------------------------------- */
4495 void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
4497 unsigned short temp1 ,
4498 temp2 ;
4500 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4501 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4502 temp2 = ~( SetInSlaveMode >> 8 ) ;
4503 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4507 /* --------------------------------------------------------------------- */
4508 /* Function : XGI_GetCRT2ResInfo */
4509 /* Input : */
4510 /* Output : */
4511 /* Description : */
4512 /* --------------------------------------------------------------------- */
4513 void XGI_GetCRT2ResInfo(unsigned short ModeNo,
4514 unsigned short ModeIdIndex,
4515 struct vb_device_info *pVBInfo)
4517 unsigned short xres ,
4518 yres ,
4519 modeflag ,
4520 resindex ;
4522 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4523 if ( ModeNo <= 0x13 )
4525 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4526 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4527 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4529 else
4531 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4532 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4533 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4535 /* if ( pVBInfo->IF_DEF_FSTN )
4537 xres *= 2 ;
4538 yres *= 2 ;
4540 else
4543 if ( modeflag & HalfDCLK )
4544 xres *= 2;
4546 if ( modeflag & DoubleScanMode )
4547 yres *= 2 ;
4548 /* } */
4551 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4553 if ( pVBInfo->IF_DEF_LVDS == 0 )
4555 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4557 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4559 if ( yres == 1024 )
4560 yres = 1056 ;
4564 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4566 if ( yres == 400 )
4567 yres = 405 ;
4568 else if ( yres == 350 )
4569 yres = 360 ;
4571 if ( pVBInfo->LCDInfo & LCDVESATiming )
4573 if ( yres == 360 )
4574 yres = 375 ;
4578 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4580 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4582 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4584 if ( yres == 350 )
4585 yres = 357 ;
4586 else if ( yres == 400 )
4587 yres = 420 ;
4588 else if ( yres == 480 )
4589 yres = 525 ;
4595 if ( xres == 720 )
4596 xres = 640 ;
4599 pVBInfo->VGAHDE = xres ;
4600 pVBInfo->HDE = xres ;
4601 pVBInfo->VGAVDE = yres ;
4602 pVBInfo->VDE = yres ;
4606 /* --------------------------------------------------------------------- */
4607 /* Function : XGI_IsLCDDualLink */
4608 /* Input : */
4609 /* Output : */
4610 /* Description : */
4611 /* --------------------------------------------------------------------- */
4612 unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
4615 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4616 return ( 1 ) ;
4618 return( 0 ) ;
4622 /* --------------------------------------------------------------------- */
4623 /* Function : XGI_GetCRT2Data */
4624 /* Input : */
4625 /* Output : */
4626 /* Description : */
4627 /* --------------------------------------------------------------------- */
4628 void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
4630 unsigned short tempax = 0,
4631 tempbx ,
4632 modeflag ,
4633 resinfo ;
4635 struct XGI_LCDDataStruct *LCDPtr = NULL ;
4636 struct XGI_TVDataStruct *TVPtr = NULL ;
4638 if ( ModeNo <= 0x13 )
4640 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4641 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4643 else
4645 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4646 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4649 pVBInfo->NewFlickerMode = 0 ;
4650 pVBInfo->RVBHRS = 50 ;
4652 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4654 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4655 return ;
4658 tempbx = 4 ;
4660 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4662 LCDPtr = (struct XGI_LCDDataStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4664 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4665 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4666 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4667 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4668 pVBInfo->HT = LCDPtr->LCDHT ;
4669 pVBInfo->VT = LCDPtr->LCDVT ;
4671 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4673 tempax = 1024 ;
4674 tempbx = 768 ;
4676 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4678 if ( pVBInfo->VGAVDE == 357 )
4679 tempbx = 527 ;
4680 else if ( pVBInfo->VGAVDE == 420 )
4681 tempbx = 620 ;
4682 else if ( pVBInfo->VGAVDE == 525 )
4683 tempbx = 775 ;
4684 else if ( pVBInfo->VGAVDE == 600 )
4685 tempbx = 775 ;
4686 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4687 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4688 else
4689 tempbx = 768 ;
4691 else
4692 tempbx = 768 ;
4694 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4696 tempax = 1024 ;
4697 tempbx = 768 ;
4699 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4701 tempax = 1280 ;
4702 if ( pVBInfo->VGAVDE == 360 )
4703 tempbx = 768 ;
4704 else if ( pVBInfo->VGAVDE == 375 )
4705 tempbx = 800 ;
4706 else if ( pVBInfo->VGAVDE == 405 )
4707 tempbx = 864 ;
4708 else
4709 tempbx = 1024 ;
4711 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4713 tempax = 1280 ;
4714 tempbx = 1024 ;
4716 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4718 tempax = 1280 ;
4719 if ( pVBInfo->VGAVDE == 350 )
4720 tempbx = 700 ;
4721 else if ( pVBInfo->VGAVDE == 400 )
4722 tempbx = 800 ;
4723 else if ( pVBInfo->VGAVDE == 1024 )
4724 tempbx = 960 ;
4725 else
4726 tempbx = 960 ;
4728 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4730 tempax = 1400 ;
4731 tempbx = 1050 ;
4733 if ( pVBInfo->VGAVDE == 1024 )
4735 tempax = 1280 ;
4736 tempbx = 1024 ;
4739 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4741 tempax = 1600 ;
4742 tempbx = 1200 ; /* alan 10/14/2003 */
4743 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4745 if ( pVBInfo->VGAVDE == 350 )
4746 tempbx = 875 ;
4747 else if ( pVBInfo->VGAVDE == 400 )
4748 tempbx = 1000 ;
4752 if ( pVBInfo->LCDInfo & LCDNonExpanding )
4754 tempax = pVBInfo->VGAHDE ;
4755 tempbx = pVBInfo->VGAVDE ;
4758 pVBInfo->HDE = tempax ;
4759 pVBInfo->VDE = tempbx ;
4760 return ;
4763 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
4765 tempbx = 4 ;
4766 TVPtr = (struct XGI_TVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4768 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
4769 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
4770 pVBInfo->VGAHT = TVPtr->VGAHT ;
4771 pVBInfo->VGAVT = TVPtr->VGAVT ;
4772 pVBInfo->HDE = TVPtr->TVHDE ;
4773 pVBInfo->VDE = TVPtr->TVVDE ;
4774 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
4775 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
4777 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
4779 if ( resinfo == 0x08 )
4780 pVBInfo->NewFlickerMode = 0x40 ;
4781 else if ( resinfo == 0x09 )
4782 pVBInfo->NewFlickerMode = 0x40 ;
4783 else if ( resinfo == 0x12 )
4784 pVBInfo->NewFlickerMode = 0x40 ;
4786 if ( pVBInfo->VGAVDE == 350 )
4787 pVBInfo->TVInfo |= TVSimuMode ;
4789 tempax = ExtHiTVHT ;
4790 tempbx = ExtHiTVVT ;
4792 if ( pVBInfo->VBInfo & SetInSlaveMode )
4794 if ( pVBInfo->TVInfo & TVSimuMode )
4796 tempax = StHiTVHT ;
4797 tempbx = StHiTVVT ;
4799 if ( !( modeflag & Charx8Dot ) )
4801 tempax = StHiTextTVHT ;
4802 tempbx = StHiTextTVVT ;
4807 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
4809 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4811 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
4812 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
4815 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4817 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
4818 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
4820 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
4822 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
4823 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
4824 if ( pVBInfo->TVInfo & NTSC1024x768 )
4825 tempax = NTSC1024x768HT ;
4828 else
4830 tempax = PALHT ;
4831 tempbx = PALVT ;
4832 if ( !( pVBInfo->TVInfo & SetPALTV ) )
4834 tempax = NTSCHT ;
4835 tempbx = NTSCVT ;
4836 if ( pVBInfo->TVInfo & NTSC1024x768 )
4837 tempax = NTSC1024x768HT ;
4841 pVBInfo->HT = tempax ;
4842 pVBInfo->VT = tempbx ;
4843 return ;
4848 /* --------------------------------------------------------------------- */
4849 /* Function : XGI_SetCRT2VCLK */
4850 /* Input : */
4851 /* Output : */
4852 /* Description : */
4853 /* --------------------------------------------------------------------- */
4854 void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
4856 unsigned char di_0, di_1, tempal;
4858 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
4859 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
4860 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
4862 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
4863 { /* 301 */
4864 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
4865 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
4866 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
4868 else
4869 { /* 301b/302b/301lv/302lv */
4870 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
4871 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
4874 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
4876 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4877 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
4878 else
4879 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
4883 /* --------------------------------------------------------------------- */
4884 /* Function : XGI_GETLCDVCLKPtr */
4885 /* Input : */
4886 /* Output : al -> VCLK Index */
4887 /* Description : */
4888 /* --------------------------------------------------------------------- */
4889 void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
4890 struct vb_device_info *pVBInfo)
4892 unsigned short index ;
4894 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4896 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
4898 if ( pVBInfo->LCDInfo & EnableScalingLCD )
4899 return ;
4902 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
4903 index = XGI_GetLCDCapPtr1( pVBInfo) ;
4905 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4906 { /* LCDB */
4907 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
4908 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
4910 else
4911 { /* LCDA */
4912 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
4913 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
4916 return ;
4920 /* --------------------------------------------------------------------- */
4921 /* Function : XGI_GetVCLKPtr */
4922 /* Input : */
4923 /* Output : */
4924 /* Description : */
4925 /* --------------------------------------------------------------------- */
4926 unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
4927 unsigned short ModeNo, unsigned short ModeIdIndex,
4928 struct vb_device_info *pVBInfo)
4931 unsigned short index ,
4932 modeflag ;
4933 unsigned short tempbx ;
4934 unsigned char tempal;
4935 unsigned char *CHTVVCLKPtr = NULL;
4937 if ( ModeNo <= 0x13 )
4938 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4939 else
4940 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4943 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
4944 { /* {LCDA/LCDB} */
4945 index = XGI_GetLCDCapPtr(pVBInfo) ;
4946 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
4948 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4949 return tempal ;
4951 /* {TV} */
4952 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
4954 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
4956 tempal = HiTVVCLKDIV2;
4957 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
4958 tempal = HiTVVCLK;
4959 if(pVBInfo->TVInfo & TVSimuMode)
4961 tempal = HiTVSimuVCLK;
4962 if(!(modeflag & Charx8Dot))
4963 tempal = HiTVTextVCLK;
4966 return tempal;
4969 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4971 tempal = YPbPr750pVCLK ;
4972 return tempal ;
4975 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4977 tempal = YPbPr525pVCLK ;
4978 return tempal ;
4981 tempal = NTSC1024VCLK ;
4983 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
4985 tempal = TVVCLKDIV2 ;
4986 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
4987 tempal = TVVCLK ;
4990 if ( pVBInfo->VBInfo & SetCRT2ToTV )
4991 return tempal ;
4993 /*else
4994 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
4996 if(ModeNo<=0x13)
4997 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4998 else
4999 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5000 *tempal = *tempal & 0x1F;
5002 tempbx = 0;
5003 if(pVBInfo->TVInfo & SetPALTV)
5004 tempbx = tempbx + 2;
5005 if(pVBInfo->TVInfo & SetCHTVOverScan)
5006 tempbx++;
5007 tempbx = tempbx << 1;
5008 } */
5009 } /* {End of VB} */
5011 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
5013 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
5014 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
5016 if( ModeNo <= 0x13 )
5018 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5020 else
5022 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5025 tempal = tempal & 0x0F;
5026 tempbx = 0;
5028 if(pVBInfo->TVInfo & SetPALTV)
5030 tempbx = tempbx + 2;
5032 if(pVBInfo->TVInfo & SetCHTVOverScan)
5034 tempbx++;
5036 /** tempbx = tempbx << 1; CH7007 ? **/
5038 /*[Billy]07/05/29 CH7007*/
5039 if ( pVBInfo->IF_DEF_CH7007 == 1 )
5041 switch( tempbx )
5043 case 0:
5044 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
5045 break ;
5046 case 1:
5047 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5048 break ;
5049 case 2:
5050 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5051 break ;
5052 case 3:
5053 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5054 break ;
5055 default:
5056 break ;
5060 /*else
5062 switch( tempbx )
5064 case 0:
5065 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5066 break ;
5067 case 1:
5068 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5069 break ;
5070 case 2:
5071 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5072 break ;
5073 case 3:
5074 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5075 break ;
5076 default:
5077 break ;
5081 tempal = CHTVVCLKPtr[ tempal ] ;
5082 return tempal ;
5087 tempal = (unsigned char)XGINew_GetReg2((pVBInfo->P3ca + 0x02));
5088 tempal = tempal >> 2 ;
5089 tempal &= 0x03 ;
5091 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5092 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5094 if ( ModeNo <= 0x13 )
5095 return tempal ;
5097 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5098 return tempal ;
5102 /* --------------------------------------------------------------------- */
5103 /* Function : XGI_GetVCLKLen */
5104 /* Input : */
5105 /* Output : */
5106 /* Description : */
5107 /* --------------------------------------------------------------------- */
5108 void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
5109 unsigned char *di_1, struct vb_device_info *pVBInfo)
5111 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5113 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5114 *di_0 = (unsigned char)XGI_CH7007VCLKData[tempal].SR2B;
5115 *di_1 = (unsigned char)XGI_CH7007VCLKData[tempal].SR2C;
5117 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5119 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5121 *di_0 = (unsigned char)XGI_VBVCLKData[tempal].SR2B;
5122 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5125 else
5127 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5128 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5133 /* --------------------------------------------------------------------- */
5134 /* Function : XGI_SetCRT2Offset */
5135 /* Input : */
5136 /* Output : */
5137 /* Description : */
5138 /* --------------------------------------------------------------------- */
5139 void XGI_SetCRT2Offset(unsigned short ModeNo,
5140 unsigned short ModeIdIndex,
5141 unsigned short RefreshRateTableIndex,
5142 struct xgi_hw_device_info *HwDeviceExtension,
5143 struct vb_device_info *pVBInfo)
5145 unsigned short offset ;
5146 unsigned char temp;
5148 if ( pVBInfo->VBInfo & SetInSlaveMode )
5150 return ;
5153 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5154 temp = (unsigned char)(offset & 0xFF);
5155 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5156 temp = (unsigned char)((offset & 0xFF00) >> 8);
5157 XGINew_SetReg1(pVBInfo->Part1Port , 0x09 , temp);
5158 temp = (unsigned char)(((offset >> 3) & 0xFF) + 1) ;
5159 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
5163 /* --------------------------------------------------------------------- */
5164 /* Function : XGI_GetOffset */
5165 /* Input : */
5166 /* Output : */
5167 /* Description : */
5168 /* --------------------------------------------------------------------- */
5169 unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
5171 unsigned short temp ,
5172 colordepth ,
5173 modeinfo ,
5174 index ,
5175 infoflag ,
5176 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5178 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5179 if ( ModeNo <= 0x14 )
5180 infoflag = 0 ;
5181 else
5182 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5185 index = ( modeinfo >> 8 ) & 0xFF ;
5187 temp = pVBInfo->ScreenOffset[ index ] ;
5189 if ( infoflag & InterlaceMode )
5191 temp = temp << 1 ;
5194 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5196 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5198 temp = ModeNo - 0x7C ;
5199 colordepth = ColorDepth[ temp ] ;
5200 temp = 0x6B ;
5201 if ( infoflag & InterlaceMode )
5203 temp = temp << 1 ;
5205 return( temp * colordepth ) ;
5207 else
5208 return( temp * colordepth ) ;
5212 /* --------------------------------------------------------------------- */
5213 /* Function : XGI_SetCRT2FIFO */
5214 /* Input : */
5215 /* Output : */
5216 /* Description : */
5217 /* --------------------------------------------------------------------- */
5218 void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
5220 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5221 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5225 /* --------------------------------------------------------------------- */
5226 /* Function : XGI_PreSetGroup1 */
5227 /* Input : */
5228 /* Output : */
5229 /* Description : */
5230 /* --------------------------------------------------------------------- */
5231 void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
5232 struct xgi_hw_device_info *HwDeviceExtension,
5233 unsigned short RefreshRateTableIndex,
5234 struct vb_device_info *pVBInfo)
5236 unsigned short tempcx = 0 ,
5237 CRT1Index = 0 ,
5238 resinfo = 0 ;
5240 if ( ModeNo > 0x13 )
5242 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5243 CRT1Index &= IndexMask ;
5244 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5247 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5248 XGI_SetCRT2FIFO(pVBInfo) ;
5249 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5251 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5253 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5256 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5257 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5261 /* --------------------------------------------------------------------- */
5262 /* Function : XGI_SetGroup1 */
5263 /* Input : */
5264 /* Output : */
5265 /* Description : */
5266 /* --------------------------------------------------------------------- */
5267 void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
5268 struct xgi_hw_device_info *HwDeviceExtension,
5269 unsigned short RefreshRateTableIndex,
5270 struct vb_device_info *pVBInfo)
5272 unsigned short temp = 0 ,
5273 tempax = 0 ,
5274 tempbx = 0 ,
5275 tempcx = 0 ,
5276 pushbx = 0 ,
5277 CRT1Index = 0 ,
5278 modeflag ,
5279 resinfo = 0 ;
5281 if ( ModeNo > 0x13 )
5283 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5284 CRT1Index &= IndexMask ;
5285 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5288 if ( ModeNo <= 0x13 )
5290 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5292 else
5294 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5297 /* bainy change table name */
5298 if ( modeflag & HalfDCLK )
5300 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5301 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5302 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5303 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5304 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5305 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5306 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5307 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5308 tempcx = tempcx >> 1 ;
5309 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5310 tempcx += tempbx ;
5312 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5314 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5315 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5316 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5317 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5318 tempcx &= 0x1F ;
5319 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5320 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5321 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5324 tempbx += 4 ;
5325 tempcx += 4 ;
5327 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5328 tempcx = pVBInfo->VGAHT / 2 ;
5330 temp = tempbx & 0x00FF ;
5332 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5334 else
5336 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5337 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5338 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5339 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5340 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5341 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5342 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5343 pushbx = pVBInfo->VGAHDE + 16 ;
5344 tempcx = tempcx >> 1 ;
5345 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5346 tempcx += tempbx ;
5348 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5350 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5351 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5352 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5353 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5354 tempcx &= 0x1F ;
5355 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5356 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5357 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5358 tempbx += 16 ;
5359 tempcx += 16 ;
5362 if ( tempcx > pVBInfo->VGAHT )
5363 tempcx = pVBInfo->VGAHT ;
5365 temp = tempbx & 0x00FF ;
5366 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5369 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5370 tempbx = pushbx ;
5371 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5372 tempax |= ( tempbx & 0xFF00 ) ;
5373 temp = ( tempax & 0xFF00 ) >> 8 ;
5374 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5375 temp = tempcx & 0x00FF ;
5376 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5377 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5378 temp = tempcx & 0x00FF ;
5380 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5382 if ( pVBInfo->VBInfo & 0x0C )
5384 temp-- ;
5388 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5389 tempbx = pVBInfo->VGAVDE - 1 ;
5390 temp = tempbx & 0x00FF ;
5391 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5392 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5393 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5394 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5396 tempax = pVBInfo->VGAVDE ;
5397 tempbx = pVBInfo->VGAVDE ;
5398 tempcx = pVBInfo->VGAVT ;
5399 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5400 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5402 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5404 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5405 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5407 if ( temp & 0x04 )
5408 tempbx |= 0x0100 ;
5410 if ( temp & 0x080 )
5411 tempbx |= 0x0200 ;
5413 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5415 if ( temp & 0x08 )
5416 tempbx |= 0x0400 ;
5418 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5419 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5422 temp = tempbx & 0x00FF ;
5423 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5424 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5425 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5426 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5427 tempax = 0 ;
5429 if ( modeflag & DoubleScanMode )
5430 tempax |= 0x80 ;
5432 if ( modeflag & HalfDCLK )
5433 tempax |= 0x40 ;
5435 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5439 /* --------------------------------------------------------------------- */
5440 /* Function : XGI_SetLockRegs */
5441 /* Input : */
5442 /* Output : */
5443 /* Description : */
5444 /* --------------------------------------------------------------------- */
5445 void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5446 struct xgi_hw_device_info *HwDeviceExtension,
5447 unsigned short RefreshRateTableIndex,
5448 struct vb_device_info *pVBInfo)
5450 unsigned short push1 ,
5451 push2 ,
5452 tempax ,
5453 tempbx = 0 ,
5454 tempcx ,
5455 temp ,
5456 resinfo ,
5457 modeflag ,
5458 CRT1Index ;
5460 if ( ModeNo <= 0x13 )
5462 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5463 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5465 else
5467 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5468 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5469 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5470 CRT1Index &= IndexMask;
5473 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5475 return ;
5478 temp = 0xFF ; /* set MAX HT */
5479 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5480 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5481 /* else */
5482 tempcx=0x08;
5484 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5485 modeflag |= Charx8Dot ;
5487 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5489 if ( modeflag & HalfDCLK )
5490 tempax = tempax >> 1 ;
5492 tempax = ( tempax / tempcx ) - 1 ;
5493 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5494 temp = tempax & 0x00FF ;
5495 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5497 temp = ( tempbx & 0xFF00 ) >> 8 ;
5499 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5501 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5502 temp += 2 ;
5504 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5506 if ( pVBInfo->VBType & VB_XGI301LV )
5508 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5510 if ( resinfo == 7 )
5511 temp -= 2 ;
5514 else
5515 if ( resinfo == 7 )
5516 temp -= 2 ;
5520 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5521 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5523 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5524 { /* 030226 bainy */
5525 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5526 tempax = pVBInfo->VGAHT ;
5527 else
5528 tempax = XGI_GetVGAHT2( pVBInfo) ;
5531 if ( tempax >= pVBInfo->VGAHT )
5533 tempax = pVBInfo->VGAHT ;
5536 if ( modeflag & HalfDCLK )
5538 tempax = tempax >> 1 ;
5541 tempax = ( tempax / tempcx ) - 5 ;
5542 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5543 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5545 temp = ( tempbx & 0x00FF ) - 1 ;
5546 if ( !( modeflag & HalfDCLK ) )
5548 temp -= 6 ;
5549 if ( pVBInfo->TVInfo & TVSimuMode )
5551 temp -= 4 ;
5552 if ( ModeNo > 0x13 )
5553 temp -= 10 ;
5557 else
5559 /* tempcx = tempbx & 0x00FF ; */
5560 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5561 tempcx = ( tempcx + tempbx ) >> 1 ;
5562 temp = ( tempcx & 0x00FF ) + 2 ;
5564 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5566 temp -= 1 ;
5567 if ( !( modeflag & HalfDCLK ) )
5569 if ( ( modeflag & Charx8Dot ) )
5571 temp += 4 ;
5572 if ( pVBInfo->VGAHDE >= 800 )
5574 temp -= 6 ;
5579 else
5581 if ( !( modeflag & HalfDCLK ) )
5583 temp -= 4 ;
5584 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5586 if( pVBInfo->VGAHDE >= 800 )
5588 temp -= 7 ;
5589 if ( pVBInfo->ModeType == ModeEGA )
5591 if ( pVBInfo->VGAVDE == 1024 )
5593 temp += 15 ;
5594 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5596 temp += 7 ;
5601 if ( pVBInfo->VGAHDE >= 1280 )
5603 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5605 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5607 temp += 28 ;
5617 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5618 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5620 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5622 if ( pVBInfo->TVInfo & TVSimuMode )
5624 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5626 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5627 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5630 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5632 if ( pVBInfo->TVInfo & SetNTSCTV )
5634 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5635 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5637 else
5639 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5640 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5641 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5645 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5647 if ( pVBInfo->TVInfo & SetNTSCTV )
5649 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5650 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5652 else
5654 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5655 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5656 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5660 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5662 if ( pVBInfo->TVInfo & SetNTSCTV )
5664 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5665 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5667 else
5669 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5670 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5676 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5677 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5678 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5680 tempbx = pVBInfo->VGAVT ;
5681 push1 = tempbx ;
5682 tempcx = 0x121 ;
5683 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5685 if ( tempbx == 357 )
5686 tempbx = 350 ;
5687 if ( tempbx == 360 )
5688 tempbx =350 ;
5689 if ( tempbx == 375 )
5690 tempbx = 350 ;
5691 if ( tempbx == 405 )
5692 tempbx = 400 ;
5693 if ( tempbx == 525 )
5694 tempbx = 480 ;
5696 push2 = tempbx ;
5698 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5700 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5702 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5704 if ( tempbx == 350 )
5705 tempbx += 5 ;
5706 if ( tempbx == 480 )
5707 tempbx += 5 ;
5711 tempbx-- ;
5712 temp = tempbx & 0x00FF ;
5713 tempbx-- ;
5714 temp = tempbx & 0x00FF ;
5715 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5716 tempbx = push2 ;
5717 tempbx-- ;
5718 temp = tempbx & 0x00FF ;
5719 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5721 if ( tempbx & 0x0100 )
5723 tempcx |= 0x0002 ;
5726 tempax = 0x000B ;
5728 if ( modeflag & DoubleScanMode )
5730 tempax |= 0x08000 ;
5733 if ( tempbx & 0x0200 )
5735 tempcx |= 0x0040 ;
5738 temp = ( tempax & 0xFF00 ) >> 8 ;
5739 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5741 if ( tempbx & 0x0400 )
5743 tempcx |= 0x0600 ;
5746 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5748 tempax = push1 ;
5749 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
5750 tempax = tempax >> 2 ;
5751 push1 = tempax ; /* push ax */
5753 if ( resinfo != 0x09 )
5755 tempax = tempax << 1 ;
5756 tempbx += tempax ;
5759 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5761 if ( pVBInfo->VBType & VB_XGI301LV )
5763 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
5764 tempbx -= 10 ;
5765 else
5767 if ( pVBInfo->TVInfo & TVSimuMode )
5769 if ( pVBInfo->TVInfo & SetPALTV )
5771 if ( pVBInfo->VBType & VB_XGI301LV )
5773 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5774 tempbx += 40 ;
5776 else
5777 tempbx += 40 ;
5782 else
5783 tempbx -= 10 ;
5785 else
5787 if ( pVBInfo->TVInfo & TVSimuMode )
5789 if ( pVBInfo->TVInfo & SetPALTV )
5791 if ( pVBInfo->VBType & VB_XGI301LV )
5793 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5794 tempbx += 40 ;
5796 else
5797 tempbx += 40 ;
5801 tempax = push1 ;
5802 tempax = tempax >> 2 ;
5803 tempax++ ;
5804 tempax += tempbx ;
5805 push1 = tempax ; /* push ax */
5807 if ( ( pVBInfo->TVInfo & SetPALTV ) )
5809 if ( tempbx <= 513 )
5811 if ( tempax >= 513 )
5813 tempbx = 513 ;
5818 temp = tempbx & 0x00FF ;
5819 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5820 tempbx-- ;
5821 temp = tempbx & 0x00FF ;
5822 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5824 if ( tempbx & 0x0100 )
5826 tempcx |= 0x0008 ;
5829 if ( tempbx & 0x0200 )
5831 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
5834 tempbx++ ;
5836 if ( tempbx & 0x0100 )
5838 tempcx |= 0x0004 ;
5841 if ( tempbx & 0x0200 )
5843 tempcx |= 0x0080 ;
5846 if ( tempbx & 0x0400 )
5848 tempcx |= 0x0C00 ;
5851 tempbx = push1 ; /* pop ax */
5852 temp = tempbx & 0x00FF ;
5853 temp &= 0x0F ;
5854 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
5856 if ( tempbx & 0x0010 )
5858 tempcx |= 0x2000 ;
5861 temp = tempcx & 0x00FF ;
5862 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
5863 temp = ( tempcx & 0x0FF00 ) >> 8 ;
5864 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
5865 tempax = modeflag ;
5866 temp = ( tempax & 0xFF00 ) >> 8 ;
5868 temp = ( temp >> 1 ) & 0x09 ;
5870 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5871 temp |= 0x01 ;
5873 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
5874 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
5875 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
5877 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
5878 temp = 0x80 ;
5879 else
5880 temp = 0x00 ;
5882 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
5884 return ;
5888 /* --------------------------------------------------------------------- */
5889 /* Function : XGI_SetGroup2 */
5890 /* Input : */
5891 /* Output : */
5892 /* Description : */
5893 /* --------------------------------------------------------------------- */
5894 void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,
5895 struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
5897 unsigned short i ,
5899 tempax ,
5900 tempbx ,
5901 tempcx ,
5902 temp ,
5903 push1 ,
5904 push2 ,
5905 modeflag ,
5906 resinfo ,
5907 crt2crtc ;
5908 unsigned char *TimingPoint ;
5910 unsigned long longtemp ,
5911 tempeax ,
5912 tempebx ,
5913 temp2 ,
5914 tempecx ;
5916 if ( ModeNo <= 0x13 )
5918 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5919 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5920 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5922 else
5924 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5925 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5926 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
5929 tempax = 0 ;
5931 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
5932 tempax |= 0x0800 ;
5934 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
5935 tempax |= 0x0400 ;
5937 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
5938 tempax |= 0x0200 ;
5940 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5941 tempax |= 0x1000 ;
5943 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5944 tempax |= 0x0100 ;
5946 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
5947 tempax &= 0xfe00 ;
5949 tempax = ( tempax & 0xff00 ) >> 8 ;
5951 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
5952 TimingPoint = pVBInfo->NTSCTiming ;
5954 if ( pVBInfo->TVInfo & SetPALTV )
5956 TimingPoint = pVBInfo->PALTiming ;
5959 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5961 TimingPoint = pVBInfo->HiTVExtTiming ;
5963 if ( pVBInfo->VBInfo & SetInSlaveMode )
5964 TimingPoint = pVBInfo->HiTVSt2Timing ;
5966 if ( pVBInfo->SetFlag & TVSimuMode )
5967 TimingPoint = pVBInfo->HiTVSt1Timing ;
5969 if ( !(modeflag & Charx8Dot) )
5970 TimingPoint = pVBInfo->HiTVTextTiming ;
5973 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5975 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5976 TimingPoint = pVBInfo->YPbPr525iTiming ;
5978 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5979 TimingPoint = pVBInfo->YPbPr525pTiming ;
5981 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5982 TimingPoint = pVBInfo->YPbPr750pTiming ;
5985 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
5987 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
5990 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
5992 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
5995 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5997 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
6000 temp = pVBInfo->NewFlickerMode ;
6001 temp &= 0x80 ;
6002 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
6004 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6005 tempax = 950 ;
6007 if ( pVBInfo->TVInfo & SetPALTV )
6008 tempax = 520 ;
6009 else
6010 tempax = 440 ;
6012 if ( pVBInfo->VDE <= tempax )
6014 tempax -= pVBInfo->VDE ;
6015 tempax = tempax >> 2 ;
6016 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
6017 push1 = tempax ;
6018 temp = ( tempax & 0xFF00 ) >> 8 ;
6019 temp += (unsigned short)TimingPoint[0];
6021 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6023 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
6025 tempcx=pVBInfo->VGAHDE;
6026 if ( tempcx >= 1024 )
6028 temp = 0x17 ; /* NTSC */
6029 if ( pVBInfo->TVInfo & SetPALTV )
6030 temp = 0x19 ; /* PAL */
6035 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6036 tempax = push1 ;
6037 temp = ( tempax & 0xFF00 ) >> 8 ;
6038 temp += TimingPoint[ 1 ] ;
6040 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6042 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
6044 tempcx = pVBInfo->VGAHDE ;
6045 if ( tempcx >= 1024 )
6047 temp = 0x1D ; /* NTSC */
6048 if ( pVBInfo->TVInfo & SetPALTV )
6049 temp = 0x52 ; /* PAL */
6053 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
6056 /* 301b */
6057 tempcx = pVBInfo->HT ;
6059 if ( XGI_IsLCDDualLink( pVBInfo ) )
6060 tempcx = tempcx >> 1 ;
6062 tempcx -= 2 ;
6063 temp = tempcx & 0x00FF ;
6064 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6066 temp = ( tempcx & 0xFF00 ) >> 8 ;
6067 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6069 tempcx = pVBInfo->HT >> 1 ;
6070 push1 = tempcx ; /* push cx */
6071 tempcx += 7 ;
6073 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6075 tempcx -= 4 ;
6078 temp = tempcx & 0x00FF ;
6079 temp = temp << 4 ;
6080 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6082 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6083 tempbx += tempcx ;
6084 push2 = tempbx ;
6085 temp = tempbx & 0x00FF ;
6086 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6087 temp = ( tempbx & 0xFF00 ) >> 8 ;
6088 temp = temp << 4 ;
6089 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6091 tempbx=push2;
6092 tempbx=tempbx+8;
6093 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6095 tempbx=tempbx-4;
6096 tempcx=tempbx;
6099 temp = ( tempbx & 0x00FF ) << 4 ;
6100 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6102 j += 2 ;
6103 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6104 temp = tempcx & 0x00FF ;
6105 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6106 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6107 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6109 tempcx += 8 ;
6110 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6112 tempcx -= 4 ;
6115 temp = tempcx & 0xFF ;
6116 temp = temp << 4 ;
6117 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6119 tempcx = push1 ; /* pop cx */
6120 j += 2 ;
6121 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6122 tempcx -= temp ;
6123 temp = tempcx & 0x00FF ;
6124 temp = temp << 4 ;
6125 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6127 tempcx -= 11 ;
6129 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6131 tempax = XGI_GetVGAHT2( pVBInfo) ;
6132 tempcx = tempax - 1 ;
6134 temp = tempcx & 0x00FF ;
6135 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6137 tempbx = pVBInfo->VDE ;
6139 if ( pVBInfo->VGAVDE == 360 )
6140 tempbx = 746 ;
6141 if ( pVBInfo->VGAVDE == 375 )
6142 tempbx = 746 ;
6143 if ( pVBInfo->VGAVDE == 405 )
6144 tempbx = 853 ;
6146 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6148 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6150 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6151 tempbx = tempbx >> 1 ;
6153 else
6154 tempbx = tempbx >> 1 ;
6157 tempbx -= 2 ;
6158 temp = tempbx & 0x00FF ;
6160 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6162 if ( pVBInfo->VBType & VB_XGI301LV )
6164 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6166 if ( pVBInfo->VBInfo & SetInSlaveMode )
6168 if ( ModeNo == 0x2f )
6169 temp += 1 ;
6173 else
6175 if ( pVBInfo->VBInfo & SetInSlaveMode )
6177 if ( ModeNo == 0x2f )
6178 temp += 1 ;
6183 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6185 temp = ( tempcx & 0xFF00 ) >> 8 ;
6186 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6188 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6190 if ( pVBInfo->VBType & VB_XGI301LV )
6192 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6194 temp |= 0x10 ;
6196 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6197 temp |= 0x20 ;
6200 else
6202 temp |= 0x10 ;
6203 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6204 temp |= 0x20 ;
6208 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6210 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6212 tempbx = pVBInfo->VDE ;
6213 tempcx = tempbx - 2 ;
6215 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6217 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6218 tempbx = tempbx >> 1 ;
6221 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6223 temp=0;
6224 if( tempcx & 0x0400 )
6225 temp |= 0x20 ;
6227 if ( tempbx & 0x0400 )
6228 temp |= 0x40 ;
6230 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6233 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6234 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6235 temp = ( tempbx - 3 ) & 0x00FF ;
6236 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6239 tempbx = tempbx & 0x00FF ;
6241 if ( !( modeflag & HalfDCLK ) )
6243 tempcx = pVBInfo->VGAHDE ;
6244 if ( tempcx >= pVBInfo->HDE )
6246 tempbx |= 0x2000 ;
6247 tempax &= 0x00FF ;
6251 tempcx = 0x0101 ;
6253 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6254 if(pVBInfo->VGAHDE>=1024)
6256 tempcx=0x1920;
6257 if(pVBInfo->VGAHDE>=1280)
6259 tempcx=0x1420;
6260 tempbx=tempbx&0xDFFF;
6265 if ( !( tempbx & 0x2000 ) )
6267 if ( modeflag & HalfDCLK )
6269 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6272 push1 = tempbx ;
6273 tempeax = pVBInfo->VGAHDE ;
6274 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6275 longtemp = tempeax * tempebx ;
6276 tempecx = tempcx & 0x00FF ;
6277 longtemp = longtemp / tempecx ;
6279 /* 301b */
6280 tempecx = 8 * 1024 ;
6282 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6284 tempecx = tempecx * 8 ;
6287 longtemp = longtemp * tempecx ;
6288 tempecx = pVBInfo->HDE ;
6289 temp2 = longtemp % tempecx ;
6290 tempeax = longtemp / tempecx ;
6291 if ( temp2 != 0 )
6293 tempeax += 1 ;
6296 tempax = (unsigned short)tempeax;
6298 /* 301b */
6299 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6301 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6303 /* end 301b */
6305 tempbx = push1 ;
6306 tempbx = (unsigned short)(((tempeax & 0x0000FF00) & 0x1F00) | (tempbx & 0x00FF));
6307 tempax = (unsigned short)(((tempeax & 0x000000FF) << 8) | (tempax & 0x00FF));
6308 temp = ( tempax & 0xFF00 ) >> 8 ;
6310 else
6312 temp = ( tempax & 0x00FF ) >> 8 ;
6315 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6316 temp = ( tempbx & 0xFF00 ) >> 8 ;
6317 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6318 temp = tempcx & 0x00FF ;
6320 if ( tempbx & 0x2000 )
6321 temp = 0 ;
6323 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6324 temp |= 0x18 ;
6326 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6327 if ( pVBInfo->TVInfo & SetPALTV )
6329 tempbx = 0x0382 ;
6330 tempcx = 0x007e ;
6332 else
6334 tempbx = 0x0369 ;
6335 tempcx = 0x0061 ;
6338 temp = tempbx & 0x00FF ;
6339 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6340 temp = tempcx & 0x00FF ;
6341 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6343 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6344 temp = temp << 2 ;
6345 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6347 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6349 temp |= 0x10 ;
6351 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6352 temp |= 0x20 ;
6354 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6355 temp |= 0x60 ;
6358 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6359 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6360 XGINew_SetReg1( pVBInfo->Part2Port , 0x43, (unsigned short)( temp - 3 ) ) ;
6362 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6364 if ( pVBInfo->TVInfo & NTSC1024x768 )
6366 TimingPoint = XGI_NTSC1024AdjTime ;
6367 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6369 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6371 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6375 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6376 if ( pVBInfo->VBType & VB_XGI301C )
6378 if ( pVBInfo->TVInfo & SetPALMTV )
6379 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6382 if ( pVBInfo->TVInfo & SetPALMTV )
6384 tempax = (unsigned char)XGINew_GetReg1(pVBInfo->Part2Port, 0x01);
6385 tempax-- ;
6386 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6388 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6389 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6392 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6394 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6396 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6400 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6402 return ;
6407 /* --------------------------------------------------------------------- */
6408 /* Function : XGI_SetLCDRegs */
6409 /* Input : */
6410 /* Output : */
6411 /* Description : */
6412 /* --------------------------------------------------------------------- */
6413 void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
6415 unsigned short push1 ,
6416 push2 ,
6417 pushbx ,
6418 tempax ,
6419 tempbx ,
6420 tempcx ,
6421 temp ,
6422 tempah ,
6423 tempbh ,
6424 tempch ,
6425 resinfo ,
6426 modeflag ,
6427 CRT1Index ;
6429 struct XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6432 if ( ModeNo <= 0x13 )
6434 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6435 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6437 else
6439 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6440 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6441 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6442 CRT1Index &= IndexMask ;
6445 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6447 return ;
6450 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6452 if ( XGI_IsLCDDualLink( pVBInfo ) )
6453 tempbx = tempbx >> 1 ;
6455 tempbx -= 1 ;
6456 temp = tempbx & 0x00FF ;
6457 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6458 temp = ( tempbx & 0xFF00 ) >> 8 ;
6459 temp = temp << 4 ;
6460 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6461 temp = 0x01 ;
6463 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6465 if ( pVBInfo->ModeType == ModeEGA )
6467 if ( pVBInfo->VGAHDE >= 1024 )
6469 temp = 0x02 ;
6470 if ( pVBInfo->LCDInfo & LCDVESATiming )
6471 temp = 0x01 ;
6476 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6477 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6478 push1 = tempbx ;
6479 tempbx-- ;
6480 temp = tempbx & 0x00FF ;
6481 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6482 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6483 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6485 tempcx = pVBInfo->VT - 1 ;
6486 push2 = tempcx + 1 ;
6487 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6488 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6489 temp = ( tempcx & 0xFF00 ) >> 8 ;
6490 temp = temp << 5 ;
6491 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6492 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6493 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6494 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6495 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6497 /* Customized LCDB Des no add */
6498 tempbx = 5 ;
6499 LCDBDesPtr = (struct XGI_LCDDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6500 tempah = pVBInfo->LCDResInfo ;
6501 tempah &= PanelResInfo ;
6503 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6505 tempbx = 1024 ;
6506 tempcx = 768 ;
6508 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6510 tempbx = 1280 ;
6511 tempcx = 1024 ;
6513 else if ( tempah == Panel1400x1050 )
6515 tempbx = 1400 ;
6516 tempcx = 1050 ;
6518 else
6520 tempbx = 1600 ;
6521 tempcx = 1200 ;
6524 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6526 tempbx = pVBInfo->HDE ;
6527 tempcx = pVBInfo->VDE ;
6530 pushbx = tempbx ;
6531 tempax = pVBInfo->VT ;
6532 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6533 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6534 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6535 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6536 tempbx = pVBInfo->LCDVDES ;
6537 tempcx += tempbx ;
6539 if ( tempcx >= tempax )
6540 tempcx -= tempax ; /* lcdvdes */
6542 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6543 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6544 temp = tempcx & 0x00FF ;
6545 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6546 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6547 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6548 tempah = tempch ;
6549 tempah = tempah << 3 ;
6550 tempah |= tempbh ;
6551 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6553 /* getlcdsync() */
6554 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6555 tempcx = tempbx ;
6556 tempax = pVBInfo->VT ;
6557 tempbx = pVBInfo->LCDVRS ;
6559 /* if ( SetLCD_Info & EnableScalingLCD ) */
6560 tempcx += tempbx ;
6561 if ( tempcx >= tempax )
6562 tempcx -= tempax ;
6564 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6565 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6566 temp = ( tempbx & 0xFF00 ) >> 8 ;
6567 temp = temp << 4 ;
6568 temp |= ( tempcx & 0x000F ) ;
6569 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6570 tempcx = pushbx ;
6571 tempax = pVBInfo->HT ;
6572 tempbx = pVBInfo->LCDHDES ;
6573 tempbx &= 0x0FFF ;
6575 if ( XGI_IsLCDDualLink( pVBInfo ) )
6577 tempax = tempax >> 1 ;
6578 tempbx = tempbx >> 1 ;
6579 tempcx = tempcx >> 1 ;
6582 if ( pVBInfo->VBType & VB_XGI302LV )
6583 tempbx += 1 ;
6585 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6586 tempbx += 1 ;
6588 tempcx += tempbx ;
6590 if ( tempcx >= tempax )
6591 tempcx -= tempax ;
6593 temp = tempbx & 0x00FF ;
6594 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6595 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6596 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6597 temp = tempcx & 0x00FF ;
6598 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6599 temp = ( tempcx & 0xFF00 ) >> 8 ;
6600 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6602 /* getlcdsync() */
6603 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6604 tempcx = tempax ;
6605 tempax = pVBInfo->HT ;
6606 tempbx = pVBInfo->LCDHRS ;
6607 /* if ( SetLCD_Info & EnableScalingLCD) */
6608 if ( XGI_IsLCDDualLink( pVBInfo) )
6610 tempax = tempax >> 1 ;
6611 tempbx = tempbx >> 1 ;
6612 tempcx = tempcx >> 1 ;
6615 if ( pVBInfo->VBType & VB_XGI302LV )
6616 tempbx += 1 ;
6618 tempcx += tempbx ;
6620 if ( tempcx >= tempax )
6621 tempcx -= tempax ;
6623 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6624 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6626 temp = ( tempbx & 0xFF00 ) >> 8 ;
6627 temp = temp << 4 ;
6628 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6629 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6630 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6632 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6634 if ( pVBInfo->VGAVDE == 525 )
6636 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6638 temp = 0xC6 ;
6640 else
6641 temp = 0xC4 ;
6643 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6644 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6647 if ( pVBInfo->VGAVDE == 420 )
6649 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6651 temp = 0x4F ;
6653 else
6654 temp = 0x4E ;
6655 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6661 /* --------------------------------------------------------------------- */
6662 /* Function : XGI_GetTap4Ptr */
6663 /* Input : */
6664 /* Output : di -> Tap4 Reg. Setting Pointer */
6665 /* Description : */
6666 /* --------------------------------------------------------------------- */
6667 struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
6668 struct vb_device_info *pVBInfo)
6670 unsigned short tempax ,
6671 tempbx ,
6674 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6676 if ( tempcx == 0 )
6678 tempax = pVBInfo->VGAHDE ;
6679 tempbx = pVBInfo->HDE ;
6681 else
6683 tempax = pVBInfo->VGAVDE ;
6684 tempbx = pVBInfo->VDE ;
6687 if ( tempax < tempbx )
6688 return &EnlargeTap4Timing[ 0 ] ;
6689 else if( tempax == tempbx )
6690 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6691 else
6692 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6694 if ( pVBInfo->TVInfo & SetPALTV )
6695 Tap4TimingPtr = PALTap4Timing ;
6698 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6700 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6701 Tap4TimingPtr = YPbPr525iTap4Timing ;
6702 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6703 Tap4TimingPtr = YPbPr525pTap4Timing ;
6704 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6705 Tap4TimingPtr = YPbPr750pTap4Timing ;
6708 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6709 Tap4TimingPtr = HiTVTap4Timing ;
6711 i = 0 ;
6712 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6714 if ( Tap4TimingPtr[ i ].DE == tempax )
6715 break ;
6716 i++ ;
6718 return &Tap4TimingPtr[ i ] ;
6722 /* --------------------------------------------------------------------- */
6723 /* Function : XGI_SetTap4Regs */
6724 /* Input : */
6725 /* Output : */
6726 /* Description : */
6727 /* --------------------------------------------------------------------- */
6728 void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
6730 unsigned short i ,
6733 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6735 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6736 return ;
6738 #ifndef Tap4
6739 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6740 #else /* Tap4 Setting */
6742 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6743 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6744 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6746 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6748 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6749 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6750 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6753 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6754 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
6755 else
6756 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
6757 #endif
6760 /* --------------------------------------------------------------------- */
6761 /* Function : XGI_SetGroup3 */
6762 /* Input : */
6763 /* Output : */
6764 /* Description : */
6765 /* --------------------------------------------------------------------- */
6766 void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6768 unsigned short i;
6769 unsigned char *tempdi;
6770 unsigned short modeflag;
6772 if(ModeNo<=0x13)
6774 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6776 else
6778 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6782 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
6783 if(pVBInfo->TVInfo&SetPALTV)
6785 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6786 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6788 else
6790 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
6791 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
6794 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
6796 return;
6799 if(pVBInfo->TVInfo&SetPALMTV)
6801 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6802 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6803 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
6806 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
6808 if(pVBInfo->TVInfo & SetYPbPrMode525i)
6810 return;
6812 tempdi=pVBInfo->HiTVGroup3Data;
6813 if(pVBInfo->SetFlag&TVSimuMode)
6815 tempdi=pVBInfo->HiTVGroup3Simu;
6816 if(!(modeflag&Charx8Dot))
6818 tempdi=pVBInfo->HiTVGroup3Text;
6822 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6824 tempdi=pVBInfo->Ren525pGroup3;
6826 if(pVBInfo->TVInfo & SetYPbPrMode750p)
6828 tempdi=pVBInfo->Ren750pGroup3;
6831 for(i=0;i<=0x3E;i++)
6833 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
6835 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
6837 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6839 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
6843 return;
6844 } /* {end of XGI_SetGroup3} */
6847 /* --------------------------------------------------------------------- */
6848 /* Function : XGI_SetGroup4 */
6849 /* Input : */
6850 /* Output : */
6851 /* Description : */
6852 /* --------------------------------------------------------------------- */
6853 void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
6855 unsigned short tempax ,
6856 tempcx ,
6857 tempbx ,
6858 modeflag ,
6859 temp ,
6860 temp2 ;
6862 unsigned long tempebx ,
6863 tempeax ,
6864 templong ;
6867 if ( ModeNo <= 0x13 )
6869 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6871 else
6873 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6876 temp = pVBInfo->RVBHCFACT ;
6877 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
6879 tempbx = pVBInfo->RVBHCMAX ;
6880 temp = tempbx & 0x00FF ;
6881 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
6882 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
6883 tempcx = pVBInfo->VGAHT - 1 ;
6884 temp = tempcx & 0x00FF ;
6885 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
6887 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
6888 temp2 |= temp ;
6890 tempcx = pVBInfo->VGAVT - 1 ;
6891 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6893 tempcx -= 5 ;
6896 temp = tempcx & 0x00FF ;
6897 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
6898 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
6899 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
6900 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
6901 tempcx = pVBInfo->VBInfo ;
6902 tempbx = pVBInfo->VGAHDE ;
6904 if ( modeflag & HalfDCLK )
6906 tempbx = tempbx >> 1 ;
6909 if ( XGI_IsLCDDualLink( pVBInfo ) )
6910 tempbx = tempbx >> 1 ;
6912 if(tempcx&SetCRT2ToHiVisionTV)
6914 temp=0;
6915 if(tempbx<=1024)
6916 temp=0xA0;
6917 if(tempbx == 1280)
6918 temp = 0xC0;
6920 else if(tempcx&SetCRT2ToTV)
6922 temp=0xA0;
6923 if(tempbx <= 800)
6924 temp=0x80;
6926 else
6928 temp=0x80;
6929 if(pVBInfo->VBInfo&SetCRT2ToLCD)
6931 temp=0;
6932 if(tempbx>800)
6933 temp=0x60;
6937 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6939 temp = 0x00 ;
6940 if ( pVBInfo->VGAHDE == 1280 )
6941 temp = 0x40 ;
6942 if ( pVBInfo->VGAHDE == 1024 )
6943 temp = 0x20 ;
6945 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
6947 tempebx = pVBInfo->VDE ;
6949 if ( tempcx & SetCRT2ToHiVisionTV )
6951 if ( !( temp & 0xE000 ) )
6952 tempbx = tempbx >> 1 ;
6955 tempcx = pVBInfo->RVBHRS ;
6956 temp = tempcx & 0x00FF ;
6957 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
6959 tempeax = pVBInfo->VGAVDE ;
6960 tempcx |= 0x04000 ;
6963 if ( tempeax <= tempebx )
6965 tempcx=(tempcx&(~0x4000));
6966 tempeax = pVBInfo->VGAVDE ;
6968 else
6970 tempeax -= tempebx ;
6974 templong = ( tempeax * 256 * 1024 ) % tempebx ;
6975 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
6976 tempebx = tempeax ;
6978 if ( templong != 0 )
6980 tempebx++ ;
6984 temp = (unsigned short)(tempebx & 0x000000FF);
6985 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
6987 temp = (unsigned short)((tempebx & 0x0000FF00) >> 8);
6988 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
6989 tempbx = (unsigned short)(tempebx >> 16);
6990 temp = tempbx & 0x00FF ;
6991 temp = temp << 4 ;
6992 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
6993 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
6995 /* 301b */
6996 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6998 temp = 0x0028 ;
6999 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
7000 tempax = pVBInfo->VGAHDE ;
7001 if ( modeflag & HalfDCLK )
7003 tempax = tempax >> 1 ;
7006 if ( XGI_IsLCDDualLink( pVBInfo ) )
7007 tempax = tempax >> 1 ;
7009 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
7010 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
7012 if ( tempax > 800 )
7013 tempax -= 800 ;
7015 else
7017 if ( pVBInfo->VGAHDE > 800 )
7019 if ( pVBInfo->VGAHDE == 1024 )
7020 tempax = ( tempax * 25 / 32 ) - 1 ;
7021 else
7022 tempax = ( tempax * 20 / 32 ) - 1 ;
7025 tempax -= 1 ;
7028 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7030 if ( pVBInfo->VBType & VB_XGI301LV )
7032 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7034 if ( pVBInfo->VGAHDE > 800 )
7036 if ( pVBInfo->VGAHDE == 1024 )
7037 tempax = ( tempax * 25 / 32 ) - 1 ;
7038 else
7039 tempax = ( tempax * 20 / 32 ) - 1 ;
7043 else
7045 if ( pVBInfo->VGAHDE > 800 )
7047 if ( pVBInfo->VGAHDE == 1024 )
7048 tempax = ( tempax * 25 / 32 ) - 1 ;
7049 else
7050 tempax = ( tempax * 20 / 32 ) - 1 ;
7056 temp = ( tempax & 0xFF00 ) >> 8 ;
7057 temp = ( ( temp & 0x0003 ) << 4 ) ;
7058 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
7059 temp = ( tempax & 0x00FF ) ;
7060 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7062 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7064 if ( pVBInfo->VGAHDE > 800 )
7066 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7069 temp = 0x0036 ;
7071 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7073 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7075 temp |= 0x0001 ;
7076 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7077 temp &= ( ~0x0001 ) ;
7081 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7082 tempbx = pVBInfo->HT ;
7083 if ( XGI_IsLCDDualLink( pVBInfo ) )
7084 tempbx = tempbx >> 1 ;
7085 tempbx = ( tempbx >> 1 ) - 2 ;
7086 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7087 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7088 temp = tempbx & 0x00FF ;
7089 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7091 /* end 301b */
7093 if ( pVBInfo->ISXPDOS == 0 )
7094 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7098 /* --------------------------------------------------------------------- */
7099 /* Function : XGI_SetGroup5 */
7100 /* Input : */
7101 /* Output : */
7102 /* Description : */
7103 /* --------------------------------------------------------------------- */
7104 void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
7106 unsigned short Pindex ,
7107 Pdata ;
7109 Pindex = pVBInfo->Part5Port ;
7110 Pdata = pVBInfo->Part5Port + 1 ;
7111 if ( pVBInfo->ModeType == ModeVGA )
7113 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7115 XGINew_EnableCRT2(pVBInfo) ;
7116 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7119 return ;
7123 /* --------------------------------------------------------------------- */
7124 /* Function : XGI_GetLcdPtr */
7125 /* Input : */
7126 /* Output : */
7127 /* Description : */
7128 /* --------------------------------------------------------------------- */
7129 void *XGI_GetLcdPtr(unsigned short BX,
7130 unsigned short ModeNo,
7131 unsigned short ModeIdIndex,
7132 unsigned short RefreshRateTableIndex,
7133 struct vb_device_info *pVBInfo)
7135 unsigned short i ,
7136 tempdx ,
7137 tempcx ,
7138 tempbx ,
7139 tempal ,
7140 modeflag ,
7141 table ;
7143 struct XGI330_LCDDataTablStruct *tempdi = 0 ;
7146 tempbx = BX;
7148 if ( ModeNo <= 0x13 )
7150 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7151 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7153 else
7155 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7156 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7159 tempal = tempal & 0x0f ;
7161 if ( tempbx <= 1 ) /* ExpLink */
7163 if ( ModeNo <= 0x13 )
7165 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7167 else
7169 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7172 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7174 if ( ModeNo <= 0x13 )
7175 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7176 else
7177 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7180 if ( tempbx & 0x01 )
7181 tempal = ( tempal >> 4 ) ;
7183 tempal = ( tempal & 0x0f ) ;
7186 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7188 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7190 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7191 tempcx = LCDDesDataLen2 ;
7192 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7193 tempcx = LVDSDesDataLen2 ;
7195 /* mov di, word ptr cs:LCDDataList[bx] */
7196 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7198 switch( tempbx )
7200 case 0:
7201 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7202 break ;
7203 case 1:
7204 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7205 break ;
7206 case 2:
7207 tempdi = XGI_EPLLCDDataPtr ;
7208 break ;
7209 case 3:
7210 tempdi = XGI_EPLLCDDesDataPtr ;
7211 break ;
7212 case 4:
7213 tempdi = XGI_LCDDataTable ;
7214 break ;
7215 case 5:
7216 tempdi = XGI_LCDDesDataTable ;
7217 break ;
7218 case 6:
7219 tempdi = XGI_EPLCHLCDRegPtr ;
7220 break ;
7221 case 7:
7222 case 8:
7223 case 9:
7224 tempdi = 0 ;
7225 break ;
7226 default:
7227 break ;
7230 if ( tempdi == 0x00 ) /* OEMUtil */
7231 return 0 ;
7233 table = tempbx ;
7234 i = 0 ;
7236 while( tempdi[ i ].PANELID != 0xff )
7238 tempdx = pVBInfo->LCDResInfo ;
7239 if ( tempbx & 0x0080 ) /* OEMUtil */
7241 tempbx &= ( ~0x0080 ) ;
7242 tempdx = pVBInfo->LCDTypeInfo ;
7245 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7246 tempdx &= ( ~PanelResInfo ) ;
7248 if ( tempdi[ i ].PANELID == tempdx )
7250 tempbx = tempdi[ i ].MASK ;
7251 tempdx = pVBInfo->LCDInfo ;
7253 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7254 tempdx |= SetLCDStdMode ;
7256 if ( modeflag & HalfDCLK )
7257 tempdx |= SetLCDLowResolution ;
7259 tempbx &= tempdx;
7260 if ( tempbx == tempdi[ i ].CAP )
7261 break ;
7263 i++ ;
7266 if ( table == 0 )
7268 switch( tempdi[ i ].DATAPTR )
7270 case 0:
7271 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7272 break ;
7273 case 1:
7274 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7275 break ;
7276 case 2:
7277 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7278 break ;
7279 case 3:
7280 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7281 break ;
7282 case 4:
7283 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7284 break ;
7285 case 5:
7286 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7287 break ;
7288 case 6:
7289 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7290 break ;
7291 case 7:
7292 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7293 break ;
7294 case 8:
7295 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7296 break ;
7297 case 9:
7298 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7299 break ;
7300 case 10:
7301 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7302 break ;
7303 default:
7304 break ;
7307 else if ( table == 1 )
7309 switch( tempdi[ i ].DATAPTR )
7311 case 0:
7312 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7313 break ;
7314 case 1:
7315 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7316 break ;
7317 case 2:
7318 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7319 break ;
7320 case 3:
7321 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7322 break ;
7323 case 4:
7324 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7325 break ;
7326 case 5:
7327 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7328 break ;
7329 case 6:
7330 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7331 break ;
7332 case 7:
7333 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7334 break ;
7335 case 8:
7336 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7337 break ;
7338 case 9:
7339 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7340 break ;
7341 case 10:
7342 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7343 break ;
7344 default:
7345 break ;
7348 else if ( table == 2 )
7350 switch( tempdi[ i ].DATAPTR )
7352 case 0:
7353 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7354 break ;
7355 case 1:
7356 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7357 break ;
7358 case 2:
7359 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7360 break ;
7361 case 3:
7362 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7363 break ;
7364 case 4:
7365 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7366 break ;
7367 case 5:
7368 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7369 break ;
7370 case 6:
7371 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7372 break ;
7373 case 7:
7374 return &XGI_LVDSNoScalingData[ tempal ] ;
7375 break ;
7376 case 8:
7377 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7378 break ;
7379 case 9:
7380 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7381 break ;
7382 case 10:
7383 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7384 break ;
7385 case 11:
7386 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7387 break ;
7388 case 12:
7389 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7390 break ;
7391 default:
7392 break ;
7395 else if ( table == 3 )
7397 switch( tempdi[ i ].DATAPTR )
7399 case 0:
7400 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7401 break ;
7402 case 1:
7403 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7404 break ;
7405 case 2:
7406 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7407 break ;
7408 case 3:
7409 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7410 break ;
7411 case 4:
7412 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7413 break ;
7414 case 5:
7415 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7416 break ;
7417 case 6:
7418 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7419 break ;
7420 case 7:
7421 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7422 break ;
7423 case 8:
7424 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7425 break ;
7426 case 9:
7427 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7428 break ;
7429 case 10:
7430 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7431 break ;
7432 case 11:
7433 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7434 break;
7435 case 12:
7436 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7437 break ;
7438 case 13:
7439 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7440 break ;
7441 case 14:
7442 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7443 break ;
7444 default:
7445 break ;
7448 else if ( table == 4 )
7450 switch( tempdi[ i ].DATAPTR )
7452 case 0:
7453 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7454 break ;
7455 case 1:
7456 return &XGI_StLCD1024x768Data[ tempal ] ;
7457 break ;
7458 case 2:
7459 return &XGI_CetLCD1024x768Data[ tempal ] ;
7460 break ;
7461 case 3:
7462 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7463 break ;
7464 case 4:
7465 return &XGI_StLCD1280x1024Data[ tempal ] ;
7466 break ;
7467 case 5:
7468 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7469 break ;
7470 case 6:
7471 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7472 break ;
7473 case 7:
7474 return &XGI_StLCD1400x1050Data[ tempal ] ;
7475 break ;
7476 case 8:
7477 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7478 break ;
7479 case 9:
7480 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7481 break ;
7482 case 10:
7483 return &XGI_StLCD1600x1200Data[ tempal ] ;
7484 break ;
7485 case 11:
7486 return &XGI_NoScalingData[ tempal ] ;
7487 break ;
7488 case 12:
7489 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7490 break ;
7491 case 13:
7492 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7493 break ;
7494 case 14:
7495 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7496 break ;
7497 case 15:
7498 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7499 break ;
7500 case 16:
7501 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7502 break;
7503 case 17:
7504 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7505 break;
7506 case 18:
7507 return &XGI_NoScalingDatax75[ tempal ] ;
7508 break ;
7509 default:
7510 break ;
7513 else if ( table == 5 )
7515 switch( tempdi[ i ].DATAPTR )
7517 case 0:
7518 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7519 break ;
7520 case 1:
7521 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7522 break ;
7523 case 2:
7524 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7525 break ;
7526 case 3:
7527 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7528 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7529 else
7530 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7531 break ;
7532 case 4:
7533 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7534 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7535 else
7536 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7537 break ;
7538 case 5:
7539 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7540 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7541 else
7542 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7543 break ;
7544 case 6:
7545 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7546 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7547 else
7548 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7549 break ;
7550 case 7:
7551 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7552 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7553 else
7554 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7555 break ;
7556 case 8:
7557 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7558 break ;
7559 case 9:
7560 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7561 break ;
7562 case 10:
7563 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7564 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7565 else
7566 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7567 break ;
7568 case 11:
7569 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7570 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7571 else
7572 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7573 break ;
7574 case 12:
7575 return &XGI_NoScalingDesData[ tempal ] ;
7576 break;
7577 case 13:
7578 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7579 break ;
7580 case 14:
7581 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7582 break ;
7583 case 15:
7584 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7585 break ;
7586 case 16:
7587 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7588 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7589 else
7590 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7591 break ;
7592 case 17:
7593 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7594 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7595 else
7596 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7597 break ;
7598 case 18:
7599 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7600 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7601 else
7602 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7603 break ;
7604 case 19:
7605 return &XGI_NoScalingDesDatax75[ tempal ] ;
7606 break ;
7607 default:
7608 break ;
7611 else if ( table == 6 )
7613 switch( tempdi[ i ].DATAPTR )
7615 case 0:
7616 return &XGI_CH7017LV1024x768[ tempal ] ;
7617 break ;
7618 case 1:
7619 return &XGI_CH7017LV1400x1050[ tempal ] ;
7620 break ;
7621 default:
7622 break ;
7625 return 0 ;
7629 /* --------------------------------------------------------------------- */
7630 /* Function : XGI_GetTVPtr */
7631 /* Input : */
7632 /* Output : */
7633 /* Description : */
7634 /* --------------------------------------------------------------------- */
7635 void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
7636 unsigned short ModeIdIndex,
7637 unsigned short RefreshRateTableIndex,
7638 struct vb_device_info *pVBInfo)
7640 unsigned short i , tempdx , tempbx , tempal , modeflag , table ;
7641 struct XGI330_TVDataTablStruct *tempdi = 0 ;
7643 tempbx = BX ;
7645 if ( ModeNo <= 0x13 )
7647 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7648 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7650 else
7652 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7653 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7656 tempal = tempal & 0x3f ;
7657 table = tempbx ;
7659 switch( tempbx )
7661 case 0:
7662 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7663 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7665 tempdi = XGI_EPLCHTVCRT1Ptr;
7667 break ;
7668 case 1:
7669 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7670 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7672 tempdi = XGI_EPLCHTVCRT1Ptr;
7674 break ;
7675 case 2:
7676 tempdi = XGI_EPLCHTVDataPtr ;
7677 break ;
7678 case 3:
7679 tempdi = 0 ;
7680 break ;
7681 case 4:
7682 tempdi = XGI_TVDataTable ;
7683 break ;
7684 case 5:
7685 tempdi = 0 ;
7686 break ;
7687 case 6:
7688 tempdi = XGI_EPLCHTVRegPtr ;
7689 break ;
7690 default:
7691 break ;
7694 if ( tempdi == 0x00 ) /* OEMUtil */
7695 return( 0 ) ;
7697 tempdx = pVBInfo->TVInfo ;
7699 if ( pVBInfo->VBInfo & SetInSlaveMode )
7700 tempdx = tempdx | SetTVLockMode ;
7702 if ( modeflag & HalfDCLK )
7703 tempdx = tempdx | SetTVLowResolution ;
7705 i = 0 ;
7707 while( tempdi[ i ].MASK != 0xffff )
7709 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7710 break ;
7711 i++ ;
7714 if ( table == 0x00 ) /* 07/05/22 */
7717 else if ( table == 0x01 )
7720 else if ( table == 0x04 )
7722 switch( tempdi[ i ].DATAPTR )
7724 case 0:
7725 return &XGI_ExtPALData[ tempal ] ;
7726 break ;
7727 case 1:
7728 return &XGI_ExtNTSCData[ tempal ] ;
7729 break ;
7730 case 2:
7731 return &XGI_StPALData[ tempal ] ;
7732 break ;
7733 case 3:
7734 return &XGI_StNTSCData[ tempal ] ;
7735 break ;
7736 case 4:
7737 return &XGI_ExtHiTVData[ tempal ] ;
7738 break ;
7739 case 5:
7740 return &XGI_St2HiTVData[ tempal ] ;
7741 break ;
7742 case 6:
7743 return &XGI_ExtYPbPr525iData[ tempal ] ;
7744 break ;
7745 case 7:
7746 return &XGI_ExtYPbPr525pData[ tempal ] ;
7747 break ;
7748 case 8:
7749 return &XGI_ExtYPbPr750pData[ tempal ] ;
7750 break ;
7751 case 9:
7752 return &XGI_StYPbPr525iData[ tempal ] ;
7753 break ;
7754 case 10:
7755 return &XGI_StYPbPr525pData[ tempal ] ;
7756 break ;
7757 case 11:
7758 return &XGI_StYPbPr750pData[ tempal ] ;
7759 break;
7760 case 12: /* avoid system hang */
7761 return &XGI_ExtNTSCData[ tempal ] ;
7762 break ;
7763 case 13:
7764 return &XGI_St1HiTVData[ tempal ] ;
7765 break ;
7766 default:
7767 break ;
7770 else if( table == 0x02 )
7772 switch( tempdi[ i ].DATAPTR )
7774 case 0:
7775 return &XGI_CHTVUNTSCData[ tempal ] ;
7776 break ;
7777 case 1:
7778 return &XGI_CHTVONTSCData[ tempal ] ;
7779 break ;
7780 case 2:
7781 return &XGI_CHTVUPALData[ tempal ] ;
7782 break ;
7783 case 3:
7784 return &XGI_CHTVOPALData[ tempal ] ;
7785 break ;
7786 default:
7787 break ;
7790 else if( table == 0x06 )
7793 return( 0 ) ;
7797 /* --------------------------------------------------------------------- */
7798 /* Function : XGI_BacklightByDrv */
7799 /* Input : */
7800 /* Output : 1 -> Skip backlight control */
7801 /* Description : */
7802 /* --------------------------------------------------------------------- */
7803 unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
7805 unsigned char tempah ;
7807 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x3A) ;
7808 if (tempah & BacklightControlBit)
7809 return 1;
7810 else
7811 return 0;
7815 /* --------------------------------------------------------------------- */
7816 /* Function : XGI_FirePWDDisable */
7817 /* Input : */
7818 /* Output : */
7819 /* Description : Turn off VDD & Backlight : Fire disable procedure */
7820 /* --------------------------------------------------------------------- */
7822 void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
7824 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
7828 /* --------------------------------------------------------------------- */
7829 /* Function : XGI_FirePWDEnable */
7830 /* Input : */
7831 /* Output : */
7832 /* Description : Turn on VDD & Backlight : Fire enable procedure */
7833 /* --------------------------------------------------------------------- */
7834 void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
7836 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
7840 /* --------------------------------------------------------------------- */
7841 /* Function : XGI_EnableGatingCRT */
7842 /* Input : */
7843 /* Output : */
7844 /* Description : */
7845 /* --------------------------------------------------------------------- */
7846 void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
7848 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
7852 /* --------------------------------------------------------------------- */
7853 /* Function : XGI_DisableGatingCRT */
7854 /* Input : */
7855 /* Output : */
7856 /* Description : */
7857 /* --------------------------------------------------------------------- */
7858 void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
7861 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
7865 /* --------------------------------------------------------------------- */
7866 /* Function : XGI_SetPanelDelay */
7867 /* Input : */
7868 /* Output : */
7869 /* Description : */
7870 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7871 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7872 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7873 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7874 /* --------------------------------------------------------------------- */
7875 void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
7877 unsigned short index ;
7879 index = XGI_GetLCDCapPtr(pVBInfo) ;
7881 if ( tempbl == 1 )
7882 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
7884 if ( tempbl == 2 )
7885 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
7887 if ( tempbl == 3 )
7888 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
7890 if ( tempbl == 4 )
7891 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
7895 /* --------------------------------------------------------------------- */
7896 /* Function : XGI_SetPanelPower */
7897 /* Input : */
7898 /* Output : */
7899 /* Description : */
7900 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
7901 /* = 0111b = 07h ; Backlight on, Power off */
7902 /* = 1011b = 0Bh ; Backlight off, Power on */
7903 /* = 1111b = 0Fh ; Backlight off, Power off */
7904 /* --------------------------------------------------------------------- */
7905 void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, struct vb_device_info *pVBInfo)
7907 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7908 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
7909 else
7910 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
7913 unsigned char XG21GPIODataTransfer(unsigned char ujDate)
7915 unsigned char ujRet = 0;
7916 unsigned char i = 0;
7918 for (i=0; i<8; i++)
7920 ujRet = ujRet << 1;
7921 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
7922 ujRet |= (ujDate >> i) & 1;
7925 return ujRet;
7928 /*----------------------------------------------------------------------------*/
7929 /* output */
7930 /* bl[5] : LVDS signal */
7931 /* bl[1] : LVDS backlight */
7932 /* bl[0] : LVDS VDD */
7933 /*----------------------------------------------------------------------------*/
7934 unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
7936 unsigned char CR4A, temp;
7938 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7939 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
7941 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7943 temp = XG21GPIODataTransfer(temp);
7944 temp &= 0x23;
7945 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7946 return temp;
7949 /*----------------------------------------------------------------------------*/
7950 /* output */
7951 /* bl[5] : LVDS signal */
7952 /* bl[1] : LVDS backlight */
7953 /* bl[0] : LVDS VDD */
7954 /*----------------------------------------------------------------------------*/
7955 unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
7957 unsigned char CR4A, CRB4, temp;
7959 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7960 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
7962 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7964 temp &= 0x0C;
7965 temp >>= 2;
7966 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7967 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
7968 temp |= ((CRB4&0x04)<<3);
7969 return temp;
7971 /*----------------------------------------------------------------------------*/
7972 /* input */
7973 /* bl[5] : 1;LVDS signal on */
7974 /* bl[1] : 1;LVDS backlight on */
7975 /* bl[0] : 1:LVDS VDD on */
7976 /* bh: 100000b : clear bit 5, to set bit5 */
7977 /* 000010b : clear bit 1, to set bit1 */
7978 /* 000001b : clear bit 0, to set bit0 */
7979 /*----------------------------------------------------------------------------*/
7980 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo)
7982 unsigned char CR4A, temp;
7984 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7985 tempbh &= 0x23;
7986 tempbl &= 0x23;
7987 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7989 if (tempbh&0x20)
7991 temp = (tempbl>>4)&0x02;
7993 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7997 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7999 temp = XG21GPIODataTransfer(temp);
8000 temp &= ~tempbh;
8001 temp |= tempbl;
8002 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
8005 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo)
8007 unsigned char CR4A, temp;
8008 unsigned short tempbh0, tempbl0;
8010 tempbh0 = tempbh;
8011 tempbl0 = tempbl;
8012 tempbh0 &= 0x20;
8013 tempbl0 &= 0x20;
8014 tempbh0 >>= 3;
8015 tempbl0 >>= 3;
8017 if (tempbh&0x20)
8019 temp = (tempbl>>4)&0x02;
8021 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8024 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
8026 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8027 tempbh &= 0x03;
8028 tempbl &= 0x03;
8029 tempbh <<= 2;
8030 tempbl <<= 2; /* GPIOC,GPIOD */
8031 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
8032 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
8035 /* --------------------------------------------------------------------- */
8036 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
8038 unsigned short index ;
8040 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8041 if (index < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct))
8042 return index;
8043 return 0;
8046 /* --------------------------------------------------------------------- */
8047 /* Function : XGI_XG21SetPanelDelay */
8048 /* Input : */
8049 /* Output : */
8050 /* Description : */
8051 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8052 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
8053 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
8054 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
8055 /* --------------------------------------------------------------------- */
8056 void XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
8058 unsigned short index ;
8060 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
8061 if ( tempbl == 1 )
8062 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8064 if ( tempbl == 2 )
8065 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8067 if ( tempbl == 3 )
8068 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8070 if ( tempbl == 4 )
8071 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8074 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
8075 unsigned short ModeIdIndex,
8076 struct vb_device_info *pVBInfo)
8078 unsigned short xres ,
8079 yres ,
8080 colordepth ,
8081 modeflag ,
8082 resindex ,
8083 lvdstableindex;
8085 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8086 if ( ModeNo <= 0x13 )
8088 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8089 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8090 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8092 else
8094 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8095 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8096 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8099 if ( !( modeflag & Charx8Dot ) )
8101 xres /= 9;
8102 xres *= 8;
8105 if ( ModeNo > 0x13 )
8107 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8109 xres *= 2 ;
8111 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8113 yres *= 2 ;
8117 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8118 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8119 return 0;
8121 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8122 return 0;
8124 if ( ModeNo > 0x13 )
8126 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8127 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8129 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8130 if (colordepth > 2)
8131 return 0;
8135 return 1;
8138 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
8140 unsigned char temp;
8142 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8143 temp = ( temp & 1 ) << 6;
8144 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8145 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8149 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
8151 unsigned char temp;
8153 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8154 temp = ( temp & 3 ) << 6;
8155 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8156 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8160 void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
8161 struct vb_device_info *pVBInfo)
8163 unsigned char temp, Miscdata;
8164 unsigned short xres ,
8165 yres ,
8166 modeflag ,
8167 resindex ,
8168 lvdstableindex ;
8169 unsigned short LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8170 unsigned short LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8171 unsigned short value;
8173 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8175 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8)) >> 8);
8176 temp &= LCDPolarity;
8177 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc) ;
8179 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8181 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity) ;
8182 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8183 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8185 XGI_SetXG21FPBits(pVBInfo);
8186 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8187 if ( ModeNo <= 0x13 )
8189 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8190 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8191 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8193 else
8195 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8196 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8197 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8200 if (!( modeflag & Charx8Dot ))
8201 xres = xres * 8 / 9;
8203 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8205 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8206 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8208 LVDSHBS -= xres/4 ;
8210 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8212 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8213 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8215 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8216 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8218 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8220 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8222 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8223 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8225 LVDSVBS += yres/2 ;
8227 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8229 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8230 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8232 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8233 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8235 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8237 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11) ;
8238 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8240 if (!( modeflag & Charx8Dot ))
8242 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8245 /* HT SR0B[1:0] CR00 */
8246 value = ( LVDSHT >> 3 ) - 5;
8247 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8248 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8250 /* HBS SR0B[5:4] CR02 */
8251 value = ( LVDSHBS >> 3 ) - 1;
8252 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8253 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8255 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8256 value = ( LVDSHBE >> 3 ) - 1;
8257 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8258 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8259 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8261 /* HRS SR0B[7:6] CR04 */
8262 value = ( LVDSHRS >> 3 ) + 2;
8263 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8264 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8266 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8267 value--;
8268 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8269 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8271 /* HRE SR0C[2] CR05[4:0] */
8272 value = ( LVDSHRE >> 3 ) + 2;
8273 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8274 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8276 /* Panel HRE SR2F[7:2] */
8277 value--;
8278 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8280 /* VT SR0A[0] CR07[5][0] CR06 */
8281 value = LVDSVT - 2 ;
8282 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8283 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8284 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8285 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8287 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8288 value = LVDSVBS - 1 ;
8289 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8290 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8291 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8292 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8294 /* VBE SR0A[4] CR16 */
8295 value = LVDSVBE - 1;
8296 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8297 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8299 /* VRS SR0A[3] CR7[7][2] CR10 */
8300 value = LVDSVRS - 1 ;
8301 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8302 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8303 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8304 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8306 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8307 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8308 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8309 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8311 /* VRE SR0A[5] CR11[3:0] */
8312 value = LVDSVRE - 1;
8313 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8314 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8316 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8317 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8319 for ( temp=0, value = 0; temp < 3; temp++)
8322 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8323 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8324 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8325 value += 0x10;
8328 if (!( modeflag & Charx8Dot ))
8330 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8331 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8332 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8334 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8335 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8337 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8343 /* no shadow case */
8344 void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
8345 struct vb_device_info *pVBInfo)
8347 unsigned char temp, Miscdata;
8348 unsigned short xres ,
8349 yres ,
8350 modeflag ,
8351 resindex ,
8352 lvdstableindex ;
8353 unsigned short LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8354 unsigned short LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8355 unsigned short value;
8357 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8358 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8)) >> 8);
8359 temp &= LCDPolarity;
8360 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
8362 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8364 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity) ;
8365 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8366 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8368 XGI_SetXG27FPBits(pVBInfo);
8369 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8370 if ( ModeNo <= 0x13 )
8372 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8373 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8374 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8376 else
8378 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8379 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8380 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8383 if (!( modeflag & Charx8Dot ))
8384 xres = xres * 8 / 9;
8386 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8388 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8389 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8391 LVDSHBS -= xres/4 ;
8393 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8395 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8396 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8398 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8399 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8401 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8403 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8405 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8406 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8408 LVDSVBS += yres/2 ;
8410 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8412 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8413 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8415 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8416 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8418 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8420 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3d4, 0x11) ;
8421 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8423 if (!( modeflag & Charx8Dot ))
8425 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8428 /* HT SR0B[1:0] CR00 */
8429 value = ( LVDSHT >> 3 ) - 5;
8430 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8431 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8433 /* HBS SR0B[5:4] CR02 */
8434 value = ( LVDSHBS >> 3 ) - 1;
8435 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8436 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8438 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8439 value = ( LVDSHBE >> 3 ) - 1;
8440 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8441 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8442 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8444 /* HRS SR0B[7:6] CR04 */
8445 value = ( LVDSHRS >> 3 ) + 2;
8446 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8447 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8449 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8450 value--;
8451 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8452 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8454 /* HRE SR0C[2] CR05[4:0] */
8455 value = ( LVDSHRE >> 3 ) + 2;
8456 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8457 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8459 /* Panel HRE SR2F[7:2] */
8460 value--;
8461 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8463 /* VT SR0A[0] CR07[5][0] CR06 */
8464 value = LVDSVT - 2 ;
8465 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8466 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8467 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8468 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8470 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8471 value = LVDSVBS - 1 ;
8472 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8473 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8474 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8475 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8477 /* VBE SR0A[4] CR16 */
8478 value = LVDSVBE - 1;
8479 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8480 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8482 /* VRS SR0A[3] CR7[7][2] CR10 */
8483 value = LVDSVRS - 1 ;
8484 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8485 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8486 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8487 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8489 /* Panel VRS SR35[2:0] SR34[7:0] */
8490 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8491 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8493 /* VRE SR0A[5] CR11[3:0] */
8494 value = LVDSVRE - 1;
8495 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8496 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8498 /* Panel VRE SR3F[7:2] */
8499 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8501 for ( temp=0, value = 0; temp < 3; temp++)
8504 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8505 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8506 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8507 value += 0x10;
8510 if (!( modeflag & Charx8Dot ))
8512 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8513 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8514 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8516 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8517 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8519 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8525 /* --------------------------------------------------------------------- */
8526 /* Function : XGI_IsLCDON */
8527 /* Input : */
8528 /* Output : 0 : Skip PSC Control */
8529 /* 1: Disable PSC */
8530 /* Description : */
8531 /* --------------------------------------------------------------------- */
8532 unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
8534 unsigned short tempax ;
8536 tempax = pVBInfo->VBInfo ;
8537 if ( tempax & SetCRT2ToDualEdge )
8538 return 0;
8539 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8540 return 1;
8542 return 0;
8546 /* --------------------------------------------------------------------- */
8547 /* Function : XGI_EnablePWD */
8548 /* Input : */
8549 /* Output : */
8550 /* Description : */
8551 /* --------------------------------------------------------------------- */
8552 void XGI_EnablePWD(struct vb_device_info *pVBInfo)
8554 unsigned short index ,
8555 temp ;
8557 index = XGI_GetLCDCapPtr(pVBInfo) ;
8558 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8559 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8560 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8561 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8562 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8563 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8564 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8568 /* --------------------------------------------------------------------- */
8569 /* Function : XGI_DisablePWD */
8570 /* Input : */
8571 /* Output : */
8572 /* Description : */
8573 /* --------------------------------------------------------------------- */
8574 void XGI_DisablePWD(struct vb_device_info *pVBInfo)
8576 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8580 /* --------------------------------------------------------------------- */
8581 /* Function : XGI_DisableChISLCD */
8582 /* Input : */
8583 /* Output : 0 -> Not LCD Mode */
8584 /* Description : */
8585 /* --------------------------------------------------------------------- */
8586 unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
8588 unsigned short tempbx ,
8589 tempah ;
8591 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8592 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
8594 if ( tempbx & ( EnableChA | DisableChA ) )
8596 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8597 return 0 ;
8600 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8601 return 0;
8603 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8604 return 1;
8606 return 0;
8610 /* --------------------------------------------------------------------- */
8611 /* Function : XGI_EnableChISLCD */
8612 /* Input : */
8613 /* Output : 0 -> Not LCD mode */
8614 /* Description : */
8615 /* --------------------------------------------------------------------- */
8616 unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
8618 unsigned short tempbx ,
8619 tempah ;
8622 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8623 tempah = ~( (unsigned short)XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8625 if ( tempbx & ( EnableChA | DisableChA ) )
8627 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8628 return 0;
8631 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8632 return 0;
8634 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8635 return 1;
8637 return 0;
8641 /* --------------------------------------------------------------------- */
8642 /* Function : XGI_GetLCDCapPtr */
8643 /* Input : */
8644 /* Output : */
8645 /* Description : */
8646 /* --------------------------------------------------------------------- */
8647 unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
8649 unsigned char tempal ,
8650 tempah ,
8651 tempbl ,
8654 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8655 tempal = tempah & 0x0F ;
8656 tempah = tempah & 0xF0 ;
8657 i = 0 ;
8658 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8660 while( tempbl != 0xFF )
8662 if ( tempbl & 0x80 ) /* OEMUtil */
8664 tempal = tempah ;
8665 tempbl = tempbl & ~( 0x80 ) ;
8668 if ( tempal == tempbl )
8669 break ;
8671 i++ ;
8673 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8676 return i ;
8680 /* --------------------------------------------------------------------- */
8681 /* Function : XGI_GetLCDCapPtr1 */
8682 /* Input : */
8683 /* Output : */
8684 /* Description : */
8685 /* --------------------------------------------------------------------- */
8686 unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
8688 unsigned short tempah ,
8689 tempal ,
8690 tempbl ,
8693 tempal = pVBInfo->LCDResInfo ;
8694 tempah = pVBInfo->LCDTypeInfo ;
8696 i = 0 ;
8697 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
8699 while( tempbl != 0xFF )
8701 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
8703 tempal = tempah ;
8704 tempbl &= ~0x80 ;
8707 if ( tempal == tempbl )
8708 break ;
8710 i++ ;
8711 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8714 if ( tempbl == 0xFF )
8716 pVBInfo->LCDResInfo = Panel1024x768 ;
8717 pVBInfo->LCDTypeInfo = 0 ;
8718 i = 0 ;
8721 return i ;
8725 /* --------------------------------------------------------------------- */
8726 /* Function : XGI_GetLCDSync */
8727 /* Input : */
8728 /* Output : */
8729 /* Description : */
8730 /* --------------------------------------------------------------------- */
8731 void XGI_GetLCDSync(unsigned short *HSyncWidth , unsigned short *VSyncWidth,
8732 struct vb_device_info *pVBInfo)
8734 unsigned short Index ;
8736 Index = XGI_GetLCDCapPtr(pVBInfo) ;
8737 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
8738 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
8740 return ;
8745 /* --------------------------------------------------------------------- */
8746 /* Function : XGI_EnableBridge */
8747 /* Input : */
8748 /* Output : */
8749 /* Description : */
8750 /* --------------------------------------------------------------------- */
8751 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
8753 unsigned short tempbl ,
8754 tempah ;
8756 if ( pVBInfo->SetFlag == Win9xDOSMode )
8758 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8760 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8761 return ;
8763 else /* LVDS or CH7017 */
8764 return ;
8768 if ( HwDeviceExtension->jChipType < XG40 )
8770 if ( !XGI_DisableChISLCD(pVBInfo) )
8772 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8774 if ( pVBInfo->LCDInfo & SetPWDEnable )
8776 XGI_EnablePWD( pVBInfo);
8778 else
8780 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
8781 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8783 tempbl = 0xFD ;
8784 tempah = 0x02 ;
8786 else
8788 tempbl = 0xFB ;
8789 tempah = 0x00 ;
8792 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
8793 XGI_SetPanelDelay( 1,pVBInfo ) ;
8797 } /* Not 340 */
8801 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8803 if ( !( pVBInfo->SetFlag & DisableChA ) )
8805 if ( pVBInfo->SetFlag & EnableChA )
8807 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
8809 else
8811 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
8813 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
8818 if ( !( pVBInfo->SetFlag & DisableChB ) )
8820 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
8822 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x32);
8823 tempah &= 0xDF;
8824 if ( pVBInfo->VBInfo & SetInSlaveMode )
8826 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
8827 tempah |= 0x20 ;
8829 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
8830 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
8832 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->Part1Port, 0x2E);
8834 if ( !( tempah & 0x80 ) )
8835 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8837 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
8841 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
8843 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
8844 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8846 if ( !XGI_DisableChISLCD(pVBInfo) )
8848 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8849 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
8851 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
8855 tempah = 0x00 ;
8857 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
8859 tempah = 0xc0 ;
8861 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
8863 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8865 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8867 tempah = tempah & 0x40;
8868 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8869 tempah = tempah ^ 0xC0 ;
8871 if ( pVBInfo->SetFlag & DisableChB )
8872 tempah &= 0xBF ;
8874 if ( pVBInfo->SetFlag & DisableChA )
8875 tempah &= 0x7F ;
8877 if ( pVBInfo->SetFlag & EnableChB )
8878 tempah |= 0x40 ;
8880 if ( pVBInfo->SetFlag & EnableChA )
8881 tempah |= 0x80 ;
8887 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
8889 if ( pVBInfo->SetFlag & Win9xDOSMode )
8891 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8892 return ;
8895 if ( !( pVBInfo->SetFlag & DisableChA ) )
8897 XGI_VBLongWait( pVBInfo) ;
8898 if ( !( pVBInfo->SetFlag & GatingCRT ) )
8900 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8901 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8902 XGI_VBLongWait( pVBInfo) ;
8905 } /* 301 */
8906 else /* LVDS */
8908 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
8909 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
8913 tempah = (unsigned char)XGINew_GetReg1(pVBInfo->Part1Port, 0x2E);
8914 if ( !( tempah & 0x80 ) )
8915 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8917 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
8918 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
8919 } /* End of VB */
8922 if ( HwDeviceExtension->jChipType < XG40 )
8924 if ( !XGI_EnableChISLCD(pVBInfo) )
8926 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
8928 if ( XGI_BacklightByDrv(pVBInfo) )
8929 return ;
8931 else
8932 return ;
8935 if ( pVBInfo->LCDInfo & SetPWDEnable )
8937 XGI_FirePWDEnable(pVBInfo) ;
8938 return ;
8941 XGI_SetPanelDelay( 2,pVBInfo ) ;
8943 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8945 tempah = 0x01 ;
8946 tempbl = 0xFE ; /* turn on backlght */
8948 else
8950 tempbl = 0xF7 ;
8951 tempah = 0x00 ;
8953 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
8958 /* --------------------------------------------------------------------- */
8959 /* Function : XGI_DisableBridge */
8960 /* Input : */
8961 /* Output : */
8962 /* Description : */
8963 /* --------------------------------------------------------------------- */
8964 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
8966 unsigned short tempax ,
8967 tempbx ,
8968 tempah = 0 ,
8969 tempbl = 0 ;
8971 if ( pVBInfo->SetFlag == Win9xDOSMode )
8972 return ;
8975 if ( HwDeviceExtension->jChipType < XG40 )
8977 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8979 if ( !XGI_IsLCDON(pVBInfo) )
8981 if ( pVBInfo->LCDInfo & SetPWDEnable )
8982 XGI_EnablePWD( pVBInfo) ;
8983 else
8985 pVBInfo->LCDInfo &= ~SetPWDEnable ;
8986 XGI_DisablePWD(pVBInfo) ;
8987 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8989 tempbx = 0xFE ; /* not 01h */
8990 tempax = 0 ;
8992 else
8994 tempbx = 0xF7 ; /* not 08h */
8995 tempax = 0x08 ;
8997 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
8998 XGI_SetPanelDelay( 3,pVBInfo ) ;
9000 } /* end if(!XGI_IsLCDON(pVBInfo)) */
9004 /* if ( CH7017 )
9006 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
9008 if ( !XGI_IsLCDON(pVBInfo) )
9010 if ( DISCHARGE )
9012 tempbx = XGINew_GetCH7005( 0x61 ) ;
9013 if ( tempbx < 0x01 ) //first time we power up
9014 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
9015 else
9016 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
9020 } */
9022 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9024 tempah = 0x3F ;
9025 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
9027 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9029 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9031 tempah = 0x7F; /* Disable Channel A */
9032 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9033 tempah = 0xBF ; /* Disable Channel B */
9035 if ( pVBInfo->SetFlag & DisableChB )
9036 tempah &= 0xBF ; /* force to disable Cahnnel */
9038 if ( pVBInfo->SetFlag & DisableChA )
9039 tempah &= 0x7F ; /* Force to disable Channel B */
9044 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
9046 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9048 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9049 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
9052 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
9054 if ( pVBInfo->SetFlag & GatingCRT )
9055 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9056 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9059 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9061 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9062 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
9065 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
9067 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
9068 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9070 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9071 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9072 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9074 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9075 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9077 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9078 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9079 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9080 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9083 else /* {301} */
9085 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9087 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9088 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9089 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9092 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9093 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9099 if ( HwDeviceExtension->jChipType < XG40 )
9101 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9103 if ( pVBInfo->LCDInfo & SetPWDEnable )
9105 if ( pVBInfo->LCDInfo & SetPWDEnable )
9106 XGI_BacklightByDrv(pVBInfo) ;
9107 else
9109 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9110 if ( pVBInfo->VBType & VB_XGI301LV )
9112 tempbl = 0xFD ;
9113 tempah = 0x00 ;
9115 else
9117 tempbl = 0xFB ;
9118 tempah = 0x04 ;
9122 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9128 /* --------------------------------------------------------------------- */
9129 /* Function : XGI_GetTVPtrIndex */
9130 /* Input : */
9131 /* Output : */
9132 /* Description : bx 0 : ExtNTSC */
9133 /* 1 : StNTSC */
9134 /* 2 : ExtPAL */
9135 /* 3 : StPAL */
9136 /* 4 : ExtHiTV */
9137 /* 5 : StHiTV */
9138 /* 6 : Ext525i */
9139 /* 7 : St525i */
9140 /* 8 : Ext525p */
9141 /* 9 : St525p */
9142 /* A : Ext750p */
9143 /* B : St750p */
9144 /* --------------------------------------------------------------------- */
9145 unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
9147 unsigned short tempbx = 0 ;
9149 if ( pVBInfo->TVInfo & SetPALTV )
9150 tempbx = 2 ;
9151 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9152 tempbx = 4 ;
9153 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9154 tempbx = 6 ;
9155 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9156 tempbx = 8 ;
9157 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9158 tempbx = 10 ;
9159 if ( pVBInfo->TVInfo & TVSimuMode )
9160 tempbx++ ;
9162 return tempbx ;
9166 /* --------------------------------------------------------------------- */
9167 /* Function : XGI_OEM310Setting */
9168 /* Input : */
9169 /* Output : */
9170 /* Description : Customized Param. for 301 */
9171 /* --------------------------------------------------------------------- */
9172 void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9174 if ( pVBInfo->SetFlag & Win9xDOSMode )
9175 return ;
9177 /* GetPart1IO(); */
9178 XGI_SetDelayComp(pVBInfo) ;
9180 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9181 XGI_SetLCDCap(pVBInfo) ;
9183 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9185 /* GetPart2IO() */
9186 XGI_SetPhaseIncr(pVBInfo) ;
9187 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9188 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9190 if ( pVBInfo->VBType&VB_XGI301)
9191 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9196 /* --------------------------------------------------------------------- */
9197 /* Function : XGI_SetDelayComp */
9198 /* Input : */
9199 /* Output : */
9200 /* Description : */
9201 /* --------------------------------------------------------------------- */
9202 void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
9204 unsigned short index ;
9206 unsigned char tempah ,
9207 tempbl ,
9208 tempbh ;
9210 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9212 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9214 tempbl = 0;
9215 tempbh = 0;
9217 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9218 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9220 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9221 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9223 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9224 tempbl = tempbl >> 4 ;
9226 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9227 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9229 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9230 tempbl = CRT2Delay2 ;
9232 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9234 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9235 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9237 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9238 tempbl = tempbh ;
9241 tempbl &= 0x0F ;
9242 tempbh &= 0xF0 ;
9243 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9245 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9247 tempah &= 0xF0 ;
9248 tempah |= tempbl ;
9251 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9253 tempah &= 0x0F ;
9254 tempah |= tempbh ;
9256 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9259 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9261 tempbl = 0;
9262 tempbh = 0;
9263 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9265 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9266 tempah &= 0x0f ;
9267 tempah = tempah << 4 ;
9268 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9274 /* --------------------------------------------------------------------- */
9275 /* Function : XGI_SetLCDCap */
9276 /* Input : */
9277 /* Output : */
9278 /* Description : */
9279 /* --------------------------------------------------------------------- */
9280 void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
9282 unsigned short tempcx ;
9284 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9286 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9288 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9289 { /* 301LV/302LV only */
9290 /* Set 301LV Capability */
9291 XGINew_SetReg1(pVBInfo->Part4Port, 0x24, (unsigned char)(tempcx & 0x1F));
9293 /* VB Driving */
9294 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
9295 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
9296 (unsigned short)((tempcx & (EnableVBCLKDRVLOW | EnablePLLSPLOW)) >> 8));
9299 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9301 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9302 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9303 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9304 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9306 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9308 if ( tempcx & EnableSpectrum )
9309 SetSpectrum( pVBInfo) ;
9312 else /* LVDS,CH7017 */
9313 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9317 /* --------------------------------------------------------------------- */
9318 /* Function : XGI_SetLCDCap_A */
9319 /* Input : */
9320 /* Output : */
9321 /* Description : */
9322 /* --------------------------------------------------------------------- */
9323 void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
9325 unsigned short temp ;
9327 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9329 if ( temp & LCDRGB18Bit )
9331 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
9332 (unsigned short)(0x20 | (tempcx & 0x00C0))); /* Enable Dither */
9333 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9335 else
9337 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
9338 (unsigned short)(0x30 | (tempcx & 0x00C0)));
9339 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9343 if ( tempcx & EnableLCD24bpp ) // 24bits
9345 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(unsigned short)(0x30|(tempcx&0x00C0)) );
9346 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9348 else
9350 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(unsigned short)(0x20|(tempcx&0x00C0)) ); // Enable Dither
9351 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9357 /* --------------------------------------------------------------------- */
9358 /* Function : XGI_SetLCDCap_B */
9359 /* Input : cx -> LCD Capability */
9360 /* Output : */
9361 /* Description : */
9362 /* --------------------------------------------------------------------- */
9363 void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
9365 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9366 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
9367 (unsigned short)(((tempcx & 0x00ff) >> 6) | 0x0c));
9368 else
9369 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
9370 (unsigned short)(((tempcx & 0x00ff) >> 6) | 0x18)); /* Enable Dither */
9374 /* --------------------------------------------------------------------- */
9375 /* Function : SetSpectrum */
9376 /* Input : */
9377 /* Output : */
9378 /* Description : */
9379 /* --------------------------------------------------------------------- */
9380 void SetSpectrum(struct vb_device_info *pVBInfo)
9382 unsigned short index ;
9384 index = XGI_GetLCDCapPtr(pVBInfo) ;
9386 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9387 XGI_LongWait(pVBInfo) ;
9388 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9389 XGI_LongWait(pVBInfo) ;
9391 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9392 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9393 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9394 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9395 XGI_LongWait(pVBInfo) ;
9396 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9400 /* --------------------------------------------------------------------- */
9401 /* Function : XGI_SetAntiFlicker */
9402 /* Input : */
9403 /* Output : */
9404 /* Description : Set TV Customized Param. */
9405 /* --------------------------------------------------------------------- */
9406 void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
9407 struct vb_device_info *pVBInfo)
9409 unsigned short tempbx ,
9410 index ;
9412 unsigned char tempah ;
9414 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9415 return ;
9417 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9418 tempbx &= 0xFE ;
9420 if ( ModeNo <= 0x13 )
9422 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9424 else
9426 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9429 tempbx += index ;
9430 tempah = TVAntiFlickList[ tempbx ] ;
9431 tempah = tempah << 4 ;
9433 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9437 /* --------------------------------------------------------------------- */
9438 /* Function : XGI_SetEdgeEnhance */
9439 /* Input : */
9440 /* Output : */
9441 /* Description : */
9442 /* --------------------------------------------------------------------- */
9443 void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9445 unsigned short tempbx ,
9446 index ;
9448 unsigned char tempah ;
9451 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9452 tempbx &= 0xFE ;
9454 if ( ModeNo <= 0x13 )
9456 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9458 else
9460 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9463 tempbx += index ;
9464 tempah = TVEdgeList[ tempbx ] ;
9465 tempah = tempah << 5 ;
9467 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9471 /* --------------------------------------------------------------------- */
9472 /* Function : XGI_SetPhaseIncr */
9473 /* Input : */
9474 /* Output : */
9475 /* Description : */
9476 /* --------------------------------------------------------------------- */
9477 void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
9479 unsigned short tempbx ;
9481 unsigned char tempcl ,
9482 tempch ;
9484 unsigned long tempData ;
9486 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9487 tempData = TVPhaseList[ tempbx ] ;
9489 XGINew_SetReg1(pVBInfo->Part2Port, 0x31,
9490 (unsigned short)(tempData & 0x000000FF));
9491 XGINew_SetReg1(pVBInfo->Part2Port, 0x32,
9492 (unsigned short)((tempData & 0x0000FF00) >> 8));
9493 XGINew_SetReg1(pVBInfo->Part2Port, 0x33,
9494 (unsigned short)((tempData & 0x00FF0000) >> 16));
9495 XGINew_SetReg1(pVBInfo->Part2Port, 0x34,
9496 (unsigned short)((tempData & 0xFF000000) >> 24));
9500 /* --------------------------------------------------------------------- */
9501 /* Function : XGI_SetYFilter */
9502 /* Input : */
9503 /* Output : */
9504 /* Description : */
9505 /* --------------------------------------------------------------------- */
9506 void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
9507 struct vb_device_info *pVBInfo)
9509 unsigned short tempbx ,
9510 index ;
9512 unsigned char tempcl ,
9513 tempch ,
9514 tempal ,
9515 *filterPtr ;
9517 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9519 switch( tempbx )
9521 case 0x00:
9522 case 0x04:
9523 filterPtr = NTSCYFilter1 ;
9524 break ;
9526 case 0x01:
9527 filterPtr = PALYFilter1 ;
9528 break ;
9530 case 0x02:
9531 case 0x05:
9532 case 0x0D:
9533 filterPtr = PALMYFilter1 ;
9534 break ;
9536 case 0x03:
9537 filterPtr = PALNYFilter1 ;
9538 break ;
9540 case 0x08:
9541 case 0x0C:
9542 filterPtr = NTSCYFilter2 ;
9543 break ;
9545 case 0x0A:
9546 filterPtr = PALMYFilter2 ;
9547 break ;
9549 case 0x0B:
9550 filterPtr = PALNYFilter2 ;
9551 break ;
9553 case 0x09:
9554 filterPtr = PALYFilter2 ;
9555 break ;
9557 default:
9558 return ;
9561 if ( ModeNo <= 0x13 )
9562 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9563 else
9564 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9566 if ( tempcl == 0 )
9567 index = tempal * 4;
9568 else
9569 index = tempal * 7;
9571 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9573 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9574 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9575 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9576 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9578 else
9580 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9581 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9582 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9583 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9586 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9588 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9589 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9590 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9595 /* --------------------------------------------------------------------- */
9596 /* Function : XGI_GetTVPtrIndex2 */
9597 /* Input : */
9598 /* Output : bx 0 : NTSC */
9599 /* 1 : PAL */
9600 /* 2 : PALM */
9601 /* 3 : PALN */
9602 /* 4 : NTSC1024x768 */
9603 /* 5 : PAL-M 1024x768 */
9604 /* 6-7: reserved */
9605 /* cl 0 : YFilter1 */
9606 /* 1 : YFilter2 */
9607 /* ch 0 : 301A */
9608 /* 1 : 301B/302B/301LV/302LV */
9609 /* Description : */
9610 /* --------------------------------------------------------------------- */
9611 void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
9612 unsigned char *tempch, struct vb_device_info *pVBInfo)
9614 *tempbx = 0 ;
9615 *tempcl = 0 ;
9616 *tempch = 0 ;
9618 if ( pVBInfo->TVInfo & SetPALTV )
9619 *tempbx = 1 ;
9621 if ( pVBInfo->TVInfo & SetPALMTV )
9622 *tempbx = 2 ;
9624 if ( pVBInfo->TVInfo & SetPALNTV )
9625 *tempbx = 3 ;
9627 if ( pVBInfo->TVInfo & NTSC1024x768 )
9629 *tempbx = 4 ;
9630 if ( pVBInfo->TVInfo & SetPALMTV )
9631 *tempbx = 5 ;
9634 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9636 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9638 *tempbx += 8 ;
9639 *tempcl += 1 ;
9643 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9644 (*tempch)++ ;
9648 /* --------------------------------------------------------------------- */
9649 /* Function : XGI_SetCRT2ModeRegs */
9650 /* Input : */
9651 /* Output : */
9652 /* Description : Origin code for crt2group */
9653 /* --------------------------------------------------------------------- */
9654 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
9655 struct xgi_hw_device_info *HwDeviceExtension,
9656 struct vb_device_info *pVBInfo)
9658 unsigned short tempbl ;
9659 short tempcl ;
9661 unsigned char tempah ;
9663 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9664 tempah=0;
9665 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9667 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9668 tempah &= ~0x10 ; /* BTRAMDAC */
9669 tempah |= 0x40 ; /* BTRAM */
9671 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9673 tempah=0x40; /* BTDRAM */
9674 if ( ModeNo > 0x13 )
9676 tempcl = pVBInfo->ModeType ;
9677 tempcl -= ModeVGA ;
9678 if ( tempcl >= 0 )
9680 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9681 if ( tempah == 0 )
9682 tempah = 1 ;
9683 tempah |= 0x040 ;
9686 if ( pVBInfo->VBInfo & SetInSlaveMode )
9687 tempah ^= 0x50 ; /* BTDAC */
9691 /* 0210 shampoo
9692 if ( pVBInfo->VBInfo & DisableCRT2Display )
9694 tempah = 0 ;
9697 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9698 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9700 tempcl = pVBInfo->ModeType ;
9701 if ( ModeNo > 0x13 )
9703 tempcl -= ModeVGA ;
9704 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
9706 tempah=(0x008>>tempcl) ;
9707 if ( tempah == 0 )
9708 tempah = 1 ;
9709 tempah |= 0x040;
9712 else
9714 tempah = 0x040 ;
9717 if ( pVBInfo->VBInfo & SetInSlaveMode )
9719 tempah = ( tempah ^ 0x050 ) ;
9724 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9725 tempah = 0x08 ;
9726 tempbl = 0xf0 ;
9728 if ( pVBInfo->VBInfo & DisableCRT2Display )
9729 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9730 else
9732 tempah = 0x00 ;
9733 tempbl = 0xff ;
9735 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9737 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
9739 tempbl &= 0xf7 ;
9740 tempah |= 0x01 ;
9741 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9743 else
9745 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9747 tempbl &= 0xf7 ;
9748 tempah |= 0x01 ;
9751 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9753 tempbl &= 0xf8 ;
9754 tempah = 0x01 ;
9756 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
9757 tempah |= 0x02 ;
9759 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9761 tempah = tempah ^ 0x05 ;
9762 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
9763 tempah = tempah ^ 0x01 ;
9766 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9767 tempah |= 0x08 ;
9768 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9770 else
9771 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9774 else
9775 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9778 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9780 tempah &= ( ~0x08 ) ;
9781 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
9783 tempah |= 0x010 ;
9785 tempah |= 0x080 ;
9787 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9789 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
9790 /* { */
9791 tempah |= 0x020 ;
9792 if ( ModeNo > 0x13 )
9794 if ( pVBInfo->VBInfo & DriverMode )
9795 tempah = tempah ^ 0x20 ;
9797 /* } */
9800 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
9801 tempah = 0 ;
9803 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9804 tempah |= 0x40 ;
9806 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9808 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
9809 /* { */
9810 if ( pVBInfo->TVInfo & RPLLDIV2XO )
9811 tempah |= 0x40 ;
9812 /* } */
9815 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
9816 tempah |= 0x80 ;
9818 if ( pVBInfo->LCDResInfo == Panel1280x960 )
9819 tempah |= 0x80 ;
9821 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
9824 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9826 tempah = 0 ;
9827 tempbl = 0xfb ;
9829 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9831 tempbl=0xff;
9832 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9833 tempah |= 0x04 ; /* shampoo 0129 */
9836 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
9837 tempah = 0x00 ;
9838 tempbl = 0xcf ;
9839 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9841 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9842 tempah |= 0x30 ;
9845 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
9846 tempah = 0 ;
9847 tempbl = 0x3f ;
9849 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9851 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9852 tempah |= 0xc0 ;
9854 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
9857 tempah = 0 ;
9858 tempbl = 0x7f ;
9859 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9861 tempbl = 0xff ;
9862 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9863 tempah |= 0x80 ;
9866 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
9868 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9870 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9872 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
9873 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
9879 /* --------------------------------------------------------------------- */
9880 /* Function : XGI_CloseCRTC */
9881 /* Input : */
9882 /* Output : */
9883 /* Description : */
9884 /* --------------------------------------------------------------------- */
9885 void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
9887 unsigned short tempbx ;
9889 tempbx = 0 ;
9891 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9892 tempbx = 0x08A0 ;
9898 /* --------------------------------------------------------------------- */
9899 /* Function : XGI_OpenCRTC */
9900 /* Input : */
9901 /* Output : */
9902 /* Description : */
9903 /* --------------------------------------------------------------------- */
9904 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
9906 unsigned short tempbx ;
9908 tempbx = 0 ;
9914 /* --------------------------------------------------------------------- */
9915 /* Function : XGI_GetRAMDAC2DATA */
9916 /* Input : */
9917 /* Output : */
9918 /* Description : */
9919 /* --------------------------------------------------------------------- */
9920 void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo)
9922 unsigned short tempax ,
9923 tempbx ,
9924 temp1 ,
9925 temp2 ,
9926 modeflag = 0 ,
9927 tempcx ,
9928 StandTableIndex ,
9929 CRT1Index ;
9931 pVBInfo->RVBHCMAX = 1 ;
9932 pVBInfo->RVBHCFACT = 1 ;
9934 if ( ModeNo <= 0x13 )
9936 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9937 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
9938 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
9939 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
9940 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
9942 else
9944 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9945 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
9946 CRT1Index &= IndexMask ;
9947 temp1 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
9948 temp2 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
9949 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
9950 tempbx = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
9951 tempcx = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
9952 tempcx &= 0x0100 ;
9953 tempcx = tempcx << 2 ;
9954 tempbx |= tempcx;
9955 temp1 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
9958 if ( temp1 & 0x01 )
9959 tempbx |= 0x0100 ;
9961 if ( temp1 & 0x20 )
9962 tempbx |= 0x0200 ;
9963 tempax += 5 ;
9965 if ( modeflag & Charx8Dot )
9966 tempax *= 8 ;
9967 else
9968 tempax *= 9 ;
9970 pVBInfo->VGAHT = tempax ;
9971 pVBInfo->HT = tempax ;
9972 tempbx++ ;
9973 pVBInfo->VGAVT = tempbx ;
9974 pVBInfo->VT = tempbx ;
9979 /* --------------------------------------------------------------------- */
9980 /* Function : XGI_GetColorDepth */
9981 /* Input : */
9982 /* Output : */
9983 /* Description : */
9984 /* --------------------------------------------------------------------- */
9985 unsigned short XGI_GetColorDepth(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
9987 unsigned short ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
9988 short index ;
9989 unsigned short modeflag ;
9991 if ( ModeNo <= 0x13 )
9993 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9995 else
9997 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
10000 index=(modeflag&ModeInfoFlag)-ModeEGA;
10002 if ( index < 0 )
10003 index = 0 ;
10005 return( ColorDepth[ index ] ) ;
10010 /* --------------------------------------------------------------------- */
10011 /* Function : XGI_UnLockCRT2 */
10012 /* Input : */
10013 /* Output : */
10014 /* Description : */
10015 /* --------------------------------------------------------------------- */
10016 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
10019 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
10024 /* --------------------------------------------------------------------- */
10025 /* Function : XGI_LockCRT2 */
10026 /* Input : */
10027 /* Output : */
10028 /* Description : */
10029 /* --------------------------------------------------------------------- */
10030 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
10033 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
10039 /* --------------------------------------------------------------------- */
10040 /* Function : XGINew_EnableCRT2 */
10041 /* Input : */
10042 /* Output : */
10043 /* Description : */
10044 /* --------------------------------------------------------------------- */
10045 void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
10047 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
10052 /* --------------------------------------------------------------------- */
10053 /* Function : */
10054 /* Input : */
10055 /* Output : */
10056 /* Description : */
10057 /* --------------------------------------------------------------------- */
10058 void XGINew_LCD_Wait_Time(unsigned char DelayTime, struct vb_device_info *pVBInfo)
10060 unsigned short i ,
10063 unsigned long temp ,
10064 flag ;
10066 flag = 0 ;
10067 //printk("XGINew_LCD_Wait_Time");
10068 //return;
10069 for( i = 0 ; i < DelayTime ; i++ )
10071 for( j = 0 ; j < 66 ; j++ )
10074 temp = XGINew_GetReg3( 0x61 ) ;
10076 //temp &= 0x10000000;
10077 temp &= 0x10;
10078 if ( temp == flag )
10079 continue ;
10081 flag = temp ;
10089 /* --------------------------------------------------------------------- */
10090 /* Function : XGI_BridgeIsOn */
10091 /* Input : */
10092 /* Output : */
10093 /* Description : */
10094 /* --------------------------------------------------------------------- */
10095 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
10097 unsigned short flag ;
10099 if ( pVBInfo->IF_DEF_LVDS == 1 )
10101 return( 1 ) ;
10103 else
10105 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10106 if ( ( flag == 1 ) || ( flag == 2 ) )
10107 return( 1 ) ; /* 301b */
10108 else
10109 return( 0 ) ;
10115 /* --------------------------------------------------------------------- */
10116 /* Function : XGI_LongWait */
10117 /* Input : */
10118 /* Output : */
10119 /* Description : */
10120 /* --------------------------------------------------------------------- */
10121 void XGI_LongWait(struct vb_device_info *pVBInfo)
10123 unsigned short i ;
10125 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10127 if ( !( i & 0xC0 ) )
10129 for( i = 0 ; i < 0xFFFF ; i++ )
10131 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10132 break ;
10135 for( i = 0 ; i < 0xFFFF ; i++ )
10137 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10138 break ;
10144 /* --------------------------------------------------------------------- */
10145 /* Function : XGI_VBLongWait */
10146 /* Input : */
10147 /* Output : */
10148 /* Description : */
10149 /* --------------------------------------------------------------------- */
10150 void XGI_VBLongWait(struct vb_device_info *pVBInfo)
10152 unsigned short tempal ,
10153 temp ,
10156 return ;
10157 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10159 temp = 0 ;
10160 for( i = 0 ; i < 3 ; i++ )
10162 for( j = 0 ; j < 100 ; j++ )
10164 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10165 if ( temp & 0x01 )
10166 { /* VBWaitMode2 */
10167 if ( ( tempal & 0x08 ) )
10169 continue ;
10172 if ( !( tempal & 0x08 ) )
10174 break ;
10177 else
10178 { /* VBWaitMode1 */
10179 if ( !( tempal & 0x08 ) )
10181 continue ;
10184 if ( ( tempal & 0x08 ) )
10186 break ;
10190 temp = temp ^ 0x01 ;
10193 else
10195 XGI_LongWait(pVBInfo) ;
10197 return ;
10203 /* --------------------------------------------------------------------- */
10204 /* Function : XGI_GetVGAHT2 */
10205 /* Input : */
10206 /* Output : */
10207 /* Description : */
10208 /* --------------------------------------------------------------------- */
10209 unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
10211 unsigned long tempax ,
10212 tempbx ;
10214 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10215 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10216 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10218 return( (unsigned short)tempax ) ;
10222 /* --------------------------------------------------------------------- */
10223 /* Function : XGI_GetVCLK2Ptr */
10224 /* Input : */
10225 /* Output : */
10226 /* Description : */
10227 /* --------------------------------------------------------------------- */
10228 unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
10229 unsigned short ModeIdIndex,
10230 unsigned short RefreshRateTableIndex,
10231 struct xgi_hw_device_info *HwDeviceExtension,
10232 struct vb_device_info *pVBInfo)
10234 unsigned short tempbx ;
10236 unsigned short LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10237 unsigned short LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10238 unsigned short LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10239 unsigned short LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10240 unsigned short LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10242 unsigned short CRT2Index , VCLKIndex ;
10243 unsigned short modeflag , resinfo ;
10244 unsigned char *CHTVVCLKPtr = NULL ;
10246 if ( ModeNo <= 0x13 )
10248 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10249 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10250 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10252 else
10254 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10255 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10256 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10259 if ( pVBInfo->IF_DEF_LVDS == 0 )
10261 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10262 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10264 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10266 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10268 else
10270 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10273 else /* for TV */
10275 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10277 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10279 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10281 VCLKIndex = HiTVVCLKDIV2 ;
10284 VCLKIndex += 25 ;
10287 else
10289 VCLKIndex = HiTVVCLK ;
10292 VCLKIndex += 25 ;
10296 if ( pVBInfo->SetFlag & TVSimuMode )
10298 if( modeflag & Charx8Dot )
10300 VCLKIndex = HiTVSimuVCLK ;
10303 VCLKIndex += 25 ;
10306 else
10308 VCLKIndex = HiTVTextVCLK ;
10311 VCLKIndex += 25 ;
10316 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10318 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10320 VCLKIndex = YPbPr750pVCLK ;
10321 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10323 VCLKIndex = YPbPr525pVCLK ;
10324 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10326 VCLKIndex = YPbPr525iVCLK_2 ;
10327 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10328 VCLKIndex = YPbPr525iVCLK ;
10334 else
10336 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10338 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10340 VCLKIndex = TVVCLKDIV2 ;
10343 VCLKIndex += 25 ;
10346 else
10348 VCLKIndex = TVVCLK ;
10351 VCLKIndex += 25 ;
10357 else
10358 { /* for CRT2 */
10359 VCLKIndex = (unsigned char)XGINew_GetReg2((pVBInfo->P3ca + 0x02)); /* Port 3cch */
10360 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10361 if ( ModeNo > 0x13 )
10363 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10364 VCLKIndex &= IndexMask ;
10369 else
10370 { /* LVDS */
10371 if ( ModeNo <= 0x13 )
10372 VCLKIndex = CRT2Index ;
10373 else
10374 VCLKIndex = CRT2Index ;
10376 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10378 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10380 VCLKIndex &= 0x1f ;
10381 tempbx = 0 ;
10383 if ( pVBInfo->VBInfo & SetPALTV )
10384 tempbx += 2 ;
10386 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10387 tempbx += 1 ;
10389 switch( tempbx )
10391 case 0:
10392 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10393 break ;
10394 case 1:
10395 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10396 break;
10397 case 2:
10398 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10399 break ;
10400 case 3:
10401 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10402 break ;
10403 default:
10404 break ;
10407 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10410 else
10412 VCLKIndex = VCLKIndex >> 6 ;
10413 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10414 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10415 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10416 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10417 else
10418 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10421 /* VCLKIndex = VCLKIndex&IndexMask ; */
10425 return( VCLKIndex ) ;