9f5ce8c98c1e575678c7f216ca6e7085324dea49
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / xgifb / vb_setmode.c
1 #include "osdef.h"
2
3
4
5 #ifdef LINUX_XF86
6 #include "xf86.h"
7 #include "xf86PciInfo.h"
8 #include "xgi.h"
9 #include "xgi_regs.h"
10 #endif
11
12 #ifdef LINUX_KERNEL
13 #include <asm/io.h>
14 #include <linux/types.h>
15 #include <linux/version.h>
16 #include "XGIfb.h"
17 #endif
18
19
20 #include "vb_def.h"
21 #include "vgatypes.h"
22 #include "vb_struct.h"
23 #include "vb_util.h"
24 #include "vb_table.h"
25
26
27
28 #define IndexMask 0xff
29 #ifndef XGI_MASK_DUAL_CHIP
30 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
31 #endif
32
33
34
35 BOOLEAN XGI_IsLCDDualLink(PVB_DEVICE_INFO pVBInfo);
36 BOOLEAN XGI_SetCRT2Group301(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
37 BOOLEAN XGI_BacklightByDrv(PVB_DEVICE_INFO pVBInfo);
38
39 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo);
40 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo);
41 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo);
42 BOOLEAN XGI_AjustCRT2Rate(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,USHORT *i, PVB_DEVICE_INFO pVBInfo);
43 BOOLEAN XGI_SearchModeID( USHORT ModeNo,USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
44 BOOLEAN XGI_GetLCDInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
45 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo ) ;
46 BOOLEAN XGI_BridgeIsOn(PVB_DEVICE_INFO pVBInfo);
47 UCHAR XGI_GetModePtr( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
48 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
49 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
50 USHORT XGI_GetResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
51 USHORT XGI_GetColorDepth(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
52 USHORT XGI_GetVGAHT2(PVB_DEVICE_INFO pVBInfo);
53 USHORT XGI_GetVCLK2Ptr(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
54 void XGI_VBLongWait(PVB_DEVICE_INFO pVBInfo);
55 void XGI_SaveCRT2Info(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo);
56 void XGI_GetCRT2Data(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
57 void XGI_GetCRT2ResInfo(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
58 void XGI_PreSetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
59 void XGI_SetGroup1(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
60 void XGI_SetLockRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
61 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
62 void XGI_SetGroup2(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
63 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
64 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
65 void XGI_SetGroup5(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
66 void* XGI_GetLcdPtr(USHORT BX, USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
67 void* XGI_GetTVPtr(USHORT BX, USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
68 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo);
69 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
70 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
71 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
72 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
73 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo);
74 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo);
75 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo);
76 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo);
77
78 void XGI_DisplayOn(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
79 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
80 void XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
81 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
82 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
83 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
84 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo);
85 void XGI_UpdateXG21CRTC(USHORT ModeNo, PVB_DEVICE_INFO pVBInfo, USHORT RefreshRateTableIndex);
86 void XGI_WaitDisply(PVB_DEVICE_INFO pVBInfo);
87 void XGI_SenseCRT1(PVB_DEVICE_INFO pVBInfo);
88 void XGI_SetSeqRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
89 void XGI_SetMiscRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
90 void XGI_SetCRTCRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
91 void XGI_SetATTRegs(USHORT ModeNo,USHORT StandTableIndex,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
92 void XGI_SetGRCRegs(USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo);
93 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo);
94
95 void XGI_SetSync(USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
96 void XGI_SetCRT1CRTC(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
97 void XGI_SetCRT1Timing_H(PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
98 void XGI_SetCRT1Timing_V(USHORT ModeIdIndex,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);
99 void XGI_SetCRT1DE(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
100 void XGI_SetCRT1VCLK(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
101 void XGI_SetCRT1FIFO(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
102 void XGI_SetCRT1ModeRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
103 void XGI_SetVCLKState(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
104
105 void XGI_LoadDAC(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
106 void XGI_WriteDAC(USHORT dl, USHORT ah, USHORT al, USHORT dh, PVB_DEVICE_INFO pVBInfo);
107 /*void XGI_ClearBuffer(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,PVB_DEVICE_INFO pVBInfo);*/
108 void XGI_SetLCDAGroup(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
109 void XGI_GetLVDSResInfo( USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
110 void XGI_GetLVDSData(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
111 void XGI_ModCRT1Regs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
112 void XGI_SetLVDSRegs(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
113 void XGI_UpdateModeInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
114 void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
115 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo);
116 void XGI_GetVBInfo(USHORT ModeNo,USHORT ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
117 void XGI_GetTVInfo(USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
118 void XGI_SetCRT2ECLK( USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
119 void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
120 void XGI_GetLCDSync(USHORT* HSyncWidth, USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo);
121 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
122 void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
123 void XGI_SetCRT2VCLK(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
124 void XGI_OEM310Setting(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
125 void XGI_SetDelayComp(PVB_DEVICE_INFO pVBInfo);
126 void XGI_SetLCDCap(PVB_DEVICE_INFO pVBInfo);
127 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
128 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo);
129 void SetSpectrum(PVB_DEVICE_INFO pVBInfo);
130 void XGI_SetAntiFlicker(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
131 void XGI_SetEdgeEnhance(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
132 void XGI_SetPhaseIncr(PVB_DEVICE_INFO pVBInfo);
133 void XGI_SetYFilter(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
134 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo);
135 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo );
136 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
137 void XGI_CloseCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
138 void XGI_OpenCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
139 void XGI_GetRAMDAC2DATA(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
140 void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
141 void XGI_LockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
142 void XGINew_EnableCRT2(PVB_DEVICE_INFO pVBInfo);
143 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo);
144 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo);
145 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo );
146 void XGI_GetLCDVCLKPtr(UCHAR* di_0,UCHAR *di_1, PVB_DEVICE_INFO pVBInfo);
147 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
148 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo);
149 USHORT XGI_GetLCDCapPtr(PVB_DEVICE_INFO pVBInfo);
150 USHORT XGI_GetLCDCapPtr1(PVB_DEVICE_INFO pVBInfo);
151 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo);
152 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
153 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
154 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo);
155 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo);
156 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
157 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
158 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo);
159 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
160 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
161 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
162 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo );
163
164 extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
165
166 /* USHORT XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
167
168
169
170
171
172 USHORT XGINew_MDA_DAC[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
173 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
174 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
175 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
176 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
177 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
178 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
179 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F};
180
181 USHORT XGINew_CGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
182 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
183 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
184 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
185 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
186 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
187 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
188 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
189
190 USHORT XGINew_EGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15,
191 0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35,
192 0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D,
193 0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D,
194 0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17,
195 0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37,
196 0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F,
197 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F};
198
199 USHORT XGINew_VGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15,
200 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F,
201 0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18,
202 0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F,
203
204 0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F,
205 0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00,
206 0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18,
207 0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04,
208 0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10,
209 0x0B,0x0C,0x0D,0x0F,0x10};
210
211
212 /* --------------------------------------------------------------------- */
213 /* Function : InitTo330Pointer */
214 /* Input : */
215 /* Output : */
216 /* Description : */
217 /* --------------------------------------------------------------------- */
218 void InitTo330Pointer( UCHAR ChipType ,PVB_DEVICE_INFO pVBInfo)
219 {
220 pVBInfo->SModeIDTable = (XGI_StStruct *) XGI330_SModeIDTable ;
221 pVBInfo->StandTable = (XGI_StandTableStruct *) XGI330_StandTable ;
222 pVBInfo->EModeIDTable = (XGI_ExtStruct *) XGI330_EModeIDTable ;
223 pVBInfo->RefIndex = (XGI_Ext2Struct *) XGI330_RefIndex ;
224 pVBInfo->XGINEWUB_CRT1Table = (XGI_CRT1TableStruct *) XGI_CRT1Table ;
225
226 /* add for new UNIVGABIOS */
227 /* XGINew_UBLCDDataTable = (XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
228 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
229
230
231 if ( ChipType >= XG40 )
232 {
233 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI340New_MCLKData ;
234 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI340_ECLKData ;
235 }
236 else
237 {
238 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI330New_MCLKData ;
239 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI330_ECLKData ;
240 }
241
242 pVBInfo->VCLKData = (XGI_VCLKDataStruct *) XGI_VCLKData ;
243 pVBInfo->VBVCLKData = (XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
244 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
245 pVBInfo->StResInfo = (XGI_StResInfoStruct *) XGI330_StResInfo ;
246 pVBInfo->ModeResInfo = (XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
247
248 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
249 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
250 pVBInfo->pSR07 = &XGI330_SR07 ;
251 pVBInfo->LCDResInfo = 0 ;
252 pVBInfo->LCDTypeInfo = 0 ;
253 pVBInfo->LCDInfo = 0 ;
254 pVBInfo->VBInfo = 0 ;
255 pVBInfo->TVInfo = 0;
256
257
258 pVBInfo->SR15 = XGI340_SR13 ;
259 pVBInfo->CR40 = XGI340_cr41 ;
260 pVBInfo->SR25 = XGI330_sr25 ;
261 pVBInfo->pSR31 = &XGI330_sr31 ;
262 pVBInfo->pSR32 = &XGI330_sr32 ;
263 pVBInfo->CR6B = XGI340_CR6B ;
264 pVBInfo->CR6E = XGI340_CR6E ;
265 pVBInfo->CR6F = XGI340_CR6F ;
266 pVBInfo->CR89 = XGI340_CR89 ;
267 pVBInfo->AGPReg = XGI340_AGPReg ;
268 pVBInfo->SR16 = XGI340_SR16 ;
269 pVBInfo->pCRCF = &XG40_CRCF ;
270 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
271
272
273 pVBInfo->CR49 = XGI330_CR49 ;
274 pVBInfo->pSR1F = &XGI330_SR1F ;
275 pVBInfo->pSR21 = &XGI330_SR21 ;
276 pVBInfo->pSR22 = &XGI330_SR22 ;
277 pVBInfo->pSR23 = &XGI330_SR23 ;
278 pVBInfo->pSR24 = &XGI330_SR24 ;
279 pVBInfo->pSR33 = &XGI330_SR33 ;
280
281
282
283 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
284 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
285 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
286 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
287 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
288 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
289 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
290 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
291 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
292 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
293
294 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
295 pVBInfo->PALTiming = XGI330_PALTiming ;
296 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
297 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
298 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
299 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
300 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
301 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
302 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
303 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
304 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
305 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
306 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
307 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
308
309
310 pVBInfo->TimingH = (XGI_TimingHStruct *) XGI_TimingH ;
311 pVBInfo->TimingV = (XGI_TimingVStruct *) XGI_TimingV ;
312 pVBInfo->UpdateCRT1 = (XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
313
314 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
315 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
316 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
317 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
318
319 /* 310 customization related */
320 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
321 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
322 else
323 pVBInfo->LCDCapList = XGI_LCDCapList ;
324
325 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
326 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
327
328 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
329 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
330
331
332 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
333
334 if ( ChipType >= XG20 )
335 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
336
337 if ( ChipType == XG27 )
338 {
339 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI27New_MCLKData ;
340 pVBInfo->CR40 = XGI27_cr41 ;
341 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
342 pVBInfo->pSR36 = &XG27_SR36 ;
343 pVBInfo->pCR8F = &XG27_CR8F ;
344 pVBInfo->pCRD0 = XG27_CRD0 ;
345 pVBInfo->pCRDE = XG27_CRDE ;
346 pVBInfo->pSR40 = &XG27_SR40 ;
347 pVBInfo->pSR41 = &XG27_SR41 ;
348
349 }
350
351 if ( ChipType >= XG20 )
352 {
353 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
354 pVBInfo->pCR2E = &XG21_CR2E ;
355 pVBInfo->pCR2F = &XG21_CR2F ;
356 pVBInfo->pCR46 = &XG21_CR46 ;
357 pVBInfo->pCR47 = &XG21_CR47 ;
358 }
359
360 }
361
362
363
364
365
366
367 /* --------------------------------------------------------------------- */
368 /* Function : XGISetModeNew */
369 /* Input : */
370 /* Output : */
371 /* Description : */
372 /* --------------------------------------------------------------------- */
373 BOOLEAN XGISetModeNew( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo )
374 {
375 USHORT ModeIdIndex ;
376 /* PUCHAR pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
377 VB_DEVICE_INFO VBINF;
378 PVB_DEVICE_INFO pVBInfo = &VBINF;
379 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
380 pVBInfo->BaseAddr = (ULONG)HwDeviceExtension->pjIOAddress ;
381 pVBInfo->IF_DEF_LVDS = 0 ;
382 pVBInfo->IF_DEF_CH7005 = 0 ;
383 pVBInfo->IF_DEF_LCDA = 1 ;
384 pVBInfo->IF_DEF_CH7017 = 0 ;
385 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
386 pVBInfo->IF_DEF_VideoCapture = 0 ;
387 pVBInfo->IF_DEF_ScaleLCD = 0 ;
388 pVBInfo->IF_DEF_OEMUtil = 0 ;
389 pVBInfo->IF_DEF_PWD = 0 ;
390
391
392 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
393 {
394 pVBInfo->IF_DEF_YPbPr = 0 ;
395 pVBInfo->IF_DEF_HiVision = 0 ;
396 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
397 pVBInfo->VBType = 0 ; /*set VBType default 0*/
398 }
399 else if ( HwDeviceExtension->jChipType >= XG40 )
400 {
401 pVBInfo->IF_DEF_YPbPr = 1 ;
402 pVBInfo->IF_DEF_HiVision = 1 ;
403 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
404 }
405 else
406 {
407 pVBInfo->IF_DEF_YPbPr = 1 ;
408 pVBInfo->IF_DEF_HiVision = 1 ;
409 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
410 }
411
412 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
413 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
414 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
415 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
416 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
417 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
418 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
419 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
420 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
421 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
422 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
423 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
424 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
425 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
426 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
427 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
428 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
429 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
430
431 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
432 {
433 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
434 {
435 pVBInfo->IF_DEF_LVDS = 1 ;
436 }
437 }
438 if ( HwDeviceExtension->jChipType == XG27 )
439 {
440 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
441 {
442 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
443 {
444 pVBInfo->IF_DEF_LVDS = 1 ;
445 }
446 }
447 }
448
449 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
450 XGI_GetVBType( pVBInfo ) ;
451
452 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
453 if ( ModeNo & 0x80 )
454 {
455 ModeNo = ModeNo & 0x7F ;
456 /* XGINew_flag_clearbuffer = 0 ; */
457 }
458 /* else
459 {
460 XGINew_flag_clearbuffer = 1 ;
461 }
462 */
463 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
464
465 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
466 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
467
468 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
469
470 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
471
472 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
473 {
474 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
475 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
476 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
477 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
478 /* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
479
480 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
481 {
482 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
483
484 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
485 {
486 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
487 }
488 }
489 else
490 {
491 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
492 {
493 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
494 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
495 {
496 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
497 }
498 }
499 }
500
501 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
502 {
503 switch( HwDeviceExtension->ujVBChipID )
504 {
505 case VB_CHIP_301:
506 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
507 break ;
508
509 case VB_CHIP_302:
510 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
511 break ;
512
513 default:
514 break ;
515 }
516 }
517
518 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
519 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
520 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
521 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
522 } /* !XG20 */
523 else
524 {
525
526
527 if ( pVBInfo->IF_DEF_LVDS == 1 )
528 {
529 if ( !XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo) )
530 {
531 return FALSE;
532 }
533 }
534
535 if ( ModeNo <= 0x13 )
536 {
537 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
538 }
539 else
540 {
541 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
542 }
543
544 pVBInfo->SetFlag = 0 ;
545 if ( pVBInfo->IF_DEF_CH7007 != 1 )
546 {
547 pVBInfo->VBInfo = DisableCRT2Display ;
548 }
549
550
551 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
552
553 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
554
555 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
556 /*
557 if( HwDeviceExtension->jChipType == XG21 )
558 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
559 */
560 }
561
562
563 /*
564 if ( ModeNo <= 0x13 )
565 {
566 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
567 }
568 else
569 {
570 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
571 }
572 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
573 pVBInfo->SetFlag = 0x00 ;
574 pVBInfo->VBInfo = DisableCRT2Display ;
575 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
576
577 if ( temp == 0 )
578 return( 0 ) ;
579
580 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
581 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
582 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
583 */
584
585 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
586
587 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
588 {
589 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
590 }
591
592 return( TRUE ) ;
593 }
594
595
596 /* --------------------------------------------------------------------- */
597 /* Function : XGI_SetCRT1Group */
598 /* Input : */
599 /* Output : */
600 /* Description : */
601 /* --------------------------------------------------------------------- */
602 void XGI_SetCRT1Group( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
603 {
604 USHORT StandTableIndex ,
605 RefreshRateTableIndex ,
606 b3CC ,
607 temp ;
608
609 USHORT XGINew_P3cc = pVBInfo->P3cc;
610
611 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
612 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
613 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
614 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
615 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
616 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
617 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
618 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
619 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
620 XGI_ClearExt1Regs(pVBInfo) ;
621
622 /* if ( pVBInfo->IF_DEF_ExpLink ) */
623 if ( HwDeviceExtension->jChipType == XG27 )
624 {
625 if ( pVBInfo->IF_DEF_LVDS == 0 )
626 {
627 XGI_SetDefaultVCLK( pVBInfo ) ;
628 }
629 }
630
631 temp = ~ProgrammingCRT2 ;
632 pVBInfo->SetFlag &= temp ;
633 pVBInfo->SelectCRT2Rate = 0 ;
634
635 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
636 {
637 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
638 {
639 pVBInfo->SetFlag |= ProgrammingCRT2 ;
640 }
641 }
642
643 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
644 if ( RefreshRateTableIndex != 0xFFFF )
645 {
646 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
647 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
648 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
649 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
650 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
651 }
652
653 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
654 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
655 {
656 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
657 {
658 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
659 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
660 b3CC =(UCHAR) XGINew_GetReg2(XGINew_P3cc) ;
661 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
662 }
663 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
664 {
665 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
666 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
667 b3CC = (UCHAR)XGINew_GetReg2(XGINew_P3cc) ;
668 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
669 }
670 }
671
672 if ( HwDeviceExtension->jChipType >= XG21 )
673 {
674 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
675 if ( temp & 0xA0 )
676 {
677
678 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
679 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
680 /* XG21 CRT1 Timing */
681 if ( HwDeviceExtension->jChipType == XG27 )
682 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
683 else
684 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
685
686 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
687
688 if ( HwDeviceExtension->jChipType == XG27 )
689 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
690 else
691 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
692
693 if ( pVBInfo->IF_DEF_LVDS == 1 )
694 {
695 if ( HwDeviceExtension->jChipType == XG27 )
696 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
697 else
698 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
699 }
700 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
701 }
702 }
703
704 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
705 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
706 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
707
708
709 /* XGI_LoadCharacter(); //dif ifdef TVFont */
710
711 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
712 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
713 }
714
715
716 /* --------------------------------------------------------------------- */
717 /* Function : XGI_GetModePtr */
718 /* Input : */
719 /* Output : */
720 /* Description : */
721 /* --------------------------------------------------------------------- */
722 UCHAR XGI_GetModePtr( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
723 {
724 UCHAR index ;
725
726 if ( ModeNo <= 0x13 )
727 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
728 else
729 {
730 if ( pVBInfo->ModeType <= 0x02 )
731 index = 0x1B ; /* 02 -> ModeEGA */
732 else
733 index = 0x0F ;
734 }
735 return( index ) ; /* Get pVBInfo->StandTable index */
736 }
737
738
739 /* --------------------------------------------------------------------- */
740 /* Function : XGI_SetBIOSData */
741 /* Input : */
742 /* Output : */
743 /* Description : */
744 /* --------------------------------------------------------------------- */
745 /*UCHAR XGI_SetBIOSData( USHORT ModeNo , USHORT ModeIdIndex )
746 {
747 return( 0 ) ;
748 }
749 */
750
751 /* --------------------------------------------------------------------- */
752 /* Function : XGI_ClearBankRegs */
753 /* Input : */
754 /* Output : */
755 /* Description : */
756 /* --------------------------------------------------------------------- */
757 /*UCHAR XGI_ClearBankRegs( USHORT ModeNo , USHORT ModeIdIndex )
758 {
759 return( 0 ) ;
760 }
761 */
762
763 /* --------------------------------------------------------------------- */
764 /* Function : XGI_SetSeqRegs */
765 /* Input : */
766 /* Output : */
767 /* Description : */
768 /* --------------------------------------------------------------------- */
769 void XGI_SetSeqRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
770 {
771 UCHAR tempah ,
772 SRdata ;
773
774 USHORT i ,
775 modeflag ;
776
777 if ( ModeNo <= 0x13 )
778 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
779 else
780 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
781
782 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
783 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
784
785 i = SetCRT2ToLCDA ;
786 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
787 {
788 tempah |= 0x01 ;
789 }
790 else
791 {
792 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
793 {
794 if ( pVBInfo->VBInfo & SetInSlaveMode )
795 tempah |= 0x01 ;
796 }
797 }
798
799 tempah |= 0x20 ; /* screen off */
800 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
801
802 for( i = 02 ; i <= 04 ; i++ )
803 {
804 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
805 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
806 }
807 }
808
809
810 /* --------------------------------------------------------------------- */
811 /* Function : XGI_SetMiscRegs */
812 /* Input : */
813 /* Output : */
814 /* Description : */
815 /* --------------------------------------------------------------------- */
816 void XGI_SetMiscRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
817 {
818 UCHAR Miscdata ;
819
820 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
821 /*
822 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
823 {
824 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
825 {
826 Miscdata |= 0x0C ;
827 }
828 }
829 */
830
831 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
832 }
833
834
835 /* --------------------------------------------------------------------- */
836 /* Function : XGI_SetCRTCRegs */
837 /* Input : */
838 /* Output : */
839 /* Description : */
840 /* --------------------------------------------------------------------- */
841 void XGI_SetCRTCRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
842 {
843 UCHAR CRTCdata ;
844 USHORT i ;
845
846 CRTCdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
847 CRTCdata &= 0x7f ;
848 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
849
850 for( i = 0 ; i <= 0x18 ; i++ )
851 {
852 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
853 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
854 }
855 /*
856 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
857 {
858 if ( pVBInfo->VBInfo & SetInSlaveMode )
859 {
860 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
861 {
862 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
863 }
864 }
865 }
866 */
867 }
868
869
870 /* --------------------------------------------------------------------- */
871 /* Function : */
872 /* Input : */
873 /* Output : */
874 /* Description : */
875 /* --------------------------------------------------------------------- */
876 void XGI_SetATTRegs( USHORT ModeNo , USHORT StandTableIndex , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
877 {
878 UCHAR ARdata ;
879 USHORT i ,
880 modeflag ;
881
882 if ( ModeNo <= 0x13 )
883 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
884 else
885 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
886
887 for( i = 0 ; i <= 0x13 ; i++ )
888 {
889 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
890 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
891 {
892 if ( i == 0x13 )
893 {
894 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
895 ARdata = 0 ;
896 else
897 {
898 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
899 {
900 if ( pVBInfo->VBInfo & SetInSlaveMode )
901 ARdata = 0 ;
902 }
903 }
904 }
905 }
906
907 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
908 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
909 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
910 }
911
912 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
913 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
914 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
915 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
916 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
917 }
918
919
920 /* --------------------------------------------------------------------- */
921 /* Function : XGI_SetGRCRegs */
922 /* Input : */
923 /* Output : */
924 /* Description : */
925 /* --------------------------------------------------------------------- */
926 void XGI_SetGRCRegs( USHORT StandTableIndex, PVB_DEVICE_INFO pVBInfo )
927 {
928 UCHAR GRdata ;
929 USHORT i ;
930
931 for( i = 0 ; i <= 0x08 ; i++ )
932 {
933 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
934 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
935 }
936
937 if ( pVBInfo->ModeType > ModeVGA )
938 {
939 GRdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3ce , 0x05 ) ;
940 GRdata &= 0xBF ; /* 256 color disable */
941 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
942 }
943 }
944
945
946 /* --------------------------------------------------------------------- */
947 /* Function : XGI_ClearExt1Regs */
948 /* Input : */
949 /* Output : */
950 /* Description : */
951 /* --------------------------------------------------------------------- */
952 void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo)
953 {
954 USHORT i ;
955
956 for( i = 0x0A ; i <= 0x0E ; i++ )
957 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
958 }
959
960
961 /* --------------------------------------------------------------------- */
962 /* Function : XGI_SetDefaultVCLK */
963 /* Input : */
964 /* Output : */
965 /* Description : */
966 /* --------------------------------------------------------------------- */
967 UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo )
968 {
969
970 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
971 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
972 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
973
974 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
975 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
976 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
977
978 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
979 return( 0 ) ;
980 }
981
982
983 /* --------------------------------------------------------------------- */
984 /* Function : XGI_GetRatePtrCRT2 */
985 /* Input : */
986 /* Output : */
987 /* Description : */
988 /* --------------------------------------------------------------------- */
989 USHORT XGI_GetRatePtrCRT2( PXGI_HW_DEVICE_INFO pXGIHWDE, USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
990 {
991 SHORT LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
992 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
993
994 USHORT RefreshRateTableIndex , i ,
995 modeflag , index , temp ;
996
997 if ( ModeNo <= 0x13 )
998 {
999 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1000 }
1001 else
1002 {
1003 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1004 }
1005
1006 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1007 {
1008 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1009 {
1010 if ( modeflag & HalfDCLK )
1011 return( 0 ) ;
1012 }
1013 }
1014
1015 if ( ModeNo < 0x14 )
1016 return( 0xFFFF ) ;
1017
1018 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1019 index = index >> pVBInfo->SelectCRT2Rate ;
1020 index &= 0x0F ;
1021
1022 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1023 index = 0 ;
1024
1025 if ( index > 0 )
1026 index-- ;
1027
1028 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1029 {
1030 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1031 {
1032 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1033 {
1034 index = 0 ;
1035 }
1036 }
1037
1038 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1039 {
1040 if( pVBInfo->IF_DEF_LVDS == 0 )
1041 {
1042 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1043 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1044 else
1045 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1046
1047 if ( index > temp )
1048 {
1049 index = temp ;
1050 }
1051 }
1052 else
1053 {
1054 index = 0 ;
1055 }
1056 }
1057 }
1058
1059 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1060 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1061 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1062 {
1063 /*
1064 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1065 {
1066 index++;
1067 }
1068 */
1069 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1070 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1071 {
1072 index++;
1073 }
1074 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1075 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1076 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1077 {
1078 index++;
1079 }
1080 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1081 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1082 {
1083 index++;
1084 }
1085 }
1086
1087 i = 0 ;
1088 do
1089 {
1090 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1091 break ;
1092 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1093 temp &= ModeInfoFlag ;
1094 if ( temp < pVBInfo->ModeType )
1095 break ;
1096 i++ ;
1097 index-- ;
1098
1099 } while( index != 0xFFFF ) ;
1100 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1101 {
1102 if ( pVBInfo->VBInfo & SetInSlaveMode )
1103 {
1104 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1105 if ( temp & InterlaceMode )
1106 {
1107 i++ ;
1108 }
1109 }
1110 }
1111 i-- ;
1112 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1113 {
1114 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1115 }
1116 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1117 }
1118
1119
1120 /* --------------------------------------------------------------------- */
1121 /* Function : XGI_AjustCRT2Rate */
1122 /* Input : */
1123 /* Output : */
1124 /* Description : */
1125 /* --------------------------------------------------------------------- */
1126 BOOLEAN XGI_AjustCRT2Rate( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , USHORT *i, PVB_DEVICE_INFO pVBInfo )
1127 {
1128 USHORT tempax ,
1129 tempbx ,
1130 resinfo ,
1131 modeflag ,
1132 infoflag ;
1133
1134 if ( ModeNo <= 0x13 )
1135 {
1136 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1137 }
1138 else
1139 {
1140 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1141 }
1142
1143 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1144 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1145 tempax = 0 ;
1146
1147 if ( pVBInfo->IF_DEF_LVDS == 0 )
1148 {
1149 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1150 {
1151 tempax |= SupportRAMDAC2 ;
1152
1153 if ( pVBInfo->VBType & VB_XGI301C )
1154 tempax |= SupportCRT2in301C ;
1155 }
1156
1157 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1158 {
1159 tempax |= SupportLCD ;
1160
1161 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1162 {
1163 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1164 {
1165 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1166 {
1167 if ( resinfo >= 9 )
1168 {
1169 tempax = 0 ;
1170 return( 0 ) ;
1171 }
1172 }
1173 }
1174 }
1175 }
1176
1177 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1178 {
1179 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1180 {
1181 tempax |= SupportYPbPr ;
1182 if ( pVBInfo->VBInfo & SetInSlaveMode )
1183 {
1184 if ( resinfo == 4 )
1185 return( 0 ) ;
1186
1187 if ( resinfo == 3 )
1188 return( 0 ) ;
1189
1190 if ( resinfo > 7 )
1191 return( 0 ) ;
1192 }
1193 }
1194 else
1195 {
1196 tempax |= SupportHiVisionTV ;
1197 if ( pVBInfo->VBInfo & SetInSlaveMode )
1198 {
1199 if ( resinfo == 4 )
1200 return( 0 ) ;
1201
1202 if ( resinfo == 3 )
1203 {
1204 if ( pVBInfo->SetFlag & TVSimuMode )
1205 return( 0 ) ;
1206 }
1207
1208 if ( resinfo > 7 )
1209 return( 0 ) ;
1210 }
1211 }
1212 }
1213 else
1214 {
1215 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1216 {
1217 tempax |= SupportTV ;
1218
1219 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1220 {
1221 tempax |= SupportTV1024 ;
1222 }
1223
1224 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1225 {
1226 if ( modeflag & NoSupportSimuTV )
1227 {
1228 if ( pVBInfo->VBInfo & SetInSlaveMode )
1229 {
1230 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1231 {
1232 return( 0 ) ;
1233 }
1234 }
1235 }
1236 }
1237 }
1238 }
1239 }
1240 else /* for LVDS */
1241 {
1242 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1243 {
1244 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1245 {
1246 tempax |= SupportCHTV ;
1247 }
1248 }
1249
1250 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1251 {
1252 tempax |= SupportLCD ;
1253
1254 if ( resinfo > 0x08 )
1255 return( 0 ) ; /* 1024x768 */
1256
1257 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1258 {
1259 if ( resinfo > 0x07 )
1260 return( 0 ) ; /* 800x600 */
1261
1262 if ( resinfo == 0x04 )
1263 return( 0 ) ; /* 512x384 */
1264 }
1265 }
1266 }
1267
1268 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1269 {
1270 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1271 if ( infoflag & tempax )
1272 {
1273 return( 1 ) ;
1274 }
1275 if ( ( *i ) == 0 )
1276 break ;
1277 }
1278
1279 for( ( *i ) = 0 ; ; ( *i )++ )
1280 {
1281 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1282 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1283 {
1284 return( 0 ) ;
1285 }
1286
1287 if ( infoflag & tempax )
1288 {
1289 return( 1 ) ;
1290 }
1291 }
1292 return( 1 ) ;
1293 }
1294
1295
1296 /* --------------------------------------------------------------------- */
1297 /* Function : XGI_SetSync */
1298 /* Input : */
1299 /* Output : */
1300 /* Description : */
1301 /* --------------------------------------------------------------------- */
1302 void XGI_SetSync(USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1303 {
1304 USHORT sync ,
1305 temp ;
1306
1307 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1308 sync &= 0xC0 ;
1309 temp = 0x2F ;
1310 temp |= sync ;
1311 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1312 }
1313
1314
1315 /* --------------------------------------------------------------------- */
1316 /* Function : XGI_SetCRT1CRTC */
1317 /* Input : */
1318 /* Output : */
1319 /* Description : */
1320 /* --------------------------------------------------------------------- */
1321 void XGI_SetCRT1CRTC( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1322 {
1323 UCHAR index ,
1324 data ;
1325
1326 USHORT i ;
1327
1328 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1329 index = index&IndexMask ;
1330
1331 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1332 data &= 0x7F ;
1333 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1334
1335 for( i = 0 ; i < 8 ; i++ )
1336 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1337
1338 for( i = 0 ; i < 7 ; i++ )
1339 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1340
1341 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1342
1343
1344
1345 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1346
1347
1348 if( pVBInfo->ModeType > 0x03 )
1349 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1350 }
1351
1352
1353 /* --------------------------------------------------------------------- */
1354 /* Function : XGI_SetCRT1Timing_H */
1355 /* Input : */
1356 /* Output : */
1357 /* Description : */
1358 /* --------------------------------------------------------------------- */
1359 void XGI_SetCRT1Timing_H( PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1360 {
1361 UCHAR data , data1, pushax;
1362 USHORT i , j ;
1363
1364 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1365 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1366 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1367
1368 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ; /* unlock cr0-7 */
1369 data &= 0x7F ;
1370 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1371
1372 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1373 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1374
1375 for( i = 0x01 ; i <= 0x04 ; i++ )
1376 {
1377 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
1378 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 1 ) , data ) ;
1379 }
1380
1381 for( i = 0x05 ; i <= 0x06 ; i++ )
1382 {
1383 data = pVBInfo->TimingH[ 0 ].data[ i ];
1384 XGINew_SetReg1( pVBInfo->P3c4 ,( USHORT )( i + 6 ) , data ) ;
1385 }
1386
1387 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1388 j &= 0x1F ;
1389 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1390 data &= 0xE0 ;
1391 data |= j ;
1392 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1393
1394 if ( HwDeviceExtension->jChipType >= XG20 )
1395 {
1396 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x04 ) ;
1397 data = data - 1 ;
1398 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1399 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x05 ) ;
1400 data1 = data ;
1401 data1 &= 0xE0 ;
1402 data &= 0x1F ;
1403 if ( data == 0 )
1404 {
1405 pushax = data ;
1406 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0c ) ;
1407 data &= 0xFB ;
1408 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1409 data = pushax ;
1410 }
1411 data = data - 1 ;
1412 data |= data1 ;
1413 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1414 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1415 data = data >> 5 ;
1416 data = data + 3 ;
1417 if ( data > 7 )
1418 data = data - 7 ;
1419 data = data << 5 ;
1420 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1421 }
1422 }
1423
1424
1425 /* --------------------------------------------------------------------- */
1426 /* Function : XGI_SetCRT1Timing_V */
1427 /* Input : */
1428 /* Output : */
1429 /* Description : */
1430 /* --------------------------------------------------------------------- */
1431 void XGI_SetCRT1Timing_V( USHORT ModeIdIndex , USHORT ModeNo,PVB_DEVICE_INFO pVBInfo )
1432 {
1433 UCHAR data ;
1434 USHORT i , j ;
1435
1436 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1437 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1438 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1439
1440 for( i = 0x00 ; i <= 0x01 ; i++ )
1441 {
1442 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1443 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 6 ) , data ) ;
1444 }
1445
1446 for( i = 0x02 ; i <= 0x03 ; i++ )
1447 {
1448 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1449 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x0e ) , data ) ;
1450 }
1451
1452 for( i = 0x04 ; i <= 0x05 ; i++ )
1453 {
1454 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
1455 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 0x11 ) , data ) ;
1456 }
1457
1458 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0a ) ;
1459 j &= 0xC0 ;
1460 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1461 data &= 0x3F ;
1462 data |= j ;
1463 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1464
1465 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1466 data &= 0x80 ;
1467 data = data >> 2 ;
1468
1469 if ( ModeNo <= 0x13 )
1470 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1471 else
1472 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1473
1474 i &= DoubleScanMode ;
1475 if ( i )
1476 data |= 0x80 ;
1477
1478 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x09 ) ;
1479 j &= 0x5F ;
1480 data |= j ;
1481 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1482 }
1483
1484
1485 /* --------------------------------------------------------------------- */
1486 /* Function : XGI_SetXG21CRTC */
1487 /* Input : Stand or enhance CRTC table */
1488 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1489 /* Description : Set LCD timing */
1490 /* --------------------------------------------------------------------- */
1491 void XGI_SetXG21CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1492 {
1493 UCHAR StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1494 USHORT Temp1, Temp2, Temp3 ;
1495
1496 if ( ModeNo <= 0x13 )
1497 {
1498 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1499 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1500 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1501 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1502 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1503 Tempcx = Tempax ;
1504 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1505 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1506 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1507 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1508 Tempdx <<= 2 ; /* Tempdx << 2 */
1509 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1510 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1511
1512 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1513 Tempbx = Tempax ; /* Tempbx=Tempax */
1514 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1515 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1516 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1517 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1518 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1519 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1520 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1521 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1522
1523 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] UCHAR -> USHORT */
1524 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1525 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1526 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1527 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1528
1529 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1530 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1531 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1532 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1533 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1534 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1535 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1536 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1537 Tempax = (UCHAR)Temp2 ; /* Tempax[7:0]: VRE[7:0] */
1538 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1539 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1540 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1541 Tempbx = (UCHAR)Temp1 ; /* Tempbx[1:0]: VRS[10:9] */
1542 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1543 Tempax &= 0x7F ;
1544 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1545 }
1546 else
1547 {
1548 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1549 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1550 Tempcx = Tempax ; /* Tempcx: HRS */
1551 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1552
1553 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1554 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1555 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1556 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1557 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1558
1559 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1560 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1561
1562 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1563 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1564 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1565 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1566
1567 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1568 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1569
1570 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1571 if( Tempax < Tempcx ) /* HRE < HRS */
1572 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1573
1574 Temp2 &= 0xFF ;
1575 Tempax = (UCHAR)Temp2 ; /* Tempax: HRE[7:0] */
1576 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1577 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1578 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1579 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1580 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1581
1582 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1583 Tempbx = Tempax ; /* Tempbx: VRS */
1584 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1585 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1586 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1587 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1588 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1589 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1590 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1591 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1592
1593 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1594 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1595 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1596 Tempax &= 0x80 ;
1597 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1598 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1599 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1600 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1601 Temp2 = Tempax ;
1602 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1603 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1604
1605 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1606 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1607 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1608 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1609 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1610 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1611 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1612 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1613
1614 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1615 if ( Tempax < Temp3 ) /* VRE < VRS */
1616 Temp2 |= 0x20 ; /* VRE + 0x20 */
1617
1618 Temp2 &= 0xFF ;
1619 Tempax = (UCHAR)Temp2 ; /* Tempax: VRE[7:0] */
1620 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1621 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1622 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1623 Tempbx = (UCHAR)Temp1 ;
1624 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1625 Tempax &= 0x7F ;
1626 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1627 }
1628 }
1629
1630 void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
1631 {
1632 USHORT StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
1633
1634 if ( ModeNo <= 0x13 )
1635 {
1636 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1637 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1638 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1639 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1640 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1641 Tempcx = Tempax ;
1642 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1643 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1644 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1645 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1646 Tempdx <<= 2 ; /* Tempdx << 2 */
1647 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1648 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1649
1650 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1651 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1652 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1653 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1654 Tempbx = Tempax ; /* Tempbx=CR07 */
1655 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1656 Tempax >>= 2;
1657 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1658 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1659 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1660
1661
1662 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1663 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1664 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1665 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1666 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1667 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1668 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1669 Tempax = (UCHAR)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1670 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1671 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1672 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1673 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1674 }
1675 else
1676 {
1677 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1678 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1679 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1680 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1681
1682 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1683 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1684 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1685
1686 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1687 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1688 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1689
1690 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1691 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1692 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1693 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1694
1695 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1696 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1697
1698 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1699 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1700 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1701 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1702
1703 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1704 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1705 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1706 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1707 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1708 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1709
1710 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1711 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1712
1713 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1714 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1715 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1716 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1717 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1718 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1719 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1720 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1721 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1722 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1723 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1724
1725
1726 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1727 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1728 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1729 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1730 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1731 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1732 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1733 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1734 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1735
1736 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1737 Tempbx |= 0x20 ; /* VRE + 0x20 */
1738
1739 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1740 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1741 Tempax = Tempcx >> 8;
1742 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1743 }
1744 }
1745
1746
1747 /* --------------------------------------------------------------------- */
1748 /* Function : XGI_SetXG21LCD */
1749 /* Input : */
1750 /* Output : FCLK duty cycle, FCLK delay compensation */
1751 /* Description : All values set zero */
1752 /* --------------------------------------------------------------------- */
1753 void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1754 {
1755 USHORT Data , Temp , b3CC ;
1756 USHORT XGI_P3cc ;
1757
1758 XGI_P3cc = pVBInfo->P3cc ;
1759
1760 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1761 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1762 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1763 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1764 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1765 {
1766 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1767 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1768 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1769 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1770 }
1771
1772 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1773
1774 if ( Temp & 0x01 )
1775 {
1776 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1777 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1778 }
1779
1780 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1781
1782 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1783 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1784
1785 if ( ModeNo <= 0x13 )
1786 {
1787 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1788 if ( b3CC & 0x40 )
1789 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1790 if ( b3CC & 0x80 )
1791 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1792 }
1793 else
1794 {
1795 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1796 if ( Data & 0x4000 )
1797 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1798 if ( Data & 0x8000 )
1799 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1800 }
1801 }
1802
1803 void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
1804 {
1805 USHORT Data , Temp , b3CC ;
1806 USHORT XGI_P3cc ;
1807
1808 XGI_P3cc = pVBInfo->P3cc ;
1809
1810 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1811 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1812 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1813 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1814
1815 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1816 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1817 {
1818 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1819 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1820 }
1821
1822 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1823 {
1824 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1825 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1826 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1827 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1828 }
1829
1830 XGI_SetXG27FPBits(pVBInfo);
1831
1832 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1833
1834 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1835 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1836
1837 if ( ModeNo <= 0x13 )
1838 {
1839 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1840 if ( b3CC & 0x40 )
1841 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1842 if ( b3CC & 0x80 )
1843 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1844 }
1845 else
1846 {
1847 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1848 if ( Data & 0x4000 )
1849 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1850 if ( Data & 0x8000 )
1851 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1852 }
1853 }
1854
1855 /* --------------------------------------------------------------------- */
1856 /* Function : XGI_UpdateXG21CRTC */
1857 /* Input : */
1858 /* Output : CRT1 CRTC */
1859 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1860 /* --------------------------------------------------------------------- */
1861 void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT RefreshRateTableIndex )
1862 {
1863 int i , index = -1;
1864
1865 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1866 if ( ModeNo <= 0x13 )
1867 {
1868 for( i = 0 ; i < 12 ; i++ )
1869 {
1870 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1871 index = i ;
1872 }
1873 }
1874 else
1875 {
1876 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1877 index = 12 ;
1878 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1879 index = 13 ;
1880 else if ( ModeNo == 0x2F )
1881 index = 14 ;
1882 else if ( ModeNo == 0x50 )
1883 index = 15 ;
1884 else if ( ModeNo == 0x59 )
1885 index = 16 ;
1886 }
1887
1888 if( index != -1 )
1889 {
1890 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1891 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1892 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1893 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1894 }
1895 }
1896
1897
1898 /* --------------------------------------------------------------------- */
1899 /* Function : XGI_SetCRT1DE */
1900 /* Input : */
1901 /* Output : */
1902 /* Description : */
1903 /* --------------------------------------------------------------------- */
1904 void XGI_SetCRT1DE( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo,USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
1905 {
1906 USHORT resindex ,
1907 tempax ,
1908 tempbx ,
1909 tempcx ,
1910 temp ,
1911 modeflag ;
1912
1913 UCHAR data ;
1914
1915 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1916
1917 if ( ModeNo <= 0x13 )
1918 {
1919 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1920 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1921 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1922 }
1923 else
1924 {
1925 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1926 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1927 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1928 }
1929
1930 if ( modeflag & HalfDCLK )
1931 tempax = tempax >> 1 ;
1932
1933 if ( ModeNo > 0x13 )
1934 {
1935 if ( modeflag & HalfDCLK )
1936 tempax = tempax << 1 ;
1937
1938 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1939
1940 if ( temp & InterlaceMode )
1941 tempbx = tempbx >> 1 ;
1942
1943 if ( modeflag & DoubleScanMode )
1944 tempbx = tempbx << 1 ;
1945 }
1946
1947 tempcx = 8 ;
1948
1949 /* if ( !( modeflag & Charx8Dot ) ) */
1950 /* tempcx = 9 ; */
1951
1952 tempax /= tempcx ;
1953 tempax -= 1 ;
1954 tempbx -= 1 ;
1955 tempcx = tempax ;
1956 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1957 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1958 data &= 0x7F ;
1959 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
1960 XGINew_SetReg1( pVBInfo->P3d4 , 0x01 , ( USHORT )( tempcx & 0xff ) ) ;
1961 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x0b , ~0x0c , ( USHORT )( ( tempcx & 0x0ff00 ) >> 10 ) ) ;
1962 XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , ( USHORT )( tempbx & 0xff ) ) ;
1963 tempax = 0 ;
1964 tempbx = tempbx >> 8 ;
1965
1966 if ( tempbx & 0x01 )
1967 tempax |= 0x02 ;
1968
1969 if ( tempbx & 0x02 )
1970 tempax |= 0x40 ;
1971
1972 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
1973 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x07 ) ;
1974 data &= 0xFF ;
1975 tempax = 0 ;
1976
1977 if ( tempbx & 0x04 )
1978 tempax |= 0x02 ;
1979
1980 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
1981 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
1982 }
1983
1984
1985 /* --------------------------------------------------------------------- */
1986 /* Function : XGI_GetResInfo */
1987 /* Input : */
1988 /* Output : */
1989 /* Description : */
1990 /* --------------------------------------------------------------------- */
1991 USHORT XGI_GetResInfo(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
1992 {
1993 USHORT resindex ;
1994
1995 if ( ModeNo <= 0x13 )
1996 {
1997 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
1998 }
1999 else
2000 {
2001 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2002 }
2003 return( resindex ) ;
2004 }
2005
2006
2007 /* --------------------------------------------------------------------- */
2008 /* Function : XGI_SetCRT1Offset */
2009 /* Input : */
2010 /* Output : */
2011 /* Description : */
2012 /* --------------------------------------------------------------------- */
2013 void XGI_SetCRT1Offset( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2014 {
2015 USHORT temp ,
2016 ah ,
2017 al ,
2018 temp2 ,
2019 i ,
2020 DisplayUnit ;
2021
2022 /* GetOffset */
2023 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2024 temp = temp >> 8 ;
2025 temp = pVBInfo->ScreenOffset[ temp ] ;
2026
2027 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2028 temp2 &= InterlaceMode ;
2029
2030 if ( temp2 )
2031 temp = temp << 1;
2032
2033 temp2 = pVBInfo->ModeType - ModeEGA ;
2034
2035 switch( temp2 )
2036 {
2037 case 0:
2038 temp2 = 1 ;
2039 break ;
2040 case 1:
2041 temp2 = 2 ;
2042 break ;
2043 case 2:
2044 temp2 = 4 ;
2045 break ;
2046 case 3:
2047 temp2 = 4 ;
2048 break ;
2049 case 4:
2050 temp2 = 6 ;
2051 break;
2052 case 5:
2053 temp2 = 8 ;
2054 break ;
2055 default:
2056 break ;
2057 }
2058
2059 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2060 temp = temp * temp2 + temp2 / 2 ;
2061 else
2062 temp *= temp2 ;
2063
2064 /* SetOffset */
2065 DisplayUnit = temp ;
2066 temp2 = temp ;
2067 temp = temp >> 8 ; /* ah */
2068 temp &= 0x0F ;
2069 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2070 i &= 0xF0 ;
2071 i |= temp ;
2072 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2073
2074 temp =( UCHAR )temp2 ;
2075 temp &= 0xFF ; /* al */
2076 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2077
2078 /* SetDisplayUnit */
2079 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2080 temp2 &= InterlaceMode ;
2081 if ( temp2 )
2082 DisplayUnit >>= 1 ;
2083
2084 DisplayUnit = DisplayUnit << 5 ;
2085 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2086 al = DisplayUnit & 0x00ff ;
2087 if ( al == 0 )
2088 ah += 1 ;
2089 else
2090 ah += 2 ;
2091
2092 if ( HwDeviceExtension->jChipType >= XG20 )
2093 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2094 ah -= 1 ;
2095
2096 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2097 }
2098
2099
2100 /* --------------------------------------------------------------------- */
2101 /* Function : XGI_SetCRT1VCLK */
2102 /* Input : */
2103 /* Output : */
2104 /* Description : */
2105 /* --------------------------------------------------------------------- */
2106 void XGI_SetCRT1VCLK( USHORT ModeNo , USHORT ModeIdIndex ,
2107 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2108 {
2109 UCHAR index , data ;
2110 USHORT vclkindex ;
2111
2112 if ( pVBInfo->IF_DEF_LVDS == 1 )
2113 {
2114 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2115 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2116 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2117 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2118 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2119 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2120 }
2121 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2122 {
2123 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2124 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2125 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2126 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2127 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2128 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2129 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2130 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2131 }
2132 else
2133 {
2134 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2135 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2136 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2137 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2138 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2139 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2140 }
2141
2142 if ( HwDeviceExtension->jChipType >= XG20 )
2143 {
2144 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2145 {
2146 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2147 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2148 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2149 index = data ;
2150 index &= 0xE0 ;
2151 data &= 0x1F ;
2152 data = data << 1 ;
2153 data += 1 ;
2154 data |= index ;
2155 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2156 }
2157 }
2158 }
2159
2160
2161 /* --------------------------------------------------------------------- */
2162 /* Function : XGI_SetCRT1FIFO */
2163 /* Input : */
2164 /* Output : */
2165 /* Description : */
2166 /* --------------------------------------------------------------------- */
2167 void XGI_SetCRT1FIFO( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2168 {
2169 USHORT data ;
2170
2171 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2172 data &= 0xfe ;
2173 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2174
2175 if ( ModeNo > 0x13 )
2176 {
2177 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2178 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2179 data &= 0xC0 ;
2180 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2181 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2182 data |= 0x01 ;
2183 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2184 }
2185 else
2186 {
2187 if (HwDeviceExtension->jChipType == XG27)
2188 {
2189 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2190 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2191 data &= 0xC0 ;
2192 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2193 }
2194 else
2195 {
2196 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2197 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2198 data &= 0xF0 ;
2199 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2200 }
2201 }
2202
2203 if (HwDeviceExtension->jChipType == XG21)
2204 {
2205 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2206 }
2207 }
2208
2209
2210 /* --------------------------------------------------------------------- */
2211 /* Function : XGI_SetCRT1ModeRegs */
2212 /* Input : */
2213 /* Output : */
2214 /* Description : */
2215 /* --------------------------------------------------------------------- */
2216 void XGI_SetCRT1ModeRegs( PXGI_HW_DEVICE_INFO HwDeviceExtension ,
2217 USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2218 {
2219 USHORT data ,
2220 data2 ,
2221 data3 ,
2222 infoflag = 0 ,
2223 modeflag ,
2224 resindex ,
2225 xres ;
2226
2227 if ( ModeNo > 0x13 )
2228 {
2229 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2230 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2231 }
2232 else
2233 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2234
2235 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2236 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2237
2238 if ( ModeNo > 0x13 )
2239 data = infoflag ;
2240 else
2241 data = 0 ;
2242
2243 data2 = 0 ;
2244
2245 if ( ModeNo > 0x13 )
2246 {
2247 if ( pVBInfo->ModeType > 0x02 )
2248 {
2249 data2 |= 0x02 ;
2250 data3 = pVBInfo->ModeType - ModeVGA ;
2251 data3 = data3 << 2 ;
2252 data2 |= data3 ;
2253 }
2254 }
2255
2256 data &= InterlaceMode ;
2257
2258 if ( data )
2259 data2 |= 0x20 ;
2260
2261 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2262 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2263 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2264 if ( ModeNo <= 0x13 )
2265 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2266 else
2267 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2268
2269 data = 0x0000 ;
2270 if ( infoflag & InterlaceMode )
2271 {
2272 if ( xres == 1024 )
2273 data = 0x0035 ;
2274 else if ( xres == 1280 )
2275 data = 0x0048 ;
2276 }
2277
2278 data2 = data & 0x00FF ;
2279 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2280 data2 = ( data & 0xFF00 ) >> 8 ;
2281 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2282
2283 if( modeflag & HalfDCLK )
2284 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2285
2286 data2 = 0 ;
2287
2288 if ( modeflag & LineCompareOff )
2289 data2 |= 0x08 ;
2290
2291 if ( ModeNo > 0x13 )
2292 {
2293 if ( pVBInfo->ModeType == ModeEGA )
2294 data2 |= 0x40 ;
2295 }
2296
2297 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2298 data = 0x60 ;
2299 if ( pVBInfo->ModeType != ModeText )
2300 {
2301 data = data ^ 0x60 ;
2302 if ( pVBInfo->ModeType != ModeEGA )
2303 {
2304 data = data ^ 0xA0 ;
2305 }
2306 }
2307 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2308
2309 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2310
2311 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2312 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2313 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2314
2315 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2316
2317 if (HwDeviceExtension->jChipType == XG27 )
2318 {
2319 if ( data & 0x40 )
2320 data = 0x2c ;
2321 else
2322 data = 0x6c ;
2323 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2324 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2325 }
2326 else
2327 if (HwDeviceExtension->jChipType >= XG20 )
2328 {
2329 if ( data & 0x40 )
2330 data = 0x33 ;
2331 else
2332 data = 0x73 ;
2333 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2334 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2335 }
2336 else
2337 {
2338 if ( data & 0x40 )
2339 data = 0x2c ;
2340 else
2341 data = 0x6c ;
2342 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2343 }
2344
2345 }
2346
2347
2348 /* --------------------------------------------------------------------- */
2349 /* Function : XGI_SetVCLKState */
2350 /* Input : */
2351 /* Output : */
2352 /* Description : */
2353 /* --------------------------------------------------------------------- */
2354 void XGI_SetVCLKState( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo , USHORT RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo )
2355 {
2356 USHORT data ,
2357 data2 = 0 ;
2358 SHORT VCLK ;
2359
2360 UCHAR index ;
2361
2362 if ( ModeNo <= 0x13 )
2363 VCLK = 0 ;
2364 else
2365 {
2366 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2367 index &= IndexMask ;
2368 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2369 }
2370
2371 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2372 data &= 0xf3 ;
2373 if ( VCLK >= 200 )
2374 data |= 0x0c ; /* VCLK > 200 */
2375
2376 if ( HwDeviceExtension->jChipType >= XG20 )
2377 data &= ~0x04 ; /* 2 pixel mode */
2378
2379 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2380
2381 if ( HwDeviceExtension->jChipType < XG20 )
2382 {
2383 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2384 data &= 0xE7 ;
2385 if ( VCLK < 200 )
2386 data |= 0x10 ;
2387 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2388 }
2389
2390 /* Jong for Adavantech LCD ripple issue
2391 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2392 data2 = 0x03 ;
2393 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2394 data2 = 0x02 ;
2395 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2396 data2 = 0x01 ;
2397 else if ( VCLK > 260 )
2398 data2 = 0x00 ;
2399 */
2400 data2 = 0x00 ;
2401
2402 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2403 if (HwDeviceExtension->jChipType >= XG27 )
2404 {
2405 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2406 }
2407
2408
2409 }
2410
2411
2412 /* --------------------------------------------------------------------- */
2413 /* Function : XGI_VesaLowResolution */
2414 /* Input : */
2415 /* Output : */
2416 /* Description : */
2417 /* --------------------------------------------------------------------- */
2418 /*void XGI_VesaLowResolution( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo)
2419 {
2420 USHORT modeflag;
2421
2422 if ( ModeNo > 0x13 )
2423 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2424 else
2425 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2426
2427 if ( ModeNo > 0x13 )
2428 {
2429 if ( modeflag & DoubleScanMode )
2430 {
2431 if ( modeflag & HalfDCLK )
2432 {
2433 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2434 {
2435 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2436 {
2437 if ( pVBInfo->VBInfo & SetInSlaveMode )
2438 {
2439 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2440 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2441 return ;
2442 }
2443 }
2444 }
2445 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2446 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2447 return ;
2448 }
2449 }
2450 }
2451 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2452 }
2453 */
2454
2455 /* --------------------------------------------------------------------- */
2456 /* Function : XGI_LoadDAC */
2457 /* Input : */
2458 /* Output : */
2459 /* Description : */
2460 /* --------------------------------------------------------------------- */
2461 void XGI_LoadDAC( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2462 {
2463 USHORT data , data2 , time ,
2464 i , j , k , m , n , o ,
2465 si , di , bx , dl , al , ah , dh ,
2466 *table = NULL ;
2467
2468 if ( ModeNo <= 0x13 )
2469 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2470 else
2471 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2472
2473 data &= DACInfoFlag ;
2474 time = 64 ;
2475
2476 if ( data == 0x00 )
2477 table = XGINew_MDA_DAC ;
2478 else if ( data == 0x08 )
2479 table = XGINew_CGA_DAC ;
2480 else if ( data == 0x10 )
2481 table = XGINew_EGA_DAC ;
2482 else if ( data == 0x18 )
2483 {
2484 time = 256 ;
2485 table = XGINew_VGA_DAC ;
2486 }
2487
2488 if ( time == 256 )
2489 j = 16 ;
2490 else
2491 j = time ;
2492
2493 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2494 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2495
2496 for( i = 0 ; i < j ; i++ )
2497 {
2498 data = table[ i ] ;
2499
2500 for( k = 0 ; k < 3 ; k++ )
2501 {
2502 data2 = 0 ;
2503
2504 if ( data & 0x01 )
2505 data2 = 0x2A ;
2506
2507 if ( data & 0x02 )
2508 data2 += 0x15 ;
2509
2510 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2511 data = data >> 2 ;
2512 }
2513 }
2514
2515 if ( time == 256 )
2516 {
2517 for( i = 16 ; i < 32 ; i++ )
2518 {
2519 data = table[ i ] ;
2520
2521 for( k = 0 ; k < 3 ; k++ )
2522 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2523 }
2524
2525 si = 32 ;
2526
2527 for( m = 0 ; m < 9 ; m++ )
2528 {
2529 di = si ;
2530 bx = si + 0x04 ;
2531 dl = 0 ;
2532
2533 for( n = 0 ; n < 3 ; n++ )
2534 {
2535 for( o = 0 ; o < 5 ; o++ )
2536 {
2537 dh = table[ si ] ;
2538 ah = table[ di ] ;
2539 al = table[ bx ] ;
2540 si++ ;
2541 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2542 }
2543
2544 si -= 2 ;
2545
2546 for( o = 0 ; o < 3 ; o++ )
2547 {
2548 dh = table[ bx ] ;
2549 ah = table[ di ] ;
2550 al = table[ si ] ;
2551 si-- ;
2552 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2553 }
2554
2555 dl++ ;
2556 }
2557
2558 si += 5 ;
2559 }
2560 }
2561 }
2562
2563
2564 /* --------------------------------------------------------------------- */
2565 /* Function : XGI_WriteDAC */
2566 /* Input : */
2567 /* Output : */
2568 /* Description : */
2569 /* --------------------------------------------------------------------- */
2570 void XGI_WriteDAC( USHORT dl , USHORT ah , USHORT al , USHORT dh,PVB_DEVICE_INFO pVBInfo )
2571 {
2572 USHORT temp , bh , bl ;
2573
2574 bh = ah ;
2575 bl = al ;
2576
2577 if ( dl != 0 )
2578 {
2579 temp = bh ;
2580 bh = dh ;
2581 dh = temp ;
2582 if ( dl == 1 )
2583 {
2584 temp = bl ;
2585 bl = dh ;
2586 dh = temp ;
2587 }
2588 else
2589 {
2590 temp = bl ;
2591 bl = bh ;
2592 bh = temp ;
2593 }
2594 }
2595 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )dh ) ;
2596 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bh ) ;
2597 XGINew_SetReg3( pVBInfo->P3c9 , ( USHORT )bl ) ;
2598 }
2599
2600 #if 0
2601 /* --------------------------------------------------------------------- */
2602 /* Function : XGI_ClearBuffer */
2603 /* Input : */
2604 /* Output : */
2605 /* Description : */
2606 /* --------------------------------------------------------------------- */
2607 void XGI_ClearBuffer( PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT ModeNo, PVB_DEVICE_INFO pVBInfo)
2608 {
2609 PVOID VideoMemoryAddress = ( PVOID )HwDeviceExtension->pjVideoMemoryAddress ;
2610 ULONG AdapterMemorySize = ( ULONG )HwDeviceExtension->ulVideoMemorySize ;
2611 PUSHORT pBuffer ;
2612 #ifndef LINUX_XF86
2613 int i ;
2614 #endif
2615
2616 if ( pVBInfo->ModeType >= ModeEGA )
2617 {
2618 if ( ModeNo > 0x13 )
2619 {
2620 AdapterMemorySize = 0x40000 ; /* clear 256k */
2621 /* GetDRAMSize( HwDeviceExtension ) ; */
2622 XGI_SetMemory( VideoMemoryAddress , AdapterMemorySize , 0 ) ;
2623 }
2624 else
2625 {
2626 /*
2627 pBuffer = VideoMemoryAddress ;
2628 for( i = 0 ; i < 0x4000 ; i++ )
2629 pBuffer[ i ] = 0x0000 ;
2630 */
2631 }
2632 }
2633 else
2634 {
2635 pBuffer = VideoMemoryAddress ;
2636 if ( pVBInfo->ModeType < ModeCGA )
2637 {
2638 /*
2639 for ( i = 0 ; i < 0x4000 ; i++ )
2640 pBuffer[ i ] = 0x0720 ;
2641 */
2642 }
2643 else
2644 XGI_SetMemory( VideoMemoryAddress , 0x8000 , 0 ) ;
2645 }
2646 }
2647
2648 #endif
2649 /* --------------------------------------------------------------------- */
2650 /* Function : XGI_SetLCDAGroup */
2651 /* Input : */
2652 /* Output : */
2653 /* Description : */
2654 /* --------------------------------------------------------------------- */
2655 void XGI_SetLCDAGroup( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
2656 {
2657 USHORT RefreshRateTableIndex ;
2658 /* USHORT temp ; */
2659
2660 /* pVBInfo->SelectCRT2Rate = 0 ; */
2661
2662 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2663 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2664 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2665 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2666 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2667 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2668 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2669 }
2670
2671
2672 /* --------------------------------------------------------------------- */
2673 /* Function : XGI_GetLVDSResInfo */
2674 /* Input : */
2675 /* Output : */
2676 /* Description : */
2677 /* --------------------------------------------------------------------- */
2678 void XGI_GetLVDSResInfo( USHORT ModeNo , USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo )
2679 {
2680 USHORT resindex , xres , yres , modeflag ;
2681
2682 if ( ModeNo <= 0x13 )
2683 {
2684 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2685 }
2686 else
2687 {
2688 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2689 }
2690
2691
2692 /* if ( ModeNo > 0x13 ) */
2693 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2694 /* else */
2695 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2696
2697 if ( ModeNo <= 0x13 )
2698 {
2699 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2700 }
2701 else
2702 {
2703 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2704 }
2705
2706 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2707
2708 if ( ModeNo <= 0x13 )
2709 {
2710 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2711 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2712 }
2713 else
2714 {
2715 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2716 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2717 }
2718 if ( ModeNo > 0x13 )
2719 {
2720 if ( modeflag & HalfDCLK )
2721 xres = xres << 1 ;
2722
2723 if ( modeflag & DoubleScanMode )
2724 yres = yres << 1 ;
2725 }
2726 /* if ( modeflag & Charx8Dot ) */
2727 /* { */
2728
2729 if ( xres == 720 )
2730 xres = 640 ;
2731
2732 /* } */
2733 pVBInfo->VGAHDE = xres ;
2734 pVBInfo->HDE = xres ;
2735 pVBInfo->VGAVDE = yres ;
2736 pVBInfo->VDE = yres ;
2737 }
2738
2739
2740 /* --------------------------------------------------------------------- */
2741 /* Function : XGI_GetLVDSData */
2742 /* Input : */
2743 /* Output : */
2744 /* Description : */
2745 /* --------------------------------------------------------------------- */
2746 void XGI_GetLVDSData( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2747 {
2748 USHORT tempbx ;
2749 XGI330_LVDSDataStruct *LCDPtr = NULL ;
2750 XGI330_CHTVDataStruct *TVPtr = NULL ;
2751
2752 tempbx = 2 ;
2753
2754 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2755 {
2756 LCDPtr = ( XGI330_LVDSDataStruct * )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo) ;
2757 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2758 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2759 pVBInfo->HT = LCDPtr->LCDHT ;
2760 pVBInfo->VT = LCDPtr->LCDVT ;
2761 }
2762 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2763 {
2764 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2765 {
2766 TVPtr = ( XGI330_CHTVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2767 pVBInfo->VGAHT = TVPtr->VGAHT ;
2768 pVBInfo->VGAVT = TVPtr->VGAVT ;
2769 pVBInfo->HT = TVPtr->LCDHT ;
2770 pVBInfo->VT = TVPtr->LCDVT ;
2771 }
2772 }
2773
2774 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2775 {
2776 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2777 {
2778 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2779 {
2780 pVBInfo->HDE = 1024 ;
2781 pVBInfo->VDE = 768 ;
2782 }
2783 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2784 {
2785 pVBInfo->HDE = 1280 ;
2786 pVBInfo->VDE = 1024 ;
2787 }
2788 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2789 {
2790 pVBInfo->HDE = 1400 ;
2791 pVBInfo->VDE = 1050 ;
2792 }
2793 else
2794 {
2795 pVBInfo->HDE = 1600 ;
2796 pVBInfo->VDE = 1200 ;
2797 }
2798 }
2799 }
2800 }
2801
2802
2803 /* --------------------------------------------------------------------- */
2804 /* Function : XGI_ModCRT1Regs */
2805 /* Input : */
2806 /* Output : */
2807 /* Description : */
2808 /* --------------------------------------------------------------------- */
2809 void XGI_ModCRT1Regs( USHORT ModeNo , USHORT ModeIdIndex ,
2810 USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
2811 {
2812 UCHAR index ;
2813 USHORT tempbx , i ;
2814 XGI_LVDSCRT1HDataStruct *LCDPtr = NULL ;
2815 XGI_LVDSCRT1VDataStruct *LCDPtr1 =NULL ;
2816 /* XGI330_CHTVDataStruct *TVPtr = NULL ; */
2817 XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2818 XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2819
2820 if( ModeNo <= 0x13 )
2821 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2822 else
2823 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2824
2825 index= index & IndexMask ;
2826
2827 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2828 {
2829 tempbx = 0 ;
2830
2831 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2832 {
2833 LCDPtr = ( XGI_LVDSCRT1HDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2834
2835 for( i = 0 ; i < 8 ; i++ )
2836 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2837 }
2838
2839 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2840 {
2841 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2842 {
2843 CH7007TV_TimingHPtr = ( XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2844
2845 for( i = 0 ; i < 8 ; i++ )
2846 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2847 }
2848 }
2849
2850 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2851 {
2852 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2853 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2854 } */
2855
2856 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2857
2858 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2859 {
2860 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2861 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2862 }
2863
2864 tempbx = 1 ;
2865
2866 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2867 {
2868 LCDPtr1 = ( XGI_LVDSCRT1VDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2869 for( i = 0 ; i < 7 ; i++ )
2870 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2871 }
2872
2873 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2874 {
2875 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2876 {
2877 CH7007TV_TimingVPtr = ( XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2878
2879 for( i = 0 ; i < 7 ; i++ )
2880 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2881 }
2882 }
2883 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2884 {
2885 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2886 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2887 } */
2888
2889 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2890
2891 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2892 {
2893 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2894 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2895 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2896
2897 }
2898 }
2899 }
2900
2901
2902
2903 /* --------------------------------------------------------------------- */
2904 /* Function : XGI_SetLVDSRegs */
2905 /* Input : */
2906 /* Output : */
2907 /* Description : */
2908 /* --------------------------------------------------------------------- */
2909 void XGI_SetLVDSRegs( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
2910 {
2911 USHORT tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
2912 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2913 XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2914 XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2915
2916 if ( ModeNo > 0x13 )
2917 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2918 else
2919 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2920
2921 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2922 {
2923 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2924 {
2925 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2926 {
2927 tempbx = 8 ;
2928 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2929 }
2930
2931 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2932 {
2933 tempbx = 3 ;
2934 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2935 LCDPtr1 = ( XGI330_LCDDataDesStruct2 * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2936 else
2937 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2938 }
2939
2940 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
2941 push1 = tempbx ;
2942 push2 = tempax ;
2943
2944 /* GetLCDResInfo */
2945 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2946 {
2947 tempax = 1024 ;
2948 tempbx = 768 ;
2949 }
2950 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2951 {
2952 tempax = 1280 ;
2953 tempbx = 1024 ;
2954 }
2955 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2956 {
2957 tempax = 1400 ;
2958 tempbx = 1050 ;
2959 }
2960 else
2961 {
2962 tempax = 1600 ;
2963 tempbx = 1200 ;
2964 }
2965
2966 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
2967 {
2968 pVBInfo->HDE=tempax;
2969 pVBInfo->VDE=tempbx;
2970 pVBInfo->VGAHDE=tempax;
2971 pVBInfo->VGAVDE=tempbx;
2972 }
2973
2974 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
2975 {
2976 tempax=pVBInfo->HDE;
2977 tempbx=pVBInfo->VDE;
2978 }
2979
2980 tempax = pVBInfo->HT ;
2981
2982 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2983 tempbx = LCDPtr1->LCDHDES ;
2984 else
2985 tempbx = LCDPtr->LCDHDES ;
2986
2987 tempcx = pVBInfo->HDE ;
2988 tempbx = tempbx & 0x0fff ;
2989 tempcx += tempbx ;
2990
2991 if ( tempcx >= tempax )
2992 tempcx -= tempax ;
2993
2994 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
2995
2996 tempcx = tempcx >> 3 ;
2997 tempbx = tempbx >> 3 ;
2998
2999 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , ( USHORT )( tempbx & 0xff ) ) ;
3000 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , ( USHORT )( tempcx & 0xff ) ) ;
3001
3002 tempax = pVBInfo->HT ;
3003
3004 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3005 tempbx = LCDPtr1->LCDHRS ;
3006 else
3007 tempbx = LCDPtr->LCDHRS ;
3008
3009 tempcx = push2 ;
3010
3011 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3012 tempcx = LCDPtr1->LCDHSync ;
3013
3014 tempcx += tempbx ;
3015
3016 if ( tempcx >= tempax )
3017 tempcx -= tempax ;
3018
3019 tempax = tempbx & 0x07 ;
3020 tempax = tempax >> 5 ;
3021 tempcx = tempcx >> 3 ;
3022 tempbx = tempbx >> 3 ;
3023
3024 tempcx &= 0x1f ;
3025 tempax |= tempcx ;
3026
3027 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
3028 XGINew_SetReg1( pVBInfo->Part1Port , 0x14 , ( USHORT )( tempbx & 0xff ) ) ;
3029
3030 tempax = pVBInfo->VT ;
3031 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3032 tempbx = LCDPtr1->LCDVDES ;
3033 else
3034 tempbx = LCDPtr->LCDVDES ;
3035 tempcx = pVBInfo->VDE ;
3036
3037 tempbx = tempbx & 0x0fff ;
3038 tempcx += tempbx ;
3039 if ( tempcx >= tempax )
3040 tempcx -= tempax ;
3041
3042 XGINew_SetReg1( pVBInfo->Part1Port , 0x1b , ( USHORT )( tempbx & 0xff ) ) ;
3043 XGINew_SetReg1( pVBInfo->Part1Port , 0x1c , ( USHORT )( tempcx & 0xff ) ) ;
3044
3045 tempbx = ( tempbx >> 8 ) & 0x07 ;
3046 tempcx = ( tempcx >> 8 ) & 0x07 ;
3047
3048 XGINew_SetReg1( pVBInfo->Part1Port , 0x1d , ( USHORT )( ( tempcx << 3 ) | tempbx ) ) ;
3049
3050 tempax = pVBInfo->VT ;
3051 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3052 tempbx = LCDPtr1->LCDVRS ;
3053 else
3054 tempbx = LCDPtr->LCDVRS ;
3055
3056 /* tempbx = tempbx >> 4 ; */
3057 tempcx = push1 ;
3058
3059 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3060 tempcx = LCDPtr1->LCDVSync ;
3061
3062 tempcx += tempbx ;
3063 if ( tempcx >= tempax )
3064 tempcx -= tempax ;
3065
3066 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , ( USHORT )( tempbx & 0xff ) ) ;
3067 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , ~0x0f , ( USHORT )( tempcx & 0x0f ) ) ;
3068
3069 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3070
3071 tempbx = pVBInfo->VGAVDE ;
3072 if ( tempbx != pVBInfo->VDE )
3073 tempax |= 0x40 ;
3074
3075 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3076 tempax |= 0x40 ;
3077
3078 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3079
3080 tempcx = pVBInfo->VGAVT ;
3081 tempbx = pVBInfo->VDE ;
3082 tempax = pVBInfo->VGAVDE ;
3083 tempcx -= tempax ;
3084
3085 temp = tempax ; /* 0430 ylshieh */
3086 temp1 = ( temp << 18 ) / tempbx ;
3087
3088 tempdx = ( USHORT )( ( temp << 18 ) % tempbx ) ;
3089
3090 if ( tempdx != 0 )
3091 temp1 += 1 ;
3092
3093 temp2 = temp1 ;
3094 push3 = temp2 ;
3095
3096 XGINew_SetReg1( pVBInfo->Part1Port , 0x37 , ( USHORT )( temp2 & 0xff ) ) ;
3097 XGINew_SetReg1( pVBInfo->Part1Port , 0x36 , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3098
3099 tempbx = ( USHORT )( temp2 >> 16 ) ;
3100 tempax = tempbx & 0x03 ;
3101
3102 tempbx = pVBInfo->VGAVDE ;
3103 if ( tempbx == pVBInfo->VDE )
3104 tempax |= 0x04 ;
3105
3106 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3107
3108 if ( pVBInfo->VBType & VB_XGI301C )
3109 {
3110 temp2 = push3 ;
3111 XGINew_SetReg1( pVBInfo->Part4Port , 0x3c , ( USHORT )( temp2 & 0xff ) ) ;
3112 XGINew_SetReg1( pVBInfo->Part4Port , 0x3b , ( USHORT )( ( temp2 >> 8 ) & 0xff ) ) ;
3113 tempbx = ( USHORT )( temp2 >> 16 ) ;
3114 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x3a , ~0xc0 , ( USHORT )( ( tempbx & 0xff ) << 6 ) ) ;
3115
3116 tempcx = pVBInfo->VGAVDE ;
3117 if ( tempcx == pVBInfo->VDE )
3118 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3119 else
3120 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3121 }
3122
3123 tempcx = pVBInfo->VGAHDE ;
3124 tempbx = pVBInfo->HDE ;
3125
3126 temp1 = tempcx << 16 ;
3127
3128 tempax = ( USHORT )( temp1 / tempbx ) ;
3129
3130 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3131 tempax = 65535 ;
3132
3133 temp3 = tempax ;
3134 temp1 = pVBInfo->VGAHDE << 16 ;
3135
3136 temp1 /= temp3 ;
3137 temp3 = temp3 << 16 ;
3138 temp1 -= 1 ;
3139
3140 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3141
3142 tempax = ( USHORT )( temp3 & 0xff ) ;
3143 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3144
3145 temp1 = pVBInfo->VGAVDE << 18 ;
3146 temp1 = temp1 / push3 ;
3147 tempbx = ( USHORT )( temp1 & 0xffff ) ;
3148
3149 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3150 tempbx -= 1 ;
3151
3152 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
3153 tempax |= ( USHORT )( ( temp3 >> 8 ) & 0x07 ) ;
3154 XGINew_SetReg1( pVBInfo->Part1Port , 0x20 , ( USHORT )( tempax & 0xff ) ) ;
3155 XGINew_SetReg1( pVBInfo->Part1Port , 0x21 , ( USHORT )( tempbx & 0xff ) ) ;
3156
3157 temp3 = temp3 >> 16 ;
3158
3159 if ( modeflag & HalfDCLK )
3160 temp3 = temp3 >> 1 ;
3161
3162 XGINew_SetReg1(pVBInfo->Part1Port , 0x22 , ( USHORT )( ( temp3 >> 8 ) & 0xff ) ) ;
3163 XGINew_SetReg1(pVBInfo->Part1Port , 0x23 , ( USHORT )( temp3 & 0xff ) ) ;
3164 }
3165 }
3166 }
3167
3168
3169 /* --------------------------------------------------------------------- */
3170 /* Function : XGI_SetCRT2ECLK */
3171 /* Input : */
3172 /* Output : */
3173 /* Description : */
3174 /* --------------------------------------------------------------------- */
3175 void XGI_SetCRT2ECLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
3176 {
3177 UCHAR di_0 , di_1 , tempal ;
3178 int i ;
3179
3180 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3181 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3182 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3183
3184 for( i = 0 ; i < 4 ; i++ )
3185 {
3186 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , ~0x30 , ( USHORT )( 0x10 * i ) ) ;
3187 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3188 {
3189 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3190 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3191 }
3192 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3193 {
3194 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3195 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3196 }
3197 else
3198 {
3199 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3200 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3201 }
3202 }
3203 }
3204
3205
3206 /* --------------------------------------------------------------------- */
3207 /* Function : XGI_UpdateModeInfo */
3208 /* Input : */
3209 /* Output : */
3210 /* Description : */
3211 /* --------------------------------------------------------------------- */
3212 void XGI_UpdateModeInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
3213 {
3214 USHORT tempcl ,
3215 tempch ,
3216 temp ,
3217 tempbl ,
3218 tempax ;
3219
3220 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3221 {
3222 tempcl = 0 ;
3223 tempch = 0 ;
3224 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3225
3226 if ( !( temp & 0x20 ) )
3227 {
3228 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3229 if ( temp & 0x80 )
3230 {
3231 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3232 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3233 else
3234 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3235
3236 if ( !( temp & 0x40 ) )
3237 tempcl |= ActiveCRT1 ;
3238 }
3239 }
3240
3241 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3242 temp &= 0x0f ;
3243
3244 if ( !( temp == 0x08 ) )
3245 {
3246 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3247 if ( tempax & 0x04 )
3248 tempcl = tempcl | ActiveLCD ;
3249
3250 temp &= 0x05 ;
3251
3252 if ( !( tempcl & ActiveLCD ) )
3253 if ( temp == 0x01 )
3254 tempcl |= ActiveCRT2 ;
3255
3256 if ( temp == 0x04 )
3257 tempcl |= ActiveLCD ;
3258
3259 if ( temp == 0x05 )
3260 {
3261 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3262
3263 if( !( temp & 0x08 ) )
3264 tempch |= ActiveAVideo ;
3265
3266 if ( !( temp & 0x04 ) )
3267 tempch |= ActiveSVideo ;
3268
3269 if ( temp & 0x02 )
3270 tempch |= ActiveSCART ;
3271
3272 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3273 {
3274 if ( temp & 0x01 )
3275 tempch |= ActiveHiTV ;
3276 }
3277
3278 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3279 {
3280 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3281
3282 if ( temp & 0x10 )
3283 tempch |= ActiveYPbPr ;
3284 }
3285
3286 if ( tempch != 0 )
3287 tempcl |= ActiveTV ;
3288 }
3289 }
3290
3291 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3292 if ( tempcl & ActiveLCD )
3293 {
3294 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3295 {
3296 if ( temp & ActiveTV )
3297 tempcl |= ActiveTV ;
3298 }
3299 }
3300 temp = tempcl ;
3301 tempbl = ~ModeSwitchStatus ;
3302 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3303
3304 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3305 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3306 }
3307 else
3308 {
3309 return ;
3310 }
3311 }
3312
3313
3314 /* --------------------------------------------------------------------- */
3315 /* Function : XGI_GetVGAType */
3316 /* Input : */
3317 /* Output : */
3318 /* Description : */
3319 /* --------------------------------------------------------------------- */
3320 void XGI_GetVGAType( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3321 {
3322 /*
3323 if ( HwDeviceExtension->jChipType >= XG20 )
3324 {
3325 pVBInfo->Set_VGAType = XG20;
3326 }
3327 else if ( HwDeviceExtension->jChipType >= XG40 )
3328 {
3329 pVBInfo->Set_VGAType = VGA_XGI340 ;
3330 }
3331 */
3332 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3333 }
3334
3335
3336 /* --------------------------------------------------------------------- */
3337 /* Function : XGI_GetVBType */
3338 /* Input : */
3339 /* Output : */
3340 /* Description : */
3341 /* --------------------------------------------------------------------- */
3342 void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo)
3343 {
3344 USHORT flag , tempbx , tempah ;
3345
3346 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3347 {
3348 pVBInfo->VBType = VB_CH7007 ;
3349 return;
3350 }
3351 if ( pVBInfo->IF_DEF_LVDS == 0 )
3352 {
3353 tempbx = VB_XGI302B ;
3354 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3355 if ( flag != 0x02 )
3356 {
3357 tempbx = VB_XGI301 ;
3358 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3359 if ( flag >= 0xB0 )
3360 {
3361 tempbx = VB_XGI301B ;
3362 if ( flag >= 0xC0 )
3363 {
3364 tempbx = VB_XGI301C ;
3365 if ( flag >= 0xD0 )
3366 {
3367 tempbx = VB_XGI301LV ;
3368 if ( flag >= 0xE0 )
3369 {
3370 tempbx = VB_XGI302LV ;
3371 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3372 if ( tempah != 0xFF )
3373 tempbx = VB_XGI301C ;
3374 }
3375 }
3376 }
3377
3378 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3379 {
3380 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3381
3382 if ( !( flag & 0x02 ) )
3383 tempbx = tempbx | VB_NoLCD ;
3384 }
3385 }
3386 }
3387 pVBInfo->VBType = tempbx ;
3388 }
3389 /*
3390 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3391 pVBInfo->VBType = VB_CH7017 ;
3392 else //LVDS
3393 pVBInfo->VBType = VB_LVDS_NS ;
3394 */
3395
3396 }
3397
3398
3399 /* --------------------------------------------------------------------- */
3400 /* Function : XGI_GetVBInfo */
3401 /* Input : */
3402 /* Output : */
3403 /* Description : */
3404 /* --------------------------------------------------------------------- */
3405 void XGI_GetVBInfo( USHORT ModeNo , USHORT ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
3406 {
3407 USHORT tempax ,
3408 push ,
3409 tempbx ,
3410 temp ,
3411 modeflag ;
3412
3413 if ( ModeNo <= 0x13 )
3414 {
3415 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3416 }
3417 else
3418 {
3419 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3420 }
3421
3422 pVBInfo->SetFlag = 0 ;
3423 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3424 tempbx = 0 ;
3425
3426 if ( pVBInfo->VBType & 0xFFFF )
3427 {
3428 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3429 tempbx = tempbx | temp ;
3430 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3431 push = temp ;
3432 push = push << 8 ;
3433 tempax = temp << 8 ;
3434 tempbx = tempbx | tempax ;
3435 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3436 temp = 0xFFFF ^ temp ;
3437 tempbx &= temp ;
3438
3439 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3440
3441 if ( pVBInfo->IF_DEF_LCDA == 1 )
3442 {
3443
3444 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3445 {
3446 if ( pVBInfo->IF_DEF_LVDS == 0 )
3447 {
3448 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3449 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3450 {
3451 if ( temp & EnableDualEdge )
3452 {
3453 tempbx |= SetCRT2ToDualEdge ;
3454
3455 if ( temp & SetToLCDA )
3456 tempbx |= SetCRT2ToLCDA ;
3457 }
3458 }
3459 }
3460 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3461 {
3462 if ( pVBInfo->VBType & VB_CH7017 )
3463 {
3464 if ( temp & EnableDualEdge )
3465 {
3466 tempbx |= SetCRT2ToDualEdge ;
3467
3468 if ( temp & SetToLCDA )
3469 tempbx |= SetCRT2ToLCDA ;
3470 }
3471 }
3472 }
3473 }
3474 }
3475
3476 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3477 {
3478 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3479 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3480 {
3481 if ( temp & SetYPbPr ) /* temp = CR38 */
3482 {
3483 if ( pVBInfo->IF_DEF_HiVision == 1 )
3484 {
3485 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3486 temp &= YPbPrMode ;
3487 tempbx |= SetCRT2ToHiVisionTV ;
3488
3489 if ( temp != YPbPrMode1080i ) {
3490 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3491 tempbx |= SetCRT2ToYPbPr ; }
3492 }
3493
3494 /* tempbx |= SetCRT2ToYPbPr ; */
3495 }
3496 }
3497 }
3498
3499 tempax = push ; /* restore CR31 */
3500
3501 if ( pVBInfo->IF_DEF_LVDS == 0 )
3502 {
3503 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3504 {
3505 if ( pVBInfo->IF_DEF_HiVision == 1 )
3506 temp = 0x09FC ;
3507 else
3508 temp = 0x097C ;
3509 }
3510 else
3511 {
3512 if ( pVBInfo->IF_DEF_HiVision == 1 )
3513 temp = 0x01FC ;
3514 else
3515 temp = 0x017C ;
3516 }
3517 }
3518 else /* 3nd party chip */
3519 {
3520 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3521 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3522 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3523 {
3524 temp = SetCRT2ToTV ;
3525 }
3526 else
3527 temp = SetCRT2ToLCD ;
3528 }
3529
3530 if ( !( tempbx & temp ) )
3531 {
3532 tempax |= DisableCRT2Display ;
3533 tempbx = 0 ;
3534 }
3535
3536 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3537 {
3538 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3539 {
3540 if ( tempbx & SetCRT2ToLCDA )
3541 {
3542 if ( tempbx & SetSimuScanMode )
3543 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3544 else
3545 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3546 }
3547 }
3548 }
3549
3550 /* shampoo add */
3551 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3552 {
3553 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3554 {
3555 if ( tempbx & SetCRT2ToRAMDAC )
3556 {
3557 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3558 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3559 }
3560 }
3561 else
3562 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3563 }
3564
3565 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3566 {
3567 if ( tempbx & SetCRT2ToLCD )
3568 {
3569 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3570 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3571 }
3572 }
3573
3574 if ( tempbx & SetCRT2ToSCART )
3575 {
3576 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3577 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3578 }
3579
3580 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3581 {
3582 if ( tempbx & SetCRT2ToYPbPr )
3583 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3584 }
3585
3586 if ( pVBInfo->IF_DEF_HiVision == 1 )
3587 {
3588 if ( tempbx & SetCRT2ToHiVisionTV )
3589 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3590 }
3591
3592 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3593 {
3594 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3595 tempbx = DisableCRT2Display ;
3596 }
3597
3598 if ( !( tempbx & DisableCRT2Display ) )
3599 {
3600 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3601 {
3602 if ( pVBInfo->IF_DEF_LCDA == 1 )
3603 {
3604 if ( !( tempbx & SetCRT2ToLCDA ) )
3605 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3606 }
3607
3608 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3609 {
3610 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3611 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3612 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3613 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3614 {
3615 if ( ModeNo <= 13 )
3616 {
3617 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3618 {
3619 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3620 pVBInfo->SetFlag |= EnableVCMode ;
3621 }
3622 }
3623 }
3624 }
3625 }
3626
3627 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3628 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3629 {
3630 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3631 pVBInfo->SetFlag |= ReserveTVOption ;
3632 }
3633 }
3634 }
3635
3636 pVBInfo->VBInfo = tempbx ;
3637 }
3638
3639
3640 /* --------------------------------------------------------------------- */
3641 /* Function : XGI_GetTVInfo */
3642 /* Input : */
3643 /* Output : */
3644 /* Description : */
3645 /* --------------------------------------------------------------------- */
3646 void XGI_GetTVInfo( USHORT ModeNo , USHORT ModeIdIndex ,PVB_DEVICE_INFO pVBInfo )
3647 {
3648 USHORT temp ,
3649 tempbx = 0 ,
3650 resinfo = 0 ,
3651 modeflag ,
3652 index1 ;
3653
3654 tempbx = 0 ;
3655 resinfo = 0 ;
3656
3657 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3658 {
3659 if ( ModeNo <= 0x13 )
3660 {
3661 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3662 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3663 }
3664 else
3665 {
3666 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3667 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3668 }
3669
3670 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3671 {
3672 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3673 tempbx = temp;
3674 if ( tempbx & SetPALTV )
3675 {
3676 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3677 if ( tempbx & SetPALMTV )
3678 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3679 }
3680 else
3681 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3682 /*
3683 if ( pVBInfo->IF_DEF_LVDS == 0 )
3684 {
3685 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3686 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3687 tempbx |= temp2 ;
3688 if ( temp2 & 0x02 ) //PAL-M
3689 tempbx &= ( ~SetPALTV ) ;
3690 }
3691 */
3692 }
3693
3694 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3695 {
3696 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3697
3698 if ( tempbx & TVOverScan )
3699 tempbx |= SetCHTVOverScan ;
3700 }
3701
3702 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3703 {
3704 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3705
3706 if ( tempbx & TVOverScan )
3707 {
3708 tempbx |= SetCHTVOverScan ;
3709 }
3710 }
3711
3712
3713 if ( pVBInfo->IF_DEF_LVDS == 0 )
3714 {
3715 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3716 tempbx |= SetPALTV ;
3717 }
3718
3719 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3720 {
3721 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3722 {
3723 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3724 index1 &= YPbPrMode ;
3725
3726 if ( index1 == YPbPrMode525i )
3727 tempbx |= SetYPbPrMode525i ;
3728
3729 if ( index1 == YPbPrMode525p )
3730 tempbx = tempbx | SetYPbPrMode525p;
3731 if ( index1 == YPbPrMode750p)
3732 tempbx = tempbx | SetYPbPrMode750p;
3733 }
3734 }
3735
3736 if ( pVBInfo->IF_DEF_HiVision == 1 )
3737 {
3738 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3739 {
3740 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3741 }
3742 }
3743
3744 if ( pVBInfo->IF_DEF_LVDS == 0 )
3745 { /* shampoo */
3746 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3747 tempbx |= TVSimuMode ;
3748
3749 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3750 tempbx |= NTSC1024x768 ;
3751
3752 tempbx |= RPLLDIV2XO ;
3753
3754 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3755 {
3756 if ( pVBInfo->VBInfo & SetInSlaveMode )
3757 tempbx &=( ~RPLLDIV2XO ) ;
3758 }
3759 else
3760 {
3761 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3762 tempbx &= ( ~RPLLDIV2XO ) ;
3763 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3764 {
3765 if ( tempbx & TVSimuMode )
3766 tempbx &= ( ~RPLLDIV2XO ) ;
3767 }
3768 }
3769 }
3770 }
3771 pVBInfo->TVInfo = tempbx ;
3772 }
3773
3774
3775 /* --------------------------------------------------------------------- */
3776 /* Function : XGI_GetLCDInfo */
3777 /* Input : */
3778 /* Output : */
3779 /* Description : */
3780 /* --------------------------------------------------------------------- */
3781 BOOLEAN XGI_GetLCDInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
3782 {
3783 USHORT temp ,
3784 tempax ,
3785 tempbx ,
3786 modeflag ,
3787 resinfo = 0 ,
3788 LCDIdIndex ;
3789
3790 pVBInfo->LCDResInfo = 0 ;
3791 pVBInfo->LCDTypeInfo = 0 ;
3792 pVBInfo->LCDInfo = 0 ;
3793
3794 if ( ModeNo <= 0x13 )
3795 {
3796 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3797 }
3798 else
3799 {
3800 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3801 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3802 }
3803
3804 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3805 tempbx = temp & 0x0F ;
3806
3807 if ( tempbx == 0 )
3808 tempbx = Panel1024x768 ; /* default */
3809
3810 /* LCD75 [2003/8/22] Vicent */
3811 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3812 {
3813 if ( pVBInfo->VBInfo & DriverMode )
3814 {
3815 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3816 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3817 tempax &= 0x0F ;
3818 else
3819 tempax = tempax >> 4 ;
3820
3821 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3822 {
3823 if ( tempax >= 3 )
3824 tempbx |= PanelRef75Hz ;
3825 }
3826 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3827 {
3828 if ( tempax >= 4 )
3829 tempbx |= PanelRef75Hz ;
3830 }
3831 }
3832 }
3833
3834 pVBInfo->LCDResInfo = tempbx ;
3835
3836 /* End of LCD75 */
3837
3838 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3839 {
3840 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3841 }
3842
3843 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3844 {
3845 return 0;
3846 }
3847
3848 tempbx = 0 ;
3849
3850 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3851
3852 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3853
3854 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3855 temp &= ~EnableScalingLCD ;
3856
3857 tempbx |= temp ;
3858
3859 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3860
3861 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3862
3863 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3864 {
3865 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3866 {
3867 tempbx |= SetLCDDualLink ;
3868 }
3869 }
3870
3871 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3872 {
3873 if ( tempax & LCDDualLink )
3874 {
3875 tempbx |= SetLCDDualLink ;
3876 }
3877 }
3878
3879 if ( pVBInfo->IF_DEF_LVDS == 0 )
3880 {
3881 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3882 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3883 }
3884
3885 /*
3886 if ( tempax & LCDBToA )
3887 {
3888 tempbx |= SetLCDBToA ;
3889 }
3890 */
3891
3892 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3893 {
3894 if ( modeflag & HalfDCLK )
3895 {
3896 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3897 if ( !( tempbx & SetLCDtoNonExpanding ) )
3898 {
3899 tempbx |= EnableLVDSDDA ;
3900 }
3901 else
3902 {
3903 if ( ModeNo > 0x13 )
3904 {
3905 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3906 {
3907 if ( resinfo == 4 )
3908 { /* 512x384 */
3909 tempbx |= EnableLVDSDDA ;
3910 }
3911 }
3912 }
3913 }
3914 }
3915 }
3916
3917 if ( pVBInfo->VBInfo & SetInSlaveMode )
3918 {
3919 if ( pVBInfo->VBInfo & SetNotSimuMode )
3920 {
3921 tempbx |= LCDVESATiming ;
3922 }
3923 }
3924 else
3925 {
3926 tempbx |= LCDVESATiming ;
3927 }
3928
3929 pVBInfo->LCDInfo = tempbx ;
3930
3931 if ( pVBInfo->IF_DEF_PWD == 1 )
3932 {
3933 if ( pVBInfo->LCDInfo & SetPWDEnable )
3934 {
3935 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3936 {
3937 if ( !( tempax & PWDEnable ) )
3938 {
3939 pVBInfo->LCDInfo &= ~SetPWDEnable ;
3940 }
3941 }
3942 }
3943 }
3944
3945 if ( pVBInfo->IF_DEF_LVDS == 0 )
3946 {
3947 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3948 {
3949 if ( pVBInfo->VBInfo & SetInSlaveMode )
3950 {
3951 if ( !( tempax & LockLCDBToA ) )
3952 {
3953 if ( ModeNo <= 0x13 )
3954 {
3955 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
3956 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
3957 }
3958 }
3959 }
3960 }
3961 }
3962
3963 /*
3964 if ( pVBInfo->IF_DEF_LVDS == 0 )
3965 {
3966 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3967 {
3968 if ( pVBInfo->VBInfo & SetInSlaveMode )
3969 {
3970 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
3971 {
3972 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3973 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3974 }
3975 }
3976 }
3977 }
3978 */
3979
3980 return( 1 ) ;
3981 }
3982
3983
3984 /* --------------------------------------------------------------------- */
3985 /* Function : XGI_SearchModeID */
3986 /* Input : */
3987 /* Output : */
3988 /* Description : */
3989 /* --------------------------------------------------------------------- */
3990 BOOLEAN XGI_SearchModeID( USHORT ModeNo , USHORT *ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
3991 {
3992
3993
3994
3995 #ifdef LINUX /* chiawen for linux solution */
3996
3997 if ( ModeNo <= 5 )
3998 ModeNo |= 1 ;
3999 if ( ModeNo <= 0x13 )
4000 {
4001 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
4002 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4003 {
4004 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == ModeNo )
4005 break ;
4006 if ( pVBInfo->SModeIDTable[ *ModeIdIndex ].St_ModeID == 0xFF )
4007 return( FALSE ) ;
4008 }
4009
4010 if ( ModeNo == 0x07 )
4011 ( *ModeIdIndex )++ ; /* 400 lines */
4012
4013 if ( ModeNo <= 3 )
4014 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4015 /* else 350 lines */
4016 }
4017 else
4018 {
4019 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4020 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4021 {
4022 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == ModeNo )
4023 break ;
4024 if ( pVBInfo->EModeIDTable[ *ModeIdIndex ].Ext_ModeID == 0xFF )
4025 return( FALSE ) ;
4026 }
4027 }
4028
4029 #endif
4030
4031 return( TRUE ) ;
4032 }
4033
4034
4035
4036
4037 /* win2000 MM adapter not support standard mode! */
4038
4039 /* --------------------------------------------------------------------- */
4040 /* Function : */
4041 /* Input : */
4042 /* Output : */
4043 /* Description : */
4044 /* --------------------------------------------------------------------- */
4045 BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4046 {
4047 USHORT memorysize ,
4048 modeflag ,
4049 temp ,
4050 temp1 ,
4051 tmp ;
4052
4053 /* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4054 ( HwDeviceExtension->jChipType == XGI_650M ) )
4055 {
4056 return( TRUE ) ;
4057 } */
4058
4059 if ( ModeNo <= 0x13 )
4060 {
4061 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4062 }
4063 else {
4064 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4065 }
4066
4067 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4068
4069 memorysize = modeflag & MemoryInfoFlag ;
4070 memorysize = memorysize > MemorySizeShift ;
4071 memorysize++ ; /* Get memory size */
4072
4073 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4074 tmp = temp ;
4075
4076 if ( HwDeviceExtension->jChipType == XG40 )
4077 {
4078 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4079 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4080 {
4081 temp <<= 2 ;
4082 }
4083 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4084 {
4085 temp <<= 1 ;
4086 }
4087 }
4088 else if ( HwDeviceExtension->jChipType == XG42 )
4089 {
4090 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4091 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4092 {
4093 temp <<= 1 ;
4094 }
4095 }
4096 else if ( HwDeviceExtension->jChipType == XG45 )
4097 {
4098 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4099 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4100 {
4101 temp <<= 2 ;
4102 }
4103 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4104 {
4105 temp1 = temp ;
4106 temp <<= 1 ;
4107 temp += temp1 ;
4108 }
4109 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4110 {
4111 temp <<= 1 ;
4112 }
4113 }
4114 if ( temp < memorysize )
4115 return( FALSE ) ;
4116 else
4117 return( TRUE ) ;
4118 }
4119
4120
4121 /* --------------------------------------------------------------------- */
4122 /* Function : XGINew_IsLowResolution */
4123 /* Input : */
4124 /* Output : */
4125 /* Description : */
4126 /* --------------------------------------------------------------------- */
4127 /*void XGINew_IsLowResolution( USHORT ModeNo , USHORT ModeIdIndex, BOOLEAN XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo,USHORT ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
4128 {
4129 USHORT data ;
4130 USHORT ModeFlag ;
4131
4132 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4133 data &= 0x7F ;
4134 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4135
4136 if ( ModeNo > 0x13 )
4137 {
4138 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4139 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4140 {
4141 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4142 data |= 0x80 ;
4143 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4144 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4145 data &= 0xF7 ;
4146 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4147 }
4148 }
4149 }
4150
4151 */
4152
4153 /* --------------------------------------------------------------------- */
4154 /* Function : XGI_DisplayOn */
4155 /* Input : */
4156 /* Output : */
4157 /* Description : */
4158 /* --------------------------------------------------------------------- */
4159 void XGI_DisplayOn( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4160 {
4161
4162 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4163 if ( pXGIHWDE->jChipType == XG21 )
4164 {
4165 if ( pVBInfo->IF_DEF_LVDS == 1 )
4166 {
4167 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4168 {
4169 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4170 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4171 }
4172 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4173 {
4174 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4175 }
4176 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4177 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4178 }
4179 else
4180 {
4181 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4182 }
4183
4184 }
4185
4186 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4187 {
4188
4189 }
4190
4191
4192 if ( pXGIHWDE->jChipType == XG27 )
4193 {
4194 if ( pVBInfo->IF_DEF_LVDS == 1 )
4195 {
4196 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4197 {
4198 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4199 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4200 }
4201 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4202 {
4203 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4204 }
4205 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4206 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4207 }
4208 else
4209 {
4210 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4211 }
4212
4213 }
4214 }
4215
4216
4217 /* --------------------------------------------------------------------- */
4218 /* Function : XGI_DisplayOff */
4219 /* Input : */
4220 /* Output : */
4221 /* Description : */
4222 /* --------------------------------------------------------------------- */
4223 void XGI_DisplayOff( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4224 {
4225
4226 if ( pXGIHWDE->jChipType == XG21 )
4227 {
4228 if ( pVBInfo->IF_DEF_LVDS == 1 )
4229 {
4230 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4231 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4232 }
4233 else
4234 {
4235 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4236 }
4237 }
4238
4239 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4240 {
4241 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4242 {
4243 }
4244 }
4245
4246
4247 if ( pXGIHWDE->jChipType == XG27 )
4248 {
4249 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4250 {
4251 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4252 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4253 }
4254
4255 if ( pVBInfo->IF_DEF_LVDS == 0 )
4256 {
4257 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4258 }
4259 }
4260
4261 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4262 }
4263
4264
4265 /* --------------------------------------------------------------------- */
4266 /* Function : XGI_WaitDisply */
4267 /* Input : */
4268 /* Output : */
4269 /* Description : chiawen for sensecrt1 */
4270 /* --------------------------------------------------------------------- */
4271 void XGI_WaitDisply( PVB_DEVICE_INFO pVBInfo )
4272 {
4273 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4274 break ;
4275
4276 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4277 break ;
4278 }
4279
4280 /* --------------------------------------------------------------------- */
4281 /* Function : XGI_SenseCRT1 */
4282 /* Input : */
4283 /* Output : */
4284 /* Description : */
4285 /* --------------------------------------------------------------------- */
4286
4287 void XGI_SenseCRT1( PVB_DEVICE_INFO pVBInfo )
4288 {
4289 UCHAR CRTCData[ 17 ] = { 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4290 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4291 0x04 , 0x00 , 0x00 , 0x05 , 0x00 } ;
4292
4293 UCHAR SR01 = 0 , SR1F = 0 , SR07 = 0 , SR06 = 0 ;
4294
4295 UCHAR CR17 , CR63 , SR31 ;
4296 USHORT temp ;
4297 UCHAR DAC_TEST_PARMS[ 3 ] = { 0x0F , 0x0F , 0x0F } ;
4298
4299 int i ;
4300 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4301
4302 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4303 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4304 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) | 0x02 ) ) ;
4305
4306 SR31 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) ;
4307 CR63 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
4308 SR01 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4309
4310 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , ( UCHAR )( SR01 & 0xDF ) ) ;
4311 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , ( UCHAR )( CR63 & 0xBF ) ) ;
4312
4313 CR17 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
4314 XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , ( UCHAR )( CR17 | 0x80 ) ) ;
4315
4316 SR1F = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
4317 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR )( SR1F | 0x04 ) ) ;
4318
4319 SR07 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x07 ) ;
4320 XGINew_SetReg1( pVBInfo->P3c4 , 0x07 , ( UCHAR )( SR07 & 0xFB ) ) ;
4321 SR06 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x06 ) ;
4322 XGINew_SetReg1( pVBInfo->P3c4 , 0x06 , ( UCHAR )( SR06 & 0xC3 ) ) ;
4323
4324 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4325
4326 for( i = 0 ; i < 8 ; i++ )
4327 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )i , CRTCData[ i ] ) ;
4328
4329 for( i = 8 ; i < 11 ; i++ )
4330 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 8 ) , CRTCData[ i ] ) ;
4331
4332 for( i = 11 ; i < 13 ; i++ )
4333 XGINew_SetReg1( pVBInfo->P3d4 , ( USHORT )( i + 4 ) , CRTCData[ i ] ) ;
4334
4335 for( i = 13 ; i < 16 ; i++ )
4336 XGINew_SetReg1( pVBInfo->P3c4 , ( USHORT )( i - 3 ) , CRTCData[ i ] ) ;
4337
4338 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , ( UCHAR )( CRTCData[ 16 ] & 0xE0 ) ) ;
4339
4340 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4341 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4342 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4343
4344 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4345
4346 for( i = 0 ; i < 256 ; i++ )
4347 {
4348 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 0 ] ) ;
4349 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 1 ] ) ;
4350 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 2 ] ) ;
4351 }
4352
4353 XGI_VBLongWait( pVBInfo ) ;
4354 XGI_VBLongWait( pVBInfo ) ;
4355 XGI_VBLongWait( pVBInfo ) ;
4356
4357 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4358
4359 XGI_WaitDisply( pVBInfo ) ;
4360 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4361
4362 if( temp & 0x10 )
4363 {
4364 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4365 }
4366 else
4367 {
4368 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4369 }
4370
4371 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4372 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4373
4374 for( i = 0 ; i < 256 ; i++ )
4375 {
4376 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4377 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4378 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4379 }
4380
4381 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4382 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4383 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4384
4385 /* [2004/05/11] Vicent */
4386 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) & 0xFD ) ) ;
4387 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR ) SR1F ) ;
4388 }
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399 /* --------------------------------------------------------------------- */
4400 /* Function : XGI_WaitDisplay */
4401 /* Input : */
4402 /* Output : */
4403 /* Description : */
4404 /* --------------------------------------------------------------------- */
4405 void XGI_WaitDisplay( PVB_DEVICE_INFO pVBInfo )
4406 {
4407 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4408
4409 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4410 }
4411
4412
4413
4414
4415 /* --------------------------------------------------------------------- */
4416 /* Function : XGI_SetCRT2Group301 */
4417 /* Input : */
4418 /* Output : */
4419 /* Description : */
4420 /* --------------------------------------------------------------------- */
4421 BOOLEAN XGI_SetCRT2Group301( USHORT ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
4422 {
4423 USHORT tempbx ,
4424 ModeIdIndex ,
4425 RefreshRateTableIndex ;
4426
4427 tempbx=pVBInfo->VBInfo ;
4428 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4429 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4430 pVBInfo->SelectCRT2Rate = 4 ;
4431 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4432 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4433 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4434 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4435 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4436 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4437 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4438 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4439 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4440 XGI_SetTap4Regs(pVBInfo) ;
4441 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4442 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4443 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4444 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4445 XGI_AutoThreshold( pVBInfo) ;
4446 return 1 ;
4447 }
4448
4449
4450 /* --------------------------------------------------------------------- */
4451 /* Function : XGI_AutoThreshold */
4452 /* Input : */
4453 /* Output : */
4454 /* Description : */
4455 /* --------------------------------------------------------------------- */
4456 void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo )
4457 {
4458 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4459 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4460 }
4461
4462
4463 /* --------------------------------------------------------------------- */
4464 /* Function : XGI_SaveCRT2Info */
4465 /* Input : */
4466 /* Output : */
4467 /* Description : */
4468 /* --------------------------------------------------------------------- */
4469 void XGI_SaveCRT2Info( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo)
4470 {
4471 USHORT temp1 ,
4472 temp2 ;
4473
4474 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4475 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4476 temp2 = ~( SetInSlaveMode >> 8 ) ;
4477 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4478 }
4479
4480
4481 /* --------------------------------------------------------------------- */
4482 /* Function : XGI_GetCRT2ResInfo */
4483 /* Input : */
4484 /* Output : */
4485 /* Description : */
4486 /* --------------------------------------------------------------------- */
4487 void XGI_GetCRT2ResInfo( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
4488 {
4489 USHORT xres ,
4490 yres ,
4491 modeflag ,
4492 resindex ;
4493
4494 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4495 if ( ModeNo <= 0x13 )
4496 {
4497 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4498 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4499 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4500 }
4501 else
4502 {
4503 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4504 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4505 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4506
4507 /* if ( pVBInfo->IF_DEF_FSTN )
4508 {
4509 xres *= 2 ;
4510 yres *= 2 ;
4511 }
4512 else
4513 {
4514 */
4515 if ( modeflag & HalfDCLK )
4516 xres *= 2;
4517
4518 if ( modeflag & DoubleScanMode )
4519 yres *= 2 ;
4520 /* } */
4521 }
4522
4523 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4524 {
4525 if ( pVBInfo->IF_DEF_LVDS == 0 )
4526 {
4527 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4528 {
4529 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4530 {
4531 if ( yres == 1024 )
4532 yres = 1056 ;
4533 }
4534 }
4535
4536 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4537 {
4538 if ( yres == 400 )
4539 yres = 405 ;
4540 else if ( yres == 350 )
4541 yres = 360 ;
4542
4543 if ( pVBInfo->LCDInfo & LCDVESATiming )
4544 {
4545 if ( yres == 360 )
4546 yres = 375 ;
4547 }
4548 }
4549
4550 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4551 {
4552 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4553 {
4554 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4555 {
4556 if ( yres == 350 )
4557 yres = 357 ;
4558 else if ( yres == 400 )
4559 yres = 420 ;
4560 else if ( yres == 480 )
4561 yres = 525 ;
4562 }
4563 }
4564 }
4565 }
4566
4567 if ( xres == 720 )
4568 xres = 640 ;
4569 }
4570
4571 pVBInfo->VGAHDE = xres ;
4572 pVBInfo->HDE = xres ;
4573 pVBInfo->VGAVDE = yres ;
4574 pVBInfo->VDE = yres ;
4575 }
4576
4577
4578 /* --------------------------------------------------------------------- */
4579 /* Function : XGI_IsLCDDualLink */
4580 /* Input : */
4581 /* Output : */
4582 /* Description : */
4583 /* --------------------------------------------------------------------- */
4584 BOOLEAN XGI_IsLCDDualLink( PVB_DEVICE_INFO pVBInfo )
4585 {
4586
4587 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4588 return ( 1 ) ;
4589
4590 return( 0 ) ;
4591 }
4592
4593
4594 /* --------------------------------------------------------------------- */
4595 /* Function : XGI_GetCRT2Data */
4596 /* Input : */
4597 /* Output : */
4598 /* Description : */
4599 /* --------------------------------------------------------------------- */
4600 void XGI_GetCRT2Data( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4601 {
4602 USHORT tempax = 0,
4603 tempbx ,
4604 modeflag ,
4605 resinfo ;
4606
4607 XGI_LCDDataStruct *LCDPtr = NULL ;
4608 XGI_TVDataStruct *TVPtr = NULL ;
4609
4610 if ( ModeNo <= 0x13 )
4611 {
4612 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4613 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4614 }
4615 else
4616 {
4617 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4618 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4619 }
4620
4621 pVBInfo->NewFlickerMode = 0 ;
4622 pVBInfo->RVBHRS = 50 ;
4623
4624 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4625 {
4626 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4627 return ;
4628 }
4629
4630 tempbx = 4 ;
4631
4632 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4633 {
4634 LCDPtr = (XGI_LCDDataStruct* )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4635
4636 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4637 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4638 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4639 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4640 pVBInfo->HT = LCDPtr->LCDHT ;
4641 pVBInfo->VT = LCDPtr->LCDVT ;
4642
4643 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4644 {
4645 tempax = 1024 ;
4646 tempbx = 768 ;
4647
4648 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4649 {
4650 if ( pVBInfo->VGAVDE == 357 )
4651 tempbx = 527 ;
4652 else if ( pVBInfo->VGAVDE == 420 )
4653 tempbx = 620 ;
4654 else if ( pVBInfo->VGAVDE == 525 )
4655 tempbx = 775 ;
4656 else if ( pVBInfo->VGAVDE == 600 )
4657 tempbx = 775 ;
4658 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4659 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4660 else
4661 tempbx = 768 ;
4662 }
4663 else
4664 tempbx = 768 ;
4665 }
4666 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4667 {
4668 tempax = 1024 ;
4669 tempbx = 768 ;
4670 }
4671 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4672 {
4673 tempax = 1280 ;
4674 if ( pVBInfo->VGAVDE == 360 )
4675 tempbx = 768 ;
4676 else if ( pVBInfo->VGAVDE == 375 )
4677 tempbx = 800 ;
4678 else if ( pVBInfo->VGAVDE == 405 )
4679 tempbx = 864 ;
4680 else
4681 tempbx = 1024 ;
4682 }
4683 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4684 {
4685 tempax = 1280 ;
4686 tempbx = 1024 ;
4687 }
4688 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4689 {
4690 tempax = 1280 ;
4691 if ( pVBInfo->VGAVDE == 350 )
4692 tempbx = 700 ;
4693 else if ( pVBInfo->VGAVDE == 400 )
4694 tempbx = 800 ;
4695 else if ( pVBInfo->VGAVDE == 1024 )
4696 tempbx = 960 ;
4697 else
4698 tempbx = 960 ;
4699 }
4700 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4701 {
4702 tempax = 1400 ;
4703 tempbx = 1050 ;
4704
4705 if ( pVBInfo->VGAVDE == 1024 )
4706 {
4707 tempax = 1280 ;
4708 tempbx = 1024 ;
4709 }
4710 }
4711 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4712 {
4713 tempax = 1600 ;
4714 tempbx = 1200 ; /* alan 10/14/2003 */
4715 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4716 {
4717 if ( pVBInfo->VGAVDE == 350 )
4718 tempbx = 875 ;
4719 else if ( pVBInfo->VGAVDE == 400 )
4720 tempbx = 1000 ;
4721 }
4722 }
4723
4724 if ( pVBInfo->LCDInfo & LCDNonExpanding )
4725 {
4726 tempax = pVBInfo->VGAHDE ;
4727 tempbx = pVBInfo->VGAVDE ;
4728 }
4729
4730 pVBInfo->HDE = tempax ;
4731 pVBInfo->VDE = tempbx ;
4732 return ;
4733 }
4734
4735 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
4736 {
4737 tempbx = 4 ;
4738 TVPtr = ( XGI_TVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4739
4740 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
4741 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
4742 pVBInfo->VGAHT = TVPtr->VGAHT ;
4743 pVBInfo->VGAVT = TVPtr->VGAVT ;
4744 pVBInfo->HDE = TVPtr->TVHDE ;
4745 pVBInfo->VDE = TVPtr->TVVDE ;
4746 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
4747 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
4748
4749 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
4750 {
4751 if ( resinfo == 0x08 )
4752 pVBInfo->NewFlickerMode = 0x40 ;
4753 else if ( resinfo == 0x09 )
4754 pVBInfo->NewFlickerMode = 0x40 ;
4755 else if ( resinfo == 0x12 )
4756 pVBInfo->NewFlickerMode = 0x40 ;
4757
4758 if ( pVBInfo->VGAVDE == 350 )
4759 pVBInfo->TVInfo |= TVSimuMode ;
4760
4761 tempax = ExtHiTVHT ;
4762 tempbx = ExtHiTVVT ;
4763
4764 if ( pVBInfo->VBInfo & SetInSlaveMode )
4765 {
4766 if ( pVBInfo->TVInfo & TVSimuMode )
4767 {
4768 tempax = StHiTVHT ;
4769 tempbx = StHiTVVT ;
4770
4771 if ( !( modeflag & Charx8Dot ) )
4772 {
4773 tempax = StHiTextTVHT ;
4774 tempbx = StHiTextTVVT ;
4775 }
4776 }
4777 }
4778 }
4779 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
4780 {
4781 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4782 {
4783 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
4784 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
4785 }
4786
4787 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4788 {
4789 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
4790 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
4791 }
4792 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
4793 {
4794 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
4795 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
4796 if ( pVBInfo->TVInfo & NTSC1024x768 )
4797 tempax = NTSC1024x768HT ;
4798 }
4799 }
4800 else
4801 {
4802 tempax = PALHT ;
4803 tempbx = PALVT ;
4804 if ( !( pVBInfo->TVInfo & SetPALTV ) )
4805 {
4806 tempax = NTSCHT ;
4807 tempbx = NTSCVT ;
4808 if ( pVBInfo->TVInfo & NTSC1024x768 )
4809 tempax = NTSC1024x768HT ;
4810 }
4811 }
4812
4813 pVBInfo->HT = tempax ;
4814 pVBInfo->VT = tempbx ;
4815 return ;
4816 }
4817 }
4818
4819
4820 /* --------------------------------------------------------------------- */
4821 /* Function : XGI_SetCRT2VCLK */
4822 /* Input : */
4823 /* Output : */
4824 /* Description : */
4825 /* --------------------------------------------------------------------- */
4826 void XGI_SetCRT2VCLK( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
4827 {
4828 UCHAR di_0 ,
4829 di_1 ,
4830 tempal ;
4831
4832 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
4833 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
4834 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
4835
4836 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
4837 { /* 301 */
4838 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
4839 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
4840 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
4841 }
4842 else
4843 { /* 301b/302b/301lv/302lv */
4844 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
4845 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
4846 }
4847
4848 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
4849
4850 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4851 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
4852 else
4853 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
4854 }
4855
4856
4857 /* --------------------------------------------------------------------- */
4858 /* Function : XGI_GETLCDVCLKPtr */
4859 /* Input : */
4860 /* Output : al -> VCLK Index */
4861 /* Description : */
4862 /* --------------------------------------------------------------------- */
4863 void XGI_GetLCDVCLKPtr( UCHAR* di_0 , UCHAR *di_1, PVB_DEVICE_INFO pVBInfo )
4864 {
4865 USHORT index ;
4866
4867 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4868 {
4869 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
4870 {
4871 if ( pVBInfo->LCDInfo & EnableScalingLCD )
4872 return ;
4873 }
4874
4875 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
4876 index = XGI_GetLCDCapPtr1( pVBInfo) ;
4877
4878 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4879 { /* LCDB */
4880 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
4881 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
4882 }
4883 else
4884 { /* LCDA */
4885 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
4886 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
4887 }
4888 }
4889 return ;
4890 }
4891
4892
4893 /* --------------------------------------------------------------------- */
4894 /* Function : XGI_GetVCLKPtr */
4895 /* Input : */
4896 /* Output : */
4897 /* Description : */
4898 /* --------------------------------------------------------------------- */
4899 UCHAR XGI_GetVCLKPtr(USHORT RefreshRateTableIndex,USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
4900 {
4901
4902 USHORT index ,
4903 modeflag ;
4904 #ifndef LINUX_XF86
4905 USHORT tempbx ;
4906 #endif
4907
4908 UCHAR tempal ;
4909 UCHAR *CHTVVCLKPtr = NULL ;
4910
4911 if ( ModeNo <= 0x13 )
4912 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4913 else
4914 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4915
4916
4917 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
4918 { /* {LCDA/LCDB} */
4919 index = XGI_GetLCDCapPtr(pVBInfo) ;
4920 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
4921
4922 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4923 return tempal ;
4924
4925 /* {TV} */
4926 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
4927 {
4928 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
4929 {
4930 tempal = HiTVVCLKDIV2;
4931 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
4932 tempal = HiTVVCLK;
4933 if(pVBInfo->TVInfo & TVSimuMode)
4934 {
4935 tempal = HiTVSimuVCLK;
4936 if(!(modeflag & Charx8Dot))
4937 tempal = HiTVTextVCLK;
4938
4939 }
4940 return tempal;
4941 }
4942
4943 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4944 {
4945 tempal = YPbPr750pVCLK ;
4946 return tempal ;
4947 }
4948
4949 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4950 {
4951 tempal = YPbPr525pVCLK ;
4952 return tempal ;
4953 }
4954
4955 tempal = NTSC1024VCLK ;
4956
4957 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
4958 {
4959 tempal = TVVCLKDIV2 ;
4960 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
4961 tempal = TVVCLK ;
4962 }
4963
4964 if ( pVBInfo->VBInfo & SetCRT2ToTV )
4965 return tempal ;
4966 }
4967 /*else
4968 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
4969 {
4970 if(ModeNo<=0x13)
4971 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4972 else
4973 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4974 *tempal = *tempal & 0x1F;
4975
4976 tempbx = 0;
4977 if(pVBInfo->TVInfo & SetPALTV)
4978 tempbx = tempbx + 2;
4979 if(pVBInfo->TVInfo & SetCHTVOverScan)
4980 tempbx++;
4981 tempbx = tempbx << 1;
4982 } */
4983 } /* {End of VB} */
4984
4985 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
4986 {
4987 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4988 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
4989 {
4990 if( ModeNo <= 0x13 )
4991 {
4992 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
4993 }
4994 else
4995 {
4996 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4997 }
4998
4999 tempal = tempal & 0x0F;
5000 tempbx = 0;
5001
5002 if(pVBInfo->TVInfo & SetPALTV)
5003 {
5004 tempbx = tempbx + 2;
5005 }
5006 if(pVBInfo->TVInfo & SetCHTVOverScan)
5007 {
5008 tempbx++;
5009 }
5010 /** tempbx = tempbx << 1; CH7007 ? **/
5011
5012 /*[Billy]07/05/29 CH7007*/
5013 if ( pVBInfo->IF_DEF_CH7007 == 1 )
5014 {
5015 switch( tempbx )
5016 {
5017 case 0:
5018 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
5019 break ;
5020 case 1:
5021 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5022 break ;
5023 case 2:
5024 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5025 break ;
5026 case 3:
5027 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5028 break ;
5029 default:
5030 break ;
5031
5032 }
5033 }
5034 /*else
5035 {
5036 switch( tempbx )
5037 {
5038 case 0:
5039 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5040 break ;
5041 case 1:
5042 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5043 break ;
5044 case 2:
5045 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5046 break ;
5047 case 3:
5048 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5049 break ;
5050 default:
5051 break ;
5052 }
5053 }*/
5054
5055 tempal = CHTVVCLKPtr[ tempal ] ;
5056 return tempal ;
5057 }
5058
5059 }
5060
5061 tempal = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ;
5062 tempal = tempal >> 2 ;
5063 tempal &= 0x03 ;
5064
5065 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5066 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5067
5068 if ( ModeNo <= 0x13 )
5069 return tempal ;
5070
5071 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5072 return tempal ;
5073 }
5074
5075
5076 /* --------------------------------------------------------------------- */
5077 /* Function : XGI_GetVCLKLen */
5078 /* Input : */
5079 /* Output : */
5080 /* Description : */
5081 /* --------------------------------------------------------------------- */
5082 void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo)
5083 {
5084 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5085 {
5086 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5087 *di_0 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2B ;
5088 *di_1 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2C ;
5089 }
5090 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5091 {
5092 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5093 {
5094 *di_0 = ( UCHAR )XGI_VBVCLKData[ tempal ].SR2B ;
5095 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5096 }
5097 }
5098 else
5099 {
5100 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5101 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5102 }
5103 }
5104
5105
5106 /* --------------------------------------------------------------------- */
5107 /* Function : XGI_SetCRT2Offset */
5108 /* Input : */
5109 /* Output : */
5110 /* Description : */
5111 /* --------------------------------------------------------------------- */
5112 void XGI_SetCRT2Offset( USHORT ModeNo ,
5113 USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5114 {
5115 USHORT offset ;
5116 UCHAR temp ;
5117
5118 if ( pVBInfo->VBInfo & SetInSlaveMode )
5119 {
5120 return ;
5121 }
5122
5123 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5124 temp = ( UCHAR )( offset & 0xFF ) ;
5125 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5126 temp =( UCHAR)( ( offset & 0xFF00 ) >> 8 ) ;
5127 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , temp ) ;
5128 temp =( UCHAR )( ( ( offset >> 3 ) & 0xFF ) + 1 ) ;
5129 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5130 }
5131
5132
5133 /* --------------------------------------------------------------------- */
5134 /* Function : XGI_GetOffset */
5135 /* Input : */
5136 /* Output : */
5137 /* Description : */
5138 /* --------------------------------------------------------------------- */
5139 USHORT XGI_GetOffset(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
5140 {
5141 USHORT temp ,
5142 colordepth ,
5143 modeinfo ,
5144 index ,
5145 infoflag ,
5146 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5147
5148 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5149 if ( ModeNo <= 0x14 )
5150 infoflag = 0 ;
5151 else
5152 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5153
5154
5155 index = ( modeinfo >> 8 ) & 0xFF ;
5156
5157 temp = pVBInfo->ScreenOffset[ index ] ;
5158
5159 if ( infoflag & InterlaceMode )
5160 {
5161 temp = temp << 1 ;
5162 }
5163
5164 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5165
5166 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5167 {
5168 temp = ModeNo - 0x7C ;
5169 colordepth = ColorDepth[ temp ] ;
5170 temp = 0x6B ;
5171 if ( infoflag & InterlaceMode )
5172 {
5173 temp = temp << 1 ;
5174 }
5175 return( temp * colordepth ) ;
5176 }
5177 else
5178 return( temp * colordepth ) ;
5179 }
5180
5181
5182 /* --------------------------------------------------------------------- */
5183 /* Function : XGI_SetCRT2FIFO */
5184 /* Input : */
5185 /* Output : */
5186 /* Description : */
5187 /* --------------------------------------------------------------------- */
5188 void XGI_SetCRT2FIFO( PVB_DEVICE_INFO pVBInfo)
5189 {
5190 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5191 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5192 }
5193
5194
5195 /* --------------------------------------------------------------------- */
5196 /* Function : XGI_PreSetGroup1 */
5197 /* Input : */
5198 /* Output : */
5199 /* Description : */
5200 /* --------------------------------------------------------------------- */
5201 void XGI_PreSetGroup1(USHORT ModeNo , USHORT ModeIdIndex ,PXGI_HW_DEVICE_INFO HwDeviceExtension,
5202 USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5203 {
5204 USHORT tempcx = 0 ,
5205 CRT1Index = 0 ,
5206 resinfo = 0 ;
5207
5208 if ( ModeNo > 0x13 )
5209 {
5210 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5211 CRT1Index &= IndexMask ;
5212 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5213 }
5214
5215 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5216 XGI_SetCRT2FIFO(pVBInfo) ;
5217 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5218
5219 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5220 {
5221 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5222 }
5223
5224 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5225 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5226 }
5227
5228
5229 /* --------------------------------------------------------------------- */
5230 /* Function : XGI_SetGroup1 */
5231 /* Input : */
5232 /* Output : */
5233 /* Description : */
5234 /* --------------------------------------------------------------------- */
5235 void XGI_SetGroup1( USHORT ModeNo , USHORT ModeIdIndex ,
5236 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5237 {
5238 USHORT temp = 0 ,
5239 tempax = 0 ,
5240 tempbx = 0 ,
5241 tempcx = 0 ,
5242 pushbx = 0 ,
5243 CRT1Index = 0 ,
5244 modeflag ,
5245 resinfo = 0 ;
5246
5247 if ( ModeNo > 0x13 )
5248 {
5249 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5250 CRT1Index &= IndexMask ;
5251 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5252 }
5253
5254 if ( ModeNo <= 0x13 )
5255 {
5256 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5257 }
5258 else
5259 {
5260 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5261 }
5262
5263 /* bainy change table name */
5264 if ( modeflag & HalfDCLK )
5265 {
5266 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5267 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5268 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5269 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5270 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5271 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5272 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5273 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5274 tempcx = tempcx >> 1 ;
5275 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5276 tempcx += tempbx ;
5277
5278 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5279 {
5280 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5281 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5282 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5283 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5284 tempcx &= 0x1F ;
5285 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5286 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5287 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5288 }
5289
5290 tempbx += 4 ;
5291 tempcx += 4 ;
5292
5293 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5294 tempcx = pVBInfo->VGAHT / 2 ;
5295
5296 temp = tempbx & 0x00FF ;
5297
5298 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5299 }
5300 else
5301 {
5302 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5303 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5304 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5305 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5306 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5307 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5308 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5309 pushbx = pVBInfo->VGAHDE + 16 ;
5310 tempcx = tempcx >> 1 ;
5311 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5312 tempcx += tempbx ;
5313
5314 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5315 {
5316 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5317 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5318 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5319 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5320 tempcx &= 0x1F ;
5321 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5322 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5323 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5324 tempbx += 16 ;
5325 tempcx += 16 ;
5326 }
5327
5328 if ( tempcx > pVBInfo->VGAHT )
5329 tempcx = pVBInfo->VGAHT ;
5330
5331 temp = tempbx & 0x00FF ;
5332 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5333 }
5334
5335 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5336 tempbx = pushbx ;
5337 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5338 tempax |= ( tempbx & 0xFF00 ) ;
5339 temp = ( tempax & 0xFF00 ) >> 8 ;
5340 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5341 temp = tempcx & 0x00FF ;
5342 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5343 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5344 temp = tempcx & 0x00FF ;
5345
5346 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5347 {
5348 if ( pVBInfo->VBInfo & 0x0C )
5349 {
5350 temp-- ;
5351 }
5352 }
5353
5354 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5355 tempbx = pVBInfo->VGAVDE - 1 ;
5356 temp = tempbx & 0x00FF ;
5357 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5358 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5359 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5360 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5361
5362 tempax = pVBInfo->VGAVDE ;
5363 tempbx = pVBInfo->VGAVDE ;
5364 tempcx = pVBInfo->VGAVT ;
5365 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5366 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5367
5368 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5369 {
5370 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5371 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5372
5373 if ( temp & 0x04 )
5374 tempbx |= 0x0100 ;
5375
5376 if ( temp & 0x080 )
5377 tempbx |= 0x0200 ;
5378
5379 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5380
5381 if ( temp & 0x08 )
5382 tempbx |= 0x0400 ;
5383
5384 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5385 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5386 }
5387
5388 temp = tempbx & 0x00FF ;
5389 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5390 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5391 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5392 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5393 tempax = 0 ;
5394
5395 if ( modeflag & DoubleScanMode )
5396 tempax |= 0x80 ;
5397
5398 if ( modeflag & HalfDCLK )
5399 tempax |= 0x40 ;
5400
5401 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5402 }
5403
5404
5405 /* --------------------------------------------------------------------- */
5406 /* Function : XGI_SetLockRegs */
5407 /* Input : */
5408 /* Output : */
5409 /* Description : */
5410 /* --------------------------------------------------------------------- */
5411 void XGI_SetLockRegs( USHORT ModeNo , USHORT ModeIdIndex ,
5412 PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
5413 {
5414 USHORT push1 ,
5415 push2 ,
5416 tempax ,
5417 tempbx = 0 ,
5418 tempcx ,
5419 temp ,
5420 resinfo ,
5421 modeflag ,
5422 CRT1Index ;
5423
5424 if ( ModeNo <= 0x13 )
5425 {
5426 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5427 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5428 }
5429 else
5430 {
5431 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5432 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5433 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5434 CRT1Index &= IndexMask;
5435 }
5436
5437 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5438 {
5439 return ;
5440 }
5441
5442 temp = 0xFF ; /* set MAX HT */
5443 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5444 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5445 /* else */
5446 tempcx=0x08;
5447
5448 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5449 modeflag |= Charx8Dot ;
5450
5451 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5452
5453 if ( modeflag & HalfDCLK )
5454 tempax = tempax >> 1 ;
5455
5456 tempax = ( tempax / tempcx ) - 1 ;
5457 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5458 temp = tempax & 0x00FF ;
5459 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5460
5461 temp = ( tempbx & 0xFF00 ) >> 8 ;
5462
5463 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5464 {
5465 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5466 temp += 2 ;
5467
5468 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5469 {
5470 if ( pVBInfo->VBType & VB_XGI301LV )
5471 {
5472 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5473 {
5474 if ( resinfo == 7 )
5475 temp -= 2 ;
5476 }
5477 }
5478 else
5479 if ( resinfo == 7 )
5480 temp -= 2 ;
5481 }
5482 }
5483
5484 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5485 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5486
5487 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5488 { /* 030226 bainy */
5489 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5490 tempax = pVBInfo->VGAHT ;
5491 else
5492 tempax = XGI_GetVGAHT2( pVBInfo) ;
5493 }
5494
5495 if ( tempax >= pVBInfo->VGAHT )
5496 {
5497 tempax = pVBInfo->VGAHT ;
5498 }
5499
5500 if ( modeflag & HalfDCLK )
5501 {
5502 tempax = tempax >> 1 ;
5503 }
5504
5505 tempax = ( tempax / tempcx ) - 5 ;
5506 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5507 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5508 {
5509 temp = ( tempbx & 0x00FF ) - 1 ;
5510 if ( !( modeflag & HalfDCLK ) )
5511 {
5512 temp -= 6 ;
5513 if ( pVBInfo->TVInfo & TVSimuMode )
5514 {
5515 temp -= 4 ;
5516 if ( ModeNo > 0x13 )
5517 temp -= 10 ;
5518 }
5519 }
5520 }
5521 else
5522 {
5523 /* tempcx = tempbx & 0x00FF ; */
5524 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5525 tempcx = ( tempcx + tempbx ) >> 1 ;
5526 temp = ( tempcx & 0x00FF ) + 2 ;
5527
5528 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5529 {
5530 temp -= 1 ;
5531 if ( !( modeflag & HalfDCLK ) )
5532 {
5533 if ( ( modeflag & Charx8Dot ) )
5534 {
5535 temp += 4 ;
5536 if ( pVBInfo->VGAHDE >= 800 )
5537 {
5538 temp -= 6 ;
5539 }
5540 }
5541 }
5542 }
5543 else
5544 {
5545 if ( !( modeflag & HalfDCLK ) )
5546 {
5547 temp -= 4 ;
5548 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5549 {
5550 if( pVBInfo->VGAHDE >= 800 )
5551 {
5552 temp -= 7 ;
5553 if ( pVBInfo->ModeType == ModeEGA )
5554 {
5555 if ( pVBInfo->VGAVDE == 1024 )
5556 {
5557 temp += 15 ;
5558 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5559 {
5560 temp += 7 ;
5561 }
5562 }
5563 }
5564
5565 if ( pVBInfo->VGAHDE >= 1280 )
5566 {
5567 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5568 {
5569 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5570 {
5571 temp += 28 ;
5572 }
5573 }
5574 }
5575 }
5576 }
5577 }
5578 }
5579 }
5580
5581 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5582 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5583
5584 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5585 {
5586 if ( pVBInfo->TVInfo & TVSimuMode )
5587 {
5588 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5589 {
5590 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5591 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5592 }
5593
5594 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5595 {
5596 if ( pVBInfo->TVInfo & SetNTSCTV )
5597 {
5598 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5599 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5600 }
5601 else
5602 {
5603 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5604 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5605 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5606 }
5607 }
5608
5609 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5610 {
5611 if ( pVBInfo->TVInfo & SetNTSCTV )
5612 {
5613 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5614 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5615 }
5616 else
5617 {
5618 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5619 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5620 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5621 }
5622 }
5623
5624 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5625 {
5626 if ( pVBInfo->TVInfo & SetNTSCTV )
5627 {
5628 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5629 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5630 }
5631 else
5632 {
5633 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5634 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5635 }
5636 }
5637 }
5638 }
5639
5640 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5641 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5642 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5643
5644 tempbx = pVBInfo->VGAVT ;
5645 push1 = tempbx ;
5646 tempcx = 0x121 ;
5647 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5648
5649 if ( tempbx == 357 )
5650 tempbx = 350 ;
5651 if ( tempbx == 360 )
5652 tempbx =350 ;
5653 if ( tempbx == 375 )
5654 tempbx = 350 ;
5655 if ( tempbx == 405 )
5656 tempbx = 400 ;
5657 if ( tempbx == 525 )
5658 tempbx = 480 ;
5659
5660 push2 = tempbx ;
5661
5662 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5663 {
5664 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5665 {
5666 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5667 {
5668 if ( tempbx == 350 )
5669 tempbx += 5 ;
5670 if ( tempbx == 480 )
5671 tempbx += 5 ;
5672 }
5673 }
5674 }
5675 tempbx-- ;
5676 temp = tempbx & 0x00FF ;
5677 tempbx-- ;
5678 temp = tempbx & 0x00FF ;
5679 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5680 tempbx = push2 ;
5681 tempbx-- ;
5682 temp = tempbx & 0x00FF ;
5683 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5684
5685 if ( tempbx & 0x0100 )
5686 {
5687 tempcx |= 0x0002 ;
5688 }
5689
5690 tempax = 0x000B ;
5691
5692 if ( modeflag & DoubleScanMode )
5693 {
5694 tempax |= 0x08000 ;
5695 }
5696
5697 if ( tempbx & 0x0200 )
5698 {
5699 tempcx |= 0x0040 ;
5700 }
5701
5702 temp = ( tempax & 0xFF00 ) >> 8 ;
5703 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5704
5705 if ( tempbx & 0x0400 )
5706 {
5707 tempcx |= 0x0600 ;
5708 }
5709
5710 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5711
5712 tempax = push1 ;
5713 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
5714 tempax = tempax >> 2 ;
5715 push1 = tempax ; /* push ax */
5716
5717 if ( resinfo != 0x09 )
5718 {
5719 tempax = tempax << 1 ;
5720 tempbx += tempax ;
5721 }
5722
5723 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5724 {
5725 if ( pVBInfo->VBType & VB_XGI301LV )
5726 {
5727 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
5728 tempbx -= 10 ;
5729 else
5730 {
5731 if ( pVBInfo->TVInfo & TVSimuMode )
5732 {
5733 if ( pVBInfo->TVInfo & SetPALTV )
5734 {
5735 if ( pVBInfo->VBType & VB_XGI301LV )
5736 {
5737 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5738 tempbx += 40 ;
5739 }
5740 else
5741 tempbx += 40 ;
5742 }
5743 }
5744 }
5745 }
5746 else
5747 tempbx -= 10 ;
5748 }
5749 else
5750 {
5751 if ( pVBInfo->TVInfo & TVSimuMode )
5752 {
5753 if ( pVBInfo->TVInfo & SetPALTV )
5754 {
5755 if ( pVBInfo->VBType & VB_XGI301LV )
5756 {
5757 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5758 tempbx += 40 ;
5759 }
5760 else
5761 tempbx += 40 ;
5762 }
5763 }
5764 }
5765 tempax = push1 ;
5766 tempax = tempax >> 2 ;
5767 tempax++ ;
5768 tempax += tempbx ;
5769 push1 = tempax ; /* push ax */
5770
5771 if ( ( pVBInfo->TVInfo & SetPALTV ) )
5772 {
5773 if ( tempbx <= 513 )
5774 {
5775 if ( tempax >= 513 )
5776 {
5777 tempbx = 513 ;
5778 }
5779 }
5780 }
5781
5782 temp = tempbx & 0x00FF ;
5783 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5784 tempbx-- ;
5785 temp = tempbx & 0x00FF ;
5786 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5787
5788 if ( tempbx & 0x0100 )
5789 {
5790 tempcx |= 0x0008 ;
5791 }
5792
5793 if ( tempbx & 0x0200 )
5794 {
5795 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
5796 }
5797
5798 tempbx++ ;
5799
5800 if ( tempbx & 0x0100 )
5801 {
5802 tempcx |= 0x0004 ;
5803 }
5804
5805 if ( tempbx & 0x0200 )
5806 {
5807 tempcx |= 0x0080 ;
5808 }
5809
5810 if ( tempbx & 0x0400 )
5811 {
5812 tempcx |= 0x0C00 ;
5813 }
5814
5815 tempbx = push1 ; /* pop ax */
5816 temp = tempbx & 0x00FF ;
5817 temp &= 0x0F ;
5818 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
5819
5820 if ( tempbx & 0x0010 )
5821 {
5822 tempcx |= 0x2000 ;
5823 }
5824
5825 temp = tempcx & 0x00FF ;
5826 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
5827 temp = ( tempcx & 0x0FF00 ) >> 8 ;
5828 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
5829 tempax = modeflag ;
5830 temp = ( tempax & 0xFF00 ) >> 8 ;
5831
5832 temp = ( temp >> 1 ) & 0x09 ;
5833
5834 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5835 temp |= 0x01 ;
5836
5837 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
5838 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
5839 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
5840
5841 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
5842 temp = 0x80 ;
5843 else
5844 temp = 0x00 ;
5845
5846 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
5847
5848 return ;
5849 }
5850
5851
5852 /* --------------------------------------------------------------------- */
5853 /* Function : XGI_SetGroup2 */
5854 /* Input : */
5855 /* Output : */
5856 /* Description : */
5857 /* --------------------------------------------------------------------- */
5858 void XGI_SetGroup2( USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableIndex,
5859 PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5860 {
5861 USHORT i ,
5862 j ,
5863 tempax ,
5864 tempbx ,
5865 tempcx ,
5866 temp ,
5867 push1 ,
5868 push2 ,
5869 modeflag ,
5870 resinfo ,
5871 crt2crtc ;
5872 UCHAR *TimingPoint ;
5873
5874 ULONG longtemp ,
5875 tempeax ,
5876 tempebx ,
5877 temp2 ,
5878 tempecx ;
5879
5880 if ( ModeNo <= 0x13 )
5881 {
5882 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5883 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5884 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5885 }
5886 else
5887 {
5888 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5889 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5890 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
5891 }
5892
5893 tempax = 0 ;
5894
5895 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
5896 tempax |= 0x0800 ;
5897
5898 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
5899 tempax |= 0x0400 ;
5900
5901 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
5902 tempax |= 0x0200 ;
5903
5904 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5905 tempax |= 0x1000 ;
5906
5907 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5908 tempax |= 0x0100 ;
5909
5910 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
5911 tempax &= 0xfe00 ;
5912
5913 tempax = ( tempax & 0xff00 ) >> 8 ;
5914
5915 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
5916 TimingPoint = pVBInfo->NTSCTiming ;
5917
5918 if ( pVBInfo->TVInfo & SetPALTV )
5919 {
5920 TimingPoint = pVBInfo->PALTiming ;
5921 }
5922
5923 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5924 {
5925 TimingPoint = pVBInfo->HiTVExtTiming ;
5926
5927 if ( pVBInfo->VBInfo & SetInSlaveMode )
5928 TimingPoint = pVBInfo->HiTVSt2Timing ;
5929
5930 if ( pVBInfo->SetFlag & TVSimuMode )
5931 TimingPoint = pVBInfo->HiTVSt1Timing ;
5932
5933 if ( !(modeflag & Charx8Dot) )
5934 TimingPoint = pVBInfo->HiTVTextTiming ;
5935 }
5936
5937 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5938 {
5939 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5940 TimingPoint = pVBInfo->YPbPr525iTiming ;
5941
5942 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5943 TimingPoint = pVBInfo->YPbPr525pTiming ;
5944
5945 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5946 TimingPoint = pVBInfo->YPbPr750pTiming ;
5947 }
5948
5949 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
5950 {
5951 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
5952 }
5953
5954 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
5955 {
5956 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
5957 }
5958
5959 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5960 {
5961 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
5962 }
5963
5964 temp = pVBInfo->NewFlickerMode ;
5965 temp &= 0x80 ;
5966 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
5967
5968 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5969 tempax = 950 ;
5970
5971 if ( pVBInfo->TVInfo & SetPALTV )
5972 tempax = 520 ;
5973 else
5974 tempax = 440 ;
5975
5976 if ( pVBInfo->VDE <= tempax )
5977 {
5978 tempax -= pVBInfo->VDE ;
5979 tempax = tempax >> 2 ;
5980 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
5981 push1 = tempax ;
5982 temp = ( tempax & 0xFF00 ) >> 8 ;
5983 temp += ( USHORT )TimingPoint[ 0 ] ;
5984
5985 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5986 {
5987 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
5988 {
5989 tempcx=pVBInfo->VGAHDE;
5990 if ( tempcx >= 1024 )
5991 {
5992 temp = 0x17 ; /* NTSC */
5993 if ( pVBInfo->TVInfo & SetPALTV )
5994 temp = 0x19 ; /* PAL */
5995 }
5996 }
5997 }
5998
5999 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6000 tempax = push1 ;
6001 temp = ( tempax & 0xFF00 ) >> 8 ;
6002 temp += TimingPoint[ 1 ] ;
6003
6004 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6005 {
6006 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
6007 {
6008 tempcx = pVBInfo->VGAHDE ;
6009 if ( tempcx >= 1024 )
6010 {
6011 temp = 0x1D ; /* NTSC */
6012 if ( pVBInfo->TVInfo & SetPALTV )
6013 temp = 0x52 ; /* PAL */
6014 }
6015 }
6016 }
6017 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
6018 }
6019
6020 /* 301b */
6021 tempcx = pVBInfo->HT ;
6022
6023 if ( XGI_IsLCDDualLink( pVBInfo ) )
6024 tempcx = tempcx >> 1 ;
6025
6026 tempcx -= 2 ;
6027 temp = tempcx & 0x00FF ;
6028 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6029
6030 temp = ( tempcx & 0xFF00 ) >> 8 ;
6031 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6032
6033 tempcx = pVBInfo->HT >> 1 ;
6034 push1 = tempcx ; /* push cx */
6035 tempcx += 7 ;
6036
6037 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6038 {
6039 tempcx -= 4 ;
6040 }
6041
6042 temp = tempcx & 0x00FF ;
6043 temp = temp << 4 ;
6044 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6045
6046 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6047 tempbx += tempcx ;
6048 push2 = tempbx ;
6049 temp = tempbx & 0x00FF ;
6050 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6051 temp = ( tempbx & 0xFF00 ) >> 8 ;
6052 temp = temp << 4 ;
6053 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6054
6055 tempbx=push2;
6056 tempbx=tempbx+8;
6057 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6058 {
6059 tempbx=tempbx-4;
6060 tempcx=tempbx;
6061 }
6062
6063 temp = ( tempbx & 0x00FF ) << 4 ;
6064 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6065
6066 j += 2 ;
6067 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6068 temp = tempcx & 0x00FF ;
6069 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6070 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6071 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6072
6073 tempcx += 8 ;
6074 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6075 {
6076 tempcx -= 4 ;
6077 }
6078
6079 temp = tempcx & 0xFF ;
6080 temp = temp << 4 ;
6081 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6082
6083 tempcx = push1 ; /* pop cx */
6084 j += 2 ;
6085 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6086 tempcx -= temp ;
6087 temp = tempcx & 0x00FF ;
6088 temp = temp << 4 ;
6089 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6090
6091 tempcx -= 11 ;
6092
6093 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6094 {
6095 tempax = XGI_GetVGAHT2( pVBInfo) ;
6096 tempcx = tempax - 1 ;
6097 }
6098 temp = tempcx & 0x00FF ;
6099 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6100
6101 tempbx = pVBInfo->VDE ;
6102
6103 if ( pVBInfo->VGAVDE == 360 )
6104 tempbx = 746 ;
6105 if ( pVBInfo->VGAVDE == 375 )
6106 tempbx = 746 ;
6107 if ( pVBInfo->VGAVDE == 405 )
6108 tempbx = 853 ;
6109
6110 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6111 {
6112 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6113 {
6114 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6115 tempbx = tempbx >> 1 ;
6116 }
6117 else
6118 tempbx = tempbx >> 1 ;
6119 }
6120
6121 tempbx -= 2 ;
6122 temp = tempbx & 0x00FF ;
6123
6124 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6125 {
6126 if ( pVBInfo->VBType & VB_XGI301LV )
6127 {
6128 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6129 {
6130 if ( pVBInfo->VBInfo & SetInSlaveMode )
6131 {
6132 if ( ModeNo == 0x2f )
6133 temp += 1 ;
6134 }
6135 }
6136 }
6137 else
6138 {
6139 if ( pVBInfo->VBInfo & SetInSlaveMode )
6140 {
6141 if ( ModeNo == 0x2f )
6142 temp += 1 ;
6143 }
6144 }
6145 }
6146
6147 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6148
6149 temp = ( tempcx & 0xFF00 ) >> 8 ;
6150 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6151
6152 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6153 {
6154 if ( pVBInfo->VBType & VB_XGI301LV )
6155 {
6156 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6157 {
6158 temp |= 0x10 ;
6159
6160 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6161 temp |= 0x20 ;
6162 }
6163 }
6164 else
6165 {
6166 temp |= 0x10 ;
6167 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6168 temp |= 0x20 ;
6169 }
6170 }
6171
6172 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6173
6174 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6175 {
6176 tempbx = pVBInfo->VDE ;
6177 tempcx = tempbx - 2 ;
6178
6179 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6180 {
6181 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6182 tempbx = tempbx >> 1 ;
6183 }
6184
6185 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6186 {
6187 temp=0;
6188 if( tempcx & 0x0400 )
6189 temp |= 0x20 ;
6190
6191 if ( tempbx & 0x0400 )
6192 temp |= 0x40 ;
6193
6194 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6195 }
6196
6197 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6198 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6199 temp = ( tempbx - 3 ) & 0x00FF ;
6200 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6201 }
6202
6203 tempbx = tempbx & 0x00FF ;
6204
6205 if ( !( modeflag & HalfDCLK ) )
6206 {
6207 tempcx = pVBInfo->VGAHDE ;
6208 if ( tempcx >= pVBInfo->HDE )
6209 {
6210 tempbx |= 0x2000 ;
6211 tempax &= 0x00FF ;
6212 }
6213 }
6214
6215 tempcx = 0x0101 ;
6216
6217 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6218 if(pVBInfo->VGAHDE>=1024)
6219 {
6220 tempcx=0x1920;
6221 if(pVBInfo->VGAHDE>=1280)
6222 {
6223 tempcx=0x1420;
6224 tempbx=tempbx&0xDFFF;
6225 }
6226 }
6227 }
6228
6229 if ( !( tempbx & 0x2000 ) )
6230 {
6231 if ( modeflag & HalfDCLK )
6232 {
6233 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6234 }
6235
6236 push1 = tempbx ;
6237 tempeax = pVBInfo->VGAHDE ;
6238 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6239 longtemp = tempeax * tempebx ;
6240 tempecx = tempcx & 0x00FF ;
6241 longtemp = longtemp / tempecx ;
6242
6243 /* 301b */
6244 tempecx = 8 * 1024 ;
6245
6246 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6247 {
6248 tempecx = tempecx * 8 ;
6249 }
6250
6251 longtemp = longtemp * tempecx ;
6252 tempecx = pVBInfo->HDE ;
6253 temp2 = longtemp % tempecx ;
6254 tempeax = longtemp / tempecx ;
6255 if ( temp2 != 0 )
6256 {
6257 tempeax += 1 ;
6258 }
6259
6260 tempax = ( USHORT )tempeax ;
6261
6262 /* 301b */
6263 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6264 {
6265 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6266 }
6267 /* end 301b */
6268
6269 tempbx = push1 ;
6270 tempbx =( USHORT )( ( ( tempeax & 0x0000FF00 ) & 0x1F00 ) | ( tempbx & 0x00FF ) ) ;
6271 tempax =( USHORT )( ( ( tempeax & 0x000000FF ) << 8 ) | ( tempax & 0x00FF ) ) ;
6272 temp = ( tempax & 0xFF00 ) >> 8 ;
6273 }
6274 else
6275 {
6276 temp = ( tempax & 0x00FF ) >> 8 ;
6277 }
6278
6279 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6280 temp = ( tempbx & 0xFF00 ) >> 8 ;
6281 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6282 temp = tempcx & 0x00FF ;
6283
6284 if ( tempbx & 0x2000 )
6285 temp = 0 ;
6286
6287 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6288 temp |= 0x18 ;
6289
6290 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6291 if ( pVBInfo->TVInfo & SetPALTV )
6292 {
6293 tempbx = 0x0382 ;
6294 tempcx = 0x007e ;
6295 }
6296 else
6297 {
6298 tempbx = 0x0369 ;
6299 tempcx = 0x0061 ;
6300 }
6301
6302 temp = tempbx & 0x00FF ;
6303 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6304 temp = tempcx & 0x00FF ;
6305 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6306
6307 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6308 temp = temp << 2 ;
6309 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6310
6311 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6312 {
6313 temp |= 0x10 ;
6314
6315 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6316 temp |= 0x20 ;
6317
6318 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6319 temp |= 0x60 ;
6320 }
6321
6322 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6323 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
6324 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , ( USHORT )( temp - 3 ) ) ;
6325
6326 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6327 {
6328 if ( pVBInfo->TVInfo & NTSC1024x768 )
6329 {
6330 TimingPoint = XGI_NTSC1024AdjTime ;
6331 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6332 {
6333 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6334 }
6335 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6336 }
6337 }
6338
6339 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6340 if ( pVBInfo->VBType & VB_XGI301C )
6341 {
6342 if ( pVBInfo->TVInfo & SetPALMTV )
6343 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6344 }
6345
6346 if ( pVBInfo->TVInfo & SetPALMTV )
6347 {
6348 tempax = ( UCHAR )XGINew_GetReg1( pVBInfo->Part2Port , 0x01 ) ;
6349 tempax-- ;
6350 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6351
6352 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6353 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6354 }
6355
6356 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6357 {
6358 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6359 {
6360 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6361 }
6362 }
6363
6364 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6365 {
6366 return ;
6367 }
6368 }
6369
6370
6371 /* --------------------------------------------------------------------- */
6372 /* Function : XGI_SetLCDRegs */
6373 /* Input : */
6374 /* Output : */
6375 /* Description : */
6376 /* --------------------------------------------------------------------- */
6377 void XGI_SetLCDRegs(USHORT ModeNo,USHORT ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
6378 {
6379 USHORT push1 ,
6380 push2 ,
6381 pushbx ,
6382 tempax ,
6383 tempbx ,
6384 tempcx ,
6385 temp ,
6386 tempah ,
6387 tempbh ,
6388 tempch ,
6389 resinfo ,
6390 modeflag ,
6391 CRT1Index ;
6392
6393 XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6394
6395
6396 if ( ModeNo <= 0x13 )
6397 {
6398 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6399 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6400 }
6401 else
6402 {
6403 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6404 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6405 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6406 CRT1Index &= IndexMask ;
6407 }
6408
6409 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6410 {
6411 return ;
6412 }
6413
6414 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6415
6416 if ( XGI_IsLCDDualLink( pVBInfo ) )
6417 tempbx = tempbx >> 1 ;
6418
6419 tempbx -= 1 ;
6420 temp = tempbx & 0x00FF ;
6421 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6422 temp = ( tempbx & 0xFF00 ) >> 8 ;
6423 temp = temp << 4 ;
6424 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6425 temp = 0x01 ;
6426
6427 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6428 {
6429 if ( pVBInfo->ModeType == ModeEGA )
6430 {
6431 if ( pVBInfo->VGAHDE >= 1024 )
6432 {
6433 temp = 0x02 ;
6434 if ( pVBInfo->LCDInfo & LCDVESATiming )
6435 temp = 0x01 ;
6436 }
6437 }
6438 }
6439
6440 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6441 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6442 push1 = tempbx ;
6443 tempbx-- ;
6444 temp = tempbx & 0x00FF ;
6445 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6446 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6447 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6448
6449 tempcx = pVBInfo->VT - 1 ;
6450 push2 = tempcx + 1 ;
6451 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6452 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6453 temp = ( tempcx & 0xFF00 ) >> 8 ;
6454 temp = temp << 5 ;
6455 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6456 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6457 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6458 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6459 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6460
6461 /* Customized LCDB Des no add */
6462 tempbx = 5 ;
6463 LCDBDesPtr = ( XGI_LCDDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
6464 tempah = pVBInfo->LCDResInfo ;
6465 tempah &= PanelResInfo ;
6466
6467 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6468 {
6469 tempbx = 1024 ;
6470 tempcx = 768 ;
6471 }
6472 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6473 {
6474 tempbx = 1280 ;
6475 tempcx = 1024 ;
6476 }
6477 else if ( tempah == Panel1400x1050 )
6478 {
6479 tempbx = 1400 ;
6480 tempcx = 1050 ;
6481 }
6482 else
6483 {
6484 tempbx = 1600 ;
6485 tempcx = 1200 ;
6486 }
6487
6488 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6489 {
6490 tempbx = pVBInfo->HDE ;
6491 tempcx = pVBInfo->VDE ;
6492 }
6493
6494 pushbx = tempbx ;
6495 tempax = pVBInfo->VT ;
6496 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6497 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6498 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6499 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6500 tempbx = pVBInfo->LCDVDES ;
6501 tempcx += tempbx ;
6502
6503 if ( tempcx >= tempax )
6504 tempcx -= tempax ; /* lcdvdes */
6505
6506 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6507 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6508 temp = tempcx & 0x00FF ;
6509 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6510 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6511 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6512 tempah = tempch ;
6513 tempah = tempah << 3 ;
6514 tempah |= tempbh ;
6515 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6516
6517 /* getlcdsync() */
6518 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6519 tempcx = tempbx ;
6520 tempax = pVBInfo->VT ;
6521 tempbx = pVBInfo->LCDVRS ;
6522
6523 /* if ( SetLCD_Info & EnableScalingLCD ) */
6524 tempcx += tempbx ;
6525 if ( tempcx >= tempax )
6526 tempcx -= tempax ;
6527
6528 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6529 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6530 temp = ( tempbx & 0xFF00 ) >> 8 ;
6531 temp = temp << 4 ;
6532 temp |= ( tempcx & 0x000F ) ;
6533 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6534 tempcx = pushbx ;
6535 tempax = pVBInfo->HT ;
6536 tempbx = pVBInfo->LCDHDES ;
6537 tempbx &= 0x0FFF ;
6538
6539 if ( XGI_IsLCDDualLink( pVBInfo ) )
6540 {
6541 tempax = tempax >> 1 ;
6542 tempbx = tempbx >> 1 ;
6543 tempcx = tempcx >> 1 ;
6544 }
6545
6546 if ( pVBInfo->VBType & VB_XGI302LV )
6547 tempbx += 1 ;
6548
6549 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6550 tempbx += 1 ;
6551
6552 tempcx += tempbx ;
6553
6554 if ( tempcx >= tempax )
6555 tempcx -= tempax ;
6556
6557 temp = tempbx & 0x00FF ;
6558 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6559 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6560 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6561 temp = tempcx & 0x00FF ;
6562 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6563 temp = ( tempcx & 0xFF00 ) >> 8 ;
6564 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6565
6566 /* getlcdsync() */
6567 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6568 tempcx = tempax ;
6569 tempax = pVBInfo->HT ;
6570 tempbx = pVBInfo->LCDHRS ;
6571 /* if ( SetLCD_Info & EnableScalingLCD) */
6572 if ( XGI_IsLCDDualLink( pVBInfo) )
6573 {
6574 tempax = tempax >> 1 ;
6575 tempbx = tempbx >> 1 ;
6576 tempcx = tempcx >> 1 ;
6577 }
6578
6579 if ( pVBInfo->VBType & VB_XGI302LV )
6580 tempbx += 1 ;
6581
6582 tempcx += tempbx ;
6583
6584 if ( tempcx >= tempax )
6585 tempcx -= tempax ;
6586
6587 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6588 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6589
6590 temp = ( tempbx & 0xFF00 ) >> 8 ;
6591 temp = temp << 4 ;
6592 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6593 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6594 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6595
6596 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6597 {
6598 if ( pVBInfo->VGAVDE == 525 )
6599 {
6600 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6601 {
6602 temp = 0xC6 ;
6603 }
6604 else
6605 temp = 0xC4 ;
6606
6607 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6608 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6609 }
6610
6611 if ( pVBInfo->VGAVDE == 420 )
6612 {
6613 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6614 {
6615 temp = 0x4F ;
6616 }
6617 else
6618 temp = 0x4E ;
6619 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6620 }
6621 }
6622 }
6623
6624
6625 /* --------------------------------------------------------------------- */
6626 /* Function : XGI_GetTap4Ptr */
6627 /* Input : */
6628 /* Output : di -> Tap4 Reg. Setting Pointer */
6629 /* Description : */
6630 /* --------------------------------------------------------------------- */
6631 XGI301C_Tap4TimingStruct* XGI_GetTap4Ptr(USHORT tempcx, PVB_DEVICE_INFO pVBInfo)
6632 {
6633 USHORT tempax ,
6634 tempbx ,
6635 i ;
6636
6637 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6638
6639 if ( tempcx == 0 )
6640 {
6641 tempax = pVBInfo->VGAHDE ;
6642 tempbx = pVBInfo->HDE ;
6643 }
6644 else
6645 {
6646 tempax = pVBInfo->VGAVDE ;
6647 tempbx = pVBInfo->VDE ;
6648 }
6649
6650 if ( tempax < tempbx )
6651 return &EnlargeTap4Timing[ 0 ] ;
6652 else if( tempax == tempbx )
6653 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6654 else
6655 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6656
6657 if ( pVBInfo->TVInfo & SetPALTV )
6658 Tap4TimingPtr = PALTap4Timing ;
6659
6660
6661 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6662 {
6663 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6664 Tap4TimingPtr = YPbPr525iTap4Timing ;
6665 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6666 Tap4TimingPtr = YPbPr525pTap4Timing ;
6667 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6668 Tap4TimingPtr = YPbPr750pTap4Timing ;
6669 }
6670
6671 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6672 Tap4TimingPtr = HiTVTap4Timing ;
6673
6674 i = 0 ;
6675 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6676 {
6677 if ( Tap4TimingPtr[ i ].DE == tempax )
6678 break ;
6679 i++ ;
6680 }
6681 return &Tap4TimingPtr[ i ] ;
6682 }
6683
6684
6685 /* --------------------------------------------------------------------- */
6686 /* Function : XGI_SetTap4Regs */
6687 /* Input : */
6688 /* Output : */
6689 /* Description : */
6690 /* --------------------------------------------------------------------- */
6691 void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo)
6692 {
6693 USHORT i ,
6694 j ;
6695
6696 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6697
6698 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6699 return ;
6700
6701 #ifndef Tap4
6702 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6703 #else /* Tap4 Setting */
6704
6705 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6706 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6707 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6708
6709 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6710 {
6711 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6712 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6713 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6714 }
6715
6716 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6717 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
6718 else
6719 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
6720 #endif
6721 }
6722
6723 /* --------------------------------------------------------------------- */
6724 /* Function : XGI_SetGroup3 */
6725 /* Input : */
6726 /* Output : */
6727 /* Description : */
6728 /* --------------------------------------------------------------------- */
6729 void XGI_SetGroup3(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
6730 {
6731 USHORT i;
6732 UCHAR *tempdi;
6733 USHORT modeflag;
6734
6735 if(ModeNo<=0x13)
6736 {
6737 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6738 }
6739 else
6740 {
6741 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6742 }
6743
6744
6745 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
6746 if(pVBInfo->TVInfo&SetPALTV)
6747 {
6748 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6749 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6750 }
6751 else
6752 {
6753 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
6754 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
6755 }
6756
6757 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
6758 {
6759 return;
6760 }
6761
6762 if(pVBInfo->TVInfo&SetPALMTV)
6763 {
6764 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6765 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6766 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
6767 }
6768
6769 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
6770 {
6771 if(pVBInfo->TVInfo & SetYPbPrMode525i)
6772 {
6773 return;
6774 }
6775 tempdi=pVBInfo->HiTVGroup3Data;
6776 if(pVBInfo->SetFlag&TVSimuMode)
6777 {
6778 tempdi=pVBInfo->HiTVGroup3Simu;
6779 if(!(modeflag&Charx8Dot))
6780 {
6781 tempdi=pVBInfo->HiTVGroup3Text;
6782 }
6783 }
6784
6785 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6786 {
6787 tempdi=pVBInfo->Ren525pGroup3;
6788 }
6789 if(pVBInfo->TVInfo & SetYPbPrMode750p)
6790 {
6791 tempdi=pVBInfo->Ren750pGroup3;
6792 }
6793
6794 for(i=0;i<=0x3E;i++)
6795 {
6796 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
6797 }
6798 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
6799 {
6800 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6801 {
6802 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
6803 }
6804 }
6805 }
6806 return;
6807 } /* {end of XGI_SetGroup3} */
6808
6809
6810 /* --------------------------------------------------------------------- */
6811 /* Function : XGI_SetGroup4 */
6812 /* Input : */
6813 /* Output : */
6814 /* Description : */
6815 /* --------------------------------------------------------------------- */
6816 void XGI_SetGroup4(USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
6817 {
6818 USHORT tempax ,
6819 tempcx ,
6820 tempbx ,
6821 modeflag ,
6822 temp ,
6823 temp2 ;
6824
6825 ULONG tempebx ,
6826 tempeax ,
6827 templong ;
6828
6829
6830 if ( ModeNo <= 0x13 )
6831 {
6832 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6833 }
6834 else
6835 {
6836 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6837 }
6838
6839 temp = pVBInfo->RVBHCFACT ;
6840 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
6841
6842 tempbx = pVBInfo->RVBHCMAX ;
6843 temp = tempbx & 0x00FF ;
6844 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
6845 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
6846 tempcx = pVBInfo->VGAHT - 1 ;
6847 temp = tempcx & 0x00FF ;
6848 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
6849
6850 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
6851 temp2 |= temp ;
6852
6853 tempcx = pVBInfo->VGAVT - 1 ;
6854 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6855 {
6856 tempcx -= 5 ;
6857 }
6858
6859 temp = tempcx & 0x00FF ;
6860 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
6861 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
6862 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
6863 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
6864 tempcx = pVBInfo->VBInfo ;
6865 tempbx = pVBInfo->VGAHDE ;
6866
6867 if ( modeflag & HalfDCLK )
6868 {
6869 tempbx = tempbx >> 1 ;
6870 }
6871
6872 if ( XGI_IsLCDDualLink( pVBInfo ) )
6873 tempbx = tempbx >> 1 ;
6874
6875 if(tempcx&SetCRT2ToHiVisionTV)
6876 {
6877 temp=0;
6878 if(tempbx<=1024)
6879 temp=0xA0;
6880 if(tempbx == 1280)
6881 temp = 0xC0;
6882 }
6883 else if(tempcx&SetCRT2ToTV)
6884 {
6885 temp=0xA0;
6886 if(tempbx <= 800)
6887 temp=0x80;
6888 }
6889 else
6890 {
6891 temp=0x80;
6892 if(pVBInfo->VBInfo&SetCRT2ToLCD)
6893 {
6894 temp=0;
6895 if(tempbx>800)
6896 temp=0x60;
6897 }
6898 }
6899
6900 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6901 {
6902 temp = 0x00 ;
6903 if ( pVBInfo->VGAHDE == 1280 )
6904 temp = 0x40 ;
6905 if ( pVBInfo->VGAHDE == 1024 )
6906 temp = 0x20 ;
6907 }
6908 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
6909
6910 tempebx = pVBInfo->VDE ;
6911
6912 if ( tempcx & SetCRT2ToHiVisionTV )
6913 {
6914 if ( !( temp & 0xE000 ) )
6915 tempbx = tempbx >> 1 ;
6916 }
6917
6918 tempcx = pVBInfo->RVBHRS ;
6919 temp = tempcx & 0x00FF ;
6920 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
6921
6922 tempeax = pVBInfo->VGAVDE ;
6923 tempcx |= 0x04000 ;
6924
6925
6926 if ( tempeax <= tempebx )
6927 {
6928 tempcx=(tempcx&(~0x4000));
6929 tempeax = pVBInfo->VGAVDE ;
6930 }
6931 else
6932 {
6933 tempeax -= tempebx ;
6934 }
6935
6936
6937 templong = ( tempeax * 256 * 1024 ) % tempebx ;
6938 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
6939 tempebx = tempeax ;
6940
6941 if ( templong != 0 )
6942 {
6943 tempebx++ ;
6944 }
6945
6946
6947 temp = ( USHORT )( tempebx & 0x000000FF ) ;
6948 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
6949
6950 temp = ( USHORT )( ( tempebx & 0x0000FF00 ) >> 8 ) ;
6951 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
6952 tempbx = ( USHORT )( tempebx >> 16 ) ;
6953 temp = tempbx & 0x00FF ;
6954 temp = temp << 4 ;
6955 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
6956 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
6957
6958 /* 301b */
6959 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6960 {
6961 temp = 0x0028 ;
6962 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
6963 tempax = pVBInfo->VGAHDE ;
6964 if ( modeflag & HalfDCLK )
6965 {
6966 tempax = tempax >> 1 ;
6967 }
6968
6969 if ( XGI_IsLCDDualLink( pVBInfo ) )
6970 tempax = tempax >> 1 ;
6971
6972 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6973 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
6974 {
6975 if ( tempax > 800 )
6976 tempax -= 800 ;
6977 }
6978 else
6979 {
6980 if ( pVBInfo->VGAHDE > 800 )
6981 {
6982 if ( pVBInfo->VGAHDE == 1024 )
6983 tempax = ( tempax * 25 / 32 ) - 1 ;
6984 else
6985 tempax = ( tempax * 20 / 32 ) - 1 ;
6986 }
6987 }
6988 tempax -= 1 ;
6989
6990 /*
6991 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
6992 {
6993 if ( pVBInfo->VBType & VB_XGI301LV )
6994 {
6995 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
6996 {
6997 if ( pVBInfo->VGAHDE > 800 )
6998 {
6999 if ( pVBInfo->VGAHDE == 1024 )
7000 tempax = ( tempax * 25 / 32 ) - 1 ;
7001 else
7002 tempax = ( tempax * 20 / 32 ) - 1 ;
7003 }
7004 }
7005 }
7006 else
7007 {
7008 if ( pVBInfo->VGAHDE > 800 )
7009 {
7010 if ( pVBInfo->VGAHDE == 1024 )
7011 tempax = ( tempax * 25 / 32 ) - 1 ;
7012 else
7013 tempax = ( tempax * 20 / 32 ) - 1 ;
7014 }
7015 }
7016 }
7017 */
7018
7019 temp = ( tempax & 0xFF00 ) >> 8 ;
7020 temp = ( ( temp & 0x0003 ) << 4 ) ;
7021 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
7022 temp = ( tempax & 0x00FF ) ;
7023 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7024
7025 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7026 {
7027 if ( pVBInfo->VGAHDE > 800 )
7028 {
7029 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7030 }
7031 }
7032 temp = 0x0036 ;
7033
7034 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7035 {
7036 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7037 {
7038 temp |= 0x0001 ;
7039 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7040 temp &= ( ~0x0001 ) ;
7041 }
7042 }
7043
7044 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7045 tempbx = pVBInfo->HT ;
7046 if ( XGI_IsLCDDualLink( pVBInfo ) )
7047 tempbx = tempbx >> 1 ;
7048 tempbx = ( tempbx >> 1 ) - 2 ;
7049 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7050 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7051 temp = tempbx & 0x00FF ;
7052 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7053 }
7054 /* end 301b */
7055
7056 if ( pVBInfo->ISXPDOS == 0 )
7057 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7058 }
7059
7060
7061 /* --------------------------------------------------------------------- */
7062 /* Function : XGI_SetGroup5 */
7063 /* Input : */
7064 /* Output : */
7065 /* Description : */
7066 /* --------------------------------------------------------------------- */
7067 void XGI_SetGroup5( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
7068 {
7069 USHORT Pindex ,
7070 Pdata ;
7071
7072 Pindex = pVBInfo->Part5Port ;
7073 Pdata = pVBInfo->Part5Port + 1 ;
7074 if ( pVBInfo->ModeType == ModeVGA )
7075 {
7076 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7077 {
7078 XGINew_EnableCRT2(pVBInfo) ;
7079 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7080 }
7081 }
7082 return ;
7083 }
7084
7085
7086 /* --------------------------------------------------------------------- */
7087 /* Function : XGI_GetLcdPtr */
7088 /* Input : */
7089 /* Output : */
7090 /* Description : */
7091 /* --------------------------------------------------------------------- */
7092 void* XGI_GetLcdPtr( USHORT BX , USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7093 {
7094 USHORT i ,
7095 tempdx ,
7096 tempcx ,
7097 tempbx ,
7098 tempal ,
7099 modeflag ,
7100 table ;
7101
7102 XGI330_LCDDataTablStruct *tempdi = 0 ;
7103
7104
7105 tempbx = BX;
7106
7107 if ( ModeNo <= 0x13 )
7108 {
7109 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7110 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7111 }
7112 else
7113 {
7114 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7115 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7116 }
7117
7118 tempal = tempal & 0x0f ;
7119
7120 if ( tempbx <= 1 ) /* ExpLink */
7121 {
7122 if ( ModeNo <= 0x13 )
7123 {
7124 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7125 }
7126 else
7127 {
7128 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7129 }
7130
7131 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7132 {
7133 if ( ModeNo <= 0x13 )
7134 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7135 else
7136 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7137 }
7138
7139 if ( tempbx & 0x01 )
7140 tempal = ( tempal >> 4 ) ;
7141
7142 tempal = ( tempal & 0x0f ) ;
7143 }
7144
7145 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7146
7147 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7148 {
7149 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7150 tempcx = LCDDesDataLen2 ;
7151 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7152 tempcx = LVDSDesDataLen2 ;
7153 }
7154 /* mov di, word ptr cs:LCDDataList[bx] */
7155 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7156
7157 switch( tempbx )
7158 {
7159 case 0:
7160 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7161 break ;
7162 case 1:
7163 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7164 break ;
7165 case 2:
7166 tempdi = XGI_EPLLCDDataPtr ;
7167 break ;
7168 case 3:
7169 tempdi = XGI_EPLLCDDesDataPtr ;
7170 break ;
7171 case 4:
7172 tempdi = XGI_LCDDataTable ;
7173 break ;
7174 case 5:
7175 tempdi = XGI_LCDDesDataTable ;
7176 break ;
7177 case 6:
7178 tempdi = XGI_EPLCHLCDRegPtr ;
7179 break ;
7180 case 7:
7181 case 8:
7182 case 9:
7183 tempdi = 0 ;
7184 break ;
7185 default:
7186 break ;
7187 }
7188
7189 if ( tempdi == 0x00 ) /* OEMUtil */
7190 return 0 ;
7191
7192 table = tempbx ;
7193 i = 0 ;
7194
7195 while( tempdi[ i ].PANELID != 0xff )
7196 {
7197 tempdx = pVBInfo->LCDResInfo ;
7198 if ( tempbx & 0x0080 ) /* OEMUtil */
7199 {
7200 tempbx &= ( ~0x0080 ) ;
7201 tempdx = pVBInfo->LCDTypeInfo ;
7202 }
7203
7204 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7205 tempdx &= ( ~PanelResInfo ) ;
7206
7207 if ( tempdi[ i ].PANELID == tempdx )
7208 {
7209 tempbx = tempdi[ i ].MASK ;
7210 tempdx = pVBInfo->LCDInfo ;
7211
7212 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7213 tempdx |= SetLCDStdMode ;
7214
7215 if ( modeflag & HalfDCLK )
7216 tempdx |= SetLCDLowResolution ;
7217
7218 tempbx &= tempdx;
7219 if ( tempbx == tempdi[ i ].CAP )
7220 break ;
7221 }
7222 i++ ;
7223 }
7224
7225 if ( table == 0 )
7226 {
7227 switch( tempdi[ i ].DATAPTR )
7228 {
7229 case 0:
7230 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7231 break ;
7232 case 1:
7233 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7234 break ;
7235 case 2:
7236 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7237 break ;
7238 case 3:
7239 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7240 break ;
7241 case 4:
7242 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7243 break ;
7244 case 5:
7245 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7246 break ;
7247 case 6:
7248 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7249 break ;
7250 case 7:
7251 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7252 break ;
7253 case 8:
7254 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7255 break ;
7256 case 9:
7257 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7258 break ;
7259 case 10:
7260 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7261 break ;
7262 default:
7263 break ;
7264 }
7265 }
7266 else if ( table == 1 )
7267 {
7268 switch( tempdi[ i ].DATAPTR )
7269 {
7270 case 0:
7271 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7272 break ;
7273 case 1:
7274 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7275 break ;
7276 case 2:
7277 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7278 break ;
7279 case 3:
7280 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7281 break ;
7282 case 4:
7283 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7284 break ;
7285 case 5:
7286 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7287 break ;
7288 case 6:
7289 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7290 break ;
7291 case 7:
7292 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7293 break ;
7294 case 8:
7295 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7296 break ;
7297 case 9:
7298 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7299 break ;
7300 case 10:
7301 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7302 break ;
7303 default:
7304 break ;
7305 }
7306 }
7307 else if ( table == 2 )
7308 {
7309 switch( tempdi[ i ].DATAPTR )
7310 {
7311 case 0:
7312 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7313 break ;
7314 case 1:
7315 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7316 break ;
7317 case 2:
7318 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7319 break ;
7320 case 3:
7321 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7322 break ;
7323 case 4:
7324 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7325 break ;
7326 case 5:
7327 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7328 break ;
7329 case 6:
7330 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7331 break ;
7332 case 7:
7333 return &XGI_LVDSNoScalingData[ tempal ] ;
7334 break ;
7335 case 8:
7336 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7337 break ;
7338 case 9:
7339 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7340 break ;
7341 case 10:
7342 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7343 break ;
7344 case 11:
7345 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7346 break ;
7347 case 12:
7348 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7349 break ;
7350 default:
7351 break ;
7352 }
7353 }
7354 else if ( table == 3 )
7355 {
7356 switch( tempdi[ i ].DATAPTR )
7357 {
7358 case 0:
7359 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7360 break ;
7361 case 1:
7362 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7363 break ;
7364 case 2:
7365 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7366 break ;
7367 case 3:
7368 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7369 break ;
7370 case 4:
7371 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7372 break ;
7373 case 5:
7374 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7375 break ;
7376 case 6:
7377 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7378 break ;
7379 case 7:
7380 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7381 break ;
7382 case 8:
7383 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7384 break ;
7385 case 9:
7386 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7387 break ;
7388 case 10:
7389 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7390 break ;
7391 case 11:
7392 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7393 break;
7394 case 12:
7395 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7396 break ;
7397 case 13:
7398 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7399 break ;
7400 case 14:
7401 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7402 break ;
7403 default:
7404 break ;
7405 }
7406 }
7407 else if ( table == 4 )
7408 {
7409 switch( tempdi[ i ].DATAPTR )
7410 {
7411 case 0:
7412 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7413 break ;
7414 case 1:
7415 return &XGI_StLCD1024x768Data[ tempal ] ;
7416 break ;
7417 case 2:
7418 return &XGI_CetLCD1024x768Data[ tempal ] ;
7419 break ;
7420 case 3:
7421 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7422 break ;
7423 case 4:
7424 return &XGI_StLCD1280x1024Data[ tempal ] ;
7425 break ;
7426 case 5:
7427 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7428 break ;
7429 case 6:
7430 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7431 break ;
7432 case 7:
7433 return &XGI_StLCD1400x1050Data[ tempal ] ;
7434 break ;
7435 case 8:
7436 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7437 break ;
7438 case 9:
7439 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7440 break ;
7441 case 10:
7442 return &XGI_StLCD1600x1200Data[ tempal ] ;
7443 break ;
7444 case 11:
7445 return &XGI_NoScalingData[ tempal ] ;
7446 break ;
7447 case 12:
7448 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7449 break ;
7450 case 13:
7451 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7452 break ;
7453 case 14:
7454 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7455 break ;
7456 case 15:
7457 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7458 break ;
7459 case 16:
7460 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7461 break;
7462 case 17:
7463 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7464 break;
7465 case 18:
7466 return &XGI_NoScalingDatax75[ tempal ] ;
7467 break ;
7468 default:
7469 break ;
7470 }
7471 }
7472 else if ( table == 5 )
7473 {
7474 switch( tempdi[ i ].DATAPTR )
7475 {
7476 case 0:
7477 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7478 break ;
7479 case 1:
7480 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7481 break ;
7482 case 2:
7483 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7484 break ;
7485 case 3:
7486 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7487 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7488 else
7489 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7490 break ;
7491 case 4:
7492 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7493 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7494 else
7495 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7496 break ;
7497 case 5:
7498 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7499 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7500 else
7501 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7502 break ;
7503 case 6:
7504 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7505 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7506 else
7507 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7508 break ;
7509 case 7:
7510 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7511 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7512 else
7513 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7514 break ;
7515 case 8:
7516 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7517 break ;
7518 case 9:
7519 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7520 break ;
7521 case 10:
7522 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7523 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7524 else
7525 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7526 break ;
7527 case 11:
7528 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7529 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7530 else
7531 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7532 break ;
7533 case 12:
7534 return &XGI_NoScalingDesData[ tempal ] ;
7535 break;
7536 case 13:
7537 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7538 break ;
7539 case 14:
7540 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7541 break ;
7542 case 15:
7543 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7544 break ;
7545 case 16:
7546 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7547 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7548 else
7549 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7550 break ;
7551 case 17:
7552 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7553 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7554 else
7555 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7556 break ;
7557 case 18:
7558 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7559 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7560 else
7561 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7562 break ;
7563 case 19:
7564 return &XGI_NoScalingDesDatax75[ tempal ] ;
7565 break ;
7566 default:
7567 break ;
7568 }
7569 }
7570 else if ( table == 6 )
7571 {
7572 switch( tempdi[ i ].DATAPTR )
7573 {
7574 case 0:
7575 return &XGI_CH7017LV1024x768[ tempal ] ;
7576 break ;
7577 case 1:
7578 return &XGI_CH7017LV1400x1050[ tempal ] ;
7579 break ;
7580 default:
7581 break ;
7582 }
7583 }
7584 return 0 ;
7585 }
7586
7587
7588 /* --------------------------------------------------------------------- */
7589 /* Function : XGI_GetTVPtr */
7590 /* Input : */
7591 /* Output : */
7592 /* Description : */
7593 /* --------------------------------------------------------------------- */
7594 void* XGI_GetTVPtr (USHORT BX,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
7595 {
7596 USHORT i , tempdx , tempbx , tempal , modeflag , table ;
7597 XGI330_TVDataTablStruct *tempdi = 0 ;
7598
7599 tempbx = BX ;
7600
7601 if ( ModeNo <= 0x13 )
7602 {
7603 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7604 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7605 }
7606 else
7607 {
7608 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7609 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7610 }
7611
7612 tempal = tempal & 0x3f ;
7613 table = tempbx ;
7614
7615 switch( tempbx )
7616 {
7617 case 0:
7618 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7619 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7620 {
7621 tempdi = XGI_EPLCHTVCRT1Ptr;
7622 }
7623 break ;
7624 case 1:
7625 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7626 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7627 {
7628 tempdi = XGI_EPLCHTVCRT1Ptr;
7629 }
7630 break ;
7631 case 2:
7632 tempdi = XGI_EPLCHTVDataPtr ;
7633 break ;
7634 case 3:
7635 tempdi = 0 ;
7636 break ;
7637 case 4:
7638 tempdi = XGI_TVDataTable ;
7639 break ;
7640 case 5:
7641 tempdi = 0 ;
7642 break ;
7643 case 6:
7644 tempdi = XGI_EPLCHTVRegPtr ;
7645 break ;
7646 default:
7647 break ;
7648 }
7649
7650 if ( tempdi == 0x00 ) /* OEMUtil */
7651 return( 0 ) ;
7652
7653 tempdx = pVBInfo->TVInfo ;
7654
7655 if ( pVBInfo->VBInfo & SetInSlaveMode )
7656 tempdx = tempdx | SetTVLockMode ;
7657
7658 if ( modeflag & HalfDCLK )
7659 tempdx = tempdx | SetTVLowResolution ;
7660
7661 i = 0 ;
7662
7663 while( tempdi[ i ].MASK != 0xffff )
7664 {
7665 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7666 break ;
7667 i++ ;
7668 }
7669
7670 if ( table == 0x00 ) /* 07/05/22 */
7671 {
7672 }
7673 else if ( table == 0x01 )
7674 {
7675 }
7676 else if ( table == 0x04 )
7677 {
7678 switch( tempdi[ i ].DATAPTR )
7679 {
7680 case 0:
7681 return &XGI_ExtPALData[ tempal ] ;
7682 break ;
7683 case 1:
7684 return &XGI_ExtNTSCData[ tempal ] ;
7685 break ;
7686 case 2:
7687 return &XGI_StPALData[ tempal ] ;
7688 break ;
7689 case 3:
7690 return &XGI_StNTSCData[ tempal ] ;
7691 break ;
7692 case 4:
7693 return &XGI_ExtHiTVData[ tempal ] ;
7694 break ;
7695 case 5:
7696 return &XGI_St2HiTVData[ tempal ] ;
7697 break ;
7698 case 6:
7699 return &XGI_ExtYPbPr525iData[ tempal ] ;
7700 break ;
7701 case 7:
7702 return &XGI_ExtYPbPr525pData[ tempal ] ;
7703 break ;
7704 case 8:
7705 return &XGI_ExtYPbPr750pData[ tempal ] ;
7706 break ;
7707 case 9:
7708 return &XGI_StYPbPr525iData[ tempal ] ;
7709 break ;
7710 case 10:
7711 return &XGI_StYPbPr525pData[ tempal ] ;
7712 break ;
7713 case 11:
7714 return &XGI_StYPbPr750pData[ tempal ] ;
7715 break;
7716 case 12: /* avoid system hang */
7717 return &XGI_ExtNTSCData[ tempal ] ;
7718 break ;
7719 case 13:
7720 return &XGI_St1HiTVData[ tempal ] ;
7721 break ;
7722 default:
7723 break ;
7724 }
7725 }
7726 else if( table == 0x02 )
7727 {
7728 switch( tempdi[ i ].DATAPTR )
7729 {
7730 case 0:
7731 return &XGI_CHTVUNTSCData[ tempal ] ;
7732 break ;
7733 case 1:
7734 return &XGI_CHTVONTSCData[ tempal ] ;
7735 break ;
7736 case 2:
7737 return &XGI_CHTVUPALData[ tempal ] ;
7738 break ;
7739 case 3:
7740 return &XGI_CHTVOPALData[ tempal ] ;
7741 break ;
7742 default:
7743 break ;
7744 }
7745 }
7746 else if( table == 0x06 )
7747 {
7748 }
7749 return( 0 ) ;
7750 }
7751
7752
7753 /* --------------------------------------------------------------------- */
7754 /* Function : XGI_BacklightByDrv */
7755 /* Input : */
7756 /* Output : TRUE -> Skip backlight control */
7757 /* Description : */
7758 /* --------------------------------------------------------------------- */
7759 BOOLEAN XGI_BacklightByDrv( PVB_DEVICE_INFO pVBInfo )
7760 {
7761 UCHAR tempah ;
7762
7763 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x3A ) ;
7764 if ( tempah & BacklightControlBit )
7765 return TRUE ;
7766 else
7767 return FALSE ;
7768 }
7769
7770
7771 /* --------------------------------------------------------------------- */
7772 /* Function : XGI_FirePWDDisable */
7773 /* Input : */
7774 /* Output : */
7775 /* Description : Turn off VDD & Backlight : Fire disable procedure */
7776 /* --------------------------------------------------------------------- */
7777 /*
7778 void XGI_FirePWDDisable( PVB_DEVICE_INFO pVBInfo )
7779 {
7780 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
7781 }
7782 */
7783
7784 /* --------------------------------------------------------------------- */
7785 /* Function : XGI_FirePWDEnable */
7786 /* Input : */
7787 /* Output : */
7788 /* Description : Turn on VDD & Backlight : Fire enable procedure */
7789 /* --------------------------------------------------------------------- */
7790 void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo )
7791 {
7792 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
7793 }
7794
7795
7796 /* --------------------------------------------------------------------- */
7797 /* Function : XGI_EnableGatingCRT */
7798 /* Input : */
7799 /* Output : */
7800 /* Description : */
7801 /* --------------------------------------------------------------------- */
7802 void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7803 {
7804 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
7805 }
7806
7807
7808 /* --------------------------------------------------------------------- */
7809 /* Function : XGI_DisableGatingCRT */
7810 /* Input : */
7811 /* Output : */
7812 /* Description : */
7813 /* --------------------------------------------------------------------- */
7814 void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7815 {
7816
7817 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
7818 }
7819
7820
7821 /* --------------------------------------------------------------------- */
7822 /* Function : XGI_SetPanelDelay */
7823 /* Input : */
7824 /* Output : */
7825 /* Description : */
7826 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7827 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
7828 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
7829 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
7830 /* --------------------------------------------------------------------- */
7831 void XGI_SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7832 {
7833 USHORT index ;
7834
7835 index = XGI_GetLCDCapPtr(pVBInfo) ;
7836
7837 if ( tempbl == 1 )
7838 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
7839
7840 if ( tempbl == 2 )
7841 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
7842
7843 if ( tempbl == 3 )
7844 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
7845
7846 if ( tempbl == 4 )
7847 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
7848 }
7849
7850
7851 /* --------------------------------------------------------------------- */
7852 /* Function : XGI_SetPanelPower */
7853 /* Input : */
7854 /* Output : */
7855 /* Description : */
7856 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
7857 /* = 0111b = 07h ; Backlight on, Power off */
7858 /* = 1011b = 0Bh ; Backlight off, Power on */
7859 /* = 1111b = 0Fh ; Backlight off, Power off */
7860 /* --------------------------------------------------------------------- */
7861 void XGI_SetPanelPower(USHORT tempah,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7862 {
7863 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7864 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
7865 else
7866 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
7867 }
7868
7869 UCHAR XG21GPIODataTransfer(UCHAR ujDate)
7870 {
7871 UCHAR ujRet = 0;
7872 UCHAR i = 0;
7873
7874 for (i=0; i<8; i++)
7875 {
7876 ujRet = ujRet << 1;
7877 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
7878 ujRet |= (ujDate >> i) & 1;
7879 }
7880
7881 return ujRet;
7882 }
7883
7884 /*----------------------------------------------------------------------------*/
7885 /* output */
7886 /* bl[5] : LVDS signal */
7887 /* bl[1] : LVDS backlight */
7888 /* bl[0] : LVDS VDD */
7889 /*----------------------------------------------------------------------------*/
7890 UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7891 {
7892 UCHAR CR4A,temp;
7893
7894 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7895 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
7896
7897 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7898
7899 temp = XG21GPIODataTransfer(temp);
7900 temp &= 0x23;
7901 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7902 return temp;
7903 }
7904
7905 /*----------------------------------------------------------------------------*/
7906 /* output */
7907 /* bl[5] : LVDS signal */
7908 /* bl[1] : LVDS backlight */
7909 /* bl[0] : LVDS VDD */
7910 /*----------------------------------------------------------------------------*/
7911 UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7912 {
7913 UCHAR CR4A,CRB4,temp;
7914
7915 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7916 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
7917
7918 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7919
7920 temp &= 0x0C;
7921 temp >>= 2;
7922 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7923 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
7924 temp |= ((CRB4&0x04)<<3);
7925 return temp;
7926 }
7927 /*----------------------------------------------------------------------------*/
7928 /* input */
7929 /* bl[5] : 1;LVDS signal on */
7930 /* bl[1] : 1;LVDS backlight on */
7931 /* bl[0] : 1:LVDS VDD on */
7932 /* bh: 100000b : clear bit 5, to set bit5 */
7933 /* 000010b : clear bit 1, to set bit1 */
7934 /* 000001b : clear bit 0, to set bit0 */
7935 /*----------------------------------------------------------------------------*/
7936 void XGI_XG21BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7937 {
7938 UCHAR CR4A,temp;
7939
7940 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7941 tempbh &= 0x23;
7942 tempbl &= 0x23;
7943 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7944
7945 if (tempbh&0x20)
7946 {
7947 temp = (tempbl>>4)&0x02;
7948
7949 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7950
7951 }
7952
7953 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7954
7955 temp = XG21GPIODataTransfer(temp);
7956 temp &= ~tempbh;
7957 temp |= tempbl;
7958 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
7959 }
7960
7961 void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
7962 {
7963 UCHAR CR4A,temp;
7964 USHORT tempbh0,tempbl0;
7965
7966 tempbh0 = tempbh;
7967 tempbl0 = tempbl;
7968 tempbh0 &= 0x20;
7969 tempbl0 &= 0x20;
7970 tempbh0 >>= 3;
7971 tempbl0 >>= 3;
7972
7973 if (tempbh&0x20)
7974 {
7975 temp = (tempbl>>4)&0x02;
7976
7977 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7978
7979 }
7980 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
7981
7982 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7983 tempbh &= 0x03;
7984 tempbl &= 0x03;
7985 tempbh <<= 2;
7986 tempbl <<= 2; /* GPIOC,GPIOD */
7987 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7988 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
7989 }
7990
7991 /* --------------------------------------------------------------------- */
7992 USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo)
7993 {
7994 USHORT index ;
7995
7996 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
7997 if (index<sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct))
7998 {
7999 return index;
8000 }
8001 return 0;
8002 }
8003
8004 /* --------------------------------------------------------------------- */
8005 /* Function : XGI_XG21SetPanelDelay */
8006 /* Input : */
8007 /* Output : */
8008 /* Description : */
8009 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8010 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
8011 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
8012 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
8013 /* --------------------------------------------------------------------- */
8014 void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo)
8015 {
8016 USHORT index ;
8017
8018 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
8019 if ( tempbl == 1 )
8020 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8021
8022 if ( tempbl == 2 )
8023 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8024
8025 if ( tempbl == 3 )
8026 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8027
8028 if ( tempbl == 4 )
8029 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8030 }
8031
8032 BOOLEAN XGI_XG21CheckLVDSMode(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8033 {
8034 USHORT xres ,
8035 yres ,
8036 colordepth ,
8037 modeflag ,
8038 resindex ,
8039 lvdstableindex;
8040
8041 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8042 if ( ModeNo <= 0x13 )
8043 {
8044 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8045 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8046 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8047 }
8048 else
8049 {
8050 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8051 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8052 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8053 }
8054
8055 if ( !( modeflag & Charx8Dot ) )
8056 {
8057 xres /= 9;
8058 xres *= 8;
8059 }
8060
8061 if ( ModeNo > 0x13 )
8062 {
8063 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8064 {
8065 xres *= 2 ;
8066 }
8067 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8068 {
8069 yres *= 2 ;
8070 }
8071 }
8072
8073 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8074 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
8075 return FALSE;
8076
8077 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
8078 return FALSE;
8079
8080 if ( ModeNo > 0x13 )
8081 {
8082 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8083 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8084 {
8085 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
8086 if ( colordepth > 2 )
8087 {
8088 return FALSE;
8089 }
8090 }
8091 }
8092 return TRUE;
8093 }
8094
8095 void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo)
8096 {
8097 UCHAR temp;
8098
8099 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8100 temp = ( temp & 1 ) << 6;
8101 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8102 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8103
8104 }
8105
8106 void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo)
8107 {
8108 UCHAR temp;
8109
8110 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8111 temp = ( temp & 3 ) << 6;
8112 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8113 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8114
8115 }
8116
8117 void XGI_SetXG21LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8118 {
8119 UCHAR temp,Miscdata;
8120 USHORT xres ,
8121 yres ,
8122 modeflag ,
8123 resindex ,
8124 lvdstableindex ;
8125 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8126 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8127 USHORT value;
8128
8129 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8130
8131 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8132 temp &= LCDPolarity;
8133 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8134
8135 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8136
8137 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8138 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8139 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8140
8141 XGI_SetXG21FPBits(pVBInfo);
8142 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8143 if ( ModeNo <= 0x13 )
8144 {
8145 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8146 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8147 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8148 }
8149 else
8150 {
8151 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8152 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8153 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8154 }
8155
8156 if (!( modeflag & Charx8Dot ))
8157 xres = xres * 8 / 9;
8158
8159 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8160
8161 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8162 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8163 {
8164 LVDSHBS -= xres/4 ;
8165 }
8166 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8167
8168 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8169 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8170
8171 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8172 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8173
8174 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8175
8176 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8177
8178 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8179 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8180 {
8181 LVDSVBS += yres/2 ;
8182 }
8183 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8184
8185 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8186 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8187
8188 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8189 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8190
8191 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8192
8193 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8194 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8195
8196 if (!( modeflag & Charx8Dot ))
8197 {
8198 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8199 }
8200
8201 /* HT SR0B[1:0] CR00 */
8202 value = ( LVDSHT >> 3 ) - 5;
8203 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8204 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8205
8206 /* HBS SR0B[5:4] CR02 */
8207 value = ( LVDSHBS >> 3 ) - 1;
8208 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8209 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8210
8211 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8212 value = ( LVDSHBE >> 3 ) - 1;
8213 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8214 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8215 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8216
8217 /* HRS SR0B[7:6] CR04 */
8218 value = ( LVDSHRS >> 3 ) + 2;
8219 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8220 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8221
8222 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8223 value--;
8224 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8225 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8226
8227 /* HRE SR0C[2] CR05[4:0] */
8228 value = ( LVDSHRE >> 3 ) + 2;
8229 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8230 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8231
8232 /* Panel HRE SR2F[7:2] */
8233 value--;
8234 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8235
8236 /* VT SR0A[0] CR07[5][0] CR06 */
8237 value = LVDSVT - 2 ;
8238 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8239 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8240 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8241 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8242
8243 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8244 value = LVDSVBS - 1 ;
8245 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8246 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8247 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8248 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8249
8250 /* VBE SR0A[4] CR16 */
8251 value = LVDSVBE - 1;
8252 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8253 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8254
8255 /* VRS SR0A[3] CR7[7][2] CR10 */
8256 value = LVDSVRS - 1 ;
8257 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8258 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8259 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8260 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8261
8262 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8263 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8264 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8265 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8266
8267 /* VRE SR0A[5] CR11[3:0] */
8268 value = LVDSVRE - 1;
8269 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8270 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8271
8272 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8273 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8274
8275 for ( temp=0, value = 0; temp < 3; temp++)
8276 {
8277
8278 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8279 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8280 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8281 value += 0x10;
8282 }
8283
8284 if (!( modeflag & Charx8Dot ))
8285 {
8286 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8287 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8288 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8289
8290 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8291 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8292
8293 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8294 }
8295
8296
8297 }
8298
8299 /* no shadow case */
8300 void XGI_SetXG27LVDSPara(USHORT ModeNo,USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
8301 {
8302 UCHAR temp,Miscdata;
8303 USHORT xres ,
8304 yres ,
8305 modeflag ,
8306 resindex ,
8307 lvdstableindex ;
8308 USHORT LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8309 USHORT LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8310 USHORT value;
8311
8312 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8313 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8314 temp &= LCDPolarity;
8315 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8316
8317 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8318
8319 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8320 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8321 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8322
8323 XGI_SetXG27FPBits(pVBInfo);
8324 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8325 if ( ModeNo <= 0x13 )
8326 {
8327 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8328 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8329 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8330 }
8331 else
8332 {
8333 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8334 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8335 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8336 }
8337
8338 if (!( modeflag & Charx8Dot ))
8339 xres = xres * 8 / 9;
8340
8341 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8342
8343 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8344 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8345 {
8346 LVDSHBS -= xres/4 ;
8347 }
8348 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8349
8350 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8351 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8352
8353 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8354 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8355
8356 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8357
8358 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8359
8360 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8361 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8362 {
8363 LVDSVBS += yres/2 ;
8364 }
8365 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8366
8367 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8368 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8369
8370 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8371 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8372
8373 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8374
8375 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8376 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8377
8378 if (!( modeflag & Charx8Dot ))
8379 {
8380 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8381 }
8382
8383 /* HT SR0B[1:0] CR00 */
8384 value = ( LVDSHT >> 3 ) - 5;
8385 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8386 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8387
8388 /* HBS SR0B[5:4] CR02 */
8389 value = ( LVDSHBS >> 3 ) - 1;
8390 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8391 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8392
8393 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8394 value = ( LVDSHBE >> 3 ) - 1;
8395 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8396 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8397 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8398
8399 /* HRS SR0B[7:6] CR04 */
8400 value = ( LVDSHRS >> 3 ) + 2;
8401 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8402 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8403
8404 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8405 value--;
8406 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8407 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8408
8409 /* HRE SR0C[2] CR05[4:0] */
8410 value = ( LVDSHRE >> 3 ) + 2;
8411 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8412 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8413
8414 /* Panel HRE SR2F[7:2] */
8415 value--;
8416 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8417
8418 /* VT SR0A[0] CR07[5][0] CR06 */
8419 value = LVDSVT - 2 ;
8420 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8421 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8422 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8423 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8424
8425 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8426 value = LVDSVBS - 1 ;
8427 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8428 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8429 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8430 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8431
8432 /* VBE SR0A[4] CR16 */
8433 value = LVDSVBE - 1;
8434 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8435 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8436
8437 /* VRS SR0A[3] CR7[7][2] CR10 */
8438 value = LVDSVRS - 1 ;
8439 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8440 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8441 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8442 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8443
8444 /* Panel VRS SR35[2:0] SR34[7:0] */
8445 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8446 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8447
8448 /* VRE SR0A[5] CR11[3:0] */
8449 value = LVDSVRE - 1;
8450 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8451 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8452
8453 /* Panel VRE SR3F[7:2] */
8454 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8455
8456 for ( temp=0, value = 0; temp < 3; temp++)
8457 {
8458
8459 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8460 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8461 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8462 value += 0x10;
8463 }
8464
8465 if (!( modeflag & Charx8Dot ))
8466 {
8467 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8468 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8469 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8470
8471 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8472 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8473
8474 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8475 }
8476
8477
8478 }
8479
8480 /* --------------------------------------------------------------------- */
8481 /* Function : XGI_IsLCDON */
8482 /* Input : */
8483 /* Output : FALSE : Skip PSC Control */
8484 /* TRUE: Disable PSC */
8485 /* Description : */
8486 /* --------------------------------------------------------------------- */
8487 BOOLEAN XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo)
8488 {
8489 USHORT tempax ;
8490
8491 tempax = pVBInfo->VBInfo ;
8492 if ( tempax & SetCRT2ToDualEdge )
8493 return FALSE ;
8494 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
8495 return TRUE ;
8496
8497 return FALSE ;
8498 }
8499
8500
8501 /* --------------------------------------------------------------------- */
8502 /* Function : XGI_EnablePWD */
8503 /* Input : */
8504 /* Output : */
8505 /* Description : */
8506 /* --------------------------------------------------------------------- */
8507 void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo )
8508 {
8509 USHORT index ,
8510 temp ;
8511
8512 index = XGI_GetLCDCapPtr(pVBInfo) ;
8513 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8514 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8515 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8516 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8517 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8518 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8519 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8520 }
8521
8522
8523 /* --------------------------------------------------------------------- */
8524 /* Function : XGI_DisablePWD */
8525 /* Input : */
8526 /* Output : */
8527 /* Description : */
8528 /* --------------------------------------------------------------------- */
8529 void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo )
8530 {
8531 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8532 }
8533
8534
8535 /* --------------------------------------------------------------------- */
8536 /* Function : XGI_DisableChISLCD */
8537 /* Input : */
8538 /* Output : FALSE -> Not LCD Mode */
8539 /* Description : */
8540 /* --------------------------------------------------------------------- */
8541 BOOLEAN XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo)
8542 {
8543 USHORT tempbx ,
8544 tempah ;
8545
8546 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
8547 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8548
8549 if ( tempbx & ( EnableChA | DisableChA ) )
8550 {
8551 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8552 return FALSE ;
8553 }
8554
8555 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8556 return FALSE ;
8557
8558 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8559 return TRUE ;
8560
8561 return FALSE ;
8562 }
8563
8564
8565 /* --------------------------------------------------------------------- */
8566 /* Function : XGI_EnableChISLCD */
8567 /* Input : */
8568 /* Output : 0 -> Not LCD mode */
8569 /* Description : */
8570 /* --------------------------------------------------------------------- */
8571 BOOLEAN XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo)
8572 {
8573 USHORT tempbx ,
8574 tempah ;
8575
8576
8577 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
8578 tempah = ~( ( USHORT )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
8579
8580 if ( tempbx & ( EnableChA | DisableChA ) )
8581 {
8582 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
8583 return FALSE ;
8584 }
8585
8586 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
8587 return FALSE ;
8588
8589 if ( tempah & 0x01 ) /* Chk LCDB Mode */
8590 return TRUE ;
8591
8592 return FALSE ;
8593 }
8594
8595
8596 /* --------------------------------------------------------------------- */
8597 /* Function : XGI_GetLCDCapPtr */
8598 /* Input : */
8599 /* Output : */
8600 /* Description : */
8601 /* --------------------------------------------------------------------- */
8602 USHORT XGI_GetLCDCapPtr( PVB_DEVICE_INFO pVBInfo )
8603 {
8604 UCHAR tempal ,
8605 tempah ,
8606 tempbl ,
8607 i ;
8608
8609 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8610 tempal = tempah & 0x0F ;
8611 tempah = tempah & 0xF0 ;
8612 i = 0 ;
8613 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8614
8615 while( tempbl != 0xFF )
8616 {
8617 if ( tempbl & 0x80 ) /* OEMUtil */
8618 {
8619 tempal = tempah ;
8620 tempbl = tempbl & ~( 0x80 ) ;
8621 }
8622
8623 if ( tempal == tempbl )
8624 break ;
8625
8626 i++ ;
8627
8628 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8629 }
8630
8631 return i ;
8632 }
8633
8634
8635 /* --------------------------------------------------------------------- */
8636 /* Function : XGI_GetLCDCapPtr1 */
8637 /* Input : */
8638 /* Output : */
8639 /* Description : */
8640 /* --------------------------------------------------------------------- */
8641 USHORT XGI_GetLCDCapPtr1( PVB_DEVICE_INFO pVBInfo )
8642 {
8643 USHORT tempah ,
8644 tempal ,
8645 tempbl ,
8646 i ;
8647
8648 tempal = pVBInfo->LCDResInfo ;
8649 tempah = pVBInfo->LCDTypeInfo ;
8650
8651 i = 0 ;
8652 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
8653
8654 while( tempbl != 0xFF )
8655 {
8656 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
8657 {
8658 tempal = tempah ;
8659 tempbl &= ~0x80 ;
8660 }
8661
8662 if ( tempal == tempbl )
8663 break ;
8664
8665 i++ ;
8666 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8667 }
8668
8669 if ( tempbl == 0xFF )
8670 {
8671 pVBInfo->LCDResInfo = Panel1024x768 ;
8672 pVBInfo->LCDTypeInfo = 0 ;
8673 i = 0 ;
8674 }
8675
8676 return i ;
8677 }
8678
8679
8680 /* --------------------------------------------------------------------- */
8681 /* Function : XGI_GetLCDSync */
8682 /* Input : */
8683 /* Output : */
8684 /* Description : */
8685 /* --------------------------------------------------------------------- */
8686 void XGI_GetLCDSync( USHORT* HSyncWidth , USHORT* VSyncWidth, PVB_DEVICE_INFO pVBInfo )
8687 {
8688 USHORT Index ;
8689
8690 Index = XGI_GetLCDCapPtr(pVBInfo) ;
8691 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
8692 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
8693
8694 return ;
8695 }
8696
8697
8698
8699 /* --------------------------------------------------------------------- */
8700 /* Function : XGI_EnableBridge */
8701 /* Input : */
8702 /* Output : */
8703 /* Description : */
8704 /* --------------------------------------------------------------------- */
8705 void XGI_EnableBridge( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
8706 {
8707 USHORT tempbl ,
8708 tempah ;
8709
8710 if ( pVBInfo->SetFlag == Win9xDOSMode )
8711 {
8712 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8713 {
8714 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8715 return ;
8716 }
8717 else /* LVDS or CH7017 */
8718 return ;
8719 }
8720
8721
8722 if ( HwDeviceExtension->jChipType < XG40 )
8723 {
8724 if ( !XGI_DisableChISLCD(pVBInfo) )
8725 {
8726 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8727 {
8728 if ( pVBInfo->LCDInfo & SetPWDEnable )
8729 {
8730 XGI_EnablePWD( pVBInfo);
8731 }
8732 else
8733 {
8734 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
8735 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8736 {
8737 tempbl = 0xFD ;
8738 tempah = 0x02 ;
8739 }
8740 else
8741 {
8742 tempbl = 0xFB ;
8743 tempah = 0x00 ;
8744 }
8745
8746 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
8747 XGI_SetPanelDelay( 1,pVBInfo ) ;
8748 }
8749 }
8750 }
8751 } /* Not 340 */
8752
8753
8754
8755 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8756 {
8757 if ( !( pVBInfo->SetFlag & DisableChA ) )
8758 {
8759 if ( pVBInfo->SetFlag & EnableChA )
8760 {
8761 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
8762 }
8763 else
8764 {
8765 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
8766 {
8767 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
8768 }
8769 }
8770 }
8771
8772 if ( !( pVBInfo->SetFlag & DisableChB ) )
8773 {
8774 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
8775 {
8776 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
8777 tempah &= 0xDF;
8778 if ( pVBInfo->VBInfo & SetInSlaveMode )
8779 {
8780 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
8781 tempah |= 0x20 ;
8782 }
8783 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
8784 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
8785
8786
8787 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8788
8789 if ( !( tempah & 0x80 ) )
8790 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8791
8792 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
8793 }
8794 }
8795
8796 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
8797 {
8798 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
8799 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8800 {
8801 if ( !XGI_DisableChISLCD(pVBInfo) )
8802 {
8803 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8804 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
8805 }
8806 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
8807 }
8808 }
8809
8810 tempah = 0x00 ;
8811
8812 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
8813 {
8814 tempah = 0xc0 ;
8815
8816 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
8817 {
8818 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8819 {
8820 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8821 {
8822 tempah = tempah & 0x40;
8823 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8824 tempah = tempah ^ 0xC0 ;
8825
8826 if ( pVBInfo->SetFlag & DisableChB )
8827 tempah &= 0xBF ;
8828
8829 if ( pVBInfo->SetFlag & DisableChA )
8830 tempah &= 0x7F ;
8831
8832 if ( pVBInfo->SetFlag & EnableChB )
8833 tempah |= 0x40 ;
8834
8835 if ( pVBInfo->SetFlag & EnableChA )
8836 tempah |= 0x80 ;
8837 }
8838 }
8839 }
8840 }
8841
8842 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
8843
8844 if ( pVBInfo->SetFlag & Win9xDOSMode )
8845 {
8846 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8847 return ;
8848 }
8849
8850 if ( !( pVBInfo->SetFlag & DisableChA ) )
8851 {
8852 XGI_VBLongWait( pVBInfo) ;
8853 if ( !( pVBInfo->SetFlag & GatingCRT ) )
8854 {
8855 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8856 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8857 XGI_VBLongWait( pVBInfo) ;
8858 }
8859 }
8860 } /* 301 */
8861 else /* LVDS */
8862 {
8863 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
8864 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
8865
8866
8867
8868 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8869 if ( !( tempah & 0x80 ) )
8870 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8871
8872 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
8873 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
8874 } /* End of VB */
8875
8876
8877 if ( HwDeviceExtension->jChipType < XG40 )
8878 {
8879 if ( !XGI_EnableChISLCD(pVBInfo) )
8880 {
8881 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
8882 {
8883 if ( XGI_BacklightByDrv(pVBInfo) )
8884 return ;
8885 }
8886 else
8887 return ;
8888 }
8889
8890 if ( pVBInfo->LCDInfo & SetPWDEnable )
8891 {
8892 XGI_FirePWDEnable(pVBInfo) ;
8893 return ;
8894 }
8895
8896 XGI_SetPanelDelay( 2,pVBInfo ) ;
8897
8898 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8899 {
8900 tempah = 0x01 ;
8901 tempbl = 0xFE ; /* turn on backlght */
8902 }
8903 else
8904 {
8905 tempbl = 0xF7 ;
8906 tempah = 0x00 ;
8907 }
8908 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
8909 }
8910 }
8911
8912
8913 /* --------------------------------------------------------------------- */
8914 /* Function : XGI_DisableBridge */
8915 /* Input : */
8916 /* Output : */
8917 /* Description : */
8918 /* --------------------------------------------------------------------- */
8919 void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8920 {
8921 USHORT tempax ,
8922 tempbx ,
8923 tempah = 0 ,
8924 tempbl = 0 ;
8925
8926 if ( pVBInfo->SetFlag == Win9xDOSMode )
8927 return ;
8928
8929
8930 if ( HwDeviceExtension->jChipType < XG40 )
8931 {
8932 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8933 {
8934 if ( !XGI_IsLCDON(pVBInfo) )
8935 {
8936 if ( pVBInfo->LCDInfo & SetPWDEnable )
8937 XGI_EnablePWD( pVBInfo) ;
8938 else
8939 {
8940 pVBInfo->LCDInfo &= ~SetPWDEnable ;
8941 XGI_DisablePWD(pVBInfo) ;
8942 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8943 {
8944 tempbx = 0xFE ; /* not 01h */
8945 tempax = 0 ;
8946 }
8947 else
8948 {
8949 tempbx = 0xF7 ; /* not 08h */
8950 tempax = 0x08 ;
8951 }
8952 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
8953 XGI_SetPanelDelay( 3,pVBInfo ) ;
8954 }
8955 } /* end if(!XGI_IsLCDON(pVBInfo)) */
8956 }
8957 }
8958
8959 /* if ( CH7017 )
8960 {
8961 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8962 {
8963 if ( !XGI_IsLCDON(pVBInfo) )
8964 {
8965 if ( DISCHARGE )
8966 {
8967 tempbx = XGINew_GetCH7005( 0x61 ) ;
8968 if ( tempbx < 0x01 ) //first time we power up
8969 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
8970 else
8971 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
8972 }
8973 }
8974 }
8975 } */
8976
8977 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8978 {
8979 tempah = 0x3F ;
8980 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
8981 {
8982 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8983 {
8984 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8985 {
8986 tempah = 0x7F; /* Disable Channel A */
8987 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
8988 tempah = 0xBF ; /* Disable Channel B */
8989
8990 if ( pVBInfo->SetFlag & DisableChB )
8991 tempah &= 0xBF ; /* force to disable Cahnnel */
8992
8993 if ( pVBInfo->SetFlag & DisableChA )
8994 tempah &= 0x7F ; /* Force to disable Channel B */
8995 }
8996 }
8997 }
8998
8999 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
9000
9001 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9002 {
9003 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9004 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
9005 }
9006
9007 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
9008 {
9009 if ( pVBInfo->SetFlag & GatingCRT )
9010 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9011 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9012 }
9013
9014 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9015 {
9016 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9017 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
9018 }
9019
9020 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
9021
9022 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
9023 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9024
9025 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9026 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9027 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9028
9029 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9030 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9031 {
9032 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9033 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9034 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9035 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9036 }
9037 }
9038 else /* {301} */
9039 {
9040 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9041 {
9042 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9043 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9044 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9045 }
9046
9047 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9048 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9049 }
9050
9051
9052
9053
9054 if ( HwDeviceExtension->jChipType < XG40 )
9055 {
9056 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9057 {
9058 if ( pVBInfo->LCDInfo & SetPWDEnable )
9059 {
9060 if ( pVBInfo->LCDInfo & SetPWDEnable )
9061 XGI_BacklightByDrv(pVBInfo) ;
9062 else
9063 {
9064 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9065 if ( pVBInfo->VBType & VB_XGI301LV )
9066 {
9067 tempbl = 0xFD ;
9068 tempah = 0x00 ;
9069 }
9070 else
9071 {
9072 tempbl = 0xFB ;
9073 tempah = 0x04 ;
9074 }
9075 }
9076 }
9077 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9078 }
9079 }
9080 }
9081
9082
9083 /* --------------------------------------------------------------------- */
9084 /* Function : XGI_GetTVPtrIndex */
9085 /* Input : */
9086 /* Output : */
9087 /* Description : bx 0 : ExtNTSC */
9088 /* 1 : StNTSC */
9089 /* 2 : ExtPAL */
9090 /* 3 : StPAL */
9091 /* 4 : ExtHiTV */
9092 /* 5 : StHiTV */
9093 /* 6 : Ext525i */
9094 /* 7 : St525i */
9095 /* 8 : Ext525p */
9096 /* 9 : St525p */
9097 /* A : Ext750p */
9098 /* B : St750p */
9099 /* --------------------------------------------------------------------- */
9100 USHORT XGI_GetTVPtrIndex( PVB_DEVICE_INFO pVBInfo )
9101 {
9102 USHORT tempbx = 0 ;
9103
9104 if ( pVBInfo->TVInfo & SetPALTV )
9105 tempbx = 2 ;
9106 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9107 tempbx = 4 ;
9108 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9109 tempbx = 6 ;
9110 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9111 tempbx = 8 ;
9112 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9113 tempbx = 10 ;
9114 if ( pVBInfo->TVInfo & TVSimuMode )
9115 tempbx++ ;
9116
9117 return tempbx ;
9118 }
9119
9120
9121 /* --------------------------------------------------------------------- */
9122 /* Function : XGI_OEM310Setting */
9123 /* Input : */
9124 /* Output : */
9125 /* Description : Customized Param. for 301 */
9126 /* --------------------------------------------------------------------- */
9127 void XGI_OEM310Setting( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9128 {
9129 if ( pVBInfo->SetFlag & Win9xDOSMode )
9130 return ;
9131
9132 /* GetPart1IO(); */
9133 XGI_SetDelayComp(pVBInfo) ;
9134
9135 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9136 XGI_SetLCDCap(pVBInfo) ;
9137
9138 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9139 {
9140 /* GetPart2IO() */
9141 XGI_SetPhaseIncr(pVBInfo) ;
9142 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9143 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9144
9145 if ( pVBInfo->VBType&VB_XGI301)
9146 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9147 }
9148 }
9149
9150
9151 /* --------------------------------------------------------------------- */
9152 /* Function : XGI_SetDelayComp */
9153 /* Input : */
9154 /* Output : */
9155 /* Description : */
9156 /* --------------------------------------------------------------------- */
9157 void XGI_SetDelayComp( PVB_DEVICE_INFO pVBInfo )
9158 {
9159 USHORT index ;
9160
9161 UCHAR tempah ,
9162 tempbl ,
9163 tempbh ;
9164
9165 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9166 {
9167 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9168 {
9169 tempbl = 0;
9170 tempbh = 0;
9171
9172 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9173 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9174
9175 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9176 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9177
9178 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9179 tempbl = tempbl >> 4 ;
9180 /*
9181 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9182 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9183
9184 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9185 tempbl = CRT2Delay2 ;
9186 */
9187 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9188 {
9189 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9190 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9191
9192 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9193 tempbl = tempbh ;
9194 }
9195
9196 tempbl &= 0x0F ;
9197 tempbh &= 0xF0 ;
9198 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9199
9200 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9201 {
9202 tempah &= 0xF0 ;
9203 tempah |= tempbl ;
9204 }
9205
9206 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9207 {
9208 tempah &= 0x0F ;
9209 tempah |= tempbh ;
9210 }
9211 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9212 }
9213 }
9214 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9215 {
9216 tempbl = 0;
9217 tempbh = 0;
9218 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9219 {
9220 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9221 tempah &= 0x0f ;
9222 tempah = tempah << 4 ;
9223 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9224 }
9225 }
9226 }
9227
9228
9229 /* --------------------------------------------------------------------- */
9230 /* Function : XGI_SetLCDCap */
9231 /* Input : */
9232 /* Output : */
9233 /* Description : */
9234 /* --------------------------------------------------------------------- */
9235 void XGI_SetLCDCap( PVB_DEVICE_INFO pVBInfo )
9236 {
9237 USHORT tempcx ;
9238
9239 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9240
9241 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9242 {
9243 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9244 { /* 301LV/302LV only */
9245 /* Set 301LV Capability */
9246 XGINew_SetReg1( pVBInfo->Part4Port , 0x24 , ( UCHAR )( tempcx & 0x1F ) ) ;
9247 }
9248 /* VB Driving */
9249 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~( ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) >> 8 ) , ( USHORT )( ( tempcx & ( EnableVBCLKDRVLOW | EnablePLLSPLOW ) ) >> 8 ) ) ;
9250 }
9251
9252 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9253 {
9254 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9255 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9256 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9257 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9258
9259 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9260 {
9261 if ( tempcx & EnableSpectrum )
9262 SetSpectrum( pVBInfo) ;
9263 }
9264 }
9265 else /* LVDS,CH7017 */
9266 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9267 }
9268
9269
9270 /* --------------------------------------------------------------------- */
9271 /* Function : XGI_SetLCDCap_A */
9272 /* Input : */
9273 /* Output : */
9274 /* Description : */
9275 /* --------------------------------------------------------------------- */
9276 void XGI_SetLCDCap_A(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9277 {
9278 USHORT temp ;
9279
9280 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9281
9282 if ( temp & LCDRGB18Bit )
9283 {
9284 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x20 | ( tempcx & 0x00C0 ) ) ) ; /* Enable Dither */
9285 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9286 }
9287 else
9288 {
9289 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0x0F , ( USHORT )( 0x30 | ( tempcx & 0x00C0 ) ) ) ;
9290 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9291 }
9292
9293 /*
9294 if ( tempcx & EnableLCD24bpp ) // 24bits
9295 {
9296 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x30|(tempcx&0x00C0)) );
9297 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9298 }
9299 else
9300 {
9301 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(USHORT)(0x20|(tempcx&0x00C0)) );//Enable Dither
9302 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9303 }
9304 */
9305 }
9306
9307
9308 /* --------------------------------------------------------------------- */
9309 /* Function : XGI_SetLCDCap_B */
9310 /* Input : cx -> LCD Capability */
9311 /* Output : */
9312 /* Description : */
9313 /* --------------------------------------------------------------------- */
9314 void XGI_SetLCDCap_B(USHORT tempcx,PVB_DEVICE_INFO pVBInfo)
9315 {
9316 if ( tempcx & EnableLCD24bpp ) /* 24bits */
9317 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x0c ) ) ;
9318 else
9319 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1A , 0xE0 , ( USHORT )( ( ( tempcx & 0x00ff ) >> 6 ) | 0x18 ) ) ; /* Enable Dither */
9320 }
9321
9322
9323 /* --------------------------------------------------------------------- */
9324 /* Function : SetSpectrum */
9325 /* Input : */
9326 /* Output : */
9327 /* Description : */
9328 /* --------------------------------------------------------------------- */
9329 void SetSpectrum( PVB_DEVICE_INFO pVBInfo )
9330 {
9331 USHORT index ;
9332
9333 index = XGI_GetLCDCapPtr(pVBInfo) ;
9334
9335 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9336 XGI_LongWait(pVBInfo) ;
9337 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9338 XGI_LongWait(pVBInfo) ;
9339
9340 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9341 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9342 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9343 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9344 XGI_LongWait(pVBInfo) ;
9345 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9346 }
9347
9348
9349 /* --------------------------------------------------------------------- */
9350 /* Function : XGI_SetAntiFlicker */
9351 /* Input : */
9352 /* Output : */
9353 /* Description : Set TV Customized Param. */
9354 /* --------------------------------------------------------------------- */
9355 void XGI_SetAntiFlicker( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
9356 {
9357 USHORT tempbx ,
9358 index ;
9359
9360 UCHAR tempah ;
9361
9362 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9363 return ;
9364
9365 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9366 tempbx &= 0xFE ;
9367
9368 if ( ModeNo <= 0x13 )
9369 {
9370 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9371 }
9372 else
9373 {
9374 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9375 }
9376
9377 tempbx += index ;
9378 tempah = TVAntiFlickList[ tempbx ] ;
9379 tempah = tempah << 4 ;
9380
9381 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9382 }
9383
9384
9385 /* --------------------------------------------------------------------- */
9386 /* Function : XGI_SetEdgeEnhance */
9387 /* Input : */
9388 /* Output : */
9389 /* Description : */
9390 /* --------------------------------------------------------------------- */
9391 void XGI_SetEdgeEnhance( USHORT ModeNo , USHORT ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
9392 {
9393 USHORT tempbx ,
9394 index ;
9395
9396 UCHAR tempah ;
9397
9398
9399 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9400 tempbx &= 0xFE ;
9401
9402 if ( ModeNo <= 0x13 )
9403 {
9404 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9405 }
9406 else
9407 {
9408 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9409 }
9410
9411 tempbx += index ;
9412 tempah = TVEdgeList[ tempbx ] ;
9413 tempah = tempah << 5 ;
9414
9415 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9416 }
9417
9418
9419 /* --------------------------------------------------------------------- */
9420 /* Function : XGI_SetPhaseIncr */
9421 /* Input : */
9422 /* Output : */
9423 /* Description : */
9424 /* --------------------------------------------------------------------- */
9425 void XGI_SetPhaseIncr( PVB_DEVICE_INFO pVBInfo )
9426 {
9427 USHORT tempbx ;
9428
9429 UCHAR tempcl ,
9430 tempch ;
9431
9432 ULONG tempData ;
9433
9434 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9435 tempData = TVPhaseList[ tempbx ] ;
9436
9437 XGINew_SetReg1( pVBInfo->Part2Port , 0x31 , ( USHORT )( tempData & 0x000000FF ) ) ;
9438 XGINew_SetReg1( pVBInfo->Part2Port , 0x32 , ( USHORT )( ( tempData & 0x0000FF00 ) >> 8 ) ) ;
9439 XGINew_SetReg1( pVBInfo->Part2Port , 0x33 , ( USHORT )( ( tempData & 0x00FF0000 ) >> 16 ) ) ;
9440 XGINew_SetReg1( pVBInfo->Part2Port , 0x34 , ( USHORT )( ( tempData & 0xFF000000 ) >> 24 ) ) ;
9441 }
9442
9443
9444 /* --------------------------------------------------------------------- */
9445 /* Function : XGI_SetYFilter */
9446 /* Input : */
9447 /* Output : */
9448 /* Description : */
9449 /* --------------------------------------------------------------------- */
9450 void XGI_SetYFilter( USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9451 {
9452 USHORT tempbx ,
9453 index ;
9454
9455 UCHAR tempcl ,
9456 tempch ,
9457 tempal ,
9458 *filterPtr ;
9459
9460 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9461
9462 switch( tempbx )
9463 {
9464 case 0x00:
9465 case 0x04:
9466 filterPtr = NTSCYFilter1 ;
9467 break ;
9468
9469 case 0x01:
9470 filterPtr = PALYFilter1 ;
9471 break ;
9472
9473 case 0x02:
9474 case 0x05:
9475 case 0x0D:
9476 filterPtr = PALMYFilter1 ;
9477 break ;
9478
9479 case 0x03:
9480 filterPtr = PALNYFilter1 ;
9481 break ;
9482
9483 case 0x08:
9484 case 0x0C:
9485 filterPtr = NTSCYFilter2 ;
9486 break ;
9487
9488 case 0x0A:
9489 filterPtr = PALMYFilter2 ;
9490 break ;
9491
9492 case 0x0B:
9493 filterPtr = PALNYFilter2 ;
9494 break ;
9495
9496 case 0x09:
9497 filterPtr = PALYFilter2 ;
9498 break ;
9499
9500 default:
9501 return ;
9502 }
9503
9504 if ( ModeNo <= 0x13 )
9505 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9506 else
9507 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9508
9509 if ( tempcl == 0 )
9510 index = tempal * 4;
9511 else
9512 index = tempal * 7;
9513
9514 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9515 {
9516 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9517 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9518 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9519 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9520 }
9521 else
9522 {
9523 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9524 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9525 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9526 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9527 }
9528
9529 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9530 {
9531 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9532 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9533 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9534 }
9535 }
9536
9537
9538 /* --------------------------------------------------------------------- */
9539 /* Function : XGI_GetTVPtrIndex2 */
9540 /* Input : */
9541 /* Output : bx 0 : NTSC */
9542 /* 1 : PAL */
9543 /* 2 : PALM */
9544 /* 3 : PALN */
9545 /* 4 : NTSC1024x768 */
9546 /* 5 : PAL-M 1024x768 */
9547 /* 6-7: reserved */
9548 /* cl 0 : YFilter1 */
9549 /* 1 : YFilter2 */
9550 /* ch 0 : 301A */
9551 /* 1 : 301B/302B/301LV/302LV */
9552 /* Description : */
9553 /* --------------------------------------------------------------------- */
9554 void XGI_GetTVPtrIndex2(USHORT* tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo)
9555 {
9556 *tempbx = 0 ;
9557 *tempcl = 0 ;
9558 *tempch = 0 ;
9559
9560 if ( pVBInfo->TVInfo & SetPALTV )
9561 *tempbx = 1 ;
9562
9563 if ( pVBInfo->TVInfo & SetPALMTV )
9564 *tempbx = 2 ;
9565
9566 if ( pVBInfo->TVInfo & SetPALNTV )
9567 *tempbx = 3 ;
9568
9569 if ( pVBInfo->TVInfo & NTSC1024x768 )
9570 {
9571 *tempbx = 4 ;
9572 if ( pVBInfo->TVInfo & SetPALMTV )
9573 *tempbx = 5 ;
9574 }
9575
9576 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9577 {
9578 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9579 {
9580 *tempbx += 8 ;
9581 *tempcl += 1 ;
9582 }
9583 }
9584
9585 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9586 (*tempch)++ ;
9587 }
9588
9589
9590 /* --------------------------------------------------------------------- */
9591 /* Function : XGI_SetCRT2ModeRegs */
9592 /* Input : */
9593 /* Output : */
9594 /* Description : Origin code for crt2group */
9595 /* --------------------------------------------------------------------- */
9596 void XGI_SetCRT2ModeRegs(USHORT ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
9597 {
9598 USHORT tempbl ;
9599 SHORT tempcl ;
9600
9601 UCHAR tempah ;
9602
9603 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9604 tempah=0;
9605 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9606 {
9607 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9608 tempah &= ~0x10 ; /* BTRAMDAC */
9609 tempah |= 0x40 ; /* BTRAM */
9610
9611 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9612 {
9613 tempah=0x40; /* BTDRAM */
9614 if ( ModeNo > 0x13 )
9615 {
9616 tempcl = pVBInfo->ModeType ;
9617 tempcl -= ModeVGA ;
9618 if ( tempcl >= 0 )
9619 {
9620 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9621 if ( tempah == 0 )
9622 tempah = 1 ;
9623 tempah |= 0x040 ;
9624 }
9625 }
9626 if ( pVBInfo->VBInfo & SetInSlaveMode )
9627 tempah ^= 0x50 ; /* BTDAC */
9628 }
9629 }
9630
9631 /* 0210 shampoo
9632 if ( pVBInfo->VBInfo & DisableCRT2Display )
9633 {
9634 tempah = 0 ;
9635 }
9636
9637 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9638 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9639 {
9640 tempcl = pVBInfo->ModeType ;
9641 if ( ModeNo > 0x13 )
9642 {
9643 tempcl -= ModeVGA ;
9644 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
9645 {
9646 tempah=(0x008>>tempcl) ;
9647 if ( tempah == 0 )
9648 tempah = 1 ;
9649 tempah |= 0x040;
9650 }
9651 }
9652 else
9653 {
9654 tempah = 0x040 ;
9655 }
9656
9657 if ( pVBInfo->VBInfo & SetInSlaveMode )
9658 {
9659 tempah = ( tempah ^ 0x050 ) ;
9660 }
9661 }
9662 */
9663
9664 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9665 tempah = 0x08 ;
9666 tempbl = 0xf0 ;
9667
9668 if ( pVBInfo->VBInfo & DisableCRT2Display )
9669 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9670 else
9671 {
9672 tempah = 0x00 ;
9673 tempbl = 0xff ;
9674
9675 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9676 {
9677 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
9678 {
9679 tempbl &= 0xf7 ;
9680 tempah |= 0x01 ;
9681 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9682 }
9683 else
9684 {
9685 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9686 {
9687 tempbl &= 0xf7 ;
9688 tempah |= 0x01 ;
9689 }
9690
9691 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9692 {
9693 tempbl &= 0xf8 ;
9694 tempah = 0x01 ;
9695
9696 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
9697 tempah |= 0x02 ;
9698
9699 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9700 {
9701 tempah = tempah ^ 0x05 ;
9702 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
9703 tempah = tempah ^ 0x01 ;
9704 }
9705
9706 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9707 tempah |= 0x08 ;
9708 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9709 }
9710 else
9711 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9712 }
9713 }
9714 else
9715 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9716 }
9717
9718 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9719 {
9720 tempah &= ( ~0x08 ) ;
9721 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
9722 {
9723 tempah |= 0x010 ;
9724 }
9725 tempah |= 0x080 ;
9726
9727 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9728 {
9729 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
9730 /* { */
9731 tempah |= 0x020 ;
9732 if ( ModeNo > 0x13 )
9733 {
9734 if ( pVBInfo->VBInfo & DriverMode )
9735 tempah = tempah ^ 0x20 ;
9736 }
9737 /* } */
9738 }
9739
9740 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
9741 tempah = 0 ;
9742
9743 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9744 tempah |= 0x40 ;
9745
9746 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9747 {
9748 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
9749 /* { */
9750 if ( pVBInfo->TVInfo & RPLLDIV2XO )
9751 tempah |= 0x40 ;
9752 /* } */
9753 }
9754
9755 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
9756 tempah |= 0x80 ;
9757
9758 if ( pVBInfo->LCDResInfo == Panel1280x960 )
9759 tempah |= 0x80 ;
9760
9761 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
9762 }
9763
9764 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9765 {
9766 tempah = 0 ;
9767 tempbl = 0xfb ;
9768
9769 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9770 {
9771 tempbl=0xff;
9772 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9773 tempah |= 0x04 ; /* shampoo 0129 */
9774 }
9775
9776 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
9777 tempah = 0x00 ;
9778 tempbl = 0xcf ;
9779 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9780 {
9781 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9782 tempah |= 0x30 ;
9783 }
9784
9785 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
9786 tempah = 0 ;
9787 tempbl = 0x3f ;
9788
9789 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9790 {
9791 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9792 tempah |= 0xc0 ;
9793 }
9794 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
9795 }
9796
9797 tempah = 0 ;
9798 tempbl = 0x7f ;
9799 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9800 {
9801 tempbl = 0xff ;
9802 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9803 tempah |= 0x80 ;
9804 }
9805
9806 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
9807
9808 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9809 {
9810 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9811 {
9812 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
9813 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
9814 }
9815 }
9816 }
9817
9818
9819 /* --------------------------------------------------------------------- */
9820 /* Function : XGI_CloseCRTC */
9821 /* Input : */
9822 /* Output : */
9823 /* Description : */
9824 /* --------------------------------------------------------------------- */
9825 void XGI_CloseCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9826 {
9827 USHORT tempbx ;
9828
9829 tempbx = 0 ;
9830
9831 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9832 tempbx = 0x08A0 ;
9833
9834
9835 }
9836
9837
9838 /* --------------------------------------------------------------------- */
9839 /* Function : XGI_OpenCRTC */
9840 /* Input : */
9841 /* Output : */
9842 /* Description : */
9843 /* --------------------------------------------------------------------- */
9844 void XGI_OpenCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9845 {
9846 USHORT tempbx ;
9847
9848 tempbx = 0 ;
9849
9850
9851 }
9852
9853
9854 /* --------------------------------------------------------------------- */
9855 /* Function : XGI_GetRAMDAC2DATA */
9856 /* Input : */
9857 /* Output : */
9858 /* Description : */
9859 /* --------------------------------------------------------------------- */
9860 void XGI_GetRAMDAC2DATA(USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
9861 {
9862 USHORT tempax ,
9863 tempbx ,
9864 temp1 ,
9865 temp2 ,
9866 modeflag = 0 ,
9867 tempcx ,
9868 StandTableIndex ,
9869 CRT1Index ;
9870
9871 pVBInfo->RVBHCMAX = 1 ;
9872 pVBInfo->RVBHCFACT = 1 ;
9873
9874 if ( ModeNo <= 0x13 )
9875 {
9876 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9877 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
9878 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
9879 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
9880 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
9881 }
9882 else
9883 {
9884 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9885 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
9886 CRT1Index &= IndexMask ;
9887 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 0 ] ;
9888 temp2 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] ;
9889 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
9890 tempbx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 8 ] ;
9891 tempcx = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] << 8 ;
9892 tempcx &= 0x0100 ;
9893 tempcx = tempcx << 2 ;
9894 tempbx |= tempcx;
9895 temp1 = ( USHORT )pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
9896 }
9897
9898 if ( temp1 & 0x01 )
9899 tempbx |= 0x0100 ;
9900
9901 if ( temp1 & 0x20 )
9902 tempbx |= 0x0200 ;
9903 tempax += 5 ;
9904
9905 if ( modeflag & Charx8Dot )
9906 tempax *= 8 ;
9907 else
9908 tempax *= 9 ;
9909
9910 pVBInfo->VGAHT = tempax ;
9911 pVBInfo->HT = tempax ;
9912 tempbx++ ;
9913 pVBInfo->VGAVT = tempbx ;
9914 pVBInfo->VT = tempbx ;
9915 }
9916
9917
9918
9919 /* --------------------------------------------------------------------- */
9920 /* Function : XGI_GetColorDepth */
9921 /* Input : */
9922 /* Output : */
9923 /* Description : */
9924 /* --------------------------------------------------------------------- */
9925 USHORT XGI_GetColorDepth(USHORT ModeNo , USHORT ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
9926 {
9927 USHORT ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
9928 SHORT index ;
9929 USHORT modeflag ;
9930
9931 if ( ModeNo <= 0x13 )
9932 {
9933 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9934 }
9935 else
9936 {
9937 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9938 }
9939
9940 index=(modeflag&ModeInfoFlag)-ModeEGA;
9941
9942 if ( index < 0 )
9943 index = 0 ;
9944
9945 return( ColorDepth[ index ] ) ;
9946 }
9947
9948
9949
9950 /* --------------------------------------------------------------------- */
9951 /* Function : XGI_UnLockCRT2 */
9952 /* Input : */
9953 /* Output : */
9954 /* Description : */
9955 /* --------------------------------------------------------------------- */
9956 void XGI_UnLockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9957 {
9958
9959 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
9960
9961 }
9962
9963
9964 /* --------------------------------------------------------------------- */
9965 /* Function : XGI_LockCRT2 */
9966 /* Input : */
9967 /* Output : */
9968 /* Description : */
9969 /* --------------------------------------------------------------------- */
9970 void XGI_LockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9971 {
9972
9973 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
9974
9975
9976 }
9977
9978
9979 /* --------------------------------------------------------------------- */
9980 /* Function : XGINew_EnableCRT2 */
9981 /* Input : */
9982 /* Output : */
9983 /* Description : */
9984 /* --------------------------------------------------------------------- */
9985 void XGINew_EnableCRT2( PVB_DEVICE_INFO pVBInfo)
9986 {
9987 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
9988 }
9989
9990
9991
9992 /* --------------------------------------------------------------------- */
9993 /* Function : */
9994 /* Input : */
9995 /* Output : */
9996 /* Description : */
9997 /* --------------------------------------------------------------------- */
9998 void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo)
9999 {
10000 USHORT i ,
10001 j ;
10002
10003 ULONG temp ,
10004 flag ;
10005
10006 flag = 0 ;
10007 //printk("XGINew_LCD_Wait_Time");
10008 //return;
10009 for( i = 0 ; i < DelayTime ; i++ )
10010 {
10011 for( j = 0 ; j < 66 ; j++ )
10012 {
10013
10014 temp = XGINew_GetReg3( 0x61 ) ;
10015
10016 //temp &= 0x10000000;
10017 temp &= 0x10;
10018 if ( temp == flag )
10019 continue ;
10020
10021 flag = temp ;
10022 }
10023 }
10024 }
10025
10026
10027
10028
10029 /* --------------------------------------------------------------------- */
10030 /* Function : XGI_BridgeIsOn */
10031 /* Input : */
10032 /* Output : */
10033 /* Description : */
10034 /* --------------------------------------------------------------------- */
10035 BOOLEAN XGI_BridgeIsOn( PVB_DEVICE_INFO pVBInfo )
10036 {
10037 USHORT flag ;
10038
10039 if ( pVBInfo->IF_DEF_LVDS == 1 )
10040 {
10041 return( 1 ) ;
10042 }
10043 else
10044 {
10045 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10046 if ( ( flag == 1 ) || ( flag == 2 ) )
10047 return( 1 ) ; /* 301b */
10048 else
10049 return( 0 ) ;
10050 }
10051 }
10052
10053
10054
10055 /* --------------------------------------------------------------------- */
10056 /* Function : XGI_LongWait */
10057 /* Input : */
10058 /* Output : */
10059 /* Description : */
10060 /* --------------------------------------------------------------------- */
10061 void XGI_LongWait(PVB_DEVICE_INFO pVBInfo)
10062 {
10063 USHORT i ;
10064
10065 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10066
10067 if ( !( i & 0xC0 ) )
10068 {
10069 for( i = 0 ; i < 0xFFFF ; i++ )
10070 {
10071 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10072 break ;
10073 }
10074
10075 for( i = 0 ; i < 0xFFFF ; i++ )
10076 {
10077 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10078 break ;
10079 }
10080 }
10081 }
10082
10083
10084 /* --------------------------------------------------------------------- */
10085 /* Function : XGI_VBLongWait */
10086 /* Input : */
10087 /* Output : */
10088 /* Description : */
10089 /* --------------------------------------------------------------------- */
10090 void XGI_VBLongWait( PVB_DEVICE_INFO pVBInfo )
10091 {
10092 USHORT tempal ,
10093 temp ,
10094 i ,
10095 j ;
10096 return ;
10097 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10098 {
10099 temp = 0 ;
10100 for( i = 0 ; i < 3 ; i++ )
10101 {
10102 for( j = 0 ; j < 100 ; j++ )
10103 {
10104 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10105 if ( temp & 0x01 )
10106 { /* VBWaitMode2 */
10107 if ( ( tempal & 0x08 ) )
10108 {
10109 continue ;
10110 }
10111
10112 if ( !( tempal & 0x08 ) )
10113 {
10114 break ;
10115 }
10116 }
10117 else
10118 { /* VBWaitMode1 */
10119 if ( !( tempal & 0x08 ) )
10120 {
10121 continue ;
10122 }
10123
10124 if ( ( tempal & 0x08 ) )
10125 {
10126 break ;
10127 }
10128 }
10129 }
10130 temp = temp ^ 0x01 ;
10131 }
10132 }
10133 else
10134 {
10135 XGI_LongWait(pVBInfo) ;
10136 }
10137 return ;
10138 }
10139
10140
10141
10142
10143 /* --------------------------------------------------------------------- */
10144 /* Function : XGI_GetVGAHT2 */
10145 /* Input : */
10146 /* Output : */
10147 /* Description : */
10148 /* --------------------------------------------------------------------- */
10149 USHORT XGI_GetVGAHT2( PVB_DEVICE_INFO pVBInfo )
10150 {
10151 ULONG tempax ,
10152 tempbx ;
10153
10154 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10155 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10156 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10157
10158 return( ( USHORT )tempax ) ;
10159 }
10160
10161
10162 /* --------------------------------------------------------------------- */
10163 /* Function : XGI_GetVCLK2Ptr */
10164 /* Input : */
10165 /* Output : */
10166 /* Description : */
10167 /* --------------------------------------------------------------------- */
10168 USHORT XGI_GetVCLK2Ptr( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
10169 {
10170 USHORT tempbx ;
10171
10172 USHORT LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10173 USHORT LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10174 USHORT LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10175 USHORT LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10176 USHORT LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10177
10178 USHORT CRT2Index , VCLKIndex ;
10179 USHORT modeflag , resinfo ;
10180 UCHAR *CHTVVCLKPtr = NULL ;
10181
10182 if ( ModeNo <= 0x13 )
10183 {
10184 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10185 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10186 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10187 }
10188 else
10189 {
10190 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10191 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10192 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10193 }
10194
10195 if ( pVBInfo->IF_DEF_LVDS == 0 )
10196 {
10197 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10198 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10199 {
10200 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10201 {
10202 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10203 }
10204 else
10205 {
10206 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10207 }
10208 }
10209 else /* for TV */
10210 {
10211 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10212 {
10213 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10214 {
10215 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10216 {
10217 VCLKIndex = HiTVVCLKDIV2 ;
10218
10219
10220 VCLKIndex += 25 ;
10221
10222 }
10223 else
10224 {
10225 VCLKIndex = HiTVVCLK ;
10226
10227
10228 VCLKIndex += 25 ;
10229
10230 }
10231
10232 if ( pVBInfo->SetFlag & TVSimuMode )
10233 {
10234 if( modeflag & Charx8Dot )
10235 {
10236 VCLKIndex = HiTVSimuVCLK ;
10237
10238
10239 VCLKIndex += 25 ;
10240
10241 }
10242 else
10243 {
10244 VCLKIndex = HiTVTextVCLK ;
10245
10246
10247 VCLKIndex += 25 ;
10248
10249 }
10250 }
10251
10252 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10253 {
10254 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10255 {
10256 VCLKIndex = YPbPr750pVCLK ;
10257 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10258 {
10259 VCLKIndex = YPbPr525pVCLK ;
10260 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10261 {
10262 VCLKIndex = YPbPr525iVCLK_2 ;
10263 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10264 VCLKIndex = YPbPr525iVCLK ;
10265 }
10266 }
10267 }
10268 }
10269 }
10270 else
10271 {
10272 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10273 {
10274 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10275 {
10276 VCLKIndex = TVVCLKDIV2 ;
10277
10278
10279 VCLKIndex += 25 ;
10280
10281 }
10282 else
10283 {
10284 VCLKIndex = TVVCLK ;
10285
10286
10287 VCLKIndex += 25 ;
10288
10289 }
10290 }
10291 }
10292 }
10293 else
10294 { /* for CRT2 */
10295 VCLKIndex = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ; /* Port 3cch */
10296 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10297 if ( ModeNo > 0x13 )
10298 {
10299 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10300 VCLKIndex &= IndexMask ;
10301 }
10302 }
10303 }
10304 }
10305 else
10306 { /* LVDS */
10307 if ( ModeNo <= 0x13 )
10308 VCLKIndex = CRT2Index ;
10309 else
10310 VCLKIndex = CRT2Index ;
10311
10312 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10313 {
10314 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10315 {
10316 VCLKIndex &= 0x1f ;
10317 tempbx = 0 ;
10318
10319 if ( pVBInfo->VBInfo & SetPALTV )
10320 tempbx += 2 ;
10321
10322 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10323 tempbx += 1 ;
10324
10325 switch( tempbx )
10326 {
10327 case 0:
10328 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10329 break ;
10330 case 1:
10331 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10332 break;
10333 case 2:
10334 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10335 break ;
10336 case 3:
10337 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10338 break ;
10339 default:
10340 break ;
10341 }
10342
10343 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10344 }
10345 }
10346 else
10347 {
10348 VCLKIndex = VCLKIndex >> 6 ;
10349 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10350 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10351 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10352 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10353 else
10354 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10355 }
10356 }
10357 /* VCLKIndex = VCLKIndex&IndexMask ; */
10358
10359
10360
10361 return( VCLKIndex ) ;
10362 }
10363