3 #include <linux/types.h>
4 #include <linux/version.h>
10 #include "vb_struct.h"
16 #define IndexMask 0xff
17 #ifndef XGI_MASK_DUAL_CHIP
18 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
23 unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo);
24 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
25 struct xgi_hw_device_info *HwDeviceExtension,
26 struct vb_device_info *pVBInfo);
27 unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo);
29 unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo);
30 unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo);
31 unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo);
32 unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
33 unsigned short ModeIdIndex,
34 unsigned short RefreshRateTableIndex,
35 unsigned short *i, struct vb_device_info *pVBInfo);
36 unsigned char XGI_SearchModeID(unsigned short ModeNo,
37 unsigned short *ModeIdIndex,
38 struct vb_device_info *pVBInfo);
39 unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
40 unsigned short ModeIdIndex,
41 struct vb_device_info *pVBInfo);
42 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
43 unsigned short ModeNo);
44 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo);
45 unsigned char XGI_GetModePtr(unsigned short ModeNo,
46 unsigned short ModeIdIndex,
47 struct vb_device_info *pVBInfo);
48 unsigned short XGI_GetOffset(unsigned short ModeNo,
49 unsigned short ModeIdIndex,
50 unsigned short RefreshRateTableIndex,
51 struct xgi_hw_device_info *HwDeviceExtension,
52 struct vb_device_info *pVBInfo);
53 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
54 unsigned short ModeNo,
55 unsigned short ModeIdIndex,
56 struct vb_device_info *pVBInfo);
57 unsigned short XGI_GetResInfo(unsigned short ModeNo,
58 unsigned short ModeIdIndex,
59 struct vb_device_info *pVBInfo);
60 unsigned short XGI_GetColorDepth(unsigned short ModeNo,
61 unsigned short ModeIdIndex,
62 struct vb_device_info *pVBInfo);
63 unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo);
64 unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
65 unsigned short ModeIdIndex,
66 unsigned short RefreshRateTableIndex,
67 struct xgi_hw_device_info *HwDeviceExtension,
68 struct vb_device_info *pVBInfo);
69 void XGI_VBLongWait(struct vb_device_info *pVBInfo);
70 void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo);
71 void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
72 void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
73 void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
74 void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
75 void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
76 void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
77 void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
78 void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
79 void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
80 void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
81 void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
82 void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
83 void XGI_FirePWDEnable(struct vb_device_info *pVBInfo);
84 void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
85 void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
86 void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo);
87 void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, struct vb_device_info *pVBInfo);
88 void XGI_EnablePWD(struct vb_device_info *pVBInfo);
89 void XGI_DisablePWD(struct vb_device_info *pVBInfo);
90 void XGI_AutoThreshold(struct vb_device_info *pVBInfo);
91 void XGI_SetTap4Regs(struct vb_device_info *pVBInfo);
93 void XGI_DisplayOn(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
94 void XGI_DisplayOff(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
95 void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
96 void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
97 void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
98 void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
99 void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
100 void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex);
101 void XGI_WaitDisply(struct vb_device_info *pVBInfo);
102 void XGI_SenseCRT1(struct vb_device_info *pVBInfo);
103 void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
104 void XGI_SetMiscRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
105 void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
106 void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
107 void XGI_SetGRCRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
108 void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo);
110 void XGI_SetSync(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
111 void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension);
112 void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension);
113 void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo, struct vb_device_info *pVBInfo);
114 void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
115 void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
116 void XGI_SetCRT1FIFO(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
117 void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
118 void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
120 void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
121 void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al, unsigned short dh, struct vb_device_info *pVBInfo);
122 /*void XGI_ClearBuffer(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, struct vb_device_info *pVBInfo);*/
123 void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
124 void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
125 struct vb_device_info *pVBInfo);
126 void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
127 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo);
128 void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
129 unsigned short RefreshRateTableIndex,
130 struct xgi_hw_device_info *HwDeviceExtension,
131 struct vb_device_info *pVBInfo);
132 void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
133 void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
134 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
135 void XGI_GetVBType(struct vb_device_info *pVBInfo);
136 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
137 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
138 void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
139 void InitTo330Pointer(unsigned char, struct vb_device_info *pVBInfo);
140 void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, struct vb_device_info *pVBInfo);
141 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
142 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
143 void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
144 void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
145 void XGI_SetDelayComp(struct vb_device_info *pVBInfo);
146 void XGI_SetLCDCap(struct vb_device_info *pVBInfo);
147 void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo);
148 void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo);
149 void SetSpectrum(struct vb_device_info *pVBInfo);
150 void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
151 void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
152 void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo);
153 void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
154 void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char* tempcl,
155 unsigned char *tempch, struct vb_device_info *pVBInfo);
156 unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo);
157 void XGI_SetCRT2ModeRegs(unsigned short ModeNo, struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
158 void XGI_CloseCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
159 void XGI_OpenCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
160 void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
161 void XGI_UnLockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
162 void XGI_LockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
163 void XGINew_EnableCRT2(struct vb_device_info *pVBInfo);
164 void XGINew_LCD_Wait_Time(unsigned char DelayTime, struct vb_device_info *pVBInfo);
165 void XGI_LongWait(struct vb_device_info *pVBInfo);
166 void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
167 void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
168 struct vb_device_info *pVBInfo);
169 unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
170 unsigned short ModeNo,
171 unsigned short ModeIdIndex,
172 struct vb_device_info *pVBInfo);
173 void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
174 unsigned char *di_1, struct vb_device_info *pVBInfo);
175 unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo);
176 unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo);
177 struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo);
178 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo);
179 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo);
180 unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo);
181 unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo);
182 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
183 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
184 void XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo);
185 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
186 void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
187 void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
188 unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo);
190 extern void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVBInfo);
192 /* unsigned short XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
195 static unsigned short XGINew_MDA_DAC[] = {
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
198 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
199 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
202 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
203 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
205 static unsigned short XGINew_CGA_DAC[] = {
206 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
207 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
208 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
209 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
210 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
211 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
212 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
213 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
215 static unsigned short XGINew_EGA_DAC[] = {
216 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
217 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
218 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
219 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
220 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
221 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
222 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
223 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
225 static unsigned short XGINew_VGA_DAC[] = {
226 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
227 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
228 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
229 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
230 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
231 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
232 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
233 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
234 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
235 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
237 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
239 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable;
240 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable;
241 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
242 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
243 pVBInfo->XGINEWUB_CRT1Table
244 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
246 /* add for new UNIVGABIOS */
247 /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
248 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
250 if (ChipType >= XG40) {
252 = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
254 = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
257 = (struct XGI_MCLKDataStruct *) XGI330New_MCLKData;
259 = (struct XGI_ECLKDataStruct *) XGI330_ECLKData;
262 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData;
263 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData;
264 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
265 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo;
267 = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo;
269 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
270 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
271 pVBInfo->pSR07 = &XGI330_SR07;
272 pVBInfo->LCDResInfo = 0;
273 pVBInfo->LCDTypeInfo = 0;
274 pVBInfo->LCDInfo = 0;
278 pVBInfo->SR15 = XGI340_SR13;
279 pVBInfo->CR40 = XGI340_cr41;
280 pVBInfo->SR25 = XGI330_sr25;
281 pVBInfo->pSR31 = &XGI330_sr31;
282 pVBInfo->pSR32 = &XGI330_sr32;
283 pVBInfo->CR6B = XGI340_CR6B;
284 pVBInfo->CR6E = XGI340_CR6E;
285 pVBInfo->CR6F = XGI340_CR6F;
286 pVBInfo->CR89 = XGI340_CR89;
287 pVBInfo->AGPReg = XGI340_AGPReg;
288 pVBInfo->SR16 = XGI340_SR16;
289 pVBInfo->pCRCF = &XG40_CRCF;
290 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
292 pVBInfo->CR49 = XGI330_CR49;
293 pVBInfo->pSR1F = &XGI330_SR1F;
294 pVBInfo->pSR21 = &XGI330_SR21;
295 pVBInfo->pSR22 = &XGI330_SR22;
296 pVBInfo->pSR23 = &XGI330_SR23;
297 pVBInfo->pSR24 = &XGI330_SR24;
298 pVBInfo->pSR33 = &XGI330_SR33;
300 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
301 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
302 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
303 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
304 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
305 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
306 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
307 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
308 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
309 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
311 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
312 pVBInfo->PALTiming = XGI330_PALTiming;
313 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
314 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
315 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
316 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
317 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
318 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
319 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
320 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
321 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
322 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
323 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
324 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
326 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
327 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
328 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
330 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC;
331 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC;
332 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL;
333 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL;
335 /* 310 customization related */
336 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
337 pVBInfo->LCDCapList = XGI_LCDDLCapList;
339 pVBInfo->LCDCapList = XGI_LCDCapList;
341 if ((ChipType == XG21) || (ChipType == XG27))
342 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList;
344 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
345 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
347 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
349 if (ChipType >= XG20)
350 pVBInfo->pXGINew_CR97 = &XG20_CR97;
352 if (ChipType == XG27) {
354 = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
355 pVBInfo->CR40 = XGI27_cr41;
356 pVBInfo->pXGINew_CR97 = &XG27_CR97;
357 pVBInfo->pSR36 = &XG27_SR36;
358 pVBInfo->pCR8F = &XG27_CR8F;
359 pVBInfo->pCRD0 = XG27_CRD0;
360 pVBInfo->pCRDE = XG27_CRDE;
361 pVBInfo->pSR40 = &XG27_SR40;
362 pVBInfo->pSR41 = &XG27_SR41;
366 if (ChipType >= XG20) {
367 pVBInfo->pDVOSetting = &XG21_DVOSetting;
368 pVBInfo->pCR2E = &XG21_CR2E;
369 pVBInfo->pCR2F = &XG21_CR2F;
370 pVBInfo->pCR46 = &XG21_CR46;
371 pVBInfo->pCR47 = &XG21_CR47;
376 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
377 unsigned short ModeNo)
379 unsigned short ModeIdIndex;
380 /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */
381 struct vb_device_info VBINF;
382 struct vb_device_info *pVBInfo = &VBINF;
383 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
384 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
385 pVBInfo->IF_DEF_LVDS = 0;
386 pVBInfo->IF_DEF_CH7005 = 0;
387 pVBInfo->IF_DEF_LCDA = 1;
388 pVBInfo->IF_DEF_CH7017 = 0;
389 pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */
390 pVBInfo->IF_DEF_VideoCapture = 0;
391 pVBInfo->IF_DEF_ScaleLCD = 0;
392 pVBInfo->IF_DEF_OEMUtil = 0;
393 pVBInfo->IF_DEF_PWD = 0;
395 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
396 pVBInfo->IF_DEF_YPbPr = 0;
397 pVBInfo->IF_DEF_HiVision = 0;
398 pVBInfo->IF_DEF_CRT2Monitor = 0;
399 pVBInfo->VBType = 0; /*set VBType default 0*/
400 } else if (HwDeviceExtension->jChipType >= XG40) {
401 pVBInfo->IF_DEF_YPbPr = 1;
402 pVBInfo->IF_DEF_HiVision = 1;
403 pVBInfo->IF_DEF_CRT2Monitor = 1;
405 pVBInfo->IF_DEF_YPbPr = 1;
406 pVBInfo->IF_DEF_HiVision = 1;
407 pVBInfo->IF_DEF_CRT2Monitor = 0;
410 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
411 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
412 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
413 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
414 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
415 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
416 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
417 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
418 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
419 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
420 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
421 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
422 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
423 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04;
424 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10;
425 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12;
426 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
427 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
429 if (HwDeviceExtension->jChipType == XG21) { /* for x86 Linux, XG21 LVDS */
430 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
431 pVBInfo->IF_DEF_LVDS = 1;
433 if (HwDeviceExtension->jChipType == XG27) {
434 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
435 if (XGINew_GetReg1(pVBInfo->P3d4, 0x30) & 0x20)
436 pVBInfo->IF_DEF_LVDS = 1;
440 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
441 XGI_GetVBType(pVBInfo);
443 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
445 ModeNo = ModeNo & 0x7F;
446 /* XGINew_flag_clearbuffer = 0; */
449 XGINew_flag_clearbuffer = 1;
452 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
454 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
455 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
457 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
459 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
461 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
462 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
463 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
464 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
465 XGI_DisableBridge(HwDeviceExtension, pVBInfo);
466 /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */
468 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
469 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
470 ModeIdIndex, pVBInfo);
472 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
473 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
474 HwDeviceExtension, pVBInfo);
477 if (!(pVBInfo->VBInfo & SwitchToCRT2)) {
478 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
479 ModeIdIndex, pVBInfo);
480 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
481 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
488 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) {
489 switch (HwDeviceExtension->ujVBChipID) {
491 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
492 pVBInfo); /*add for CRT2 */
496 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
497 pVBInfo); /*add for CRT2 */
505 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
506 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
507 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
508 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
511 if (pVBInfo->IF_DEF_LVDS == 1)
512 if (!XGI_XG21CheckLVDSMode(ModeNo, ModeIdIndex, pVBInfo))
515 if (ModeNo <= 0x13) {
517 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag
521 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag
525 pVBInfo->SetFlag = 0;
526 if (pVBInfo->IF_DEF_CH7007 != 1)
527 pVBInfo->VBInfo = DisableCRT2Display;
529 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
531 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex,
534 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
536 if (HwDeviceExtension->jChipType == XG21)
537 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
542 if (ModeNo <= 0x13) {
543 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
545 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
547 pVBInfo->ModeType = modeflag&ModeInfoFlag;
548 pVBInfo->SetFlag = 0x00;
549 pVBInfo->VBInfo = DisableCRT2Display;
550 temp = XGINew_CheckMemorySize(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
555 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
556 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
557 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
560 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
562 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
563 XGI_LockCRT2(HwDeviceExtension, pVBInfo);
569 void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
570 unsigned short ModeNo, unsigned short ModeIdIndex,
571 struct vb_device_info *pVBInfo)
573 unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
575 unsigned short XGINew_P3cc = pVBInfo->P3cc;
577 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
578 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
579 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
580 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
581 XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
582 XGI_SetMiscRegs(StandTableIndex, pVBInfo);
583 XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
584 XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
585 XGI_SetGRCRegs(StandTableIndex, pVBInfo);
586 XGI_ClearExt1Regs(pVBInfo);
588 /* if (pVBInfo->IF_DEF_ExpLink) */
589 if (HwDeviceExtension->jChipType == XG27) {
590 if (pVBInfo->IF_DEF_LVDS == 0)
591 XGI_SetDefaultVCLK(pVBInfo);
594 temp = ~ProgrammingCRT2;
595 pVBInfo->SetFlag &= temp;
596 pVBInfo->SelectCRT2Rate = 0;
598 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
599 | VB_XGI302LV | VB_XGI301C)) {
600 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA
602 pVBInfo->SetFlag |= ProgrammingCRT2;
606 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
607 ModeIdIndex, pVBInfo);
608 if (RefreshRateTableIndex != 0xFFFF) {
609 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
610 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
611 pVBInfo, HwDeviceExtension);
612 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
613 RefreshRateTableIndex, pVBInfo);
614 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
615 HwDeviceExtension, pVBInfo);
616 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
617 RefreshRateTableIndex, pVBInfo);
620 if ((HwDeviceExtension->jChipType >= XG20)
621 && (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
622 if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
623 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x4E);
624 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE9);
625 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc);
626 XGINew_SetReg3(XGINew_P3cc, (b3CC |= 0x0C));
627 } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
629 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
630 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE3);
631 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc);
632 XGINew_SetReg3(XGINew_P3cc, (b3CC |= 0x0C));
636 if (HwDeviceExtension->jChipType >= XG21) {
637 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
640 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x20); *//* Enable write GPIOF */
641 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x48, ~0x20); *//* P. DWN */
642 /* XG21 CRT1 Timing */
643 if (HwDeviceExtension->jChipType == XG27)
644 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
645 RefreshRateTableIndex, pVBInfo);
647 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
648 RefreshRateTableIndex, pVBInfo);
650 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
651 RefreshRateTableIndex);
653 if (HwDeviceExtension->jChipType == XG27)
654 XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex,
657 XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex,
660 if (pVBInfo->IF_DEF_LVDS == 1) {
661 if (HwDeviceExtension->jChipType == XG27)
662 XGI_SetXG27LVDSPara(ModeNo,
663 ModeIdIndex, pVBInfo);
665 XGI_SetXG21LVDSPara(ModeNo,
666 ModeIdIndex, pVBInfo);
668 /* XGINew_SetRegOR(pVBInfo->P3d4, 0x48, 0x20); *//* P. ON */
672 pVBInfo->SetFlag &= (~ProgrammingCRT2);
673 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
674 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
675 RefreshRateTableIndex, pVBInfo);
677 /* XGI_LoadCharacter(); //dif ifdef TVFont */
679 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
680 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
683 unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
684 struct vb_device_info *pVBInfo)
689 index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
691 if (pVBInfo->ModeType <= 0x02)
692 index = 0x1B; /* 02 -> ModeEGA */
696 return index; /* Get pVBInfo->StandTable index */
700 unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) {
705 /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) {
710 void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
711 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
713 unsigned char tempah, SRdata;
715 unsigned short i, modeflag;
718 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
720 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
722 XGINew_SetReg1(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
723 tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
726 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
729 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
730 if (pVBInfo->VBInfo & SetInSlaveMode)
735 tempah |= 0x20; /* screen off */
736 XGINew_SetReg1(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
738 for (i = 02; i <= 04; i++) {
739 SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; /* Get SR2,3,4 from file */
740 XGINew_SetReg1(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
744 void XGI_SetMiscRegs(unsigned short StandTableIndex,
745 struct vb_device_info *pVBInfo)
747 unsigned char Miscdata;
749 Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; /* Get Misc from file */
751 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
752 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
758 XGINew_SetReg3(pVBInfo->P3c2, Miscdata); /* Set Misc(3c2) */
761 void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
762 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
764 unsigned char CRTCdata;
767 CRTCdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
769 XGINew_SetReg1(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
771 for (i = 0; i <= 0x18; i++) {
772 CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; /* Get CRTC from file */
773 XGINew_SetReg1(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
776 if ((HwDeviceExtension->jChipType == XGI_630) && (HwDeviceExtension->jChipRevision == 0x30)) {
777 if (pVBInfo->VBInfo & SetInSlaveMode) {
778 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
779 XGINew_SetReg1(pVBInfo->P3d4, 0x18, 0xFE);
786 void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
787 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
789 unsigned char ARdata;
790 unsigned short i, modeflag;
793 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
795 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
797 for (i = 0; i <= 0x13; i++) {
798 ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
799 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
801 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
804 if (pVBInfo->VBInfo & (SetCRT2ToTV
814 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
815 XGINew_SetReg3(pVBInfo->P3c0, i); /* set index */
816 XGINew_SetReg3(pVBInfo->P3c0, ARdata); /* set data */
819 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
820 XGINew_SetReg3(pVBInfo->P3c0, 0x14); /* set index */
821 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data */
822 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
823 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
826 void XGI_SetGRCRegs(unsigned short StandTableIndex,
827 struct vb_device_info *pVBInfo)
829 unsigned char GRdata;
832 for (i = 0; i <= 0x08; i++) {
833 GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; /* Get GR from file */
834 XGINew_SetReg1(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
837 if (pVBInfo->ModeType > ModeVGA) {
838 GRdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3ce, 0x05);
839 GRdata &= 0xBF; /* 256 color disable */
840 XGINew_SetReg1(pVBInfo->P3ce, 0x05, GRdata);
844 void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
848 for (i = 0x0A; i <= 0x0E; i++)
849 XGINew_SetReg1(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
852 unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
855 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
856 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
857 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
859 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
860 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
861 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
863 XGINew_SetRegAND(pVBInfo->P3c4, 0x31, ~0x30);
867 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
868 unsigned short ModeNo, unsigned short ModeIdIndex,
869 struct vb_device_info *pVBInfo)
871 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
872 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
875 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
878 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
880 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
882 if (pVBInfo->IF_DEF_CH7005 == 1) {
883 if (pVBInfo->VBInfo & SetCRT2ToTV) {
884 if (modeflag & HalfDCLK)
892 index = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
893 index = index >> pVBInfo->SelectCRT2Rate;
896 if (pVBInfo->LCDInfo & LCDNonExpanding)
902 if (pVBInfo->SetFlag & ProgrammingCRT2) {
903 if (pVBInfo->IF_DEF_CH7005 == 1) {
904 if (pVBInfo->VBInfo & SetCRT2ToTV)
908 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
909 if (pVBInfo->IF_DEF_LVDS == 0) {
910 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
911 | VB_XGI301LV | VB_XGI302LV
914 = LCDARefreshIndex[pVBInfo->LCDResInfo
918 = LCDRefreshIndex[pVBInfo->LCDResInfo
929 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
930 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
931 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
933 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & XG2xNotSupport) {
937 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800)
938 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
942 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
943 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024)
944 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
948 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280)
949 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
957 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].ModeID
961 = pVBInfo->RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
962 temp &= ModeInfoFlag;
963 if (temp < pVBInfo->ModeType)
968 } while (index != 0xFFFF);
969 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
970 if (pVBInfo->VBInfo & SetInSlaveMode) {
972 = pVBInfo->RefIndex[RefreshRateTableIndex
973 + i - 1].Ext_InfoFlag;
974 if (temp & InterlaceMode)
979 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
980 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
981 RefreshRateTableIndex, &i, pVBInfo);
983 return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */
986 unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
987 unsigned short ModeIdIndex,
988 unsigned short RefreshRateTableIndex, unsigned short *i,
989 struct vb_device_info *pVBInfo)
991 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
994 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
996 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
998 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
999 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
1002 if (pVBInfo->IF_DEF_LVDS == 0) {
1003 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
1004 tempax |= SupportRAMDAC2;
1006 if (pVBInfo->VBType & VB_XGI301C)
1007 tempax |= SupportCRT2in301C;
1010 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */
1011 tempax |= SupportLCD;
1013 if (pVBInfo->LCDResInfo != Panel1280x1024) {
1014 if (pVBInfo->LCDResInfo != Panel1280x960) {
1015 if (pVBInfo->LCDInfo & LCDNonExpanding) {
1025 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
1026 if ((pVBInfo->VBType & VB_XGI301LV)
1027 && (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
1028 tempax |= SupportYPbPr;
1029 if (pVBInfo->VBInfo & SetInSlaveMode) {
1040 tempax |= SupportHiVisionTV;
1041 if (pVBInfo->VBInfo & SetInSlaveMode) {
1046 if (pVBInfo->SetFlag
1056 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
1057 | SetCRT2ToSVIDEO | SetCRT2ToSCART
1058 | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) {
1059 tempax |= SupportTV;
1061 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
1062 | VB_XGI301LV | VB_XGI302LV
1064 tempax |= SupportTV1024;
1067 if (!(pVBInfo->VBInfo & SetPALTV)) {
1068 if (modeflag & NoSupportSimuTV) {
1071 if (!(pVBInfo->VBInfo
1072 & SetNotSimuMode)) {
1080 } else { /* for LVDS */
1081 if (pVBInfo->IF_DEF_CH7005 == 1) {
1082 if (pVBInfo->VBInfo & SetCRT2ToTV)
1083 tempax |= SupportCHTV;
1086 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
1087 tempax |= SupportLCD;
1090 return 0; /* 1024x768 */
1092 if (pVBInfo->LCDResInfo < Panel1024x768) {
1094 return 0; /* 800x600 */
1096 if (resinfo == 0x04)
1097 return 0; /* 512x384 */
1102 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == tempbx; (*i)--) {
1104 = pVBInfo->RefIndex[RefreshRateTableIndex
1105 + (*i)].Ext_InfoFlag;
1106 if (infoflag & tempax)
1113 for ((*i) = 0;; (*i)++) {
1115 = pVBInfo->RefIndex[RefreshRateTableIndex
1116 + (*i)].Ext_InfoFlag;
1117 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
1122 if (infoflag & tempax)
1128 void XGI_SetSync(unsigned short RefreshRateTableIndex,
1129 struct vb_device_info *pVBInfo)
1131 unsigned short sync, temp;
1133 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; /* di+0x00 */
1137 XGINew_SetReg3(pVBInfo->P3c2, temp); /* Set Misc(3c2) */
1140 void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1141 unsigned short RefreshRateTableIndex,
1142 struct vb_device_info *pVBInfo,
1143 struct xgi_hw_device_info *HwDeviceExtension)
1145 unsigned char index, data;
1148 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */
1149 index = index & IndexMask;
1151 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1153 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1155 for (i = 0; i < 8; i++)
1156 pVBInfo->TimingH[0].data[i]
1157 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
1159 for (i = 0; i < 7; i++)
1160 pVBInfo->TimingV[0].data[i]
1161 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
1163 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
1165 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
1167 if (pVBInfo->ModeType > 0x03)
1168 XGINew_SetReg1(pVBInfo->P3d4, 0x14, 0x4F);
1171 void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
1172 struct xgi_hw_device_info *HwDeviceExtension)
1174 unsigned char data, data1, pushax;
1175 unsigned short i, j;
1177 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
1178 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
1179 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
1181 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
1183 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data);
1185 data = pVBInfo->TimingH[0].data[0];
1186 XGINew_SetReg1(pVBInfo->P3d4, 0, data);
1188 for (i = 0x01; i <= 0x04; i++) {
1189 data = pVBInfo->TimingH[0].data[i];
1190 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 1), data);
1193 for (i = 0x05; i <= 0x06; i++) {
1194 data = pVBInfo->TimingH[0].data[i];
1195 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i + 6), data);
1198 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1200 data = pVBInfo->TimingH[0].data[7];
1203 XGINew_SetReg1(pVBInfo->P3c4, 0x0e, data);
1205 if (HwDeviceExtension->jChipType >= XG20) {
1206 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x04);
1208 XGINew_SetReg1(pVBInfo->P3d4, 0x04, data);
1209 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x05);
1215 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4,
1218 XGINew_SetReg1(pVBInfo->P3c4, 0x0c, data);
1223 XGINew_SetReg1(pVBInfo->P3d4, 0x05, data);
1224 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1230 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0e, ~0xE0, data);
1234 void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo,
1235 struct vb_device_info *pVBInfo)
1238 unsigned short i, j;
1240 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
1241 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
1242 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
1244 for (i = 0x00; i <= 0x01; i++) {
1245 data = pVBInfo->TimingV[0].data[i];
1246 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 6), data);
1249 for (i = 0x02; i <= 0x03; i++) {
1250 data = pVBInfo->TimingV[0].data[i];
1251 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
1254 for (i = 0x04; i <= 0x05; i++) {
1255 data = pVBInfo->TimingV[0].data[i];
1256 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
1259 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0a);
1261 data = pVBInfo->TimingV[0].data[6];
1264 XGINew_SetReg1(pVBInfo->P3c4, 0x0a, data);
1266 data = pVBInfo->TimingV[0].data[6];
1271 i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1273 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1275 i &= DoubleScanMode;
1279 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x09);
1282 XGINew_SetReg1(pVBInfo->P3d4, 0x09, data);
1285 /* --------------------------------------------------------------------- */
1286 /* Function : XGI_SetXG21CRTC */
1287 /* Input : Stand or enhance CRTC table */
1288 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1289 /* Description : Set LCD timing */
1290 /* --------------------------------------------------------------------- */
1291 void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1292 unsigned short RefreshRateTableIndex,
1293 struct vb_device_info *pVBInfo)
1295 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1296 unsigned short Temp1, Temp2, Temp3;
1298 if (ModeNo <= 0x13) {
1299 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
1300 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
1301 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
1302 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
1303 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
1305 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
1306 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1307 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
1308 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
1309 Tempdx <<= 2; /* Tempdx << 2 */
1310 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
1311 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
1313 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR16 VRS */
1314 Tempbx = Tempax; /* Tempbx=Tempax */
1315 Tempax &= 0x01; /* Tempax: VRS[0] */
1316 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
1317 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax: CR7 VRS */
1318 Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
1319 Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
1320 Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
1321 Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
1322 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempdx); /* SR34[7:0]: VRS[8:1] */
1324 Temp1 = Tempcx << 1; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
1325 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
1326 Tempax &= 0x80; /* Tempax[7]: CR7[7] */
1327 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
1328 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
1330 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR16 VRE */
1331 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1332 Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
1333 Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
1334 Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
1335 if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
1336 Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
1337 Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
1338 Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
1339 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
1340 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
1341 Temp1 >>= 9; /* [10:9]->[1:0] */
1342 Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
1343 Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
1345 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
1347 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
1348 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1349 Tempcx = Tempax; /* Tempcx: HRS */
1350 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
1352 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
1353 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
1354 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
1355 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
1356 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
1358 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
1359 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
1361 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
1362 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
1363 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
1364 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
1366 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
1367 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
1369 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
1370 if (Tempax < Tempcx) /* HRE < HRS */
1371 Temp2 |= 0x40; /* Temp2 + 0x40 */
1374 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
1375 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
1376 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1377 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
1378 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1379 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
1381 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
1382 Tempbx = Tempax; /* Tempbx: VRS */
1383 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
1384 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
1385 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[2][7] VRE */
1386 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
1387 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
1388 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
1389 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
1390 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
1392 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
1393 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
1394 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
1396 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
1397 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
1398 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SRA */
1399 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
1401 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
1402 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
1404 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
1405 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1406 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SRA */
1407 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
1408 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
1409 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
1410 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
1411 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
1413 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
1414 if (Tempax < Temp3) /* VRE < VRS */
1415 Temp2 |= 0x20; /* VRE + 0x20 */
1418 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
1419 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
1420 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
1421 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
1422 Tempbx = (unsigned char) Temp1;
1423 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1425 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
1429 void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1430 unsigned short RefreshRateTableIndex,
1431 struct vb_device_info *pVBInfo)
1433 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1435 if (ModeNo <= 0x13) {
1436 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
1437 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
1438 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
1439 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
1440 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
1442 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
1443 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1444 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
1445 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
1446 Tempdx <<= 2; /* Tempdx << 2 */
1447 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
1448 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
1450 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR10 VRS */
1451 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
1452 Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
1453 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1454 Tempbx = Tempax; /* Tempbx=CR07 */
1455 Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
1457 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35 D[0]->VRS D[8] */
1458 Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
1459 Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
1461 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR11 VRE */
1462 Tempax &= 0x0F; /* Tempax: VRE[3:0] */
1463 Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
1464 Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
1465 Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
1466 if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
1467 Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
1468 Tempax = (unsigned char) Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1469 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
1470 Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
1471 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F D[7:2]->VRE D[5:0] */
1472 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); /* SR35 D[2:1]->VRS[10:9] */
1474 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
1475 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1476 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
1477 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
1479 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
1480 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1481 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1483 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
1484 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
1485 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
1487 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
1488 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
1489 Tempax <<= 3; /* Tempax[5]: HRE[5] */
1490 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
1492 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
1493 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
1495 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1496 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
1497 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
1498 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1500 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
1501 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1502 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1503 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1504 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1505 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
1507 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
1508 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */
1510 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
1511 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[7][2] VRS[9][8] */
1512 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
1513 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
1514 Tempax >>= 2; /* Tempax[0]: VRS[8] */
1515 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35[0]: VRS[8] */
1516 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
1517 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
1518 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SR0A */
1519 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1520 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
1522 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
1523 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1524 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SR0A */
1525 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
1526 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
1527 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
1528 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
1529 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
1530 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
1532 if (Tempbx <= Tempcx) /* VRE <= VRS */
1533 Tempbx |= 0x20; /* VRE + 0x20 */
1535 Tempax = (Tempbx << 2) & 0xFF; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1536 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F[7:2]:VRE[5:0] */
1537 Tempax = Tempcx >> 8;
1538 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, Tempax); /* SR35[2:0]:VRS[10:8] */
1542 /* --------------------------------------------------------------------- */
1543 /* Function : XGI_SetXG21LCD */
1545 /* Output : FCLK duty cycle, FCLK delay compensation */
1546 /* Description : All values set zero */
1547 /* --------------------------------------------------------------------- */
1548 void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
1549 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
1551 unsigned short Data, Temp, b3CC;
1552 unsigned short XGI_P3cc;
1554 XGI_P3cc = pVBInfo->P3cc;
1556 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
1557 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
1558 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
1559 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
1560 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1561 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1562 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1563 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1564 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1567 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
1570 XGINew_SetRegOR(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */
1571 XGINew_SetRegOR(pVBInfo->P3c4, 0x09, 0x40);
1574 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1576 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20);
1577 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80);
1579 if (ModeNo <= 0x13) {
1580 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1582 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1584 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1586 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1588 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1590 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1594 void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
1595 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
1597 unsigned short Data, Temp, b3CC;
1598 unsigned short XGI_P3cc;
1600 XGI_P3cc = pVBInfo->P3cc;
1602 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
1603 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
1604 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
1605 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
1607 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
1608 if ((Temp & 0x03) == 0) { /* dual 12 */
1609 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x13);
1610 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x13);
1613 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1614 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1615 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1616 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1617 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1620 XGI_SetXG27FPBits(pVBInfo);
1622 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1624 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
1625 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
1627 if (ModeNo <= 0x13) {
1628 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1630 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1632 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1634 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1636 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1638 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1642 /* --------------------------------------------------------------------- */
1643 /* Function : XGI_UpdateXG21CRTC */
1645 /* Output : CRT1 CRTC */
1646 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1647 /* --------------------------------------------------------------------- */
1648 void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo,
1649 unsigned short RefreshRateTableIndex)
1653 XGINew_SetRegAND(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
1654 if (ModeNo <= 0x13) {
1655 for (i = 0; i < 12; i++) {
1656 if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
1661 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1664 else if (ModeNo == 0x2E
1665 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1668 else if (ModeNo == 0x2F)
1670 else if (ModeNo == 0x50)
1672 else if (ModeNo == 0x59)
1677 XGINew_SetReg1(pVBInfo->P3d4, 0x02,
1678 pVBInfo->UpdateCRT1[index].CR02);
1679 XGINew_SetReg1(pVBInfo->P3d4, 0x03,
1680 pVBInfo->UpdateCRT1[index].CR03);
1681 XGINew_SetReg1(pVBInfo->P3d4, 0x15,
1682 pVBInfo->UpdateCRT1[index].CR15);
1683 XGINew_SetReg1(pVBInfo->P3d4, 0x16,
1684 pVBInfo->UpdateCRT1[index].CR16);
1688 void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1689 unsigned short ModeNo, unsigned short ModeIdIndex,
1690 unsigned short RefreshRateTableIndex,
1691 struct vb_device_info *pVBInfo)
1693 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1697 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1699 if (ModeNo <= 0x13) {
1700 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1701 tempax = pVBInfo->StResInfo[resindex].HTotal;
1702 tempbx = pVBInfo->StResInfo[resindex].VTotal;
1704 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1705 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
1706 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
1709 if (modeflag & HalfDCLK)
1710 tempax = tempax >> 1;
1712 if (ModeNo > 0x13) {
1713 if (modeflag & HalfDCLK)
1714 tempax = tempax << 1;
1716 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1718 if (temp & InterlaceMode)
1719 tempbx = tempbx >> 1;
1721 if (modeflag & DoubleScanMode)
1722 tempbx = tempbx << 1;
1727 /* if (!(modeflag & Charx8Dot)) */
1734 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1735 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1737 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1738 XGINew_SetReg1(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
1739 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0b, ~0x0c,
1740 (unsigned short) ((tempcx & 0x0ff00) >> 10));
1741 XGINew_SetReg1(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
1743 tempbx = tempbx >> 8;
1751 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x42, tempax);
1752 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x07);
1759 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
1760 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp);
1763 unsigned short XGI_GetResInfo(unsigned short ModeNo,
1764 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1766 unsigned short resindex;
1769 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1771 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1775 void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex,
1776 unsigned short RefreshRateTableIndex,
1777 struct xgi_hw_device_info *HwDeviceExtension,
1778 struct vb_device_info *pVBInfo)
1780 unsigned short temp, ah, al, temp2, i, DisplayUnit;
1783 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
1785 temp = pVBInfo->ScreenOffset[temp];
1787 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1788 temp2 &= InterlaceMode;
1793 temp2 = pVBInfo->ModeType - ModeEGA;
1818 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1819 temp = temp * temp2 + temp2 / 2;
1826 temp = temp >> 8; /* ah */
1828 i = XGINew_GetReg1(pVBInfo->P3c4, 0x0E);
1831 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, i);
1833 temp = (unsigned char) temp2;
1834 temp &= 0xFF; /* al */
1835 XGINew_SetReg1(pVBInfo->P3d4, 0x13, temp);
1837 /* SetDisplayUnit */
1838 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1839 temp2 &= InterlaceMode;
1843 DisplayUnit = DisplayUnit << 5;
1844 ah = (DisplayUnit & 0xff00) >> 8;
1845 al = DisplayUnit & 0x00ff;
1851 if (HwDeviceExtension->jChipType >= XG20)
1852 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1855 XGINew_SetReg1(pVBInfo->P3c4, 0x10, ah);
1858 void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
1859 struct xgi_hw_device_info *HwDeviceExtension,
1860 unsigned short RefreshRateTableIndex,
1861 struct vb_device_info *pVBInfo)
1863 unsigned char index, data;
1864 unsigned short vclkindex;
1866 if (pVBInfo->IF_DEF_LVDS == 1) {
1867 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1868 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1869 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1870 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1871 pVBInfo->VCLKData[index].SR2B);
1872 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1873 pVBInfo->VCLKData[index].SR2C);
1874 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1875 } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
1876 | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1878 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1879 RefreshRateTableIndex, HwDeviceExtension,
1881 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1882 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1883 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1884 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1885 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1886 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1887 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1889 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1890 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1891 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1892 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1893 pVBInfo->VCLKData[index].SR2B);
1894 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1895 pVBInfo->VCLKData[index].SR2C);
1896 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1899 if (HwDeviceExtension->jChipType >= XG20) {
1900 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & HalfDCLK) {
1901 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2B);
1902 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1903 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2C);
1910 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1915 void XGI_SetCRT1FIFO(unsigned short ModeNo,
1916 struct xgi_hw_device_info *HwDeviceExtension,
1917 struct vb_device_info *pVBInfo)
1919 unsigned short data;
1921 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1923 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1925 if (ModeNo > 0x13) {
1926 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x34);
1927 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1929 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x30);
1930 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1932 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data);
1934 if (HwDeviceExtension->jChipType == XG27) {
1935 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x0E);
1936 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1938 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x20);
1940 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0xAE);
1941 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1943 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data);
1947 if (HwDeviceExtension->jChipType == XG21)
1948 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1951 void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1952 unsigned short ModeNo, unsigned short ModeIdIndex,
1953 unsigned short RefreshRateTableIndex,
1954 struct vb_device_info *pVBInfo)
1956 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1959 if (ModeNo > 0x13) {
1960 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1962 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1964 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
1966 if (XGINew_GetReg1(pVBInfo->P3d4, 0x31) & 0x01)
1967 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1976 if (ModeNo > 0x13) {
1977 if (pVBInfo->ModeType > 0x02) {
1979 data3 = pVBInfo->ModeType - ModeVGA;
1985 data &= InterlaceMode;
1990 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1991 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
1992 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1994 xres = pVBInfo->StResInfo[resindex].HTotal;
1996 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1999 if (infoflag & InterlaceMode) {
2002 else if (xres == 1280)
2006 data2 = data & 0x00FF;
2007 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFF, data2);
2008 data2 = (data & 0xFF00) >> 8;
2009 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFC, data2);
2011 if (modeflag & HalfDCLK)
2012 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
2016 if (modeflag & LineCompareOff)
2019 if (ModeNo > 0x13) {
2020 if (pVBInfo->ModeType == ModeEGA)
2024 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0F, ~0x48, data2);
2026 if (pVBInfo->ModeType != ModeText) {
2028 if (pVBInfo->ModeType != ModeEGA)
2031 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x21, 0x1F, data);
2033 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
2036 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
2037 /* if (XGINew_IF_DEF_NEW_LOWRES) */
2038 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); //030305 fix lowresolution bug */
2040 data = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
2042 if (HwDeviceExtension->jChipType == XG27) {
2047 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
2048 XGINew_SetRegOR(pVBInfo->P3d4, 0x51, 0x10);
2049 } else if (HwDeviceExtension->jChipType >= XG20) {
2054 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
2055 XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0x02);
2061 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
2066 void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
2067 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
2068 struct vb_device_info *pVBInfo)
2070 unsigned short data, data2 = 0;
2073 unsigned char index;
2078 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2080 VCLK = pVBInfo->VCLKData[index].CLOCK;
2083 data = XGINew_GetReg1(pVBInfo->P3c4, 0x32);
2086 data |= 0x0c; /* VCLK > 200 */
2088 if (HwDeviceExtension->jChipType >= XG20)
2089 data &= ~0x04; /* 2 pixel mode */
2091 XGINew_SetReg1(pVBInfo->P3c4, 0x32, data);
2093 if (HwDeviceExtension->jChipType < XG20) {
2094 data = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
2098 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, data);
2101 /* Jong for Adavantech LCD ripple issue
2102 if ((VCLK >= 0) && (VCLK < 135))
2104 else if ((VCLK >= 135) && (VCLK < 160))
2106 else if ((VCLK >= 160) && (VCLK < 260))
2108 else if (VCLK > 260)
2113 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x07, 0xFC, data2);
2114 if (HwDeviceExtension->jChipType >= XG27)
2115 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
2121 void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2123 unsigned short modeflag;
2126 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2128 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2130 if (ModeNo > 0x13) {
2131 if (modeflag & DoubleScanMode) {
2132 if (modeflag & HalfDCLK) {
2133 if (pVBInfo->VBType & VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
2134 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
2135 if (pVBInfo->VBInfo & SetInSlaveMode) {
2136 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
2137 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
2142 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0xff, 0x80);
2143 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
2148 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
2152 void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
2153 struct vb_device_info *pVBInfo)
2155 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
2156 ah, dh, *table = NULL;
2159 data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2161 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2163 data &= DACInfoFlag;
2167 table = XGINew_MDA_DAC;
2168 else if (data == 0x08)
2169 table = XGINew_CGA_DAC;
2170 else if (data == 0x10)
2171 table = XGINew_EGA_DAC;
2172 else if (data == 0x18) {
2174 table = XGINew_VGA_DAC;
2182 XGINew_SetReg3(pVBInfo->P3c6, 0xFF);
2183 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
2185 for (i = 0; i < j; i++) {
2188 for (k = 0; k < 3; k++) {
2197 XGINew_SetReg3(pVBInfo->P3c9, data2);
2203 for (i = 16; i < 32; i++) {
2206 for (k = 0; k < 3; k++)
2207 XGINew_SetReg3(pVBInfo->P3c9, data);
2212 for (m = 0; m < 9; m++) {
2217 for (n = 0; n < 3; n++) {
2218 for (o = 0; o < 5; o++) {
2223 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
2228 for (o = 0; o < 3; o++) {
2233 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
2244 void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al,
2245 unsigned short dh, struct vb_device_info *pVBInfo)
2247 unsigned short temp, bh, bl;
2266 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) dh);
2267 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) bh);
2268 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) bl);
2271 void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
2272 struct xgi_hw_device_info *HwDeviceExtension,
2273 struct vb_device_info *pVBInfo)
2275 unsigned short RefreshRateTableIndex;
2276 /* unsigned short temp ; */
2278 /* pVBInfo->SelectCRT2Rate = 0; */
2280 pVBInfo->SetFlag |= ProgrammingCRT2;
2281 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
2282 ModeIdIndex, pVBInfo);
2283 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
2284 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2285 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2286 HwDeviceExtension, pVBInfo);
2287 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2288 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2291 void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2292 struct vb_device_info *pVBInfo)
2294 unsigned short resindex, xres, yres, modeflag;
2297 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
2299 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
2301 /* if (ModeNo > 0x13) */
2302 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
2304 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
2307 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
2309 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
2311 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
2313 if (ModeNo <= 0x13) {
2314 xres = pVBInfo->StResInfo[resindex].HTotal;
2315 yres = pVBInfo->StResInfo[resindex].VTotal;
2317 xres = pVBInfo->ModeResInfo[resindex].HTotal;
2318 yres = pVBInfo->ModeResInfo[resindex].VTotal;
2320 if (ModeNo > 0x13) {
2321 if (modeflag & HalfDCLK)
2324 if (modeflag & DoubleScanMode)
2327 /* if (modeflag & Charx8Dot) */
2334 pVBInfo->VGAHDE = xres;
2335 pVBInfo->HDE = xres;
2336 pVBInfo->VGAVDE = yres;
2337 pVBInfo->VDE = yres;
2340 void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2341 unsigned short RefreshRateTableIndex,
2342 struct vb_device_info *pVBInfo)
2344 unsigned short tempbx;
2345 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2346 struct XGI330_CHTVDataStruct *TVPtr = NULL;
2350 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2351 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2352 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2354 pVBInfo->VGAHT = LCDPtr->VGAHT;
2355 pVBInfo->VGAVT = LCDPtr->VGAVT;
2356 pVBInfo->HT = LCDPtr->LCDHT;
2357 pVBInfo->VT = LCDPtr->LCDVT;
2359 if (pVBInfo->IF_DEF_CH7017 == 1) {
2360 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2361 TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr(
2362 tempbx, ModeNo, ModeIdIndex,
2363 RefreshRateTableIndex, pVBInfo);
2364 pVBInfo->VGAHT = TVPtr->VGAHT;
2365 pVBInfo->VGAVT = TVPtr->VGAVT;
2366 pVBInfo->HT = TVPtr->LCDHT;
2367 pVBInfo->VT = TVPtr->LCDVT;
2371 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2372 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2373 | EnableScalingLCD))) {
2374 if ((pVBInfo->LCDResInfo == Panel1024x768)
2375 || (pVBInfo->LCDResInfo
2376 == Panel1024x768x75)) {
2377 pVBInfo->HDE = 1024;
2379 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2380 || (pVBInfo->LCDResInfo
2381 == Panel1280x1024x75)) {
2382 pVBInfo->HDE = 1280;
2383 pVBInfo->VDE = 1024;
2384 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2385 pVBInfo->HDE = 1400;
2386 pVBInfo->VDE = 1050;
2388 pVBInfo->HDE = 1600;
2389 pVBInfo->VDE = 1200;
2395 void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2396 unsigned short RefreshRateTableIndex,
2397 struct xgi_hw_device_info *HwDeviceExtension,
2398 struct vb_device_info *pVBInfo)
2400 unsigned char index;
2401 unsigned short tempbx, i;
2402 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2403 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2404 /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */
2405 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2406 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2409 index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2411 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2413 index = index & IndexMask;
2415 if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1)
2416 && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2419 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2421 = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr(
2424 RefreshRateTableIndex,
2427 for (i = 0; i < 8; i++)
2428 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2431 if (pVBInfo->IF_DEF_CH7007 == 1) {
2432 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2434 = (struct XGI_CH7007TV_TimingHStruct *) XGI_GetTVPtr(
2438 RefreshRateTableIndex,
2441 for (i = 0; i < 8; i++)
2442 pVBInfo->TimingH[0].data[i]
2443 = CH7007TV_TimingHPtr[0].data[i];
2447 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2448 if (pVBInfo->VBInfo & SetCRT2ToTV)
2449 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2453 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2455 if (pVBInfo->IF_DEF_CH7007 == 1) {
2456 XGINew_SetReg1(pVBInfo->P3c4, 0x2E,
2457 CH7007TV_TimingHPtr[0].data[8]);
2458 XGINew_SetReg1(pVBInfo->P3c4, 0x2F,
2459 CH7007TV_TimingHPtr[0].data[9]);
2464 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2466 = (struct XGI_LVDSCRT1VDataStruct *) XGI_GetLcdPtr(
2469 RefreshRateTableIndex,
2471 for (i = 0; i < 7; i++)
2472 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2475 if (pVBInfo->IF_DEF_CH7007 == 1) {
2476 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2478 = (struct XGI_CH7007TV_TimingVStruct *) XGI_GetTVPtr(
2482 RefreshRateTableIndex,
2485 for (i = 0; i < 7; i++)
2486 pVBInfo->TimingV[0].data[i]
2487 = CH7007TV_TimingVPtr[0].data[i];
2490 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2491 if (pVBInfo->VBInfo & SetCRT2ToTV)
2492 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2496 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2498 if (pVBInfo->IF_DEF_CH7007 == 1) {
2499 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x33, ~0x01,
2500 CH7007TV_TimingVPtr[0].data[7] & 0x01);
2501 XGINew_SetReg1(pVBInfo->P3c4, 0x34,
2502 CH7007TV_TimingVPtr[0].data[8]);
2503 XGINew_SetReg1(pVBInfo->P3c4, 0x3F,
2504 CH7007TV_TimingVPtr[0].data[9]);
2510 void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2511 unsigned short RefreshRateTableIndex,
2512 struct vb_device_info *pVBInfo)
2514 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2515 unsigned long temp, temp1, temp2, temp3, push3;
2516 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2517 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2520 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2522 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2524 if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2525 if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo
2526 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
2527 if (pVBInfo->IF_DEF_OEMUtil == 1) {
2530 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2534 RefreshRateTableIndex,
2538 if ((pVBInfo->IF_DEF_OEMUtil == 0) || (LCDPtr == NULL)) {
2540 if (pVBInfo->LCDInfo & EnableScalingLCD)
2542 = (struct XGI330_LCDDataDesStruct2 *) XGI_GetLcdPtr(
2546 RefreshRateTableIndex,
2550 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2554 RefreshRateTableIndex,
2558 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2563 if ((pVBInfo->LCDResInfo == Panel1024x768)
2564 || (pVBInfo->LCDResInfo
2565 == Panel1024x768x75)) {
2568 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2569 || (pVBInfo->LCDResInfo
2570 == Panel1280x1024x75)) {
2573 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2581 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2582 pVBInfo->HDE = tempax;
2583 pVBInfo->VDE = tempbx;
2584 pVBInfo->VGAHDE = tempax;
2585 pVBInfo->VGAVDE = tempbx;
2588 if ((pVBInfo->IF_DEF_ScaleLCD == 1)
2589 && (pVBInfo->LCDInfo & EnableScalingLCD)) {
2590 tempax = pVBInfo->HDE;
2591 tempbx = pVBInfo->VDE;
2594 tempax = pVBInfo->HT;
2596 if (pVBInfo->LCDInfo & EnableScalingLCD)
2597 tempbx = LCDPtr1->LCDHDES;
2599 tempbx = LCDPtr->LCDHDES;
2601 tempcx = pVBInfo->HDE;
2602 tempbx = tempbx & 0x0fff;
2605 if (tempcx >= tempax)
2608 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2610 tempcx = tempcx >> 3;
2611 tempbx = tempbx >> 3;
2613 XGINew_SetReg1(pVBInfo->Part1Port, 0x16,
2614 (unsigned short) (tempbx & 0xff));
2615 XGINew_SetReg1(pVBInfo->Part1Port, 0x17,
2616 (unsigned short) (tempcx & 0xff));
2618 tempax = pVBInfo->HT;
2620 if (pVBInfo->LCDInfo & EnableScalingLCD)
2621 tempbx = LCDPtr1->LCDHRS;
2623 tempbx = LCDPtr->LCDHRS;
2627 if (pVBInfo->LCDInfo & EnableScalingLCD)
2628 tempcx = LCDPtr1->LCDHSync;
2632 if (tempcx >= tempax)
2635 tempax = tempbx & 0x07;
2636 tempax = tempax >> 5;
2637 tempcx = tempcx >> 3;
2638 tempbx = tempbx >> 3;
2643 XGINew_SetReg1(pVBInfo->Part1Port, 0x15, tempax);
2644 XGINew_SetReg1(pVBInfo->Part1Port, 0x14,
2645 (unsigned short) (tempbx & 0xff));
2647 tempax = pVBInfo->VT;
2648 if (pVBInfo->LCDInfo & EnableScalingLCD)
2649 tempbx = LCDPtr1->LCDVDES;
2651 tempbx = LCDPtr->LCDVDES;
2652 tempcx = pVBInfo->VDE;
2654 tempbx = tempbx & 0x0fff;
2656 if (tempcx >= tempax)
2659 XGINew_SetReg1(pVBInfo->Part1Port, 0x1b,
2660 (unsigned short) (tempbx & 0xff));
2661 XGINew_SetReg1(pVBInfo->Part1Port, 0x1c,
2662 (unsigned short) (tempcx & 0xff));
2664 tempbx = (tempbx >> 8) & 0x07;
2665 tempcx = (tempcx >> 8) & 0x07;
2667 XGINew_SetReg1(pVBInfo->Part1Port, 0x1d,
2668 (unsigned short) ((tempcx << 3)
2671 tempax = pVBInfo->VT;
2672 if (pVBInfo->LCDInfo & EnableScalingLCD)
2673 tempbx = LCDPtr1->LCDVRS;
2675 tempbx = LCDPtr->LCDVRS;
2677 /* tempbx = tempbx >> 4; */
2680 if (pVBInfo->LCDInfo & EnableScalingLCD)
2681 tempcx = LCDPtr1->LCDVSync;
2684 if (tempcx >= tempax)
2687 XGINew_SetReg1(pVBInfo->Part1Port, 0x18,
2688 (unsigned short) (tempbx & 0xff));
2689 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f,
2690 (unsigned short) (tempcx & 0x0f));
2692 tempax = ((tempbx >> 8) & 0x07) << 3;
2694 tempbx = pVBInfo->VGAVDE;
2695 if (tempbx != pVBInfo->VDE)
2698 if (pVBInfo->LCDInfo & EnableLVDSDDA)
2701 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1a, 0x07,
2704 tempcx = pVBInfo->VGAVT;
2705 tempbx = pVBInfo->VDE;
2706 tempax = pVBInfo->VGAVDE;
2709 temp = tempax; /* 0430 ylshieh */
2710 temp1 = (temp << 18) / tempbx;
2712 tempdx = (unsigned short) ((temp << 18) % tempbx);
2720 XGINew_SetReg1(pVBInfo->Part1Port, 0x37,
2721 (unsigned short) (temp2 & 0xff));
2722 XGINew_SetReg1(pVBInfo->Part1Port, 0x36,
2723 (unsigned short) ((temp2 >> 8) & 0xff));
2725 tempbx = (unsigned short) (temp2 >> 16);
2726 tempax = tempbx & 0x03;
2728 tempbx = pVBInfo->VGAVDE;
2729 if (tempbx == pVBInfo->VDE)
2732 XGINew_SetReg1(pVBInfo->Part1Port, 0x35, tempax);
2734 if (pVBInfo->VBType & VB_XGI301C) {
2736 XGINew_SetReg1(pVBInfo->Part4Port, 0x3c,
2737 (unsigned short) (temp2 & 0xff));
2738 XGINew_SetReg1(pVBInfo->Part4Port, 0x3b,
2739 (unsigned short) ((temp2 >> 8)
2741 tempbx = (unsigned short) (temp2 >> 16);
2742 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x3a,
2744 (unsigned short) ((tempbx
2747 tempcx = pVBInfo->VGAVDE;
2748 if (tempcx == pVBInfo->VDE)
2749 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2752 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2756 tempcx = pVBInfo->VGAHDE;
2757 tempbx = pVBInfo->HDE;
2759 temp1 = tempcx << 16;
2761 tempax = (unsigned short) (temp1 / tempbx);
2763 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2767 temp1 = pVBInfo->VGAHDE << 16;
2770 temp3 = temp3 << 16;
2773 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
2775 tempax = (unsigned short) (temp3 & 0xff);
2776 XGINew_SetReg1(pVBInfo->Part1Port, 0x1f, tempax);
2778 temp1 = pVBInfo->VGAVDE << 18;
2779 temp1 = temp1 / push3;
2780 tempbx = (unsigned short) (temp1 & 0xffff);
2782 if (pVBInfo->LCDResInfo == Panel1024x768)
2785 tempax = ((tempbx >> 8) & 0xff) << 3;
2786 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
2787 XGINew_SetReg1(pVBInfo->Part1Port, 0x20,
2788 (unsigned short) (tempax & 0xff));
2789 XGINew_SetReg1(pVBInfo->Part1Port, 0x21,
2790 (unsigned short) (tempbx & 0xff));
2792 temp3 = temp3 >> 16;
2794 if (modeflag & HalfDCLK)
2797 XGINew_SetReg1(pVBInfo->Part1Port, 0x22,
2798 (unsigned short) ((temp3 >> 8) & 0xff));
2799 XGINew_SetReg1(pVBInfo->Part1Port, 0x23,
2800 (unsigned short) (temp3 & 0xff));
2805 void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2806 unsigned short RefreshRateTableIndex,
2807 struct vb_device_info *pVBInfo)
2809 unsigned char di_0, di_1, tempal;
2812 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2814 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2815 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2817 for (i = 0; i < 4; i++) {
2818 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, ~0x30,
2819 (unsigned short) (0x10 * i));
2820 if (pVBInfo->IF_DEF_CH7007 == 1) {
2821 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
2822 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
2823 } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
2824 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
2825 XGINew_SetReg1(pVBInfo->P3c4, 0x2e, di_0);
2826 XGINew_SetReg1(pVBInfo->P3c4, 0x2f, di_1);
2828 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
2829 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
2834 void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
2835 struct vb_device_info *pVBInfo)
2837 unsigned short tempcl, tempch, temp, tempbl, tempax;
2839 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
2840 | VB_XGI302LV | VB_XGI301C)) {
2843 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
2845 if (!(temp & 0x20)) {
2846 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x17);
2848 if ((HwDeviceExtension->jChipType >= XG20)
2849 || (HwDeviceExtension->jChipType
2851 temp = XGINew_GetReg1(pVBInfo->P3d4,
2854 temp = XGINew_GetReg1(pVBInfo->P3d4,
2858 tempcl |= ActiveCRT1;
2862 temp = XGINew_GetReg1(pVBInfo->Part1Port, 0x2e);
2865 if (!(temp == 0x08)) {
2866 tempax = XGINew_GetReg1(pVBInfo->Part1Port, 0x13); /* Check ChannelA by Part1_13 [2003/10/03] */
2868 tempcl = tempcl | ActiveLCD;
2872 if (!(tempcl & ActiveLCD))
2874 tempcl |= ActiveCRT2;
2877 tempcl |= ActiveLCD;
2880 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x00);
2883 tempch |= ActiveAVideo;
2886 tempch |= ActiveSVideo;
2889 tempch |= ActiveSCART;
2891 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
2893 tempch |= ActiveHiTV;
2896 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
2897 temp = XGINew_GetReg1(
2902 tempch |= ActiveYPbPr;
2910 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x3d);
2911 if (tempcl & ActiveLCD) {
2912 if ((pVBInfo->SetFlag & ReserveTVOption)) {
2913 if (temp & ActiveTV)
2918 tempbl = ~ModeSwitchStatus;
2919 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x3d, tempbl, temp);
2921 if (!(pVBInfo->SetFlag & ReserveTVOption))
2922 XGINew_SetReg1(pVBInfo->P3d4, 0x3e, tempch);
2928 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
2929 struct vb_device_info *pVBInfo)
2932 if ( HwDeviceExtension->jChipType >= XG20 ) {
2933 pVBInfo->Set_VGAType = XG20;
2934 } else if (HwDeviceExtension->jChipType >= XG40) {
2935 pVBInfo->Set_VGAType = VGA_XGI340;
2938 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
2941 void XGI_GetVBType(struct vb_device_info *pVBInfo)
2943 unsigned short flag, tempbx, tempah;
2945 if (pVBInfo->IF_DEF_CH7007 == 1) {
2946 pVBInfo->VBType = VB_CH7007;
2949 if (pVBInfo->IF_DEF_LVDS == 0) {
2950 tempbx = VB_XGI302B;
2951 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
2954 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x01);
2956 tempbx = VB_XGI301B;
2958 tempbx = VB_XGI301C;
2960 tempbx = VB_XGI301LV;
2962 tempbx = VB_XGI302LV;
2974 if (tempbx & (VB_XGI301B | VB_XGI302B)) {
2975 flag = XGINew_GetReg1(
2980 tempbx = tempbx | VB_NoLCD;
2984 pVBInfo->VBType = tempbx;
2987 else if (pVBInfo->IF_DEF_CH7017 == 1)
2988 pVBInfo->VBType = VB_CH7017;
2990 pVBInfo->VBType = VB_LVDS_NS;
2995 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2996 struct xgi_hw_device_info *HwDeviceExtension,
2997 struct vb_device_info *pVBInfo)
2999 unsigned short tempax, push, tempbx, temp, modeflag;
3002 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3004 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3006 pVBInfo->SetFlag = 0;
3007 pVBInfo->ModeType = modeflag & ModeInfoFlag;
3010 if (pVBInfo->VBType & 0xFFFF) {
3011 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x30); /* Check Display Device */
3012 tempbx = tempbx | temp;
3013 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
3017 tempbx = tempbx | tempax;
3018 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA
3019 | SetInSlaveMode | DisableCRT2Display);
3020 temp = 0xFFFF ^ temp;
3023 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
3025 if (pVBInfo->IF_DEF_LCDA == 1) {
3027 if ((pVBInfo->Set_VGAType >= XG20)
3028 || (pVBInfo->Set_VGAType >= XG40)) {
3029 if (pVBInfo->IF_DEF_LVDS == 0) {
3030 /* if ((pVBInfo->VBType & VB_XGI302B) || (pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType & VB_XGI301C)) */
3031 if (pVBInfo->VBType & (VB_XGI302B
3035 if (temp & EnableDualEdge) {
3037 |= SetCRT2ToDualEdge;
3039 if (temp & SetToLCDA)
3044 } else if (pVBInfo->IF_DEF_CH7017 == 1) {
3045 if (pVBInfo->VBType & VB_CH7017) {
3046 if (temp & EnableDualEdge) {
3048 |= SetCRT2ToDualEdge;
3050 if (temp & SetToLCDA)
3059 if (pVBInfo->IF_DEF_YPbPr == 1) {
3060 if (((pVBInfo->IF_DEF_LVDS == 0) && ((pVBInfo->VBType
3061 & VB_XGI301LV) || (pVBInfo->VBType
3062 & VB_XGI302LV) || (pVBInfo->VBType
3064 || ((pVBInfo->IF_DEF_CH7017 == 1)
3067 || ((pVBInfo->IF_DEF_CH7007 == 1)
3069 & VB_CH7007))) { /* [Billy] 07/05/04 */
3070 if (temp & SetYPbPr) { /* temp = CR38 */
3071 if (pVBInfo->IF_DEF_HiVision == 1) {
3072 temp = XGINew_GetReg1(
3074 0x35); /* shampoo add for new scratch */
3076 tempbx |= SetCRT2ToHiVisionTV;
3078 if (temp != YPbPrMode1080i) {
3080 &= (~SetCRT2ToHiVisionTV);
3086 /* tempbx |= SetCRT2ToYPbPr; */
3091 tempax = push; /* restore CR31 */
3093 if (pVBInfo->IF_DEF_LVDS == 0) {
3094 if (pVBInfo->IF_DEF_YPbPr == 1) {
3095 if (pVBInfo->IF_DEF_HiVision == 1)
3100 if (pVBInfo->IF_DEF_HiVision == 1)
3105 } else { /* 3nd party chip */
3106 if (pVBInfo->IF_DEF_CH7017 == 1)
3107 temp = (SetCRT2ToTV | SetCRT2ToLCD
3109 else if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/03 */
3112 temp = SetCRT2ToLCD;
3115 if (!(tempbx & temp)) {
3116 tempax |= DisableCRT2Display;
3120 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
3121 if (!(pVBInfo->VBType & VB_NoLCD)) {
3122 if (tempbx & SetCRT2ToLCDA) {
3123 if (tempbx & SetSimuScanMode)
3139 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { /* for driver abnormal */
3140 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
3141 if (tempbx & SetCRT2ToRAMDAC) {
3142 tempbx &= (0xFF00 | SetCRT2ToRAMDAC
3145 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3148 tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD
3153 if (!(pVBInfo->VBType & VB_NoLCD)) {
3154 if (tempbx & SetCRT2ToLCD) {
3155 tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2
3157 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3161 if (tempbx & SetCRT2ToSCART) {
3162 tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2
3164 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3167 if (pVBInfo->IF_DEF_YPbPr == 1) {
3168 if (tempbx & SetCRT2ToYPbPr)
3169 tempbx &= (0xFF00 | SwitchToCRT2
3173 if (pVBInfo->IF_DEF_HiVision == 1) {
3174 if (tempbx & SetCRT2ToHiVisionTV)
3175 tempbx &= (0xFF00 | SetCRT2ToHiVisionTV
3180 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
3181 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode)))
3182 tempbx = DisableCRT2Display;
3185 if (!(tempbx & DisableCRT2Display)) {
3186 if ((!(tempbx & DriverMode))
3187 || (!(modeflag & CRT2Mode))) {
3188 if (pVBInfo->IF_DEF_LCDA == 1) {
3189 if (!(tempbx & SetCRT2ToLCDA))
3195 if (pVBInfo->IF_DEF_VideoCapture == 1) {
3196 if (((HwDeviceExtension->jChipType
3198 && (pVBInfo->Set_VGAType
3200 || ((HwDeviceExtension->jChipType
3202 && (pVBInfo->Set_VGAType
3204 || ((HwDeviceExtension->jChipType
3206 && (pVBInfo->Set_VGAType
3208 || ((HwDeviceExtension->jChipType
3210 && (pVBInfo->Set_VGAType
3214 & SetCRT2ToRAMDAC)) { /*CRT2 not need to support*/
3217 | (~SetInSlaveMode));
3226 /* LCD+TV can't support in slave mode (Force LCDA+TV->LCDB) */
3227 if ((tempbx & SetInSlaveMode) && (tempbx
3229 tempbx ^= (SetCRT2ToLCD | SetCRT2ToLCDA
3230 | SetCRT2ToDualEdge);
3231 pVBInfo->SetFlag |= ReserveTVOption;
3236 pVBInfo->VBInfo = tempbx;
3239 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3240 struct vb_device_info *pVBInfo)
3242 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
3247 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3248 if (ModeNo <= 0x13) {
3250 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
3251 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
3254 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3256 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
3259 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3260 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3262 if (tempbx & SetPALTV) {
3263 tempbx &= (SetCHTVOverScan | SetPALMTV
3264 | SetPALNTV | SetPALTV);
3265 if (tempbx & SetPALMTV)
3266 tempbx &= ~SetPALTV; /* set to NTSC if PAL-M */
3268 tempbx &= (SetCHTVOverScan | SetNTSCJ
3271 if (pVBInfo->IF_DEF_LVDS == 0) {
3272 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x38); //PAL-M/PAL-N Info
3273 temp2 = (index1 & 0xC0) >> 5; //00:PAL, 01:PAL-M, 10:PAL-N
3275 if (temp2 & 0x02) //PAL-M
3276 tempbx &= (~SetPALTV);
3281 if (pVBInfo->IF_DEF_CH7017 == 1) {
3282 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3284 if (tempbx & TVOverScan)
3285 tempbx |= SetCHTVOverScan;
3288 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */
3289 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3291 if (tempbx & TVOverScan)
3292 tempbx |= SetCHTVOverScan;
3295 if (pVBInfo->IF_DEF_LVDS == 0) {
3296 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3300 if (pVBInfo->IF_DEF_YPbPr == 1) {
3301 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3302 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3303 index1 &= YPbPrMode;
3305 if (index1 == YPbPrMode525i)
3306 tempbx |= SetYPbPrMode525i;
3308 if (index1 == YPbPrMode525p)
3309 tempbx = tempbx | SetYPbPrMode525p;
3310 if (index1 == YPbPrMode750p)
3311 tempbx = tempbx | SetYPbPrMode750p;
3315 if (pVBInfo->IF_DEF_HiVision == 1) {
3316 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
3317 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV;
3320 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3321 if ((pVBInfo->VBInfo & SetInSlaveMode)
3322 && (!(pVBInfo->VBInfo & SetNotSimuMode)))
3323 tempbx |= TVSimuMode;
3325 if (!(tempbx & SetPALTV) && (modeflag > 13) && (resinfo
3326 == 8)) /* NTSC 1024x768, */
3327 tempbx |= NTSC1024x768;
3329 tempbx |= RPLLDIV2XO;
3331 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3332 if (pVBInfo->VBInfo & SetInSlaveMode)
3333 tempbx &= (~RPLLDIV2XO);
3335 if (tempbx & (SetYPbPrMode525p
3336 | SetYPbPrMode750p))
3337 tempbx &= (~RPLLDIV2XO);
3338 else if (!(pVBInfo->VBType & (VB_XGI301B
3339 | VB_XGI302B | VB_XGI301LV
3340 | VB_XGI302LV | VB_XGI301C))) {
3341 if (tempbx & TVSimuMode)
3342 tempbx &= (~RPLLDIV2XO);
3347 pVBInfo->TVInfo = tempbx;
3350 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3351 struct vb_device_info *pVBInfo)
3353 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3355 pVBInfo->LCDResInfo = 0;
3356 pVBInfo->LCDTypeInfo = 0;
3357 pVBInfo->LCDInfo = 0;
3359 if (ModeNo <= 0x13) {
3360 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag // */
3362 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3363 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo // */
3366 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3367 tempbx = temp & 0x0F;
3370 tempbx = Panel1024x768; /* default */
3372 /* LCD75 [2003/8/22] Vicent */
3373 if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) {
3374 if (pVBInfo->VBInfo & DriverMode) {
3375 tempax = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
3376 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
3379 tempax = tempax >> 4;
3381 if ((resinfo == 6) || (resinfo == 9)) {
3383 tempbx |= PanelRef75Hz;
3384 } else if ((resinfo == 7) || (resinfo == 8)) {
3386 tempbx |= PanelRef75Hz;
3391 pVBInfo->LCDResInfo = tempbx;
3395 if (pVBInfo->IF_DEF_OEMUtil == 1)
3396 pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
3398 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
3403 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
3405 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
3407 if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
3408 temp &= ~EnableScalingLCD;
3412 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
3414 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
3416 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3417 if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3418 & VB_XGI301C)) && (tempax & LCDDualLink)) {
3419 tempbx |= SetLCDDualLink;
3423 if (pVBInfo->IF_DEF_CH7017 == 1) {
3424 if (tempax & LCDDualLink)
3425 tempbx |= SetLCDDualLink;
3428 if (pVBInfo->IF_DEF_LVDS == 0) {
3429 if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
3430 & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
3431 == 9) && (!(tempbx & EnableScalingLCD)))
3432 tempbx |= SetLCDtoNonExpanding; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3436 if (tempax & LCDBToA) {
3437 tempbx |= SetLCDBToA;
3441 if (pVBInfo->IF_DEF_ExpLink == 1) {
3442 if (modeflag & HalfDCLK) {
3443 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
3444 if (!(tempbx & SetLCDtoNonExpanding)) {
3445 tempbx |= EnableLVDSDDA;
3447 if (ModeNo > 0x13) {
3448 if (pVBInfo->LCDResInfo
3450 if (resinfo == 4) { /* 512x384 */
3451 tempbx |= EnableLVDSDDA;
3459 if (pVBInfo->VBInfo & SetInSlaveMode) {
3460 if (pVBInfo->VBInfo & SetNotSimuMode)
3461 tempbx |= LCDVESATiming;
3463 tempbx |= LCDVESATiming;
3466 pVBInfo->LCDInfo = tempbx;
3468 if (pVBInfo->IF_DEF_PWD == 1) {
3469 if (pVBInfo->LCDInfo & SetPWDEnable) {
3470 if ((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3472 if (!(tempax & PWDEnable))
3473 pVBInfo->LCDInfo &= ~SetPWDEnable;
3478 if (pVBInfo->IF_DEF_LVDS == 0) {
3479 if (tempax & (LockLCDBToA | StLCDBToA)) {
3480 if (pVBInfo->VBInfo & SetInSlaveMode) {
3481 if (!(tempax & LockLCDBToA)) {
3482 if (ModeNo <= 0x13) {
3484 &= ~(SetSimuScanMode
3489 | SetCRT2ToDualEdge;
3497 if (pVBInfo->IF_DEF_LVDS == 0) {
3498 if (tempax & (LockLCDBToA | StLCDBToA)) {
3499 if (pVBInfo->VBInfo & SetInSlaveMode) {
3500 if (!((!(tempax & LockLCDBToA)) && (ModeNo > 0x13))) {
3501 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3502 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3512 unsigned char XGI_SearchModeID(unsigned short ModeNo,
3513 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
3517 if (ModeNo <= 0x13) {
3518 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
3519 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3520 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3522 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3527 (*ModeIdIndex)++; /* 400 lines */
3529 (*ModeIdIndex) += 2; /* 400 lines */
3530 /* else 350 lines */
3532 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
3533 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3534 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3536 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3544 /* win2000 MM adapter not support standard mode! */
3547 static unsigned char XGINew_CheckMemorySize(
3548 struct xgi_hw_device_info *HwDeviceExtension,
3549 unsigned short ModeNo,
3550 unsigned short ModeIdIndex,
3551 struct vb_device_info *pVBInfo)
3553 unsigned short memorysize, modeflag, temp, temp1, tmp;
3556 if ((HwDeviceExtension->jChipType == XGI_650) ||
3557 (HwDeviceExtension->jChipType == XGI_650M)) {
3563 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3565 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3567 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
3569 memorysize = modeflag & MemoryInfoFlag;
3570 memorysize = memorysize > MemorySizeShift;
3571 memorysize++; /* Get memory size */
3573 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
3576 if (HwDeviceExtension->jChipType == XG40) {
3577 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3578 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3580 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
3583 } else if (HwDeviceExtension->jChipType == XG42) {
3584 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3585 if ((tmp & 0x04) == 0x04) { /* Dual channels */
3588 } else if (HwDeviceExtension->jChipType == XG45) {
3589 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3590 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3592 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
3596 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
3600 if (temp < memorysize)
3608 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)
3610 unsigned short data ;
3611 unsigned short ModeFlag ;
3613 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3615 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
3617 if (ModeNo > 0x13) {
3618 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3619 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
3620 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3622 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
3623 data = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3625 XGINew_SetReg1(pVBInfo->P3c4, 0x01, data);
3631 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
3632 struct vb_device_info *pVBInfo)
3635 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3636 if (pXGIHWDE->jChipType == XG21) {
3637 if (pVBInfo->IF_DEF_LVDS == 1) {
3638 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3639 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3640 XGI_XG21SetPanelDelay(2, pVBInfo);
3642 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3643 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3644 XGI_XG21SetPanelDelay(3, pVBInfo);
3645 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3647 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3652 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
3656 if (pXGIHWDE->jChipType == XG27) {
3657 if (pVBInfo->IF_DEF_LVDS == 1) {
3658 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
3659 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3660 XGI_XG21SetPanelDelay(2, pVBInfo);
3662 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
3663 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3664 XGI_XG21SetPanelDelay(3, pVBInfo);
3665 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3667 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3673 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
3674 struct vb_device_info *pVBInfo)
3677 if (pXGIHWDE->jChipType == XG21) {
3678 if (pVBInfo->IF_DEF_LVDS == 1) {
3679 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3680 XGI_XG21SetPanelDelay(3, pVBInfo);
3682 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3686 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
3687 /* if (IsCH7007TVMode(pVBInfo) == 0) */
3692 if (pXGIHWDE->jChipType == XG27) {
3693 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
3694 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3695 XGI_XG21SetPanelDelay(3, pVBInfo);
3698 if (pVBInfo->IF_DEF_LVDS == 0)
3699 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3702 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
3705 void XGI_WaitDisply(struct vb_device_info *pVBInfo)
3707 while ((XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3710 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3714 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
3716 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
3717 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
3720 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
3722 unsigned char CR17, CR63, SR31;
3723 unsigned short temp;
3724 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
3727 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
3729 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
3730 XGINew_SetReg1(pVBInfo->P3d4, 0x57, 0x4A);
3731 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3732 pVBInfo->P3d4, 0x53) | 0x02));
3734 SR31 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x31);
3735 CR63 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x63);
3736 SR01 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3738 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
3739 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
3741 CR17 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x17);
3742 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
3744 SR1F = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
3745 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
3747 SR07 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x07);
3748 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
3749 SR06 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x06);
3750 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
3752 XGINew_SetReg1(pVBInfo->P3d4, 0x11, 0x00);
3754 for (i = 0; i < 8; i++)
3755 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
3757 for (i = 8; i < 11; i++)
3758 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 8),
3761 for (i = 11; i < 13; i++)
3762 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 4),
3765 for (i = 13; i < 16; i++)
3766 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i - 3),
3769 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
3772 XGINew_SetReg1(pVBInfo->P3c4, 0x31, 0x00);
3773 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
3774 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE1);
3776 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
3778 for (i = 0; i < 256; i++) {
3779 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3780 (unsigned char) DAC_TEST_PARMS[0]);
3781 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3782 (unsigned char) DAC_TEST_PARMS[1]);
3783 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3784 (unsigned char) DAC_TEST_PARMS[2]);
3787 XGI_VBLongWait(pVBInfo);
3788 XGI_VBLongWait(pVBInfo);
3789 XGI_VBLongWait(pVBInfo);
3791 XGINew_LCD_Wait_Time(0x01, pVBInfo);
3793 XGI_WaitDisply(pVBInfo);
3794 temp = XGINew_GetReg2(pVBInfo->P3c2);
3797 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
3799 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
3801 /* alan, avoid display something, set BLACK DAC if not restore DAC */
3802 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
3804 for (i = 0; i < 256; i++) {
3805 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3806 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3807 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3810 XGINew_SetReg1(pVBInfo->P3c4, 0x01, SR01);
3811 XGINew_SetReg1(pVBInfo->P3d4, 0x63, CR63);
3812 XGINew_SetReg1(pVBInfo->P3c4, 0x31, SR31);
3814 /* [2004/05/11] Vicent */
3815 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3816 pVBInfo->P3d4, 0x53) & 0xFD));
3817 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
3821 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
3823 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01));
3824 while (XGINew_GetReg2(pVBInfo->P3da) & 0x01);
3828 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
3829 struct xgi_hw_device_info *HwDeviceExtension,
3830 struct vb_device_info *pVBInfo)
3832 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
3834 tempbx = pVBInfo->VBInfo;
3835 pVBInfo->SetFlag |= ProgrammingCRT2;
3836 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
3837 pVBInfo->SelectCRT2Rate = 4;
3838 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
3839 ModeIdIndex, pVBInfo);
3840 XGI_SaveCRT2Info(ModeNo, pVBInfo);
3841 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
3842 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3843 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3844 RefreshRateTableIndex, pVBInfo);
3845 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3846 RefreshRateTableIndex, pVBInfo);
3847 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3848 RefreshRateTableIndex, pVBInfo);
3849 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3850 HwDeviceExtension, pVBInfo);
3851 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3852 RefreshRateTableIndex, pVBInfo);
3853 XGI_SetTap4Regs(pVBInfo);
3854 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
3855 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3856 HwDeviceExtension, pVBInfo);
3857 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3858 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
3859 XGI_AutoThreshold(pVBInfo);
3863 void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
3865 if (!(pVBInfo->SetFlag & Win9xDOSMode))
3866 XGINew_SetRegOR(pVBInfo->Part1Port, 0x01, 0x40);
3869 void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
3871 unsigned short temp1, temp2;
3873 XGINew_SetReg1(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
3874 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
3875 temp2 = ~(SetInSlaveMode >> 8);
3876 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, temp2, temp1);
3879 void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3880 struct vb_device_info *pVBInfo)
3882 unsigned short xres, yres, modeflag, resindex;
3884 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
3885 if (ModeNo <= 0x13) {
3886 xres = pVBInfo->StResInfo[resindex].HTotal;
3887 yres = pVBInfo->StResInfo[resindex].VTotal;
3888 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
3890 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
3891 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
3892 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
3895 if (pVBInfo->IF_DEF_FSTN) {
3900 if (modeflag & HalfDCLK)
3903 if (modeflag & DoubleScanMode)
3908 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3909 if (pVBInfo->IF_DEF_LVDS == 0) {
3910 if (pVBInfo->LCDResInfo == Panel1600x1200) {
3911 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3917 if (pVBInfo->LCDResInfo == Panel1280x1024) {
3920 else if (yres == 350)
3923 if (pVBInfo->LCDInfo & LCDVESATiming) {
3929 if (pVBInfo->LCDResInfo == Panel1024x768) {
3930 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3931 if (!(pVBInfo->LCDInfo
3932 & LCDNonExpanding)) {
3935 else if (yres == 400)
3937 else if (yres == 480)
3948 pVBInfo->VGAHDE = xres;
3949 pVBInfo->HDE = xres;
3950 pVBInfo->VGAVDE = yres;
3951 pVBInfo->VDE = yres;
3954 unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
3957 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
3958 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
3964 void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
3965 unsigned short RefreshRateTableIndex,
3966 struct vb_device_info *pVBInfo)
3968 unsigned short tempax = 0, tempbx, modeflag, resinfo;
3970 struct XGI_LCDDataStruct *LCDPtr = NULL;
3971 struct XGI_TVDataStruct *TVPtr = NULL;
3973 if (ModeNo <= 0x13) {
3974 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
3975 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
3977 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
3978 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3981 pVBInfo->NewFlickerMode = 0;
3982 pVBInfo->RVBHRS = 50;
3984 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3985 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3992 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3993 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
3994 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3997 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
3998 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
3999 pVBInfo->VGAHT = LCDPtr->VGAHT;
4000 pVBInfo->VGAVT = LCDPtr->VGAVT;
4001 pVBInfo->HT = LCDPtr->LCDHT;
4002 pVBInfo->VT = LCDPtr->LCDVT;
4004 if (pVBInfo->LCDResInfo == Panel1024x768) {
4008 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4009 if (pVBInfo->VGAVDE == 357)
4011 else if (pVBInfo->VGAVDE == 420)
4013 else if (pVBInfo->VGAVDE == 525)
4015 else if (pVBInfo->VGAVDE == 600)
4017 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4018 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4023 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4026 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4028 if (pVBInfo->VGAVDE == 360)
4030 else if (pVBInfo->VGAVDE == 375)
4032 else if (pVBInfo->VGAVDE == 405)
4036 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4039 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4041 if (pVBInfo->VGAVDE == 350)
4043 else if (pVBInfo->VGAVDE == 400)
4045 else if (pVBInfo->VGAVDE == 1024)
4049 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4053 if (pVBInfo->VGAVDE == 1024) {
4057 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4059 tempbx = 1200; /* alan 10/14/2003 */
4060 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4061 if (pVBInfo->VGAVDE == 350)
4063 else if (pVBInfo->VGAVDE == 400)
4068 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4069 tempax = pVBInfo->VGAHDE;
4070 tempbx = pVBInfo->VGAVDE;
4073 pVBInfo->HDE = tempax;
4074 pVBInfo->VDE = tempbx;
4078 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4080 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4081 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4084 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4085 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4086 pVBInfo->VGAHT = TVPtr->VGAHT;
4087 pVBInfo->VGAVT = TVPtr->VGAVT;
4088 pVBInfo->HDE = TVPtr->TVHDE;
4089 pVBInfo->VDE = TVPtr->TVVDE;
4090 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4091 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
4093 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4094 if (resinfo == 0x08)
4095 pVBInfo->NewFlickerMode = 0x40;
4096 else if (resinfo == 0x09)
4097 pVBInfo->NewFlickerMode = 0x40;
4098 else if (resinfo == 0x12)
4099 pVBInfo->NewFlickerMode = 0x40;
4101 if (pVBInfo->VGAVDE == 350)
4102 pVBInfo->TVInfo |= TVSimuMode;
4107 if (pVBInfo->VBInfo & SetInSlaveMode) {
4108 if (pVBInfo->TVInfo & TVSimuMode) {
4112 if (!(modeflag & Charx8Dot)) {
4113 tempax = StHiTextTVHT;
4114 tempbx = StHiTextTVVT;
4118 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4119 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4120 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4121 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4124 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4125 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4126 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4127 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4128 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4129 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4130 if (pVBInfo->TVInfo & NTSC1024x768)
4131 tempax = NTSC1024x768HT;
4136 if (!(pVBInfo->TVInfo & SetPALTV)) {
4139 if (pVBInfo->TVInfo & NTSC1024x768)
4140 tempax = NTSC1024x768HT;
4144 pVBInfo->HT = tempax;
4145 pVBInfo->VT = tempbx;
4150 void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4151 unsigned short RefreshRateTableIndex,
4152 struct vb_device_info *pVBInfo)
4154 unsigned char di_0, di_1, tempal;
4156 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4158 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4159 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
4161 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4163 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, 0x10);
4164 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4165 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4166 } else { /* 301b/302b/301lv/302lv */
4167 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4168 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4171 XGINew_SetReg1(pVBInfo->Part4Port, 0x00, 0x12);
4173 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4174 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x28);
4176 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x08);
4179 /* --------------------------------------------------------------------- */
4180 /* Function : XGI_GETLCDVCLKPtr */
4182 /* Output : al -> VCLK Index */
4184 /* --------------------------------------------------------------------- */
4185 void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
4186 struct vb_device_info *pVBInfo)
4188 unsigned short index;
4190 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4191 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
4192 if (pVBInfo->LCDInfo & EnableScalingLCD)
4196 /* index = XGI_GetLCDCapPtr(pVBInfo); */
4197 index = XGI_GetLCDCapPtr1(pVBInfo);
4199 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
4200 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
4201 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
4203 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
4204 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
4210 unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
4211 unsigned short ModeNo, unsigned short ModeIdIndex,
4212 struct vb_device_info *pVBInfo)
4215 unsigned short index, modeflag;
4216 unsigned short tempbx;
4217 unsigned char tempal;
4218 unsigned char *CHTVVCLKPtr = NULL;
4221 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4223 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4225 if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
4226 & EnableScalingLCD))) { /* {LCDA/LCDB} */
4227 index = XGI_GetLCDCapPtr(pVBInfo);
4228 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
4230 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
4234 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4235 | VB_XGI302LV | VB_XGI301C)) {
4236 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4237 tempal = HiTVVCLKDIV2;
4238 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4240 if (pVBInfo->TVInfo & TVSimuMode) {
4241 tempal = HiTVSimuVCLK;
4242 if (!(modeflag & Charx8Dot))
4243 tempal = HiTVTextVCLK;
4249 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4250 tempal = YPbPr750pVCLK;
4254 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4255 tempal = YPbPr525pVCLK;
4259 tempal = NTSC1024VCLK;
4261 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
4262 tempal = TVVCLKDIV2;
4263 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4267 if (pVBInfo->VBInfo & SetCRT2ToTV)
4270 /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
4272 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4274 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4275 *tempal = *tempal & 0x1F;
4277 if (pVBInfo->TVInfo & SetPALTV)
4278 tempbx = tempbx + 2;
4279 if (pVBInfo->TVInfo & SetCHTVOverScan)
4281 tempbx = tempbx << 1;
4285 if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
4286 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4287 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
4288 if (ModeNo <= 0x13) {
4290 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4293 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4296 tempal = tempal & 0x0F;
4299 if (pVBInfo->TVInfo & SetPALTV)
4300 tempbx = tempbx + 2;
4302 if (pVBInfo->TVInfo & SetCHTVOverScan)
4305 /** tempbx = tempbx << 1; CH7007 ? **/
4307 /* [Billy]07/05/29 CH7007 */
4308 if (pVBInfo->IF_DEF_CH7007 == 1) {
4311 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
4314 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
4317 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
4320 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
4330 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
4333 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
4336 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
4339 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
4347 tempal = CHTVVCLKPtr[tempal];
4353 tempal = (unsigned char) XGINew_GetReg2((pVBInfo->P3ca + 0x02));
4354 tempal = tempal >> 2;
4357 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
4358 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
4363 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
4367 void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
4368 unsigned char *di_1, struct vb_device_info *pVBInfo)
4370 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
4371 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
4372 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
4373 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
4374 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
4375 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
4376 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
4377 & ProgrammingCRT2)) {
4378 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
4379 *di_1 = XGI_VBVCLKData[tempal].SR2C;
4382 *di_0 = XGI_VCLKData[tempal].SR2B;
4383 *di_1 = XGI_VCLKData[tempal].SR2C;
4387 static void XGI_SetCRT2Offset(unsigned short ModeNo,
4388 unsigned short ModeIdIndex,
4389 unsigned short RefreshRateTableIndex,
4390 struct xgi_hw_device_info *HwDeviceExtension,
4391 struct vb_device_info *pVBInfo)
4393 unsigned short offset;
4396 if (pVBInfo->VBInfo & SetInSlaveMode)
4399 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4400 HwDeviceExtension, pVBInfo);
4401 temp = (unsigned char) (offset & 0xFF);
4402 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp);
4403 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4404 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, temp);
4405 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4406 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4409 unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
4410 unsigned short RefreshRateTableIndex,
4411 struct xgi_hw_device_info *HwDeviceExtension,
4412 struct vb_device_info *pVBInfo)
4414 unsigned short temp, colordepth, modeinfo, index, infoflag,
4415 ColorDepth[] = { 0x01, 0x02, 0x04 };
4417 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4421 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4423 index = (modeinfo >> 8) & 0xFF;
4425 temp = pVBInfo->ScreenOffset[index];
4427 if (infoflag & InterlaceMode)
4430 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4432 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4433 temp = ModeNo - 0x7C;
4434 colordepth = ColorDepth[temp];
4436 if (infoflag & InterlaceMode)
4438 return temp * colordepth;
4440 return temp * colordepth;
4444 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
4446 XGINew_SetReg1(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
4447 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
4450 void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4451 struct xgi_hw_device_info *HwDeviceExtension,
4452 unsigned short RefreshRateTableIndex,
4453 struct vb_device_info *pVBInfo)
4455 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
4457 if (ModeNo > 0x13) {
4458 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4459 CRT1Index &= IndexMask;
4460 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4463 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4464 HwDeviceExtension, pVBInfo);
4465 XGI_SetCRT2FIFO(pVBInfo);
4466 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4468 for (tempcx = 4; tempcx < 7; tempcx++)
4469 XGINew_SetReg1(pVBInfo->Part1Port, tempcx, 0x0);
4471 XGINew_SetReg1(pVBInfo->Part1Port, 0x50, 0x00);
4472 XGINew_SetReg1(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
4475 void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4476 struct xgi_hw_device_info *HwDeviceExtension,
4477 unsigned short RefreshRateTableIndex,
4478 struct vb_device_info *pVBInfo)
4480 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4481 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
4483 if (ModeNo > 0x13) {
4484 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4485 CRT1Index &= IndexMask;
4486 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4490 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4492 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4494 /* bainy change table name */
4495 if (modeflag & HalfDCLK) {
4496 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4497 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4498 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4499 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4500 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4501 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4502 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4503 pushbx = pVBInfo->VGAHDE / 2 + 16;
4504 tempcx = tempcx >> 1;
4505 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4508 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4509 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4510 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4512 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4513 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4515 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4516 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4517 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4523 if (tempcx > (pVBInfo->VGAHT / 2))
4524 tempcx = pVBInfo->VGAHT / 2;
4526 temp = tempbx & 0x00FF;
4528 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4530 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4531 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4532 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4533 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4534 temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4535 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4536 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4537 pushbx = pVBInfo->VGAHDE + 16;
4538 tempcx = tempcx >> 1;
4539 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4542 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4543 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4544 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
4546 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4547 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4549 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4550 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4551 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4556 if (tempcx > pVBInfo->VGAHT)
4557 tempcx = pVBInfo->VGAHT;
4559 temp = tempbx & 0x00FF;
4560 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4563 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4565 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4566 tempax |= (tempbx & 0xFF00);
4567 temp = (tempax & 0xFF00) >> 8;
4568 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4569 temp = tempcx & 0x00FF;
4570 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp);
4571 tempcx = (pVBInfo->VGAVT - 1);
4572 temp = tempcx & 0x00FF;
4574 if (pVBInfo->IF_DEF_CH7005 == 1) {
4575 if (pVBInfo->VBInfo & 0x0C)
4579 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4580 tempbx = pVBInfo->VGAVDE - 1;
4581 temp = tempbx & 0x00FF;
4582 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, temp);
4583 temp = ((tempbx & 0xFF00) << 3) >> 8;
4584 temp |= ((tempcx & 0xFF00) >> 8);
4585 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, temp);
4587 tempax = pVBInfo->VGAVDE;
4588 tempbx = pVBInfo->VGAVDE;
4589 tempcx = pVBInfo->VGAVT;
4590 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
4591 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
4593 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4594 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4595 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4603 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
4608 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4609 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4612 temp = tempbx & 0x00FF;
4613 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4614 temp = ((tempbx & 0xFF00) >> 8) << 4;
4615 temp = ((tempcx & 0x000F) | (temp));
4616 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, temp);
4619 if (modeflag & DoubleScanMode)
4622 if (modeflag & HalfDCLK)
4625 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
4628 void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4629 struct xgi_hw_device_info *HwDeviceExtension,
4630 unsigned short RefreshRateTableIndex,
4631 struct vb_device_info *pVBInfo)
4633 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4634 modeflag, CRT1Index;
4636 if (ModeNo <= 0x13) {
4637 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4638 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4640 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4641 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4642 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4643 CRT1Index &= IndexMask;
4646 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4649 temp = 0xFF; /* set MAX HT */
4650 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4651 /* if (modeflag & Charx8Dot) */
4652 /* tempcx = 0x08; */
4656 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4657 modeflag |= Charx8Dot;
4659 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
4661 if (modeflag & HalfDCLK)
4662 tempax = tempax >> 1;
4664 tempax = (tempax / tempcx) - 1;
4665 tempbx |= ((tempax & 0x00FF) << 8);
4666 temp = tempax & 0x00FF;
4667 XGINew_SetReg1(pVBInfo->Part1Port, 0x04, temp);
4669 temp = (tempbx & 0xFF00) >> 8;
4671 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4672 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4673 | VB_XGI302LV | VB_XGI301C)))
4676 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4677 if (pVBInfo->VBType & VB_XGI301LV) {
4678 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4682 } else if (resinfo == 7) {
4688 XGINew_SetReg1(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
4689 XGINew_SetReg1(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
4691 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4692 if (pVBInfo->VBInfo & SetCRT2ToTV)
4693 tempax = pVBInfo->VGAHT;
4695 tempax = XGI_GetVGAHT2(pVBInfo);
4698 if (tempax >= pVBInfo->VGAHT)
4699 tempax = pVBInfo->VGAHT;
4701 if (modeflag & HalfDCLK)
4702 tempax = tempax >> 1;
4704 tempax = (tempax / tempcx) - 5;
4705 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4706 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4707 temp = (tempbx & 0x00FF) - 1;
4708 if (!(modeflag & HalfDCLK)) {
4710 if (pVBInfo->TVInfo & TVSimuMode) {
4717 /* tempcx = tempbx & 0x00FF ; */
4718 tempbx = (tempbx & 0xFF00) >> 8;
4719 tempcx = (tempcx + tempbx) >> 1;
4720 temp = (tempcx & 0x00FF) + 2;
4722 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4724 if (!(modeflag & HalfDCLK)) {
4725 if ((modeflag & Charx8Dot)) {
4727 if (pVBInfo->VGAHDE >= 800)
4732 if (!(modeflag & HalfDCLK)) {
4734 if (pVBInfo->LCDResInfo != Panel1280x960) {
4735 if (pVBInfo->VGAHDE >= 800) {
4737 if (pVBInfo->ModeType
4742 if (pVBInfo->LCDResInfo
4743 != Panel1280x1024) {
4750 if (pVBInfo->VGAHDE >= 1280) {
4751 if (pVBInfo->LCDResInfo
4753 if (pVBInfo->LCDInfo
4754 & LCDNonExpanding) {
4766 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
4767 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
4769 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4770 if (pVBInfo->TVInfo & TVSimuMode) {
4771 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
4772 == 0x11) || (ModeNo == 0x13) || (ModeNo
4774 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, 0x5b);
4775 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0x03);
4778 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
4779 if (pVBInfo->TVInfo & SetNTSCTV) {
4780 XGINew_SetReg1(pVBInfo->Part1Port,
4782 XGINew_SetReg1(pVBInfo->Part1Port,
4785 XGINew_SetReg1(pVBInfo->Part1Port,
4787 XGINew_SetReg1(pVBInfo->Part1Port,
4789 XGINew_SetReg1(pVBInfo->Part1Port,
4794 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
4796 if (pVBInfo->TVInfo & SetNTSCTV) {
4797 XGINew_SetReg1(pVBInfo->Part1Port,
4799 XGINew_SetReg1(pVBInfo->Part1Port,
4802 XGINew_SetReg1(pVBInfo->Part1Port,
4804 XGINew_SetReg1(pVBInfo->Part1Port,
4806 XGINew_SetReg1(pVBInfo->Part1Port,
4811 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
4812 == 0x0D) || (ModeNo == 0x50)) {
4813 if (pVBInfo->TVInfo & SetNTSCTV) {
4814 XGINew_SetReg1(pVBInfo->Part1Port,
4816 XGINew_SetReg1(pVBInfo->Part1Port,
4819 XGINew_SetReg1(pVBInfo->Part1Port,
4821 XGINew_SetReg1(pVBInfo->Part1Port,
4828 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
4829 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
4830 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
4832 tempbx = pVBInfo->VGAVT;
4835 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
4850 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4851 if (pVBInfo->LCDResInfo == Panel1024x768) {
4852 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4861 temp = tempbx & 0x00FF;
4863 temp = tempbx & 0x00FF;
4864 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
4867 temp = tempbx & 0x00FF;
4868 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4870 if (tempbx & 0x0100)
4875 if (modeflag & DoubleScanMode)
4878 if (tempbx & 0x0200)
4881 temp = (tempax & 0xFF00) >> 8;
4882 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4884 if (tempbx & 0x0400)
4887 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
4890 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
4891 tempax = tempax >> 2;
4892 push1 = tempax; /* push ax */
4894 if (resinfo != 0x09) {
4895 tempax = tempax << 1;
4899 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4900 if (pVBInfo->VBType & VB_XGI301LV) {
4901 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
4904 if (pVBInfo->TVInfo & TVSimuMode) {
4905 if (pVBInfo->TVInfo & SetPALTV) {
4908 if (!(pVBInfo->TVInfo
4911 | SetYPbPrMode1080i)))
4923 if (pVBInfo->TVInfo & TVSimuMode) {
4924 if (pVBInfo->TVInfo & SetPALTV) {
4925 if (pVBInfo->VBType & VB_XGI301LV) {
4926 if (!(pVBInfo->TVInfo
4929 | SetYPbPrMode1080i)))
4938 tempax = tempax >> 2;
4941 push1 = tempax; /* push ax */
4943 if ((pVBInfo->TVInfo & SetPALTV)) {
4944 if (tempbx <= 513) {
4950 temp = tempbx & 0x00FF;
4951 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4953 temp = tempbx & 0x00FF;
4954 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4956 if (tempbx & 0x0100)
4959 if (tempbx & 0x0200)
4960 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
4964 if (tempbx & 0x0100)
4967 if (tempbx & 0x0200)
4970 if (tempbx & 0x0400)
4973 tempbx = push1; /* pop ax */
4974 temp = tempbx & 0x00FF;
4976 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
4978 if (tempbx & 0x0010)
4981 temp = tempcx & 0x00FF;
4982 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
4983 temp = (tempcx & 0x0FF00) >> 8;
4984 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
4986 temp = (tempax & 0xFF00) >> 8;
4988 temp = (temp >> 1) & 0x09;
4990 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4993 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
4994 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
4995 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
4997 if (pVBInfo->LCDInfo & LCDRGB18Bit)
5002 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5007 void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5008 unsigned short RefreshRateTableIndex,
5009 struct xgi_hw_device_info *HwDeviceExtension,
5010 struct vb_device_info *pVBInfo)
5012 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5013 modeflag, resinfo, crt2crtc;
5014 unsigned char *TimingPoint;
5016 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5018 if (ModeNo <= 0x13) {
5019 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5020 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5021 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5023 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5024 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5026 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5031 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5034 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5037 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5040 if (!(pVBInfo->TVInfo & SetPALTV))
5043 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5046 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5049 tempax = (tempax & 0xff00) >> 8;
5051 XGINew_SetReg1(pVBInfo->Part2Port, 0x0, tempax);
5052 TimingPoint = pVBInfo->NTSCTiming;
5054 if (pVBInfo->TVInfo & SetPALTV)
5055 TimingPoint = pVBInfo->PALTiming;
5057 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5058 TimingPoint = pVBInfo->HiTVExtTiming;
5060 if (pVBInfo->VBInfo & SetInSlaveMode)
5061 TimingPoint = pVBInfo->HiTVSt2Timing;
5063 if (pVBInfo->SetFlag & TVSimuMode)
5064 TimingPoint = pVBInfo->HiTVSt1Timing;
5066 if (!(modeflag & Charx8Dot))
5067 TimingPoint = pVBInfo->HiTVTextTiming;
5070 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5071 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5072 TimingPoint = pVBInfo->YPbPr525iTiming;
5074 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5075 TimingPoint = pVBInfo->YPbPr525pTiming;
5077 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5078 TimingPoint = pVBInfo->YPbPr750pTiming;
5081 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5082 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]);
5084 for (i = 0x39; i <= 0x45; i++, j++)
5085 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
5087 if (pVBInfo->VBInfo & SetCRT2ToTV)
5088 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5090 temp = pVBInfo->NewFlickerMode;
5092 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5094 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5097 if (pVBInfo->TVInfo & SetPALTV)
5102 if (pVBInfo->VDE <= tempax) {
5103 tempax -= pVBInfo->VDE;
5104 tempax = tempax >> 2;
5105 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5107 temp = (tempax & 0xFF00) >> 8;
5108 temp += (unsigned short) TimingPoint[0];
5110 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5111 | VB_XGI302LV | VB_XGI301C)) {
5112 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5113 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5114 | SetCRT2ToYPbPr)) {
5115 tempcx = pVBInfo->VGAHDE;
5116 if (tempcx >= 1024) {
5117 temp = 0x17; /* NTSC */
5118 if (pVBInfo->TVInfo & SetPALTV)
5119 temp = 0x19; /* PAL */
5124 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5126 temp = (tempax & 0xFF00) >> 8;
5127 temp += TimingPoint[1];
5129 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5130 | VB_XGI302LV | VB_XGI301C)) {
5131 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5132 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5133 | SetCRT2ToYPbPr))) {
5134 tempcx = pVBInfo->VGAHDE;
5135 if (tempcx >= 1024) {
5136 temp = 0x1D; /* NTSC */
5137 if (pVBInfo->TVInfo & SetPALTV)
5138 temp = 0x52; /* PAL */
5142 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, temp);
5146 tempcx = pVBInfo->HT;
5148 if (XGI_IsLCDDualLink(pVBInfo))
5149 tempcx = tempcx >> 1;
5152 temp = tempcx & 0x00FF;
5153 XGINew_SetReg1(pVBInfo->Part2Port, 0x1B, temp);
5155 temp = (tempcx & 0xFF00) >> 8;
5156 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5158 tempcx = pVBInfo->HT >> 1;
5159 push1 = tempcx; /* push cx */
5162 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5165 temp = tempcx & 0x00FF;
5167 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5169 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5172 temp = tempbx & 0x00FF;
5173 XGINew_SetReg1(pVBInfo->Part2Port, 0x24, temp);
5174 temp = (tempbx & 0xFF00) >> 8;
5176 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5179 tempbx = tempbx + 8;
5180 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5181 tempbx = tempbx - 4;
5185 temp = (tempbx & 0x00FF) << 4;
5186 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5189 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5190 temp = tempcx & 0x00FF;
5191 XGINew_SetReg1(pVBInfo->Part2Port, 0x27, temp);
5192 temp = ((tempcx & 0xFF00) >> 8) << 4;
5193 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5196 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5199 temp = tempcx & 0xFF;
5201 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5203 tempcx = push1; /* pop cx */
5205 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5207 temp = tempcx & 0x00FF;
5209 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5213 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5214 tempax = XGI_GetVGAHT2(pVBInfo);
5215 tempcx = tempax - 1;
5217 temp = tempcx & 0x00FF;
5218 XGINew_SetReg1(pVBInfo->Part2Port, 0x2E, temp);
5220 tempbx = pVBInfo->VDE;
5222 if (pVBInfo->VGAVDE == 360)
5224 if (pVBInfo->VGAVDE == 375)
5226 if (pVBInfo->VGAVDE == 405)
5229 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5230 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5231 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5232 | SetYPbPrMode750p)))
5233 tempbx = tempbx >> 1;
5235 tempbx = tempbx >> 1;
5239 temp = tempbx & 0x00FF;
5241 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5242 if (pVBInfo->VBType & VB_XGI301LV) {
5243 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5244 if (pVBInfo->VBInfo & SetInSlaveMode) {
5250 if (pVBInfo->VBInfo & SetInSlaveMode) {
5257 XGINew_SetReg1(pVBInfo->Part2Port, 0x2F, temp);
5259 temp = (tempcx & 0xFF00) >> 8;
5260 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5262 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5263 if (pVBInfo->VBType & VB_XGI301LV) {
5264 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5267 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5272 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5277 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, temp);
5279 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5280 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5281 tempbx = pVBInfo->VDE;
5282 tempcx = tempbx - 2;
5284 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5285 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5286 | SetYPbPrMode750p)))
5287 tempbx = tempbx >> 1;
5290 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5292 if (tempcx & 0x0400)
5295 if (tempbx & 0x0400)
5298 XGINew_SetReg1(pVBInfo->Part4Port, 0x10, temp);
5301 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5302 XGINew_SetReg1(pVBInfo->Part2Port, 0x46, temp);
5303 temp = (tempbx - 3) & 0x00FF;
5304 XGINew_SetReg1(pVBInfo->Part2Port, 0x47, temp);
5307 tempbx = tempbx & 0x00FF;
5309 if (!(modeflag & HalfDCLK)) {
5310 tempcx = pVBInfo->VGAHDE;
5311 if (tempcx >= pVBInfo->HDE) {
5319 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5320 if (pVBInfo->VGAHDE >= 1024) {
5322 if (pVBInfo->VGAHDE >= 1280) {
5324 tempbx = tempbx & 0xDFFF;
5329 if (!(tempbx & 0x2000)) {
5330 if (modeflag & HalfDCLK)
5331 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5334 tempeax = pVBInfo->VGAHDE;
5335 tempebx = (tempcx & 0xFF00) >> 8;
5336 longtemp = tempeax * tempebx;
5337 tempecx = tempcx & 0x00FF;
5338 longtemp = longtemp / tempecx;
5343 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5344 | VB_XGI302LV | VB_XGI301C)) {
5345 tempecx = tempecx * 8;
5348 longtemp = longtemp * tempecx;
5349 tempecx = pVBInfo->HDE;
5350 temp2 = longtemp % tempecx;
5351 tempeax = longtemp / tempecx;
5355 tempax = (unsigned short) tempeax;
5358 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5359 | VB_XGI302LV | VB_XGI301C)) {
5360 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5365 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5366 | (tempbx & 0x00FF));
5367 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5368 | (tempax & 0x00FF));
5369 temp = (tempax & 0xFF00) >> 8;
5371 temp = (tempax & 0x00FF) >> 8;
5374 XGINew_SetReg1(pVBInfo->Part2Port, 0x44, temp);
5375 temp = (tempbx & 0xFF00) >> 8;
5376 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5377 temp = tempcx & 0x00FF;
5379 if (tempbx & 0x2000)
5382 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5385 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5386 if (pVBInfo->TVInfo & SetPALTV) {
5394 temp = tempbx & 0x00FF;
5395 XGINew_SetReg1(pVBInfo->Part2Port, 0x4b, temp);
5396 temp = tempcx & 0x00FF;
5397 XGINew_SetReg1(pVBInfo->Part2Port, 0x4c, temp);
5399 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5401 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5403 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5406 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5409 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5413 XGINew_SetReg1(pVBInfo->Part2Port, 0x4d, temp);
5414 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x43); /* 301b change */
5415 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5417 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5418 if (pVBInfo->TVInfo & NTSC1024x768) {
5419 TimingPoint = XGI_NTSC1024AdjTime;
5420 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5421 XGINew_SetReg1(pVBInfo->Part2Port, i,
5424 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, 0x72);
5428 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5429 if (pVBInfo->VBType & VB_XGI301C) {
5430 if (pVBInfo->TVInfo & SetPALMTV)
5431 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x08,
5432 0x08); /* PALM Mode */
5435 if (pVBInfo->TVInfo & SetPALMTV) {
5436 tempax = (unsigned char) XGINew_GetReg1(pVBInfo->Part2Port,
5439 XGINew_SetRegAND(pVBInfo->Part2Port, 0x01, tempax);
5441 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5442 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xEF);
5445 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5446 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5447 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, 0x00);
5450 if (pVBInfo->VBInfo & SetCRT2ToTV)
5454 void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5455 struct xgi_hw_device_info *HwDeviceExtension,
5456 unsigned short RefreshRateTableIndex,
5457 struct vb_device_info *pVBInfo)
5459 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5460 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5462 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5464 if (ModeNo <= 0x13) {
5465 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5466 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5468 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5469 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5471 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5472 CRT1Index &= IndexMask;
5475 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5478 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5480 if (XGI_IsLCDDualLink(pVBInfo))
5481 tempbx = tempbx >> 1;
5484 temp = tempbx & 0x00FF;
5485 XGINew_SetReg1(pVBInfo->Part2Port, 0x2C, temp);
5486 temp = (tempbx & 0xFF00) >> 8;
5488 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5491 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5492 if (pVBInfo->ModeType == ModeEGA) {
5493 if (pVBInfo->VGAHDE >= 1024) {
5495 if (pVBInfo->LCDInfo & LCDVESATiming)
5501 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, temp);
5502 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5505 temp = tempbx & 0x00FF;
5506 XGINew_SetReg1(pVBInfo->Part2Port, 0x03, temp);
5507 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5508 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5510 tempcx = pVBInfo->VT - 1;
5512 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5513 XGINew_SetReg1(pVBInfo->Part2Port, 0x19, temp);
5514 temp = (tempcx & 0xFF00) >> 8;
5516 XGINew_SetReg1(pVBInfo->Part2Port, 0x1A, temp);
5517 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5518 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5519 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5520 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5522 /* Customized LCDB Des no add */
5524 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5525 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5526 tempah = pVBInfo->LCDResInfo;
5527 tempah &= PanelResInfo;
5529 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5532 } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
5535 } else if (tempah == Panel1400x1050) {
5543 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5544 tempbx = pVBInfo->HDE;
5545 tempcx = pVBInfo->VDE;
5549 tempax = pVBInfo->VT;
5550 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5551 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5552 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5553 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5554 tempbx = pVBInfo->LCDVDES;
5557 if (tempcx >= tempax)
5558 tempcx -= tempax; /* lcdvdes */
5560 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5561 XGINew_SetReg1(pVBInfo->Part2Port, 0x05, temp);
5562 temp = tempcx & 0x00FF;
5563 XGINew_SetReg1(pVBInfo->Part2Port, 0x06, temp);
5564 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5565 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5567 tempah = tempah << 3;
5569 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, tempah);
5572 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5574 tempax = pVBInfo->VT;
5575 tempbx = pVBInfo->LCDVRS;
5577 /* if (SetLCD_Info & EnableScalingLCD) */
5579 if (tempcx >= tempax)
5582 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5583 XGINew_SetReg1(pVBInfo->Part2Port, 0x04, temp);
5584 temp = (tempbx & 0xFF00) >> 8;
5586 temp |= (tempcx & 0x000F);
5587 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5589 tempax = pVBInfo->HT;
5590 tempbx = pVBInfo->LCDHDES;
5593 if (XGI_IsLCDDualLink(pVBInfo)) {
5594 tempax = tempax >> 1;
5595 tempbx = tempbx >> 1;
5596 tempcx = tempcx >> 1;
5599 if (pVBInfo->VBType & VB_XGI302LV)
5602 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5607 if (tempcx >= tempax)
5610 temp = tempbx & 0x00FF;
5611 XGINew_SetReg1(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5612 temp = ((tempbx & 0xFF00) >> 8) << 4;
5613 XGINew_SetReg1(pVBInfo->Part2Port, 0x20, temp);
5614 temp = tempcx & 0x00FF;
5615 XGINew_SetReg1(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5616 temp = (tempcx & 0xFF00) >> 8;
5617 XGINew_SetReg1(pVBInfo->Part2Port, 0x25, temp);
5620 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5622 tempax = pVBInfo->HT;
5623 tempbx = pVBInfo->LCDHRS;
5624 /* if ( SetLCD_Info & EnableScalingLCD) */
5625 if (XGI_IsLCDDualLink(pVBInfo)) {
5626 tempax = tempax >> 1;
5627 tempbx = tempbx >> 1;
5628 tempcx = tempcx >> 1;
5631 if (pVBInfo->VBType & VB_XGI302LV)
5636 if (tempcx >= tempax)
5639 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5640 XGINew_SetReg1(pVBInfo->Part2Port, 0x1C, temp);
5642 temp = (tempbx & 0xFF00) >> 8;
5644 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5645 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5646 XGINew_SetReg1(pVBInfo->Part2Port, 0x21, temp);
5648 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5649 if (pVBInfo->VGAVDE == 525) {
5650 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5651 | VB_XGI301LV | VB_XGI302LV
5657 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5658 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, 0xB3);
5661 if (pVBInfo->VGAVDE == 420) {
5662 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5663 | VB_XGI301LV | VB_XGI302LV
5668 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5673 /* --------------------------------------------------------------------- */
5674 /* Function : XGI_GetTap4Ptr */
5676 /* Output : di -> Tap4 Reg. Setting Pointer */
5678 /* --------------------------------------------------------------------- */
5679 struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
5680 struct vb_device_info *pVBInfo)
5682 unsigned short tempax, tempbx, i;
5684 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5687 tempax = pVBInfo->VGAHDE;
5688 tempbx = pVBInfo->HDE;
5690 tempax = pVBInfo->VGAVDE;
5691 tempbx = pVBInfo->VDE;
5694 if (tempax < tempbx)
5695 return &EnlargeTap4Timing[0];
5696 else if (tempax == tempbx)
5697 return &NoScaleTap4Timing[0]; /* 1:1 */
5699 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
5701 if (pVBInfo->TVInfo & SetPALTV)
5702 Tap4TimingPtr = PALTap4Timing;
5704 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5705 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5706 Tap4TimingPtr = YPbPr525iTap4Timing;
5707 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5708 Tap4TimingPtr = YPbPr525pTap4Timing;
5709 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5710 Tap4TimingPtr = YPbPr750pTap4Timing;
5713 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5714 Tap4TimingPtr = HiTVTap4Timing;
5717 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5718 if (Tap4TimingPtr[i].DE == tempax)
5722 return &Tap4TimingPtr[i];
5725 void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
5727 unsigned short i, j;
5729 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5731 if (!(pVBInfo->VBType & VB_XGI301C))
5735 XGINew_SetRegAND(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
5736 #else /* Tap4 Setting */
5738 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5739 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5740 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5742 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5743 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
5744 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5745 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5748 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5749 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
5751 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
5755 void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5756 struct vb_device_info *pVBInfo)
5759 unsigned char *tempdi;
5760 unsigned short modeflag;
5763 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5765 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5767 XGINew_SetReg1(pVBInfo->Part3Port, 0x00, 0x00);
5768 if (pVBInfo->TVInfo & SetPALTV) {
5769 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5770 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5772 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xF5);
5773 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xB7);
5776 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5779 if (pVBInfo->TVInfo & SetPALMTV) {
5780 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5781 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5782 XGINew_SetReg1(pVBInfo->Part3Port, 0x3D, 0xA8);
5785 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
5786 & SetCRT2ToYPbPr)) {
5787 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5790 tempdi = pVBInfo->HiTVGroup3Data;
5791 if (pVBInfo->SetFlag & TVSimuMode) {
5792 tempdi = pVBInfo->HiTVGroup3Simu;
5793 if (!(modeflag & Charx8Dot))
5794 tempdi = pVBInfo->HiTVGroup3Text;
5797 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5798 tempdi = pVBInfo->Ren525pGroup3;
5800 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5801 tempdi = pVBInfo->Ren750pGroup3;
5803 for (i = 0; i <= 0x3E; i++)
5804 XGINew_SetReg1(pVBInfo->Part3Port, i, tempdi[i]);
5806 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
5807 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5808 XGINew_SetReg1(pVBInfo->Part3Port, 0x28, 0x3f);
5812 } /* {end of XGI_SetGroup3} */
5814 void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
5815 unsigned short RefreshRateTableIndex,
5816 struct xgi_hw_device_info *HwDeviceExtension,
5817 struct vb_device_info *pVBInfo)
5819 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
5821 unsigned long tempebx, tempeax, templong;
5824 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5826 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5828 temp = pVBInfo->RVBHCFACT;
5829 XGINew_SetReg1(pVBInfo->Part4Port, 0x13, temp);
5831 tempbx = pVBInfo->RVBHCMAX;
5832 temp = tempbx & 0x00FF;
5833 XGINew_SetReg1(pVBInfo->Part4Port, 0x14, temp);
5834 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
5835 tempcx = pVBInfo->VGAHT - 1;
5836 temp = tempcx & 0x00FF;
5837 XGINew_SetReg1(pVBInfo->Part4Port, 0x16, temp);
5839 temp = ((tempcx & 0xFF00) >> 8) << 3;
5842 tempcx = pVBInfo->VGAVT - 1;
5843 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5846 temp = tempcx & 0x00FF;
5847 XGINew_SetReg1(pVBInfo->Part4Port, 0x17, temp);
5848 temp = temp2 | ((tempcx & 0xFF00) >> 8);
5849 XGINew_SetReg1(pVBInfo->Part4Port, 0x15, temp);
5850 XGINew_SetRegOR(pVBInfo->Part4Port, 0x0D, 0x08);
5851 tempcx = pVBInfo->VBInfo;
5852 tempbx = pVBInfo->VGAHDE;
5854 if (modeflag & HalfDCLK)
5855 tempbx = tempbx >> 1;
5857 if (XGI_IsLCDDualLink(pVBInfo))
5858 tempbx = tempbx >> 1;
5860 if (tempcx & SetCRT2ToHiVisionTV) {
5866 } else if (tempcx & SetCRT2ToTV) {
5872 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5879 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
5881 if (pVBInfo->VGAHDE == 1280)
5883 if (pVBInfo->VGAHDE == 1024)
5886 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
5888 tempebx = pVBInfo->VDE;
5890 if (tempcx & SetCRT2ToHiVisionTV) {
5891 if (!(temp & 0xE000))
5892 tempbx = tempbx >> 1;
5895 tempcx = pVBInfo->RVBHRS;
5896 temp = tempcx & 0x00FF;
5897 XGINew_SetReg1(pVBInfo->Part4Port, 0x18, temp);
5899 tempeax = pVBInfo->VGAVDE;
5902 if (tempeax <= tempebx) {
5903 tempcx = (tempcx & (~0x4000));
5904 tempeax = pVBInfo->VGAVDE;
5909 templong = (tempeax * 256 * 1024) % tempebx;
5910 tempeax = (tempeax * 256 * 1024) / tempebx;
5916 temp = (unsigned short) (tempebx & 0x000000FF);
5917 XGINew_SetReg1(pVBInfo->Part4Port, 0x1B, temp);
5919 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
5920 XGINew_SetReg1(pVBInfo->Part4Port, 0x1A, temp);
5921 tempbx = (unsigned short) (tempebx >> 16);
5922 temp = tempbx & 0x00FF;
5924 temp |= ((tempcx & 0xFF00) >> 8);
5925 XGINew_SetReg1(pVBInfo->Part4Port, 0x19, temp);
5928 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5929 | VB_XGI302LV | VB_XGI301C)) {
5931 XGINew_SetReg1(pVBInfo->Part4Port, 0x1C, temp);
5932 tempax = pVBInfo->VGAHDE;
5933 if (modeflag & HalfDCLK)
5934 tempax = tempax >> 1;
5936 if (XGI_IsLCDDualLink(pVBInfo))
5937 tempax = tempax >> 1;
5939 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
5940 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5944 if (pVBInfo->VGAHDE > 800) {
5945 if (pVBInfo->VGAHDE == 1024)
5946 tempax = (tempax * 25 / 32) - 1;
5948 tempax = (tempax * 20 / 32) - 1;
5954 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5955 if (pVBInfo->VBType & VB_XGI301LV) {
5956 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
5957 if (pVBInfo->VGAHDE > 800) {
5958 if (pVBInfo->VGAHDE == 1024)
5959 tempax = (tempax * 25 / 32) - 1;
5961 tempax = (tempax * 20 / 32) - 1;
5965 if (pVBInfo->VGAHDE > 800) {
5966 if (pVBInfo->VGAHDE == 1024)
5967 tempax = (tempax * 25 / 32) - 1;
5969 tempax = (tempax * 20 / 32) - 1;
5975 temp = (tempax & 0xFF00) >> 8;
5976 temp = ((temp & 0x0003) << 4);
5977 XGINew_SetReg1(pVBInfo->Part4Port, 0x1E, temp);
5978 temp = (tempax & 0x00FF);
5979 XGINew_SetReg1(pVBInfo->Part4Port, 0x1D, temp);
5981 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5982 if (pVBInfo->VGAHDE > 800)
5983 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1E, 0x08);
5988 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5989 if (!(pVBInfo->TVInfo & (NTSC1024x768
5990 | SetYPbPrMode525p | SetYPbPrMode750p
5991 | SetYPbPrMode1080i))) {
5993 if ((pVBInfo->VBInfo & SetInSlaveMode)
5994 && (!(pVBInfo->TVInfo
6000 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6001 tempbx = pVBInfo->HT;
6002 if (XGI_IsLCDDualLink(pVBInfo))
6003 tempbx = tempbx >> 1;
6004 tempbx = (tempbx >> 1) - 2;
6005 temp = ((tempbx & 0x0700) >> 8) << 3;
6006 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6007 temp = tempbx & 0x00FF;
6008 XGINew_SetReg1(pVBInfo->Part4Port, 0x22, temp);
6012 if (pVBInfo->ISXPDOS == 0)
6013 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6017 void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6018 struct vb_device_info *pVBInfo)
6020 unsigned short Pindex, Pdata;
6022 Pindex = pVBInfo->Part5Port;
6023 Pdata = pVBInfo->Part5Port + 1;
6024 if (pVBInfo->ModeType == ModeVGA) {
6025 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6026 | CRT2DisplayFlag))) {
6027 XGINew_EnableCRT2(pVBInfo);
6028 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6034 void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
6035 unsigned short ModeIdIndex,
6036 unsigned short RefreshRateTableIndex,
6037 struct vb_device_info *pVBInfo)
6039 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
6041 struct XGI330_LCDDataTablStruct *tempdi = NULL;
6045 if (ModeNo <= 0x13) {
6046 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6047 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6049 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6050 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6053 tempal = tempal & 0x0f;
6055 if (tempbx <= 1) { /* ExpLink */
6056 if (ModeNo <= 0x13) {
6057 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
6060 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6063 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6066 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
6069 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
6073 tempal = (tempal >> 4);
6075 tempal = (tempal & 0x0f);
6078 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
6080 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
6081 if ((tempbx == 5) || (tempbx) == 7)
6082 tempcx = LCDDesDataLen2;
6083 else if ((tempbx == 3) || (tempbx == 8))
6084 tempcx = LVDSDesDataLen2;
6086 /* mov di, word ptr cs:LCDDataList[bx] */
6087 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
6091 tempdi = XGI_EPLLCDCRT1Ptr_H;
6094 tempdi = XGI_EPLLCDCRT1Ptr_V;
6097 tempdi = XGI_EPLLCDDataPtr;
6100 tempdi = XGI_EPLLCDDesDataPtr;
6103 tempdi = XGI_LCDDataTable;
6106 tempdi = XGI_LCDDesDataTable;
6109 tempdi = XGI_EPLCHLCDRegPtr;
6120 if (tempdi == NULL) /* OEMUtil */
6126 while (tempdi[i].PANELID != 0xff) {
6127 tempdx = pVBInfo->LCDResInfo;
6128 if (tempbx & 0x0080) { /* OEMUtil */
6129 tempbx &= (~0x0080);
6130 tempdx = pVBInfo->LCDTypeInfo;
6133 if (pVBInfo->LCDInfo & EnableScalingLCD)
6134 tempdx &= (~PanelResInfo);
6136 if (tempdi[i].PANELID == tempdx) {
6137 tempbx = tempdi[i].MASK;
6138 tempdx = pVBInfo->LCDInfo;
6140 if (ModeNo <= 0x13) /* alan 09/10/2003 */
6141 tempdx |= SetLCDStdMode;
6143 if (modeflag & HalfDCLK)
6144 tempdx |= SetLCDLowResolution;
6147 if (tempbx == tempdi[i].CAP)
6154 switch (tempdi[i].DATAPTR) {
6156 return &XGI_LVDSCRT11024x768_1_H[tempal];
6159 return &XGI_LVDSCRT11024x768_2_H[tempal];
6162 return &XGI_LVDSCRT11280x1024_1_H[tempal];
6165 return &XGI_LVDSCRT11280x1024_2_H[tempal];
6168 return &XGI_LVDSCRT11400x1050_1_H[tempal];
6171 return &XGI_LVDSCRT11400x1050_2_H[tempal];
6174 return &XGI_LVDSCRT11600x1200_1_H[tempal];
6177 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
6180 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
6183 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
6186 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
6191 } else if (table == 1) {
6192 switch (tempdi[i].DATAPTR) {
6194 return &XGI_LVDSCRT11024x768_1_V[tempal];
6197 return &XGI_LVDSCRT11024x768_2_V[tempal];
6200 return &XGI_LVDSCRT11280x1024_1_V[tempal];
6203 return &XGI_LVDSCRT11280x1024_2_V[tempal];
6206 return &XGI_LVDSCRT11400x1050_1_V[tempal];
6209 return &XGI_LVDSCRT11400x1050_2_V[tempal];
6212 return &XGI_LVDSCRT11600x1200_1_V[tempal];
6215 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
6218 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
6221 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
6224 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
6229 } else if (table == 2) {
6230 switch (tempdi[i].DATAPTR) {
6232 return &XGI_LVDS1024x768Data_1[tempal];
6235 return &XGI_LVDS1024x768Data_2[tempal];
6238 return &XGI_LVDS1280x1024Data_1[tempal];
6241 return &XGI_LVDS1280x1024Data_2[tempal];
6244 return &XGI_LVDS1400x1050Data_1[tempal];
6247 return &XGI_LVDS1400x1050Data_2[tempal];
6250 return &XGI_LVDS1600x1200Data_1[tempal];
6253 return &XGI_LVDSNoScalingData[tempal];
6256 return &XGI_LVDS1024x768Data_1x75[tempal];
6259 return &XGI_LVDS1024x768Data_2x75[tempal];
6262 return &XGI_LVDS1280x1024Data_1x75[tempal];
6265 return &XGI_LVDS1280x1024Data_2x75[tempal];
6268 return &XGI_LVDSNoScalingDatax75[tempal];
6273 } else if (table == 3) {
6274 switch (tempdi[i].DATAPTR) {
6276 return &XGI_LVDS1024x768Des_1[tempal];
6279 return &XGI_LVDS1024x768Des_3[tempal];
6282 return &XGI_LVDS1024x768Des_2[tempal];
6285 return &XGI_LVDS1280x1024Des_1[tempal];
6288 return &XGI_LVDS1280x1024Des_2[tempal];
6291 return &XGI_LVDS1400x1050Des_1[tempal];
6294 return &XGI_LVDS1400x1050Des_2[tempal];
6297 return &XGI_LVDS1600x1200Des_1[tempal];
6300 return &XGI_LVDSNoScalingDesData[tempal];
6303 return &XGI_LVDS1024x768Des_1x75[tempal];
6306 return &XGI_LVDS1024x768Des_3x75[tempal];
6309 return &XGI_LVDS1024x768Des_2x75[tempal];
6312 return &XGI_LVDS1280x1024Des_1x75[tempal];
6315 return &XGI_LVDS1280x1024Des_2x75[tempal];
6318 return &XGI_LVDSNoScalingDesDatax75[tempal];
6323 } else if (table == 4) {
6324 switch (tempdi[i].DATAPTR) {
6326 return &XGI_ExtLCD1024x768Data[tempal];
6329 return &XGI_StLCD1024x768Data[tempal];
6332 return &XGI_CetLCD1024x768Data[tempal];
6335 return &XGI_ExtLCD1280x1024Data[tempal];
6338 return &XGI_StLCD1280x1024Data[tempal];
6341 return &XGI_CetLCD1280x1024Data[tempal];
6344 return &XGI_ExtLCD1400x1050Data[tempal];
6347 return &XGI_StLCD1400x1050Data[tempal];
6350 return &XGI_CetLCD1400x1050Data[tempal];
6353 return &XGI_ExtLCD1600x1200Data[tempal];
6356 return &XGI_StLCD1600x1200Data[tempal];
6359 return &XGI_NoScalingData[tempal];
6362 return &XGI_ExtLCD1024x768x75Data[tempal];
6365 return &XGI_ExtLCD1024x768x75Data[tempal];
6368 return &XGI_CetLCD1024x768x75Data[tempal];
6371 return &XGI_ExtLCD1280x1024x75Data[tempal];
6374 return &XGI_StLCD1280x1024x75Data[tempal];
6377 return &XGI_CetLCD1280x1024x75Data[tempal];
6380 return &XGI_NoScalingDatax75[tempal];
6385 } else if (table == 5) {
6386 switch (tempdi[i].DATAPTR) {
6388 return &XGI_ExtLCDDes1024x768Data[tempal];
6391 return &XGI_StLCDDes1024x768Data[tempal];
6394 return &XGI_CetLCDDes1024x768Data[tempal];
6397 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6399 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
6401 return &XGI_ExtLCDDes1280x1024Data[tempal];
6404 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6406 return &XGI_StLCDDLDes1280x1024Data[tempal];
6408 return &XGI_StLCDDes1280x1024Data[tempal];
6411 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6413 return &XGI_CetLCDDLDes1280x1024Data[tempal];
6415 return &XGI_CetLCDDes1280x1024Data[tempal];
6418 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6420 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
6422 return &XGI_ExtLCDDes1400x1050Data[tempal];
6425 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6427 return &XGI_StLCDDLDes1400x1050Data[tempal];
6429 return &XGI_StLCDDes1400x1050Data[tempal];
6432 return &XGI_CetLCDDes1400x1050Data[tempal];
6435 return &XGI_CetLCDDes1400x1050Data2[tempal];
6438 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6440 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
6442 return &XGI_ExtLCDDes1600x1200Data[tempal];
6445 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6447 return &XGI_StLCDDLDes1600x1200Data[tempal];
6449 return &XGI_StLCDDes1600x1200Data[tempal];
6452 return &XGI_NoScalingDesData[tempal];
6455 return &XGI_ExtLCDDes1024x768x75Data[tempal];
6458 return &XGI_StLCDDes1024x768x75Data[tempal];
6461 return &XGI_CetLCDDes1024x768x75Data[tempal];
6464 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6466 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
6468 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
6471 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6473 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
6475 return &XGI_StLCDDes1280x1024x75Data[tempal];
6478 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6480 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
6482 return &XGI_CetLCDDes1280x1024x75Data[tempal];
6485 return &XGI_NoScalingDesDatax75[tempal];
6490 } else if (table == 6) {
6491 switch (tempdi[i].DATAPTR) {
6493 return &XGI_CH7017LV1024x768[tempal];
6496 return &XGI_CH7017LV1400x1050[tempal];
6505 void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
6506 unsigned short ModeIdIndex,
6507 unsigned short RefreshRateTableIndex,
6508 struct vb_device_info *pVBInfo)
6510 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
6511 struct XGI330_TVDataTablStruct *tempdi = NULL;
6515 if (ModeNo <= 0x13) {
6516 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6517 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6519 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6520 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6523 tempal = tempal & 0x3f;
6528 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
6529 if (pVBInfo->IF_DEF_CH7007 == 1)
6530 tempdi = XGI_EPLCHTVCRT1Ptr;
6534 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
6535 if (pVBInfo->IF_DEF_CH7007 == 1)
6536 tempdi = XGI_EPLCHTVCRT1Ptr;
6540 tempdi = XGI_EPLCHTVDataPtr;
6546 tempdi = XGI_TVDataTable;
6552 tempdi = XGI_EPLCHTVRegPtr;
6558 if (tempdi == NULL) /* OEMUtil */
6561 tempdx = pVBInfo->TVInfo;
6563 if (pVBInfo->VBInfo & SetInSlaveMode)
6564 tempdx = tempdx | SetTVLockMode;
6566 if (modeflag & HalfDCLK)
6567 tempdx = tempdx | SetTVLowResolution;
6571 while (tempdi[i].MASK != 0xffff) {
6572 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
6577 if (table == 0x00) { /* 07/05/22 */
6578 } else if (table == 0x01) {
6579 } else if (table == 0x04) {
6580 switch (tempdi[i].DATAPTR) {
6582 return &XGI_ExtPALData[tempal];
6585 return &XGI_ExtNTSCData[tempal];
6588 return &XGI_StPALData[tempal];
6591 return &XGI_StNTSCData[tempal];
6594 return &XGI_ExtHiTVData[tempal];
6597 return &XGI_St2HiTVData[tempal];
6600 return &XGI_ExtYPbPr525iData[tempal];
6603 return &XGI_ExtYPbPr525pData[tempal];
6606 return &XGI_ExtYPbPr750pData[tempal];
6609 return &XGI_StYPbPr525iData[tempal];
6612 return &XGI_StYPbPr525pData[tempal];
6615 return &XGI_StYPbPr750pData[tempal];
6617 case 12: /* avoid system hang */
6618 return &XGI_ExtNTSCData[tempal];
6621 return &XGI_St1HiTVData[tempal];
6626 } else if (table == 0x02) {
6627 switch (tempdi[i].DATAPTR) {
6629 return &XGI_CHTVUNTSCData[tempal];
6632 return &XGI_CHTVONTSCData[tempal];
6635 return &XGI_CHTVUPALData[tempal];
6638 return &XGI_CHTVOPALData[tempal];
6643 } else if (table == 0x06) {
6648 /* --------------------------------------------------------------------- */
6649 /* Function : XGI_BacklightByDrv */
6651 /* Output : 1 -> Skip backlight control */
6653 /* --------------------------------------------------------------------- */
6654 unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
6656 unsigned char tempah;
6658 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x3A);
6659 if (tempah & BacklightControlBit)
6665 /* --------------------------------------------------------------------- */
6666 /* Function : XGI_FirePWDDisable */
6669 /* Description : Turn off VDD & Backlight : Fire disable procedure */
6670 /* --------------------------------------------------------------------- */
6672 void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
6674 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x00, 0xFC);
6678 /* --------------------------------------------------------------------- */
6679 /* Function : XGI_FirePWDEnable */
6682 /* Description : Turn on VDD & Backlight : Fire enable procedure */
6683 /* --------------------------------------------------------------------- */
6684 void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
6686 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x03, 0xFC);
6689 void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6690 struct vb_device_info *pVBInfo)
6692 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
6695 void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6696 struct vb_device_info *pVBInfo)
6699 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
6702 /* --------------------------------------------------------------------- */
6703 /* Function : XGI_SetPanelDelay */
6707 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6708 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6709 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6710 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6711 /* --------------------------------------------------------------------- */
6712 void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
6714 unsigned short index;
6716 index = XGI_GetLCDCapPtr(pVBInfo);
6719 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S1, pVBInfo);
6722 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S2, pVBInfo);
6725 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S3, pVBInfo);
6728 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S4, pVBInfo);
6731 /* --------------------------------------------------------------------- */
6732 /* Function : XGI_SetPanelPower */
6736 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
6737 /* = 0111b = 07h ; Backlight on, Power off */
6738 /* = 1011b = 0Bh ; Backlight off, Power on */
6739 /* = 1111b = 0Fh ; Backlight off, Power off */
6740 /* --------------------------------------------------------------------- */
6741 void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl,
6742 struct vb_device_info *pVBInfo)
6744 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
6745 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x26, tempbl, tempah);
6747 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x11, tempbl, tempah);
6750 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
6752 unsigned char ujRet = 0;
6753 unsigned char i = 0;
6755 for (i = 0; i < 8; i++) {
6757 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
6758 ujRet |= (ujDate >> i) & 1;
6764 /*----------------------------------------------------------------------------*/
6766 /* bl[5] : LVDS signal */
6767 /* bl[1] : LVDS backlight */
6768 /* bl[0] : LVDS VDD */
6769 /*----------------------------------------------------------------------------*/
6770 unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
6772 unsigned char CR4A, temp;
6774 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6775 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
6777 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6779 temp = XG21GPIODataTransfer(temp);
6781 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6785 /*----------------------------------------------------------------------------*/
6787 /* bl[5] : LVDS signal */
6788 /* bl[1] : LVDS backlight */
6789 /* bl[0] : LVDS VDD */
6790 /*----------------------------------------------------------------------------*/
6791 unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
6793 unsigned char CR4A, CRB4, temp;
6795 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6796 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
6798 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6802 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6803 CRB4 = XGINew_GetReg1(pVBInfo->P3d4, 0xB4);
6804 temp |= ((CRB4 & 0x04) << 3);
6807 /*----------------------------------------------------------------------------*/
6809 /* bl[5] : 1;LVDS signal on */
6810 /* bl[1] : 1;LVDS backlight on */
6811 /* bl[0] : 1:LVDS VDD on */
6812 /* bh: 100000b : clear bit 5, to set bit5 */
6813 /* 000010b : clear bit 1, to set bit1 */
6814 /* 000001b : clear bit 0, to set bit0 */
6815 /*----------------------------------------------------------------------------*/
6816 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6817 struct vb_device_info *pVBInfo)
6819 unsigned char CR4A, temp;
6821 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6824 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6826 if (tempbh & 0x20) {
6827 temp = (tempbl >> 4) & 0x02;
6829 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6833 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6835 temp = XG21GPIODataTransfer(temp);
6838 XGINew_SetReg1(pVBInfo->P3d4, 0x48, temp);
6841 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6842 struct vb_device_info *pVBInfo)
6844 unsigned char CR4A, temp;
6845 unsigned short tempbh0, tempbl0;
6854 if (tempbh & 0x20) {
6855 temp = (tempbl >> 4) & 0x02;
6857 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6860 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
6862 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6866 tempbl <<= 2; /* GPIOC,GPIOD */
6867 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6868 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
6871 /* --------------------------------------------------------------------- */
6872 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
6874 unsigned short index;
6876 index = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
6877 if (index < sizeof(XGI21_LCDCapList)
6878 / sizeof(struct XGI21_LVDSCapStruct))
6883 /* --------------------------------------------------------------------- */
6884 /* Function : XGI_XG21SetPanelDelay */
6888 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6889 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6890 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6891 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6892 /* --------------------------------------------------------------------- */
6893 void XGI_XG21SetPanelDelay(unsigned short tempbl,
6894 struct vb_device_info *pVBInfo)
6896 unsigned short index;
6898 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6900 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S1,
6904 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S2,
6908 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S3,
6912 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S4,
6916 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
6917 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6919 unsigned short xres, yres, colordepth, modeflag, resindex,
6922 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6923 if (ModeNo <= 0x13) {
6924 xres = pVBInfo->StResInfo[resindex].HTotal;
6925 yres = pVBInfo->StResInfo[resindex].VTotal;
6926 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6928 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6929 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6930 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6933 if (!(modeflag & Charx8Dot)) {
6938 if (ModeNo > 0x13) {
6939 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6942 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6947 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6948 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6951 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6954 if (ModeNo > 0x13) {
6956 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6958 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
6959 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
6969 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
6973 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6974 temp = (temp & 1) << 6;
6975 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
6976 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6980 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
6984 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6985 temp = (temp & 3) << 6;
6986 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6987 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6991 void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6992 struct vb_device_info *pVBInfo)
6994 unsigned char temp, Miscdata;
6995 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6996 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6997 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6998 unsigned short value;
7000 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
7002 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7003 & (LCDPolarity << 8)) >> 8);
7004 temp &= LCDPolarity;
7005 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
7007 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
7009 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7011 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7012 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
7014 XGI_SetXG21FPBits(pVBInfo);
7015 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7016 if (ModeNo <= 0x13) {
7017 xres = pVBInfo->StResInfo[resindex].HTotal;
7018 yres = pVBInfo->StResInfo[resindex].VTotal;
7019 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7021 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7022 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7023 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7026 if (!(modeflag & Charx8Dot))
7027 xres = xres * 8 / 9;
7029 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
7031 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7033 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7034 LVDSHBS -= xres / 4;
7036 if (LVDSHBS > LVDSHT)
7039 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7040 if (LVDSHRS > LVDSHT)
7043 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7044 if (LVDSHRE > LVDSHT)
7047 LVDSHBE = LVDSHBS + LVDSHT
7048 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
7050 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
7052 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7054 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7055 LVDSVBS += yres / 2;
7057 if (LVDSVBS > LVDSVT)
7060 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7061 if (LVDSVRS > LVDSVT)
7064 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7065 if (LVDSVRE > LVDSVT)
7068 LVDSVBE = LVDSVBS + LVDSVT
7069 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
7071 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7072 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
7074 if (!(modeflag & Charx8Dot))
7075 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
7077 /* HT SR0B[1:0] CR00 */
7078 value = (LVDSHT >> 3) - 5;
7079 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7080 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
7082 /* HBS SR0B[5:4] CR02 */
7083 value = (LVDSHBS >> 3) - 1;
7084 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7085 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
7087 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7088 value = (LVDSHBE >> 3) - 1;
7089 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7090 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7091 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
7093 /* HRS SR0B[7:6] CR04 */
7094 value = (LVDSHRS >> 3) + 2;
7095 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7096 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
7098 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7100 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7101 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
7103 /* HRE SR0C[2] CR05[4:0] */
7104 value = (LVDSHRE >> 3) + 2;
7105 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7106 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
7108 /* Panel HRE SR2F[7:2] */
7110 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
7112 /* VT SR0A[0] CR07[5][0] CR06 */
7114 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7115 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7116 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7117 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
7119 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7120 value = LVDSVBS - 1;
7121 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7122 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7123 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7124 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
7126 /* VBE SR0A[4] CR16 */
7127 value = LVDSVBE - 1;
7128 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7129 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
7131 /* VRS SR0A[3] CR7[7][2] CR10 */
7132 value = LVDSVRS - 1;
7133 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7134 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7135 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7136 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
7138 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
7139 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
7140 XGINew_SetReg1(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
7141 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
7143 /* VRE SR0A[5] CR11[3:0] */
7144 value = LVDSVRE - 1;
7145 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7146 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
7148 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
7149 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
7151 for (temp = 0, value = 0; temp < 3; temp++) {
7153 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7154 XGINew_SetReg1(pVBInfo->P3c4,
7156 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7157 XGINew_SetReg1(pVBInfo->P3c4,
7159 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7163 if (!(modeflag & Charx8Dot)) {
7164 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7165 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7166 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
7168 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7169 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7171 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7176 /* no shadow case */
7177 void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
7178 struct vb_device_info *pVBInfo)
7180 unsigned char temp, Miscdata;
7181 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
7182 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
7183 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
7184 unsigned short value;
7186 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
7187 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7188 & (LCDPolarity << 8)) >> 8);
7189 temp &= LCDPolarity;
7190 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
7192 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
7194 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7196 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7197 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
7199 XGI_SetXG27FPBits(pVBInfo);
7200 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7201 if (ModeNo <= 0x13) {
7202 xres = pVBInfo->StResInfo[resindex].HTotal;
7203 yres = pVBInfo->StResInfo[resindex].VTotal;
7204 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7206 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7207 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7208 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7211 if (!(modeflag & Charx8Dot))
7212 xres = xres * 8 / 9;
7214 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
7216 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7218 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7219 LVDSHBS -= xres / 4;
7221 if (LVDSHBS > LVDSHT)
7224 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7225 if (LVDSHRS > LVDSHT)
7228 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7229 if (LVDSHRE > LVDSHT)
7232 LVDSHBE = LVDSHBS + LVDSHT
7233 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
7235 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
7237 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7239 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7240 LVDSVBS += yres / 2;
7242 if (LVDSVBS > LVDSVT)
7245 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7246 if (LVDSVRS > LVDSVT)
7249 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7250 if (LVDSVRE > LVDSVT)
7253 LVDSVBE = LVDSVBS + LVDSVT
7254 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
7256 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7257 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
7259 if (!(modeflag & Charx8Dot))
7260 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
7262 /* HT SR0B[1:0] CR00 */
7263 value = (LVDSHT >> 3) - 5;
7264 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7265 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
7267 /* HBS SR0B[5:4] CR02 */
7268 value = (LVDSHBS >> 3) - 1;
7269 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7270 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
7272 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7273 value = (LVDSHBE >> 3) - 1;
7274 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7275 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7276 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
7278 /* HRS SR0B[7:6] CR04 */
7279 value = (LVDSHRS >> 3) + 2;
7280 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7281 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
7283 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7285 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7286 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
7288 /* HRE SR0C[2] CR05[4:0] */
7289 value = (LVDSHRE >> 3) + 2;
7290 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7291 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
7293 /* Panel HRE SR2F[7:2] */
7295 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
7297 /* VT SR0A[0] CR07[5][0] CR06 */
7299 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7300 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7301 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7302 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
7304 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7305 value = LVDSVBS - 1;
7306 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7307 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7308 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7309 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
7311 /* VBE SR0A[4] CR16 */
7312 value = LVDSVBE - 1;
7313 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7314 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
7316 /* VRS SR0A[3] CR7[7][2] CR10 */
7317 value = LVDSVRS - 1;
7318 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7319 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7320 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7321 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
7323 /* Panel VRS SR35[2:0] SR34[7:0] */
7324 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
7325 XGINew_SetReg1(pVBInfo->P3c4, 0x34, value & 0xFF);
7327 /* VRE SR0A[5] CR11[3:0] */
7328 value = LVDSVRE - 1;
7329 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7330 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
7332 /* Panel VRE SR3F[7:2] */
7333 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
7335 for (temp = 0, value = 0; temp < 3; temp++) {
7337 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7338 XGINew_SetReg1(pVBInfo->P3c4,
7340 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7341 XGINew_SetReg1(pVBInfo->P3c4,
7343 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7347 if (!(modeflag & Charx8Dot)) {
7348 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7349 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7350 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
7352 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7353 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7355 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7360 /* --------------------------------------------------------------------- */
7361 /* Function : XGI_IsLCDON */
7363 /* Output : 0 : Skip PSC Control */
7364 /* 1: Disable PSC */
7366 /* --------------------------------------------------------------------- */
7367 unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
7369 unsigned short tempax;
7371 tempax = pVBInfo->VBInfo;
7372 if (tempax & SetCRT2ToDualEdge)
7374 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
7380 void XGI_EnablePWD(struct vb_device_info *pVBInfo)
7382 unsigned short index, temp;
7384 index = XGI_GetLCDCapPtr(pVBInfo);
7385 temp = pVBInfo->LCDCapList[index].PWD_2B;
7386 XGINew_SetReg1(pVBInfo->Part4Port, 0x2B, temp);
7387 XGINew_SetReg1(pVBInfo->Part4Port, 0x2C,
7388 pVBInfo->LCDCapList[index].PWD_2C);
7389 XGINew_SetReg1(pVBInfo->Part4Port, 0x2D,
7390 pVBInfo->LCDCapList[index].PWD_2D);
7391 XGINew_SetReg1(pVBInfo->Part4Port, 0x2E,
7392 pVBInfo->LCDCapList[index].PWD_2E);
7393 XGINew_SetReg1(pVBInfo->Part4Port, 0x2F,
7394 pVBInfo->LCDCapList[index].PWD_2F);
7395 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x80); /* enable PWD */
7398 void XGI_DisablePWD(struct vb_device_info *pVBInfo)
7400 XGINew_SetRegAND(pVBInfo->Part4Port, 0x27, 0x7F); /* disable PWD */
7403 /* --------------------------------------------------------------------- */
7404 /* Function : XGI_DisableChISLCD */
7406 /* Output : 0 -> Not LCD Mode */
7408 /* --------------------------------------------------------------------- */
7409 unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
7411 unsigned short tempbx, tempah;
7413 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
7414 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
7416 if (tempbx & (EnableChA | DisableChA)) {
7417 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7421 if (!(tempbx & (EnableChB | DisableChB)))
7424 if (tempah & 0x01) /* Chk LCDB Mode */
7430 /* --------------------------------------------------------------------- */
7431 /* Function : XGI_EnableChISLCD */
7433 /* Output : 0 -> Not LCD mode */
7435 /* --------------------------------------------------------------------- */
7436 unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
7438 unsigned short tempbx, tempah;
7440 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
7441 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
7443 if (tempbx & (EnableChA | DisableChA)) {
7444 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7448 if (!(tempbx & (EnableChB | DisableChB)))
7451 if (tempah & 0x01) /* Chk LCDB Mode */
7457 unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
7459 unsigned char tempal, tempah, tempbl, i;
7461 tempah = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
7462 tempal = tempah & 0x0F;
7463 tempah = tempah & 0xF0;
7465 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7467 while (tempbl != 0xFF) {
7468 if (tempbl & 0x80) { /* OEMUtil */
7470 tempbl = tempbl & ~(0x80);
7473 if (tempal == tempbl)
7478 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7484 unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
7486 unsigned short tempah, tempal, tempbl, i;
7488 tempal = pVBInfo->LCDResInfo;
7489 tempah = pVBInfo->LCDTypeInfo;
7492 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7494 while (tempbl != 0xFF) {
7495 if ((tempbl & 0x80) && (tempbl != 0x80)) {
7500 if (tempal == tempbl)
7504 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7507 if (tempbl == 0xFF) {
7508 pVBInfo->LCDResInfo = Panel1024x768;
7509 pVBInfo->LCDTypeInfo = 0;
7516 void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
7517 struct vb_device_info *pVBInfo)
7519 unsigned short Index;
7521 Index = XGI_GetLCDCapPtr(pVBInfo);
7522 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
7523 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
7528 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7529 struct vb_device_info *pVBInfo)
7531 unsigned short tempbl, tempah;
7533 if (pVBInfo->SetFlag == Win9xDOSMode) {
7534 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7535 | VB_XGI302LV | VB_XGI301C)) {
7536 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7539 /* LVDS or CH7017 */
7543 if (HwDeviceExtension->jChipType < XG40) {
7544 if (!XGI_DisableChISLCD(pVBInfo)) {
7545 if ((XGI_EnableChISLCD(pVBInfo)) || (pVBInfo->VBInfo
7546 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
7547 if (pVBInfo->LCDInfo & SetPWDEnable) {
7548 XGI_EnablePWD(pVBInfo);
7550 pVBInfo->LCDInfo &= (~SetPWDEnable);
7551 if (pVBInfo->VBType & (VB_XGI301LV
7561 XGI_SetPanelPower(tempah, tempbl,
7563 XGI_SetPanelDelay(1, pVBInfo);
7569 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7570 | VB_XGI302LV | VB_XGI301C)) {
7571 if (!(pVBInfo->SetFlag & DisableChA)) {
7572 if (pVBInfo->SetFlag & EnableChA) {
7573 XGINew_SetReg1(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
7575 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
7576 XGINew_SetReg1(pVBInfo->Part1Port,
7577 0x1E, 0x20); /* Power on */
7582 if (!(pVBInfo->SetFlag & DisableChB)) {
7583 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
7584 & (SetCRT2ToLCD | SetCRT2ToTV
7585 | SetCRT2ToRAMDAC))) {
7586 tempah = (unsigned char) XGINew_GetReg1(
7587 pVBInfo->P3c4, 0x32);
7589 if (pVBInfo->VBInfo & SetInSlaveMode) {
7590 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
7593 XGINew_SetReg1(pVBInfo->P3c4, 0x32, tempah);
7594 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x20);
7596 tempah = (unsigned char) XGINew_GetReg1(
7597 pVBInfo->Part1Port, 0x2E);
7599 if (!(tempah & 0x80))
7600 XGINew_SetRegOR(pVBInfo->Part1Port,
7601 0x2E, 0x80); /* BVBDOENABLE = 1 */
7603 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
7607 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
7608 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
7609 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x00, ~0xE0,
7610 0x20); /* shampoo 0129 */
7611 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7612 if (!XGI_DisableChISLCD(pVBInfo)) {
7613 if (XGI_EnableChISLCD(pVBInfo)
7619 0x2A, 0x7F); /* LVDS PLL power on */
7621 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
7627 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7630 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
7631 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7632 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7633 tempah = tempah & 0x40;
7636 tempah = tempah ^ 0xC0;
7638 if (pVBInfo->SetFlag
7642 if (pVBInfo->SetFlag
7646 if (pVBInfo->SetFlag
7650 if (pVBInfo->SetFlag
7658 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
7660 if (pVBInfo->SetFlag & Win9xDOSMode) {
7661 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7665 if (!(pVBInfo->SetFlag & DisableChA)) {
7666 XGI_VBLongWait(pVBInfo);
7667 if (!(pVBInfo->SetFlag & GatingCRT)) {
7668 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
7669 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7670 XGI_VBLongWait(pVBInfo);
7675 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
7677 XGINew_SetRegOR(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
7679 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->Part1Port,
7681 if (!(tempah & 0x80))
7682 XGINew_SetRegOR(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
7684 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F);
7685 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7688 if (HwDeviceExtension->jChipType < XG40) {
7689 if (!XGI_EnableChISLCD(pVBInfo)) {
7690 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7691 if (XGI_BacklightByDrv(pVBInfo))
7697 if (pVBInfo->LCDInfo & SetPWDEnable) {
7698 XGI_FirePWDEnable(pVBInfo);
7702 XGI_SetPanelDelay(2, pVBInfo);
7704 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
7706 tempbl = 0xFE; /* turn on backlght */
7711 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7715 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7716 struct vb_device_info *pVBInfo)
7718 unsigned short tempax, tempbx, tempah = 0, tempbl = 0;
7720 if (pVBInfo->SetFlag == Win9xDOSMode)
7723 if (HwDeviceExtension->jChipType < XG40) {
7724 if ((!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7725 || (XGI_DisableChISLCD(pVBInfo))) {
7726 if (!XGI_IsLCDON(pVBInfo)) {
7727 if (pVBInfo->LCDInfo & SetPWDEnable)
7728 XGI_EnablePWD(pVBInfo);
7730 pVBInfo->LCDInfo &= ~SetPWDEnable;
7731 XGI_DisablePWD(pVBInfo);
7732 if (pVBInfo->VBType & (VB_XGI301LV
7735 tempbx = 0xFE; /* not 01h */
7738 tempbx = 0xF7; /* not 08h */
7741 XGI_SetPanelPower(tempax, tempbx,
7743 XGI_SetPanelDelay(3, pVBInfo);
7745 } /* end if (!XGI_IsLCDON(pVBInfo)) */
7751 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
7752 if (!XGI_IsLCDON(pVBInfo)) {
7754 tempbx = XGINew_GetCH7005(0x61);
7755 if (tempbx < 0x01) // first time we power up
7756 XGINew_SetCH7005(0x0066); // and disable power sequence
7758 XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
7765 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7766 | VB_XGI302LV | VB_XGI301C)) {
7768 if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
7769 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7770 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7771 tempah = 0x7F; /* Disable Channel A */
7772 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7773 tempah = 0xBF; /* Disable Channel B */
7775 if (pVBInfo->SetFlag & DisableChB)
7776 tempah &= 0xBF; /* force to disable Cahnnel */
7778 if (pVBInfo->SetFlag & DisableChA)
7779 tempah &= 0x7F; /* Force to disable Channel B */
7784 XGINew_SetRegAND(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
7786 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7787 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7788 || (XGI_DisableChISLCD(pVBInfo))
7789 || (XGI_IsLCDON(pVBInfo)))
7790 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
7793 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7794 & (DisableCRT2Display | SetCRT2ToLCDA
7795 | SetSimuScanMode))) {
7796 if (pVBInfo->SetFlag & GatingCRT)
7797 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
7798 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7801 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7802 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7804 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
7807 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
7809 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
7810 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xdf);
7812 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7813 & (DisableCRT2Display | SetSimuScanMode))
7814 || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7819 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7821 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7822 & (DisableCRT2Display | SetSimuScanMode))
7823 || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7824 || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7825 | SetCRT2ToLCD | SetCRT2ToTV))) {
7826 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
7827 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
7828 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
7829 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
7831 } else { /* {301} */
7832 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
7833 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7834 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
7835 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
7838 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
7840 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7843 if (HwDeviceExtension->jChipType < XG40) {
7844 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7845 || (XGI_DisableChISLCD(pVBInfo))
7846 || (XGI_IsLCDON(pVBInfo))) {
7847 if (pVBInfo->LCDInfo & SetPWDEnable) {
7848 if (pVBInfo->LCDInfo & SetPWDEnable)
7849 XGI_BacklightByDrv(pVBInfo);
7851 XGI_SetPanelDelay(4, pVBInfo);
7852 if (pVBInfo->VBType & VB_XGI301LV) {
7861 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7866 /* --------------------------------------------------------------------- */
7867 /* Function : XGI_GetTVPtrIndex */
7870 /* Description : bx 0 : ExtNTSC */
7882 /* --------------------------------------------------------------------- */
7883 unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
7885 unsigned short tempbx = 0;
7887 if (pVBInfo->TVInfo & SetPALTV)
7889 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7891 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7893 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7895 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7897 if (pVBInfo->TVInfo & TVSimuMode)
7903 /* --------------------------------------------------------------------- */
7904 /* Function : XGI_OEM310Setting */
7907 /* Description : Customized Param. for 301 */
7908 /* --------------------------------------------------------------------- */
7909 void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
7910 struct vb_device_info *pVBInfo)
7912 if (pVBInfo->SetFlag & Win9xDOSMode)
7916 XGI_SetDelayComp(pVBInfo);
7918 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7919 XGI_SetLCDCap(pVBInfo);
7921 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7923 XGI_SetPhaseIncr(pVBInfo);
7924 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7925 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
7927 if (pVBInfo->VBType & VB_XGI301)
7928 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7932 void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
7934 unsigned short index;
7936 unsigned char tempah, tempbl, tempbh;
7938 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7939 | VB_XGI302LV | VB_XGI301C)) {
7940 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7941 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7945 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7946 tempbl = pVBInfo->XGI_TVDelayList[index];
7948 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7949 | VB_XGI301LV | VB_XGI302LV
7951 tempbl = pVBInfo->XGI_TVDelayList2[index];
7953 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7954 tempbl = tempbl >> 4;
7956 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7957 tempbl = CRT2Delay1; // Get CRT2 Delay
7958 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
7959 tempbl = CRT2Delay2;
7961 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7962 index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
7963 tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
7965 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7971 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x2D);
7973 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7974 | SetCRT2ToTV)) { /* Channel B */
7979 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7983 XGINew_SetReg1(pVBInfo->Part1Port, 0x2D, tempah);
7985 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7988 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7990 = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
7991 pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
7993 tempah = tempah << 4;
7994 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2D, 0x0f,
8000 void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
8002 unsigned short tempcx;
8004 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
8006 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8007 | VB_XGI302LV | VB_XGI301C)) {
8008 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
8009 /* Set 301LV Capability */
8010 XGINew_SetReg1(pVBInfo->Part4Port, 0x24,
8011 (unsigned char) (tempcx & 0x1F));
8014 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
8015 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
8016 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
8017 | EnablePLLSPLOW)) >> 8));
8020 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8021 | VB_XGI302LV | VB_XGI301C)) {
8022 if (pVBInfo->VBInfo & SetCRT2ToLCD)
8023 XGI_SetLCDCap_B(tempcx, pVBInfo);
8024 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8025 XGI_SetLCDCap_A(tempcx, pVBInfo);
8027 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8028 if (tempcx & EnableSpectrum)
8029 SetSpectrum(pVBInfo);
8033 XGI_SetLCDCap_A(tempcx, pVBInfo);
8037 void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
8039 unsigned short temp;
8041 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
8043 if (temp & LCDRGB18Bit) {
8044 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
8045 (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
8046 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
8048 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
8049 (unsigned short) (0x30 | (tempcx & 0x00C0)));
8050 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
8054 if (tempcx & EnableLCD24bpp) { // 24bits
8055 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
8056 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
8058 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
8059 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
8064 /* --------------------------------------------------------------------- */
8065 /* Function : XGI_SetLCDCap_B */
8066 /* Input : cx -> LCD Capability */
8069 /* --------------------------------------------------------------------- */
8070 void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
8072 if (tempcx & EnableLCD24bpp) /* 24bits */
8073 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8074 (unsigned short) (((tempcx & 0x00ff) >> 6)
8077 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8078 (unsigned short) (((tempcx & 0x00ff) >> 6)
8079 | 0x18)); /* Enable Dither */
8082 void SetSpectrum(struct vb_device_info *pVBInfo)
8084 unsigned short index;
8086 index = XGI_GetLCDCapPtr(pVBInfo);
8088 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
8089 XGI_LongWait(pVBInfo);
8090 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
8091 XGI_LongWait(pVBInfo);
8093 XGINew_SetReg1(pVBInfo->Part4Port, 0x31,
8094 pVBInfo->LCDCapList[index].Spectrum_31);
8095 XGINew_SetReg1(pVBInfo->Part4Port, 0x32,
8096 pVBInfo->LCDCapList[index].Spectrum_32);
8097 XGINew_SetReg1(pVBInfo->Part4Port, 0x33,
8098 pVBInfo->LCDCapList[index].Spectrum_33);
8099 XGINew_SetReg1(pVBInfo->Part4Port, 0x34,
8100 pVBInfo->LCDCapList[index].Spectrum_34);
8101 XGI_LongWait(pVBInfo);
8102 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
8105 /* --------------------------------------------------------------------- */
8106 /* Function : XGI_SetAntiFlicker */
8109 /* Description : Set TV Customized Param. */
8110 /* --------------------------------------------------------------------- */
8111 void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
8112 struct vb_device_info *pVBInfo)
8114 unsigned short tempbx, index;
8116 unsigned char tempah;
8118 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
8121 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8125 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
8127 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
8130 tempah = TVAntiFlickList[tempbx];
8131 tempah = tempah << 4;
8133 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
8136 void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
8137 struct vb_device_info *pVBInfo)
8139 unsigned short tempbx, index;
8141 unsigned char tempah;
8143 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8147 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
8149 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
8152 tempah = TVEdgeList[tempbx];
8153 tempah = tempah << 5;
8155 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
8158 void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
8160 unsigned short tempbx;
8162 unsigned char tempcl, tempch;
8164 unsigned long tempData;
8166 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
8167 tempData = TVPhaseList[tempbx];
8169 XGINew_SetReg1(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
8171 XGINew_SetReg1(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
8172 & 0x0000FF00) >> 8));
8173 XGINew_SetReg1(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
8174 & 0x00FF0000) >> 16));
8175 XGINew_SetReg1(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
8176 & 0xFF000000) >> 24));
8179 void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
8180 struct vb_device_info *pVBInfo)
8182 unsigned short tempbx, index;
8184 unsigned char tempcl, tempch, tempal, *filterPtr;
8186 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
8191 filterPtr = NTSCYFilter1;
8195 filterPtr = PALYFilter1;
8201 filterPtr = PALMYFilter1;
8205 filterPtr = PALNYFilter1;
8210 filterPtr = NTSCYFilter2;
8214 filterPtr = PALMYFilter2;
8218 filterPtr = PALNYFilter2;
8222 filterPtr = PALYFilter2;
8230 tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
8233 = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
8240 if ((tempcl == 0) && (tempch == 1)) {
8241 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, 0);
8242 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, 0);
8243 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, 0);
8244 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8246 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
8247 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
8248 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
8249 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8252 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8253 | VB_XGI302LV | VB_XGI301C)) {
8254 XGINew_SetReg1(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
8255 XGINew_SetReg1(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
8256 XGINew_SetReg1(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
8260 /* --------------------------------------------------------------------- */
8261 /* Function : XGI_GetTVPtrIndex2 */
8263 /* Output : bx 0 : NTSC */
8267 /* 4 : NTSC1024x768 */
8268 /* 5 : PAL-M 1024x768 */
8270 /* cl 0 : YFilter1 */
8273 /* 1 : 301B/302B/301LV/302LV */
8275 /* --------------------------------------------------------------------- */
8276 void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
8277 unsigned char *tempch, struct vb_device_info *pVBInfo)
8283 if (pVBInfo->TVInfo & SetPALTV)
8286 if (pVBInfo->TVInfo & SetPALMTV)
8289 if (pVBInfo->TVInfo & SetPALNTV)
8292 if (pVBInfo->TVInfo & NTSC1024x768) {
8294 if (pVBInfo->TVInfo & SetPALMTV)
8298 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8299 | VB_XGI302LV | VB_XGI301C)) {
8300 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
8307 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8308 | VB_XGI302LV | VB_XGI301C))
8312 /* --------------------------------------------------------------------- */
8313 /* Function : XGI_SetCRT2ModeRegs */
8316 /* Description : Origin code for crt2group */
8317 /* --------------------------------------------------------------------- */
8318 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
8319 struct xgi_hw_device_info *HwDeviceExtension,
8320 struct vb_device_info *pVBInfo)
8322 unsigned short tempbl;
8325 unsigned char tempah;
8327 /* XGINew_SetReg1(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
8329 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8330 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00);
8331 tempah &= ~0x10; /* BTRAMDAC */
8332 tempah |= 0x40; /* BTRAM */
8334 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8336 tempah = 0x40; /* BTDRAM */
8337 if (ModeNo > 0x13) {
8338 tempcl = pVBInfo->ModeType;
8341 tempah = (0x008 >> tempcl); /* BT Color */
8347 if (pVBInfo->VBInfo & SetInSlaveMode)
8348 tempah ^= 0x50; /* BTDAC */
8353 if (pVBInfo->VBInfo & DisableCRT2Display) {
8357 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8358 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
8359 tempcl = pVBInfo->ModeType;
8360 if (ModeNo > 0x13) {
8362 if ((tempcl > 0) || (tempcl == 0)) {
8363 tempah=(0x008>>tempcl) ;
8372 if (pVBInfo->VBInfo & SetInSlaveMode) {
8373 tempah = (tempah ^ 0x050);
8378 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8382 if (pVBInfo->VBInfo & DisableCRT2Display) {
8383 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
8388 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8389 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
8390 if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
8391 && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
8394 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e,
8397 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8402 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
8403 | SetCRT2ToTV | SetCRT2ToLCD)) {
8407 if (!(pVBInfo->VBInfo & SetInSlaveMode))
8410 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
8411 tempah = tempah ^ 0x05;
8412 if (!(pVBInfo->VBInfo
8414 tempah = tempah ^ 0x01;
8417 if (!(pVBInfo->VBInfo
8418 & SetCRT2ToDualEdge))
8420 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8421 0x2e, tempbl, tempah);
8423 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8424 0x2e, tempbl, tempah);
8428 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl,
8433 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
8436 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
8437 & SetInSlaveMode))) {
8442 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8443 /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
8445 if (ModeNo > 0x13) {
8446 if (pVBInfo->VBInfo & DriverMode)
8447 tempah = tempah ^ 0x20;
8452 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
8455 if (pVBInfo->LCDInfo & SetLCDDualLink)
8458 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8459 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
8460 if (pVBInfo->TVInfo & RPLLDIV2XO)
8465 if ((pVBInfo->LCDResInfo == Panel1280x1024)
8466 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
8469 if (pVBInfo->LCDResInfo == Panel1280x960)
8472 XGINew_SetReg1(pVBInfo->Part4Port, 0x0C, tempah);
8475 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8476 | VB_XGI302LV | VB_XGI301C)) {
8480 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8482 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8483 tempah |= 0x04; /* shampoo 0129 */
8486 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x13, tempbl, tempah);
8489 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8490 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8494 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
8498 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8499 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8502 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, tempbl, tempah);
8507 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
8509 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
8513 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x23, tempbl, tempah);
8515 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8516 if (pVBInfo->LCDInfo & SetLCDDualLink) {
8517 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x20);
8518 XGINew_SetRegOR(pVBInfo->Part4Port, 0x34, 0x10);
8523 void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8524 struct vb_device_info *pVBInfo)
8526 unsigned short tempbx;
8530 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8535 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8536 struct vb_device_info *pVBInfo)
8538 unsigned short tempbx;
8542 void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
8543 unsigned short RefreshRateTableIndex,
8544 struct vb_device_info *pVBInfo)
8546 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
8547 StandTableIndex, CRT1Index;
8549 pVBInfo->RVBHCMAX = 1;
8550 pVBInfo->RVBHCFACT = 1;
8552 if (ModeNo <= 0x13) {
8553 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8554 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8555 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
8556 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
8557 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
8559 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8561 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
8562 CRT1Index &= IndexMask;
8564 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
8566 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
8567 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
8569 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
8571 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
8574 tempcx = tempcx << 2;
8577 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
8587 if (modeflag & Charx8Dot)
8592 pVBInfo->VGAHT = tempax;
8593 pVBInfo->HT = tempax;
8595 pVBInfo->VGAVT = tempbx;
8596 pVBInfo->VT = tempbx;
8599 unsigned short XGI_GetColorDepth(unsigned short ModeNo,
8600 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
8602 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
8604 unsigned short modeflag;
8607 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8609 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8611 index = (modeflag & ModeInfoFlag) - ModeEGA;
8616 return ColorDepth[index];
8619 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8620 struct vb_device_info *pVBInfo)
8623 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
8627 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8628 struct vb_device_info *pVBInfo)
8631 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
8635 void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
8637 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
8640 void XGINew_LCD_Wait_Time(unsigned char DelayTime,
8641 struct vb_device_info *pVBInfo)
8643 unsigned short i, j;
8645 unsigned long temp, flag;
8648 /* printk("XGINew_LCD_Wait_Time"); */
8650 for (i = 0; i < DelayTime; i++) {
8651 for (j = 0; j < 66; j++) {
8652 temp = XGINew_GetReg3(0x61);
8653 /* temp &= 0x10000000; */
8663 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
8665 unsigned short flag;
8667 if (pVBInfo->IF_DEF_LVDS == 1) {
8670 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
8671 if ((flag == 1) || (flag == 2))
8672 return 1; /* 301b */
8678 void XGI_LongWait(struct vb_device_info *pVBInfo)
8682 i = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
8685 for (i = 0; i < 0xFFFF; i++) {
8686 if (!(XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8690 for (i = 0; i < 0xFFFF; i++) {
8691 if ((XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8697 void XGI_VBLongWait(struct vb_device_info *pVBInfo)
8699 unsigned short tempal, temp, i, j;
8701 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
8703 for (i = 0; i < 3; i++) {
8704 for (j = 0; j < 100; j++) {
8705 tempal = XGINew_GetReg2(pVBInfo->P3da);
8706 if (temp & 0x01) { /* VBWaitMode2 */
8707 if ((tempal & 0x08))
8710 if (!(tempal & 0x08))
8713 } else { /* VBWaitMode1 */
8714 if (!(tempal & 0x08))
8717 if ((tempal & 0x08))
8724 XGI_LongWait(pVBInfo);
8729 unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
8731 unsigned long tempax, tempbx;
8733 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
8735 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
8736 tempax = (tempax * pVBInfo->HT) / tempbx;
8738 return (unsigned short) tempax;
8741 unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
8742 unsigned short ModeIdIndex,
8743 unsigned short RefreshRateTableIndex,
8744 struct xgi_hw_device_info *HwDeviceExtension,
8745 struct vb_device_info *pVBInfo)
8747 unsigned short tempbx;
8749 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8751 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
8752 VCLK108_2 + 5, VCLK108_2 + 5 };
8753 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
8754 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8756 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8759 unsigned short CRT2Index, VCLKIndex;
8760 unsigned short modeflag, resinfo;
8761 unsigned char *CHTVVCLKPtr = NULL;
8763 if (ModeNo <= 0x13) {
8764 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8765 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
8766 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
8768 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
8769 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
8771 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
8774 if (pVBInfo->IF_DEF_LVDS == 0) {
8775 CRT2Index = CRT2Index >> 6; /* for LCD */
8776 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
8777 if (pVBInfo->LCDResInfo != Panel1024x768)
8778 VCLKIndex = LCDXlat2VCLK[CRT2Index];
8780 VCLKIndex = LCDXlat1VCLK[CRT2Index];
8781 } else { /* for TV */
8782 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8783 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
8784 if (pVBInfo->SetFlag & RPLLDIV2XO) {
8785 VCLKIndex = HiTVVCLKDIV2;
8790 VCLKIndex = HiTVVCLK;
8796 if (pVBInfo->SetFlag & TVSimuMode) {
8797 if (modeflag & Charx8Dot) {
8812 if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
8813 if (!(pVBInfo->VBExtInfo
8814 == VB_YPbPr1080i)) {
8817 if (!(pVBInfo->VBExtInfo
8821 if (!(pVBInfo->VBExtInfo
8825 if (!(pVBInfo->SetFlag
8834 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8835 if (pVBInfo->SetFlag
8837 VCLKIndex = TVVCLKDIV2;
8849 } else { /* for CRT2 */
8850 VCLKIndex = (unsigned char) XGINew_GetReg2(
8851 (pVBInfo->P3ca + 0x02)); /* Port 3cch */
8852 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
8853 if (ModeNo > 0x13) {
8855 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
8856 VCLKIndex &= IndexMask;
8862 VCLKIndex = CRT2Index;
8864 VCLKIndex = CRT2Index;
8866 if (pVBInfo->IF_DEF_CH7005 == 1) {
8867 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
8871 if (pVBInfo->VBInfo & SetPALTV)
8874 if (pVBInfo->VBInfo & SetCHTVOverScan)
8879 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
8882 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
8885 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
8888 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
8894 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
8897 VCLKIndex = VCLKIndex >> 6;
8898 if ((pVBInfo->LCDResInfo == Panel800x600)
8899 || (pVBInfo->LCDResInfo == Panel320x480))
8900 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
8901 else if ((pVBInfo->LCDResInfo == Panel1024x768)
8902 || (pVBInfo->LCDResInfo
8903 == Panel1024x768x75))
8904 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
8906 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
8909 /* VCLKIndex = VCLKIndex&IndexMask; */