blob: f27259e80987641531c347998d02671ebca28e29 [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
Bill Pemberton82d6eb52010-06-17 13:10:46 -040023unsigned char XGI_IsLCDDualLink(PVB_DEVICE_INFO pVBInfo);
24unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
25 PXGI_HW_DEVICE_INFO HwDeviceExtension,
26 PVB_DEVICE_INFO pVBInfo);
27unsigned char XGI_BacklightByDrv(PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020028
Bill Pemberton82d6eb52010-06-17 13:10:46 -040029unsigned char XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo);
30unsigned char XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo);
31unsigned char XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo);
32unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
33 unsigned short ModeIdIndex,
34 unsigned short RefreshRateTableIndex,
35 unsigned short *i, PVB_DEVICE_INFO pVBInfo);
36unsigned char XGI_SearchModeID(unsigned short ModeNo,
37 unsigned short *ModeIdIndex,
38 PVB_DEVICE_INFO pVBInfo);
39unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
40 unsigned short ModeIdIndex,
41 PVB_DEVICE_INFO pVBInfo);
42unsigned char XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension,
43 unsigned short ModeNo);
44unsigned char XGI_BridgeIsOn(PVB_DEVICE_INFO pVBInfo);
45UCHAR XGI_GetModePtr(unsigned short ModeNo,
46 unsigned short ModeIdIndex,
47 PVB_DEVICE_INFO pVBInfo);
48unsigned short XGI_GetOffset(unsigned short ModeNo,
49 unsigned short ModeIdIndex,
50 unsigned short RefreshRateTableIndex,
51 PXGI_HW_DEVICE_INFO HwDeviceExtension,
52 PVB_DEVICE_INFO pVBInfo);
53unsigned short XGI_GetRatePtrCRT2(PXGI_HW_DEVICE_INFO pXGIHWDE,
54 unsigned short ModeNo,
55 unsigned short ModeIdIndex,
56 PVB_DEVICE_INFO pVBInfo);
57unsigned short XGI_GetResInfo(unsigned short ModeNo,
58 unsigned short ModeIdIndex,
59 PVB_DEVICE_INFO pVBInfo);
60unsigned short XGI_GetColorDepth(unsigned short ModeNo,
61 unsigned short ModeIdIndex,
62 PVB_DEVICE_INFO pVBInfo);
63unsigned short XGI_GetVGAHT2(PVB_DEVICE_INFO pVBInfo);
64unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
65 unsigned short ModeIdIndex,
66 unsigned short RefreshRateTableIndex,
67 PXGI_HW_DEVICE_INFO HwDeviceExtension,
68 PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020069void XGI_VBLongWait(PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040070void XGI_SaveCRT2Info(unsigned short ModeNo, PVB_DEVICE_INFO pVBInfo);
71void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
72void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
73void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
74void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
75void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
76void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
77void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
78void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
79void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
80void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
81void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
82void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020083void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo);
84void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
85void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040086void XGI_SetPanelDelay(unsigned short tempbl, PVB_DEVICE_INFO pVBInfo);
87void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020088void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo);
89void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo);
90void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo);
91void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo);
92
93void XGI_DisplayOn(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
94void XGI_DisplayOff( PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
Bill Pemberton82d6eb52010-06-17 13:10:46 -040095void XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
96void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
97void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
98void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
99void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
100void XGI_UpdateXG21CRTC(unsigned short ModeNo, PVB_DEVICE_INFO pVBInfo, unsigned short RefreshRateTableIndex);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200101void XGI_WaitDisply(PVB_DEVICE_INFO pVBInfo);
102void XGI_SenseCRT1(PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400103void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
104void XGI_SetMiscRegs(unsigned short StandTableIndex, PVB_DEVICE_INFO pVBInfo);
105void XGI_SetCRTCRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short StandTableIndex, PVB_DEVICE_INFO pVBInfo);
106void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex,PVB_DEVICE_INFO pVBInfo );
107void XGI_SetGRCRegs(unsigned short StandTableIndex, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200108void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo);
109
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400110void XGI_SetSync(unsigned short RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
111void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200112void XGI_SetCRT1Timing_H(PVB_DEVICE_INFO pVBInfo,PXGI_HW_DEVICE_INFO HwDeviceExtension);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400113void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo,PVB_DEVICE_INFO pVBInfo);
114void XGI_SetCRT1DE(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
115void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
116void XGI_SetCRT1FIFO(unsigned short ModeNo,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
117void XGI_SetCRT1ModeRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
118void XGI_SetVCLKState(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short ModeNo, unsigned short RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200119
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400120void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
121void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al, unsigned short dh, PVB_DEVICE_INFO pVBInfo);
122/*void XGI_ClearBuffer(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short ModeNo,PVB_DEVICE_INFO pVBInfo);*/
123void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
124void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
125void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
126void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
127void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200128void XGI_UpdateModeInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
129void XGI_GetVGAType(PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
130void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400131void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo);
132void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,PVB_DEVICE_INFO pVBInfo);
133void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200134void InitTo330Pointer(UCHAR,PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400135void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200136void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
137void XGI_EnableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400138void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
139void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200140void XGI_SetDelayComp(PVB_DEVICE_INFO pVBInfo);
141void XGI_SetLCDCap(PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400142void XGI_SetLCDCap_A(unsigned short tempcx,PVB_DEVICE_INFO pVBInfo);
143void XGI_SetLCDCap_B(unsigned short tempcx,PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200144void SetSpectrum(PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400145void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
146void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200147void XGI_SetPhaseIncr(PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400148void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
149void XGI_GetTVPtrIndex2(unsigned short *tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo);
150unsigned short XGI_GetTVPtrIndex(PVB_DEVICE_INFO pVBInfo);
151void XGI_SetCRT2ModeRegs(unsigned short ModeNo,PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo );
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200152void XGI_CloseCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
153void XGI_OpenCRTC(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400154void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200155void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
156void XGI_LockCRT2(PXGI_HW_DEVICE_INFO, PVB_DEVICE_INFO pVBInfo);
157void XGINew_EnableCRT2(PVB_DEVICE_INFO pVBInfo);
158void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo);
159void XGI_LongWait(PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400160void XGI_SetCRT1Offset(unsigned short ModeNo , unsigned short ModeIdIndex , unsigned short RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo );
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200161void XGI_GetLCDVCLKPtr(UCHAR* di_0,UCHAR *di_1, PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400162UCHAR XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200163void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400164unsigned short XGI_GetLCDCapPtr(PVB_DEVICE_INFO pVBInfo);
165unsigned short XGI_GetLCDCapPtr1(PVB_DEVICE_INFO pVBInfo);
166XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200167void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo);
168void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo);
169UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo);
170UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400171void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, PVB_DEVICE_INFO pVBInfo);
172void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, PVB_DEVICE_INFO pVBInfo);
173void XGI_XG21SetPanelDelay(unsigned short tempbl, PVB_DEVICE_INFO pVBInfo);
174unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
175void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
176void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo );
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200177UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo );
178
179extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200180
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400181/* unsigned short XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200182
183
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400184unsigned short XGINew_MDA_DAC[] = {
185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
186 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
187 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
188 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
191 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
192 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200193
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400194unsigned short XGINew_CGA_DAC[] = {
195 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
196 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
197 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
198 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
199 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
200 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
201 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
202 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200203
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400204unsigned short XGINew_EGA_DAC[] = {
205 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
206 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
207 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
208 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
209 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
210 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
211 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
212 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200213
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400214unsigned short XGINew_VGA_DAC[] = {
215 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
216 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
217 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
218 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
219 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
220 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
221 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
222 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
223 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
224 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200225
226
227/* --------------------------------------------------------------------- */
228/* Function : InitTo330Pointer */
229/* Input : */
230/* Output : */
231/* Description : */
232/* --------------------------------------------------------------------- */
233void InitTo330Pointer( UCHAR ChipType ,PVB_DEVICE_INFO pVBInfo)
234{
235 pVBInfo->SModeIDTable = (XGI_StStruct *) XGI330_SModeIDTable ;
236 pVBInfo->StandTable = (XGI_StandTableStruct *) XGI330_StandTable ;
237 pVBInfo->EModeIDTable = (XGI_ExtStruct *) XGI330_EModeIDTable ;
238 pVBInfo->RefIndex = (XGI_Ext2Struct *) XGI330_RefIndex ;
239 pVBInfo->XGINEWUB_CRT1Table = (XGI_CRT1TableStruct *) XGI_CRT1Table ;
240
241 /* add for new UNIVGABIOS */
242 /* XGINew_UBLCDDataTable = (XGI_LCDDataTablStruct *) XGI_LCDDataTable ; */
243 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable ; */
244
245
246 if ( ChipType >= XG40 )
247 {
248 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI340New_MCLKData ;
249 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI340_ECLKData ;
250 }
251 else
252 {
253 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI330New_MCLKData ;
254 pVBInfo->ECLKData = (XGI_ECLKDataStruct *) XGI330_ECLKData ;
255 }
256
257 pVBInfo->VCLKData = (XGI_VCLKDataStruct *) XGI_VCLKData ;
258 pVBInfo->VBVCLKData = (XGI_VBVCLKDataStruct *) XGI_VBVCLKData ;
259 pVBInfo->ScreenOffset = XGI330_ScreenOffset ;
260 pVBInfo->StResInfo = (XGI_StResInfoStruct *) XGI330_StResInfo ;
261 pVBInfo->ModeResInfo = (XGI_ModeResInfoStruct *) XGI330_ModeResInfo ;
262
263 pVBInfo->pOutputSelect = &XGI330_OutputSelect ;
264 pVBInfo->pSoftSetting = &XGI330_SoftSetting ;
265 pVBInfo->pSR07 = &XGI330_SR07 ;
266 pVBInfo->LCDResInfo = 0 ;
267 pVBInfo->LCDTypeInfo = 0 ;
268 pVBInfo->LCDInfo = 0 ;
269 pVBInfo->VBInfo = 0 ;
270 pVBInfo->TVInfo = 0;
271
272
273 pVBInfo->SR15 = XGI340_SR13 ;
274 pVBInfo->CR40 = XGI340_cr41 ;
275 pVBInfo->SR25 = XGI330_sr25 ;
276 pVBInfo->pSR31 = &XGI330_sr31 ;
277 pVBInfo->pSR32 = &XGI330_sr32 ;
278 pVBInfo->CR6B = XGI340_CR6B ;
279 pVBInfo->CR6E = XGI340_CR6E ;
280 pVBInfo->CR6F = XGI340_CR6F ;
281 pVBInfo->CR89 = XGI340_CR89 ;
282 pVBInfo->AGPReg = XGI340_AGPReg ;
283 pVBInfo->SR16 = XGI340_SR16 ;
284 pVBInfo->pCRCF = &XG40_CRCF ;
285 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition ;
286
287
288 pVBInfo->CR49 = XGI330_CR49 ;
289 pVBInfo->pSR1F = &XGI330_SR1F ;
290 pVBInfo->pSR21 = &XGI330_SR21 ;
291 pVBInfo->pSR22 = &XGI330_SR22 ;
292 pVBInfo->pSR23 = &XGI330_SR23 ;
293 pVBInfo->pSR24 = &XGI330_SR24 ;
294 pVBInfo->pSR33 = &XGI330_SR33 ;
295
296
297
298 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2 ;
299 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D ;
300 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E ;
301 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10 ;
302 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData ;
303 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData ;
304 pVBInfo->pYCSenseData = &XGI330_YCSenseData ;
305 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2 ;
306 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2 ;
307 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2 ;
308
309 pVBInfo->NTSCTiming = XGI330_NTSCTiming ;
310 pVBInfo->PALTiming = XGI330_PALTiming ;
311 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming ;
312 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing ;
313 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing ;
314 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming ;
315 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming ;
316 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming ;
317 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming ;
318 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data ;
319 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu ;
320 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text ;
321 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3 ;
322 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3 ;
323
324
325 pVBInfo->TimingH = (XGI_TimingHStruct *) XGI_TimingH ;
326 pVBInfo->TimingV = (XGI_TimingVStruct *) XGI_TimingV ;
327 pVBInfo->UpdateCRT1 = (XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table ;
328
329 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC ;
330 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC ;
331 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL ;
332 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL ;
333
334 /* 310 customization related */
335 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
336 pVBInfo->LCDCapList = XGI_LCDDLCapList ;
337 else
338 pVBInfo->LCDCapList = XGI_LCDCapList ;
339
340 if ( ( ChipType == XG21 ) || ( ChipType == XG27 ) )
341 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList ;
342
343 pVBInfo->XGI_TVDelayList = XGI301TVDelayList ;
344 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2 ;
345
346
347 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition ;
348
349 if ( ChipType >= XG20 )
350 pVBInfo->pXGINew_CR97 = &XG20_CR97 ;
351
352 if ( ChipType == XG27 )
353 {
354 pVBInfo->MCLKData = (XGI_MCLKDataStruct *) XGI27New_MCLKData ;
355 pVBInfo->CR40 = XGI27_cr41 ;
356 pVBInfo->pXGINew_CR97 = &XG27_CR97 ;
357 pVBInfo->pSR36 = &XG27_SR36 ;
358 pVBInfo->pCR8F = &XG27_CR8F ;
359 pVBInfo->pCRD0 = XG27_CRD0 ;
360 pVBInfo->pCRDE = XG27_CRDE ;
361 pVBInfo->pSR40 = &XG27_SR40 ;
362 pVBInfo->pSR41 = &XG27_SR41 ;
363
364 }
365
366 if ( ChipType >= XG20 )
367 {
368 pVBInfo->pDVOSetting = &XG21_DVOSetting ;
369 pVBInfo->pCR2E = &XG21_CR2E ;
370 pVBInfo->pCR2F = &XG21_CR2F ;
371 pVBInfo->pCR46 = &XG21_CR46 ;
372 pVBInfo->pCR47 = &XG21_CR47 ;
373 }
374
375}
376
377
378
379
380
381
382/* --------------------------------------------------------------------- */
383/* Function : XGISetModeNew */
384/* Input : */
385/* Output : */
386/* Description : */
387/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400388unsigned char XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short ModeNo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200389{
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400390 unsigned short ModeIdIndex ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200391 /* PUCHAR pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; */
392 VB_DEVICE_INFO VBINF;
393 PVB_DEVICE_INFO pVBInfo = &VBINF;
394 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400395 pVBInfo->BaseAddr = (unsigned long)HwDeviceExtension->pjIOAddress ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200396 pVBInfo->IF_DEF_LVDS = 0 ;
397 pVBInfo->IF_DEF_CH7005 = 0 ;
398 pVBInfo->IF_DEF_LCDA = 1 ;
399 pVBInfo->IF_DEF_CH7017 = 0 ;
400 pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
401 pVBInfo->IF_DEF_VideoCapture = 0 ;
402 pVBInfo->IF_DEF_ScaleLCD = 0 ;
403 pVBInfo->IF_DEF_OEMUtil = 0 ;
404 pVBInfo->IF_DEF_PWD = 0 ;
405
406
407 if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
408 {
409 pVBInfo->IF_DEF_YPbPr = 0 ;
410 pVBInfo->IF_DEF_HiVision = 0 ;
411 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
412 pVBInfo->VBType = 0 ; /*set VBType default 0*/
413 }
414 else if ( HwDeviceExtension->jChipType >= XG40 )
415 {
416 pVBInfo->IF_DEF_YPbPr = 1 ;
417 pVBInfo->IF_DEF_HiVision = 1 ;
418 pVBInfo->IF_DEF_CRT2Monitor = 1 ;
419 }
420 else
421 {
422 pVBInfo->IF_DEF_YPbPr = 1 ;
423 pVBInfo->IF_DEF_HiVision = 1 ;
424 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
425 }
426
427 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
428 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
429 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
430 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
431 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
432 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
433 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
434 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
435 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
436 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
437 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
438 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
439 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
440 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
441 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
442 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
443 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
444 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
445
446 if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
447 {
448 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
449 {
450 pVBInfo->IF_DEF_LVDS = 1 ;
451 }
452 }
453 if ( HwDeviceExtension->jChipType == XG27 )
454 {
455 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
456 {
457 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
458 {
459 pVBInfo->IF_DEF_LVDS = 1 ;
460 }
461 }
462 }
463
464 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
465 XGI_GetVBType( pVBInfo ) ;
466
467 InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200468 if ( ModeNo & 0x80 )
469 {
470 ModeNo = ModeNo & 0x7F ;
471/* XGINew_flag_clearbuffer = 0 ; */
472 }
473/* else
474 {
475 XGINew_flag_clearbuffer = 1 ;
476 }
477*/
478 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
479
480 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 1.Openkey */
481 XGI_UnLockCRT2( HwDeviceExtension , pVBInfo ) ;
482
483 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
484
485 XGI_GetVGAType(HwDeviceExtension, pVBInfo) ;
486
487 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
488 {
489 XGI_GetVBInfo(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
490 XGI_GetTVInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
491 XGI_GetLCDInfo(ModeNo , ModeIdIndex, pVBInfo ) ;
492 XGI_DisableBridge( HwDeviceExtension,pVBInfo ) ;
493/* XGI_OpenCRTC( HwDeviceExtension, pVBInfo ) ; */
494
495 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA ) )
496 {
497 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
498
499 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
500 {
501 XGI_SetLCDAGroup(ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
502 }
503 }
504 else
505 {
506 if ( !( pVBInfo->VBInfo & SwitchToCRT2) )
507 {
508 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
509 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
510 {
511 XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ;
512 }
513 }
514 }
515
516 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SwitchToCRT2 ) )
517 {
518 switch( HwDeviceExtension->ujVBChipID )
519 {
520 case VB_CHIP_301:
521 XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
522 break ;
523
524 case VB_CHIP_302:
525 XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */
526 break ;
527
528 default:
529 break ;
530 }
531 }
532
533 XGI_SetCRT2ModeRegs( ModeNo, HwDeviceExtension,pVBInfo ) ;
534 XGI_OEM310Setting( ModeNo, ModeIdIndex,pVBInfo ) ; /*0212*/
535 XGI_CloseCRTC( HwDeviceExtension, pVBInfo ) ;
536 XGI_EnableBridge( HwDeviceExtension ,pVBInfo) ;
537 } /* !XG20 */
538 else
539 {
Bill Pembertondda08c52010-06-17 13:10:42 -0400540 if (pVBInfo->IF_DEF_LVDS == 1)
541 if (!XGI_XG21CheckLVDSMode(ModeNo , ModeIdIndex, pVBInfo))
542 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200543
544 if ( ModeNo <= 0x13 )
545 {
546 pVBInfo->ModeType = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag & ModeInfoFlag;
547 }
548 else
549 {
550 pVBInfo->ModeType = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & ModeInfoFlag;
551 }
552
553 pVBInfo->SetFlag = 0 ;
554 if ( pVBInfo->IF_DEF_CH7007 != 1 )
555 {
556 pVBInfo->VBInfo = DisableCRT2Display ;
557 }
558
559
560 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
561
562 XGI_SetCRT1Group(HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
563
564 XGI_DisplayOn( HwDeviceExtension, pVBInfo ) ;
565 /*
566 if( HwDeviceExtension->jChipType == XG21 )
567 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
568 */
569 }
570
571
572/*
573 if ( ModeNo <= 0x13 )
574 {
575 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
576 }
577 else
578 {
579 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
580 }
581 pVBInfo->ModeType = modeflag&ModeInfoFlag ;
582 pVBInfo->SetFlag = 0x00 ;
583 pVBInfo->VBInfo = DisableCRT2Display ;
584 temp = XGINew_CheckMemorySize( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
585
586 if ( temp == 0 )
587 return( 0 ) ;
588
589 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
590 XGI_SetCRT1Group( HwDeviceExtension , ModeNo , ModeIdIndex, pVBInfo ) ;
591 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
592*/
593
594 XGI_UpdateModeInfo( HwDeviceExtension, pVBInfo ) ;
595
596 if ( HwDeviceExtension->jChipType < XG20 ) /* kuku 2004/06/25 */
597{
598 XGI_LockCRT2( HwDeviceExtension, pVBInfo ) ;
599}
600
Bill Pembertondda08c52010-06-17 13:10:42 -0400601 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200602}
603
604
605/* --------------------------------------------------------------------- */
606/* Function : XGI_SetCRT1Group */
607/* Input : */
608/* Output : */
609/* Description : */
610/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400611void XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension,
612 unsigned short ModeNo,
613 unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200614{
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400615 unsigned short StandTableIndex ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200616 RefreshRateTableIndex ,
617 b3CC ,
618 temp ;
619
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400620 unsigned short XGINew_P3cc = pVBInfo->P3cc;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200621
622 /* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
623 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
624 /* XGI_SetBIOSData(ModeNo , ModeIdIndex ) ; */
625 /* XGI_ClearBankRegs( ModeNo , ModeIdIndex ) ; */
626 XGI_SetSeqRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
627 XGI_SetMiscRegs( StandTableIndex, pVBInfo ) ;
628 XGI_SetCRTCRegs( HwDeviceExtension , StandTableIndex, pVBInfo) ;
629 XGI_SetATTRegs( ModeNo , StandTableIndex , ModeIdIndex, pVBInfo ) ;
630 XGI_SetGRCRegs( StandTableIndex, pVBInfo ) ;
631 XGI_ClearExt1Regs(pVBInfo) ;
632
633/* if ( pVBInfo->IF_DEF_ExpLink ) */
634 if ( HwDeviceExtension->jChipType == XG27 )
635 {
636 if ( pVBInfo->IF_DEF_LVDS == 0 )
637 {
638 XGI_SetDefaultVCLK( pVBInfo ) ;
639 }
640 }
641
642 temp = ~ProgrammingCRT2 ;
643 pVBInfo->SetFlag &= temp ;
644 pVBInfo->SelectCRT2Rate = 0 ;
645
646 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
647 {
648 if ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToLCDA | SetInSlaveMode ) )
649 {
650 pVBInfo->SetFlag |= ProgrammingCRT2 ;
651 }
652 }
653
654 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
655 if ( RefreshRateTableIndex != 0xFFFF )
656 {
657 XGI_SetSync( RefreshRateTableIndex, pVBInfo ) ;
658 XGI_SetCRT1CRTC( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo, HwDeviceExtension ) ;
659 XGI_SetCRT1DE( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
660 XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
661 XGI_SetCRT1VCLK( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
662 }
663
664 if ( ( HwDeviceExtension->jChipType >= XG20 )&&
665 ( HwDeviceExtension->jChipType < XG27 ) ) /* fix H/W DCLK/2 bug */
666 {
667 if ( ( ModeNo == 0x00 ) | (ModeNo == 0x01) )
668 {
669 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x4E) ;
670 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE9) ;
671 b3CC =(UCHAR) XGINew_GetReg2(XGINew_P3cc) ;
672 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
673 }
674 else if ( ( ModeNo == 0x04) | ( ModeNo == 0x05) | ( ModeNo == 0x0D) )
675 {
676 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B) ;
677 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE3) ;
678 b3CC = (UCHAR)XGINew_GetReg2(XGINew_P3cc) ;
679 XGINew_SetReg3(XGINew_P3cc , (b3CC |= 0x0C) ) ;
680 }
681 }
682
683 if ( HwDeviceExtension->jChipType >= XG21 )
684 {
685 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
686 if ( temp & 0xA0 )
687 {
688
689 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
690 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
691 /* XG21 CRT1 Timing */
692 if ( HwDeviceExtension->jChipType == XG27 )
693 XGI_SetXG27CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
694 else
695 XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
696
697 XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
698
699 if ( HwDeviceExtension->jChipType == XG27 )
700 XGI_SetXG27LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
701 else
702 XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
703
704 if ( pVBInfo->IF_DEF_LVDS == 1 )
705 {
706 if ( HwDeviceExtension->jChipType == XG27 )
707 XGI_SetXG27LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
708 else
709 XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
710 }
711 /*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
712 }
713 }
714
715 pVBInfo->SetFlag &= ( ~ProgrammingCRT2 ) ;
716 XGI_SetCRT1FIFO( ModeNo , HwDeviceExtension, pVBInfo ) ;
717 XGI_SetCRT1ModeRegs( HwDeviceExtension , ModeNo , ModeIdIndex , RefreshRateTableIndex , pVBInfo) ;
718
719
720 /* XGI_LoadCharacter(); //dif ifdef TVFont */
721
722 XGI_LoadDAC( ModeNo , ModeIdIndex, pVBInfo ) ;
723 /* XGI_ClearBuffer( HwDeviceExtension , ModeNo, pVBInfo ) ; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200724}
725
726
727/* --------------------------------------------------------------------- */
728/* Function : XGI_GetModePtr */
729/* Input : */
730/* Output : */
731/* Description : */
732/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400733UCHAR XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
734 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200735{
736 UCHAR index ;
737
738 if ( ModeNo <= 0x13 )
739 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_StTableIndex ;
740 else
741 {
742 if ( pVBInfo->ModeType <= 0x02 )
743 index = 0x1B ; /* 02 -> ModeEGA */
744 else
745 index = 0x0F ;
746 }
747 return( index ) ; /* Get pVBInfo->StandTable index */
748}
749
750
751/* --------------------------------------------------------------------- */
752/* Function : XGI_SetBIOSData */
753/* Input : */
754/* Output : */
755/* Description : */
756/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400757/*UCHAR XGI_SetBIOSData(unsigned short ModeNo , unsigned short ModeIdIndex )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200758{
759 return( 0 ) ;
760}
761*/
762
763/* --------------------------------------------------------------------- */
764/* Function : XGI_ClearBankRegs */
765/* Input : */
766/* Output : */
767/* Description : */
768/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400769/*UCHAR XGI_ClearBankRegs(unsigned short ModeNo , unsigned short ModeIdIndex )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200770{
771 return( 0 ) ;
772}
773*/
774
775/* --------------------------------------------------------------------- */
776/* Function : XGI_SetSeqRegs */
777/* Input : */
778/* Output : */
779/* Description : */
780/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400781void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
782 unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200783{
784 UCHAR tempah ,
785 SRdata ;
786
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400787 unsigned short i ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200788 modeflag ;
789
790 if ( ModeNo <= 0x13 )
791 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
792 else
793 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
794
795 XGINew_SetReg1( pVBInfo->P3c4 , 0x00 , 0x03 ) ; /* Set SR0 */
796 tempah=pVBInfo->StandTable[ StandTableIndex ].SR[ 0 ] ;
797
798 i = SetCRT2ToLCDA ;
799 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
800 {
801 tempah |= 0x01 ;
802 }
803 else
804 {
805 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
806 {
807 if ( pVBInfo->VBInfo & SetInSlaveMode )
808 tempah |= 0x01 ;
809 }
810 }
811
812 tempah |= 0x20 ; /* screen off */
813 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , tempah ) ; /* Set SR1 */
814
815 for( i = 02 ; i <= 04 ; i++ )
816 {
817 SRdata = pVBInfo->StandTable[ StandTableIndex ].SR[ i - 1 ] ; /* Get SR2,3,4 from file */
818 XGINew_SetReg1( pVBInfo->P3c4 , i , SRdata ) ; /* Set SR2 3 4 */
819 }
820}
821
822
823/* --------------------------------------------------------------------- */
824/* Function : XGI_SetMiscRegs */
825/* Input : */
826/* Output : */
827/* Description : */
828/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400829void XGI_SetMiscRegs(unsigned short StandTableIndex, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200830{
831 UCHAR Miscdata ;
832
833 Miscdata = pVBInfo->StandTable[ StandTableIndex ].MISC ; /* Get Misc from file */
834/*
835 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
836 {
837 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
838 {
839 Miscdata |= 0x0C ;
840 }
841 }
842*/
843
844 XGINew_SetReg3( pVBInfo->P3c2 , Miscdata ) ; /* Set Misc(3c2) */
845}
846
847
848/* --------------------------------------------------------------------- */
849/* Function : XGI_SetCRTCRegs */
850/* Input : */
851/* Output : */
852/* Description : */
853/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400854void XGI_SetCRTCRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension ,
855 unsigned short StandTableIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200856{
857 UCHAR CRTCdata ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400858 unsigned short i ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200859
860 CRTCdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
861 CRTCdata &= 0x7f ;
862 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , CRTCdata ) ; /* Unlock CRTC */
863
864 for( i = 0 ; i <= 0x18 ; i++ )
865 {
866 CRTCdata = pVBInfo->StandTable[ StandTableIndex ].CRTC[ i ] ; /* Get CRTC from file */
867 XGINew_SetReg1( pVBInfo->P3d4 , i , CRTCdata ) ; /* Set CRTC( 3d4 ) */
868 }
869/*
870 if ( ( HwDeviceExtension->jChipType == XGI_630 )&& ( HwDeviceExtension->jChipRevision == 0x30 ) )
871 {
872 if ( pVBInfo->VBInfo & SetInSlaveMode )
873 {
874 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
875 {
876 XGINew_SetReg1( pVBInfo->P3d4 , 0x18 , 0xFE ) ;
877 }
878 }
879 }
880*/
881}
882
883
884/* --------------------------------------------------------------------- */
885/* Function : */
886/* Input : */
887/* Output : */
888/* Description : */
889/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400890void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
891 unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200892{
893 UCHAR ARdata ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400894 unsigned short i, modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200895
896 if ( ModeNo <= 0x13 )
897 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
898 else
899 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
900
901 for( i = 0 ; i <= 0x13 ; i++ )
902 {
903 ARdata = pVBInfo->StandTable[ StandTableIndex ].ATTR[ i ] ;
904 if ( modeflag & Charx8Dot ) /* ifndef Dot9 */
905 {
906 if ( i == 0x13 )
907 {
908 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
909 ARdata = 0 ;
910 else
911 {
912 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD ) )
913 {
914 if ( pVBInfo->VBInfo & SetInSlaveMode )
915 ARdata = 0 ;
916 }
917 }
918 }
919 }
920
921 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
922 XGINew_SetReg3( pVBInfo->P3c0 , i ) ; /* set index */
923 XGINew_SetReg3( pVBInfo->P3c0 , ARdata ) ; /* set data */
924 }
925
926 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
927 XGINew_SetReg3( pVBInfo->P3c0 , 0x14 ) ; /* set index */
928 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data */
929 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
930 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
931}
932
933
934/* --------------------------------------------------------------------- */
935/* Function : XGI_SetGRCRegs */
936/* Input : */
937/* Output : */
938/* Description : */
939/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400940void XGI_SetGRCRegs(unsigned short StandTableIndex, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200941{
942 UCHAR GRdata ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400943 unsigned short i ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200944
945 for( i = 0 ; i <= 0x08 ; i++ )
946 {
947 GRdata = pVBInfo->StandTable[ StandTableIndex ].GRC[ i ] ; /* Get GR from file */
948 XGINew_SetReg1( pVBInfo->P3ce , i , GRdata ) ; /* Set GR(3ce) */
949 }
950
951 if ( pVBInfo->ModeType > ModeVGA )
952 {
953 GRdata = ( UCHAR )XGINew_GetReg1( pVBInfo->P3ce , 0x05 ) ;
954 GRdata &= 0xBF ; /* 256 color disable */
955 XGINew_SetReg1( pVBInfo->P3ce , 0x05 , GRdata ) ;
956 }
957}
958
959
960/* --------------------------------------------------------------------- */
961/* Function : XGI_ClearExt1Regs */
962/* Input : */
963/* Output : */
964/* Description : */
965/* --------------------------------------------------------------------- */
966void XGI_ClearExt1Regs(PVB_DEVICE_INFO pVBInfo)
967{
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400968 unsigned short i ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200969
970 for( i = 0x0A ; i <= 0x0E ; i++ )
971 XGINew_SetReg1( pVBInfo->P3c4 , i , 0x00 ) ; /* Clear SR0A-SR0E */
972}
973
974
975/* --------------------------------------------------------------------- */
976/* Function : XGI_SetDefaultVCLK */
977/* Input : */
978/* Output : */
979/* Description : */
980/* --------------------------------------------------------------------- */
981UCHAR XGI_SetDefaultVCLK( PVB_DEVICE_INFO pVBInfo )
982{
983
984 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x20 ) ;
985 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 0 ].SR2B ) ;
986 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 0 ].SR2C ) ;
987
988 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , 0x10 ) ;
989 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ 1 ].SR2B ) ;
990 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ 1 ].SR2C ) ;
991
992 XGINew_SetRegAND( pVBInfo->P3c4 , 0x31 , ~0x30 ) ;
993 return( 0 ) ;
994}
995
996
997/* --------------------------------------------------------------------- */
998/* Function : XGI_GetRatePtrCRT2 */
999/* Input : */
1000/* Output : */
1001/* Description : */
1002/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001003unsigned short XGI_GetRatePtrCRT2(PXGI_HW_DEVICE_INFO pXGIHWDE,
1004 unsigned short ModeNo,
1005 unsigned short ModeIdIndex,
1006 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001007{
1008 SHORT LCDRefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 } ,
1009 LCDARefreshIndex[] = { 0x00 , 0x00 , 0x03 , 0x01 , 0x01 , 0x01 , 0x01 } ;
1010
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001011 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001012
1013 if ( ModeNo <= 0x13 )
1014 {
1015 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1016 }
1017 else
1018 {
1019 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1020 }
1021
1022 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1023 {
1024 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1025 {
1026 if ( modeflag & HalfDCLK )
1027 return( 0 ) ;
1028 }
1029 }
1030
1031 if ( ModeNo < 0x14 )
1032 return( 0xFFFF ) ;
1033
1034 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
1035 index = index >> pVBInfo->SelectCRT2Rate ;
1036 index &= 0x0F ;
1037
1038 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1039 index = 0 ;
1040
1041 if ( index > 0 )
1042 index-- ;
1043
1044 if ( pVBInfo->SetFlag & ProgrammingCRT2 )
1045 {
1046 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1047 {
1048 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1049 {
1050 index = 0 ;
1051 }
1052 }
1053
1054 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
1055 {
1056 if( pVBInfo->IF_DEF_LVDS == 0 )
1057 {
1058 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1059 temp = LCDARefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ; /* 301b */
1060 else
1061 temp = LCDRefreshIndex[ pVBInfo->LCDResInfo & 0x0F ] ;
1062
1063 if ( index > temp )
1064 {
1065 index = temp ;
1066 }
1067 }
1068 else
1069 {
1070 index = 0 ;
1071 }
1072 }
1073 }
1074
1075 RefreshRateTableIndex = pVBInfo->EModeIDTable[ ModeIdIndex ].REFindex ;
1076 ModeNo = pVBInfo->RefIndex[ RefreshRateTableIndex ].ModeID ;
1077 if ( pXGIHWDE->jChipType >= XG20 ) /* for XG20, XG21, XG27 */
1078 {
1079 /*
1080 if ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag & XG2xNotSupport )
1081 {
1082 index++;
1083 }
1084 */
1085 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 800 ) &&
1086 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 600 ) )
1087 {
1088 index++;
1089 }
1090/* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
1091 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1024 ) &&
1092 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 768 ) )
1093 {
1094 index++;
1095 }
1096 if ( ( pVBInfo->RefIndex[ RefreshRateTableIndex ].XRes == 1280 ) &&
1097 ( pVBInfo->RefIndex[ RefreshRateTableIndex ].YRes == 1024 ) )
1098 {
1099 index++;
1100 }
1101 }
1102
1103 i = 0 ;
1104 do
1105 {
1106 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + i ].ModeID != ModeNo )
1107 break ;
1108 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i ].Ext_InfoFlag ;
1109 temp &= ModeInfoFlag ;
1110 if ( temp < pVBInfo->ModeType )
1111 break ;
1112 i++ ;
1113 index-- ;
1114
1115 } while( index != 0xFFFF ) ;
1116 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
1117 {
1118 if ( pVBInfo->VBInfo & SetInSlaveMode )
1119 {
1120 temp = pVBInfo->RefIndex[ RefreshRateTableIndex + i - 1 ].Ext_InfoFlag ;
1121 if ( temp & InterlaceMode )
1122 {
1123 i++ ;
1124 }
1125 }
1126 }
1127 i-- ;
1128 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
1129 {
1130 temp = XGI_AjustCRT2Rate( ModeNo , ModeIdIndex , RefreshRateTableIndex , &i, pVBInfo) ;
1131 }
1132 return( RefreshRateTableIndex + i ) ; /*return(0x01|(temp1<<1)); */
1133}
1134
1135
1136/* --------------------------------------------------------------------- */
1137/* Function : XGI_AjustCRT2Rate */
1138/* Input : */
1139/* Output : */
1140/* Description : */
1141/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001142unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, unsigned short ModeIdIndex,
1143 unsigned short RefreshRateTableIndex,
1144 unsigned short *i, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001145{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001146 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001147
1148 if ( ModeNo <= 0x13 )
1149 {
1150 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
1151 }
1152 else
1153 {
1154 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1155 }
1156
1157 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
1158 tempbx = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID ;
1159 tempax = 0 ;
1160
1161 if ( pVBInfo->IF_DEF_LVDS == 0 )
1162 {
1163 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
1164 {
1165 tempax |= SupportRAMDAC2 ;
1166
1167 if ( pVBInfo->VBType & VB_XGI301C )
1168 tempax |= SupportCRT2in301C ;
1169 }
1170
1171 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) /* 301b */
1172 {
1173 tempax |= SupportLCD ;
1174
1175 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
1176 {
1177 if ( pVBInfo->LCDResInfo != Panel1280x960 )
1178 {
1179 if ( pVBInfo->LCDInfo & LCDNonExpanding )
1180 {
1181 if ( resinfo >= 9 )
1182 {
1183 tempax = 0 ;
1184 return( 0 ) ;
1185 }
1186 }
1187 }
1188 }
1189 }
1190
1191 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) /* for HiTV */
1192 {
1193 if ( ( pVBInfo->VBType & VB_XGI301LV ) && ( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
1194 {
1195 tempax |= SupportYPbPr ;
1196 if ( pVBInfo->VBInfo & SetInSlaveMode )
1197 {
1198 if ( resinfo == 4 )
1199 return( 0 ) ;
1200
1201 if ( resinfo == 3 )
1202 return( 0 ) ;
1203
1204 if ( resinfo > 7 )
1205 return( 0 ) ;
1206 }
1207 }
1208 else
1209 {
1210 tempax |= SupportHiVisionTV ;
1211 if ( pVBInfo->VBInfo & SetInSlaveMode )
1212 {
1213 if ( resinfo == 4 )
1214 return( 0 ) ;
1215
1216 if ( resinfo == 3 )
1217 {
1218 if ( pVBInfo->SetFlag & TVSimuMode )
1219 return( 0 ) ;
1220 }
1221
1222 if ( resinfo > 7 )
1223 return( 0 ) ;
1224 }
1225 }
1226 }
1227 else
1228 {
1229 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV ) )
1230 {
1231 tempax |= SupportTV ;
1232
1233 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
1234 {
1235 tempax |= SupportTV1024 ;
1236 }
1237
1238 if ( !( pVBInfo->VBInfo & SetPALTV ) )
1239 {
1240 if ( modeflag & NoSupportSimuTV )
1241 {
1242 if ( pVBInfo->VBInfo & SetInSlaveMode )
1243 {
1244 if ( !( pVBInfo->VBInfo & SetNotSimuMode ) )
1245 {
1246 return( 0 ) ;
1247 }
1248 }
1249 }
1250 }
1251 }
1252 }
1253 }
1254 else /* for LVDS */
1255 {
1256 if ( pVBInfo->IF_DEF_CH7005 == 1 )
1257 {
1258 if ( pVBInfo->VBInfo & SetCRT2ToTV )
1259 {
1260 tempax |= SupportCHTV ;
1261 }
1262 }
1263
1264 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
1265 {
1266 tempax |= SupportLCD ;
1267
1268 if ( resinfo > 0x08 )
1269 return( 0 ) ; /* 1024x768 */
1270
1271 if ( pVBInfo->LCDResInfo < Panel1024x768 )
1272 {
1273 if ( resinfo > 0x07 )
1274 return( 0 ) ; /* 800x600 */
1275
1276 if ( resinfo == 0x04 )
1277 return( 0 ) ; /* 512x384 */
1278 }
1279 }
1280 }
1281
1282 for( ; pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID == tempbx ; ( *i )-- )
1283 {
1284 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1285 if ( infoflag & tempax )
1286 {
1287 return( 1 ) ;
1288 }
1289 if ( ( *i ) == 0 )
1290 break ;
1291 }
1292
1293 for( ( *i ) = 0 ; ; ( *i )++ )
1294 {
1295 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].Ext_InfoFlag ;
1296 if ( pVBInfo->RefIndex[ RefreshRateTableIndex + ( *i ) ].ModeID != tempbx )
1297 {
1298 return( 0 ) ;
1299 }
1300
1301 if ( infoflag & tempax )
1302 {
1303 return( 1 ) ;
1304 }
1305 }
1306 return( 1 ) ;
1307}
1308
1309
1310/* --------------------------------------------------------------------- */
1311/* Function : XGI_SetSync */
1312/* Input : */
1313/* Output : */
1314/* Description : */
1315/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001316void XGI_SetSync(unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001317{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001318 unsigned short sync ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001319 temp ;
1320
1321 sync = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag >> 8 ; /* di+0x00 */
1322 sync &= 0xC0 ;
1323 temp = 0x2F ;
1324 temp |= sync ;
1325 XGINew_SetReg3( pVBInfo->P3c2 , temp ) ; /* Set Misc(3c2) */
1326}
1327
1328
1329/* --------------------------------------------------------------------- */
1330/* Function : XGI_SetCRT1CRTC */
1331/* Input : */
1332/* Output : */
1333/* Description : */
1334/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001335void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1336 unsigned short RefreshRateTableIndex,
1337 PVB_DEVICE_INFO pVBInfo,
1338 PXGI_HW_DEVICE_INFO HwDeviceExtension)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001339{
1340 UCHAR index ,
1341 data ;
1342
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001343 unsigned short i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001344
1345 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ; /* Get index */
1346 index = index&IndexMask ;
1347
1348 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1349 data &= 0x7F ;
1350 XGINew_SetReg1(pVBInfo->P3d4,0x11,data); /* Unlock CRTC */
1351
1352 for( i = 0 ; i < 8 ; i++ )
1353 pVBInfo->TimingH[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i ] ;
1354
1355 for( i = 0 ; i < 7 ; i++ )
1356 pVBInfo->TimingV[ 0 ].data[ i ] = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ i + 8 ] ;
1357
1358 XGI_SetCRT1Timing_H( pVBInfo, HwDeviceExtension ) ;
1359
1360
1361
1362 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo, pVBInfo ) ;
1363
1364
1365 if( pVBInfo->ModeType > 0x03 )
1366 XGINew_SetReg1( pVBInfo->P3d4 , 0x14 , 0x4F ) ;
1367}
1368
1369
1370/* --------------------------------------------------------------------- */
1371/* Function : XGI_SetCRT1Timing_H */
1372/* Input : */
1373/* Output : */
1374/* Description : */
1375/* --------------------------------------------------------------------- */
1376void XGI_SetCRT1Timing_H( PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO HwDeviceExtension )
1377{
1378 UCHAR data , data1, pushax;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001379 unsigned short i, j;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001380
1381 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1382 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1383 /* XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x11 , 0x7f , 0x00 ) ; */
1384
1385 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ; /* unlock cr0-7 */
1386 data &= 0x7F ;
1387 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ;
1388
1389 data = pVBInfo->TimingH[ 0 ].data[ 0 ] ;
1390 XGINew_SetReg1( pVBInfo->P3d4 , 0 , data ) ;
1391
1392 for( i = 0x01 ; i <= 0x04 ; i++ )
1393 {
1394 data = pVBInfo->TimingH[ 0 ].data[ i ] ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001395 XGINew_SetReg1( pVBInfo->P3d4, (unsigned short)(i + 1), data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001396 }
1397
1398 for( i = 0x05 ; i <= 0x06 ; i++ )
1399 {
1400 data = pVBInfo->TimingH[ 0 ].data[ i ];
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001401 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short)(i + 6), data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001402 }
1403
1404 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1405 j &= 0x1F ;
1406 data = pVBInfo->TimingH[ 0 ].data[ 7 ] ;
1407 data &= 0xE0 ;
1408 data |= j ;
1409 XGINew_SetReg1( pVBInfo->P3c4 , 0x0e , data ) ;
1410
1411 if ( HwDeviceExtension->jChipType >= XG20 )
1412 {
1413 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x04 ) ;
1414 data = data - 1 ;
1415 XGINew_SetReg1( pVBInfo->P3d4 , 0x04 , data ) ;
1416 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x05 ) ;
1417 data1 = data ;
1418 data1 &= 0xE0 ;
1419 data &= 0x1F ;
1420 if ( data == 0 )
1421 {
1422 pushax = data ;
1423 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0c ) ;
1424 data &= 0xFB ;
1425 XGINew_SetReg1( pVBInfo->P3c4 , 0x0c , data ) ;
1426 data = pushax ;
1427 }
1428 data = data - 1 ;
1429 data |= data1 ;
1430 XGINew_SetReg1( pVBInfo->P3d4 , 0x05 , data ) ;
1431 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0e ) ;
1432 data = data >> 5 ;
1433 data = data + 3 ;
1434 if ( data > 7 )
1435 data = data - 7 ;
1436 data = data << 5 ;
1437 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0e , ~0xE0 , data ) ;
1438 }
1439}
1440
1441
1442/* --------------------------------------------------------------------- */
1443/* Function : XGI_SetCRT1Timing_V */
1444/* Input : */
1445/* Output : */
1446/* Description : */
1447/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001448void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
1449 unsigned short ModeNo,
1450 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001451{
1452 UCHAR data ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001453 unsigned short i, j;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001454
1455 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0 ) ; */
1456 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x56 , 0 ) ; */
1457 /* XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , 0x7f , 0x00 ) ; */
1458
1459 for( i = 0x00 ; i <= 0x01 ; i++ )
1460 {
1461 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001462 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 6), data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001463 }
1464
1465 for( i = 0x02 ; i <= 0x03 ; i++ )
1466 {
1467 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001468 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 0x0e), data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001469 }
1470
1471 for( i = 0x04 ; i <= 0x05 ; i++ )
1472 {
1473 data = pVBInfo->TimingV[ 0 ].data[ i ] ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001474 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 0x11), data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001475 }
1476
1477 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x0a ) ;
1478 j &= 0xC0 ;
1479 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1480 data &= 0x3F ;
1481 data |= j ;
1482 XGINew_SetReg1( pVBInfo->P3c4 , 0x0a , data ) ;
1483
1484 data = pVBInfo->TimingV[ 0 ].data[ 6 ] ;
1485 data &= 0x80 ;
1486 data = data >> 2 ;
1487
1488 if ( ModeNo <= 0x13 )
1489 i = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1490 else
1491 i = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1492
1493 i &= DoubleScanMode ;
1494 if ( i )
1495 data |= 0x80 ;
1496
1497 j = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x09 ) ;
1498 j &= 0x5F ;
1499 data |= j ;
1500 XGINew_SetReg1( pVBInfo->P3d4 , 0x09 , data ) ;
1501}
1502
1503
1504/* --------------------------------------------------------------------- */
1505/* Function : XGI_SetXG21CRTC */
1506/* Input : Stand or enhance CRTC table */
1507/* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1508/* Description : Set LCD timing */
1509/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001510void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1511 unsigned short RefreshRateTableIndex,
1512 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001513{
1514 UCHAR StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001515 unsigned short Temp1, Temp2, Temp3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001516
1517 if ( ModeNo <= 0x13 )
1518 {
1519 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1520 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1521 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1522 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1523 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1524 Tempcx = Tempax ;
1525 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1526 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1527 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1528 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1529 Tempdx <<= 2 ; /* Tempdx << 2 */
1530 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1531 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1532
1533 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR16 VRS */
1534 Tempbx = Tempax ; /* Tempbx=Tempax */
1535 Tempax &= 0x01 ; /* Tempax: VRS[0] */
1536 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS */
1537 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax: CR7 VRS */
1538 Tempdx = Tempbx >> 1 ; /* Tempdx: VRS[7:1] */
1539 Tempcx = Tempax & 0x04 ; /* Tempcx: CR7[2] */
1540 Tempcx <<= 5 ; /* Tempcx[7]: VRS[8] */
1541 Tempdx |= Tempcx ; /* Tempdx: VRS[8:1] */
1542 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempdx ) ; /* SR34[7:0]: VRS[8:1] */
1543
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001544 Temp1 = Tempcx << 1 ; /* Temp1[8]: VRS[8] UCHAR -> unsigned short */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001545 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1546 Tempax &= 0x80 ; /* Tempax[7]: CR7[7] */
1547 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1548 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1549
1550 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR16 VRE */
1551 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1552 Temp2 = Temp1 & 0x3F0 ; /* Temp2[9:4]: VRS[9:4] */
1553 Temp2 |= Tempax ; /* Temp2[9:0]: VRE[9:0] */
1554 Temp3 = Temp1 & 0x0F ; /* Temp3[3:0]: VRS[3:0] */
1555 if ( Tempax < Temp3 ) /* VRE[3:0]<VRS[3:0] */
1556 Temp2 |= 0x10 ; /* Temp2: VRE + 0x10 */
1557 Temp2 &= 0xFF ; /* Temp2[7:0]: VRE[7:0] */
1558 Tempax = (UCHAR)Temp2 ; /* Tempax[7:0]: VRE[7:0] */
1559 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1560 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1561 Temp1 >>= 9 ; /* [10:9]->[1:0] */
1562 Tempbx = (UCHAR)Temp1 ; /* Tempbx[1:0]: VRS[10:9] */
1563 Tempax |= Tempbx ; /* VRE[5:0]VRS[10:9] */
1564 Tempax &= 0x7F ;
1565 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1566 }
1567 else
1568 {
1569 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1570 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1571 Tempcx = Tempax ; /* Tempcx: HRS */
1572 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1573
1574 Tempdx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SRB */
1575 Tempdx &= 0xC0 ; /* Tempdx[7:6]: SRB[7:6] */
1576 Temp1 = Tempdx ; /* Temp1[7:6]: HRS[9:8] */
1577 Temp1 <<= 2 ; /* Temp1[9:8]: HRS[9:8] */
1578 Temp1 |= Tempax ; /* Temp1[9:0]: HRS[9:0] */
1579
1580 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1581 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1582
1583 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1584 Tempbx &= 0x04 ; /* Tempbx[2]: HRE[5] */
1585 Tempbx <<= 3 ; /* Tempbx[5]: HRE[5] */
1586 Tempax |= Tempbx ; /* Tempax[5:0]: HRE[5:0] */
1587
1588 Temp2 = Temp1 & 0x3C0 ; /* Temp2[9:6]: HRS[9:6] */
1589 Temp2 |= Tempax ; /* Temp2[9:0]: HRE[9:0] */
1590
1591 Tempcx &= 0x3F ; /* Tempcx[5:0]: HRS[5:0] */
1592 if( Tempax < Tempcx ) /* HRE < HRS */
1593 Temp2 |= 0x40 ; /* Temp2 + 0x40 */
1594
1595 Temp2 &= 0xFF ;
1596 Tempax = (UCHAR)Temp2 ; /* Tempax: HRE[7:0] */
1597 Tempax <<= 2 ; /* Tempax[7:2]: HRE[5:0] */
1598 Tempdx >>= 6 ; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1599 Tempax |= Tempdx ; /* HRE[5:0]HRS[9:8] */
1600 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1601 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1602
1603 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1604 Tempbx = Tempax ; /* Tempbx: VRS */
1605 Tempax &= 0x01 ; /* Tempax[0]: VRS[0] */
1606 XGINew_SetRegOR( pVBInfo->P3c4 , 0x33 , Tempax ) ; /* SR33[0]->VRS[0] */
1607 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[2][7] VRE */
1608 Tempcx = Tempbx >> 1 ; /* Tempcx[6:0]: VRS[7:1] */
1609 Tempdx = Tempax & 0x04 ; /* Tempdx[2]: CR7[2] */
1610 Tempdx <<= 5 ; /* Tempdx[7]: VRS[8] */
1611 Tempcx |= Tempdx ; /* Tempcx[7:0]: VRS[8:1] */
1612 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempcx ) ; /* SR34[8:1]->VRS */
1613
1614 Temp1 = Tempdx ; /* Temp1[7]: Tempdx[7] */
1615 Temp1 <<= 1 ; /* Temp1[8]: VRS[8] */
1616 Temp1 |= Tempbx ; /* Temp1[8:0]: VRS[8:0] */
1617 Tempax &= 0x80 ;
1618 Temp2 = Tempax << 2 ; /* Temp2[9]: VRS[9] */
1619 Temp1 |= Temp2 ; /* Temp1[9:0]: VRS[9:0] */
1620 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SRA */
1621 Tempax &= 0x08 ; /* Tempax[3]: VRS[3] */
1622 Temp2 = Tempax ;
1623 Temp2 <<= 7 ; /* Temp2[10]: VRS[10] */
1624 Temp1 |= Temp2 ; /* Temp1[10:0]: VRS[10:0] */
1625
1626 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1627 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1628 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SRA */
1629 Tempbx &= 0x20 ; /* Tempbx[5]: VRE[5] */
1630 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1631 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1632 Temp2 = Temp1 & 0x7E0 ; /* Temp2[10:5]: VRS[10:5] */
1633 Temp2 |= Tempax ; /* Temp2[10:5]: VRE[10:5] */
1634
1635 Temp3 = Temp1 & 0x1F ; /* Temp3[4:0]: VRS[4:0] */
1636 if ( Tempax < Temp3 ) /* VRE < VRS */
1637 Temp2 |= 0x20 ; /* VRE + 0x20 */
1638
1639 Temp2 &= 0xFF ;
1640 Tempax = (UCHAR)Temp2 ; /* Tempax: VRE[7:0] */
1641 Tempax <<= 2 ; /* Tempax[7:0]; VRE[5:0]00 */
1642 Temp1 &= 0x600 ; /* Temp1[10:9]: VRS[10:9] */
1643 Temp1 >>= 9 ; /* Temp1[1:0]: VRS[10:9] */
1644 Tempbx = (UCHAR)Temp1 ;
1645 Tempax |= Tempbx ; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1646 Tempax &= 0x7F ;
1647 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , Tempax ) ; /* SR3F D[7:2]->VRE D[1:0]->VRS */
1648 }
1649}
1650
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001651void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
1652 unsigned short RefreshRateTableIndex,
1653 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001654{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001655 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001656
1657 if ( ModeNo <= 0x13 )
1658 {
1659 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
1660 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 4 ] ; /* CR04 HRS */
1661 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E [7:0]->HRS */
1662 Tempbx = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 5 ] ; /* Tempbx: CR05 HRE */
1663 Tempbx &= 0x1F ; /* Tempbx: HRE[4:0] */
1664 Tempcx = Tempax ;
1665 Tempcx &= 0xE0 ; /* Tempcx: HRS[7:5] */
1666 Tempdx = Tempcx | Tempbx ; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1667 if ( Tempbx < ( Tempax & 0x1F ) ) /* IF HRE < HRS */
1668 Tempdx |= 0x20 ; /* Tempdx: HRE = HRE + 0x20 */
1669 Tempdx <<= 2 ; /* Tempdx << 2 */
1670 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempdx ) ; /* SR2F [7:2]->HRE */
1671 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1672
1673 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 16 ] ; /* Tempax: CR10 VRS */
1674 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS */
1675 Tempcx = Tempax ; /* Tempcx=Tempax=VRS[7:0] */
1676 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1677 Tempbx = Tempax ; /* Tempbx=CR07 */
1678 Tempax &= 0x04 ; /* Tempax[2]: CR07[2] VRS[8] */
1679 Tempax >>= 2;
1680 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01, Tempax ) ; /* SR35 D[0]->VRS D[8] */
1681 Tempcx |= (Tempax << 8) ; /* Tempcx[8] |= VRS[8] */
1682 Tempcx |= (Tempbx & 0x80)<<2; /* Tempcx[9] |= VRS[9] */
1683
1684
1685 Tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 17 ] ; /* CR11 VRE */
1686 Tempax &= 0x0F ; /* Tempax: VRE[3:0] */
1687 Tempbx = Tempcx ; /* Tempbx=Tempcx=VRS[9:0] */
1688 Tempbx &= 0x3F0 ; /* Tempbx[9:4]: VRS[9:4] */
1689 Tempbx |= Tempax ; /* Tempbx[9:0]: VRE[9:0] */
1690 if ( Tempax <= (Tempcx & 0x0F) ) /* VRE[3:0]<=VRS[3:0] */
1691 Tempbx |= 0x10 ; /* Tempbx: VRE + 0x10 */
1692 Tempax = (UCHAR)Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1693 Tempax <<= 2 ; /* Tempax << 2: VRE[5:0] */
1694 Tempcx = (Tempcx&0x600)>>8; /* Tempcx VRS[10:9] */
1695 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC, Tempax ) ; /* SR3F D[7:2]->VRE D[5:0] */
1696 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x06, Tempcx ) ; /* SR35 D[2:1]->VRS[10:9] */
1697 }
1698 else
1699 {
1700 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
1701 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1702 Tempbx = Tempax ; /* Tempbx: HRS[7:0] */
1703 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , Tempax ) ; /* SR2E[7:0]->HRS */
1704
1705 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1706 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1707 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
1708
1709 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 4 ] ; /* CR5 HRE */
1710 Tempax &= 0x1F ; /* Tempax[4:0]: HRE[4:0] */
1711 Tempcx = Tempax ; /* Tempcx: HRE[4:0] */
1712
1713 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 6 ] ; /* SRC */
1714 Tempax &= 0x04 ; /* Tempax[2]: HRE[5] */
1715 Tempax <<= 3 ; /* Tempax[5]: HRE[5] */
1716 Tempcx |= Tempax ; /* Tempcx[5:0]: HRE[5:0] */
1717
1718 Tempbx = Tempbx & 0x3C0 ; /* Tempbx[9:6]: HRS[9:6] */
1719 Tempbx |= Tempcx ; /* Tempbx: HRS[9:6]HRE[5:0] */
1720
1721 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 3 ] ; /* Tempax: CR4 HRS */
1722 Tempax &= 0x3F ; /* Tempax: HRS[5:0] */
1723 if( Tempcx <= Tempax ) /* HRE[5:0] < HRS[5:0] */
1724 Tempbx += 0x40 ; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
1725
1726 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 5 ] ; /* SR0B */
1727 Tempax &= 0xC0 ; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1728 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1729 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1730 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , Tempax ) ; /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1731 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , 0xE3 , 00 ) ;
1732
1733 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 10 ] ; /* CR10 VRS */
1734 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , Tempax ) ; /* SR34[7:0]->VRS[7:0] */
1735
1736 Tempcx = Tempax ; /* Tempcx <= VRS[7:0] */
1737 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 9 ] ; /* CR7[7][2] VRS[9][8] */
1738 Tempbx = Tempax ; /* Tempbx <= CR07[7:0] */
1739 Tempax = Tempax & 0x04 ; /* Tempax[2]: CR7[2]: VRS[8] */
1740 Tempax >>= 2 ; /* Tempax[0]: VRS[8] */
1741 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x01 , Tempax ) ; /* SR35[0]: VRS[8] */
1742 Tempcx |= (Tempax<<8) ; /* Tempcx <= VRS[8:0] */
1743 Tempcx |= ((Tempbx&0x80)<<2) ; /* Tempcx <= VRS[9:0] */
1744 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempax: SR0A */
1745 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1746 Tempcx |= (Tempax<<7) ; /* Tempcx <= VRS[10:0] */
1747
1748
1749 Tempax = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 11 ] ; /* Tempax: CR11 VRE */
1750 Tempax &= 0x0F ; /* Tempax[3:0]: VRE[3:0] */
1751 Tempbx = pVBInfo->XGINEWUB_CRT1Table[ index ].CR[ 14 ] ; /* Tempbx: SR0A */
1752 Tempbx &= 0x20 ; /* Tempbx[5]: SR0A[5]: VRE[4] */
1753 Tempbx >>= 1 ; /* Tempbx[4]: VRE[4] */
1754 Tempax |= Tempbx ; /* Tempax[4:0]: VRE[4:0] */
1755 Tempbx = Tempcx ; /* Tempbx: VRS[10:0] */
1756 Tempbx &= 0x7E0 ; /* Tempbx[10:5]: VRS[10:5] */
1757 Tempbx |= Tempax ; /* Tempbx: VRS[10:5]VRE[4:0] */
1758
1759 if ( Tempbx <= Tempcx ) /* VRE <= VRS */
1760 Tempbx |= 0x20 ; /* VRE + 0x20 */
1761
1762 Tempax = (Tempbx<<2) & 0xFF ; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1763 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , Tempax ) ; /* SR3F[7:2]:VRE[5:0] */
1764 Tempax = Tempcx >> 8;
1765 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , Tempax ) ; /* SR35[2:0]:VRS[10:8] */
1766 }
1767}
1768
1769
1770/* --------------------------------------------------------------------- */
1771/* Function : XGI_SetXG21LCD */
1772/* Input : */
1773/* Output : FCLK duty cycle, FCLK delay compensation */
1774/* Description : All values set zero */
1775/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001776void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,
1777 unsigned short RefreshRateTableIndex,
1778 unsigned short ModeNo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001779{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001780 unsigned short Data, Temp, b3CC;
1781 unsigned short XGI_P3cc;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001782
1783 XGI_P3cc = pVBInfo->P3cc ;
1784
1785 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1786 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1787 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1788 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1789 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1790 {
1791 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1792 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1793 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1794 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1795 }
1796
1797 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1798
1799 if ( Temp & 0x01 )
1800 {
1801 XGINew_SetRegOR( pVBInfo->P3c4 , 0x06 , 0x40 ) ; /* 18 bits FP */
1802 XGINew_SetRegOR( pVBInfo->P3c4 , 0x09 , 0x40 ) ;
1803 }
1804
1805 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1806
1807 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ;
1808 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ;
1809
1810 if ( ModeNo <= 0x13 )
1811 {
1812 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1813 if ( b3CC & 0x40 )
1814 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1815 if ( b3CC & 0x80 )
1816 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1817 }
1818 else
1819 {
1820 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1821 if ( Data & 0x4000 )
1822 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1823 if ( Data & 0x8000 )
1824 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1825 }
1826}
1827
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001828void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,
1829 unsigned short RefreshRateTableIndex,
1830 unsigned short ModeNo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001831{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001832 unsigned short Data , Temp , b3CC ;
1833 unsigned short XGI_P3cc ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001834
1835 XGI_P3cc = pVBInfo->P3cc ;
1836
1837 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , 0x00 ) ;
1838 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , 0x00 ) ;
1839 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
1840 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
1841
1842 Temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
1843 if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
1844 {
1845 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , 0x13 ) ;
1846 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , 0x13 ) ;
1847 }
1848
1849 if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
1850 {
1851 XGINew_SetReg1( pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
1852 XGINew_SetReg1( pVBInfo->P3d4 , 0x2F , *pVBInfo->pCR2F ) ;
1853 XGINew_SetReg1( pVBInfo->P3d4 , 0x46 , *pVBInfo->pCR46 ) ;
1854 XGINew_SetReg1( pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
1855 }
1856
1857 XGI_SetXG27FPBits(pVBInfo);
1858
1859 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
1860
1861 XGINew_SetRegAND( pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
1862 XGINew_SetRegAND( pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
1863
1864 if ( ModeNo <= 0x13 )
1865 {
1866 b3CC = (UCHAR) XGINew_GetReg2( XGI_P3cc ) ;
1867 if ( b3CC & 0x40 )
1868 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1869 if ( b3CC & 0x80 )
1870 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1871 }
1872 else
1873 {
1874 Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1875 if ( Data & 0x4000 )
1876 XGINew_SetRegOR( pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
1877 if ( Data & 0x8000 )
1878 XGINew_SetRegOR( pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
1879 }
1880}
1881
1882/* --------------------------------------------------------------------- */
1883/* Function : XGI_UpdateXG21CRTC */
1884/* Input : */
1885/* Output : CRT1 CRTC */
1886/* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1887/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001888void XGI_UpdateXG21CRTC(unsigned short ModeNo,
1889 PVB_DEVICE_INFO pVBInfo,
1890 unsigned short RefreshRateTableIndex)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001891{
1892 int i , index = -1;
1893
1894 XGINew_SetRegAND( pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
1895 if ( ModeNo <= 0x13 )
1896 {
1897 for( i = 0 ; i < 12 ; i++ )
1898 {
1899 if ( ModeNo == pVBInfo->UpdateCRT1[ i ].ModeID )
1900 index = i ;
1901 }
1902 }
1903 else
1904 {
1905 if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x60 ) )
1906 index = 12 ;
1907 else if ( ModeNo == 0x2E && ( pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC == RES640x480x72 ) )
1908 index = 13 ;
1909 else if ( ModeNo == 0x2F )
1910 index = 14 ;
1911 else if ( ModeNo == 0x50 )
1912 index = 15 ;
1913 else if ( ModeNo == 0x59 )
1914 index = 16 ;
1915 }
1916
1917 if( index != -1 )
1918 {
1919 XGINew_SetReg1( pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
1920 XGINew_SetReg1( pVBInfo->P3d4 , 0x03 , pVBInfo->UpdateCRT1[ index ].CR03 ) ;
1921 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
1922 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
1923 }
1924}
1925
1926
1927/* --------------------------------------------------------------------- */
1928/* Function : XGI_SetCRT1DE */
1929/* Input : */
1930/* Output : */
1931/* Description : */
1932/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001933void XGI_SetCRT1DE(PXGI_HW_DEVICE_INFO HwDeviceExtension,
1934 unsigned short ModeNo,
1935 unsigned short ModeIdIndex,
1936 unsigned short RefreshRateTableIndex,
1937 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001938{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001939 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001940
1941 UCHAR data ;
1942
1943 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
1944
1945 if ( ModeNo <= 0x13 )
1946 {
1947 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
1948 tempax = pVBInfo->StResInfo[ resindex ].HTotal ;
1949 tempbx = pVBInfo->StResInfo[ resindex ].VTotal ;
1950 }
1951 else
1952 {
1953 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
1954 tempax = pVBInfo->ModeResInfo[ resindex ].HTotal ;
1955 tempbx = pVBInfo->ModeResInfo[ resindex ].VTotal ;
1956 }
1957
1958 if ( modeflag & HalfDCLK )
1959 tempax = tempax >> 1 ;
1960
1961 if ( ModeNo > 0x13 )
1962 {
1963 if ( modeflag & HalfDCLK )
1964 tempax = tempax << 1 ;
1965
1966 temp = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
1967
1968 if ( temp & InterlaceMode )
1969 tempbx = tempbx >> 1 ;
1970
1971 if ( modeflag & DoubleScanMode )
1972 tempbx = tempbx << 1 ;
1973 }
1974
1975 tempcx = 8 ;
1976
1977 /* if ( !( modeflag & Charx8Dot ) ) */
1978 /* tempcx = 9 ; */
1979
1980 tempax /= tempcx ;
1981 tempax -= 1 ;
1982 tempbx -= 1 ;
1983 tempcx = tempax ;
1984 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1985 data = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
1986 data &= 0x7F ;
1987 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , data ) ; /* Unlock CRTC */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001988 XGINew_SetReg1(pVBInfo->P3d4, 0x01, (unsigned short)(tempcx & 0xff));
1989 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0b, ~0x0c, (unsigned short)((tempcx & 0x0ff00) >> 10));
1990 XGINew_SetReg1(pVBInfo->P3d4, 0x12, (unsigned short)(tempbx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001991 tempax = 0 ;
1992 tempbx = tempbx >> 8 ;
1993
1994 if ( tempbx & 0x01 )
1995 tempax |= 0x02 ;
1996
1997 if ( tempbx & 0x02 )
1998 tempax |= 0x40 ;
1999
2000 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x42 , tempax ) ;
2001 data =( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x07 ) ;
2002 data &= 0xFF ;
2003 tempax = 0 ;
2004
2005 if ( tempbx & 0x04 )
2006 tempax |= 0x02 ;
2007
2008 XGINew_SetRegANDOR( pVBInfo->P3d4 ,0x0a , ~0x02 , tempax ) ;
2009 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp ) ;
2010}
2011
2012
2013/* --------------------------------------------------------------------- */
2014/* Function : XGI_GetResInfo */
2015/* Input : */
2016/* Output : */
2017/* Description : */
2018/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002019unsigned short XGI_GetResInfo(unsigned short ModeNo,
2020 unsigned short ModeIdIndex,
2021 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002022{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002023 unsigned short resindex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002024
2025 if ( ModeNo <= 0x13 )
2026 {
2027 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2028 }
2029 else
2030 {
2031 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2032 }
2033 return( resindex ) ;
2034}
2035
2036
2037/* --------------------------------------------------------------------- */
2038/* Function : XGI_SetCRT1Offset */
2039/* Input : */
2040/* Output : */
2041/* Description : */
2042/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002043void XGI_SetCRT1Offset(unsigned short ModeNo,
2044 unsigned short ModeIdIndex,
2045 unsigned short RefreshRateTableIndex,
2046 PXGI_HW_DEVICE_INFO HwDeviceExtension,
2047 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002048{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002049 unsigned short temp ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002050 ah ,
2051 al ,
2052 temp2 ,
2053 i ,
2054 DisplayUnit ;
2055
2056 /* GetOffset */
2057 temp = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
2058 temp = temp >> 8 ;
2059 temp = pVBInfo->ScreenOffset[ temp ] ;
2060
2061 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2062 temp2 &= InterlaceMode ;
2063
2064 if ( temp2 )
2065 temp = temp << 1;
2066
2067 temp2 = pVBInfo->ModeType - ModeEGA ;
2068
2069 switch( temp2 )
2070 {
2071 case 0:
2072 temp2 = 1 ;
2073 break ;
2074 case 1:
2075 temp2 = 2 ;
2076 break ;
2077 case 2:
2078 temp2 = 4 ;
2079 break ;
2080 case 3:
2081 temp2 = 4 ;
2082 break ;
2083 case 4:
2084 temp2 = 6 ;
2085 break;
2086 case 5:
2087 temp2 = 8 ;
2088 break ;
2089 default:
2090 break ;
2091 }
2092
2093 if ( ( ModeNo >= 0x26 ) && ( ModeNo <= 0x28 ) )
2094 temp = temp * temp2 + temp2 / 2 ;
2095 else
2096 temp *= temp2 ;
2097
2098 /* SetOffset */
2099 DisplayUnit = temp ;
2100 temp2 = temp ;
2101 temp = temp >> 8 ; /* ah */
2102 temp &= 0x0F ;
2103 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x0E ) ;
2104 i &= 0xF0 ;
2105 i |= temp ;
2106 XGINew_SetReg1( pVBInfo->P3c4 , 0x0E , i ) ;
2107
2108 temp =( UCHAR )temp2 ;
2109 temp &= 0xFF ; /* al */
2110 XGINew_SetReg1( pVBInfo->P3d4 , 0x13 , temp ) ;
2111
2112 /* SetDisplayUnit */
2113 temp2 = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2114 temp2 &= InterlaceMode ;
2115 if ( temp2 )
2116 DisplayUnit >>= 1 ;
2117
2118 DisplayUnit = DisplayUnit << 5 ;
2119 ah = ( DisplayUnit & 0xff00 ) >> 8 ;
2120 al = DisplayUnit & 0x00ff ;
2121 if ( al == 0 )
2122 ah += 1 ;
2123 else
2124 ah += 2 ;
2125
2126 if ( HwDeviceExtension->jChipType >= XG20 )
2127 if ( ( ModeNo == 0x4A ) | (ModeNo == 0x49 ) )
2128 ah -= 1 ;
2129
2130 XGINew_SetReg1( pVBInfo->P3c4 , 0x10 , ah ) ;
2131}
2132
2133
2134/* --------------------------------------------------------------------- */
2135/* Function : XGI_SetCRT1VCLK */
2136/* Input : */
2137/* Output : */
2138/* Description : */
2139/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002140void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2141 PXGI_HW_DEVICE_INFO HwDeviceExtension,
2142 unsigned short RefreshRateTableIndex,
2143 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002144{
2145 UCHAR index , data ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002146 unsigned short vclkindex ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002147
2148 if ( pVBInfo->IF_DEF_LVDS == 1 )
2149 {
2150 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2151 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2152 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2153 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2154 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2155 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2156 }
2157 else if ( ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) && ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
2158 {
2159 vclkindex = XGI_GetVCLK2Ptr( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2160 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2161 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2162 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_A ;
2163 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2164 data = pVBInfo->VBVCLKData[ vclkindex ].Part4_B ;
2165 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2166 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2167 }
2168 else
2169 {
2170 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2171 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) & 0xCF ;
2172 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , data ) ;
2173 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->VCLKData[ index ].SR2B ) ;
2174 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->VCLKData[ index ].SR2C ) ;
2175 XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ;
2176 }
2177
2178 if ( HwDeviceExtension->jChipType >= XG20 )
2179 {
2180 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag & HalfDCLK )
2181 {
2182 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2B ) ;
2183 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , data ) ;
2184 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x2C ) ;
2185 index = data ;
2186 index &= 0xE0 ;
2187 data &= 0x1F ;
2188 data = data << 1 ;
2189 data += 1 ;
2190 data |= index ;
2191 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , data ) ;
2192 }
2193 }
2194}
2195
2196
2197/* --------------------------------------------------------------------- */
2198/* Function : XGI_SetCRT1FIFO */
2199/* Input : */
2200/* Output : */
2201/* Description : */
2202/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002203void XGI_SetCRT1FIFO(unsigned short ModeNo,
2204 PXGI_HW_DEVICE_INFO HwDeviceExtension,
2205 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002206{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002207 unsigned short data ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002208
2209 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2210 data &= 0xfe ;
2211 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ; /* diable auto-threshold */
2212
2213 if ( ModeNo > 0x13 )
2214 {
2215 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x34 ) ;
2216 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2217 data &= 0xC0 ;
2218 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x30) ;
2219 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x3D ) ;
2220 data |= 0x01 ;
2221 XGINew_SetReg1( pVBInfo->P3c4 , 0x3D , data ) ;
2222 }
2223 else
2224 {
2225 if (HwDeviceExtension->jChipType == XG27)
2226 {
2227 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0x0E ) ;
2228 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2229 data &= 0xC0 ;
2230 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data | 0x20 ) ;
2231 }
2232 else
2233 {
2234 XGINew_SetReg1( pVBInfo->P3c4 , 0x08 , 0xAE ) ;
2235 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x09 ) ;
2236 data &= 0xF0 ;
2237 XGINew_SetReg1( pVBInfo->P3c4 , 0x09 , data ) ;
2238 }
2239 }
2240
2241 if (HwDeviceExtension->jChipType == XG21)
2242 {
2243 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
2244 }
2245}
2246
2247
2248/* --------------------------------------------------------------------- */
2249/* Function : XGI_SetCRT1ModeRegs */
2250/* Input : */
2251/* Output : */
2252/* Description : */
2253/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002254void XGI_SetCRT1ModeRegs(PXGI_HW_DEVICE_INFO HwDeviceExtension,
2255 unsigned short ModeNo, unsigned short ModeIdIndex,
2256 unsigned short RefreshRateTableIndex,
2257 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002258{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002259 unsigned short data ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002260 data2 ,
2261 data3 ,
2262 infoflag = 0 ,
2263 modeflag ,
2264 resindex ,
2265 xres ;
2266
2267 if ( ModeNo > 0x13 )
2268 {
2269 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2270 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
2271 }
2272 else
2273 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
2274
2275 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) & 0x01 )
2276 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , 0x3F , 0x00 ) ;
2277
2278 if ( ModeNo > 0x13 )
2279 data = infoflag ;
2280 else
2281 data = 0 ;
2282
2283 data2 = 0 ;
2284
2285 if ( ModeNo > 0x13 )
2286 {
2287 if ( pVBInfo->ModeType > 0x02 )
2288 {
2289 data2 |= 0x02 ;
2290 data3 = pVBInfo->ModeType - ModeVGA ;
2291 data3 = data3 << 2 ;
2292 data2 |= data3 ;
2293 }
2294 }
2295
2296 data &= InterlaceMode ;
2297
2298 if ( data )
2299 data2 |= 0x20 ;
2300
2301 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x3F , data2 ) ;
2302 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
2303 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2304 if ( ModeNo <= 0x13 )
2305 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2306 else
2307 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
2308
2309 data = 0x0000 ;
2310 if ( infoflag & InterlaceMode )
2311 {
2312 if ( xres == 1024 )
2313 data = 0x0035 ;
2314 else if ( xres == 1280 )
2315 data = 0x0048 ;
2316 }
2317
2318 data2 = data & 0x00FF ;
2319 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFF , data2 ) ;
2320 data2 = ( data & 0xFF00 ) >> 8 ;
2321 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x19 , 0xFC , data2 ) ;
2322
2323 if( modeflag & HalfDCLK )
2324 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xF7 , 0x08 ) ;
2325
2326 data2 = 0 ;
2327
2328 if ( modeflag & LineCompareOff )
2329 data2 |= 0x08 ;
2330
2331 if ( ModeNo > 0x13 )
2332 {
2333 if ( pVBInfo->ModeType == ModeEGA )
2334 data2 |= 0x40 ;
2335 }
2336
2337 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0F , ~0x48 , data2 ) ;
2338 data = 0x60 ;
2339 if ( pVBInfo->ModeType != ModeText )
2340 {
2341 data = data ^ 0x60 ;
2342 if ( pVBInfo->ModeType != ModeEGA )
2343 {
2344 data = data ^ 0xA0 ;
2345 }
2346 }
2347 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x21 , 0x1F , data ) ;
2348
2349 XGI_SetVCLKState( HwDeviceExtension , ModeNo , RefreshRateTableIndex, pVBInfo) ;
2350
2351 /* if(modeflag&HalfDCLK)//030305 fix lowresolution bug */
2352 /* if(XGINew_IF_DEF_NEW_LOWRES) */
2353 /* XGI_VesaLowResolution(ModeNo,ModeIdIndex);//030305 fix lowresolution bug */
2354
2355 data=XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
2356
2357 if (HwDeviceExtension->jChipType == XG27 )
2358 {
2359 if ( data & 0x40 )
2360 data = 0x2c ;
2361 else
2362 data = 0x6c ;
2363 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2364 XGINew_SetRegOR( pVBInfo->P3d4 , 0x51 , 0x10 ) ;
2365 }
2366 else
2367 if (HwDeviceExtension->jChipType >= XG20 )
2368 {
2369 if ( data & 0x40 )
2370 data = 0x33 ;
2371 else
2372 data = 0x73 ;
2373 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2374 XGINew_SetReg1( pVBInfo->P3d4 , 0x51 , 0x02 ) ;
2375 }
2376 else
2377 {
2378 if ( data & 0x40 )
2379 data = 0x2c ;
2380 else
2381 data = 0x6c ;
2382 XGINew_SetReg1( pVBInfo->P3d4 , 0x52 , data ) ;
2383 }
2384
2385}
2386
2387
2388/* --------------------------------------------------------------------- */
2389/* Function : XGI_SetVCLKState */
2390/* Input : */
2391/* Output : */
2392/* Description : */
2393/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002394void XGI_SetVCLKState(PXGI_HW_DEVICE_INFO HwDeviceExtension,
2395 unsigned short ModeNo,
2396 unsigned short RefreshRateTableIndex,
2397 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002398{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002399 unsigned short data ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002400 data2 = 0 ;
2401 SHORT VCLK ;
2402
2403 UCHAR index ;
2404
2405 if ( ModeNo <= 0x13 )
2406 VCLK = 0 ;
2407 else
2408 {
2409 index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
2410 index &= IndexMask ;
2411 VCLK = pVBInfo->VCLKData[ index ].CLOCK ;
2412 }
2413
2414 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
2415 data &= 0xf3 ;
2416 if ( VCLK >= 200 )
2417 data |= 0x0c ; /* VCLK > 200 */
2418
2419 if ( HwDeviceExtension->jChipType >= XG20 )
2420 data &= ~0x04 ; /* 2 pixel mode */
2421
2422 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , data ) ;
2423
2424 if ( HwDeviceExtension->jChipType < XG20 )
2425 {
2426 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
2427 data &= 0xE7 ;
2428 if ( VCLK < 200 )
2429 data |= 0x10 ;
2430 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , data ) ;
2431 }
2432
2433/* Jong for Adavantech LCD ripple issue
2434 if ( ( VCLK >= 0 ) && ( VCLK < 135 ) )
2435 data2 = 0x03 ;
2436 else if ( ( VCLK >= 135 ) && ( VCLK < 160 ) )
2437 data2 = 0x02 ;
2438 else if ( ( VCLK >= 160 ) && ( VCLK < 260 ) )
2439 data2 = 0x01 ;
2440 else if ( VCLK > 260 )
2441 data2 = 0x00 ;
2442*/
2443 data2 = 0x00 ;
2444
2445 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x07 , 0xFC , data2 ) ;
2446 if (HwDeviceExtension->jChipType >= XG27 )
2447 {
2448 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x40 , 0xFC , data2&0x03 ) ;
2449 }
2450
2451
2452}
2453
2454
2455/* --------------------------------------------------------------------- */
2456/* Function : XGI_VesaLowResolution */
2457/* Input : */
2458/* Output : */
2459/* Description : */
2460/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002461/*void XGI_VesaLowResolution(unsigned short ModeNo , unsigned short ModeIdIndex ,PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002462{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002463 unsigned short modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002464
2465 if ( ModeNo > 0x13 )
2466 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2467 else
2468 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2469
2470 if ( ModeNo > 0x13 )
2471 {
2472 if ( modeflag & DoubleScanMode )
2473 {
2474 if ( modeflag & HalfDCLK )
2475 {
2476 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
2477 {
2478 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
2479 {
2480 if ( pVBInfo->VBInfo & SetInSlaveMode )
2481 {
2482 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2483 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2484 return ;
2485 }
2486 }
2487 }
2488 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0xff , 0x80 ) ;
2489 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xf7 , 0x00 ) ;
2490 return ;
2491 }
2492 }
2493 }
2494 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0f , 0x7f , 0x00 ) ;
2495}
2496*/
2497
2498/* --------------------------------------------------------------------- */
2499/* Function : XGI_LoadDAC */
2500/* Input : */
2501/* Output : */
2502/* Description : */
2503/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002504void XGI_LoadDAC(unsigned short ModeNo,
2505 unsigned short ModeIdIndex,
2506 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002507{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002508 unsigned short data , data2 , time ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002509 i , j , k , m , n , o ,
2510 si , di , bx , dl , al , ah , dh ,
2511 *table = NULL ;
2512
2513 if ( ModeNo <= 0x13 )
2514 data = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2515 else
2516 data = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2517
2518 data &= DACInfoFlag ;
2519 time = 64 ;
2520
2521 if ( data == 0x00 )
2522 table = XGINew_MDA_DAC ;
2523 else if ( data == 0x08 )
2524 table = XGINew_CGA_DAC ;
2525 else if ( data == 0x10 )
2526 table = XGINew_EGA_DAC ;
2527 else if ( data == 0x18 )
2528 {
2529 time = 256 ;
2530 table = XGINew_VGA_DAC ;
2531 }
2532
2533 if ( time == 256 )
2534 j = 16 ;
2535 else
2536 j = time ;
2537
2538 XGINew_SetReg3( pVBInfo->P3c6 , 0xFF ) ;
2539 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
2540
2541 for( i = 0 ; i < j ; i++ )
2542 {
2543 data = table[ i ] ;
2544
2545 for( k = 0 ; k < 3 ; k++ )
2546 {
2547 data2 = 0 ;
2548
2549 if ( data & 0x01 )
2550 data2 = 0x2A ;
2551
2552 if ( data & 0x02 )
2553 data2 += 0x15 ;
2554
2555 XGINew_SetReg3( pVBInfo->P3c9 , data2 ) ;
2556 data = data >> 2 ;
2557 }
2558 }
2559
2560 if ( time == 256 )
2561 {
2562 for( i = 16 ; i < 32 ; i++ )
2563 {
2564 data = table[ i ] ;
2565
2566 for( k = 0 ; k < 3 ; k++ )
2567 XGINew_SetReg3( pVBInfo->P3c9 , data ) ;
2568 }
2569
2570 si = 32 ;
2571
2572 for( m = 0 ; m < 9 ; m++ )
2573 {
2574 di = si ;
2575 bx = si + 0x04 ;
2576 dl = 0 ;
2577
2578 for( n = 0 ; n < 3 ; n++ )
2579 {
2580 for( o = 0 ; o < 5 ; o++ )
2581 {
2582 dh = table[ si ] ;
2583 ah = table[ di ] ;
2584 al = table[ bx ] ;
2585 si++ ;
2586 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2587 }
2588
2589 si -= 2 ;
2590
2591 for( o = 0 ; o < 3 ; o++ )
2592 {
2593 dh = table[ bx ] ;
2594 ah = table[ di ] ;
2595 al = table[ si ] ;
2596 si-- ;
2597 XGI_WriteDAC( dl , ah , al , dh, pVBInfo ) ;
2598 }
2599
2600 dl++ ;
2601 }
2602
2603 si += 5 ;
2604 }
2605 }
2606}
2607
2608
2609/* --------------------------------------------------------------------- */
2610/* Function : XGI_WriteDAC */
2611/* Input : */
2612/* Output : */
2613/* Description : */
2614/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002615void XGI_WriteDAC(unsigned short dl, unsigned short ah,
2616 unsigned short al, unsigned short dh,
2617 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002618{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002619 unsigned short temp , bh , bl ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002620
2621 bh = ah ;
2622 bl = al ;
2623
2624 if ( dl != 0 )
2625 {
2626 temp = bh ;
2627 bh = dh ;
2628 dh = temp ;
2629 if ( dl == 1 )
2630 {
2631 temp = bl ;
2632 bl = dh ;
2633 dh = temp ;
2634 }
2635 else
2636 {
2637 temp = bl ;
2638 bl = bh ;
2639 bh = temp ;
2640 }
2641 }
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002642 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)dh);
2643 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)bh);
2644 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short)bl);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002645}
2646
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002647/* --------------------------------------------------------------------- */
2648/* Function : XGI_SetLCDAGroup */
2649/* Input : */
2650/* Output : */
2651/* Description : */
2652/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002653void XGI_SetLCDAGroup(unsigned short ModeNo,
2654 unsigned short ModeIdIndex,
2655 PXGI_HW_DEVICE_INFO HwDeviceExtension,
2656 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002657{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002658 unsigned short RefreshRateTableIndex ;
2659 /* unsigned short temp ; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002660
2661 /* pVBInfo->SelectCRT2Rate = 0 ; */
2662
2663 pVBInfo->SetFlag |= ProgrammingCRT2 ;
2664 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
2665 XGI_GetLVDSResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
2666 XGI_GetLVDSData( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo);
2667 XGI_ModCRT1Regs( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
2668 XGI_SetLVDSRegs( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2669 XGI_SetCRT2ECLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2670}
2671
2672
2673/* --------------------------------------------------------------------- */
2674/* Function : XGI_GetLVDSResInfo */
2675/* Input : */
2676/* Output : */
2677/* Description : */
2678/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002679void XGI_GetLVDSResInfo(unsigned short ModeNo,
2680 unsigned short ModeIdIndex,
2681 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002682{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002683 unsigned short resindex , xres , yres , modeflag ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002684
2685 if ( ModeNo <= 0x13 )
2686 {
2687 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2688 }
2689 else
2690 {
2691 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2692 }
2693
2694
2695 /* if ( ModeNo > 0x13 ) */
2696 /* modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; */
2697 /* else */
2698 /* modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; */
2699
2700 if ( ModeNo <= 0x13 )
2701 {
2702 resindex = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
2703 }
2704 else
2705 {
2706 resindex = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
2707 }
2708
2709 /* resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ; */
2710
2711 if ( ModeNo <= 0x13 )
2712 {
2713 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
2714 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
2715 }
2716 else
2717 {
2718 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ;
2719 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ;
2720 }
2721 if ( ModeNo > 0x13 )
2722 {
2723 if ( modeflag & HalfDCLK )
2724 xres = xres << 1 ;
2725
2726 if ( modeflag & DoubleScanMode )
2727 yres = yres << 1 ;
2728 }
2729 /* if ( modeflag & Charx8Dot ) */
2730 /* { */
2731
2732 if ( xres == 720 )
2733 xres = 640 ;
2734
2735 /* } */
2736 pVBInfo->VGAHDE = xres ;
2737 pVBInfo->HDE = xres ;
2738 pVBInfo->VGAVDE = yres ;
2739 pVBInfo->VDE = yres ;
2740}
2741
2742
2743/* --------------------------------------------------------------------- */
2744/* Function : XGI_GetLVDSData */
2745/* Input : */
2746/* Output : */
2747/* Description : */
2748/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002749void XGI_GetLVDSData(unsigned short ModeNo,
2750 unsigned short ModeIdIndex,
2751 unsigned short RefreshRateTableIndex,
2752 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002753{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002754 unsigned short tempbx ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002755 XGI330_LVDSDataStruct *LCDPtr = NULL ;
2756 XGI330_CHTVDataStruct *TVPtr = NULL ;
2757
2758 tempbx = 2 ;
2759
2760 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2761 {
2762 LCDPtr = ( XGI330_LVDSDataStruct * )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo) ;
2763 pVBInfo->VGAHT = LCDPtr->VGAHT ;
2764 pVBInfo->VGAVT = LCDPtr->VGAVT ;
2765 pVBInfo->HT = LCDPtr->LCDHT ;
2766 pVBInfo->VT = LCDPtr->LCDVT ;
2767 }
2768 if ( pVBInfo->IF_DEF_CH7017 == 1 )
2769 {
2770 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2771 {
2772 TVPtr = ( XGI330_CHTVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2773 pVBInfo->VGAHT = TVPtr->VGAHT ;
2774 pVBInfo->VGAVT = TVPtr->VGAVT ;
2775 pVBInfo->HT = TVPtr->LCDHT ;
2776 pVBInfo->VT = TVPtr->LCDVT ;
2777 }
2778 }
2779
2780 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2781 {
2782 if ( !( pVBInfo->LCDInfo & ( SetLCDtoNonExpanding | EnableScalingLCD ) ) )
2783 {
2784 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2785 {
2786 pVBInfo->HDE = 1024 ;
2787 pVBInfo->VDE = 768 ;
2788 }
2789 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2790 {
2791 pVBInfo->HDE = 1280 ;
2792 pVBInfo->VDE = 1024 ;
2793 }
2794 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2795 {
2796 pVBInfo->HDE = 1400 ;
2797 pVBInfo->VDE = 1050 ;
2798 }
2799 else
2800 {
2801 pVBInfo->HDE = 1600 ;
2802 pVBInfo->VDE = 1200 ;
2803 }
2804 }
2805 }
2806}
2807
2808
2809/* --------------------------------------------------------------------- */
2810/* Function : XGI_ModCRT1Regs */
2811/* Input : */
2812/* Output : */
2813/* Description : */
2814/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002815void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2816 unsigned short RefreshRateTableIndex,
2817 PXGI_HW_DEVICE_INFO HwDeviceExtension,
2818 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002819{
2820 UCHAR index ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002821 unsigned short tempbx , i ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002822 XGI_LVDSCRT1HDataStruct *LCDPtr = NULL ;
2823 XGI_LVDSCRT1VDataStruct *LCDPtr1 =NULL ;
2824 /* XGI330_CHTVDataStruct *TVPtr = NULL ; */
2825 XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2826 XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2827
2828 if( ModeNo <= 0x13 )
2829 index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
2830 else
2831 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2832
2833 index= index & IndexMask ;
2834
2835 if ( ( pVBInfo->IF_DEF_ScaleLCD == 0 ) || ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) ) )
2836 {
2837 tempbx = 0 ;
2838
2839 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2840 {
2841 LCDPtr = ( XGI_LVDSCRT1HDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2842
2843 for( i = 0 ; i < 8 ; i++ )
2844 pVBInfo->TimingH[ 0 ].data[ i ] = LCDPtr[ 0 ].Reg[ i ] ;
2845 }
2846
2847 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2848 {
2849 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2850 {
2851 CH7007TV_TimingHPtr = ( XGI_CH7007TV_TimingHStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2852
2853 for( i = 0 ; i < 8 ; i++ )
2854 pVBInfo->TimingH[ 0 ].data[ i ] = CH7007TV_TimingHPtr[ 0 ].data[ i ] ;
2855 }
2856 }
2857
2858 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2859 {
2860 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2861 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2862 } */
2863
2864 XGI_SetCRT1Timing_H(pVBInfo,HwDeviceExtension) ;
2865
2866 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2867 {
2868 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , CH7007TV_TimingHPtr[ 0 ].data[ 8 ] ) ;
2869 XGINew_SetReg1( pVBInfo->P3c4 , 0x2F , CH7007TV_TimingHPtr[ 0 ].data[ 9 ] ) ;
2870 }
2871
2872 tempbx = 1 ;
2873
2874 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
2875 {
2876 LCDPtr1 = ( XGI_LVDSCRT1VDataStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2877 for( i = 0 ; i < 7 ; i++ )
2878 pVBInfo->TimingV[ 0 ].data[ i ] = LCDPtr1[ 0 ].Reg[ i ] ;
2879 }
2880
2881 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2882 {
2883 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2884 {
2885 CH7007TV_TimingVPtr = ( XGI_CH7007TV_TimingVStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2886
2887 for( i = 0 ; i < 7 ; i++ )
2888 pVBInfo->TimingV[ 0 ].data[ i ] = CH7007TV_TimingVPtr[ 0 ].data[ i ] ;
2889 }
2890 }
2891 /* if ( pVBInfo->IF_DEF_CH7017 == 1 )
2892 {
2893 if ( pVBInfo->VBInfo & SetCRT2ToTV )
2894 TVPtr = ( XGI330_CHTVDataStruct *)XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2895 } */
2896
2897 XGI_SetCRT1Timing_V( ModeIdIndex , ModeNo , pVBInfo) ;
2898
2899 if ( pVBInfo->IF_DEF_CH7007 == 1 )
2900 {
2901 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x33 , ~0x01 , CH7007TV_TimingVPtr[ 0 ].data[ 7 ]&0x01 ) ;
2902 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , CH7007TV_TimingVPtr[ 0 ].data[8 ] ) ;
2903 XGINew_SetReg1( pVBInfo->P3c4 , 0x3F , CH7007TV_TimingVPtr[ 0 ].data[9 ] ) ;
2904
2905 }
2906 }
2907}
2908
2909
2910
2911/* --------------------------------------------------------------------- */
2912/* Function : XGI_SetLVDSRegs */
2913/* Input : */
2914/* Output : */
2915/* Description : */
2916/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002917void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2918 unsigned short RefreshRateTableIndex,
2919 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002920{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002921 unsigned short tempbx , tempax , tempcx , tempdx , push1 , push2 , modeflag ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002922 unsigned long temp , temp1 , temp2 , temp3 , push3 ;
2923 XGI330_LCDDataDesStruct *LCDPtr = NULL ;
2924 XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL ;
2925
2926 if ( ModeNo > 0x13 )
2927 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
2928 else
2929 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
2930
2931 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
2932 {
2933 if ( ( pVBInfo->IF_DEF_CH7017 == 0 ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
2934 {
2935 if ( pVBInfo->IF_DEF_OEMUtil == 1 )
2936 {
2937 tempbx = 8 ;
2938 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2939 }
2940
2941 if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
2942 {
2943 tempbx = 3 ;
2944 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2945 LCDPtr1 = ( XGI330_LCDDataDesStruct2 * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2946 else
2947 LCDPtr = ( XGI330_LCDDataDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
2948 }
2949
2950 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
2951 push1 = tempbx ;
2952 push2 = tempax ;
2953
2954 /* GetLCDResInfo */
2955 if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
2956 {
2957 tempax = 1024 ;
2958 tempbx = 768 ;
2959 }
2960 else if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
2961 {
2962 tempax = 1280 ;
2963 tempbx = 1024 ;
2964 }
2965 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
2966 {
2967 tempax = 1400 ;
2968 tempbx = 1050 ;
2969 }
2970 else
2971 {
2972 tempax = 1600 ;
2973 tempbx = 1200 ;
2974 }
2975
2976 if ( pVBInfo->LCDInfo & SetLCDtoNonExpanding )
2977 {
2978 pVBInfo->HDE=tempax;
2979 pVBInfo->VDE=tempbx;
2980 pVBInfo->VGAHDE=tempax;
2981 pVBInfo->VGAVDE=tempbx;
2982 }
2983
2984 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( pVBInfo->LCDInfo & EnableScalingLCD ) )
2985 {
2986 tempax=pVBInfo->HDE;
2987 tempbx=pVBInfo->VDE;
2988 }
2989
2990 tempax = pVBInfo->HT ;
2991
2992 if ( pVBInfo->LCDInfo & EnableScalingLCD )
2993 tempbx = LCDPtr1->LCDHDES ;
2994 else
2995 tempbx = LCDPtr->LCDHDES ;
2996
2997 tempcx = pVBInfo->HDE ;
2998 tempbx = tempbx & 0x0fff ;
2999 tempcx += tempbx ;
3000
3001 if ( tempcx >= tempax )
3002 tempcx -= tempax ;
3003
3004 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , tempbx & 0x07 ) ;
3005
3006 tempcx = tempcx >> 3 ;
3007 tempbx = tempbx >> 3 ;
3008
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003009 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, (unsigned short)(tempbx & 0xff));
3010 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, (unsigned short)(tempcx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003011
3012 tempax = pVBInfo->HT ;
3013
3014 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3015 tempbx = LCDPtr1->LCDHRS ;
3016 else
3017 tempbx = LCDPtr->LCDHRS ;
3018
3019 tempcx = push2 ;
3020
3021 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3022 tempcx = LCDPtr1->LCDHSync ;
3023
3024 tempcx += tempbx ;
3025
3026 if ( tempcx >= tempax )
3027 tempcx -= tempax ;
3028
3029 tempax = tempbx & 0x07 ;
3030 tempax = tempax >> 5 ;
3031 tempcx = tempcx >> 3 ;
3032 tempbx = tempbx >> 3 ;
3033
3034 tempcx &= 0x1f ;
3035 tempax |= tempcx ;
3036
3037 XGINew_SetReg1( pVBInfo->Part1Port , 0x15 , tempax ) ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003038 XGINew_SetReg1(pVBInfo->Part1Port, 0x14, (unsigned short)(tempbx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003039
3040 tempax = pVBInfo->VT ;
3041 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3042 tempbx = LCDPtr1->LCDVDES ;
3043 else
3044 tempbx = LCDPtr->LCDVDES ;
3045 tempcx = pVBInfo->VDE ;
3046
3047 tempbx = tempbx & 0x0fff ;
3048 tempcx += tempbx ;
3049 if ( tempcx >= tempax )
3050 tempcx -= tempax ;
3051
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003052 XGINew_SetReg1(pVBInfo->Part1Port, 0x1b, (unsigned short)(tempbx & 0xff));
3053 XGINew_SetReg1(pVBInfo->Part1Port, 0x1c, (unsigned short)(tempcx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003054
3055 tempbx = ( tempbx >> 8 ) & 0x07 ;
3056 tempcx = ( tempcx >> 8 ) & 0x07 ;
3057
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003058 XGINew_SetReg1(pVBInfo->Part1Port, 0x1d, (unsigned short)((tempcx << 3) | tempbx));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003059
3060 tempax = pVBInfo->VT ;
3061 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3062 tempbx = LCDPtr1->LCDVRS ;
3063 else
3064 tempbx = LCDPtr->LCDVRS ;
3065
3066 /* tempbx = tempbx >> 4 ; */
3067 tempcx = push1 ;
3068
3069 if ( pVBInfo->LCDInfo & EnableScalingLCD )
3070 tempcx = LCDPtr1->LCDVSync ;
3071
3072 tempcx += tempbx ;
3073 if ( tempcx >= tempax )
3074 tempcx -= tempax ;
3075
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003076 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, (unsigned short)(tempbx & 0xff));
3077 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f, (unsigned short)(tempcx & 0x0f));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003078
3079 tempax = ( ( tempbx >> 8 ) & 0x07 ) << 3 ;
3080
3081 tempbx = pVBInfo->VGAVDE ;
3082 if ( tempbx != pVBInfo->VDE )
3083 tempax |= 0x40 ;
3084
3085 if ( pVBInfo->LCDInfo & EnableLVDSDDA )
3086 tempax |= 0x40 ;
3087
3088 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1a , 0x07 , tempax ) ;
3089
3090 tempcx = pVBInfo->VGAVT ;
3091 tempbx = pVBInfo->VDE ;
3092 tempax = pVBInfo->VGAVDE ;
3093 tempcx -= tempax ;
3094
3095 temp = tempax ; /* 0430 ylshieh */
3096 temp1 = ( temp << 18 ) / tempbx ;
3097
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003098 tempdx = (unsigned short)((temp << 18) % tempbx);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003099
3100 if ( tempdx != 0 )
3101 temp1 += 1 ;
3102
3103 temp2 = temp1 ;
3104 push3 = temp2 ;
3105
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003106 XGINew_SetReg1(pVBInfo->Part1Port, 0x37, (unsigned short)(temp2 & 0xff));
3107 XGINew_SetReg1(pVBInfo->Part1Port, 0x36, (unsigned short)((temp2 >> 8) & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003108
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003109 tempbx = (unsigned short)(temp2 >> 16);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003110 tempax = tempbx & 0x03 ;
3111
3112 tempbx = pVBInfo->VGAVDE ;
3113 if ( tempbx == pVBInfo->VDE )
3114 tempax |= 0x04 ;
3115
3116 XGINew_SetReg1( pVBInfo->Part1Port , 0x35 , tempax ) ;
3117
3118 if ( pVBInfo->VBType & VB_XGI301C )
3119 {
3120 temp2 = push3 ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003121 XGINew_SetReg1(pVBInfo->Part4Port, 0x3c, (unsigned short)(temp2 & 0xff));
3122 XGINew_SetReg1(pVBInfo->Part4Port, 0x3b, (unsigned short)((temp2 >> 8) & 0xff));
3123 tempbx = (unsigned short)(temp2 >> 16);
3124 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x3a, ~0xc0, (unsigned short)((tempbx & 0xff) << 6));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003125
3126 tempcx = pVBInfo->VGAVDE ;
3127 if ( tempcx == pVBInfo->VDE )
3128 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x00 ) ;
3129 else
3130 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x30 , ~0x0c , 0x08 ) ;
3131 }
3132
3133 tempcx = pVBInfo->VGAHDE ;
3134 tempbx = pVBInfo->HDE ;
3135
3136 temp1 = tempcx << 16 ;
3137
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003138 tempax = (unsigned short)(temp1 / tempbx);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003139
3140 if ( ( tempbx & 0xffff ) == ( tempcx & 0xffff ) )
3141 tempax = 65535 ;
3142
3143 temp3 = tempax ;
3144 temp1 = pVBInfo->VGAHDE << 16 ;
3145
3146 temp1 /= temp3 ;
3147 temp3 = temp3 << 16 ;
3148 temp1 -= 1 ;
3149
3150 temp3 = ( temp3 & 0xffff0000 ) + ( temp1 & 0xffff ) ;
3151
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003152 tempax = (unsigned short)(temp3 & 0xff);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003153 XGINew_SetReg1( pVBInfo->Part1Port , 0x1f , tempax ) ;
3154
3155 temp1 = pVBInfo->VGAVDE << 18 ;
3156 temp1 = temp1 / push3 ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003157 tempbx = (unsigned short)(temp1 & 0xffff);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003158
3159 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3160 tempbx -= 1 ;
3161
3162 tempax = ( ( tempbx >> 8 ) & 0xff ) << 3 ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003163 tempax |= (unsigned short)((temp3 >> 8) & 0x07);
3164 XGINew_SetReg1(pVBInfo->Part1Port, 0x20, (unsigned short)(tempax & 0xff));
3165 XGINew_SetReg1(pVBInfo->Part1Port, 0x21, (unsigned short)(tempbx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003166
3167 temp3 = temp3 >> 16 ;
3168
3169 if ( modeflag & HalfDCLK )
3170 temp3 = temp3 >> 1 ;
3171
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003172 XGINew_SetReg1(pVBInfo->Part1Port , 0x22, (unsigned short)((temp3 >> 8) & 0xff));
3173 XGINew_SetReg1(pVBInfo->Part1Port , 0x23, (unsigned short)(temp3 & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003174 }
3175 }
3176}
3177
3178
3179/* --------------------------------------------------------------------- */
3180/* Function : XGI_SetCRT2ECLK */
3181/* Input : */
3182/* Output : */
3183/* Description : */
3184/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003185void XGI_SetCRT2ECLK(unsigned short ModeNo , unsigned short ModeIdIndex , unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003186{
3187 UCHAR di_0 , di_1 , tempal ;
3188 int i ;
3189
3190 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
3191 XGI_GetVCLKLen( tempal , &di_0 , &di_1, pVBInfo ) ;
3192 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
3193
3194 for( i = 0 ; i < 4 ; i++ )
3195 {
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003196 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, ~0x30, (unsigned short)(0x10 * i));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003197 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3198 {
3199 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3200 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3201 }
3202 else if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
3203 {
3204 XGINew_SetReg1( pVBInfo->P3c4 , 0x2e , di_0 ) ;
3205 XGINew_SetReg1( pVBInfo->P3c4 , 0x2f , di_1 ) ;
3206 }
3207 else
3208 {
3209 XGINew_SetReg1( pVBInfo->P3c4 , 0x2b , di_0 ) ;
3210 XGINew_SetReg1( pVBInfo->P3c4 , 0x2c , di_1 ) ;
3211 }
3212 }
3213}
3214
3215
3216/* --------------------------------------------------------------------- */
3217/* Function : XGI_UpdateModeInfo */
3218/* Input : */
3219/* Output : */
3220/* Description : */
3221/* --------------------------------------------------------------------- */
3222void XGI_UpdateModeInfo( PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo )
3223{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003224 unsigned short tempcl ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003225 tempch ,
3226 temp ,
3227 tempbl ,
3228 tempax ;
3229
3230 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3231 {
3232 tempcl = 0 ;
3233 tempch = 0 ;
3234 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
3235
3236 if ( !( temp & 0x20 ) )
3237 {
3238 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
3239 if ( temp & 0x80 )
3240 {
3241 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
3242 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) ;
3243 else
3244 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
3245
3246 if ( !( temp & 0x40 ) )
3247 tempcl |= ActiveCRT1 ;
3248 }
3249 }
3250
3251 temp = XGINew_GetReg1( pVBInfo->Part1Port , 0x2e ) ;
3252 temp &= 0x0f ;
3253
3254 if ( !( temp == 0x08 ) )
3255 {
3256 tempax = XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; /* Check ChannelA by Part1_13 [2003/10/03] */
3257 if ( tempax & 0x04 )
3258 tempcl = tempcl | ActiveLCD ;
3259
3260 temp &= 0x05 ;
3261
3262 if ( !( tempcl & ActiveLCD ) )
3263 if ( temp == 0x01 )
3264 tempcl |= ActiveCRT2 ;
3265
3266 if ( temp == 0x04 )
3267 tempcl |= ActiveLCD ;
3268
3269 if ( temp == 0x05 )
3270 {
3271 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
3272
3273 if( !( temp & 0x08 ) )
3274 tempch |= ActiveAVideo ;
3275
3276 if ( !( temp & 0x04 ) )
3277 tempch |= ActiveSVideo ;
3278
3279 if ( temp & 0x02 )
3280 tempch |= ActiveSCART ;
3281
3282 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3283 {
3284 if ( temp & 0x01 )
3285 tempch |= ActiveHiTV ;
3286 }
3287
3288 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3289 {
3290 temp = XGINew_GetReg1( pVBInfo->Part2Port , 0x4d ) ;
3291
3292 if ( temp & 0x10 )
3293 tempch |= ActiveYPbPr ;
3294 }
3295
3296 if ( tempch != 0 )
3297 tempcl |= ActiveTV ;
3298 }
3299 }
3300
3301 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x3d ) ;
3302 if ( tempcl & ActiveLCD )
3303 {
3304 if ( ( pVBInfo->SetFlag & ReserveTVOption ) )
3305 {
3306 if ( temp & ActiveTV )
3307 tempcl |= ActiveTV ;
3308 }
3309 }
3310 temp = tempcl ;
3311 tempbl = ~ModeSwitchStatus ;
3312 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x3d , tempbl , temp ) ;
3313
3314 if ( !( pVBInfo->SetFlag & ReserveTVOption ) )
3315 XGINew_SetReg1( pVBInfo->P3d4 , 0x3e , tempch ) ;
3316 }
3317 else
3318 {
3319 return ;
3320 }
3321}
3322
3323
3324/* --------------------------------------------------------------------- */
3325/* Function : XGI_GetVGAType */
3326/* Input : */
3327/* Output : */
3328/* Description : */
3329/* --------------------------------------------------------------------- */
3330void XGI_GetVGAType( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
3331{
3332 /*
3333 if ( HwDeviceExtension->jChipType >= XG20 )
3334 {
3335 pVBInfo->Set_VGAType = XG20;
3336 }
3337 else if ( HwDeviceExtension->jChipType >= XG40 )
3338 {
3339 pVBInfo->Set_VGAType = VGA_XGI340 ;
3340 }
3341 */
3342 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3343}
3344
3345
3346/* --------------------------------------------------------------------- */
3347/* Function : XGI_GetVBType */
3348/* Input : */
3349/* Output : */
3350/* Description : */
3351/* --------------------------------------------------------------------- */
3352void XGI_GetVBType(PVB_DEVICE_INFO pVBInfo)
3353{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003354 unsigned short flag , tempbx , tempah ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003355
3356 if ( pVBInfo->IF_DEF_CH7007 == 1 )
3357 {
3358 pVBInfo->VBType = VB_CH7007 ;
3359 return;
3360 }
3361 if ( pVBInfo->IF_DEF_LVDS == 0 )
3362 {
3363 tempbx = VB_XGI302B ;
3364 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
3365 if ( flag != 0x02 )
3366 {
3367 tempbx = VB_XGI301 ;
3368 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
3369 if ( flag >= 0xB0 )
3370 {
3371 tempbx = VB_XGI301B ;
3372 if ( flag >= 0xC0 )
3373 {
3374 tempbx = VB_XGI301C ;
3375 if ( flag >= 0xD0 )
3376 {
3377 tempbx = VB_XGI301LV ;
3378 if ( flag >= 0xE0 )
3379 {
3380 tempbx = VB_XGI302LV ;
3381 tempah = XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) ;
3382 if ( tempah != 0xFF )
3383 tempbx = VB_XGI301C ;
3384 }
3385 }
3386 }
3387
3388 if ( tempbx & ( VB_XGI301B | VB_XGI302B ) )
3389 {
3390 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x23 ) ;
3391
3392 if ( !( flag & 0x02 ) )
3393 tempbx = tempbx | VB_NoLCD ;
3394 }
3395 }
3396 }
3397 pVBInfo->VBType = tempbx ;
3398 }
3399/*
3400 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3401 pVBInfo->VBType = VB_CH7017 ;
3402 else //LVDS
3403 pVBInfo->VBType = VB_LVDS_NS ;
3404*/
3405
3406}
3407
3408
3409/* --------------------------------------------------------------------- */
3410/* Function : XGI_GetVBInfo */
3411/* Input : */
3412/* Output : */
3413/* Description : */
3414/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003415void XGI_GetVBInfo(unsigned short ModeNo , unsigned short ModeIdIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003416{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003417 unsigned short tempax ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003418 push ,
3419 tempbx ,
3420 temp ,
3421 modeflag ;
3422
3423 if ( ModeNo <= 0x13 )
3424 {
3425 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
3426 }
3427 else
3428 {
3429 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3430 }
3431
3432 pVBInfo->SetFlag = 0 ;
3433 pVBInfo->ModeType = modeflag & ModeInfoFlag ;
3434 tempbx = 0 ;
3435
3436 if ( pVBInfo->VBType & 0xFFFF )
3437 {
3438 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; /* Check Display Device */
3439 tempbx = tempbx | temp ;
3440 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ;
3441 push = temp ;
3442 push = push << 8 ;
3443 tempax = temp << 8 ;
3444 tempbx = tempbx | tempax ;
3445 temp = ( SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | SetInSlaveMode | DisableCRT2Display ) ;
3446 temp = 0xFFFF ^ temp ;
3447 tempbx &= temp ;
3448
3449 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
3450
3451 if ( pVBInfo->IF_DEF_LCDA == 1 )
3452 {
3453
3454 if ( ( pVBInfo->Set_VGAType >= XG20 ) || ( pVBInfo->Set_VGAType >= XG40 ))
3455 {
3456 if ( pVBInfo->IF_DEF_LVDS == 0 )
3457 {
3458 /* if ( ( pVBInfo->VBType & VB_XGI302B ) || ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) */
3459 if ( pVBInfo->VBType & ( VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
3460 {
3461 if ( temp & EnableDualEdge )
3462 {
3463 tempbx |= SetCRT2ToDualEdge ;
3464
3465 if ( temp & SetToLCDA )
3466 tempbx |= SetCRT2ToLCDA ;
3467 }
3468 }
3469 }
3470 else if ( pVBInfo->IF_DEF_CH7017 == 1 )
3471 {
3472 if ( pVBInfo->VBType & VB_CH7017 )
3473 {
3474 if ( temp & EnableDualEdge )
3475 {
3476 tempbx |= SetCRT2ToDualEdge ;
3477
3478 if ( temp & SetToLCDA )
3479 tempbx |= SetCRT2ToLCDA ;
3480 }
3481 }
3482 }
3483 }
3484 }
3485
3486 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3487 {
3488 if ( ( ( pVBInfo->IF_DEF_LVDS == 0 ) && ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) )
3489 || ( ( pVBInfo->IF_DEF_CH7017 == 1 ) && ( pVBInfo->VBType&VB_CH7017 ) ) || ( (pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType&VB_CH7007) ) ) /* [Billy] 07/05/04 */
3490 {
3491 if ( temp & SetYPbPr ) /* temp = CR38 */
3492 {
3493 if ( pVBInfo->IF_DEF_HiVision == 1 )
3494 {
3495 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ; /* shampoo add for new scratch */
3496 temp &= YPbPrMode ;
3497 tempbx |= SetCRT2ToHiVisionTV ;
3498
3499 if ( temp != YPbPrMode1080i ) {
3500 tempbx &= ( ~SetCRT2ToHiVisionTV ) ;
3501 tempbx |= SetCRT2ToYPbPr ; }
3502 }
3503
3504 /* tempbx |= SetCRT2ToYPbPr ; */
3505 }
3506 }
3507 }
3508
3509 tempax = push ; /* restore CR31 */
3510
3511 if ( pVBInfo->IF_DEF_LVDS == 0 )
3512 {
3513 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3514 {
3515 if ( pVBInfo->IF_DEF_HiVision == 1 )
3516 temp = 0x09FC ;
3517 else
3518 temp = 0x097C ;
3519 }
3520 else
3521 {
3522 if ( pVBInfo->IF_DEF_HiVision == 1 )
3523 temp = 0x01FC ;
3524 else
3525 temp = 0x017C ;
3526 }
3527 }
3528 else /* 3nd party chip */
3529 {
3530 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3531 temp = ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) ;
3532 else if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/03 */
3533 {
3534 temp = SetCRT2ToTV ;
3535 }
3536 else
3537 temp = SetCRT2ToLCD ;
3538 }
3539
3540 if ( !( tempbx & temp ) )
3541 {
3542 tempax |= DisableCRT2Display ;
3543 tempbx = 0 ;
3544 }
3545
3546 if ( pVBInfo->IF_DEF_LCDA == 1 ) /* Select Display Device */
3547 {
3548 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3549 {
3550 if ( tempbx & SetCRT2ToLCDA )
3551 {
3552 if ( tempbx & SetSimuScanMode )
3553 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SwitchToCRT2 ) ) ;
3554 else
3555 tempbx &= ( ~( SetCRT2ToLCD | SetCRT2ToRAMDAC | SetCRT2ToTV | SwitchToCRT2 ) ) ;
3556 }
3557 }
3558 }
3559
3560 /* shampoo add */
3561 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) ) /* for driver abnormal */
3562 {
3563 if ( pVBInfo->IF_DEF_CRT2Monitor == 1 )
3564 {
3565 if ( tempbx & SetCRT2ToRAMDAC )
3566 {
3567 tempbx &= ( 0xFF00 | SetCRT2ToRAMDAC | SwitchToCRT2 | SetSimuScanMode ) ;
3568 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3569 }
3570 }
3571 else
3572 tempbx &= ( ~( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ;
3573 }
3574
3575 if ( !( pVBInfo->VBType & VB_NoLCD ) )
3576 {
3577 if ( tempbx & SetCRT2ToLCD )
3578 {
3579 tempbx &= ( 0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | SetSimuScanMode ) ;
3580 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3581 }
3582 }
3583
3584 if ( tempbx & SetCRT2ToSCART )
3585 {
3586 tempbx &= ( 0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | SetSimuScanMode ) ;
3587 tempbx &= ( 0x00FF | ( ~SetCRT2ToYPbPr ) ) ;
3588 }
3589
3590 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3591 {
3592 if ( tempbx & SetCRT2ToYPbPr )
3593 tempbx &= ( 0xFF00 | SwitchToCRT2 | SetSimuScanMode ) ;
3594 }
3595
3596 if ( pVBInfo->IF_DEF_HiVision == 1 )
3597 {
3598 if ( tempbx & SetCRT2ToHiVisionTV )
3599 tempbx &= ( 0xFF00 | SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode ) ;
3600 }
3601
3602 if ( tempax & DisableCRT2Display ) /* Set Display Device Info */
3603 {
3604 if ( !( tempbx & ( SwitchToCRT2 | SetSimuScanMode ) ) )
3605 tempbx = DisableCRT2Display ;
3606 }
3607
3608 if ( !( tempbx & DisableCRT2Display ) )
3609 {
3610 if ( ( !( tempbx & DriverMode ) ) || ( !( modeflag & CRT2Mode ) ) )
3611 {
3612 if ( pVBInfo->IF_DEF_LCDA == 1 )
3613 {
3614 if ( !( tempbx & SetCRT2ToLCDA ) )
3615 tempbx |= ( SetInSlaveMode | SetSimuScanMode ) ;
3616 }
3617
3618 if ( pVBInfo->IF_DEF_VideoCapture == 1 )
3619 {
3620 if ( ( ( HwDeviceExtension->jChipType == XG40 ) && ( pVBInfo->Set_VGAType == XG40 ) )
3621 || ( ( HwDeviceExtension->jChipType == XG41 ) && ( pVBInfo->Set_VGAType == XG41 ) )
3622 || ( ( HwDeviceExtension->jChipType == XG42 ) && ( pVBInfo->Set_VGAType == XG42 ) )
3623 || ( ( HwDeviceExtension->jChipType == XG45 ) && ( pVBInfo->Set_VGAType == XG45 ) ) )
3624 {
3625 if ( ModeNo <= 13 )
3626 {
3627 if ( !( tempbx & SetCRT2ToRAMDAC ) ) /*CRT2 not need to support*/
3628 {
3629 tempbx &= ( 0x00FF | ( ~SetInSlaveMode ) ) ;
3630 pVBInfo->SetFlag |= EnableVCMode ;
3631 }
3632 }
3633 }
3634 }
3635 }
3636
3637 /*LCD+TV can't support in slave mode (Force LCDA+TV->LCDB)*/
3638 if ( ( tempbx & SetInSlaveMode ) && ( tempbx & SetCRT2ToLCDA ) )
3639 {
3640 tempbx ^= ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToDualEdge ) ;
3641 pVBInfo->SetFlag |= ReserveTVOption ;
3642 }
3643 }
3644 }
3645
3646 pVBInfo->VBInfo = tempbx ;
3647}
3648
3649
3650/* --------------------------------------------------------------------- */
3651/* Function : XGI_GetTVInfo */
3652/* Input : */
3653/* Output : */
3654/* Description : */
3655/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003656void XGI_GetTVInfo(unsigned short ModeNo , unsigned short ModeIdIndex ,PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003657{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003658 unsigned short temp ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003659 tempbx = 0 ,
3660 resinfo = 0 ,
3661 modeflag ,
3662 index1 ;
3663
3664 tempbx = 0 ;
3665 resinfo = 0 ;
3666
3667 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3668 {
3669 if ( ModeNo <= 0x13 )
3670 {
3671 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag */
3672 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ; /* si+St_ResInfo */
3673 }
3674 else
3675 {
3676 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3677 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo */
3678 }
3679
3680 if ( pVBInfo->VBInfo & SetCRT2ToTV )
3681 {
3682 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3683 tempbx = temp;
3684 if ( tempbx & SetPALTV )
3685 {
3686 tempbx &= ( SetCHTVOverScan | SetPALMTV | SetPALNTV | SetPALTV ) ;
3687 if ( tempbx & SetPALMTV )
3688 tempbx &= ~SetPALTV ; /* set to NTSC if PAL-M */
3689 }
3690 else
3691 tempbx &= ( SetCHTVOverScan | SetNTSCJ | SetPALTV ) ;
3692/*
3693 if ( pVBInfo->IF_DEF_LVDS == 0 )
3694 {
3695 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; //PAL-M/PAL-N Info
3696 temp2 = ( index1 & 0xC0 ) >> 5 ; //00:PAL, 01:PAL-M, 10:PAL-N
3697 tempbx |= temp2 ;
3698 if ( temp2 & 0x02 ) //PAL-M
3699 tempbx &= ( ~SetPALTV ) ;
3700 }
3701*/
3702 }
3703
3704 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3705 {
3706 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3707
3708 if ( tempbx & TVOverScan )
3709 tempbx |= SetCHTVOverScan ;
3710 }
3711
3712 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 07/05/04 */
3713 {
3714 tempbx = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3715
3716 if ( tempbx & TVOverScan )
3717 {
3718 tempbx |= SetCHTVOverScan ;
3719 }
3720 }
3721
3722
3723 if ( pVBInfo->IF_DEF_LVDS == 0 )
3724 {
3725 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
3726 tempbx |= SetPALTV ;
3727 }
3728
3729 if ( pVBInfo->IF_DEF_YPbPr == 1 )
3730 {
3731 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
3732 {
3733 index1 = XGINew_GetReg1( pVBInfo->P3d4 , 0x35 ) ;
3734 index1 &= YPbPrMode ;
3735
3736 if ( index1 == YPbPrMode525i )
3737 tempbx |= SetYPbPrMode525i ;
3738
3739 if ( index1 == YPbPrMode525p )
3740 tempbx = tempbx | SetYPbPrMode525p;
3741 if ( index1 == YPbPrMode750p)
3742 tempbx = tempbx | SetYPbPrMode750p;
3743 }
3744 }
3745
3746 if ( pVBInfo->IF_DEF_HiVision == 1 )
3747 {
3748 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3749 {
3750 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV ;
3751 }
3752 }
3753
3754 if ( pVBInfo->IF_DEF_LVDS == 0 )
3755 { /* shampoo */
3756 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->VBInfo & SetNotSimuMode ) ) )
3757 tempbx |= TVSimuMode ;
3758
3759 if ( !( tempbx & SetPALTV ) && ( modeflag > 13 ) && ( resinfo == 8 ) ) /* NTSC 1024x768, */
3760 tempbx |= NTSC1024x768 ;
3761
3762 tempbx |= RPLLDIV2XO ;
3763
3764 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
3765 {
3766 if ( pVBInfo->VBInfo & SetInSlaveMode )
3767 tempbx &=( ~RPLLDIV2XO ) ;
3768 }
3769 else
3770 {
3771 if ( tempbx & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
3772 tempbx &= ( ~RPLLDIV2XO ) ;
3773 else if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
3774 {
3775 if ( tempbx & TVSimuMode )
3776 tempbx &= ( ~RPLLDIV2XO ) ;
3777 }
3778 }
3779 }
3780 }
3781 pVBInfo->TVInfo = tempbx ;
3782}
3783
3784
3785/* --------------------------------------------------------------------- */
3786/* Function : XGI_GetLCDInfo */
3787/* Input : */
3788/* Output : */
3789/* Description : */
3790/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003791unsigned char XGI_GetLCDInfo(unsigned short ModeNo , unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003792{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04003793 unsigned short temp ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003794 tempax ,
3795 tempbx ,
3796 modeflag ,
3797 resinfo = 0 ,
3798 LCDIdIndex ;
3799
3800 pVBInfo->LCDResInfo = 0 ;
3801 pVBInfo->LCDTypeInfo = 0 ;
3802 pVBInfo->LCDInfo = 0 ;
3803
3804 if ( ModeNo <= 0x13 )
3805 {
3806 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ModeFlag // */
3807 }
3808 else
3809 {
3810 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
3811 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ; /* si+Ext_ResInfo// */
3812 }
3813
3814 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ; /* Get LCD Res.Info */
3815 tempbx = temp & 0x0F ;
3816
3817 if ( tempbx == 0 )
3818 tempbx = Panel1024x768 ; /* default */
3819
3820 /* LCD75 [2003/8/22] Vicent */
3821 if ( ( tempbx == Panel1024x768 ) || ( tempbx == Panel1280x1024 ) )
3822 {
3823 if ( pVBInfo->VBInfo & DriverMode )
3824 {
3825 tempax = XGINew_GetReg1( pVBInfo->P3d4 , 0x33 ) ;
3826 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
3827 tempax &= 0x0F ;
3828 else
3829 tempax = tempax >> 4 ;
3830
3831 if ( ( resinfo == 6 ) || ( resinfo == 9 ) )
3832 {
3833 if ( tempax >= 3 )
3834 tempbx |= PanelRef75Hz ;
3835 }
3836 else if ( ( resinfo == 7 ) || ( resinfo == 8 ) )
3837 {
3838 if ( tempax >= 4 )
3839 tempbx |= PanelRef75Hz ;
3840 }
3841 }
3842 }
3843
3844 pVBInfo->LCDResInfo = tempbx ;
3845
3846 /* End of LCD75 */
3847
3848 if( pVBInfo->IF_DEF_OEMUtil == 1 )
3849 {
3850 pVBInfo->LCDTypeInfo = ( temp & 0xf0 ) >> 4 ;
3851 }
3852
3853 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
3854 {
3855 return 0;
3856 }
3857
3858 tempbx = 0 ;
3859
3860 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
3861
3862 temp &= ( ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable ) ;
3863
3864 if ( ( pVBInfo->IF_DEF_ScaleLCD == 1 ) && ( temp & LCDNonExpanding ) )
3865 temp &= ~EnableScalingLCD ;
3866
3867 tempbx |= temp ;
3868
3869 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo) ;
3870
3871 tempax = pVBInfo->LCDCapList[ LCDIdIndex ].LCD_Capability ;
3872
3873 if ( pVBInfo->IF_DEF_LVDS == 0 ) /* shampoo */
3874 {
3875 if ( ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) ) && ( tempax & LCDDualLink ) )
3876 {
3877 tempbx |= SetLCDDualLink ;
3878 }
3879 }
3880
3881 if ( pVBInfo->IF_DEF_CH7017 == 1 )
3882 {
3883 if ( tempax & LCDDualLink )
3884 {
3885 tempbx |= SetLCDDualLink ;
3886 }
3887 }
3888
3889 if ( pVBInfo->IF_DEF_LVDS == 0 )
3890 {
3891 if ( ( pVBInfo->LCDResInfo == Panel1400x1050 ) && ( pVBInfo->VBInfo & SetCRT2ToLCD ) && ( ModeNo > 0x13 ) && ( resinfo == 9 ) && ( !( tempbx & EnableScalingLCD ) ) )
3892 tempbx |= SetLCDtoNonExpanding ; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3893 }
3894
3895/*
3896 if ( tempax & LCDBToA )
3897 {
3898 tempbx |= SetLCDBToA ;
3899 }
3900*/
3901
3902 if ( pVBInfo->IF_DEF_ExpLink == 1 )
3903 {
3904 if ( modeflag & HalfDCLK )
3905 {
3906 /* if ( !( pVBInfo->LCDInfo&LCDNonExpanding ) ) */
3907 if ( !( tempbx & SetLCDtoNonExpanding ) )
3908 {
3909 tempbx |= EnableLVDSDDA ;
3910 }
3911 else
3912 {
3913 if ( ModeNo > 0x13 )
3914 {
3915 if ( pVBInfo->LCDResInfo == Panel1024x768 )
3916 {
3917 if ( resinfo == 4 )
3918 { /* 512x384 */
3919 tempbx |= EnableLVDSDDA ;
3920 }
3921 }
3922 }
3923 }
3924 }
3925 }
3926
3927 if ( pVBInfo->VBInfo & SetInSlaveMode )
3928 {
3929 if ( pVBInfo->VBInfo & SetNotSimuMode )
3930 {
3931 tempbx |= LCDVESATiming ;
3932 }
3933 }
3934 else
3935 {
3936 tempbx |= LCDVESATiming ;
3937 }
3938
3939 pVBInfo->LCDInfo = tempbx ;
3940
3941 if ( pVBInfo->IF_DEF_PWD == 1 )
3942 {
3943 if ( pVBInfo->LCDInfo & SetPWDEnable )
3944 {
3945 if ( ( pVBInfo->VBType & VB_XGI302LV ) || ( pVBInfo->VBType & VB_XGI301C ) )
3946 {
3947 if ( !( tempax & PWDEnable ) )
3948 {
3949 pVBInfo->LCDInfo &= ~SetPWDEnable ;
3950 }
3951 }
3952 }
3953 }
3954
3955 if ( pVBInfo->IF_DEF_LVDS == 0 )
3956 {
3957 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3958 {
3959 if ( pVBInfo->VBInfo & SetInSlaveMode )
3960 {
3961 if ( !( tempax & LockLCDBToA ) )
3962 {
3963 if ( ModeNo <= 0x13 )
3964 {
3965 pVBInfo->VBInfo &= ~( SetSimuScanMode | SetInSlaveMode | SetCRT2ToLCD ) ;
3966 pVBInfo->VBInfo |= SetCRT2ToLCDA | SetCRT2ToDualEdge ;
3967 }
3968 }
3969 }
3970 }
3971 }
3972
3973/*
3974 if ( pVBInfo->IF_DEF_LVDS == 0 )
3975 {
3976 if ( tempax & ( LockLCDBToA | StLCDBToA ) )
3977 {
3978 if ( pVBInfo->VBInfo & SetInSlaveMode )
3979 {
3980 if ( !( ( !( tempax & LockLCDBToA ) ) && ( ModeNo > 0x13 ) ) )
3981 {
3982 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3983 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3984 }
3985 }
3986 }
3987 }
3988*/
3989
3990 return( 1 ) ;
3991}
3992
3993
3994/* --------------------------------------------------------------------- */
3995/* Function : XGI_SearchModeID */
3996/* Input : */
3997/* Output : */
3998/* Description : */
3999/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004000unsigned char XGI_SearchModeID(unsigned short ModeNo , unsigned short *ModeIdIndex, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004001{
4002
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004003
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004004
4005#ifdef LINUX /* chiawen for linux solution */
4006
4007 if ( ModeNo <= 5 )
4008 ModeNo |= 1 ;
4009 if ( ModeNo <= 0x13 )
4010 {
4011 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->SModeIDTable)/sizeof(XGI_StStruct);(*ModeIdIndex)++) */
4012 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4013 {
Bill Pembertondda08c52010-06-17 13:10:42 -04004014 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
4015 break;
4016 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
4017 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004018 }
4019
4020 if ( ModeNo == 0x07 )
4021 ( *ModeIdIndex )++ ; /* 400 lines */
4022
4023 if ( ModeNo <= 3 )
4024 ( *ModeIdIndex ) += 2 ; /* 400 lines */
4025 /* else 350 lines */
4026 }
4027 else
4028 {
4029 /* for (*ModeIdIndex=0;*ModeIdIndex<sizeof(pVBInfo->EModeIDTable)/sizeof(XGI_ExtStruct);(*ModeIdIndex)++) */
4030 for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ )
4031 {
Bill Pembertondda08c52010-06-17 13:10:42 -04004032 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
4033 break;
4034 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
4035 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004036 }
4037 }
4038
4039#endif
4040
Bill Pembertondda08c52010-06-17 13:10:42 -04004041 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004042}
4043
4044
4045
4046
4047/* win2000 MM adapter not support standard mode! */
4048
4049/* --------------------------------------------------------------------- */
4050/* Function : */
4051/* Input : */
4052/* Output : */
4053/* Description : */
4054/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004055unsigned char XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004056{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004057 unsigned short memorysize ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004058 modeflag ,
4059 temp ,
4060 temp1 ,
4061 tmp ;
4062
4063/* if ( ( HwDeviceExtension->jChipType == XGI_650 ) ||
4064 ( HwDeviceExtension->jChipType == XGI_650M ) )
4065 {
Bill Pembertondda08c52010-06-17 13:10:42 -04004066 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004067 } */
4068
4069 if ( ModeNo <= 0x13 )
4070 {
4071 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
4072 }
4073 else {
4074 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4075 }
4076
4077 /* ModeType = modeflag&ModeInfoFlag ; // Get mode type */
4078
4079 memorysize = modeflag & MemoryInfoFlag ;
4080 memorysize = memorysize > MemorySizeShift ;
4081 memorysize++ ; /* Get memory size */
4082
4083 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x14 ) ; /* Get DRAM Size */
4084 tmp = temp ;
4085
4086 if ( HwDeviceExtension->jChipType == XG40 )
4087 {
4088 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4089 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4090 {
4091 temp <<= 2 ;
4092 }
4093 else if ( ( tmp & 0x0c ) == 0x08 ) /* Dual channels */
4094 {
4095 temp <<= 1 ;
4096 }
4097 }
4098 else if ( HwDeviceExtension->jChipType == XG42 )
4099 {
4100 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4101 if ( ( tmp & 0x04 ) == 0x04 ) /* Dual channels */
4102 {
4103 temp <<= 1 ;
4104 }
4105 }
4106 else if ( HwDeviceExtension->jChipType == XG45 )
4107 {
4108 temp = 1 << ( ( temp & 0x0F0 ) >> 4 ) ; /* memory size per channel SR14[7:4] */
4109 if ( ( tmp & 0x0c ) == 0x0C ) /* Qual channels */
4110 {
4111 temp <<= 2 ;
4112 }
4113 else if ( ( tmp & 0x0c ) == 0x08 ) /* triple channels */
4114 {
4115 temp1 = temp ;
4116 temp <<= 1 ;
4117 temp += temp1 ;
4118 }
4119 else if ( ( tmp & 0x0c ) == 0x04 ) /* Dual channels */
4120 {
4121 temp <<= 1 ;
4122 }
4123 }
Bill Pembertondda08c52010-06-17 13:10:42 -04004124 if (temp < memorysize)
4125 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004126 else
Bill Pembertondda08c52010-06-17 13:10:42 -04004127 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004128}
4129
4130
4131/* --------------------------------------------------------------------- */
4132/* Function : XGINew_IsLowResolution */
4133/* Input : */
4134/* Output : */
4135/* Description : */
4136/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004137/*void XGINew_IsLowResolution(unsigned short ModeNo , unsigned short ModeIdIndex, unsigned char XGINew_CheckMemorySize(PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex,PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004138{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004139 unsigned short data ;
4140 unsigned short ModeFlag ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004141
4142 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4143 data &= 0x7F ;
4144 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4145
4146 if ( ModeNo > 0x13 )
4147 {
4148 ModeFlag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
4149 if ( ( ModeFlag & HalfDCLK ) && ( ModeFlag & DoubleScanMode ) )
4150 {
4151 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x0F ) ;
4152 data |= 0x80 ;
4153 XGINew_SetReg1( pVBInfo->P3c4 , 0x0F , data ) ;
4154 data = XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4155 data &= 0xF7 ;
4156 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , data ) ;
4157 }
4158 }
4159}
4160
4161*/
4162
4163/* --------------------------------------------------------------------- */
4164/* Function : XGI_DisplayOn */
4165/* Input : */
4166/* Output : */
4167/* Description : */
4168/* --------------------------------------------------------------------- */
4169void XGI_DisplayOn( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4170{
4171
4172 XGINew_SetRegANDOR(pVBInfo->P3c4,0x01,0xDF,0x00);
4173 if ( pXGIHWDE->jChipType == XG21 )
4174 {
4175 if ( pVBInfo->IF_DEF_LVDS == 1 )
4176 {
4177 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x1))
4178 {
4179 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4180 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4181 }
4182 if (!(XGI_XG21GetPSCValue( pVBInfo )&0x20))
4183 {
4184 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4185 }
4186 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4187 XGI_XG21BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4188 }
4189 else
4190 {
4191 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4192 }
4193
4194 }
4195
4196 if (pVBInfo->IF_DEF_CH7007 == 1) /* [Billy] 07/05/23 For CH7007 */
4197 {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004198
4199 }
4200
4201
4202 if ( pXGIHWDE->jChipType == XG27 )
4203 {
4204 if ( pVBInfo->IF_DEF_LVDS == 1 )
4205 {
4206 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x1))
4207 {
4208 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
4209 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
4210 }
4211 if (!(XGI_XG27GetPSCValue( pVBInfo )&0x20))
4212 {
4213 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
4214 }
4215 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4216 XGI_XG27BLSignalVDD( 0x02 , 0x02, pVBInfo ) ; /* LVDS backlight on */
4217 }
4218 else
4219 {
4220 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* DVO/DVI signal on */
4221 }
4222
4223 }
4224}
4225
4226
4227/* --------------------------------------------------------------------- */
4228/* Function : XGI_DisplayOff */
4229/* Input : */
4230/* Output : */
4231/* Description : */
4232/* --------------------------------------------------------------------- */
4233void XGI_DisplayOff( PXGI_HW_DEVICE_INFO pXGIHWDE , PVB_DEVICE_INFO pVBInfo )
4234{
4235
4236 if ( pXGIHWDE->jChipType == XG21 )
4237 {
4238 if ( pVBInfo->IF_DEF_LVDS == 1 )
4239 {
4240 XGI_XG21BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4241 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4242 }
4243 else
4244 {
4245 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4246 }
4247 }
4248
4249 if (pVBInfo->IF_DEF_CH7007 == 1) /*[Billy] 07/05/23 For CH7007 */
4250 {
4251 /* if( IsCH7007TVMode( pVBInfo ) == 0 ) */
4252 {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004253 }
4254 }
4255
4256
4257 if ( pXGIHWDE->jChipType == XG27 )
4258 {
4259 if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
4260 {
4261 XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
4262 XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
4263 }
4264
4265 if ( pVBInfo->IF_DEF_LVDS == 0 )
4266 {
4267 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
4268 }
4269 }
4270
4271 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ;
4272}
4273
4274
4275/* --------------------------------------------------------------------- */
4276/* Function : XGI_WaitDisply */
4277/* Input : */
4278/* Output : */
4279/* Description : chiawen for sensecrt1 */
4280/* --------------------------------------------------------------------- */
4281void XGI_WaitDisply( PVB_DEVICE_INFO pVBInfo )
4282{
4283 while( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4284 break ;
4285
4286 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) )
4287 break ;
4288}
4289
4290/* --------------------------------------------------------------------- */
4291/* Function : XGI_SenseCRT1 */
4292/* Input : */
4293/* Output : */
4294/* Description : */
4295/* --------------------------------------------------------------------- */
4296
4297void XGI_SenseCRT1( PVB_DEVICE_INFO pVBInfo )
4298{
4299 UCHAR CRTCData[ 17 ] = { 0x5F , 0x4F , 0x50 , 0x82 , 0x55 , 0x81 ,
4300 0x0B , 0x3E , 0xE9 , 0x0B , 0xDF , 0xE7 ,
4301 0x04 , 0x00 , 0x00 , 0x05 , 0x00 } ;
4302
4303 UCHAR SR01 = 0 , SR1F = 0 , SR07 = 0 , SR06 = 0 ;
4304
4305 UCHAR CR17 , CR63 , SR31 ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004306 unsigned short temp ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004307 UCHAR DAC_TEST_PARMS[ 3 ] = { 0x0F , 0x0F , 0x0F } ;
4308
4309 int i ;
4310 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ;
4311
4312 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
4313 XGINew_SetReg1( pVBInfo->P3d4 , 0x57 , 0x4A ) ;
4314 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) | 0x02 ) ) ;
4315
4316 SR31 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x31 ) ;
4317 CR63 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x63 ) ;
4318 SR01 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x01 ) ;
4319
4320 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , ( UCHAR )( SR01 & 0xDF ) ) ;
4321 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , ( UCHAR )( CR63 & 0xBF ) ) ;
4322
4323 CR17 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x17 ) ;
4324 XGINew_SetReg1( pVBInfo->P3d4 , 0x17 , ( UCHAR )( CR17 | 0x80 ) ) ;
4325
4326 SR1F = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
4327 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR )( SR1F | 0x04 ) ) ;
4328
4329 SR07 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x07 ) ;
4330 XGINew_SetReg1( pVBInfo->P3c4 , 0x07 , ( UCHAR )( SR07 & 0xFB ) ) ;
4331 SR06 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x06 ) ;
4332 XGINew_SetReg1( pVBInfo->P3c4 , 0x06 , ( UCHAR )( SR06 & 0xC3 ) ) ;
4333
4334 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , 0x00 ) ;
4335
4336 for( i = 0 ; i < 8 ; i++ )
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004337 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)i, CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004338
4339 for( i = 8 ; i < 11 ; i++ )
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004340 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 8), CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004341
4342 for( i = 11 ; i < 13 ; i++ )
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004343 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short)(i + 4), CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004344
4345 for( i = 13 ; i < 16 ; i++ )
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004346 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short)(i - 3), CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004347
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004348 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (UCHAR)(CRTCData[16] & 0xE0));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004349
4350 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , 0x00 ) ;
4351 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , 0x1B ) ;
4352 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , 0xE1 ) ;
4353
4354 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4355
4356 for( i = 0 ; i < 256 ; i++ )
4357 {
4358 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 0 ] ) ;
4359 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 1 ] ) ;
4360 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , ( UCHAR )DAC_TEST_PARMS[ 2 ] ) ;
4361 }
4362
4363 XGI_VBLongWait( pVBInfo ) ;
4364 XGI_VBLongWait( pVBInfo ) ;
4365 XGI_VBLongWait( pVBInfo ) ;
4366
4367 XGINew_LCD_Wait_Time( 0x01 , pVBInfo ) ;
4368
4369 XGI_WaitDisply( pVBInfo ) ;
4370 temp = XGINew_GetReg2( pVBInfo->P3c2 ) ;
4371
4372 if( temp & 0x10 )
4373 {
4374 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x20 ) ;
4375 }
4376 else
4377 {
4378 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xDF , 0x00 ) ;
4379 }
4380
4381 /* alan, avoid display something, set BLACK DAC if not restore DAC */
4382 XGINew_SetReg3( pVBInfo->P3c8 , 0x00 ) ;
4383
4384 for( i = 0 ; i < 256 ; i++ )
4385 {
4386 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4387 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4388 XGINew_SetReg3( ( pVBInfo->P3c8 + 1 ) , 0 ) ;
4389 }
4390
4391 XGINew_SetReg1( pVBInfo->P3c4 , 0x01 , SR01 ) ;
4392 XGINew_SetReg1( pVBInfo->P3d4 , 0x63 , CR63 ) ;
4393 XGINew_SetReg1( pVBInfo->P3c4 , 0x31 , SR31 ) ;
4394
4395 /* [2004/05/11] Vicent */
4396 XGINew_SetReg1( pVBInfo->P3d4 , 0x53 , ( UCHAR )( XGINew_GetReg1( pVBInfo->P3d4 , 0x53 ) & 0xFD ) ) ;
4397 XGINew_SetReg1( pVBInfo->P3c4 , 0x1F , ( UCHAR ) SR1F ) ;
4398}
4399
4400
4401
4402
4403
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004404
4405
4406
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004407
4408
4409/* --------------------------------------------------------------------- */
4410/* Function : XGI_WaitDisplay */
4411/* Input : */
4412/* Output : */
4413/* Description : */
4414/* --------------------------------------------------------------------- */
4415void XGI_WaitDisplay( PVB_DEVICE_INFO pVBInfo )
4416{
4417 while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
4418
4419 while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
4420}
4421
4422
4423
4424
4425/* --------------------------------------------------------------------- */
4426/* Function : XGI_SetCRT2Group301 */
4427/* Input : */
4428/* Output : */
4429/* Description : */
4430/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004431unsigned char XGI_SetCRT2Group301(unsigned short ModeNo , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004432{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004433 unsigned short tempbx ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004434 ModeIdIndex ,
4435 RefreshRateTableIndex ;
4436
4437 tempbx=pVBInfo->VBInfo ;
4438 pVBInfo->SetFlag |= ProgrammingCRT2 ;
4439 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
4440 pVBInfo->SelectCRT2Rate = 4 ;
4441 RefreshRateTableIndex = XGI_GetRatePtrCRT2( HwDeviceExtension, ModeNo , ModeIdIndex, pVBInfo ) ;
4442 XGI_SaveCRT2Info( ModeNo, pVBInfo ) ;
4443 XGI_GetCRT2ResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4444 XGI_GetCRT2Data( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4445 XGI_PreSetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4446 XGI_SetGroup1( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4447 XGI_SetLockRegs( ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4448 XGI_SetGroup2( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4449 XGI_SetLCDRegs(ModeNo , ModeIdIndex , HwDeviceExtension , RefreshRateTableIndex, pVBInfo ) ;
4450 XGI_SetTap4Regs(pVBInfo) ;
4451 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
4452 XGI_SetGroup4( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
4453 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4454 XGI_SetGroup5( ModeNo , ModeIdIndex, pVBInfo) ;
4455 XGI_AutoThreshold( pVBInfo) ;
4456 return 1 ;
4457}
4458
4459
4460/* --------------------------------------------------------------------- */
4461/* Function : XGI_AutoThreshold */
4462/* Input : */
4463/* Output : */
4464/* Description : */
4465/* --------------------------------------------------------------------- */
4466void XGI_AutoThreshold( PVB_DEVICE_INFO pVBInfo )
4467{
4468 if ( !( pVBInfo->SetFlag & Win9xDOSMode ) )
4469 XGINew_SetRegOR( pVBInfo->Part1Port , 0x01 , 0x40 ) ;
4470}
4471
4472
4473/* --------------------------------------------------------------------- */
4474/* Function : XGI_SaveCRT2Info */
4475/* Input : */
4476/* Output : */
4477/* Description : */
4478/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004479void XGI_SaveCRT2Info(unsigned short ModeNo , PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004480{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004481 unsigned short temp1 ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004482 temp2 ;
4483
4484 XGINew_SetReg1( pVBInfo->P3d4 , 0x34 , ModeNo ) ; /* reserve CR34 for CRT1 Mode No */
4485 temp1 = ( pVBInfo->VBInfo&SetInSlaveMode ) >> 8 ;
4486 temp2 = ~( SetInSlaveMode >> 8 ) ;
4487 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x31 , temp2 , temp1 ) ;
4488}
4489
4490
4491/* --------------------------------------------------------------------- */
4492/* Function : XGI_GetCRT2ResInfo */
4493/* Input : */
4494/* Output : */
4495/* Description : */
4496/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004497void XGI_GetCRT2ResInfo(unsigned short ModeNo,
4498 unsigned short ModeIdIndex,
4499 PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004500{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004501 unsigned short xres ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004502 yres ,
4503 modeflag ,
4504 resindex ;
4505
4506 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo) ;
4507 if ( ModeNo <= 0x13 )
4508 {
4509 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
4510 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
4511 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4512 }
4513 else
4514 {
4515 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
4516 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
4517 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
4518
4519/* if ( pVBInfo->IF_DEF_FSTN )
4520 {
4521 xres *= 2 ;
4522 yres *= 2 ;
4523 }
4524 else
4525 {
4526*/
4527 if ( modeflag & HalfDCLK )
4528 xres *= 2;
4529
4530 if ( modeflag & DoubleScanMode )
4531 yres *= 2 ;
4532/* } */
4533 }
4534
4535 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4536 {
4537 if ( pVBInfo->IF_DEF_LVDS == 0 )
4538 {
4539 if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4540 {
4541 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4542 {
4543 if ( yres == 1024 )
4544 yres = 1056 ;
4545 }
4546 }
4547
4548 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4549 {
4550 if ( yres == 400 )
4551 yres = 405 ;
4552 else if ( yres == 350 )
4553 yres = 360 ;
4554
4555 if ( pVBInfo->LCDInfo & LCDVESATiming )
4556 {
4557 if ( yres == 360 )
4558 yres = 375 ;
4559 }
4560 }
4561
4562 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4563 {
4564 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4565 {
4566 if ( !( pVBInfo->LCDInfo & LCDNonExpanding ) )
4567 {
4568 if ( yres == 350 )
4569 yres = 357 ;
4570 else if ( yres == 400 )
4571 yres = 420 ;
4572 else if ( yres == 480 )
4573 yres = 525 ;
4574 }
4575 }
4576 }
4577 }
4578
4579 if ( xres == 720 )
4580 xres = 640 ;
4581 }
4582
4583 pVBInfo->VGAHDE = xres ;
4584 pVBInfo->HDE = xres ;
4585 pVBInfo->VGAVDE = yres ;
4586 pVBInfo->VDE = yres ;
4587}
4588
4589
4590/* --------------------------------------------------------------------- */
4591/* Function : XGI_IsLCDDualLink */
4592/* Input : */
4593/* Output : */
4594/* Description : */
4595/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004596unsigned char XGI_IsLCDDualLink( PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004597{
4598
4599 if ( ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) && ( pVBInfo->LCDInfo & SetLCDDualLink ) ) /* shampoo0129 */
4600 return ( 1 ) ;
4601
4602 return( 0 ) ;
4603}
4604
4605
4606/* --------------------------------------------------------------------- */
4607/* Function : XGI_GetCRT2Data */
4608/* Input : */
4609/* Output : */
4610/* Description : */
4611/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004612void XGI_GetCRT2Data( unsigned short ModeNo , unsigned short ModeIdIndex , unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004613{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004614 unsigned short tempax = 0,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004615 tempbx ,
4616 modeflag ,
4617 resinfo ;
4618
4619 XGI_LCDDataStruct *LCDPtr = NULL ;
4620 XGI_TVDataStruct *TVPtr = NULL ;
4621
4622 if ( ModeNo <= 0x13 )
4623 {
4624 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4625 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
4626 }
4627 else
4628 {
4629 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
4630 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
4631 }
4632
4633 pVBInfo->NewFlickerMode = 0 ;
4634 pVBInfo->RVBHRS = 50 ;
4635
4636 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4637 {
4638 XGI_GetRAMDAC2DATA( ModeNo , ModeIdIndex , RefreshRateTableIndex,pVBInfo ) ;
4639 return ;
4640 }
4641
4642 tempbx = 4 ;
4643
4644 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4645 {
4646 LCDPtr = (XGI_LCDDataStruct* )XGI_GetLcdPtr( tempbx, ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4647
4648 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX ;
4649 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT ;
4650 pVBInfo->VGAHT = LCDPtr->VGAHT ;
4651 pVBInfo->VGAVT = LCDPtr->VGAVT ;
4652 pVBInfo->HT = LCDPtr->LCDHT ;
4653 pVBInfo->VT = LCDPtr->LCDVT ;
4654
4655 if ( pVBInfo->LCDResInfo == Panel1024x768 )
4656 {
4657 tempax = 1024 ;
4658 tempbx = 768 ;
4659
4660 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4661 {
4662 if ( pVBInfo->VGAVDE == 357 )
4663 tempbx = 527 ;
4664 else if ( pVBInfo->VGAVDE == 420 )
4665 tempbx = 620 ;
4666 else if ( pVBInfo->VGAVDE == 525 )
4667 tempbx = 775 ;
4668 else if ( pVBInfo->VGAVDE == 600 )
4669 tempbx = 775 ;
4670 /* else if(pVBInfo->VGAVDE==350) tempbx=560; */
4671 /* else if(pVBInfo->VGAVDE==400) tempbx=640; */
4672 else
4673 tempbx = 768 ;
4674 }
4675 else
4676 tempbx = 768 ;
4677 }
4678 else if ( pVBInfo->LCDResInfo == Panel1024x768x75 )
4679 {
4680 tempax = 1024 ;
4681 tempbx = 768 ;
4682 }
4683 else if ( pVBInfo->LCDResInfo == Panel1280x1024 )
4684 {
4685 tempax = 1280 ;
4686 if ( pVBInfo->VGAVDE == 360 )
4687 tempbx = 768 ;
4688 else if ( pVBInfo->VGAVDE == 375 )
4689 tempbx = 800 ;
4690 else if ( pVBInfo->VGAVDE == 405 )
4691 tempbx = 864 ;
4692 else
4693 tempbx = 1024 ;
4694 }
4695 else if ( pVBInfo->LCDResInfo == Panel1280x1024x75 )
4696 {
4697 tempax = 1280 ;
4698 tempbx = 1024 ;
4699 }
4700 else if ( pVBInfo->LCDResInfo == Panel1280x960 )
4701 {
4702 tempax = 1280 ;
4703 if ( pVBInfo->VGAVDE == 350 )
4704 tempbx = 700 ;
4705 else if ( pVBInfo->VGAVDE == 400 )
4706 tempbx = 800 ;
4707 else if ( pVBInfo->VGAVDE == 1024 )
4708 tempbx = 960 ;
4709 else
4710 tempbx = 960 ;
4711 }
4712 else if ( pVBInfo->LCDResInfo == Panel1400x1050 )
4713 {
4714 tempax = 1400 ;
4715 tempbx = 1050 ;
4716
4717 if ( pVBInfo->VGAVDE == 1024 )
4718 {
4719 tempax = 1280 ;
4720 tempbx = 1024 ;
4721 }
4722 }
4723 else if ( pVBInfo->LCDResInfo == Panel1600x1200 )
4724 {
4725 tempax = 1600 ;
4726 tempbx = 1200 ; /* alan 10/14/2003 */
4727 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
4728 {
4729 if ( pVBInfo->VGAVDE == 350 )
4730 tempbx = 875 ;
4731 else if ( pVBInfo->VGAVDE == 400 )
4732 tempbx = 1000 ;
4733 }
4734 }
4735
4736 if ( pVBInfo->LCDInfo & LCDNonExpanding )
4737 {
4738 tempax = pVBInfo->VGAHDE ;
4739 tempbx = pVBInfo->VGAVDE ;
4740 }
4741
4742 pVBInfo->HDE = tempax ;
4743 pVBInfo->VDE = tempbx ;
4744 return ;
4745 }
4746
4747 if ( pVBInfo->VBInfo & ( SetCRT2ToTV ) )
4748 {
4749 tempbx = 4 ;
4750 TVPtr = ( XGI_TVDataStruct * )XGI_GetTVPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
4751
4752 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX ;
4753 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT ;
4754 pVBInfo->VGAHT = TVPtr->VGAHT ;
4755 pVBInfo->VGAVT = TVPtr->VGAVT ;
4756 pVBInfo->HDE = TVPtr->TVHDE ;
4757 pVBInfo->VDE = TVPtr->TVVDE ;
4758 pVBInfo->RVBHRS = TVPtr->RVBHRS ;
4759 pVBInfo->NewFlickerMode = TVPtr->FlickerMode ;
4760
4761 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
4762 {
4763 if ( resinfo == 0x08 )
4764 pVBInfo->NewFlickerMode = 0x40 ;
4765 else if ( resinfo == 0x09 )
4766 pVBInfo->NewFlickerMode = 0x40 ;
4767 else if ( resinfo == 0x12 )
4768 pVBInfo->NewFlickerMode = 0x40 ;
4769
4770 if ( pVBInfo->VGAVDE == 350 )
4771 pVBInfo->TVInfo |= TVSimuMode ;
4772
4773 tempax = ExtHiTVHT ;
4774 tempbx = ExtHiTVVT ;
4775
4776 if ( pVBInfo->VBInfo & SetInSlaveMode )
4777 {
4778 if ( pVBInfo->TVInfo & TVSimuMode )
4779 {
4780 tempax = StHiTVHT ;
4781 tempbx = StHiTVVT ;
4782
4783 if ( !( modeflag & Charx8Dot ) )
4784 {
4785 tempax = StHiTextTVHT ;
4786 tempbx = StHiTextTVVT ;
4787 }
4788 }
4789 }
4790 }
4791 else if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
4792 {
4793 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4794 {
4795 tempax = YPbPrTV750pHT ; /* Ext750pTVHT */
4796 tempbx = YPbPrTV750pVT ; /* Ext750pTVVT */
4797 }
4798
4799 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4800 {
4801 tempax = YPbPrTV525pHT ; /* Ext525pTVHT */
4802 tempbx = YPbPrTV525pVT ; /* Ext525pTVVT */
4803 }
4804 else if ( pVBInfo->TVInfo & SetYPbPrMode525i )
4805 {
4806 tempax = YPbPrTV525iHT ; /* Ext525iTVHT */
4807 tempbx = YPbPrTV525iVT ; /* Ext525iTVVT */
4808 if ( pVBInfo->TVInfo & NTSC1024x768 )
4809 tempax = NTSC1024x768HT ;
4810 }
4811 }
4812 else
4813 {
4814 tempax = PALHT ;
4815 tempbx = PALVT ;
4816 if ( !( pVBInfo->TVInfo & SetPALTV ) )
4817 {
4818 tempax = NTSCHT ;
4819 tempbx = NTSCVT ;
4820 if ( pVBInfo->TVInfo & NTSC1024x768 )
4821 tempax = NTSC1024x768HT ;
4822 }
4823 }
4824
4825 pVBInfo->HT = tempax ;
4826 pVBInfo->VT = tempbx ;
4827 return ;
4828 }
4829}
4830
4831
4832/* --------------------------------------------------------------------- */
4833/* Function : XGI_SetCRT2VCLK */
4834/* Input : */
4835/* Output : */
4836/* Description : */
4837/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004838void XGI_SetCRT2VCLK(unsigned short ModeNo , unsigned short ModeIdIndex , unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004839{
4840 UCHAR di_0 ,
4841 di_1 ,
4842 tempal ;
4843
4844 tempal = XGI_GetVCLKPtr( RefreshRateTableIndex , ModeNo , ModeIdIndex, pVBInfo ) ;
4845 XGI_GetVCLKLen( tempal, &di_0 , &di_1, pVBInfo ) ;
4846 XGI_GetLCDVCLKPtr( &di_0 , &di_1, pVBInfo ) ;
4847
4848 if ( pVBInfo->VBType & VB_XGI301 ) /* shampoo 0129 */
4849 { /* 301 */
4850 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , 0x10 ) ;
4851 XGINew_SetReg1(pVBInfo->Part4Port , 0x0B , di_1 ) ;
4852 XGINew_SetReg1(pVBInfo->Part4Port , 0x0A , di_0 ) ;
4853 }
4854 else
4855 { /* 301b/302b/301lv/302lv */
4856 XGINew_SetReg1( pVBInfo->Part4Port , 0x0A , di_0 ) ;
4857 XGINew_SetReg1( pVBInfo->Part4Port , 0x0B , di_1 ) ;
4858 }
4859
4860 XGINew_SetReg1( pVBInfo->Part4Port , 0x00 , 0x12 ) ;
4861
4862 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
4863 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x28 ) ;
4864 else
4865 XGINew_SetRegOR( pVBInfo->Part4Port , 0x12 , 0x08 ) ;
4866}
4867
4868
4869/* --------------------------------------------------------------------- */
4870/* Function : XGI_GETLCDVCLKPtr */
4871/* Input : */
4872/* Output : al -> VCLK Index */
4873/* Description : */
4874/* --------------------------------------------------------------------- */
4875void XGI_GetLCDVCLKPtr( UCHAR* di_0 , UCHAR *di_1, PVB_DEVICE_INFO pVBInfo )
4876{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004877 unsigned short index ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004878
4879 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4880 {
4881 if ( pVBInfo->IF_DEF_ScaleLCD == 1 )
4882 {
4883 if ( pVBInfo->LCDInfo & EnableScalingLCD )
4884 return ;
4885 }
4886
4887 /* index = XGI_GetLCDCapPtr(pVBInfo) ; */
4888 index = XGI_GetLCDCapPtr1( pVBInfo) ;
4889
4890 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
4891 { /* LCDB */
4892 *di_0 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData1 ;
4893 *di_1 = pVBInfo->LCDCapList[ index ].LCUCHAR_VCLKData2 ;
4894 }
4895 else
4896 { /* LCDA */
4897 *di_0 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData1 ;
4898 *di_1 = pVBInfo->LCDCapList[ index ].LCDA_VCLKData2 ;
4899 }
4900 }
4901 return ;
4902}
4903
4904
4905/* --------------------------------------------------------------------- */
4906/* Function : XGI_GetVCLKPtr */
4907/* Input : */
4908/* Output : */
4909/* Description : */
4910/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004911UCHAR XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004912{
4913
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004914 unsigned short index ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004915 modeflag ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004916 unsigned short tempbx ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004917 UCHAR tempal ;
4918 UCHAR *CHTVVCLKPtr = NULL ;
4919
4920 if ( ModeNo <= 0x13 )
4921 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
4922 else
4923 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4924
4925
4926 if ( ( pVBInfo->SetFlag & ProgrammingCRT2 ) && ( !( pVBInfo->LCDInfo & EnableScalingLCD ) ) )
4927 { /* {LCDA/LCDB} */
4928 index = XGI_GetLCDCapPtr(pVBInfo) ;
4929 tempal = pVBInfo->LCDCapList[ index ].LCD_VCLK ;
4930
4931 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
4932 return tempal ;
4933
4934 /* {TV} */
4935 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV| VB_XGI302LV| VB_XGI301C ) )
4936 {
4937 if(pVBInfo->VBInfo&SetCRT2ToHiVisionTV)
4938 {
4939 tempal = HiTVVCLKDIV2;
4940 if(!(pVBInfo->TVInfo & RPLLDIV2XO))
4941 tempal = HiTVVCLK;
4942 if(pVBInfo->TVInfo & TVSimuMode)
4943 {
4944 tempal = HiTVSimuVCLK;
4945 if(!(modeflag & Charx8Dot))
4946 tempal = HiTVTextVCLK;
4947
4948 }
4949 return tempal;
4950 }
4951
4952 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
4953 {
4954 tempal = YPbPr750pVCLK ;
4955 return tempal ;
4956 }
4957
4958 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
4959 {
4960 tempal = YPbPr525pVCLK ;
4961 return tempal ;
4962 }
4963
4964 tempal = NTSC1024VCLK ;
4965
4966 if ( !( pVBInfo->TVInfo & NTSC1024x768 ) )
4967 {
4968 tempal = TVVCLKDIV2 ;
4969 if ( !( pVBInfo->TVInfo & RPLLDIV2XO ) )
4970 tempal = TVVCLK ;
4971 }
4972
4973 if ( pVBInfo->VBInfo & SetCRT2ToTV )
4974 return tempal ;
4975 }
4976 /*else
4977 if((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017))
4978 {
4979 if(ModeNo<=0x13)
4980 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4981 else
4982 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4983 *tempal = *tempal & 0x1F;
4984
4985 tempbx = 0;
4986 if(pVBInfo->TVInfo & SetPALTV)
4987 tempbx = tempbx + 2;
4988 if(pVBInfo->TVInfo & SetCHTVOverScan)
4989 tempbx++;
4990 tempbx = tempbx << 1;
4991 } */
4992 } /* {End of VB} */
4993
4994 if((pVBInfo->IF_DEF_CH7007==1)&&(pVBInfo->VBType&VB_CH7007)) /* [Billy] 07/05/08 CH7007 */
4995 {
4996 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4997 if ( (pVBInfo->VBInfo & SetCRT2ToTV) )
4998 {
4999 if( ModeNo <= 0x13 )
5000 {
5001 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5002 }
5003 else
5004 {
5005 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5006 }
5007
5008 tempal = tempal & 0x0F;
5009 tempbx = 0;
5010
5011 if(pVBInfo->TVInfo & SetPALTV)
5012 {
5013 tempbx = tempbx + 2;
5014 }
5015 if(pVBInfo->TVInfo & SetCHTVOverScan)
5016 {
5017 tempbx++;
5018 }
5019 /** tempbx = tempbx << 1; CH7007 ? **/
5020
5021/*[Billy]07/05/29 CH7007*/
5022 if ( pVBInfo->IF_DEF_CH7007 == 1 )
5023 {
5024 switch( tempbx )
5025 {
5026 case 0:
5027 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC ;
5028 break ;
5029 case 1:
5030 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC ;
5031 break ;
5032 case 2:
5033 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL ;
5034 break ;
5035 case 3:
5036 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL ;
5037 break ;
5038 default:
5039 break ;
5040
5041 }
5042 }
5043 /*else
5044 {
5045 switch( tempbx )
5046 {
5047 case 0:
5048 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
5049 break ;
5050 case 1:
5051 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
5052 break ;
5053 case 2:
5054 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
5055 break ;
5056 case 3:
5057 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
5058 break ;
5059 default:
5060 break ;
5061 }
5062 }*/
5063
5064 tempal = CHTVVCLKPtr[ tempal ] ;
5065 return tempal ;
5066 }
5067
5068 }
5069
5070 tempal = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ;
5071 tempal = tempal >> 2 ;
5072 tempal &= 0x03 ;
5073
5074 if ( ( pVBInfo->LCDInfo & EnableScalingLCD ) && ( modeflag & Charx8Dot ) ) /* for Dot8 Scaling LCD */
5075 tempal = tempal ^ tempal ; /* ; set to VCLK25MHz always */
5076
5077 if ( ModeNo <= 0x13 )
5078 return tempal ;
5079
5080 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ;
5081 return tempal ;
5082}
5083
5084
5085/* --------------------------------------------------------------------- */
5086/* Function : XGI_GetVCLKLen */
5087/* Input : */
5088/* Output : */
5089/* Description : */
5090/* --------------------------------------------------------------------- */
5091void XGI_GetVCLKLen(UCHAR tempal,UCHAR* di_0,UCHAR* di_1, PVB_DEVICE_INFO pVBInfo)
5092{
5093 if ( pVBInfo->IF_DEF_CH7007 == 1 ) /* [Billy] 2007/05/16 */
5094 {
5095 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
5096 *di_0 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2B ;
5097 *di_1 = ( UCHAR )XGI_CH7007VCLKData[ tempal ].SR2C ;
5098 }
5099 else if ( pVBInfo->VBType & ( VB_XGI301 | VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5100 {
5101 if ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->SetFlag & ProgrammingCRT2 ) )
5102 {
5103 *di_0 = ( UCHAR )XGI_VBVCLKData[ tempal ].SR2B ;
5104 *di_1 = XGI_VBVCLKData[ tempal ].SR2C ;
5105 }
5106 }
5107 else
5108 {
5109 *di_0 = XGI_VCLKData[ tempal ].SR2B ;
5110 *di_1 = XGI_VCLKData[ tempal ].SR2C ;
5111 }
5112}
5113
5114
5115/* --------------------------------------------------------------------- */
5116/* Function : XGI_SetCRT2Offset */
5117/* Input : */
5118/* Output : */
5119/* Description : */
5120/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005121void XGI_SetCRT2Offset(unsigned short ModeNo ,
5122 unsigned short ModeIdIndex , unsigned short RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005123{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005124 unsigned short offset ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005125 UCHAR temp ;
5126
5127 if ( pVBInfo->VBInfo & SetInSlaveMode )
5128 {
5129 return ;
5130 }
5131
5132 offset = XGI_GetOffset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5133 temp = ( UCHAR )( offset & 0xFF ) ;
5134 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ;
5135 temp =( UCHAR)( ( offset & 0xFF00 ) >> 8 ) ;
5136 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , temp ) ;
5137 temp =( UCHAR )( ( ( offset >> 3 ) & 0xFF ) + 1 ) ;
5138 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5139}
5140
5141
5142/* --------------------------------------------------------------------- */
5143/* Function : XGI_GetOffset */
5144/* Input : */
5145/* Output : */
5146/* Description : */
5147/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005148unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension,PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005149{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005150 unsigned short temp ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005151 colordepth ,
5152 modeinfo ,
5153 index ,
5154 infoflag ,
5155 ColorDepth[] = { 0x01 , 0x02 , 0x04 } ;
5156
5157 modeinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeInfo ;
5158 if ( ModeNo <= 0x14 )
5159 infoflag = 0 ;
5160 else
5161 infoflag = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
5162
5163
5164 index = ( modeinfo >> 8 ) & 0xFF ;
5165
5166 temp = pVBInfo->ScreenOffset[ index ] ;
5167
5168 if ( infoflag & InterlaceMode )
5169 {
5170 temp = temp << 1 ;
5171 }
5172
5173 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
5174
5175 if ( ( ModeNo >= 0x7C ) && ( ModeNo <= 0x7E ) )
5176 {
5177 temp = ModeNo - 0x7C ;
5178 colordepth = ColorDepth[ temp ] ;
5179 temp = 0x6B ;
5180 if ( infoflag & InterlaceMode )
5181 {
5182 temp = temp << 1 ;
5183 }
5184 return( temp * colordepth ) ;
5185 }
5186 else
5187 return( temp * colordepth ) ;
5188}
5189
5190
5191/* --------------------------------------------------------------------- */
5192/* Function : XGI_SetCRT2FIFO */
5193/* Input : */
5194/* Output : */
5195/* Description : */
5196/* --------------------------------------------------------------------- */
5197void XGI_SetCRT2FIFO( PVB_DEVICE_INFO pVBInfo)
5198{
5199 XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
5200 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
5201}
5202
5203
5204/* --------------------------------------------------------------------- */
5205/* Function : XGI_PreSetGroup1 */
5206/* Input : */
5207/* Output : */
5208/* Description : */
5209/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005210void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
5211 PXGI_HW_DEVICE_INFO HwDeviceExtension,
5212 unsigned short RefreshRateTableIndex,
5213 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005214{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005215 unsigned short tempcx = 0 ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005216 CRT1Index = 0 ,
5217 resinfo = 0 ;
5218
5219 if ( ModeNo > 0x13 )
5220 {
5221 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5222 CRT1Index &= IndexMask ;
5223 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5224 }
5225
5226 XGI_SetCRT2Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ;
5227 XGI_SetCRT2FIFO(pVBInfo) ;
5228 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
5229
5230 for( tempcx = 4 ; tempcx < 7 ; tempcx++ )
5231 {
5232 XGINew_SetReg1( pVBInfo->Part1Port , tempcx , 0x0 ) ;
5233 }
5234
5235 XGINew_SetReg1( pVBInfo->Part1Port , 0x50 , 0x00 ) ;
5236 XGINew_SetReg1( pVBInfo->Part1Port , 0x02 , 0x44 ) ; /* temp 0206 */
5237}
5238
5239
5240/* --------------------------------------------------------------------- */
5241/* Function : XGI_SetGroup1 */
5242/* Input : */
5243/* Output : */
5244/* Description : */
5245/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005246void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
5247 PXGI_HW_DEVICE_INFO HwDeviceExtension,
5248 unsigned short RefreshRateTableIndex,
5249 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005250{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005251 unsigned short temp = 0 ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005252 tempax = 0 ,
5253 tempbx = 0 ,
5254 tempcx = 0 ,
5255 pushbx = 0 ,
5256 CRT1Index = 0 ,
5257 modeflag ,
5258 resinfo = 0 ;
5259
5260 if ( ModeNo > 0x13 )
5261 {
5262 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5263 CRT1Index &= IndexMask ;
5264 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5265 }
5266
5267 if ( ModeNo <= 0x13 )
5268 {
5269 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
5270 }
5271 else
5272 {
5273 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
5274 }
5275
5276 /* bainy change table name */
5277 if ( modeflag & HalfDCLK )
5278 {
5279 temp = ( pVBInfo->VGAHT / 2 - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5280 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5281 temp = ( ( ( pVBInfo->VGAHT / 2 - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5282 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5283 temp = ( pVBInfo->VGAHDE / 2 + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5284 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5285 tempcx = ( ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) / 2 ) >> 2 ;
5286 pushbx = pVBInfo->VGAHDE / 2 + 16 ;
5287 tempcx = tempcx >> 1 ;
5288 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5289 tempcx += tempbx ;
5290
5291 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5292 {
5293 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5294 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] & 0xC0 ) << 2 ) ;
5295 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5296 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[ 5 ] ;
5297 tempcx &= 0x1F ;
5298 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 15 ] ;
5299 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5300 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5301 }
5302
5303 tempbx += 4 ;
5304 tempcx += 4 ;
5305
5306 if ( tempcx > ( pVBInfo->VGAHT / 2 ) )
5307 tempcx = pVBInfo->VGAHT / 2 ;
5308
5309 temp = tempbx & 0x00FF ;
5310
5311 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5312 }
5313 else
5314 {
5315 temp = ( pVBInfo->VGAHT - 1 ) & 0x0FF ; /* BTVGA2HT 0x08,0x09 */
5316 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , temp ) ;
5317 temp = ( ( ( pVBInfo->VGAHT - 1 ) & 0xFF00 ) >> 8 ) << 4 ;
5318 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x09 , ~0x0F0 , temp ) ;
5319 temp = ( pVBInfo->VGAHDE + 16 ) & 0x0FF ; /* BTVGA2HDEE 0x0A,0x0C */
5320 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ;
5321 tempcx = ( pVBInfo->VGAHT - pVBInfo->VGAHDE ) >> 2 ; /* cx */
5322 pushbx = pVBInfo->VGAHDE + 16 ;
5323 tempcx = tempcx >> 1 ;
5324 tempbx = pushbx + tempcx ; /* bx BTVGA@HRS 0x0B,0x0C */
5325 tempcx += tempbx ;
5326
5327 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5328 {
5329 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 3 ] ;
5330 tempbx |= ( ( pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 5 ] & 0xC0 ) << 2 ) ;
5331 tempbx = ( tempbx - 3 ) << 3 ; /* (VGAHRS-3)*8 */
5332 tempcx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 4 ] ;
5333 tempcx &= 0x1F ;
5334 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 6 ] ;
5335 temp = ( temp & 0x04 ) << ( 5 - 2 ) ; /* VGAHRE D[5] */
5336 tempcx = ( ( tempcx | temp ) - 3 ) << 3 ; /* (VGAHRE-3)*8 */
5337 tempbx += 16 ;
5338 tempcx += 16 ;
5339 }
5340
5341 if ( tempcx > pVBInfo->VGAHT )
5342 tempcx = pVBInfo->VGAHT ;
5343
5344 temp = tempbx & 0x00FF ;
5345 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5346 }
5347
5348 tempax = ( tempax & 0x00FF ) | ( tempbx & 0xFF00 ) ;
5349 tempbx = pushbx ;
5350 tempbx = ( tempbx & 0x00FF ) | ( ( tempbx & 0xFF00 ) << 4 ) ;
5351 tempax |= ( tempbx & 0xFF00 ) ;
5352 temp = ( tempax & 0xFF00 ) >> 8 ;
5353 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5354 temp = tempcx & 0x00FF ;
5355 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ;
5356 tempcx = ( pVBInfo->VGAVT - 1 ) ;
5357 temp = tempcx & 0x00FF ;
5358
5359 if ( pVBInfo->IF_DEF_CH7005 == 1 )
5360 {
5361 if ( pVBInfo->VBInfo & 0x0C )
5362 {
5363 temp-- ;
5364 }
5365 }
5366
5367 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5368 tempbx = pVBInfo->VGAVDE - 1 ;
5369 temp = tempbx & 0x00FF ;
5370 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , temp ) ;
5371 temp = ( ( tempbx & 0xFF00 ) << 3 ) >> 8 ;
5372 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
5373 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , temp ) ;
5374
5375 tempax = pVBInfo->VGAVDE ;
5376 tempbx = pVBInfo->VGAVDE ;
5377 tempcx = pVBInfo->VGAVT ;
5378 tempbx = ( pVBInfo->VGAVT + pVBInfo->VGAVDE ) >> 1 ; /* BTVGA2VRS 0x10,0x11 */
5379 tempcx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) >> 4 ) + tempbx + 1 ; /* BTVGA2VRE 0x11 */
5380
5381 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
5382 {
5383 tempbx = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 10 ] ;
5384 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 9 ] ;
5385
5386 if ( temp & 0x04 )
5387 tempbx |= 0x0100 ;
5388
5389 if ( temp & 0x080 )
5390 tempbx |= 0x0200 ;
5391
5392 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 14 ] ;
5393
5394 if ( temp & 0x08 )
5395 tempbx |= 0x0400 ;
5396
5397 temp = pVBInfo->XGINEWUB_CRT1Table[ CRT1Index ].CR[ 11 ] ;
5398 tempcx = ( tempcx & 0xFF00 ) | ( temp & 0x00FF ) ;
5399 }
5400
5401 temp = tempbx & 0x00FF ;
5402 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5403 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
5404 temp = ( ( tempcx & 0x000F ) | ( temp ) ) ;
5405 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , temp ) ;
5406 tempax = 0 ;
5407
5408 if ( modeflag & DoubleScanMode )
5409 tempax |= 0x80 ;
5410
5411 if ( modeflag & HalfDCLK )
5412 tempax |= 0x40 ;
5413
5414 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2C , ~0x0C0 , tempax ) ;
5415}
5416
5417
5418/* --------------------------------------------------------------------- */
5419/* Function : XGI_SetLockRegs */
5420/* Input : */
5421/* Output : */
5422/* Description : */
5423/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005424void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5425 PXGI_HW_DEVICE_INFO HwDeviceExtension,
5426 unsigned short RefreshRateTableIndex,
5427 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005428{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005429 unsigned short push1 ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005430 push2 ,
5431 tempax ,
5432 tempbx = 0 ,
5433 tempcx ,
5434 temp ,
5435 resinfo ,
5436 modeflag ,
5437 CRT1Index ;
5438
5439 if ( ModeNo <= 0x13 )
5440 {
5441 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5442 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5443 }
5444 else
5445 {
5446 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5447 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5448 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
5449 CRT1Index &= IndexMask;
5450 }
5451
5452 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
5453 {
5454 return ;
5455 }
5456
5457 temp = 0xFF ; /* set MAX HT */
5458 XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , temp ) ;
5459 /* if ( modeflag & Charx8Dot ) tempcx = 0x08 ; */
5460 /* else */
5461 tempcx=0x08;
5462
5463 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5464 modeflag |= Charx8Dot ;
5465
5466 tempax = pVBInfo->VGAHDE ; /* 0x04 Horizontal Display End */
5467
5468 if ( modeflag & HalfDCLK )
5469 tempax = tempax >> 1 ;
5470
5471 tempax = ( tempax / tempcx ) - 1 ;
5472 tempbx |= ( ( tempax & 0x00FF ) << 8 ) ;
5473 temp = tempax & 0x00FF ;
5474 XGINew_SetReg1( pVBInfo->Part1Port , 0x04 , temp ) ;
5475
5476 temp = ( tempbx & 0xFF00 ) >> 8 ;
5477
5478 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5479 {
5480 if ( !( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) )
5481 temp += 2 ;
5482
5483 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5484 {
5485 if ( pVBInfo->VBType & VB_XGI301LV )
5486 {
5487 if ( pVBInfo->VBExtInfo == VB_YPbPr1080i )
5488 {
5489 if ( resinfo == 7 )
5490 temp -= 2 ;
5491 }
5492 }
5493 else
5494 if ( resinfo == 7 )
5495 temp -= 2 ;
5496 }
5497 }
5498
5499 XGINew_SetReg1( pVBInfo->Part1Port , 0x05 , temp ) ; /* 0x05 Horizontal Display Start */
5500 XGINew_SetReg1( pVBInfo->Part1Port , 0x06 , 0x03 ) ; /* 0x06 Horizontal Blank end */
5501
5502 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
5503 { /* 030226 bainy */
5504 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5505 tempax = pVBInfo->VGAHT ;
5506 else
5507 tempax = XGI_GetVGAHT2( pVBInfo) ;
5508 }
5509
5510 if ( tempax >= pVBInfo->VGAHT )
5511 {
5512 tempax = pVBInfo->VGAHT ;
5513 }
5514
5515 if ( modeflag & HalfDCLK )
5516 {
5517 tempax = tempax >> 1 ;
5518 }
5519
5520 tempax = ( tempax / tempcx ) - 5 ;
5521 tempcx = tempax ; /* 20030401 0x07 horizontal Retrace Start */
5522 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5523 {
5524 temp = ( tempbx & 0x00FF ) - 1 ;
5525 if ( !( modeflag & HalfDCLK ) )
5526 {
5527 temp -= 6 ;
5528 if ( pVBInfo->TVInfo & TVSimuMode )
5529 {
5530 temp -= 4 ;
5531 if ( ModeNo > 0x13 )
5532 temp -= 10 ;
5533 }
5534 }
5535 }
5536 else
5537 {
5538 /* tempcx = tempbx & 0x00FF ; */
5539 tempbx = ( tempbx & 0xFF00 ) >> 8 ;
5540 tempcx = ( tempcx + tempbx ) >> 1 ;
5541 temp = ( tempcx & 0x00FF ) + 2 ;
5542
5543 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5544 {
5545 temp -= 1 ;
5546 if ( !( modeflag & HalfDCLK ) )
5547 {
5548 if ( ( modeflag & Charx8Dot ) )
5549 {
5550 temp += 4 ;
5551 if ( pVBInfo->VGAHDE >= 800 )
5552 {
5553 temp -= 6 ;
5554 }
5555 }
5556 }
5557 }
5558 else
5559 {
5560 if ( !( modeflag & HalfDCLK ) )
5561 {
5562 temp -= 4 ;
5563 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5564 {
5565 if( pVBInfo->VGAHDE >= 800 )
5566 {
5567 temp -= 7 ;
5568 if ( pVBInfo->ModeType == ModeEGA )
5569 {
5570 if ( pVBInfo->VGAVDE == 1024 )
5571 {
5572 temp += 15 ;
5573 if ( pVBInfo->LCDResInfo != Panel1280x1024 )
5574 {
5575 temp += 7 ;
5576 }
5577 }
5578 }
5579
5580 if ( pVBInfo->VGAHDE >= 1280 )
5581 {
5582 if ( pVBInfo->LCDResInfo != Panel1280x960 )
5583 {
5584 if ( pVBInfo->LCDInfo & LCDNonExpanding )
5585 {
5586 temp += 28 ;
5587 }
5588 }
5589 }
5590 }
5591 }
5592 }
5593 }
5594 }
5595
5596 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , temp ) ; /* 0x07 Horizontal Retrace Start */
5597 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0 ) ; /* 0x08 Horizontal Retrace End */
5598
5599 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5600 {
5601 if ( pVBInfo->TVInfo & TVSimuMode )
5602 {
5603 if ( ( ModeNo == 0x06 ) || ( ModeNo == 0x10 ) || ( ModeNo == 0x11 ) || ( ModeNo == 0x13 ) || ( ModeNo == 0x0F ) )
5604 {
5605 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x5b ) ;
5606 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5607 }
5608
5609 if ( ( ModeNo == 0x00 ) || ( ModeNo == 0x01 ) )
5610 {
5611 if ( pVBInfo->TVInfo & SetNTSCTV )
5612 {
5613 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5614 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x61 ) ;
5615 }
5616 else
5617 {
5618 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2A ) ;
5619 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x41 ) ;
5620 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5621 }
5622 }
5623
5624 if ( ( ModeNo == 0x02 ) || ( ModeNo == 0x03 ) || ( ModeNo == 0x07 ) )
5625 {
5626 if ( pVBInfo->TVInfo & SetNTSCTV )
5627 {
5628 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x54 ) ;
5629 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5630 }
5631 else
5632 {
5633 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x55 ) ;
5634 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x00 ) ;
5635 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , 0xF0 ) ;
5636 }
5637 }
5638
5639 if ( ( ModeNo == 0x04 ) || ( ModeNo == 0x05 ) || ( ModeNo == 0x0D ) || ( ModeNo == 0x50 ) )
5640 {
5641 if ( pVBInfo->TVInfo & SetNTSCTV )
5642 {
5643 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x30 ) ;
5644 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x03 ) ;
5645 }
5646 else
5647 {
5648 XGINew_SetReg1( pVBInfo->Part1Port , 0x07 , 0x2f ) ;
5649 XGINew_SetReg1( pVBInfo->Part1Port , 0x08 , 0x02 ) ;
5650 }
5651 }
5652 }
5653 }
5654
5655 XGINew_SetReg1( pVBInfo->Part1Port , 0x18 , 0x03 ) ; /* 0x18 SR0B */
5656 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x19 , 0xF0 , 0x00 ) ;
5657 XGINew_SetReg1( pVBInfo->Part1Port , 0x09 , 0xFF ) ; /* 0x09 Set Max VT */
5658
5659 tempbx = pVBInfo->VGAVT ;
5660 push1 = tempbx ;
5661 tempcx = 0x121 ;
5662 tempbx = pVBInfo->VGAVDE ; /* 0x0E Virtical Display End */
5663
5664 if ( tempbx == 357 )
5665 tempbx = 350 ;
5666 if ( tempbx == 360 )
5667 tempbx =350 ;
5668 if ( tempbx == 375 )
5669 tempbx = 350 ;
5670 if ( tempbx == 405 )
5671 tempbx = 400 ;
5672 if ( tempbx == 525 )
5673 tempbx = 480 ;
5674
5675 push2 = tempbx ;
5676
5677 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
5678 {
5679 if ( pVBInfo->LCDResInfo == Panel1024x768 )
5680 {
5681 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
5682 {
5683 if ( tempbx == 350 )
5684 tempbx += 5 ;
5685 if ( tempbx == 480 )
5686 tempbx += 5 ;
5687 }
5688 }
5689 }
5690 tempbx-- ;
5691 temp = tempbx & 0x00FF ;
5692 tempbx-- ;
5693 temp = tempbx & 0x00FF ;
5694 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 ,temp ) ; /* 0x10 vertical Blank Start */
5695 tempbx = push2 ;
5696 tempbx-- ;
5697 temp = tempbx & 0x00FF ;
5698 XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , temp ) ;
5699
5700 if ( tempbx & 0x0100 )
5701 {
5702 tempcx |= 0x0002 ;
5703 }
5704
5705 tempax = 0x000B ;
5706
5707 if ( modeflag & DoubleScanMode )
5708 {
5709 tempax |= 0x08000 ;
5710 }
5711
5712 if ( tempbx & 0x0200 )
5713 {
5714 tempcx |= 0x0040 ;
5715 }
5716
5717 temp = ( tempax & 0xFF00 ) >> 8 ;
5718 XGINew_SetReg1( pVBInfo->Part1Port , 0x0B , temp ) ;
5719
5720 if ( tempbx & 0x0400 )
5721 {
5722 tempcx |= 0x0600 ;
5723 }
5724
5725 XGINew_SetReg1( pVBInfo->Part1Port , 0x11 , 0x00 ) ; /* 0x11 Vertival Blank End */
5726
5727 tempax = push1 ;
5728 tempax -= tempbx ; /* 0x0C Vertical Retrace Start */
5729 tempax = tempax >> 2 ;
5730 push1 = tempax ; /* push ax */
5731
5732 if ( resinfo != 0x09 )
5733 {
5734 tempax = tempax << 1 ;
5735 tempbx += tempax ;
5736 }
5737
5738 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5739 {
5740 if ( pVBInfo->VBType & VB_XGI301LV )
5741 {
5742 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
5743 tempbx -= 10 ;
5744 else
5745 {
5746 if ( pVBInfo->TVInfo & TVSimuMode )
5747 {
5748 if ( pVBInfo->TVInfo & SetPALTV )
5749 {
5750 if ( pVBInfo->VBType & VB_XGI301LV )
5751 {
5752 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5753 tempbx += 40 ;
5754 }
5755 else
5756 tempbx += 40 ;
5757 }
5758 }
5759 }
5760 }
5761 else
5762 tempbx -= 10 ;
5763 }
5764 else
5765 {
5766 if ( pVBInfo->TVInfo & TVSimuMode )
5767 {
5768 if ( pVBInfo->TVInfo & SetPALTV )
5769 {
5770 if ( pVBInfo->VBType & VB_XGI301LV )
5771 {
5772 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
5773 tempbx += 40 ;
5774 }
5775 else
5776 tempbx += 40 ;
5777 }
5778 }
5779 }
5780 tempax = push1 ;
5781 tempax = tempax >> 2 ;
5782 tempax++ ;
5783 tempax += tempbx ;
5784 push1 = tempax ; /* push ax */
5785
5786 if ( ( pVBInfo->TVInfo & SetPALTV ) )
5787 {
5788 if ( tempbx <= 513 )
5789 {
5790 if ( tempax >= 513 )
5791 {
5792 tempbx = 513 ;
5793 }
5794 }
5795 }
5796
5797 temp = tempbx & 0x00FF ;
5798 XGINew_SetReg1( pVBInfo->Part1Port , 0x0C , temp ) ;
5799 tempbx-- ;
5800 temp = tempbx & 0x00FF ;
5801 XGINew_SetReg1( pVBInfo->Part1Port , 0x10 , temp ) ;
5802
5803 if ( tempbx & 0x0100 )
5804 {
5805 tempcx |= 0x0008 ;
5806 }
5807
5808 if ( tempbx & 0x0200 )
5809 {
5810 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x0B , 0x0FF , 0x20 ) ;
5811 }
5812
5813 tempbx++ ;
5814
5815 if ( tempbx & 0x0100 )
5816 {
5817 tempcx |= 0x0004 ;
5818 }
5819
5820 if ( tempbx & 0x0200 )
5821 {
5822 tempcx |= 0x0080 ;
5823 }
5824
5825 if ( tempbx & 0x0400 )
5826 {
5827 tempcx |= 0x0C00 ;
5828 }
5829
5830 tempbx = push1 ; /* pop ax */
5831 temp = tempbx & 0x00FF ;
5832 temp &= 0x0F ;
5833 XGINew_SetReg1( pVBInfo->Part1Port , 0x0D , temp ) ; /* 0x0D vertical Retrace End */
5834
5835 if ( tempbx & 0x0010 )
5836 {
5837 tempcx |= 0x2000 ;
5838 }
5839
5840 temp = tempcx & 0x00FF ;
5841 XGINew_SetReg1( pVBInfo->Part1Port , 0x0A , temp ) ; /* 0x0A CR07 */
5842 temp = ( tempcx & 0x0FF00 ) >> 8 ;
5843 XGINew_SetReg1( pVBInfo->Part1Port , 0x17 , temp ) ; /* 0x17 SR0A */
5844 tempax = modeflag ;
5845 temp = ( tempax & 0xFF00 ) >> 8 ;
5846
5847 temp = ( temp >> 1 ) & 0x09 ;
5848
5849 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
5850 temp |= 0x01 ;
5851
5852 XGINew_SetReg1( pVBInfo->Part1Port , 0x16 , temp ) ; /* 0x16 SR01 */
5853 XGINew_SetReg1( pVBInfo->Part1Port , 0x0F , 0 ) ; /* 0x0F CR14 */
5854 XGINew_SetReg1( pVBInfo->Part1Port , 0x12 , 0 ) ; /* 0x12 CR17 */
5855
5856 if ( pVBInfo->LCDInfo & LCDRGB18Bit )
5857 temp = 0x80 ;
5858 else
5859 temp = 0x00 ;
5860
5861 XGINew_SetReg1( pVBInfo->Part1Port , 0x1A , temp ) ; /* 0x1A SR0E */
5862
5863 return ;
5864}
5865
5866
5867/* --------------------------------------------------------------------- */
5868/* Function : XGI_SetGroup2 */
5869/* Input : */
5870/* Output : */
5871/* Description : */
5872/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005873void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005874 PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
5875{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005876 unsigned short i ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005877 j ,
5878 tempax ,
5879 tempbx ,
5880 tempcx ,
5881 temp ,
5882 push1 ,
5883 push2 ,
5884 modeflag ,
5885 resinfo ,
5886 crt2crtc ;
5887 UCHAR *TimingPoint ;
5888
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005889 unsigned long longtemp ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005890 tempeax ,
5891 tempebx ,
5892 temp2 ,
5893 tempecx ;
5894
5895 if ( ModeNo <= 0x13 )
5896 {
5897 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
5898 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
5899 crt2crtc = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
5900 }
5901 else
5902 {
5903 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
5904 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
5905 crt2crtc = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
5906 }
5907
5908 tempax = 0 ;
5909
5910 if ( !( pVBInfo->VBInfo & SetCRT2ToAVIDEO ) )
5911 tempax |= 0x0800 ;
5912
5913 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
5914 tempax |= 0x0400 ;
5915
5916 if ( pVBInfo->VBInfo & SetCRT2ToSCART )
5917 tempax |= 0x0200 ;
5918
5919 if ( !( pVBInfo->TVInfo & SetPALTV ) )
5920 tempax |= 0x1000 ;
5921
5922 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5923 tempax |= 0x0100 ;
5924
5925 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
5926 tempax &= 0xfe00 ;
5927
5928 tempax = ( tempax & 0xff00 ) >> 8 ;
5929
5930 XGINew_SetReg1( pVBInfo->Part2Port , 0x0 , tempax ) ;
5931 TimingPoint = pVBInfo->NTSCTiming ;
5932
5933 if ( pVBInfo->TVInfo & SetPALTV )
5934 {
5935 TimingPoint = pVBInfo->PALTiming ;
5936 }
5937
5938 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5939 {
5940 TimingPoint = pVBInfo->HiTVExtTiming ;
5941
5942 if ( pVBInfo->VBInfo & SetInSlaveMode )
5943 TimingPoint = pVBInfo->HiTVSt2Timing ;
5944
5945 if ( pVBInfo->SetFlag & TVSimuMode )
5946 TimingPoint = pVBInfo->HiTVSt1Timing ;
5947
5948 if ( !(modeflag & Charx8Dot) )
5949 TimingPoint = pVBInfo->HiTVTextTiming ;
5950 }
5951
5952 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
5953 {
5954 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
5955 TimingPoint = pVBInfo->YPbPr525iTiming ;
5956
5957 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
5958 TimingPoint = pVBInfo->YPbPr525pTiming ;
5959
5960 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
5961 TimingPoint = pVBInfo->YPbPr750pTiming ;
5962 }
5963
5964 for( i = 0x01 , j = 0 ; i <= 0x2D ; i++ , j++ )
5965 {
5966 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
5967 }
5968
5969 for( i = 0x39 ; i <= 0x45 ; i++ , j++ )
5970 {
5971 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ; /* di->temp2[j] */
5972 }
5973
5974 if ( pVBInfo->VBInfo & SetCRT2ToTV )
5975 {
5976 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , 0x00 ) ;
5977 }
5978
5979 temp = pVBInfo->NewFlickerMode ;
5980 temp &= 0x80 ;
5981 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xFF , temp ) ;
5982
5983 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
5984 tempax = 950 ;
5985
5986 if ( pVBInfo->TVInfo & SetPALTV )
5987 tempax = 520 ;
5988 else
5989 tempax = 440 ;
5990
5991 if ( pVBInfo->VDE <= tempax )
5992 {
5993 tempax -= pVBInfo->VDE ;
5994 tempax = tempax >> 2 ;
5995 tempax = ( tempax & 0x00FF ) | ( ( tempax & 0x00FF ) << 8 ) ;
5996 push1 = tempax ;
5997 temp = ( tempax & 0xFF00 ) >> 8 ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04005998 temp += (unsigned short)TimingPoint[0];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005999
6000 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6001 {
6002 if ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) )
6003 {
6004 tempcx=pVBInfo->VGAHDE;
6005 if ( tempcx >= 1024 )
6006 {
6007 temp = 0x17 ; /* NTSC */
6008 if ( pVBInfo->TVInfo & SetPALTV )
6009 temp = 0x19 ; /* PAL */
6010 }
6011 }
6012 }
6013
6014 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6015 tempax = push1 ;
6016 temp = ( tempax & 0xFF00 ) >> 8 ;
6017 temp += TimingPoint[ 1 ] ;
6018
6019 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6020 {
6021 if ( ( pVBInfo->VBInfo & ( SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToYPbPr ) ) )
6022 {
6023 tempcx = pVBInfo->VGAHDE ;
6024 if ( tempcx >= 1024 )
6025 {
6026 temp = 0x1D ; /* NTSC */
6027 if ( pVBInfo->TVInfo & SetPALTV )
6028 temp = 0x52 ; /* PAL */
6029 }
6030 }
6031 }
6032 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , temp ) ;
6033 }
6034
6035 /* 301b */
6036 tempcx = pVBInfo->HT ;
6037
6038 if ( XGI_IsLCDDualLink( pVBInfo ) )
6039 tempcx = tempcx >> 1 ;
6040
6041 tempcx -= 2 ;
6042 temp = tempcx & 0x00FF ;
6043 XGINew_SetReg1( pVBInfo->Part2Port , 0x1B , temp ) ;
6044
6045 temp = ( tempcx & 0xFF00 ) >> 8 ;
6046 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F , temp ) ;
6047
6048 tempcx = pVBInfo->HT >> 1 ;
6049 push1 = tempcx ; /* push cx */
6050 tempcx += 7 ;
6051
6052 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6053 {
6054 tempcx -= 4 ;
6055 }
6056
6057 temp = tempcx & 0x00FF ;
6058 temp = temp << 4 ;
6059 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x22 , 0x0F , temp ) ;
6060
6061 tempbx = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6062 tempbx += tempcx ;
6063 push2 = tempbx ;
6064 temp = tempbx & 0x00FF ;
6065 XGINew_SetReg1( pVBInfo->Part2Port , 0x24 , temp ) ;
6066 temp = ( tempbx & 0xFF00 ) >> 8 ;
6067 temp = temp << 4 ;
6068 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x25,0x0F,temp);
6069
6070 tempbx=push2;
6071 tempbx=tempbx+8;
6072 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6073 {
6074 tempbx=tempbx-4;
6075 tempcx=tempbx;
6076 }
6077
6078 temp = ( tempbx & 0x00FF ) << 4 ;
6079 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x29 , 0x0F , temp ) ;
6080
6081 j += 2 ;
6082 tempcx += ( TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ) ;
6083 temp = tempcx & 0x00FF ;
6084 XGINew_SetReg1( pVBInfo->Part2Port , 0x27 , temp ) ;
6085 temp = ( ( tempcx & 0xFF00 ) >> 8 ) << 4 ;
6086 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x28 , 0x0F , temp ) ;
6087
6088 tempcx += 8 ;
6089 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6090 {
6091 tempcx -= 4 ;
6092 }
6093
6094 temp = tempcx & 0xFF ;
6095 temp = temp << 4 ;
6096 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2A , 0x0F , temp ) ;
6097
6098 tempcx = push1 ; /* pop cx */
6099 j += 2 ;
6100 temp = TimingPoint[ j ] | ( ( TimingPoint[ j + 1 ] ) << 8 ) ;
6101 tempcx -= temp ;
6102 temp = tempcx & 0x00FF ;
6103 temp = temp << 4 ;
6104 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2D , 0x0F ,temp ) ;
6105
6106 tempcx -= 11 ;
6107
6108 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6109 {
6110 tempax = XGI_GetVGAHT2( pVBInfo) ;
6111 tempcx = tempax - 1 ;
6112 }
6113 temp = tempcx & 0x00FF ;
6114 XGINew_SetReg1( pVBInfo->Part2Port , 0x2E , temp ) ;
6115
6116 tempbx = pVBInfo->VDE ;
6117
6118 if ( pVBInfo->VGAVDE == 360 )
6119 tempbx = 746 ;
6120 if ( pVBInfo->VGAVDE == 375 )
6121 tempbx = 746 ;
6122 if ( pVBInfo->VGAVDE == 405 )
6123 tempbx = 853 ;
6124
6125 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6126 {
6127 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6128 {
6129 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6130 tempbx = tempbx >> 1 ;
6131 }
6132 else
6133 tempbx = tempbx >> 1 ;
6134 }
6135
6136 tempbx -= 2 ;
6137 temp = tempbx & 0x00FF ;
6138
6139 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6140 {
6141 if ( pVBInfo->VBType & VB_XGI301LV )
6142 {
6143 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6144 {
6145 if ( pVBInfo->VBInfo & SetInSlaveMode )
6146 {
6147 if ( ModeNo == 0x2f )
6148 temp += 1 ;
6149 }
6150 }
6151 }
6152 else
6153 {
6154 if ( pVBInfo->VBInfo & SetInSlaveMode )
6155 {
6156 if ( ModeNo == 0x2f )
6157 temp += 1 ;
6158 }
6159 }
6160 }
6161
6162 XGINew_SetReg1( pVBInfo->Part2Port , 0x2F , temp ) ;
6163
6164 temp = ( tempcx & 0xFF00 ) >> 8 ;
6165 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) << 6 ;
6166
6167 if ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) )
6168 {
6169 if ( pVBInfo->VBType & VB_XGI301LV )
6170 {
6171 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
6172 {
6173 temp |= 0x10 ;
6174
6175 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6176 temp |= 0x20 ;
6177 }
6178 }
6179 else
6180 {
6181 temp |= 0x10 ;
6182 if ( !( pVBInfo->VBInfo & SetCRT2ToSVIDEO ) )
6183 temp |= 0x20 ;
6184 }
6185 }
6186
6187 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , temp ) ;
6188
6189 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) ) /* TV gatingno */
6190 {
6191 tempbx = pVBInfo->VDE ;
6192 tempcx = tempbx - 2 ;
6193
6194 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6195 {
6196 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6197 tempbx = tempbx >> 1 ;
6198 }
6199
6200 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
6201 {
6202 temp=0;
6203 if( tempcx & 0x0400 )
6204 temp |= 0x20 ;
6205
6206 if ( tempbx & 0x0400 )
6207 temp |= 0x40 ;
6208
6209 XGINew_SetReg1( pVBInfo->Part4Port , 0x10 , temp ) ;
6210 }
6211
6212 temp = ( ( ( tempbx - 3 ) & 0x0300 ) >> 8 ) << 5 ;
6213 XGINew_SetReg1( pVBInfo->Part2Port , 0x46 , temp ) ;
6214 temp = ( tempbx - 3 ) & 0x00FF ;
6215 XGINew_SetReg1( pVBInfo->Part2Port , 0x47 , temp ) ;
6216 }
6217
6218 tempbx = tempbx & 0x00FF ;
6219
6220 if ( !( modeflag & HalfDCLK ) )
6221 {
6222 tempcx = pVBInfo->VGAHDE ;
6223 if ( tempcx >= pVBInfo->HDE )
6224 {
6225 tempbx |= 0x2000 ;
6226 tempax &= 0x00FF ;
6227 }
6228 }
6229
6230 tempcx = 0x0101 ;
6231
6232 if( pVBInfo->VBInfo & SetCRT2ToTV ) { /*301b*/
6233 if(pVBInfo->VGAHDE>=1024)
6234 {
6235 tempcx=0x1920;
6236 if(pVBInfo->VGAHDE>=1280)
6237 {
6238 tempcx=0x1420;
6239 tempbx=tempbx&0xDFFF;
6240 }
6241 }
6242 }
6243
6244 if ( !( tempbx & 0x2000 ) )
6245 {
6246 if ( modeflag & HalfDCLK )
6247 {
6248 tempcx = ( tempcx & 0xFF00 ) | ( ( tempcx & 0x00FF ) << 1 ) ;
6249 }
6250
6251 push1 = tempbx ;
6252 tempeax = pVBInfo->VGAHDE ;
6253 tempebx = ( tempcx & 0xFF00 ) >> 8 ;
6254 longtemp = tempeax * tempebx ;
6255 tempecx = tempcx & 0x00FF ;
6256 longtemp = longtemp / tempecx ;
6257
6258 /* 301b */
6259 tempecx = 8 * 1024 ;
6260
6261 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6262 {
6263 tempecx = tempecx * 8 ;
6264 }
6265
6266 longtemp = longtemp * tempecx ;
6267 tempecx = pVBInfo->HDE ;
6268 temp2 = longtemp % tempecx ;
6269 tempeax = longtemp / tempecx ;
6270 if ( temp2 != 0 )
6271 {
6272 tempeax += 1 ;
6273 }
6274
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006275 tempax = (unsigned short)tempeax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006276
6277 /* 301b */
6278 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6279 {
6280 tempcx = ( ( tempax & 0xFF00 ) >> 5 ) >> 8 ;
6281 }
6282 /* end 301b */
6283
6284 tempbx = push1 ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006285 tempbx = (unsigned short)(((tempeax & 0x0000FF00) & 0x1F00) | (tempbx & 0x00FF));
6286 tempax = (unsigned short)(((tempeax & 0x000000FF) << 8) | (tempax & 0x00FF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006287 temp = ( tempax & 0xFF00 ) >> 8 ;
6288 }
6289 else
6290 {
6291 temp = ( tempax & 0x00FF ) >> 8 ;
6292 }
6293
6294 XGINew_SetReg1( pVBInfo->Part2Port , 0x44 , temp ) ;
6295 temp = ( tempbx & 0xFF00 ) >> 8 ;
6296 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x45 , ~0x03F , temp ) ;
6297 temp = tempcx & 0x00FF ;
6298
6299 if ( tempbx & 0x2000 )
6300 temp = 0 ;
6301
6302 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6303 temp |= 0x18 ;
6304
6305 XGINew_SetRegANDOR(pVBInfo->Part2Port,0x46,~0x1F,temp);
6306 if ( pVBInfo->TVInfo & SetPALTV )
6307 {
6308 tempbx = 0x0382 ;
6309 tempcx = 0x007e ;
6310 }
6311 else
6312 {
6313 tempbx = 0x0369 ;
6314 tempcx = 0x0061 ;
6315 }
6316
6317 temp = tempbx & 0x00FF ;
6318 XGINew_SetReg1( pVBInfo->Part2Port , 0x4b , temp ) ;
6319 temp = tempcx & 0x00FF ;
6320 XGINew_SetReg1( pVBInfo->Part2Port , 0x4c , temp ) ;
6321
6322 temp = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x03 ;
6323 temp = temp << 2 ;
6324 temp |= ( ( tempbx & 0xFF00 ) >> 8 ) & 0x03 ;
6325
6326 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6327 {
6328 temp |= 0x10 ;
6329
6330 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6331 temp |= 0x20 ;
6332
6333 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6334 temp |= 0x60 ;
6335 }
6336
6337 XGINew_SetReg1( pVBInfo->Part2Port , 0x4d , temp ) ;
6338 temp=XGINew_GetReg1( pVBInfo->Part2Port , 0x43 ) ; /* 301b change */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006339 XGINew_SetReg1( pVBInfo->Part2Port , 0x43, (unsigned short)( temp - 3 ) ) ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006340
6341 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) )
6342 {
6343 if ( pVBInfo->TVInfo & NTSC1024x768 )
6344 {
6345 TimingPoint = XGI_NTSC1024AdjTime ;
6346 for( i = 0x1c , j = 0 ; i <= 0x30 ; i++ , j++ )
6347 {
6348 XGINew_SetReg1( pVBInfo->Part2Port , i , TimingPoint[ j ] ) ;
6349 }
6350 XGINew_SetReg1( pVBInfo->Part2Port , 0x43 , 0x72 ) ;
6351 }
6352 }
6353
6354 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
6355 if ( pVBInfo->VBType & VB_XGI301C )
6356 {
6357 if ( pVBInfo->TVInfo & SetPALMTV )
6358 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x08 , 0x08 ) ; /* PALM Mode */
6359 }
6360
6361 if ( pVBInfo->TVInfo & SetPALMTV )
6362 {
6363 tempax = ( UCHAR )XGINew_GetReg1( pVBInfo->Part2Port , 0x01 ) ;
6364 tempax-- ;
6365 XGINew_SetRegAND( pVBInfo->Part2Port , 0x01 , tempax ) ;
6366
6367 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
6368 XGINew_SetRegAND( pVBInfo->Part2Port , 0x00 , 0xEF ) ;
6369 }
6370
6371 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6372 {
6373 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
6374 {
6375 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , 0x00 ) ;
6376 }
6377 }
6378
6379 if ( pVBInfo->VBInfo & SetCRT2ToTV )
6380 {
6381 return ;
6382 }
6383}
6384
6385
6386/* --------------------------------------------------------------------- */
6387/* Function : XGI_SetLCDRegs */
6388/* Input : */
6389/* Output : */
6390/* Description : */
6391/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006392void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, PXGI_HW_DEVICE_INFO HwDeviceExtension, unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006393{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006394 unsigned short push1 ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006395 push2 ,
6396 pushbx ,
6397 tempax ,
6398 tempbx ,
6399 tempcx ,
6400 temp ,
6401 tempah ,
6402 tempbh ,
6403 tempch ,
6404 resinfo ,
6405 modeflag ,
6406 CRT1Index ;
6407
6408 XGI_LCDDesStruct *LCDBDesPtr = NULL ;
6409
6410
6411 if ( ModeNo <= 0x13 )
6412 {
6413 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6414 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
6415 }
6416 else
6417 {
6418 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6419 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
6420 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
6421 CRT1Index &= IndexMask ;
6422 }
6423
6424 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
6425 {
6426 return ;
6427 }
6428
6429 tempbx = pVBInfo->HDE ; /* RHACTE=HDE-1 */
6430
6431 if ( XGI_IsLCDDualLink( pVBInfo ) )
6432 tempbx = tempbx >> 1 ;
6433
6434 tempbx -= 1 ;
6435 temp = tempbx & 0x00FF ;
6436 XGINew_SetReg1( pVBInfo->Part2Port , 0x2C , temp ) ;
6437 temp = ( tempbx & 0xFF00 ) >> 8 ;
6438 temp = temp << 4 ;
6439 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x2B , 0x0F , temp ) ;
6440 temp = 0x01 ;
6441
6442 if ( pVBInfo->LCDResInfo == Panel1280x1024 )
6443 {
6444 if ( pVBInfo->ModeType == ModeEGA )
6445 {
6446 if ( pVBInfo->VGAHDE >= 1024 )
6447 {
6448 temp = 0x02 ;
6449 if ( pVBInfo->LCDInfo & LCDVESATiming )
6450 temp = 0x01 ;
6451 }
6452 }
6453 }
6454
6455 XGINew_SetReg1( pVBInfo->Part2Port , 0x0B , temp ) ;
6456 tempbx = pVBInfo->VDE ; /* RTVACTEO=(VDE-1)&0xFF */
6457 push1 = tempbx ;
6458 tempbx-- ;
6459 temp = tempbx & 0x00FF ;
6460 XGINew_SetReg1( pVBInfo->Part2Port , 0x03 , temp ) ;
6461 temp = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6462 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0C , ~0x07 , temp ) ;
6463
6464 tempcx = pVBInfo->VT - 1 ;
6465 push2 = tempcx + 1 ;
6466 temp = tempcx & 0x00FF ; /* RVTVT=VT-1 */
6467 XGINew_SetReg1( pVBInfo->Part2Port , 0x19 , temp ) ;
6468 temp = ( tempcx & 0xFF00 ) >> 8 ;
6469 temp = temp << 5 ;
6470 XGINew_SetReg1( pVBInfo->Part2Port , 0x1A , temp ) ;
6471 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x09 , 0xF0 , 0x00 ) ;
6472 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0xF0 , 0x00 ) ;
6473 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x17 , 0xFB , 0x00 ) ;
6474 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x18 , 0xDF , 0x00 ) ;
6475
6476 /* Customized LCDB Des no add */
6477 tempbx = 5 ;
6478 LCDBDesPtr = ( XGI_LCDDesStruct * )XGI_GetLcdPtr( tempbx , ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
6479 tempah = pVBInfo->LCDResInfo ;
6480 tempah &= PanelResInfo ;
6481
6482 if ( ( tempah == Panel1024x768 ) || ( tempah == Panel1024x768x75 ) )
6483 {
6484 tempbx = 1024 ;
6485 tempcx = 768 ;
6486 }
6487 else if ( ( tempah == Panel1280x1024 ) || ( tempah == Panel1280x1024x75 ) )
6488 {
6489 tempbx = 1280 ;
6490 tempcx = 1024 ;
6491 }
6492 else if ( tempah == Panel1400x1050 )
6493 {
6494 tempbx = 1400 ;
6495 tempcx = 1050 ;
6496 }
6497 else
6498 {
6499 tempbx = 1600 ;
6500 tempcx = 1200 ;
6501 }
6502
6503 if ( pVBInfo->LCDInfo & EnableScalingLCD )
6504 {
6505 tempbx = pVBInfo->HDE ;
6506 tempcx = pVBInfo->VDE ;
6507 }
6508
6509 pushbx = tempbx ;
6510 tempax = pVBInfo->VT ;
6511 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES ;
6512 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS ;
6513 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES ;
6514 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS ;
6515 tempbx = pVBInfo->LCDVDES ;
6516 tempcx += tempbx ;
6517
6518 if ( tempcx >= tempax )
6519 tempcx -= tempax ; /* lcdvdes */
6520
6521 temp = tempbx & 0x00FF ; /* RVEQ1EQ=lcdvdes */
6522 XGINew_SetReg1( pVBInfo->Part2Port , 0x05 , temp ) ;
6523 temp = tempcx & 0x00FF ;
6524 XGINew_SetReg1( pVBInfo->Part2Port , 0x06 , temp ) ;
6525 tempch = ( ( tempcx & 0xFF00 ) >> 8 ) & 0x07 ;
6526 tempbh = ( ( tempbx & 0xFF00 ) >> 8 ) & 0x07 ;
6527 tempah = tempch ;
6528 tempah = tempah << 3 ;
6529 tempah |= tempbh ;
6530 XGINew_SetReg1( pVBInfo->Part2Port , 0x02 , tempah ) ;
6531
6532 /* getlcdsync() */
6533 XGI_GetLCDSync( &tempax , &tempbx,pVBInfo ) ;
6534 tempcx = tempbx ;
6535 tempax = pVBInfo->VT ;
6536 tempbx = pVBInfo->LCDVRS ;
6537
6538 /* if ( SetLCD_Info & EnableScalingLCD ) */
6539 tempcx += tempbx ;
6540 if ( tempcx >= tempax )
6541 tempcx -= tempax ;
6542
6543 temp = tempbx & 0x00FF ; /* RTVACTEE=lcdvrs */
6544 XGINew_SetReg1( pVBInfo->Part2Port , 0x04 , temp ) ;
6545 temp = ( tempbx & 0xFF00 ) >> 8 ;
6546 temp = temp << 4 ;
6547 temp |= ( tempcx & 0x000F ) ;
6548 XGINew_SetReg1( pVBInfo->Part2Port , 0x01 , temp ) ;
6549 tempcx = pushbx ;
6550 tempax = pVBInfo->HT ;
6551 tempbx = pVBInfo->LCDHDES ;
6552 tempbx &= 0x0FFF ;
6553
6554 if ( XGI_IsLCDDualLink( pVBInfo ) )
6555 {
6556 tempax = tempax >> 1 ;
6557 tempbx = tempbx >> 1 ;
6558 tempcx = tempcx >> 1 ;
6559 }
6560
6561 if ( pVBInfo->VBType & VB_XGI302LV )
6562 tempbx += 1 ;
6563
6564 if ( pVBInfo->VBType & VB_XGI301C ) /* tap4 */
6565 tempbx += 1 ;
6566
6567 tempcx += tempbx ;
6568
6569 if ( tempcx >= tempax )
6570 tempcx -= tempax ;
6571
6572 temp = tempbx & 0x00FF ;
6573 XGINew_SetReg1( pVBInfo->Part2Port , 0x1F , temp ) ; /* RHBLKE=lcdhdes */
6574 temp = ( ( tempbx & 0xFF00 ) >> 8 ) << 4 ;
6575 XGINew_SetReg1( pVBInfo->Part2Port , 0x20 , temp ) ;
6576 temp = tempcx & 0x00FF ;
6577 XGINew_SetReg1( pVBInfo->Part2Port , 0x23 , temp ) ; /* RHEQPLE=lcdhdee */
6578 temp = ( tempcx & 0xFF00 ) >> 8 ;
6579 XGINew_SetReg1( pVBInfo->Part2Port , 0x25 , temp ) ;
6580
6581 /* getlcdsync() */
6582 XGI_GetLCDSync( &tempax , &tempbx ,pVBInfo) ;
6583 tempcx = tempax ;
6584 tempax = pVBInfo->HT ;
6585 tempbx = pVBInfo->LCDHRS ;
6586 /* if ( SetLCD_Info & EnableScalingLCD) */
6587 if ( XGI_IsLCDDualLink( pVBInfo) )
6588 {
6589 tempax = tempax >> 1 ;
6590 tempbx = tempbx >> 1 ;
6591 tempcx = tempcx >> 1 ;
6592 }
6593
6594 if ( pVBInfo->VBType & VB_XGI302LV )
6595 tempbx += 1 ;
6596
6597 tempcx += tempbx ;
6598
6599 if ( tempcx >= tempax )
6600 tempcx -= tempax ;
6601
6602 temp = tempbx & 0x00FF ; /* RHBURSTS=lcdhrs */
6603 XGINew_SetReg1( pVBInfo->Part2Port , 0x1C , temp ) ;
6604
6605 temp = ( tempbx & 0xFF00 ) >> 8 ;
6606 temp = temp << 4 ;
6607 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x1D , ~0x0F0 , temp ) ;
6608 temp = tempcx & 0x00FF ; /* RHSYEXP2S=lcdhre */
6609 XGINew_SetReg1( pVBInfo->Part2Port , 0x21 , temp ) ;
6610
6611 if ( !( pVBInfo->LCDInfo & LCDVESATiming ) )
6612 {
6613 if ( pVBInfo->VGAVDE == 525 )
6614 {
6615 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6616 {
6617 temp = 0xC6 ;
6618 }
6619 else
6620 temp = 0xC4 ;
6621
6622 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6623 XGINew_SetReg1( pVBInfo->Part2Port , 0x30 , 0xB3 ) ;
6624 }
6625
6626 if ( pVBInfo->VGAVDE == 420 )
6627 {
6628 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6629 {
6630 temp = 0x4F ;
6631 }
6632 else
6633 temp = 0x4E ;
6634 XGINew_SetReg1( pVBInfo->Part2Port , 0x2f , temp ) ;
6635 }
6636 }
6637}
6638
6639
6640/* --------------------------------------------------------------------- */
6641/* Function : XGI_GetTap4Ptr */
6642/* Input : */
6643/* Output : di -> Tap4 Reg. Setting Pointer */
6644/* Description : */
6645/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006646XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
6647 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006648{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006649 unsigned short tempax ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006650 tempbx ,
6651 i ;
6652
6653 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6654
6655 if ( tempcx == 0 )
6656 {
6657 tempax = pVBInfo->VGAHDE ;
6658 tempbx = pVBInfo->HDE ;
6659 }
6660 else
6661 {
6662 tempax = pVBInfo->VGAVDE ;
6663 tempbx = pVBInfo->VDE ;
6664 }
6665
6666 if ( tempax < tempbx )
6667 return &EnlargeTap4Timing[ 0 ] ;
6668 else if( tempax == tempbx )
6669 return &NoScaleTap4Timing[ 0 ] ; /* 1:1 */
6670 else
6671 Tap4TimingPtr = NTSCTap4Timing ; /* NTSC */
6672
6673 if ( pVBInfo->TVInfo & SetPALTV )
6674 Tap4TimingPtr = PALTap4Timing ;
6675
6676
6677 if ( pVBInfo->VBInfo & SetCRT2ToYPbPr )
6678 {
6679 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
6680 Tap4TimingPtr = YPbPr525iTap4Timing ;
6681 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
6682 Tap4TimingPtr = YPbPr525pTap4Timing ;
6683 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
6684 Tap4TimingPtr = YPbPr750pTap4Timing ;
6685 }
6686
6687 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
6688 Tap4TimingPtr = HiTVTap4Timing ;
6689
6690 i = 0 ;
6691 while( Tap4TimingPtr[ i ].DE != 0xFFFF )
6692 {
6693 if ( Tap4TimingPtr[ i ].DE == tempax )
6694 break ;
6695 i++ ;
6696 }
6697 return &Tap4TimingPtr[ i ] ;
6698}
6699
6700
6701/* --------------------------------------------------------------------- */
6702/* Function : XGI_SetTap4Regs */
6703/* Input : */
6704/* Output : */
6705/* Description : */
6706/* --------------------------------------------------------------------- */
6707void XGI_SetTap4Regs( PVB_DEVICE_INFO pVBInfo)
6708{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006709 unsigned short i ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006710 j ;
6711
6712 XGI301C_Tap4TimingStruct *Tap4TimingPtr ;
6713
6714 if ( !( pVBInfo->VBType & VB_XGI301C ) )
6715 return ;
6716
6717#ifndef Tap4
6718 XGINew_SetRegAND( pVBInfo->Part2Port , 0x4E , 0xEB ) ; /* Disable Tap4 */
6719#else /* Tap4 Setting */
6720
6721 Tap4TimingPtr = XGI_GetTap4Ptr( 0 , pVBInfo) ; /* Set Horizontal Scaling */
6722 for( i = 0x80 , j = 0 ; i <= 0xBF ; i++ , j++ )
6723 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6724
6725 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6726 {
6727 Tap4TimingPtr = XGI_GetTap4Ptr( 1 , pVBInfo); /* Set Vertical Scaling */
6728 for( i = 0xC0 , j = 0 ; i < 0xFF ; i++ , j++ )
6729 XGINew_SetReg1( pVBInfo->Part2Port , i , Tap4TimingPtr->Reg[ j ] ) ;
6730 }
6731
6732 if ( ( pVBInfo->VBInfo & SetCRT2ToTV ) && ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) )
6733 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x04 ) ; /* Enable V.Scaling */
6734 else
6735 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x4E , ~0x14 , 0x10 ) ; /* Enable H.Scaling */
6736#endif
6737}
6738
6739/* --------------------------------------------------------------------- */
6740/* Function : XGI_SetGroup3 */
6741/* Input : */
6742/* Output : */
6743/* Description : */
6744/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006745void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006746{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006747 unsigned short i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006748 UCHAR *tempdi;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006749 unsigned short modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006750
6751 if(ModeNo<=0x13)
6752 {
6753 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6754 }
6755 else
6756 {
6757 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6758 }
6759
6760
6761 XGINew_SetReg1(pVBInfo->Part3Port,0x00,0x00);
6762 if(pVBInfo->TVInfo&SetPALTV)
6763 {
6764 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6765 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6766 }
6767 else
6768 {
6769 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xF5);
6770 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xB7);
6771 }
6772
6773 if(!(pVBInfo->VBInfo&SetCRT2ToTV))
6774 {
6775 return;
6776 }
6777
6778 if(pVBInfo->TVInfo&SetPALMTV)
6779 {
6780 XGINew_SetReg1(pVBInfo->Part3Port,0x13,0xFA);
6781 XGINew_SetReg1(pVBInfo->Part3Port,0x14,0xC8);
6782 XGINew_SetReg1(pVBInfo->Part3Port,0x3D,0xA8);
6783 }
6784
6785 if((pVBInfo->VBInfo&SetCRT2ToHiVisionTV)|| (pVBInfo->VBInfo&SetCRT2ToYPbPr))
6786 {
6787 if(pVBInfo->TVInfo & SetYPbPrMode525i)
6788 {
6789 return;
6790 }
6791 tempdi=pVBInfo->HiTVGroup3Data;
6792 if(pVBInfo->SetFlag&TVSimuMode)
6793 {
6794 tempdi=pVBInfo->HiTVGroup3Simu;
6795 if(!(modeflag&Charx8Dot))
6796 {
6797 tempdi=pVBInfo->HiTVGroup3Text;
6798 }
6799 }
6800
6801 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6802 {
6803 tempdi=pVBInfo->Ren525pGroup3;
6804 }
6805 if(pVBInfo->TVInfo & SetYPbPrMode750p)
6806 {
6807 tempdi=pVBInfo->Ren750pGroup3;
6808 }
6809
6810 for(i=0;i<=0x3E;i++)
6811 {
6812 XGINew_SetReg1(pVBInfo->Part3Port,i,tempdi[i]);
6813 }
6814 if(pVBInfo->VBType&VB_XGI301C) /* Marcovision */
6815 {
6816 if(pVBInfo->TVInfo & SetYPbPrMode525p)
6817 {
6818 XGINew_SetReg1(pVBInfo->Part3Port,0x28,0x3f);
6819 }
6820 }
6821 }
6822 return;
6823} /* {end of XGI_SetGroup3} */
6824
6825
6826/* --------------------------------------------------------------------- */
6827/* Function : XGI_SetGroup4 */
6828/* Input : */
6829/* Output : */
6830/* Description : */
6831/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006832void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006833{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006834 unsigned short tempax ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006835 tempcx ,
6836 tempbx ,
6837 modeflag ,
6838 temp ,
6839 temp2 ;
6840
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006841 unsigned long tempebx ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006842 tempeax ,
6843 templong ;
6844
6845
6846 if ( ModeNo <= 0x13 )
6847 {
6848 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
6849 }
6850 else
6851 {
6852 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
6853 }
6854
6855 temp = pVBInfo->RVBHCFACT ;
6856 XGINew_SetReg1( pVBInfo->Part4Port , 0x13 , temp ) ;
6857
6858 tempbx = pVBInfo->RVBHCMAX ;
6859 temp = tempbx & 0x00FF ;
6860 XGINew_SetReg1( pVBInfo->Part4Port , 0x14 , temp ) ;
6861 temp2 = ( ( tempbx & 0xFF00 ) >> 8 ) << 7 ;
6862 tempcx = pVBInfo->VGAHT - 1 ;
6863 temp = tempcx & 0x00FF ;
6864 XGINew_SetReg1( pVBInfo->Part4Port , 0x16 , temp ) ;
6865
6866 temp =( ( tempcx & 0xFF00 ) >> 8 ) << 3 ;
6867 temp2 |= temp ;
6868
6869 tempcx = pVBInfo->VGAVT - 1 ;
6870 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
6871 {
6872 tempcx -= 5 ;
6873 }
6874
6875 temp = tempcx & 0x00FF ;
6876 XGINew_SetReg1( pVBInfo->Part4Port , 0x17 , temp ) ;
6877 temp = temp2 | ( ( tempcx & 0xFF00 ) >> 8 ) ;
6878 XGINew_SetReg1( pVBInfo->Part4Port , 0x15 , temp ) ;
6879 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0D , 0x08 ) ;
6880 tempcx = pVBInfo->VBInfo ;
6881 tempbx = pVBInfo->VGAHDE ;
6882
6883 if ( modeflag & HalfDCLK )
6884 {
6885 tempbx = tempbx >> 1 ;
6886 }
6887
6888 if ( XGI_IsLCDDualLink( pVBInfo ) )
6889 tempbx = tempbx >> 1 ;
6890
6891 if(tempcx&SetCRT2ToHiVisionTV)
6892 {
6893 temp=0;
6894 if(tempbx<=1024)
6895 temp=0xA0;
6896 if(tempbx == 1280)
6897 temp = 0xC0;
6898 }
6899 else if(tempcx&SetCRT2ToTV)
6900 {
6901 temp=0xA0;
6902 if(tempbx <= 800)
6903 temp=0x80;
6904 }
6905 else
6906 {
6907 temp=0x80;
6908 if(pVBInfo->VBInfo&SetCRT2ToLCD)
6909 {
6910 temp=0;
6911 if(tempbx>800)
6912 temp=0x60;
6913 }
6914 }
6915
6916 if ( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
6917 {
6918 temp = 0x00 ;
6919 if ( pVBInfo->VGAHDE == 1280 )
6920 temp = 0x40 ;
6921 if ( pVBInfo->VGAHDE == 1024 )
6922 temp = 0x20 ;
6923 }
6924 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0E , ~0xEF , temp ) ;
6925
6926 tempebx = pVBInfo->VDE ;
6927
6928 if ( tempcx & SetCRT2ToHiVisionTV )
6929 {
6930 if ( !( temp & 0xE000 ) )
6931 tempbx = tempbx >> 1 ;
6932 }
6933
6934 tempcx = pVBInfo->RVBHRS ;
6935 temp = tempcx & 0x00FF ;
6936 XGINew_SetReg1( pVBInfo->Part4Port , 0x18 , temp );
6937
6938 tempeax = pVBInfo->VGAVDE ;
6939 tempcx |= 0x04000 ;
6940
6941
6942 if ( tempeax <= tempebx )
6943 {
6944 tempcx=(tempcx&(~0x4000));
6945 tempeax = pVBInfo->VGAVDE ;
6946 }
6947 else
6948 {
6949 tempeax -= tempebx ;
6950 }
6951
6952
6953 templong = ( tempeax * 256 * 1024 ) % tempebx ;
6954 tempeax = ( tempeax * 256 * 1024 ) / tempebx ;
6955 tempebx = tempeax ;
6956
6957 if ( templong != 0 )
6958 {
6959 tempebx++ ;
6960 }
6961
6962
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006963 temp = (unsigned short)(tempebx & 0x000000FF);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006964 XGINew_SetReg1( pVBInfo->Part4Port , 0x1B , temp ) ;
6965
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006966 temp = (unsigned short)((tempebx & 0x0000FF00) >> 8);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006967 XGINew_SetReg1( pVBInfo->Part4Port , 0x1A , temp ) ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006968 tempbx = (unsigned short)(tempebx >> 16);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006969 temp = tempbx & 0x00FF ;
6970 temp = temp << 4 ;
6971 temp |= ( ( tempcx & 0xFF00 ) >> 8 ) ;
6972 XGINew_SetReg1( pVBInfo->Part4Port , 0x19 , temp ) ;
6973
6974 /* 301b */
6975 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
6976 {
6977 temp = 0x0028 ;
6978 XGINew_SetReg1( pVBInfo->Part4Port , 0x1C , temp ) ;
6979 tempax = pVBInfo->VGAHDE ;
6980 if ( modeflag & HalfDCLK )
6981 {
6982 tempax = tempax >> 1 ;
6983 }
6984
6985 if ( XGI_IsLCDDualLink( pVBInfo ) )
6986 tempax = tempax >> 1 ;
6987
6988 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6989 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
6990 {
6991 if ( tempax > 800 )
6992 tempax -= 800 ;
6993 }
6994 else
6995 {
6996 if ( pVBInfo->VGAHDE > 800 )
6997 {
6998 if ( pVBInfo->VGAHDE == 1024 )
6999 tempax = ( tempax * 25 / 32 ) - 1 ;
7000 else
7001 tempax = ( tempax * 20 / 32 ) - 1 ;
7002 }
7003 }
7004 tempax -= 1 ;
7005
7006/*
7007 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7008 {
7009 if ( pVBInfo->VBType & VB_XGI301LV )
7010 {
7011 if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7012 {
7013 if ( pVBInfo->VGAHDE > 800 )
7014 {
7015 if ( pVBInfo->VGAHDE == 1024 )
7016 tempax = ( tempax * 25 / 32 ) - 1 ;
7017 else
7018 tempax = ( tempax * 20 / 32 ) - 1 ;
7019 }
7020 }
7021 }
7022 else
7023 {
7024 if ( pVBInfo->VGAHDE > 800 )
7025 {
7026 if ( pVBInfo->VGAHDE == 1024 )
7027 tempax = ( tempax * 25 / 32 ) - 1 ;
7028 else
7029 tempax = ( tempax * 20 / 32 ) - 1 ;
7030 }
7031 }
7032 }
7033*/
7034
7035 temp = ( tempax & 0xFF00 ) >> 8 ;
7036 temp = ( ( temp & 0x0003 ) << 4 ) ;
7037 XGINew_SetReg1( pVBInfo->Part4Port , 0x1E , temp ) ;
7038 temp = ( tempax & 0x00FF ) ;
7039 XGINew_SetReg1( pVBInfo->Part4Port , 0x1D , temp ) ;
7040
7041 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToHiVisionTV ) )
7042 {
7043 if ( pVBInfo->VGAHDE > 800 )
7044 {
7045 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1E , 0x08 ) ;
7046 }
7047 }
7048 temp = 0x0036 ;
7049
7050 if ( pVBInfo->VBInfo & SetCRT2ToTV )
7051 {
7052 if ( !( pVBInfo->TVInfo & ( NTSC1024x768 | SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i ) ) )
7053 {
7054 temp |= 0x0001 ;
7055 if ( ( pVBInfo->VBInfo & SetInSlaveMode ) && ( !( pVBInfo->TVInfo & TVSimuMode ) ) )
7056 temp &= ( ~0x0001 ) ;
7057 }
7058 }
7059
7060 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x1F , 0x00C0 , temp ) ;
7061 tempbx = pVBInfo->HT ;
7062 if ( XGI_IsLCDDualLink( pVBInfo ) )
7063 tempbx = tempbx >> 1 ;
7064 tempbx = ( tempbx >> 1 ) - 2 ;
7065 temp = ( ( tempbx & 0x0700 ) >> 8 ) << 3 ;
7066 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , 0x00C0 , temp ) ;
7067 temp = tempbx & 0x00FF ;
7068 XGINew_SetReg1( pVBInfo->Part4Port , 0x22 , temp ) ;
7069 }
7070 /* end 301b */
7071
7072 if ( pVBInfo->ISXPDOS == 0 )
7073 XGI_SetCRT2VCLK( ModeNo , ModeIdIndex , RefreshRateTableIndex, pVBInfo ) ;
7074}
7075
7076
7077/* --------------------------------------------------------------------- */
7078/* Function : XGI_SetGroup5 */
7079/* Input : */
7080/* Output : */
7081/* Description : */
7082/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007083void XGI_SetGroup5(unsigned short ModeNo , unsigned short ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007084{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007085 unsigned short Pindex ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007086 Pdata ;
7087
7088 Pindex = pVBInfo->Part5Port ;
7089 Pdata = pVBInfo->Part5Port + 1 ;
7090 if ( pVBInfo->ModeType == ModeVGA )
7091 {
7092 if ( !( pVBInfo->VBInfo & ( SetInSlaveMode | LoadDACFlag | CRT2DisplayFlag ) ) )
7093 {
7094 XGINew_EnableCRT2(pVBInfo) ;
7095 /* LoadDAC2(pVBInfo->Part5Port,ModeNo,ModeIdIndex); */
7096 }
7097 }
7098 return ;
7099}
7100
7101
7102/* --------------------------------------------------------------------- */
7103/* Function : XGI_GetLcdPtr */
7104/* Input : */
7105/* Output : */
7106/* Description : */
7107/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007108void *XGI_GetLcdPtr(unsigned short BX,
7109 unsigned short ModeNo,
7110 unsigned short ModeIdIndex,
7111 unsigned short RefreshRateTableIndex,
7112 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007113{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007114 unsigned short i ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007115 tempdx ,
7116 tempcx ,
7117 tempbx ,
7118 tempal ,
7119 modeflag ,
7120 table ;
7121
7122 XGI330_LCDDataTablStruct *tempdi = 0 ;
7123
7124
7125 tempbx = BX;
7126
7127 if ( ModeNo <= 0x13 )
7128 {
7129 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7130 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7131 }
7132 else
7133 {
7134 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7135 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7136 }
7137
7138 tempal = tempal & 0x0f ;
7139
7140 if ( tempbx <= 1 ) /* ExpLink */
7141 {
7142 if ( ModeNo <= 0x13 )
7143 {
7144 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ; /* find no Ext_CRT2CRTC2 */
7145 }
7146 else
7147 {
7148 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7149 }
7150
7151 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
7152 {
7153 if ( ModeNo <= 0x13 )
7154 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC2 ;
7155 else
7156 tempal= pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC2 ;
7157 }
7158
7159 if ( tempbx & 0x01 )
7160 tempal = ( tempal >> 4 ) ;
7161
7162 tempal = ( tempal & 0x0f ) ;
7163 }
7164
7165 tempcx = LCDLenList[ tempbx ] ; /* mov cl,byte ptr cs:LCDLenList[bx] */
7166
7167 if ( pVBInfo->LCDInfo & EnableScalingLCD ) /* ScaleLCD */
7168 {
7169 if ( ( tempbx == 5 ) || ( tempbx ) == 7 )
7170 tempcx = LCDDesDataLen2 ;
7171 else if ( ( tempbx == 3 ) || ( tempbx == 8 ) )
7172 tempcx = LVDSDesDataLen2 ;
7173 }
7174 /* mov di, word ptr cs:LCDDataList[bx] */
7175 /* tempdi=pVideoMemory[LCDDataList+tempbx*2]|(pVideoMemory[LCDDataList+tempbx*2+1]<<8); */
7176
7177 switch( tempbx )
7178 {
7179 case 0:
7180 tempdi = XGI_EPLLCDCRT1Ptr_H ;
7181 break ;
7182 case 1:
7183 tempdi = XGI_EPLLCDCRT1Ptr_V ;
7184 break ;
7185 case 2:
7186 tempdi = XGI_EPLLCDDataPtr ;
7187 break ;
7188 case 3:
7189 tempdi = XGI_EPLLCDDesDataPtr ;
7190 break ;
7191 case 4:
7192 tempdi = XGI_LCDDataTable ;
7193 break ;
7194 case 5:
7195 tempdi = XGI_LCDDesDataTable ;
7196 break ;
7197 case 6:
7198 tempdi = XGI_EPLCHLCDRegPtr ;
7199 break ;
7200 case 7:
7201 case 8:
7202 case 9:
7203 tempdi = 0 ;
7204 break ;
7205 default:
7206 break ;
7207 }
7208
7209 if ( tempdi == 0x00 ) /* OEMUtil */
7210 return 0 ;
7211
7212 table = tempbx ;
7213 i = 0 ;
7214
7215 while( tempdi[ i ].PANELID != 0xff )
7216 {
7217 tempdx = pVBInfo->LCDResInfo ;
7218 if ( tempbx & 0x0080 ) /* OEMUtil */
7219 {
7220 tempbx &= ( ~0x0080 ) ;
7221 tempdx = pVBInfo->LCDTypeInfo ;
7222 }
7223
7224 if ( pVBInfo->LCDInfo & EnableScalingLCD )
7225 tempdx &= ( ~PanelResInfo ) ;
7226
7227 if ( tempdi[ i ].PANELID == tempdx )
7228 {
7229 tempbx = tempdi[ i ].MASK ;
7230 tempdx = pVBInfo->LCDInfo ;
7231
7232 if ( ModeNo <= 0x13 ) /* alan 09/10/2003 */
7233 tempdx |= SetLCDStdMode ;
7234
7235 if ( modeflag & HalfDCLK )
7236 tempdx |= SetLCDLowResolution ;
7237
7238 tempbx &= tempdx;
7239 if ( tempbx == tempdi[ i ].CAP )
7240 break ;
7241 }
7242 i++ ;
7243 }
7244
7245 if ( table == 0 )
7246 {
7247 switch( tempdi[ i ].DATAPTR )
7248 {
7249 case 0:
7250 return &XGI_LVDSCRT11024x768_1_H[ tempal ] ;
7251 break ;
7252 case 1:
7253 return &XGI_LVDSCRT11024x768_2_H[ tempal ] ;
7254 break ;
7255 case 2:
7256 return &XGI_LVDSCRT11280x1024_1_H[ tempal ] ;
7257 break ;
7258 case 3:
7259 return &XGI_LVDSCRT11280x1024_2_H[ tempal ] ;
7260 break ;
7261 case 4:
7262 return &XGI_LVDSCRT11400x1050_1_H[ tempal ] ;
7263 break ;
7264 case 5:
7265 return &XGI_LVDSCRT11400x1050_2_H[ tempal ] ;
7266 break ;
7267 case 6:
7268 return &XGI_LVDSCRT11600x1200_1_H[ tempal ] ;
7269 break ;
7270 case 7:
7271 return &XGI_LVDSCRT11024x768_1_Hx75[ tempal ] ;
7272 break ;
7273 case 8:
7274 return &XGI_LVDSCRT11024x768_2_Hx75[ tempal ] ;
7275 break ;
7276 case 9:
7277 return &XGI_LVDSCRT11280x1024_1_Hx75[ tempal ] ;
7278 break ;
7279 case 10:
7280 return &XGI_LVDSCRT11280x1024_2_Hx75[ tempal ] ;
7281 break ;
7282 default:
7283 break ;
7284 }
7285 }
7286 else if ( table == 1 )
7287 {
7288 switch( tempdi[ i ].DATAPTR )
7289 {
7290 case 0:
7291 return &XGI_LVDSCRT11024x768_1_V[ tempal ] ;
7292 break ;
7293 case 1:
7294 return &XGI_LVDSCRT11024x768_2_V[ tempal ] ;
7295 break ;
7296 case 2:
7297 return &XGI_LVDSCRT11280x1024_1_V[ tempal ] ;
7298 break ;
7299 case 3:
7300 return &XGI_LVDSCRT11280x1024_2_V[ tempal ] ;
7301 break ;
7302 case 4:
7303 return &XGI_LVDSCRT11400x1050_1_V[ tempal ] ;
7304 break ;
7305 case 5:
7306 return &XGI_LVDSCRT11400x1050_2_V[ tempal ] ;
7307 break ;
7308 case 6:
7309 return &XGI_LVDSCRT11600x1200_1_V[ tempal ] ;
7310 break ;
7311 case 7:
7312 return &XGI_LVDSCRT11024x768_1_Vx75[ tempal ] ;
7313 break ;
7314 case 8:
7315 return &XGI_LVDSCRT11024x768_2_Vx75[ tempal ] ;
7316 break ;
7317 case 9:
7318 return &XGI_LVDSCRT11280x1024_1_Vx75[ tempal ] ;
7319 break ;
7320 case 10:
7321 return &XGI_LVDSCRT11280x1024_2_Vx75[ tempal ] ;
7322 break ;
7323 default:
7324 break ;
7325 }
7326 }
7327 else if ( table == 2 )
7328 {
7329 switch( tempdi[ i ].DATAPTR )
7330 {
7331 case 0:
7332 return &XGI_LVDS1024x768Data_1[ tempal ] ;
7333 break ;
7334 case 1:
7335 return &XGI_LVDS1024x768Data_2[ tempal ] ;
7336 break ;
7337 case 2:
7338 return &XGI_LVDS1280x1024Data_1[ tempal ] ;
7339 break ;
7340 case 3:
7341 return &XGI_LVDS1280x1024Data_2[ tempal ] ;
7342 break ;
7343 case 4:
7344 return &XGI_LVDS1400x1050Data_1[ tempal ] ;
7345 break ;
7346 case 5:
7347 return &XGI_LVDS1400x1050Data_2[ tempal ] ;
7348 break ;
7349 case 6:
7350 return &XGI_LVDS1600x1200Data_1[ tempal ] ;
7351 break ;
7352 case 7:
7353 return &XGI_LVDSNoScalingData[ tempal ] ;
7354 break ;
7355 case 8:
7356 return &XGI_LVDS1024x768Data_1x75[ tempal ] ;
7357 break ;
7358 case 9:
7359 return &XGI_LVDS1024x768Data_2x75[ tempal ] ;
7360 break ;
7361 case 10:
7362 return &XGI_LVDS1280x1024Data_1x75[ tempal ] ;
7363 break ;
7364 case 11:
7365 return &XGI_LVDS1280x1024Data_2x75[ tempal ] ;
7366 break ;
7367 case 12:
7368 return &XGI_LVDSNoScalingDatax75[ tempal ] ;
7369 break ;
7370 default:
7371 break ;
7372 }
7373 }
7374 else if ( table == 3 )
7375 {
7376 switch( tempdi[ i ].DATAPTR )
7377 {
7378 case 0:
7379 return &XGI_LVDS1024x768Des_1[ tempal ] ;
7380 break ;
7381 case 1:
7382 return &XGI_LVDS1024x768Des_3[ tempal ] ;
7383 break ;
7384 case 2:
7385 return &XGI_LVDS1024x768Des_2[ tempal ] ;
7386 break ;
7387 case 3:
7388 return &XGI_LVDS1280x1024Des_1[ tempal ] ;
7389 break ;
7390 case 4:
7391 return &XGI_LVDS1280x1024Des_2[ tempal ] ;
7392 break ;
7393 case 5:
7394 return &XGI_LVDS1400x1050Des_1[ tempal ] ;
7395 break ;
7396 case 6:
7397 return &XGI_LVDS1400x1050Des_2[ tempal ] ;
7398 break ;
7399 case 7:
7400 return &XGI_LVDS1600x1200Des_1[ tempal ] ;
7401 break ;
7402 case 8:
7403 return &XGI_LVDSNoScalingDesData[ tempal ] ;
7404 break ;
7405 case 9:
7406 return &XGI_LVDS1024x768Des_1x75[ tempal ] ;
7407 break ;
7408 case 10:
7409 return &XGI_LVDS1024x768Des_3x75[ tempal ] ;
7410 break ;
7411 case 11:
7412 return &XGI_LVDS1024x768Des_2x75[ tempal ] ;
7413 break;
7414 case 12:
7415 return &XGI_LVDS1280x1024Des_1x75[ tempal ] ;
7416 break ;
7417 case 13:
7418 return &XGI_LVDS1280x1024Des_2x75[ tempal ] ;
7419 break ;
7420 case 14:
7421 return &XGI_LVDSNoScalingDesDatax75[ tempal ] ;
7422 break ;
7423 default:
7424 break ;
7425 }
7426 }
7427 else if ( table == 4 )
7428 {
7429 switch( tempdi[ i ].DATAPTR )
7430 {
7431 case 0:
7432 return &XGI_ExtLCD1024x768Data[ tempal ] ;
7433 break ;
7434 case 1:
7435 return &XGI_StLCD1024x768Data[ tempal ] ;
7436 break ;
7437 case 2:
7438 return &XGI_CetLCD1024x768Data[ tempal ] ;
7439 break ;
7440 case 3:
7441 return &XGI_ExtLCD1280x1024Data[ tempal ] ;
7442 break ;
7443 case 4:
7444 return &XGI_StLCD1280x1024Data[ tempal ] ;
7445 break ;
7446 case 5:
7447 return &XGI_CetLCD1280x1024Data[ tempal ] ;
7448 break ;
7449 case 6:
7450 return &XGI_ExtLCD1400x1050Data[ tempal ] ;
7451 break ;
7452 case 7:
7453 return &XGI_StLCD1400x1050Data[ tempal ] ;
7454 break ;
7455 case 8:
7456 return &XGI_CetLCD1400x1050Data[ tempal ] ;
7457 break ;
7458 case 9:
7459 return &XGI_ExtLCD1600x1200Data[ tempal ] ;
7460 break ;
7461 case 10:
7462 return &XGI_StLCD1600x1200Data[ tempal ] ;
7463 break ;
7464 case 11:
7465 return &XGI_NoScalingData[ tempal ] ;
7466 break ;
7467 case 12:
7468 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7469 break ;
7470 case 13:
7471 return &XGI_ExtLCD1024x768x75Data[ tempal ] ;
7472 break ;
7473 case 14:
7474 return &XGI_CetLCD1024x768x75Data[ tempal ] ;
7475 break ;
7476 case 15:
7477 return &XGI_ExtLCD1280x1024x75Data[ tempal ] ;
7478 break ;
7479 case 16:
7480 return &XGI_StLCD1280x1024x75Data[ tempal ] ;
7481 break;
7482 case 17:
7483 return &XGI_CetLCD1280x1024x75Data[ tempal ] ;
7484 break;
7485 case 18:
7486 return &XGI_NoScalingDatax75[ tempal ] ;
7487 break ;
7488 default:
7489 break ;
7490 }
7491 }
7492 else if ( table == 5 )
7493 {
7494 switch( tempdi[ i ].DATAPTR )
7495 {
7496 case 0:
7497 return &XGI_ExtLCDDes1024x768Data[ tempal ] ;
7498 break ;
7499 case 1:
7500 return &XGI_StLCDDes1024x768Data[ tempal ] ;
7501 break ;
7502 case 2:
7503 return &XGI_CetLCDDes1024x768Data[ tempal ] ;
7504 break ;
7505 case 3:
7506 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7507 return &XGI_ExtLCDDLDes1280x1024Data[ tempal ] ;
7508 else
7509 return &XGI_ExtLCDDes1280x1024Data[ tempal ] ;
7510 break ;
7511 case 4:
7512 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7513 return &XGI_StLCDDLDes1280x1024Data[ tempal ] ;
7514 else
7515 return &XGI_StLCDDes1280x1024Data[ tempal ] ;
7516 break ;
7517 case 5:
7518 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7519 return &XGI_CetLCDDLDes1280x1024Data[ tempal ] ;
7520 else
7521 return &XGI_CetLCDDes1280x1024Data[ tempal ] ;
7522 break ;
7523 case 6:
7524 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7525 return &XGI_ExtLCDDLDes1400x1050Data[ tempal ] ;
7526 else
7527 return &XGI_ExtLCDDes1400x1050Data[ tempal ] ;
7528 break ;
7529 case 7:
7530 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7531 return &XGI_StLCDDLDes1400x1050Data[ tempal ] ;
7532 else
7533 return &XGI_StLCDDes1400x1050Data[ tempal ] ;
7534 break ;
7535 case 8:
7536 return &XGI_CetLCDDes1400x1050Data[ tempal ] ;
7537 break ;
7538 case 9:
7539 return &XGI_CetLCDDes1400x1050Data2[ tempal ] ;
7540 break ;
7541 case 10:
7542 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7543 return &XGI_ExtLCDDLDes1600x1200Data[ tempal ] ;
7544 else
7545 return &XGI_ExtLCDDes1600x1200Data[ tempal ] ;
7546 break ;
7547 case 11:
7548 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7549 return &XGI_StLCDDLDes1600x1200Data[ tempal ] ;
7550 else
7551 return &XGI_StLCDDes1600x1200Data[ tempal ] ;
7552 break ;
7553 case 12:
7554 return &XGI_NoScalingDesData[ tempal ] ;
7555 break;
7556 case 13:
7557 return &XGI_ExtLCDDes1024x768x75Data[ tempal ] ;
7558 break ;
7559 case 14:
7560 return &XGI_StLCDDes1024x768x75Data[ tempal ] ;
7561 break ;
7562 case 15:
7563 return &XGI_CetLCDDes1024x768x75Data[ tempal ] ;
7564 break ;
7565 case 16:
7566 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7567 return &XGI_ExtLCDDLDes1280x1024x75Data[ tempal ] ;
7568 else
7569 return &XGI_ExtLCDDes1280x1024x75Data[ tempal ] ;
7570 break ;
7571 case 17:
7572 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7573 return &XGI_StLCDDLDes1280x1024x75Data[ tempal ] ;
7574 else
7575 return &XGI_StLCDDes1280x1024x75Data[ tempal ] ;
7576 break ;
7577 case 18:
7578 if ( ( pVBInfo->VBType & VB_XGI301LV ) || ( pVBInfo->VBType & VB_XGI302LV ) )
7579 return &XGI_CetLCDDLDes1280x1024x75Data[ tempal ] ;
7580 else
7581 return &XGI_CetLCDDes1280x1024x75Data[ tempal ] ;
7582 break ;
7583 case 19:
7584 return &XGI_NoScalingDesDatax75[ tempal ] ;
7585 break ;
7586 default:
7587 break ;
7588 }
7589 }
7590 else if ( table == 6 )
7591 {
7592 switch( tempdi[ i ].DATAPTR )
7593 {
7594 case 0:
7595 return &XGI_CH7017LV1024x768[ tempal ] ;
7596 break ;
7597 case 1:
7598 return &XGI_CH7017LV1400x1050[ tempal ] ;
7599 break ;
7600 default:
7601 break ;
7602 }
7603 }
7604 return 0 ;
7605}
7606
7607
7608/* --------------------------------------------------------------------- */
7609/* Function : XGI_GetTVPtr */
7610/* Input : */
7611/* Output : */
7612/* Description : */
7613/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007614void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
7615 unsigned short ModeIdIndex,
7616 unsigned short RefreshRateTableIndex,
7617 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007618{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007619 unsigned short i , tempdx , tempbx , tempal , modeflag , table ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007620 XGI330_TVDataTablStruct *tempdi = 0 ;
7621
7622 tempbx = BX ;
7623
7624 if ( ModeNo <= 0x13 )
7625 {
7626 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
7627 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
7628 }
7629 else
7630 {
7631 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
7632 tempal = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
7633 }
7634
7635 tempal = tempal & 0x3f ;
7636 table = tempbx ;
7637
7638 switch( tempbx )
7639 {
7640 case 0:
7641 tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
7642 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7643 {
7644 tempdi = XGI_EPLCHTVCRT1Ptr;
7645 }
7646 break ;
7647 case 1:
7648 tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
7649 if ( pVBInfo->IF_DEF_CH7007 == 1 )
7650 {
7651 tempdi = XGI_EPLCHTVCRT1Ptr;
7652 }
7653 break ;
7654 case 2:
7655 tempdi = XGI_EPLCHTVDataPtr ;
7656 break ;
7657 case 3:
7658 tempdi = 0 ;
7659 break ;
7660 case 4:
7661 tempdi = XGI_TVDataTable ;
7662 break ;
7663 case 5:
7664 tempdi = 0 ;
7665 break ;
7666 case 6:
7667 tempdi = XGI_EPLCHTVRegPtr ;
7668 break ;
7669 default:
7670 break ;
7671 }
7672
7673 if ( tempdi == 0x00 ) /* OEMUtil */
7674 return( 0 ) ;
7675
7676 tempdx = pVBInfo->TVInfo ;
7677
7678 if ( pVBInfo->VBInfo & SetInSlaveMode )
7679 tempdx = tempdx | SetTVLockMode ;
7680
7681 if ( modeflag & HalfDCLK )
7682 tempdx = tempdx | SetTVLowResolution ;
7683
7684 i = 0 ;
7685
7686 while( tempdi[ i ].MASK != 0xffff )
7687 {
7688 if ( ( tempdx & tempdi[ i ].MASK ) == tempdi[ i ].CAP )
7689 break ;
7690 i++ ;
7691 }
7692
7693 if ( table == 0x00 ) /* 07/05/22 */
7694 {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007695 }
7696 else if ( table == 0x01 )
7697 {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007698 }
7699 else if ( table == 0x04 )
7700 {
7701 switch( tempdi[ i ].DATAPTR )
7702 {
7703 case 0:
7704 return &XGI_ExtPALData[ tempal ] ;
7705 break ;
7706 case 1:
7707 return &XGI_ExtNTSCData[ tempal ] ;
7708 break ;
7709 case 2:
7710 return &XGI_StPALData[ tempal ] ;
7711 break ;
7712 case 3:
7713 return &XGI_StNTSCData[ tempal ] ;
7714 break ;
7715 case 4:
7716 return &XGI_ExtHiTVData[ tempal ] ;
7717 break ;
7718 case 5:
7719 return &XGI_St2HiTVData[ tempal ] ;
7720 break ;
7721 case 6:
7722 return &XGI_ExtYPbPr525iData[ tempal ] ;
7723 break ;
7724 case 7:
7725 return &XGI_ExtYPbPr525pData[ tempal ] ;
7726 break ;
7727 case 8:
7728 return &XGI_ExtYPbPr750pData[ tempal ] ;
7729 break ;
7730 case 9:
7731 return &XGI_StYPbPr525iData[ tempal ] ;
7732 break ;
7733 case 10:
7734 return &XGI_StYPbPr525pData[ tempal ] ;
7735 break ;
7736 case 11:
7737 return &XGI_StYPbPr750pData[ tempal ] ;
7738 break;
7739 case 12: /* avoid system hang */
7740 return &XGI_ExtNTSCData[ tempal ] ;
7741 break ;
7742 case 13:
7743 return &XGI_St1HiTVData[ tempal ] ;
7744 break ;
7745 default:
7746 break ;
7747 }
7748 }
7749 else if( table == 0x02 )
7750 {
7751 switch( tempdi[ i ].DATAPTR )
7752 {
7753 case 0:
7754 return &XGI_CHTVUNTSCData[ tempal ] ;
7755 break ;
7756 case 1:
7757 return &XGI_CHTVONTSCData[ tempal ] ;
7758 break ;
7759 case 2:
7760 return &XGI_CHTVUPALData[ tempal ] ;
7761 break ;
7762 case 3:
7763 return &XGI_CHTVOPALData[ tempal ] ;
7764 break ;
7765 default:
7766 break ;
7767 }
7768 }
7769 else if( table == 0x06 )
7770 {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007771 }
7772 return( 0 ) ;
7773}
7774
7775
7776/* --------------------------------------------------------------------- */
7777/* Function : XGI_BacklightByDrv */
7778/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04007779/* Output : 1 -> Skip backlight control */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007780/* Description : */
7781/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007782unsigned char XGI_BacklightByDrv(PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007783{
7784 UCHAR tempah ;
7785
7786 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x3A ) ;
Bill Pembertondda08c52010-06-17 13:10:42 -04007787 if (tempah & BacklightControlBit)
7788 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007789 else
Bill Pembertondda08c52010-06-17 13:10:42 -04007790 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007791}
7792
7793
7794/* --------------------------------------------------------------------- */
7795/* Function : XGI_FirePWDDisable */
7796/* Input : */
7797/* Output : */
7798/* Description : Turn off VDD & Backlight : Fire disable procedure */
7799/* --------------------------------------------------------------------- */
7800/*
7801void XGI_FirePWDDisable( PVB_DEVICE_INFO pVBInfo )
7802{
7803 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x00 , 0xFC ) ;
7804}
7805*/
7806
7807/* --------------------------------------------------------------------- */
7808/* Function : XGI_FirePWDEnable */
7809/* Input : */
7810/* Output : */
7811/* Description : Turn on VDD & Backlight : Fire enable procedure */
7812/* --------------------------------------------------------------------- */
7813void XGI_FirePWDEnable(PVB_DEVICE_INFO pVBInfo )
7814{
7815 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x26 , 0x03 , 0xFC ) ;
7816}
7817
7818
7819/* --------------------------------------------------------------------- */
7820/* Function : XGI_EnableGatingCRT */
7821/* Input : */
7822/* Output : */
7823/* Description : */
7824/* --------------------------------------------------------------------- */
7825void XGI_EnableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7826{
7827 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x40 ) ;
7828}
7829
7830
7831/* --------------------------------------------------------------------- */
7832/* Function : XGI_DisableGatingCRT */
7833/* Input : */
7834/* Output : */
7835/* Description : */
7836/* --------------------------------------------------------------------- */
7837void XGI_DisableGatingCRT(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
7838{
7839
7840 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x63 , 0xBF , 0x00 ) ;
7841}
7842
7843
7844/* --------------------------------------------------------------------- */
7845/* Function : XGI_SetPanelDelay */
7846/* Input : */
7847/* Output : */
7848/* Description : */
7849/* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
7850/* : bl : 2 ; T2 : the duration signal on and Vdd on */
7851/* : bl : 3 ; T3 : the duration between CPL off and signal off */
7852/* : bl : 4 ; T4 : the duration signal off and Vdd off */
7853/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007854void XGI_SetPanelDelay(unsigned short tempbl, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007855{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007856 unsigned short index ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007857
7858 index = XGI_GetLCDCapPtr(pVBInfo) ;
7859
7860 if ( tempbl == 1 )
7861 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S1, pVBInfo ) ;
7862
7863 if ( tempbl == 2 )
7864 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S2, pVBInfo ) ;
7865
7866 if ( tempbl == 3 )
7867 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S3, pVBInfo ) ;
7868
7869 if ( tempbl == 4 )
7870 XGINew_LCD_Wait_Time( pVBInfo->LCDCapList[ index ].PSC_S4, pVBInfo ) ;
7871}
7872
7873
7874/* --------------------------------------------------------------------- */
7875/* Function : XGI_SetPanelPower */
7876/* Input : */
7877/* Output : */
7878/* Description : */
7879/* I/O : ah = 0011b = 03h ; Backlight on, Power on */
7880/* = 0111b = 07h ; Backlight on, Power off */
7881/* = 1011b = 0Bh ; Backlight off, Power on */
7882/* = 1111b = 0Fh ; Backlight off, Power off */
7883/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007884void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007885{
7886 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
7887 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x26 , tempbl , tempah ) ;
7888 else
7889 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
7890}
7891
7892UCHAR XG21GPIODataTransfer(UCHAR ujDate)
7893{
7894 UCHAR ujRet = 0;
7895 UCHAR i = 0;
7896
7897 for (i=0; i<8; i++)
7898 {
7899 ujRet = ujRet << 1;
7900 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
7901 ujRet |= (ujDate >> i) & 1;
7902 }
7903
7904 return ujRet;
7905}
7906
7907/*----------------------------------------------------------------------------*/
7908/* output */
7909/* bl[5] : LVDS signal */
7910/* bl[1] : LVDS backlight */
7911/* bl[0] : LVDS VDD */
7912/*----------------------------------------------------------------------------*/
7913UCHAR XGI_XG21GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7914{
7915 UCHAR CR4A,temp;
7916
7917 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7918 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x23 ) ; /* enable GPIO write */
7919
7920 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7921
7922 temp = XG21GPIODataTransfer(temp);
7923 temp &= 0x23;
7924 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7925 return temp;
7926}
7927
7928/*----------------------------------------------------------------------------*/
7929/* output */
7930/* bl[5] : LVDS signal */
7931/* bl[1] : LVDS backlight */
7932/* bl[0] : LVDS VDD */
7933/*----------------------------------------------------------------------------*/
7934UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo)
7935{
7936 UCHAR CR4A,CRB4,temp;
7937
7938 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7939 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
7940
7941 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7942
7943 temp &= 0x0C;
7944 temp >>= 2;
7945 XGINew_SetReg1( pVBInfo->P3d4 , 0x4A , CR4A ) ;
7946 CRB4 = XGINew_GetReg1( pVBInfo->P3d4 , 0xB4 ) ;
7947 temp |= ((CRB4&0x04)<<3);
7948 return temp;
7949}
7950/*----------------------------------------------------------------------------*/
7951/* input */
7952/* bl[5] : 1;LVDS signal on */
7953/* bl[1] : 1;LVDS backlight on */
7954/* bl[0] : 1:LVDS VDD on */
7955/* bh: 100000b : clear bit 5, to set bit5 */
7956/* 000010b : clear bit 1, to set bit1 */
7957/* 000001b : clear bit 0, to set bit0 */
7958/*----------------------------------------------------------------------------*/
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007959void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007960{
7961 UCHAR CR4A,temp;
7962
7963 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
7964 tempbh &= 0x23;
7965 tempbl &= 0x23;
7966 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
7967
7968 if (tempbh&0x20)
7969 {
7970 temp = (tempbl>>4)&0x02;
7971
7972 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
7973
7974 }
7975
7976 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x48 ) ;
7977
7978 temp = XG21GPIODataTransfer(temp);
7979 temp &= ~tempbh;
7980 temp |= tempbl;
7981 XGINew_SetReg1( pVBInfo->P3d4 , 0x48 , temp ) ;
7982}
7983
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007984void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007985{
7986 UCHAR CR4A,temp;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007987 unsigned short tempbh0, tempbl0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007988
7989 tempbh0 = tempbh;
7990 tempbl0 = tempbl;
7991 tempbh0 &= 0x20;
7992 tempbl0 &= 0x20;
7993 tempbh0 >>= 3;
7994 tempbl0 >>= 3;
7995
7996 if (tempbh&0x20)
7997 {
7998 temp = (tempbl>>4)&0x02;
7999
8000 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
8001
8002 }
8003 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
8004
8005 CR4A = XGINew_GetReg1( pVBInfo->P3d4 , 0x4A ) ;
8006 tempbh &= 0x03;
8007 tempbl &= 0x03;
8008 tempbh <<= 2;
8009 tempbl <<= 2; /* GPIOC,GPIOD */
8010 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
8011 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
8012}
8013
8014/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008015unsigned short XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008016{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008017 unsigned short index ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008018
8019 index = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8020 if (index<sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct))
8021 {
8022 return index;
8023 }
8024 return 0;
8025}
8026
8027/* --------------------------------------------------------------------- */
8028/* Function : XGI_XG21SetPanelDelay */
8029/* Input : */
8030/* Output : */
8031/* Description : */
8032/* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
8033/* : bl : 2 ; T2 : the duration signal on and Vdd on */
8034/* : bl : 3 ; T3 : the duration between CPL off and signal off */
8035/* : bl : 4 ; T4 : the duration signal off and Vdd off */
8036/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008037void XGI_XG21SetPanelDelay(unsigned short tempbl, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008038{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008039 unsigned short index ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008040
8041 index = XGI_GetLVDSOEMTableIndex( pVBInfo );
8042 if ( tempbl == 1 )
8043 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
8044
8045 if ( tempbl == 2 )
8046 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
8047
8048 if ( tempbl == 3 )
8049 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
8050
8051 if ( tempbl == 4 )
8052 XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
8053}
8054
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008055unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
8056 unsigned short ModeIdIndex,
8057 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008058{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008059 unsigned short xres ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008060 yres ,
8061 colordepth ,
8062 modeflag ,
8063 resindex ,
8064 lvdstableindex;
8065
8066 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8067 if ( ModeNo <= 0x13 )
8068 {
8069 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8070 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8071 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8072 }
8073 else
8074 {
8075 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8076 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8077 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8078 }
8079
8080 if ( !( modeflag & Charx8Dot ) )
8081 {
8082 xres /= 9;
8083 xres *= 8;
8084 }
8085
8086 if ( ModeNo > 0x13 )
8087 {
8088 if ( ( ModeNo>0x13 ) && ( modeflag & HalfDCLK ) )
8089 {
8090 xres *= 2 ;
8091 }
8092 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8093 {
8094 yres *= 2 ;
8095 }
8096 }
8097
8098 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8099 if ( xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) )
Bill Pembertondda08c52010-06-17 13:10:42 -04008100 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008101
8102 if ( yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE) )
Bill Pembertondda08c52010-06-17 13:10:42 -04008103 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008104
8105 if ( ModeNo > 0x13 )
8106 {
8107 if ( ( xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE) ) ||
8108 ( yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) )
8109 {
8110 colordepth = XGI_GetColorDepth( ModeNo , ModeIdIndex, pVBInfo ) ;
Bill Pembertondda08c52010-06-17 13:10:42 -04008111 if (colordepth > 2)
8112 return 0;
8113
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008114 }
8115 }
Bill Pembertondda08c52010-06-17 13:10:42 -04008116 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008117}
8118
8119void XGI_SetXG21FPBits(PVB_DEVICE_INFO pVBInfo)
8120{
8121 UCHAR temp;
8122
8123 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[0] 1: 18bit */
8124 temp = ( temp & 1 ) << 6;
8125 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x40 , temp ) ; /* SR06[6] 18bit Dither */
8126 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
8127
8128}
8129
8130void XGI_SetXG27FPBits(PVB_DEVICE_INFO pVBInfo)
8131{
8132 UCHAR temp;
8133
8134 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ; /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
8135 temp = ( temp & 3 ) << 6;
8136 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0xc0 , temp & 0x80 ) ; /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
8137 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0xc0 , temp | 0x80 ) ; /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
8138
8139}
8140
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008141void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
8142 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008143{
8144 UCHAR temp,Miscdata;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008145 unsigned short xres ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008146 yres ,
8147 modeflag ,
8148 resindex ,
8149 lvdstableindex ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008150 unsigned short LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8151 unsigned short LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8152 unsigned short value;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008153
8154 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8155
8156 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8157 temp &= LCDPolarity;
8158 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8159
8160 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8161
8162 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8163 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8164 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8165
8166 XGI_SetXG21FPBits(pVBInfo);
8167 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8168 if ( ModeNo <= 0x13 )
8169 {
8170 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8171 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8172 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8173 }
8174 else
8175 {
8176 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8177 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8178 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8179 }
8180
8181 if (!( modeflag & Charx8Dot ))
8182 xres = xres * 8 / 9;
8183
8184 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8185
8186 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8187 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8188 {
8189 LVDSHBS -= xres/4 ;
8190 }
8191 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8192
8193 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8194 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8195
8196 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8197 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8198
8199 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8200
8201 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8202
8203 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8204 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8205 {
8206 LVDSVBS += yres/2 ;
8207 }
8208 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8209
8210 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8211 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8212
8213 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8214 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8215
8216 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8217
8218 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8219 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8220
8221 if (!( modeflag & Charx8Dot ))
8222 {
8223 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8224 }
8225
8226 /* HT SR0B[1:0] CR00 */
8227 value = ( LVDSHT >> 3 ) - 5;
8228 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8229 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8230
8231 /* HBS SR0B[5:4] CR02 */
8232 value = ( LVDSHBS >> 3 ) - 1;
8233 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8234 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8235
8236 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8237 value = ( LVDSHBE >> 3 ) - 1;
8238 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8239 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8240 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8241
8242 /* HRS SR0B[7:6] CR04 */
8243 value = ( LVDSHRS >> 3 ) + 2;
8244 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8245 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8246
8247 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8248 value--;
8249 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8250 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8251
8252 /* HRE SR0C[2] CR05[4:0] */
8253 value = ( LVDSHRE >> 3 ) + 2;
8254 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8255 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8256
8257 /* Panel HRE SR2F[7:2] */
8258 value--;
8259 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8260
8261 /* VT SR0A[0] CR07[5][0] CR06 */
8262 value = LVDSVT - 2 ;
8263 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8264 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8265 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8266 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8267
8268 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8269 value = LVDSVBS - 1 ;
8270 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8271 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8272 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8273 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8274
8275 /* VBE SR0A[4] CR16 */
8276 value = LVDSVBE - 1;
8277 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8278 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8279
8280 /* VRS SR0A[3] CR7[7][2] CR10 */
8281 value = LVDSVRS - 1 ;
8282 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8283 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8284 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8285 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8286
8287 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
8288 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0x03 , ( value & 0x600 ) >> 9 ) ;
8289 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , (value >> 1) & 0xFF ) ;
8290 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x33 , ~0x01 , value & 0x01 ) ;
8291
8292 /* VRE SR0A[5] CR11[3:0] */
8293 value = LVDSVRE - 1;
8294 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8295 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8296
8297 /* Panel VRE SR3F[7:2] */ /* SR3F[7] has to be 0, h/w bug */
8298 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0x7C ) ;
8299
8300 for ( temp=0, value = 0; temp < 3; temp++)
8301 {
8302
8303 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8304 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8305 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8306 value += 0x10;
8307 }
8308
8309 if (!( modeflag & Charx8Dot ))
8310 {
8311 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8312 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8313 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8314
8315 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8316 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8317
8318 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8319 }
8320
8321
8322}
8323
8324/* no shadow case */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008325void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
8326 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008327{
8328 UCHAR temp,Miscdata;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008329 unsigned short xres ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008330 yres ,
8331 modeflag ,
8332 resindex ,
8333 lvdstableindex ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008334 unsigned short LVDSHT,LVDSHBS,LVDSHRS,LVDSHRE,LVDSHBE;
8335 unsigned short LVDSVT,LVDSVBS,LVDSVRS,LVDSVRE,LVDSVBE;
8336 unsigned short value;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008337
8338 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
8339 temp = (UCHAR) ( ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & (LCDPolarity << 8 ) ) >> 8 );
8340 temp &= LCDPolarity;
8341 Miscdata =(UCHAR) XGINew_GetReg2(pVBInfo->P3cc) ;
8342
8343 XGINew_SetReg3( pVBInfo->P3c2 , (Miscdata & 0x3F) | temp ) ;
8344
8345 temp = (UCHAR) ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability & LCDPolarity ) ;
8346 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x80 , temp&0x80 ) ; /* SR35[7] FP VSync polarity */
8347 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x30 , ~0x20 , (temp&0x40)>>1 ) ; /* SR30[5] FP HSync polarity */
8348
8349 XGI_SetXG27FPBits(pVBInfo);
8350 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
8351 if ( ModeNo <= 0x13 )
8352 {
8353 xres = pVBInfo->StResInfo[ resindex ].HTotal ;
8354 yres = pVBInfo->StResInfo[ resindex ].VTotal ;
8355 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8356 }
8357 else
8358 {
8359 xres = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
8360 yres = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
8361 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex].Ext_ModeFlag ; /* si+St_ModeFlag */
8362 }
8363
8364 if (!( modeflag & Charx8Dot ))
8365 xres = xres * 8 / 9;
8366
8367 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
8368
8369 LVDSHBS = xres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE - xres ) / 2 ;
8370 if ( ( ModeNo<=0x13 ) && ( modeflag & HalfDCLK ) )
8371 {
8372 LVDSHBS -= xres/4 ;
8373 }
8374 if (LVDSHBS > LVDSHT) LVDSHBS -= LVDSHT ;
8375
8376 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP ;
8377 if (LVDSHRS > LVDSHT) LVDSHRS -= LVDSHT ;
8378
8379 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC ;
8380 if (LVDSHRE > LVDSHT) LVDSHRE -= LVDSHT ;
8381
8382 LVDSHBE = LVDSHBS + LVDSHT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE ;
8383
8384 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
8385
8386 LVDSVBS = yres + ( pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE - yres ) / 2 ;
8387 if ( ( ModeNo>0x13 ) && ( modeflag & DoubleScanMode ) )
8388 {
8389 LVDSVBS += yres/2 ;
8390 }
8391 if (LVDSVBS > LVDSVT) LVDSVBS -= LVDSVT ;
8392
8393 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP ;
8394 if (LVDSVRS > LVDSVT) LVDSVRS -= LVDSVT ;
8395
8396 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC ;
8397 if (LVDSVRE > LVDSVT) LVDSVRE -= LVDSVT ;
8398
8399 LVDSVBE = LVDSVBS + LVDSVT - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE ;
8400
8401 temp = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x11 ) ;
8402 XGINew_SetReg1( pVBInfo->P3d4 , 0x11 , temp & 0x7f ) ; /* Unlock CRTC */
8403
8404 if (!( modeflag & Charx8Dot ))
8405 {
8406 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1 , 0x1 ) ;
8407 }
8408
8409 /* HT SR0B[1:0] CR00 */
8410 value = ( LVDSHT >> 3 ) - 5;
8411 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8412 XGINew_SetReg1( pVBInfo->P3d4 , 0x0 , (value & 0xFF) ) ;
8413
8414 /* HBS SR0B[5:4] CR02 */
8415 value = ( LVDSHBS >> 3 ) - 1;
8416 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0x30 , ( value & 0x300 ) >> 4 ) ;
8417 XGINew_SetReg1( pVBInfo->P3d4 , 0x2 , (value & 0xFF) ) ;
8418
8419 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
8420 value = ( LVDSHBE >> 3 ) - 1;
8421 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x03 , ( value & 0xC0 ) >> 6 ) ;
8422 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x80 , ( value & 0x20 ) << 2 ) ;
8423 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x03 , ~0x1F , value & 0x1F ) ;
8424
8425 /* HRS SR0B[7:6] CR04 */
8426 value = ( LVDSHRS >> 3 ) + 2;
8427 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0B , ~0xC0 , ( value & 0x300 ) >> 2 ) ;
8428 XGINew_SetReg1( pVBInfo->P3d4 , 0x4 , (value & 0xFF) ) ;
8429
8430 /* Panel HRS SR2F[1:0] SR2E[7:0] */
8431 value--;
8432 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0x03 , ( value & 0x300 ) >> 8 ) ;
8433 XGINew_SetReg1( pVBInfo->P3c4 , 0x2E , (value & 0xFF) ) ;
8434
8435 /* HRE SR0C[2] CR05[4:0] */
8436 value = ( LVDSHRE >> 3 ) + 2;
8437 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0C , ~0x04 , ( value & 0x20 ) >> 3 ) ;
8438 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x05 , ~0x1F , value & 0x1F ) ;
8439
8440 /* Panel HRE SR2F[7:2] */
8441 value--;
8442 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x2F , ~0xFC , value << 2 ) ;
8443
8444 /* VT SR0A[0] CR07[5][0] CR06 */
8445 value = LVDSVT - 2 ;
8446 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x01 , ( value & 0x400 ) >> 10 ) ;
8447 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8448 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x01 , ( value & 0x100 ) >> 8 ) ;
8449 XGINew_SetReg1( pVBInfo->P3d4 , 0x06 , (value & 0xFF) ) ;
8450
8451 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
8452 value = LVDSVBS - 1 ;
8453 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x04 , ( value & 0x400 ) >> 8 ) ;
8454 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x09 , ~0x20 , ( value & 0x200 ) >> 4 ) ;
8455 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x08 , ( value & 0x100 ) >> 5 ) ;
8456 XGINew_SetReg1( pVBInfo->P3d4 , 0x15 , (value & 0xFF) ) ;
8457
8458 /* VBE SR0A[4] CR16 */
8459 value = LVDSVBE - 1;
8460 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x10 , ( value & 0x100 ) >> 4 ) ;
8461 XGINew_SetReg1( pVBInfo->P3d4 , 0x16 , (value & 0xFF) ) ;
8462
8463 /* VRS SR0A[3] CR7[7][2] CR10 */
8464 value = LVDSVRS - 1 ;
8465 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x08 , ( value & 0x400 ) >> 7 ) ;
8466 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x80 , ( value & 0x200 ) >> 2 ) ;
8467 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x07 , ~0x04 , ( value & 0x100 ) >> 6 ) ;
8468 XGINew_SetReg1( pVBInfo->P3d4 , 0x10 , (value & 0xFF) ) ;
8469
8470 /* Panel VRS SR35[2:0] SR34[7:0] */
8471 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x35 , ~0x07 , ( value & 0x700 ) >> 8 ) ;
8472 XGINew_SetReg1( pVBInfo->P3c4 , 0x34 , value & 0xFF ) ;
8473
8474 /* VRE SR0A[5] CR11[3:0] */
8475 value = LVDSVRE - 1;
8476 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x0A , ~0x20 , ( value & 0x10 ) << 1 ) ;
8477 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x11 , ~0x0F , value & 0x0F ) ;
8478
8479 /* Panel VRE SR3F[7:2] */
8480 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x3F , ~0xFC , ( value << 2 ) & 0xFC ) ;
8481
8482 for ( temp=0, value = 0; temp < 3; temp++)
8483 {
8484
8485 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x31 , ~0x30 , value ) ;
8486 XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1) ;
8487 XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2) ;
8488 value += 0x10;
8489 }
8490
8491 if (!( modeflag & Charx8Dot ))
8492 {
8493 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8494 XGINew_SetReg3( pVBInfo->P3c0 , 0x13 ) ; /* set index */
8495 XGINew_SetReg3( pVBInfo->P3c0 , 0x00 ) ; /* set data, panning = 0, shift left 1 dot*/
8496
8497 XGINew_GetReg2( pVBInfo->P3da ) ; /* Enable Attribute */
8498 XGINew_SetReg3( pVBInfo->P3c0 , 0x20 ) ;
8499
8500 XGINew_GetReg2( pVBInfo->P3da ) ; /* reset 3da */
8501 }
8502
8503
8504}
8505
8506/* --------------------------------------------------------------------- */
8507/* Function : XGI_IsLCDON */
8508/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04008509/* Output : 0 : Skip PSC Control */
8510/* 1: Disable PSC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008511/* Description : */
8512/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008513unsigned char XGI_IsLCDON(PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008514{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008515 unsigned short tempax ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008516
8517 tempax = pVBInfo->VBInfo ;
8518 if ( tempax & SetCRT2ToDualEdge )
Bill Pembertondda08c52010-06-17 13:10:42 -04008519 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008520 else if ( tempax & ( DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode ) )
Bill Pembertondda08c52010-06-17 13:10:42 -04008521 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008522
Bill Pembertondda08c52010-06-17 13:10:42 -04008523 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008524}
8525
8526
8527/* --------------------------------------------------------------------- */
8528/* Function : XGI_EnablePWD */
8529/* Input : */
8530/* Output : */
8531/* Description : */
8532/* --------------------------------------------------------------------- */
8533void XGI_EnablePWD( PVB_DEVICE_INFO pVBInfo )
8534{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008535 unsigned short index ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008536 temp ;
8537
8538 index = XGI_GetLCDCapPtr(pVBInfo) ;
8539 temp = pVBInfo->LCDCapList[ index ].PWD_2B ;
8540 XGINew_SetReg1( pVBInfo->Part4Port , 0x2B , temp ) ;
8541 XGINew_SetReg1( pVBInfo->Part4Port , 0x2C , pVBInfo->LCDCapList[ index ].PWD_2C ) ;
8542 XGINew_SetReg1( pVBInfo->Part4Port , 0x2D , pVBInfo->LCDCapList[ index ].PWD_2D ) ;
8543 XGINew_SetReg1( pVBInfo->Part4Port , 0x2E , pVBInfo->LCDCapList[ index ].PWD_2E ) ;
8544 XGINew_SetReg1( pVBInfo->Part4Port , 0x2F , pVBInfo->LCDCapList[ index ].PWD_2F ) ;
8545 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x80 ) ; /* enable PWD */
8546}
8547
8548
8549/* --------------------------------------------------------------------- */
8550/* Function : XGI_DisablePWD */
8551/* Input : */
8552/* Output : */
8553/* Description : */
8554/* --------------------------------------------------------------------- */
8555void XGI_DisablePWD( PVB_DEVICE_INFO pVBInfo )
8556{
8557 XGINew_SetRegAND( pVBInfo->Part4Port , 0x27 , 0x7F ) ; /* disable PWD */
8558}
8559
8560
8561/* --------------------------------------------------------------------- */
8562/* Function : XGI_DisableChISLCD */
8563/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04008564/* Output : 0 -> Not LCD Mode */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008565/* Description : */
8566/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008567unsigned char XGI_DisableChISLCD(PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008568{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008569 unsigned short tempbx ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008570 tempah ;
8571
8572 tempbx = pVBInfo->SetFlag & ( DisableChA | DisableChB ) ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008573 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008574
8575 if ( tempbx & ( EnableChA | DisableChA ) )
8576 {
8577 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
Bill Pembertondda08c52010-06-17 13:10:42 -04008578 return 0 ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008579 }
8580
8581 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
Bill Pembertondda08c52010-06-17 13:10:42 -04008582 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008583
8584 if ( tempah & 0x01 ) /* Chk LCDB Mode */
Bill Pembertondda08c52010-06-17 13:10:42 -04008585 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008586
Bill Pembertondda08c52010-06-17 13:10:42 -04008587 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008588}
8589
8590
8591/* --------------------------------------------------------------------- */
8592/* Function : XGI_EnableChISLCD */
8593/* Input : */
8594/* Output : 0 -> Not LCD mode */
8595/* Description : */
8596/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008597unsigned char XGI_EnableChISLCD(PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008598{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008599 unsigned short tempbx ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008600 tempah ;
8601
8602
8603 tempbx = pVBInfo->SetFlag & ( EnableChA | EnableChB ) ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008604 tempah = ~( (unsigned short)XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ) ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008605
8606 if ( tempbx & ( EnableChA | DisableChA ) )
8607 {
8608 if ( !( tempah & 0x08 ) ) /* Chk LCDA Mode */
Bill Pembertondda08c52010-06-17 13:10:42 -04008609 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008610 }
8611
8612 if ( !( tempbx & ( EnableChB | DisableChB ) ) )
Bill Pembertondda08c52010-06-17 13:10:42 -04008613 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008614
8615 if ( tempah & 0x01 ) /* Chk LCDB Mode */
Bill Pembertondda08c52010-06-17 13:10:42 -04008616 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008617
Bill Pembertondda08c52010-06-17 13:10:42 -04008618 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008619}
8620
8621
8622/* --------------------------------------------------------------------- */
8623/* Function : XGI_GetLCDCapPtr */
8624/* Input : */
8625/* Output : */
8626/* Description : */
8627/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008628unsigned short XGI_GetLCDCapPtr(PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008629{
8630 UCHAR tempal ,
8631 tempah ,
8632 tempbl ,
8633 i ;
8634
8635 tempah = XGINew_GetReg1( pVBInfo->P3d4 , 0x36 ) ;
8636 tempal = tempah & 0x0F ;
8637 tempah = tempah & 0xF0 ;
8638 i = 0 ;
8639 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8640
8641 while( tempbl != 0xFF )
8642 {
8643 if ( tempbl & 0x80 ) /* OEMUtil */
8644 {
8645 tempal = tempah ;
8646 tempbl = tempbl & ~( 0x80 ) ;
8647 }
8648
8649 if ( tempal == tempbl )
8650 break ;
8651
8652 i++ ;
8653
8654 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8655 }
8656
8657 return i ;
8658}
8659
8660
8661/* --------------------------------------------------------------------- */
8662/* Function : XGI_GetLCDCapPtr1 */
8663/* Input : */
8664/* Output : */
8665/* Description : */
8666/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008667unsigned short XGI_GetLCDCapPtr1(PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008668{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008669 unsigned short tempah ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008670 tempal ,
8671 tempbl ,
8672 i ;
8673
8674 tempal = pVBInfo->LCDResInfo ;
8675 tempah = pVBInfo->LCDTypeInfo ;
8676
8677 i = 0 ;
8678 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID;
8679
8680 while( tempbl != 0xFF )
8681 {
8682 if ( ( tempbl & 0x80 ) && ( tempbl != 0x80 ) )
8683 {
8684 tempal = tempah ;
8685 tempbl &= ~0x80 ;
8686 }
8687
8688 if ( tempal == tempbl )
8689 break ;
8690
8691 i++ ;
8692 tempbl = pVBInfo->LCDCapList[ i ].LCD_ID ;
8693 }
8694
8695 if ( tempbl == 0xFF )
8696 {
8697 pVBInfo->LCDResInfo = Panel1024x768 ;
8698 pVBInfo->LCDTypeInfo = 0 ;
8699 i = 0 ;
8700 }
8701
8702 return i ;
8703}
8704
8705
8706/* --------------------------------------------------------------------- */
8707/* Function : XGI_GetLCDSync */
8708/* Input : */
8709/* Output : */
8710/* Description : */
8711/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008712void XGI_GetLCDSync(unsigned short *HSyncWidth , unsigned short *VSyncWidth,
8713 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008714{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008715 unsigned short Index ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008716
8717 Index = XGI_GetLCDCapPtr(pVBInfo) ;
8718 *HSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_HSyncWidth ;
8719 *VSyncWidth = pVBInfo->LCDCapList[ Index ].LCD_VSyncWidth ;
8720
8721 return ;
8722}
8723
8724
8725
8726/* --------------------------------------------------------------------- */
8727/* Function : XGI_EnableBridge */
8728/* Input : */
8729/* Output : */
8730/* Description : */
8731/* --------------------------------------------------------------------- */
8732void XGI_EnableBridge( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo)
8733{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008734 unsigned short tempbl ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008735 tempah ;
8736
8737 if ( pVBInfo->SetFlag == Win9xDOSMode )
8738 {
8739 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8740 {
8741 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8742 return ;
8743 }
8744 else /* LVDS or CH7017 */
8745 return ;
8746 }
8747
8748
8749 if ( HwDeviceExtension->jChipType < XG40 )
8750 {
8751 if ( !XGI_DisableChISLCD(pVBInfo) )
8752 {
8753 if ( ( XGI_EnableChISLCD(pVBInfo) ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8754 {
8755 if ( pVBInfo->LCDInfo & SetPWDEnable )
8756 {
8757 XGI_EnablePWD( pVBInfo);
8758 }
8759 else
8760 {
8761 pVBInfo->LCDInfo &= ( ~SetPWDEnable ) ;
8762 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8763 {
8764 tempbl = 0xFD ;
8765 tempah = 0x02 ;
8766 }
8767 else
8768 {
8769 tempbl = 0xFB ;
8770 tempah = 0x00 ;
8771 }
8772
8773 XGI_SetPanelPower( tempah , tempbl, pVBInfo ) ;
8774 XGI_SetPanelDelay( 1,pVBInfo ) ;
8775 }
8776 }
8777 }
8778 } /* Not 340 */
8779
8780
8781
8782 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8783 {
8784 if ( !( pVBInfo->SetFlag & DisableChA ) )
8785 {
8786 if ( pVBInfo->SetFlag & EnableChA )
8787 {
8788 XGINew_SetReg1( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* Power on */
8789 }
8790 else
8791 {
8792 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge ) /* SetCRT2ToLCDA ) */
8793 {
8794 XGINew_SetReg1(pVBInfo->Part1Port,0x1E,0x20); /* Power on */
8795 }
8796 }
8797 }
8798
8799 if ( !( pVBInfo->SetFlag & DisableChB ) )
8800 {
8801 if ( ( pVBInfo->SetFlag & EnableChB ) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV | SetCRT2ToRAMDAC ) ) )
8802 {
8803 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->P3c4 , 0x32 ) ;
8804 tempah &= 0xDF;
8805 if ( pVBInfo->VBInfo & SetInSlaveMode )
8806 {
8807 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
8808 tempah |= 0x20 ;
8809 }
8810 XGINew_SetReg1( pVBInfo->P3c4 , 0x32 , tempah ) ;
8811 XGINew_SetRegOR( pVBInfo->P3c4 , 0x1E , 0x20 ) ;
8812
8813
8814 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8815
8816 if ( !( tempah & 0x80 ) )
8817 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8818
8819 XGINew_SetRegAND( pVBInfo->Part1Port , 0x00 , 0x7F ) ; /* BScreenOFF = 0 */
8820 }
8821 }
8822
8823 if ( ( pVBInfo->SetFlag & ( EnableChA | EnableChB ) ) || ( !( pVBInfo->VBInfo & DisableCRT2Display ) ) )
8824 {
8825 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x00 , ~0xE0 , 0x20 ) ; /* shampoo 0129 */
8826 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
8827 {
8828 if ( !XGI_DisableChISLCD(pVBInfo) )
8829 {
8830 if ( XGI_EnableChISLCD( pVBInfo) || ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) )
8831 XGINew_SetRegAND( pVBInfo->Part4Port ,0x2A , 0x7F ) ; /* LVDS PLL power on */
8832 }
8833 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x7F ) ; /* LVDS Driver power on */
8834 }
8835 }
8836
8837 tempah = 0x00 ;
8838
8839 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
8840 {
8841 tempah = 0xc0 ;
8842
8843 if ( !( pVBInfo->VBInfo & SetSimuScanMode ) )
8844 {
8845 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8846 {
8847 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
8848 {
8849 tempah = tempah & 0x40;
8850 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
8851 tempah = tempah ^ 0xC0 ;
8852
8853 if ( pVBInfo->SetFlag & DisableChB )
8854 tempah &= 0xBF ;
8855
8856 if ( pVBInfo->SetFlag & DisableChA )
8857 tempah &= 0x7F ;
8858
8859 if ( pVBInfo->SetFlag & EnableChB )
8860 tempah |= 0x40 ;
8861
8862 if ( pVBInfo->SetFlag & EnableChA )
8863 tempah |= 0x80 ;
8864 }
8865 }
8866 }
8867 }
8868
8869 XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , tempah ) ; /* EnablePart4_1F */
8870
8871 if ( pVBInfo->SetFlag & Win9xDOSMode )
8872 {
8873 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8874 return ;
8875 }
8876
8877 if ( !( pVBInfo->SetFlag & DisableChA ) )
8878 {
8879 XGI_VBLongWait( pVBInfo) ;
8880 if ( !( pVBInfo->SetFlag & GatingCRT ) )
8881 {
8882 XGI_DisableGatingCRT( HwDeviceExtension, pVBInfo ) ;
8883 XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
8884 XGI_VBLongWait( pVBInfo) ;
8885 }
8886 }
8887 } /* 301 */
8888 else /* LVDS */
8889 {
8890 if ( pVBInfo->VBInfo & ( SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
8891 XGINew_SetRegOR( pVBInfo->Part1Port , 0x1E , 0x20 ) ; /* enable CRT2 */
8892
8893
8894
8895 tempah = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x2E ) ;
8896 if ( !( tempah & 0x80 ) )
8897 XGINew_SetRegOR( pVBInfo->Part1Port , 0x2E , 0x80 ) ; /* BVBDOENABLE = 1 */
8898
8899 XGINew_SetRegAND(pVBInfo->Part1Port,0x00,0x7F);
8900 XGI_DisplayOn( HwDeviceExtension, pVBInfo);
8901 } /* End of VB */
8902
8903
8904 if ( HwDeviceExtension->jChipType < XG40 )
8905 {
8906 if ( !XGI_EnableChISLCD(pVBInfo) )
8907 {
8908 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
8909 {
8910 if ( XGI_BacklightByDrv(pVBInfo) )
8911 return ;
8912 }
8913 else
8914 return ;
8915 }
8916
8917 if ( pVBInfo->LCDInfo & SetPWDEnable )
8918 {
8919 XGI_FirePWDEnable(pVBInfo) ;
8920 return ;
8921 }
8922
8923 XGI_SetPanelDelay( 2,pVBInfo ) ;
8924
8925 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8926 {
8927 tempah = 0x01 ;
8928 tempbl = 0xFE ; /* turn on backlght */
8929 }
8930 else
8931 {
8932 tempbl = 0xF7 ;
8933 tempah = 0x00 ;
8934 }
8935 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
8936 }
8937}
8938
8939
8940/* --------------------------------------------------------------------- */
8941/* Function : XGI_DisableBridge */
8942/* Input : */
8943/* Output : */
8944/* Description : */
8945/* --------------------------------------------------------------------- */
8946void XGI_DisableBridge(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
8947{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008948 unsigned short tempax ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008949 tempbx ,
8950 tempah = 0 ,
8951 tempbl = 0 ;
8952
8953 if ( pVBInfo->SetFlag == Win9xDOSMode )
8954 return ;
8955
8956
8957 if ( HwDeviceExtension->jChipType < XG40 )
8958 {
8959 if ( ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8960 {
8961 if ( !XGI_IsLCDON(pVBInfo) )
8962 {
8963 if ( pVBInfo->LCDInfo & SetPWDEnable )
8964 XGI_EnablePWD( pVBInfo) ;
8965 else
8966 {
8967 pVBInfo->LCDInfo &= ~SetPWDEnable ;
8968 XGI_DisablePWD(pVBInfo) ;
8969 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
8970 {
8971 tempbx = 0xFE ; /* not 01h */
8972 tempax = 0 ;
8973 }
8974 else
8975 {
8976 tempbx = 0xF7 ; /* not 08h */
8977 tempax = 0x08 ;
8978 }
8979 XGI_SetPanelPower( tempax , tempbx , pVBInfo) ;
8980 XGI_SetPanelDelay( 3,pVBInfo ) ;
8981 }
8982 } /* end if(!XGI_IsLCDON(pVBInfo)) */
8983 }
8984 }
8985
8986/* if ( CH7017 )
8987 {
8988 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2toLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) )
8989 {
8990 if ( !XGI_IsLCDON(pVBInfo) )
8991 {
8992 if ( DISCHARGE )
8993 {
8994 tempbx = XGINew_GetCH7005( 0x61 ) ;
8995 if ( tempbx < 0x01 ) //first time we power up
8996 XGINew_SetCH7005( 0x0066 ) ; //and disable power sequence
8997 else
8998 XGINew_SetCH7005( 0x5f66 ) ; //leave VDD on - disable power
8999 }
9000 }
9001 }
9002 } */
9003
9004 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B| VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9005 {
9006 tempah = 0x3F ;
9007 if ( !( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) ) )
9008 {
9009 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9010 {
9011 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9012 {
9013 tempah = 0x7F; /* Disable Channel A */
9014 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9015 tempah = 0xBF ; /* Disable Channel B */
9016
9017 if ( pVBInfo->SetFlag & DisableChB )
9018 tempah &= 0xBF ; /* force to disable Cahnnel */
9019
9020 if ( pVBInfo->SetFlag & DisableChA )
9021 tempah &= 0x7F ; /* Force to disable Channel B */
9022 }
9023 }
9024 }
9025
9026 XGINew_SetRegAND( pVBInfo->Part4Port , 0x1F , tempah ) ; /* disable part4_1f */
9027
9028 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9029 {
9030 if ( ( ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9031 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x80 ) ; /* LVDS Driver power down */
9032 }
9033
9034 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) ) )
9035 {
9036 if ( pVBInfo->SetFlag & GatingCRT )
9037 XGI_EnableGatingCRT( HwDeviceExtension, pVBInfo ) ;
9038 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9039 }
9040
9041 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9042 {
9043 if ( ( pVBInfo->SetFlag & DisableChA ) || ( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9044 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1e , 0xdf ) ; /* Power down */
9045 }
9046
9047 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xdf ) ; /* disable TV as primary VGA swap */
9048
9049 if ( ( pVBInfo->VBInfo & ( SetSimuScanMode | SetCRT2ToDualEdge ) ) )
9050 XGINew_SetRegAND(pVBInfo->Part2Port,0x00,0xdf);
9051
9052 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9053 || ( ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) && ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) ) )
9054 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9055
9056 if ( ( pVBInfo->SetFlag & DisableChB ) || ( pVBInfo->VBInfo & ( DisableCRT2Display | SetSimuScanMode ) )
9057 || ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) ) || ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) )
9058 {
9059 tempah= XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ; /* save Part1 index 0 */
9060 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x10 ) ; /* BTDAC = 1, avoid VB reset */
9061 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* disable CRT2 */
9062 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ; /* restore Part1 index 0 */
9063 }
9064 }
9065 else /* {301} */
9066 {
9067 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToTV ) )
9068 {
9069 XGINew_SetRegOR( pVBInfo->Part1Port , 0x00 , 0x80 ) ; /* BScreenOff=1 */
9070 XGINew_SetRegAND( pVBInfo->Part1Port , 0x1E , 0xDF ) ; /* Disable CRT2 */
9071 XGINew_SetRegAND( pVBInfo->P3c4 , 0x32 , 0xDF ) ; /* Disable TV asPrimary VGA swap */
9072 }
9073
9074 if ( pVBInfo->VBInfo & ( DisableCRT2Display | SetCRT2ToLCDA | SetSimuScanMode ) )
9075 XGI_DisplayOff( HwDeviceExtension, pVBInfo) ;
9076 }
9077
9078
9079
9080
9081 if ( HwDeviceExtension->jChipType < XG40 )
9082 {
9083 if ( !( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) ) || ( XGI_DisableChISLCD(pVBInfo) ) || ( XGI_IsLCDON(pVBInfo) ) )
9084 {
9085 if ( pVBInfo->LCDInfo & SetPWDEnable )
9086 {
9087 if ( pVBInfo->LCDInfo & SetPWDEnable )
9088 XGI_BacklightByDrv(pVBInfo) ;
9089 else
9090 {
9091 XGI_SetPanelDelay( 4 ,pVBInfo) ;
9092 if ( pVBInfo->VBType & VB_XGI301LV )
9093 {
9094 tempbl = 0xFD ;
9095 tempah = 0x00 ;
9096 }
9097 else
9098 {
9099 tempbl = 0xFB ;
9100 tempah = 0x04 ;
9101 }
9102 }
9103 }
9104 XGI_SetPanelPower( tempah , tempbl , pVBInfo) ;
9105 }
9106 }
9107}
9108
9109
9110/* --------------------------------------------------------------------- */
9111/* Function : XGI_GetTVPtrIndex */
9112/* Input : */
9113/* Output : */
9114/* Description : bx 0 : ExtNTSC */
9115/* 1 : StNTSC */
9116/* 2 : ExtPAL */
9117/* 3 : StPAL */
9118/* 4 : ExtHiTV */
9119/* 5 : StHiTV */
9120/* 6 : Ext525i */
9121/* 7 : St525i */
9122/* 8 : Ext525p */
9123/* 9 : St525p */
9124/* A : Ext750p */
9125/* B : St750p */
9126/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009127unsigned short XGI_GetTVPtrIndex(PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009128{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009129 unsigned short tempbx = 0 ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009130
9131 if ( pVBInfo->TVInfo & SetPALTV )
9132 tempbx = 2 ;
9133 if ( pVBInfo->TVInfo & SetYPbPrMode1080i )
9134 tempbx = 4 ;
9135 if ( pVBInfo->TVInfo & SetYPbPrMode525i )
9136 tempbx = 6 ;
9137 if ( pVBInfo->TVInfo & SetYPbPrMode525p )
9138 tempbx = 8 ;
9139 if ( pVBInfo->TVInfo & SetYPbPrMode750p )
9140 tempbx = 10 ;
9141 if ( pVBInfo->TVInfo & TVSimuMode )
9142 tempbx++ ;
9143
9144 return tempbx ;
9145}
9146
9147
9148/* --------------------------------------------------------------------- */
9149/* Function : XGI_OEM310Setting */
9150/* Input : */
9151/* Output : */
9152/* Description : Customized Param. for 301 */
9153/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009154void XGI_OEM310Setting(unsigned short ModeNo , unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009155{
9156 if ( pVBInfo->SetFlag & Win9xDOSMode )
9157 return ;
9158
9159 /* GetPart1IO(); */
9160 XGI_SetDelayComp(pVBInfo) ;
9161
9162 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9163 XGI_SetLCDCap(pVBInfo) ;
9164
9165 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9166 {
9167 /* GetPart2IO() */
9168 XGI_SetPhaseIncr(pVBInfo) ;
9169 XGI_SetYFilter( ModeNo , ModeIdIndex,pVBInfo ) ;
9170 XGI_SetAntiFlicker( ModeNo , ModeIdIndex,pVBInfo ) ;
9171
9172 if ( pVBInfo->VBType&VB_XGI301)
9173 XGI_SetEdgeEnhance( ModeNo , ModeIdIndex ,pVBInfo) ;
9174 }
9175}
9176
9177
9178/* --------------------------------------------------------------------- */
9179/* Function : XGI_SetDelayComp */
9180/* Input : */
9181/* Output : */
9182/* Description : */
9183/* --------------------------------------------------------------------- */
9184void XGI_SetDelayComp( PVB_DEVICE_INFO pVBInfo )
9185{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009186 unsigned short index ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009187
9188 UCHAR tempah ,
9189 tempbl ,
9190 tempbh ;
9191
9192 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9193 {
9194 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToTV | SetCRT2ToRAMDAC ) )
9195 {
9196 tempbl = 0;
9197 tempbh = 0;
9198
9199 index = XGI_GetTVPtrIndex(pVBInfo ) ; /* Get TV Delay */
9200 tempbl = pVBInfo->XGI_TVDelayList[ index ] ;
9201
9202 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9203 tempbl = pVBInfo->XGI_TVDelayList2[ index ] ;
9204
9205 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9206 tempbl = tempbl >> 4 ;
9207/*
9208 if ( pVBInfo->VBInfo & SetCRT2ToRAMDAC )
9209 tempbl = CRT2Delay1 ; // Get CRT2 Delay
9210
9211 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9212 tempbl = CRT2Delay2 ;
9213*/
9214 if ( pVBInfo->VBInfo & ( SetCRT2ToLCD | SetCRT2ToLCDA ) )
9215 {
9216 index = XGI_GetLCDCapPtr(pVBInfo) ; /* Get LCD Delay */
9217 tempbh=pVBInfo->LCDCapList[ index ].LCD_DelayCompensation ;
9218
9219 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9220 tempbl = tempbh ;
9221 }
9222
9223 tempbl &= 0x0F ;
9224 tempbh &= 0xF0 ;
9225 tempah = XGINew_GetReg1( pVBInfo->Part1Port , 0x2D ) ;
9226
9227 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV ) ) /* Channel B */
9228 {
9229 tempah &= 0xF0 ;
9230 tempah |= tempbl ;
9231 }
9232
9233 if ( pVBInfo->VBInfo & SetCRT2ToLCDA ) /* Channel A */
9234 {
9235 tempah &= 0x0F ;
9236 tempah |= tempbh ;
9237 }
9238 XGINew_SetReg1(pVBInfo->Part1Port,0x2D,tempah);
9239 }
9240 }
9241 else if ( pVBInfo->IF_DEF_LVDS == 1 )
9242 {
9243 tempbl = 0;
9244 tempbh = 0;
9245 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9246 {
9247 tempah = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_DelayCompensation ; /* / Get LCD Delay */
9248 tempah &= 0x0f ;
9249 tempah = tempah << 4 ;
9250 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2D , 0x0f , tempah ) ;
9251 }
9252 }
9253}
9254
9255
9256/* --------------------------------------------------------------------- */
9257/* Function : XGI_SetLCDCap */
9258/* Input : */
9259/* Output : */
9260/* Description : */
9261/* --------------------------------------------------------------------- */
9262void XGI_SetLCDCap( PVB_DEVICE_INFO pVBInfo )
9263{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009264 unsigned short tempcx ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009265
9266 tempcx = pVBInfo->LCDCapList[ XGI_GetLCDCapPtr(pVBInfo) ].LCD_Capability ;
9267
9268 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9269 {
9270 if ( pVBInfo->VBType & ( VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9271 { /* 301LV/302LV only */
9272 /* Set 301LV Capability */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009273 XGINew_SetReg1(pVBInfo->Part4Port, 0x24, (UCHAR)(tempcx & 0x1F));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009274 }
9275 /* VB Driving */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009276 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
9277 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
9278 (unsigned short)((tempcx & (EnableVBCLKDRVLOW | EnablePLLSPLOW)) >> 8));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009279 }
9280
9281 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9282 {
9283 if ( pVBInfo->VBInfo & SetCRT2ToLCD )
9284 XGI_SetLCDCap_B( tempcx,pVBInfo ) ;
9285 else if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9286 XGI_SetLCDCap_A( tempcx,pVBInfo ) ;
9287
9288 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9289 {
9290 if ( tempcx & EnableSpectrum )
9291 SetSpectrum( pVBInfo) ;
9292 }
9293 }
9294 else /* LVDS,CH7017 */
9295 XGI_SetLCDCap_A( tempcx, pVBInfo ) ;
9296}
9297
9298
9299/* --------------------------------------------------------------------- */
9300/* Function : XGI_SetLCDCap_A */
9301/* Input : */
9302/* Output : */
9303/* Description : */
9304/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009305void XGI_SetLCDCap_A(unsigned short tempcx, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009306{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009307 unsigned short temp ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009308
9309 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x37 ) ;
9310
9311 if ( temp & LCDRGB18Bit )
9312 {
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009313 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
9314 (unsigned short)(0x20 | (tempcx & 0x00C0))); /* Enable Dither */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009315 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x80 ) ;
9316 }
9317 else
9318 {
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009319 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
9320 (unsigned short)(0x30 | (tempcx & 0x00C0)));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009321 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x1A , 0x7F , 0x00 ) ;
9322 }
9323
9324/*
9325 if ( tempcx & EnableLCD24bpp ) // 24bits
9326 {
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009327 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(unsigned short)(0x30|(tempcx&0x00C0)) );
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009328 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x00);
9329 }
9330 else
9331 {
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009332 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x19, 0x0F,(unsigned short)(0x20|(tempcx&0x00C0)) ); // Enable Dither
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009333 XGINew_SetRegANDOR(pVBInfo->Part1Port,0x1A,0x7F,0x80);
9334 }
9335*/
9336}
9337
9338
9339/* --------------------------------------------------------------------- */
9340/* Function : XGI_SetLCDCap_B */
9341/* Input : cx -> LCD Capability */
9342/* Output : */
9343/* Description : */
9344/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009345void XGI_SetLCDCap_B(unsigned short tempcx, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009346{
9347 if ( tempcx & EnableLCD24bpp ) /* 24bits */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009348 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
9349 (unsigned short)(((tempcx & 0x00ff) >> 6) | 0x0c));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009350 else
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009351 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
9352 (unsigned short)(((tempcx & 0x00ff) >> 6) | 0x18)); /* Enable Dither */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009353}
9354
9355
9356/* --------------------------------------------------------------------- */
9357/* Function : SetSpectrum */
9358/* Input : */
9359/* Output : */
9360/* Description : */
9361/* --------------------------------------------------------------------- */
9362void SetSpectrum( PVB_DEVICE_INFO pVBInfo )
9363{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009364 unsigned short index ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009365
9366 index = XGI_GetLCDCapPtr(pVBInfo) ;
9367
9368 XGINew_SetRegAND( pVBInfo->Part4Port , 0x30 , 0x8F ) ; /* disable down spectrum D[4] */
9369 XGI_LongWait(pVBInfo) ;
9370 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x20 ) ; /* reset spectrum */
9371 XGI_LongWait(pVBInfo) ;
9372
9373 XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , pVBInfo->LCDCapList[ index ].Spectrum_31 ) ;
9374 XGINew_SetReg1( pVBInfo->Part4Port , 0x32 , pVBInfo->LCDCapList[ index ].Spectrum_32 ) ;
9375 XGINew_SetReg1( pVBInfo->Part4Port , 0x33 , pVBInfo->LCDCapList[ index ].Spectrum_33 ) ;
9376 XGINew_SetReg1( pVBInfo->Part4Port , 0x34 , pVBInfo->LCDCapList[ index ].Spectrum_34 ) ;
9377 XGI_LongWait(pVBInfo) ;
9378 XGINew_SetRegOR( pVBInfo->Part4Port , 0x30 , 0x40 ) ; /* enable spectrum */
9379}
9380
9381
9382/* --------------------------------------------------------------------- */
9383/* Function : XGI_SetAntiFlicker */
9384/* Input : */
9385/* Output : */
9386/* Description : Set TV Customized Param. */
9387/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009388void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
9389 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009390{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009391 unsigned short tempbx ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009392 index ;
9393
9394 UCHAR tempah ;
9395
9396 if (pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) )
9397 return ;
9398
9399 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9400 tempbx &= 0xFE ;
9401
9402 if ( ModeNo <= 0x13 )
9403 {
9404 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVFlickerIndex ;
9405 }
9406 else
9407 {
9408 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVFlickerIndex ;
9409 }
9410
9411 tempbx += index ;
9412 tempah = TVAntiFlickList[ tempbx ] ;
9413 tempah = tempah << 4 ;
9414
9415 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x0A , 0x8F , tempah ) ;
9416}
9417
9418
9419/* --------------------------------------------------------------------- */
9420/* Function : XGI_SetEdgeEnhance */
9421/* Input : */
9422/* Output : */
9423/* Description : */
9424/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009425void XGI_SetEdgeEnhance(unsigned short ModeNo , unsigned short ModeIdIndex , PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009426{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009427 unsigned short tempbx ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009428 index ;
9429
9430 UCHAR tempah ;
9431
9432
9433 tempbx = XGI_GetTVPtrIndex(pVBInfo ) ;
9434 tempbx &= 0xFE ;
9435
9436 if ( ModeNo <= 0x13 )
9437 {
9438 index = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVEdgeIndex ;
9439 }
9440 else
9441 {
9442 index = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVEdgeIndex ;
9443 }
9444
9445 tempbx += index ;
9446 tempah = TVEdgeList[ tempbx ] ;
9447 tempah = tempah << 5 ;
9448
9449 XGINew_SetRegANDOR( pVBInfo->Part2Port , 0x3A , 0x1F , tempah ) ;
9450}
9451
9452
9453/* --------------------------------------------------------------------- */
9454/* Function : XGI_SetPhaseIncr */
9455/* Input : */
9456/* Output : */
9457/* Description : */
9458/* --------------------------------------------------------------------- */
9459void XGI_SetPhaseIncr( PVB_DEVICE_INFO pVBInfo )
9460{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009461 unsigned short tempbx ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009462
9463 UCHAR tempcl ,
9464 tempch ;
9465
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009466 unsigned long tempData ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009467
9468 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9469 tempData = TVPhaseList[ tempbx ] ;
9470
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009471 XGINew_SetReg1(pVBInfo->Part2Port, 0x31,
9472 (unsigned short)(tempData & 0x000000FF));
9473 XGINew_SetReg1(pVBInfo->Part2Port, 0x32,
9474 (unsigned short)((tempData & 0x0000FF00) >> 8));
9475 XGINew_SetReg1(pVBInfo->Part2Port, 0x33,
9476 (unsigned short)((tempData & 0x00FF0000) >> 16));
9477 XGINew_SetReg1(pVBInfo->Part2Port, 0x34,
9478 (unsigned short)((tempData & 0xFF000000) >> 24));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009479}
9480
9481
9482/* --------------------------------------------------------------------- */
9483/* Function : XGI_SetYFilter */
9484/* Input : */
9485/* Output : */
9486/* Description : */
9487/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009488void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
9489 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009490{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009491 unsigned short tempbx ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009492 index ;
9493
9494 UCHAR tempcl ,
9495 tempch ,
9496 tempal ,
9497 *filterPtr ;
9498
9499 XGI_GetTVPtrIndex2( &tempbx , &tempcl , &tempch, pVBInfo ) ; /* bx, cl, ch */
9500
9501 switch( tempbx )
9502 {
9503 case 0x00:
9504 case 0x04:
9505 filterPtr = NTSCYFilter1 ;
9506 break ;
9507
9508 case 0x01:
9509 filterPtr = PALYFilter1 ;
9510 break ;
9511
9512 case 0x02:
9513 case 0x05:
9514 case 0x0D:
9515 filterPtr = PALMYFilter1 ;
9516 break ;
9517
9518 case 0x03:
9519 filterPtr = PALNYFilter1 ;
9520 break ;
9521
9522 case 0x08:
9523 case 0x0C:
9524 filterPtr = NTSCYFilter2 ;
9525 break ;
9526
9527 case 0x0A:
9528 filterPtr = PALMYFilter2 ;
9529 break ;
9530
9531 case 0x0B:
9532 filterPtr = PALNYFilter2 ;
9533 break ;
9534
9535 case 0x09:
9536 filterPtr = PALYFilter2 ;
9537 break ;
9538
9539 default:
9540 return ;
9541 }
9542
9543 if ( ModeNo <= 0x13 )
9544 tempal = pVBInfo->SModeIDTable[ ModeIdIndex ].VB_StTVYFilterIndex ;
9545 else
9546 tempal = pVBInfo->EModeIDTable[ ModeIdIndex ].VB_ExtTVYFilterIndex ;
9547
9548 if ( tempcl == 0 )
9549 index = tempal * 4;
9550 else
9551 index = tempal * 7;
9552
9553 if ( ( tempcl == 0 ) && ( tempch == 1 ) )
9554 {
9555 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , 0 ) ;
9556 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , 0 ) ;
9557 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , 0 ) ;
9558 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9559 }
9560 else
9561 {
9562 XGINew_SetReg1( pVBInfo->Part2Port , 0x35 , filterPtr[ index++ ] ) ;
9563 XGINew_SetReg1( pVBInfo->Part2Port , 0x36 , filterPtr[ index++ ] ) ;
9564 XGINew_SetReg1( pVBInfo->Part2Port , 0x37 , filterPtr[ index++ ] ) ;
9565 XGINew_SetReg1( pVBInfo->Part2Port , 0x38 , filterPtr[ index++ ] ) ;
9566 }
9567
9568 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9569 {
9570 XGINew_SetReg1( pVBInfo->Part2Port , 0x48 , filterPtr[ index++ ] ) ;
9571 XGINew_SetReg1( pVBInfo->Part2Port , 0x49 , filterPtr[ index++ ] ) ;
9572 XGINew_SetReg1( pVBInfo->Part2Port , 0x4A , filterPtr[ index++ ] ) ;
9573 }
9574}
9575
9576
9577/* --------------------------------------------------------------------- */
9578/* Function : XGI_GetTVPtrIndex2 */
9579/* Input : */
9580/* Output : bx 0 : NTSC */
9581/* 1 : PAL */
9582/* 2 : PALM */
9583/* 3 : PALN */
9584/* 4 : NTSC1024x768 */
9585/* 5 : PAL-M 1024x768 */
9586/* 6-7: reserved */
9587/* cl 0 : YFilter1 */
9588/* 1 : YFilter2 */
9589/* ch 0 : 301A */
9590/* 1 : 301B/302B/301LV/302LV */
9591/* Description : */
9592/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009593void XGI_GetTVPtrIndex2(unsigned short *tempbx,UCHAR* tempcl,UCHAR* tempch, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009594{
9595 *tempbx = 0 ;
9596 *tempcl = 0 ;
9597 *tempch = 0 ;
9598
9599 if ( pVBInfo->TVInfo & SetPALTV )
9600 *tempbx = 1 ;
9601
9602 if ( pVBInfo->TVInfo & SetPALMTV )
9603 *tempbx = 2 ;
9604
9605 if ( pVBInfo->TVInfo & SetPALNTV )
9606 *tempbx = 3 ;
9607
9608 if ( pVBInfo->TVInfo & NTSC1024x768 )
9609 {
9610 *tempbx = 4 ;
9611 if ( pVBInfo->TVInfo & SetPALMTV )
9612 *tempbx = 5 ;
9613 }
9614
9615 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9616 {
9617 if ( ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) || ( pVBInfo->TVInfo & TVSimuMode ) )
9618 {
9619 *tempbx += 8 ;
9620 *tempcl += 1 ;
9621 }
9622 }
9623
9624 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9625 (*tempch)++ ;
9626}
9627
9628
9629/* --------------------------------------------------------------------- */
9630/* Function : XGI_SetCRT2ModeRegs */
9631/* Input : */
9632/* Output : */
9633/* Description : Origin code for crt2group */
9634/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009635void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
9636 PXGI_HW_DEVICE_INFO HwDeviceExtension,
9637 PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009638{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009639 unsigned short tempbl ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009640 SHORT tempcl ;
9641
9642 UCHAR tempah ;
9643
9644 /* XGINew_SetReg1( pVBInfo->Part1Port , 0x03 , 0x00 ) ; // fix write part1 index 0 BTDRAM bit Bug */
9645 tempah=0;
9646 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9647 {
9648 tempah=XGINew_GetReg1( pVBInfo->Part1Port , 0x00 ) ;
9649 tempah &= ~0x10 ; /* BTRAMDAC */
9650 tempah |= 0x40 ; /* BTRAM */
9651
9652 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9653 {
9654 tempah=0x40; /* BTDRAM */
9655 if ( ModeNo > 0x13 )
9656 {
9657 tempcl = pVBInfo->ModeType ;
9658 tempcl -= ModeVGA ;
9659 if ( tempcl >= 0 )
9660 {
9661 tempah = ( 0x008 >> tempcl ) ; /* BT Color */
9662 if ( tempah == 0 )
9663 tempah = 1 ;
9664 tempah |= 0x040 ;
9665 }
9666 }
9667 if ( pVBInfo->VBInfo & SetInSlaveMode )
9668 tempah ^= 0x50 ; /* BTDAC */
9669 }
9670 }
9671
9672/* 0210 shampoo
9673 if ( pVBInfo->VBInfo & DisableCRT2Display )
9674 {
9675 tempah = 0 ;
9676 }
9677
9678 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9679 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9680 {
9681 tempcl = pVBInfo->ModeType ;
9682 if ( ModeNo > 0x13 )
9683 {
9684 tempcl -= ModeVGA ;
9685 if ( ( tempcl > 0 ) || ( tempcl == 0 ) )
9686 {
9687 tempah=(0x008>>tempcl) ;
9688 if ( tempah == 0 )
9689 tempah = 1 ;
9690 tempah |= 0x040;
9691 }
9692 }
9693 else
9694 {
9695 tempah = 0x040 ;
9696 }
9697
9698 if ( pVBInfo->VBInfo & SetInSlaveMode )
9699 {
9700 tempah = ( tempah ^ 0x050 ) ;
9701 }
9702 }
9703*/
9704
9705 XGINew_SetReg1( pVBInfo->Part1Port , 0x00 , tempah ) ;
9706 tempah = 0x08 ;
9707 tempbl = 0xf0 ;
9708
9709 if ( pVBInfo->VBInfo & DisableCRT2Display )
9710 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9711 else
9712 {
9713 tempah = 0x00 ;
9714 tempbl = 0xff ;
9715
9716 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9717 {
9718 if ( ( pVBInfo->VBInfo & SetCRT2ToLCDA ) && ( !( pVBInfo->VBInfo & SetSimuScanMode ) ) )
9719 {
9720 tempbl &= 0xf7 ;
9721 tempah |= 0x01 ;
9722 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9723 }
9724 else
9725 {
9726 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9727 {
9728 tempbl &= 0xf7 ;
9729 tempah |= 0x01 ;
9730 }
9731
9732 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD ) )
9733 {
9734 tempbl &= 0xf8 ;
9735 tempah = 0x01 ;
9736
9737 if ( !( pVBInfo->VBInfo & SetInSlaveMode ) )
9738 tempah |= 0x02 ;
9739
9740 if ( !( pVBInfo->VBInfo & SetCRT2ToRAMDAC ) )
9741 {
9742 tempah = tempah ^ 0x05 ;
9743 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
9744 tempah = tempah ^ 0x01 ;
9745 }
9746
9747 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9748 tempah |= 0x08 ;
9749 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9750 }
9751 else
9752 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9753 }
9754 }
9755 else
9756 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2e , tempbl , tempah ) ;
9757 }
9758
9759 if ( pVBInfo->VBInfo & ( SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA ) )
9760 {
9761 tempah &= ( ~0x08 ) ;
9762 if ( ( pVBInfo->ModeType == ModeVGA ) && ( !( pVBInfo->VBInfo & SetInSlaveMode ) ) )
9763 {
9764 tempah |= 0x010 ;
9765 }
9766 tempah |= 0x080 ;
9767
9768 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9769 {
9770 /* if ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) */
9771 /* { */
9772 tempah |= 0x020 ;
9773 if ( ModeNo > 0x13 )
9774 {
9775 if ( pVBInfo->VBInfo & DriverMode )
9776 tempah = tempah ^ 0x20 ;
9777 }
9778 /* } */
9779 }
9780
9781 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x0D , ~0x0BF , tempah ) ;
9782 tempah = 0 ;
9783
9784 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9785 tempah |= 0x40 ;
9786
9787 if ( pVBInfo->VBInfo & SetCRT2ToTV )
9788 {
9789 /* if ( ( !( pVBInfo->VBInfo & SetCRT2ToHiVisionTV ) ) && ( !( pVBInfo->TVInfo & ( SetYPbPrMode525p | SetYPbPrMode750p ) ) ) ) */
9790 /* { */
9791 if ( pVBInfo->TVInfo & RPLLDIV2XO )
9792 tempah |= 0x40 ;
9793 /* } */
9794 }
9795
9796 if ( ( pVBInfo->LCDResInfo == Panel1280x1024 ) || ( pVBInfo->LCDResInfo == Panel1280x1024x75 ) )
9797 tempah |= 0x80 ;
9798
9799 if ( pVBInfo->LCDResInfo == Panel1280x960 )
9800 tempah |= 0x80 ;
9801
9802 XGINew_SetReg1( pVBInfo->Part4Port , 0x0C , tempah ) ;
9803 }
9804
9805 if ( pVBInfo->VBType & ( VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C ) )
9806 {
9807 tempah = 0 ;
9808 tempbl = 0xfb ;
9809
9810 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9811 {
9812 tempbl=0xff;
9813 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9814 tempah |= 0x04 ; /* shampoo 0129 */
9815 }
9816
9817 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x13 , tempbl , tempah ) ;
9818 tempah = 0x00 ;
9819 tempbl = 0xcf ;
9820 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9821 {
9822 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9823 tempah |= 0x30 ;
9824 }
9825
9826 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2c , tempbl , tempah ) ;
9827 tempah = 0 ;
9828 tempbl = 0x3f ;
9829
9830 if ( !( pVBInfo->VBInfo & DisableCRT2Display ) )
9831 {
9832 if ( pVBInfo->VBInfo & SetCRT2ToDualEdge )
9833 tempah |= 0xc0 ;
9834 }
9835 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x21 , tempbl , tempah ) ;
9836 }
9837
9838 tempah = 0 ;
9839 tempbl = 0x7f ;
9840 if ( !( pVBInfo->VBInfo & SetCRT2ToLCDA ) )
9841 {
9842 tempbl = 0xff ;
9843 if ( !( pVBInfo->VBInfo & SetCRT2ToDualEdge ) )
9844 tempah |= 0x80 ;
9845 }
9846
9847 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x23 , tempbl , tempah ) ;
9848
9849 if ( pVBInfo->VBType & ( VB_XGI302LV | VB_XGI301C ) )
9850 {
9851 if ( pVBInfo->LCDInfo & SetLCDDualLink )
9852 {
9853 XGINew_SetRegOR( pVBInfo->Part4Port , 0x27 , 0x20 ) ;
9854 XGINew_SetRegOR( pVBInfo->Part4Port , 0x34 , 0x10 ) ;
9855 }
9856 }
9857}
9858
9859
9860/* --------------------------------------------------------------------- */
9861/* Function : XGI_CloseCRTC */
9862/* Input : */
9863/* Output : */
9864/* Description : */
9865/* --------------------------------------------------------------------- */
9866void XGI_CloseCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9867{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009868 unsigned short tempbx ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009869
9870 tempbx = 0 ;
9871
9872 if ( pVBInfo->VBInfo & SetCRT2ToLCDA )
9873 tempbx = 0x08A0 ;
9874
9875
9876}
9877
9878
9879/* --------------------------------------------------------------------- */
9880/* Function : XGI_OpenCRTC */
9881/* Input : */
9882/* Output : */
9883/* Description : */
9884/* --------------------------------------------------------------------- */
9885void XGI_OpenCRTC( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9886{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009887 unsigned short tempbx ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009888
9889 tempbx = 0 ;
9890
9891
9892}
9893
9894
9895/* --------------------------------------------------------------------- */
9896/* Function : XGI_GetRAMDAC2DATA */
9897/* Input : */
9898/* Output : */
9899/* Description : */
9900/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009901void XGI_GetRAMDAC2DATA(unsigned short ModeNo , unsigned short ModeIdIndex , unsigned short RefreshRateTableIndex, PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009902{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009903 unsigned short tempax ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009904 tempbx ,
9905 temp1 ,
9906 temp2 ,
9907 modeflag = 0 ,
9908 tempcx ,
9909 StandTableIndex ,
9910 CRT1Index ;
9911
9912 pVBInfo->RVBHCMAX = 1 ;
9913 pVBInfo->RVBHCFACT = 1 ;
9914
9915 if ( ModeNo <= 0x13 )
9916 {
9917 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9918 StandTableIndex = XGI_GetModePtr( ModeNo , ModeIdIndex, pVBInfo ) ;
9919 tempax = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 0 ] ;
9920 tempbx = pVBInfo->StandTable[StandTableIndex ].CRTC[ 6 ] ;
9921 temp1 = pVBInfo->StandTable[ StandTableIndex ].CRTC[ 7 ] ;
9922 }
9923 else
9924 {
9925 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9926 CRT1Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT1CRTC ;
9927 CRT1Index &= IndexMask ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009928 temp1 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
9929 temp2 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009930 tempax = ( temp1 & 0xFF ) | ( ( temp2 & 0x03 ) << 8 ) ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009931 tempbx = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
9932 tempcx = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009933 tempcx &= 0x0100 ;
9934 tempcx = tempcx << 2 ;
9935 tempbx |= tempcx;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009936 temp1 = (unsigned short)pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009937 }
9938
9939 if ( temp1 & 0x01 )
9940 tempbx |= 0x0100 ;
9941
9942 if ( temp1 & 0x20 )
9943 tempbx |= 0x0200 ;
9944 tempax += 5 ;
9945
9946 if ( modeflag & Charx8Dot )
9947 tempax *= 8 ;
9948 else
9949 tempax *= 9 ;
9950
9951 pVBInfo->VGAHT = tempax ;
9952 pVBInfo->HT = tempax ;
9953 tempbx++ ;
9954 pVBInfo->VGAVT = tempbx ;
9955 pVBInfo->VT = tempbx ;
9956}
9957
9958
9959
9960/* --------------------------------------------------------------------- */
9961/* Function : XGI_GetColorDepth */
9962/* Input : */
9963/* Output : */
9964/* Description : */
9965/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009966unsigned short XGI_GetColorDepth(unsigned short ModeNo , unsigned short ModeIdIndex, PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009967{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009968 unsigned short ColorDepth[ 6 ] = { 1 , 2 , 4 , 4 , 6 , 8 } ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009969 SHORT index ;
Bill Pemberton82d6eb52010-06-17 13:10:46 -04009970 unsigned short modeflag ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02009971
9972 if ( ModeNo <= 0x13 )
9973 {
9974 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ;
9975 }
9976 else
9977 {
9978 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ;
9979 }
9980
9981 index=(modeflag&ModeInfoFlag)-ModeEGA;
9982
9983 if ( index < 0 )
9984 index = 0 ;
9985
9986 return( ColorDepth[ index ] ) ;
9987}
9988
9989
9990
9991/* --------------------------------------------------------------------- */
9992/* Function : XGI_UnLockCRT2 */
9993/* Input : */
9994/* Output : */
9995/* Description : */
9996/* --------------------------------------------------------------------- */
9997void XGI_UnLockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
9998{
9999
10000 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2f , 0xFF , 0x01 ) ;
10001
10002}
10003
10004
10005/* --------------------------------------------------------------------- */
10006/* Function : XGI_LockCRT2 */
10007/* Input : */
10008/* Output : */
10009/* Description : */
10010/* --------------------------------------------------------------------- */
10011void XGI_LockCRT2( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo )
10012{
10013
10014 XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x2F , 0xFE , 0x00 ) ;
10015
10016
10017}
10018
10019
10020/* --------------------------------------------------------------------- */
10021/* Function : XGINew_EnableCRT2 */
10022/* Input : */
10023/* Output : */
10024/* Description : */
10025/* --------------------------------------------------------------------- */
10026void XGINew_EnableCRT2( PVB_DEVICE_INFO pVBInfo)
10027{
10028 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1E , 0xFF , 0x20 ) ;
10029}
10030
10031
10032
10033/* --------------------------------------------------------------------- */
10034/* Function : */
10035/* Input : */
10036/* Output : */
10037/* Description : */
10038/* --------------------------------------------------------------------- */
10039void XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo)
10040{
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010041 unsigned short i ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010042 j ;
10043
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010044 unsigned long temp ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010045 flag ;
10046
10047 flag = 0 ;
10048//printk("XGINew_LCD_Wait_Time");
10049//return;
10050 for( i = 0 ; i < DelayTime ; i++ )
10051 {
10052 for( j = 0 ; j < 66 ; j++ )
10053 {
10054
10055 temp = XGINew_GetReg3( 0x61 ) ;
10056
10057 //temp &= 0x10000000;
10058 temp &= 0x10;
10059 if ( temp == flag )
10060 continue ;
10061
10062 flag = temp ;
10063 }
10064 }
10065}
10066
10067
10068
10069
10070/* --------------------------------------------------------------------- */
10071/* Function : XGI_BridgeIsOn */
10072/* Input : */
10073/* Output : */
10074/* Description : */
10075/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010076unsigned char XGI_BridgeIsOn( PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010077{
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010078 unsigned short flag ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010079
10080 if ( pVBInfo->IF_DEF_LVDS == 1 )
10081 {
10082 return( 1 ) ;
10083 }
10084 else
10085 {
10086 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x00 ) ;
10087 if ( ( flag == 1 ) || ( flag == 2 ) )
10088 return( 1 ) ; /* 301b */
10089 else
10090 return( 0 ) ;
10091 }
10092}
10093
10094
10095
10096/* --------------------------------------------------------------------- */
10097/* Function : XGI_LongWait */
10098/* Input : */
10099/* Output : */
10100/* Description : */
10101/* --------------------------------------------------------------------- */
10102void XGI_LongWait(PVB_DEVICE_INFO pVBInfo)
10103{
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010104 unsigned short i ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010105
10106 i = XGINew_GetReg1( pVBInfo->P3c4 , 0x1F ) ;
10107
10108 if ( !( i & 0xC0 ) )
10109 {
10110 for( i = 0 ; i < 0xFFFF ; i++ )
10111 {
10112 if ( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10113 break ;
10114 }
10115
10116 for( i = 0 ; i < 0xFFFF ; i++ )
10117 {
10118 if ( ( XGINew_GetReg2( pVBInfo->P3da ) & 0x08 ) )
10119 break ;
10120 }
10121 }
10122}
10123
10124
10125/* --------------------------------------------------------------------- */
10126/* Function : XGI_VBLongWait */
10127/* Input : */
10128/* Output : */
10129/* Description : */
10130/* --------------------------------------------------------------------- */
10131void XGI_VBLongWait( PVB_DEVICE_INFO pVBInfo )
10132{
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010133 unsigned short tempal ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010134 temp ,
10135 i ,
10136 j ;
10137return ;
10138 if ( !( pVBInfo->VBInfo & SetCRT2ToTV ) )
10139 {
10140 temp = 0 ;
10141 for( i = 0 ; i < 3 ; i++ )
10142 {
10143 for( j = 0 ; j < 100 ; j++ )
10144 {
10145 tempal = XGINew_GetReg2( pVBInfo->P3da ) ;
10146 if ( temp & 0x01 )
10147 { /* VBWaitMode2 */
10148 if ( ( tempal & 0x08 ) )
10149 {
10150 continue ;
10151 }
10152
10153 if ( !( tempal & 0x08 ) )
10154 {
10155 break ;
10156 }
10157 }
10158 else
10159 { /* VBWaitMode1 */
10160 if ( !( tempal & 0x08 ) )
10161 {
10162 continue ;
10163 }
10164
10165 if ( ( tempal & 0x08 ) )
10166 {
10167 break ;
10168 }
10169 }
10170 }
10171 temp = temp ^ 0x01 ;
10172 }
10173 }
10174 else
10175 {
10176 XGI_LongWait(pVBInfo) ;
10177 }
10178 return ;
10179}
10180
10181
10182
10183
10184/* --------------------------------------------------------------------- */
10185/* Function : XGI_GetVGAHT2 */
10186/* Input : */
10187/* Output : */
10188/* Description : */
10189/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010190unsigned short XGI_GetVGAHT2( PVB_DEVICE_INFO pVBInfo )
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010191{
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010192 unsigned long tempax ,
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010193 tempbx ;
10194
10195 tempbx = ( ( pVBInfo->VGAVT - pVBInfo->VGAVDE ) * pVBInfo->RVBHCMAX ) & 0xFFFF ;
10196 tempax = ( pVBInfo->VT - pVBInfo->VDE ) * pVBInfo->RVBHCFACT ;
10197 tempax = ( tempax * pVBInfo->HT ) /tempbx ;
10198
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010199 return( (unsigned short)tempax ) ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010200}
10201
10202
10203/* --------------------------------------------------------------------- */
10204/* Function : XGI_GetVCLK2Ptr */
10205/* Input : */
10206/* Output : */
10207/* Description : */
10208/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010209unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo , unsigned short ModeIdIndex , unsigned short RefreshRateTableIndex , PXGI_HW_DEVICE_INFO HwDeviceExtension ,PVB_DEVICE_INFO pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010210{
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010211 unsigned short tempbx ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010212
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010213 unsigned short LCDXlat1VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10214 unsigned short LCDXlat2VCLK[ 4 ] = { VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 , VCLK108_2 + 5 } ;
10215 unsigned short LVDSXlat1VCLK[ 4 ] = { VCLK40 , VCLK40 , VCLK40 , VCLK40 } ;
10216 unsigned short LVDSXlat2VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
10217 unsigned short LVDSXlat3VCLK[ 4 ] = { VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 , VCLK65 + 2 } ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010218
Bill Pemberton82d6eb52010-06-17 13:10:46 -040010219 unsigned short CRT2Index , VCLKIndex ;
10220 unsigned short modeflag , resinfo ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020010221 UCHAR *CHTVVCLKPtr = NULL ;
10222
10223 if ( ModeNo <= 0x13 )
10224 {
10225 modeflag = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ModeFlag ; /* si+St_ResInfo */
10226 resinfo = pVBInfo->SModeIDTable[ ModeIdIndex ].St_ResInfo ;
10227 CRT2Index = pVBInfo->SModeIDTable[ ModeIdIndex ].St_CRT2CRTC ;
10228 }
10229 else
10230 {
10231 modeflag = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeFlag ; /* si+Ext_ResInfo */
10232 resinfo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_RESINFO ;
10233 CRT2Index = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRT2CRTC ;
10234 }
10235
10236 if ( pVBInfo->IF_DEF_LVDS == 0 )
10237 {
10238 CRT2Index = CRT2Index >> 6 ; /* for LCD */
10239 if ( ( ( pVBInfo->VBInfo & SetCRT2ToLCD ) | SetCRT2ToLCDA ) ) /*301b*/
10240 {
10241 if ( pVBInfo->LCDResInfo != Panel1024x768 )
10242 {
10243 VCLKIndex = LCDXlat2VCLK[ CRT2Index ] ;
10244 }
10245 else
10246 {
10247 VCLKIndex = LCDXlat1VCLK[ CRT2Index ] ;
10248 }
10249 }
10250 else /* for TV */
10251 {
10252 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10253 {
10254 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
10255 {
10256 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10257 {
10258 VCLKIndex = HiTVVCLKDIV2 ;
10259
10260
10261 VCLKIndex += 25 ;
10262
10263 }
10264 else
10265 {
10266 VCLKIndex = HiTVVCLK ;
10267
10268
10269 VCLKIndex += 25 ;
10270
10271 }
10272
10273 if ( pVBInfo->SetFlag & TVSimuMode )
10274 {
10275 if( modeflag & Charx8Dot )
10276 {
10277 VCLKIndex = HiTVSimuVCLK ;
10278
10279
10280 VCLKIndex += 25 ;
10281
10282 }
10283 else
10284 {
10285 VCLKIndex = HiTVTextVCLK ;
10286
10287
10288 VCLKIndex += 25 ;
10289
10290 }
10291 }
10292
10293 if ( pVBInfo->VBType & VB_XGI301LV ) /* 301lv */
10294 {
10295 if ( !( pVBInfo->VBExtInfo == VB_YPbPr1080i ) )
10296 {
10297 VCLKIndex = YPbPr750pVCLK ;
10298 if ( !( pVBInfo->VBExtInfo == VB_YPbPr750p ) )
10299 {
10300 VCLKIndex = YPbPr525pVCLK ;
10301 if ( !( pVBInfo->VBExtInfo == VB_YPbPr525p ) )
10302 {
10303 VCLKIndex = YPbPr525iVCLK_2 ;
10304 if ( !( pVBInfo->SetFlag & RPLLDIV2XO ) )
10305 VCLKIndex = YPbPr525iVCLK ;
10306 }
10307 }
10308 }
10309 }
10310 }
10311 else
10312 {
10313 if ( pVBInfo->VBInfo & SetCRT2ToTV )
10314 {
10315 if ( pVBInfo->SetFlag & RPLLDIV2XO )
10316 {
10317 VCLKIndex = TVVCLKDIV2 ;
10318
10319
10320 VCLKIndex += 25 ;
10321
10322 }
10323 else
10324 {
10325 VCLKIndex = TVVCLK ;
10326
10327
10328 VCLKIndex += 25 ;
10329
10330 }
10331 }
10332 }
10333 }
10334 else
10335 { /* for CRT2 */
10336 VCLKIndex = ( UCHAR )XGINew_GetReg2( ( pVBInfo->P3ca + 0x02 ) ) ; /* Port 3cch */
10337 VCLKIndex = ( ( VCLKIndex >> 2 ) & 0x03 ) ;
10338 if ( ModeNo > 0x13 )
10339 {
10340 VCLKIndex = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_CRTVCLK ; /* di+Ext_CRTVCLK */
10341 VCLKIndex &= IndexMask ;
10342 }
10343 }
10344 }
10345 }
10346 else
10347 { /* LVDS */
10348 if ( ModeNo <= 0x13 )
10349 VCLKIndex = CRT2Index ;
10350 else
10351 VCLKIndex = CRT2Index ;
10352
10353 if ( pVBInfo->IF_DEF_CH7005 == 1 )
10354 {
10355 if ( !( pVBInfo->VBInfo & SetCRT2ToLCD ) )
10356 {
10357 VCLKIndex &= 0x1f ;
10358 tempbx = 0 ;
10359
10360 if ( pVBInfo->VBInfo & SetPALTV )
10361 tempbx += 2 ;
10362
10363 if ( pVBInfo->VBInfo & SetCHTVOverScan )
10364 tempbx += 1 ;
10365
10366 switch( tempbx )
10367 {
10368 case 0:
10369 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC ;
10370 break ;
10371 case 1:
10372 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC ;
10373 break;
10374 case 2:
10375 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL ;
10376 break ;
10377 case 3:
10378 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL ;
10379 break ;
10380 default:
10381 break ;
10382 }
10383
10384 VCLKIndex = CHTVVCLKPtr[ VCLKIndex ] ;
10385 }
10386 }
10387 else
10388 {
10389 VCLKIndex = VCLKIndex >> 6 ;
10390 if ( ( pVBInfo->LCDResInfo == Panel800x600 ) || ( pVBInfo->LCDResInfo == Panel320x480 ) )
10391 VCLKIndex = LVDSXlat1VCLK[ VCLKIndex ] ;
10392 else if ( ( pVBInfo->LCDResInfo == Panel1024x768 ) || ( pVBInfo->LCDResInfo == Panel1024x768x75 ) )
10393 VCLKIndex = LVDSXlat2VCLK[ VCLKIndex ] ;
10394 else
10395 VCLKIndex = LVDSXlat3VCLK[ VCLKIndex ] ;
10396 }
10397 }
10398 /* VCLKIndex = VCLKIndex&IndexMask ; */
10399
10400
10401
10402 return( VCLKIndex ) ;
10403}
10404