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)
3516 #ifdef LINUX /* chiawen for linux solution */
3520 if (ModeNo <= 0x13) {
3521 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
3522 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3523 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3525 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3530 (*ModeIdIndex)++; /* 400 lines */
3532 (*ModeIdIndex) += 2; /* 400 lines */
3533 /* else 350 lines */
3535 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
3536 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3537 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3539 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3549 /* win2000 MM adapter not support standard mode! */
3552 static unsigned char XGINew_CheckMemorySize(
3553 struct xgi_hw_device_info *HwDeviceExtension,
3554 unsigned short ModeNo,
3555 unsigned short ModeIdIndex,
3556 struct vb_device_info *pVBInfo)
3558 unsigned short memorysize, modeflag, temp, temp1, tmp;
3561 if ((HwDeviceExtension->jChipType == XGI_650) ||
3562 (HwDeviceExtension->jChipType == XGI_650M)) {
3568 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3570 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3572 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
3574 memorysize = modeflag & MemoryInfoFlag;
3575 memorysize = memorysize > MemorySizeShift;
3576 memorysize++; /* Get memory size */
3578 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
3581 if (HwDeviceExtension->jChipType == XG40) {
3582 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3583 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3585 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
3588 } else if (HwDeviceExtension->jChipType == XG42) {
3589 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3590 if ((tmp & 0x04) == 0x04) { /* Dual channels */
3593 } else if (HwDeviceExtension->jChipType == XG45) {
3594 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3595 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3597 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
3601 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
3605 if (temp < memorysize)
3613 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)
3615 unsigned short data ;
3616 unsigned short ModeFlag ;
3618 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3620 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
3622 if (ModeNo > 0x13) {
3623 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3624 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
3625 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3627 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
3628 data = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3630 XGINew_SetReg1(pVBInfo->P3c4, 0x01, data);
3636 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
3637 struct vb_device_info *pVBInfo)
3640 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3641 if (pXGIHWDE->jChipType == XG21) {
3642 if (pVBInfo->IF_DEF_LVDS == 1) {
3643 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3644 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3645 XGI_XG21SetPanelDelay(2, pVBInfo);
3647 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3648 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3649 XGI_XG21SetPanelDelay(3, pVBInfo);
3650 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3652 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3657 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
3661 if (pXGIHWDE->jChipType == XG27) {
3662 if (pVBInfo->IF_DEF_LVDS == 1) {
3663 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
3664 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3665 XGI_XG21SetPanelDelay(2, pVBInfo);
3667 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
3668 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3669 XGI_XG21SetPanelDelay(3, pVBInfo);
3670 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3672 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3678 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
3679 struct vb_device_info *pVBInfo)
3682 if (pXGIHWDE->jChipType == XG21) {
3683 if (pVBInfo->IF_DEF_LVDS == 1) {
3684 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3685 XGI_XG21SetPanelDelay(3, pVBInfo);
3687 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3691 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
3692 /* if (IsCH7007TVMode(pVBInfo) == 0) */
3697 if (pXGIHWDE->jChipType == XG27) {
3698 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
3699 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3700 XGI_XG21SetPanelDelay(3, pVBInfo);
3703 if (pVBInfo->IF_DEF_LVDS == 0)
3704 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3707 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
3710 void XGI_WaitDisply(struct vb_device_info *pVBInfo)
3712 while ((XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3715 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3719 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
3721 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
3722 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
3725 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
3727 unsigned char CR17, CR63, SR31;
3728 unsigned short temp;
3729 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
3732 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
3734 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
3735 XGINew_SetReg1(pVBInfo->P3d4, 0x57, 0x4A);
3736 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3737 pVBInfo->P3d4, 0x53) | 0x02));
3739 SR31 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x31);
3740 CR63 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x63);
3741 SR01 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3743 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
3744 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
3746 CR17 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x17);
3747 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
3749 SR1F = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
3750 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
3752 SR07 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x07);
3753 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
3754 SR06 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x06);
3755 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
3757 XGINew_SetReg1(pVBInfo->P3d4, 0x11, 0x00);
3759 for (i = 0; i < 8; i++)
3760 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
3762 for (i = 8; i < 11; i++)
3763 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 8),
3766 for (i = 11; i < 13; i++)
3767 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 4),
3770 for (i = 13; i < 16; i++)
3771 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i - 3),
3774 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
3777 XGINew_SetReg1(pVBInfo->P3c4, 0x31, 0x00);
3778 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
3779 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE1);
3781 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
3783 for (i = 0; i < 256; i++) {
3784 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3785 (unsigned char) DAC_TEST_PARMS[0]);
3786 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3787 (unsigned char) DAC_TEST_PARMS[1]);
3788 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3789 (unsigned char) DAC_TEST_PARMS[2]);
3792 XGI_VBLongWait(pVBInfo);
3793 XGI_VBLongWait(pVBInfo);
3794 XGI_VBLongWait(pVBInfo);
3796 XGINew_LCD_Wait_Time(0x01, pVBInfo);
3798 XGI_WaitDisply(pVBInfo);
3799 temp = XGINew_GetReg2(pVBInfo->P3c2);
3802 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
3804 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
3806 /* alan, avoid display something, set BLACK DAC if not restore DAC */
3807 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
3809 for (i = 0; i < 256; i++) {
3810 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3811 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3812 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3815 XGINew_SetReg1(pVBInfo->P3c4, 0x01, SR01);
3816 XGINew_SetReg1(pVBInfo->P3d4, 0x63, CR63);
3817 XGINew_SetReg1(pVBInfo->P3c4, 0x31, SR31);
3819 /* [2004/05/11] Vicent */
3820 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3821 pVBInfo->P3d4, 0x53) & 0xFD));
3822 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
3826 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
3828 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01));
3829 while (XGINew_GetReg2(pVBInfo->P3da) & 0x01);
3833 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
3834 struct xgi_hw_device_info *HwDeviceExtension,
3835 struct vb_device_info *pVBInfo)
3837 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
3839 tempbx = pVBInfo->VBInfo;
3840 pVBInfo->SetFlag |= ProgrammingCRT2;
3841 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
3842 pVBInfo->SelectCRT2Rate = 4;
3843 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
3844 ModeIdIndex, pVBInfo);
3845 XGI_SaveCRT2Info(ModeNo, pVBInfo);
3846 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
3847 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3848 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3849 RefreshRateTableIndex, pVBInfo);
3850 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3851 RefreshRateTableIndex, pVBInfo);
3852 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3853 RefreshRateTableIndex, pVBInfo);
3854 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3855 HwDeviceExtension, pVBInfo);
3856 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3857 RefreshRateTableIndex, pVBInfo);
3858 XGI_SetTap4Regs(pVBInfo);
3859 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
3860 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3861 HwDeviceExtension, pVBInfo);
3862 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3863 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
3864 XGI_AutoThreshold(pVBInfo);
3868 void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
3870 if (!(pVBInfo->SetFlag & Win9xDOSMode))
3871 XGINew_SetRegOR(pVBInfo->Part1Port, 0x01, 0x40);
3874 void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
3876 unsigned short temp1, temp2;
3878 XGINew_SetReg1(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
3879 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
3880 temp2 = ~(SetInSlaveMode >> 8);
3881 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, temp2, temp1);
3884 void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3885 struct vb_device_info *pVBInfo)
3887 unsigned short xres, yres, modeflag, resindex;
3889 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
3890 if (ModeNo <= 0x13) {
3891 xres = pVBInfo->StResInfo[resindex].HTotal;
3892 yres = pVBInfo->StResInfo[resindex].VTotal;
3893 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
3895 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
3896 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
3897 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
3900 if (pVBInfo->IF_DEF_FSTN) {
3905 if (modeflag & HalfDCLK)
3908 if (modeflag & DoubleScanMode)
3913 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3914 if (pVBInfo->IF_DEF_LVDS == 0) {
3915 if (pVBInfo->LCDResInfo == Panel1600x1200) {
3916 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3922 if (pVBInfo->LCDResInfo == Panel1280x1024) {
3925 else if (yres == 350)
3928 if (pVBInfo->LCDInfo & LCDVESATiming) {
3934 if (pVBInfo->LCDResInfo == Panel1024x768) {
3935 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3936 if (!(pVBInfo->LCDInfo
3937 & LCDNonExpanding)) {
3940 else if (yres == 400)
3942 else if (yres == 480)
3953 pVBInfo->VGAHDE = xres;
3954 pVBInfo->HDE = xres;
3955 pVBInfo->VGAVDE = yres;
3956 pVBInfo->VDE = yres;
3959 unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
3962 if ((((pVBInfo->VBInfo & SetCRT2ToLCD) | SetCRT2ToLCDA))
3963 && (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
3969 void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
3970 unsigned short RefreshRateTableIndex,
3971 struct vb_device_info *pVBInfo)
3973 unsigned short tempax = 0, tempbx, modeflag, resinfo;
3975 struct XGI_LCDDataStruct *LCDPtr = NULL;
3976 struct XGI_TVDataStruct *TVPtr = NULL;
3978 if (ModeNo <= 0x13) {
3979 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
3980 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
3982 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
3983 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3986 pVBInfo->NewFlickerMode = 0;
3987 pVBInfo->RVBHRS = 50;
3989 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3990 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3997 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3998 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
3999 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4002 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
4003 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
4004 pVBInfo->VGAHT = LCDPtr->VGAHT;
4005 pVBInfo->VGAVT = LCDPtr->VGAVT;
4006 pVBInfo->HT = LCDPtr->LCDHT;
4007 pVBInfo->VT = LCDPtr->LCDVT;
4009 if (pVBInfo->LCDResInfo == Panel1024x768) {
4013 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4014 if (pVBInfo->VGAVDE == 357)
4016 else if (pVBInfo->VGAVDE == 420)
4018 else if (pVBInfo->VGAVDE == 525)
4020 else if (pVBInfo->VGAVDE == 600)
4022 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4023 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4028 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4031 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4033 if (pVBInfo->VGAVDE == 360)
4035 else if (pVBInfo->VGAVDE == 375)
4037 else if (pVBInfo->VGAVDE == 405)
4041 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4044 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4046 if (pVBInfo->VGAVDE == 350)
4048 else if (pVBInfo->VGAVDE == 400)
4050 else if (pVBInfo->VGAVDE == 1024)
4054 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4058 if (pVBInfo->VGAVDE == 1024) {
4062 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4064 tempbx = 1200; /* alan 10/14/2003 */
4065 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4066 if (pVBInfo->VGAVDE == 350)
4068 else if (pVBInfo->VGAVDE == 400)
4073 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4074 tempax = pVBInfo->VGAHDE;
4075 tempbx = pVBInfo->VGAVDE;
4078 pVBInfo->HDE = tempax;
4079 pVBInfo->VDE = tempbx;
4083 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4085 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4086 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4089 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4090 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4091 pVBInfo->VGAHT = TVPtr->VGAHT;
4092 pVBInfo->VGAVT = TVPtr->VGAVT;
4093 pVBInfo->HDE = TVPtr->TVHDE;
4094 pVBInfo->VDE = TVPtr->TVVDE;
4095 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4096 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
4098 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4099 if (resinfo == 0x08)
4100 pVBInfo->NewFlickerMode = 0x40;
4101 else if (resinfo == 0x09)
4102 pVBInfo->NewFlickerMode = 0x40;
4103 else if (resinfo == 0x12)
4104 pVBInfo->NewFlickerMode = 0x40;
4106 if (pVBInfo->VGAVDE == 350)
4107 pVBInfo->TVInfo |= TVSimuMode;
4112 if (pVBInfo->VBInfo & SetInSlaveMode) {
4113 if (pVBInfo->TVInfo & TVSimuMode) {
4117 if (!(modeflag & Charx8Dot)) {
4118 tempax = StHiTextTVHT;
4119 tempbx = StHiTextTVVT;
4123 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4124 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4125 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4126 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4129 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4130 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4131 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4132 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4133 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4134 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4135 if (pVBInfo->TVInfo & NTSC1024x768)
4136 tempax = NTSC1024x768HT;
4141 if (!(pVBInfo->TVInfo & SetPALTV)) {
4144 if (pVBInfo->TVInfo & NTSC1024x768)
4145 tempax = NTSC1024x768HT;
4149 pVBInfo->HT = tempax;
4150 pVBInfo->VT = tempbx;
4155 void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4156 unsigned short RefreshRateTableIndex,
4157 struct vb_device_info *pVBInfo)
4159 unsigned char di_0, di_1, tempal;
4161 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4163 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4164 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
4166 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4168 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, 0x10);
4169 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4170 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4171 } else { /* 301b/302b/301lv/302lv */
4172 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4173 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4176 XGINew_SetReg1(pVBInfo->Part4Port, 0x00, 0x12);
4178 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4179 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x28);
4181 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x08);
4184 /* --------------------------------------------------------------------- */
4185 /* Function : XGI_GETLCDVCLKPtr */
4187 /* Output : al -> VCLK Index */
4189 /* --------------------------------------------------------------------- */
4190 void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
4191 struct vb_device_info *pVBInfo)
4193 unsigned short index;
4195 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4196 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
4197 if (pVBInfo->LCDInfo & EnableScalingLCD)
4201 /* index = XGI_GetLCDCapPtr(pVBInfo); */
4202 index = XGI_GetLCDCapPtr1(pVBInfo);
4204 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
4205 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
4206 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
4208 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
4209 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
4215 unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
4216 unsigned short ModeNo, unsigned short ModeIdIndex,
4217 struct vb_device_info *pVBInfo)
4220 unsigned short index, modeflag;
4221 unsigned short tempbx;
4222 unsigned char tempal;
4223 unsigned char *CHTVVCLKPtr = NULL;
4226 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4228 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4230 if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
4231 & EnableScalingLCD))) { /* {LCDA/LCDB} */
4232 index = XGI_GetLCDCapPtr(pVBInfo);
4233 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
4235 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
4239 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4240 | VB_XGI302LV | VB_XGI301C)) {
4241 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4242 tempal = HiTVVCLKDIV2;
4243 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4245 if (pVBInfo->TVInfo & TVSimuMode) {
4246 tempal = HiTVSimuVCLK;
4247 if (!(modeflag & Charx8Dot))
4248 tempal = HiTVTextVCLK;
4254 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4255 tempal = YPbPr750pVCLK;
4259 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4260 tempal = YPbPr525pVCLK;
4264 tempal = NTSC1024VCLK;
4266 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
4267 tempal = TVVCLKDIV2;
4268 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4272 if (pVBInfo->VBInfo & SetCRT2ToTV)
4275 /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
4277 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4279 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4280 *tempal = *tempal & 0x1F;
4282 if (pVBInfo->TVInfo & SetPALTV)
4283 tempbx = tempbx + 2;
4284 if (pVBInfo->TVInfo & SetCHTVOverScan)
4286 tempbx = tempbx << 1;
4290 if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
4291 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4292 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
4293 if (ModeNo <= 0x13) {
4295 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4298 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4301 tempal = tempal & 0x0F;
4304 if (pVBInfo->TVInfo & SetPALTV)
4305 tempbx = tempbx + 2;
4307 if (pVBInfo->TVInfo & SetCHTVOverScan)
4310 /** tempbx = tempbx << 1; CH7007 ? **/
4312 /* [Billy]07/05/29 CH7007 */
4313 if (pVBInfo->IF_DEF_CH7007 == 1) {
4316 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
4319 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
4322 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
4325 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
4335 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
4338 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
4341 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
4344 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
4352 tempal = CHTVVCLKPtr[tempal];
4358 tempal = (unsigned char) XGINew_GetReg2((pVBInfo->P3ca + 0x02));
4359 tempal = tempal >> 2;
4362 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
4363 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
4368 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
4372 void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
4373 unsigned char *di_1, struct vb_device_info *pVBInfo)
4375 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
4376 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
4377 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
4378 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
4379 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
4380 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
4381 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
4382 & ProgrammingCRT2)) {
4383 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
4384 *di_1 = XGI_VBVCLKData[tempal].SR2C;
4387 *di_0 = XGI_VCLKData[tempal].SR2B;
4388 *di_1 = XGI_VCLKData[tempal].SR2C;
4392 static void XGI_SetCRT2Offset(unsigned short ModeNo,
4393 unsigned short ModeIdIndex,
4394 unsigned short RefreshRateTableIndex,
4395 struct xgi_hw_device_info *HwDeviceExtension,
4396 struct vb_device_info *pVBInfo)
4398 unsigned short offset;
4401 if (pVBInfo->VBInfo & SetInSlaveMode)
4404 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4405 HwDeviceExtension, pVBInfo);
4406 temp = (unsigned char) (offset & 0xFF);
4407 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp);
4408 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4409 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, temp);
4410 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4411 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4414 unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
4415 unsigned short RefreshRateTableIndex,
4416 struct xgi_hw_device_info *HwDeviceExtension,
4417 struct vb_device_info *pVBInfo)
4419 unsigned short temp, colordepth, modeinfo, index, infoflag,
4420 ColorDepth[] = { 0x01, 0x02, 0x04 };
4422 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4426 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4428 index = (modeinfo >> 8) & 0xFF;
4430 temp = pVBInfo->ScreenOffset[index];
4432 if (infoflag & InterlaceMode)
4435 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4437 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4438 temp = ModeNo - 0x7C;
4439 colordepth = ColorDepth[temp];
4441 if (infoflag & InterlaceMode)
4443 return temp * colordepth;
4445 return temp * colordepth;
4449 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
4451 XGINew_SetReg1(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
4452 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
4455 void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4456 struct xgi_hw_device_info *HwDeviceExtension,
4457 unsigned short RefreshRateTableIndex,
4458 struct vb_device_info *pVBInfo)
4460 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
4462 if (ModeNo > 0x13) {
4463 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4464 CRT1Index &= IndexMask;
4465 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4468 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4469 HwDeviceExtension, pVBInfo);
4470 XGI_SetCRT2FIFO(pVBInfo);
4471 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4473 for (tempcx = 4; tempcx < 7; tempcx++)
4474 XGINew_SetReg1(pVBInfo->Part1Port, tempcx, 0x0);
4476 XGINew_SetReg1(pVBInfo->Part1Port, 0x50, 0x00);
4477 XGINew_SetReg1(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
4480 void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4481 struct xgi_hw_device_info *HwDeviceExtension,
4482 unsigned short RefreshRateTableIndex,
4483 struct vb_device_info *pVBInfo)
4485 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4486 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
4488 if (ModeNo > 0x13) {
4489 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4490 CRT1Index &= IndexMask;
4491 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4495 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4497 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4499 /* bainy change table name */
4500 if (modeflag & HalfDCLK) {
4501 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4502 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4503 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4504 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4505 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4506 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4507 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4508 pushbx = pVBInfo->VGAHDE / 2 + 16;
4509 tempcx = tempcx >> 1;
4510 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4513 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4514 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4515 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4517 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4518 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4520 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4521 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4522 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4528 if (tempcx > (pVBInfo->VGAHT / 2))
4529 tempcx = pVBInfo->VGAHT / 2;
4531 temp = tempbx & 0x00FF;
4533 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4535 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4536 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4537 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4538 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4539 temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4540 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4541 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4542 pushbx = pVBInfo->VGAHDE + 16;
4543 tempcx = tempcx >> 1;
4544 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4547 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4548 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4549 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
4551 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4552 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4554 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4555 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4556 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4561 if (tempcx > pVBInfo->VGAHT)
4562 tempcx = pVBInfo->VGAHT;
4564 temp = tempbx & 0x00FF;
4565 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4568 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4570 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4571 tempax |= (tempbx & 0xFF00);
4572 temp = (tempax & 0xFF00) >> 8;
4573 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4574 temp = tempcx & 0x00FF;
4575 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp);
4576 tempcx = (pVBInfo->VGAVT - 1);
4577 temp = tempcx & 0x00FF;
4579 if (pVBInfo->IF_DEF_CH7005 == 1) {
4580 if (pVBInfo->VBInfo & 0x0C)
4584 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4585 tempbx = pVBInfo->VGAVDE - 1;
4586 temp = tempbx & 0x00FF;
4587 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, temp);
4588 temp = ((tempbx & 0xFF00) << 3) >> 8;
4589 temp |= ((tempcx & 0xFF00) >> 8);
4590 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, temp);
4592 tempax = pVBInfo->VGAVDE;
4593 tempbx = pVBInfo->VGAVDE;
4594 tempcx = pVBInfo->VGAVT;
4595 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
4596 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
4598 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4599 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4600 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4608 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
4613 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4614 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4617 temp = tempbx & 0x00FF;
4618 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4619 temp = ((tempbx & 0xFF00) >> 8) << 4;
4620 temp = ((tempcx & 0x000F) | (temp));
4621 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, temp);
4624 if (modeflag & DoubleScanMode)
4627 if (modeflag & HalfDCLK)
4630 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
4633 void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4634 struct xgi_hw_device_info *HwDeviceExtension,
4635 unsigned short RefreshRateTableIndex,
4636 struct vb_device_info *pVBInfo)
4638 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4639 modeflag, CRT1Index;
4641 if (ModeNo <= 0x13) {
4642 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4643 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4645 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4646 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4647 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4648 CRT1Index &= IndexMask;
4651 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4654 temp = 0xFF; /* set MAX HT */
4655 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4656 /* if (modeflag & Charx8Dot) */
4657 /* tempcx = 0x08; */
4661 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4662 modeflag |= Charx8Dot;
4664 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
4666 if (modeflag & HalfDCLK)
4667 tempax = tempax >> 1;
4669 tempax = (tempax / tempcx) - 1;
4670 tempbx |= ((tempax & 0x00FF) << 8);
4671 temp = tempax & 0x00FF;
4672 XGINew_SetReg1(pVBInfo->Part1Port, 0x04, temp);
4674 temp = (tempbx & 0xFF00) >> 8;
4676 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4677 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4678 | VB_XGI302LV | VB_XGI301C)))
4681 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4682 if (pVBInfo->VBType & VB_XGI301LV) {
4683 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4687 } else if (resinfo == 7) {
4693 XGINew_SetReg1(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
4694 XGINew_SetReg1(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
4696 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4697 if (pVBInfo->VBInfo & SetCRT2ToTV)
4698 tempax = pVBInfo->VGAHT;
4700 tempax = XGI_GetVGAHT2(pVBInfo);
4703 if (tempax >= pVBInfo->VGAHT)
4704 tempax = pVBInfo->VGAHT;
4706 if (modeflag & HalfDCLK)
4707 tempax = tempax >> 1;
4709 tempax = (tempax / tempcx) - 5;
4710 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4711 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4712 temp = (tempbx & 0x00FF) - 1;
4713 if (!(modeflag & HalfDCLK)) {
4715 if (pVBInfo->TVInfo & TVSimuMode) {
4722 /* tempcx = tempbx & 0x00FF ; */
4723 tempbx = (tempbx & 0xFF00) >> 8;
4724 tempcx = (tempcx + tempbx) >> 1;
4725 temp = (tempcx & 0x00FF) + 2;
4727 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4729 if (!(modeflag & HalfDCLK)) {
4730 if ((modeflag & Charx8Dot)) {
4732 if (pVBInfo->VGAHDE >= 800)
4737 if (!(modeflag & HalfDCLK)) {
4739 if (pVBInfo->LCDResInfo != Panel1280x960) {
4740 if (pVBInfo->VGAHDE >= 800) {
4742 if (pVBInfo->ModeType
4747 if (pVBInfo->LCDResInfo
4748 != Panel1280x1024) {
4755 if (pVBInfo->VGAHDE >= 1280) {
4756 if (pVBInfo->LCDResInfo
4758 if (pVBInfo->LCDInfo
4759 & LCDNonExpanding) {
4771 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
4772 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
4774 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4775 if (pVBInfo->TVInfo & TVSimuMode) {
4776 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
4777 == 0x11) || (ModeNo == 0x13) || (ModeNo
4779 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, 0x5b);
4780 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0x03);
4783 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
4784 if (pVBInfo->TVInfo & SetNTSCTV) {
4785 XGINew_SetReg1(pVBInfo->Part1Port,
4787 XGINew_SetReg1(pVBInfo->Part1Port,
4790 XGINew_SetReg1(pVBInfo->Part1Port,
4792 XGINew_SetReg1(pVBInfo->Part1Port,
4794 XGINew_SetReg1(pVBInfo->Part1Port,
4799 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
4801 if (pVBInfo->TVInfo & SetNTSCTV) {
4802 XGINew_SetReg1(pVBInfo->Part1Port,
4804 XGINew_SetReg1(pVBInfo->Part1Port,
4807 XGINew_SetReg1(pVBInfo->Part1Port,
4809 XGINew_SetReg1(pVBInfo->Part1Port,
4811 XGINew_SetReg1(pVBInfo->Part1Port,
4816 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
4817 == 0x0D) || (ModeNo == 0x50)) {
4818 if (pVBInfo->TVInfo & SetNTSCTV) {
4819 XGINew_SetReg1(pVBInfo->Part1Port,
4821 XGINew_SetReg1(pVBInfo->Part1Port,
4824 XGINew_SetReg1(pVBInfo->Part1Port,
4826 XGINew_SetReg1(pVBInfo->Part1Port,
4833 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
4834 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
4835 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
4837 tempbx = pVBInfo->VGAVT;
4840 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
4855 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4856 if (pVBInfo->LCDResInfo == Panel1024x768) {
4857 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4866 temp = tempbx & 0x00FF;
4868 temp = tempbx & 0x00FF;
4869 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
4872 temp = tempbx & 0x00FF;
4873 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4875 if (tempbx & 0x0100)
4880 if (modeflag & DoubleScanMode)
4883 if (tempbx & 0x0200)
4886 temp = (tempax & 0xFF00) >> 8;
4887 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4889 if (tempbx & 0x0400)
4892 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
4895 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
4896 tempax = tempax >> 2;
4897 push1 = tempax; /* push ax */
4899 if (resinfo != 0x09) {
4900 tempax = tempax << 1;
4904 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4905 if (pVBInfo->VBType & VB_XGI301LV) {
4906 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
4909 if (pVBInfo->TVInfo & TVSimuMode) {
4910 if (pVBInfo->TVInfo & SetPALTV) {
4913 if (!(pVBInfo->TVInfo
4916 | SetYPbPrMode1080i)))
4928 if (pVBInfo->TVInfo & TVSimuMode) {
4929 if (pVBInfo->TVInfo & SetPALTV) {
4930 if (pVBInfo->VBType & VB_XGI301LV) {
4931 if (!(pVBInfo->TVInfo
4934 | SetYPbPrMode1080i)))
4943 tempax = tempax >> 2;
4946 push1 = tempax; /* push ax */
4948 if ((pVBInfo->TVInfo & SetPALTV)) {
4949 if (tempbx <= 513) {
4955 temp = tempbx & 0x00FF;
4956 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4958 temp = tempbx & 0x00FF;
4959 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4961 if (tempbx & 0x0100)
4964 if (tempbx & 0x0200)
4965 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
4969 if (tempbx & 0x0100)
4972 if (tempbx & 0x0200)
4975 if (tempbx & 0x0400)
4978 tempbx = push1; /* pop ax */
4979 temp = tempbx & 0x00FF;
4981 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
4983 if (tempbx & 0x0010)
4986 temp = tempcx & 0x00FF;
4987 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
4988 temp = (tempcx & 0x0FF00) >> 8;
4989 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
4991 temp = (tempax & 0xFF00) >> 8;
4993 temp = (temp >> 1) & 0x09;
4995 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4998 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
4999 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
5000 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
5002 if (pVBInfo->LCDInfo & LCDRGB18Bit)
5007 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5012 void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5013 unsigned short RefreshRateTableIndex,
5014 struct xgi_hw_device_info *HwDeviceExtension,
5015 struct vb_device_info *pVBInfo)
5017 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5018 modeflag, resinfo, crt2crtc;
5019 unsigned char *TimingPoint;
5021 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5023 if (ModeNo <= 0x13) {
5024 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5025 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5026 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5028 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5029 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5031 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5036 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5039 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5042 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5045 if (!(pVBInfo->TVInfo & SetPALTV))
5048 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5051 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5054 tempax = (tempax & 0xff00) >> 8;
5056 XGINew_SetReg1(pVBInfo->Part2Port, 0x0, tempax);
5057 TimingPoint = pVBInfo->NTSCTiming;
5059 if (pVBInfo->TVInfo & SetPALTV)
5060 TimingPoint = pVBInfo->PALTiming;
5062 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5063 TimingPoint = pVBInfo->HiTVExtTiming;
5065 if (pVBInfo->VBInfo & SetInSlaveMode)
5066 TimingPoint = pVBInfo->HiTVSt2Timing;
5068 if (pVBInfo->SetFlag & TVSimuMode)
5069 TimingPoint = pVBInfo->HiTVSt1Timing;
5071 if (!(modeflag & Charx8Dot))
5072 TimingPoint = pVBInfo->HiTVTextTiming;
5075 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5076 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5077 TimingPoint = pVBInfo->YPbPr525iTiming;
5079 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5080 TimingPoint = pVBInfo->YPbPr525pTiming;
5082 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5083 TimingPoint = pVBInfo->YPbPr750pTiming;
5086 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5087 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]);
5089 for (i = 0x39; i <= 0x45; i++, j++)
5090 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
5092 if (pVBInfo->VBInfo & SetCRT2ToTV)
5093 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5095 temp = pVBInfo->NewFlickerMode;
5097 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5099 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5102 if (pVBInfo->TVInfo & SetPALTV)
5107 if (pVBInfo->VDE <= tempax) {
5108 tempax -= pVBInfo->VDE;
5109 tempax = tempax >> 2;
5110 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5112 temp = (tempax & 0xFF00) >> 8;
5113 temp += (unsigned short) TimingPoint[0];
5115 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5116 | VB_XGI302LV | VB_XGI301C)) {
5117 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5118 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5119 | SetCRT2ToYPbPr)) {
5120 tempcx = pVBInfo->VGAHDE;
5121 if (tempcx >= 1024) {
5122 temp = 0x17; /* NTSC */
5123 if (pVBInfo->TVInfo & SetPALTV)
5124 temp = 0x19; /* PAL */
5129 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5131 temp = (tempax & 0xFF00) >> 8;
5132 temp += TimingPoint[1];
5134 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5135 | VB_XGI302LV | VB_XGI301C)) {
5136 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5137 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5138 | SetCRT2ToYPbPr))) {
5139 tempcx = pVBInfo->VGAHDE;
5140 if (tempcx >= 1024) {
5141 temp = 0x1D; /* NTSC */
5142 if (pVBInfo->TVInfo & SetPALTV)
5143 temp = 0x52; /* PAL */
5147 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, temp);
5151 tempcx = pVBInfo->HT;
5153 if (XGI_IsLCDDualLink(pVBInfo))
5154 tempcx = tempcx >> 1;
5157 temp = tempcx & 0x00FF;
5158 XGINew_SetReg1(pVBInfo->Part2Port, 0x1B, temp);
5160 temp = (tempcx & 0xFF00) >> 8;
5161 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5163 tempcx = pVBInfo->HT >> 1;
5164 push1 = tempcx; /* push cx */
5167 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5170 temp = tempcx & 0x00FF;
5172 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5174 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5177 temp = tempbx & 0x00FF;
5178 XGINew_SetReg1(pVBInfo->Part2Port, 0x24, temp);
5179 temp = (tempbx & 0xFF00) >> 8;
5181 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5184 tempbx = tempbx + 8;
5185 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5186 tempbx = tempbx - 4;
5190 temp = (tempbx & 0x00FF) << 4;
5191 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5194 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5195 temp = tempcx & 0x00FF;
5196 XGINew_SetReg1(pVBInfo->Part2Port, 0x27, temp);
5197 temp = ((tempcx & 0xFF00) >> 8) << 4;
5198 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5201 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5204 temp = tempcx & 0xFF;
5206 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5208 tempcx = push1; /* pop cx */
5210 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5212 temp = tempcx & 0x00FF;
5214 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5218 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5219 tempax = XGI_GetVGAHT2(pVBInfo);
5220 tempcx = tempax - 1;
5222 temp = tempcx & 0x00FF;
5223 XGINew_SetReg1(pVBInfo->Part2Port, 0x2E, temp);
5225 tempbx = pVBInfo->VDE;
5227 if (pVBInfo->VGAVDE == 360)
5229 if (pVBInfo->VGAVDE == 375)
5231 if (pVBInfo->VGAVDE == 405)
5234 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5235 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5236 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5237 | SetYPbPrMode750p)))
5238 tempbx = tempbx >> 1;
5240 tempbx = tempbx >> 1;
5244 temp = tempbx & 0x00FF;
5246 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5247 if (pVBInfo->VBType & VB_XGI301LV) {
5248 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5249 if (pVBInfo->VBInfo & SetInSlaveMode) {
5255 if (pVBInfo->VBInfo & SetInSlaveMode) {
5262 XGINew_SetReg1(pVBInfo->Part2Port, 0x2F, temp);
5264 temp = (tempcx & 0xFF00) >> 8;
5265 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5267 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5268 if (pVBInfo->VBType & VB_XGI301LV) {
5269 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5272 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5277 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5282 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, temp);
5284 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5285 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5286 tempbx = pVBInfo->VDE;
5287 tempcx = tempbx - 2;
5289 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5290 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5291 | SetYPbPrMode750p)))
5292 tempbx = tempbx >> 1;
5295 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5297 if (tempcx & 0x0400)
5300 if (tempbx & 0x0400)
5303 XGINew_SetReg1(pVBInfo->Part4Port, 0x10, temp);
5306 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5307 XGINew_SetReg1(pVBInfo->Part2Port, 0x46, temp);
5308 temp = (tempbx - 3) & 0x00FF;
5309 XGINew_SetReg1(pVBInfo->Part2Port, 0x47, temp);
5312 tempbx = tempbx & 0x00FF;
5314 if (!(modeflag & HalfDCLK)) {
5315 tempcx = pVBInfo->VGAHDE;
5316 if (tempcx >= pVBInfo->HDE) {
5324 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5325 if (pVBInfo->VGAHDE >= 1024) {
5327 if (pVBInfo->VGAHDE >= 1280) {
5329 tempbx = tempbx & 0xDFFF;
5334 if (!(tempbx & 0x2000)) {
5335 if (modeflag & HalfDCLK)
5336 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5339 tempeax = pVBInfo->VGAHDE;
5340 tempebx = (tempcx & 0xFF00) >> 8;
5341 longtemp = tempeax * tempebx;
5342 tempecx = tempcx & 0x00FF;
5343 longtemp = longtemp / tempecx;
5348 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5349 | VB_XGI302LV | VB_XGI301C)) {
5350 tempecx = tempecx * 8;
5353 longtemp = longtemp * tempecx;
5354 tempecx = pVBInfo->HDE;
5355 temp2 = longtemp % tempecx;
5356 tempeax = longtemp / tempecx;
5360 tempax = (unsigned short) tempeax;
5363 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5364 | VB_XGI302LV | VB_XGI301C)) {
5365 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5370 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5371 | (tempbx & 0x00FF));
5372 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5373 | (tempax & 0x00FF));
5374 temp = (tempax & 0xFF00) >> 8;
5376 temp = (tempax & 0x00FF) >> 8;
5379 XGINew_SetReg1(pVBInfo->Part2Port, 0x44, temp);
5380 temp = (tempbx & 0xFF00) >> 8;
5381 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5382 temp = tempcx & 0x00FF;
5384 if (tempbx & 0x2000)
5387 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5390 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5391 if (pVBInfo->TVInfo & SetPALTV) {
5399 temp = tempbx & 0x00FF;
5400 XGINew_SetReg1(pVBInfo->Part2Port, 0x4b, temp);
5401 temp = tempcx & 0x00FF;
5402 XGINew_SetReg1(pVBInfo->Part2Port, 0x4c, temp);
5404 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5406 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5408 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5411 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5414 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5418 XGINew_SetReg1(pVBInfo->Part2Port, 0x4d, temp);
5419 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x43); /* 301b change */
5420 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5422 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5423 if (pVBInfo->TVInfo & NTSC1024x768) {
5424 TimingPoint = XGI_NTSC1024AdjTime;
5425 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5426 XGINew_SetReg1(pVBInfo->Part2Port, i,
5429 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, 0x72);
5433 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5434 if (pVBInfo->VBType & VB_XGI301C) {
5435 if (pVBInfo->TVInfo & SetPALMTV)
5436 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x08,
5437 0x08); /* PALM Mode */
5440 if (pVBInfo->TVInfo & SetPALMTV) {
5441 tempax = (unsigned char) XGINew_GetReg1(pVBInfo->Part2Port,
5444 XGINew_SetRegAND(pVBInfo->Part2Port, 0x01, tempax);
5446 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5447 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xEF);
5450 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5451 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5452 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, 0x00);
5455 if (pVBInfo->VBInfo & SetCRT2ToTV)
5459 void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5460 struct xgi_hw_device_info *HwDeviceExtension,
5461 unsigned short RefreshRateTableIndex,
5462 struct vb_device_info *pVBInfo)
5464 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5465 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5467 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5469 if (ModeNo <= 0x13) {
5470 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5471 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5473 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5474 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5476 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5477 CRT1Index &= IndexMask;
5480 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5483 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5485 if (XGI_IsLCDDualLink(pVBInfo))
5486 tempbx = tempbx >> 1;
5489 temp = tempbx & 0x00FF;
5490 XGINew_SetReg1(pVBInfo->Part2Port, 0x2C, temp);
5491 temp = (tempbx & 0xFF00) >> 8;
5493 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5496 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5497 if (pVBInfo->ModeType == ModeEGA) {
5498 if (pVBInfo->VGAHDE >= 1024) {
5500 if (pVBInfo->LCDInfo & LCDVESATiming)
5506 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, temp);
5507 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5510 temp = tempbx & 0x00FF;
5511 XGINew_SetReg1(pVBInfo->Part2Port, 0x03, temp);
5512 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5513 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5515 tempcx = pVBInfo->VT - 1;
5517 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5518 XGINew_SetReg1(pVBInfo->Part2Port, 0x19, temp);
5519 temp = (tempcx & 0xFF00) >> 8;
5521 XGINew_SetReg1(pVBInfo->Part2Port, 0x1A, temp);
5522 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5523 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5524 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5525 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5527 /* Customized LCDB Des no add */
5529 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5530 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5531 tempah = pVBInfo->LCDResInfo;
5532 tempah &= PanelResInfo;
5534 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5537 } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
5540 } else if (tempah == Panel1400x1050) {
5548 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5549 tempbx = pVBInfo->HDE;
5550 tempcx = pVBInfo->VDE;
5554 tempax = pVBInfo->VT;
5555 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5556 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5557 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5558 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5559 tempbx = pVBInfo->LCDVDES;
5562 if (tempcx >= tempax)
5563 tempcx -= tempax; /* lcdvdes */
5565 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5566 XGINew_SetReg1(pVBInfo->Part2Port, 0x05, temp);
5567 temp = tempcx & 0x00FF;
5568 XGINew_SetReg1(pVBInfo->Part2Port, 0x06, temp);
5569 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5570 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5572 tempah = tempah << 3;
5574 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, tempah);
5577 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5579 tempax = pVBInfo->VT;
5580 tempbx = pVBInfo->LCDVRS;
5582 /* if (SetLCD_Info & EnableScalingLCD) */
5584 if (tempcx >= tempax)
5587 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5588 XGINew_SetReg1(pVBInfo->Part2Port, 0x04, temp);
5589 temp = (tempbx & 0xFF00) >> 8;
5591 temp |= (tempcx & 0x000F);
5592 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5594 tempax = pVBInfo->HT;
5595 tempbx = pVBInfo->LCDHDES;
5598 if (XGI_IsLCDDualLink(pVBInfo)) {
5599 tempax = tempax >> 1;
5600 tempbx = tempbx >> 1;
5601 tempcx = tempcx >> 1;
5604 if (pVBInfo->VBType & VB_XGI302LV)
5607 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5612 if (tempcx >= tempax)
5615 temp = tempbx & 0x00FF;
5616 XGINew_SetReg1(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5617 temp = ((tempbx & 0xFF00) >> 8) << 4;
5618 XGINew_SetReg1(pVBInfo->Part2Port, 0x20, temp);
5619 temp = tempcx & 0x00FF;
5620 XGINew_SetReg1(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5621 temp = (tempcx & 0xFF00) >> 8;
5622 XGINew_SetReg1(pVBInfo->Part2Port, 0x25, temp);
5625 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5627 tempax = pVBInfo->HT;
5628 tempbx = pVBInfo->LCDHRS;
5629 /* if ( SetLCD_Info & EnableScalingLCD) */
5630 if (XGI_IsLCDDualLink(pVBInfo)) {
5631 tempax = tempax >> 1;
5632 tempbx = tempbx >> 1;
5633 tempcx = tempcx >> 1;
5636 if (pVBInfo->VBType & VB_XGI302LV)
5641 if (tempcx >= tempax)
5644 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5645 XGINew_SetReg1(pVBInfo->Part2Port, 0x1C, temp);
5647 temp = (tempbx & 0xFF00) >> 8;
5649 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5650 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5651 XGINew_SetReg1(pVBInfo->Part2Port, 0x21, temp);
5653 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5654 if (pVBInfo->VGAVDE == 525) {
5655 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5656 | VB_XGI301LV | VB_XGI302LV
5662 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5663 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, 0xB3);
5666 if (pVBInfo->VGAVDE == 420) {
5667 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5668 | VB_XGI301LV | VB_XGI302LV
5673 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5678 /* --------------------------------------------------------------------- */
5679 /* Function : XGI_GetTap4Ptr */
5681 /* Output : di -> Tap4 Reg. Setting Pointer */
5683 /* --------------------------------------------------------------------- */
5684 struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
5685 struct vb_device_info *pVBInfo)
5687 unsigned short tempax, tempbx, i;
5689 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5692 tempax = pVBInfo->VGAHDE;
5693 tempbx = pVBInfo->HDE;
5695 tempax = pVBInfo->VGAVDE;
5696 tempbx = pVBInfo->VDE;
5699 if (tempax < tempbx)
5700 return &EnlargeTap4Timing[0];
5701 else if (tempax == tempbx)
5702 return &NoScaleTap4Timing[0]; /* 1:1 */
5704 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
5706 if (pVBInfo->TVInfo & SetPALTV)
5707 Tap4TimingPtr = PALTap4Timing;
5709 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5710 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5711 Tap4TimingPtr = YPbPr525iTap4Timing;
5712 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5713 Tap4TimingPtr = YPbPr525pTap4Timing;
5714 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5715 Tap4TimingPtr = YPbPr750pTap4Timing;
5718 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5719 Tap4TimingPtr = HiTVTap4Timing;
5722 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5723 if (Tap4TimingPtr[i].DE == tempax)
5727 return &Tap4TimingPtr[i];
5730 void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
5732 unsigned short i, j;
5734 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5736 if (!(pVBInfo->VBType & VB_XGI301C))
5740 XGINew_SetRegAND(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
5741 #else /* Tap4 Setting */
5743 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5744 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5745 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5747 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5748 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
5749 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5750 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5753 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5754 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
5756 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
5760 void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5761 struct vb_device_info *pVBInfo)
5764 unsigned char *tempdi;
5765 unsigned short modeflag;
5768 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5770 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5772 XGINew_SetReg1(pVBInfo->Part3Port, 0x00, 0x00);
5773 if (pVBInfo->TVInfo & SetPALTV) {
5774 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5775 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5777 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xF5);
5778 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xB7);
5781 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5784 if (pVBInfo->TVInfo & SetPALMTV) {
5785 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5786 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5787 XGINew_SetReg1(pVBInfo->Part3Port, 0x3D, 0xA8);
5790 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
5791 & SetCRT2ToYPbPr)) {
5792 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5795 tempdi = pVBInfo->HiTVGroup3Data;
5796 if (pVBInfo->SetFlag & TVSimuMode) {
5797 tempdi = pVBInfo->HiTVGroup3Simu;
5798 if (!(modeflag & Charx8Dot))
5799 tempdi = pVBInfo->HiTVGroup3Text;
5802 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5803 tempdi = pVBInfo->Ren525pGroup3;
5805 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5806 tempdi = pVBInfo->Ren750pGroup3;
5808 for (i = 0; i <= 0x3E; i++)
5809 XGINew_SetReg1(pVBInfo->Part3Port, i, tempdi[i]);
5811 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
5812 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5813 XGINew_SetReg1(pVBInfo->Part3Port, 0x28, 0x3f);
5817 } /* {end of XGI_SetGroup3} */
5819 void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
5820 unsigned short RefreshRateTableIndex,
5821 struct xgi_hw_device_info *HwDeviceExtension,
5822 struct vb_device_info *pVBInfo)
5824 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
5826 unsigned long tempebx, tempeax, templong;
5829 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5831 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5833 temp = pVBInfo->RVBHCFACT;
5834 XGINew_SetReg1(pVBInfo->Part4Port, 0x13, temp);
5836 tempbx = pVBInfo->RVBHCMAX;
5837 temp = tempbx & 0x00FF;
5838 XGINew_SetReg1(pVBInfo->Part4Port, 0x14, temp);
5839 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
5840 tempcx = pVBInfo->VGAHT - 1;
5841 temp = tempcx & 0x00FF;
5842 XGINew_SetReg1(pVBInfo->Part4Port, 0x16, temp);
5844 temp = ((tempcx & 0xFF00) >> 8) << 3;
5847 tempcx = pVBInfo->VGAVT - 1;
5848 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5851 temp = tempcx & 0x00FF;
5852 XGINew_SetReg1(pVBInfo->Part4Port, 0x17, temp);
5853 temp = temp2 | ((tempcx & 0xFF00) >> 8);
5854 XGINew_SetReg1(pVBInfo->Part4Port, 0x15, temp);
5855 XGINew_SetRegOR(pVBInfo->Part4Port, 0x0D, 0x08);
5856 tempcx = pVBInfo->VBInfo;
5857 tempbx = pVBInfo->VGAHDE;
5859 if (modeflag & HalfDCLK)
5860 tempbx = tempbx >> 1;
5862 if (XGI_IsLCDDualLink(pVBInfo))
5863 tempbx = tempbx >> 1;
5865 if (tempcx & SetCRT2ToHiVisionTV) {
5871 } else if (tempcx & SetCRT2ToTV) {
5877 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5884 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
5886 if (pVBInfo->VGAHDE == 1280)
5888 if (pVBInfo->VGAHDE == 1024)
5891 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
5893 tempebx = pVBInfo->VDE;
5895 if (tempcx & SetCRT2ToHiVisionTV) {
5896 if (!(temp & 0xE000))
5897 tempbx = tempbx >> 1;
5900 tempcx = pVBInfo->RVBHRS;
5901 temp = tempcx & 0x00FF;
5902 XGINew_SetReg1(pVBInfo->Part4Port, 0x18, temp);
5904 tempeax = pVBInfo->VGAVDE;
5907 if (tempeax <= tempebx) {
5908 tempcx = (tempcx & (~0x4000));
5909 tempeax = pVBInfo->VGAVDE;
5914 templong = (tempeax * 256 * 1024) % tempebx;
5915 tempeax = (tempeax * 256 * 1024) / tempebx;
5921 temp = (unsigned short) (tempebx & 0x000000FF);
5922 XGINew_SetReg1(pVBInfo->Part4Port, 0x1B, temp);
5924 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
5925 XGINew_SetReg1(pVBInfo->Part4Port, 0x1A, temp);
5926 tempbx = (unsigned short) (tempebx >> 16);
5927 temp = tempbx & 0x00FF;
5929 temp |= ((tempcx & 0xFF00) >> 8);
5930 XGINew_SetReg1(pVBInfo->Part4Port, 0x19, temp);
5933 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5934 | VB_XGI302LV | VB_XGI301C)) {
5936 XGINew_SetReg1(pVBInfo->Part4Port, 0x1C, temp);
5937 tempax = pVBInfo->VGAHDE;
5938 if (modeflag & HalfDCLK)
5939 tempax = tempax >> 1;
5941 if (XGI_IsLCDDualLink(pVBInfo))
5942 tempax = tempax >> 1;
5944 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
5945 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5949 if (pVBInfo->VGAHDE > 800) {
5950 if (pVBInfo->VGAHDE == 1024)
5951 tempax = (tempax * 25 / 32) - 1;
5953 tempax = (tempax * 20 / 32) - 1;
5959 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5960 if (pVBInfo->VBType & VB_XGI301LV) {
5961 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
5962 if (pVBInfo->VGAHDE > 800) {
5963 if (pVBInfo->VGAHDE == 1024)
5964 tempax = (tempax * 25 / 32) - 1;
5966 tempax = (tempax * 20 / 32) - 1;
5970 if (pVBInfo->VGAHDE > 800) {
5971 if (pVBInfo->VGAHDE == 1024)
5972 tempax = (tempax * 25 / 32) - 1;
5974 tempax = (tempax * 20 / 32) - 1;
5980 temp = (tempax & 0xFF00) >> 8;
5981 temp = ((temp & 0x0003) << 4);
5982 XGINew_SetReg1(pVBInfo->Part4Port, 0x1E, temp);
5983 temp = (tempax & 0x00FF);
5984 XGINew_SetReg1(pVBInfo->Part4Port, 0x1D, temp);
5986 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5987 if (pVBInfo->VGAHDE > 800)
5988 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1E, 0x08);
5993 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5994 if (!(pVBInfo->TVInfo & (NTSC1024x768
5995 | SetYPbPrMode525p | SetYPbPrMode750p
5996 | SetYPbPrMode1080i))) {
5998 if ((pVBInfo->VBInfo & SetInSlaveMode)
5999 && (!(pVBInfo->TVInfo
6005 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6006 tempbx = pVBInfo->HT;
6007 if (XGI_IsLCDDualLink(pVBInfo))
6008 tempbx = tempbx >> 1;
6009 tempbx = (tempbx >> 1) - 2;
6010 temp = ((tempbx & 0x0700) >> 8) << 3;
6011 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6012 temp = tempbx & 0x00FF;
6013 XGINew_SetReg1(pVBInfo->Part4Port, 0x22, temp);
6017 if (pVBInfo->ISXPDOS == 0)
6018 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6022 void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6023 struct vb_device_info *pVBInfo)
6025 unsigned short Pindex, Pdata;
6027 Pindex = pVBInfo->Part5Port;
6028 Pdata = pVBInfo->Part5Port + 1;
6029 if (pVBInfo->ModeType == ModeVGA) {
6030 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6031 | CRT2DisplayFlag))) {
6032 XGINew_EnableCRT2(pVBInfo);
6033 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6039 void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
6040 unsigned short ModeIdIndex,
6041 unsigned short RefreshRateTableIndex,
6042 struct vb_device_info *pVBInfo)
6044 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
6046 struct XGI330_LCDDataTablStruct *tempdi = NULL;
6050 if (ModeNo <= 0x13) {
6051 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6052 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6054 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6055 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6058 tempal = tempal & 0x0f;
6060 if (tempbx <= 1) { /* ExpLink */
6061 if (ModeNo <= 0x13) {
6062 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
6065 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6068 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6071 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
6074 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
6078 tempal = (tempal >> 4);
6080 tempal = (tempal & 0x0f);
6083 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
6085 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
6086 if ((tempbx == 5) || (tempbx) == 7)
6087 tempcx = LCDDesDataLen2;
6088 else if ((tempbx == 3) || (tempbx == 8))
6089 tempcx = LVDSDesDataLen2;
6091 /* mov di, word ptr cs:LCDDataList[bx] */
6092 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
6096 tempdi = XGI_EPLLCDCRT1Ptr_H;
6099 tempdi = XGI_EPLLCDCRT1Ptr_V;
6102 tempdi = XGI_EPLLCDDataPtr;
6105 tempdi = XGI_EPLLCDDesDataPtr;
6108 tempdi = XGI_LCDDataTable;
6111 tempdi = XGI_LCDDesDataTable;
6114 tempdi = XGI_EPLCHLCDRegPtr;
6125 if (tempdi == NULL) /* OEMUtil */
6131 while (tempdi[i].PANELID != 0xff) {
6132 tempdx = pVBInfo->LCDResInfo;
6133 if (tempbx & 0x0080) { /* OEMUtil */
6134 tempbx &= (~0x0080);
6135 tempdx = pVBInfo->LCDTypeInfo;
6138 if (pVBInfo->LCDInfo & EnableScalingLCD)
6139 tempdx &= (~PanelResInfo);
6141 if (tempdi[i].PANELID == tempdx) {
6142 tempbx = tempdi[i].MASK;
6143 tempdx = pVBInfo->LCDInfo;
6145 if (ModeNo <= 0x13) /* alan 09/10/2003 */
6146 tempdx |= SetLCDStdMode;
6148 if (modeflag & HalfDCLK)
6149 tempdx |= SetLCDLowResolution;
6152 if (tempbx == tempdi[i].CAP)
6159 switch (tempdi[i].DATAPTR) {
6161 return &XGI_LVDSCRT11024x768_1_H[tempal];
6164 return &XGI_LVDSCRT11024x768_2_H[tempal];
6167 return &XGI_LVDSCRT11280x1024_1_H[tempal];
6170 return &XGI_LVDSCRT11280x1024_2_H[tempal];
6173 return &XGI_LVDSCRT11400x1050_1_H[tempal];
6176 return &XGI_LVDSCRT11400x1050_2_H[tempal];
6179 return &XGI_LVDSCRT11600x1200_1_H[tempal];
6182 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
6185 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
6188 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
6191 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
6196 } else if (table == 1) {
6197 switch (tempdi[i].DATAPTR) {
6199 return &XGI_LVDSCRT11024x768_1_V[tempal];
6202 return &XGI_LVDSCRT11024x768_2_V[tempal];
6205 return &XGI_LVDSCRT11280x1024_1_V[tempal];
6208 return &XGI_LVDSCRT11280x1024_2_V[tempal];
6211 return &XGI_LVDSCRT11400x1050_1_V[tempal];
6214 return &XGI_LVDSCRT11400x1050_2_V[tempal];
6217 return &XGI_LVDSCRT11600x1200_1_V[tempal];
6220 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
6223 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
6226 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
6229 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
6234 } else if (table == 2) {
6235 switch (tempdi[i].DATAPTR) {
6237 return &XGI_LVDS1024x768Data_1[tempal];
6240 return &XGI_LVDS1024x768Data_2[tempal];
6243 return &XGI_LVDS1280x1024Data_1[tempal];
6246 return &XGI_LVDS1280x1024Data_2[tempal];
6249 return &XGI_LVDS1400x1050Data_1[tempal];
6252 return &XGI_LVDS1400x1050Data_2[tempal];
6255 return &XGI_LVDS1600x1200Data_1[tempal];
6258 return &XGI_LVDSNoScalingData[tempal];
6261 return &XGI_LVDS1024x768Data_1x75[tempal];
6264 return &XGI_LVDS1024x768Data_2x75[tempal];
6267 return &XGI_LVDS1280x1024Data_1x75[tempal];
6270 return &XGI_LVDS1280x1024Data_2x75[tempal];
6273 return &XGI_LVDSNoScalingDatax75[tempal];
6278 } else if (table == 3) {
6279 switch (tempdi[i].DATAPTR) {
6281 return &XGI_LVDS1024x768Des_1[tempal];
6284 return &XGI_LVDS1024x768Des_3[tempal];
6287 return &XGI_LVDS1024x768Des_2[tempal];
6290 return &XGI_LVDS1280x1024Des_1[tempal];
6293 return &XGI_LVDS1280x1024Des_2[tempal];
6296 return &XGI_LVDS1400x1050Des_1[tempal];
6299 return &XGI_LVDS1400x1050Des_2[tempal];
6302 return &XGI_LVDS1600x1200Des_1[tempal];
6305 return &XGI_LVDSNoScalingDesData[tempal];
6308 return &XGI_LVDS1024x768Des_1x75[tempal];
6311 return &XGI_LVDS1024x768Des_3x75[tempal];
6314 return &XGI_LVDS1024x768Des_2x75[tempal];
6317 return &XGI_LVDS1280x1024Des_1x75[tempal];
6320 return &XGI_LVDS1280x1024Des_2x75[tempal];
6323 return &XGI_LVDSNoScalingDesDatax75[tempal];
6328 } else if (table == 4) {
6329 switch (tempdi[i].DATAPTR) {
6331 return &XGI_ExtLCD1024x768Data[tempal];
6334 return &XGI_StLCD1024x768Data[tempal];
6337 return &XGI_CetLCD1024x768Data[tempal];
6340 return &XGI_ExtLCD1280x1024Data[tempal];
6343 return &XGI_StLCD1280x1024Data[tempal];
6346 return &XGI_CetLCD1280x1024Data[tempal];
6349 return &XGI_ExtLCD1400x1050Data[tempal];
6352 return &XGI_StLCD1400x1050Data[tempal];
6355 return &XGI_CetLCD1400x1050Data[tempal];
6358 return &XGI_ExtLCD1600x1200Data[tempal];
6361 return &XGI_StLCD1600x1200Data[tempal];
6364 return &XGI_NoScalingData[tempal];
6367 return &XGI_ExtLCD1024x768x75Data[tempal];
6370 return &XGI_ExtLCD1024x768x75Data[tempal];
6373 return &XGI_CetLCD1024x768x75Data[tempal];
6376 return &XGI_ExtLCD1280x1024x75Data[tempal];
6379 return &XGI_StLCD1280x1024x75Data[tempal];
6382 return &XGI_CetLCD1280x1024x75Data[tempal];
6385 return &XGI_NoScalingDatax75[tempal];
6390 } else if (table == 5) {
6391 switch (tempdi[i].DATAPTR) {
6393 return &XGI_ExtLCDDes1024x768Data[tempal];
6396 return &XGI_StLCDDes1024x768Data[tempal];
6399 return &XGI_CetLCDDes1024x768Data[tempal];
6402 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6404 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
6406 return &XGI_ExtLCDDes1280x1024Data[tempal];
6409 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6411 return &XGI_StLCDDLDes1280x1024Data[tempal];
6413 return &XGI_StLCDDes1280x1024Data[tempal];
6416 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6418 return &XGI_CetLCDDLDes1280x1024Data[tempal];
6420 return &XGI_CetLCDDes1280x1024Data[tempal];
6423 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6425 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
6427 return &XGI_ExtLCDDes1400x1050Data[tempal];
6430 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6432 return &XGI_StLCDDLDes1400x1050Data[tempal];
6434 return &XGI_StLCDDes1400x1050Data[tempal];
6437 return &XGI_CetLCDDes1400x1050Data[tempal];
6440 return &XGI_CetLCDDes1400x1050Data2[tempal];
6443 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6445 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
6447 return &XGI_ExtLCDDes1600x1200Data[tempal];
6450 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6452 return &XGI_StLCDDLDes1600x1200Data[tempal];
6454 return &XGI_StLCDDes1600x1200Data[tempal];
6457 return &XGI_NoScalingDesData[tempal];
6460 return &XGI_ExtLCDDes1024x768x75Data[tempal];
6463 return &XGI_StLCDDes1024x768x75Data[tempal];
6466 return &XGI_CetLCDDes1024x768x75Data[tempal];
6469 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6471 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
6473 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
6476 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6478 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
6480 return &XGI_StLCDDes1280x1024x75Data[tempal];
6483 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6485 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
6487 return &XGI_CetLCDDes1280x1024x75Data[tempal];
6490 return &XGI_NoScalingDesDatax75[tempal];
6495 } else if (table == 6) {
6496 switch (tempdi[i].DATAPTR) {
6498 return &XGI_CH7017LV1024x768[tempal];
6501 return &XGI_CH7017LV1400x1050[tempal];
6510 void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
6511 unsigned short ModeIdIndex,
6512 unsigned short RefreshRateTableIndex,
6513 struct vb_device_info *pVBInfo)
6515 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
6516 struct XGI330_TVDataTablStruct *tempdi = NULL;
6520 if (ModeNo <= 0x13) {
6521 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6522 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6524 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6525 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6528 tempal = tempal & 0x3f;
6533 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
6534 if (pVBInfo->IF_DEF_CH7007 == 1)
6535 tempdi = XGI_EPLCHTVCRT1Ptr;
6539 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
6540 if (pVBInfo->IF_DEF_CH7007 == 1)
6541 tempdi = XGI_EPLCHTVCRT1Ptr;
6545 tempdi = XGI_EPLCHTVDataPtr;
6551 tempdi = XGI_TVDataTable;
6557 tempdi = XGI_EPLCHTVRegPtr;
6563 if (tempdi == NULL) /* OEMUtil */
6566 tempdx = pVBInfo->TVInfo;
6568 if (pVBInfo->VBInfo & SetInSlaveMode)
6569 tempdx = tempdx | SetTVLockMode;
6571 if (modeflag & HalfDCLK)
6572 tempdx = tempdx | SetTVLowResolution;
6576 while (tempdi[i].MASK != 0xffff) {
6577 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
6582 if (table == 0x00) { /* 07/05/22 */
6583 } else if (table == 0x01) {
6584 } else if (table == 0x04) {
6585 switch (tempdi[i].DATAPTR) {
6587 return &XGI_ExtPALData[tempal];
6590 return &XGI_ExtNTSCData[tempal];
6593 return &XGI_StPALData[tempal];
6596 return &XGI_StNTSCData[tempal];
6599 return &XGI_ExtHiTVData[tempal];
6602 return &XGI_St2HiTVData[tempal];
6605 return &XGI_ExtYPbPr525iData[tempal];
6608 return &XGI_ExtYPbPr525pData[tempal];
6611 return &XGI_ExtYPbPr750pData[tempal];
6614 return &XGI_StYPbPr525iData[tempal];
6617 return &XGI_StYPbPr525pData[tempal];
6620 return &XGI_StYPbPr750pData[tempal];
6622 case 12: /* avoid system hang */
6623 return &XGI_ExtNTSCData[tempal];
6626 return &XGI_St1HiTVData[tempal];
6631 } else if (table == 0x02) {
6632 switch (tempdi[i].DATAPTR) {
6634 return &XGI_CHTVUNTSCData[tempal];
6637 return &XGI_CHTVONTSCData[tempal];
6640 return &XGI_CHTVUPALData[tempal];
6643 return &XGI_CHTVOPALData[tempal];
6648 } else if (table == 0x06) {
6653 /* --------------------------------------------------------------------- */
6654 /* Function : XGI_BacklightByDrv */
6656 /* Output : 1 -> Skip backlight control */
6658 /* --------------------------------------------------------------------- */
6659 unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
6661 unsigned char tempah;
6663 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x3A);
6664 if (tempah & BacklightControlBit)
6670 /* --------------------------------------------------------------------- */
6671 /* Function : XGI_FirePWDDisable */
6674 /* Description : Turn off VDD & Backlight : Fire disable procedure */
6675 /* --------------------------------------------------------------------- */
6677 void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
6679 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x00, 0xFC);
6683 /* --------------------------------------------------------------------- */
6684 /* Function : XGI_FirePWDEnable */
6687 /* Description : Turn on VDD & Backlight : Fire enable procedure */
6688 /* --------------------------------------------------------------------- */
6689 void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
6691 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x03, 0xFC);
6694 void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6695 struct vb_device_info *pVBInfo)
6697 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
6700 void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6701 struct vb_device_info *pVBInfo)
6704 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
6707 /* --------------------------------------------------------------------- */
6708 /* Function : XGI_SetPanelDelay */
6712 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6713 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6714 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6715 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6716 /* --------------------------------------------------------------------- */
6717 void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
6719 unsigned short index;
6721 index = XGI_GetLCDCapPtr(pVBInfo);
6724 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S1, pVBInfo);
6727 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S2, pVBInfo);
6730 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S3, pVBInfo);
6733 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S4, pVBInfo);
6736 /* --------------------------------------------------------------------- */
6737 /* Function : XGI_SetPanelPower */
6741 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
6742 /* = 0111b = 07h ; Backlight on, Power off */
6743 /* = 1011b = 0Bh ; Backlight off, Power on */
6744 /* = 1111b = 0Fh ; Backlight off, Power off */
6745 /* --------------------------------------------------------------------- */
6746 void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl,
6747 struct vb_device_info *pVBInfo)
6749 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
6750 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x26, tempbl, tempah);
6752 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x11, tempbl, tempah);
6755 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
6757 unsigned char ujRet = 0;
6758 unsigned char i = 0;
6760 for (i = 0; i < 8; i++) {
6762 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
6763 ujRet |= (ujDate >> i) & 1;
6769 /*----------------------------------------------------------------------------*/
6771 /* bl[5] : LVDS signal */
6772 /* bl[1] : LVDS backlight */
6773 /* bl[0] : LVDS VDD */
6774 /*----------------------------------------------------------------------------*/
6775 unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
6777 unsigned char CR4A, temp;
6779 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6780 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
6782 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6784 temp = XG21GPIODataTransfer(temp);
6786 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6790 /*----------------------------------------------------------------------------*/
6792 /* bl[5] : LVDS signal */
6793 /* bl[1] : LVDS backlight */
6794 /* bl[0] : LVDS VDD */
6795 /*----------------------------------------------------------------------------*/
6796 unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
6798 unsigned char CR4A, CRB4, temp;
6800 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6801 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
6803 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6807 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6808 CRB4 = XGINew_GetReg1(pVBInfo->P3d4, 0xB4);
6809 temp |= ((CRB4 & 0x04) << 3);
6812 /*----------------------------------------------------------------------------*/
6814 /* bl[5] : 1;LVDS signal on */
6815 /* bl[1] : 1;LVDS backlight on */
6816 /* bl[0] : 1:LVDS VDD on */
6817 /* bh: 100000b : clear bit 5, to set bit5 */
6818 /* 000010b : clear bit 1, to set bit1 */
6819 /* 000001b : clear bit 0, to set bit0 */
6820 /*----------------------------------------------------------------------------*/
6821 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6822 struct vb_device_info *pVBInfo)
6824 unsigned char CR4A, temp;
6826 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6829 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6831 if (tempbh & 0x20) {
6832 temp = (tempbl >> 4) & 0x02;
6834 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6838 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6840 temp = XG21GPIODataTransfer(temp);
6843 XGINew_SetReg1(pVBInfo->P3d4, 0x48, temp);
6846 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6847 struct vb_device_info *pVBInfo)
6849 unsigned char CR4A, temp;
6850 unsigned short tempbh0, tempbl0;
6859 if (tempbh & 0x20) {
6860 temp = (tempbl >> 4) & 0x02;
6862 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6865 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
6867 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6871 tempbl <<= 2; /* GPIOC,GPIOD */
6872 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6873 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
6876 /* --------------------------------------------------------------------- */
6877 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
6879 unsigned short index;
6881 index = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
6882 if (index < sizeof(XGI21_LCDCapList)
6883 / sizeof(struct XGI21_LVDSCapStruct))
6888 /* --------------------------------------------------------------------- */
6889 /* Function : XGI_XG21SetPanelDelay */
6893 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6894 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6895 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6896 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6897 /* --------------------------------------------------------------------- */
6898 void XGI_XG21SetPanelDelay(unsigned short tempbl,
6899 struct vb_device_info *pVBInfo)
6901 unsigned short index;
6903 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6905 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S1,
6909 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S2,
6913 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S3,
6917 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S4,
6921 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
6922 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6924 unsigned short xres, yres, colordepth, modeflag, resindex,
6927 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6928 if (ModeNo <= 0x13) {
6929 xres = pVBInfo->StResInfo[resindex].HTotal;
6930 yres = pVBInfo->StResInfo[resindex].VTotal;
6931 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6933 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6934 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6935 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6938 if (!(modeflag & Charx8Dot)) {
6943 if (ModeNo > 0x13) {
6944 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6947 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6952 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6953 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6956 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6959 if (ModeNo > 0x13) {
6961 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6963 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
6964 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
6974 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
6978 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6979 temp = (temp & 1) << 6;
6980 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
6981 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6985 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
6989 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6990 temp = (temp & 3) << 6;
6991 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6992 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6996 void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6997 struct vb_device_info *pVBInfo)
6999 unsigned char temp, Miscdata;
7000 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
7001 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
7002 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
7003 unsigned short value;
7005 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
7007 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7008 & (LCDPolarity << 8)) >> 8);
7009 temp &= LCDPolarity;
7010 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
7012 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
7014 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7016 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7017 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
7019 XGI_SetXG21FPBits(pVBInfo);
7020 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7021 if (ModeNo <= 0x13) {
7022 xres = pVBInfo->StResInfo[resindex].HTotal;
7023 yres = pVBInfo->StResInfo[resindex].VTotal;
7024 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7026 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7027 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7028 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7031 if (!(modeflag & Charx8Dot))
7032 xres = xres * 8 / 9;
7034 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
7036 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7038 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7039 LVDSHBS -= xres / 4;
7041 if (LVDSHBS > LVDSHT)
7044 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7045 if (LVDSHRS > LVDSHT)
7048 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7049 if (LVDSHRE > LVDSHT)
7052 LVDSHBE = LVDSHBS + LVDSHT
7053 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
7055 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
7057 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7059 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7060 LVDSVBS += yres / 2;
7062 if (LVDSVBS > LVDSVT)
7065 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7066 if (LVDSVRS > LVDSVT)
7069 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7070 if (LVDSVRE > LVDSVT)
7073 LVDSVBE = LVDSVBS + LVDSVT
7074 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
7076 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7077 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
7079 if (!(modeflag & Charx8Dot))
7080 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
7082 /* HT SR0B[1:0] CR00 */
7083 value = (LVDSHT >> 3) - 5;
7084 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7085 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
7087 /* HBS SR0B[5:4] CR02 */
7088 value = (LVDSHBS >> 3) - 1;
7089 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7090 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
7092 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7093 value = (LVDSHBE >> 3) - 1;
7094 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7095 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7096 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
7098 /* HRS SR0B[7:6] CR04 */
7099 value = (LVDSHRS >> 3) + 2;
7100 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7101 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
7103 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7105 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7106 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
7108 /* HRE SR0C[2] CR05[4:0] */
7109 value = (LVDSHRE >> 3) + 2;
7110 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7111 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
7113 /* Panel HRE SR2F[7:2] */
7115 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
7117 /* VT SR0A[0] CR07[5][0] CR06 */
7119 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7120 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7121 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7122 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
7124 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7125 value = LVDSVBS - 1;
7126 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7127 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7128 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7129 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
7131 /* VBE SR0A[4] CR16 */
7132 value = LVDSVBE - 1;
7133 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7134 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
7136 /* VRS SR0A[3] CR7[7][2] CR10 */
7137 value = LVDSVRS - 1;
7138 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7139 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7140 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7141 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
7143 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
7144 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
7145 XGINew_SetReg1(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
7146 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
7148 /* VRE SR0A[5] CR11[3:0] */
7149 value = LVDSVRE - 1;
7150 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7151 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
7153 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
7154 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
7156 for (temp = 0, value = 0; temp < 3; temp++) {
7158 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7159 XGINew_SetReg1(pVBInfo->P3c4,
7161 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7162 XGINew_SetReg1(pVBInfo->P3c4,
7164 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7168 if (!(modeflag & Charx8Dot)) {
7169 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7170 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7171 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
7173 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7174 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7176 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7181 /* no shadow case */
7182 void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
7183 struct vb_device_info *pVBInfo)
7185 unsigned char temp, Miscdata;
7186 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
7187 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
7188 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
7189 unsigned short value;
7191 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
7192 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7193 & (LCDPolarity << 8)) >> 8);
7194 temp &= LCDPolarity;
7195 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
7197 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
7199 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7201 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7202 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
7204 XGI_SetXG27FPBits(pVBInfo);
7205 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7206 if (ModeNo <= 0x13) {
7207 xres = pVBInfo->StResInfo[resindex].HTotal;
7208 yres = pVBInfo->StResInfo[resindex].VTotal;
7209 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7211 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7212 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7213 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7216 if (!(modeflag & Charx8Dot))
7217 xres = xres * 8 / 9;
7219 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
7221 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7223 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7224 LVDSHBS -= xres / 4;
7226 if (LVDSHBS > LVDSHT)
7229 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7230 if (LVDSHRS > LVDSHT)
7233 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7234 if (LVDSHRE > LVDSHT)
7237 LVDSHBE = LVDSHBS + LVDSHT
7238 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
7240 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
7242 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7244 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7245 LVDSVBS += yres / 2;
7247 if (LVDSVBS > LVDSVT)
7250 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7251 if (LVDSVRS > LVDSVT)
7254 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7255 if (LVDSVRE > LVDSVT)
7258 LVDSVBE = LVDSVBS + LVDSVT
7259 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
7261 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7262 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
7264 if (!(modeflag & Charx8Dot))
7265 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
7267 /* HT SR0B[1:0] CR00 */
7268 value = (LVDSHT >> 3) - 5;
7269 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7270 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
7272 /* HBS SR0B[5:4] CR02 */
7273 value = (LVDSHBS >> 3) - 1;
7274 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7275 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
7277 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7278 value = (LVDSHBE >> 3) - 1;
7279 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7280 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7281 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
7283 /* HRS SR0B[7:6] CR04 */
7284 value = (LVDSHRS >> 3) + 2;
7285 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7286 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
7288 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7290 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7291 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
7293 /* HRE SR0C[2] CR05[4:0] */
7294 value = (LVDSHRE >> 3) + 2;
7295 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7296 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
7298 /* Panel HRE SR2F[7:2] */
7300 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
7302 /* VT SR0A[0] CR07[5][0] CR06 */
7304 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7305 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7306 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7307 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
7309 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7310 value = LVDSVBS - 1;
7311 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7312 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7313 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7314 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
7316 /* VBE SR0A[4] CR16 */
7317 value = LVDSVBE - 1;
7318 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7319 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
7321 /* VRS SR0A[3] CR7[7][2] CR10 */
7322 value = LVDSVRS - 1;
7323 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7324 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7325 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7326 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
7328 /* Panel VRS SR35[2:0] SR34[7:0] */
7329 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
7330 XGINew_SetReg1(pVBInfo->P3c4, 0x34, value & 0xFF);
7332 /* VRE SR0A[5] CR11[3:0] */
7333 value = LVDSVRE - 1;
7334 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7335 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
7337 /* Panel VRE SR3F[7:2] */
7338 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
7340 for (temp = 0, value = 0; temp < 3; temp++) {
7342 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7343 XGINew_SetReg1(pVBInfo->P3c4,
7345 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7346 XGINew_SetReg1(pVBInfo->P3c4,
7348 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7352 if (!(modeflag & Charx8Dot)) {
7353 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7354 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7355 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
7357 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7358 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7360 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7365 /* --------------------------------------------------------------------- */
7366 /* Function : XGI_IsLCDON */
7368 /* Output : 0 : Skip PSC Control */
7369 /* 1: Disable PSC */
7371 /* --------------------------------------------------------------------- */
7372 unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
7374 unsigned short tempax;
7376 tempax = pVBInfo->VBInfo;
7377 if (tempax & SetCRT2ToDualEdge)
7379 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
7385 void XGI_EnablePWD(struct vb_device_info *pVBInfo)
7387 unsigned short index, temp;
7389 index = XGI_GetLCDCapPtr(pVBInfo);
7390 temp = pVBInfo->LCDCapList[index].PWD_2B;
7391 XGINew_SetReg1(pVBInfo->Part4Port, 0x2B, temp);
7392 XGINew_SetReg1(pVBInfo->Part4Port, 0x2C,
7393 pVBInfo->LCDCapList[index].PWD_2C);
7394 XGINew_SetReg1(pVBInfo->Part4Port, 0x2D,
7395 pVBInfo->LCDCapList[index].PWD_2D);
7396 XGINew_SetReg1(pVBInfo->Part4Port, 0x2E,
7397 pVBInfo->LCDCapList[index].PWD_2E);
7398 XGINew_SetReg1(pVBInfo->Part4Port, 0x2F,
7399 pVBInfo->LCDCapList[index].PWD_2F);
7400 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x80); /* enable PWD */
7403 void XGI_DisablePWD(struct vb_device_info *pVBInfo)
7405 XGINew_SetRegAND(pVBInfo->Part4Port, 0x27, 0x7F); /* disable PWD */
7408 /* --------------------------------------------------------------------- */
7409 /* Function : XGI_DisableChISLCD */
7411 /* Output : 0 -> Not LCD Mode */
7413 /* --------------------------------------------------------------------- */
7414 unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
7416 unsigned short tempbx, tempah;
7418 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
7419 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
7421 if (tempbx & (EnableChA | DisableChA)) {
7422 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7426 if (!(tempbx & (EnableChB | DisableChB)))
7429 if (tempah & 0x01) /* Chk LCDB Mode */
7435 /* --------------------------------------------------------------------- */
7436 /* Function : XGI_EnableChISLCD */
7438 /* Output : 0 -> Not LCD mode */
7440 /* --------------------------------------------------------------------- */
7441 unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
7443 unsigned short tempbx, tempah;
7445 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
7446 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
7448 if (tempbx & (EnableChA | DisableChA)) {
7449 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7453 if (!(tempbx & (EnableChB | DisableChB)))
7456 if (tempah & 0x01) /* Chk LCDB Mode */
7462 unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
7464 unsigned char tempal, tempah, tempbl, i;
7466 tempah = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
7467 tempal = tempah & 0x0F;
7468 tempah = tempah & 0xF0;
7470 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7472 while (tempbl != 0xFF) {
7473 if (tempbl & 0x80) { /* OEMUtil */
7475 tempbl = tempbl & ~(0x80);
7478 if (tempal == tempbl)
7483 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7489 unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
7491 unsigned short tempah, tempal, tempbl, i;
7493 tempal = pVBInfo->LCDResInfo;
7494 tempah = pVBInfo->LCDTypeInfo;
7497 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7499 while (tempbl != 0xFF) {
7500 if ((tempbl & 0x80) && (tempbl != 0x80)) {
7505 if (tempal == tempbl)
7509 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7512 if (tempbl == 0xFF) {
7513 pVBInfo->LCDResInfo = Panel1024x768;
7514 pVBInfo->LCDTypeInfo = 0;
7521 void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
7522 struct vb_device_info *pVBInfo)
7524 unsigned short Index;
7526 Index = XGI_GetLCDCapPtr(pVBInfo);
7527 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
7528 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
7533 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7534 struct vb_device_info *pVBInfo)
7536 unsigned short tempbl, tempah;
7538 if (pVBInfo->SetFlag == Win9xDOSMode) {
7539 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7540 | VB_XGI302LV | VB_XGI301C)) {
7541 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7544 /* LVDS or CH7017 */
7548 if (HwDeviceExtension->jChipType < XG40) {
7549 if (!XGI_DisableChISLCD(pVBInfo)) {
7550 if ((XGI_EnableChISLCD(pVBInfo)) || (pVBInfo->VBInfo
7551 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
7552 if (pVBInfo->LCDInfo & SetPWDEnable) {
7553 XGI_EnablePWD(pVBInfo);
7555 pVBInfo->LCDInfo &= (~SetPWDEnable);
7556 if (pVBInfo->VBType & (VB_XGI301LV
7566 XGI_SetPanelPower(tempah, tempbl,
7568 XGI_SetPanelDelay(1, pVBInfo);
7574 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7575 | VB_XGI302LV | VB_XGI301C)) {
7576 if (!(pVBInfo->SetFlag & DisableChA)) {
7577 if (pVBInfo->SetFlag & EnableChA) {
7578 XGINew_SetReg1(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
7580 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
7581 XGINew_SetReg1(pVBInfo->Part1Port,
7582 0x1E, 0x20); /* Power on */
7587 if (!(pVBInfo->SetFlag & DisableChB)) {
7588 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
7589 & (SetCRT2ToLCD | SetCRT2ToTV
7590 | SetCRT2ToRAMDAC))) {
7591 tempah = (unsigned char) XGINew_GetReg1(
7592 pVBInfo->P3c4, 0x32);
7594 if (pVBInfo->VBInfo & SetInSlaveMode) {
7595 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
7598 XGINew_SetReg1(pVBInfo->P3c4, 0x32, tempah);
7599 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x20);
7601 tempah = (unsigned char) XGINew_GetReg1(
7602 pVBInfo->Part1Port, 0x2E);
7604 if (!(tempah & 0x80))
7605 XGINew_SetRegOR(pVBInfo->Part1Port,
7606 0x2E, 0x80); /* BVBDOENABLE = 1 */
7608 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
7612 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
7613 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
7614 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x00, ~0xE0,
7615 0x20); /* shampoo 0129 */
7616 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7617 if (!XGI_DisableChISLCD(pVBInfo)) {
7618 if (XGI_EnableChISLCD(pVBInfo)
7624 0x2A, 0x7F); /* LVDS PLL power on */
7626 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
7632 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7635 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
7636 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7637 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7638 tempah = tempah & 0x40;
7641 tempah = tempah ^ 0xC0;
7643 if (pVBInfo->SetFlag
7647 if (pVBInfo->SetFlag
7651 if (pVBInfo->SetFlag
7655 if (pVBInfo->SetFlag
7663 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
7665 if (pVBInfo->SetFlag & Win9xDOSMode) {
7666 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7670 if (!(pVBInfo->SetFlag & DisableChA)) {
7671 XGI_VBLongWait(pVBInfo);
7672 if (!(pVBInfo->SetFlag & GatingCRT)) {
7673 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
7674 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7675 XGI_VBLongWait(pVBInfo);
7680 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
7682 XGINew_SetRegOR(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
7684 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->Part1Port,
7686 if (!(tempah & 0x80))
7687 XGINew_SetRegOR(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
7689 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F);
7690 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7693 if (HwDeviceExtension->jChipType < XG40) {
7694 if (!XGI_EnableChISLCD(pVBInfo)) {
7695 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7696 if (XGI_BacklightByDrv(pVBInfo))
7702 if (pVBInfo->LCDInfo & SetPWDEnable) {
7703 XGI_FirePWDEnable(pVBInfo);
7707 XGI_SetPanelDelay(2, pVBInfo);
7709 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
7711 tempbl = 0xFE; /* turn on backlght */
7716 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7720 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7721 struct vb_device_info *pVBInfo)
7723 unsigned short tempax, tempbx, tempah = 0, tempbl = 0;
7725 if (pVBInfo->SetFlag == Win9xDOSMode)
7728 if (HwDeviceExtension->jChipType < XG40) {
7729 if ((!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7730 || (XGI_DisableChISLCD(pVBInfo))) {
7731 if (!XGI_IsLCDON(pVBInfo)) {
7732 if (pVBInfo->LCDInfo & SetPWDEnable)
7733 XGI_EnablePWD(pVBInfo);
7735 pVBInfo->LCDInfo &= ~SetPWDEnable;
7736 XGI_DisablePWD(pVBInfo);
7737 if (pVBInfo->VBType & (VB_XGI301LV
7740 tempbx = 0xFE; /* not 01h */
7743 tempbx = 0xF7; /* not 08h */
7746 XGI_SetPanelPower(tempax, tempbx,
7748 XGI_SetPanelDelay(3, pVBInfo);
7750 } /* end if (!XGI_IsLCDON(pVBInfo)) */
7756 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
7757 if (!XGI_IsLCDON(pVBInfo)) {
7759 tempbx = XGINew_GetCH7005(0x61);
7760 if (tempbx < 0x01) // first time we power up
7761 XGINew_SetCH7005(0x0066); // and disable power sequence
7763 XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
7770 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7771 | VB_XGI302LV | VB_XGI301C)) {
7773 if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
7774 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7775 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7776 tempah = 0x7F; /* Disable Channel A */
7777 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7778 tempah = 0xBF; /* Disable Channel B */
7780 if (pVBInfo->SetFlag & DisableChB)
7781 tempah &= 0xBF; /* force to disable Cahnnel */
7783 if (pVBInfo->SetFlag & DisableChA)
7784 tempah &= 0x7F; /* Force to disable Channel B */
7789 XGINew_SetRegAND(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
7791 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7792 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7793 || (XGI_DisableChISLCD(pVBInfo))
7794 || (XGI_IsLCDON(pVBInfo)))
7795 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
7798 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7799 & (DisableCRT2Display | SetCRT2ToLCDA
7800 | SetSimuScanMode))) {
7801 if (pVBInfo->SetFlag & GatingCRT)
7802 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
7803 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7806 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7807 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7809 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
7812 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
7814 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
7815 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xdf);
7817 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7818 & (DisableCRT2Display | SetSimuScanMode))
7819 || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7824 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7826 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7827 & (DisableCRT2Display | SetSimuScanMode))
7828 || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7829 || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7830 | SetCRT2ToLCD | SetCRT2ToTV))) {
7831 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
7832 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
7833 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
7834 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
7836 } else { /* {301} */
7837 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
7838 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7839 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
7840 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
7843 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
7845 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7848 if (HwDeviceExtension->jChipType < XG40) {
7849 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7850 || (XGI_DisableChISLCD(pVBInfo))
7851 || (XGI_IsLCDON(pVBInfo))) {
7852 if (pVBInfo->LCDInfo & SetPWDEnable) {
7853 if (pVBInfo->LCDInfo & SetPWDEnable)
7854 XGI_BacklightByDrv(pVBInfo);
7856 XGI_SetPanelDelay(4, pVBInfo);
7857 if (pVBInfo->VBType & VB_XGI301LV) {
7866 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7871 /* --------------------------------------------------------------------- */
7872 /* Function : XGI_GetTVPtrIndex */
7875 /* Description : bx 0 : ExtNTSC */
7887 /* --------------------------------------------------------------------- */
7888 unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
7890 unsigned short tempbx = 0;
7892 if (pVBInfo->TVInfo & SetPALTV)
7894 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7896 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7898 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7900 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7902 if (pVBInfo->TVInfo & TVSimuMode)
7908 /* --------------------------------------------------------------------- */
7909 /* Function : XGI_OEM310Setting */
7912 /* Description : Customized Param. for 301 */
7913 /* --------------------------------------------------------------------- */
7914 void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
7915 struct vb_device_info *pVBInfo)
7917 if (pVBInfo->SetFlag & Win9xDOSMode)
7921 XGI_SetDelayComp(pVBInfo);
7923 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7924 XGI_SetLCDCap(pVBInfo);
7926 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7928 XGI_SetPhaseIncr(pVBInfo);
7929 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7930 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
7932 if (pVBInfo->VBType & VB_XGI301)
7933 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7937 void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
7939 unsigned short index;
7941 unsigned char tempah, tempbl, tempbh;
7943 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7944 | VB_XGI302LV | VB_XGI301C)) {
7945 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7946 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7950 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7951 tempbl = pVBInfo->XGI_TVDelayList[index];
7953 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7954 | VB_XGI301LV | VB_XGI302LV
7956 tempbl = pVBInfo->XGI_TVDelayList2[index];
7958 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7959 tempbl = tempbl >> 4;
7961 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7962 tempbl = CRT2Delay1; // Get CRT2 Delay
7963 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
7964 tempbl = CRT2Delay2;
7966 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7967 index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
7968 tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
7970 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7976 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x2D);
7978 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7979 | SetCRT2ToTV)) { /* Channel B */
7984 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7988 XGINew_SetReg1(pVBInfo->Part1Port, 0x2D, tempah);
7990 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7993 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7995 = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
7996 pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
7998 tempah = tempah << 4;
7999 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2D, 0x0f,
8005 void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
8007 unsigned short tempcx;
8009 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
8011 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8012 | VB_XGI302LV | VB_XGI301C)) {
8013 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
8014 /* Set 301LV Capability */
8015 XGINew_SetReg1(pVBInfo->Part4Port, 0x24,
8016 (unsigned char) (tempcx & 0x1F));
8019 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
8020 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
8021 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
8022 | EnablePLLSPLOW)) >> 8));
8025 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8026 | VB_XGI302LV | VB_XGI301C)) {
8027 if (pVBInfo->VBInfo & SetCRT2ToLCD)
8028 XGI_SetLCDCap_B(tempcx, pVBInfo);
8029 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8030 XGI_SetLCDCap_A(tempcx, pVBInfo);
8032 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8033 if (tempcx & EnableSpectrum)
8034 SetSpectrum(pVBInfo);
8038 XGI_SetLCDCap_A(tempcx, pVBInfo);
8042 void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
8044 unsigned short temp;
8046 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
8048 if (temp & LCDRGB18Bit) {
8049 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
8050 (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
8051 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
8053 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
8054 (unsigned short) (0x30 | (tempcx & 0x00C0)));
8055 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
8059 if (tempcx & EnableLCD24bpp) { // 24bits
8060 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
8061 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
8063 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
8064 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
8069 /* --------------------------------------------------------------------- */
8070 /* Function : XGI_SetLCDCap_B */
8071 /* Input : cx -> LCD Capability */
8074 /* --------------------------------------------------------------------- */
8075 void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
8077 if (tempcx & EnableLCD24bpp) /* 24bits */
8078 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8079 (unsigned short) (((tempcx & 0x00ff) >> 6)
8082 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8083 (unsigned short) (((tempcx & 0x00ff) >> 6)
8084 | 0x18)); /* Enable Dither */
8087 void SetSpectrum(struct vb_device_info *pVBInfo)
8089 unsigned short index;
8091 index = XGI_GetLCDCapPtr(pVBInfo);
8093 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
8094 XGI_LongWait(pVBInfo);
8095 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
8096 XGI_LongWait(pVBInfo);
8098 XGINew_SetReg1(pVBInfo->Part4Port, 0x31,
8099 pVBInfo->LCDCapList[index].Spectrum_31);
8100 XGINew_SetReg1(pVBInfo->Part4Port, 0x32,
8101 pVBInfo->LCDCapList[index].Spectrum_32);
8102 XGINew_SetReg1(pVBInfo->Part4Port, 0x33,
8103 pVBInfo->LCDCapList[index].Spectrum_33);
8104 XGINew_SetReg1(pVBInfo->Part4Port, 0x34,
8105 pVBInfo->LCDCapList[index].Spectrum_34);
8106 XGI_LongWait(pVBInfo);
8107 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
8110 /* --------------------------------------------------------------------- */
8111 /* Function : XGI_SetAntiFlicker */
8114 /* Description : Set TV Customized Param. */
8115 /* --------------------------------------------------------------------- */
8116 void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
8117 struct vb_device_info *pVBInfo)
8119 unsigned short tempbx, index;
8121 unsigned char tempah;
8123 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
8126 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8130 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
8132 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
8135 tempah = TVAntiFlickList[tempbx];
8136 tempah = tempah << 4;
8138 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
8141 void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
8142 struct vb_device_info *pVBInfo)
8144 unsigned short tempbx, index;
8146 unsigned char tempah;
8148 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8152 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
8154 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
8157 tempah = TVEdgeList[tempbx];
8158 tempah = tempah << 5;
8160 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
8163 void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
8165 unsigned short tempbx;
8167 unsigned char tempcl, tempch;
8169 unsigned long tempData;
8171 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
8172 tempData = TVPhaseList[tempbx];
8174 XGINew_SetReg1(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
8176 XGINew_SetReg1(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
8177 & 0x0000FF00) >> 8));
8178 XGINew_SetReg1(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
8179 & 0x00FF0000) >> 16));
8180 XGINew_SetReg1(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
8181 & 0xFF000000) >> 24));
8184 void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
8185 struct vb_device_info *pVBInfo)
8187 unsigned short tempbx, index;
8189 unsigned char tempcl, tempch, tempal, *filterPtr;
8191 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
8196 filterPtr = NTSCYFilter1;
8200 filterPtr = PALYFilter1;
8206 filterPtr = PALMYFilter1;
8210 filterPtr = PALNYFilter1;
8215 filterPtr = NTSCYFilter2;
8219 filterPtr = PALMYFilter2;
8223 filterPtr = PALNYFilter2;
8227 filterPtr = PALYFilter2;
8235 tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
8238 = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
8245 if ((tempcl == 0) && (tempch == 1)) {
8246 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, 0);
8247 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, 0);
8248 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, 0);
8249 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8251 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
8252 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
8253 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
8254 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8257 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8258 | VB_XGI302LV | VB_XGI301C)) {
8259 XGINew_SetReg1(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
8260 XGINew_SetReg1(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
8261 XGINew_SetReg1(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
8265 /* --------------------------------------------------------------------- */
8266 /* Function : XGI_GetTVPtrIndex2 */
8268 /* Output : bx 0 : NTSC */
8272 /* 4 : NTSC1024x768 */
8273 /* 5 : PAL-M 1024x768 */
8275 /* cl 0 : YFilter1 */
8278 /* 1 : 301B/302B/301LV/302LV */
8280 /* --------------------------------------------------------------------- */
8281 void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
8282 unsigned char *tempch, struct vb_device_info *pVBInfo)
8288 if (pVBInfo->TVInfo & SetPALTV)
8291 if (pVBInfo->TVInfo & SetPALMTV)
8294 if (pVBInfo->TVInfo & SetPALNTV)
8297 if (pVBInfo->TVInfo & NTSC1024x768) {
8299 if (pVBInfo->TVInfo & SetPALMTV)
8303 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8304 | VB_XGI302LV | VB_XGI301C)) {
8305 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
8312 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8313 | VB_XGI302LV | VB_XGI301C))
8317 /* --------------------------------------------------------------------- */
8318 /* Function : XGI_SetCRT2ModeRegs */
8321 /* Description : Origin code for crt2group */
8322 /* --------------------------------------------------------------------- */
8323 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
8324 struct xgi_hw_device_info *HwDeviceExtension,
8325 struct vb_device_info *pVBInfo)
8327 unsigned short tempbl;
8330 unsigned char tempah;
8332 /* XGINew_SetReg1(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
8334 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8335 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00);
8336 tempah &= ~0x10; /* BTRAMDAC */
8337 tempah |= 0x40; /* BTRAM */
8339 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8341 tempah = 0x40; /* BTDRAM */
8342 if (ModeNo > 0x13) {
8343 tempcl = pVBInfo->ModeType;
8346 tempah = (0x008 >> tempcl); /* BT Color */
8352 if (pVBInfo->VBInfo & SetInSlaveMode)
8353 tempah ^= 0x50; /* BTDAC */
8358 if (pVBInfo->VBInfo & DisableCRT2Display) {
8362 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8363 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
8364 tempcl = pVBInfo->ModeType;
8365 if (ModeNo > 0x13) {
8367 if ((tempcl > 0) || (tempcl == 0)) {
8368 tempah=(0x008>>tempcl) ;
8377 if (pVBInfo->VBInfo & SetInSlaveMode) {
8378 tempah = (tempah ^ 0x050);
8383 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8387 if (pVBInfo->VBInfo & DisableCRT2Display) {
8388 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
8393 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8394 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
8395 if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
8396 && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
8399 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e,
8402 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8407 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
8408 | SetCRT2ToTV | SetCRT2ToLCD)) {
8412 if (!(pVBInfo->VBInfo & SetInSlaveMode))
8415 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
8416 tempah = tempah ^ 0x05;
8417 if (!(pVBInfo->VBInfo
8419 tempah = tempah ^ 0x01;
8422 if (!(pVBInfo->VBInfo
8423 & SetCRT2ToDualEdge))
8425 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8426 0x2e, tempbl, tempah);
8428 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8429 0x2e, tempbl, tempah);
8433 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl,
8438 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
8441 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
8442 & SetInSlaveMode))) {
8447 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8448 /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
8450 if (ModeNo > 0x13) {
8451 if (pVBInfo->VBInfo & DriverMode)
8452 tempah = tempah ^ 0x20;
8457 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
8460 if (pVBInfo->LCDInfo & SetLCDDualLink)
8463 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8464 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
8465 if (pVBInfo->TVInfo & RPLLDIV2XO)
8470 if ((pVBInfo->LCDResInfo == Panel1280x1024)
8471 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
8474 if (pVBInfo->LCDResInfo == Panel1280x960)
8477 XGINew_SetReg1(pVBInfo->Part4Port, 0x0C, tempah);
8480 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8481 | VB_XGI302LV | VB_XGI301C)) {
8485 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8487 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8488 tempah |= 0x04; /* shampoo 0129 */
8491 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x13, tempbl, tempah);
8494 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8495 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8499 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
8503 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8504 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8507 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, tempbl, tempah);
8512 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
8514 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
8518 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x23, tempbl, tempah);
8520 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8521 if (pVBInfo->LCDInfo & SetLCDDualLink) {
8522 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x20);
8523 XGINew_SetRegOR(pVBInfo->Part4Port, 0x34, 0x10);
8528 void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8529 struct vb_device_info *pVBInfo)
8531 unsigned short tempbx;
8535 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8540 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8541 struct vb_device_info *pVBInfo)
8543 unsigned short tempbx;
8547 void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
8548 unsigned short RefreshRateTableIndex,
8549 struct vb_device_info *pVBInfo)
8551 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
8552 StandTableIndex, CRT1Index;
8554 pVBInfo->RVBHCMAX = 1;
8555 pVBInfo->RVBHCFACT = 1;
8557 if (ModeNo <= 0x13) {
8558 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8559 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8560 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
8561 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
8562 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
8564 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8566 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
8567 CRT1Index &= IndexMask;
8569 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
8571 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
8572 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
8574 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
8576 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
8579 tempcx = tempcx << 2;
8582 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
8592 if (modeflag & Charx8Dot)
8597 pVBInfo->VGAHT = tempax;
8598 pVBInfo->HT = tempax;
8600 pVBInfo->VGAVT = tempbx;
8601 pVBInfo->VT = tempbx;
8604 unsigned short XGI_GetColorDepth(unsigned short ModeNo,
8605 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
8607 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
8609 unsigned short modeflag;
8612 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8614 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8616 index = (modeflag & ModeInfoFlag) - ModeEGA;
8621 return ColorDepth[index];
8624 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8625 struct vb_device_info *pVBInfo)
8628 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
8632 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8633 struct vb_device_info *pVBInfo)
8636 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
8640 void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
8642 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
8645 void XGINew_LCD_Wait_Time(unsigned char DelayTime,
8646 struct vb_device_info *pVBInfo)
8648 unsigned short i, j;
8650 unsigned long temp, flag;
8653 /* printk("XGINew_LCD_Wait_Time"); */
8655 for (i = 0; i < DelayTime; i++) {
8656 for (j = 0; j < 66; j++) {
8657 temp = XGINew_GetReg3(0x61);
8658 /* temp &= 0x10000000; */
8668 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
8670 unsigned short flag;
8672 if (pVBInfo->IF_DEF_LVDS == 1) {
8675 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
8676 if ((flag == 1) || (flag == 2))
8677 return 1; /* 301b */
8683 void XGI_LongWait(struct vb_device_info *pVBInfo)
8687 i = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
8690 for (i = 0; i < 0xFFFF; i++) {
8691 if (!(XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8695 for (i = 0; i < 0xFFFF; i++) {
8696 if ((XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8702 void XGI_VBLongWait(struct vb_device_info *pVBInfo)
8704 unsigned short tempal, temp, i, j;
8706 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
8708 for (i = 0; i < 3; i++) {
8709 for (j = 0; j < 100; j++) {
8710 tempal = XGINew_GetReg2(pVBInfo->P3da);
8711 if (temp & 0x01) { /* VBWaitMode2 */
8712 if ((tempal & 0x08))
8715 if (!(tempal & 0x08))
8718 } else { /* VBWaitMode1 */
8719 if (!(tempal & 0x08))
8722 if ((tempal & 0x08))
8729 XGI_LongWait(pVBInfo);
8734 unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
8736 unsigned long tempax, tempbx;
8738 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
8740 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
8741 tempax = (tempax * pVBInfo->HT) / tempbx;
8743 return (unsigned short) tempax;
8746 unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
8747 unsigned short ModeIdIndex,
8748 unsigned short RefreshRateTableIndex,
8749 struct xgi_hw_device_info *HwDeviceExtension,
8750 struct vb_device_info *pVBInfo)
8752 unsigned short tempbx;
8754 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8756 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
8757 VCLK108_2 + 5, VCLK108_2 + 5 };
8758 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
8759 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8761 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8764 unsigned short CRT2Index, VCLKIndex;
8765 unsigned short modeflag, resinfo;
8766 unsigned char *CHTVVCLKPtr = NULL;
8768 if (ModeNo <= 0x13) {
8769 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8770 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
8771 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
8773 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
8774 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
8776 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
8779 if (pVBInfo->IF_DEF_LVDS == 0) {
8780 CRT2Index = CRT2Index >> 6; /* for LCD */
8781 if (((pVBInfo->VBInfo & SetCRT2ToLCD) | SetCRT2ToLCDA)) { /*301b*/
8782 if (pVBInfo->LCDResInfo != Panel1024x768)
8783 VCLKIndex = LCDXlat2VCLK[CRT2Index];
8785 VCLKIndex = LCDXlat1VCLK[CRT2Index];
8786 } else { /* for TV */
8787 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8788 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
8789 if (pVBInfo->SetFlag & RPLLDIV2XO) {
8790 VCLKIndex = HiTVVCLKDIV2;
8795 VCLKIndex = HiTVVCLK;
8801 if (pVBInfo->SetFlag & TVSimuMode) {
8802 if (modeflag & Charx8Dot) {
8817 if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
8818 if (!(pVBInfo->VBExtInfo
8819 == VB_YPbPr1080i)) {
8822 if (!(pVBInfo->VBExtInfo
8826 if (!(pVBInfo->VBExtInfo
8830 if (!(pVBInfo->SetFlag
8839 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8840 if (pVBInfo->SetFlag
8842 VCLKIndex = TVVCLKDIV2;
8854 } else { /* for CRT2 */
8855 VCLKIndex = (unsigned char) XGINew_GetReg2(
8856 (pVBInfo->P3ca + 0x02)); /* Port 3cch */
8857 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
8858 if (ModeNo > 0x13) {
8860 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
8861 VCLKIndex &= IndexMask;
8867 VCLKIndex = CRT2Index;
8869 VCLKIndex = CRT2Index;
8871 if (pVBInfo->IF_DEF_CH7005 == 1) {
8872 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
8876 if (pVBInfo->VBInfo & SetPALTV)
8879 if (pVBInfo->VBInfo & SetCHTVOverScan)
8884 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
8887 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
8890 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
8893 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
8899 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
8902 VCLKIndex = VCLKIndex >> 6;
8903 if ((pVBInfo->LCDResInfo == Panel800x600)
8904 || (pVBInfo->LCDResInfo == Panel320x480))
8905 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
8906 else if ((pVBInfo->LCDResInfo == Panel1024x768)
8907 || (pVBInfo->LCDResInfo
8908 == Panel1024x768x75))
8909 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
8911 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
8914 /* VCLKIndex = VCLKIndex&IndexMask; */