3 #include <linux/delay.h>
4 #include <linux/types.h>
5 #include <linux/version.h>
11 #include "vb_struct.h"
14 #include "vb_setmode.h"
17 #define IndexMask 0xff
18 #ifndef XGI_MASK_DUAL_CHIP
19 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
24 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
25 unsigned short ModeIdIndex,
26 unsigned short RefreshRateTableIndex,
27 unsigned short *i, struct vb_device_info *pVBInfo);
28 static unsigned char XGI_GetModePtr(unsigned short ModeNo,
29 unsigned short ModeIdIndex,
30 struct vb_device_info *pVBInfo);
31 static unsigned short XGI_GetOffset(unsigned short ModeNo,
32 unsigned short ModeIdIndex,
33 unsigned short RefreshRateTableIndex,
34 struct xgi_hw_device_info *HwDeviceExtension,
35 struct vb_device_info *pVBInfo);
36 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
37 unsigned short ModeIdIndex,
38 struct vb_device_info *pVBInfo);
39 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo);
40 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
41 unsigned short ModeIdIndex,
42 unsigned short RefreshRateTableIndex,
43 struct xgi_hw_device_info *HwDeviceExtension,
44 struct vb_device_info *pVBInfo);
45 static void XGI_VBLongWait(struct vb_device_info *pVBInfo);
46 static void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo);
47 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
48 static void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
49 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
50 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
51 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
52 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
53 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
54 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
55 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
56 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
57 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
58 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
59 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo);
60 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo);
62 static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
63 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
64 static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
65 static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
66 static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
67 static void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex);
68 static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
69 static void XGI_SetMiscRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
70 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
71 static void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
72 static void XGI_SetGRCRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
73 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo);
75 static void XGI_SetSync(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
76 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension);
77 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension);
78 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo, struct vb_device_info *pVBInfo);
79 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
80 static void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
81 static void XGI_SetCRT1FIFO(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
82 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
83 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
85 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
86 static void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al, unsigned short dh, struct vb_device_info *pVBInfo);
87 /*void XGI_ClearBuffer(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, struct vb_device_info *pVBInfo);*/
88 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
89 static void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
90 struct vb_device_info *pVBInfo);
91 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
92 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
93 unsigned short RefreshRateTableIndex,
94 struct xgi_hw_device_info *HwDeviceExtension,
95 struct vb_device_info *pVBInfo);
96 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
97 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
98 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
99 static void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, struct vb_device_info *pVBInfo);
100 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
101 static void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
102 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo);
103 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo);
104 static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo);
105 static void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo);
106 static void SetSpectrum(struct vb_device_info *pVBInfo);
107 static void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
108 static void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
109 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo);
110 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
111 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char* tempcl,
112 unsigned char *tempch, struct vb_device_info *pVBInfo);
113 static void XGI_CloseCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
114 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
115 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo);
116 static void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
117 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
118 struct vb_device_info *pVBInfo);
119 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
120 unsigned short ModeNo,
121 unsigned short ModeIdIndex,
122 struct vb_device_info *pVBInfo);
123 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
124 unsigned char *di_1, struct vb_device_info *pVBInfo);
125 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo);
126 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo);
127 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo);
128 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo);
129 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo);
130 static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
131 static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
132 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo);
134 static unsigned short XGINew_MDA_DAC[] = {
135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
136 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
137 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
138 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
140 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
141 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
142 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
144 static unsigned short XGINew_CGA_DAC[] = {
145 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
146 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
147 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
148 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
149 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
150 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
151 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
152 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
154 static unsigned short XGINew_EGA_DAC[] = {
155 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
156 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
157 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
158 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
159 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
160 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
161 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
162 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
164 static unsigned short XGINew_VGA_DAC[] = {
165 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
166 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
167 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
168 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
169 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
170 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
171 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
172 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
173 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
174 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
176 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
178 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable;
179 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable;
180 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
181 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
182 pVBInfo->XGINEWUB_CRT1Table
183 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
185 /* add for new UNIVGABIOS */
186 /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
187 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
189 if (ChipType >= XG40) {
191 = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
193 = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
196 = (struct XGI_MCLKDataStruct *) XGI330New_MCLKData;
198 = (struct XGI_ECLKDataStruct *) XGI330_ECLKData;
201 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData;
202 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData;
203 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
204 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo;
206 = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo;
208 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
209 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
210 pVBInfo->pSR07 = &XGI330_SR07;
211 pVBInfo->LCDResInfo = 0;
212 pVBInfo->LCDTypeInfo = 0;
213 pVBInfo->LCDInfo = 0;
217 pVBInfo->SR15 = XGI340_SR13;
218 pVBInfo->CR40 = XGI340_cr41;
219 pVBInfo->SR25 = XGI330_sr25;
220 pVBInfo->pSR31 = &XGI330_sr31;
221 pVBInfo->pSR32 = &XGI330_sr32;
222 pVBInfo->CR6B = XGI340_CR6B;
223 pVBInfo->CR6E = XGI340_CR6E;
224 pVBInfo->CR6F = XGI340_CR6F;
225 pVBInfo->CR89 = XGI340_CR89;
226 pVBInfo->AGPReg = XGI340_AGPReg;
227 pVBInfo->SR16 = XGI340_SR16;
228 pVBInfo->pCRCF = &XG40_CRCF;
229 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
231 pVBInfo->CR49 = XGI330_CR49;
232 pVBInfo->pSR1F = &XGI330_SR1F;
233 pVBInfo->pSR21 = &XGI330_SR21;
234 pVBInfo->pSR22 = &XGI330_SR22;
235 pVBInfo->pSR23 = &XGI330_SR23;
236 pVBInfo->pSR24 = &XGI330_SR24;
237 pVBInfo->pSR33 = &XGI330_SR33;
239 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
240 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
241 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
242 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
243 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
244 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
245 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
246 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
247 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
248 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
250 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
251 pVBInfo->PALTiming = XGI330_PALTiming;
252 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
253 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
254 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
255 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
256 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
257 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
258 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
259 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
260 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
261 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
262 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
263 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
265 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
266 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
267 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
269 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC;
270 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC;
271 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL;
272 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL;
274 /* 310 customization related */
275 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
276 pVBInfo->LCDCapList = XGI_LCDDLCapList;
278 pVBInfo->LCDCapList = XGI_LCDCapList;
280 if ((ChipType == XG21) || (ChipType == XG27))
281 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList;
283 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
284 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
286 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
288 if (ChipType >= XG20)
289 pVBInfo->pXGINew_CR97 = &XG20_CR97;
291 if (ChipType == XG27) {
293 = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
294 pVBInfo->CR40 = XGI27_cr41;
295 pVBInfo->pXGINew_CR97 = &XG27_CR97;
296 pVBInfo->pSR36 = &XG27_SR36;
297 pVBInfo->pCR8F = &XG27_CR8F;
298 pVBInfo->pCRD0 = XG27_CRD0;
299 pVBInfo->pCRDE = XG27_CRDE;
300 pVBInfo->pSR40 = &XG27_SR40;
301 pVBInfo->pSR41 = &XG27_SR41;
305 if (ChipType >= XG20) {
306 pVBInfo->pDVOSetting = &XG21_DVOSetting;
307 pVBInfo->pCR2E = &XG21_CR2E;
308 pVBInfo->pCR2F = &XG21_CR2F;
309 pVBInfo->pCR46 = &XG21_CR46;
310 pVBInfo->pCR47 = &XG21_CR47;
315 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
316 unsigned short ModeNo)
318 unsigned short ModeIdIndex;
319 /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */
320 struct vb_device_info VBINF;
321 struct vb_device_info *pVBInfo = &VBINF;
322 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
323 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
324 pVBInfo->IF_DEF_LVDS = 0;
325 pVBInfo->IF_DEF_CH7005 = 0;
326 pVBInfo->IF_DEF_LCDA = 1;
327 pVBInfo->IF_DEF_CH7017 = 0;
328 pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */
329 pVBInfo->IF_DEF_VideoCapture = 0;
330 pVBInfo->IF_DEF_ScaleLCD = 0;
331 pVBInfo->IF_DEF_OEMUtil = 0;
332 pVBInfo->IF_DEF_PWD = 0;
334 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
335 pVBInfo->IF_DEF_YPbPr = 0;
336 pVBInfo->IF_DEF_HiVision = 0;
337 pVBInfo->IF_DEF_CRT2Monitor = 0;
338 pVBInfo->VBType = 0; /*set VBType default 0*/
339 } else if (HwDeviceExtension->jChipType >= XG40) {
340 pVBInfo->IF_DEF_YPbPr = 1;
341 pVBInfo->IF_DEF_HiVision = 1;
342 pVBInfo->IF_DEF_CRT2Monitor = 1;
344 pVBInfo->IF_DEF_YPbPr = 1;
345 pVBInfo->IF_DEF_HiVision = 1;
346 pVBInfo->IF_DEF_CRT2Monitor = 0;
349 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
350 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
351 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
352 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
353 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
354 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
355 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
356 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
357 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
358 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
359 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
360 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
361 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
362 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04;
363 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10;
364 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12;
365 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
366 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
368 if (HwDeviceExtension->jChipType == XG21) { /* for x86 Linux, XG21 LVDS */
369 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
370 pVBInfo->IF_DEF_LVDS = 1;
372 if (HwDeviceExtension->jChipType == XG27) {
373 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
374 if (XGINew_GetReg1(pVBInfo->P3d4, 0x30) & 0x20)
375 pVBInfo->IF_DEF_LVDS = 1;
379 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
380 XGI_GetVBType(pVBInfo);
382 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
384 ModeNo = ModeNo & 0x7F;
385 /* XGINew_flag_clearbuffer = 0; */
388 XGINew_flag_clearbuffer = 1;
391 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
393 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
394 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
396 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
398 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
400 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
401 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
402 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
403 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
404 XGI_DisableBridge(HwDeviceExtension, pVBInfo);
405 /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */
407 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
408 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
409 ModeIdIndex, pVBInfo);
411 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
412 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
413 HwDeviceExtension, pVBInfo);
416 if (!(pVBInfo->VBInfo & SwitchToCRT2)) {
417 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
418 ModeIdIndex, pVBInfo);
419 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
420 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
427 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) {
428 switch (HwDeviceExtension->ujVBChipID) {
430 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
431 pVBInfo); /*add for CRT2 */
435 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
436 pVBInfo); /*add for CRT2 */
444 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
445 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
446 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
447 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
450 if (pVBInfo->IF_DEF_LVDS == 1)
451 if (!XGI_XG21CheckLVDSMode(ModeNo, ModeIdIndex, pVBInfo))
454 if (ModeNo <= 0x13) {
456 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag
460 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag
464 pVBInfo->SetFlag = 0;
465 if (pVBInfo->IF_DEF_CH7007 != 1)
466 pVBInfo->VBInfo = DisableCRT2Display;
468 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
470 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex,
473 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
475 if (HwDeviceExtension->jChipType == XG21)
476 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
481 if (ModeNo <= 0x13) {
482 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
484 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
486 pVBInfo->ModeType = modeflag&ModeInfoFlag;
487 pVBInfo->SetFlag = 0x00;
488 pVBInfo->VBInfo = DisableCRT2Display;
489 temp = XGINew_CheckMemorySize(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
494 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
495 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
496 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
499 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
501 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
502 XGI_LockCRT2(HwDeviceExtension, pVBInfo);
508 static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
509 unsigned short ModeNo, unsigned short ModeIdIndex,
510 struct vb_device_info *pVBInfo)
512 unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
514 unsigned short XGINew_P3cc = pVBInfo->P3cc;
516 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
517 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
518 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
519 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
520 XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
521 XGI_SetMiscRegs(StandTableIndex, pVBInfo);
522 XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
523 XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
524 XGI_SetGRCRegs(StandTableIndex, pVBInfo);
525 XGI_ClearExt1Regs(pVBInfo);
527 /* if (pVBInfo->IF_DEF_ExpLink) */
528 if (HwDeviceExtension->jChipType == XG27) {
529 if (pVBInfo->IF_DEF_LVDS == 0)
530 XGI_SetDefaultVCLK(pVBInfo);
533 temp = ~ProgrammingCRT2;
534 pVBInfo->SetFlag &= temp;
535 pVBInfo->SelectCRT2Rate = 0;
537 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
538 | VB_XGI302LV | VB_XGI301C)) {
539 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA
541 pVBInfo->SetFlag |= ProgrammingCRT2;
545 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
546 ModeIdIndex, pVBInfo);
547 if (RefreshRateTableIndex != 0xFFFF) {
548 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
549 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
550 pVBInfo, HwDeviceExtension);
551 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
552 RefreshRateTableIndex, pVBInfo);
553 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
554 HwDeviceExtension, pVBInfo);
555 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
556 RefreshRateTableIndex, pVBInfo);
559 if ((HwDeviceExtension->jChipType >= XG20)
560 && (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
561 if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
562 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x4E);
563 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE9);
564 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc);
565 XGINew_SetReg3(XGINew_P3cc, (b3CC |= 0x0C));
566 } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
568 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
569 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE3);
570 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc);
571 XGINew_SetReg3(XGINew_P3cc, (b3CC |= 0x0C));
575 if (HwDeviceExtension->jChipType >= XG21) {
576 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
579 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x20); *//* Enable write GPIOF */
580 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x48, ~0x20); *//* P. DWN */
581 /* XG21 CRT1 Timing */
582 if (HwDeviceExtension->jChipType == XG27)
583 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
584 RefreshRateTableIndex, pVBInfo);
586 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
587 RefreshRateTableIndex, pVBInfo);
589 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
590 RefreshRateTableIndex);
592 if (HwDeviceExtension->jChipType == XG27)
593 XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex,
596 XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex,
599 if (pVBInfo->IF_DEF_LVDS == 1) {
600 if (HwDeviceExtension->jChipType == XG27)
601 XGI_SetXG27LVDSPara(ModeNo,
602 ModeIdIndex, pVBInfo);
604 XGI_SetXG21LVDSPara(ModeNo,
605 ModeIdIndex, pVBInfo);
607 /* XGINew_SetRegOR(pVBInfo->P3d4, 0x48, 0x20); *//* P. ON */
611 pVBInfo->SetFlag &= (~ProgrammingCRT2);
612 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
613 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
614 RefreshRateTableIndex, pVBInfo);
616 /* XGI_LoadCharacter(); //dif ifdef TVFont */
618 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
619 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
622 static unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
623 struct vb_device_info *pVBInfo)
628 index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
630 if (pVBInfo->ModeType <= 0x02)
631 index = 0x1B; /* 02 -> ModeEGA */
635 return index; /* Get pVBInfo->StandTable index */
639 unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) {
644 /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) {
649 static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
650 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
652 unsigned char tempah, SRdata;
654 unsigned short i, modeflag;
657 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
659 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
661 XGINew_SetReg1(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
662 tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
665 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
668 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
669 if (pVBInfo->VBInfo & SetInSlaveMode)
674 tempah |= 0x20; /* screen off */
675 XGINew_SetReg1(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
677 for (i = 02; i <= 04; i++) {
678 SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; /* Get SR2,3,4 from file */
679 XGINew_SetReg1(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
683 static void XGI_SetMiscRegs(unsigned short StandTableIndex,
684 struct vb_device_info *pVBInfo)
686 unsigned char Miscdata;
688 Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; /* Get Misc from file */
690 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
691 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
697 XGINew_SetReg3(pVBInfo->P3c2, Miscdata); /* Set Misc(3c2) */
700 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
701 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
703 unsigned char CRTCdata;
706 CRTCdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
708 XGINew_SetReg1(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
710 for (i = 0; i <= 0x18; i++) {
711 CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; /* Get CRTC from file */
712 XGINew_SetReg1(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
715 if ((HwDeviceExtension->jChipType == XGI_630) && (HwDeviceExtension->jChipRevision == 0x30)) {
716 if (pVBInfo->VBInfo & SetInSlaveMode) {
717 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
718 XGINew_SetReg1(pVBInfo->P3d4, 0x18, 0xFE);
725 static void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
726 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
728 unsigned char ARdata;
729 unsigned short i, modeflag;
732 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
734 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
736 for (i = 0; i <= 0x13; i++) {
737 ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
738 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
740 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
743 if (pVBInfo->VBInfo & (SetCRT2ToTV
753 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
754 XGINew_SetReg3(pVBInfo->P3c0, i); /* set index */
755 XGINew_SetReg3(pVBInfo->P3c0, ARdata); /* set data */
758 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
759 XGINew_SetReg3(pVBInfo->P3c0, 0x14); /* set index */
760 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data */
761 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
762 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
765 static void XGI_SetGRCRegs(unsigned short StandTableIndex,
766 struct vb_device_info *pVBInfo)
768 unsigned char GRdata;
771 for (i = 0; i <= 0x08; i++) {
772 GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; /* Get GR from file */
773 XGINew_SetReg1(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
776 if (pVBInfo->ModeType > ModeVGA) {
777 GRdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3ce, 0x05);
778 GRdata &= 0xBF; /* 256 color disable */
779 XGINew_SetReg1(pVBInfo->P3ce, 0x05, GRdata);
783 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
787 for (i = 0x0A; i <= 0x0E; i++)
788 XGINew_SetReg1(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
791 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
794 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
795 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
796 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
798 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
799 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
800 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
802 XGINew_SetRegAND(pVBInfo->P3c4, 0x31, ~0x30);
806 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
807 unsigned short ModeNo, unsigned short ModeIdIndex,
808 struct vb_device_info *pVBInfo)
810 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
811 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
814 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
817 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
819 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
821 if (pVBInfo->IF_DEF_CH7005 == 1) {
822 if (pVBInfo->VBInfo & SetCRT2ToTV) {
823 if (modeflag & HalfDCLK)
831 index = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
832 index = index >> pVBInfo->SelectCRT2Rate;
835 if (pVBInfo->LCDInfo & LCDNonExpanding)
841 if (pVBInfo->SetFlag & ProgrammingCRT2) {
842 if (pVBInfo->IF_DEF_CH7005 == 1) {
843 if (pVBInfo->VBInfo & SetCRT2ToTV)
847 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
848 if (pVBInfo->IF_DEF_LVDS == 0) {
849 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
850 | VB_XGI301LV | VB_XGI302LV
853 = LCDARefreshIndex[pVBInfo->LCDResInfo
857 = LCDRefreshIndex[pVBInfo->LCDResInfo
868 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
869 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
870 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
872 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & XG2xNotSupport) {
876 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800)
877 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
881 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
882 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024)
883 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
887 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280)
888 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
896 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].ModeID
900 = pVBInfo->RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
901 temp &= ModeInfoFlag;
902 if (temp < pVBInfo->ModeType)
907 } while (index != 0xFFFF);
908 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
909 if (pVBInfo->VBInfo & SetInSlaveMode) {
911 = pVBInfo->RefIndex[RefreshRateTableIndex
912 + i - 1].Ext_InfoFlag;
913 if (temp & InterlaceMode)
918 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
919 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
920 RefreshRateTableIndex, &i, pVBInfo);
922 return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */
925 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
926 unsigned short ModeIdIndex,
927 unsigned short RefreshRateTableIndex, unsigned short *i,
928 struct vb_device_info *pVBInfo)
930 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
933 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
935 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
937 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
938 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
941 if (pVBInfo->IF_DEF_LVDS == 0) {
942 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
943 tempax |= SupportRAMDAC2;
945 if (pVBInfo->VBType & VB_XGI301C)
946 tempax |= SupportCRT2in301C;
949 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */
950 tempax |= SupportLCD;
952 if (pVBInfo->LCDResInfo != Panel1280x1024) {
953 if (pVBInfo->LCDResInfo != Panel1280x960) {
954 if (pVBInfo->LCDInfo & LCDNonExpanding) {
964 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
965 if ((pVBInfo->VBType & VB_XGI301LV)
966 && (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
967 tempax |= SupportYPbPr;
968 if (pVBInfo->VBInfo & SetInSlaveMode) {
979 tempax |= SupportHiVisionTV;
980 if (pVBInfo->VBInfo & SetInSlaveMode) {
995 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
996 | SetCRT2ToSVIDEO | SetCRT2ToSCART
997 | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) {
1000 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
1001 | VB_XGI301LV | VB_XGI302LV
1003 tempax |= SupportTV1024;
1006 if (!(pVBInfo->VBInfo & SetPALTV)) {
1007 if (modeflag & NoSupportSimuTV) {
1010 if (!(pVBInfo->VBInfo
1011 & SetNotSimuMode)) {
1019 } else { /* for LVDS */
1020 if (pVBInfo->IF_DEF_CH7005 == 1) {
1021 if (pVBInfo->VBInfo & SetCRT2ToTV)
1022 tempax |= SupportCHTV;
1025 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
1026 tempax |= SupportLCD;
1029 return 0; /* 1024x768 */
1031 if (pVBInfo->LCDResInfo < Panel1024x768) {
1033 return 0; /* 800x600 */
1035 if (resinfo == 0x04)
1036 return 0; /* 512x384 */
1041 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == tempbx; (*i)--) {
1043 = pVBInfo->RefIndex[RefreshRateTableIndex
1044 + (*i)].Ext_InfoFlag;
1045 if (infoflag & tempax)
1052 for ((*i) = 0;; (*i)++) {
1054 = pVBInfo->RefIndex[RefreshRateTableIndex
1055 + (*i)].Ext_InfoFlag;
1056 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
1061 if (infoflag & tempax)
1067 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
1068 struct vb_device_info *pVBInfo)
1070 unsigned short sync, temp;
1072 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; /* di+0x00 */
1076 XGINew_SetReg3(pVBInfo->P3c2, temp); /* Set Misc(3c2) */
1079 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1080 unsigned short RefreshRateTableIndex,
1081 struct vb_device_info *pVBInfo,
1082 struct xgi_hw_device_info *HwDeviceExtension)
1084 unsigned char index, data;
1087 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */
1088 index = index & IndexMask;
1090 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1092 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1094 for (i = 0; i < 8; i++)
1095 pVBInfo->TimingH[0].data[i]
1096 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
1098 for (i = 0; i < 7; i++)
1099 pVBInfo->TimingV[0].data[i]
1100 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
1102 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
1104 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
1106 if (pVBInfo->ModeType > 0x03)
1107 XGINew_SetReg1(pVBInfo->P3d4, 0x14, 0x4F);
1110 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
1111 struct xgi_hw_device_info *HwDeviceExtension)
1113 unsigned char data, data1, pushax;
1114 unsigned short i, j;
1116 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
1117 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
1118 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
1120 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
1122 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data);
1124 data = pVBInfo->TimingH[0].data[0];
1125 XGINew_SetReg1(pVBInfo->P3d4, 0, data);
1127 for (i = 0x01; i <= 0x04; i++) {
1128 data = pVBInfo->TimingH[0].data[i];
1129 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 1), data);
1132 for (i = 0x05; i <= 0x06; i++) {
1133 data = pVBInfo->TimingH[0].data[i];
1134 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i + 6), data);
1137 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1139 data = pVBInfo->TimingH[0].data[7];
1142 XGINew_SetReg1(pVBInfo->P3c4, 0x0e, data);
1144 if (HwDeviceExtension->jChipType >= XG20) {
1145 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x04);
1147 XGINew_SetReg1(pVBInfo->P3d4, 0x04, data);
1148 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x05);
1154 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4,
1157 XGINew_SetReg1(pVBInfo->P3c4, 0x0c, data);
1162 XGINew_SetReg1(pVBInfo->P3d4, 0x05, data);
1163 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1169 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0e, ~0xE0, data);
1173 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo,
1174 struct vb_device_info *pVBInfo)
1177 unsigned short i, j;
1179 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
1180 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
1181 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
1183 for (i = 0x00; i <= 0x01; i++) {
1184 data = pVBInfo->TimingV[0].data[i];
1185 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 6), data);
1188 for (i = 0x02; i <= 0x03; i++) {
1189 data = pVBInfo->TimingV[0].data[i];
1190 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
1193 for (i = 0x04; i <= 0x05; i++) {
1194 data = pVBInfo->TimingV[0].data[i];
1195 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
1198 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0a);
1200 data = pVBInfo->TimingV[0].data[6];
1203 XGINew_SetReg1(pVBInfo->P3c4, 0x0a, data);
1205 data = pVBInfo->TimingV[0].data[6];
1210 i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1212 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1214 i &= DoubleScanMode;
1218 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x09);
1221 XGINew_SetReg1(pVBInfo->P3d4, 0x09, data);
1224 /* --------------------------------------------------------------------- */
1225 /* Function : XGI_SetXG21CRTC */
1226 /* Input : Stand or enhance CRTC table */
1227 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1228 /* Description : Set LCD timing */
1229 /* --------------------------------------------------------------------- */
1230 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1231 unsigned short RefreshRateTableIndex,
1232 struct vb_device_info *pVBInfo)
1234 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1235 unsigned short Temp1, Temp2, Temp3;
1237 if (ModeNo <= 0x13) {
1238 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
1239 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
1240 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
1241 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
1242 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
1244 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
1245 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1246 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
1247 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
1248 Tempdx <<= 2; /* Tempdx << 2 */
1249 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
1250 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
1252 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR16 VRS */
1253 Tempbx = Tempax; /* Tempbx=Tempax */
1254 Tempax &= 0x01; /* Tempax: VRS[0] */
1255 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
1256 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax: CR7 VRS */
1257 Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
1258 Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
1259 Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
1260 Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
1261 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempdx); /* SR34[7:0]: VRS[8:1] */
1263 Temp1 = Tempcx << 1; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
1264 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
1265 Tempax &= 0x80; /* Tempax[7]: CR7[7] */
1266 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
1267 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
1269 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR16 VRE */
1270 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1271 Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
1272 Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
1273 Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
1274 if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
1275 Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
1276 Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
1277 Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
1278 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
1279 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
1280 Temp1 >>= 9; /* [10:9]->[1:0] */
1281 Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
1282 Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
1284 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
1286 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
1287 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1288 Tempcx = Tempax; /* Tempcx: HRS */
1289 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
1291 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
1292 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
1293 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
1294 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
1295 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
1297 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
1298 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
1300 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
1301 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
1302 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
1303 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
1305 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
1306 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
1308 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
1309 if (Tempax < Tempcx) /* HRE < HRS */
1310 Temp2 |= 0x40; /* Temp2 + 0x40 */
1313 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
1314 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
1315 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1316 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
1317 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1318 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
1320 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
1321 Tempbx = Tempax; /* Tempbx: VRS */
1322 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
1323 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
1324 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[2][7] VRE */
1325 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
1326 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
1327 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
1328 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
1329 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
1331 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
1332 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
1333 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
1335 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
1336 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
1337 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SRA */
1338 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
1340 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
1341 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
1343 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
1344 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1345 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SRA */
1346 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
1347 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
1348 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
1349 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
1350 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
1352 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
1353 if (Tempax < Temp3) /* VRE < VRS */
1354 Temp2 |= 0x20; /* VRE + 0x20 */
1357 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
1358 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
1359 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
1360 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
1361 Tempbx = (unsigned char) Temp1;
1362 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1364 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
1368 static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1369 unsigned short RefreshRateTableIndex,
1370 struct vb_device_info *pVBInfo)
1372 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1374 if (ModeNo <= 0x13) {
1375 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
1376 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
1377 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
1378 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
1379 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
1381 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
1382 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1383 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
1384 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
1385 Tempdx <<= 2; /* Tempdx << 2 */
1386 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
1387 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
1389 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR10 VRS */
1390 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
1391 Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
1392 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1393 Tempbx = Tempax; /* Tempbx=CR07 */
1394 Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
1396 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35 D[0]->VRS D[8] */
1397 Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
1398 Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
1400 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR11 VRE */
1401 Tempax &= 0x0F; /* Tempax: VRE[3:0] */
1402 Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
1403 Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
1404 Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
1405 if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
1406 Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
1407 Tempax = (unsigned char) Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1408 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
1409 Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
1410 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F D[7:2]->VRE D[5:0] */
1411 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); /* SR35 D[2:1]->VRS[10:9] */
1413 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
1414 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1415 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
1416 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
1418 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
1419 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1420 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1422 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
1423 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
1424 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
1426 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
1427 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
1428 Tempax <<= 3; /* Tempax[5]: HRE[5] */
1429 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
1431 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
1432 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
1434 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1435 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
1436 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
1437 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1439 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
1440 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1441 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1442 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1443 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1444 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
1446 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
1447 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */
1449 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
1450 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[7][2] VRS[9][8] */
1451 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
1452 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
1453 Tempax >>= 2; /* Tempax[0]: VRS[8] */
1454 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35[0]: VRS[8] */
1455 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
1456 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
1457 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SR0A */
1458 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1459 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
1461 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
1462 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1463 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SR0A */
1464 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
1465 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
1466 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
1467 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
1468 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
1469 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
1471 if (Tempbx <= Tempcx) /* VRE <= VRS */
1472 Tempbx |= 0x20; /* VRE + 0x20 */
1474 Tempax = (Tempbx << 2) & 0xFF; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1475 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F[7:2]:VRE[5:0] */
1476 Tempax = Tempcx >> 8;
1477 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, Tempax); /* SR35[2:0]:VRS[10:8] */
1481 /* --------------------------------------------------------------------- */
1482 /* Function : XGI_SetXG21LCD */
1484 /* Output : FCLK duty cycle, FCLK delay compensation */
1485 /* Description : All values set zero */
1486 /* --------------------------------------------------------------------- */
1487 static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
1488 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
1490 unsigned short Data, Temp, b3CC;
1491 unsigned short XGI_P3cc;
1493 XGI_P3cc = pVBInfo->P3cc;
1495 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
1496 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
1497 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
1498 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
1499 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1500 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1501 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1502 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1503 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1506 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
1509 XGINew_SetRegOR(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */
1510 XGINew_SetRegOR(pVBInfo->P3c4, 0x09, 0x40);
1513 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1515 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20);
1516 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80);
1518 if (ModeNo <= 0x13) {
1519 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1521 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1523 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1525 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1527 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1529 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1533 static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
1534 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
1536 unsigned short Data, Temp, b3CC;
1537 unsigned short XGI_P3cc;
1539 XGI_P3cc = pVBInfo->P3cc;
1541 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
1542 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
1543 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
1544 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
1546 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
1547 if ((Temp & 0x03) == 0) { /* dual 12 */
1548 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x13);
1549 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x13);
1552 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1553 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1554 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1555 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1556 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1559 XGI_SetXG27FPBits(pVBInfo);
1561 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1563 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
1564 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
1566 if (ModeNo <= 0x13) {
1567 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1569 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1571 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1573 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1575 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1577 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1581 /* --------------------------------------------------------------------- */
1582 /* Function : XGI_UpdateXG21CRTC */
1584 /* Output : CRT1 CRTC */
1585 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1586 /* --------------------------------------------------------------------- */
1587 static void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo,
1588 unsigned short RefreshRateTableIndex)
1592 XGINew_SetRegAND(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
1593 if (ModeNo <= 0x13) {
1594 for (i = 0; i < 12; i++) {
1595 if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
1600 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1603 else if (ModeNo == 0x2E
1604 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1607 else if (ModeNo == 0x2F)
1609 else if (ModeNo == 0x50)
1611 else if (ModeNo == 0x59)
1616 XGINew_SetReg1(pVBInfo->P3d4, 0x02,
1617 pVBInfo->UpdateCRT1[index].CR02);
1618 XGINew_SetReg1(pVBInfo->P3d4, 0x03,
1619 pVBInfo->UpdateCRT1[index].CR03);
1620 XGINew_SetReg1(pVBInfo->P3d4, 0x15,
1621 pVBInfo->UpdateCRT1[index].CR15);
1622 XGINew_SetReg1(pVBInfo->P3d4, 0x16,
1623 pVBInfo->UpdateCRT1[index].CR16);
1627 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1628 unsigned short ModeNo, unsigned short ModeIdIndex,
1629 unsigned short RefreshRateTableIndex,
1630 struct vb_device_info *pVBInfo)
1632 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1636 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1638 if (ModeNo <= 0x13) {
1639 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1640 tempax = pVBInfo->StResInfo[resindex].HTotal;
1641 tempbx = pVBInfo->StResInfo[resindex].VTotal;
1643 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1644 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
1645 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
1648 if (modeflag & HalfDCLK)
1649 tempax = tempax >> 1;
1651 if (ModeNo > 0x13) {
1652 if (modeflag & HalfDCLK)
1653 tempax = tempax << 1;
1655 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1657 if (temp & InterlaceMode)
1658 tempbx = tempbx >> 1;
1660 if (modeflag & DoubleScanMode)
1661 tempbx = tempbx << 1;
1666 /* if (!(modeflag & Charx8Dot)) */
1673 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1674 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1676 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1677 XGINew_SetReg1(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
1678 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0b, ~0x0c,
1679 (unsigned short) ((tempcx & 0x0ff00) >> 10));
1680 XGINew_SetReg1(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
1682 tempbx = tempbx >> 8;
1690 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x42, tempax);
1691 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x07);
1698 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
1699 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp);
1702 unsigned short XGI_GetResInfo(unsigned short ModeNo,
1703 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1705 unsigned short resindex;
1708 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1710 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1714 static void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex,
1715 unsigned short RefreshRateTableIndex,
1716 struct xgi_hw_device_info *HwDeviceExtension,
1717 struct vb_device_info *pVBInfo)
1719 unsigned short temp, ah, al, temp2, i, DisplayUnit;
1722 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
1724 temp = pVBInfo->ScreenOffset[temp];
1726 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1727 temp2 &= InterlaceMode;
1732 temp2 = pVBInfo->ModeType - ModeEGA;
1757 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1758 temp = temp * temp2 + temp2 / 2;
1765 temp = temp >> 8; /* ah */
1767 i = XGINew_GetReg1(pVBInfo->P3c4, 0x0E);
1770 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, i);
1772 temp = (unsigned char) temp2;
1773 temp &= 0xFF; /* al */
1774 XGINew_SetReg1(pVBInfo->P3d4, 0x13, temp);
1776 /* SetDisplayUnit */
1777 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1778 temp2 &= InterlaceMode;
1782 DisplayUnit = DisplayUnit << 5;
1783 ah = (DisplayUnit & 0xff00) >> 8;
1784 al = DisplayUnit & 0x00ff;
1790 if (HwDeviceExtension->jChipType >= XG20)
1791 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1794 XGINew_SetReg1(pVBInfo->P3c4, 0x10, ah);
1797 static void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
1798 struct xgi_hw_device_info *HwDeviceExtension,
1799 unsigned short RefreshRateTableIndex,
1800 struct vb_device_info *pVBInfo)
1802 unsigned char index, data;
1803 unsigned short vclkindex;
1805 if (pVBInfo->IF_DEF_LVDS == 1) {
1806 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1807 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1808 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1809 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1810 pVBInfo->VCLKData[index].SR2B);
1811 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1812 pVBInfo->VCLKData[index].SR2C);
1813 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1814 } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
1815 | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1817 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1818 RefreshRateTableIndex, HwDeviceExtension,
1820 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1821 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1822 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1823 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1824 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1825 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1826 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1828 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1829 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1830 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1831 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1832 pVBInfo->VCLKData[index].SR2B);
1833 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1834 pVBInfo->VCLKData[index].SR2C);
1835 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1838 if (HwDeviceExtension->jChipType >= XG20) {
1839 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & HalfDCLK) {
1840 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2B);
1841 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1842 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2C);
1849 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1854 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1855 struct xgi_hw_device_info *HwDeviceExtension,
1856 struct vb_device_info *pVBInfo)
1858 unsigned short data;
1860 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1862 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1864 if (ModeNo > 0x13) {
1865 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x34);
1866 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1868 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x30);
1869 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1871 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data);
1873 if (HwDeviceExtension->jChipType == XG27) {
1874 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x0E);
1875 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1877 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x20);
1879 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0xAE);
1880 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1882 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data);
1886 if (HwDeviceExtension->jChipType == XG21)
1887 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1890 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1891 unsigned short ModeNo, unsigned short ModeIdIndex,
1892 unsigned short RefreshRateTableIndex,
1893 struct vb_device_info *pVBInfo)
1895 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1898 if (ModeNo > 0x13) {
1899 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1901 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1903 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
1905 if (XGINew_GetReg1(pVBInfo->P3d4, 0x31) & 0x01)
1906 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1915 if (ModeNo > 0x13) {
1916 if (pVBInfo->ModeType > 0x02) {
1918 data3 = pVBInfo->ModeType - ModeVGA;
1924 data &= InterlaceMode;
1929 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1930 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
1931 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1933 xres = pVBInfo->StResInfo[resindex].HTotal;
1935 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1938 if (infoflag & InterlaceMode) {
1941 else if (xres == 1280)
1945 data2 = data & 0x00FF;
1946 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFF, data2);
1947 data2 = (data & 0xFF00) >> 8;
1948 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFC, data2);
1950 if (modeflag & HalfDCLK)
1951 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1955 if (modeflag & LineCompareOff)
1958 if (ModeNo > 0x13) {
1959 if (pVBInfo->ModeType == ModeEGA)
1963 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1965 if (pVBInfo->ModeType != ModeText) {
1967 if (pVBInfo->ModeType != ModeEGA)
1970 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x21, 0x1F, data);
1972 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1975 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
1976 /* if (XGINew_IF_DEF_NEW_LOWRES) */
1977 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); //030305 fix lowresolution bug */
1979 data = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
1981 if (HwDeviceExtension->jChipType == XG27) {
1986 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
1987 XGINew_SetRegOR(pVBInfo->P3d4, 0x51, 0x10);
1988 } else if (HwDeviceExtension->jChipType >= XG20) {
1993 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
1994 XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0x02);
2000 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
2005 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
2006 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
2007 struct vb_device_info *pVBInfo)
2009 unsigned short data, data2 = 0;
2012 unsigned char index;
2017 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2019 VCLK = pVBInfo->VCLKData[index].CLOCK;
2022 data = XGINew_GetReg1(pVBInfo->P3c4, 0x32);
2025 data |= 0x0c; /* VCLK > 200 */
2027 if (HwDeviceExtension->jChipType >= XG20)
2028 data &= ~0x04; /* 2 pixel mode */
2030 XGINew_SetReg1(pVBInfo->P3c4, 0x32, data);
2032 if (HwDeviceExtension->jChipType < XG20) {
2033 data = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
2037 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, data);
2040 /* Jong for Adavantech LCD ripple issue
2041 if ((VCLK >= 0) && (VCLK < 135))
2043 else if ((VCLK >= 135) && (VCLK < 160))
2045 else if ((VCLK >= 160) && (VCLK < 260))
2047 else if (VCLK > 260)
2052 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x07, 0xFC, data2);
2053 if (HwDeviceExtension->jChipType >= XG27)
2054 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
2060 void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2062 unsigned short modeflag;
2065 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2067 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2069 if (ModeNo > 0x13) {
2070 if (modeflag & DoubleScanMode) {
2071 if (modeflag & HalfDCLK) {
2072 if (pVBInfo->VBType & VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
2073 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
2074 if (pVBInfo->VBInfo & SetInSlaveMode) {
2075 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
2076 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
2081 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0xff, 0x80);
2082 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
2087 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
2091 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
2092 struct vb_device_info *pVBInfo)
2094 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
2095 ah, dh, *table = NULL;
2098 data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2100 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2102 data &= DACInfoFlag;
2106 table = XGINew_MDA_DAC;
2107 else if (data == 0x08)
2108 table = XGINew_CGA_DAC;
2109 else if (data == 0x10)
2110 table = XGINew_EGA_DAC;
2111 else if (data == 0x18) {
2113 table = XGINew_VGA_DAC;
2121 XGINew_SetReg3(pVBInfo->P3c6, 0xFF);
2122 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
2124 for (i = 0; i < j; i++) {
2127 for (k = 0; k < 3; k++) {
2136 XGINew_SetReg3(pVBInfo->P3c9, data2);
2142 for (i = 16; i < 32; i++) {
2145 for (k = 0; k < 3; k++)
2146 XGINew_SetReg3(pVBInfo->P3c9, data);
2151 for (m = 0; m < 9; m++) {
2156 for (n = 0; n < 3; n++) {
2157 for (o = 0; o < 5; o++) {
2162 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
2167 for (o = 0; o < 3; o++) {
2172 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
2183 static void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al,
2184 unsigned short dh, struct vb_device_info *pVBInfo)
2186 unsigned short temp, bh, bl;
2205 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) dh);
2206 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) bh);
2207 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) bl);
2210 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
2211 struct xgi_hw_device_info *HwDeviceExtension,
2212 struct vb_device_info *pVBInfo)
2214 unsigned short RefreshRateTableIndex;
2215 /* unsigned short temp ; */
2217 /* pVBInfo->SelectCRT2Rate = 0; */
2219 pVBInfo->SetFlag |= ProgrammingCRT2;
2220 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
2221 ModeIdIndex, pVBInfo);
2222 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
2223 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2224 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2225 HwDeviceExtension, pVBInfo);
2226 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2227 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2230 static void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2231 struct vb_device_info *pVBInfo)
2233 unsigned short resindex, xres, yres, modeflag;
2236 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
2238 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
2240 /* if (ModeNo > 0x13) */
2241 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
2243 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
2246 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
2248 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
2250 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
2252 if (ModeNo <= 0x13) {
2253 xres = pVBInfo->StResInfo[resindex].HTotal;
2254 yres = pVBInfo->StResInfo[resindex].VTotal;
2256 xres = pVBInfo->ModeResInfo[resindex].HTotal;
2257 yres = pVBInfo->ModeResInfo[resindex].VTotal;
2259 if (ModeNo > 0x13) {
2260 if (modeflag & HalfDCLK)
2263 if (modeflag & DoubleScanMode)
2266 /* if (modeflag & Charx8Dot) */
2273 pVBInfo->VGAHDE = xres;
2274 pVBInfo->HDE = xres;
2275 pVBInfo->VGAVDE = yres;
2276 pVBInfo->VDE = yres;
2279 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2280 unsigned short RefreshRateTableIndex,
2281 struct vb_device_info *pVBInfo)
2283 unsigned short tempbx;
2284 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2285 struct XGI330_CHTVDataStruct *TVPtr = NULL;
2289 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2290 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2291 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2293 pVBInfo->VGAHT = LCDPtr->VGAHT;
2294 pVBInfo->VGAVT = LCDPtr->VGAVT;
2295 pVBInfo->HT = LCDPtr->LCDHT;
2296 pVBInfo->VT = LCDPtr->LCDVT;
2298 if (pVBInfo->IF_DEF_CH7017 == 1) {
2299 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2300 TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr(
2301 tempbx, ModeNo, ModeIdIndex,
2302 RefreshRateTableIndex, pVBInfo);
2303 pVBInfo->VGAHT = TVPtr->VGAHT;
2304 pVBInfo->VGAVT = TVPtr->VGAVT;
2305 pVBInfo->HT = TVPtr->LCDHT;
2306 pVBInfo->VT = TVPtr->LCDVT;
2310 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2311 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2312 | EnableScalingLCD))) {
2313 if ((pVBInfo->LCDResInfo == Panel1024x768)
2314 || (pVBInfo->LCDResInfo
2315 == Panel1024x768x75)) {
2316 pVBInfo->HDE = 1024;
2318 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2319 || (pVBInfo->LCDResInfo
2320 == Panel1280x1024x75)) {
2321 pVBInfo->HDE = 1280;
2322 pVBInfo->VDE = 1024;
2323 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2324 pVBInfo->HDE = 1400;
2325 pVBInfo->VDE = 1050;
2327 pVBInfo->HDE = 1600;
2328 pVBInfo->VDE = 1200;
2334 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2335 unsigned short RefreshRateTableIndex,
2336 struct xgi_hw_device_info *HwDeviceExtension,
2337 struct vb_device_info *pVBInfo)
2339 unsigned char index;
2340 unsigned short tempbx, i;
2341 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2342 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2343 /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */
2344 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2345 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2348 index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2350 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2352 index = index & IndexMask;
2354 if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1)
2355 && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2358 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2360 = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr(
2363 RefreshRateTableIndex,
2366 for (i = 0; i < 8; i++)
2367 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2370 if (pVBInfo->IF_DEF_CH7007 == 1) {
2371 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2373 = (struct XGI_CH7007TV_TimingHStruct *) XGI_GetTVPtr(
2377 RefreshRateTableIndex,
2380 for (i = 0; i < 8; i++)
2381 pVBInfo->TimingH[0].data[i]
2382 = CH7007TV_TimingHPtr[0].data[i];
2386 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2387 if (pVBInfo->VBInfo & SetCRT2ToTV)
2388 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2392 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2394 if (pVBInfo->IF_DEF_CH7007 == 1) {
2395 XGINew_SetReg1(pVBInfo->P3c4, 0x2E,
2396 CH7007TV_TimingHPtr[0].data[8]);
2397 XGINew_SetReg1(pVBInfo->P3c4, 0x2F,
2398 CH7007TV_TimingHPtr[0].data[9]);
2403 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2405 = (struct XGI_LVDSCRT1VDataStruct *) XGI_GetLcdPtr(
2408 RefreshRateTableIndex,
2410 for (i = 0; i < 7; i++)
2411 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2414 if (pVBInfo->IF_DEF_CH7007 == 1) {
2415 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2417 = (struct XGI_CH7007TV_TimingVStruct *) XGI_GetTVPtr(
2421 RefreshRateTableIndex,
2424 for (i = 0; i < 7; i++)
2425 pVBInfo->TimingV[0].data[i]
2426 = CH7007TV_TimingVPtr[0].data[i];
2429 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2430 if (pVBInfo->VBInfo & SetCRT2ToTV)
2431 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2435 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2437 if (pVBInfo->IF_DEF_CH7007 == 1) {
2438 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x33, ~0x01,
2439 CH7007TV_TimingVPtr[0].data[7] & 0x01);
2440 XGINew_SetReg1(pVBInfo->P3c4, 0x34,
2441 CH7007TV_TimingVPtr[0].data[8]);
2442 XGINew_SetReg1(pVBInfo->P3c4, 0x3F,
2443 CH7007TV_TimingVPtr[0].data[9]);
2449 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2450 unsigned short RefreshRateTableIndex,
2451 struct vb_device_info *pVBInfo)
2453 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2454 unsigned long temp, temp1, temp2, temp3, push3;
2455 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2456 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2459 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2461 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2463 if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2464 if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo
2465 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
2466 if (pVBInfo->IF_DEF_OEMUtil == 1) {
2469 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2473 RefreshRateTableIndex,
2477 if ((pVBInfo->IF_DEF_OEMUtil == 0) || (LCDPtr == NULL)) {
2479 if (pVBInfo->LCDInfo & EnableScalingLCD)
2481 = (struct XGI330_LCDDataDesStruct2 *) XGI_GetLcdPtr(
2485 RefreshRateTableIndex,
2489 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2493 RefreshRateTableIndex,
2497 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2502 if ((pVBInfo->LCDResInfo == Panel1024x768)
2503 || (pVBInfo->LCDResInfo
2504 == Panel1024x768x75)) {
2507 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2508 || (pVBInfo->LCDResInfo
2509 == Panel1280x1024x75)) {
2512 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2520 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2521 pVBInfo->HDE = tempax;
2522 pVBInfo->VDE = tempbx;
2523 pVBInfo->VGAHDE = tempax;
2524 pVBInfo->VGAVDE = tempbx;
2527 if ((pVBInfo->IF_DEF_ScaleLCD == 1)
2528 && (pVBInfo->LCDInfo & EnableScalingLCD)) {
2529 tempax = pVBInfo->HDE;
2530 tempbx = pVBInfo->VDE;
2533 tempax = pVBInfo->HT;
2535 if (pVBInfo->LCDInfo & EnableScalingLCD)
2536 tempbx = LCDPtr1->LCDHDES;
2538 tempbx = LCDPtr->LCDHDES;
2540 tempcx = pVBInfo->HDE;
2541 tempbx = tempbx & 0x0fff;
2544 if (tempcx >= tempax)
2547 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2549 tempcx = tempcx >> 3;
2550 tempbx = tempbx >> 3;
2552 XGINew_SetReg1(pVBInfo->Part1Port, 0x16,
2553 (unsigned short) (tempbx & 0xff));
2554 XGINew_SetReg1(pVBInfo->Part1Port, 0x17,
2555 (unsigned short) (tempcx & 0xff));
2557 tempax = pVBInfo->HT;
2559 if (pVBInfo->LCDInfo & EnableScalingLCD)
2560 tempbx = LCDPtr1->LCDHRS;
2562 tempbx = LCDPtr->LCDHRS;
2566 if (pVBInfo->LCDInfo & EnableScalingLCD)
2567 tempcx = LCDPtr1->LCDHSync;
2571 if (tempcx >= tempax)
2574 tempax = tempbx & 0x07;
2575 tempax = tempax >> 5;
2576 tempcx = tempcx >> 3;
2577 tempbx = tempbx >> 3;
2582 XGINew_SetReg1(pVBInfo->Part1Port, 0x15, tempax);
2583 XGINew_SetReg1(pVBInfo->Part1Port, 0x14,
2584 (unsigned short) (tempbx & 0xff));
2586 tempax = pVBInfo->VT;
2587 if (pVBInfo->LCDInfo & EnableScalingLCD)
2588 tempbx = LCDPtr1->LCDVDES;
2590 tempbx = LCDPtr->LCDVDES;
2591 tempcx = pVBInfo->VDE;
2593 tempbx = tempbx & 0x0fff;
2595 if (tempcx >= tempax)
2598 XGINew_SetReg1(pVBInfo->Part1Port, 0x1b,
2599 (unsigned short) (tempbx & 0xff));
2600 XGINew_SetReg1(pVBInfo->Part1Port, 0x1c,
2601 (unsigned short) (tempcx & 0xff));
2603 tempbx = (tempbx >> 8) & 0x07;
2604 tempcx = (tempcx >> 8) & 0x07;
2606 XGINew_SetReg1(pVBInfo->Part1Port, 0x1d,
2607 (unsigned short) ((tempcx << 3)
2610 tempax = pVBInfo->VT;
2611 if (pVBInfo->LCDInfo & EnableScalingLCD)
2612 tempbx = LCDPtr1->LCDVRS;
2614 tempbx = LCDPtr->LCDVRS;
2616 /* tempbx = tempbx >> 4; */
2619 if (pVBInfo->LCDInfo & EnableScalingLCD)
2620 tempcx = LCDPtr1->LCDVSync;
2623 if (tempcx >= tempax)
2626 XGINew_SetReg1(pVBInfo->Part1Port, 0x18,
2627 (unsigned short) (tempbx & 0xff));
2628 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f,
2629 (unsigned short) (tempcx & 0x0f));
2631 tempax = ((tempbx >> 8) & 0x07) << 3;
2633 tempbx = pVBInfo->VGAVDE;
2634 if (tempbx != pVBInfo->VDE)
2637 if (pVBInfo->LCDInfo & EnableLVDSDDA)
2640 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1a, 0x07,
2643 tempcx = pVBInfo->VGAVT;
2644 tempbx = pVBInfo->VDE;
2645 tempax = pVBInfo->VGAVDE;
2648 temp = tempax; /* 0430 ylshieh */
2649 temp1 = (temp << 18) / tempbx;
2651 tempdx = (unsigned short) ((temp << 18) % tempbx);
2659 XGINew_SetReg1(pVBInfo->Part1Port, 0x37,
2660 (unsigned short) (temp2 & 0xff));
2661 XGINew_SetReg1(pVBInfo->Part1Port, 0x36,
2662 (unsigned short) ((temp2 >> 8) & 0xff));
2664 tempbx = (unsigned short) (temp2 >> 16);
2665 tempax = tempbx & 0x03;
2667 tempbx = pVBInfo->VGAVDE;
2668 if (tempbx == pVBInfo->VDE)
2671 XGINew_SetReg1(pVBInfo->Part1Port, 0x35, tempax);
2673 if (pVBInfo->VBType & VB_XGI301C) {
2675 XGINew_SetReg1(pVBInfo->Part4Port, 0x3c,
2676 (unsigned short) (temp2 & 0xff));
2677 XGINew_SetReg1(pVBInfo->Part4Port, 0x3b,
2678 (unsigned short) ((temp2 >> 8)
2680 tempbx = (unsigned short) (temp2 >> 16);
2681 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x3a,
2683 (unsigned short) ((tempbx
2686 tempcx = pVBInfo->VGAVDE;
2687 if (tempcx == pVBInfo->VDE)
2688 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2691 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2695 tempcx = pVBInfo->VGAHDE;
2696 tempbx = pVBInfo->HDE;
2698 temp1 = tempcx << 16;
2700 tempax = (unsigned short) (temp1 / tempbx);
2702 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2706 temp1 = pVBInfo->VGAHDE << 16;
2709 temp3 = temp3 << 16;
2712 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
2714 tempax = (unsigned short) (temp3 & 0xff);
2715 XGINew_SetReg1(pVBInfo->Part1Port, 0x1f, tempax);
2717 temp1 = pVBInfo->VGAVDE << 18;
2718 temp1 = temp1 / push3;
2719 tempbx = (unsigned short) (temp1 & 0xffff);
2721 if (pVBInfo->LCDResInfo == Panel1024x768)
2724 tempax = ((tempbx >> 8) & 0xff) << 3;
2725 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
2726 XGINew_SetReg1(pVBInfo->Part1Port, 0x20,
2727 (unsigned short) (tempax & 0xff));
2728 XGINew_SetReg1(pVBInfo->Part1Port, 0x21,
2729 (unsigned short) (tempbx & 0xff));
2731 temp3 = temp3 >> 16;
2733 if (modeflag & HalfDCLK)
2736 XGINew_SetReg1(pVBInfo->Part1Port, 0x22,
2737 (unsigned short) ((temp3 >> 8) & 0xff));
2738 XGINew_SetReg1(pVBInfo->Part1Port, 0x23,
2739 (unsigned short) (temp3 & 0xff));
2744 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2745 unsigned short RefreshRateTableIndex,
2746 struct vb_device_info *pVBInfo)
2748 unsigned char di_0, di_1, tempal;
2751 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2753 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2754 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2756 for (i = 0; i < 4; i++) {
2757 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, ~0x30,
2758 (unsigned short) (0x10 * i));
2759 if (pVBInfo->IF_DEF_CH7007 == 1) {
2760 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
2761 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
2762 } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
2763 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
2764 XGINew_SetReg1(pVBInfo->P3c4, 0x2e, di_0);
2765 XGINew_SetReg1(pVBInfo->P3c4, 0x2f, di_1);
2767 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
2768 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
2773 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
2774 struct vb_device_info *pVBInfo)
2776 unsigned short tempcl, tempch, temp, tempbl, tempax;
2778 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
2779 | VB_XGI302LV | VB_XGI301C)) {
2782 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
2784 if (!(temp & 0x20)) {
2785 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x17);
2787 if ((HwDeviceExtension->jChipType >= XG20)
2788 || (HwDeviceExtension->jChipType
2790 temp = XGINew_GetReg1(pVBInfo->P3d4,
2793 temp = XGINew_GetReg1(pVBInfo->P3d4,
2797 tempcl |= ActiveCRT1;
2801 temp = XGINew_GetReg1(pVBInfo->Part1Port, 0x2e);
2804 if (!(temp == 0x08)) {
2805 tempax = XGINew_GetReg1(pVBInfo->Part1Port, 0x13); /* Check ChannelA by Part1_13 [2003/10/03] */
2807 tempcl = tempcl | ActiveLCD;
2811 if (!(tempcl & ActiveLCD))
2813 tempcl |= ActiveCRT2;
2816 tempcl |= ActiveLCD;
2819 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x00);
2822 tempch |= ActiveAVideo;
2825 tempch |= ActiveSVideo;
2828 tempch |= ActiveSCART;
2830 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
2832 tempch |= ActiveHiTV;
2835 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
2836 temp = XGINew_GetReg1(
2841 tempch |= ActiveYPbPr;
2849 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x3d);
2850 if (tempcl & ActiveLCD) {
2851 if ((pVBInfo->SetFlag & ReserveTVOption)) {
2852 if (temp & ActiveTV)
2857 tempbl = ~ModeSwitchStatus;
2858 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x3d, tempbl, temp);
2860 if (!(pVBInfo->SetFlag & ReserveTVOption))
2861 XGINew_SetReg1(pVBInfo->P3d4, 0x3e, tempch);
2867 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
2868 struct vb_device_info *pVBInfo)
2871 if ( HwDeviceExtension->jChipType >= XG20 ) {
2872 pVBInfo->Set_VGAType = XG20;
2873 } else if (HwDeviceExtension->jChipType >= XG40) {
2874 pVBInfo->Set_VGAType = VGA_XGI340;
2877 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
2880 void XGI_GetVBType(struct vb_device_info *pVBInfo)
2882 unsigned short flag, tempbx, tempah;
2884 if (pVBInfo->IF_DEF_CH7007 == 1) {
2885 pVBInfo->VBType = VB_CH7007;
2888 if (pVBInfo->IF_DEF_LVDS == 0) {
2889 tempbx = VB_XGI302B;
2890 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
2893 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x01);
2895 tempbx = VB_XGI301B;
2897 tempbx = VB_XGI301C;
2899 tempbx = VB_XGI301LV;
2901 tempbx = VB_XGI302LV;
2913 if (tempbx & (VB_XGI301B | VB_XGI302B)) {
2914 flag = XGINew_GetReg1(
2919 tempbx = tempbx | VB_NoLCD;
2923 pVBInfo->VBType = tempbx;
2926 else if (pVBInfo->IF_DEF_CH7017 == 1)
2927 pVBInfo->VBType = VB_CH7017;
2929 pVBInfo->VBType = VB_LVDS_NS;
2934 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2935 struct xgi_hw_device_info *HwDeviceExtension,
2936 struct vb_device_info *pVBInfo)
2938 unsigned short tempax, push, tempbx, temp, modeflag;
2941 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2943 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2945 pVBInfo->SetFlag = 0;
2946 pVBInfo->ModeType = modeflag & ModeInfoFlag;
2949 if (pVBInfo->VBType & 0xFFFF) {
2950 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x30); /* Check Display Device */
2951 tempbx = tempbx | temp;
2952 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
2956 tempbx = tempbx | tempax;
2957 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA
2958 | SetInSlaveMode | DisableCRT2Display);
2959 temp = 0xFFFF ^ temp;
2962 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
2964 if (pVBInfo->IF_DEF_LCDA == 1) {
2966 if ((pVBInfo->Set_VGAType >= XG20)
2967 || (pVBInfo->Set_VGAType >= XG40)) {
2968 if (pVBInfo->IF_DEF_LVDS == 0) {
2969 /* if ((pVBInfo->VBType & VB_XGI302B) || (pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType & VB_XGI301C)) */
2970 if (pVBInfo->VBType & (VB_XGI302B
2974 if (temp & EnableDualEdge) {
2976 |= SetCRT2ToDualEdge;
2978 if (temp & SetToLCDA)
2983 } else if (pVBInfo->IF_DEF_CH7017 == 1) {
2984 if (pVBInfo->VBType & VB_CH7017) {
2985 if (temp & EnableDualEdge) {
2987 |= SetCRT2ToDualEdge;
2989 if (temp & SetToLCDA)
2998 if (pVBInfo->IF_DEF_YPbPr == 1) {
2999 if (((pVBInfo->IF_DEF_LVDS == 0) && ((pVBInfo->VBType
3000 & VB_XGI301LV) || (pVBInfo->VBType
3001 & VB_XGI302LV) || (pVBInfo->VBType
3003 || ((pVBInfo->IF_DEF_CH7017 == 1)
3006 || ((pVBInfo->IF_DEF_CH7007 == 1)
3008 & VB_CH7007))) { /* [Billy] 07/05/04 */
3009 if (temp & SetYPbPr) { /* temp = CR38 */
3010 if (pVBInfo->IF_DEF_HiVision == 1) {
3011 temp = XGINew_GetReg1(
3013 0x35); /* shampoo add for new scratch */
3015 tempbx |= SetCRT2ToHiVisionTV;
3017 if (temp != YPbPrMode1080i) {
3019 &= (~SetCRT2ToHiVisionTV);
3025 /* tempbx |= SetCRT2ToYPbPr; */
3030 tempax = push; /* restore CR31 */
3032 if (pVBInfo->IF_DEF_LVDS == 0) {
3033 if (pVBInfo->IF_DEF_YPbPr == 1) {
3034 if (pVBInfo->IF_DEF_HiVision == 1)
3039 if (pVBInfo->IF_DEF_HiVision == 1)
3044 } else { /* 3nd party chip */
3045 if (pVBInfo->IF_DEF_CH7017 == 1)
3046 temp = (SetCRT2ToTV | SetCRT2ToLCD
3048 else if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/03 */
3051 temp = SetCRT2ToLCD;
3054 if (!(tempbx & temp)) {
3055 tempax |= DisableCRT2Display;
3059 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
3060 if (!(pVBInfo->VBType & VB_NoLCD)) {
3061 if (tempbx & SetCRT2ToLCDA) {
3062 if (tempbx & SetSimuScanMode)
3078 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { /* for driver abnormal */
3079 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
3080 if (tempbx & SetCRT2ToRAMDAC) {
3081 tempbx &= (0xFF00 | SetCRT2ToRAMDAC
3084 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3087 tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD
3092 if (!(pVBInfo->VBType & VB_NoLCD)) {
3093 if (tempbx & SetCRT2ToLCD) {
3094 tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2
3096 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3100 if (tempbx & SetCRT2ToSCART) {
3101 tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2
3103 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3106 if (pVBInfo->IF_DEF_YPbPr == 1) {
3107 if (tempbx & SetCRT2ToYPbPr)
3108 tempbx &= (0xFF00 | SwitchToCRT2
3112 if (pVBInfo->IF_DEF_HiVision == 1) {
3113 if (tempbx & SetCRT2ToHiVisionTV)
3114 tempbx &= (0xFF00 | SetCRT2ToHiVisionTV
3119 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
3120 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode)))
3121 tempbx = DisableCRT2Display;
3124 if (!(tempbx & DisableCRT2Display)) {
3125 if ((!(tempbx & DriverMode))
3126 || (!(modeflag & CRT2Mode))) {
3127 if (pVBInfo->IF_DEF_LCDA == 1) {
3128 if (!(tempbx & SetCRT2ToLCDA))
3134 if (pVBInfo->IF_DEF_VideoCapture == 1) {
3135 if (((HwDeviceExtension->jChipType
3137 && (pVBInfo->Set_VGAType
3139 || ((HwDeviceExtension->jChipType
3141 && (pVBInfo->Set_VGAType
3143 || ((HwDeviceExtension->jChipType
3145 && (pVBInfo->Set_VGAType
3147 || ((HwDeviceExtension->jChipType
3149 && (pVBInfo->Set_VGAType
3153 & SetCRT2ToRAMDAC)) { /*CRT2 not need to support*/
3156 | (~SetInSlaveMode));
3165 /* LCD+TV can't support in slave mode (Force LCDA+TV->LCDB) */
3166 if ((tempbx & SetInSlaveMode) && (tempbx
3168 tempbx ^= (SetCRT2ToLCD | SetCRT2ToLCDA
3169 | SetCRT2ToDualEdge);
3170 pVBInfo->SetFlag |= ReserveTVOption;
3175 pVBInfo->VBInfo = tempbx;
3178 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3179 struct vb_device_info *pVBInfo)
3181 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
3186 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3187 if (ModeNo <= 0x13) {
3189 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
3190 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
3193 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3195 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
3198 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3199 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3201 if (tempbx & SetPALTV) {
3202 tempbx &= (SetCHTVOverScan | SetPALMTV
3203 | SetPALNTV | SetPALTV);
3204 if (tempbx & SetPALMTV)
3205 tempbx &= ~SetPALTV; /* set to NTSC if PAL-M */
3207 tempbx &= (SetCHTVOverScan | SetNTSCJ
3210 if (pVBInfo->IF_DEF_LVDS == 0) {
3211 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x38); //PAL-M/PAL-N Info
3212 temp2 = (index1 & 0xC0) >> 5; //00:PAL, 01:PAL-M, 10:PAL-N
3214 if (temp2 & 0x02) //PAL-M
3215 tempbx &= (~SetPALTV);
3220 if (pVBInfo->IF_DEF_CH7017 == 1) {
3221 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3223 if (tempbx & TVOverScan)
3224 tempbx |= SetCHTVOverScan;
3227 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */
3228 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3230 if (tempbx & TVOverScan)
3231 tempbx |= SetCHTVOverScan;
3234 if (pVBInfo->IF_DEF_LVDS == 0) {
3235 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3239 if (pVBInfo->IF_DEF_YPbPr == 1) {
3240 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3241 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3242 index1 &= YPbPrMode;
3244 if (index1 == YPbPrMode525i)
3245 tempbx |= SetYPbPrMode525i;
3247 if (index1 == YPbPrMode525p)
3248 tempbx = tempbx | SetYPbPrMode525p;
3249 if (index1 == YPbPrMode750p)
3250 tempbx = tempbx | SetYPbPrMode750p;
3254 if (pVBInfo->IF_DEF_HiVision == 1) {
3255 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
3256 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV;
3259 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3260 if ((pVBInfo->VBInfo & SetInSlaveMode)
3261 && (!(pVBInfo->VBInfo & SetNotSimuMode)))
3262 tempbx |= TVSimuMode;
3264 if (!(tempbx & SetPALTV) && (modeflag > 13) && (resinfo
3265 == 8)) /* NTSC 1024x768, */
3266 tempbx |= NTSC1024x768;
3268 tempbx |= RPLLDIV2XO;
3270 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3271 if (pVBInfo->VBInfo & SetInSlaveMode)
3272 tempbx &= (~RPLLDIV2XO);
3274 if (tempbx & (SetYPbPrMode525p
3275 | SetYPbPrMode750p))
3276 tempbx &= (~RPLLDIV2XO);
3277 else if (!(pVBInfo->VBType & (VB_XGI301B
3278 | VB_XGI302B | VB_XGI301LV
3279 | VB_XGI302LV | VB_XGI301C))) {
3280 if (tempbx & TVSimuMode)
3281 tempbx &= (~RPLLDIV2XO);
3286 pVBInfo->TVInfo = tempbx;
3289 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3290 struct vb_device_info *pVBInfo)
3292 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3294 pVBInfo->LCDResInfo = 0;
3295 pVBInfo->LCDTypeInfo = 0;
3296 pVBInfo->LCDInfo = 0;
3298 if (ModeNo <= 0x13) {
3299 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag // */
3301 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3302 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo // */
3305 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3306 tempbx = temp & 0x0F;
3309 tempbx = Panel1024x768; /* default */
3311 /* LCD75 [2003/8/22] Vicent */
3312 if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) {
3313 if (pVBInfo->VBInfo & DriverMode) {
3314 tempax = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
3315 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
3318 tempax = tempax >> 4;
3320 if ((resinfo == 6) || (resinfo == 9)) {
3322 tempbx |= PanelRef75Hz;
3323 } else if ((resinfo == 7) || (resinfo == 8)) {
3325 tempbx |= PanelRef75Hz;
3330 pVBInfo->LCDResInfo = tempbx;
3334 if (pVBInfo->IF_DEF_OEMUtil == 1)
3335 pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
3337 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
3342 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
3344 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
3346 if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
3347 temp &= ~EnableScalingLCD;
3351 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
3353 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
3355 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3356 if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3357 & VB_XGI301C)) && (tempax & LCDDualLink)) {
3358 tempbx |= SetLCDDualLink;
3362 if (pVBInfo->IF_DEF_CH7017 == 1) {
3363 if (tempax & LCDDualLink)
3364 tempbx |= SetLCDDualLink;
3367 if (pVBInfo->IF_DEF_LVDS == 0) {
3368 if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
3369 & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
3370 == 9) && (!(tempbx & EnableScalingLCD)))
3371 tempbx |= SetLCDtoNonExpanding; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3375 if (tempax & LCDBToA) {
3376 tempbx |= SetLCDBToA;
3380 if (pVBInfo->IF_DEF_ExpLink == 1) {
3381 if (modeflag & HalfDCLK) {
3382 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
3383 if (!(tempbx & SetLCDtoNonExpanding)) {
3384 tempbx |= EnableLVDSDDA;
3386 if (ModeNo > 0x13) {
3387 if (pVBInfo->LCDResInfo
3389 if (resinfo == 4) { /* 512x384 */
3390 tempbx |= EnableLVDSDDA;
3398 if (pVBInfo->VBInfo & SetInSlaveMode) {
3399 if (pVBInfo->VBInfo & SetNotSimuMode)
3400 tempbx |= LCDVESATiming;
3402 tempbx |= LCDVESATiming;
3405 pVBInfo->LCDInfo = tempbx;
3407 if (pVBInfo->IF_DEF_PWD == 1) {
3408 if (pVBInfo->LCDInfo & SetPWDEnable) {
3409 if ((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3411 if (!(tempax & PWDEnable))
3412 pVBInfo->LCDInfo &= ~SetPWDEnable;
3417 if (pVBInfo->IF_DEF_LVDS == 0) {
3418 if (tempax & (LockLCDBToA | StLCDBToA)) {
3419 if (pVBInfo->VBInfo & SetInSlaveMode) {
3420 if (!(tempax & LockLCDBToA)) {
3421 if (ModeNo <= 0x13) {
3423 &= ~(SetSimuScanMode
3428 | SetCRT2ToDualEdge;
3436 if (pVBInfo->IF_DEF_LVDS == 0) {
3437 if (tempax & (LockLCDBToA | StLCDBToA)) {
3438 if (pVBInfo->VBInfo & SetInSlaveMode) {
3439 if (!((!(tempax & LockLCDBToA)) && (ModeNo > 0x13))) {
3440 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3441 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3451 unsigned char XGI_SearchModeID(unsigned short ModeNo,
3452 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
3456 if (ModeNo <= 0x13) {
3457 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
3458 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3459 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3461 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3466 (*ModeIdIndex)++; /* 400 lines */
3468 (*ModeIdIndex) += 2; /* 400 lines */
3469 /* else 350 lines */
3471 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
3472 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3473 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3475 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3483 /* win2000 MM adapter not support standard mode! */
3486 static unsigned char XGINew_CheckMemorySize(
3487 struct xgi_hw_device_info *HwDeviceExtension,
3488 unsigned short ModeNo,
3489 unsigned short ModeIdIndex,
3490 struct vb_device_info *pVBInfo)
3492 unsigned short memorysize, modeflag, temp, temp1, tmp;
3495 if ((HwDeviceExtension->jChipType == XGI_650) ||
3496 (HwDeviceExtension->jChipType == XGI_650M)) {
3502 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3504 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3506 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
3508 memorysize = modeflag & MemoryInfoFlag;
3509 memorysize = memorysize > MemorySizeShift;
3510 memorysize++; /* Get memory size */
3512 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
3515 if (HwDeviceExtension->jChipType == XG40) {
3516 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3517 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3519 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
3522 } else if (HwDeviceExtension->jChipType == XG42) {
3523 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3524 if ((tmp & 0x04) == 0x04) { /* Dual channels */
3527 } else if (HwDeviceExtension->jChipType == XG45) {
3528 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3529 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3531 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
3535 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
3539 if (temp < memorysize)
3547 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)
3549 unsigned short data ;
3550 unsigned short ModeFlag ;
3552 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3554 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
3556 if (ModeNo > 0x13) {
3557 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3558 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
3559 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3561 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
3562 data = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3564 XGINew_SetReg1(pVBInfo->P3c4, 0x01, data);
3570 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
3571 struct vb_device_info *pVBInfo)
3574 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3575 if (pXGIHWDE->jChipType == XG21) {
3576 if (pVBInfo->IF_DEF_LVDS == 1) {
3577 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3578 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3579 XGI_XG21SetPanelDelay(2, pVBInfo);
3581 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3582 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3583 XGI_XG21SetPanelDelay(3, pVBInfo);
3584 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3586 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3591 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
3595 if (pXGIHWDE->jChipType == XG27) {
3596 if (pVBInfo->IF_DEF_LVDS == 1) {
3597 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
3598 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3599 XGI_XG21SetPanelDelay(2, pVBInfo);
3601 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
3602 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3603 XGI_XG21SetPanelDelay(3, pVBInfo);
3604 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3606 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3612 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
3613 struct vb_device_info *pVBInfo)
3616 if (pXGIHWDE->jChipType == XG21) {
3617 if (pVBInfo->IF_DEF_LVDS == 1) {
3618 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3619 XGI_XG21SetPanelDelay(3, pVBInfo);
3621 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3625 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
3626 /* if (IsCH7007TVMode(pVBInfo) == 0) */
3631 if (pXGIHWDE->jChipType == XG27) {
3632 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
3633 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3634 XGI_XG21SetPanelDelay(3, pVBInfo);
3637 if (pVBInfo->IF_DEF_LVDS == 0)
3638 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3641 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
3644 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
3646 while ((XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3649 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3653 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
3655 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
3656 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
3659 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
3661 unsigned char CR17, CR63, SR31;
3662 unsigned short temp;
3663 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
3666 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
3668 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
3669 XGINew_SetReg1(pVBInfo->P3d4, 0x57, 0x4A);
3670 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3671 pVBInfo->P3d4, 0x53) | 0x02));
3673 SR31 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x31);
3674 CR63 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x63);
3675 SR01 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3677 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
3678 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
3680 CR17 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x17);
3681 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
3683 SR1F = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
3684 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
3686 SR07 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x07);
3687 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
3688 SR06 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x06);
3689 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
3691 XGINew_SetReg1(pVBInfo->P3d4, 0x11, 0x00);
3693 for (i = 0; i < 8; i++)
3694 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
3696 for (i = 8; i < 11; i++)
3697 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 8),
3700 for (i = 11; i < 13; i++)
3701 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 4),
3704 for (i = 13; i < 16; i++)
3705 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i - 3),
3708 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
3711 XGINew_SetReg1(pVBInfo->P3c4, 0x31, 0x00);
3712 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
3713 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE1);
3715 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
3717 for (i = 0; i < 256; i++) {
3718 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3719 (unsigned char) DAC_TEST_PARMS[0]);
3720 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3721 (unsigned char) DAC_TEST_PARMS[1]);
3722 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3723 (unsigned char) DAC_TEST_PARMS[2]);
3726 XGI_VBLongWait(pVBInfo);
3727 XGI_VBLongWait(pVBInfo);
3728 XGI_VBLongWait(pVBInfo);
3732 XGI_WaitDisply(pVBInfo);
3733 temp = XGINew_GetReg2(pVBInfo->P3c2);
3736 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
3738 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
3740 /* alan, avoid display something, set BLACK DAC if not restore DAC */
3741 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
3743 for (i = 0; i < 256; i++) {
3744 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3745 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3746 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3749 XGINew_SetReg1(pVBInfo->P3c4, 0x01, SR01);
3750 XGINew_SetReg1(pVBInfo->P3d4, 0x63, CR63);
3751 XGINew_SetReg1(pVBInfo->P3c4, 0x31, SR31);
3753 /* [2004/05/11] Vicent */
3754 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3755 pVBInfo->P3d4, 0x53) & 0xFD));
3756 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
3760 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
3762 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01));
3763 while (XGINew_GetReg2(pVBInfo->P3da) & 0x01);
3767 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
3768 struct xgi_hw_device_info *HwDeviceExtension,
3769 struct vb_device_info *pVBInfo)
3771 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
3773 tempbx = pVBInfo->VBInfo;
3774 pVBInfo->SetFlag |= ProgrammingCRT2;
3775 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
3776 pVBInfo->SelectCRT2Rate = 4;
3777 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
3778 ModeIdIndex, pVBInfo);
3779 XGI_SaveCRT2Info(ModeNo, pVBInfo);
3780 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
3781 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3782 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3783 RefreshRateTableIndex, pVBInfo);
3784 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3785 RefreshRateTableIndex, pVBInfo);
3786 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3787 RefreshRateTableIndex, pVBInfo);
3788 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3789 HwDeviceExtension, pVBInfo);
3790 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3791 RefreshRateTableIndex, pVBInfo);
3792 XGI_SetTap4Regs(pVBInfo);
3793 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
3794 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3795 HwDeviceExtension, pVBInfo);
3796 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3797 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
3798 XGI_AutoThreshold(pVBInfo);
3802 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
3804 if (!(pVBInfo->SetFlag & Win9xDOSMode))
3805 XGINew_SetRegOR(pVBInfo->Part1Port, 0x01, 0x40);
3808 static void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
3810 unsigned short temp1, temp2;
3812 XGINew_SetReg1(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
3813 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
3814 temp2 = ~(SetInSlaveMode >> 8);
3815 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, temp2, temp1);
3818 static void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3819 struct vb_device_info *pVBInfo)
3821 unsigned short xres, yres, modeflag, resindex;
3823 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
3824 if (ModeNo <= 0x13) {
3825 xres = pVBInfo->StResInfo[resindex].HTotal;
3826 yres = pVBInfo->StResInfo[resindex].VTotal;
3827 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
3829 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
3830 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
3831 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
3834 if (pVBInfo->IF_DEF_FSTN) {
3839 if (modeflag & HalfDCLK)
3842 if (modeflag & DoubleScanMode)
3847 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3848 if (pVBInfo->IF_DEF_LVDS == 0) {
3849 if (pVBInfo->LCDResInfo == Panel1600x1200) {
3850 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3856 if (pVBInfo->LCDResInfo == Panel1280x1024) {
3859 else if (yres == 350)
3862 if (pVBInfo->LCDInfo & LCDVESATiming) {
3868 if (pVBInfo->LCDResInfo == Panel1024x768) {
3869 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3870 if (!(pVBInfo->LCDInfo
3871 & LCDNonExpanding)) {
3874 else if (yres == 400)
3876 else if (yres == 480)
3887 pVBInfo->VGAHDE = xres;
3888 pVBInfo->HDE = xres;
3889 pVBInfo->VGAVDE = yres;
3890 pVBInfo->VDE = yres;
3893 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
3896 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
3897 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
3903 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
3904 unsigned short RefreshRateTableIndex,
3905 struct vb_device_info *pVBInfo)
3907 unsigned short tempax = 0, tempbx, modeflag, resinfo;
3909 struct XGI_LCDDataStruct *LCDPtr = NULL;
3910 struct XGI_TVDataStruct *TVPtr = NULL;
3912 if (ModeNo <= 0x13) {
3913 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
3914 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
3916 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
3917 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3920 pVBInfo->NewFlickerMode = 0;
3921 pVBInfo->RVBHRS = 50;
3923 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3924 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3931 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3932 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
3933 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3936 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
3937 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
3938 pVBInfo->VGAHT = LCDPtr->VGAHT;
3939 pVBInfo->VGAVT = LCDPtr->VGAVT;
3940 pVBInfo->HT = LCDPtr->LCDHT;
3941 pVBInfo->VT = LCDPtr->LCDVT;
3943 if (pVBInfo->LCDResInfo == Panel1024x768) {
3947 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3948 if (pVBInfo->VGAVDE == 357)
3950 else if (pVBInfo->VGAVDE == 420)
3952 else if (pVBInfo->VGAVDE == 525)
3954 else if (pVBInfo->VGAVDE == 600)
3956 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
3957 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
3962 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
3965 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
3967 if (pVBInfo->VGAVDE == 360)
3969 else if (pVBInfo->VGAVDE == 375)
3971 else if (pVBInfo->VGAVDE == 405)
3975 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
3978 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
3980 if (pVBInfo->VGAVDE == 350)
3982 else if (pVBInfo->VGAVDE == 400)
3984 else if (pVBInfo->VGAVDE == 1024)
3988 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
3992 if (pVBInfo->VGAVDE == 1024) {
3996 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
3998 tempbx = 1200; /* alan 10/14/2003 */
3999 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4000 if (pVBInfo->VGAVDE == 350)
4002 else if (pVBInfo->VGAVDE == 400)
4007 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4008 tempax = pVBInfo->VGAHDE;
4009 tempbx = pVBInfo->VGAVDE;
4012 pVBInfo->HDE = tempax;
4013 pVBInfo->VDE = tempbx;
4017 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4019 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4020 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4023 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4024 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4025 pVBInfo->VGAHT = TVPtr->VGAHT;
4026 pVBInfo->VGAVT = TVPtr->VGAVT;
4027 pVBInfo->HDE = TVPtr->TVHDE;
4028 pVBInfo->VDE = TVPtr->TVVDE;
4029 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4030 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
4032 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4033 if (resinfo == 0x08)
4034 pVBInfo->NewFlickerMode = 0x40;
4035 else if (resinfo == 0x09)
4036 pVBInfo->NewFlickerMode = 0x40;
4037 else if (resinfo == 0x12)
4038 pVBInfo->NewFlickerMode = 0x40;
4040 if (pVBInfo->VGAVDE == 350)
4041 pVBInfo->TVInfo |= TVSimuMode;
4046 if (pVBInfo->VBInfo & SetInSlaveMode) {
4047 if (pVBInfo->TVInfo & TVSimuMode) {
4051 if (!(modeflag & Charx8Dot)) {
4052 tempax = StHiTextTVHT;
4053 tempbx = StHiTextTVVT;
4057 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4058 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4059 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4060 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4063 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4064 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4065 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4066 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4067 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4068 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4069 if (pVBInfo->TVInfo & NTSC1024x768)
4070 tempax = NTSC1024x768HT;
4075 if (!(pVBInfo->TVInfo & SetPALTV)) {
4078 if (pVBInfo->TVInfo & NTSC1024x768)
4079 tempax = NTSC1024x768HT;
4083 pVBInfo->HT = tempax;
4084 pVBInfo->VT = tempbx;
4089 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4090 unsigned short RefreshRateTableIndex,
4091 struct vb_device_info *pVBInfo)
4093 unsigned char di_0, di_1, tempal;
4095 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4097 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4098 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
4100 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4102 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, 0x10);
4103 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4104 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4105 } else { /* 301b/302b/301lv/302lv */
4106 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4107 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4110 XGINew_SetReg1(pVBInfo->Part4Port, 0x00, 0x12);
4112 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4113 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x28);
4115 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x08);
4118 /* --------------------------------------------------------------------- */
4119 /* Function : XGI_GETLCDVCLKPtr */
4121 /* Output : al -> VCLK Index */
4123 /* --------------------------------------------------------------------- */
4124 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
4125 struct vb_device_info *pVBInfo)
4127 unsigned short index;
4129 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4130 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
4131 if (pVBInfo->LCDInfo & EnableScalingLCD)
4135 /* index = XGI_GetLCDCapPtr(pVBInfo); */
4136 index = XGI_GetLCDCapPtr1(pVBInfo);
4138 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
4139 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
4140 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
4142 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
4143 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
4149 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
4150 unsigned short ModeNo, unsigned short ModeIdIndex,
4151 struct vb_device_info *pVBInfo)
4154 unsigned short index, modeflag;
4155 unsigned short tempbx;
4156 unsigned char tempal;
4157 unsigned char *CHTVVCLKPtr = NULL;
4160 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4162 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4164 if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
4165 & EnableScalingLCD))) { /* {LCDA/LCDB} */
4166 index = XGI_GetLCDCapPtr(pVBInfo);
4167 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
4169 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
4173 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4174 | VB_XGI302LV | VB_XGI301C)) {
4175 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4176 tempal = HiTVVCLKDIV2;
4177 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4179 if (pVBInfo->TVInfo & TVSimuMode) {
4180 tempal = HiTVSimuVCLK;
4181 if (!(modeflag & Charx8Dot))
4182 tempal = HiTVTextVCLK;
4188 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4189 tempal = YPbPr750pVCLK;
4193 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4194 tempal = YPbPr525pVCLK;
4198 tempal = NTSC1024VCLK;
4200 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
4201 tempal = TVVCLKDIV2;
4202 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4206 if (pVBInfo->VBInfo & SetCRT2ToTV)
4209 /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
4211 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4213 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4214 *tempal = *tempal & 0x1F;
4216 if (pVBInfo->TVInfo & SetPALTV)
4217 tempbx = tempbx + 2;
4218 if (pVBInfo->TVInfo & SetCHTVOverScan)
4220 tempbx = tempbx << 1;
4224 if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
4225 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4226 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
4227 if (ModeNo <= 0x13) {
4229 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4232 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4235 tempal = tempal & 0x0F;
4238 if (pVBInfo->TVInfo & SetPALTV)
4239 tempbx = tempbx + 2;
4241 if (pVBInfo->TVInfo & SetCHTVOverScan)
4244 /** tempbx = tempbx << 1; CH7007 ? **/
4246 /* [Billy]07/05/29 CH7007 */
4247 if (pVBInfo->IF_DEF_CH7007 == 1) {
4250 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
4253 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
4256 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
4259 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
4269 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
4272 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
4275 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
4278 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
4286 tempal = CHTVVCLKPtr[tempal];
4292 tempal = (unsigned char) XGINew_GetReg2((pVBInfo->P3ca + 0x02));
4293 tempal = tempal >> 2;
4296 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
4297 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
4302 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
4306 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
4307 unsigned char *di_1, struct vb_device_info *pVBInfo)
4309 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
4310 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
4311 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
4312 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
4313 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
4314 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
4315 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
4316 & ProgrammingCRT2)) {
4317 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
4318 *di_1 = XGI_VBVCLKData[tempal].SR2C;
4321 *di_0 = XGI_VCLKData[tempal].SR2B;
4322 *di_1 = XGI_VCLKData[tempal].SR2C;
4326 static void XGI_SetCRT2Offset(unsigned short ModeNo,
4327 unsigned short ModeIdIndex,
4328 unsigned short RefreshRateTableIndex,
4329 struct xgi_hw_device_info *HwDeviceExtension,
4330 struct vb_device_info *pVBInfo)
4332 unsigned short offset;
4335 if (pVBInfo->VBInfo & SetInSlaveMode)
4338 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4339 HwDeviceExtension, pVBInfo);
4340 temp = (unsigned char) (offset & 0xFF);
4341 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp);
4342 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4343 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, temp);
4344 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4345 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4348 static unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
4349 unsigned short RefreshRateTableIndex,
4350 struct xgi_hw_device_info *HwDeviceExtension,
4351 struct vb_device_info *pVBInfo)
4353 unsigned short temp, colordepth, modeinfo, index, infoflag,
4354 ColorDepth[] = { 0x01, 0x02, 0x04 };
4356 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4360 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4362 index = (modeinfo >> 8) & 0xFF;
4364 temp = pVBInfo->ScreenOffset[index];
4366 if (infoflag & InterlaceMode)
4369 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4371 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4372 temp = ModeNo - 0x7C;
4373 colordepth = ColorDepth[temp];
4375 if (infoflag & InterlaceMode)
4377 return temp * colordepth;
4379 return temp * colordepth;
4383 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
4385 XGINew_SetReg1(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
4386 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
4389 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4390 struct xgi_hw_device_info *HwDeviceExtension,
4391 unsigned short RefreshRateTableIndex,
4392 struct vb_device_info *pVBInfo)
4394 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
4396 if (ModeNo > 0x13) {
4397 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4398 CRT1Index &= IndexMask;
4399 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4402 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4403 HwDeviceExtension, pVBInfo);
4404 XGI_SetCRT2FIFO(pVBInfo);
4405 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4407 for (tempcx = 4; tempcx < 7; tempcx++)
4408 XGINew_SetReg1(pVBInfo->Part1Port, tempcx, 0x0);
4410 XGINew_SetReg1(pVBInfo->Part1Port, 0x50, 0x00);
4411 XGINew_SetReg1(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
4414 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4415 struct xgi_hw_device_info *HwDeviceExtension,
4416 unsigned short RefreshRateTableIndex,
4417 struct vb_device_info *pVBInfo)
4419 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4420 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
4422 if (ModeNo > 0x13) {
4423 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4424 CRT1Index &= IndexMask;
4425 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4429 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4431 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4433 /* bainy change table name */
4434 if (modeflag & HalfDCLK) {
4435 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4436 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4437 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4438 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4439 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4440 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4441 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4442 pushbx = pVBInfo->VGAHDE / 2 + 16;
4443 tempcx = tempcx >> 1;
4444 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4447 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4448 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4449 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4451 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4452 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4454 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4455 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4456 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4462 if (tempcx > (pVBInfo->VGAHT / 2))
4463 tempcx = pVBInfo->VGAHT / 2;
4465 temp = tempbx & 0x00FF;
4467 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4469 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4470 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4471 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4472 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4473 temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4474 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4475 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4476 pushbx = pVBInfo->VGAHDE + 16;
4477 tempcx = tempcx >> 1;
4478 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4481 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4482 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4483 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
4485 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4486 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4488 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4489 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4490 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4495 if (tempcx > pVBInfo->VGAHT)
4496 tempcx = pVBInfo->VGAHT;
4498 temp = tempbx & 0x00FF;
4499 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4502 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4504 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4505 tempax |= (tempbx & 0xFF00);
4506 temp = (tempax & 0xFF00) >> 8;
4507 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4508 temp = tempcx & 0x00FF;
4509 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp);
4510 tempcx = (pVBInfo->VGAVT - 1);
4511 temp = tempcx & 0x00FF;
4513 if (pVBInfo->IF_DEF_CH7005 == 1) {
4514 if (pVBInfo->VBInfo & 0x0C)
4518 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4519 tempbx = pVBInfo->VGAVDE - 1;
4520 temp = tempbx & 0x00FF;
4521 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, temp);
4522 temp = ((tempbx & 0xFF00) << 3) >> 8;
4523 temp |= ((tempcx & 0xFF00) >> 8);
4524 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, temp);
4526 tempax = pVBInfo->VGAVDE;
4527 tempbx = pVBInfo->VGAVDE;
4528 tempcx = pVBInfo->VGAVT;
4529 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
4530 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
4532 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4533 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4534 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4542 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
4547 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4548 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4551 temp = tempbx & 0x00FF;
4552 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4553 temp = ((tempbx & 0xFF00) >> 8) << 4;
4554 temp = ((tempcx & 0x000F) | (temp));
4555 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, temp);
4558 if (modeflag & DoubleScanMode)
4561 if (modeflag & HalfDCLK)
4564 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
4567 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4568 struct xgi_hw_device_info *HwDeviceExtension,
4569 unsigned short RefreshRateTableIndex,
4570 struct vb_device_info *pVBInfo)
4572 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4573 modeflag, CRT1Index;
4575 if (ModeNo <= 0x13) {
4576 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4577 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4579 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4580 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4581 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4582 CRT1Index &= IndexMask;
4585 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4588 temp = 0xFF; /* set MAX HT */
4589 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4590 /* if (modeflag & Charx8Dot) */
4591 /* tempcx = 0x08; */
4595 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4596 modeflag |= Charx8Dot;
4598 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
4600 if (modeflag & HalfDCLK)
4601 tempax = tempax >> 1;
4603 tempax = (tempax / tempcx) - 1;
4604 tempbx |= ((tempax & 0x00FF) << 8);
4605 temp = tempax & 0x00FF;
4606 XGINew_SetReg1(pVBInfo->Part1Port, 0x04, temp);
4608 temp = (tempbx & 0xFF00) >> 8;
4610 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4611 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4612 | VB_XGI302LV | VB_XGI301C)))
4615 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4616 if (pVBInfo->VBType & VB_XGI301LV) {
4617 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4621 } else if (resinfo == 7) {
4627 XGINew_SetReg1(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
4628 XGINew_SetReg1(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
4630 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4631 if (pVBInfo->VBInfo & SetCRT2ToTV)
4632 tempax = pVBInfo->VGAHT;
4634 tempax = XGI_GetVGAHT2(pVBInfo);
4637 if (tempax >= pVBInfo->VGAHT)
4638 tempax = pVBInfo->VGAHT;
4640 if (modeflag & HalfDCLK)
4641 tempax = tempax >> 1;
4643 tempax = (tempax / tempcx) - 5;
4644 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4645 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4646 temp = (tempbx & 0x00FF) - 1;
4647 if (!(modeflag & HalfDCLK)) {
4649 if (pVBInfo->TVInfo & TVSimuMode) {
4656 /* tempcx = tempbx & 0x00FF ; */
4657 tempbx = (tempbx & 0xFF00) >> 8;
4658 tempcx = (tempcx + tempbx) >> 1;
4659 temp = (tempcx & 0x00FF) + 2;
4661 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4663 if (!(modeflag & HalfDCLK)) {
4664 if ((modeflag & Charx8Dot)) {
4666 if (pVBInfo->VGAHDE >= 800)
4671 if (!(modeflag & HalfDCLK)) {
4673 if (pVBInfo->LCDResInfo != Panel1280x960) {
4674 if (pVBInfo->VGAHDE >= 800) {
4676 if (pVBInfo->ModeType
4681 if (pVBInfo->LCDResInfo
4682 != Panel1280x1024) {
4689 if (pVBInfo->VGAHDE >= 1280) {
4690 if (pVBInfo->LCDResInfo
4692 if (pVBInfo->LCDInfo
4693 & LCDNonExpanding) {
4705 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
4706 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
4708 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4709 if (pVBInfo->TVInfo & TVSimuMode) {
4710 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
4711 == 0x11) || (ModeNo == 0x13) || (ModeNo
4713 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, 0x5b);
4714 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0x03);
4717 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
4718 if (pVBInfo->TVInfo & SetNTSCTV) {
4719 XGINew_SetReg1(pVBInfo->Part1Port,
4721 XGINew_SetReg1(pVBInfo->Part1Port,
4724 XGINew_SetReg1(pVBInfo->Part1Port,
4726 XGINew_SetReg1(pVBInfo->Part1Port,
4728 XGINew_SetReg1(pVBInfo->Part1Port,
4733 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
4735 if (pVBInfo->TVInfo & SetNTSCTV) {
4736 XGINew_SetReg1(pVBInfo->Part1Port,
4738 XGINew_SetReg1(pVBInfo->Part1Port,
4741 XGINew_SetReg1(pVBInfo->Part1Port,
4743 XGINew_SetReg1(pVBInfo->Part1Port,
4745 XGINew_SetReg1(pVBInfo->Part1Port,
4750 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
4751 == 0x0D) || (ModeNo == 0x50)) {
4752 if (pVBInfo->TVInfo & SetNTSCTV) {
4753 XGINew_SetReg1(pVBInfo->Part1Port,
4755 XGINew_SetReg1(pVBInfo->Part1Port,
4758 XGINew_SetReg1(pVBInfo->Part1Port,
4760 XGINew_SetReg1(pVBInfo->Part1Port,
4767 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
4768 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
4769 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
4771 tempbx = pVBInfo->VGAVT;
4774 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
4789 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4790 if (pVBInfo->LCDResInfo == Panel1024x768) {
4791 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4800 temp = tempbx & 0x00FF;
4802 temp = tempbx & 0x00FF;
4803 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
4806 temp = tempbx & 0x00FF;
4807 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4809 if (tempbx & 0x0100)
4814 if (modeflag & DoubleScanMode)
4817 if (tempbx & 0x0200)
4820 temp = (tempax & 0xFF00) >> 8;
4821 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4823 if (tempbx & 0x0400)
4826 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
4829 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
4830 tempax = tempax >> 2;
4831 push1 = tempax; /* push ax */
4833 if (resinfo != 0x09) {
4834 tempax = tempax << 1;
4838 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4839 if (pVBInfo->VBType & VB_XGI301LV) {
4840 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
4843 if (pVBInfo->TVInfo & TVSimuMode) {
4844 if (pVBInfo->TVInfo & SetPALTV) {
4847 if (!(pVBInfo->TVInfo
4850 | SetYPbPrMode1080i)))
4862 if (pVBInfo->TVInfo & TVSimuMode) {
4863 if (pVBInfo->TVInfo & SetPALTV) {
4864 if (pVBInfo->VBType & VB_XGI301LV) {
4865 if (!(pVBInfo->TVInfo
4868 | SetYPbPrMode1080i)))
4877 tempax = tempax >> 2;
4880 push1 = tempax; /* push ax */
4882 if ((pVBInfo->TVInfo & SetPALTV)) {
4883 if (tempbx <= 513) {
4889 temp = tempbx & 0x00FF;
4890 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4892 temp = tempbx & 0x00FF;
4893 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4895 if (tempbx & 0x0100)
4898 if (tempbx & 0x0200)
4899 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
4903 if (tempbx & 0x0100)
4906 if (tempbx & 0x0200)
4909 if (tempbx & 0x0400)
4912 tempbx = push1; /* pop ax */
4913 temp = tempbx & 0x00FF;
4915 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
4917 if (tempbx & 0x0010)
4920 temp = tempcx & 0x00FF;
4921 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
4922 temp = (tempcx & 0x0FF00) >> 8;
4923 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
4925 temp = (tempax & 0xFF00) >> 8;
4927 temp = (temp >> 1) & 0x09;
4929 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4932 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
4933 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
4934 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
4936 if (pVBInfo->LCDInfo & LCDRGB18Bit)
4941 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
4946 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
4947 unsigned short RefreshRateTableIndex,
4948 struct xgi_hw_device_info *HwDeviceExtension,
4949 struct vb_device_info *pVBInfo)
4951 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
4952 modeflag, resinfo, crt2crtc;
4953 unsigned char *TimingPoint;
4955 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
4957 if (ModeNo <= 0x13) {
4958 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4959 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4960 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4962 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4963 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4965 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4970 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
4973 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4976 if (pVBInfo->VBInfo & SetCRT2ToSCART)
4979 if (!(pVBInfo->TVInfo & SetPALTV))
4982 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
4985 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
4988 tempax = (tempax & 0xff00) >> 8;
4990 XGINew_SetReg1(pVBInfo->Part2Port, 0x0, tempax);
4991 TimingPoint = pVBInfo->NTSCTiming;
4993 if (pVBInfo->TVInfo & SetPALTV)
4994 TimingPoint = pVBInfo->PALTiming;
4996 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4997 TimingPoint = pVBInfo->HiTVExtTiming;
4999 if (pVBInfo->VBInfo & SetInSlaveMode)
5000 TimingPoint = pVBInfo->HiTVSt2Timing;
5002 if (pVBInfo->SetFlag & TVSimuMode)
5003 TimingPoint = pVBInfo->HiTVSt1Timing;
5005 if (!(modeflag & Charx8Dot))
5006 TimingPoint = pVBInfo->HiTVTextTiming;
5009 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5010 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5011 TimingPoint = pVBInfo->YPbPr525iTiming;
5013 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5014 TimingPoint = pVBInfo->YPbPr525pTiming;
5016 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5017 TimingPoint = pVBInfo->YPbPr750pTiming;
5020 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5021 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]);
5023 for (i = 0x39; i <= 0x45; i++, j++)
5024 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
5026 if (pVBInfo->VBInfo & SetCRT2ToTV)
5027 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5029 temp = pVBInfo->NewFlickerMode;
5031 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5033 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5036 if (pVBInfo->TVInfo & SetPALTV)
5041 if (pVBInfo->VDE <= tempax) {
5042 tempax -= pVBInfo->VDE;
5043 tempax = tempax >> 2;
5044 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5046 temp = (tempax & 0xFF00) >> 8;
5047 temp += (unsigned short) TimingPoint[0];
5049 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5050 | VB_XGI302LV | VB_XGI301C)) {
5051 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5052 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5053 | SetCRT2ToYPbPr)) {
5054 tempcx = pVBInfo->VGAHDE;
5055 if (tempcx >= 1024) {
5056 temp = 0x17; /* NTSC */
5057 if (pVBInfo->TVInfo & SetPALTV)
5058 temp = 0x19; /* PAL */
5063 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5065 temp = (tempax & 0xFF00) >> 8;
5066 temp += TimingPoint[1];
5068 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5069 | VB_XGI302LV | VB_XGI301C)) {
5070 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5071 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5072 | SetCRT2ToYPbPr))) {
5073 tempcx = pVBInfo->VGAHDE;
5074 if (tempcx >= 1024) {
5075 temp = 0x1D; /* NTSC */
5076 if (pVBInfo->TVInfo & SetPALTV)
5077 temp = 0x52; /* PAL */
5081 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, temp);
5085 tempcx = pVBInfo->HT;
5087 if (XGI_IsLCDDualLink(pVBInfo))
5088 tempcx = tempcx >> 1;
5091 temp = tempcx & 0x00FF;
5092 XGINew_SetReg1(pVBInfo->Part2Port, 0x1B, temp);
5094 temp = (tempcx & 0xFF00) >> 8;
5095 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5097 tempcx = pVBInfo->HT >> 1;
5098 push1 = tempcx; /* push cx */
5101 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5104 temp = tempcx & 0x00FF;
5106 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5108 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5111 temp = tempbx & 0x00FF;
5112 XGINew_SetReg1(pVBInfo->Part2Port, 0x24, temp);
5113 temp = (tempbx & 0xFF00) >> 8;
5115 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5118 tempbx = tempbx + 8;
5119 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5120 tempbx = tempbx - 4;
5124 temp = (tempbx & 0x00FF) << 4;
5125 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5128 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5129 temp = tempcx & 0x00FF;
5130 XGINew_SetReg1(pVBInfo->Part2Port, 0x27, temp);
5131 temp = ((tempcx & 0xFF00) >> 8) << 4;
5132 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5135 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5138 temp = tempcx & 0xFF;
5140 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5142 tempcx = push1; /* pop cx */
5144 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5146 temp = tempcx & 0x00FF;
5148 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5152 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5153 tempax = XGI_GetVGAHT2(pVBInfo);
5154 tempcx = tempax - 1;
5156 temp = tempcx & 0x00FF;
5157 XGINew_SetReg1(pVBInfo->Part2Port, 0x2E, temp);
5159 tempbx = pVBInfo->VDE;
5161 if (pVBInfo->VGAVDE == 360)
5163 if (pVBInfo->VGAVDE == 375)
5165 if (pVBInfo->VGAVDE == 405)
5168 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5169 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5170 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5171 | SetYPbPrMode750p)))
5172 tempbx = tempbx >> 1;
5174 tempbx = tempbx >> 1;
5178 temp = tempbx & 0x00FF;
5180 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5181 if (pVBInfo->VBType & VB_XGI301LV) {
5182 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5183 if (pVBInfo->VBInfo & SetInSlaveMode) {
5189 if (pVBInfo->VBInfo & SetInSlaveMode) {
5196 XGINew_SetReg1(pVBInfo->Part2Port, 0x2F, temp);
5198 temp = (tempcx & 0xFF00) >> 8;
5199 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5201 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5202 if (pVBInfo->VBType & VB_XGI301LV) {
5203 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5206 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5211 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5216 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, temp);
5218 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5219 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5220 tempbx = pVBInfo->VDE;
5221 tempcx = tempbx - 2;
5223 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5224 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5225 | SetYPbPrMode750p)))
5226 tempbx = tempbx >> 1;
5229 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5231 if (tempcx & 0x0400)
5234 if (tempbx & 0x0400)
5237 XGINew_SetReg1(pVBInfo->Part4Port, 0x10, temp);
5240 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5241 XGINew_SetReg1(pVBInfo->Part2Port, 0x46, temp);
5242 temp = (tempbx - 3) & 0x00FF;
5243 XGINew_SetReg1(pVBInfo->Part2Port, 0x47, temp);
5246 tempbx = tempbx & 0x00FF;
5248 if (!(modeflag & HalfDCLK)) {
5249 tempcx = pVBInfo->VGAHDE;
5250 if (tempcx >= pVBInfo->HDE) {
5258 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5259 if (pVBInfo->VGAHDE >= 1024) {
5261 if (pVBInfo->VGAHDE >= 1280) {
5263 tempbx = tempbx & 0xDFFF;
5268 if (!(tempbx & 0x2000)) {
5269 if (modeflag & HalfDCLK)
5270 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5273 tempeax = pVBInfo->VGAHDE;
5274 tempebx = (tempcx & 0xFF00) >> 8;
5275 longtemp = tempeax * tempebx;
5276 tempecx = tempcx & 0x00FF;
5277 longtemp = longtemp / tempecx;
5282 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5283 | VB_XGI302LV | VB_XGI301C)) {
5284 tempecx = tempecx * 8;
5287 longtemp = longtemp * tempecx;
5288 tempecx = pVBInfo->HDE;
5289 temp2 = longtemp % tempecx;
5290 tempeax = longtemp / tempecx;
5294 tempax = (unsigned short) tempeax;
5297 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5298 | VB_XGI302LV | VB_XGI301C)) {
5299 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5304 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5305 | (tempbx & 0x00FF));
5306 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5307 | (tempax & 0x00FF));
5308 temp = (tempax & 0xFF00) >> 8;
5310 temp = (tempax & 0x00FF) >> 8;
5313 XGINew_SetReg1(pVBInfo->Part2Port, 0x44, temp);
5314 temp = (tempbx & 0xFF00) >> 8;
5315 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5316 temp = tempcx & 0x00FF;
5318 if (tempbx & 0x2000)
5321 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5324 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5325 if (pVBInfo->TVInfo & SetPALTV) {
5333 temp = tempbx & 0x00FF;
5334 XGINew_SetReg1(pVBInfo->Part2Port, 0x4b, temp);
5335 temp = tempcx & 0x00FF;
5336 XGINew_SetReg1(pVBInfo->Part2Port, 0x4c, temp);
5338 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5340 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5342 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5345 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5348 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5352 XGINew_SetReg1(pVBInfo->Part2Port, 0x4d, temp);
5353 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x43); /* 301b change */
5354 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5356 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5357 if (pVBInfo->TVInfo & NTSC1024x768) {
5358 TimingPoint = XGI_NTSC1024AdjTime;
5359 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5360 XGINew_SetReg1(pVBInfo->Part2Port, i,
5363 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, 0x72);
5367 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5368 if (pVBInfo->VBType & VB_XGI301C) {
5369 if (pVBInfo->TVInfo & SetPALMTV)
5370 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x08,
5371 0x08); /* PALM Mode */
5374 if (pVBInfo->TVInfo & SetPALMTV) {
5375 tempax = (unsigned char) XGINew_GetReg1(pVBInfo->Part2Port,
5378 XGINew_SetRegAND(pVBInfo->Part2Port, 0x01, tempax);
5380 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5381 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xEF);
5384 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5385 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5386 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, 0x00);
5389 if (pVBInfo->VBInfo & SetCRT2ToTV)
5393 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5394 struct xgi_hw_device_info *HwDeviceExtension,
5395 unsigned short RefreshRateTableIndex,
5396 struct vb_device_info *pVBInfo)
5398 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5399 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5401 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5403 if (ModeNo <= 0x13) {
5404 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5405 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5407 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5408 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5410 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5411 CRT1Index &= IndexMask;
5414 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5417 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5419 if (XGI_IsLCDDualLink(pVBInfo))
5420 tempbx = tempbx >> 1;
5423 temp = tempbx & 0x00FF;
5424 XGINew_SetReg1(pVBInfo->Part2Port, 0x2C, temp);
5425 temp = (tempbx & 0xFF00) >> 8;
5427 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5430 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5431 if (pVBInfo->ModeType == ModeEGA) {
5432 if (pVBInfo->VGAHDE >= 1024) {
5434 if (pVBInfo->LCDInfo & LCDVESATiming)
5440 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, temp);
5441 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5444 temp = tempbx & 0x00FF;
5445 XGINew_SetReg1(pVBInfo->Part2Port, 0x03, temp);
5446 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5447 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5449 tempcx = pVBInfo->VT - 1;
5451 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5452 XGINew_SetReg1(pVBInfo->Part2Port, 0x19, temp);
5453 temp = (tempcx & 0xFF00) >> 8;
5455 XGINew_SetReg1(pVBInfo->Part2Port, 0x1A, temp);
5456 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5457 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5458 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5459 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5461 /* Customized LCDB Des no add */
5463 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5464 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5465 tempah = pVBInfo->LCDResInfo;
5466 tempah &= PanelResInfo;
5468 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5471 } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
5474 } else if (tempah == Panel1400x1050) {
5482 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5483 tempbx = pVBInfo->HDE;
5484 tempcx = pVBInfo->VDE;
5488 tempax = pVBInfo->VT;
5489 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5490 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5491 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5492 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5493 tempbx = pVBInfo->LCDVDES;
5496 if (tempcx >= tempax)
5497 tempcx -= tempax; /* lcdvdes */
5499 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5500 XGINew_SetReg1(pVBInfo->Part2Port, 0x05, temp);
5501 temp = tempcx & 0x00FF;
5502 XGINew_SetReg1(pVBInfo->Part2Port, 0x06, temp);
5503 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5504 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5506 tempah = tempah << 3;
5508 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, tempah);
5511 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5513 tempax = pVBInfo->VT;
5514 tempbx = pVBInfo->LCDVRS;
5516 /* if (SetLCD_Info & EnableScalingLCD) */
5518 if (tempcx >= tempax)
5521 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5522 XGINew_SetReg1(pVBInfo->Part2Port, 0x04, temp);
5523 temp = (tempbx & 0xFF00) >> 8;
5525 temp |= (tempcx & 0x000F);
5526 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5528 tempax = pVBInfo->HT;
5529 tempbx = pVBInfo->LCDHDES;
5532 if (XGI_IsLCDDualLink(pVBInfo)) {
5533 tempax = tempax >> 1;
5534 tempbx = tempbx >> 1;
5535 tempcx = tempcx >> 1;
5538 if (pVBInfo->VBType & VB_XGI302LV)
5541 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5546 if (tempcx >= tempax)
5549 temp = tempbx & 0x00FF;
5550 XGINew_SetReg1(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5551 temp = ((tempbx & 0xFF00) >> 8) << 4;
5552 XGINew_SetReg1(pVBInfo->Part2Port, 0x20, temp);
5553 temp = tempcx & 0x00FF;
5554 XGINew_SetReg1(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5555 temp = (tempcx & 0xFF00) >> 8;
5556 XGINew_SetReg1(pVBInfo->Part2Port, 0x25, temp);
5559 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5561 tempax = pVBInfo->HT;
5562 tempbx = pVBInfo->LCDHRS;
5563 /* if ( SetLCD_Info & EnableScalingLCD) */
5564 if (XGI_IsLCDDualLink(pVBInfo)) {
5565 tempax = tempax >> 1;
5566 tempbx = tempbx >> 1;
5567 tempcx = tempcx >> 1;
5570 if (pVBInfo->VBType & VB_XGI302LV)
5575 if (tempcx >= tempax)
5578 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5579 XGINew_SetReg1(pVBInfo->Part2Port, 0x1C, temp);
5581 temp = (tempbx & 0xFF00) >> 8;
5583 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5584 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5585 XGINew_SetReg1(pVBInfo->Part2Port, 0x21, temp);
5587 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5588 if (pVBInfo->VGAVDE == 525) {
5589 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5590 | VB_XGI301LV | VB_XGI302LV
5596 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5597 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, 0xB3);
5600 if (pVBInfo->VGAVDE == 420) {
5601 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5602 | VB_XGI301LV | VB_XGI302LV
5607 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5612 /* --------------------------------------------------------------------- */
5613 /* Function : XGI_GetTap4Ptr */
5615 /* Output : di -> Tap4 Reg. Setting Pointer */
5617 /* --------------------------------------------------------------------- */
5618 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
5619 struct vb_device_info *pVBInfo)
5621 unsigned short tempax, tempbx, i;
5623 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5626 tempax = pVBInfo->VGAHDE;
5627 tempbx = pVBInfo->HDE;
5629 tempax = pVBInfo->VGAVDE;
5630 tempbx = pVBInfo->VDE;
5633 if (tempax < tempbx)
5634 return &EnlargeTap4Timing[0];
5635 else if (tempax == tempbx)
5636 return &NoScaleTap4Timing[0]; /* 1:1 */
5638 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
5640 if (pVBInfo->TVInfo & SetPALTV)
5641 Tap4TimingPtr = PALTap4Timing;
5643 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5644 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5645 Tap4TimingPtr = YPbPr525iTap4Timing;
5646 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5647 Tap4TimingPtr = YPbPr525pTap4Timing;
5648 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5649 Tap4TimingPtr = YPbPr750pTap4Timing;
5652 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5653 Tap4TimingPtr = HiTVTap4Timing;
5656 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5657 if (Tap4TimingPtr[i].DE == tempax)
5661 return &Tap4TimingPtr[i];
5664 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
5666 unsigned short i, j;
5668 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5670 if (!(pVBInfo->VBType & VB_XGI301C))
5674 XGINew_SetRegAND(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
5675 #else /* Tap4 Setting */
5677 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5678 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5679 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5681 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5682 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
5683 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5684 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5687 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5688 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
5690 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
5694 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5695 struct vb_device_info *pVBInfo)
5698 unsigned char *tempdi;
5699 unsigned short modeflag;
5702 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5704 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5706 XGINew_SetReg1(pVBInfo->Part3Port, 0x00, 0x00);
5707 if (pVBInfo->TVInfo & SetPALTV) {
5708 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5709 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5711 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xF5);
5712 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xB7);
5715 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5718 if (pVBInfo->TVInfo & SetPALMTV) {
5719 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5720 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5721 XGINew_SetReg1(pVBInfo->Part3Port, 0x3D, 0xA8);
5724 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
5725 & SetCRT2ToYPbPr)) {
5726 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5729 tempdi = pVBInfo->HiTVGroup3Data;
5730 if (pVBInfo->SetFlag & TVSimuMode) {
5731 tempdi = pVBInfo->HiTVGroup3Simu;
5732 if (!(modeflag & Charx8Dot))
5733 tempdi = pVBInfo->HiTVGroup3Text;
5736 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5737 tempdi = pVBInfo->Ren525pGroup3;
5739 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5740 tempdi = pVBInfo->Ren750pGroup3;
5742 for (i = 0; i <= 0x3E; i++)
5743 XGINew_SetReg1(pVBInfo->Part3Port, i, tempdi[i]);
5745 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
5746 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5747 XGINew_SetReg1(pVBInfo->Part3Port, 0x28, 0x3f);
5751 } /* {end of XGI_SetGroup3} */
5753 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
5754 unsigned short RefreshRateTableIndex,
5755 struct xgi_hw_device_info *HwDeviceExtension,
5756 struct vb_device_info *pVBInfo)
5758 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
5760 unsigned long tempebx, tempeax, templong;
5763 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5765 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5767 temp = pVBInfo->RVBHCFACT;
5768 XGINew_SetReg1(pVBInfo->Part4Port, 0x13, temp);
5770 tempbx = pVBInfo->RVBHCMAX;
5771 temp = tempbx & 0x00FF;
5772 XGINew_SetReg1(pVBInfo->Part4Port, 0x14, temp);
5773 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
5774 tempcx = pVBInfo->VGAHT - 1;
5775 temp = tempcx & 0x00FF;
5776 XGINew_SetReg1(pVBInfo->Part4Port, 0x16, temp);
5778 temp = ((tempcx & 0xFF00) >> 8) << 3;
5781 tempcx = pVBInfo->VGAVT - 1;
5782 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5785 temp = tempcx & 0x00FF;
5786 XGINew_SetReg1(pVBInfo->Part4Port, 0x17, temp);
5787 temp = temp2 | ((tempcx & 0xFF00) >> 8);
5788 XGINew_SetReg1(pVBInfo->Part4Port, 0x15, temp);
5789 XGINew_SetRegOR(pVBInfo->Part4Port, 0x0D, 0x08);
5790 tempcx = pVBInfo->VBInfo;
5791 tempbx = pVBInfo->VGAHDE;
5793 if (modeflag & HalfDCLK)
5794 tempbx = tempbx >> 1;
5796 if (XGI_IsLCDDualLink(pVBInfo))
5797 tempbx = tempbx >> 1;
5799 if (tempcx & SetCRT2ToHiVisionTV) {
5805 } else if (tempcx & SetCRT2ToTV) {
5811 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5818 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
5820 if (pVBInfo->VGAHDE == 1280)
5822 if (pVBInfo->VGAHDE == 1024)
5825 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
5827 tempebx = pVBInfo->VDE;
5829 if (tempcx & SetCRT2ToHiVisionTV) {
5830 if (!(temp & 0xE000))
5831 tempbx = tempbx >> 1;
5834 tempcx = pVBInfo->RVBHRS;
5835 temp = tempcx & 0x00FF;
5836 XGINew_SetReg1(pVBInfo->Part4Port, 0x18, temp);
5838 tempeax = pVBInfo->VGAVDE;
5841 if (tempeax <= tempebx) {
5842 tempcx = (tempcx & (~0x4000));
5843 tempeax = pVBInfo->VGAVDE;
5848 templong = (tempeax * 256 * 1024) % tempebx;
5849 tempeax = (tempeax * 256 * 1024) / tempebx;
5855 temp = (unsigned short) (tempebx & 0x000000FF);
5856 XGINew_SetReg1(pVBInfo->Part4Port, 0x1B, temp);
5858 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
5859 XGINew_SetReg1(pVBInfo->Part4Port, 0x1A, temp);
5860 tempbx = (unsigned short) (tempebx >> 16);
5861 temp = tempbx & 0x00FF;
5863 temp |= ((tempcx & 0xFF00) >> 8);
5864 XGINew_SetReg1(pVBInfo->Part4Port, 0x19, temp);
5867 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5868 | VB_XGI302LV | VB_XGI301C)) {
5870 XGINew_SetReg1(pVBInfo->Part4Port, 0x1C, temp);
5871 tempax = pVBInfo->VGAHDE;
5872 if (modeflag & HalfDCLK)
5873 tempax = tempax >> 1;
5875 if (XGI_IsLCDDualLink(pVBInfo))
5876 tempax = tempax >> 1;
5878 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
5879 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5883 if (pVBInfo->VGAHDE > 800) {
5884 if (pVBInfo->VGAHDE == 1024)
5885 tempax = (tempax * 25 / 32) - 1;
5887 tempax = (tempax * 20 / 32) - 1;
5893 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5894 if (pVBInfo->VBType & VB_XGI301LV) {
5895 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
5896 if (pVBInfo->VGAHDE > 800) {
5897 if (pVBInfo->VGAHDE == 1024)
5898 tempax = (tempax * 25 / 32) - 1;
5900 tempax = (tempax * 20 / 32) - 1;
5904 if (pVBInfo->VGAHDE > 800) {
5905 if (pVBInfo->VGAHDE == 1024)
5906 tempax = (tempax * 25 / 32) - 1;
5908 tempax = (tempax * 20 / 32) - 1;
5914 temp = (tempax & 0xFF00) >> 8;
5915 temp = ((temp & 0x0003) << 4);
5916 XGINew_SetReg1(pVBInfo->Part4Port, 0x1E, temp);
5917 temp = (tempax & 0x00FF);
5918 XGINew_SetReg1(pVBInfo->Part4Port, 0x1D, temp);
5920 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5921 if (pVBInfo->VGAHDE > 800)
5922 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1E, 0x08);
5927 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5928 if (!(pVBInfo->TVInfo & (NTSC1024x768
5929 | SetYPbPrMode525p | SetYPbPrMode750p
5930 | SetYPbPrMode1080i))) {
5932 if ((pVBInfo->VBInfo & SetInSlaveMode)
5933 && (!(pVBInfo->TVInfo
5939 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
5940 tempbx = pVBInfo->HT;
5941 if (XGI_IsLCDDualLink(pVBInfo))
5942 tempbx = tempbx >> 1;
5943 tempbx = (tempbx >> 1) - 2;
5944 temp = ((tempbx & 0x0700) >> 8) << 3;
5945 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
5946 temp = tempbx & 0x00FF;
5947 XGINew_SetReg1(pVBInfo->Part4Port, 0x22, temp);
5951 if (pVBInfo->ISXPDOS == 0)
5952 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5956 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
5957 struct vb_device_info *pVBInfo)
5959 unsigned short Pindex, Pdata;
5961 Pindex = pVBInfo->Part5Port;
5962 Pdata = pVBInfo->Part5Port + 1;
5963 if (pVBInfo->ModeType == ModeVGA) {
5964 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
5965 | CRT2DisplayFlag))) {
5966 XGINew_EnableCRT2(pVBInfo);
5967 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
5973 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
5974 unsigned short ModeIdIndex,
5975 unsigned short RefreshRateTableIndex,
5976 struct vb_device_info *pVBInfo)
5978 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
5980 struct XGI330_LCDDataTablStruct *tempdi = NULL;
5984 if (ModeNo <= 0x13) {
5985 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
5986 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5988 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5989 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5992 tempal = tempal & 0x0f;
5994 if (tempbx <= 1) { /* ExpLink */
5995 if (ModeNo <= 0x13) {
5996 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
5999 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6002 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6005 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
6008 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
6012 tempal = (tempal >> 4);
6014 tempal = (tempal & 0x0f);
6017 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
6019 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
6020 if ((tempbx == 5) || (tempbx) == 7)
6021 tempcx = LCDDesDataLen2;
6022 else if ((tempbx == 3) || (tempbx == 8))
6023 tempcx = LVDSDesDataLen2;
6025 /* mov di, word ptr cs:LCDDataList[bx] */
6026 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
6030 tempdi = XGI_EPLLCDCRT1Ptr_H;
6033 tempdi = XGI_EPLLCDCRT1Ptr_V;
6036 tempdi = XGI_EPLLCDDataPtr;
6039 tempdi = XGI_EPLLCDDesDataPtr;
6042 tempdi = XGI_LCDDataTable;
6045 tempdi = XGI_LCDDesDataTable;
6048 tempdi = XGI_EPLCHLCDRegPtr;
6059 if (tempdi == NULL) /* OEMUtil */
6065 while (tempdi[i].PANELID != 0xff) {
6066 tempdx = pVBInfo->LCDResInfo;
6067 if (tempbx & 0x0080) { /* OEMUtil */
6068 tempbx &= (~0x0080);
6069 tempdx = pVBInfo->LCDTypeInfo;
6072 if (pVBInfo->LCDInfo & EnableScalingLCD)
6073 tempdx &= (~PanelResInfo);
6075 if (tempdi[i].PANELID == tempdx) {
6076 tempbx = tempdi[i].MASK;
6077 tempdx = pVBInfo->LCDInfo;
6079 if (ModeNo <= 0x13) /* alan 09/10/2003 */
6080 tempdx |= SetLCDStdMode;
6082 if (modeflag & HalfDCLK)
6083 tempdx |= SetLCDLowResolution;
6086 if (tempbx == tempdi[i].CAP)
6093 switch (tempdi[i].DATAPTR) {
6095 return &XGI_LVDSCRT11024x768_1_H[tempal];
6098 return &XGI_LVDSCRT11024x768_2_H[tempal];
6101 return &XGI_LVDSCRT11280x1024_1_H[tempal];
6104 return &XGI_LVDSCRT11280x1024_2_H[tempal];
6107 return &XGI_LVDSCRT11400x1050_1_H[tempal];
6110 return &XGI_LVDSCRT11400x1050_2_H[tempal];
6113 return &XGI_LVDSCRT11600x1200_1_H[tempal];
6116 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
6119 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
6122 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
6125 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
6130 } else if (table == 1) {
6131 switch (tempdi[i].DATAPTR) {
6133 return &XGI_LVDSCRT11024x768_1_V[tempal];
6136 return &XGI_LVDSCRT11024x768_2_V[tempal];
6139 return &XGI_LVDSCRT11280x1024_1_V[tempal];
6142 return &XGI_LVDSCRT11280x1024_2_V[tempal];
6145 return &XGI_LVDSCRT11400x1050_1_V[tempal];
6148 return &XGI_LVDSCRT11400x1050_2_V[tempal];
6151 return &XGI_LVDSCRT11600x1200_1_V[tempal];
6154 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
6157 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
6160 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
6163 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
6168 } else if (table == 2) {
6169 switch (tempdi[i].DATAPTR) {
6171 return &XGI_LVDS1024x768Data_1[tempal];
6174 return &XGI_LVDS1024x768Data_2[tempal];
6177 return &XGI_LVDS1280x1024Data_1[tempal];
6180 return &XGI_LVDS1280x1024Data_2[tempal];
6183 return &XGI_LVDS1400x1050Data_1[tempal];
6186 return &XGI_LVDS1400x1050Data_2[tempal];
6189 return &XGI_LVDS1600x1200Data_1[tempal];
6192 return &XGI_LVDSNoScalingData[tempal];
6195 return &XGI_LVDS1024x768Data_1x75[tempal];
6198 return &XGI_LVDS1024x768Data_2x75[tempal];
6201 return &XGI_LVDS1280x1024Data_1x75[tempal];
6204 return &XGI_LVDS1280x1024Data_2x75[tempal];
6207 return &XGI_LVDSNoScalingDatax75[tempal];
6212 } else if (table == 3) {
6213 switch (tempdi[i].DATAPTR) {
6215 return &XGI_LVDS1024x768Des_1[tempal];
6218 return &XGI_LVDS1024x768Des_3[tempal];
6221 return &XGI_LVDS1024x768Des_2[tempal];
6224 return &XGI_LVDS1280x1024Des_1[tempal];
6227 return &XGI_LVDS1280x1024Des_2[tempal];
6230 return &XGI_LVDS1400x1050Des_1[tempal];
6233 return &XGI_LVDS1400x1050Des_2[tempal];
6236 return &XGI_LVDS1600x1200Des_1[tempal];
6239 return &XGI_LVDSNoScalingDesData[tempal];
6242 return &XGI_LVDS1024x768Des_1x75[tempal];
6245 return &XGI_LVDS1024x768Des_3x75[tempal];
6248 return &XGI_LVDS1024x768Des_2x75[tempal];
6251 return &XGI_LVDS1280x1024Des_1x75[tempal];
6254 return &XGI_LVDS1280x1024Des_2x75[tempal];
6257 return &XGI_LVDSNoScalingDesDatax75[tempal];
6262 } else if (table == 4) {
6263 switch (tempdi[i].DATAPTR) {
6265 return &XGI_ExtLCD1024x768Data[tempal];
6268 return &XGI_StLCD1024x768Data[tempal];
6271 return &XGI_CetLCD1024x768Data[tempal];
6274 return &XGI_ExtLCD1280x1024Data[tempal];
6277 return &XGI_StLCD1280x1024Data[tempal];
6280 return &XGI_CetLCD1280x1024Data[tempal];
6283 return &XGI_ExtLCD1400x1050Data[tempal];
6286 return &XGI_StLCD1400x1050Data[tempal];
6289 return &XGI_CetLCD1400x1050Data[tempal];
6292 return &XGI_ExtLCD1600x1200Data[tempal];
6295 return &XGI_StLCD1600x1200Data[tempal];
6298 return &XGI_NoScalingData[tempal];
6301 return &XGI_ExtLCD1024x768x75Data[tempal];
6304 return &XGI_ExtLCD1024x768x75Data[tempal];
6307 return &XGI_CetLCD1024x768x75Data[tempal];
6310 return &XGI_ExtLCD1280x1024x75Data[tempal];
6313 return &XGI_StLCD1280x1024x75Data[tempal];
6316 return &XGI_CetLCD1280x1024x75Data[tempal];
6319 return &XGI_NoScalingDatax75[tempal];
6324 } else if (table == 5) {
6325 switch (tempdi[i].DATAPTR) {
6327 return &XGI_ExtLCDDes1024x768Data[tempal];
6330 return &XGI_StLCDDes1024x768Data[tempal];
6333 return &XGI_CetLCDDes1024x768Data[tempal];
6336 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6338 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
6340 return &XGI_ExtLCDDes1280x1024Data[tempal];
6343 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6345 return &XGI_StLCDDLDes1280x1024Data[tempal];
6347 return &XGI_StLCDDes1280x1024Data[tempal];
6350 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6352 return &XGI_CetLCDDLDes1280x1024Data[tempal];
6354 return &XGI_CetLCDDes1280x1024Data[tempal];
6357 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6359 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
6361 return &XGI_ExtLCDDes1400x1050Data[tempal];
6364 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6366 return &XGI_StLCDDLDes1400x1050Data[tempal];
6368 return &XGI_StLCDDes1400x1050Data[tempal];
6371 return &XGI_CetLCDDes1400x1050Data[tempal];
6374 return &XGI_CetLCDDes1400x1050Data2[tempal];
6377 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6379 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
6381 return &XGI_ExtLCDDes1600x1200Data[tempal];
6384 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6386 return &XGI_StLCDDLDes1600x1200Data[tempal];
6388 return &XGI_StLCDDes1600x1200Data[tempal];
6391 return &XGI_NoScalingDesData[tempal];
6394 return &XGI_ExtLCDDes1024x768x75Data[tempal];
6397 return &XGI_StLCDDes1024x768x75Data[tempal];
6400 return &XGI_CetLCDDes1024x768x75Data[tempal];
6403 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6405 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
6407 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
6410 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6412 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
6414 return &XGI_StLCDDes1280x1024x75Data[tempal];
6417 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6419 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
6421 return &XGI_CetLCDDes1280x1024x75Data[tempal];
6424 return &XGI_NoScalingDesDatax75[tempal];
6429 } else if (table == 6) {
6430 switch (tempdi[i].DATAPTR) {
6432 return &XGI_CH7017LV1024x768[tempal];
6435 return &XGI_CH7017LV1400x1050[tempal];
6444 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
6445 unsigned short ModeIdIndex,
6446 unsigned short RefreshRateTableIndex,
6447 struct vb_device_info *pVBInfo)
6449 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
6450 struct XGI330_TVDataTablStruct *tempdi = NULL;
6454 if (ModeNo <= 0x13) {
6455 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6456 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6458 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6459 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6462 tempal = tempal & 0x3f;
6467 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
6468 if (pVBInfo->IF_DEF_CH7007 == 1)
6469 tempdi = XGI_EPLCHTVCRT1Ptr;
6473 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
6474 if (pVBInfo->IF_DEF_CH7007 == 1)
6475 tempdi = XGI_EPLCHTVCRT1Ptr;
6479 tempdi = XGI_EPLCHTVDataPtr;
6485 tempdi = XGI_TVDataTable;
6491 tempdi = XGI_EPLCHTVRegPtr;
6497 if (tempdi == NULL) /* OEMUtil */
6500 tempdx = pVBInfo->TVInfo;
6502 if (pVBInfo->VBInfo & SetInSlaveMode)
6503 tempdx = tempdx | SetTVLockMode;
6505 if (modeflag & HalfDCLK)
6506 tempdx = tempdx | SetTVLowResolution;
6510 while (tempdi[i].MASK != 0xffff) {
6511 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
6516 if (table == 0x00) { /* 07/05/22 */
6517 } else if (table == 0x01) {
6518 } else if (table == 0x04) {
6519 switch (tempdi[i].DATAPTR) {
6521 return &XGI_ExtPALData[tempal];
6524 return &XGI_ExtNTSCData[tempal];
6527 return &XGI_StPALData[tempal];
6530 return &XGI_StNTSCData[tempal];
6533 return &XGI_ExtHiTVData[tempal];
6536 return &XGI_St2HiTVData[tempal];
6539 return &XGI_ExtYPbPr525iData[tempal];
6542 return &XGI_ExtYPbPr525pData[tempal];
6545 return &XGI_ExtYPbPr750pData[tempal];
6548 return &XGI_StYPbPr525iData[tempal];
6551 return &XGI_StYPbPr525pData[tempal];
6554 return &XGI_StYPbPr750pData[tempal];
6556 case 12: /* avoid system hang */
6557 return &XGI_ExtNTSCData[tempal];
6560 return &XGI_St1HiTVData[tempal];
6565 } else if (table == 0x02) {
6566 switch (tempdi[i].DATAPTR) {
6568 return &XGI_CHTVUNTSCData[tempal];
6571 return &XGI_CHTVONTSCData[tempal];
6574 return &XGI_CHTVUPALData[tempal];
6577 return &XGI_CHTVOPALData[tempal];
6582 } else if (table == 0x06) {
6587 /* --------------------------------------------------------------------- */
6588 /* Function : XGI_BacklightByDrv */
6590 /* Output : 1 -> Skip backlight control */
6592 /* --------------------------------------------------------------------- */
6593 static unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
6595 unsigned char tempah;
6597 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x3A);
6598 if (tempah & BacklightControlBit)
6604 /* --------------------------------------------------------------------- */
6605 /* Function : XGI_FirePWDDisable */
6608 /* Description : Turn off VDD & Backlight : Fire disable procedure */
6609 /* --------------------------------------------------------------------- */
6611 void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
6613 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x00, 0xFC);
6617 /* --------------------------------------------------------------------- */
6618 /* Function : XGI_FirePWDEnable */
6621 /* Description : Turn on VDD & Backlight : Fire enable procedure */
6622 /* --------------------------------------------------------------------- */
6623 static void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
6625 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x03, 0xFC);
6628 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6629 struct vb_device_info *pVBInfo)
6631 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
6634 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6635 struct vb_device_info *pVBInfo)
6638 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
6641 /* --------------------------------------------------------------------- */
6642 /* Function : XGI_SetPanelDelay */
6646 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6647 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6648 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6649 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6650 /* --------------------------------------------------------------------- */
6651 static void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
6653 unsigned short index;
6655 index = XGI_GetLCDCapPtr(pVBInfo);
6658 mdelay(pVBInfo->LCDCapList[index].PSC_S1);
6661 mdelay(pVBInfo->LCDCapList[index].PSC_S2);
6664 mdelay(pVBInfo->LCDCapList[index].PSC_S3);
6667 mdelay(pVBInfo->LCDCapList[index].PSC_S4);
6670 /* --------------------------------------------------------------------- */
6671 /* Function : XGI_SetPanelPower */
6675 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
6676 /* = 0111b = 07h ; Backlight on, Power off */
6677 /* = 1011b = 0Bh ; Backlight off, Power on */
6678 /* = 1111b = 0Fh ; Backlight off, Power off */
6679 /* --------------------------------------------------------------------- */
6680 static void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl,
6681 struct vb_device_info *pVBInfo)
6683 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
6684 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x26, tempbl, tempah);
6686 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x11, tempbl, tempah);
6689 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
6691 unsigned char ujRet = 0;
6692 unsigned char i = 0;
6694 for (i = 0; i < 8; i++) {
6696 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
6697 ujRet |= (ujDate >> i) & 1;
6703 /*----------------------------------------------------------------------------*/
6705 /* bl[5] : LVDS signal */
6706 /* bl[1] : LVDS backlight */
6707 /* bl[0] : LVDS VDD */
6708 /*----------------------------------------------------------------------------*/
6709 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
6711 unsigned char CR4A, temp;
6713 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6714 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
6716 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6718 temp = XG21GPIODataTransfer(temp);
6720 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6724 /*----------------------------------------------------------------------------*/
6726 /* bl[5] : LVDS signal */
6727 /* bl[1] : LVDS backlight */
6728 /* bl[0] : LVDS VDD */
6729 /*----------------------------------------------------------------------------*/
6730 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
6732 unsigned char CR4A, CRB4, temp;
6734 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6735 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
6737 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6741 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6742 CRB4 = XGINew_GetReg1(pVBInfo->P3d4, 0xB4);
6743 temp |= ((CRB4 & 0x04) << 3);
6746 /*----------------------------------------------------------------------------*/
6748 /* bl[5] : 1;LVDS signal on */
6749 /* bl[1] : 1;LVDS backlight on */
6750 /* bl[0] : 1:LVDS VDD on */
6751 /* bh: 100000b : clear bit 5, to set bit5 */
6752 /* 000010b : clear bit 1, to set bit1 */
6753 /* 000001b : clear bit 0, to set bit0 */
6754 /*----------------------------------------------------------------------------*/
6755 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6756 struct vb_device_info *pVBInfo)
6758 unsigned char CR4A, temp;
6760 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6763 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6765 if (tempbh & 0x20) {
6766 temp = (tempbl >> 4) & 0x02;
6768 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6772 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6774 temp = XG21GPIODataTransfer(temp);
6777 XGINew_SetReg1(pVBInfo->P3d4, 0x48, temp);
6780 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6781 struct vb_device_info *pVBInfo)
6783 unsigned char CR4A, temp;
6784 unsigned short tempbh0, tempbl0;
6793 if (tempbh & 0x20) {
6794 temp = (tempbl >> 4) & 0x02;
6796 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6799 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
6801 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6805 tempbl <<= 2; /* GPIOC,GPIOD */
6806 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6807 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
6810 /* --------------------------------------------------------------------- */
6811 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
6813 unsigned short index;
6815 index = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
6816 if (index < sizeof(XGI21_LCDCapList)
6817 / sizeof(struct XGI21_LVDSCapStruct))
6822 /* --------------------------------------------------------------------- */
6823 /* Function : XGI_XG21SetPanelDelay */
6827 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6828 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6829 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6830 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6831 /* --------------------------------------------------------------------- */
6832 void XGI_XG21SetPanelDelay(unsigned short tempbl,
6833 struct vb_device_info *pVBInfo)
6835 unsigned short index;
6837 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6839 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1);
6842 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2);
6845 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3);
6848 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4);
6851 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
6852 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6854 unsigned short xres, yres, colordepth, modeflag, resindex,
6857 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6858 if (ModeNo <= 0x13) {
6859 xres = pVBInfo->StResInfo[resindex].HTotal;
6860 yres = pVBInfo->StResInfo[resindex].VTotal;
6861 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6863 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6864 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6865 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6868 if (!(modeflag & Charx8Dot)) {
6873 if (ModeNo > 0x13) {
6874 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6877 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6882 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6883 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6886 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6889 if (ModeNo > 0x13) {
6891 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6893 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
6894 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
6904 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
6908 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6909 temp = (temp & 1) << 6;
6910 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
6911 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6915 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
6919 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6920 temp = (temp & 3) << 6;
6921 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6922 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6926 static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6927 struct vb_device_info *pVBInfo)
6929 unsigned char temp, Miscdata;
6930 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6931 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6932 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6933 unsigned short value;
6935 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6937 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6938 & (LCDPolarity << 8)) >> 8);
6939 temp &= LCDPolarity;
6940 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
6942 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
6944 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6946 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
6947 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
6949 XGI_SetXG21FPBits(pVBInfo);
6950 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6951 if (ModeNo <= 0x13) {
6952 xres = pVBInfo->StResInfo[resindex].HTotal;
6953 yres = pVBInfo->StResInfo[resindex].VTotal;
6954 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6956 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6957 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6958 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6961 if (!(modeflag & Charx8Dot))
6962 xres = xres * 8 / 9;
6964 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6966 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6968 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6969 LVDSHBS -= xres / 4;
6971 if (LVDSHBS > LVDSHT)
6974 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6975 if (LVDSHRS > LVDSHT)
6978 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6979 if (LVDSHRE > LVDSHT)
6982 LVDSHBE = LVDSHBS + LVDSHT
6983 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6985 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6987 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6989 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6990 LVDSVBS += yres / 2;
6992 if (LVDSVBS > LVDSVT)
6995 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6996 if (LVDSVRS > LVDSVT)
6999 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7000 if (LVDSVRE > LVDSVT)
7003 LVDSVBE = LVDSVBS + LVDSVT
7004 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
7006 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7007 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
7009 if (!(modeflag & Charx8Dot))
7010 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
7012 /* HT SR0B[1:0] CR00 */
7013 value = (LVDSHT >> 3) - 5;
7014 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7015 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
7017 /* HBS SR0B[5:4] CR02 */
7018 value = (LVDSHBS >> 3) - 1;
7019 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7020 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
7022 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7023 value = (LVDSHBE >> 3) - 1;
7024 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7025 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7026 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
7028 /* HRS SR0B[7:6] CR04 */
7029 value = (LVDSHRS >> 3) + 2;
7030 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7031 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
7033 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7035 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7036 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
7038 /* HRE SR0C[2] CR05[4:0] */
7039 value = (LVDSHRE >> 3) + 2;
7040 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7041 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
7043 /* Panel HRE SR2F[7:2] */
7045 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
7047 /* VT SR0A[0] CR07[5][0] CR06 */
7049 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7050 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7051 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7052 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
7054 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7055 value = LVDSVBS - 1;
7056 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7057 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7058 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7059 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
7061 /* VBE SR0A[4] CR16 */
7062 value = LVDSVBE - 1;
7063 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7064 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
7066 /* VRS SR0A[3] CR7[7][2] CR10 */
7067 value = LVDSVRS - 1;
7068 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7069 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7070 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7071 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
7073 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
7074 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
7075 XGINew_SetReg1(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
7076 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
7078 /* VRE SR0A[5] CR11[3:0] */
7079 value = LVDSVRE - 1;
7080 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7081 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
7083 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
7084 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
7086 for (temp = 0, value = 0; temp < 3; temp++) {
7088 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7089 XGINew_SetReg1(pVBInfo->P3c4,
7091 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7092 XGINew_SetReg1(pVBInfo->P3c4,
7094 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7098 if (!(modeflag & Charx8Dot)) {
7099 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7100 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7101 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
7103 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7104 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7106 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7111 /* no shadow case */
7112 static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
7113 struct vb_device_info *pVBInfo)
7115 unsigned char temp, Miscdata;
7116 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
7117 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
7118 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
7119 unsigned short value;
7121 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
7122 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7123 & (LCDPolarity << 8)) >> 8);
7124 temp &= LCDPolarity;
7125 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
7127 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
7129 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7131 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7132 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
7134 XGI_SetXG27FPBits(pVBInfo);
7135 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7136 if (ModeNo <= 0x13) {
7137 xres = pVBInfo->StResInfo[resindex].HTotal;
7138 yres = pVBInfo->StResInfo[resindex].VTotal;
7139 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7141 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7142 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7143 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7146 if (!(modeflag & Charx8Dot))
7147 xres = xres * 8 / 9;
7149 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
7151 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7153 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7154 LVDSHBS -= xres / 4;
7156 if (LVDSHBS > LVDSHT)
7159 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7160 if (LVDSHRS > LVDSHT)
7163 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7164 if (LVDSHRE > LVDSHT)
7167 LVDSHBE = LVDSHBS + LVDSHT
7168 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
7170 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
7172 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7174 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7175 LVDSVBS += yres / 2;
7177 if (LVDSVBS > LVDSVT)
7180 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7181 if (LVDSVRS > LVDSVT)
7184 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7185 if (LVDSVRE > LVDSVT)
7188 LVDSVBE = LVDSVBS + LVDSVT
7189 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
7191 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7192 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
7194 if (!(modeflag & Charx8Dot))
7195 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
7197 /* HT SR0B[1:0] CR00 */
7198 value = (LVDSHT >> 3) - 5;
7199 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7200 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
7202 /* HBS SR0B[5:4] CR02 */
7203 value = (LVDSHBS >> 3) - 1;
7204 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7205 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
7207 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7208 value = (LVDSHBE >> 3) - 1;
7209 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7210 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7211 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
7213 /* HRS SR0B[7:6] CR04 */
7214 value = (LVDSHRS >> 3) + 2;
7215 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7216 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
7218 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7220 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7221 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
7223 /* HRE SR0C[2] CR05[4:0] */
7224 value = (LVDSHRE >> 3) + 2;
7225 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7226 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
7228 /* Panel HRE SR2F[7:2] */
7230 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
7232 /* VT SR0A[0] CR07[5][0] CR06 */
7234 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7235 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7236 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7237 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
7239 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7240 value = LVDSVBS - 1;
7241 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7242 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7243 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7244 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
7246 /* VBE SR0A[4] CR16 */
7247 value = LVDSVBE - 1;
7248 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7249 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
7251 /* VRS SR0A[3] CR7[7][2] CR10 */
7252 value = LVDSVRS - 1;
7253 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7254 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7255 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7256 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
7258 /* Panel VRS SR35[2:0] SR34[7:0] */
7259 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
7260 XGINew_SetReg1(pVBInfo->P3c4, 0x34, value & 0xFF);
7262 /* VRE SR0A[5] CR11[3:0] */
7263 value = LVDSVRE - 1;
7264 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7265 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
7267 /* Panel VRE SR3F[7:2] */
7268 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
7270 for (temp = 0, value = 0; temp < 3; temp++) {
7272 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7273 XGINew_SetReg1(pVBInfo->P3c4,
7275 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7276 XGINew_SetReg1(pVBInfo->P3c4,
7278 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7282 if (!(modeflag & Charx8Dot)) {
7283 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7284 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7285 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
7287 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7288 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7290 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7295 /* --------------------------------------------------------------------- */
7296 /* Function : XGI_IsLCDON */
7298 /* Output : 0 : Skip PSC Control */
7299 /* 1: Disable PSC */
7301 /* --------------------------------------------------------------------- */
7302 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
7304 unsigned short tempax;
7306 tempax = pVBInfo->VBInfo;
7307 if (tempax & SetCRT2ToDualEdge)
7309 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
7315 static void XGI_EnablePWD(struct vb_device_info *pVBInfo)
7317 unsigned short index, temp;
7319 index = XGI_GetLCDCapPtr(pVBInfo);
7320 temp = pVBInfo->LCDCapList[index].PWD_2B;
7321 XGINew_SetReg1(pVBInfo->Part4Port, 0x2B, temp);
7322 XGINew_SetReg1(pVBInfo->Part4Port, 0x2C,
7323 pVBInfo->LCDCapList[index].PWD_2C);
7324 XGINew_SetReg1(pVBInfo->Part4Port, 0x2D,
7325 pVBInfo->LCDCapList[index].PWD_2D);
7326 XGINew_SetReg1(pVBInfo->Part4Port, 0x2E,
7327 pVBInfo->LCDCapList[index].PWD_2E);
7328 XGINew_SetReg1(pVBInfo->Part4Port, 0x2F,
7329 pVBInfo->LCDCapList[index].PWD_2F);
7330 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x80); /* enable PWD */
7333 static void XGI_DisablePWD(struct vb_device_info *pVBInfo)
7335 XGINew_SetRegAND(pVBInfo->Part4Port, 0x27, 0x7F); /* disable PWD */
7338 /* --------------------------------------------------------------------- */
7339 /* Function : XGI_DisableChISLCD */
7341 /* Output : 0 -> Not LCD Mode */
7343 /* --------------------------------------------------------------------- */
7344 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
7346 unsigned short tempbx, tempah;
7348 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
7349 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
7351 if (tempbx & (EnableChA | DisableChA)) {
7352 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7356 if (!(tempbx & (EnableChB | DisableChB)))
7359 if (tempah & 0x01) /* Chk LCDB Mode */
7365 /* --------------------------------------------------------------------- */
7366 /* Function : XGI_EnableChISLCD */
7368 /* Output : 0 -> Not LCD mode */
7370 /* --------------------------------------------------------------------- */
7371 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
7373 unsigned short tempbx, tempah;
7375 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
7376 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
7378 if (tempbx & (EnableChA | DisableChA)) {
7379 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7383 if (!(tempbx & (EnableChB | DisableChB)))
7386 if (tempah & 0x01) /* Chk LCDB Mode */
7392 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
7394 unsigned char tempal, tempah, tempbl, i;
7396 tempah = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
7397 tempal = tempah & 0x0F;
7398 tempah = tempah & 0xF0;
7400 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7402 while (tempbl != 0xFF) {
7403 if (tempbl & 0x80) { /* OEMUtil */
7405 tempbl = tempbl & ~(0x80);
7408 if (tempal == tempbl)
7413 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7419 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
7421 unsigned short tempah, tempal, tempbl, i;
7423 tempal = pVBInfo->LCDResInfo;
7424 tempah = pVBInfo->LCDTypeInfo;
7427 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7429 while (tempbl != 0xFF) {
7430 if ((tempbl & 0x80) && (tempbl != 0x80)) {
7435 if (tempal == tempbl)
7439 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7442 if (tempbl == 0xFF) {
7443 pVBInfo->LCDResInfo = Panel1024x768;
7444 pVBInfo->LCDTypeInfo = 0;
7451 static void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
7452 struct vb_device_info *pVBInfo)
7454 unsigned short Index;
7456 Index = XGI_GetLCDCapPtr(pVBInfo);
7457 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
7458 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
7463 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7464 struct vb_device_info *pVBInfo)
7466 unsigned short tempbl, tempah;
7468 if (pVBInfo->SetFlag == Win9xDOSMode) {
7469 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7470 | VB_XGI302LV | VB_XGI301C)) {
7471 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7474 /* LVDS or CH7017 */
7478 if (HwDeviceExtension->jChipType < XG40) {
7479 if (!XGI_DisableChISLCD(pVBInfo)) {
7480 if ((XGI_EnableChISLCD(pVBInfo)) || (pVBInfo->VBInfo
7481 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
7482 if (pVBInfo->LCDInfo & SetPWDEnable) {
7483 XGI_EnablePWD(pVBInfo);
7485 pVBInfo->LCDInfo &= (~SetPWDEnable);
7486 if (pVBInfo->VBType & (VB_XGI301LV
7496 XGI_SetPanelPower(tempah, tempbl,
7498 XGI_SetPanelDelay(1, pVBInfo);
7504 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7505 | VB_XGI302LV | VB_XGI301C)) {
7506 if (!(pVBInfo->SetFlag & DisableChA)) {
7507 if (pVBInfo->SetFlag & EnableChA) {
7508 XGINew_SetReg1(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
7510 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
7511 XGINew_SetReg1(pVBInfo->Part1Port,
7512 0x1E, 0x20); /* Power on */
7517 if (!(pVBInfo->SetFlag & DisableChB)) {
7518 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
7519 & (SetCRT2ToLCD | SetCRT2ToTV
7520 | SetCRT2ToRAMDAC))) {
7521 tempah = (unsigned char) XGINew_GetReg1(
7522 pVBInfo->P3c4, 0x32);
7524 if (pVBInfo->VBInfo & SetInSlaveMode) {
7525 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
7528 XGINew_SetReg1(pVBInfo->P3c4, 0x32, tempah);
7529 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x20);
7531 tempah = (unsigned char) XGINew_GetReg1(
7532 pVBInfo->Part1Port, 0x2E);
7534 if (!(tempah & 0x80))
7535 XGINew_SetRegOR(pVBInfo->Part1Port,
7536 0x2E, 0x80); /* BVBDOENABLE = 1 */
7538 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
7542 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
7543 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
7544 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x00, ~0xE0,
7545 0x20); /* shampoo 0129 */
7546 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7547 if (!XGI_DisableChISLCD(pVBInfo)) {
7548 if (XGI_EnableChISLCD(pVBInfo)
7554 0x2A, 0x7F); /* LVDS PLL power on */
7556 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
7562 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7565 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
7566 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7567 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7568 tempah = tempah & 0x40;
7571 tempah = tempah ^ 0xC0;
7573 if (pVBInfo->SetFlag
7577 if (pVBInfo->SetFlag
7581 if (pVBInfo->SetFlag
7585 if (pVBInfo->SetFlag
7593 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
7595 if (pVBInfo->SetFlag & Win9xDOSMode) {
7596 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7600 if (!(pVBInfo->SetFlag & DisableChA)) {
7601 XGI_VBLongWait(pVBInfo);
7602 if (!(pVBInfo->SetFlag & GatingCRT)) {
7603 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
7604 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7605 XGI_VBLongWait(pVBInfo);
7610 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
7612 XGINew_SetRegOR(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
7614 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->Part1Port,
7616 if (!(tempah & 0x80))
7617 XGINew_SetRegOR(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
7619 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F);
7620 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7623 if (HwDeviceExtension->jChipType < XG40) {
7624 if (!XGI_EnableChISLCD(pVBInfo)) {
7625 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7626 if (XGI_BacklightByDrv(pVBInfo))
7632 if (pVBInfo->LCDInfo & SetPWDEnable) {
7633 XGI_FirePWDEnable(pVBInfo);
7637 XGI_SetPanelDelay(2, pVBInfo);
7639 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
7641 tempbl = 0xFE; /* turn on backlght */
7646 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7650 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7651 struct vb_device_info *pVBInfo)
7653 unsigned short tempax, tempbx, tempah = 0, tempbl = 0;
7655 if (pVBInfo->SetFlag == Win9xDOSMode)
7658 if (HwDeviceExtension->jChipType < XG40) {
7659 if ((!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7660 || (XGI_DisableChISLCD(pVBInfo))) {
7661 if (!XGI_IsLCDON(pVBInfo)) {
7662 if (pVBInfo->LCDInfo & SetPWDEnable)
7663 XGI_EnablePWD(pVBInfo);
7665 pVBInfo->LCDInfo &= ~SetPWDEnable;
7666 XGI_DisablePWD(pVBInfo);
7667 if (pVBInfo->VBType & (VB_XGI301LV
7670 tempbx = 0xFE; /* not 01h */
7673 tempbx = 0xF7; /* not 08h */
7676 XGI_SetPanelPower(tempax, tempbx,
7678 XGI_SetPanelDelay(3, pVBInfo);
7680 } /* end if (!XGI_IsLCDON(pVBInfo)) */
7686 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
7687 if (!XGI_IsLCDON(pVBInfo)) {
7689 tempbx = XGINew_GetCH7005(0x61);
7690 if (tempbx < 0x01) // first time we power up
7691 XGINew_SetCH7005(0x0066); // and disable power sequence
7693 XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
7700 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7701 | VB_XGI302LV | VB_XGI301C)) {
7703 if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
7704 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7705 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7706 tempah = 0x7F; /* Disable Channel A */
7707 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7708 tempah = 0xBF; /* Disable Channel B */
7710 if (pVBInfo->SetFlag & DisableChB)
7711 tempah &= 0xBF; /* force to disable Cahnnel */
7713 if (pVBInfo->SetFlag & DisableChA)
7714 tempah &= 0x7F; /* Force to disable Channel B */
7719 XGINew_SetRegAND(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
7721 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7722 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7723 || (XGI_DisableChISLCD(pVBInfo))
7724 || (XGI_IsLCDON(pVBInfo)))
7725 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
7728 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7729 & (DisableCRT2Display | SetCRT2ToLCDA
7730 | SetSimuScanMode))) {
7731 if (pVBInfo->SetFlag & GatingCRT)
7732 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
7733 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7736 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7737 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7739 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
7742 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
7744 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
7745 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xdf);
7747 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7748 & (DisableCRT2Display | SetSimuScanMode))
7749 || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7754 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7756 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7757 & (DisableCRT2Display | SetSimuScanMode))
7758 || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7759 || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7760 | SetCRT2ToLCD | SetCRT2ToTV))) {
7761 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
7762 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
7763 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
7764 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
7766 } else { /* {301} */
7767 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
7768 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7769 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
7770 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
7773 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
7775 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7778 if (HwDeviceExtension->jChipType < XG40) {
7779 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7780 || (XGI_DisableChISLCD(pVBInfo))
7781 || (XGI_IsLCDON(pVBInfo))) {
7782 if (pVBInfo->LCDInfo & SetPWDEnable) {
7783 if (pVBInfo->LCDInfo & SetPWDEnable)
7784 XGI_BacklightByDrv(pVBInfo);
7786 XGI_SetPanelDelay(4, pVBInfo);
7787 if (pVBInfo->VBType & VB_XGI301LV) {
7796 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7801 /* --------------------------------------------------------------------- */
7802 /* Function : XGI_GetTVPtrIndex */
7805 /* Description : bx 0 : ExtNTSC */
7817 /* --------------------------------------------------------------------- */
7818 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
7820 unsigned short tempbx = 0;
7822 if (pVBInfo->TVInfo & SetPALTV)
7824 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7826 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7828 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7830 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7832 if (pVBInfo->TVInfo & TVSimuMode)
7838 /* --------------------------------------------------------------------- */
7839 /* Function : XGI_OEM310Setting */
7842 /* Description : Customized Param. for 301 */
7843 /* --------------------------------------------------------------------- */
7844 static void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
7845 struct vb_device_info *pVBInfo)
7847 if (pVBInfo->SetFlag & Win9xDOSMode)
7851 XGI_SetDelayComp(pVBInfo);
7853 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7854 XGI_SetLCDCap(pVBInfo);
7856 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7858 XGI_SetPhaseIncr(pVBInfo);
7859 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7860 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
7862 if (pVBInfo->VBType & VB_XGI301)
7863 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7867 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
7869 unsigned short index;
7871 unsigned char tempah, tempbl, tempbh;
7873 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7874 | VB_XGI302LV | VB_XGI301C)) {
7875 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7876 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7880 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7881 tempbl = pVBInfo->XGI_TVDelayList[index];
7883 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7884 | VB_XGI301LV | VB_XGI302LV
7886 tempbl = pVBInfo->XGI_TVDelayList2[index];
7888 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7889 tempbl = tempbl >> 4;
7891 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7892 tempbl = CRT2Delay1; // Get CRT2 Delay
7893 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
7894 tempbl = CRT2Delay2;
7896 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7897 index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
7898 tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
7900 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7906 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x2D);
7908 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7909 | SetCRT2ToTV)) { /* Channel B */
7914 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7918 XGINew_SetReg1(pVBInfo->Part1Port, 0x2D, tempah);
7920 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7923 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7925 = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
7926 pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
7928 tempah = tempah << 4;
7929 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2D, 0x0f,
7935 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
7937 unsigned short tempcx;
7939 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
7941 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7942 | VB_XGI302LV | VB_XGI301C)) {
7943 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
7944 /* Set 301LV Capability */
7945 XGINew_SetReg1(pVBInfo->Part4Port, 0x24,
7946 (unsigned char) (tempcx & 0x1F));
7949 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
7950 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
7951 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
7952 | EnablePLLSPLOW)) >> 8));
7955 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7956 | VB_XGI302LV | VB_XGI301C)) {
7957 if (pVBInfo->VBInfo & SetCRT2ToLCD)
7958 XGI_SetLCDCap_B(tempcx, pVBInfo);
7959 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7960 XGI_SetLCDCap_A(tempcx, pVBInfo);
7962 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7963 if (tempcx & EnableSpectrum)
7964 SetSpectrum(pVBInfo);
7968 XGI_SetLCDCap_A(tempcx, pVBInfo);
7972 static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
7974 unsigned short temp;
7976 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
7978 if (temp & LCDRGB18Bit) {
7979 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
7980 (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
7981 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7983 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
7984 (unsigned short) (0x30 | (tempcx & 0x00C0)));
7985 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7989 if (tempcx & EnableLCD24bpp) { // 24bits
7990 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
7991 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7993 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
7994 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7999 /* --------------------------------------------------------------------- */
8000 /* Function : XGI_SetLCDCap_B */
8001 /* Input : cx -> LCD Capability */
8004 /* --------------------------------------------------------------------- */
8005 static void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
8007 if (tempcx & EnableLCD24bpp) /* 24bits */
8008 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8009 (unsigned short) (((tempcx & 0x00ff) >> 6)
8012 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8013 (unsigned short) (((tempcx & 0x00ff) >> 6)
8014 | 0x18)); /* Enable Dither */
8017 static void SetSpectrum(struct vb_device_info *pVBInfo)
8019 unsigned short index;
8021 index = XGI_GetLCDCapPtr(pVBInfo);
8023 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
8024 XGI_LongWait(pVBInfo);
8025 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
8026 XGI_LongWait(pVBInfo);
8028 XGINew_SetReg1(pVBInfo->Part4Port, 0x31,
8029 pVBInfo->LCDCapList[index].Spectrum_31);
8030 XGINew_SetReg1(pVBInfo->Part4Port, 0x32,
8031 pVBInfo->LCDCapList[index].Spectrum_32);
8032 XGINew_SetReg1(pVBInfo->Part4Port, 0x33,
8033 pVBInfo->LCDCapList[index].Spectrum_33);
8034 XGINew_SetReg1(pVBInfo->Part4Port, 0x34,
8035 pVBInfo->LCDCapList[index].Spectrum_34);
8036 XGI_LongWait(pVBInfo);
8037 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
8040 /* --------------------------------------------------------------------- */
8041 /* Function : XGI_SetAntiFlicker */
8044 /* Description : Set TV Customized Param. */
8045 /* --------------------------------------------------------------------- */
8046 static void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
8047 struct vb_device_info *pVBInfo)
8049 unsigned short tempbx, index;
8051 unsigned char tempah;
8053 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
8056 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8060 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
8062 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
8065 tempah = TVAntiFlickList[tempbx];
8066 tempah = tempah << 4;
8068 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
8071 static void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
8072 struct vb_device_info *pVBInfo)
8074 unsigned short tempbx, index;
8076 unsigned char tempah;
8078 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8082 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
8084 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
8087 tempah = TVEdgeList[tempbx];
8088 tempah = tempah << 5;
8090 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
8093 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
8095 unsigned short tempbx;
8097 unsigned char tempcl, tempch;
8099 unsigned long tempData;
8101 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
8102 tempData = TVPhaseList[tempbx];
8104 XGINew_SetReg1(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
8106 XGINew_SetReg1(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
8107 & 0x0000FF00) >> 8));
8108 XGINew_SetReg1(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
8109 & 0x00FF0000) >> 16));
8110 XGINew_SetReg1(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
8111 & 0xFF000000) >> 24));
8114 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
8115 struct vb_device_info *pVBInfo)
8117 unsigned short tempbx, index;
8119 unsigned char tempcl, tempch, tempal, *filterPtr;
8121 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
8126 filterPtr = NTSCYFilter1;
8130 filterPtr = PALYFilter1;
8136 filterPtr = PALMYFilter1;
8140 filterPtr = PALNYFilter1;
8145 filterPtr = NTSCYFilter2;
8149 filterPtr = PALMYFilter2;
8153 filterPtr = PALNYFilter2;
8157 filterPtr = PALYFilter2;
8165 tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
8168 = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
8175 if ((tempcl == 0) && (tempch == 1)) {
8176 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, 0);
8177 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, 0);
8178 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, 0);
8179 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8181 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
8182 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
8183 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
8184 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8187 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8188 | VB_XGI302LV | VB_XGI301C)) {
8189 XGINew_SetReg1(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
8190 XGINew_SetReg1(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
8191 XGINew_SetReg1(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
8195 /* --------------------------------------------------------------------- */
8196 /* Function : XGI_GetTVPtrIndex2 */
8198 /* Output : bx 0 : NTSC */
8202 /* 4 : NTSC1024x768 */
8203 /* 5 : PAL-M 1024x768 */
8205 /* cl 0 : YFilter1 */
8208 /* 1 : 301B/302B/301LV/302LV */
8210 /* --------------------------------------------------------------------- */
8211 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
8212 unsigned char *tempch, struct vb_device_info *pVBInfo)
8218 if (pVBInfo->TVInfo & SetPALTV)
8221 if (pVBInfo->TVInfo & SetPALMTV)
8224 if (pVBInfo->TVInfo & SetPALNTV)
8227 if (pVBInfo->TVInfo & NTSC1024x768) {
8229 if (pVBInfo->TVInfo & SetPALMTV)
8233 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8234 | VB_XGI302LV | VB_XGI301C)) {
8235 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
8242 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8243 | VB_XGI302LV | VB_XGI301C))
8247 /* --------------------------------------------------------------------- */
8248 /* Function : XGI_SetCRT2ModeRegs */
8251 /* Description : Origin code for crt2group */
8252 /* --------------------------------------------------------------------- */
8253 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
8254 struct xgi_hw_device_info *HwDeviceExtension,
8255 struct vb_device_info *pVBInfo)
8257 unsigned short tempbl;
8260 unsigned char tempah;
8262 /* XGINew_SetReg1(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
8264 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8265 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00);
8266 tempah &= ~0x10; /* BTRAMDAC */
8267 tempah |= 0x40; /* BTRAM */
8269 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8271 tempah = 0x40; /* BTDRAM */
8272 if (ModeNo > 0x13) {
8273 tempcl = pVBInfo->ModeType;
8276 tempah = (0x008 >> tempcl); /* BT Color */
8282 if (pVBInfo->VBInfo & SetInSlaveMode)
8283 tempah ^= 0x50; /* BTDAC */
8288 if (pVBInfo->VBInfo & DisableCRT2Display) {
8292 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8293 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
8294 tempcl = pVBInfo->ModeType;
8295 if (ModeNo > 0x13) {
8297 if ((tempcl > 0) || (tempcl == 0)) {
8298 tempah=(0x008>>tempcl) ;
8307 if (pVBInfo->VBInfo & SetInSlaveMode) {
8308 tempah = (tempah ^ 0x050);
8313 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8317 if (pVBInfo->VBInfo & DisableCRT2Display) {
8318 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
8323 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8324 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
8325 if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
8326 && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
8329 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e,
8332 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8337 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
8338 | SetCRT2ToTV | SetCRT2ToLCD)) {
8342 if (!(pVBInfo->VBInfo & SetInSlaveMode))
8345 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
8346 tempah = tempah ^ 0x05;
8347 if (!(pVBInfo->VBInfo
8349 tempah = tempah ^ 0x01;
8352 if (!(pVBInfo->VBInfo
8353 & SetCRT2ToDualEdge))
8355 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8356 0x2e, tempbl, tempah);
8358 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8359 0x2e, tempbl, tempah);
8363 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl,
8368 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
8371 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
8372 & SetInSlaveMode))) {
8377 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8378 /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
8380 if (ModeNo > 0x13) {
8381 if (pVBInfo->VBInfo & DriverMode)
8382 tempah = tempah ^ 0x20;
8387 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
8390 if (pVBInfo->LCDInfo & SetLCDDualLink)
8393 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8394 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
8395 if (pVBInfo->TVInfo & RPLLDIV2XO)
8400 if ((pVBInfo->LCDResInfo == Panel1280x1024)
8401 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
8404 if (pVBInfo->LCDResInfo == Panel1280x960)
8407 XGINew_SetReg1(pVBInfo->Part4Port, 0x0C, tempah);
8410 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8411 | VB_XGI302LV | VB_XGI301C)) {
8415 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8417 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8418 tempah |= 0x04; /* shampoo 0129 */
8421 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x13, tempbl, tempah);
8424 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8425 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8429 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
8433 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8434 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8437 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, tempbl, tempah);
8442 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
8444 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
8448 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x23, tempbl, tempah);
8450 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8451 if (pVBInfo->LCDInfo & SetLCDDualLink) {
8452 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x20);
8453 XGINew_SetRegOR(pVBInfo->Part4Port, 0x34, 0x10);
8458 static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8459 struct vb_device_info *pVBInfo)
8461 unsigned short tempbx;
8465 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8470 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8471 struct vb_device_info *pVBInfo)
8473 unsigned short tempbx;
8477 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
8478 unsigned short RefreshRateTableIndex,
8479 struct vb_device_info *pVBInfo)
8481 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
8482 StandTableIndex, CRT1Index;
8484 pVBInfo->RVBHCMAX = 1;
8485 pVBInfo->RVBHCFACT = 1;
8487 if (ModeNo <= 0x13) {
8488 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8489 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8490 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
8491 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
8492 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
8494 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8496 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
8497 CRT1Index &= IndexMask;
8499 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
8501 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
8502 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
8504 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
8506 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
8509 tempcx = tempcx << 2;
8512 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
8522 if (modeflag & Charx8Dot)
8527 pVBInfo->VGAHT = tempax;
8528 pVBInfo->HT = tempax;
8530 pVBInfo->VGAVT = tempbx;
8531 pVBInfo->VT = tempbx;
8534 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
8535 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
8537 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
8539 unsigned short modeflag;
8542 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8544 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8546 index = (modeflag & ModeInfoFlag) - ModeEGA;
8551 return ColorDepth[index];
8554 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8555 struct vb_device_info *pVBInfo)
8558 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
8562 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8563 struct vb_device_info *pVBInfo)
8566 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
8570 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
8572 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
8575 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
8577 unsigned short flag;
8579 if (pVBInfo->IF_DEF_LVDS == 1) {
8582 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
8583 if ((flag == 1) || (flag == 2))
8584 return 1; /* 301b */
8590 void XGI_LongWait(struct vb_device_info *pVBInfo)
8594 i = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
8597 for (i = 0; i < 0xFFFF; i++) {
8598 if (!(XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8602 for (i = 0; i < 0xFFFF; i++) {
8603 if ((XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8609 static void XGI_VBLongWait(struct vb_device_info *pVBInfo)
8611 unsigned short tempal, temp, i, j;
8613 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
8615 for (i = 0; i < 3; i++) {
8616 for (j = 0; j < 100; j++) {
8617 tempal = XGINew_GetReg2(pVBInfo->P3da);
8618 if (temp & 0x01) { /* VBWaitMode2 */
8619 if ((tempal & 0x08))
8622 if (!(tempal & 0x08))
8625 } else { /* VBWaitMode1 */
8626 if (!(tempal & 0x08))
8629 if ((tempal & 0x08))
8636 XGI_LongWait(pVBInfo);
8641 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
8643 unsigned long tempax, tempbx;
8645 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
8647 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
8648 tempax = (tempax * pVBInfo->HT) / tempbx;
8650 return (unsigned short) tempax;
8653 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
8654 unsigned short ModeIdIndex,
8655 unsigned short RefreshRateTableIndex,
8656 struct xgi_hw_device_info *HwDeviceExtension,
8657 struct vb_device_info *pVBInfo)
8659 unsigned short tempbx;
8661 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8663 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
8664 VCLK108_2 + 5, VCLK108_2 + 5 };
8665 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
8666 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8668 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8671 unsigned short CRT2Index, VCLKIndex;
8672 unsigned short modeflag, resinfo;
8673 unsigned char *CHTVVCLKPtr = NULL;
8675 if (ModeNo <= 0x13) {
8676 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8677 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
8678 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
8680 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
8681 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
8683 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
8686 if (pVBInfo->IF_DEF_LVDS == 0) {
8687 CRT2Index = CRT2Index >> 6; /* for LCD */
8688 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
8689 if (pVBInfo->LCDResInfo != Panel1024x768)
8690 VCLKIndex = LCDXlat2VCLK[CRT2Index];
8692 VCLKIndex = LCDXlat1VCLK[CRT2Index];
8693 } else { /* for TV */
8694 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8695 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
8696 if (pVBInfo->SetFlag & RPLLDIV2XO) {
8697 VCLKIndex = HiTVVCLKDIV2;
8702 VCLKIndex = HiTVVCLK;
8708 if (pVBInfo->SetFlag & TVSimuMode) {
8709 if (modeflag & Charx8Dot) {
8724 if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
8725 if (!(pVBInfo->VBExtInfo
8726 == VB_YPbPr1080i)) {
8729 if (!(pVBInfo->VBExtInfo
8733 if (!(pVBInfo->VBExtInfo
8737 if (!(pVBInfo->SetFlag
8746 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8747 if (pVBInfo->SetFlag
8749 VCLKIndex = TVVCLKDIV2;
8761 } else { /* for CRT2 */
8762 VCLKIndex = (unsigned char) XGINew_GetReg2(
8763 (pVBInfo->P3ca + 0x02)); /* Port 3cch */
8764 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
8765 if (ModeNo > 0x13) {
8767 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
8768 VCLKIndex &= IndexMask;
8774 VCLKIndex = CRT2Index;
8776 VCLKIndex = CRT2Index;
8778 if (pVBInfo->IF_DEF_CH7005 == 1) {
8779 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
8783 if (pVBInfo->VBInfo & SetPALTV)
8786 if (pVBInfo->VBInfo & SetCHTVOverScan)
8791 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
8794 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
8797 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
8800 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
8806 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
8809 VCLKIndex = VCLKIndex >> 6;
8810 if ((pVBInfo->LCDResInfo == Panel800x600)
8811 || (pVBInfo->LCDResInfo == Panel320x480))
8812 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
8813 else if ((pVBInfo->LCDResInfo == Panel1024x768)
8814 || (pVBInfo->LCDResInfo
8815 == Panel1024x768x75))
8816 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
8818 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
8821 /* VCLKIndex = VCLKIndex&IndexMask; */