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