Staging: xgifb: Remove unused code
[linux-2.6/cjktty.git] / drivers / staging / xgifb / vb_setmode.c
blob4a2fa32e7d94f0538e476fa00393a2a403176eba
2 #include <asm/io.h>
3 #include <linux/types.h>
4 #include <linux/version.h>
5 #include "XGIfb.h"
8 #include "vb_def.h"
9 #include "vgatypes.h"
10 #include "vb_struct.h"
11 #include "vb_util.h"
12 #include "vb_table.h"
16 #define IndexMask 0xff
17 #ifndef XGI_MASK_DUAL_CHIP
18 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
19 #endif
23 BOOLEAN XGI_IsLCDDualLink(PVB_DEVICE_INFO pVBInfo);
24 BOOLEAN XGI_SetCRT2Group301(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
25 BOOLEAN XGI_BacklightByDrv(PVB_DEVICE_INFO pVBInfo);
27 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo);
28 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo);
29 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo);
30 BOOLEAN XGI_AjustCRT2Rate(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,USHORT *i, PVB_DEVICE_INFO pVBInfo);
31 BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
32 BOOLEAN XGI_GetLCDInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
33 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo ) ;
34 BOOLEAN XGI_BridgeIsOn(PVB_DEVICE_INFO pVBInfo);
35 UCHAR XGI_GetModePtr( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
36 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
37 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
38 USHORT XGI_GetResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
39 USHORT XGI_GetColorDepth(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
40 USHORT XGI_GetVGAHT2(PVB_DEVICE_INFO pVBInfo);
41 USHORT XGI_GetVCLK2Ptr(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
42 void XGI_VBLongWait(PVB_DEVICE_INFO pVBInfo);
43 void XGI_SaveCRT2Info(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo);
44 void XGI_GetCRT2Data(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
45 void XGI_GetCRT2ResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
46 void XGI_PreSetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
47 void XGI_SetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
48 void XGI_SetLockRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
49 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
50 void XGI_SetGroup2(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
51 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
52 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
53 void XGI_SetGroup5(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
54 void* XGI_GetLcdPtr(USHORT BX, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
55 void* XGI_GetTVPtr(USHORT BX, USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
56 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo);
57 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
58 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
59 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
60 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
61 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo);
62 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo);
63 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo);
64 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo);
66 void XGI_DisplayOn(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
67 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
68 void XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
69 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
70 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
71 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
72 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
73 void XGI_UpdateXG21CRTC(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo, USHORT RefreshRateTableIndex);
74 void XGI_WaitDisply(PVB_DEVICE_INFO pVBInfo);
75 void XGI_SenseCRT1(PVB_DEVICE_INFO pVBInfo);
76 void XGI_SetSeqRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
77 void XGI_SetMiscRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
78 void XGI_SetCRTCRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
79 void XGI_SetATTRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
80 void XGI_SetGRCRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
81 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo);
83 void XGI_SetSync(USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
84 void XGI_SetCRT1CRTC(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
85 void XGI_SetCRT1Timing_H(PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
86 void XGI_SetCRT1Timing_V(USHORT ModeIdIndex,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);
87 void XGI_SetCRT1DE(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
88 void XGI_SetCRT1VCLK(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
89 void XGI_SetCRT1FIFO(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
90 void XGI_SetCRT1ModeRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
91 void XGI_SetVCLKState(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
93 void XGI_LoadDAC(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
94 void XGI_WriteDAC(USHORT dl, USHORT ah, USHORT al, USHORT dh, PVB_DEVICE_INFO pVBInfo);
95 /*void XGI_ClearBuffer(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);*/
96 void XGI_SetLCDAGroup(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
97 void XGI_GetLVDSResInfo( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
98 void XGI_GetLVDSData(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
99 void XGI_ModCRT1Regs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
100 void XGI_SetLVDSRegs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
101 void XGI_UpdateModeInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
102 void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
103 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo);
104 void XGI_GetVBInfo(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
105 void XGI_GetTVInfo(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
106 void XGI_SetCRT2ECLK( USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
107 void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
108 void XGI_GetLCDSync(USHORT* HSyncWidth, USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo);
109 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
110 void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
111 void XGI_SetCRT2VCLK(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
112 void XGI_OEM310Setting(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
113 void XGI_SetDelayComp(PVB_DEVICE_INFO pVBInfo);
114 void XGI_SetLCDCap(PVB_DEVICE_INFO pVBInfo);
115 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
116 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
117 void SetSpectrum(PVB_DEVICE_INFO pVBInfo);
118 void XGI_SetAntiFlicker(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
119 void XGI_SetEdgeEnhance(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
120 void XGI_SetPhaseIncr(PVB_DEVICE_INFO pVBInfo);
121 void XGI_SetYFilter(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
122 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo);
123 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo );
124 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
125 void XGI_CloseCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
126 void XGI_OpenCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
127 void XGI_GetRAMDAC2DATA(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
128 void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
129 void XGI_LockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
130 void XGINew_EnableCRT2(PVB_DEVICE_INFO pVBInfo);
131 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo);
132 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo);
133 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo );
134 void XGI_GetLCDVCLKPtr(UCHAR* di_0,UCHAR *di_1, PVB_DEVICE_INFO pVBInfo);
135 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
136 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo);
137 USHORT XGI_GetLCDCapPtr(PVB_DEVICE_INFO pVBInfo);
138 USHORT XGI_GetLCDCapPtr1(PVB_DEVICE_INFO pVBInfo);
139 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo);
140 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
141 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
142 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo);
143 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo);
144 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
145 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
146 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
147 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
148 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
149 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
150 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo );
152 extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
154 /* USHORT XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
160 USHORT XGINew_MDA_DAC[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
161 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
162 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
163 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
164 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
165 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
166 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
167 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F};
169 USHORT XGINew_CGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
170 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
171 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
172 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
173 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
174 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
175 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
176 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
178 USHORT XGINew_EGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15,
179 0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35,
180 0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D,
181 0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D,
182 0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17,
183 0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37,
184 0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F,
185 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
187 USHORT XGINew_VGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
188 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
189 0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18,
190 0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F,
192 0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F,
193 0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00,
194 0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18,
195 0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04,
196 0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10,
197 0x0B,0x0C,0x0D,0x0F,0x10};
200 /* --------------------------------------------------------------------- */
201 /* Function : InitTo330Pointer */
202 /* Input : */
203 /* Output : */
204 /* Description : */
205 /* --------------------------------------------------------------------- */
206 void InitTo330Pointer( UCHAR ChipType ,PVB_DEVICE_INFO pVBInfo)
208 pVBInfo->SModeIDTable = (XGI_StStruct *) XGI330_SModeIDTable ;
209 pVBInfo->StandTable = (XGI_StandTableStruct *) XGI330_StandTable ;
210 pVBInfo->EModeIDTable = (XGI_ExtStruct *) XGI330_EModeIDTable ;
211 pVBInfo->RefIndex = (XGI_Ext2Struct *) XGI330_RefIndex ;
212 pVBInfo->XGINEWUB_CRT1Table = (XGI_CRT1TableStruct *) XGI_CRT1Table ;
214 /* add for new UNIVGABIOS */
215 /* XGINew_UBLCDDataTable = (XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
216 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
219 if ( ChipType >= XG40 )
221 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI340New_MCLKData ;
222 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI340_ECLKData ;
224 else
226 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI330New_MCLKData ;
227 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI330_ECLKData ;
230 pVBInfo->VCLKData = (XGI_VCLKDataStruct *) XGI_VCLKData ;
231 pVBInfo->VBVCLKData = (XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
232 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
233 pVBInfo->StResInfo = (XGI_StResInfoStruct *) XGI330_StResInfo ;
234 pVBInfo->ModeResInfo = (XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
236 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
237 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
238 pVBInfo->pSR07 = &XGI330_SR07 ;
239 pVBInfo->LCDResInfo = 0 ;
240 pVBInfo->LCDTypeInfo = 0 ;
241 pVBInfo->LCDInfo = 0 ;
242 pVBInfo->VBInfo = 0 ;
243 pVBInfo->TVInfo = 0;
246 pVBInfo->SR15 = XGI340_SR13 ;
247 pVBInfo->CR40 = XGI340_cr41 ;
248 pVBInfo->SR25 = XGI330_sr25 ;
249 pVBInfo->pSR31 = &XGI330_sr31 ;
250 pVBInfo->pSR32 = &XGI330_sr32 ;
251 pVBInfo->CR6B = XGI340_CR6B ;
252 pVBInfo->CR6E = XGI340_CR6E ;
253 pVBInfo->CR6F = XGI340_CR6F ;
254 pVBInfo->CR89 = XGI340_CR89 ;
255 pVBInfo->AGPReg = XGI340_AGPReg ;
256 pVBInfo->SR16 = XGI340_SR16 ;
257 pVBInfo->pCRCF = &XG40_CRCF ;
258 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
261 pVBInfo->CR49 = XGI330_CR49 ;
262 pVBInfo->pSR1F = &XGI330_SR1F ;
263 pVBInfo->pSR21 = &XGI330_SR21 ;
264 pVBInfo->pSR22 = &XGI330_SR22 ;
265 pVBInfo->pSR23 = &XGI330_SR23 ;
266 pVBInfo->pSR24 = &XGI330_SR24 ;
267 pVBInfo->pSR33 = &XGI330_SR33 ;
271 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
272 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
273 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
274 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
275 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
276 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
277 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
278 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
279 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
280 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
282 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
283 pVBInfo->PALTiming = XGI330_PALTiming ;
284 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
285 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
286 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
287 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
288 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
289 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
290 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
291 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
292 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
293 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
294 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
295 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
298 pVBInfo->TimingH = (XGI_TimingHStruct *) XGI_TimingH ;
299 pVBInfo->TimingV = (XGI_TimingVStruct *) XGI_TimingV ;
300 pVBInfo->UpdateCRT1 = (XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
302 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
303 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
304 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
305 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
307 /* 310 customization related */
308 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
309 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
310 else
311 pVBInfo->LCDCapList = XGI_LCDCapList ;
313 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
314 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
316 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
317 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
320 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
322 if ( ChipType >= XG20 )
323 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
325 if ( ChipType == XG27 )
327 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI27New_MCLKData ;
328 pVBInfo->CR40 = XGI27_cr41 ;
329 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
330 pVBInfo->pSR36 = &XG27_SR36 ;
331 pVBInfo->pCR8F = &XG27_CR8F ;
332 pVBInfo->pCRD0 = XG27_CRD0 ;
333 pVBInfo->pCRDE = XG27_CRDE ;
334 pVBInfo->pSR40 = &XG27_SR40 ;
335 pVBInfo->pSR41 = &XG27_SR41 ;
339 if ( ChipType >= XG20 )
341 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
342 pVBInfo->pCR2E = &XG21_CR2E ;
343 pVBInfo->pCR2F = &XG21_CR2F ;
344 pVBInfo->pCR46 = &XG21_CR46 ;
345 pVBInfo->pCR47 = &XG21_CR47 ;
355 /* --------------------------------------------------------------------- */
356 /* Function : XGISetModeNew */
357 /* Input : */
358 /* Output : */
359 /* Description : */
360 /* --------------------------------------------------------------------- */
361 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo )
363 USHORT ModeIdIndex ;
364 /* PUCHAR pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
365 VB_DEVICE_INFO VBINF;
366 PVB_DEVICE_INFO pVBInfo = &VBINF;
367 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
368 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
369 pVBInfo->IF_DEF_LVDS = 0 ;
370 pVBInfo->IF_DEF_CH7005 = 0 ;
371 pVBInfo->IF_DEF_LCDA = 1 ;
372 pVBInfo->IF_DEF_CH7017 = 0 ;
373 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
374 pVBInfo->IF_DEF_VideoCapture = 0 ;
375 pVBInfo->IF_DEF_ScaleLCD = 0 ;
376 pVBInfo->IF_DEF_OEMUtil = 0 ;
377 pVBInfo->IF_DEF_PWD = 0 ;
380 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
382 pVBInfo->IF_DEF_YPbPr = 0 ;
383 pVBInfo->IF_DEF_HiVision = 0 ;
384 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
385 pVBInfo->VBType = 0 ; /*set VBType default 0*/
387 else if ( HwDeviceExtension->jChipType >= XG40 )
389 pVBInfo->IF_DEF_YPbPr = 1 ;
390 pVBInfo->IF_DEF_HiVision = 1 ;
391 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
393 else
395 pVBInfo->IF_DEF_YPbPr = 1 ;
396 pVBInfo->IF_DEF_HiVision = 1 ;
397 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
400 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
401 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
402 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
403 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
404 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
405 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
406 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
407 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
408 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
409 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
410 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
411 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
412 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
413 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
414 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
415 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
416 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
417 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
419 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
421 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
423 pVBInfo->IF_DEF_LVDS = 1 ;
426 if ( HwDeviceExtension->jChipType == XG27 )
428 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
430 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
432 pVBInfo->IF_DEF_LVDS = 1 ;
437 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
438 XGI_GetVBType( pVBInfo ) ;
440 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
441 if ( ModeNo & 0x80 )
443 ModeNo = ModeNo & 0x7F ;
444 /* XGINew_flag_clearbuffer = 0 ; */
446 /* else
448 XGINew_flag_clearbuffer = 1 ;
451 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
453 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
454 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
456 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
458 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
460 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
462 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
463 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
464 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
465 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
466 /* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
468 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
470 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
472 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
474 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
477 else
479 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
481 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
482 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
484 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
489 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
491 switch( HwDeviceExtension->ujVBChipID )
493 case VB_CHIP_301:
494 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
495 break ;
497 case VB_CHIP_302:
498 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
499 break ;
501 default:
502 break ;
506 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
507 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
508 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
509 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
510 } /* !XG20 */
511 else
513 if (pVBInfo->IF_DEF_LVDS == 1)
514 if (!XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo))
515 return 0;
517 if ( ModeNo <= 0x13 )
519 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
521 else
523 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
526 pVBInfo->SetFlag = 0 ;
527 if ( pVBInfo->IF_DEF_CH7007 != 1 )
529 pVBInfo->VBInfo = DisableCRT2Display ;
533 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
535 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
537 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
539 if( HwDeviceExtension->jChipType == XG21 )
540 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
546 if ( ModeNo <= 0x13 )
548 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
550 else
552 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
554 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
555 pVBInfo->SetFlag = 0x00 ;
556 pVBInfo->VBInfo = DisableCRT2Display ;
557 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
559 if ( temp == 0 )
560 return( 0 ) ;
562 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
563 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
564 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
567 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
569 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
571 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
574 return 1;
578 /* --------------------------------------------------------------------- */
579 /* Function : XGI_SetCRT1Group */
580 /* Input : */
581 /* Output : */
582 /* Description : */
583 /* --------------------------------------------------------------------- */
584 void XGI_SetCRT1Group( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
586 USHORT StandTableIndex ,
587 RefreshRateTableIndex ,
588 b3CC ,
589 temp ;
591 USHORT XGINew_P3cc = pVBInfo->P3cc;
593 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
594 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
595 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
596 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
597 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
598 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
599 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
600 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
601 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
602 XGI_ClearExt1Regs(pVBInfo) ;
604 /* if ( pVBInfo->IF_DEF_ExpLink ) */
605 if ( HwDeviceExtension->jChipType == XG27 )
607 if ( pVBInfo->IF_DEF_LVDS == 0 )
609 XGI_SetDefaultVCLK( pVBInfo ) ;
613 temp = ~ProgrammingCRT2 ;
614 pVBInfo->SetFlag &= temp ;
615 pVBInfo->SelectCRT2Rate = 0 ;
617 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
619 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
621 pVBInfo->SetFlag |= ProgrammingCRT2 ;
625 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
626 if ( RefreshRateTableIndex != 0xFFFF )
628 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
629 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
630 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
631 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
632 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
635 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
636 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
638 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
640 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
641 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
642 b3CC =(UCHAR) XGINew_GetReg2(XGINew_P3cc) ;
643 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
645 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
647 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
648 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
649 b3CC = (UCHAR)XGINew_GetReg2(XGINew_P3cc) ;
650 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
654 if ( HwDeviceExtension->jChipType >= XG21 )
656 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
657 if ( temp & 0xA0 )
660 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
661 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
662 /* XG21 CRT1 Timing */
663 if ( HwDeviceExtension->jChipType == XG27 )
664 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
665 else
666 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
668 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
670 if ( HwDeviceExtension->jChipType == XG27 )
671 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
672 else
673 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
675 if ( pVBInfo->IF_DEF_LVDS == 1 )
677 if ( HwDeviceExtension->jChipType == XG27 )
678 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
679 else
680 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
682 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
686 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
687 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
688 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
691 /* XGI_LoadCharacter(); //dif ifdef TVFont */
693 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
694 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
698 /* --------------------------------------------------------------------- */
699 /* Function : XGI_GetModePtr */
700 /* Input : */
701 /* Output : */
702 /* Description : */
703 /* --------------------------------------------------------------------- */
704 UCHAR XGI_GetModePtr( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
706 UCHAR index ;
708 if ( ModeNo <= 0x13 )
709 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
710 else
712 if ( pVBInfo->ModeType <= 0x02 )
713 index = 0x1B ; /* 02 -> ModeEGA */
714 else
715 index = 0x0F ;
717 return( index ) ; /* Get pVBInfo->StandTable index */
721 /* --------------------------------------------------------------------- */
722 /* Function : XGI_SetBIOSData */
723 /* Input : */
724 /* Output : */
725 /* Description : */
726 /* --------------------------------------------------------------------- */
727 /*UCHAR XGI_SetBIOSData( USHORT ModeNo , USHORT ModeIdIndex )
729 return( 0 ) ;
733 /* --------------------------------------------------------------------- */
734 /* Function : XGI_ClearBankRegs */
735 /* Input : */
736 /* Output : */
737 /* Description : */
738 /* --------------------------------------------------------------------- */
739 /*UCHAR XGI_ClearBankRegs( USHORT ModeNo , USHORT ModeIdIndex )
741 return( 0 ) ;
745 /* --------------------------------------------------------------------- */
746 /* Function : XGI_SetSeqRegs */
747 /* Input : */
748 /* Output : */
749 /* Description : */
750 /* --------------------------------------------------------------------- */
751 void XGI_SetSeqRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
753 UCHAR tempah ,
754 SRdata ;
756 USHORT i ,
757 modeflag ;
759 if ( ModeNo <= 0x13 )
760 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
761 else
762 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
764 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
765 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
767 i = SetCRT2ToLCDA ;
768 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
770 tempah |= 0x01 ;
772 else
774 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
776 if ( pVBInfo->VBInfo & SetInSlaveMode )
777 tempah |= 0x01 ;
781 tempah |= 0x20 ; /* screen off */
782 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
784 for( i = 02 ; i <= 04 ; i++ )
786 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
787 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
792 /* --------------------------------------------------------------------- */
793 /* Function : XGI_SetMiscRegs */
794 /* Input : */
795 /* Output : */
796 /* Description : */
797 /* --------------------------------------------------------------------- */
798 void XGI_SetMiscRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
800 UCHAR Miscdata ;
802 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
804 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
806 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
808 Miscdata |= 0x0C ;
813 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
817 /* --------------------------------------------------------------------- */
818 /* Function : XGI_SetCRTCRegs */
819 /* Input : */
820 /* Output : */
821 /* Description : */
822 /* --------------------------------------------------------------------- */
823 void XGI_SetCRTCRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
825 UCHAR CRTCdata ;
826 USHORT i ;
828 CRTCdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
829 CRTCdata &= 0x7f ;
830 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
832 for( i = 0 ; i <= 0x18 ; i++ )
834 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
835 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
838 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
840 if ( pVBInfo->VBInfo & SetInSlaveMode )
842 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
844 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
852 /* --------------------------------------------------------------------- */
853 /* Function : */
854 /* Input : */
855 /* Output : */
856 /* Description : */
857 /* --------------------------------------------------------------------- */
858 void XGI_SetATTRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
860 UCHAR ARdata ;
861 USHORT i ,
862 modeflag ;
864 if ( ModeNo <= 0x13 )
865 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
866 else
867 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
869 for( i = 0 ; i <= 0x13 ; i++ )
871 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
872 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
874 if ( i == 0x13 )
876 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
877 ARdata = 0 ;
878 else
880 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
882 if ( pVBInfo->VBInfo & SetInSlaveMode )
883 ARdata = 0 ;
889 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
890 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
891 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
894 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
895 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
896 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
897 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
898 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
902 /* --------------------------------------------------------------------- */
903 /* Function : XGI_SetGRCRegs */
904 /* Input : */
905 /* Output : */
906 /* Description : */
907 /* --------------------------------------------------------------------- */
908 void XGI_SetGRCRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
910 UCHAR GRdata ;
911 USHORT i ;
913 for( i = 0 ; i <= 0x08 ; i++ )
915 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
916 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
919 if ( pVBInfo->ModeType > ModeVGA )
921 GRdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3ce , 0x05 ) ;
922 GRdata &= 0xBF ; /* 256 color disable */
923 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
928 /* --------------------------------------------------------------------- */
929 /* Function : XGI_ClearExt1Regs */
930 /* Input : */
931 /* Output : */
932 /* Description : */
933 /* --------------------------------------------------------------------- */
934 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo)
936 USHORT i ;
938 for( i = 0x0A ; i <= 0x0E ; i++ )
939 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
943 /* --------------------------------------------------------------------- */
944 /* Function : XGI_SetDefaultVCLK */
945 /* Input : */
946 /* Output : */
947 /* Description : */
948 /* --------------------------------------------------------------------- */
949 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo )
952 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
953 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
954 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
956 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
957 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
958 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
960 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
961 return( 0 ) ;
965 /* --------------------------------------------------------------------- */
966 /* Function : XGI_GetRatePtrCRT2 */
967 /* Input : */
968 /* Output : */
969 /* Description : */
970 /* --------------------------------------------------------------------- */
971 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
973 SHORT LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
974 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
976 USHORT RefreshRateTableIndex , i ,
977 modeflag , index , temp ;
979 if ( ModeNo <= 0x13 )
981 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
983 else
985 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
988 if ( pVBInfo->IF_DEF_CH7005 == 1 )
990 if ( pVBInfo->VBInfo & SetCRT2ToTV )
992 if ( modeflag & HalfDCLK )
993 return( 0 ) ;
997 if ( ModeNo < 0x14 )
998 return( 0xFFFF ) ;
1000 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1001 index = index >> pVBInfo->SelectCRT2Rate ;
1002 index &= 0x0F ;
1004 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1005 index = 0 ;
1007 if ( index > 0 )
1008 index-- ;
1010 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1012 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1014 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1016 index = 0 ;
1020 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1022 if( pVBInfo->IF_DEF_LVDS == 0 )
1024 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1025 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1026 else
1027 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1029 if ( index > temp )
1031 index = temp ;
1034 else
1036 index = 0 ;
1041 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1042 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1043 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1046 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1048 index++;
1051 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1052 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1054 index++;
1056 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1057 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1058 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1060 index++;
1062 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1063 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1065 index++;
1069 i = 0 ;
1072 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1073 break ;
1074 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1075 temp &= ModeInfoFlag ;
1076 if ( temp < pVBInfo->ModeType )
1077 break ;
1078 i++ ;
1079 index-- ;
1081 } while( index != 0xFFFF ) ;
1082 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1084 if ( pVBInfo->VBInfo & SetInSlaveMode )
1086 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1087 if ( temp & InterlaceMode )
1089 i++ ;
1093 i-- ;
1094 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1096 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1098 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1102 /* --------------------------------------------------------------------- */
1103 /* Function : XGI_AjustCRT2Rate */
1104 /* Input : */
1105 /* Output : */
1106 /* Description : */
1107 /* --------------------------------------------------------------------- */
1108 BOOLEAN XGI_AjustCRT2Rate( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , USHORT *i, PVB_DEVICE_INFO pVBInfo )
1110 USHORT tempax ,
1111 tempbx ,
1112 resinfo ,
1113 modeflag ,
1114 infoflag ;
1116 if ( ModeNo <= 0x13 )
1118 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1120 else
1122 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1125 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1126 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1127 tempax = 0 ;
1129 if ( pVBInfo->IF_DEF_LVDS == 0 )
1131 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1133 tempax |= SupportRAMDAC2 ;
1135 if ( pVBInfo->VBType & VB_XGI301C )
1136 tempax |= SupportCRT2in301C ;
1139 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1141 tempax |= SupportLCD ;
1143 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1145 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1147 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1149 if ( resinfo >= 9 )
1151 tempax = 0 ;
1152 return( 0 ) ;
1159 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1161 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1163 tempax |= SupportYPbPr ;
1164 if ( pVBInfo->VBInfo & SetInSlaveMode )
1166 if ( resinfo == 4 )
1167 return( 0 ) ;
1169 if ( resinfo == 3 )
1170 return( 0 ) ;
1172 if ( resinfo > 7 )
1173 return( 0 ) ;
1176 else
1178 tempax |= SupportHiVisionTV ;
1179 if ( pVBInfo->VBInfo & SetInSlaveMode )
1181 if ( resinfo == 4 )
1182 return( 0 ) ;
1184 if ( resinfo == 3 )
1186 if ( pVBInfo->SetFlag & TVSimuMode )
1187 return( 0 ) ;
1190 if ( resinfo > 7 )
1191 return( 0 ) ;
1195 else
1197 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1199 tempax |= SupportTV ;
1201 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1203 tempax |= SupportTV1024 ;
1206 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1208 if ( modeflag & NoSupportSimuTV )
1210 if ( pVBInfo->VBInfo & SetInSlaveMode )
1212 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1214 return( 0 ) ;
1222 else /* for LVDS */
1224 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1226 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1228 tempax |= SupportCHTV ;
1232 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1234 tempax |= SupportLCD ;
1236 if ( resinfo > 0x08 )
1237 return( 0 ) ; /* 1024x768 */
1239 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1241 if ( resinfo > 0x07 )
1242 return( 0 ) ; /* 800x600 */
1244 if ( resinfo == 0x04 )
1245 return( 0 ) ; /* 512x384 */
1250 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1252 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1253 if ( infoflag & tempax )
1255 return( 1 ) ;
1257 if ( ( *i ) == 0 )
1258 break ;
1261 for( ( *i ) = 0 ; ; ( *i )++ )
1263 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1264 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1266 return( 0 ) ;
1269 if ( infoflag & tempax )
1271 return( 1 ) ;
1274 return( 1 ) ;
1278 /* --------------------------------------------------------------------- */
1279 /* Function : XGI_SetSync */
1280 /* Input : */
1281 /* Output : */
1282 /* Description : */
1283 /* --------------------------------------------------------------------- */
1284 void XGI_SetSync(USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1286 USHORT sync ,
1287 temp ;
1289 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1290 sync &= 0xC0 ;
1291 temp = 0x2F ;
1292 temp |= sync ;
1293 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1297 /* --------------------------------------------------------------------- */
1298 /* Function : XGI_SetCRT1CRTC */
1299 /* Input : */
1300 /* Output : */
1301 /* Description : */
1302 /* --------------------------------------------------------------------- */
1303 void XGI_SetCRT1CRTC( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1305 UCHAR index ,
1306 data ;
1308 USHORT i ;
1310 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1311 index = index&IndexMask ;
1313 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1314 data &= 0x7F ;
1315 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1317 for( i = 0 ; i < 8 ; i++ )
1318 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1320 for( i = 0 ; i < 7 ; i++ )
1321 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1323 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1327 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1330 if( pVBInfo->ModeType > 0x03 )
1331 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1335 /* --------------------------------------------------------------------- */
1336 /* Function : XGI_SetCRT1Timing_H */
1337 /* Input : */
1338 /* Output : */
1339 /* Description : */
1340 /* --------------------------------------------------------------------- */
1341 void XGI_SetCRT1Timing_H( PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1343 UCHAR data , data1, pushax;
1344 USHORT i , j ;
1346 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1347 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1348 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1350 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ; /* unlock cr0-7 */
1351 data &= 0x7F ;
1352 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1354 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1355 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1357 for( i = 0x01 ; i <= 0x04 ; i++ )
1359 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
1360 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 1 ) , data ) ;
1363 for( i = 0x05 ; i <= 0x06 ; i++ )
1365 data = pVBInfo->TimingH[ 0 ].data[ i ];
1366 XGINew_SetReg1( pVBInfo->P3c4 ,( USHORT )( i + 6 ) , data ) ;
1369 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1370 j &= 0x1F ;
1371 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1372 data &= 0xE0 ;
1373 data |= j ;
1374 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1376 if ( HwDeviceExtension->jChipType >= XG20 )
1378 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x04 ) ;
1379 data = data - 1 ;
1380 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1381 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x05 ) ;
1382 data1 = data ;
1383 data1 &= 0xE0 ;
1384 data &= 0x1F ;
1385 if ( data == 0 )
1387 pushax = data ;
1388 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0c ) ;
1389 data &= 0xFB ;
1390 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1391 data = pushax ;
1393 data = data - 1 ;
1394 data |= data1 ;
1395 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1396 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1397 data = data >> 5 ;
1398 data = data + 3 ;
1399 if ( data > 7 )
1400 data = data - 7 ;
1401 data = data << 5 ;
1402 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1407 /* --------------------------------------------------------------------- */
1408 /* Function : XGI_SetCRT1Timing_V */
1409 /* Input : */
1410 /* Output : */
1411 /* Description : */
1412 /* --------------------------------------------------------------------- */
1413 void XGI_SetCRT1Timing_V( USHORT ModeIdIndex , USHORT ModeNo,PVB_DEVICE_INFO pVBInfo )
1415 UCHAR data ;
1416 USHORT i , j ;
1418 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1419 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1420 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1422 for( i = 0x00 ; i <= 0x01 ; i++ )
1424 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1425 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 6 ) , data ) ;
1428 for( i = 0x02 ; i <= 0x03 ; i++ )
1430 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1431 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x0e ) , data ) ;
1434 for( i = 0x04 ; i <= 0x05 ; i++ )
1436 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1437 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x11 ) , data ) ;
1440 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0a ) ;
1441 j &= 0xC0 ;
1442 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1443 data &= 0x3F ;
1444 data |= j ;
1445 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1447 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1448 data &= 0x80 ;
1449 data = data >> 2 ;
1451 if ( ModeNo <= 0x13 )
1452 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1453 else
1454 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1456 i &= DoubleScanMode ;
1457 if ( i )
1458 data |= 0x80 ;
1460 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x09 ) ;
1461 j &= 0x5F ;
1462 data |= j ;
1463 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1467 /* --------------------------------------------------------------------- */
1468 /* Function : XGI_SetXG21CRTC */
1469 /* Input : Stand or enhance CRTC table */
1470 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1471 /* Description : Set LCD timing */
1472 /* --------------------------------------------------------------------- */
1473 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1475 UCHAR StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1476 USHORT Temp1, Temp2, Temp3 ;
1478 if ( ModeNo <= 0x13 )
1480 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1481 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1482 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1483 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1484 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1485 Tempcx = Tempax ;
1486 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1487 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1488 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1489 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1490 Tempdx <<= 2 ; /* Tempdx << 2 */
1491 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1492 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1494 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1495 Tempbx = Tempax ; /* Tempbx=Tempax */
1496 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1497 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1498 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1499 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1500 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1501 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1502 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1503 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1505 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] UCHAR -> USHORT */
1506 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1507 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1508 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1509 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1511 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1512 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1513 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1514 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1515 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1516 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1517 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1518 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1519 Tempax = (UCHAR)Temp2 ; /* Tempax[7:0]: VRE[7:0] */
1520 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1521 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1522 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1523 Tempbx = (UCHAR)Temp1 ; /* Tempbx[1:0]: VRS[10:9] */
1524 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1525 Tempax &= 0x7F ;
1526 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1528 else
1530 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1531 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1532 Tempcx = Tempax ; /* Tempcx: HRS */
1533 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1535 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1536 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1537 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1538 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1539 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1541 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1542 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1544 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1545 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1546 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1547 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1549 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1550 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1552 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1553 if( Tempax < Tempcx ) /* HRE < HRS */
1554 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1556 Temp2 &= 0xFF ;
1557 Tempax = (UCHAR)Temp2 ; /* Tempax: HRE[7:0] */
1558 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1559 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1560 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1561 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1562 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1564 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1565 Tempbx = Tempax ; /* Tempbx: VRS */
1566 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1567 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1568 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1569 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1570 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1571 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1572 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1573 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1575 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1576 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1577 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1578 Tempax &= 0x80 ;
1579 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1580 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1581 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1582 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1583 Temp2 = Tempax ;
1584 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1585 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1587 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1588 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1589 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1590 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1591 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1592 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1593 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1594 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1596 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1597 if ( Tempax < Temp3 ) /* VRE < VRS */
1598 Temp2 |= 0x20 ; /* VRE + 0x20 */
1600 Temp2 &= 0xFF ;
1601 Tempax = (UCHAR)Temp2 ; /* Tempax: VRE[7:0] */
1602 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1603 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1604 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1605 Tempbx = (UCHAR)Temp1 ;
1606 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1607 Tempax &= 0x7F ;
1608 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1612 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1614 USHORT StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1616 if ( ModeNo <= 0x13 )
1618 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1619 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1620 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1621 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1622 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1623 Tempcx = Tempax ;
1624 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1625 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1626 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1627 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1628 Tempdx <<= 2 ; /* Tempdx << 2 */
1629 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1630 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1632 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1633 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1634 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1635 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1636 Tempbx = Tempax ; /* Tempbx=CR07 */
1637 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1638 Tempax >>= 2;
1639 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1640 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1641 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1644 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1645 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1646 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1647 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1648 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1649 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1650 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1651 Tempax = (UCHAR)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1652 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1653 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1654 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1655 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1657 else
1659 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1660 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1661 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1662 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1664 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1665 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1666 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1668 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1669 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1670 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1672 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1673 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1674 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1675 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1677 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1678 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1680 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1681 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1682 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1683 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1685 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1686 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1687 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1688 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1689 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1690 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1692 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1693 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1695 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1696 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1697 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1698 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1699 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1700 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1701 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1702 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1703 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1704 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1705 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1708 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1709 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1710 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1711 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1712 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1713 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1714 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1715 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1716 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1718 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1719 Tempbx |= 0x20 ; /* VRE + 0x20 */
1721 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1722 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1723 Tempax = Tempcx >> 8;
1724 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1729 /* --------------------------------------------------------------------- */
1730 /* Function : XGI_SetXG21LCD */
1731 /* Input : */
1732 /* Output : FCLK duty cycle, FCLK delay compensation */
1733 /* Description : All values set zero */
1734 /* --------------------------------------------------------------------- */
1735 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1737 USHORT Data , Temp , b3CC ;
1738 USHORT XGI_P3cc ;
1740 XGI_P3cc = pVBInfo->P3cc ;
1742 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1743 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1744 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1745 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1746 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1748 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1749 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1750 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1751 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1754 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1756 if ( Temp & 0x01 )
1758 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1759 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1762 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1764 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1765 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1767 if ( ModeNo <= 0x13 )
1769 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1770 if ( b3CC & 0x40 )
1771 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1772 if ( b3CC & 0x80 )
1773 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1775 else
1777 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1778 if ( Data & 0x4000 )
1779 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1780 if ( Data & 0x8000 )
1781 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1785 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1787 USHORT Data , Temp , b3CC ;
1788 USHORT XGI_P3cc ;
1790 XGI_P3cc = pVBInfo->P3cc ;
1792 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1793 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1794 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1795 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1797 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1798 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1800 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1801 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1804 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1806 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1807 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1808 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1809 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1812 XGI_SetXG27FPBits(pVBInfo);
1814 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1816 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1817 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1819 if ( ModeNo <= 0x13 )
1821 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1822 if ( b3CC & 0x40 )
1823 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1824 if ( b3CC & 0x80 )
1825 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1827 else
1829 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1830 if ( Data & 0x4000 )
1831 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1832 if ( Data & 0x8000 )
1833 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1837 /* --------------------------------------------------------------------- */
1838 /* Function : XGI_UpdateXG21CRTC */
1839 /* Input : */
1840 /* Output : CRT1 CRTC */
1841 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1842 /* --------------------------------------------------------------------- */
1843 void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT RefreshRateTableIndex )
1845 int i , index = -1;
1847 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1848 if ( ModeNo <= 0x13 )
1850 for( i = 0 ; i < 12 ; i++ )
1852 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1853 index = i ;
1856 else
1858 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1859 index = 12 ;
1860 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1861 index = 13 ;
1862 else if ( ModeNo == 0x2F )
1863 index = 14 ;
1864 else if ( ModeNo == 0x50 )
1865 index = 15 ;
1866 else if ( ModeNo == 0x59 )
1867 index = 16 ;
1870 if( index != -1 )
1872 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1873 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1874 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1875 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1880 /* --------------------------------------------------------------------- */
1881 /* Function : XGI_SetCRT1DE */
1882 /* Input : */
1883 /* Output : */
1884 /* Description : */
1885 /* --------------------------------------------------------------------- */
1886 void XGI_SetCRT1DE( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo,USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1888 USHORT resindex ,
1889 tempax ,
1890 tempbx ,
1891 tempcx ,
1892 temp ,
1893 modeflag ;
1895 UCHAR data ;
1897 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1899 if ( ModeNo <= 0x13 )
1901 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1902 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1903 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1905 else
1907 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1908 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1909 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1912 if ( modeflag & HalfDCLK )
1913 tempax = tempax >> 1 ;
1915 if ( ModeNo > 0x13 )
1917 if ( modeflag & HalfDCLK )
1918 tempax = tempax << 1 ;
1920 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1922 if ( temp & InterlaceMode )
1923 tempbx = tempbx >> 1 ;
1925 if ( modeflag & DoubleScanMode )
1926 tempbx = tempbx << 1 ;
1929 tempcx = 8 ;
1931 /* if ( !( modeflag & Charx8Dot ) ) */
1932 /* tempcx = 9 ; */
1934 tempax /= tempcx ;
1935 tempax -= 1 ;
1936 tempbx -= 1 ;
1937 tempcx = tempax ;
1938 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1939 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1940 data &= 0x7F ;
1941 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
1942 XGINew_SetReg1( pVBInfo->P3d4 , 0x01 , ( USHORT )( tempcx & 0xff ) ) ;
1943 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x0b , ~0x0c , ( USHORT )( ( tempcx & 0x0ff00 ) >> 10 ) ) ;
1944 XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , ( USHORT )( tempbx & 0xff ) ) ;
1945 tempax = 0 ;
1946 tempbx = tempbx >> 8 ;
1948 if ( tempbx & 0x01 )
1949 tempax |= 0x02 ;
1951 if ( tempbx & 0x02 )
1952 tempax |= 0x40 ;
1954 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
1955 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x07 ) ;
1956 data &= 0xFF ;
1957 tempax = 0 ;
1959 if ( tempbx & 0x04 )
1960 tempax |= 0x02 ;
1962 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
1963 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
1967 /* --------------------------------------------------------------------- */
1968 /* Function : XGI_GetResInfo */
1969 /* Input : */
1970 /* Output : */
1971 /* Description : */
1972 /* --------------------------------------------------------------------- */
1973 USHORT XGI_GetResInfo(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
1975 USHORT resindex ;
1977 if ( ModeNo <= 0x13 )
1979 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
1981 else
1983 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
1985 return( resindex ) ;
1989 /* --------------------------------------------------------------------- */
1990 /* Function : XGI_SetCRT1Offset */
1991 /* Input : */
1992 /* Output : */
1993 /* Description : */
1994 /* --------------------------------------------------------------------- */
1995 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
1997 USHORT temp ,
1998 ah ,
1999 al ,
2000 temp2 ,
2002 DisplayUnit ;
2004 /* GetOffset */
2005 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2006 temp = temp >> 8 ;
2007 temp = pVBInfo->ScreenOffset[ temp ] ;
2009 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2010 temp2 &= InterlaceMode ;
2012 if ( temp2 )
2013 temp = temp << 1;
2015 temp2 = pVBInfo->ModeType - ModeEGA ;
2017 switch( temp2 )
2019 case 0:
2020 temp2 = 1 ;
2021 break ;
2022 case 1:
2023 temp2 = 2 ;
2024 break ;
2025 case 2:
2026 temp2 = 4 ;
2027 break ;
2028 case 3:
2029 temp2 = 4 ;
2030 break ;
2031 case 4:
2032 temp2 = 6 ;
2033 break;
2034 case 5:
2035 temp2 = 8 ;
2036 break ;
2037 default:
2038 break ;
2041 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2042 temp = temp * temp2 + temp2 / 2 ;
2043 else
2044 temp *= temp2 ;
2046 /* SetOffset */
2047 DisplayUnit = temp ;
2048 temp2 = temp ;
2049 temp = temp >> 8 ; /* ah */
2050 temp &= 0x0F ;
2051 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2052 i &= 0xF0 ;
2053 i |= temp ;
2054 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2056 temp =( UCHAR )temp2 ;
2057 temp &= 0xFF ; /* al */
2058 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2060 /* SetDisplayUnit */
2061 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2062 temp2 &= InterlaceMode ;
2063 if ( temp2 )
2064 DisplayUnit >>= 1 ;
2066 DisplayUnit = DisplayUnit << 5 ;
2067 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2068 al = DisplayUnit & 0x00ff ;
2069 if ( al == 0 )
2070 ah += 1 ;
2071 else
2072 ah += 2 ;
2074 if ( HwDeviceExtension->jChipType >= XG20 )
2075 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2076 ah -= 1 ;
2078 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2082 /* --------------------------------------------------------------------- */
2083 /* Function : XGI_SetCRT1VCLK */
2084 /* Input : */
2085 /* Output : */
2086 /* Description : */
2087 /* --------------------------------------------------------------------- */
2088 void XGI_SetCRT1VCLK( USHORT ModeNo , USHORT ModeIdIndex ,
2089 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2091 UCHAR index , data ;
2092 USHORT vclkindex ;
2094 if ( pVBInfo->IF_DEF_LVDS == 1 )
2096 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2097 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2098 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2099 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2100 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2101 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2103 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2105 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2106 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2107 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2108 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2109 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2110 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2111 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2112 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2114 else
2116 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2117 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2118 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2119 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2120 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2121 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2124 if ( HwDeviceExtension->jChipType >= XG20 )
2126 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2128 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2129 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2130 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2131 index = data ;
2132 index &= 0xE0 ;
2133 data &= 0x1F ;
2134 data = data << 1 ;
2135 data += 1 ;
2136 data |= index ;
2137 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2143 /* --------------------------------------------------------------------- */
2144 /* Function : XGI_SetCRT1FIFO */
2145 /* Input : */
2146 /* Output : */
2147 /* Description : */
2148 /* --------------------------------------------------------------------- */
2149 void XGI_SetCRT1FIFO( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2151 USHORT data ;
2153 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2154 data &= 0xfe ;
2155 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2157 if ( ModeNo > 0x13 )
2159 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2160 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2161 data &= 0xC0 ;
2162 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2163 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2164 data |= 0x01 ;
2165 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2167 else
2169 if (HwDeviceExtension->jChipType == XG27)
2171 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2172 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2173 data &= 0xC0 ;
2174 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2176 else
2178 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2179 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2180 data &= 0xF0 ;
2181 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2185 if (HwDeviceExtension->jChipType == XG21)
2187 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2192 /* --------------------------------------------------------------------- */
2193 /* Function : XGI_SetCRT1ModeRegs */
2194 /* Input : */
2195 /* Output : */
2196 /* Description : */
2197 /* --------------------------------------------------------------------- */
2198 void XGI_SetCRT1ModeRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension ,
2199 USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2201 USHORT data ,
2202 data2 ,
2203 data3 ,
2204 infoflag = 0 ,
2205 modeflag ,
2206 resindex ,
2207 xres ;
2209 if ( ModeNo > 0x13 )
2211 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2212 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2214 else
2215 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2217 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2218 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2220 if ( ModeNo > 0x13 )
2221 data = infoflag ;
2222 else
2223 data = 0 ;
2225 data2 = 0 ;
2227 if ( ModeNo > 0x13 )
2229 if ( pVBInfo->ModeType > 0x02 )
2231 data2 |= 0x02 ;
2232 data3 = pVBInfo->ModeType - ModeVGA ;
2233 data3 = data3 << 2 ;
2234 data2 |= data3 ;
2238 data &= InterlaceMode ;
2240 if ( data )
2241 data2 |= 0x20 ;
2243 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2244 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2245 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2246 if ( ModeNo <= 0x13 )
2247 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2248 else
2249 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2251 data = 0x0000 ;
2252 if ( infoflag & InterlaceMode )
2254 if ( xres == 1024 )
2255 data = 0x0035 ;
2256 else if ( xres == 1280 )
2257 data = 0x0048 ;
2260 data2 = data & 0x00FF ;
2261 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2262 data2 = ( data & 0xFF00 ) >> 8 ;
2263 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2265 if( modeflag & HalfDCLK )
2266 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2268 data2 = 0 ;
2270 if ( modeflag & LineCompareOff )
2271 data2 |= 0x08 ;
2273 if ( ModeNo > 0x13 )
2275 if ( pVBInfo->ModeType == ModeEGA )
2276 data2 |= 0x40 ;
2279 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2280 data = 0x60 ;
2281 if ( pVBInfo->ModeType != ModeText )
2283 data = data ^ 0x60 ;
2284 if ( pVBInfo->ModeType != ModeEGA )
2286 data = data ^ 0xA0 ;
2289 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2291 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2293 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2294 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2295 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2297 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2299 if (HwDeviceExtension->jChipType == XG27 )
2301 if ( data & 0x40 )
2302 data = 0x2c ;
2303 else
2304 data = 0x6c ;
2305 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2306 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2308 else
2309 if (HwDeviceExtension->jChipType >= XG20 )
2311 if ( data & 0x40 )
2312 data = 0x33 ;
2313 else
2314 data = 0x73 ;
2315 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2316 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2318 else
2320 if ( data & 0x40 )
2321 data = 0x2c ;
2322 else
2323 data = 0x6c ;
2324 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2330 /* --------------------------------------------------------------------- */
2331 /* Function : XGI_SetVCLKState */
2332 /* Input : */
2333 /* Output : */
2334 /* Description : */
2335 /* --------------------------------------------------------------------- */
2336 void XGI_SetVCLKState( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2338 USHORT data ,
2339 data2 = 0 ;
2340 SHORT VCLK ;
2342 UCHAR index ;
2344 if ( ModeNo <= 0x13 )
2345 VCLK = 0 ;
2346 else
2348 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2349 index &= IndexMask ;
2350 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2353 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2354 data &= 0xf3 ;
2355 if ( VCLK >= 200 )
2356 data |= 0x0c ; /* VCLK > 200 */
2358 if ( HwDeviceExtension->jChipType >= XG20 )
2359 data &= ~0x04 ; /* 2 pixel mode */
2361 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2363 if ( HwDeviceExtension->jChipType < XG20 )
2365 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2366 data &= 0xE7 ;
2367 if ( VCLK < 200 )
2368 data |= 0x10 ;
2369 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2372 /* Jong for Adavantech LCD ripple issue
2373 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2374 data2 = 0x03 ;
2375 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2376 data2 = 0x02 ;
2377 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2378 data2 = 0x01 ;
2379 else if ( VCLK > 260 )
2380 data2 = 0x00 ;
2382 data2 = 0x00 ;
2384 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2385 if (HwDeviceExtension->jChipType >= XG27 )
2387 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2394 /* --------------------------------------------------------------------- */
2395 /* Function : XGI_VesaLowResolution */
2396 /* Input : */
2397 /* Output : */
2398 /* Description : */
2399 /* --------------------------------------------------------------------- */
2400 /*void XGI_VesaLowResolution( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo)
2402 USHORT modeflag;
2404 if ( ModeNo > 0x13 )
2405 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2406 else
2407 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2409 if ( ModeNo > 0x13 )
2411 if ( modeflag & DoubleScanMode )
2413 if ( modeflag & HalfDCLK )
2415 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2417 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2419 if ( pVBInfo->VBInfo & SetInSlaveMode )
2421 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2422 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2423 return ;
2427 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2428 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2429 return ;
2433 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2437 /* --------------------------------------------------------------------- */
2438 /* Function : XGI_LoadDAC */
2439 /* Input : */
2440 /* Output : */
2441 /* Description : */
2442 /* --------------------------------------------------------------------- */
2443 void XGI_LoadDAC( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2445 USHORT data , data2 , time ,
2446 i , j , k , m , n , o ,
2447 si , di , bx , dl , al , ah , dh ,
2448 *table = NULL ;
2450 if ( ModeNo <= 0x13 )
2451 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2452 else
2453 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2455 data &= DACInfoFlag ;
2456 time = 64 ;
2458 if ( data == 0x00 )
2459 table = XGINew_MDA_DAC ;
2460 else if ( data == 0x08 )
2461 table = XGINew_CGA_DAC ;
2462 else if ( data == 0x10 )
2463 table = XGINew_EGA_DAC ;
2464 else if ( data == 0x18 )
2466 time = 256 ;
2467 table = XGINew_VGA_DAC ;
2470 if ( time == 256 )
2471 j = 16 ;
2472 else
2473 j = time ;
2475 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2476 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2478 for( i = 0 ; i < j ; i++ )
2480 data = table[ i ] ;
2482 for( k = 0 ; k < 3 ; k++ )
2484 data2 = 0 ;
2486 if ( data & 0x01 )
2487 data2 = 0x2A ;
2489 if ( data & 0x02 )
2490 data2 += 0x15 ;
2492 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2493 data = data >> 2 ;
2497 if ( time == 256 )
2499 for( i = 16 ; i < 32 ; i++ )
2501 data = table[ i ] ;
2503 for( k = 0 ; k < 3 ; k++ )
2504 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2507 si = 32 ;
2509 for( m = 0 ; m < 9 ; m++ )
2511 di = si ;
2512 bx = si + 0x04 ;
2513 dl = 0 ;
2515 for( n = 0 ; n < 3 ; n++ )
2517 for( o = 0 ; o < 5 ; o++ )
2519 dh = table[ si ] ;
2520 ah = table[ di ] ;
2521 al = table[ bx ] ;
2522 si++ ;
2523 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2526 si -= 2 ;
2528 for( o = 0 ; o < 3 ; o++ )
2530 dh = table[ bx ] ;
2531 ah = table[ di ] ;
2532 al = table[ si ] ;
2533 si-- ;
2534 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2537 dl++ ;
2540 si += 5 ;
2546 /* --------------------------------------------------------------------- */
2547 /* Function : XGI_WriteDAC */
2548 /* Input : */
2549 /* Output : */
2550 /* Description : */
2551 /* --------------------------------------------------------------------- */
2552 void XGI_WriteDAC( USHORT dl , USHORT ah , USHORT al , USHORT dh,PVB_DEVICE_INFO pVBInfo )
2554 USHORT temp , bh , bl ;
2556 bh = ah ;
2557 bl = al ;
2559 if ( dl != 0 )
2561 temp = bh ;
2562 bh = dh ;
2563 dh = temp ;
2564 if ( dl == 1 )
2566 temp = bl ;
2567 bl = dh ;
2568 dh = temp ;
2570 else
2572 temp = bl ;
2573 bl = bh ;
2574 bh = temp ;
2577 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )dh ) ;
2578 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bh ) ;
2579 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bl ) ;
2582 /* --------------------------------------------------------------------- */
2583 /* Function : XGI_SetLCDAGroup */
2584 /* Input : */
2585 /* Output : */
2586 /* Description : */
2587 /* --------------------------------------------------------------------- */
2588 void XGI_SetLCDAGroup( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2590 USHORT RefreshRateTableIndex ;
2591 /* USHORT temp ; */
2593 /* pVBInfo->SelectCRT2Rate = 0 ; */
2595 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2596 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2597 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2598 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2599 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2600 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2601 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2605 /* --------------------------------------------------------------------- */
2606 /* Function : XGI_GetLVDSResInfo */
2607 /* Input : */
2608 /* Output : */
2609 /* Description : */
2610 /* --------------------------------------------------------------------- */
2611 void XGI_GetLVDSResInfo( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2613 USHORT resindex , xres , yres , modeflag ;
2615 if ( ModeNo <= 0x13 )
2617 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2619 else
2621 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2625 /* if ( ModeNo > 0x13 ) */
2626 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2627 /* else */
2628 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2630 if ( ModeNo <= 0x13 )
2632 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2634 else
2636 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2639 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2641 if ( ModeNo <= 0x13 )
2643 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2644 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2646 else
2648 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2649 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2651 if ( ModeNo > 0x13 )
2653 if ( modeflag & HalfDCLK )
2654 xres = xres << 1 ;
2656 if ( modeflag & DoubleScanMode )
2657 yres = yres << 1 ;
2659 /* if ( modeflag & Charx8Dot ) */
2660 /* { */
2662 if ( xres == 720 )
2663 xres = 640 ;
2665 /* } */
2666 pVBInfo->VGAHDE = xres ;
2667 pVBInfo->HDE = xres ;
2668 pVBInfo->VGAVDE = yres ;
2669 pVBInfo->VDE = yres ;
2673 /* --------------------------------------------------------------------- */
2674 /* Function : XGI_GetLVDSData */
2675 /* Input : */
2676 /* Output : */
2677 /* Description : */
2678 /* --------------------------------------------------------------------- */
2679 void XGI_GetLVDSData( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2681 USHORT tempbx ;
2682 XGI330_LVDSDataStruct *LCDPtr = NULL ;
2683 XGI330_CHTVDataStruct *TVPtr = NULL ;
2685 tempbx = 2 ;
2687 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2689 LCDPtr = ( XGI330_LVDSDataStruct * )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo) ;
2690 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2691 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2692 pVBInfo->HT = LCDPtr->LCDHT ;
2693 pVBInfo->VT = LCDPtr->LCDVT ;
2695 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2697 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2699 TVPtr = ( XGI330_CHTVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2700 pVBInfo->VGAHT = TVPtr->VGAHT ;
2701 pVBInfo->VGAVT = TVPtr->VGAVT ;
2702 pVBInfo->HT = TVPtr->LCDHT ;
2703 pVBInfo->VT = TVPtr->LCDVT ;
2707 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2709 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2711 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2713 pVBInfo->HDE = 1024 ;
2714 pVBInfo->VDE = 768 ;
2716 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2718 pVBInfo->HDE = 1280 ;
2719 pVBInfo->VDE = 1024 ;
2721 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2723 pVBInfo->HDE = 1400 ;
2724 pVBInfo->VDE = 1050 ;
2726 else
2728 pVBInfo->HDE = 1600 ;
2729 pVBInfo->VDE = 1200 ;
2736 /* --------------------------------------------------------------------- */
2737 /* Function : XGI_ModCRT1Regs */
2738 /* Input : */
2739 /* Output : */
2740 /* Description : */
2741 /* --------------------------------------------------------------------- */
2742 void XGI_ModCRT1Regs( USHORT ModeNo , USHORT ModeIdIndex ,
2743 USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2745 UCHAR index ;
2746 USHORT tempbx , i ;
2747 XGI_LVDSCRT1HDataStruct *LCDPtr = NULL ;
2748 XGI_LVDSCRT1VDataStruct *LCDPtr1 =NULL ;
2749 /* XGI330_CHTVDataStruct *TVPtr = NULL ; */
2750 XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2751 XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2753 if( ModeNo <= 0x13 )
2754 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2755 else
2756 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2758 index= index & IndexMask ;
2760 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2762 tempbx = 0 ;
2764 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2766 LCDPtr = ( XGI_LVDSCRT1HDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2768 for( i = 0 ; i < 8 ; i++ )
2769 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2772 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2774 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2776 CH7007TV_TimingHPtr = ( XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2778 for( i = 0 ; i < 8 ; i++ )
2779 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2783 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2785 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2786 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2787 } */
2789 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2791 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2793 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2794 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2797 tempbx = 1 ;
2799 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2801 LCDPtr1 = ( XGI_LVDSCRT1VDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2802 for( i = 0 ; i < 7 ; i++ )
2803 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2806 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2808 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2810 CH7007TV_TimingVPtr = ( XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2812 for( i = 0 ; i < 7 ; i++ )
2813 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2816 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2818 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2819 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2820 } */
2822 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2824 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2826 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2827 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2828 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2836 /* --------------------------------------------------------------------- */
2837 /* Function : XGI_SetLVDSRegs */
2838 /* Input : */
2839 /* Output : */
2840 /* Description : */
2841 /* --------------------------------------------------------------------- */
2842 void XGI_SetLVDSRegs( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2844 USHORT tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
2845 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2846 XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2847 XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2849 if ( ModeNo > 0x13 )
2850 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2851 else
2852 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2854 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2856 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2858 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2860 tempbx = 8 ;
2861 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2864 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2866 tempbx = 3 ;
2867 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2868 LCDPtr1 = ( XGI330_LCDDataDesStruct2 * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2869 else
2870 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2873 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
2874 push1 = tempbx ;
2875 push2 = tempax ;
2877 /* GetLCDResInfo */
2878 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2880 tempax = 1024 ;
2881 tempbx = 768 ;
2883 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2885 tempax = 1280 ;
2886 tempbx = 1024 ;
2888 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2890 tempax = 1400 ;
2891 tempbx = 1050 ;
2893 else
2895 tempax = 1600 ;
2896 tempbx = 1200 ;
2899 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
2901 pVBInfo->HDE=tempax;
2902 pVBInfo->VDE=tempbx;
2903 pVBInfo->VGAHDE=tempax;
2904 pVBInfo->VGAVDE=tempbx;
2907 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
2909 tempax=pVBInfo->HDE;
2910 tempbx=pVBInfo->VDE;
2913 tempax = pVBInfo->HT ;
2915 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2916 tempbx = LCDPtr1->LCDHDES ;
2917 else
2918 tempbx = LCDPtr->LCDHDES ;
2920 tempcx = pVBInfo->HDE ;
2921 tempbx = tempbx & 0x0fff ;
2922 tempcx += tempbx ;
2924 if ( tempcx >= tempax )
2925 tempcx -= tempax ;
2927 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
2929 tempcx = tempcx >> 3 ;
2930 tempbx = tempbx >> 3 ;
2932 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , ( USHORT )( tempbx & 0xff ) ) ;
2933 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , ( USHORT )( tempcx & 0xff ) ) ;
2935 tempax = pVBInfo->HT ;
2937 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2938 tempbx = LCDPtr1->LCDHRS ;
2939 else
2940 tempbx = LCDPtr->LCDHRS ;
2942 tempcx = push2 ;
2944 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2945 tempcx = LCDPtr1->LCDHSync ;
2947 tempcx += tempbx ;
2949 if ( tempcx >= tempax )
2950 tempcx -= tempax ;
2952 tempax = tempbx & 0x07 ;
2953 tempax = tempax >> 5 ;
2954 tempcx = tempcx >> 3 ;
2955 tempbx = tempbx >> 3 ;
2957 tempcx &= 0x1f ;
2958 tempax |= tempcx ;
2960 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
2961 XGINew_SetReg1( pVBInfo->Part1Port , 0x14 , ( USHORT )( tempbx & 0xff ) ) ;
2963 tempax = pVBInfo->VT ;
2964 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2965 tempbx = LCDPtr1->LCDVDES ;
2966 else
2967 tempbx = LCDPtr->LCDVDES ;
2968 tempcx = pVBInfo->VDE ;
2970 tempbx = tempbx & 0x0fff ;
2971 tempcx += tempbx ;
2972 if ( tempcx >= tempax )
2973 tempcx -= tempax ;
2975 XGINew_SetReg1( pVBInfo->Part1Port , 0x1b , ( USHORT )( tempbx & 0xff ) ) ;
2976 XGINew_SetReg1( pVBInfo->Part1Port , 0x1c , ( USHORT )( tempcx & 0xff ) ) ;
2978 tempbx = ( tempbx >> 8 ) & 0x07 ;
2979 tempcx = ( tempcx >> 8 ) & 0x07 ;
2981 XGINew_SetReg1( pVBInfo->Part1Port , 0x1d , ( USHORT )( ( tempcx << 3 ) | tempbx ) ) ;
2983 tempax = pVBInfo->VT ;
2984 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2985 tempbx = LCDPtr1->LCDVRS ;
2986 else
2987 tempbx = LCDPtr->LCDVRS ;
2989 /* tempbx = tempbx >> 4 ; */
2990 tempcx = push1 ;
2992 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2993 tempcx = LCDPtr1->LCDVSync ;
2995 tempcx += tempbx ;
2996 if ( tempcx >= tempax )
2997 tempcx -= tempax ;
2999 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , ( USHORT )( tempbx & 0xff ) ) ;
3000 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , ~0x0f , ( USHORT )( tempcx & 0x0f ) ) ;
3002 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3004 tempbx = pVBInfo->VGAVDE ;
3005 if ( tempbx != pVBInfo->VDE )
3006 tempax |= 0x40 ;
3008 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3009 tempax |= 0x40 ;
3011 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3013 tempcx = pVBInfo->VGAVT ;
3014 tempbx = pVBInfo->VDE ;
3015 tempax = pVBInfo->VGAVDE ;
3016 tempcx -= tempax ;
3018 temp = tempax ; /* 0430 ylshieh */
3019 temp1 = ( temp << 18 ) / tempbx ;
3021 tempdx = ( USHORT )( ( temp << 18 ) % tempbx ) ;
3023 if ( tempdx != 0 )
3024 temp1 += 1 ;
3026 temp2 = temp1 ;
3027 push3 = temp2 ;
3029 XGINew_SetReg1( pVBInfo->Part1Port , 0x37 , ( USHORT )( temp2 & 0xff ) ) ;
3030 XGINew_SetReg1( pVBInfo->Part1Port , 0x36 , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3032 tempbx = ( USHORT )( temp2 >> 16 ) ;
3033 tempax = tempbx & 0x03 ;
3035 tempbx = pVBInfo->VGAVDE ;
3036 if ( tempbx == pVBInfo->VDE )
3037 tempax |= 0x04 ;
3039 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3041 if ( pVBInfo->VBType & VB_XGI301C )
3043 temp2 = push3 ;
3044 XGINew_SetReg1( pVBInfo->Part4Port , 0x3c , ( USHORT )( temp2 & 0xff ) ) ;
3045 XGINew_SetReg1( pVBInfo->Part4Port , 0x3b , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3046 tempbx = ( USHORT )( temp2 >> 16 ) ;
3047 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x3a , ~0xc0 , ( USHORT )( ( tempbx & 0xff ) << 6 ) ) ;
3049 tempcx = pVBInfo->VGAVDE ;
3050 if ( tempcx == pVBInfo->VDE )
3051 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3052 else
3053 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3056 tempcx = pVBInfo->VGAHDE ;
3057 tempbx = pVBInfo->HDE ;
3059 temp1 = tempcx << 16 ;
3061 tempax = ( USHORT )( temp1 / tempbx ) ;
3063 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3064 tempax = 65535 ;
3066 temp3 = tempax ;
3067 temp1 = pVBInfo->VGAHDE << 16 ;
3069 temp1 /= temp3 ;
3070 temp3 = temp3 << 16 ;
3071 temp1 -= 1 ;
3073 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3075 tempax = ( USHORT )( temp3 & 0xff ) ;
3076 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3078 temp1 = pVBInfo->VGAVDE << 18 ;
3079 temp1 = temp1 / push3 ;
3080 tempbx = ( USHORT )( temp1 & 0xffff ) ;
3082 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3083 tempbx -= 1 ;
3085 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
3086 tempax |= ( USHORT )( ( temp3 >> 8 ) & 0x07 ) ;
3087 XGINew_SetReg1( pVBInfo->Part1Port , 0x20 , ( USHORT )( tempax & 0xff ) ) ;
3088 XGINew_SetReg1( pVBInfo->Part1Port , 0x21 , ( USHORT )( tempbx & 0xff ) ) ;
3090 temp3 = temp3 >> 16 ;
3092 if ( modeflag & HalfDCLK )
3093 temp3 = temp3 >> 1 ;
3095 XGINew_SetReg1(pVBInfo->Part1Port , 0x22 , ( USHORT )( ( temp3 >> 8 ) & 0xff ) ) ;
3096 XGINew_SetReg1(pVBInfo->Part1Port , 0x23 , ( USHORT )( temp3 & 0xff ) ) ;
3102 /* --------------------------------------------------------------------- */
3103 /* Function : XGI_SetCRT2ECLK */
3104 /* Input : */
3105 /* Output : */
3106 /* Description : */
3107 /* --------------------------------------------------------------------- */
3108 void XGI_SetCRT2ECLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
3110 UCHAR di_0 , di_1 , tempal ;
3111 int i ;
3113 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3114 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3115 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3117 for( i = 0 ; i < 4 ; i++ )
3119 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , ~0x30 , ( USHORT )( 0x10 * i ) ) ;
3120 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3122 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3123 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3125 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3127 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3128 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3130 else
3132 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3133 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3139 /* --------------------------------------------------------------------- */
3140 /* Function : XGI_UpdateModeInfo */
3141 /* Input : */
3142 /* Output : */
3143 /* Description : */
3144 /* --------------------------------------------------------------------- */
3145 void XGI_UpdateModeInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
3147 USHORT tempcl ,
3148 tempch ,
3149 temp ,
3150 tempbl ,
3151 tempax ;
3153 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3155 tempcl = 0 ;
3156 tempch = 0 ;
3157 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3159 if ( !( temp & 0x20 ) )
3161 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3162 if ( temp & 0x80 )
3164 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3165 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3166 else
3167 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3169 if ( !( temp & 0x40 ) )
3170 tempcl |= ActiveCRT1 ;
3174 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3175 temp &= 0x0f ;
3177 if ( !( temp == 0x08 ) )
3179 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3180 if ( tempax & 0x04 )
3181 tempcl = tempcl | ActiveLCD ;
3183 temp &= 0x05 ;
3185 if ( !( tempcl & ActiveLCD ) )
3186 if ( temp == 0x01 )
3187 tempcl |= ActiveCRT2 ;
3189 if ( temp == 0x04 )
3190 tempcl |= ActiveLCD ;
3192 if ( temp == 0x05 )
3194 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3196 if( !( temp & 0x08 ) )
3197 tempch |= ActiveAVideo ;
3199 if ( !( temp & 0x04 ) )
3200 tempch |= ActiveSVideo ;
3202 if ( temp & 0x02 )
3203 tempch |= ActiveSCART ;
3205 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3207 if ( temp & 0x01 )
3208 tempch |= ActiveHiTV ;
3211 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3213 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3215 if ( temp & 0x10 )
3216 tempch |= ActiveYPbPr ;
3219 if ( tempch != 0 )
3220 tempcl |= ActiveTV ;
3224 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3225 if ( tempcl & ActiveLCD )
3227 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3229 if ( temp & ActiveTV )
3230 tempcl |= ActiveTV ;
3233 temp = tempcl ;
3234 tempbl = ~ModeSwitchStatus ;
3235 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3237 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3238 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3240 else
3242 return ;
3247 /* --------------------------------------------------------------------- */
3248 /* Function : XGI_GetVGAType */
3249 /* Input : */
3250 /* Output : */
3251 /* Description : */
3252 /* --------------------------------------------------------------------- */
3253 void XGI_GetVGAType( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3256 if ( HwDeviceExtension->jChipType >= XG20 )
3258 pVBInfo->Set_VGAType = XG20;
3260 else if ( HwDeviceExtension->jChipType >= XG40 )
3262 pVBInfo->Set_VGAType = VGA_XGI340 ;
3265 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3269 /* --------------------------------------------------------------------- */
3270 /* Function : XGI_GetVBType */
3271 /* Input : */
3272 /* Output : */
3273 /* Description : */
3274 /* --------------------------------------------------------------------- */
3275 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo)
3277 USHORT flag , tempbx , tempah ;
3279 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3281 pVBInfo->VBType = VB_CH7007 ;
3282 return;
3284 if ( pVBInfo->IF_DEF_LVDS == 0 )
3286 tempbx = VB_XGI302B ;
3287 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3288 if ( flag != 0x02 )
3290 tempbx = VB_XGI301 ;
3291 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3292 if ( flag >= 0xB0 )
3294 tempbx = VB_XGI301B ;
3295 if ( flag >= 0xC0 )
3297 tempbx = VB_XGI301C ;
3298 if ( flag >= 0xD0 )
3300 tempbx = VB_XGI301LV ;
3301 if ( flag >= 0xE0 )
3303 tempbx = VB_XGI302LV ;
3304 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3305 if ( tempah != 0xFF )
3306 tempbx = VB_XGI301C ;
3311 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3313 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3315 if ( !( flag & 0x02 ) )
3316 tempbx = tempbx | VB_NoLCD ;
3320 pVBInfo->VBType = tempbx ;
3323 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3324 pVBInfo->VBType = VB_CH7017 ;
3325 else //LVDS
3326 pVBInfo->VBType = VB_LVDS_NS ;
3332 /* --------------------------------------------------------------------- */
3333 /* Function : XGI_GetVBInfo */
3334 /* Input : */
3335 /* Output : */
3336 /* Description : */
3337 /* --------------------------------------------------------------------- */
3338 void XGI_GetVBInfo( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
3340 USHORT tempax ,
3341 push ,
3342 tempbx ,
3343 temp ,
3344 modeflag ;
3346 if ( ModeNo <= 0x13 )
3348 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3350 else
3352 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3355 pVBInfo->SetFlag = 0 ;
3356 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3357 tempbx = 0 ;
3359 if ( pVBInfo->VBType & 0xFFFF )
3361 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3362 tempbx = tempbx | temp ;
3363 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3364 push = temp ;
3365 push = push << 8 ;
3366 tempax = temp << 8 ;
3367 tempbx = tempbx | tempax ;
3368 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3369 temp = 0xFFFF ^ temp ;
3370 tempbx &= temp ;
3372 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3374 if ( pVBInfo->IF_DEF_LCDA == 1 )
3377 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3379 if ( pVBInfo->IF_DEF_LVDS == 0 )
3381 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3382 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3384 if ( temp & EnableDualEdge )
3386 tempbx |= SetCRT2ToDualEdge ;
3388 if ( temp & SetToLCDA )
3389 tempbx |= SetCRT2ToLCDA ;
3393 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3395 if ( pVBInfo->VBType & VB_CH7017 )
3397 if ( temp & EnableDualEdge )
3399 tempbx |= SetCRT2ToDualEdge ;
3401 if ( temp & SetToLCDA )
3402 tempbx |= SetCRT2ToLCDA ;
3409 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3411 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3412 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3414 if ( temp & SetYPbPr ) /* temp = CR38 */
3416 if ( pVBInfo->IF_DEF_HiVision == 1 )
3418 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3419 temp &= YPbPrMode ;
3420 tempbx |= SetCRT2ToHiVisionTV ;
3422 if ( temp != YPbPrMode1080i ) {
3423 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3424 tempbx |= SetCRT2ToYPbPr ; }
3427 /* tempbx |= SetCRT2ToYPbPr ; */
3432 tempax = push ; /* restore CR31 */
3434 if ( pVBInfo->IF_DEF_LVDS == 0 )
3436 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3438 if ( pVBInfo->IF_DEF_HiVision == 1 )
3439 temp = 0x09FC ;
3440 else
3441 temp = 0x097C ;
3443 else
3445 if ( pVBInfo->IF_DEF_HiVision == 1 )
3446 temp = 0x01FC ;
3447 else
3448 temp = 0x017C ;
3451 else /* 3nd party chip */
3453 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3454 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3455 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3457 temp = SetCRT2ToTV ;
3459 else
3460 temp = SetCRT2ToLCD ;
3463 if ( !( tempbx & temp ) )
3465 tempax |= DisableCRT2Display ;
3466 tempbx = 0 ;
3469 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3471 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3473 if ( tempbx & SetCRT2ToLCDA )
3475 if ( tempbx & SetSimuScanMode )
3476 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3477 else
3478 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3483 /* shampoo add */
3484 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3486 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3488 if ( tempbx & SetCRT2ToRAMDAC )
3490 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3491 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3494 else
3495 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3498 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3500 if ( tempbx & SetCRT2ToLCD )
3502 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3503 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3507 if ( tempbx & SetCRT2ToSCART )
3509 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3510 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3513 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3515 if ( tempbx & SetCRT2ToYPbPr )
3516 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3519 if ( pVBInfo->IF_DEF_HiVision == 1 )
3521 if ( tempbx & SetCRT2ToHiVisionTV )
3522 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3525 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3527 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3528 tempbx = DisableCRT2Display ;
3531 if ( !( tempbx & DisableCRT2Display ) )
3533 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3535 if ( pVBInfo->IF_DEF_LCDA == 1 )
3537 if ( !( tempbx & SetCRT2ToLCDA ) )
3538 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3541 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3543 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3544 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3545 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3546 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3548 if ( ModeNo <= 13 )
3550 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3552 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3553 pVBInfo->SetFlag |= EnableVCMode ;
3560 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3561 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3563 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3564 pVBInfo->SetFlag |= ReserveTVOption ;
3569 pVBInfo->VBInfo = tempbx ;
3573 /* --------------------------------------------------------------------- */
3574 /* Function : XGI_GetTVInfo */
3575 /* Input : */
3576 /* Output : */
3577 /* Description : */
3578 /* --------------------------------------------------------------------- */
3579 void XGI_GetTVInfo( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo )
3581 USHORT temp ,
3582 tempbx = 0 ,
3583 resinfo = 0 ,
3584 modeflag ,
3585 index1 ;
3587 tempbx = 0 ;
3588 resinfo = 0 ;
3590 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3592 if ( ModeNo <= 0x13 )
3594 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3595 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3597 else
3599 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3600 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3603 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3605 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3606 tempbx = temp;
3607 if ( tempbx & SetPALTV )
3609 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3610 if ( tempbx & SetPALMTV )
3611 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3613 else
3614 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3616 if ( pVBInfo->IF_DEF_LVDS == 0 )
3618 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3619 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3620 tempbx |= temp2 ;
3621 if ( temp2 & 0x02 ) //PAL-M
3622 tempbx &= ( ~SetPALTV ) ;
3627 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3629 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3631 if ( tempbx & TVOverScan )
3632 tempbx |= SetCHTVOverScan ;
3635 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3637 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3639 if ( tempbx & TVOverScan )
3641 tempbx |= SetCHTVOverScan ;
3646 if ( pVBInfo->IF_DEF_LVDS == 0 )
3648 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3649 tempbx |= SetPALTV ;
3652 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3654 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3656 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3657 index1 &= YPbPrMode ;
3659 if ( index1 == YPbPrMode525i )
3660 tempbx |= SetYPbPrMode525i ;
3662 if ( index1 == YPbPrMode525p )
3663 tempbx = tempbx | SetYPbPrMode525p;
3664 if ( index1 == YPbPrMode750p)
3665 tempbx = tempbx | SetYPbPrMode750p;
3669 if ( pVBInfo->IF_DEF_HiVision == 1 )
3671 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3673 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3677 if ( pVBInfo->IF_DEF_LVDS == 0 )
3678 { /* shampoo */
3679 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3680 tempbx |= TVSimuMode ;
3682 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3683 tempbx |= NTSC1024x768 ;
3685 tempbx |= RPLLDIV2XO ;
3687 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3689 if ( pVBInfo->VBInfo & SetInSlaveMode )
3690 tempbx &=( ~RPLLDIV2XO ) ;
3692 else
3694 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3695 tempbx &= ( ~RPLLDIV2XO ) ;
3696 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3698 if ( tempbx & TVSimuMode )
3699 tempbx &= ( ~RPLLDIV2XO ) ;
3704 pVBInfo->TVInfo = tempbx ;
3708 /* --------------------------------------------------------------------- */
3709 /* Function : XGI_GetLCDInfo */
3710 /* Input : */
3711 /* Output : */
3712 /* Description : */
3713 /* --------------------------------------------------------------------- */
3714 BOOLEAN XGI_GetLCDInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
3716 USHORT temp ,
3717 tempax ,
3718 tempbx ,
3719 modeflag ,
3720 resinfo = 0 ,
3721 LCDIdIndex ;
3723 pVBInfo->LCDResInfo = 0 ;
3724 pVBInfo->LCDTypeInfo = 0 ;
3725 pVBInfo->LCDInfo = 0 ;
3727 if ( ModeNo <= 0x13 )
3729 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3731 else
3733 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3734 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3737 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3738 tempbx = temp & 0x0F ;
3740 if ( tempbx == 0 )
3741 tempbx = Panel1024x768 ; /* default */
3743 /* LCD75 [2003/8/22] Vicent */
3744 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3746 if ( pVBInfo->VBInfo & DriverMode )
3748 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3749 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3750 tempax &= 0x0F ;
3751 else
3752 tempax = tempax >> 4 ;
3754 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3756 if ( tempax >= 3 )
3757 tempbx |= PanelRef75Hz ;
3759 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3761 if ( tempax >= 4 )
3762 tempbx |= PanelRef75Hz ;
3767 pVBInfo->LCDResInfo = tempbx ;
3769 /* End of LCD75 */
3771 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3773 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3776 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3778 return 0;
3781 tempbx = 0 ;
3783 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3785 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3787 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3788 temp &= ~EnableScalingLCD ;
3790 tempbx |= temp ;
3792 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3794 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3796 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3798 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3800 tempbx |= SetLCDDualLink ;
3804 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3806 if ( tempax & LCDDualLink )
3808 tempbx |= SetLCDDualLink ;
3812 if ( pVBInfo->IF_DEF_LVDS == 0 )
3814 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3815 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3819 if ( tempax & LCDBToA )
3821 tempbx |= SetLCDBToA ;
3825 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3827 if ( modeflag & HalfDCLK )
3829 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3830 if ( !( tempbx & SetLCDtoNonExpanding ) )
3832 tempbx |= EnableLVDSDDA ;
3834 else
3836 if ( ModeNo > 0x13 )
3838 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3840 if ( resinfo == 4 )
3841 { /* 512x384 */
3842 tempbx |= EnableLVDSDDA ;
3850 if ( pVBInfo->VBInfo & SetInSlaveMode )
3852 if ( pVBInfo->VBInfo & SetNotSimuMode )
3854 tempbx |= LCDVESATiming ;
3857 else
3859 tempbx |= LCDVESATiming ;
3862 pVBInfo->LCDInfo = tempbx ;
3864 if ( pVBInfo->IF_DEF_PWD == 1 )
3866 if ( pVBInfo->LCDInfo & SetPWDEnable )
3868 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3870 if ( !( tempax & PWDEnable ) )
3872 pVBInfo->LCDInfo &= ~SetPWDEnable ;
3878 if ( pVBInfo->IF_DEF_LVDS == 0 )
3880 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3882 if ( pVBInfo->VBInfo & SetInSlaveMode )
3884 if ( !( tempax & LockLCDBToA ) )
3886 if ( ModeNo <= 0x13 )
3888 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
3889 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
3897 if ( pVBInfo->IF_DEF_LVDS == 0 )
3899 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3901 if ( pVBInfo->VBInfo & SetInSlaveMode )
3903 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
3905 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3906 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3913 return( 1 ) ;
3917 /* --------------------------------------------------------------------- */
3918 /* Function : XGI_SearchModeID */
3919 /* Input : */
3920 /* Output : */
3921 /* Description : */
3922 /* --------------------------------------------------------------------- */
3923 BOOLEAN XGI_SearchModeID( USHORT ModeNo , USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
3928 #ifdef LINUX /* chiawen for linux solution */
3930 if ( ModeNo <= 5 )
3931 ModeNo |= 1 ;
3932 if ( ModeNo <= 0x13 )
3934 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
3935 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
3937 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3938 break;
3939 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3940 return 0;
3943 if ( ModeNo == 0x07 )
3944 ( *ModeIdIndex )++ ; /* 400 lines */
3946 if ( ModeNo <= 3 )
3947 ( *ModeIdIndex ) += 2 ; /* 400 lines */
3948 /* else 350 lines */
3950 else
3952 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
3953 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
3955 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3956 break;
3957 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3958 return 0;
3962 #endif
3964 return 1;
3970 /* win2000 MM adapter not support standard mode! */
3972 /* --------------------------------------------------------------------- */
3973 /* Function : */
3974 /* Input : */
3975 /* Output : */
3976 /* Description : */
3977 /* --------------------------------------------------------------------- */
3978 BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
3980 USHORT memorysize ,
3981 modeflag ,
3982 temp ,
3983 temp1 ,
3984 tmp ;
3986 /* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
3987 ( HwDeviceExtension->jChipType == XGI_650M ) )
3989 return 1;
3990 } */
3992 if ( ModeNo <= 0x13 )
3994 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3996 else {
3997 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4000 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4002 memorysize = modeflag & MemoryInfoFlag ;
4003 memorysize = memorysize > MemorySizeShift ;
4004 memorysize++ ; /* Get memory size */
4006 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4007 tmp = temp ;
4009 if ( HwDeviceExtension->jChipType == XG40 )
4011 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4012 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4014 temp <<= 2 ;
4016 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4018 temp <<= 1 ;
4021 else if ( HwDeviceExtension->jChipType == XG42 )
4023 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4024 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4026 temp <<= 1 ;
4029 else if ( HwDeviceExtension->jChipType == XG45 )
4031 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4032 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4034 temp <<= 2 ;
4036 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4038 temp1 = temp ;
4039 temp <<= 1 ;
4040 temp += temp1 ;
4042 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4044 temp <<= 1 ;
4047 if (temp < memorysize)
4048 return 0;
4049 else
4050 return 1;
4054 /* --------------------------------------------------------------------- */
4055 /* Function : XGINew_IsLowResolution */
4056 /* Input : */
4057 /* Output : */
4058 /* Description : */
4059 /* --------------------------------------------------------------------- */
4060 /*void XGINew_IsLowResolution( USHORT ModeNo , USHORT ModeIdIndex, BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4062 USHORT data ;
4063 USHORT ModeFlag ;
4065 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4066 data &= 0x7F ;
4067 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4069 if ( ModeNo > 0x13 )
4071 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4072 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4074 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4075 data |= 0x80 ;
4076 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4077 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4078 data &= 0xF7 ;
4079 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4086 /* --------------------------------------------------------------------- */
4087 /* Function : XGI_DisplayOn */
4088 /* Input : */
4089 /* Output : */
4090 /* Description : */
4091 /* --------------------------------------------------------------------- */
4092 void XGI_DisplayOn( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4095 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4096 if ( pXGIHWDE->jChipType == XG21 )
4098 if ( pVBInfo->IF_DEF_LVDS == 1 )
4100 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4102 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4103 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4105 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4107 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4109 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4110 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4112 else
4114 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4119 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4125 if ( pXGIHWDE->jChipType == XG27 )
4127 if ( pVBInfo->IF_DEF_LVDS == 1 )
4129 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4131 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4132 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4134 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4136 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4138 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4139 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4141 else
4143 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4150 /* --------------------------------------------------------------------- */
4151 /* Function : XGI_DisplayOff */
4152 /* Input : */
4153 /* Output : */
4154 /* Description : */
4155 /* --------------------------------------------------------------------- */
4156 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4159 if ( pXGIHWDE->jChipType == XG21 )
4161 if ( pVBInfo->IF_DEF_LVDS == 1 )
4163 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4164 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4166 else
4168 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4172 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4174 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4180 if ( pXGIHWDE->jChipType == XG27 )
4182 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4184 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4185 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4188 if ( pVBInfo->IF_DEF_LVDS == 0 )
4190 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4194 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4198 /* --------------------------------------------------------------------- */
4199 /* Function : XGI_WaitDisply */
4200 /* Input : */
4201 /* Output : */
4202 /* Description : chiawen for sensecrt1 */
4203 /* --------------------------------------------------------------------- */
4204 void XGI_WaitDisply( PVB_DEVICE_INFO pVBInfo )
4206 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4207 break ;
4209 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4210 break ;
4213 /* --------------------------------------------------------------------- */
4214 /* Function : XGI_SenseCRT1 */
4215 /* Input : */
4216 /* Output : */
4217 /* Description : */
4218 /* --------------------------------------------------------------------- */
4220 void XGI_SenseCRT1( PVB_DEVICE_INFO pVBInfo )
4222 UCHAR CRTCData[ 17 ] = { 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4223 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4224 0x04 , 0x00 , 0x00 , 0x05 , 0x00 } ;
4226 UCHAR SR01 = 0 , SR1F = 0 , SR07 = 0 , SR06 = 0 ;
4228 UCHAR CR17 , CR63 , SR31 ;
4229 USHORT temp ;
4230 UCHAR DAC_TEST_PARMS[ 3 ] = { 0x0F , 0x0F , 0x0F } ;
4232 int i ;
4233 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4235 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4236 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4237 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) | 0x02 ) ) ;
4239 SR31 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) ;
4240 CR63 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
4241 SR01 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4243 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , ( UCHAR )( SR01 & 0xDF ) ) ;
4244 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , ( UCHAR )( CR63 & 0xBF ) ) ;
4246 CR17 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
4247 XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , ( UCHAR )( CR17 | 0x80 ) ) ;
4249 SR1F = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
4250 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR )( SR1F | 0x04 ) ) ;
4252 SR07 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x07 ) ;
4253 XGINew_SetReg1( pVBInfo->P3c4 , 0x07 , ( UCHAR )( SR07 & 0xFB ) ) ;
4254 SR06 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x06 ) ;
4255 XGINew_SetReg1( pVBInfo->P3c4 , 0x06 , ( UCHAR )( SR06 & 0xC3 ) ) ;
4257 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4259 for( i = 0 ; i < 8 ; i++ )
4260 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )i , CRTCData[ i ] ) ;
4262 for( i = 8 ; i < 11 ; i++ )
4263 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 8 ) , CRTCData[ i ] ) ;
4265 for( i = 11 ; i < 13 ; i++ )
4266 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 4 ) , CRTCData[ i ] ) ;
4268 for( i = 13 ; i < 16 ; i++ )
4269 XGINew_SetReg1( pVBInfo->P3c4 , ( USHORT )( i - 3 ) , CRTCData[ i ] ) ;
4271 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , ( UCHAR )( CRTCData[ 16 ] & 0xE0 ) ) ;
4273 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4274 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4275 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4277 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4279 for( i = 0 ; i < 256 ; i++ )
4281 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 0 ] ) ;
4282 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 1 ] ) ;
4283 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 2 ] ) ;
4286 XGI_VBLongWait( pVBInfo ) ;
4287 XGI_VBLongWait( pVBInfo ) ;
4288 XGI_VBLongWait( pVBInfo ) ;
4290 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4292 XGI_WaitDisply( pVBInfo ) ;
4293 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4295 if( temp & 0x10 )
4297 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4299 else
4301 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4304 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4305 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4307 for( i = 0 ; i < 256 ; i++ )
4309 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4310 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4311 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4314 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4315 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4316 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4318 /* [2004/05/11] Vicent */
4319 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) & 0xFD ) ) ;
4320 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR ) SR1F ) ;
4332 /* --------------------------------------------------------------------- */
4333 /* Function : XGI_WaitDisplay */
4334 /* Input : */
4335 /* Output : */
4336 /* Description : */
4337 /* --------------------------------------------------------------------- */
4338 void XGI_WaitDisplay( PVB_DEVICE_INFO pVBInfo )
4340 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4342 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4348 /* --------------------------------------------------------------------- */
4349 /* Function : XGI_SetCRT2Group301 */
4350 /* Input : */
4351 /* Output : */
4352 /* Description : */
4353 /* --------------------------------------------------------------------- */
4354 BOOLEAN XGI_SetCRT2Group301( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
4356 USHORT tempbx ,
4357 ModeIdIndex ,
4358 RefreshRateTableIndex ;
4360 tempbx=pVBInfo->VBInfo ;
4361 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4362 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4363 pVBInfo->SelectCRT2Rate = 4 ;
4364 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4365 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4366 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4367 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4368 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4369 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4370 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4371 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4372 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4373 XGI_SetTap4Regs(pVBInfo) ;
4374 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4375 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4376 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4377 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4378 XGI_AutoThreshold( pVBInfo) ;
4379 return 1 ;
4383 /* --------------------------------------------------------------------- */
4384 /* Function : XGI_AutoThreshold */
4385 /* Input : */
4386 /* Output : */
4387 /* Description : */
4388 /* --------------------------------------------------------------------- */
4389 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo )
4391 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4392 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4396 /* --------------------------------------------------------------------- */
4397 /* Function : XGI_SaveCRT2Info */
4398 /* Input : */
4399 /* Output : */
4400 /* Description : */
4401 /* --------------------------------------------------------------------- */
4402 void XGI_SaveCRT2Info( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo)
4404 USHORT temp1 ,
4405 temp2 ;
4407 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4408 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4409 temp2 = ~( SetInSlaveMode >> 8 ) ;
4410 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4414 /* --------------------------------------------------------------------- */
4415 /* Function : XGI_GetCRT2ResInfo */
4416 /* Input : */
4417 /* Output : */
4418 /* Description : */
4419 /* --------------------------------------------------------------------- */
4420 void XGI_GetCRT2ResInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
4422 USHORT xres ,
4423 yres ,
4424 modeflag ,
4425 resindex ;
4427 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4428 if ( ModeNo <= 0x13 )
4430 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4431 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4432 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4434 else
4436 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4437 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4438 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4440 /* if ( pVBInfo->IF_DEF_FSTN )
4442 xres *= 2 ;
4443 yres *= 2 ;
4445 else
4448 if ( modeflag & HalfDCLK )
4449 xres *= 2;
4451 if ( modeflag & DoubleScanMode )
4452 yres *= 2 ;
4453 /* } */
4456 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4458 if ( pVBInfo->IF_DEF_LVDS == 0 )
4460 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4462 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4464 if ( yres == 1024 )
4465 yres = 1056 ;
4469 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4471 if ( yres == 400 )
4472 yres = 405 ;
4473 else if ( yres == 350 )
4474 yres = 360 ;
4476 if ( pVBInfo->LCDInfo & LCDVESATiming )
4478 if ( yres == 360 )
4479 yres = 375 ;
4483 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4485 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4487 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4489 if ( yres == 350 )
4490 yres = 357 ;
4491 else if ( yres == 400 )
4492 yres = 420 ;
4493 else if ( yres == 480 )
4494 yres = 525 ;
4500 if ( xres == 720 )
4501 xres = 640 ;
4504 pVBInfo->VGAHDE = xres ;
4505 pVBInfo->HDE = xres ;
4506 pVBInfo->VGAVDE = yres ;
4507 pVBInfo->VDE = yres ;
4511 /* --------------------------------------------------------------------- */
4512 /* Function : XGI_IsLCDDualLink */
4513 /* Input : */
4514 /* Output : */
4515 /* Description : */
4516 /* --------------------------------------------------------------------- */
4517 BOOLEAN XGI_IsLCDDualLink( PVB_DEVICE_INFO pVBInfo )
4520 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4521 return ( 1 ) ;
4523 return( 0 ) ;
4527 /* --------------------------------------------------------------------- */
4528 /* Function : XGI_GetCRT2Data */
4529 /* Input : */
4530 /* Output : */
4531 /* Description : */
4532 /* --------------------------------------------------------------------- */
4533 void XGI_GetCRT2Data( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4535 USHORT tempax = 0,
4536 tempbx ,
4537 modeflag ,
4538 resinfo ;
4540 XGI_LCDDataStruct *LCDPtr = NULL ;
4541 XGI_TVDataStruct *TVPtr = NULL ;
4543 if ( ModeNo <= 0x13 )
4545 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4546 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4548 else
4550 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4551 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4554 pVBInfo->NewFlickerMode = 0 ;
4555 pVBInfo->RVBHRS = 50 ;
4557 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4559 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4560 return ;
4563 tempbx = 4 ;
4565 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4567 LCDPtr = (XGI_LCDDataStruct* )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4569 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4570 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4571 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4572 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4573 pVBInfo->HT = LCDPtr->LCDHT ;
4574 pVBInfo->VT = LCDPtr->LCDVT ;
4576 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4578 tempax = 1024 ;
4579 tempbx = 768 ;
4581 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4583 if ( pVBInfo->VGAVDE == 357 )
4584 tempbx = 527 ;
4585 else if ( pVBInfo->VGAVDE == 420 )
4586 tempbx = 620 ;
4587 else if ( pVBInfo->VGAVDE == 525 )
4588 tempbx = 775 ;
4589 else if ( pVBInfo->VGAVDE == 600 )
4590 tempbx = 775 ;
4591 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4592 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4593 else
4594 tempbx = 768 ;
4596 else
4597 tempbx = 768 ;
4599 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4601 tempax = 1024 ;
4602 tempbx = 768 ;
4604 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4606 tempax = 1280 ;
4607 if ( pVBInfo->VGAVDE == 360 )
4608 tempbx = 768 ;
4609 else if ( pVBInfo->VGAVDE == 375 )
4610 tempbx = 800 ;
4611 else if ( pVBInfo->VGAVDE == 405 )
4612 tempbx = 864 ;
4613 else
4614 tempbx = 1024 ;
4616 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4618 tempax = 1280 ;
4619 tempbx = 1024 ;
4621 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4623 tempax = 1280 ;
4624 if ( pVBInfo->VGAVDE == 350 )
4625 tempbx = 700 ;
4626 else if ( pVBInfo->VGAVDE == 400 )
4627 tempbx = 800 ;
4628 else if ( pVBInfo->VGAVDE == 1024 )
4629 tempbx = 960 ;
4630 else
4631 tempbx = 960 ;
4633 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4635 tempax = 1400 ;
4636 tempbx = 1050 ;
4638 if ( pVBInfo->VGAVDE == 1024 )
4640 tempax = 1280 ;
4641 tempbx = 1024 ;
4644 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4646 tempax = 1600 ;
4647 tempbx = 1200 ; /* alan 10/14/2003 */
4648 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4650 if ( pVBInfo->VGAVDE == 350 )
4651 tempbx = 875 ;
4652 else if ( pVBInfo->VGAVDE == 400 )
4653 tempbx = 1000 ;
4657 if ( pVBInfo->LCDInfo & LCDNonExpanding )
4659 tempax = pVBInfo->VGAHDE ;
4660 tempbx = pVBInfo->VGAVDE ;
4663 pVBInfo->HDE = tempax ;
4664 pVBInfo->VDE = tempbx ;
4665 return ;
4668 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
4670 tempbx = 4 ;
4671 TVPtr = ( XGI_TVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4673 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
4674 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
4675 pVBInfo->VGAHT = TVPtr->VGAHT ;
4676 pVBInfo->VGAVT = TVPtr->VGAVT ;
4677 pVBInfo->HDE = TVPtr->TVHDE ;
4678 pVBInfo->VDE = TVPtr->TVVDE ;
4679 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
4680 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
4682 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
4684 if ( resinfo == 0x08 )
4685 pVBInfo->NewFlickerMode = 0x40 ;
4686 else if ( resinfo == 0x09 )
4687 pVBInfo->NewFlickerMode = 0x40 ;
4688 else if ( resinfo == 0x12 )
4689 pVBInfo->NewFlickerMode = 0x40 ;
4691 if ( pVBInfo->VGAVDE == 350 )
4692 pVBInfo->TVInfo |= TVSimuMode ;
4694 tempax = ExtHiTVHT ;
4695 tempbx = ExtHiTVVT ;
4697 if ( pVBInfo->VBInfo & SetInSlaveMode )
4699 if ( pVBInfo->TVInfo & TVSimuMode )
4701 tempax = StHiTVHT ;
4702 tempbx = StHiTVVT ;
4704 if ( !( modeflag & Charx8Dot ) )
4706 tempax = StHiTextTVHT ;
4707 tempbx = StHiTextTVVT ;
4712 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
4714 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4716 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
4717 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
4720 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4722 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
4723 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
4725 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
4727 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
4728 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
4729 if ( pVBInfo->TVInfo & NTSC1024x768 )
4730 tempax = NTSC1024x768HT ;
4733 else
4735 tempax = PALHT ;
4736 tempbx = PALVT ;
4737 if ( !( pVBInfo->TVInfo & SetPALTV ) )
4739 tempax = NTSCHT ;
4740 tempbx = NTSCVT ;
4741 if ( pVBInfo->TVInfo & NTSC1024x768 )
4742 tempax = NTSC1024x768HT ;
4746 pVBInfo->HT = tempax ;
4747 pVBInfo->VT = tempbx ;
4748 return ;
4753 /* --------------------------------------------------------------------- */
4754 /* Function : XGI_SetCRT2VCLK */
4755 /* Input : */
4756 /* Output : */
4757 /* Description : */
4758 /* --------------------------------------------------------------------- */
4759 void XGI_SetCRT2VCLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4761 UCHAR di_0 ,
4762 di_1 ,
4763 tempal ;
4765 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
4766 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
4767 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
4769 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
4770 { /* 301 */
4771 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
4772 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
4773 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
4775 else
4776 { /* 301b/302b/301lv/302lv */
4777 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
4778 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
4781 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
4783 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4784 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
4785 else
4786 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
4790 /* --------------------------------------------------------------------- */
4791 /* Function : XGI_GETLCDVCLKPtr */
4792 /* Input : */
4793 /* Output : al -> VCLK Index */
4794 /* Description : */
4795 /* --------------------------------------------------------------------- */
4796 void XGI_GetLCDVCLKPtr( UCHAR* di_0 , UCHAR *di_1, PVB_DEVICE_INFO pVBInfo )
4798 USHORT index ;
4800 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4802 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
4804 if ( pVBInfo->LCDInfo & EnableScalingLCD )
4805 return ;
4808 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
4809 index = XGI_GetLCDCapPtr1( pVBInfo) ;
4811 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4812 { /* LCDB */
4813 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
4814 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
4816 else
4817 { /* LCDA */
4818 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
4819 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
4822 return ;
4826 /* --------------------------------------------------------------------- */
4827 /* Function : XGI_GetVCLKPtr */
4828 /* Input : */
4829 /* Output : */
4830 /* Description : */
4831 /* --------------------------------------------------------------------- */
4832 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
4835 USHORT index ,
4836 modeflag ;
4837 USHORT tempbx ;
4838 UCHAR tempal ;
4839 UCHAR *CHTVVCLKPtr = NULL ;
4841 if ( ModeNo <= 0x13 )
4842 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4843 else
4844 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4847 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
4848 { /* {LCDA/LCDB} */
4849 index = XGI_GetLCDCapPtr(pVBInfo) ;
4850 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
4852 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4853 return tempal ;
4855 /* {TV} */
4856 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
4858 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
4860 tempal = HiTVVCLKDIV2;
4861 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
4862 tempal = HiTVVCLK;
4863 if(pVBInfo->TVInfo & TVSimuMode)
4865 tempal = HiTVSimuVCLK;
4866 if(!(modeflag & Charx8Dot))
4867 tempal = HiTVTextVCLK;
4870 return tempal;
4873 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4875 tempal = YPbPr750pVCLK ;
4876 return tempal ;
4879 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4881 tempal = YPbPr525pVCLK ;
4882 return tempal ;
4885 tempal = NTSC1024VCLK ;
4887 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
4889 tempal = TVVCLKDIV2 ;
4890 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
4891 tempal = TVVCLK ;
4894 if ( pVBInfo->VBInfo & SetCRT2ToTV )
4895 return tempal ;
4897 /*else
4898 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
4900 if(ModeNo<=0x13)
4901 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4902 else
4903 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4904 *tempal = *tempal & 0x1F;
4906 tempbx = 0;
4907 if(pVBInfo->TVInfo & SetPALTV)
4908 tempbx = tempbx + 2;
4909 if(pVBInfo->TVInfo & SetCHTVOverScan)
4910 tempbx++;
4911 tempbx = tempbx << 1;
4912 } */
4913 } /* {End of VB} */
4915 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
4917 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4918 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
4920 if( ModeNo <= 0x13 )
4922 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
4924 else
4926 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4929 tempal = tempal & 0x0F;
4930 tempbx = 0;
4932 if(pVBInfo->TVInfo & SetPALTV)
4934 tempbx = tempbx + 2;
4936 if(pVBInfo->TVInfo & SetCHTVOverScan)
4938 tempbx++;
4940 /** tempbx = tempbx << 1; CH7007 ? **/
4942 /*[Billy]07/05/29 CH7007*/
4943 if ( pVBInfo->IF_DEF_CH7007 == 1 )
4945 switch( tempbx )
4947 case 0:
4948 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
4949 break ;
4950 case 1:
4951 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
4952 break ;
4953 case 2:
4954 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
4955 break ;
4956 case 3:
4957 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
4958 break ;
4959 default:
4960 break ;
4964 /*else
4966 switch( tempbx )
4968 case 0:
4969 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
4970 break ;
4971 case 1:
4972 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
4973 break ;
4974 case 2:
4975 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
4976 break ;
4977 case 3:
4978 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
4979 break ;
4980 default:
4981 break ;
4985 tempal = CHTVVCLKPtr[ tempal ] ;
4986 return tempal ;
4991 tempal = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ;
4992 tempal = tempal >> 2 ;
4993 tempal &= 0x03 ;
4995 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
4996 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
4998 if ( ModeNo <= 0x13 )
4999 return tempal ;
5001 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5002 return tempal ;
5006 /* --------------------------------------------------------------------- */
5007 /* Function : XGI_GetVCLKLen */
5008 /* Input : */
5009 /* Output : */
5010 /* Description : */
5011 /* --------------------------------------------------------------------- */
5012 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo)
5014 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5016 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5017 *di_0 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2B ;
5018 *di_1 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2C ;
5020 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5022 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5024 *di_0 = ( UCHAR )XGI_VBVCLKData[ tempal ].SR2B ;
5025 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5028 else
5030 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5031 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5036 /* --------------------------------------------------------------------- */
5037 /* Function : XGI_SetCRT2Offset */
5038 /* Input : */
5039 /* Output : */
5040 /* Description : */
5041 /* --------------------------------------------------------------------- */
5042 void XGI_SetCRT2Offset( USHORT ModeNo ,
5043 USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5045 USHORT offset ;
5046 UCHAR temp ;
5048 if ( pVBInfo->VBInfo & SetInSlaveMode )
5050 return ;
5053 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5054 temp = ( UCHAR )( offset & 0xFF ) ;
5055 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5056 temp =( UCHAR)( ( offset & 0xFF00 ) >> 8 ) ;
5057 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , temp ) ;
5058 temp =( UCHAR )( ( ( offset >> 3 ) & 0xFF ) + 1 ) ;
5059 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5063 /* --------------------------------------------------------------------- */
5064 /* Function : XGI_GetOffset */
5065 /* Input : */
5066 /* Output : */
5067 /* Description : */
5068 /* --------------------------------------------------------------------- */
5069 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
5071 USHORT temp ,
5072 colordepth ,
5073 modeinfo ,
5074 index ,
5075 infoflag ,
5076 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5078 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5079 if ( ModeNo <= 0x14 )
5080 infoflag = 0 ;
5081 else
5082 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5085 index = ( modeinfo >> 8 ) & 0xFF ;
5087 temp = pVBInfo->ScreenOffset[ index ] ;
5089 if ( infoflag & InterlaceMode )
5091 temp = temp << 1 ;
5094 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5096 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5098 temp = ModeNo - 0x7C ;
5099 colordepth = ColorDepth[ temp ] ;
5100 temp = 0x6B ;
5101 if ( infoflag & InterlaceMode )
5103 temp = temp << 1 ;
5105 return( temp * colordepth ) ;
5107 else
5108 return( temp * colordepth ) ;
5112 /* --------------------------------------------------------------------- */
5113 /* Function : XGI_SetCRT2FIFO */
5114 /* Input : */
5115 /* Output : */
5116 /* Description : */
5117 /* --------------------------------------------------------------------- */
5118 void XGI_SetCRT2FIFO( PVB_DEVICE_INFO pVBInfo)
5120 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5121 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5125 /* --------------------------------------------------------------------- */
5126 /* Function : XGI_PreSetGroup1 */
5127 /* Input : */
5128 /* Output : */
5129 /* Description : */
5130 /* --------------------------------------------------------------------- */
5131 void XGI_PreSetGroup1(USHORT ModeNo , USHORT ModeIdIndex ,PXGI_HW_DEVICE_INFO HwDeviceExtension,
5132 USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5134 USHORT tempcx = 0 ,
5135 CRT1Index = 0 ,
5136 resinfo = 0 ;
5138 if ( ModeNo > 0x13 )
5140 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5141 CRT1Index &= IndexMask ;
5142 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5145 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5146 XGI_SetCRT2FIFO(pVBInfo) ;
5147 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5149 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5151 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5154 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5155 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5159 /* --------------------------------------------------------------------- */
5160 /* Function : XGI_SetGroup1 */
5161 /* Input : */
5162 /* Output : */
5163 /* Description : */
5164 /* --------------------------------------------------------------------- */
5165 void XGI_SetGroup1( USHORT ModeNo , USHORT ModeIdIndex ,
5166 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5168 USHORT temp = 0 ,
5169 tempax = 0 ,
5170 tempbx = 0 ,
5171 tempcx = 0 ,
5172 pushbx = 0 ,
5173 CRT1Index = 0 ,
5174 modeflag ,
5175 resinfo = 0 ;
5177 if ( ModeNo > 0x13 )
5179 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5180 CRT1Index &= IndexMask ;
5181 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5184 if ( ModeNo <= 0x13 )
5186 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5188 else
5190 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5193 /* bainy change table name */
5194 if ( modeflag & HalfDCLK )
5196 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5197 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5198 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5199 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5200 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5201 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5202 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5203 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5204 tempcx = tempcx >> 1 ;
5205 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5206 tempcx += tempbx ;
5208 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5210 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5211 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5212 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5213 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5214 tempcx &= 0x1F ;
5215 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5216 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5217 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5220 tempbx += 4 ;
5221 tempcx += 4 ;
5223 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5224 tempcx = pVBInfo->VGAHT / 2 ;
5226 temp = tempbx & 0x00FF ;
5228 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5230 else
5232 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5233 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5234 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5235 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5236 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5237 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5238 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5239 pushbx = pVBInfo->VGAHDE + 16 ;
5240 tempcx = tempcx >> 1 ;
5241 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5242 tempcx += tempbx ;
5244 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5246 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5247 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5248 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5249 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5250 tempcx &= 0x1F ;
5251 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5252 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5253 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5254 tempbx += 16 ;
5255 tempcx += 16 ;
5258 if ( tempcx > pVBInfo->VGAHT )
5259 tempcx = pVBInfo->VGAHT ;
5261 temp = tempbx & 0x00FF ;
5262 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5265 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5266 tempbx = pushbx ;
5267 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5268 tempax |= ( tempbx & 0xFF00 ) ;
5269 temp = ( tempax & 0xFF00 ) >> 8 ;
5270 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5271 temp = tempcx & 0x00FF ;
5272 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5273 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5274 temp = tempcx & 0x00FF ;
5276 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5278 if ( pVBInfo->VBInfo & 0x0C )
5280 temp-- ;
5284 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5285 tempbx = pVBInfo->VGAVDE - 1 ;
5286 temp = tempbx & 0x00FF ;
5287 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5288 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5289 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5290 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5292 tempax = pVBInfo->VGAVDE ;
5293 tempbx = pVBInfo->VGAVDE ;
5294 tempcx = pVBInfo->VGAVT ;
5295 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5296 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5298 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5300 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5301 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5303 if ( temp & 0x04 )
5304 tempbx |= 0x0100 ;
5306 if ( temp & 0x080 )
5307 tempbx |= 0x0200 ;
5309 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5311 if ( temp & 0x08 )
5312 tempbx |= 0x0400 ;
5314 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5315 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5318 temp = tempbx & 0x00FF ;
5319 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5320 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5321 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5322 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5323 tempax = 0 ;
5325 if ( modeflag & DoubleScanMode )
5326 tempax |= 0x80 ;
5328 if ( modeflag & HalfDCLK )
5329 tempax |= 0x40 ;
5331 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5335 /* --------------------------------------------------------------------- */
5336 /* Function : XGI_SetLockRegs */
5337 /* Input : */
5338 /* Output : */
5339 /* Description : */
5340 /* --------------------------------------------------------------------- */
5341 void XGI_SetLockRegs( USHORT ModeNo , USHORT ModeIdIndex ,
5342 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5344 USHORT push1 ,
5345 push2 ,
5346 tempax ,
5347 tempbx = 0 ,
5348 tempcx ,
5349 temp ,
5350 resinfo ,
5351 modeflag ,
5352 CRT1Index ;
5354 if ( ModeNo <= 0x13 )
5356 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5357 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5359 else
5361 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5362 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5363 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5364 CRT1Index &= IndexMask;
5367 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5369 return ;
5372 temp = 0xFF ; /* set MAX HT */
5373 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5374 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5375 /* else */
5376 tempcx=0x08;
5378 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5379 modeflag |= Charx8Dot ;
5381 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5383 if ( modeflag & HalfDCLK )
5384 tempax = tempax >> 1 ;
5386 tempax = ( tempax / tempcx ) - 1 ;
5387 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5388 temp = tempax & 0x00FF ;
5389 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5391 temp = ( tempbx & 0xFF00 ) >> 8 ;
5393 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5395 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5396 temp += 2 ;
5398 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5400 if ( pVBInfo->VBType & VB_XGI301LV )
5402 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5404 if ( resinfo == 7 )
5405 temp -= 2 ;
5408 else
5409 if ( resinfo == 7 )
5410 temp -= 2 ;
5414 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5415 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5417 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5418 { /* 030226 bainy */
5419 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5420 tempax = pVBInfo->VGAHT ;
5421 else
5422 tempax = XGI_GetVGAHT2( pVBInfo) ;
5425 if ( tempax >= pVBInfo->VGAHT )
5427 tempax = pVBInfo->VGAHT ;
5430 if ( modeflag & HalfDCLK )
5432 tempax = tempax >> 1 ;
5435 tempax = ( tempax / tempcx ) - 5 ;
5436 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5437 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5439 temp = ( tempbx & 0x00FF ) - 1 ;
5440 if ( !( modeflag & HalfDCLK ) )
5442 temp -= 6 ;
5443 if ( pVBInfo->TVInfo & TVSimuMode )
5445 temp -= 4 ;
5446 if ( ModeNo > 0x13 )
5447 temp -= 10 ;
5451 else
5453 /* tempcx = tempbx & 0x00FF ; */
5454 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5455 tempcx = ( tempcx + tempbx ) >> 1 ;
5456 temp = ( tempcx & 0x00FF ) + 2 ;
5458 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5460 temp -= 1 ;
5461 if ( !( modeflag & HalfDCLK ) )
5463 if ( ( modeflag & Charx8Dot ) )
5465 temp += 4 ;
5466 if ( pVBInfo->VGAHDE >= 800 )
5468 temp -= 6 ;
5473 else
5475 if ( !( modeflag & HalfDCLK ) )
5477 temp -= 4 ;
5478 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5480 if( pVBInfo->VGAHDE >= 800 )
5482 temp -= 7 ;
5483 if ( pVBInfo->ModeType == ModeEGA )
5485 if ( pVBInfo->VGAVDE == 1024 )
5487 temp += 15 ;
5488 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5490 temp += 7 ;
5495 if ( pVBInfo->VGAHDE >= 1280 )
5497 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5499 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5501 temp += 28 ;
5511 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5512 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5514 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5516 if ( pVBInfo->TVInfo & TVSimuMode )
5518 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5520 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5521 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5524 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5526 if ( pVBInfo->TVInfo & SetNTSCTV )
5528 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5529 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5531 else
5533 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5534 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5535 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5539 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5541 if ( pVBInfo->TVInfo & SetNTSCTV )
5543 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5544 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5546 else
5548 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5549 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5550 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5554 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5556 if ( pVBInfo->TVInfo & SetNTSCTV )
5558 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5559 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5561 else
5563 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5564 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5570 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5571 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5572 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5574 tempbx = pVBInfo->VGAVT ;
5575 push1 = tempbx ;
5576 tempcx = 0x121 ;
5577 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5579 if ( tempbx == 357 )
5580 tempbx = 350 ;
5581 if ( tempbx == 360 )
5582 tempbx =350 ;
5583 if ( tempbx == 375 )
5584 tempbx = 350 ;
5585 if ( tempbx == 405 )
5586 tempbx = 400 ;
5587 if ( tempbx == 525 )
5588 tempbx = 480 ;
5590 push2 = tempbx ;
5592 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5594 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5596 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5598 if ( tempbx == 350 )
5599 tempbx += 5 ;
5600 if ( tempbx == 480 )
5601 tempbx += 5 ;
5605 tempbx-- ;
5606 temp = tempbx & 0x00FF ;
5607 tempbx-- ;
5608 temp = tempbx & 0x00FF ;
5609 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5610 tempbx = push2 ;
5611 tempbx-- ;
5612 temp = tempbx & 0x00FF ;
5613 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5615 if ( tempbx & 0x0100 )
5617 tempcx |= 0x0002 ;
5620 tempax = 0x000B ;
5622 if ( modeflag & DoubleScanMode )
5624 tempax |= 0x08000 ;
5627 if ( tempbx & 0x0200 )
5629 tempcx |= 0x0040 ;
5632 temp = ( tempax & 0xFF00 ) >> 8 ;
5633 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5635 if ( tempbx & 0x0400 )
5637 tempcx |= 0x0600 ;
5640 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5642 tempax = push1 ;
5643 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
5644 tempax = tempax >> 2 ;
5645 push1 = tempax ; /* push ax */
5647 if ( resinfo != 0x09 )
5649 tempax = tempax << 1 ;
5650 tempbx += tempax ;
5653 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5655 if ( pVBInfo->VBType & VB_XGI301LV )
5657 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
5658 tempbx -= 10 ;
5659 else
5661 if ( pVBInfo->TVInfo & TVSimuMode )
5663 if ( pVBInfo->TVInfo & SetPALTV )
5665 if ( pVBInfo->VBType & VB_XGI301LV )
5667 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5668 tempbx += 40 ;
5670 else
5671 tempbx += 40 ;
5676 else
5677 tempbx -= 10 ;
5679 else
5681 if ( pVBInfo->TVInfo & TVSimuMode )
5683 if ( pVBInfo->TVInfo & SetPALTV )
5685 if ( pVBInfo->VBType & VB_XGI301LV )
5687 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5688 tempbx += 40 ;
5690 else
5691 tempbx += 40 ;
5695 tempax = push1 ;
5696 tempax = tempax >> 2 ;
5697 tempax++ ;
5698 tempax += tempbx ;
5699 push1 = tempax ; /* push ax */
5701 if ( ( pVBInfo->TVInfo & SetPALTV ) )
5703 if ( tempbx <= 513 )
5705 if ( tempax >= 513 )
5707 tempbx = 513 ;
5712 temp = tempbx & 0x00FF ;
5713 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5714 tempbx-- ;
5715 temp = tempbx & 0x00FF ;
5716 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5718 if ( tempbx & 0x0100 )
5720 tempcx |= 0x0008 ;
5723 if ( tempbx & 0x0200 )
5725 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
5728 tempbx++ ;
5730 if ( tempbx & 0x0100 )
5732 tempcx |= 0x0004 ;
5735 if ( tempbx & 0x0200 )
5737 tempcx |= 0x0080 ;
5740 if ( tempbx & 0x0400 )
5742 tempcx |= 0x0C00 ;
5745 tempbx = push1 ; /* pop ax */
5746 temp = tempbx & 0x00FF ;
5747 temp &= 0x0F ;
5748 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
5750 if ( tempbx & 0x0010 )
5752 tempcx |= 0x2000 ;
5755 temp = tempcx & 0x00FF ;
5756 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
5757 temp = ( tempcx & 0x0FF00 ) >> 8 ;
5758 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
5759 tempax = modeflag ;
5760 temp = ( tempax & 0xFF00 ) >> 8 ;
5762 temp = ( temp >> 1 ) & 0x09 ;
5764 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5765 temp |= 0x01 ;
5767 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
5768 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
5769 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
5771 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
5772 temp = 0x80 ;
5773 else
5774 temp = 0x00 ;
5776 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
5778 return ;
5782 /* --------------------------------------------------------------------- */
5783 /* Function : XGI_SetGroup2 */
5784 /* Input : */
5785 /* Output : */
5786 /* Description : */
5787 /* --------------------------------------------------------------------- */
5788 void XGI_SetGroup2( USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex,
5789 PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5791 USHORT i ,
5793 tempax ,
5794 tempbx ,
5795 tempcx ,
5796 temp ,
5797 push1 ,
5798 push2 ,
5799 modeflag ,
5800 resinfo ,
5801 crt2crtc ;
5802 UCHAR *TimingPoint ;
5804 ULONG longtemp ,
5805 tempeax ,
5806 tempebx ,
5807 temp2 ,
5808 tempecx ;
5810 if ( ModeNo <= 0x13 )
5812 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5813 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5814 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5816 else
5818 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5819 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5820 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
5823 tempax = 0 ;
5825 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
5826 tempax |= 0x0800 ;
5828 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
5829 tempax |= 0x0400 ;
5831 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
5832 tempax |= 0x0200 ;
5834 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5835 tempax |= 0x1000 ;
5837 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5838 tempax |= 0x0100 ;
5840 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
5841 tempax &= 0xfe00 ;
5843 tempax = ( tempax & 0xff00 ) >> 8 ;
5845 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
5846 TimingPoint = pVBInfo->NTSCTiming ;
5848 if ( pVBInfo->TVInfo & SetPALTV )
5850 TimingPoint = pVBInfo->PALTiming ;
5853 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5855 TimingPoint = pVBInfo->HiTVExtTiming ;
5857 if ( pVBInfo->VBInfo & SetInSlaveMode )
5858 TimingPoint = pVBInfo->HiTVSt2Timing ;
5860 if ( pVBInfo->SetFlag & TVSimuMode )
5861 TimingPoint = pVBInfo->HiTVSt1Timing ;
5863 if ( !(modeflag & Charx8Dot) )
5864 TimingPoint = pVBInfo->HiTVTextTiming ;
5867 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5869 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5870 TimingPoint = pVBInfo->YPbPr525iTiming ;
5872 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5873 TimingPoint = pVBInfo->YPbPr525pTiming ;
5875 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5876 TimingPoint = pVBInfo->YPbPr750pTiming ;
5879 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
5881 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
5884 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
5886 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
5889 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5891 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
5894 temp = pVBInfo->NewFlickerMode ;
5895 temp &= 0x80 ;
5896 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
5898 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5899 tempax = 950 ;
5901 if ( pVBInfo->TVInfo & SetPALTV )
5902 tempax = 520 ;
5903 else
5904 tempax = 440 ;
5906 if ( pVBInfo->VDE <= tempax )
5908 tempax -= pVBInfo->VDE ;
5909 tempax = tempax >> 2 ;
5910 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
5911 push1 = tempax ;
5912 temp = ( tempax & 0xFF00 ) >> 8 ;
5913 temp += ( USHORT )TimingPoint[ 0 ] ;
5915 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5917 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
5919 tempcx=pVBInfo->VGAHDE;
5920 if ( tempcx >= 1024 )
5922 temp = 0x17 ; /* NTSC */
5923 if ( pVBInfo->TVInfo & SetPALTV )
5924 temp = 0x19 ; /* PAL */
5929 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
5930 tempax = push1 ;
5931 temp = ( tempax & 0xFF00 ) >> 8 ;
5932 temp += TimingPoint[ 1 ] ;
5934 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5936 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
5938 tempcx = pVBInfo->VGAHDE ;
5939 if ( tempcx >= 1024 )
5941 temp = 0x1D ; /* NTSC */
5942 if ( pVBInfo->TVInfo & SetPALTV )
5943 temp = 0x52 ; /* PAL */
5947 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
5950 /* 301b */
5951 tempcx = pVBInfo->HT ;
5953 if ( XGI_IsLCDDualLink( pVBInfo ) )
5954 tempcx = tempcx >> 1 ;
5956 tempcx -= 2 ;
5957 temp = tempcx & 0x00FF ;
5958 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
5960 temp = ( tempcx & 0xFF00 ) >> 8 ;
5961 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
5963 tempcx = pVBInfo->HT >> 1 ;
5964 push1 = tempcx ; /* push cx */
5965 tempcx += 7 ;
5967 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5969 tempcx -= 4 ;
5972 temp = tempcx & 0x00FF ;
5973 temp = temp << 4 ;
5974 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
5976 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
5977 tempbx += tempcx ;
5978 push2 = tempbx ;
5979 temp = tempbx & 0x00FF ;
5980 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
5981 temp = ( tempbx & 0xFF00 ) >> 8 ;
5982 temp = temp << 4 ;
5983 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
5985 tempbx=push2;
5986 tempbx=tempbx+8;
5987 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5989 tempbx=tempbx-4;
5990 tempcx=tempbx;
5993 temp = ( tempbx & 0x00FF ) << 4 ;
5994 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
5996 j += 2 ;
5997 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
5998 temp = tempcx & 0x00FF ;
5999 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6000 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6001 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6003 tempcx += 8 ;
6004 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6006 tempcx -= 4 ;
6009 temp = tempcx & 0xFF ;
6010 temp = temp << 4 ;
6011 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6013 tempcx = push1 ; /* pop cx */
6014 j += 2 ;
6015 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6016 tempcx -= temp ;
6017 temp = tempcx & 0x00FF ;
6018 temp = temp << 4 ;
6019 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6021 tempcx -= 11 ;
6023 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6025 tempax = XGI_GetVGAHT2( pVBInfo) ;
6026 tempcx = tempax - 1 ;
6028 temp = tempcx & 0x00FF ;
6029 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6031 tempbx = pVBInfo->VDE ;
6033 if ( pVBInfo->VGAVDE == 360 )
6034 tempbx = 746 ;
6035 if ( pVBInfo->VGAVDE == 375 )
6036 tempbx = 746 ;
6037 if ( pVBInfo->VGAVDE == 405 )
6038 tempbx = 853 ;
6040 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6042 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6044 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6045 tempbx = tempbx >> 1 ;
6047 else
6048 tempbx = tempbx >> 1 ;
6051 tempbx -= 2 ;
6052 temp = tempbx & 0x00FF ;
6054 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6056 if ( pVBInfo->VBType & VB_XGI301LV )
6058 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6060 if ( pVBInfo->VBInfo & SetInSlaveMode )
6062 if ( ModeNo == 0x2f )
6063 temp += 1 ;
6067 else
6069 if ( pVBInfo->VBInfo & SetInSlaveMode )
6071 if ( ModeNo == 0x2f )
6072 temp += 1 ;
6077 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6079 temp = ( tempcx & 0xFF00 ) >> 8 ;
6080 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6082 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6084 if ( pVBInfo->VBType & VB_XGI301LV )
6086 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6088 temp |= 0x10 ;
6090 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6091 temp |= 0x20 ;
6094 else
6096 temp |= 0x10 ;
6097 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6098 temp |= 0x20 ;
6102 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6104 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6106 tempbx = pVBInfo->VDE ;
6107 tempcx = tempbx - 2 ;
6109 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6111 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6112 tempbx = tempbx >> 1 ;
6115 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6117 temp=0;
6118 if( tempcx & 0x0400 )
6119 temp |= 0x20 ;
6121 if ( tempbx & 0x0400 )
6122 temp |= 0x40 ;
6124 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6127 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6128 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6129 temp = ( tempbx - 3 ) & 0x00FF ;
6130 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6133 tempbx = tempbx & 0x00FF ;
6135 if ( !( modeflag & HalfDCLK ) )
6137 tempcx = pVBInfo->VGAHDE ;
6138 if ( tempcx >= pVBInfo->HDE )
6140 tempbx |= 0x2000 ;
6141 tempax &= 0x00FF ;
6145 tempcx = 0x0101 ;
6147 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6148 if(pVBInfo->VGAHDE>=1024)
6150 tempcx=0x1920;
6151 if(pVBInfo->VGAHDE>=1280)
6153 tempcx=0x1420;
6154 tempbx=tempbx&0xDFFF;
6159 if ( !( tempbx & 0x2000 ) )
6161 if ( modeflag & HalfDCLK )
6163 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6166 push1 = tempbx ;
6167 tempeax = pVBInfo->VGAHDE ;
6168 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6169 longtemp = tempeax * tempebx ;
6170 tempecx = tempcx & 0x00FF ;
6171 longtemp = longtemp / tempecx ;
6173 /* 301b */
6174 tempecx = 8 * 1024 ;
6176 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6178 tempecx = tempecx * 8 ;
6181 longtemp = longtemp * tempecx ;
6182 tempecx = pVBInfo->HDE ;
6183 temp2 = longtemp % tempecx ;
6184 tempeax = longtemp / tempecx ;
6185 if ( temp2 != 0 )
6187 tempeax += 1 ;
6190 tempax = ( USHORT )tempeax ;
6192 /* 301b */
6193 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6195 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6197 /* end 301b */
6199 tempbx = push1 ;
6200 tempbx =( USHORT )( ( ( tempeax & 0x0000FF00 ) & 0x1F00 ) | ( tempbx & 0x00FF ) ) ;
6201 tempax =( USHORT )( ( ( tempeax & 0x000000FF ) << 8 ) | ( tempax & 0x00FF ) ) ;
6202 temp = ( tempax & 0xFF00 ) >> 8 ;
6204 else
6206 temp = ( tempax & 0x00FF ) >> 8 ;
6209 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6210 temp = ( tempbx & 0xFF00 ) >> 8 ;
6211 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6212 temp = tempcx & 0x00FF ;
6214 if ( tempbx & 0x2000 )
6215 temp = 0 ;
6217 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6218 temp |= 0x18 ;
6220 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6221 if ( pVBInfo->TVInfo & SetPALTV )
6223 tempbx = 0x0382 ;
6224 tempcx = 0x007e ;
6226 else
6228 tempbx = 0x0369 ;
6229 tempcx = 0x0061 ;
6232 temp = tempbx & 0x00FF ;
6233 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6234 temp = tempcx & 0x00FF ;
6235 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6237 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6238 temp = temp << 2 ;
6239 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6241 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6243 temp |= 0x10 ;
6245 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6246 temp |= 0x20 ;
6248 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6249 temp |= 0x60 ;
6252 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6253 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6254 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , ( USHORT )( temp - 3 ) ) ;
6256 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6258 if ( pVBInfo->TVInfo & NTSC1024x768 )
6260 TimingPoint = XGI_NTSC1024AdjTime ;
6261 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6263 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6265 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6269 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6270 if ( pVBInfo->VBType & VB_XGI301C )
6272 if ( pVBInfo->TVInfo & SetPALMTV )
6273 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6276 if ( pVBInfo->TVInfo & SetPALMTV )
6278 tempax = ( UCHAR )XGINew_GetReg1( pVBInfo->Part2Port , 0x01 ) ;
6279 tempax-- ;
6280 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6282 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6283 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6286 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6288 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6290 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6294 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6296 return ;
6301 /* --------------------------------------------------------------------- */
6302 /* Function : XGI_SetLCDRegs */
6303 /* Input : */
6304 /* Output : */
6305 /* Description : */
6306 /* --------------------------------------------------------------------- */
6307 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
6309 USHORT push1 ,
6310 push2 ,
6311 pushbx ,
6312 tempax ,
6313 tempbx ,
6314 tempcx ,
6315 temp ,
6316 tempah ,
6317 tempbh ,
6318 tempch ,
6319 resinfo ,
6320 modeflag ,
6321 CRT1Index ;
6323 XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6326 if ( ModeNo <= 0x13 )
6328 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6329 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6331 else
6333 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6334 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6335 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6336 CRT1Index &= IndexMask ;
6339 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6341 return ;
6344 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6346 if ( XGI_IsLCDDualLink( pVBInfo ) )
6347 tempbx = tempbx >> 1 ;
6349 tempbx -= 1 ;
6350 temp = tempbx & 0x00FF ;
6351 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6352 temp = ( tempbx & 0xFF00 ) >> 8 ;
6353 temp = temp << 4 ;
6354 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6355 temp = 0x01 ;
6357 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6359 if ( pVBInfo->ModeType == ModeEGA )
6361 if ( pVBInfo->VGAHDE >= 1024 )
6363 temp = 0x02 ;
6364 if ( pVBInfo->LCDInfo & LCDVESATiming )
6365 temp = 0x01 ;
6370 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6371 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6372 push1 = tempbx ;
6373 tempbx-- ;
6374 temp = tempbx & 0x00FF ;
6375 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6376 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6377 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6379 tempcx = pVBInfo->VT - 1 ;
6380 push2 = tempcx + 1 ;
6381 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6382 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6383 temp = ( tempcx & 0xFF00 ) >> 8 ;
6384 temp = temp << 5 ;
6385 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6386 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6387 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6388 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6389 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6391 /* Customized LCDB Des no add */
6392 tempbx = 5 ;
6393 LCDBDesPtr = ( XGI_LCDDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
6394 tempah = pVBInfo->LCDResInfo ;
6395 tempah &= PanelResInfo ;
6397 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6399 tempbx = 1024 ;
6400 tempcx = 768 ;
6402 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6404 tempbx = 1280 ;
6405 tempcx = 1024 ;
6407 else if ( tempah == Panel1400x1050 )
6409 tempbx = 1400 ;
6410 tempcx = 1050 ;
6412 else
6414 tempbx = 1600 ;
6415 tempcx = 1200 ;
6418 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6420 tempbx = pVBInfo->HDE ;
6421 tempcx = pVBInfo->VDE ;
6424 pushbx = tempbx ;
6425 tempax = pVBInfo->VT ;
6426 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6427 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6428 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6429 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6430 tempbx = pVBInfo->LCDVDES ;
6431 tempcx += tempbx ;
6433 if ( tempcx >= tempax )
6434 tempcx -= tempax ; /* lcdvdes */
6436 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6437 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6438 temp = tempcx & 0x00FF ;
6439 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6440 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6441 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6442 tempah = tempch ;
6443 tempah = tempah << 3 ;
6444 tempah |= tempbh ;
6445 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6447 /* getlcdsync() */
6448 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6449 tempcx = tempbx ;
6450 tempax = pVBInfo->VT ;
6451 tempbx = pVBInfo->LCDVRS ;
6453 /* if ( SetLCD_Info & EnableScalingLCD ) */
6454 tempcx += tempbx ;
6455 if ( tempcx >= tempax )
6456 tempcx -= tempax ;
6458 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6459 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6460 temp = ( tempbx & 0xFF00 ) >> 8 ;
6461 temp = temp << 4 ;
6462 temp |= ( tempcx & 0x000F ) ;
6463 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6464 tempcx = pushbx ;
6465 tempax = pVBInfo->HT ;
6466 tempbx = pVBInfo->LCDHDES ;
6467 tempbx &= 0x0FFF ;
6469 if ( XGI_IsLCDDualLink( pVBInfo ) )
6471 tempax = tempax >> 1 ;
6472 tempbx = tempbx >> 1 ;
6473 tempcx = tempcx >> 1 ;
6476 if ( pVBInfo->VBType & VB_XGI302LV )
6477 tempbx += 1 ;
6479 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6480 tempbx += 1 ;
6482 tempcx += tempbx ;
6484 if ( tempcx >= tempax )
6485 tempcx -= tempax ;
6487 temp = tempbx & 0x00FF ;
6488 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6489 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6490 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6491 temp = tempcx & 0x00FF ;
6492 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6493 temp = ( tempcx & 0xFF00 ) >> 8 ;
6494 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6496 /* getlcdsync() */
6497 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6498 tempcx = tempax ;
6499 tempax = pVBInfo->HT ;
6500 tempbx = pVBInfo->LCDHRS ;
6501 /* if ( SetLCD_Info & EnableScalingLCD) */
6502 if ( XGI_IsLCDDualLink( pVBInfo) )
6504 tempax = tempax >> 1 ;
6505 tempbx = tempbx >> 1 ;
6506 tempcx = tempcx >> 1 ;
6509 if ( pVBInfo->VBType & VB_XGI302LV )
6510 tempbx += 1 ;
6512 tempcx += tempbx ;
6514 if ( tempcx >= tempax )
6515 tempcx -= tempax ;
6517 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6518 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6520 temp = ( tempbx & 0xFF00 ) >> 8 ;
6521 temp = temp << 4 ;
6522 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6523 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6524 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6526 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6528 if ( pVBInfo->VGAVDE == 525 )
6530 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6532 temp = 0xC6 ;
6534 else
6535 temp = 0xC4 ;
6537 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6538 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6541 if ( pVBInfo->VGAVDE == 420 )
6543 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6545 temp = 0x4F ;
6547 else
6548 temp = 0x4E ;
6549 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6555 /* --------------------------------------------------------------------- */
6556 /* Function : XGI_GetTap4Ptr */
6557 /* Input : */
6558 /* Output : di -> Tap4 Reg. Setting Pointer */
6559 /* Description : */
6560 /* --------------------------------------------------------------------- */
6561 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo)
6563 USHORT tempax ,
6564 tempbx ,
6567 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6569 if ( tempcx == 0 )
6571 tempax = pVBInfo->VGAHDE ;
6572 tempbx = pVBInfo->HDE ;
6574 else
6576 tempax = pVBInfo->VGAVDE ;
6577 tempbx = pVBInfo->VDE ;
6580 if ( tempax < tempbx )
6581 return &EnlargeTap4Timing[ 0 ] ;
6582 else if( tempax == tempbx )
6583 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6584 else
6585 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6587 if ( pVBInfo->TVInfo & SetPALTV )
6588 Tap4TimingPtr = PALTap4Timing ;
6591 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6593 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6594 Tap4TimingPtr = YPbPr525iTap4Timing ;
6595 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6596 Tap4TimingPtr = YPbPr525pTap4Timing ;
6597 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6598 Tap4TimingPtr = YPbPr750pTap4Timing ;
6601 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6602 Tap4TimingPtr = HiTVTap4Timing ;
6604 i = 0 ;
6605 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6607 if ( Tap4TimingPtr[ i ].DE == tempax )
6608 break ;
6609 i++ ;
6611 return &Tap4TimingPtr[ i ] ;
6615 /* --------------------------------------------------------------------- */
6616 /* Function : XGI_SetTap4Regs */
6617 /* Input : */
6618 /* Output : */
6619 /* Description : */
6620 /* --------------------------------------------------------------------- */
6621 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo)
6623 USHORT i ,
6626 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6628 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6629 return ;
6631 #ifndef Tap4
6632 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6633 #else /* Tap4 Setting */
6635 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6636 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6637 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6639 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6641 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6642 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6643 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6646 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6647 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
6648 else
6649 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
6650 #endif
6653 /* --------------------------------------------------------------------- */
6654 /* Function : XGI_SetGroup3 */
6655 /* Input : */
6656 /* Output : */
6657 /* Description : */
6658 /* --------------------------------------------------------------------- */
6659 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
6661 USHORT i;
6662 UCHAR *tempdi;
6663 USHORT modeflag;
6665 if(ModeNo<=0x13)
6667 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6669 else
6671 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6675 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
6676 if(pVBInfo->TVInfo&SetPALTV)
6678 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6679 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6681 else
6683 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
6684 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
6687 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
6689 return;
6692 if(pVBInfo->TVInfo&SetPALMTV)
6694 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6695 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6696 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
6699 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
6701 if(pVBInfo->TVInfo & SetYPbPrMode525i)
6703 return;
6705 tempdi=pVBInfo->HiTVGroup3Data;
6706 if(pVBInfo->SetFlag&TVSimuMode)
6708 tempdi=pVBInfo->HiTVGroup3Simu;
6709 if(!(modeflag&Charx8Dot))
6711 tempdi=pVBInfo->HiTVGroup3Text;
6715 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6717 tempdi=pVBInfo->Ren525pGroup3;
6719 if(pVBInfo->TVInfo & SetYPbPrMode750p)
6721 tempdi=pVBInfo->Ren750pGroup3;
6724 for(i=0;i<=0x3E;i++)
6726 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
6728 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
6730 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6732 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
6736 return;
6737 } /* {end of XGI_SetGroup3} */
6740 /* --------------------------------------------------------------------- */
6741 /* Function : XGI_SetGroup4 */
6742 /* Input : */
6743 /* Output : */
6744 /* Description : */
6745 /* --------------------------------------------------------------------- */
6746 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
6748 USHORT tempax ,
6749 tempcx ,
6750 tempbx ,
6751 modeflag ,
6752 temp ,
6753 temp2 ;
6755 ULONG tempebx ,
6756 tempeax ,
6757 templong ;
6760 if ( ModeNo <= 0x13 )
6762 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6764 else
6766 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6769 temp = pVBInfo->RVBHCFACT ;
6770 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
6772 tempbx = pVBInfo->RVBHCMAX ;
6773 temp = tempbx & 0x00FF ;
6774 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
6775 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
6776 tempcx = pVBInfo->VGAHT - 1 ;
6777 temp = tempcx & 0x00FF ;
6778 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
6780 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
6781 temp2 |= temp ;
6783 tempcx = pVBInfo->VGAVT - 1 ;
6784 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6786 tempcx -= 5 ;
6789 temp = tempcx & 0x00FF ;
6790 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
6791 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
6792 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
6793 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
6794 tempcx = pVBInfo->VBInfo ;
6795 tempbx = pVBInfo->VGAHDE ;
6797 if ( modeflag & HalfDCLK )
6799 tempbx = tempbx >> 1 ;
6802 if ( XGI_IsLCDDualLink( pVBInfo ) )
6803 tempbx = tempbx >> 1 ;
6805 if(tempcx&SetCRT2ToHiVisionTV)
6807 temp=0;
6808 if(tempbx<=1024)
6809 temp=0xA0;
6810 if(tempbx == 1280)
6811 temp = 0xC0;
6813 else if(tempcx&SetCRT2ToTV)
6815 temp=0xA0;
6816 if(tempbx <= 800)
6817 temp=0x80;
6819 else
6821 temp=0x80;
6822 if(pVBInfo->VBInfo&SetCRT2ToLCD)
6824 temp=0;
6825 if(tempbx>800)
6826 temp=0x60;
6830 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6832 temp = 0x00 ;
6833 if ( pVBInfo->VGAHDE == 1280 )
6834 temp = 0x40 ;
6835 if ( pVBInfo->VGAHDE == 1024 )
6836 temp = 0x20 ;
6838 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
6840 tempebx = pVBInfo->VDE ;
6842 if ( tempcx & SetCRT2ToHiVisionTV )
6844 if ( !( temp & 0xE000 ) )
6845 tempbx = tempbx >> 1 ;
6848 tempcx = pVBInfo->RVBHRS ;
6849 temp = tempcx & 0x00FF ;
6850 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
6852 tempeax = pVBInfo->VGAVDE ;
6853 tempcx |= 0x04000 ;
6856 if ( tempeax <= tempebx )
6858 tempcx=(tempcx&(~0x4000));
6859 tempeax = pVBInfo->VGAVDE ;
6861 else
6863 tempeax -= tempebx ;
6867 templong = ( tempeax * 256 * 1024 ) % tempebx ;
6868 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
6869 tempebx = tempeax ;
6871 if ( templong != 0 )
6873 tempebx++ ;
6877 temp = ( USHORT )( tempebx & 0x000000FF ) ;
6878 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
6880 temp = ( USHORT )( ( tempebx & 0x0000FF00 ) >> 8 ) ;
6881 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
6882 tempbx = ( USHORT )( tempebx >> 16 ) ;
6883 temp = tempbx & 0x00FF ;
6884 temp = temp << 4 ;
6885 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
6886 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
6888 /* 301b */
6889 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6891 temp = 0x0028 ;
6892 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
6893 tempax = pVBInfo->VGAHDE ;
6894 if ( modeflag & HalfDCLK )
6896 tempax = tempax >> 1 ;
6899 if ( XGI_IsLCDDualLink( pVBInfo ) )
6900 tempax = tempax >> 1 ;
6902 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6903 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
6905 if ( tempax > 800 )
6906 tempax -= 800 ;
6908 else
6910 if ( pVBInfo->VGAHDE > 800 )
6912 if ( pVBInfo->VGAHDE == 1024 )
6913 tempax = ( tempax * 25 / 32 ) - 1 ;
6914 else
6915 tempax = ( tempax * 20 / 32 ) - 1 ;
6918 tempax -= 1 ;
6921 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
6923 if ( pVBInfo->VBType & VB_XGI301LV )
6925 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6927 if ( pVBInfo->VGAHDE > 800 )
6929 if ( pVBInfo->VGAHDE == 1024 )
6930 tempax = ( tempax * 25 / 32 ) - 1 ;
6931 else
6932 tempax = ( tempax * 20 / 32 ) - 1 ;
6936 else
6938 if ( pVBInfo->VGAHDE > 800 )
6940 if ( pVBInfo->VGAHDE == 1024 )
6941 tempax = ( tempax * 25 / 32 ) - 1 ;
6942 else
6943 tempax = ( tempax * 20 / 32 ) - 1 ;
6949 temp = ( tempax & 0xFF00 ) >> 8 ;
6950 temp = ( ( temp & 0x0003 ) << 4 ) ;
6951 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
6952 temp = ( tempax & 0x00FF ) ;
6953 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
6955 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
6957 if ( pVBInfo->VGAHDE > 800 )
6959 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
6962 temp = 0x0036 ;
6964 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6966 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6968 temp |= 0x0001 ;
6969 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
6970 temp &= ( ~0x0001 ) ;
6974 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
6975 tempbx = pVBInfo->HT ;
6976 if ( XGI_IsLCDDualLink( pVBInfo ) )
6977 tempbx = tempbx >> 1 ;
6978 tempbx = ( tempbx >> 1 ) - 2 ;
6979 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
6980 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
6981 temp = tempbx & 0x00FF ;
6982 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
6984 /* end 301b */
6986 if ( pVBInfo->ISXPDOS == 0 )
6987 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
6991 /* --------------------------------------------------------------------- */
6992 /* Function : XGI_SetGroup5 */
6993 /* Input : */
6994 /* Output : */
6995 /* Description : */
6996 /* --------------------------------------------------------------------- */
6997 void XGI_SetGroup5( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
6999 USHORT Pindex ,
7000 Pdata ;
7002 Pindex = pVBInfo->Part5Port ;
7003 Pdata = pVBInfo->Part5Port + 1 ;
7004 if ( pVBInfo->ModeType == ModeVGA )
7006 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7008 XGINew_EnableCRT2(pVBInfo) ;
7009 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7012 return ;
7016 /* --------------------------------------------------------------------- */
7017 /* Function : XGI_GetLcdPtr */
7018 /* Input : */
7019 /* Output : */
7020 /* Description : */
7021 /* --------------------------------------------------------------------- */
7022 void* XGI_GetLcdPtr( USHORT BX , USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7024 USHORT i ,
7025 tempdx ,
7026 tempcx ,
7027 tempbx ,
7028 tempal ,
7029 modeflag ,
7030 table ;
7032 XGI330_LCDDataTablStruct *tempdi = 0 ;
7035 tempbx = BX;
7037 if ( ModeNo <= 0x13 )
7039 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7040 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7042 else
7044 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7045 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7048 tempal = tempal & 0x0f ;
7050 if ( tempbx <= 1 ) /* ExpLink */
7052 if ( ModeNo <= 0x13 )
7054 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7056 else
7058 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7061 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7063 if ( ModeNo <= 0x13 )
7064 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7065 else
7066 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7069 if ( tempbx & 0x01 )
7070 tempal = ( tempal >> 4 ) ;
7072 tempal = ( tempal & 0x0f ) ;
7075 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7077 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7079 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7080 tempcx = LCDDesDataLen2 ;
7081 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7082 tempcx = LVDSDesDataLen2 ;
7084 /* mov di, word ptr cs:LCDDataList[bx] */
7085 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7087 switch( tempbx )
7089 case 0:
7090 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7091 break ;
7092 case 1:
7093 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7094 break ;
7095 case 2:
7096 tempdi = XGI_EPLLCDDataPtr ;
7097 break ;
7098 case 3:
7099 tempdi = XGI_EPLLCDDesDataPtr ;
7100 break ;
7101 case 4:
7102 tempdi = XGI_LCDDataTable ;
7103 break ;
7104 case 5:
7105 tempdi = XGI_LCDDesDataTable ;
7106 break ;
7107 case 6:
7108 tempdi = XGI_EPLCHLCDRegPtr ;
7109 break ;
7110 case 7:
7111 case 8:
7112 case 9:
7113 tempdi = 0 ;
7114 break ;
7115 default:
7116 break ;
7119 if ( tempdi == 0x00 ) /* OEMUtil */
7120 return 0 ;
7122 table = tempbx ;
7123 i = 0 ;
7125 while( tempdi[ i ].PANELID != 0xff )
7127 tempdx = pVBInfo->LCDResInfo ;
7128 if ( tempbx & 0x0080 ) /* OEMUtil */
7130 tempbx &= ( ~0x0080 ) ;
7131 tempdx = pVBInfo->LCDTypeInfo ;
7134 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7135 tempdx &= ( ~PanelResInfo ) ;
7137 if ( tempdi[ i ].PANELID == tempdx )
7139 tempbx = tempdi[ i ].MASK ;
7140 tempdx = pVBInfo->LCDInfo ;
7142 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7143 tempdx |= SetLCDStdMode ;
7145 if ( modeflag & HalfDCLK )
7146 tempdx |= SetLCDLowResolution ;
7148 tempbx &= tempdx;
7149 if ( tempbx == tempdi[ i ].CAP )
7150 break ;
7152 i++ ;
7155 if ( table == 0 )
7157 switch( tempdi[ i ].DATAPTR )
7159 case 0:
7160 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7161 break ;
7162 case 1:
7163 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7164 break ;
7165 case 2:
7166 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7167 break ;
7168 case 3:
7169 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7170 break ;
7171 case 4:
7172 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7173 break ;
7174 case 5:
7175 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7176 break ;
7177 case 6:
7178 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7179 break ;
7180 case 7:
7181 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7182 break ;
7183 case 8:
7184 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7185 break ;
7186 case 9:
7187 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7188 break ;
7189 case 10:
7190 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7191 break ;
7192 default:
7193 break ;
7196 else if ( table == 1 )
7198 switch( tempdi[ i ].DATAPTR )
7200 case 0:
7201 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7202 break ;
7203 case 1:
7204 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7205 break ;
7206 case 2:
7207 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7208 break ;
7209 case 3:
7210 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7211 break ;
7212 case 4:
7213 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7214 break ;
7215 case 5:
7216 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7217 break ;
7218 case 6:
7219 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7220 break ;
7221 case 7:
7222 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7223 break ;
7224 case 8:
7225 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7226 break ;
7227 case 9:
7228 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7229 break ;
7230 case 10:
7231 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7232 break ;
7233 default:
7234 break ;
7237 else if ( table == 2 )
7239 switch( tempdi[ i ].DATAPTR )
7241 case 0:
7242 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7243 break ;
7244 case 1:
7245 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7246 break ;
7247 case 2:
7248 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7249 break ;
7250 case 3:
7251 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7252 break ;
7253 case 4:
7254 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7255 break ;
7256 case 5:
7257 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7258 break ;
7259 case 6:
7260 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7261 break ;
7262 case 7:
7263 return &XGI_LVDSNoScalingData[ tempal ] ;
7264 break ;
7265 case 8:
7266 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7267 break ;
7268 case 9:
7269 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7270 break ;
7271 case 10:
7272 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7273 break ;
7274 case 11:
7275 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7276 break ;
7277 case 12:
7278 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7279 break ;
7280 default:
7281 break ;
7284 else if ( table == 3 )
7286 switch( tempdi[ i ].DATAPTR )
7288 case 0:
7289 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7290 break ;
7291 case 1:
7292 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7293 break ;
7294 case 2:
7295 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7296 break ;
7297 case 3:
7298 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7299 break ;
7300 case 4:
7301 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7302 break ;
7303 case 5:
7304 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7305 break ;
7306 case 6:
7307 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7308 break ;
7309 case 7:
7310 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7311 break ;
7312 case 8:
7313 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7314 break ;
7315 case 9:
7316 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7317 break ;
7318 case 10:
7319 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7320 break ;
7321 case 11:
7322 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7323 break;
7324 case 12:
7325 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7326 break ;
7327 case 13:
7328 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7329 break ;
7330 case 14:
7331 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7332 break ;
7333 default:
7334 break ;
7337 else if ( table == 4 )
7339 switch( tempdi[ i ].DATAPTR )
7341 case 0:
7342 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7343 break ;
7344 case 1:
7345 return &XGI_StLCD1024x768Data[ tempal ] ;
7346 break ;
7347 case 2:
7348 return &XGI_CetLCD1024x768Data[ tempal ] ;
7349 break ;
7350 case 3:
7351 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7352 break ;
7353 case 4:
7354 return &XGI_StLCD1280x1024Data[ tempal ] ;
7355 break ;
7356 case 5:
7357 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7358 break ;
7359 case 6:
7360 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7361 break ;
7362 case 7:
7363 return &XGI_StLCD1400x1050Data[ tempal ] ;
7364 break ;
7365 case 8:
7366 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7367 break ;
7368 case 9:
7369 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7370 break ;
7371 case 10:
7372 return &XGI_StLCD1600x1200Data[ tempal ] ;
7373 break ;
7374 case 11:
7375 return &XGI_NoScalingData[ tempal ] ;
7376 break ;
7377 case 12:
7378 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7379 break ;
7380 case 13:
7381 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7382 break ;
7383 case 14:
7384 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7385 break ;
7386 case 15:
7387 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7388 break ;
7389 case 16:
7390 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7391 break;
7392 case 17:
7393 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7394 break;
7395 case 18:
7396 return &XGI_NoScalingDatax75[ tempal ] ;
7397 break ;
7398 default:
7399 break ;
7402 else if ( table == 5 )
7404 switch( tempdi[ i ].DATAPTR )
7406 case 0:
7407 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7408 break ;
7409 case 1:
7410 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7411 break ;
7412 case 2:
7413 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7414 break ;
7415 case 3:
7416 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7417 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7418 else
7419 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7420 break ;
7421 case 4:
7422 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7423 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7424 else
7425 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7426 break ;
7427 case 5:
7428 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7429 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7430 else
7431 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7432 break ;
7433 case 6:
7434 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7435 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7436 else
7437 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7438 break ;
7439 case 7:
7440 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7441 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7442 else
7443 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7444 break ;
7445 case 8:
7446 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7447 break ;
7448 case 9:
7449 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7450 break ;
7451 case 10:
7452 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7453 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7454 else
7455 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7456 break ;
7457 case 11:
7458 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7459 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7460 else
7461 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7462 break ;
7463 case 12:
7464 return &XGI_NoScalingDesData[ tempal ] ;
7465 break;
7466 case 13:
7467 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7468 break ;
7469 case 14:
7470 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7471 break ;
7472 case 15:
7473 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7474 break ;
7475 case 16:
7476 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7477 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7478 else
7479 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7480 break ;
7481 case 17:
7482 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7483 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7484 else
7485 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7486 break ;
7487 case 18:
7488 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7489 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7490 else
7491 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7492 break ;
7493 case 19:
7494 return &XGI_NoScalingDesDatax75[ tempal ] ;
7495 break ;
7496 default:
7497 break ;
7500 else if ( table == 6 )
7502 switch( tempdi[ i ].DATAPTR )
7504 case 0:
7505 return &XGI_CH7017LV1024x768[ tempal ] ;
7506 break ;
7507 case 1:
7508 return &XGI_CH7017LV1400x1050[ tempal ] ;
7509 break ;
7510 default:
7511 break ;
7514 return 0 ;
7518 /* --------------------------------------------------------------------- */
7519 /* Function : XGI_GetTVPtr */
7520 /* Input : */
7521 /* Output : */
7522 /* Description : */
7523 /* --------------------------------------------------------------------- */
7524 void* XGI_GetTVPtr (USHORT BX,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7526 USHORT i , tempdx , tempbx , tempal , modeflag , table ;
7527 XGI330_TVDataTablStruct *tempdi = 0 ;
7529 tempbx = BX ;
7531 if ( ModeNo <= 0x13 )
7533 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7534 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7536 else
7538 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7539 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7542 tempal = tempal & 0x3f ;
7543 table = tempbx ;
7545 switch( tempbx )
7547 case 0:
7548 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7549 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7551 tempdi = XGI_EPLCHTVCRT1Ptr;
7553 break ;
7554 case 1:
7555 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7556 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7558 tempdi = XGI_EPLCHTVCRT1Ptr;
7560 break ;
7561 case 2:
7562 tempdi = XGI_EPLCHTVDataPtr ;
7563 break ;
7564 case 3:
7565 tempdi = 0 ;
7566 break ;
7567 case 4:
7568 tempdi = XGI_TVDataTable ;
7569 break ;
7570 case 5:
7571 tempdi = 0 ;
7572 break ;
7573 case 6:
7574 tempdi = XGI_EPLCHTVRegPtr ;
7575 break ;
7576 default:
7577 break ;
7580 if ( tempdi == 0x00 ) /* OEMUtil */
7581 return( 0 ) ;
7583 tempdx = pVBInfo->TVInfo ;
7585 if ( pVBInfo->VBInfo & SetInSlaveMode )
7586 tempdx = tempdx | SetTVLockMode ;
7588 if ( modeflag & HalfDCLK )
7589 tempdx = tempdx | SetTVLowResolution ;
7591 i = 0 ;
7593 while( tempdi[ i ].MASK != 0xffff )
7595 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7596 break ;
7597 i++ ;
7600 if ( table == 0x00 ) /* 07/05/22 */
7603 else if ( table == 0x01 )
7606 else if ( table == 0x04 )
7608 switch( tempdi[ i ].DATAPTR )
7610 case 0:
7611 return &XGI_ExtPALData[ tempal ] ;
7612 break ;
7613 case 1:
7614 return &XGI_ExtNTSCData[ tempal ] ;
7615 break ;
7616 case 2:
7617 return &XGI_StPALData[ tempal ] ;
7618 break ;
7619 case 3:
7620 return &XGI_StNTSCData[ tempal ] ;
7621 break ;
7622 case 4:
7623 return &XGI_ExtHiTVData[ tempal ] ;
7624 break ;
7625 case 5:
7626 return &XGI_St2HiTVData[ tempal ] ;
7627 break ;
7628 case 6:
7629 return &XGI_ExtYPbPr525iData[ tempal ] ;
7630 break ;
7631 case 7:
7632 return &XGI_ExtYPbPr525pData[ tempal ] ;
7633 break ;
7634 case 8:
7635 return &XGI_ExtYPbPr750pData[ tempal ] ;
7636 break ;
7637 case 9:
7638 return &XGI_StYPbPr525iData[ tempal ] ;
7639 break ;
7640 case 10:
7641 return &XGI_StYPbPr525pData[ tempal ] ;
7642 break ;
7643 case 11:
7644 return &XGI_StYPbPr750pData[ tempal ] ;
7645 break;
7646 case 12: /* avoid system hang */
7647 return &XGI_ExtNTSCData[ tempal ] ;
7648 break ;
7649 case 13:
7650 return &XGI_St1HiTVData[ tempal ] ;
7651 break ;
7652 default:
7653 break ;
7656 else if( table == 0x02 )
7658 switch( tempdi[ i ].DATAPTR )
7660 case 0:
7661 return &XGI_CHTVUNTSCData[ tempal ] ;
7662 break ;
7663 case 1:
7664 return &XGI_CHTVONTSCData[ tempal ] ;
7665 break ;
7666 case 2:
7667 return &XGI_CHTVUPALData[ tempal ] ;
7668 break ;
7669 case 3:
7670 return &XGI_CHTVOPALData[ tempal ] ;
7671 break ;
7672 default:
7673 break ;
7676 else if( table == 0x06 )
7679 return( 0 ) ;
7683 /* --------------------------------------------------------------------- */
7684 /* Function : XGI_BacklightByDrv */
7685 /* Input : */
7686 /* Output : 1 -> Skip backlight control */
7687 /* Description : */
7688 /* --------------------------------------------------------------------- */
7689 BOOLEAN XGI_BacklightByDrv( PVB_DEVICE_INFO pVBInfo )
7691 UCHAR tempah ;
7693 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x3A ) ;
7694 if (tempah & BacklightControlBit)
7695 return 1;
7696 else
7697 return 0;
7701 /* --------------------------------------------------------------------- */
7702 /* Function : XGI_FirePWDDisable */
7703 /* Input : */
7704 /* Output : */
7705 /* Description : Turn off VDD & Backlight : Fire disable procedure */
7706 /* --------------------------------------------------------------------- */
7708 void XGI_FirePWDDisable( PVB_DEVICE_INFO pVBInfo )
7710 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
7714 /* --------------------------------------------------------------------- */
7715 /* Function : XGI_FirePWDEnable */
7716 /* Input : */
7717 /* Output : */
7718 /* Description : Turn on VDD & Backlight : Fire enable procedure */
7719 /* --------------------------------------------------------------------- */
7720 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo )
7722 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
7726 /* --------------------------------------------------------------------- */
7727 /* Function : XGI_EnableGatingCRT */
7728 /* Input : */
7729 /* Output : */
7730 /* Description : */
7731 /* --------------------------------------------------------------------- */
7732 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7734 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
7738 /* --------------------------------------------------------------------- */
7739 /* Function : XGI_DisableGatingCRT */
7740 /* Input : */
7741 /* Output : */
7742 /* Description : */
7743 /* --------------------------------------------------------------------- */
7744 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7747 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
7751 /* --------------------------------------------------------------------- */
7752 /* Function : XGI_SetPanelDelay */
7753 /* Input : */
7754 /* Output : */
7755 /* Description : */
7756 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7757 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7758 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7759 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7760 /* --------------------------------------------------------------------- */
7761 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7763 USHORT index ;
7765 index = XGI_GetLCDCapPtr(pVBInfo) ;
7767 if ( tempbl == 1 )
7768 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
7770 if ( tempbl == 2 )
7771 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
7773 if ( tempbl == 3 )
7774 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
7776 if ( tempbl == 4 )
7777 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
7781 /* --------------------------------------------------------------------- */
7782 /* Function : XGI_SetPanelPower */
7783 /* Input : */
7784 /* Output : */
7785 /* Description : */
7786 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
7787 /* = 0111b = 07h ; Backlight on, Power off */
7788 /* = 1011b = 0Bh ; Backlight off, Power on */
7789 /* = 1111b = 0Fh ; Backlight off, Power off */
7790 /* --------------------------------------------------------------------- */
7791 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7793 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7794 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
7795 else
7796 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
7799 UCHAR XG21GPIODataTransfer(UCHAR ujDate)
7801 UCHAR ujRet = 0;
7802 UCHAR i = 0;
7804 for (i=0; i<8; i++)
7806 ujRet = ujRet << 1;
7807 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
7808 ujRet |= (ujDate >> i) & 1;
7811 return ujRet;
7814 /*----------------------------------------------------------------------------*/
7815 /* output */
7816 /* bl[5] : LVDS signal */
7817 /* bl[1] : LVDS backlight */
7818 /* bl[0] : LVDS VDD */
7819 /*----------------------------------------------------------------------------*/
7820 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7822 UCHAR CR4A,temp;
7824 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7825 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
7827 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7829 temp = XG21GPIODataTransfer(temp);
7830 temp &= 0x23;
7831 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7832 return temp;
7835 /*----------------------------------------------------------------------------*/
7836 /* output */
7837 /* bl[5] : LVDS signal */
7838 /* bl[1] : LVDS backlight */
7839 /* bl[0] : LVDS VDD */
7840 /*----------------------------------------------------------------------------*/
7841 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7843 UCHAR CR4A,CRB4,temp;
7845 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7846 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
7848 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7850 temp &= 0x0C;
7851 temp >>= 2;
7852 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7853 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
7854 temp |= ((CRB4&0x04)<<3);
7855 return temp;
7857 /*----------------------------------------------------------------------------*/
7858 /* input */
7859 /* bl[5] : 1;LVDS signal on */
7860 /* bl[1] : 1;LVDS backlight on */
7861 /* bl[0] : 1:LVDS VDD on */
7862 /* bh: 100000b : clear bit 5, to set bit5 */
7863 /* 000010b : clear bit 1, to set bit1 */
7864 /* 000001b : clear bit 0, to set bit0 */
7865 /*----------------------------------------------------------------------------*/
7866 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7868 UCHAR CR4A,temp;
7870 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7871 tempbh &= 0x23;
7872 tempbl &= 0x23;
7873 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7875 if (tempbh&0x20)
7877 temp = (tempbl>>4)&0x02;
7879 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7883 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7885 temp = XG21GPIODataTransfer(temp);
7886 temp &= ~tempbh;
7887 temp |= tempbl;
7888 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
7891 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7893 UCHAR CR4A,temp;
7894 USHORT tempbh0,tempbl0;
7896 tempbh0 = tempbh;
7897 tempbl0 = tempbl;
7898 tempbh0 &= 0x20;
7899 tempbl0 &= 0x20;
7900 tempbh0 >>= 3;
7901 tempbl0 >>= 3;
7903 if (tempbh&0x20)
7905 temp = (tempbl>>4)&0x02;
7907 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7910 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
7912 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7913 tempbh &= 0x03;
7914 tempbl &= 0x03;
7915 tempbh <<= 2;
7916 tempbl <<= 2; /* GPIOC,GPIOD */
7917 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7918 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
7921 /* --------------------------------------------------------------------- */
7922 USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo)
7924 USHORT index ;
7926 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
7927 if (index<sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct))
7929 return index;
7931 return 0;
7934 /* --------------------------------------------------------------------- */
7935 /* Function : XGI_XG21SetPanelDelay */
7936 /* Input : */
7937 /* Output : */
7938 /* Description : */
7939 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7940 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7941 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7942 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7943 /* --------------------------------------------------------------------- */
7944 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7946 USHORT index ;
7948 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
7949 if ( tempbl == 1 )
7950 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
7952 if ( tempbl == 2 )
7953 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
7955 if ( tempbl == 3 )
7956 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
7958 if ( tempbl == 4 )
7959 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
7962 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
7964 USHORT xres ,
7965 yres ,
7966 colordepth ,
7967 modeflag ,
7968 resindex ,
7969 lvdstableindex;
7971 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
7972 if ( ModeNo <= 0x13 )
7974 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
7975 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
7976 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7978 else
7980 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
7981 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
7982 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
7985 if ( !( modeflag & Charx8Dot ) )
7987 xres /= 9;
7988 xres *= 8;
7991 if ( ModeNo > 0x13 )
7993 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
7995 xres *= 2 ;
7997 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
7999 yres *= 2 ;
8003 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8004 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8005 return 0;
8007 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8008 return 0;
8010 if ( ModeNo > 0x13 )
8012 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8013 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8015 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8016 if (colordepth > 2)
8017 return 0;
8021 return 1;
8024 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo)
8026 UCHAR temp;
8028 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8029 temp = ( temp & 1 ) << 6;
8030 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8031 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8035 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo)
8037 UCHAR temp;
8039 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8040 temp = ( temp & 3 ) << 6;
8041 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8042 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8046 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8048 UCHAR temp,Miscdata;
8049 USHORT xres ,
8050 yres ,
8051 modeflag ,
8052 resindex ,
8053 lvdstableindex ;
8054 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8055 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8056 USHORT value;
8058 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8060 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8061 temp &= LCDPolarity;
8062 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8064 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8066 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8067 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8068 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8070 XGI_SetXG21FPBits(pVBInfo);
8071 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8072 if ( ModeNo <= 0x13 )
8074 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8075 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8076 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8078 else
8080 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8081 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8082 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8085 if (!( modeflag & Charx8Dot ))
8086 xres = xres * 8 / 9;
8088 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8090 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8091 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8093 LVDSHBS -= xres/4 ;
8095 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8097 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8098 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8100 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8101 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8103 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8105 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8107 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8108 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8110 LVDSVBS += yres/2 ;
8112 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8114 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8115 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8117 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8118 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8120 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8122 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8123 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8125 if (!( modeflag & Charx8Dot ))
8127 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8130 /* HT SR0B[1:0] CR00 */
8131 value = ( LVDSHT >> 3 ) - 5;
8132 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8133 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8135 /* HBS SR0B[5:4] CR02 */
8136 value = ( LVDSHBS >> 3 ) - 1;
8137 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8138 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8140 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8141 value = ( LVDSHBE >> 3 ) - 1;
8142 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8143 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8144 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8146 /* HRS SR0B[7:6] CR04 */
8147 value = ( LVDSHRS >> 3 ) + 2;
8148 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8149 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8151 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8152 value--;
8153 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8154 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8156 /* HRE SR0C[2] CR05[4:0] */
8157 value = ( LVDSHRE >> 3 ) + 2;
8158 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8159 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8161 /* Panel HRE SR2F[7:2] */
8162 value--;
8163 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8165 /* VT SR0A[0] CR07[5][0] CR06 */
8166 value = LVDSVT - 2 ;
8167 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8168 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8169 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8170 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8172 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8173 value = LVDSVBS - 1 ;
8174 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8175 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8176 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8177 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8179 /* VBE SR0A[4] CR16 */
8180 value = LVDSVBE - 1;
8181 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8182 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8184 /* VRS SR0A[3] CR7[7][2] CR10 */
8185 value = LVDSVRS - 1 ;
8186 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8187 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8188 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8189 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8191 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8192 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8193 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8194 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8196 /* VRE SR0A[5] CR11[3:0] */
8197 value = LVDSVRE - 1;
8198 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8199 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8201 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8202 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8204 for ( temp=0, value = 0; temp < 3; temp++)
8207 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8208 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8209 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8210 value += 0x10;
8213 if (!( modeflag & Charx8Dot ))
8215 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8216 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8217 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8219 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8220 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8222 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8228 /* no shadow case */
8229 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8231 UCHAR temp,Miscdata;
8232 USHORT xres ,
8233 yres ,
8234 modeflag ,
8235 resindex ,
8236 lvdstableindex ;
8237 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8238 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8239 USHORT value;
8241 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8242 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8243 temp &= LCDPolarity;
8244 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8246 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8248 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8249 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8250 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8252 XGI_SetXG27FPBits(pVBInfo);
8253 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8254 if ( ModeNo <= 0x13 )
8256 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8257 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8258 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8260 else
8262 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8263 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8264 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8267 if (!( modeflag & Charx8Dot ))
8268 xres = xres * 8 / 9;
8270 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8272 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8273 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8275 LVDSHBS -= xres/4 ;
8277 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8279 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8280 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8282 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8283 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8285 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8287 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8289 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8290 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8292 LVDSVBS += yres/2 ;
8294 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8296 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8297 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8299 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8300 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8302 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8304 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8305 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8307 if (!( modeflag & Charx8Dot ))
8309 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8312 /* HT SR0B[1:0] CR00 */
8313 value = ( LVDSHT >> 3 ) - 5;
8314 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8315 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8317 /* HBS SR0B[5:4] CR02 */
8318 value = ( LVDSHBS >> 3 ) - 1;
8319 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8320 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8322 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8323 value = ( LVDSHBE >> 3 ) - 1;
8324 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8325 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8326 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8328 /* HRS SR0B[7:6] CR04 */
8329 value = ( LVDSHRS >> 3 ) + 2;
8330 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8331 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8333 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8334 value--;
8335 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8336 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8338 /* HRE SR0C[2] CR05[4:0] */
8339 value = ( LVDSHRE >> 3 ) + 2;
8340 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8341 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8343 /* Panel HRE SR2F[7:2] */
8344 value--;
8345 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8347 /* VT SR0A[0] CR07[5][0] CR06 */
8348 value = LVDSVT - 2 ;
8349 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8350 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8351 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8352 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8354 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8355 value = LVDSVBS - 1 ;
8356 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8357 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8358 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8359 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8361 /* VBE SR0A[4] CR16 */
8362 value = LVDSVBE - 1;
8363 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8364 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8366 /* VRS SR0A[3] CR7[7][2] CR10 */
8367 value = LVDSVRS - 1 ;
8368 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8369 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8370 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8371 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8373 /* Panel VRS SR35[2:0] SR34[7:0] */
8374 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8375 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8377 /* VRE SR0A[5] CR11[3:0] */
8378 value = LVDSVRE - 1;
8379 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8380 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8382 /* Panel VRE SR3F[7:2] */
8383 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8385 for ( temp=0, value = 0; temp < 3; temp++)
8388 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8389 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8390 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8391 value += 0x10;
8394 if (!( modeflag & Charx8Dot ))
8396 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8397 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8398 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8400 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8401 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8403 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8409 /* --------------------------------------------------------------------- */
8410 /* Function : XGI_IsLCDON */
8411 /* Input : */
8412 /* Output : 0 : Skip PSC Control */
8413 /* 1: Disable PSC */
8414 /* Description : */
8415 /* --------------------------------------------------------------------- */
8416 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo)
8418 USHORT tempax ;
8420 tempax = pVBInfo->VBInfo ;
8421 if ( tempax & SetCRT2ToDualEdge )
8422 return 0;
8423 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8424 return 1;
8426 return 0;
8430 /* --------------------------------------------------------------------- */
8431 /* Function : XGI_EnablePWD */
8432 /* Input : */
8433 /* Output : */
8434 /* Description : */
8435 /* --------------------------------------------------------------------- */
8436 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo )
8438 USHORT index ,
8439 temp ;
8441 index = XGI_GetLCDCapPtr(pVBInfo) ;
8442 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8443 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8444 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8445 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8446 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8447 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8448 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8452 /* --------------------------------------------------------------------- */
8453 /* Function : XGI_DisablePWD */
8454 /* Input : */
8455 /* Output : */
8456 /* Description : */
8457 /* --------------------------------------------------------------------- */
8458 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo )
8460 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8464 /* --------------------------------------------------------------------- */
8465 /* Function : XGI_DisableChISLCD */
8466 /* Input : */
8467 /* Output : 0 -> Not LCD Mode */
8468 /* Description : */
8469 /* --------------------------------------------------------------------- */
8470 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo)
8472 USHORT tempbx ,
8473 tempah ;
8475 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8476 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8478 if ( tempbx & ( EnableChA | DisableChA ) )
8480 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8481 return 0 ;
8484 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8485 return 0;
8487 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8488 return 1;
8490 return 0;
8494 /* --------------------------------------------------------------------- */
8495 /* Function : XGI_EnableChISLCD */
8496 /* Input : */
8497 /* Output : 0 -> Not LCD mode */
8498 /* Description : */
8499 /* --------------------------------------------------------------------- */
8500 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo)
8502 USHORT tempbx ,
8503 tempah ;
8506 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8507 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8509 if ( tempbx & ( EnableChA | DisableChA ) )
8511 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8512 return 0;
8515 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8516 return 0;
8518 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8519 return 1;
8521 return 0;
8525 /* --------------------------------------------------------------------- */
8526 /* Function : XGI_GetLCDCapPtr */
8527 /* Input : */
8528 /* Output : */
8529 /* Description : */
8530 /* --------------------------------------------------------------------- */
8531 USHORT XGI_GetLCDCapPtr( PVB_DEVICE_INFO pVBInfo )
8533 UCHAR tempal ,
8534 tempah ,
8535 tempbl ,
8538 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8539 tempal = tempah & 0x0F ;
8540 tempah = tempah & 0xF0 ;
8541 i = 0 ;
8542 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8544 while( tempbl != 0xFF )
8546 if ( tempbl & 0x80 ) /* OEMUtil */
8548 tempal = tempah ;
8549 tempbl = tempbl & ~( 0x80 ) ;
8552 if ( tempal == tempbl )
8553 break ;
8555 i++ ;
8557 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8560 return i ;
8564 /* --------------------------------------------------------------------- */
8565 /* Function : XGI_GetLCDCapPtr1 */
8566 /* Input : */
8567 /* Output : */
8568 /* Description : */
8569 /* --------------------------------------------------------------------- */
8570 USHORT XGI_GetLCDCapPtr1( PVB_DEVICE_INFO pVBInfo )
8572 USHORT tempah ,
8573 tempal ,
8574 tempbl ,
8577 tempal = pVBInfo->LCDResInfo ;
8578 tempah = pVBInfo->LCDTypeInfo ;
8580 i = 0 ;
8581 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
8583 while( tempbl != 0xFF )
8585 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
8587 tempal = tempah ;
8588 tempbl &= ~0x80 ;
8591 if ( tempal == tempbl )
8592 break ;
8594 i++ ;
8595 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8598 if ( tempbl == 0xFF )
8600 pVBInfo->LCDResInfo = Panel1024x768 ;
8601 pVBInfo->LCDTypeInfo = 0 ;
8602 i = 0 ;
8605 return i ;
8609 /* --------------------------------------------------------------------- */
8610 /* Function : XGI_GetLCDSync */
8611 /* Input : */
8612 /* Output : */
8613 /* Description : */
8614 /* --------------------------------------------------------------------- */
8615 void XGI_GetLCDSync( USHORT* HSyncWidth , USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo )
8617 USHORT Index ;
8619 Index = XGI_GetLCDCapPtr(pVBInfo) ;
8620 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
8621 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
8623 return ;
8628 /* --------------------------------------------------------------------- */
8629 /* Function : XGI_EnableBridge */
8630 /* Input : */
8631 /* Output : */
8632 /* Description : */
8633 /* --------------------------------------------------------------------- */
8634 void XGI_EnableBridge( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
8636 USHORT tempbl ,
8637 tempah ;
8639 if ( pVBInfo->SetFlag == Win9xDOSMode )
8641 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8643 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8644 return ;
8646 else /* LVDS or CH7017 */
8647 return ;
8651 if ( HwDeviceExtension->jChipType < XG40 )
8653 if ( !XGI_DisableChISLCD(pVBInfo) )
8655 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8657 if ( pVBInfo->LCDInfo & SetPWDEnable )
8659 XGI_EnablePWD( pVBInfo);
8661 else
8663 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
8664 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8666 tempbl = 0xFD ;
8667 tempah = 0x02 ;
8669 else
8671 tempbl = 0xFB ;
8672 tempah = 0x00 ;
8675 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
8676 XGI_SetPanelDelay( 1,pVBInfo ) ;
8680 } /* Not 340 */
8684 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8686 if ( !( pVBInfo->SetFlag & DisableChA ) )
8688 if ( pVBInfo->SetFlag & EnableChA )
8690 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
8692 else
8694 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
8696 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
8701 if ( !( pVBInfo->SetFlag & DisableChB ) )
8703 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
8705 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
8706 tempah &= 0xDF;
8707 if ( pVBInfo->VBInfo & SetInSlaveMode )
8709 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
8710 tempah |= 0x20 ;
8712 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
8713 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
8716 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8718 if ( !( tempah & 0x80 ) )
8719 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8721 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
8725 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
8727 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
8728 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8730 if ( !XGI_DisableChISLCD(pVBInfo) )
8732 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8733 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
8735 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
8739 tempah = 0x00 ;
8741 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
8743 tempah = 0xc0 ;
8745 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
8747 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8749 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8751 tempah = tempah & 0x40;
8752 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8753 tempah = tempah ^ 0xC0 ;
8755 if ( pVBInfo->SetFlag & DisableChB )
8756 tempah &= 0xBF ;
8758 if ( pVBInfo->SetFlag & DisableChA )
8759 tempah &= 0x7F ;
8761 if ( pVBInfo->SetFlag & EnableChB )
8762 tempah |= 0x40 ;
8764 if ( pVBInfo->SetFlag & EnableChA )
8765 tempah |= 0x80 ;
8771 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
8773 if ( pVBInfo->SetFlag & Win9xDOSMode )
8775 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8776 return ;
8779 if ( !( pVBInfo->SetFlag & DisableChA ) )
8781 XGI_VBLongWait( pVBInfo) ;
8782 if ( !( pVBInfo->SetFlag & GatingCRT ) )
8784 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8785 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8786 XGI_VBLongWait( pVBInfo) ;
8789 } /* 301 */
8790 else /* LVDS */
8792 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
8793 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
8797 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8798 if ( !( tempah & 0x80 ) )
8799 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8801 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
8802 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
8803 } /* End of VB */
8806 if ( HwDeviceExtension->jChipType < XG40 )
8808 if ( !XGI_EnableChISLCD(pVBInfo) )
8810 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
8812 if ( XGI_BacklightByDrv(pVBInfo) )
8813 return ;
8815 else
8816 return ;
8819 if ( pVBInfo->LCDInfo & SetPWDEnable )
8821 XGI_FirePWDEnable(pVBInfo) ;
8822 return ;
8825 XGI_SetPanelDelay( 2,pVBInfo ) ;
8827 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8829 tempah = 0x01 ;
8830 tempbl = 0xFE ; /* turn on backlght */
8832 else
8834 tempbl = 0xF7 ;
8835 tempah = 0x00 ;
8837 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
8842 /* --------------------------------------------------------------------- */
8843 /* Function : XGI_DisableBridge */
8844 /* Input : */
8845 /* Output : */
8846 /* Description : */
8847 /* --------------------------------------------------------------------- */
8848 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8850 USHORT tempax ,
8851 tempbx ,
8852 tempah = 0 ,
8853 tempbl = 0 ;
8855 if ( pVBInfo->SetFlag == Win9xDOSMode )
8856 return ;
8859 if ( HwDeviceExtension->jChipType < XG40 )
8861 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8863 if ( !XGI_IsLCDON(pVBInfo) )
8865 if ( pVBInfo->LCDInfo & SetPWDEnable )
8866 XGI_EnablePWD( pVBInfo) ;
8867 else
8869 pVBInfo->LCDInfo &= ~SetPWDEnable ;
8870 XGI_DisablePWD(pVBInfo) ;
8871 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8873 tempbx = 0xFE ; /* not 01h */
8874 tempax = 0 ;
8876 else
8878 tempbx = 0xF7 ; /* not 08h */
8879 tempax = 0x08 ;
8881 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
8882 XGI_SetPanelDelay( 3,pVBInfo ) ;
8884 } /* end if(!XGI_IsLCDON(pVBInfo)) */
8888 /* if ( CH7017 )
8890 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8892 if ( !XGI_IsLCDON(pVBInfo) )
8894 if ( DISCHARGE )
8896 tempbx = XGINew_GetCH7005( 0x61 ) ;
8897 if ( tempbx < 0x01 ) //first time we power up
8898 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
8899 else
8900 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
8904 } */
8906 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8908 tempah = 0x3F ;
8909 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
8911 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8913 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8915 tempah = 0x7F; /* Disable Channel A */
8916 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
8917 tempah = 0xBF ; /* Disable Channel B */
8919 if ( pVBInfo->SetFlag & DisableChB )
8920 tempah &= 0xBF ; /* force to disable Cahnnel */
8922 if ( pVBInfo->SetFlag & DisableChA )
8923 tempah &= 0x7F ; /* Force to disable Channel B */
8928 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
8930 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8932 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
8933 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
8936 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
8938 if ( pVBInfo->SetFlag & GatingCRT )
8939 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8940 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
8943 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8945 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
8946 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
8949 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
8951 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
8952 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
8954 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
8955 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
8956 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
8958 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
8959 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
8961 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
8962 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
8963 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
8964 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
8967 else /* {301} */
8969 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
8971 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
8972 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
8973 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
8976 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
8977 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
8983 if ( HwDeviceExtension->jChipType < XG40 )
8985 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
8987 if ( pVBInfo->LCDInfo & SetPWDEnable )
8989 if ( pVBInfo->LCDInfo & SetPWDEnable )
8990 XGI_BacklightByDrv(pVBInfo) ;
8991 else
8993 XGI_SetPanelDelay( 4 ,pVBInfo) ;
8994 if ( pVBInfo->VBType & VB_XGI301LV )
8996 tempbl = 0xFD ;
8997 tempah = 0x00 ;
8999 else
9001 tempbl = 0xFB ;
9002 tempah = 0x04 ;
9006 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9012 /* --------------------------------------------------------------------- */
9013 /* Function : XGI_GetTVPtrIndex */
9014 /* Input : */
9015 /* Output : */
9016 /* Description : bx 0 : ExtNTSC */
9017 /* 1 : StNTSC */
9018 /* 2 : ExtPAL */
9019 /* 3 : StPAL */
9020 /* 4 : ExtHiTV */
9021 /* 5 : StHiTV */
9022 /* 6 : Ext525i */
9023 /* 7 : St525i */
9024 /* 8 : Ext525p */
9025 /* 9 : St525p */
9026 /* A : Ext750p */
9027 /* B : St750p */
9028 /* --------------------------------------------------------------------- */
9029 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo )
9031 USHORT tempbx = 0 ;
9033 if ( pVBInfo->TVInfo & SetPALTV )
9034 tempbx = 2 ;
9035 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9036 tempbx = 4 ;
9037 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9038 tempbx = 6 ;
9039 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9040 tempbx = 8 ;
9041 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9042 tempbx = 10 ;
9043 if ( pVBInfo->TVInfo & TVSimuMode )
9044 tempbx++ ;
9046 return tempbx ;
9050 /* --------------------------------------------------------------------- */
9051 /* Function : XGI_OEM310Setting */
9052 /* Input : */
9053 /* Output : */
9054 /* Description : Customized Param. for 301 */
9055 /* --------------------------------------------------------------------- */
9056 void XGI_OEM310Setting( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9058 if ( pVBInfo->SetFlag & Win9xDOSMode )
9059 return ;
9061 /* GetPart1IO(); */
9062 XGI_SetDelayComp(pVBInfo) ;
9064 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9065 XGI_SetLCDCap(pVBInfo) ;
9067 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9069 /* GetPart2IO() */
9070 XGI_SetPhaseIncr(pVBInfo) ;
9071 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9072 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9074 if ( pVBInfo->VBType&VB_XGI301)
9075 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9080 /* --------------------------------------------------------------------- */
9081 /* Function : XGI_SetDelayComp */
9082 /* Input : */
9083 /* Output : */
9084 /* Description : */
9085 /* --------------------------------------------------------------------- */
9086 void XGI_SetDelayComp( PVB_DEVICE_INFO pVBInfo )
9088 USHORT index ;
9090 UCHAR tempah ,
9091 tempbl ,
9092 tempbh ;
9094 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9096 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9098 tempbl = 0;
9099 tempbh = 0;
9101 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9102 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9104 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9105 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9107 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9108 tempbl = tempbl >> 4 ;
9110 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9111 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9113 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9114 tempbl = CRT2Delay2 ;
9116 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9118 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9119 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9121 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9122 tempbl = tempbh ;
9125 tempbl &= 0x0F ;
9126 tempbh &= 0xF0 ;
9127 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9129 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9131 tempah &= 0xF0 ;
9132 tempah |= tempbl ;
9135 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9137 tempah &= 0x0F ;
9138 tempah |= tempbh ;
9140 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9143 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9145 tempbl = 0;
9146 tempbh = 0;
9147 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9149 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9150 tempah &= 0x0f ;
9151 tempah = tempah << 4 ;
9152 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9158 /* --------------------------------------------------------------------- */
9159 /* Function : XGI_SetLCDCap */
9160 /* Input : */
9161 /* Output : */
9162 /* Description : */
9163 /* --------------------------------------------------------------------- */
9164 void XGI_SetLCDCap( PVB_DEVICE_INFO pVBInfo )
9166 USHORT tempcx ;
9168 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9170 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9172 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9173 { /* 301LV/302LV only */
9174 /* Set 301LV Capability */
9175 XGINew_SetReg1( pVBInfo->Part4Port , 0x24 , ( UCHAR )( tempcx & 0x1F ) ) ;
9177 /* VB Driving */
9178 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~( ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) >> 8 ) , ( USHORT )( ( tempcx & ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) ) >> 8 ) ) ;
9181 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9183 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9184 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9185 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9186 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9188 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9190 if ( tempcx & EnableSpectrum )
9191 SetSpectrum( pVBInfo) ;
9194 else /* LVDS,CH7017 */
9195 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9199 /* --------------------------------------------------------------------- */
9200 /* Function : XGI_SetLCDCap_A */
9201 /* Input : */
9202 /* Output : */
9203 /* Description : */
9204 /* --------------------------------------------------------------------- */
9205 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9207 USHORT temp ;
9209 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9211 if ( temp & LCDRGB18Bit )
9213 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x20 | ( tempcx & 0x00C0 ) ) ) ; /* Enable Dither */
9214 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9216 else
9218 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x30 | ( tempcx & 0x00C0 ) ) ) ;
9219 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9223 if ( tempcx & EnableLCD24bpp ) // 24bits
9225 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x30|(tempcx&0x00C0)) );
9226 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9228 else
9230 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x20|(tempcx&0x00C0)) );//Enable Dither
9231 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9237 /* --------------------------------------------------------------------- */
9238 /* Function : XGI_SetLCDCap_B */
9239 /* Input : cx -> LCD Capability */
9240 /* Output : */
9241 /* Description : */
9242 /* --------------------------------------------------------------------- */
9243 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9245 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9246 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x0c ) ) ;
9247 else
9248 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x18 ) ) ; /* Enable Dither */
9252 /* --------------------------------------------------------------------- */
9253 /* Function : SetSpectrum */
9254 /* Input : */
9255 /* Output : */
9256 /* Description : */
9257 /* --------------------------------------------------------------------- */
9258 void SetSpectrum( PVB_DEVICE_INFO pVBInfo )
9260 USHORT index ;
9262 index = XGI_GetLCDCapPtr(pVBInfo) ;
9264 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9265 XGI_LongWait(pVBInfo) ;
9266 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9267 XGI_LongWait(pVBInfo) ;
9269 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9270 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9271 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9272 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9273 XGI_LongWait(pVBInfo) ;
9274 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9278 /* --------------------------------------------------------------------- */
9279 /* Function : XGI_SetAntiFlicker */
9280 /* Input : */
9281 /* Output : */
9282 /* Description : Set TV Customized Param. */
9283 /* --------------------------------------------------------------------- */
9284 void XGI_SetAntiFlicker( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
9286 USHORT tempbx ,
9287 index ;
9289 UCHAR tempah ;
9291 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9292 return ;
9294 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9295 tempbx &= 0xFE ;
9297 if ( ModeNo <= 0x13 )
9299 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9301 else
9303 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9306 tempbx += index ;
9307 tempah = TVAntiFlickList[ tempbx ] ;
9308 tempah = tempah << 4 ;
9310 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9314 /* --------------------------------------------------------------------- */
9315 /* Function : XGI_SetEdgeEnhance */
9316 /* Input : */
9317 /* Output : */
9318 /* Description : */
9319 /* --------------------------------------------------------------------- */
9320 void XGI_SetEdgeEnhance( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
9322 USHORT tempbx ,
9323 index ;
9325 UCHAR tempah ;
9328 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9329 tempbx &= 0xFE ;
9331 if ( ModeNo <= 0x13 )
9333 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9335 else
9337 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9340 tempbx += index ;
9341 tempah = TVEdgeList[ tempbx ] ;
9342 tempah = tempah << 5 ;
9344 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9348 /* --------------------------------------------------------------------- */
9349 /* Function : XGI_SetPhaseIncr */
9350 /* Input : */
9351 /* Output : */
9352 /* Description : */
9353 /* --------------------------------------------------------------------- */
9354 void XGI_SetPhaseIncr( PVB_DEVICE_INFO pVBInfo )
9356 USHORT tempbx ;
9358 UCHAR tempcl ,
9359 tempch ;
9361 ULONG tempData ;
9363 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9364 tempData = TVPhaseList[ tempbx ] ;
9366 XGINew_SetReg1( pVBInfo->Part2Port , 0x31 , ( USHORT )( tempData & 0x000000FF ) ) ;
9367 XGINew_SetReg1( pVBInfo->Part2Port , 0x32 , ( USHORT )( ( tempData & 0x0000FF00 ) >> 8 ) ) ;
9368 XGINew_SetReg1( pVBInfo->Part2Port , 0x33 , ( USHORT )( ( tempData & 0x00FF0000 ) >> 16 ) ) ;
9369 XGINew_SetReg1( pVBInfo->Part2Port , 0x34 , ( USHORT )( ( tempData & 0xFF000000 ) >> 24 ) ) ;
9373 /* --------------------------------------------------------------------- */
9374 /* Function : XGI_SetYFilter */
9375 /* Input : */
9376 /* Output : */
9377 /* Description : */
9378 /* --------------------------------------------------------------------- */
9379 void XGI_SetYFilter( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9381 USHORT tempbx ,
9382 index ;
9384 UCHAR tempcl ,
9385 tempch ,
9386 tempal ,
9387 *filterPtr ;
9389 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9391 switch( tempbx )
9393 case 0x00:
9394 case 0x04:
9395 filterPtr = NTSCYFilter1 ;
9396 break ;
9398 case 0x01:
9399 filterPtr = PALYFilter1 ;
9400 break ;
9402 case 0x02:
9403 case 0x05:
9404 case 0x0D:
9405 filterPtr = PALMYFilter1 ;
9406 break ;
9408 case 0x03:
9409 filterPtr = PALNYFilter1 ;
9410 break ;
9412 case 0x08:
9413 case 0x0C:
9414 filterPtr = NTSCYFilter2 ;
9415 break ;
9417 case 0x0A:
9418 filterPtr = PALMYFilter2 ;
9419 break ;
9421 case 0x0B:
9422 filterPtr = PALNYFilter2 ;
9423 break ;
9425 case 0x09:
9426 filterPtr = PALYFilter2 ;
9427 break ;
9429 default:
9430 return ;
9433 if ( ModeNo <= 0x13 )
9434 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9435 else
9436 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9438 if ( tempcl == 0 )
9439 index = tempal * 4;
9440 else
9441 index = tempal * 7;
9443 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9445 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9446 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9447 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9448 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9450 else
9452 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9453 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9454 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9455 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9458 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9460 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9461 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9462 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9467 /* --------------------------------------------------------------------- */
9468 /* Function : XGI_GetTVPtrIndex2 */
9469 /* Input : */
9470 /* Output : bx 0 : NTSC */
9471 /* 1 : PAL */
9472 /* 2 : PALM */
9473 /* 3 : PALN */
9474 /* 4 : NTSC1024x768 */
9475 /* 5 : PAL-M 1024x768 */
9476 /* 6-7: reserved */
9477 /* cl 0 : YFilter1 */
9478 /* 1 : YFilter2 */
9479 /* ch 0 : 301A */
9480 /* 1 : 301B/302B/301LV/302LV */
9481 /* Description : */
9482 /* --------------------------------------------------------------------- */
9483 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo)
9485 *tempbx = 0 ;
9486 *tempcl = 0 ;
9487 *tempch = 0 ;
9489 if ( pVBInfo->TVInfo & SetPALTV )
9490 *tempbx = 1 ;
9492 if ( pVBInfo->TVInfo & SetPALMTV )
9493 *tempbx = 2 ;
9495 if ( pVBInfo->TVInfo & SetPALNTV )
9496 *tempbx = 3 ;
9498 if ( pVBInfo->TVInfo & NTSC1024x768 )
9500 *tempbx = 4 ;
9501 if ( pVBInfo->TVInfo & SetPALMTV )
9502 *tempbx = 5 ;
9505 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9507 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9509 *tempbx += 8 ;
9510 *tempcl += 1 ;
9514 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9515 (*tempch)++ ;
9519 /* --------------------------------------------------------------------- */
9520 /* Function : XGI_SetCRT2ModeRegs */
9521 /* Input : */
9522 /* Output : */
9523 /* Description : Origin code for crt2group */
9524 /* --------------------------------------------------------------------- */
9525 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
9527 USHORT tempbl ;
9528 SHORT tempcl ;
9530 UCHAR tempah ;
9532 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9533 tempah=0;
9534 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9536 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9537 tempah &= ~0x10 ; /* BTRAMDAC */
9538 tempah |= 0x40 ; /* BTRAM */
9540 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9542 tempah=0x40; /* BTDRAM */
9543 if ( ModeNo > 0x13 )
9545 tempcl = pVBInfo->ModeType ;
9546 tempcl -= ModeVGA ;
9547 if ( tempcl >= 0 )
9549 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9550 if ( tempah == 0 )
9551 tempah = 1 ;
9552 tempah |= 0x040 ;
9555 if ( pVBInfo->VBInfo & SetInSlaveMode )
9556 tempah ^= 0x50 ; /* BTDAC */
9560 /* 0210 shampoo
9561 if ( pVBInfo->VBInfo & DisableCRT2Display )
9563 tempah = 0 ;
9566 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9567 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9569 tempcl = pVBInfo->ModeType ;
9570 if ( ModeNo > 0x13 )
9572 tempcl -= ModeVGA ;
9573 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
9575 tempah=(0x008>>tempcl) ;
9576 if ( tempah == 0 )
9577 tempah = 1 ;
9578 tempah |= 0x040;
9581 else
9583 tempah = 0x040 ;
9586 if ( pVBInfo->VBInfo & SetInSlaveMode )
9588 tempah = ( tempah ^ 0x050 ) ;
9593 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9594 tempah = 0x08 ;
9595 tempbl = 0xf0 ;
9597 if ( pVBInfo->VBInfo & DisableCRT2Display )
9598 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9599 else
9601 tempah = 0x00 ;
9602 tempbl = 0xff ;
9604 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9606 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
9608 tempbl &= 0xf7 ;
9609 tempah |= 0x01 ;
9610 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9612 else
9614 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9616 tempbl &= 0xf7 ;
9617 tempah |= 0x01 ;
9620 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9622 tempbl &= 0xf8 ;
9623 tempah = 0x01 ;
9625 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
9626 tempah |= 0x02 ;
9628 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9630 tempah = tempah ^ 0x05 ;
9631 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
9632 tempah = tempah ^ 0x01 ;
9635 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9636 tempah |= 0x08 ;
9637 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9639 else
9640 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9643 else
9644 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9647 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9649 tempah &= ( ~0x08 ) ;
9650 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
9652 tempah |= 0x010 ;
9654 tempah |= 0x080 ;
9656 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9658 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
9659 /* { */
9660 tempah |= 0x020 ;
9661 if ( ModeNo > 0x13 )
9663 if ( pVBInfo->VBInfo & DriverMode )
9664 tempah = tempah ^ 0x20 ;
9666 /* } */
9669 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
9670 tempah = 0 ;
9672 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9673 tempah |= 0x40 ;
9675 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9677 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
9678 /* { */
9679 if ( pVBInfo->TVInfo & RPLLDIV2XO )
9680 tempah |= 0x40 ;
9681 /* } */
9684 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
9685 tempah |= 0x80 ;
9687 if ( pVBInfo->LCDResInfo == Panel1280x960 )
9688 tempah |= 0x80 ;
9690 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
9693 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9695 tempah = 0 ;
9696 tempbl = 0xfb ;
9698 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9700 tempbl=0xff;
9701 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9702 tempah |= 0x04 ; /* shampoo 0129 */
9705 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
9706 tempah = 0x00 ;
9707 tempbl = 0xcf ;
9708 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9710 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9711 tempah |= 0x30 ;
9714 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
9715 tempah = 0 ;
9716 tempbl = 0x3f ;
9718 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9720 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9721 tempah |= 0xc0 ;
9723 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
9726 tempah = 0 ;
9727 tempbl = 0x7f ;
9728 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9730 tempbl = 0xff ;
9731 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9732 tempah |= 0x80 ;
9735 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
9737 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9739 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9741 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
9742 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
9748 /* --------------------------------------------------------------------- */
9749 /* Function : XGI_CloseCRTC */
9750 /* Input : */
9751 /* Output : */
9752 /* Description : */
9753 /* --------------------------------------------------------------------- */
9754 void XGI_CloseCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9756 USHORT tempbx ;
9758 tempbx = 0 ;
9760 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9761 tempbx = 0x08A0 ;
9767 /* --------------------------------------------------------------------- */
9768 /* Function : XGI_OpenCRTC */
9769 /* Input : */
9770 /* Output : */
9771 /* Description : */
9772 /* --------------------------------------------------------------------- */
9773 void XGI_OpenCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9775 USHORT tempbx ;
9777 tempbx = 0 ;
9783 /* --------------------------------------------------------------------- */
9784 /* Function : XGI_GetRAMDAC2DATA */
9785 /* Input : */
9786 /* Output : */
9787 /* Description : */
9788 /* --------------------------------------------------------------------- */
9789 void XGI_GetRAMDAC2DATA(USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
9791 USHORT tempax ,
9792 tempbx ,
9793 temp1 ,
9794 temp2 ,
9795 modeflag = 0 ,
9796 tempcx ,
9797 StandTableIndex ,
9798 CRT1Index ;
9800 pVBInfo->RVBHCMAX = 1 ;
9801 pVBInfo->RVBHCFACT = 1 ;
9803 if ( ModeNo <= 0x13 )
9805 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9806 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
9807 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
9808 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
9809 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
9811 else
9813 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9814 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
9815 CRT1Index &= IndexMask ;
9816 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 0 ] ;
9817 temp2 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] ;
9818 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
9819 tempbx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 8 ] ;
9820 tempcx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] << 8 ;
9821 tempcx &= 0x0100 ;
9822 tempcx = tempcx << 2 ;
9823 tempbx |= tempcx;
9824 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
9827 if ( temp1 & 0x01 )
9828 tempbx |= 0x0100 ;
9830 if ( temp1 & 0x20 )
9831 tempbx |= 0x0200 ;
9832 tempax += 5 ;
9834 if ( modeflag & Charx8Dot )
9835 tempax *= 8 ;
9836 else
9837 tempax *= 9 ;
9839 pVBInfo->VGAHT = tempax ;
9840 pVBInfo->HT = tempax ;
9841 tempbx++ ;
9842 pVBInfo->VGAVT = tempbx ;
9843 pVBInfo->VT = tempbx ;
9848 /* --------------------------------------------------------------------- */
9849 /* Function : XGI_GetColorDepth */
9850 /* Input : */
9851 /* Output : */
9852 /* Description : */
9853 /* --------------------------------------------------------------------- */
9854 USHORT XGI_GetColorDepth(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9856 USHORT ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
9857 SHORT index ;
9858 USHORT modeflag ;
9860 if ( ModeNo <= 0x13 )
9862 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9864 else
9866 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9869 index=(modeflag&ModeInfoFlag)-ModeEGA;
9871 if ( index < 0 )
9872 index = 0 ;
9874 return( ColorDepth[ index ] ) ;
9879 /* --------------------------------------------------------------------- */
9880 /* Function : XGI_UnLockCRT2 */
9881 /* Input : */
9882 /* Output : */
9883 /* Description : */
9884 /* --------------------------------------------------------------------- */
9885 void XGI_UnLockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9888 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
9893 /* --------------------------------------------------------------------- */
9894 /* Function : XGI_LockCRT2 */
9895 /* Input : */
9896 /* Output : */
9897 /* Description : */
9898 /* --------------------------------------------------------------------- */
9899 void XGI_LockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9902 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
9908 /* --------------------------------------------------------------------- */
9909 /* Function : XGINew_EnableCRT2 */
9910 /* Input : */
9911 /* Output : */
9912 /* Description : */
9913 /* --------------------------------------------------------------------- */
9914 void XGINew_EnableCRT2( PVB_DEVICE_INFO pVBInfo)
9916 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
9921 /* --------------------------------------------------------------------- */
9922 /* Function : */
9923 /* Input : */
9924 /* Output : */
9925 /* Description : */
9926 /* --------------------------------------------------------------------- */
9927 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo)
9929 USHORT i ,
9932 ULONG temp ,
9933 flag ;
9935 flag = 0 ;
9936 //printk("XGINew_LCD_Wait_Time");
9937 //return;
9938 for( i = 0 ; i < DelayTime ; i++ )
9940 for( j = 0 ; j < 66 ; j++ )
9943 temp = XGINew_GetReg3( 0x61 ) ;
9945 //temp &= 0x10000000;
9946 temp &= 0x10;
9947 if ( temp == flag )
9948 continue ;
9950 flag = temp ;
9958 /* --------------------------------------------------------------------- */
9959 /* Function : XGI_BridgeIsOn */
9960 /* Input : */
9961 /* Output : */
9962 /* Description : */
9963 /* --------------------------------------------------------------------- */
9964 BOOLEAN XGI_BridgeIsOn( PVB_DEVICE_INFO pVBInfo )
9966 USHORT flag ;
9968 if ( pVBInfo->IF_DEF_LVDS == 1 )
9970 return( 1 ) ;
9972 else
9974 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
9975 if ( ( flag == 1 ) || ( flag == 2 ) )
9976 return( 1 ) ; /* 301b */
9977 else
9978 return( 0 ) ;
9984 /* --------------------------------------------------------------------- */
9985 /* Function : XGI_LongWait */
9986 /* Input : */
9987 /* Output : */
9988 /* Description : */
9989 /* --------------------------------------------------------------------- */
9990 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo)
9992 USHORT i ;
9994 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
9996 if ( !( i & 0xC0 ) )
9998 for( i = 0 ; i < 0xFFFF ; i++ )
10000 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10001 break ;
10004 for( i = 0 ; i < 0xFFFF ; i++ )
10006 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10007 break ;
10013 /* --------------------------------------------------------------------- */
10014 /* Function : XGI_VBLongWait */
10015 /* Input : */
10016 /* Output : */
10017 /* Description : */
10018 /* --------------------------------------------------------------------- */
10019 void XGI_VBLongWait( PVB_DEVICE_INFO pVBInfo )
10021 USHORT tempal ,
10022 temp ,
10025 return ;
10026 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10028 temp = 0 ;
10029 for( i = 0 ; i < 3 ; i++ )
10031 for( j = 0 ; j < 100 ; j++ )
10033 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10034 if ( temp & 0x01 )
10035 { /* VBWaitMode2 */
10036 if ( ( tempal & 0x08 ) )
10038 continue ;
10041 if ( !( tempal & 0x08 ) )
10043 break ;
10046 else
10047 { /* VBWaitMode1 */
10048 if ( !( tempal & 0x08 ) )
10050 continue ;
10053 if ( ( tempal & 0x08 ) )
10055 break ;
10059 temp = temp ^ 0x01 ;
10062 else
10064 XGI_LongWait(pVBInfo) ;
10066 return ;
10072 /* --------------------------------------------------------------------- */
10073 /* Function : XGI_GetVGAHT2 */
10074 /* Input : */
10075 /* Output : */
10076 /* Description : */
10077 /* --------------------------------------------------------------------- */
10078 USHORT XGI_GetVGAHT2( PVB_DEVICE_INFO pVBInfo )
10080 ULONG tempax ,
10081 tempbx ;
10083 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10084 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10085 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10087 return( ( USHORT )tempax ) ;
10091 /* --------------------------------------------------------------------- */
10092 /* Function : XGI_GetVCLK2Ptr */
10093 /* Input : */
10094 /* Output : */
10095 /* Description : */
10096 /* --------------------------------------------------------------------- */
10097 USHORT XGI_GetVCLK2Ptr( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
10099 USHORT tempbx ;
10101 USHORT LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10102 USHORT LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10103 USHORT LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10104 USHORT LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10105 USHORT LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10107 USHORT CRT2Index , VCLKIndex ;
10108 USHORT modeflag , resinfo ;
10109 UCHAR *CHTVVCLKPtr = NULL ;
10111 if ( ModeNo <= 0x13 )
10113 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10114 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10115 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10117 else
10119 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10120 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10121 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10124 if ( pVBInfo->IF_DEF_LVDS == 0 )
10126 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10127 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10129 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10131 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10133 else
10135 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10138 else /* for TV */
10140 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10142 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10144 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10146 VCLKIndex = HiTVVCLKDIV2 ;
10149 VCLKIndex += 25 ;
10152 else
10154 VCLKIndex = HiTVVCLK ;
10157 VCLKIndex += 25 ;
10161 if ( pVBInfo->SetFlag & TVSimuMode )
10163 if( modeflag & Charx8Dot )
10165 VCLKIndex = HiTVSimuVCLK ;
10168 VCLKIndex += 25 ;
10171 else
10173 VCLKIndex = HiTVTextVCLK ;
10176 VCLKIndex += 25 ;
10181 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10183 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10185 VCLKIndex = YPbPr750pVCLK ;
10186 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10188 VCLKIndex = YPbPr525pVCLK ;
10189 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10191 VCLKIndex = YPbPr525iVCLK_2 ;
10192 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10193 VCLKIndex = YPbPr525iVCLK ;
10199 else
10201 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10203 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10205 VCLKIndex = TVVCLKDIV2 ;
10208 VCLKIndex += 25 ;
10211 else
10213 VCLKIndex = TVVCLK ;
10216 VCLKIndex += 25 ;
10222 else
10223 { /* for CRT2 */
10224 VCLKIndex = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ; /* Port 3cch */
10225 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10226 if ( ModeNo > 0x13 )
10228 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10229 VCLKIndex &= IndexMask ;
10234 else
10235 { /* LVDS */
10236 if ( ModeNo <= 0x13 )
10237 VCLKIndex = CRT2Index ;
10238 else
10239 VCLKIndex = CRT2Index ;
10241 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10243 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10245 VCLKIndex &= 0x1f ;
10246 tempbx = 0 ;
10248 if ( pVBInfo->VBInfo & SetPALTV )
10249 tempbx += 2 ;
10251 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10252 tempbx += 1 ;
10254 switch( tempbx )
10256 case 0:
10257 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10258 break ;
10259 case 1:
10260 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10261 break;
10262 case 2:
10263 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10264 break ;
10265 case 3:
10266 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10267 break ;
10268 default:
10269 break ;
10272 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10275 else
10277 VCLKIndex = VCLKIndex >> 6 ;
10278 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10279 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10280 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10281 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10282 else
10283 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10286 /* VCLKIndex = VCLKIndex&IndexMask ; */
10290 return( VCLKIndex ) ;