blob: c4db2fc6dda845f8fe4f1304bd4d342e58c144fd [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 Pemberton80adad82010-06-17 13:10:51 -040023unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040024unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053025 struct xgi_hw_device_info *HwDeviceExtension,
26 struct vb_device_info *pVBInfo);
Bill Pemberton80adad82010-06-17 13:10:51 -040027unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020028
Bill Pemberton80adad82010-06-17 13:10:51 -040029unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo);
30unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo);
31unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040032unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053033 unsigned short ModeIdIndex,
34 unsigned short RefreshRateTableIndex,
35 unsigned short *i, struct vb_device_info *pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040036unsigned char XGI_SearchModeID(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053037 unsigned short *ModeIdIndex,
38 struct vb_device_info *pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040039unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
40 unsigned short ModeIdIndex,
Bill Pemberton80adad82010-06-17 13:10:51 -040041 struct vb_device_info *pVBInfo);
Bill Pembertone4147ab2010-06-17 13:10:50 -040042unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053043 unsigned short ModeNo);
Bill Pemberton80adad82010-06-17 13:10:51 -040044unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo);
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053045unsigned char XGI_GetModePtr(unsigned short ModeNo,
Bill Pemberton82d6eb52010-06-17 13:10:46 -040046 unsigned short ModeIdIndex,
Bill Pemberton80adad82010-06-17 13:10:51 -040047 struct vb_device_info *pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040048unsigned short XGI_GetOffset(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053049 unsigned short ModeIdIndex,
50 unsigned short RefreshRateTableIndex,
51 struct xgi_hw_device_info *HwDeviceExtension,
52 struct vb_device_info *pVBInfo);
Bill Pembertone4147ab2010-06-17 13:10:50 -040053unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053054 unsigned short ModeNo,
55 unsigned short ModeIdIndex,
56 struct vb_device_info *pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040057unsigned short XGI_GetResInfo(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053058 unsigned short ModeIdIndex,
59 struct vb_device_info *pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040060unsigned short XGI_GetColorDepth(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053061 unsigned short ModeIdIndex,
62 struct vb_device_info *pVBInfo);
Bill Pemberton80adad82010-06-17 13:10:51 -040063unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo);
Bill Pemberton82d6eb52010-06-17 13:10:46 -040064unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +053065 unsigned short ModeIdIndex,
66 unsigned short RefreshRateTableIndex,
67 struct xgi_hw_device_info *HwDeviceExtension,
68 struct vb_device_info *pVBInfo);
Bill Pemberton80adad82010-06-17 13:10:51 -040069void XGI_VBLongWait(struct vb_device_info *pVBInfo);
70void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo);
71void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
72void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
73void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
74void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
75void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
76void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
77void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
78void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
79void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
80void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
81void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
82void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
83void XGI_FirePWDEnable(struct vb_device_info *pVBInfo);
84void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
85void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
86void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo);
87void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, struct vb_device_info *pVBInfo);
88void XGI_EnablePWD(struct vb_device_info *pVBInfo);
89void XGI_DisablePWD(struct vb_device_info *pVBInfo);
90void XGI_AutoThreshold(struct vb_device_info *pVBInfo);
91void XGI_SetTap4Regs(struct vb_device_info *pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +020092
Bill Pemberton80adad82010-06-17 13:10:51 -040093void XGI_DisplayOn(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
94void XGI_DisplayOff(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
95void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
96void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
97void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
98void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
99void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo);
100void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex);
101void XGI_WaitDisply(struct vb_device_info *pVBInfo);
102void XGI_SenseCRT1(struct vb_device_info *pVBInfo);
103void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
104void XGI_SetMiscRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
105void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
106void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
107void XGI_SetGRCRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo);
108void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200109
Bill Pemberton80adad82010-06-17 13:10:51 -0400110void XGI_SetSync(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
111void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension);
112void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension);
113void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo, struct vb_device_info *pVBInfo);
114void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
115void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
116void XGI_SetCRT1FIFO(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
117void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
118void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200119
Bill Pemberton80adad82010-06-17 13:10:51 -0400120void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
121void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al, unsigned short dh, struct vb_device_info *pVBInfo);
122/*void XGI_ClearBuffer(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, struct vb_device_info *pVBInfo);*/
123void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
124void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530125 struct vb_device_info *pVBInfo);
Bill Pemberton80adad82010-06-17 13:10:51 -0400126void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
Randy Dunlap89229672010-08-10 08:46:44 -0700127unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo);
Bill Pemberton80adad82010-06-17 13:10:51 -0400128void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530129 unsigned short RefreshRateTableIndex,
130 struct xgi_hw_device_info *HwDeviceExtension,
131 struct vb_device_info *pVBInfo);
Bill Pemberton80adad82010-06-17 13:10:51 -0400132void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
133void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
134void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
135void XGI_GetVBType(struct vb_device_info *pVBInfo);
136void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
137void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
138void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
139void InitTo330Pointer(unsigned char, struct vb_device_info *pVBInfo);
140void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, struct vb_device_info *pVBInfo);
141void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
142void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
143void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
144void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
145void XGI_SetDelayComp(struct vb_device_info *pVBInfo);
146void XGI_SetLCDCap(struct vb_device_info *pVBInfo);
147void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo);
148void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo);
149void SetSpectrum(struct vb_device_info *pVBInfo);
150void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
151void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
152void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo);
153void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
Bill Pemberton108afbf2010-06-17 13:10:47 -0400154void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char* tempcl,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530155 unsigned char *tempch, struct vb_device_info *pVBInfo);
Bill Pemberton80adad82010-06-17 13:10:51 -0400156unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo);
157void XGI_SetCRT2ModeRegs(unsigned short ModeNo, struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
158void XGI_CloseCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
159void XGI_OpenCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
160void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
161void XGI_UnLockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
162void XGI_LockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
163void XGINew_EnableCRT2(struct vb_device_info *pVBInfo);
164void XGINew_LCD_Wait_Time(unsigned char DelayTime, struct vb_device_info *pVBInfo);
165void XGI_LongWait(struct vb_device_info *pVBInfo);
166void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
Bill Pemberton108afbf2010-06-17 13:10:47 -0400167void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530168 struct vb_device_info *pVBInfo);
Bill Pemberton108afbf2010-06-17 13:10:47 -0400169unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530170 unsigned short ModeNo,
171 unsigned short ModeIdIndex,
172 struct vb_device_info *pVBInfo);
Bill Pemberton108afbf2010-06-17 13:10:47 -0400173void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
Bill Pemberton80adad82010-06-17 13:10:51 -0400174 unsigned char *di_1, struct vb_device_info *pVBInfo);
175unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo);
176unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo);
177struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo);
178void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo);
179void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo);
180unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo);
181unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo);
182void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
183void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
184void XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo);
185unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
186void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
187void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
188unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200189
Bill Pemberton80adad82010-06-17 13:10:51 -0400190extern void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200191
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400192/* unsigned short XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200193
194
Randy Dunlap89229672010-08-10 08:46:44 -0700195static unsigned short XGINew_MDA_DAC[] = {
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
198 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
199 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
202 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
203 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200204
Randy Dunlap89229672010-08-10 08:46:44 -0700205static unsigned short XGINew_CGA_DAC[] = {
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400206 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
207 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
208 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
209 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
210 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
211 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
212 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
213 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200214
Randy Dunlap89229672010-08-10 08:46:44 -0700215static unsigned short XGINew_EGA_DAC[] = {
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400216 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
217 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
218 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
219 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
220 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
221 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
222 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
223 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200224
Randy Dunlap89229672010-08-10 08:46:44 -0700225static unsigned short XGINew_VGA_DAC[] = {
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400226 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
227 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
228 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
229 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
230 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
231 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
232 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
233 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
234 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
235 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200236
Bill Pemberton80adad82010-06-17 13:10:51 -0400237void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200238{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530239 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable;
240 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable;
241 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
242 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
243 pVBInfo->XGINEWUB_CRT1Table
244 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200245
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530246 /* add for new UNIVGABIOS */
247 /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
248 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200249
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530250 if (ChipType >= XG40) {
251 pVBInfo->MCLKData
252 = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
253 pVBInfo->ECLKData
254 = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
255 } else {
256 pVBInfo->MCLKData
257 = (struct XGI_MCLKDataStruct *) XGI330New_MCLKData;
258 pVBInfo->ECLKData
259 = (struct XGI_ECLKDataStruct *) XGI330_ECLKData;
260 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200261
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530262 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData;
263 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData;
264 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
265 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo;
266 pVBInfo->ModeResInfo
267 = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200268
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530269 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
270 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
271 pVBInfo->pSR07 = &XGI330_SR07;
272 pVBInfo->LCDResInfo = 0;
273 pVBInfo->LCDTypeInfo = 0;
274 pVBInfo->LCDInfo = 0;
275 pVBInfo->VBInfo = 0;
276 pVBInfo->TVInfo = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200277
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530278 pVBInfo->SR15 = XGI340_SR13;
279 pVBInfo->CR40 = XGI340_cr41;
280 pVBInfo->SR25 = XGI330_sr25;
281 pVBInfo->pSR31 = &XGI330_sr31;
282 pVBInfo->pSR32 = &XGI330_sr32;
283 pVBInfo->CR6B = XGI340_CR6B;
284 pVBInfo->CR6E = XGI340_CR6E;
285 pVBInfo->CR6F = XGI340_CR6F;
286 pVBInfo->CR89 = XGI340_CR89;
287 pVBInfo->AGPReg = XGI340_AGPReg;
288 pVBInfo->SR16 = XGI340_SR16;
289 pVBInfo->pCRCF = &XG40_CRCF;
290 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200291
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530292 pVBInfo->CR49 = XGI330_CR49;
293 pVBInfo->pSR1F = &XGI330_SR1F;
294 pVBInfo->pSR21 = &XGI330_SR21;
295 pVBInfo->pSR22 = &XGI330_SR22;
296 pVBInfo->pSR23 = &XGI330_SR23;
297 pVBInfo->pSR24 = &XGI330_SR24;
298 pVBInfo->pSR33 = &XGI330_SR33;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200299
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530300 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
301 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
302 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
303 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
304 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
305 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
306 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
307 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
308 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
309 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200310
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530311 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
312 pVBInfo->PALTiming = XGI330_PALTiming;
313 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
314 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
315 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
316 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
317 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
318 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
319 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
320 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
321 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
322 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
323 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
324 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200325
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530326 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
327 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
328 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200329
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530330 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC;
331 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC;
332 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL;
333 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200334
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530335 /* 310 customization related */
336 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
337 pVBInfo->LCDCapList = XGI_LCDDLCapList;
338 else
339 pVBInfo->LCDCapList = XGI_LCDCapList;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200340
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530341 if ((ChipType == XG21) || (ChipType == XG27))
342 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200343
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530344 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
345 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200346
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530347 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200348
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530349 if (ChipType >= XG20)
350 pVBInfo->pXGINew_CR97 = &XG20_CR97;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200351
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530352 if (ChipType == XG27) {
353 pVBInfo->MCLKData
354 = (struct 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;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200363
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530364 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200365
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530366 if (ChipType >= XG20) {
367 pVBInfo->pDVOSetting = &XG21_DVOSetting;
368 pVBInfo->pCR2E = &XG21_CR2E;
369 pVBInfo->pCR2F = &XG21_CR2F;
370 pVBInfo->pCR46 = &XG21_CR46;
371 pVBInfo->pCR47 = &XG21_CR47;
372 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200373
374}
375
Bill Pembertone4147ab2010-06-17 13:10:50 -0400376unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530377 unsigned short ModeNo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200378{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530379 unsigned short ModeIdIndex;
380 /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */
381 struct vb_device_info VBINF;
382 struct vb_device_info *pVBInfo = &VBINF;
383 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
384 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
385 pVBInfo->IF_DEF_LVDS = 0;
386 pVBInfo->IF_DEF_CH7005 = 0;
387 pVBInfo->IF_DEF_LCDA = 1;
388 pVBInfo->IF_DEF_CH7017 = 0;
389 pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */
390 pVBInfo->IF_DEF_VideoCapture = 0;
391 pVBInfo->IF_DEF_ScaleLCD = 0;
392 pVBInfo->IF_DEF_OEMUtil = 0;
393 pVBInfo->IF_DEF_PWD = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200394
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530395 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
396 pVBInfo->IF_DEF_YPbPr = 0;
397 pVBInfo->IF_DEF_HiVision = 0;
398 pVBInfo->IF_DEF_CRT2Monitor = 0;
399 pVBInfo->VBType = 0; /*set VBType default 0*/
400 } else if (HwDeviceExtension->jChipType >= XG40) {
401 pVBInfo->IF_DEF_YPbPr = 1;
402 pVBInfo->IF_DEF_HiVision = 1;
403 pVBInfo->IF_DEF_CRT2Monitor = 1;
404 } else {
405 pVBInfo->IF_DEF_YPbPr = 1;
406 pVBInfo->IF_DEF_HiVision = 1;
407 pVBInfo->IF_DEF_CRT2Monitor = 0;
408 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200409
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530410 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
411 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
412 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
413 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
414 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
415 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
416 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
417 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
418 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
419 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
420 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
421 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
422 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
423 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04;
424 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10;
425 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12;
426 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
427 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200428
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530429 if (HwDeviceExtension->jChipType == XG21) { /* for x86 Linux, XG21 LVDS */
430 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
431 pVBInfo->IF_DEF_LVDS = 1;
432 }
433 if (HwDeviceExtension->jChipType == XG27) {
434 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
435 if (XGINew_GetReg1(pVBInfo->P3d4, 0x30) & 0x20)
436 pVBInfo->IF_DEF_LVDS = 1;
437 }
438 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200439
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530440 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
441 XGI_GetVBType(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200442
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530443 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
444 if (ModeNo & 0x80) {
445 ModeNo = ModeNo & 0x7F;
446 /* XGINew_flag_clearbuffer = 0; */
447 }
448 /* else {
449 XGINew_flag_clearbuffer = 1;
450 }
451 */
452 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200453
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530454 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
455 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200456
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530457 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200458
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530459 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200460
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530461 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
462 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
463 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
464 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
465 XGI_DisableBridge(HwDeviceExtension, pVBInfo);
466 /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200467
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530468 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
469 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
470 ModeIdIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200471
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530472 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
473 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
474 HwDeviceExtension, pVBInfo);
475 }
476 } else {
477 if (!(pVBInfo->VBInfo & SwitchToCRT2)) {
478 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
479 ModeIdIndex, pVBInfo);
480 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
481 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
482 HwDeviceExtension,
483 pVBInfo);
484 }
485 }
486 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200487
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530488 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) {
489 switch (HwDeviceExtension->ujVBChipID) {
490 case VB_CHIP_301:
491 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
492 pVBInfo); /*add for CRT2 */
493 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200494
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530495 case VB_CHIP_302:
496 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
497 pVBInfo); /*add for CRT2 */
498 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200499
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530500 default:
501 break;
502 }
503 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200504
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530505 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
506 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
507 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
508 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
509 } /* !XG20 */
510 else {
511 if (pVBInfo->IF_DEF_LVDS == 1)
512 if (!XGI_XG21CheckLVDSMode(ModeNo, ModeIdIndex, pVBInfo))
513 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200514
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530515 if (ModeNo <= 0x13) {
516 pVBInfo->ModeType
517 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag
518 & ModeInfoFlag;
519 } else {
520 pVBInfo->ModeType
521 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag
522 & ModeInfoFlag;
523 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200524
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530525 pVBInfo->SetFlag = 0;
526 if (pVBInfo->IF_DEF_CH7007 != 1)
527 pVBInfo->VBInfo = DisableCRT2Display;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200528
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530529 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200530
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530531 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex,
532 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200533
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530534 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
535 /*
536 if (HwDeviceExtension->jChipType == XG21)
537 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
538 */
539 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200540
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530541 /*
542 if (ModeNo <= 0x13) {
543 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
544 } else {
545 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
546 }
547 pVBInfo->ModeType = modeflag&ModeInfoFlag;
548 pVBInfo->SetFlag = 0x00;
549 pVBInfo->VBInfo = DisableCRT2Display;
550 temp = XGINew_CheckMemorySize(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200551
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530552 if (temp == 0)
553 return (0);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200554
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530555 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
556 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
557 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
558 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200559
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530560 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200561
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530562 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
563 XGI_LockCRT2(HwDeviceExtension, pVBInfo);
564 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200565
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530566 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200567}
568
Bill Pembertone4147ab2010-06-17 13:10:50 -0400569void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530570 unsigned short ModeNo, unsigned short ModeIdIndex,
571 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200572{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530573 unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200574
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530575 unsigned short XGINew_P3cc = pVBInfo->P3cc;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200576
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530577 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
578 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
579 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
580 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
581 XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
582 XGI_SetMiscRegs(StandTableIndex, pVBInfo);
583 XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
584 XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
585 XGI_SetGRCRegs(StandTableIndex, pVBInfo);
586 XGI_ClearExt1Regs(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200587
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530588 /* if (pVBInfo->IF_DEF_ExpLink) */
589 if (HwDeviceExtension->jChipType == XG27) {
590 if (pVBInfo->IF_DEF_LVDS == 0)
591 XGI_SetDefaultVCLK(pVBInfo);
592 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200593
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530594 temp = ~ProgrammingCRT2;
595 pVBInfo->SetFlag &= temp;
596 pVBInfo->SelectCRT2Rate = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200597
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530598 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
599 | VB_XGI302LV | VB_XGI301C)) {
600 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA
601 | SetInSlaveMode)) {
602 pVBInfo->SetFlag |= ProgrammingCRT2;
603 }
604 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200605
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530606 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
607 ModeIdIndex, pVBInfo);
608 if (RefreshRateTableIndex != 0xFFFF) {
609 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
610 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
611 pVBInfo, HwDeviceExtension);
612 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
613 RefreshRateTableIndex, pVBInfo);
614 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
615 HwDeviceExtension, pVBInfo);
616 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
617 RefreshRateTableIndex, pVBInfo);
618 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200619
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530620 if ((HwDeviceExtension->jChipType >= XG20)
621 && (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
622 if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
623 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x4E);
624 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE9);
625 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc);
626 XGINew_SetReg3(XGINew_P3cc, (b3CC |= 0x0C));
627 } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
628 == 0x0D)) {
629 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
630 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE3);
631 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc);
632 XGINew_SetReg3(XGINew_P3cc, (b3CC |= 0x0C));
633 }
634 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200635
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530636 if (HwDeviceExtension->jChipType >= XG21) {
637 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
638 if (temp & 0xA0) {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200639
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530640 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x20); *//* Enable write GPIOF */
641 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x48, ~0x20); *//* P. DWN */
642 /* XG21 CRT1 Timing */
643 if (HwDeviceExtension->jChipType == XG27)
644 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
645 RefreshRateTableIndex, pVBInfo);
646 else
647 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
648 RefreshRateTableIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200649
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530650 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
651 RefreshRateTableIndex);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200652
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530653 if (HwDeviceExtension->jChipType == XG27)
654 XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex,
655 ModeNo);
656 else
657 XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex,
658 ModeNo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200659
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530660 if (pVBInfo->IF_DEF_LVDS == 1) {
661 if (HwDeviceExtension->jChipType == XG27)
662 XGI_SetXG27LVDSPara(ModeNo,
663 ModeIdIndex, pVBInfo);
664 else
665 XGI_SetXG21LVDSPara(ModeNo,
666 ModeIdIndex, pVBInfo);
667 }
668 /* XGINew_SetRegOR(pVBInfo->P3d4, 0x48, 0x20); *//* P. ON */
669 }
670 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200671
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530672 pVBInfo->SetFlag &= (~ProgrammingCRT2);
673 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
674 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
675 RefreshRateTableIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200676
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530677 /* XGI_LoadCharacter(); //dif ifdef TVFont */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200678
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530679 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
680 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200681}
682
Bill Pemberton108afbf2010-06-17 13:10:47 -0400683unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530684 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200685{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530686 unsigned char index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200687
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530688 if (ModeNo <= 0x13)
689 index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
690 else {
691 if (pVBInfo->ModeType <= 0x02)
692 index = 0x1B; /* 02 -> ModeEGA */
693 else
694 index = 0x0F;
695 }
696 return index; /* Get pVBInfo->StandTable index */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200697}
698
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530699/*
700unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) {
701 return (0);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200702}
703*/
704
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530705/* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) {
706 return( 0 ) ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200707}
708*/
709
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400710void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530711 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200712{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530713 unsigned char tempah, SRdata;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200714
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530715 unsigned short i, modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200716
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530717 if (ModeNo <= 0x13)
718 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
719 else
720 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200721
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530722 XGINew_SetReg1(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
723 tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200724
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530725 i = SetCRT2ToLCDA;
726 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
727 tempah |= 0x01;
728 } else {
729 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
730 if (pVBInfo->VBInfo & SetInSlaveMode)
731 tempah |= 0x01;
732 }
733 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200734
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530735 tempah |= 0x20; /* screen off */
736 XGINew_SetReg1(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200737
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530738 for (i = 02; i <= 04; i++) {
739 SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; /* Get SR2,3,4 from file */
740 XGINew_SetReg1(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
741 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200742}
743
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530744void XGI_SetMiscRegs(unsigned short StandTableIndex,
745 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200746{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530747 unsigned char Miscdata;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200748
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530749 Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; /* Get Misc from file */
750 /*
751 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
752 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
753 Miscdata |= 0x0C;
754 }
755 }
756 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200757
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530758 XGINew_SetReg3(pVBInfo->P3c2, Miscdata); /* Set Misc(3c2) */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200759}
760
Bill Pembertone4147ab2010-06-17 13:10:50 -0400761void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530762 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200763{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530764 unsigned char CRTCdata;
765 unsigned short i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200766
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530767 CRTCdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
768 CRTCdata &= 0x7f;
769 XGINew_SetReg1(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200770
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530771 for (i = 0; i <= 0x18; i++) {
772 CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; /* Get CRTC from file */
773 XGINew_SetReg1(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
774 }
775 /*
776 if ((HwDeviceExtension->jChipType == XGI_630) && (HwDeviceExtension->jChipRevision == 0x30)) {
777 if (pVBInfo->VBInfo & SetInSlaveMode) {
778 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
779 XGINew_SetReg1(pVBInfo->P3d4, 0x18, 0xFE);
780 }
781 }
782 }
783 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200784}
785
Bill Pemberton82d6eb52010-06-17 13:10:46 -0400786void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530787 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200788{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530789 unsigned char ARdata;
790 unsigned short i, modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200791
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530792 if (ModeNo <= 0x13)
793 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
794 else
795 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200796
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530797 for (i = 0; i <= 0x13; i++) {
798 ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
799 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
800 if (i == 0x13) {
801 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
802 ARdata = 0;
803 } else {
804 if (pVBInfo->VBInfo & (SetCRT2ToTV
805 | SetCRT2ToLCD)) {
806 if (pVBInfo->VBInfo
807 & SetInSlaveMode)
808 ARdata = 0;
809 }
810 }
811 }
812 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200813
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530814 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
815 XGINew_SetReg3(pVBInfo->P3c0, i); /* set index */
816 XGINew_SetReg3(pVBInfo->P3c0, ARdata); /* set data */
817 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200818
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530819 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
820 XGINew_SetReg3(pVBInfo->P3c0, 0x14); /* set index */
821 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data */
822 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
823 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200824}
825
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530826void XGI_SetGRCRegs(unsigned short StandTableIndex,
827 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200828{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530829 unsigned char GRdata;
830 unsigned short i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200831
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530832 for (i = 0; i <= 0x08; i++) {
833 GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; /* Get GR from file */
834 XGINew_SetReg1(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
835 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200836
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530837 if (pVBInfo->ModeType > ModeVGA) {
838 GRdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3ce, 0x05);
839 GRdata &= 0xBF; /* 256 color disable */
840 XGINew_SetReg1(pVBInfo->P3ce, 0x05, GRdata);
841 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200842}
843
Bill Pemberton80adad82010-06-17 13:10:51 -0400844void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200845{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530846 unsigned short i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200847
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530848 for (i = 0x0A; i <= 0x0E; i++)
849 XGINew_SetReg1(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200850}
851
Bill Pemberton80adad82010-06-17 13:10:51 -0400852unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200853{
854
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530855 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
856 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
857 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200858
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530859 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
860 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
861 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200862
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530863 XGINew_SetRegAND(pVBInfo->P3c4, 0x31, ~0x30);
864 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200865}
866
Bill Pembertone4147ab2010-06-17 13:10:50 -0400867unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530868 unsigned short ModeNo, unsigned short ModeIdIndex,
869 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200870{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530871 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
872 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
873 0x01, 0x01 };
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200874
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530875 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200876
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530877 if (ModeNo <= 0x13)
878 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
879 else
880 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200881
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530882 if (pVBInfo->IF_DEF_CH7005 == 1) {
883 if (pVBInfo->VBInfo & SetCRT2ToTV) {
884 if (modeflag & HalfDCLK)
885 return 0;
886 }
887 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200888
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530889 if (ModeNo < 0x14)
890 return 0xFFFF;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200891
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530892 index = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
893 index = index >> pVBInfo->SelectCRT2Rate;
894 index &= 0x0F;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200895
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530896 if (pVBInfo->LCDInfo & LCDNonExpanding)
897 index = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200898
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530899 if (index > 0)
900 index--;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200901
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530902 if (pVBInfo->SetFlag & ProgrammingCRT2) {
903 if (pVBInfo->IF_DEF_CH7005 == 1) {
904 if (pVBInfo->VBInfo & SetCRT2ToTV)
905 index = 0;
906 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200907
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530908 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
909 if (pVBInfo->IF_DEF_LVDS == 0) {
910 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
911 | VB_XGI301LV | VB_XGI302LV
912 | VB_XGI301C))
913 temp
914 = LCDARefreshIndex[pVBInfo->LCDResInfo
915 & 0x0F]; /* 301b */
916 else
917 temp
918 = LCDRefreshIndex[pVBInfo->LCDResInfo
919 & 0x0F];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200920
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530921 if (index > temp)
922 index = temp;
923 } else {
924 index = 0;
925 }
926 }
927 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200928
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530929 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
930 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
931 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
932 /*
933 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & XG2xNotSupport) {
934 index++;
935 }
936 */
937 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800)
938 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
939 == 600)) {
940 index++;
941 }
942 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
943 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024)
944 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
945 == 768)) {
946 index++;
947 }
948 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280)
949 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
950 == 1024)) {
951 index++;
952 }
953 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200954
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530955 i = 0;
956 do {
957 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].ModeID
958 != ModeNo)
959 break;
960 temp
961 = pVBInfo->RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
962 temp &= ModeInfoFlag;
963 if (temp < pVBInfo->ModeType)
964 break;
965 i++;
966 index--;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200967
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530968 } while (index != 0xFFFF);
969 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
970 if (pVBInfo->VBInfo & SetInSlaveMode) {
971 temp
972 = pVBInfo->RefIndex[RefreshRateTableIndex
973 + i - 1].Ext_InfoFlag;
974 if (temp & InterlaceMode)
975 i++;
976 }
977 }
978 i--;
979 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
980 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
981 RefreshRateTableIndex, &i, pVBInfo);
982 }
983 return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200984}
985
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530986unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
987 unsigned short ModeIdIndex,
988 unsigned short RefreshRateTableIndex, unsigned short *i,
989 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200990{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530991 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200992
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530993 if (ModeNo <= 0x13)
994 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
995 else
996 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +0200997
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530998 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
999 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
1000 tempax = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001001
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301002 if (pVBInfo->IF_DEF_LVDS == 0) {
1003 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
1004 tempax |= SupportRAMDAC2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001005
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301006 if (pVBInfo->VBType & VB_XGI301C)
1007 tempax |= SupportCRT2in301C;
1008 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001009
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301010 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */
1011 tempax |= SupportLCD;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001012
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301013 if (pVBInfo->LCDResInfo != Panel1280x1024) {
1014 if (pVBInfo->LCDResInfo != Panel1280x960) {
1015 if (pVBInfo->LCDInfo & LCDNonExpanding) {
1016 if (resinfo >= 9) {
1017 tempax = 0;
1018 return 0;
1019 }
1020 }
1021 }
1022 }
1023 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001024
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301025 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
1026 if ((pVBInfo->VBType & VB_XGI301LV)
1027 && (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
1028 tempax |= SupportYPbPr;
1029 if (pVBInfo->VBInfo & SetInSlaveMode) {
1030 if (resinfo == 4)
1031 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001032
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301033 if (resinfo == 3)
1034 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001035
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301036 if (resinfo > 7)
1037 return 0;
1038 }
1039 } else {
1040 tempax |= SupportHiVisionTV;
1041 if (pVBInfo->VBInfo & SetInSlaveMode) {
1042 if (resinfo == 4)
1043 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001044
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301045 if (resinfo == 3) {
1046 if (pVBInfo->SetFlag
1047 & TVSimuMode)
1048 return 0;
1049 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001050
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301051 if (resinfo > 7)
1052 return 0;
1053 }
1054 }
1055 } else {
1056 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
1057 | SetCRT2ToSVIDEO | SetCRT2ToSCART
1058 | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) {
1059 tempax |= SupportTV;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001060
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301061 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
1062 | VB_XGI301LV | VB_XGI302LV
1063 | VB_XGI301C)) {
1064 tempax |= SupportTV1024;
1065 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001066
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301067 if (!(pVBInfo->VBInfo & SetPALTV)) {
1068 if (modeflag & NoSupportSimuTV) {
1069 if (pVBInfo->VBInfo
1070 & SetInSlaveMode) {
1071 if (!(pVBInfo->VBInfo
1072 & SetNotSimuMode)) {
1073 return 0;
1074 }
1075 }
1076 }
1077 }
1078 }
1079 }
1080 } else { /* for LVDS */
1081 if (pVBInfo->IF_DEF_CH7005 == 1) {
1082 if (pVBInfo->VBInfo & SetCRT2ToTV)
1083 tempax |= SupportCHTV;
1084 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001085
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301086 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
1087 tempax |= SupportLCD;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001088
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301089 if (resinfo > 0x08)
1090 return 0; /* 1024x768 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001091
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301092 if (pVBInfo->LCDResInfo < Panel1024x768) {
1093 if (resinfo > 0x07)
1094 return 0; /* 800x600 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001095
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301096 if (resinfo == 0x04)
1097 return 0; /* 512x384 */
1098 }
1099 }
1100 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001101
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301102 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == tempbx; (*i)--) {
1103 infoflag
1104 = pVBInfo->RefIndex[RefreshRateTableIndex
1105 + (*i)].Ext_InfoFlag;
1106 if (infoflag & tempax)
1107 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001108
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301109 if ((*i) == 0)
1110 break;
1111 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001112
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301113 for ((*i) = 0;; (*i)++) {
1114 infoflag
1115 = pVBInfo->RefIndex[RefreshRateTableIndex
1116 + (*i)].Ext_InfoFlag;
1117 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
1118 != tempbx) {
1119 return 0;
1120 }
1121
1122 if (infoflag & tempax)
1123 return 1;
1124 }
1125 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001126}
1127
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301128void XGI_SetSync(unsigned short RefreshRateTableIndex,
1129 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001130{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301131 unsigned short sync, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001132
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301133 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; /* di+0x00 */
1134 sync &= 0xC0;
1135 temp = 0x2F;
1136 temp |= sync;
1137 XGINew_SetReg3(pVBInfo->P3c2, temp); /* Set Misc(3c2) */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001138}
1139
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001140void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301141 unsigned short RefreshRateTableIndex,
1142 struct vb_device_info *pVBInfo,
1143 struct xgi_hw_device_info *HwDeviceExtension)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001144{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301145 unsigned char index, data;
1146 unsigned short i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001147
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301148 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */
1149 index = index & IndexMask;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001150
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301151 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1152 data &= 0x7F;
1153 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001154
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301155 for (i = 0; i < 8; i++)
1156 pVBInfo->TimingH[0].data[i]
1157 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001158
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301159 for (i = 0; i < 7; i++)
1160 pVBInfo->TimingV[0].data[i]
1161 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001162
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301163 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001164
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301165 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001166
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301167 if (pVBInfo->ModeType > 0x03)
1168 XGINew_SetReg1(pVBInfo->P3d4, 0x14, 0x4F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001169}
1170
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301171void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
1172 struct xgi_hw_device_info *HwDeviceExtension)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001173{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301174 unsigned char data, data1, pushax;
1175 unsigned short i, j;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001176
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301177 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
1178 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
1179 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001180
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301181 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
1182 data &= 0x7F;
1183 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001184
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301185 data = pVBInfo->TimingH[0].data[0];
1186 XGINew_SetReg1(pVBInfo->P3d4, 0, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001187
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301188 for (i = 0x01; i <= 0x04; i++) {
1189 data = pVBInfo->TimingH[0].data[i];
1190 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 1), data);
1191 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001192
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301193 for (i = 0x05; i <= 0x06; i++) {
1194 data = pVBInfo->TimingH[0].data[i];
1195 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i + 6), data);
1196 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001197
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301198 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1199 j &= 0x1F;
1200 data = pVBInfo->TimingH[0].data[7];
1201 data &= 0xE0;
1202 data |= j;
1203 XGINew_SetReg1(pVBInfo->P3c4, 0x0e, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001204
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301205 if (HwDeviceExtension->jChipType >= XG20) {
1206 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x04);
1207 data = data - 1;
1208 XGINew_SetReg1(pVBInfo->P3d4, 0x04, data);
1209 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x05);
1210 data1 = data;
1211 data1 &= 0xE0;
1212 data &= 0x1F;
1213 if (data == 0) {
1214 pushax = data;
1215 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4,
1216 0x0c);
1217 data &= 0xFB;
1218 XGINew_SetReg1(pVBInfo->P3c4, 0x0c, data);
1219 data = pushax;
1220 }
1221 data = data - 1;
1222 data |= data1;
1223 XGINew_SetReg1(pVBInfo->P3d4, 0x05, data);
1224 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
1225 data = data >> 5;
1226 data = data + 3;
1227 if (data > 7)
1228 data = data - 7;
1229 data = data << 5;
1230 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0e, ~0xE0, data);
1231 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001232}
1233
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301234void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo,
1235 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001236{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301237 unsigned char data;
1238 unsigned short i, j;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001239
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301240 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
1241 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
1242 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001243
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301244 for (i = 0x00; i <= 0x01; i++) {
1245 data = pVBInfo->TimingV[0].data[i];
1246 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 6), data);
1247 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001248
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301249 for (i = 0x02; i <= 0x03; i++) {
1250 data = pVBInfo->TimingV[0].data[i];
1251 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
1252 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001253
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301254 for (i = 0x04; i <= 0x05; i++) {
1255 data = pVBInfo->TimingV[0].data[i];
1256 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
1257 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001258
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301259 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0a);
1260 j &= 0xC0;
1261 data = pVBInfo->TimingV[0].data[6];
1262 data &= 0x3F;
1263 data |= j;
1264 XGINew_SetReg1(pVBInfo->P3c4, 0x0a, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001265
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301266 data = pVBInfo->TimingV[0].data[6];
1267 data &= 0x80;
1268 data = data >> 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001269
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301270 if (ModeNo <= 0x13)
1271 i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1272 else
1273 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001274
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301275 i &= DoubleScanMode;
1276 if (i)
1277 data |= 0x80;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001278
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301279 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x09);
1280 j &= 0x5F;
1281 data |= j;
1282 XGINew_SetReg1(pVBInfo->P3d4, 0x09, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001283}
1284
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001285/* --------------------------------------------------------------------- */
1286/* Function : XGI_SetXG21CRTC */
1287/* Input : Stand or enhance CRTC table */
1288/* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
1289/* Description : Set LCD timing */
1290/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001291void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301292 unsigned short RefreshRateTableIndex,
1293 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001294{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301295 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
1296 unsigned short Temp1, Temp2, Temp3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001297
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301298 if (ModeNo <= 0x13) {
1299 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
1300 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
1301 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
1302 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
1303 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
1304 Tempcx = Tempax;
1305 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
1306 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1307 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
1308 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
1309 Tempdx <<= 2; /* Tempdx << 2 */
1310 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
1311 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001312
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301313 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR16 VRS */
1314 Tempbx = Tempax; /* Tempbx=Tempax */
1315 Tempax &= 0x01; /* Tempax: VRS[0] */
1316 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
1317 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax: CR7 VRS */
1318 Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
1319 Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
1320 Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
1321 Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
1322 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempdx); /* SR34[7:0]: VRS[8:1] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001323
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301324 Temp1 = Tempcx << 1; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
1325 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
1326 Tempax &= 0x80; /* Tempax[7]: CR7[7] */
1327 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
1328 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001329
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301330 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR16 VRE */
1331 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1332 Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
1333 Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
1334 Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
1335 if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
1336 Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
1337 Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
1338 Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
1339 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
1340 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
1341 Temp1 >>= 9; /* [10:9]->[1:0] */
1342 Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
1343 Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
1344 Tempax &= 0x7F;
1345 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
1346 } else {
1347 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
1348 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1349 Tempcx = Tempax; /* Tempcx: HRS */
1350 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001351
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301352 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
1353 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
1354 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
1355 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
1356 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001357
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301358 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
1359 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001360
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301361 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
1362 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
1363 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
1364 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001365
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301366 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
1367 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001368
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301369 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
1370 if (Tempax < Tempcx) /* HRE < HRS */
1371 Temp2 |= 0x40; /* Temp2 + 0x40 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001372
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301373 Temp2 &= 0xFF;
1374 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
1375 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
1376 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
1377 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
1378 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F D[7:2]->HRE, D[1:0]->HRS */
1379 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001380
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301381 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
1382 Tempbx = Tempax; /* Tempbx: VRS */
1383 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
1384 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
1385 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[2][7] VRE */
1386 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
1387 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
1388 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
1389 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
1390 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001391
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301392 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
1393 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
1394 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
1395 Tempax &= 0x80;
1396 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
1397 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
1398 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SRA */
1399 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
1400 Temp2 = Tempax;
1401 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
1402 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001403
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301404 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
1405 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1406 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SRA */
1407 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
1408 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
1409 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
1410 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
1411 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001412
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301413 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
1414 if (Tempax < Temp3) /* VRE < VRS */
1415 Temp2 |= 0x20; /* VRE + 0x20 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001416
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301417 Temp2 &= 0xFF;
1418 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
1419 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
1420 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
1421 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
1422 Tempbx = (unsigned char) Temp1;
1423 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
1424 Tempax &= 0x7F;
1425 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
1426 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001427}
1428
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001429void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301430 unsigned short RefreshRateTableIndex,
1431 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001432{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001433 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001434
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301435 if (ModeNo <= 0x13) {
1436 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
1437 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
1438 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
1439 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
1440 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
1441 Tempcx = Tempax;
1442 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
1443 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
1444 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
1445 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
1446 Tempdx <<= 2; /* Tempdx << 2 */
1447 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
1448 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001449
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301450 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR10 VRS */
1451 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
1452 Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
1453 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
1454 Tempbx = Tempax; /* Tempbx=CR07 */
1455 Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
1456 Tempax >>= 2;
1457 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35 D[0]->VRS D[8] */
1458 Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
1459 Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001460
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301461 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR11 VRE */
1462 Tempax &= 0x0F; /* Tempax: VRE[3:0] */
1463 Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
1464 Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
1465 Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
1466 if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
1467 Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
1468 Tempax = (unsigned char) Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
1469 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
1470 Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
1471 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F D[7:2]->VRE D[5:0] */
1472 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); /* SR35 D[2:1]->VRS[10:9] */
1473 } else {
1474 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
1475 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1476 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
1477 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001478
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301479 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
1480 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1481 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001482
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301483 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
1484 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
1485 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001486
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301487 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
1488 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
1489 Tempax <<= 3; /* Tempax[5]: HRE[5] */
1490 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001491
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301492 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
1493 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001494
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301495 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
1496 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
1497 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
1498 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001499
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301500 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
1501 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
1502 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
1503 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
1504 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
1505 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001506
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301507 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
1508 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001509
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301510 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
1511 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[7][2] VRS[9][8] */
1512 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
1513 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
1514 Tempax >>= 2; /* Tempax[0]: VRS[8] */
1515 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35[0]: VRS[8] */
1516 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
1517 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
1518 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SR0A */
1519 Tempax &= 0x08; /* SR0A[3] VRS[10] */
1520 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001521
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301522 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
1523 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
1524 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SR0A */
1525 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
1526 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
1527 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
1528 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
1529 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
1530 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001531
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301532 if (Tempbx <= Tempcx) /* VRE <= VRS */
1533 Tempbx |= 0x20; /* VRE + 0x20 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001534
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301535 Tempax = (Tempbx << 2) & 0xFF; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
1536 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F[7:2]:VRE[5:0] */
1537 Tempax = Tempcx >> 8;
1538 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, Tempax); /* SR35[2:0]:VRS[10:8] */
1539 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001540}
1541
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001542/* --------------------------------------------------------------------- */
1543/* Function : XGI_SetXG21LCD */
1544/* Input : */
1545/* Output : FCLK duty cycle, FCLK delay compensation */
1546/* Description : All values set zero */
1547/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04001548void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301549 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001550{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001551 unsigned short Data, Temp, b3CC;
1552 unsigned short XGI_P3cc;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001553
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301554 XGI_P3cc = pVBInfo->P3cc;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001555
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301556 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
1557 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
1558 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
1559 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
1560 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1561 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1562 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1563 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1564 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1565 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001566
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301567 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001568
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301569 if (Temp & 0x01) {
1570 XGINew_SetRegOR(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */
1571 XGINew_SetRegOR(pVBInfo->P3c4, 0x09, 0x40);
1572 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001573
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301574 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001575
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301576 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20);
1577 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001578
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301579 if (ModeNo <= 0x13) {
1580 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1581 if (b3CC & 0x40)
1582 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1583 if (b3CC & 0x80)
1584 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1585 } else {
1586 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1587 if (Data & 0x4000)
1588 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1589 if (Data & 0x8000)
1590 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1591 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001592}
1593
Bill Pemberton80adad82010-06-17 13:10:51 -04001594void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301595 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001596{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301597 unsigned short Data, Temp, b3CC;
1598 unsigned short XGI_P3cc;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001599
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301600 XGI_P3cc = pVBInfo->P3cc;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001601
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301602 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
1603 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
1604 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
1605 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001606
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301607 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
1608 if ((Temp & 0x03) == 0) { /* dual 12 */
1609 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x13);
1610 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x13);
1611 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001612
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301613 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1614 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1615 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1616 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1617 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1618 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001619
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301620 XGI_SetXG27FPBits(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001621
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301622 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001623
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301624 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
1625 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001626
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301627 if (ModeNo <= 0x13) {
1628 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1629 if (b3CC & 0x40)
1630 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1631 if (b3CC & 0x80)
1632 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1633 } else {
1634 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1635 if (Data & 0x4000)
1636 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1637 if (Data & 0x8000)
1638 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1639 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001640}
1641
1642/* --------------------------------------------------------------------- */
1643/* Function : XGI_UpdateXG21CRTC */
1644/* Input : */
1645/* Output : CRT1 CRTC */
1646/* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1647/* --------------------------------------------------------------------- */
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301648void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo,
1649 unsigned short RefreshRateTableIndex)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001650{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301651 int i, index = -1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001652
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301653 XGINew_SetRegAND(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
1654 if (ModeNo <= 0x13) {
1655 for (i = 0; i < 12; i++) {
1656 if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
1657 index = i;
1658 }
1659 } else {
1660 if (ModeNo == 0x2E
1661 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1662 == RES640x480x60))
1663 index = 12;
1664 else if (ModeNo == 0x2E
1665 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1666 == RES640x480x72))
1667 index = 13;
1668 else if (ModeNo == 0x2F)
1669 index = 14;
1670 else if (ModeNo == 0x50)
1671 index = 15;
1672 else if (ModeNo == 0x59)
1673 index = 16;
1674 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001675
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301676 if (index != -1) {
1677 XGINew_SetReg1(pVBInfo->P3d4, 0x02,
1678 pVBInfo->UpdateCRT1[index].CR02);
1679 XGINew_SetReg1(pVBInfo->P3d4, 0x03,
1680 pVBInfo->UpdateCRT1[index].CR03);
1681 XGINew_SetReg1(pVBInfo->P3d4, 0x15,
1682 pVBInfo->UpdateCRT1[index].CR15);
1683 XGINew_SetReg1(pVBInfo->P3d4, 0x16,
1684 pVBInfo->UpdateCRT1[index].CR16);
1685 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001686}
1687
Bill Pembertone4147ab2010-06-17 13:10:50 -04001688void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301689 unsigned short ModeNo, unsigned short ModeIdIndex,
1690 unsigned short RefreshRateTableIndex,
1691 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001692{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001693 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001694
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301695 unsigned char data;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001696
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301697 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001698
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301699 if (ModeNo <= 0x13) {
1700 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1701 tempax = pVBInfo->StResInfo[resindex].HTotal;
1702 tempbx = pVBInfo->StResInfo[resindex].VTotal;
1703 } else {
1704 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1705 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
1706 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
1707 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001708
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301709 if (modeflag & HalfDCLK)
1710 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001711
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301712 if (ModeNo > 0x13) {
1713 if (modeflag & HalfDCLK)
1714 tempax = tempax << 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001715
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301716 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001717
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301718 if (temp & InterlaceMode)
1719 tempbx = tempbx >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001720
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301721 if (modeflag & DoubleScanMode)
1722 tempbx = tempbx << 1;
1723 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001724
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301725 tempcx = 8;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001726
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301727 /* if (!(modeflag & Charx8Dot)) */
1728 /* tempcx = 9; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001729
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301730 tempax /= tempcx;
1731 tempax -= 1;
1732 tempbx -= 1;
1733 tempcx = tempax;
1734 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1735 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1736 data &= 0x7F;
1737 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1738 XGINew_SetReg1(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
1739 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0b, ~0x0c,
1740 (unsigned short) ((tempcx & 0x0ff00) >> 10));
1741 XGINew_SetReg1(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
1742 tempax = 0;
1743 tempbx = tempbx >> 8;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001744
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301745 if (tempbx & 0x01)
1746 tempax |= 0x02;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001747
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301748 if (tempbx & 0x02)
1749 tempax |= 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001750
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301751 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x42, tempax);
1752 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x07);
1753 data &= 0xFF;
1754 tempax = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001755
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301756 if (tempbx & 0x04)
1757 tempax |= 0x02;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001758
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301759 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
1760 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001761}
1762
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001763unsigned short XGI_GetResInfo(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301764 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001765{
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001766 unsigned short resindex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001767
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301768 if (ModeNo <= 0x13)
1769 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1770 else
1771 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1772 return resindex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001773}
1774
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301775void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex,
1776 unsigned short RefreshRateTableIndex,
1777 struct xgi_hw_device_info *HwDeviceExtension,
1778 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001779{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301780 unsigned short temp, ah, al, temp2, i, DisplayUnit;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001781
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301782 /* GetOffset */
1783 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
1784 temp = temp >> 8;
1785 temp = pVBInfo->ScreenOffset[temp];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001786
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301787 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1788 temp2 &= InterlaceMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001789
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301790 if (temp2)
1791 temp = temp << 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001792
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301793 temp2 = pVBInfo->ModeType - ModeEGA;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001794
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301795 switch (temp2) {
1796 case 0:
1797 temp2 = 1;
1798 break;
1799 case 1:
1800 temp2 = 2;
1801 break;
1802 case 2:
1803 temp2 = 4;
1804 break;
1805 case 3:
1806 temp2 = 4;
1807 break;
1808 case 4:
1809 temp2 = 6;
1810 break;
1811 case 5:
1812 temp2 = 8;
1813 break;
1814 default:
1815 break;
1816 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001817
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301818 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1819 temp = temp * temp2 + temp2 / 2;
1820 else
1821 temp *= temp2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001822
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301823 /* SetOffset */
1824 DisplayUnit = temp;
1825 temp2 = temp;
1826 temp = temp >> 8; /* ah */
1827 temp &= 0x0F;
1828 i = XGINew_GetReg1(pVBInfo->P3c4, 0x0E);
1829 i &= 0xF0;
1830 i |= temp;
1831 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, i);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001832
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301833 temp = (unsigned char) temp2;
1834 temp &= 0xFF; /* al */
1835 XGINew_SetReg1(pVBInfo->P3d4, 0x13, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001836
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301837 /* SetDisplayUnit */
1838 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1839 temp2 &= InterlaceMode;
1840 if (temp2)
1841 DisplayUnit >>= 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001842
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301843 DisplayUnit = DisplayUnit << 5;
1844 ah = (DisplayUnit & 0xff00) >> 8;
1845 al = DisplayUnit & 0x00ff;
1846 if (al == 0)
1847 ah += 1;
1848 else
1849 ah += 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001850
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301851 if (HwDeviceExtension->jChipType >= XG20)
1852 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1853 ah -= 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001854
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301855 XGINew_SetReg1(pVBInfo->P3c4, 0x10, ah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001856}
1857
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001858void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301859 struct xgi_hw_device_info *HwDeviceExtension,
1860 unsigned short RefreshRateTableIndex,
1861 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001862{
Bill Pemberton108afbf2010-06-17 13:10:47 -04001863 unsigned char index, data;
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301864 unsigned short vclkindex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001865
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301866 if (pVBInfo->IF_DEF_LVDS == 1) {
1867 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1868 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1869 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1870 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1871 pVBInfo->VCLKData[index].SR2B);
1872 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1873 pVBInfo->VCLKData[index].SR2C);
1874 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1875 } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
1876 | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1877 & SetCRT2ToLCDA)) {
1878 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1879 RefreshRateTableIndex, HwDeviceExtension,
1880 pVBInfo);
1881 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1882 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1883 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1884 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1885 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1886 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1887 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1888 } else {
1889 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1890 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1891 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1892 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1893 pVBInfo->VCLKData[index].SR2B);
1894 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1895 pVBInfo->VCLKData[index].SR2C);
1896 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1897 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001898
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301899 if (HwDeviceExtension->jChipType >= XG20) {
1900 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & HalfDCLK) {
1901 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2B);
1902 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1903 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2C);
1904 index = data;
1905 index &= 0xE0;
1906 data &= 0x1F;
1907 data = data << 1;
1908 data += 1;
1909 data |= index;
1910 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1911 }
1912 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001913}
1914
Bill Pemberton82d6eb52010-06-17 13:10:46 -04001915void XGI_SetCRT1FIFO(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301916 struct xgi_hw_device_info *HwDeviceExtension,
1917 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001918{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301919 unsigned short data;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001920
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301921 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1922 data &= 0xfe;
1923 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001924
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301925 if (ModeNo > 0x13) {
1926 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x34);
1927 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1928 data &= 0xC0;
1929 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x30);
1930 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1931 data |= 0x01;
1932 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data);
1933 } else {
1934 if (HwDeviceExtension->jChipType == XG27) {
1935 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x0E);
1936 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1937 data &= 0xC0;
1938 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x20);
1939 } else {
1940 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0xAE);
1941 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1942 data &= 0xF0;
1943 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data);
1944 }
1945 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001946
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301947 if (HwDeviceExtension->jChipType == XG21)
1948 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001949}
1950
Bill Pembertone4147ab2010-06-17 13:10:50 -04001951void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301952 unsigned short ModeNo, unsigned short ModeIdIndex,
1953 unsigned short RefreshRateTableIndex,
1954 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001955{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301956 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1957 xres;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001958
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301959 if (ModeNo > 0x13) {
1960 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1961 infoflag
1962 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1963 } else
1964 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001965
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301966 if (XGINew_GetReg1(pVBInfo->P3d4, 0x31) & 0x01)
1967 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001968
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301969 if (ModeNo > 0x13)
1970 data = infoflag;
1971 else
1972 data = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001973
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301974 data2 = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001975
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301976 if (ModeNo > 0x13) {
1977 if (pVBInfo->ModeType > 0x02) {
1978 data2 |= 0x02;
1979 data3 = pVBInfo->ModeType - ModeVGA;
1980 data3 = data3 << 2;
1981 data2 |= data3;
1982 }
1983 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001984
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301985 data &= InterlaceMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001986
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301987 if (data)
1988 data2 |= 0x20;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001989
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301990 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1991 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
1992 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1993 if (ModeNo <= 0x13)
1994 xres = pVBInfo->StResInfo[resindex].HTotal;
1995 else
1996 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02001997
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05301998 data = 0x0000;
1999 if (infoflag & InterlaceMode) {
2000 if (xres == 1024)
2001 data = 0x0035;
2002 else if (xres == 1280)
2003 data = 0x0048;
2004 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002005
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302006 data2 = data & 0x00FF;
2007 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFF, data2);
2008 data2 = (data & 0xFF00) >> 8;
2009 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFC, data2);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002010
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302011 if (modeflag & HalfDCLK)
2012 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002013
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302014 data2 = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002015
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302016 if (modeflag & LineCompareOff)
2017 data2 |= 0x08;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002018
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302019 if (ModeNo > 0x13) {
2020 if (pVBInfo->ModeType == ModeEGA)
2021 data2 |= 0x40;
2022 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002023
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302024 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0F, ~0x48, data2);
2025 data = 0x60;
2026 if (pVBInfo->ModeType != ModeText) {
2027 data = data ^ 0x60;
2028 if (pVBInfo->ModeType != ModeEGA)
2029 data = data ^ 0xA0;
2030 }
2031 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x21, 0x1F, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002032
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302033 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
2034 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002035
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302036 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
2037 /* if (XGINew_IF_DEF_NEW_LOWRES) */
2038 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); //030305 fix lowresolution bug */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002039
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302040 data = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002041
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302042 if (HwDeviceExtension->jChipType == XG27) {
2043 if (data & 0x40)
2044 data = 0x2c;
2045 else
2046 data = 0x6c;
2047 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
2048 XGINew_SetRegOR(pVBInfo->P3d4, 0x51, 0x10);
2049 } else if (HwDeviceExtension->jChipType >= XG20) {
2050 if (data & 0x40)
2051 data = 0x33;
2052 else
2053 data = 0x73;
2054 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
2055 XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0x02);
2056 } else {
2057 if (data & 0x40)
2058 data = 0x2c;
2059 else
2060 data = 0x6c;
2061 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
2062 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002063
2064}
2065
Bill Pembertone4147ab2010-06-17 13:10:50 -04002066void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302067 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
2068 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002069{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302070 unsigned short data, data2 = 0;
2071 short VCLK;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002072
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302073 unsigned char index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002074
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302075 if (ModeNo <= 0x13)
2076 VCLK = 0;
2077 else {
2078 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2079 index &= IndexMask;
2080 VCLK = pVBInfo->VCLKData[index].CLOCK;
2081 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002082
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302083 data = XGINew_GetReg1(pVBInfo->P3c4, 0x32);
2084 data &= 0xf3;
2085 if (VCLK >= 200)
2086 data |= 0x0c; /* VCLK > 200 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002087
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302088 if (HwDeviceExtension->jChipType >= XG20)
2089 data &= ~0x04; /* 2 pixel mode */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002090
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302091 XGINew_SetReg1(pVBInfo->P3c4, 0x32, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002092
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302093 if (HwDeviceExtension->jChipType < XG20) {
2094 data = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
2095 data &= 0xE7;
2096 if (VCLK < 200)
2097 data |= 0x10;
2098 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, data);
2099 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002100
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302101 /* Jong for Adavantech LCD ripple issue
2102 if ((VCLK >= 0) && (VCLK < 135))
2103 data2 = 0x03;
2104 else if ((VCLK >= 135) && (VCLK < 160))
2105 data2 = 0x02;
2106 else if ((VCLK >= 160) && (VCLK < 260))
2107 data2 = 0x01;
2108 else if (VCLK > 260)
2109 data2 = 0x00;
2110 */
2111 data2 = 0x00;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002112
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302113 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x07, 0xFC, data2);
2114 if (HwDeviceExtension->jChipType >= XG27)
2115 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002116
2117}
2118
2119
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302120/*
2121void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002122{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302123 unsigned short modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002124
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302125 if (ModeNo > 0x13)
2126 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2127 else
2128 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002129
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302130 if (ModeNo > 0x13) {
2131 if (modeflag & DoubleScanMode) {
2132 if (modeflag & HalfDCLK) {
2133 if (pVBInfo->VBType & VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
2134 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
2135 if (pVBInfo->VBInfo & SetInSlaveMode) {
2136 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
2137 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
2138 return;
2139 }
2140 }
2141 }
2142 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0xff, 0x80);
2143 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
2144 return;
2145 }
2146 }
2147 }
2148 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002149}
2150*/
2151
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302152void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
2153 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002154{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302155 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
2156 ah, dh, *table = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002157
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302158 if (ModeNo <= 0x13)
2159 data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2160 else
2161 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002162
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302163 data &= DACInfoFlag;
2164 time = 64;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002165
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302166 if (data == 0x00)
2167 table = XGINew_MDA_DAC;
2168 else if (data == 0x08)
2169 table = XGINew_CGA_DAC;
2170 else if (data == 0x10)
2171 table = XGINew_EGA_DAC;
2172 else if (data == 0x18) {
2173 time = 256;
2174 table = XGINew_VGA_DAC;
2175 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002176
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302177 if (time == 256)
2178 j = 16;
2179 else
2180 j = time;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002181
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302182 XGINew_SetReg3(pVBInfo->P3c6, 0xFF);
2183 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002184
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302185 for (i = 0; i < j; i++) {
2186 data = table[i];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002187
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302188 for (k = 0; k < 3; k++) {
2189 data2 = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002190
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302191 if (data & 0x01)
2192 data2 = 0x2A;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002193
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302194 if (data & 0x02)
2195 data2 += 0x15;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002196
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302197 XGINew_SetReg3(pVBInfo->P3c9, data2);
2198 data = data >> 2;
2199 }
2200 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002201
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302202 if (time == 256) {
2203 for (i = 16; i < 32; i++) {
2204 data = table[i];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002205
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302206 for (k = 0; k < 3; k++)
2207 XGINew_SetReg3(pVBInfo->P3c9, data);
2208 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002209
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302210 si = 32;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002211
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302212 for (m = 0; m < 9; m++) {
2213 di = si;
2214 bx = si + 0x04;
2215 dl = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002216
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302217 for (n = 0; n < 3; n++) {
2218 for (o = 0; o < 5; o++) {
2219 dh = table[si];
2220 ah = table[di];
2221 al = table[bx];
2222 si++;
2223 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
2224 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002225
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302226 si -= 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002227
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302228 for (o = 0; o < 3; o++) {
2229 dh = table[bx];
2230 ah = table[di];
2231 al = table[si];
2232 si--;
2233 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
2234 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002235
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302236 dl++;
2237 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002238
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302239 si += 5;
2240 }
2241 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002242}
2243
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302244void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al,
2245 unsigned short dh, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002246{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302247 unsigned short temp, bh, bl;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002248
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302249 bh = ah;
2250 bl = al;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002251
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302252 if (dl != 0) {
2253 temp = bh;
2254 bh = dh;
2255 dh = temp;
2256 if (dl == 1) {
2257 temp = bl;
2258 bl = dh;
2259 dh = temp;
2260 } else {
2261 temp = bl;
2262 bl = bh;
2263 bh = temp;
2264 }
2265 }
2266 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) dh);
2267 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) bh);
2268 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) bl);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002269}
2270
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302271void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
2272 struct xgi_hw_device_info *HwDeviceExtension,
2273 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002274{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302275 unsigned short RefreshRateTableIndex;
2276 /* unsigned short temp ; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002277
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302278 /* pVBInfo->SelectCRT2Rate = 0; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002279
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302280 pVBInfo->SetFlag |= ProgrammingCRT2;
2281 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
2282 ModeIdIndex, pVBInfo);
2283 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
2284 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2285 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2286 HwDeviceExtension, pVBInfo);
2287 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2288 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002289}
2290
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302291void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2292 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002293{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302294 unsigned short resindex, xres, yres, modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002295
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302296 if (ModeNo <= 0x13)
2297 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
2298 else
2299 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002300
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302301 /* if (ModeNo > 0x13) */
2302 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
2303 /* else */
2304 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002305
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302306 if (ModeNo <= 0x13)
2307 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
2308 else
2309 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002310
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302311 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002312
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302313 if (ModeNo <= 0x13) {
2314 xres = pVBInfo->StResInfo[resindex].HTotal;
2315 yres = pVBInfo->StResInfo[resindex].VTotal;
2316 } else {
2317 xres = pVBInfo->ModeResInfo[resindex].HTotal;
2318 yres = pVBInfo->ModeResInfo[resindex].VTotal;
2319 }
2320 if (ModeNo > 0x13) {
2321 if (modeflag & HalfDCLK)
2322 xres = xres << 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002323
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302324 if (modeflag & DoubleScanMode)
2325 yres = yres << 1;
2326 }
2327 /* if (modeflag & Charx8Dot) */
2328 /* { */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002329
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302330 if (xres == 720)
2331 xres = 640;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002332
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302333 /* } */
2334 pVBInfo->VGAHDE = xres;
2335 pVBInfo->HDE = xres;
2336 pVBInfo->VGAVDE = yres;
2337 pVBInfo->VDE = yres;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002338}
2339
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302340void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2341 unsigned short RefreshRateTableIndex,
2342 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002343{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302344 unsigned short tempbx;
2345 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2346 struct XGI330_CHTVDataStruct *TVPtr = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002347
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302348 tempbx = 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002349
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302350 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2351 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2352 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2353 pVBInfo);
2354 pVBInfo->VGAHT = LCDPtr->VGAHT;
2355 pVBInfo->VGAVT = LCDPtr->VGAVT;
2356 pVBInfo->HT = LCDPtr->LCDHT;
2357 pVBInfo->VT = LCDPtr->LCDVT;
2358 }
2359 if (pVBInfo->IF_DEF_CH7017 == 1) {
2360 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2361 TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr(
2362 tempbx, ModeNo, ModeIdIndex,
2363 RefreshRateTableIndex, pVBInfo);
2364 pVBInfo->VGAHT = TVPtr->VGAHT;
2365 pVBInfo->VGAVT = TVPtr->VGAVT;
2366 pVBInfo->HT = TVPtr->LCDHT;
2367 pVBInfo->VT = TVPtr->LCDVT;
2368 }
2369 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002370
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302371 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2372 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2373 | EnableScalingLCD))) {
2374 if ((pVBInfo->LCDResInfo == Panel1024x768)
2375 || (pVBInfo->LCDResInfo
2376 == Panel1024x768x75)) {
2377 pVBInfo->HDE = 1024;
2378 pVBInfo->VDE = 768;
2379 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2380 || (pVBInfo->LCDResInfo
2381 == Panel1280x1024x75)) {
2382 pVBInfo->HDE = 1280;
2383 pVBInfo->VDE = 1024;
2384 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2385 pVBInfo->HDE = 1400;
2386 pVBInfo->VDE = 1050;
2387 } else {
2388 pVBInfo->HDE = 1600;
2389 pVBInfo->VDE = 1200;
2390 }
2391 }
2392 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002393}
2394
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002395void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302396 unsigned short RefreshRateTableIndex,
2397 struct xgi_hw_device_info *HwDeviceExtension,
2398 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002399{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302400 unsigned char index;
2401 unsigned short tempbx, i;
2402 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2403 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2404 /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */
2405 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2406 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002407
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302408 if (ModeNo <= 0x13)
2409 index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2410 else
2411 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002412
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302413 index = index & IndexMask;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002414
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302415 if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1)
2416 && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2417 tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002418
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302419 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2420 LCDPtr
2421 = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr(
2422 tempbx, ModeNo,
2423 ModeIdIndex,
2424 RefreshRateTableIndex,
2425 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002426
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302427 for (i = 0; i < 8; i++)
2428 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2429 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002430
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302431 if (pVBInfo->IF_DEF_CH7007 == 1) {
2432 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2433 CH7007TV_TimingHPtr
2434 = (struct XGI_CH7007TV_TimingHStruct *) XGI_GetTVPtr(
2435 tempbx,
2436 ModeNo,
2437 ModeIdIndex,
2438 RefreshRateTableIndex,
2439 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002440
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302441 for (i = 0; i < 8; i++)
2442 pVBInfo->TimingH[0].data[i]
2443 = CH7007TV_TimingHPtr[0].data[i];
2444 }
2445 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002446
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302447 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2448 if (pVBInfo->VBInfo & SetCRT2ToTV)
2449 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2450 }
2451 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002452
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302453 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002454
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302455 if (pVBInfo->IF_DEF_CH7007 == 1) {
2456 XGINew_SetReg1(pVBInfo->P3c4, 0x2E,
2457 CH7007TV_TimingHPtr[0].data[8]);
2458 XGINew_SetReg1(pVBInfo->P3c4, 0x2F,
2459 CH7007TV_TimingHPtr[0].data[9]);
2460 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002461
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302462 tempbx = 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002463
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302464 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2465 LCDPtr1
2466 = (struct XGI_LVDSCRT1VDataStruct *) XGI_GetLcdPtr(
2467 tempbx, ModeNo,
2468 ModeIdIndex,
2469 RefreshRateTableIndex,
2470 pVBInfo);
2471 for (i = 0; i < 7; i++)
2472 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2473 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002474
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302475 if (pVBInfo->IF_DEF_CH7007 == 1) {
2476 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2477 CH7007TV_TimingVPtr
2478 = (struct XGI_CH7007TV_TimingVStruct *) XGI_GetTVPtr(
2479 tempbx,
2480 ModeNo,
2481 ModeIdIndex,
2482 RefreshRateTableIndex,
2483 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002484
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302485 for (i = 0; i < 7; i++)
2486 pVBInfo->TimingV[0].data[i]
2487 = CH7007TV_TimingVPtr[0].data[i];
2488 }
2489 }
2490 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2491 if (pVBInfo->VBInfo & SetCRT2ToTV)
2492 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2493 }
2494 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002495
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302496 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002497
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302498 if (pVBInfo->IF_DEF_CH7007 == 1) {
2499 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x33, ~0x01,
2500 CH7007TV_TimingVPtr[0].data[7] & 0x01);
2501 XGINew_SetReg1(pVBInfo->P3c4, 0x34,
2502 CH7007TV_TimingVPtr[0].data[8]);
2503 XGINew_SetReg1(pVBInfo->P3c4, 0x3F,
2504 CH7007TV_TimingVPtr[0].data[9]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002505
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302506 }
2507 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002508}
2509
Bill Pemberton82d6eb52010-06-17 13:10:46 -04002510void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302511 unsigned short RefreshRateTableIndex,
2512 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002513{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302514 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2515 unsigned long temp, temp1, temp2, temp3, push3;
2516 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2517 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002518
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302519 if (ModeNo > 0x13)
2520 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2521 else
2522 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002523
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302524 if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2525 if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo
2526 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
2527 if (pVBInfo->IF_DEF_OEMUtil == 1) {
2528 tempbx = 8;
2529 LCDPtr
2530 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2531 tempbx,
2532 ModeNo,
2533 ModeIdIndex,
2534 RefreshRateTableIndex,
2535 pVBInfo);
2536 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002537
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302538 if ((pVBInfo->IF_DEF_OEMUtil == 0) || (LCDPtr == NULL)) {
2539 tempbx = 3;
2540 if (pVBInfo->LCDInfo & EnableScalingLCD)
2541 LCDPtr1
2542 = (struct XGI330_LCDDataDesStruct2 *) XGI_GetLcdPtr(
2543 tempbx,
2544 ModeNo,
2545 ModeIdIndex,
2546 RefreshRateTableIndex,
2547 pVBInfo);
2548 else
2549 LCDPtr
2550 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2551 tempbx,
2552 ModeNo,
2553 ModeIdIndex,
2554 RefreshRateTableIndex,
2555 pVBInfo);
2556 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002557
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302558 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2559 push1 = tempbx;
2560 push2 = tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002561
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302562 /* GetLCDResInfo */
2563 if ((pVBInfo->LCDResInfo == Panel1024x768)
2564 || (pVBInfo->LCDResInfo
2565 == Panel1024x768x75)) {
2566 tempax = 1024;
2567 tempbx = 768;
2568 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2569 || (pVBInfo->LCDResInfo
2570 == Panel1280x1024x75)) {
2571 tempax = 1280;
2572 tempbx = 1024;
2573 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2574 tempax = 1400;
2575 tempbx = 1050;
2576 } else {
2577 tempax = 1600;
2578 tempbx = 1200;
2579 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002580
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302581 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2582 pVBInfo->HDE = tempax;
2583 pVBInfo->VDE = tempbx;
2584 pVBInfo->VGAHDE = tempax;
2585 pVBInfo->VGAVDE = tempbx;
2586 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002587
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302588 if ((pVBInfo->IF_DEF_ScaleLCD == 1)
2589 && (pVBInfo->LCDInfo & EnableScalingLCD)) {
2590 tempax = pVBInfo->HDE;
2591 tempbx = pVBInfo->VDE;
2592 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002593
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302594 tempax = pVBInfo->HT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002595
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302596 if (pVBInfo->LCDInfo & EnableScalingLCD)
2597 tempbx = LCDPtr1->LCDHDES;
2598 else
2599 tempbx = LCDPtr->LCDHDES;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002600
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302601 tempcx = pVBInfo->HDE;
2602 tempbx = tempbx & 0x0fff;
2603 tempcx += tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002604
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302605 if (tempcx >= tempax)
2606 tempcx -= tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002607
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302608 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002609
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302610 tempcx = tempcx >> 3;
2611 tempbx = tempbx >> 3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002612
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302613 XGINew_SetReg1(pVBInfo->Part1Port, 0x16,
2614 (unsigned short) (tempbx & 0xff));
2615 XGINew_SetReg1(pVBInfo->Part1Port, 0x17,
2616 (unsigned short) (tempcx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002617
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302618 tempax = pVBInfo->HT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002619
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302620 if (pVBInfo->LCDInfo & EnableScalingLCD)
2621 tempbx = LCDPtr1->LCDHRS;
2622 else
2623 tempbx = LCDPtr->LCDHRS;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002624
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302625 tempcx = push2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002626
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302627 if (pVBInfo->LCDInfo & EnableScalingLCD)
2628 tempcx = LCDPtr1->LCDHSync;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002629
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302630 tempcx += tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002631
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302632 if (tempcx >= tempax)
2633 tempcx -= tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002634
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302635 tempax = tempbx & 0x07;
2636 tempax = tempax >> 5;
2637 tempcx = tempcx >> 3;
2638 tempbx = tempbx >> 3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002639
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302640 tempcx &= 0x1f;
2641 tempax |= tempcx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002642
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302643 XGINew_SetReg1(pVBInfo->Part1Port, 0x15, tempax);
2644 XGINew_SetReg1(pVBInfo->Part1Port, 0x14,
2645 (unsigned short) (tempbx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002646
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302647 tempax = pVBInfo->VT;
2648 if (pVBInfo->LCDInfo & EnableScalingLCD)
2649 tempbx = LCDPtr1->LCDVDES;
2650 else
2651 tempbx = LCDPtr->LCDVDES;
2652 tempcx = pVBInfo->VDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002653
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302654 tempbx = tempbx & 0x0fff;
2655 tempcx += tempbx;
2656 if (tempcx >= tempax)
2657 tempcx -= tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002658
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302659 XGINew_SetReg1(pVBInfo->Part1Port, 0x1b,
2660 (unsigned short) (tempbx & 0xff));
2661 XGINew_SetReg1(pVBInfo->Part1Port, 0x1c,
2662 (unsigned short) (tempcx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002663
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302664 tempbx = (tempbx >> 8) & 0x07;
2665 tempcx = (tempcx >> 8) & 0x07;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002666
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302667 XGINew_SetReg1(pVBInfo->Part1Port, 0x1d,
2668 (unsigned short) ((tempcx << 3)
2669 | tempbx));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002670
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302671 tempax = pVBInfo->VT;
2672 if (pVBInfo->LCDInfo & EnableScalingLCD)
2673 tempbx = LCDPtr1->LCDVRS;
2674 else
2675 tempbx = LCDPtr->LCDVRS;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002676
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302677 /* tempbx = tempbx >> 4; */
2678 tempcx = push1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002679
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302680 if (pVBInfo->LCDInfo & EnableScalingLCD)
2681 tempcx = LCDPtr1->LCDVSync;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002682
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302683 tempcx += tempbx;
2684 if (tempcx >= tempax)
2685 tempcx -= tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002686
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302687 XGINew_SetReg1(pVBInfo->Part1Port, 0x18,
2688 (unsigned short) (tempbx & 0xff));
2689 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f,
2690 (unsigned short) (tempcx & 0x0f));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002691
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302692 tempax = ((tempbx >> 8) & 0x07) << 3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002693
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302694 tempbx = pVBInfo->VGAVDE;
2695 if (tempbx != pVBInfo->VDE)
2696 tempax |= 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002697
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302698 if (pVBInfo->LCDInfo & EnableLVDSDDA)
2699 tempax |= 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002700
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302701 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1a, 0x07,
2702 tempax);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002703
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302704 tempcx = pVBInfo->VGAVT;
2705 tempbx = pVBInfo->VDE;
2706 tempax = pVBInfo->VGAVDE;
2707 tempcx -= tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002708
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302709 temp = tempax; /* 0430 ylshieh */
2710 temp1 = (temp << 18) / tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002711
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302712 tempdx = (unsigned short) ((temp << 18) % tempbx);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002713
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302714 if (tempdx != 0)
2715 temp1 += 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002716
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302717 temp2 = temp1;
2718 push3 = temp2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002719
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302720 XGINew_SetReg1(pVBInfo->Part1Port, 0x37,
2721 (unsigned short) (temp2 & 0xff));
2722 XGINew_SetReg1(pVBInfo->Part1Port, 0x36,
2723 (unsigned short) ((temp2 >> 8) & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002724
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302725 tempbx = (unsigned short) (temp2 >> 16);
2726 tempax = tempbx & 0x03;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002727
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302728 tempbx = pVBInfo->VGAVDE;
2729 if (tempbx == pVBInfo->VDE)
2730 tempax |= 0x04;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002731
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302732 XGINew_SetReg1(pVBInfo->Part1Port, 0x35, tempax);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002733
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302734 if (pVBInfo->VBType & VB_XGI301C) {
2735 temp2 = push3;
2736 XGINew_SetReg1(pVBInfo->Part4Port, 0x3c,
2737 (unsigned short) (temp2 & 0xff));
2738 XGINew_SetReg1(pVBInfo->Part4Port, 0x3b,
2739 (unsigned short) ((temp2 >> 8)
2740 & 0xff));
2741 tempbx = (unsigned short) (temp2 >> 16);
2742 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x3a,
2743 ~0xc0,
2744 (unsigned short) ((tempbx
2745 & 0xff) << 6));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002746
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302747 tempcx = pVBInfo->VGAVDE;
2748 if (tempcx == pVBInfo->VDE)
2749 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2750 0x30, ~0x0c, 0x00);
2751 else
2752 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2753 0x30, ~0x0c, 0x08);
2754 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002755
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302756 tempcx = pVBInfo->VGAHDE;
2757 tempbx = pVBInfo->HDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002758
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302759 temp1 = tempcx << 16;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002760
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302761 tempax = (unsigned short) (temp1 / tempbx);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002762
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302763 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2764 tempax = 65535;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002765
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302766 temp3 = tempax;
2767 temp1 = pVBInfo->VGAHDE << 16;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002768
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302769 temp1 /= temp3;
2770 temp3 = temp3 << 16;
2771 temp1 -= 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002772
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302773 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002774
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302775 tempax = (unsigned short) (temp3 & 0xff);
2776 XGINew_SetReg1(pVBInfo->Part1Port, 0x1f, tempax);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002777
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302778 temp1 = pVBInfo->VGAVDE << 18;
2779 temp1 = temp1 / push3;
2780 tempbx = (unsigned short) (temp1 & 0xffff);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002781
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302782 if (pVBInfo->LCDResInfo == Panel1024x768)
2783 tempbx -= 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002784
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302785 tempax = ((tempbx >> 8) & 0xff) << 3;
2786 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
2787 XGINew_SetReg1(pVBInfo->Part1Port, 0x20,
2788 (unsigned short) (tempax & 0xff));
2789 XGINew_SetReg1(pVBInfo->Part1Port, 0x21,
2790 (unsigned short) (tempbx & 0xff));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002791
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302792 temp3 = temp3 >> 16;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002793
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302794 if (modeflag & HalfDCLK)
2795 temp3 = temp3 >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002796
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302797 XGINew_SetReg1(pVBInfo->Part1Port, 0x22,
2798 (unsigned short) ((temp3 >> 8) & 0xff));
2799 XGINew_SetReg1(pVBInfo->Part1Port, 0x23,
2800 (unsigned short) (temp3 & 0xff));
2801 }
2802 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002803}
2804
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302805void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2806 unsigned short RefreshRateTableIndex,
2807 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002808{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302809 unsigned char di_0, di_1, tempal;
2810 int i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002811
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302812 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2813 pVBInfo);
2814 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2815 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002816
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302817 for (i = 0; i < 4; i++) {
2818 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, ~0x30,
2819 (unsigned short) (0x10 * i));
2820 if (pVBInfo->IF_DEF_CH7007 == 1) {
2821 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
2822 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
2823 } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
2824 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
2825 XGINew_SetReg1(pVBInfo->P3c4, 0x2e, di_0);
2826 XGINew_SetReg1(pVBInfo->P3c4, 0x2f, di_1);
2827 } else {
2828 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
2829 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
2830 }
2831 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002832}
2833
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302834void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
2835 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002836{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302837 unsigned short tempcl, tempch, temp, tempbl, tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002838
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302839 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
2840 | VB_XGI302LV | VB_XGI301C)) {
2841 tempcl = 0;
2842 tempch = 0;
2843 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002844
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302845 if (!(temp & 0x20)) {
2846 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x17);
2847 if (temp & 0x80) {
2848 if ((HwDeviceExtension->jChipType >= XG20)
2849 || (HwDeviceExtension->jChipType
2850 >= XG40))
2851 temp = XGINew_GetReg1(pVBInfo->P3d4,
2852 0x53);
2853 else
2854 temp = XGINew_GetReg1(pVBInfo->P3d4,
2855 0x63);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002856
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302857 if (!(temp & 0x40))
2858 tempcl |= ActiveCRT1;
2859 }
2860 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002861
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302862 temp = XGINew_GetReg1(pVBInfo->Part1Port, 0x2e);
2863 temp &= 0x0f;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002864
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302865 if (!(temp == 0x08)) {
2866 tempax = XGINew_GetReg1(pVBInfo->Part1Port, 0x13); /* Check ChannelA by Part1_13 [2003/10/03] */
2867 if (tempax & 0x04)
2868 tempcl = tempcl | ActiveLCD;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002869
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302870 temp &= 0x05;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002871
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302872 if (!(tempcl & ActiveLCD))
2873 if (temp == 0x01)
2874 tempcl |= ActiveCRT2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002875
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302876 if (temp == 0x04)
2877 tempcl |= ActiveLCD;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002878
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302879 if (temp == 0x05) {
2880 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002881
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302882 if (!(temp & 0x08))
2883 tempch |= ActiveAVideo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002884
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302885 if (!(temp & 0x04))
2886 tempch |= ActiveSVideo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002887
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302888 if (temp & 0x02)
2889 tempch |= ActiveSCART;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002890
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302891 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
2892 if (temp & 0x01)
2893 tempch |= ActiveHiTV;
2894 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002895
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302896 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
2897 temp = XGINew_GetReg1(
2898 pVBInfo->Part2Port,
2899 0x4d);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002900
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302901 if (temp & 0x10)
2902 tempch |= ActiveYPbPr;
2903 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002904
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302905 if (tempch != 0)
2906 tempcl |= ActiveTV;
2907 }
2908 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002909
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302910 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x3d);
2911 if (tempcl & ActiveLCD) {
2912 if ((pVBInfo->SetFlag & ReserveTVOption)) {
2913 if (temp & ActiveTV)
2914 tempcl |= ActiveTV;
2915 }
2916 }
2917 temp = tempcl;
2918 tempbl = ~ModeSwitchStatus;
2919 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x3d, tempbl, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002920
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302921 if (!(pVBInfo->SetFlag & ReserveTVOption))
2922 XGINew_SetReg1(pVBInfo->P3d4, 0x3e, tempch);
2923 } else {
2924 return;
2925 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002926}
2927
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302928void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
2929 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002930{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302931 /*
2932 if ( HwDeviceExtension->jChipType >= XG20 ) {
2933 pVBInfo->Set_VGAType = XG20;
2934 } else if (HwDeviceExtension->jChipType >= XG40) {
2935 pVBInfo->Set_VGAType = VGA_XGI340;
2936 }
2937 */
2938 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002939}
2940
Bill Pemberton80adad82010-06-17 13:10:51 -04002941void XGI_GetVBType(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002942{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302943 unsigned short flag, tempbx, tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002944
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302945 if (pVBInfo->IF_DEF_CH7007 == 1) {
2946 pVBInfo->VBType = VB_CH7007;
2947 return;
2948 }
2949 if (pVBInfo->IF_DEF_LVDS == 0) {
2950 tempbx = VB_XGI302B;
2951 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
2952 if (flag != 0x02) {
2953 tempbx = VB_XGI301;
2954 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x01);
2955 if (flag >= 0xB0) {
2956 tempbx = VB_XGI301B;
2957 if (flag >= 0xC0) {
2958 tempbx = VB_XGI301C;
2959 if (flag >= 0xD0) {
2960 tempbx = VB_XGI301LV;
2961 if (flag >= 0xE0) {
2962 tempbx = VB_XGI302LV;
2963 tempah
2964 = XGINew_GetReg1(
2965 pVBInfo->Part4Port,
2966 0x39);
2967 if (tempah != 0xFF)
2968 tempbx
2969 = VB_XGI301C;
2970 }
2971 }
2972 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002973
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302974 if (tempbx & (VB_XGI301B | VB_XGI302B)) {
2975 flag = XGINew_GetReg1(
2976 pVBInfo->Part4Port,
2977 0x23);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002978
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302979 if (!(flag & 0x02))
2980 tempbx = tempbx | VB_NoLCD;
2981 }
2982 }
2983 }
2984 pVBInfo->VBType = tempbx;
2985 }
2986 /*
2987 else if (pVBInfo->IF_DEF_CH7017 == 1)
2988 pVBInfo->VBType = VB_CH7017;
2989 else //LVDS
2990 pVBInfo->VBType = VB_LVDS_NS;
2991 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002992
2993}
2994
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302995void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2996 struct xgi_hw_device_info *HwDeviceExtension,
2997 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02002998{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05302999 unsigned short tempax, push, tempbx, temp, modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003000
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303001 if (ModeNo <= 0x13)
3002 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3003 else
3004 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003005
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303006 pVBInfo->SetFlag = 0;
3007 pVBInfo->ModeType = modeflag & ModeInfoFlag;
3008 tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003009
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303010 if (pVBInfo->VBType & 0xFFFF) {
3011 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x30); /* Check Display Device */
3012 tempbx = tempbx | temp;
3013 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
3014 push = temp;
3015 push = push << 8;
3016 tempax = temp << 8;
3017 tempbx = tempbx | tempax;
3018 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA
3019 | SetInSlaveMode | DisableCRT2Display);
3020 temp = 0xFFFF ^ temp;
3021 tempbx &= temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003022
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303023 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003024
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303025 if (pVBInfo->IF_DEF_LCDA == 1) {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003026
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303027 if ((pVBInfo->Set_VGAType >= XG20)
3028 || (pVBInfo->Set_VGAType >= XG40)) {
3029 if (pVBInfo->IF_DEF_LVDS == 0) {
3030 /* if ((pVBInfo->VBType & VB_XGI302B) || (pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType & VB_XGI301C)) */
3031 if (pVBInfo->VBType & (VB_XGI302B
3032 | VB_XGI301LV
3033 | VB_XGI302LV
3034 | VB_XGI301C)) {
3035 if (temp & EnableDualEdge) {
3036 tempbx
3037 |= SetCRT2ToDualEdge;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003038
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303039 if (temp & SetToLCDA)
3040 tempbx
3041 |= SetCRT2ToLCDA;
3042 }
3043 }
3044 } else if (pVBInfo->IF_DEF_CH7017 == 1) {
3045 if (pVBInfo->VBType & VB_CH7017) {
3046 if (temp & EnableDualEdge) {
3047 tempbx
3048 |= SetCRT2ToDualEdge;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003049
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303050 if (temp & SetToLCDA)
3051 tempbx
3052 |= SetCRT2ToLCDA;
3053 }
3054 }
3055 }
3056 }
3057 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003058
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303059 if (pVBInfo->IF_DEF_YPbPr == 1) {
3060 if (((pVBInfo->IF_DEF_LVDS == 0) && ((pVBInfo->VBType
3061 & VB_XGI301LV) || (pVBInfo->VBType
3062 & VB_XGI302LV) || (pVBInfo->VBType
3063 & VB_XGI301C)))
3064 || ((pVBInfo->IF_DEF_CH7017 == 1)
3065 && (pVBInfo->VBType
3066 & VB_CH7017))
3067 || ((pVBInfo->IF_DEF_CH7007 == 1)
3068 && (pVBInfo->VBType
3069 & VB_CH7007))) { /* [Billy] 07/05/04 */
3070 if (temp & SetYPbPr) { /* temp = CR38 */
3071 if (pVBInfo->IF_DEF_HiVision == 1) {
3072 temp = XGINew_GetReg1(
3073 pVBInfo->P3d4,
3074 0x35); /* shampoo add for new scratch */
3075 temp &= YPbPrMode;
3076 tempbx |= SetCRT2ToHiVisionTV;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003077
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303078 if (temp != YPbPrMode1080i) {
3079 tempbx
3080 &= (~SetCRT2ToHiVisionTV);
3081 tempbx
3082 |= SetCRT2ToYPbPr;
3083 }
3084 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003085
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303086 /* tempbx |= SetCRT2ToYPbPr; */
3087 }
3088 }
3089 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003090
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303091 tempax = push; /* restore CR31 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003092
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303093 if (pVBInfo->IF_DEF_LVDS == 0) {
3094 if (pVBInfo->IF_DEF_YPbPr == 1) {
3095 if (pVBInfo->IF_DEF_HiVision == 1)
3096 temp = 0x09FC;
3097 else
3098 temp = 0x097C;
3099 } else {
3100 if (pVBInfo->IF_DEF_HiVision == 1)
3101 temp = 0x01FC;
3102 else
3103 temp = 0x017C;
3104 }
3105 } else { /* 3nd party chip */
3106 if (pVBInfo->IF_DEF_CH7017 == 1)
3107 temp = (SetCRT2ToTV | SetCRT2ToLCD
3108 | SetCRT2ToLCDA);
3109 else if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/03 */
3110 temp = SetCRT2ToTV;
3111 } else
3112 temp = SetCRT2ToLCD;
3113 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003114
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303115 if (!(tempbx & temp)) {
3116 tempax |= DisableCRT2Display;
3117 tempbx = 0;
3118 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003119
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303120 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
3121 if (!(pVBInfo->VBType & VB_NoLCD)) {
3122 if (tempbx & SetCRT2ToLCDA) {
3123 if (tempbx & SetSimuScanMode)
3124 tempbx
3125 &= (~(SetCRT2ToLCD
3126 | SetCRT2ToRAMDAC
3127 | SwitchToCRT2));
3128 else
3129 tempbx
3130 &= (~(SetCRT2ToLCD
3131 | SetCRT2ToRAMDAC
3132 | SetCRT2ToTV
3133 | SwitchToCRT2));
3134 }
3135 }
3136 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003137
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303138 /* shampoo add */
3139 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { /* for driver abnormal */
3140 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
3141 if (tempbx & SetCRT2ToRAMDAC) {
3142 tempbx &= (0xFF00 | SetCRT2ToRAMDAC
3143 | SwitchToCRT2
3144 | SetSimuScanMode);
3145 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3146 }
3147 } else {
3148 tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD
3149 | SetCRT2ToTV));
3150 }
3151 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003152
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303153 if (!(pVBInfo->VBType & VB_NoLCD)) {
3154 if (tempbx & SetCRT2ToLCD) {
3155 tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2
3156 | SetSimuScanMode);
3157 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3158 }
3159 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003160
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303161 if (tempbx & SetCRT2ToSCART) {
3162 tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2
3163 | SetSimuScanMode);
3164 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3165 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003166
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303167 if (pVBInfo->IF_DEF_YPbPr == 1) {
3168 if (tempbx & SetCRT2ToYPbPr)
3169 tempbx &= (0xFF00 | SwitchToCRT2
3170 | SetSimuScanMode);
3171 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003172
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303173 if (pVBInfo->IF_DEF_HiVision == 1) {
3174 if (tempbx & SetCRT2ToHiVisionTV)
3175 tempbx &= (0xFF00 | SetCRT2ToHiVisionTV
3176 | SwitchToCRT2
3177 | SetSimuScanMode);
3178 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003179
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303180 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
3181 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode)))
3182 tempbx = DisableCRT2Display;
3183 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003184
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303185 if (!(tempbx & DisableCRT2Display)) {
3186 if ((!(tempbx & DriverMode))
3187 || (!(modeflag & CRT2Mode))) {
3188 if (pVBInfo->IF_DEF_LCDA == 1) {
3189 if (!(tempbx & SetCRT2ToLCDA))
3190 tempbx
3191 |= (SetInSlaveMode
3192 | SetSimuScanMode);
3193 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003194
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303195 if (pVBInfo->IF_DEF_VideoCapture == 1) {
3196 if (((HwDeviceExtension->jChipType
3197 == XG40)
3198 && (pVBInfo->Set_VGAType
3199 == XG40))
3200 || ((HwDeviceExtension->jChipType
3201 == XG41)
3202 && (pVBInfo->Set_VGAType
3203 == XG41))
3204 || ((HwDeviceExtension->jChipType
3205 == XG42)
3206 && (pVBInfo->Set_VGAType
3207 == XG42))
3208 || ((HwDeviceExtension->jChipType
3209 == XG45)
3210 && (pVBInfo->Set_VGAType
3211 == XG45))) {
3212 if (ModeNo <= 13) {
3213 if (!(tempbx
3214 & SetCRT2ToRAMDAC)) { /*CRT2 not need to support*/
3215 tempbx
3216 &= (0x00FF
3217 | (~SetInSlaveMode));
3218 pVBInfo->SetFlag
3219 |= EnableVCMode;
3220 }
3221 }
3222 }
3223 }
3224 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003225
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303226 /* LCD+TV can't support in slave mode (Force LCDA+TV->LCDB) */
3227 if ((tempbx & SetInSlaveMode) && (tempbx
3228 & SetCRT2ToLCDA)) {
3229 tempbx ^= (SetCRT2ToLCD | SetCRT2ToLCDA
3230 | SetCRT2ToDualEdge);
3231 pVBInfo->SetFlag |= ReserveTVOption;
3232 }
3233 }
3234 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003235
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303236 pVBInfo->VBInfo = tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003237}
3238
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303239void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3240 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003241{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303242 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003243
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303244 tempbx = 0;
3245 resinfo = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003246
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303247 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3248 if (ModeNo <= 0x13) {
3249 modeflag
3250 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
3251 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
3252 } else {
3253 modeflag
3254 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3255 resinfo
3256 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
3257 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003258
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303259 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3260 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3261 tempbx = temp;
3262 if (tempbx & SetPALTV) {
3263 tempbx &= (SetCHTVOverScan | SetPALMTV
3264 | SetPALNTV | SetPALTV);
3265 if (tempbx & SetPALMTV)
3266 tempbx &= ~SetPALTV; /* set to NTSC if PAL-M */
3267 } else
3268 tempbx &= (SetCHTVOverScan | SetNTSCJ
3269 | SetPALTV);
3270 /*
3271 if (pVBInfo->IF_DEF_LVDS == 0) {
3272 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x38); //PAL-M/PAL-N Info
3273 temp2 = (index1 & 0xC0) >> 5; //00:PAL, 01:PAL-M, 10:PAL-N
3274 tempbx |= temp2;
3275 if (temp2 & 0x02) //PAL-M
3276 tempbx &= (~SetPALTV);
3277 }
3278 */
3279 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003280
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303281 if (pVBInfo->IF_DEF_CH7017 == 1) {
3282 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003283
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303284 if (tempbx & TVOverScan)
3285 tempbx |= SetCHTVOverScan;
3286 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003287
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303288 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */
3289 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003290
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303291 if (tempbx & TVOverScan)
3292 tempbx |= SetCHTVOverScan;
3293 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003294
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303295 if (pVBInfo->IF_DEF_LVDS == 0) {
3296 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3297 tempbx |= SetPALTV;
3298 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003299
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303300 if (pVBInfo->IF_DEF_YPbPr == 1) {
3301 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3302 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3303 index1 &= YPbPrMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003304
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303305 if (index1 == YPbPrMode525i)
3306 tempbx |= SetYPbPrMode525i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003307
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303308 if (index1 == YPbPrMode525p)
3309 tempbx = tempbx | SetYPbPrMode525p;
3310 if (index1 == YPbPrMode750p)
3311 tempbx = tempbx | SetYPbPrMode750p;
3312 }
3313 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003314
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303315 if (pVBInfo->IF_DEF_HiVision == 1) {
3316 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
3317 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV;
3318 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003319
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303320 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3321 if ((pVBInfo->VBInfo & SetInSlaveMode)
3322 && (!(pVBInfo->VBInfo & SetNotSimuMode)))
3323 tempbx |= TVSimuMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003324
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303325 if (!(tempbx & SetPALTV) && (modeflag > 13) && (resinfo
3326 == 8)) /* NTSC 1024x768, */
3327 tempbx |= NTSC1024x768;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003328
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303329 tempbx |= RPLLDIV2XO;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003330
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303331 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3332 if (pVBInfo->VBInfo & SetInSlaveMode)
3333 tempbx &= (~RPLLDIV2XO);
3334 } else {
3335 if (tempbx & (SetYPbPrMode525p
3336 | SetYPbPrMode750p))
3337 tempbx &= (~RPLLDIV2XO);
3338 else if (!(pVBInfo->VBType & (VB_XGI301B
3339 | VB_XGI302B | VB_XGI301LV
3340 | VB_XGI302LV | VB_XGI301C))) {
3341 if (tempbx & TVSimuMode)
3342 tempbx &= (~RPLLDIV2XO);
3343 }
3344 }
3345 }
3346 }
3347 pVBInfo->TVInfo = tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003348}
3349
Bill Pemberton108afbf2010-06-17 13:10:47 -04003350unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303351 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003352{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303353 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003354
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303355 pVBInfo->LCDResInfo = 0;
3356 pVBInfo->LCDTypeInfo = 0;
3357 pVBInfo->LCDInfo = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003358
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303359 if (ModeNo <= 0x13) {
3360 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag // */
3361 } else {
3362 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3363 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo // */
3364 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003365
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303366 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3367 tempbx = temp & 0x0F;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003368
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303369 if (tempbx == 0)
3370 tempbx = Panel1024x768; /* default */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003371
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303372 /* LCD75 [2003/8/22] Vicent */
3373 if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) {
3374 if (pVBInfo->VBInfo & DriverMode) {
3375 tempax = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
3376 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
3377 tempax &= 0x0F;
3378 else
3379 tempax = tempax >> 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003380
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303381 if ((resinfo == 6) || (resinfo == 9)) {
3382 if (tempax >= 3)
3383 tempbx |= PanelRef75Hz;
3384 } else if ((resinfo == 7) || (resinfo == 8)) {
3385 if (tempax >= 4)
3386 tempbx |= PanelRef75Hz;
3387 }
3388 }
3389 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003390
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303391 pVBInfo->LCDResInfo = tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003392
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303393 /* End of LCD75 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003394
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303395 if (pVBInfo->IF_DEF_OEMUtil == 1)
3396 pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003397
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303398 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
3399 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003400
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303401 tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003402
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303403 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003404
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303405 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003406
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303407 if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
3408 temp &= ~EnableScalingLCD;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003409
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303410 tempbx |= temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003411
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303412 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003413
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303414 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003415
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303416 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3417 if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3418 & VB_XGI301C)) && (tempax & LCDDualLink)) {
3419 tempbx |= SetLCDDualLink;
3420 }
3421 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003422
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303423 if (pVBInfo->IF_DEF_CH7017 == 1) {
3424 if (tempax & LCDDualLink)
3425 tempbx |= SetLCDDualLink;
3426 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003427
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303428 if (pVBInfo->IF_DEF_LVDS == 0) {
3429 if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
3430 & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
3431 == 9) && (!(tempbx & EnableScalingLCD)))
3432 tempbx |= SetLCDtoNonExpanding; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3433 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003434
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303435 /*
3436 if (tempax & LCDBToA) {
3437 tempbx |= SetLCDBToA;
3438 }
3439 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003440
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303441 if (pVBInfo->IF_DEF_ExpLink == 1) {
3442 if (modeflag & HalfDCLK) {
3443 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
3444 if (!(tempbx & SetLCDtoNonExpanding)) {
3445 tempbx |= EnableLVDSDDA;
3446 } else {
3447 if (ModeNo > 0x13) {
3448 if (pVBInfo->LCDResInfo
3449 == Panel1024x768) {
3450 if (resinfo == 4) { /* 512x384 */
3451 tempbx |= EnableLVDSDDA;
3452 }
3453 }
3454 }
3455 }
3456 }
3457 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003458
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303459 if (pVBInfo->VBInfo & SetInSlaveMode) {
3460 if (pVBInfo->VBInfo & SetNotSimuMode)
3461 tempbx |= LCDVESATiming;
3462 } else {
3463 tempbx |= LCDVESATiming;
3464 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003465
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303466 pVBInfo->LCDInfo = tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003467
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303468 if (pVBInfo->IF_DEF_PWD == 1) {
3469 if (pVBInfo->LCDInfo & SetPWDEnable) {
3470 if ((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3471 & VB_XGI301C)) {
3472 if (!(tempax & PWDEnable))
3473 pVBInfo->LCDInfo &= ~SetPWDEnable;
3474 }
3475 }
3476 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003477
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303478 if (pVBInfo->IF_DEF_LVDS == 0) {
3479 if (tempax & (LockLCDBToA | StLCDBToA)) {
3480 if (pVBInfo->VBInfo & SetInSlaveMode) {
3481 if (!(tempax & LockLCDBToA)) {
3482 if (ModeNo <= 0x13) {
3483 pVBInfo->VBInfo
3484 &= ~(SetSimuScanMode
3485 | SetInSlaveMode
3486 | SetCRT2ToLCD);
3487 pVBInfo->VBInfo
3488 |= SetCRT2ToLCDA
3489 | SetCRT2ToDualEdge;
3490 }
3491 }
3492 }
3493 }
3494 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003495
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303496 /*
3497 if (pVBInfo->IF_DEF_LVDS == 0) {
3498 if (tempax & (LockLCDBToA | StLCDBToA)) {
3499 if (pVBInfo->VBInfo & SetInSlaveMode) {
3500 if (!((!(tempax & LockLCDBToA)) && (ModeNo > 0x13))) {
3501 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3502 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3503 }
3504 }
3505 }
3506 }
3507 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003508
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303509 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003510}
3511
Bill Pemberton108afbf2010-06-17 13:10:47 -04003512unsigned char XGI_SearchModeID(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303513 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003514{
3515
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003516#ifdef LINUX /* chiawen for linux solution */
3517
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303518 if (ModeNo <= 5)
3519 ModeNo |= 1;
3520 if (ModeNo <= 0x13) {
3521 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
3522 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3523 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3524 break;
3525 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3526 return 0;
3527 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003528
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303529 if (ModeNo == 0x07)
3530 (*ModeIdIndex)++; /* 400 lines */
3531 if (ModeNo <= 3)
3532 (*ModeIdIndex) += 2; /* 400 lines */
3533 /* else 350 lines */
3534 } else {
3535 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
3536 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3537 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3538 break;
3539 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3540 return 0;
3541 }
3542 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003543
3544#endif
3545
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303546 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003547}
3548
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003549/* win2000 MM adapter not support standard mode! */
3550
Randy Dunlap89229672010-08-10 08:46:44 -07003551#if 0
Randy Dunlap89229672010-08-10 08:46:44 -07003552static unsigned char XGINew_CheckMemorySize(
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303553 struct xgi_hw_device_info *HwDeviceExtension,
3554 unsigned short ModeNo,
3555 unsigned short ModeIdIndex,
3556 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003557{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303558 unsigned short memorysize, modeflag, temp, temp1, tmp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003559
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303560 /*
3561 if ((HwDeviceExtension->jChipType == XGI_650) ||
3562 (HwDeviceExtension->jChipType == XGI_650M)) {
3563 return 1;
3564 }
3565 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003566
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303567 if (ModeNo <= 0x13)
3568 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3569 else
3570 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003571
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303572 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003573
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303574 memorysize = modeflag & MemoryInfoFlag;
3575 memorysize = memorysize > MemorySizeShift;
3576 memorysize++; /* Get memory size */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003577
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303578 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
3579 tmp = temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003580
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303581 if (HwDeviceExtension->jChipType == XG40) {
3582 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3583 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3584 temp <<= 2;
3585 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
3586 temp <<= 1;
3587 }
3588 } else if (HwDeviceExtension->jChipType == XG42) {
3589 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3590 if ((tmp & 0x04) == 0x04) { /* Dual channels */
3591 temp <<= 1;
3592 }
3593 } else if (HwDeviceExtension->jChipType == XG45) {
3594 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3595 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3596 temp <<= 2;
3597 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
3598 temp1 = temp;
3599 temp <<= 1;
3600 temp += temp1;
3601 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
3602 temp <<= 1;
3603 }
3604 }
3605 if (temp < memorysize)
3606 return 0;
3607 else
3608 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003609}
Randy Dunlap89229672010-08-10 08:46:44 -07003610#endif
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003611
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303612/*
3613void XGINew_IsLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003614{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303615 unsigned short data ;
3616 unsigned short ModeFlag ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003617
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303618 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3619 data &= 0x7F;
3620 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003621
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303622 if (ModeNo > 0x13) {
3623 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3624 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
3625 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3626 data |= 0x80;
3627 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
3628 data = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3629 data &= 0xF7;
3630 XGINew_SetReg1(pVBInfo->P3c4, 0x01, data);
3631 }
3632 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003633}
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003634*/
3635
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303636void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
3637 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003638{
3639
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303640 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3641 if (pXGIHWDE->jChipType == XG21) {
3642 if (pVBInfo->IF_DEF_LVDS == 1) {
3643 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3644 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3645 XGI_XG21SetPanelDelay(2, pVBInfo);
3646 }
3647 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3648 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3649 XGI_XG21SetPanelDelay(3, pVBInfo);
3650 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3651 } else {
3652 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3653 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003654
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303655 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003656
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303657 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003658
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303659 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003660
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303661 if (pXGIHWDE->jChipType == XG27) {
3662 if (pVBInfo->IF_DEF_LVDS == 1) {
3663 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
3664 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3665 XGI_XG21SetPanelDelay(2, pVBInfo);
3666 }
3667 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
3668 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3669 XGI_XG21SetPanelDelay(3, pVBInfo);
3670 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3671 } else {
3672 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3673 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003674
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303675 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003676}
3677
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303678void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
3679 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003680{
3681
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303682 if (pXGIHWDE->jChipType == XG21) {
3683 if (pVBInfo->IF_DEF_LVDS == 1) {
3684 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3685 XGI_XG21SetPanelDelay(3, pVBInfo);
3686 } else {
3687 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3688 }
3689 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003690
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303691 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
3692 /* if (IsCH7007TVMode(pVBInfo) == 0) */
3693 {
3694 }
3695 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003696
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303697 if (pXGIHWDE->jChipType == XG27) {
3698 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
3699 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3700 XGI_XG21SetPanelDelay(3, pVBInfo);
3701 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003702
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303703 if (pVBInfo->IF_DEF_LVDS == 0)
3704 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3705 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003706
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303707 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003708}
3709
Bill Pemberton80adad82010-06-17 13:10:51 -04003710void XGI_WaitDisply(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003711{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303712 while ((XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3713 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003714
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303715 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3716 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003717}
3718
Bill Pemberton80adad82010-06-17 13:10:51 -04003719void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003720{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303721 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
3722 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
3723 0x05, 0x00 };
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003724
Bill Pemberton108afbf2010-06-17 13:10:47 -04003725 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003726
Bill Pemberton108afbf2010-06-17 13:10:47 -04003727 unsigned char CR17, CR63, SR31;
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303728 unsigned short temp;
3729 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003730
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303731 int i;
3732 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003733
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303734 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
3735 XGINew_SetReg1(pVBInfo->P3d4, 0x57, 0x4A);
3736 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3737 pVBInfo->P3d4, 0x53) | 0x02));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003738
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303739 SR31 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x31);
3740 CR63 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x63);
3741 SR01 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003742
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303743 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
3744 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003745
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303746 CR17 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x17);
3747 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003748
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303749 SR1F = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
3750 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003751
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303752 SR07 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x07);
3753 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
3754 SR06 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x06);
3755 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003756
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303757 XGINew_SetReg1(pVBInfo->P3d4, 0x11, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003758
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303759 for (i = 0; i < 8; i++)
3760 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003761
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303762 for (i = 8; i < 11; i++)
3763 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 8),
3764 CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003765
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303766 for (i = 11; i < 13; i++)
3767 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 4),
3768 CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003769
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303770 for (i = 13; i < 16; i++)
3771 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i - 3),
3772 CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003773
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303774 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
3775 & 0xE0));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003776
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303777 XGINew_SetReg1(pVBInfo->P3c4, 0x31, 0x00);
3778 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
3779 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE1);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003780
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303781 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003782
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303783 for (i = 0; i < 256; i++) {
3784 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3785 (unsigned char) DAC_TEST_PARMS[0]);
3786 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3787 (unsigned char) DAC_TEST_PARMS[1]);
3788 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3789 (unsigned char) DAC_TEST_PARMS[2]);
3790 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003791
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303792 XGI_VBLongWait(pVBInfo);
3793 XGI_VBLongWait(pVBInfo);
3794 XGI_VBLongWait(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003795
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303796 XGINew_LCD_Wait_Time(0x01, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003797
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303798 XGI_WaitDisply(pVBInfo);
3799 temp = XGINew_GetReg2(pVBInfo->P3c2);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003800
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303801 if (temp & 0x10)
3802 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
3803 else
3804 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003805
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303806 /* alan, avoid display something, set BLACK DAC if not restore DAC */
3807 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003808
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303809 for (i = 0; i < 256; i++) {
3810 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3811 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3812 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3813 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003814
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303815 XGINew_SetReg1(pVBInfo->P3c4, 0x01, SR01);
3816 XGINew_SetReg1(pVBInfo->P3d4, 0x63, CR63);
3817 XGINew_SetReg1(pVBInfo->P3c4, 0x31, SR31);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003818
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303819 /* [2004/05/11] Vicent */
3820 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3821 pVBInfo->P3d4, 0x53) & 0xFD));
3822 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003823}
3824
Randy Dunlap89229672010-08-10 08:46:44 -07003825#if 0
Randy Dunlap89229672010-08-10 08:46:44 -07003826static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003827{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303828 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01));
3829 while (XGINew_GetReg2(pVBInfo->P3da) & 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003830}
Randy Dunlap89229672010-08-10 08:46:44 -07003831#endif
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003832
Bill Pemberton108afbf2010-06-17 13:10:47 -04003833unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303834 struct xgi_hw_device_info *HwDeviceExtension,
3835 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003836{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303837 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003838
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303839 tempbx = pVBInfo->VBInfo;
3840 pVBInfo->SetFlag |= ProgrammingCRT2;
3841 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
3842 pVBInfo->SelectCRT2Rate = 4;
3843 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
3844 ModeIdIndex, pVBInfo);
3845 XGI_SaveCRT2Info(ModeNo, pVBInfo);
3846 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
3847 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3848 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3849 RefreshRateTableIndex, pVBInfo);
3850 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3851 RefreshRateTableIndex, pVBInfo);
3852 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3853 RefreshRateTableIndex, pVBInfo);
3854 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3855 HwDeviceExtension, pVBInfo);
3856 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3857 RefreshRateTableIndex, pVBInfo);
3858 XGI_SetTap4Regs(pVBInfo);
3859 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
3860 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3861 HwDeviceExtension, pVBInfo);
3862 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3863 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
3864 XGI_AutoThreshold(pVBInfo);
3865 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003866}
3867
Bill Pemberton80adad82010-06-17 13:10:51 -04003868void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003869{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303870 if (!(pVBInfo->SetFlag & Win9xDOSMode))
3871 XGINew_SetRegOR(pVBInfo->Part1Port, 0x01, 0x40);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003872}
3873
Bill Pemberton80adad82010-06-17 13:10:51 -04003874void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003875{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303876 unsigned short temp1, temp2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003877
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303878 XGINew_SetReg1(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
3879 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
3880 temp2 = ~(SetInSlaveMode >> 8);
3881 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, temp2, temp1);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003882}
3883
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303884void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3885 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003886{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303887 unsigned short xres, yres, modeflag, resindex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003888
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303889 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
3890 if (ModeNo <= 0x13) {
3891 xres = pVBInfo->StResInfo[resindex].HTotal;
3892 yres = pVBInfo->StResInfo[resindex].VTotal;
3893 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
3894 } else {
3895 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
3896 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
3897 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003898
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303899 /*
3900 if (pVBInfo->IF_DEF_FSTN) {
3901 xres *= 2;
3902 yres *= 2;
3903 } else {
3904 */
3905 if (modeflag & HalfDCLK)
3906 xres *= 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003907
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303908 if (modeflag & DoubleScanMode)
3909 yres *= 2;
3910 /* } */
3911 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003912
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303913 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3914 if (pVBInfo->IF_DEF_LVDS == 0) {
3915 if (pVBInfo->LCDResInfo == Panel1600x1200) {
3916 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3917 if (yres == 1024)
3918 yres = 1056;
3919 }
3920 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003921
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303922 if (pVBInfo->LCDResInfo == Panel1280x1024) {
3923 if (yres == 400)
3924 yres = 405;
3925 else if (yres == 350)
3926 yres = 360;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003927
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303928 if (pVBInfo->LCDInfo & LCDVESATiming) {
3929 if (yres == 360)
3930 yres = 375;
3931 }
3932 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003933
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303934 if (pVBInfo->LCDResInfo == Panel1024x768) {
3935 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3936 if (!(pVBInfo->LCDInfo
3937 & LCDNonExpanding)) {
3938 if (yres == 350)
3939 yres = 357;
3940 else if (yres == 400)
3941 yres = 420;
3942 else if (yres == 480)
3943 yres = 525;
3944 }
3945 }
3946 }
3947 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003948
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303949 if (xres == 720)
3950 xres = 640;
3951 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003952
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303953 pVBInfo->VGAHDE = xres;
3954 pVBInfo->HDE = xres;
3955 pVBInfo->VGAVDE = yres;
3956 pVBInfo->VDE = yres;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003957}
3958
Bill Pemberton80adad82010-06-17 13:10:51 -04003959unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003960{
3961
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303962 if ((((pVBInfo->VBInfo & SetCRT2ToLCD) | SetCRT2ToLCDA))
3963 && (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
3964 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003965
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303966 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003967}
3968
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303969void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
3970 unsigned short RefreshRateTableIndex,
3971 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003972{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303973 unsigned short tempax = 0, tempbx, modeflag, resinfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003974
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303975 struct XGI_LCDDataStruct *LCDPtr = NULL;
3976 struct XGI_TVDataStruct *TVPtr = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003977
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303978 if (ModeNo <= 0x13) {
3979 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
3980 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
3981 } else {
3982 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
3983 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3984 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003985
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303986 pVBInfo->NewFlickerMode = 0;
3987 pVBInfo->RVBHRS = 50;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003988
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303989 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3990 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3991 pVBInfo);
3992 return;
3993 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003994
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303995 tempbx = 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003996
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303997 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3998 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
3999 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4000 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004001
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304002 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
4003 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
4004 pVBInfo->VGAHT = LCDPtr->VGAHT;
4005 pVBInfo->VGAVT = LCDPtr->VGAVT;
4006 pVBInfo->HT = LCDPtr->LCDHT;
4007 pVBInfo->VT = LCDPtr->LCDVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004008
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304009 if (pVBInfo->LCDResInfo == Panel1024x768) {
4010 tempax = 1024;
4011 tempbx = 768;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004012
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304013 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4014 if (pVBInfo->VGAVDE == 357)
4015 tempbx = 527;
4016 else if (pVBInfo->VGAVDE == 420)
4017 tempbx = 620;
4018 else if (pVBInfo->VGAVDE == 525)
4019 tempbx = 775;
4020 else if (pVBInfo->VGAVDE == 600)
4021 tempbx = 775;
4022 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4023 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4024 else
4025 tempbx = 768;
4026 } else
4027 tempbx = 768;
4028 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4029 tempax = 1024;
4030 tempbx = 768;
4031 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4032 tempax = 1280;
4033 if (pVBInfo->VGAVDE == 360)
4034 tempbx = 768;
4035 else if (pVBInfo->VGAVDE == 375)
4036 tempbx = 800;
4037 else if (pVBInfo->VGAVDE == 405)
4038 tempbx = 864;
4039 else
4040 tempbx = 1024;
4041 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4042 tempax = 1280;
4043 tempbx = 1024;
4044 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4045 tempax = 1280;
4046 if (pVBInfo->VGAVDE == 350)
4047 tempbx = 700;
4048 else if (pVBInfo->VGAVDE == 400)
4049 tempbx = 800;
4050 else if (pVBInfo->VGAVDE == 1024)
4051 tempbx = 960;
4052 else
4053 tempbx = 960;
4054 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4055 tempax = 1400;
4056 tempbx = 1050;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004057
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304058 if (pVBInfo->VGAVDE == 1024) {
4059 tempax = 1280;
4060 tempbx = 1024;
4061 }
4062 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4063 tempax = 1600;
4064 tempbx = 1200; /* alan 10/14/2003 */
4065 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4066 if (pVBInfo->VGAVDE == 350)
4067 tempbx = 875;
4068 else if (pVBInfo->VGAVDE == 400)
4069 tempbx = 1000;
4070 }
4071 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004072
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304073 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4074 tempax = pVBInfo->VGAHDE;
4075 tempbx = pVBInfo->VGAVDE;
4076 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004077
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304078 pVBInfo->HDE = tempax;
4079 pVBInfo->VDE = tempbx;
4080 return;
4081 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004082
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304083 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4084 tempbx = 4;
4085 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4086 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4087 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004088
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304089 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4090 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4091 pVBInfo->VGAHT = TVPtr->VGAHT;
4092 pVBInfo->VGAVT = TVPtr->VGAVT;
4093 pVBInfo->HDE = TVPtr->TVHDE;
4094 pVBInfo->VDE = TVPtr->TVVDE;
4095 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4096 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004097
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304098 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4099 if (resinfo == 0x08)
4100 pVBInfo->NewFlickerMode = 0x40;
4101 else if (resinfo == 0x09)
4102 pVBInfo->NewFlickerMode = 0x40;
4103 else if (resinfo == 0x12)
4104 pVBInfo->NewFlickerMode = 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004105
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304106 if (pVBInfo->VGAVDE == 350)
4107 pVBInfo->TVInfo |= TVSimuMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004108
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304109 tempax = ExtHiTVHT;
4110 tempbx = ExtHiTVVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004111
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304112 if (pVBInfo->VBInfo & SetInSlaveMode) {
4113 if (pVBInfo->TVInfo & TVSimuMode) {
4114 tempax = StHiTVHT;
4115 tempbx = StHiTVVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004116
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304117 if (!(modeflag & Charx8Dot)) {
4118 tempax = StHiTextTVHT;
4119 tempbx = StHiTextTVVT;
4120 }
4121 }
4122 }
4123 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4124 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4125 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4126 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4127 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004128
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304129 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4130 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4131 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4132 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4133 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4134 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4135 if (pVBInfo->TVInfo & NTSC1024x768)
4136 tempax = NTSC1024x768HT;
4137 }
4138 } else {
4139 tempax = PALHT;
4140 tempbx = PALVT;
4141 if (!(pVBInfo->TVInfo & SetPALTV)) {
4142 tempax = NTSCHT;
4143 tempbx = NTSCVT;
4144 if (pVBInfo->TVInfo & NTSC1024x768)
4145 tempax = NTSC1024x768HT;
4146 }
4147 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004148
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304149 pVBInfo->HT = tempax;
4150 pVBInfo->VT = tempbx;
4151 return;
4152 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004153}
4154
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304155void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4156 unsigned short RefreshRateTableIndex,
4157 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004158{
Bill Pemberton108afbf2010-06-17 13:10:47 -04004159 unsigned char di_0, di_1, tempal;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004160
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304161 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4162 pVBInfo);
4163 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4164 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004165
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304166 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4167 /* 301 */
4168 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, 0x10);
4169 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4170 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4171 } else { /* 301b/302b/301lv/302lv */
4172 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4173 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4174 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004175
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304176 XGINew_SetReg1(pVBInfo->Part4Port, 0x00, 0x12);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004177
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304178 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4179 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x28);
4180 else
4181 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x08);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004182}
4183
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004184/* --------------------------------------------------------------------- */
4185/* Function : XGI_GETLCDVCLKPtr */
4186/* Input : */
4187/* Output : al -> VCLK Index */
4188/* Description : */
4189/* --------------------------------------------------------------------- */
Bill Pemberton108afbf2010-06-17 13:10:47 -04004190void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304191 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004192{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304193 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004194
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304195 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4196 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
4197 if (pVBInfo->LCDInfo & EnableScalingLCD)
4198 return;
4199 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004200
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304201 /* index = XGI_GetLCDCapPtr(pVBInfo); */
4202 index = XGI_GetLCDCapPtr1(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004203
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304204 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
4205 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
4206 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
4207 } else { /* LCDA */
4208 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
4209 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
4210 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004211 }
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304212 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004213}
4214
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304215unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
4216 unsigned short ModeNo, unsigned short ModeIdIndex,
4217 struct vb_device_info *pVBInfo)
4218{
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004219
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304220 unsigned short index, modeflag;
4221 unsigned short tempbx;
4222 unsigned char tempal;
4223 unsigned char *CHTVVCLKPtr = NULL;
4224
4225 if (ModeNo <= 0x13)
4226 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4227 else
4228 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4229
4230 if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
4231 & EnableScalingLCD))) { /* {LCDA/LCDB} */
4232 index = XGI_GetLCDCapPtr(pVBInfo);
4233 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
4234
4235 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
4236 return tempal;
4237
4238 /* {TV} */
4239 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4240 | VB_XGI302LV | VB_XGI301C)) {
4241 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4242 tempal = HiTVVCLKDIV2;
4243 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4244 tempal = HiTVVCLK;
4245 if (pVBInfo->TVInfo & TVSimuMode) {
4246 tempal = HiTVSimuVCLK;
4247 if (!(modeflag & Charx8Dot))
4248 tempal = HiTVTextVCLK;
4249
4250 }
4251 return tempal;
4252 }
4253
4254 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4255 tempal = YPbPr750pVCLK;
4256 return tempal;
4257 }
4258
4259 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4260 tempal = YPbPr525pVCLK;
4261 return tempal;
4262 }
4263
4264 tempal = NTSC1024VCLK;
4265
4266 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
4267 tempal = TVVCLKDIV2;
4268 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4269 tempal = TVVCLK;
4270 }
4271
4272 if (pVBInfo->VBInfo & SetCRT2ToTV)
4273 return tempal;
4274 }
4275 /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
4276 if (ModeNo<=0x13)
4277 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4278 else
4279 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4280 *tempal = *tempal & 0x1F;
4281 tempbx = 0;
4282 if (pVBInfo->TVInfo & SetPALTV)
4283 tempbx = tempbx + 2;
4284 if (pVBInfo->TVInfo & SetCHTVOverScan)
4285 tempbx++;
4286 tempbx = tempbx << 1;
4287 } */
4288 } /* {End of VB} */
4289
4290 if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
4291 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4292 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
4293 if (ModeNo <= 0x13) {
4294 tempal
4295 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4296 } else {
4297 tempal
4298 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4299 }
4300
4301 tempal = tempal & 0x0F;
4302 tempbx = 0;
4303
4304 if (pVBInfo->TVInfo & SetPALTV)
4305 tempbx = tempbx + 2;
4306
4307 if (pVBInfo->TVInfo & SetCHTVOverScan)
4308 tempbx++;
4309
4310 /** tempbx = tempbx << 1; CH7007 ? **/
4311
4312 /* [Billy]07/05/29 CH7007 */
4313 if (pVBInfo->IF_DEF_CH7007 == 1) {
4314 switch (tempbx) {
4315 case 0:
4316 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
4317 break;
4318 case 1:
4319 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
4320 break;
4321 case 2:
4322 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
4323 break;
4324 case 3:
4325 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
4326 break;
4327 default:
4328 break;
4329
4330 }
4331 }
4332 /* else {
4333 switch(tempbx) {
4334 case 0:
4335 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
4336 break;
4337 case 1:
4338 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
4339 break;
4340 case 2:
4341 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
4342 break;
4343 case 3:
4344 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
4345 break;
4346 default:
4347 break;
4348 }
4349 }
4350 */
4351
4352 tempal = CHTVVCLKPtr[tempal];
4353 return tempal;
4354 }
4355
4356 }
4357
4358 tempal = (unsigned char) XGINew_GetReg2((pVBInfo->P3ca + 0x02));
4359 tempal = tempal >> 2;
4360 tempal &= 0x03;
4361
4362 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
4363 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
4364
4365 if (ModeNo <= 0x13)
4366 return tempal;
4367
4368 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
4369 return tempal;
4370}
4371
4372void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
4373 unsigned char *di_1, struct vb_device_info *pVBInfo)
4374{
4375 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
4376 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
4377 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
4378 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
4379 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
4380 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
4381 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
4382 & ProgrammingCRT2)) {
4383 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
4384 *di_1 = XGI_VBVCLKData[tempal].SR2C;
4385 }
4386 } else {
4387 *di_0 = XGI_VCLKData[tempal].SR2B;
4388 *di_1 = XGI_VCLKData[tempal].SR2C;
4389 }
4390}
4391
4392static void XGI_SetCRT2Offset(unsigned short ModeNo,
4393 unsigned short ModeIdIndex,
4394 unsigned short RefreshRateTableIndex,
4395 struct xgi_hw_device_info *HwDeviceExtension,
4396 struct vb_device_info *pVBInfo)
4397{
4398 unsigned short offset;
4399 unsigned char temp;
4400
4401 if (pVBInfo->VBInfo & SetInSlaveMode)
4402 return;
4403
4404 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4405 HwDeviceExtension, pVBInfo);
4406 temp = (unsigned char) (offset & 0xFF);
4407 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp);
4408 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4409 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, temp);
4410 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4411 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4412}
4413
4414unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
4415 unsigned short RefreshRateTableIndex,
4416 struct xgi_hw_device_info *HwDeviceExtension,
4417 struct vb_device_info *pVBInfo)
4418{
4419 unsigned short temp, colordepth, modeinfo, index, infoflag,
4420 ColorDepth[] = { 0x01, 0x02, 0x04 };
4421
4422 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4423 if (ModeNo <= 0x14)
4424 infoflag = 0;
4425 else
4426 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4427
4428 index = (modeinfo >> 8) & 0xFF;
4429
4430 temp = pVBInfo->ScreenOffset[index];
4431
4432 if (infoflag & InterlaceMode)
4433 temp = temp << 1;
4434
4435 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4436
4437 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4438 temp = ModeNo - 0x7C;
4439 colordepth = ColorDepth[temp];
4440 temp = 0x6B;
4441 if (infoflag & InterlaceMode)
4442 temp = temp << 1;
4443 return temp * colordepth;
4444 } else {
4445 return temp * colordepth;
4446 }
4447}
4448
Randy Dunlap89229672010-08-10 08:46:44 -07004449static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004450{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304451 XGINew_SetReg1(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
4452 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004453}
4454
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004455void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304456 struct xgi_hw_device_info *HwDeviceExtension,
4457 unsigned short RefreshRateTableIndex,
4458 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004459{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304460 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004461
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304462 if (ModeNo > 0x13) {
4463 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4464 CRT1Index &= IndexMask;
4465 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4466 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004467
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304468 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4469 HwDeviceExtension, pVBInfo);
4470 XGI_SetCRT2FIFO(pVBInfo);
4471 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004472
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304473 for (tempcx = 4; tempcx < 7; tempcx++)
4474 XGINew_SetReg1(pVBInfo->Part1Port, tempcx, 0x0);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004475
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304476 XGINew_SetReg1(pVBInfo->Part1Port, 0x50, 0x00);
4477 XGINew_SetReg1(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004478}
4479
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004480void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304481 struct xgi_hw_device_info *HwDeviceExtension,
4482 unsigned short RefreshRateTableIndex,
4483 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004484{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304485 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4486 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004487
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304488 if (ModeNo > 0x13) {
4489 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4490 CRT1Index &= IndexMask;
4491 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004492 }
4493
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304494 if (ModeNo <= 0x13)
4495 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4496 else
4497 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004498
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304499 /* bainy change table name */
4500 if (modeflag & HalfDCLK) {
4501 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4502 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4503 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4504 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4505 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4506 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4507 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4508 pushbx = pVBInfo->VGAHDE / 2 + 16;
4509 tempcx = tempcx >> 1;
4510 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4511 tempcx += tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004512
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304513 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4514 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4515 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4516 & 0xC0) << 2);
4517 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4518 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4519 tempcx &= 0x1F;
4520 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4521 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4522 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4523 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004524
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304525 tempbx += 4;
4526 tempcx += 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004527
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304528 if (tempcx > (pVBInfo->VGAHT / 2))
4529 tempcx = pVBInfo->VGAHT / 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004530
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304531 temp = tempbx & 0x00FF;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004532
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304533 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4534 } else {
4535 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4536 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4537 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4538 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4539 temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4540 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4541 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4542 pushbx = pVBInfo->VGAHDE + 16;
4543 tempcx = tempcx >> 1;
4544 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4545 tempcx += tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004546
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304547 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4548 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4549 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
4550 & 0xC0) << 2);
4551 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4552 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4553 tempcx &= 0x1F;
4554 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4555 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4556 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4557 tempbx += 16;
4558 tempcx += 16;
4559 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004560
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304561 if (tempcx > pVBInfo->VGAHT)
4562 tempcx = pVBInfo->VGAHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004563
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304564 temp = tempbx & 0x00FF;
4565 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4566 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004567
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304568 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4569 tempbx = pushbx;
4570 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4571 tempax |= (tempbx & 0xFF00);
4572 temp = (tempax & 0xFF00) >> 8;
4573 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4574 temp = tempcx & 0x00FF;
4575 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp);
4576 tempcx = (pVBInfo->VGAVT - 1);
4577 temp = tempcx & 0x00FF;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004578
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304579 if (pVBInfo->IF_DEF_CH7005 == 1) {
4580 if (pVBInfo->VBInfo & 0x0C)
4581 temp--;
4582 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004583
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304584 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4585 tempbx = pVBInfo->VGAVDE - 1;
4586 temp = tempbx & 0x00FF;
4587 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, temp);
4588 temp = ((tempbx & 0xFF00) << 3) >> 8;
4589 temp |= ((tempcx & 0xFF00) >> 8);
4590 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004591
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304592 tempax = pVBInfo->VGAVDE;
4593 tempbx = pVBInfo->VGAVDE;
4594 tempcx = pVBInfo->VGAVT;
4595 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
4596 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004597
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304598 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4599 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4600 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004601
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304602 if (temp & 0x04)
4603 tempbx |= 0x0100;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004604
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304605 if (temp & 0x080)
4606 tempbx |= 0x0200;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004607
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304608 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004609
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304610 if (temp & 0x08)
4611 tempbx |= 0x0400;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004612
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304613 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4614 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4615 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004616
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304617 temp = tempbx & 0x00FF;
4618 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4619 temp = ((tempbx & 0xFF00) >> 8) << 4;
4620 temp = ((tempcx & 0x000F) | (temp));
4621 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, temp);
4622 tempax = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004623
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304624 if (modeflag & DoubleScanMode)
4625 tempax |= 0x80;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004626
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304627 if (modeflag & HalfDCLK)
4628 tempax |= 0x40;
4629
4630 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004631}
4632
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304633void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4634 struct xgi_hw_device_info *HwDeviceExtension,
4635 unsigned short RefreshRateTableIndex,
4636 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004637{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304638 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4639 modeflag, CRT1Index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004640
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304641 if (ModeNo <= 0x13) {
4642 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4643 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4644 } else {
4645 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4646 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4647 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4648 CRT1Index &= IndexMask;
4649 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004650
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304651 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4652 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004653
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304654 temp = 0xFF; /* set MAX HT */
4655 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4656 /* if (modeflag & Charx8Dot) */
4657 /* tempcx = 0x08; */
4658 /* else */
4659 tempcx = 0x08;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004660
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304661 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4662 modeflag |= Charx8Dot;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004663
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304664 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004665
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304666 if (modeflag & HalfDCLK)
4667 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004668
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304669 tempax = (tempax / tempcx) - 1;
4670 tempbx |= ((tempax & 0x00FF) << 8);
4671 temp = tempax & 0x00FF;
4672 XGINew_SetReg1(pVBInfo->Part1Port, 0x04, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004673
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304674 temp = (tempbx & 0xFF00) >> 8;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004675
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304676 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4677 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4678 | VB_XGI302LV | VB_XGI301C)))
4679 temp += 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004680
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304681 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4682 if (pVBInfo->VBType & VB_XGI301LV) {
4683 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4684 if (resinfo == 7)
4685 temp -= 2;
4686 }
4687 } else if (resinfo == 7) {
4688 temp -= 2;
4689 }
4690 }
4691 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004692
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304693 XGINew_SetReg1(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
4694 XGINew_SetReg1(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004695
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304696 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4697 if (pVBInfo->VBInfo & SetCRT2ToTV)
4698 tempax = pVBInfo->VGAHT;
4699 else
4700 tempax = XGI_GetVGAHT2(pVBInfo);
4701 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004702
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304703 if (tempax >= pVBInfo->VGAHT)
4704 tempax = pVBInfo->VGAHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004705
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304706 if (modeflag & HalfDCLK)
4707 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004708
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304709 tempax = (tempax / tempcx) - 5;
4710 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4711 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4712 temp = (tempbx & 0x00FF) - 1;
4713 if (!(modeflag & HalfDCLK)) {
4714 temp -= 6;
4715 if (pVBInfo->TVInfo & TVSimuMode) {
4716 temp -= 4;
4717 if (ModeNo > 0x13)
4718 temp -= 10;
4719 }
4720 }
4721 } else {
4722 /* tempcx = tempbx & 0x00FF ; */
4723 tempbx = (tempbx & 0xFF00) >> 8;
4724 tempcx = (tempcx + tempbx) >> 1;
4725 temp = (tempcx & 0x00FF) + 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004726
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304727 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4728 temp -= 1;
4729 if (!(modeflag & HalfDCLK)) {
4730 if ((modeflag & Charx8Dot)) {
4731 temp += 4;
4732 if (pVBInfo->VGAHDE >= 800)
4733 temp -= 6;
4734 }
4735 }
4736 } else {
4737 if (!(modeflag & HalfDCLK)) {
4738 temp -= 4;
4739 if (pVBInfo->LCDResInfo != Panel1280x960) {
4740 if (pVBInfo->VGAHDE >= 800) {
4741 temp -= 7;
4742 if (pVBInfo->ModeType
4743 == ModeEGA) {
4744 if (pVBInfo->VGAVDE
4745 == 1024) {
4746 temp += 15;
4747 if (pVBInfo->LCDResInfo
4748 != Panel1280x1024) {
4749 temp
4750 += 7;
4751 }
4752 }
4753 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004754
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304755 if (pVBInfo->VGAHDE >= 1280) {
4756 if (pVBInfo->LCDResInfo
4757 != Panel1280x960) {
4758 if (pVBInfo->LCDInfo
4759 & LCDNonExpanding) {
4760 temp
4761 += 28;
4762 }
4763 }
4764 }
4765 }
4766 }
4767 }
4768 }
4769 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004770
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304771 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
4772 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004773
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304774 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4775 if (pVBInfo->TVInfo & TVSimuMode) {
4776 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
4777 == 0x11) || (ModeNo == 0x13) || (ModeNo
4778 == 0x0F)) {
4779 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, 0x5b);
4780 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0x03);
4781 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004782
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304783 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
4784 if (pVBInfo->TVInfo & SetNTSCTV) {
4785 XGINew_SetReg1(pVBInfo->Part1Port,
4786 0x07, 0x2A);
4787 XGINew_SetReg1(pVBInfo->Part1Port,
4788 0x08, 0x61);
4789 } else {
4790 XGINew_SetReg1(pVBInfo->Part1Port,
4791 0x07, 0x2A);
4792 XGINew_SetReg1(pVBInfo->Part1Port,
4793 0x08, 0x41);
4794 XGINew_SetReg1(pVBInfo->Part1Port,
4795 0x0C, 0xF0);
4796 }
4797 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004798
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304799 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
4800 == 0x07)) {
4801 if (pVBInfo->TVInfo & SetNTSCTV) {
4802 XGINew_SetReg1(pVBInfo->Part1Port,
4803 0x07, 0x54);
4804 XGINew_SetReg1(pVBInfo->Part1Port,
4805 0x08, 0x00);
4806 } else {
4807 XGINew_SetReg1(pVBInfo->Part1Port,
4808 0x07, 0x55);
4809 XGINew_SetReg1(pVBInfo->Part1Port,
4810 0x08, 0x00);
4811 XGINew_SetReg1(pVBInfo->Part1Port,
4812 0x0C, 0xF0);
4813 }
4814 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004815
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304816 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
4817 == 0x0D) || (ModeNo == 0x50)) {
4818 if (pVBInfo->TVInfo & SetNTSCTV) {
4819 XGINew_SetReg1(pVBInfo->Part1Port,
4820 0x07, 0x30);
4821 XGINew_SetReg1(pVBInfo->Part1Port,
4822 0x08, 0x03);
4823 } else {
4824 XGINew_SetReg1(pVBInfo->Part1Port,
4825 0x07, 0x2f);
4826 XGINew_SetReg1(pVBInfo->Part1Port,
4827 0x08, 0x02);
4828 }
4829 }
4830 }
4831 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004832
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304833 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
4834 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
4835 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004836
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304837 tempbx = pVBInfo->VGAVT;
4838 push1 = tempbx;
4839 tempcx = 0x121;
4840 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004841
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304842 if (tempbx == 357)
4843 tempbx = 350;
4844 if (tempbx == 360)
4845 tempbx = 350;
4846 if (tempbx == 375)
4847 tempbx = 350;
4848 if (tempbx == 405)
4849 tempbx = 400;
4850 if (tempbx == 525)
4851 tempbx = 480;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004852
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304853 push2 = tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004854
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304855 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4856 if (pVBInfo->LCDResInfo == Panel1024x768) {
4857 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4858 if (tempbx == 350)
4859 tempbx += 5;
4860 if (tempbx == 480)
4861 tempbx += 5;
4862 }
4863 }
4864 }
4865 tempbx--;
4866 temp = tempbx & 0x00FF;
4867 tempbx--;
4868 temp = tempbx & 0x00FF;
4869 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
4870 tempbx = push2;
4871 tempbx--;
4872 temp = tempbx & 0x00FF;
4873 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004874
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304875 if (tempbx & 0x0100)
4876 tempcx |= 0x0002;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004877
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304878 tempax = 0x000B;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004879
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304880 if (modeflag & DoubleScanMode)
4881 tempax |= 0x08000;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004882
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304883 if (tempbx & 0x0200)
4884 tempcx |= 0x0040;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004885
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304886 temp = (tempax & 0xFF00) >> 8;
4887 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004888
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304889 if (tempbx & 0x0400)
4890 tempcx |= 0x0600;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004891
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304892 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
4893
4894 tempax = push1;
4895 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
4896 tempax = tempax >> 2;
4897 push1 = tempax; /* push ax */
4898
4899 if (resinfo != 0x09) {
4900 tempax = tempax << 1;
4901 tempbx += tempax;
4902 }
4903
4904 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4905 if (pVBInfo->VBType & VB_XGI301LV) {
4906 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
4907 tempbx -= 10;
4908 } else {
4909 if (pVBInfo->TVInfo & TVSimuMode) {
4910 if (pVBInfo->TVInfo & SetPALTV) {
4911 if (pVBInfo->VBType
4912 & VB_XGI301LV) {
4913 if (!(pVBInfo->TVInfo
4914 & (SetYPbPrMode525p
4915 | SetYPbPrMode750p
4916 | SetYPbPrMode1080i)))
4917 tempbx += 40;
4918 } else {
4919 tempbx += 40;
4920 }
4921 }
4922 }
4923 }
4924 } else {
4925 tempbx -= 10;
4926 }
4927 } else {
4928 if (pVBInfo->TVInfo & TVSimuMode) {
4929 if (pVBInfo->TVInfo & SetPALTV) {
4930 if (pVBInfo->VBType & VB_XGI301LV) {
4931 if (!(pVBInfo->TVInfo
4932 & (SetYPbPrMode525p
4933 | SetYPbPrMode750p
4934 | SetYPbPrMode1080i)))
4935 tempbx += 40;
4936 } else {
4937 tempbx += 40;
4938 }
4939 }
4940 }
4941 }
4942 tempax = push1;
4943 tempax = tempax >> 2;
4944 tempax++;
4945 tempax += tempbx;
4946 push1 = tempax; /* push ax */
4947
4948 if ((pVBInfo->TVInfo & SetPALTV)) {
4949 if (tempbx <= 513) {
4950 if (tempax >= 513)
4951 tempbx = 513;
4952 }
4953 }
4954
4955 temp = tempbx & 0x00FF;
4956 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4957 tempbx--;
4958 temp = tempbx & 0x00FF;
4959 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4960
4961 if (tempbx & 0x0100)
4962 tempcx |= 0x0008;
4963
4964 if (tempbx & 0x0200)
4965 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
4966
4967 tempbx++;
4968
4969 if (tempbx & 0x0100)
4970 tempcx |= 0x0004;
4971
4972 if (tempbx & 0x0200)
4973 tempcx |= 0x0080;
4974
4975 if (tempbx & 0x0400)
4976 tempcx |= 0x0C00;
4977
4978 tempbx = push1; /* pop ax */
4979 temp = tempbx & 0x00FF;
4980 temp &= 0x0F;
4981 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
4982
4983 if (tempbx & 0x0010)
4984 tempcx |= 0x2000;
4985
4986 temp = tempcx & 0x00FF;
4987 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
4988 temp = (tempcx & 0x0FF00) >> 8;
4989 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
4990 tempax = modeflag;
4991 temp = (tempax & 0xFF00) >> 8;
4992
4993 temp = (temp >> 1) & 0x09;
4994
4995 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4996 temp |= 0x01;
4997
4998 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
4999 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
5000 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
5001
5002 if (pVBInfo->LCDInfo & LCDRGB18Bit)
5003 temp = 0x80;
5004 else
5005 temp = 0x00;
5006
5007 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5008
5009 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005010}
5011
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305012void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5013 unsigned short RefreshRateTableIndex,
5014 struct xgi_hw_device_info *HwDeviceExtension,
5015 struct vb_device_info *pVBInfo)
5016{
5017 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5018 modeflag, resinfo, crt2crtc;
5019 unsigned char *TimingPoint;
5020
5021 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5022
5023 if (ModeNo <= 0x13) {
5024 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5025 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5026 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5027 } else {
5028 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5029 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5030 crt2crtc
5031 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5032 }
5033
5034 tempax = 0;
5035
5036 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5037 tempax |= 0x0800;
5038
5039 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5040 tempax |= 0x0400;
5041
5042 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5043 tempax |= 0x0200;
5044
5045 if (!(pVBInfo->TVInfo & SetPALTV))
5046 tempax |= 0x1000;
5047
5048 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5049 tempax |= 0x0100;
5050
5051 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5052 tempax &= 0xfe00;
5053
5054 tempax = (tempax & 0xff00) >> 8;
5055
5056 XGINew_SetReg1(pVBInfo->Part2Port, 0x0, tempax);
5057 TimingPoint = pVBInfo->NTSCTiming;
5058
5059 if (pVBInfo->TVInfo & SetPALTV)
5060 TimingPoint = pVBInfo->PALTiming;
5061
5062 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5063 TimingPoint = pVBInfo->HiTVExtTiming;
5064
5065 if (pVBInfo->VBInfo & SetInSlaveMode)
5066 TimingPoint = pVBInfo->HiTVSt2Timing;
5067
5068 if (pVBInfo->SetFlag & TVSimuMode)
5069 TimingPoint = pVBInfo->HiTVSt1Timing;
5070
5071 if (!(modeflag & Charx8Dot))
5072 TimingPoint = pVBInfo->HiTVTextTiming;
5073 }
5074
5075 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5076 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5077 TimingPoint = pVBInfo->YPbPr525iTiming;
5078
5079 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5080 TimingPoint = pVBInfo->YPbPr525pTiming;
5081
5082 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5083 TimingPoint = pVBInfo->YPbPr750pTiming;
5084 }
5085
5086 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5087 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]);
5088
5089 for (i = 0x39; i <= 0x45; i++, j++)
5090 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
5091
5092 if (pVBInfo->VBInfo & SetCRT2ToTV)
5093 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5094
5095 temp = pVBInfo->NewFlickerMode;
5096 temp &= 0x80;
5097 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5098
5099 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5100 tempax = 950;
5101
5102 if (pVBInfo->TVInfo & SetPALTV)
5103 tempax = 520;
5104 else
5105 tempax = 440;
5106
5107 if (pVBInfo->VDE <= tempax) {
5108 tempax -= pVBInfo->VDE;
5109 tempax = tempax >> 2;
5110 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5111 push1 = tempax;
5112 temp = (tempax & 0xFF00) >> 8;
5113 temp += (unsigned short) TimingPoint[0];
5114
5115 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5116 | VB_XGI302LV | VB_XGI301C)) {
5117 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5118 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5119 | SetCRT2ToYPbPr)) {
5120 tempcx = pVBInfo->VGAHDE;
5121 if (tempcx >= 1024) {
5122 temp = 0x17; /* NTSC */
5123 if (pVBInfo->TVInfo & SetPALTV)
5124 temp = 0x19; /* PAL */
5125 }
5126 }
5127 }
5128
5129 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5130 tempax = push1;
5131 temp = (tempax & 0xFF00) >> 8;
5132 temp += TimingPoint[1];
5133
5134 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5135 | VB_XGI302LV | VB_XGI301C)) {
5136 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5137 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5138 | SetCRT2ToYPbPr))) {
5139 tempcx = pVBInfo->VGAHDE;
5140 if (tempcx >= 1024) {
5141 temp = 0x1D; /* NTSC */
5142 if (pVBInfo->TVInfo & SetPALTV)
5143 temp = 0x52; /* PAL */
5144 }
5145 }
5146 }
5147 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, temp);
5148 }
5149
5150 /* 301b */
5151 tempcx = pVBInfo->HT;
5152
5153 if (XGI_IsLCDDualLink(pVBInfo))
5154 tempcx = tempcx >> 1;
5155
5156 tempcx -= 2;
5157 temp = tempcx & 0x00FF;
5158 XGINew_SetReg1(pVBInfo->Part2Port, 0x1B, temp);
5159
5160 temp = (tempcx & 0xFF00) >> 8;
5161 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5162
5163 tempcx = pVBInfo->HT >> 1;
5164 push1 = tempcx; /* push cx */
5165 tempcx += 7;
5166
5167 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5168 tempcx -= 4;
5169
5170 temp = tempcx & 0x00FF;
5171 temp = temp << 4;
5172 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5173
5174 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5175 tempbx += tempcx;
5176 push2 = tempbx;
5177 temp = tempbx & 0x00FF;
5178 XGINew_SetReg1(pVBInfo->Part2Port, 0x24, temp);
5179 temp = (tempbx & 0xFF00) >> 8;
5180 temp = temp << 4;
5181 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5182
5183 tempbx = push2;
5184 tempbx = tempbx + 8;
5185 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5186 tempbx = tempbx - 4;
5187 tempcx = tempbx;
5188 }
5189
5190 temp = (tempbx & 0x00FF) << 4;
5191 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5192
5193 j += 2;
5194 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5195 temp = tempcx & 0x00FF;
5196 XGINew_SetReg1(pVBInfo->Part2Port, 0x27, temp);
5197 temp = ((tempcx & 0xFF00) >> 8) << 4;
5198 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5199
5200 tempcx += 8;
5201 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5202 tempcx -= 4;
5203
5204 temp = tempcx & 0xFF;
5205 temp = temp << 4;
5206 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5207
5208 tempcx = push1; /* pop cx */
5209 j += 2;
5210 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5211 tempcx -= temp;
5212 temp = tempcx & 0x00FF;
5213 temp = temp << 4;
5214 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5215
5216 tempcx -= 11;
5217
5218 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5219 tempax = XGI_GetVGAHT2(pVBInfo);
5220 tempcx = tempax - 1;
5221 }
5222 temp = tempcx & 0x00FF;
5223 XGINew_SetReg1(pVBInfo->Part2Port, 0x2E, temp);
5224
5225 tempbx = pVBInfo->VDE;
5226
5227 if (pVBInfo->VGAVDE == 360)
5228 tempbx = 746;
5229 if (pVBInfo->VGAVDE == 375)
5230 tempbx = 746;
5231 if (pVBInfo->VGAVDE == 405)
5232 tempbx = 853;
5233
5234 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5235 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5236 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5237 | SetYPbPrMode750p)))
5238 tempbx = tempbx >> 1;
5239 } else
5240 tempbx = tempbx >> 1;
5241 }
5242
5243 tempbx -= 2;
5244 temp = tempbx & 0x00FF;
5245
5246 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5247 if (pVBInfo->VBType & VB_XGI301LV) {
5248 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5249 if (pVBInfo->VBInfo & SetInSlaveMode) {
5250 if (ModeNo == 0x2f)
5251 temp += 1;
5252 }
5253 }
5254 } else {
5255 if (pVBInfo->VBInfo & SetInSlaveMode) {
5256 if (ModeNo == 0x2f)
5257 temp += 1;
5258 }
5259 }
5260 }
5261
5262 XGINew_SetReg1(pVBInfo->Part2Port, 0x2F, temp);
5263
5264 temp = (tempcx & 0xFF00) >> 8;
5265 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5266
5267 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5268 if (pVBInfo->VBType & VB_XGI301LV) {
5269 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5270 temp |= 0x10;
5271
5272 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5273 temp |= 0x20;
5274 }
5275 } else {
5276 temp |= 0x10;
5277 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5278 temp |= 0x20;
5279 }
5280 }
5281
5282 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, temp);
5283
5284 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5285 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5286 tempbx = pVBInfo->VDE;
5287 tempcx = tempbx - 2;
5288
5289 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5290 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5291 | SetYPbPrMode750p)))
5292 tempbx = tempbx >> 1;
5293 }
5294
5295 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5296 temp = 0;
5297 if (tempcx & 0x0400)
5298 temp |= 0x20;
5299
5300 if (tempbx & 0x0400)
5301 temp |= 0x40;
5302
5303 XGINew_SetReg1(pVBInfo->Part4Port, 0x10, temp);
5304 }
5305
5306 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5307 XGINew_SetReg1(pVBInfo->Part2Port, 0x46, temp);
5308 temp = (tempbx - 3) & 0x00FF;
5309 XGINew_SetReg1(pVBInfo->Part2Port, 0x47, temp);
5310 }
5311
5312 tempbx = tempbx & 0x00FF;
5313
5314 if (!(modeflag & HalfDCLK)) {
5315 tempcx = pVBInfo->VGAHDE;
5316 if (tempcx >= pVBInfo->HDE) {
5317 tempbx |= 0x2000;
5318 tempax &= 0x00FF;
5319 }
5320 }
5321
5322 tempcx = 0x0101;
5323
5324 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5325 if (pVBInfo->VGAHDE >= 1024) {
5326 tempcx = 0x1920;
5327 if (pVBInfo->VGAHDE >= 1280) {
5328 tempcx = 0x1420;
5329 tempbx = tempbx & 0xDFFF;
5330 }
5331 }
5332 }
5333
5334 if (!(tempbx & 0x2000)) {
5335 if (modeflag & HalfDCLK)
5336 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5337
5338 push1 = tempbx;
5339 tempeax = pVBInfo->VGAHDE;
5340 tempebx = (tempcx & 0xFF00) >> 8;
5341 longtemp = tempeax * tempebx;
5342 tempecx = tempcx & 0x00FF;
5343 longtemp = longtemp / tempecx;
5344
5345 /* 301b */
5346 tempecx = 8 * 1024;
5347
5348 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5349 | VB_XGI302LV | VB_XGI301C)) {
5350 tempecx = tempecx * 8;
5351 }
5352
5353 longtemp = longtemp * tempecx;
5354 tempecx = pVBInfo->HDE;
5355 temp2 = longtemp % tempecx;
5356 tempeax = longtemp / tempecx;
5357 if (temp2 != 0)
5358 tempeax += 1;
5359
5360 tempax = (unsigned short) tempeax;
5361
5362 /* 301b */
5363 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5364 | VB_XGI302LV | VB_XGI301C)) {
5365 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5366 }
5367 /* end 301b */
5368
5369 tempbx = push1;
5370 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5371 | (tempbx & 0x00FF));
5372 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5373 | (tempax & 0x00FF));
5374 temp = (tempax & 0xFF00) >> 8;
5375 } else {
5376 temp = (tempax & 0x00FF) >> 8;
5377 }
5378
5379 XGINew_SetReg1(pVBInfo->Part2Port, 0x44, temp);
5380 temp = (tempbx & 0xFF00) >> 8;
5381 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5382 temp = tempcx & 0x00FF;
5383
5384 if (tempbx & 0x2000)
5385 temp = 0;
5386
5387 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5388 temp |= 0x18;
5389
5390 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5391 if (pVBInfo->TVInfo & SetPALTV) {
5392 tempbx = 0x0382;
5393 tempcx = 0x007e;
5394 } else {
5395 tempbx = 0x0369;
5396 tempcx = 0x0061;
5397 }
5398
5399 temp = tempbx & 0x00FF;
5400 XGINew_SetReg1(pVBInfo->Part2Port, 0x4b, temp);
5401 temp = tempcx & 0x00FF;
5402 XGINew_SetReg1(pVBInfo->Part2Port, 0x4c, temp);
5403
5404 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5405 temp = temp << 2;
5406 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5407
5408 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5409 temp |= 0x10;
5410
5411 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5412 temp |= 0x20;
5413
5414 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5415 temp |= 0x60;
5416 }
5417
5418 XGINew_SetReg1(pVBInfo->Part2Port, 0x4d, temp);
5419 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x43); /* 301b change */
5420 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5421
5422 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5423 if (pVBInfo->TVInfo & NTSC1024x768) {
5424 TimingPoint = XGI_NTSC1024AdjTime;
5425 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5426 XGINew_SetReg1(pVBInfo->Part2Port, i,
5427 TimingPoint[j]);
5428 }
5429 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, 0x72);
5430 }
5431 }
5432
5433 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5434 if (pVBInfo->VBType & VB_XGI301C) {
5435 if (pVBInfo->TVInfo & SetPALMTV)
5436 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x08,
5437 0x08); /* PALM Mode */
5438 }
5439
5440 if (pVBInfo->TVInfo & SetPALMTV) {
5441 tempax = (unsigned char) XGINew_GetReg1(pVBInfo->Part2Port,
5442 0x01);
5443 tempax--;
5444 XGINew_SetRegAND(pVBInfo->Part2Port, 0x01, tempax);
5445
5446 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5447 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xEF);
5448 }
5449
5450 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5451 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5452 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, 0x00);
5453 }
5454
5455 if (pVBInfo->VBInfo & SetCRT2ToTV)
5456 return;
5457}
5458
5459void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5460 struct xgi_hw_device_info *HwDeviceExtension,
5461 unsigned short RefreshRateTableIndex,
5462 struct vb_device_info *pVBInfo)
5463{
5464 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5465 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5466
5467 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5468
5469 if (ModeNo <= 0x13) {
5470 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5471 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5472 } else {
5473 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5474 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5475 CRT1Index
5476 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5477 CRT1Index &= IndexMask;
5478 }
5479
5480 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5481 return;
5482
5483 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5484
5485 if (XGI_IsLCDDualLink(pVBInfo))
5486 tempbx = tempbx >> 1;
5487
5488 tempbx -= 1;
5489 temp = tempbx & 0x00FF;
5490 XGINew_SetReg1(pVBInfo->Part2Port, 0x2C, temp);
5491 temp = (tempbx & 0xFF00) >> 8;
5492 temp = temp << 4;
5493 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5494 temp = 0x01;
5495
5496 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5497 if (pVBInfo->ModeType == ModeEGA) {
5498 if (pVBInfo->VGAHDE >= 1024) {
5499 temp = 0x02;
5500 if (pVBInfo->LCDInfo & LCDVESATiming)
5501 temp = 0x01;
5502 }
5503 }
5504 }
5505
5506 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, temp);
5507 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5508 push1 = tempbx;
5509 tempbx--;
5510 temp = tempbx & 0x00FF;
5511 XGINew_SetReg1(pVBInfo->Part2Port, 0x03, temp);
5512 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5513 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5514
5515 tempcx = pVBInfo->VT - 1;
5516 push2 = tempcx + 1;
5517 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5518 XGINew_SetReg1(pVBInfo->Part2Port, 0x19, temp);
5519 temp = (tempcx & 0xFF00) >> 8;
5520 temp = temp << 5;
5521 XGINew_SetReg1(pVBInfo->Part2Port, 0x1A, temp);
5522 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5523 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5524 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5525 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5526
5527 /* Customized LCDB Des no add */
5528 tempbx = 5;
5529 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5530 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5531 tempah = pVBInfo->LCDResInfo;
5532 tempah &= PanelResInfo;
5533
5534 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5535 tempbx = 1024;
5536 tempcx = 768;
5537 } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
5538 tempbx = 1280;
5539 tempcx = 1024;
5540 } else if (tempah == Panel1400x1050) {
5541 tempbx = 1400;
5542 tempcx = 1050;
5543 } else {
5544 tempbx = 1600;
5545 tempcx = 1200;
5546 }
5547
5548 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5549 tempbx = pVBInfo->HDE;
5550 tempcx = pVBInfo->VDE;
5551 }
5552
5553 pushbx = tempbx;
5554 tempax = pVBInfo->VT;
5555 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5556 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5557 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5558 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5559 tempbx = pVBInfo->LCDVDES;
5560 tempcx += tempbx;
5561
5562 if (tempcx >= tempax)
5563 tempcx -= tempax; /* lcdvdes */
5564
5565 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5566 XGINew_SetReg1(pVBInfo->Part2Port, 0x05, temp);
5567 temp = tempcx & 0x00FF;
5568 XGINew_SetReg1(pVBInfo->Part2Port, 0x06, temp);
5569 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5570 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5571 tempah = tempch;
5572 tempah = tempah << 3;
5573 tempah |= tempbh;
5574 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, tempah);
5575
5576 /* getlcdsync() */
5577 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5578 tempcx = tempbx;
5579 tempax = pVBInfo->VT;
5580 tempbx = pVBInfo->LCDVRS;
5581
5582 /* if (SetLCD_Info & EnableScalingLCD) */
5583 tempcx += tempbx;
5584 if (tempcx >= tempax)
5585 tempcx -= tempax;
5586
5587 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5588 XGINew_SetReg1(pVBInfo->Part2Port, 0x04, temp);
5589 temp = (tempbx & 0xFF00) >> 8;
5590 temp = temp << 4;
5591 temp |= (tempcx & 0x000F);
5592 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5593 tempcx = pushbx;
5594 tempax = pVBInfo->HT;
5595 tempbx = pVBInfo->LCDHDES;
5596 tempbx &= 0x0FFF;
5597
5598 if (XGI_IsLCDDualLink(pVBInfo)) {
5599 tempax = tempax >> 1;
5600 tempbx = tempbx >> 1;
5601 tempcx = tempcx >> 1;
5602 }
5603
5604 if (pVBInfo->VBType & VB_XGI302LV)
5605 tempbx += 1;
5606
5607 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5608 tempbx += 1;
5609
5610 tempcx += tempbx;
5611
5612 if (tempcx >= tempax)
5613 tempcx -= tempax;
5614
5615 temp = tempbx & 0x00FF;
5616 XGINew_SetReg1(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5617 temp = ((tempbx & 0xFF00) >> 8) << 4;
5618 XGINew_SetReg1(pVBInfo->Part2Port, 0x20, temp);
5619 temp = tempcx & 0x00FF;
5620 XGINew_SetReg1(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5621 temp = (tempcx & 0xFF00) >> 8;
5622 XGINew_SetReg1(pVBInfo->Part2Port, 0x25, temp);
5623
5624 /* getlcdsync() */
5625 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5626 tempcx = tempax;
5627 tempax = pVBInfo->HT;
5628 tempbx = pVBInfo->LCDHRS;
5629 /* if ( SetLCD_Info & EnableScalingLCD) */
5630 if (XGI_IsLCDDualLink(pVBInfo)) {
5631 tempax = tempax >> 1;
5632 tempbx = tempbx >> 1;
5633 tempcx = tempcx >> 1;
5634 }
5635
5636 if (pVBInfo->VBType & VB_XGI302LV)
5637 tempbx += 1;
5638
5639 tempcx += tempbx;
5640
5641 if (tempcx >= tempax)
5642 tempcx -= tempax;
5643
5644 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5645 XGINew_SetReg1(pVBInfo->Part2Port, 0x1C, temp);
5646
5647 temp = (tempbx & 0xFF00) >> 8;
5648 temp = temp << 4;
5649 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5650 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5651 XGINew_SetReg1(pVBInfo->Part2Port, 0x21, temp);
5652
5653 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5654 if (pVBInfo->VGAVDE == 525) {
5655 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5656 | VB_XGI301LV | VB_XGI302LV
5657 | VB_XGI301C)) {
5658 temp = 0xC6;
5659 } else
5660 temp = 0xC4;
5661
5662 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5663 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, 0xB3);
5664 }
5665
5666 if (pVBInfo->VGAVDE == 420) {
5667 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5668 | VB_XGI301LV | VB_XGI302LV
5669 | VB_XGI301C)) {
5670 temp = 0x4F;
5671 } else
5672 temp = 0x4E;
5673 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5674 }
5675 }
5676}
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005677
5678/* --------------------------------------------------------------------- */
5679/* Function : XGI_GetTap4Ptr */
5680/* Input : */
5681/* Output : di -> Tap4 Reg. Setting Pointer */
5682/* Description : */
5683/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04005684struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305685 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005686{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305687 unsigned short tempax, tempbx, i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005688
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305689 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005690
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305691 if (tempcx == 0) {
5692 tempax = pVBInfo->VGAHDE;
5693 tempbx = pVBInfo->HDE;
5694 } else {
5695 tempax = pVBInfo->VGAVDE;
5696 tempbx = pVBInfo->VDE;
5697 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005698
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305699 if (tempax < tempbx)
5700 return &EnlargeTap4Timing[0];
5701 else if (tempax == tempbx)
5702 return &NoScaleTap4Timing[0]; /* 1:1 */
5703 else
5704 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005705
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305706 if (pVBInfo->TVInfo & SetPALTV)
5707 Tap4TimingPtr = PALTap4Timing;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005708
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305709 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5710 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5711 Tap4TimingPtr = YPbPr525iTap4Timing;
5712 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5713 Tap4TimingPtr = YPbPr525pTap4Timing;
5714 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5715 Tap4TimingPtr = YPbPr750pTap4Timing;
5716 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005717
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305718 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5719 Tap4TimingPtr = HiTVTap4Timing;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005720
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305721 i = 0;
5722 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5723 if (Tap4TimingPtr[i].DE == tempax)
5724 break;
5725 i++;
5726 }
5727 return &Tap4TimingPtr[i];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005728}
5729
Bill Pemberton80adad82010-06-17 13:10:51 -04005730void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005731{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305732 unsigned short i, j;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005733
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305734 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005735
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305736 if (!(pVBInfo->VBType & VB_XGI301C))
5737 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005738
5739#ifndef Tap4
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305740 XGINew_SetRegAND(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005741#else /* Tap4 Setting */
5742
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305743 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5744 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5745 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005746
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305747 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5748 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
5749 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5750 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5751 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005752
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305753 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5754 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
5755 else
5756 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005757#endif
5758}
5759
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305760void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5761 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005762{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305763 unsigned short i;
5764 unsigned char *tempdi;
5765 unsigned short modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005766
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305767 if (ModeNo <= 0x13)
5768 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5769 else
5770 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005771
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305772 XGINew_SetReg1(pVBInfo->Part3Port, 0x00, 0x00);
5773 if (pVBInfo->TVInfo & SetPALTV) {
5774 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5775 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5776 } else {
5777 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xF5);
5778 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xB7);
5779 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005780
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305781 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5782 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005783
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305784 if (pVBInfo->TVInfo & SetPALMTV) {
5785 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5786 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5787 XGINew_SetReg1(pVBInfo->Part3Port, 0x3D, 0xA8);
5788 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005789
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305790 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
5791 & SetCRT2ToYPbPr)) {
5792 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5793 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005794
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305795 tempdi = pVBInfo->HiTVGroup3Data;
5796 if (pVBInfo->SetFlag & TVSimuMode) {
5797 tempdi = pVBInfo->HiTVGroup3Simu;
5798 if (!(modeflag & Charx8Dot))
5799 tempdi = pVBInfo->HiTVGroup3Text;
5800 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005801
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305802 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5803 tempdi = pVBInfo->Ren525pGroup3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005804
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305805 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5806 tempdi = pVBInfo->Ren750pGroup3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005807
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305808 for (i = 0; i <= 0x3E; i++)
5809 XGINew_SetReg1(pVBInfo->Part3Port, i, tempdi[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005810
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305811 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
5812 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5813 XGINew_SetReg1(pVBInfo->Part3Port, 0x28, 0x3f);
5814 }
5815 }
5816 return;
5817} /* {end of XGI_SetGroup3} */
5818
5819void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
5820 unsigned short RefreshRateTableIndex,
5821 struct xgi_hw_device_info *HwDeviceExtension,
5822 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005823{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305824 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005825
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305826 unsigned long tempebx, tempeax, templong;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005827
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305828 if (ModeNo <= 0x13)
5829 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5830 else
5831 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005832
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305833 temp = pVBInfo->RVBHCFACT;
5834 XGINew_SetReg1(pVBInfo->Part4Port, 0x13, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005835
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305836 tempbx = pVBInfo->RVBHCMAX;
5837 temp = tempbx & 0x00FF;
5838 XGINew_SetReg1(pVBInfo->Part4Port, 0x14, temp);
5839 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
5840 tempcx = pVBInfo->VGAHT - 1;
5841 temp = tempcx & 0x00FF;
5842 XGINew_SetReg1(pVBInfo->Part4Port, 0x16, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005843
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305844 temp = ((tempcx & 0xFF00) >> 8) << 3;
5845 temp2 |= temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005846
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305847 tempcx = pVBInfo->VGAVT - 1;
5848 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5849 tempcx -= 5;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005850
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305851 temp = tempcx & 0x00FF;
5852 XGINew_SetReg1(pVBInfo->Part4Port, 0x17, temp);
5853 temp = temp2 | ((tempcx & 0xFF00) >> 8);
5854 XGINew_SetReg1(pVBInfo->Part4Port, 0x15, temp);
5855 XGINew_SetRegOR(pVBInfo->Part4Port, 0x0D, 0x08);
5856 tempcx = pVBInfo->VBInfo;
5857 tempbx = pVBInfo->VGAHDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005858
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305859 if (modeflag & HalfDCLK)
5860 tempbx = tempbx >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005861
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305862 if (XGI_IsLCDDualLink(pVBInfo))
5863 tempbx = tempbx >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005864
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305865 if (tempcx & SetCRT2ToHiVisionTV) {
5866 temp = 0;
5867 if (tempbx <= 1024)
5868 temp = 0xA0;
5869 if (tempbx == 1280)
5870 temp = 0xC0;
5871 } else if (tempcx & SetCRT2ToTV) {
5872 temp = 0xA0;
5873 if (tempbx <= 800)
5874 temp = 0x80;
5875 } else {
5876 temp = 0x80;
5877 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5878 temp = 0;
5879 if (tempbx > 800)
5880 temp = 0x60;
5881 }
5882 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005883
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305884 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
5885 temp = 0x00;
5886 if (pVBInfo->VGAHDE == 1280)
5887 temp = 0x40;
5888 if (pVBInfo->VGAHDE == 1024)
5889 temp = 0x20;
5890 }
5891 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005892
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305893 tempebx = pVBInfo->VDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005894
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305895 if (tempcx & SetCRT2ToHiVisionTV) {
5896 if (!(temp & 0xE000))
5897 tempbx = tempbx >> 1;
5898 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005899
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305900 tempcx = pVBInfo->RVBHRS;
5901 temp = tempcx & 0x00FF;
5902 XGINew_SetReg1(pVBInfo->Part4Port, 0x18, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005903
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305904 tempeax = pVBInfo->VGAVDE;
5905 tempcx |= 0x04000;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005906
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305907 if (tempeax <= tempebx) {
5908 tempcx = (tempcx & (~0x4000));
5909 tempeax = pVBInfo->VGAVDE;
5910 } else {
5911 tempeax -= tempebx;
5912 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005913
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305914 templong = (tempeax * 256 * 1024) % tempebx;
5915 tempeax = (tempeax * 256 * 1024) / tempebx;
5916 tempebx = tempeax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005917
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305918 if (templong != 0)
5919 tempebx++;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005920
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305921 temp = (unsigned short) (tempebx & 0x000000FF);
5922 XGINew_SetReg1(pVBInfo->Part4Port, 0x1B, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005923
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305924 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
5925 XGINew_SetReg1(pVBInfo->Part4Port, 0x1A, temp);
5926 tempbx = (unsigned short) (tempebx >> 16);
5927 temp = tempbx & 0x00FF;
5928 temp = temp << 4;
5929 temp |= ((tempcx & 0xFF00) >> 8);
5930 XGINew_SetReg1(pVBInfo->Part4Port, 0x19, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005931
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305932 /* 301b */
5933 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5934 | VB_XGI302LV | VB_XGI301C)) {
5935 temp = 0x0028;
5936 XGINew_SetReg1(pVBInfo->Part4Port, 0x1C, temp);
5937 tempax = pVBInfo->VGAHDE;
5938 if (modeflag & HalfDCLK)
5939 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005940
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305941 if (XGI_IsLCDDualLink(pVBInfo))
5942 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005943
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305944 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
5945 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5946 if (tempax > 800)
5947 tempax -= 800;
5948 } else {
5949 if (pVBInfo->VGAHDE > 800) {
5950 if (pVBInfo->VGAHDE == 1024)
5951 tempax = (tempax * 25 / 32) - 1;
5952 else
5953 tempax = (tempax * 20 / 32) - 1;
5954 }
5955 }
5956 tempax -= 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005957
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305958 /*
5959 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5960 if (pVBInfo->VBType & VB_XGI301LV) {
5961 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
5962 if (pVBInfo->VGAHDE > 800) {
5963 if (pVBInfo->VGAHDE == 1024)
5964 tempax = (tempax * 25 / 32) - 1;
5965 else
5966 tempax = (tempax * 20 / 32) - 1;
5967 }
5968 }
5969 } else {
5970 if (pVBInfo->VGAHDE > 800) {
5971 if (pVBInfo->VGAHDE == 1024)
5972 tempax = (tempax * 25 / 32) - 1;
5973 else
5974 tempax = (tempax * 20 / 32) - 1;
5975 }
5976 }
5977 }
5978 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005979
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305980 temp = (tempax & 0xFF00) >> 8;
5981 temp = ((temp & 0x0003) << 4);
5982 XGINew_SetReg1(pVBInfo->Part4Port, 0x1E, temp);
5983 temp = (tempax & 0x00FF);
5984 XGINew_SetReg1(pVBInfo->Part4Port, 0x1D, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005985
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305986 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5987 if (pVBInfo->VGAHDE > 800)
5988 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1E, 0x08);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005989
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305990 }
5991 temp = 0x0036;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005992
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305993 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5994 if (!(pVBInfo->TVInfo & (NTSC1024x768
5995 | SetYPbPrMode525p | SetYPbPrMode750p
5996 | SetYPbPrMode1080i))) {
5997 temp |= 0x0001;
5998 if ((pVBInfo->VBInfo & SetInSlaveMode)
5999 && (!(pVBInfo->TVInfo
6000 & TVSimuMode)))
6001 temp &= (~0x0001);
6002 }
6003 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006004
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306005 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6006 tempbx = pVBInfo->HT;
6007 if (XGI_IsLCDDualLink(pVBInfo))
6008 tempbx = tempbx >> 1;
6009 tempbx = (tempbx >> 1) - 2;
6010 temp = ((tempbx & 0x0700) >> 8) << 3;
6011 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6012 temp = tempbx & 0x00FF;
6013 XGINew_SetReg1(pVBInfo->Part4Port, 0x22, temp);
6014 }
6015 /* end 301b */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006016
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306017 if (pVBInfo->ISXPDOS == 0)
6018 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6019 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006020}
6021
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306022void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6023 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006024{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306025 unsigned short Pindex, Pdata;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006026
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306027 Pindex = pVBInfo->Part5Port;
6028 Pdata = pVBInfo->Part5Port + 1;
6029 if (pVBInfo->ModeType == ModeVGA) {
6030 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6031 | CRT2DisplayFlag))) {
6032 XGINew_EnableCRT2(pVBInfo);
6033 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6034 }
6035 }
6036 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006037}
6038
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306039void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
6040 unsigned short ModeIdIndex,
6041 unsigned short RefreshRateTableIndex,
6042 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006043{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306044 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006045
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306046 struct XGI330_LCDDataTablStruct *tempdi = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006047
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306048 tempbx = BX;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006049
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306050 if (ModeNo <= 0x13) {
6051 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6052 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6053 } else {
6054 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6055 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6056 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006057
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306058 tempal = tempal & 0x0f;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006059
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306060 if (tempbx <= 1) { /* ExpLink */
6061 if (ModeNo <= 0x13) {
6062 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
6063 } else {
6064 tempal
6065 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6066 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006067
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306068 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6069 if (ModeNo <= 0x13)
6070 tempal
6071 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
6072 else
6073 tempal
6074 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
6075 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006076
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306077 if (tempbx & 0x01)
6078 tempal = (tempal >> 4);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006079
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306080 tempal = (tempal & 0x0f);
6081 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006082
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306083 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006084
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306085 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
6086 if ((tempbx == 5) || (tempbx) == 7)
6087 tempcx = LCDDesDataLen2;
6088 else if ((tempbx == 3) || (tempbx == 8))
6089 tempcx = LVDSDesDataLen2;
6090 }
6091 /* mov di, word ptr cs:LCDDataList[bx] */
6092 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006093
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306094 switch (tempbx) {
6095 case 0:
6096 tempdi = XGI_EPLLCDCRT1Ptr_H;
6097 break;
6098 case 1:
6099 tempdi = XGI_EPLLCDCRT1Ptr_V;
6100 break;
6101 case 2:
6102 tempdi = XGI_EPLLCDDataPtr;
6103 break;
6104 case 3:
6105 tempdi = XGI_EPLLCDDesDataPtr;
6106 break;
6107 case 4:
6108 tempdi = XGI_LCDDataTable;
6109 break;
6110 case 5:
6111 tempdi = XGI_LCDDesDataTable;
6112 break;
6113 case 6:
6114 tempdi = XGI_EPLCHLCDRegPtr;
6115 break;
6116 case 7:
6117 case 8:
6118 case 9:
6119 tempdi = NULL;
6120 break;
6121 default:
6122 break;
6123 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006124
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306125 if (tempdi == NULL) /* OEMUtil */
6126 return NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006127
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306128 table = tempbx;
6129 i = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006130
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306131 while (tempdi[i].PANELID != 0xff) {
6132 tempdx = pVBInfo->LCDResInfo;
6133 if (tempbx & 0x0080) { /* OEMUtil */
6134 tempbx &= (~0x0080);
6135 tempdx = pVBInfo->LCDTypeInfo;
6136 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006137
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306138 if (pVBInfo->LCDInfo & EnableScalingLCD)
6139 tempdx &= (~PanelResInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006140
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306141 if (tempdi[i].PANELID == tempdx) {
6142 tempbx = tempdi[i].MASK;
6143 tempdx = pVBInfo->LCDInfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006144
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306145 if (ModeNo <= 0x13) /* alan 09/10/2003 */
6146 tempdx |= SetLCDStdMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006147
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306148 if (modeflag & HalfDCLK)
6149 tempdx |= SetLCDLowResolution;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006150
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306151 tempbx &= tempdx;
6152 if (tempbx == tempdi[i].CAP)
6153 break;
6154 }
6155 i++;
6156 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006157
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306158 if (table == 0) {
6159 switch (tempdi[i].DATAPTR) {
6160 case 0:
6161 return &XGI_LVDSCRT11024x768_1_H[tempal];
6162 break;
6163 case 1:
6164 return &XGI_LVDSCRT11024x768_2_H[tempal];
6165 break;
6166 case 2:
6167 return &XGI_LVDSCRT11280x1024_1_H[tempal];
6168 break;
6169 case 3:
6170 return &XGI_LVDSCRT11280x1024_2_H[tempal];
6171 break;
6172 case 4:
6173 return &XGI_LVDSCRT11400x1050_1_H[tempal];
6174 break;
6175 case 5:
6176 return &XGI_LVDSCRT11400x1050_2_H[tempal];
6177 break;
6178 case 6:
6179 return &XGI_LVDSCRT11600x1200_1_H[tempal];
6180 break;
6181 case 7:
6182 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
6183 break;
6184 case 8:
6185 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
6186 break;
6187 case 9:
6188 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
6189 break;
6190 case 10:
6191 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
6192 break;
6193 default:
6194 break;
6195 }
6196 } else if (table == 1) {
6197 switch (tempdi[i].DATAPTR) {
6198 case 0:
6199 return &XGI_LVDSCRT11024x768_1_V[tempal];
6200 break;
6201 case 1:
6202 return &XGI_LVDSCRT11024x768_2_V[tempal];
6203 break;
6204 case 2:
6205 return &XGI_LVDSCRT11280x1024_1_V[tempal];
6206 break;
6207 case 3:
6208 return &XGI_LVDSCRT11280x1024_2_V[tempal];
6209 break;
6210 case 4:
6211 return &XGI_LVDSCRT11400x1050_1_V[tempal];
6212 break;
6213 case 5:
6214 return &XGI_LVDSCRT11400x1050_2_V[tempal];
6215 break;
6216 case 6:
6217 return &XGI_LVDSCRT11600x1200_1_V[tempal];
6218 break;
6219 case 7:
6220 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
6221 break;
6222 case 8:
6223 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
6224 break;
6225 case 9:
6226 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
6227 break;
6228 case 10:
6229 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
6230 break;
6231 default:
6232 break;
6233 }
6234 } else if (table == 2) {
6235 switch (tempdi[i].DATAPTR) {
6236 case 0:
6237 return &XGI_LVDS1024x768Data_1[tempal];
6238 break;
6239 case 1:
6240 return &XGI_LVDS1024x768Data_2[tempal];
6241 break;
6242 case 2:
6243 return &XGI_LVDS1280x1024Data_1[tempal];
6244 break;
6245 case 3:
6246 return &XGI_LVDS1280x1024Data_2[tempal];
6247 break;
6248 case 4:
6249 return &XGI_LVDS1400x1050Data_1[tempal];
6250 break;
6251 case 5:
6252 return &XGI_LVDS1400x1050Data_2[tempal];
6253 break;
6254 case 6:
6255 return &XGI_LVDS1600x1200Data_1[tempal];
6256 break;
6257 case 7:
6258 return &XGI_LVDSNoScalingData[tempal];
6259 break;
6260 case 8:
6261 return &XGI_LVDS1024x768Data_1x75[tempal];
6262 break;
6263 case 9:
6264 return &XGI_LVDS1024x768Data_2x75[tempal];
6265 break;
6266 case 10:
6267 return &XGI_LVDS1280x1024Data_1x75[tempal];
6268 break;
6269 case 11:
6270 return &XGI_LVDS1280x1024Data_2x75[tempal];
6271 break;
6272 case 12:
6273 return &XGI_LVDSNoScalingDatax75[tempal];
6274 break;
6275 default:
6276 break;
6277 }
6278 } else if (table == 3) {
6279 switch (tempdi[i].DATAPTR) {
6280 case 0:
6281 return &XGI_LVDS1024x768Des_1[tempal];
6282 break;
6283 case 1:
6284 return &XGI_LVDS1024x768Des_3[tempal];
6285 break;
6286 case 2:
6287 return &XGI_LVDS1024x768Des_2[tempal];
6288 break;
6289 case 3:
6290 return &XGI_LVDS1280x1024Des_1[tempal];
6291 break;
6292 case 4:
6293 return &XGI_LVDS1280x1024Des_2[tempal];
6294 break;
6295 case 5:
6296 return &XGI_LVDS1400x1050Des_1[tempal];
6297 break;
6298 case 6:
6299 return &XGI_LVDS1400x1050Des_2[tempal];
6300 break;
6301 case 7:
6302 return &XGI_LVDS1600x1200Des_1[tempal];
6303 break;
6304 case 8:
6305 return &XGI_LVDSNoScalingDesData[tempal];
6306 break;
6307 case 9:
6308 return &XGI_LVDS1024x768Des_1x75[tempal];
6309 break;
6310 case 10:
6311 return &XGI_LVDS1024x768Des_3x75[tempal];
6312 break;
6313 case 11:
6314 return &XGI_LVDS1024x768Des_2x75[tempal];
6315 break;
6316 case 12:
6317 return &XGI_LVDS1280x1024Des_1x75[tempal];
6318 break;
6319 case 13:
6320 return &XGI_LVDS1280x1024Des_2x75[tempal];
6321 break;
6322 case 14:
6323 return &XGI_LVDSNoScalingDesDatax75[tempal];
6324 break;
6325 default:
6326 break;
6327 }
6328 } else if (table == 4) {
6329 switch (tempdi[i].DATAPTR) {
6330 case 0:
6331 return &XGI_ExtLCD1024x768Data[tempal];
6332 break;
6333 case 1:
6334 return &XGI_StLCD1024x768Data[tempal];
6335 break;
6336 case 2:
6337 return &XGI_CetLCD1024x768Data[tempal];
6338 break;
6339 case 3:
6340 return &XGI_ExtLCD1280x1024Data[tempal];
6341 break;
6342 case 4:
6343 return &XGI_StLCD1280x1024Data[tempal];
6344 break;
6345 case 5:
6346 return &XGI_CetLCD1280x1024Data[tempal];
6347 break;
6348 case 6:
6349 return &XGI_ExtLCD1400x1050Data[tempal];
6350 break;
6351 case 7:
6352 return &XGI_StLCD1400x1050Data[tempal];
6353 break;
6354 case 8:
6355 return &XGI_CetLCD1400x1050Data[tempal];
6356 break;
6357 case 9:
6358 return &XGI_ExtLCD1600x1200Data[tempal];
6359 break;
6360 case 10:
6361 return &XGI_StLCD1600x1200Data[tempal];
6362 break;
6363 case 11:
6364 return &XGI_NoScalingData[tempal];
6365 break;
6366 case 12:
6367 return &XGI_ExtLCD1024x768x75Data[tempal];
6368 break;
6369 case 13:
6370 return &XGI_ExtLCD1024x768x75Data[tempal];
6371 break;
6372 case 14:
6373 return &XGI_CetLCD1024x768x75Data[tempal];
6374 break;
6375 case 15:
6376 return &XGI_ExtLCD1280x1024x75Data[tempal];
6377 break;
6378 case 16:
6379 return &XGI_StLCD1280x1024x75Data[tempal];
6380 break;
6381 case 17:
6382 return &XGI_CetLCD1280x1024x75Data[tempal];
6383 break;
6384 case 18:
6385 return &XGI_NoScalingDatax75[tempal];
6386 break;
6387 default:
6388 break;
6389 }
6390 } else if (table == 5) {
6391 switch (tempdi[i].DATAPTR) {
6392 case 0:
6393 return &XGI_ExtLCDDes1024x768Data[tempal];
6394 break;
6395 case 1:
6396 return &XGI_StLCDDes1024x768Data[tempal];
6397 break;
6398 case 2:
6399 return &XGI_CetLCDDes1024x768Data[tempal];
6400 break;
6401 case 3:
6402 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6403 & VB_XGI302LV))
6404 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
6405 else
6406 return &XGI_ExtLCDDes1280x1024Data[tempal];
6407 break;
6408 case 4:
6409 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6410 & VB_XGI302LV))
6411 return &XGI_StLCDDLDes1280x1024Data[tempal];
6412 else
6413 return &XGI_StLCDDes1280x1024Data[tempal];
6414 break;
6415 case 5:
6416 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6417 & VB_XGI302LV))
6418 return &XGI_CetLCDDLDes1280x1024Data[tempal];
6419 else
6420 return &XGI_CetLCDDes1280x1024Data[tempal];
6421 break;
6422 case 6:
6423 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6424 & VB_XGI302LV))
6425 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
6426 else
6427 return &XGI_ExtLCDDes1400x1050Data[tempal];
6428 break;
6429 case 7:
6430 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6431 & VB_XGI302LV))
6432 return &XGI_StLCDDLDes1400x1050Data[tempal];
6433 else
6434 return &XGI_StLCDDes1400x1050Data[tempal];
6435 break;
6436 case 8:
6437 return &XGI_CetLCDDes1400x1050Data[tempal];
6438 break;
6439 case 9:
6440 return &XGI_CetLCDDes1400x1050Data2[tempal];
6441 break;
6442 case 10:
6443 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6444 & VB_XGI302LV))
6445 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
6446 else
6447 return &XGI_ExtLCDDes1600x1200Data[tempal];
6448 break;
6449 case 11:
6450 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6451 & VB_XGI302LV))
6452 return &XGI_StLCDDLDes1600x1200Data[tempal];
6453 else
6454 return &XGI_StLCDDes1600x1200Data[tempal];
6455 break;
6456 case 12:
6457 return &XGI_NoScalingDesData[tempal];
6458 break;
6459 case 13:
6460 return &XGI_ExtLCDDes1024x768x75Data[tempal];
6461 break;
6462 case 14:
6463 return &XGI_StLCDDes1024x768x75Data[tempal];
6464 break;
6465 case 15:
6466 return &XGI_CetLCDDes1024x768x75Data[tempal];
6467 break;
6468 case 16:
6469 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6470 & VB_XGI302LV))
6471 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
6472 else
6473 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
6474 break;
6475 case 17:
6476 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6477 & VB_XGI302LV))
6478 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
6479 else
6480 return &XGI_StLCDDes1280x1024x75Data[tempal];
6481 break;
6482 case 18:
6483 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6484 & VB_XGI302LV))
6485 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
6486 else
6487 return &XGI_CetLCDDes1280x1024x75Data[tempal];
6488 break;
6489 case 19:
6490 return &XGI_NoScalingDesDatax75[tempal];
6491 break;
6492 default:
6493 break;
6494 }
6495 } else if (table == 6) {
6496 switch (tempdi[i].DATAPTR) {
6497 case 0:
6498 return &XGI_CH7017LV1024x768[tempal];
6499 break;
6500 case 1:
6501 return &XGI_CH7017LV1400x1050[tempal];
6502 break;
6503 default:
6504 break;
6505 }
6506 }
6507 return NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006508}
6509
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006510void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306511 unsigned short ModeIdIndex,
6512 unsigned short RefreshRateTableIndex,
6513 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006514{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306515 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
6516 struct XGI330_TVDataTablStruct *tempdi = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006517
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306518 tempbx = BX;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006519
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306520 if (ModeNo <= 0x13) {
6521 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6522 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6523 } else {
6524 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6525 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6526 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006527
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306528 tempal = tempal & 0x3f;
6529 table = tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006530
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306531 switch (tempbx) {
6532 case 0:
6533 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
6534 if (pVBInfo->IF_DEF_CH7007 == 1)
6535 tempdi = XGI_EPLCHTVCRT1Ptr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006536
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306537 break;
6538 case 1:
6539 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
6540 if (pVBInfo->IF_DEF_CH7007 == 1)
6541 tempdi = XGI_EPLCHTVCRT1Ptr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006542
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306543 break;
6544 case 2:
6545 tempdi = XGI_EPLCHTVDataPtr;
6546 break;
6547 case 3:
6548 tempdi = NULL;
6549 break;
6550 case 4:
6551 tempdi = XGI_TVDataTable;
6552 break;
6553 case 5:
6554 tempdi = NULL;
6555 break;
6556 case 6:
6557 tempdi = XGI_EPLCHTVRegPtr;
6558 break;
6559 default:
6560 break;
6561 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006562
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306563 if (tempdi == NULL) /* OEMUtil */
6564 return NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006565
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306566 tempdx = pVBInfo->TVInfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006567
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306568 if (pVBInfo->VBInfo & SetInSlaveMode)
6569 tempdx = tempdx | SetTVLockMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006570
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306571 if (modeflag & HalfDCLK)
6572 tempdx = tempdx | SetTVLowResolution;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006573
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306574 i = 0;
6575
6576 while (tempdi[i].MASK != 0xffff) {
6577 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
6578 break;
6579 i++;
6580 }
6581
6582 if (table == 0x00) { /* 07/05/22 */
6583 } else if (table == 0x01) {
6584 } else if (table == 0x04) {
6585 switch (tempdi[i].DATAPTR) {
6586 case 0:
6587 return &XGI_ExtPALData[tempal];
6588 break;
6589 case 1:
6590 return &XGI_ExtNTSCData[tempal];
6591 break;
6592 case 2:
6593 return &XGI_StPALData[tempal];
6594 break;
6595 case 3:
6596 return &XGI_StNTSCData[tempal];
6597 break;
6598 case 4:
6599 return &XGI_ExtHiTVData[tempal];
6600 break;
6601 case 5:
6602 return &XGI_St2HiTVData[tempal];
6603 break;
6604 case 6:
6605 return &XGI_ExtYPbPr525iData[tempal];
6606 break;
6607 case 7:
6608 return &XGI_ExtYPbPr525pData[tempal];
6609 break;
6610 case 8:
6611 return &XGI_ExtYPbPr750pData[tempal];
6612 break;
6613 case 9:
6614 return &XGI_StYPbPr525iData[tempal];
6615 break;
6616 case 10:
6617 return &XGI_StYPbPr525pData[tempal];
6618 break;
6619 case 11:
6620 return &XGI_StYPbPr750pData[tempal];
6621 break;
6622 case 12: /* avoid system hang */
6623 return &XGI_ExtNTSCData[tempal];
6624 break;
6625 case 13:
6626 return &XGI_St1HiTVData[tempal];
6627 break;
6628 default:
6629 break;
6630 }
6631 } else if (table == 0x02) {
6632 switch (tempdi[i].DATAPTR) {
6633 case 0:
6634 return &XGI_CHTVUNTSCData[tempal];
6635 break;
6636 case 1:
6637 return &XGI_CHTVONTSCData[tempal];
6638 break;
6639 case 2:
6640 return &XGI_CHTVUPALData[tempal];
6641 break;
6642 case 3:
6643 return &XGI_CHTVOPALData[tempal];
6644 break;
6645 default:
6646 break;
6647 }
6648 } else if (table == 0x06) {
6649 }
6650 return NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006651}
6652
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006653/* --------------------------------------------------------------------- */
6654/* Function : XGI_BacklightByDrv */
6655/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04006656/* Output : 1 -> Skip backlight control */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006657/* Description : */
6658/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04006659unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006660{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306661 unsigned char tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006662
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306663 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x3A);
6664 if (tempah & BacklightControlBit)
6665 return 1;
6666 else
6667 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006668}
6669
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006670/* --------------------------------------------------------------------- */
6671/* Function : XGI_FirePWDDisable */
6672/* Input : */
6673/* Output : */
6674/* Description : Turn off VDD & Backlight : Fire disable procedure */
6675/* --------------------------------------------------------------------- */
6676/*
Bill Pemberton80adad82010-06-17 13:10:51 -04006677void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006678{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306679 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x00, 0xFC);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006680}
6681*/
6682
6683/* --------------------------------------------------------------------- */
6684/* Function : XGI_FirePWDEnable */
6685/* Input : */
6686/* Output : */
6687/* Description : Turn on VDD & Backlight : Fire enable procedure */
6688/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04006689void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006690{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306691 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x03, 0xFC);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006692}
6693
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306694void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6695 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006696{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306697 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006698}
6699
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306700void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6701 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006702{
6703
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306704 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006705}
6706
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006707/* --------------------------------------------------------------------- */
6708/* Function : XGI_SetPanelDelay */
6709/* Input : */
6710/* Output : */
6711/* Description : */
6712/* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6713/* : bl : 2 ; T2 : the duration signal on and Vdd on */
6714/* : bl : 3 ; T3 : the duration between CPL off and signal off */
6715/* : bl : 4 ; T4 : the duration signal off and Vdd off */
6716/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04006717void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006718{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306719 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006720
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306721 index = XGI_GetLCDCapPtr(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006722
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306723 if (tempbl == 1)
6724 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S1, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006725
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306726 if (tempbl == 2)
6727 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S2, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006728
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306729 if (tempbl == 3)
6730 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S3, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006731
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306732 if (tempbl == 4)
6733 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S4, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006734}
6735
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006736/* --------------------------------------------------------------------- */
6737/* Function : XGI_SetPanelPower */
6738/* Input : */
6739/* Output : */
6740/* Description : */
6741/* I/O : ah = 0011b = 03h ; Backlight on, Power on */
6742/* = 0111b = 07h ; Backlight on, Power off */
6743/* = 1011b = 0Bh ; Backlight off, Power on */
6744/* = 1111b = 0Fh ; Backlight off, Power off */
6745/* --------------------------------------------------------------------- */
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306746void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl,
6747 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006748{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306749 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
6750 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x26, tempbl, tempah);
6751 else
6752 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x11, tempbl, tempah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006753}
6754
Randy Dunlap89229672010-08-10 08:46:44 -07006755static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006756{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306757 unsigned char ujRet = 0;
6758 unsigned char i = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006759
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306760 for (i = 0; i < 8; i++) {
6761 ujRet = ujRet << 1;
6762 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
6763 ujRet |= (ujDate >> i) & 1;
6764 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006765
6766 return ujRet;
6767}
6768
6769/*----------------------------------------------------------------------------*/
6770/* output */
6771/* bl[5] : LVDS signal */
6772/* bl[1] : LVDS backlight */
6773/* bl[0] : LVDS VDD */
6774/*----------------------------------------------------------------------------*/
Bill Pemberton80adad82010-06-17 13:10:51 -04006775unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006776{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306777 unsigned char CR4A, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006778
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306779 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6780 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006781
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306782 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006783
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306784 temp = XG21GPIODataTransfer(temp);
6785 temp &= 0x23;
6786 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6787 return temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006788}
6789
6790/*----------------------------------------------------------------------------*/
6791/* output */
6792/* bl[5] : LVDS signal */
6793/* bl[1] : LVDS backlight */
6794/* bl[0] : LVDS VDD */
6795/*----------------------------------------------------------------------------*/
Bill Pemberton80adad82010-06-17 13:10:51 -04006796unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006797{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306798 unsigned char CR4A, CRB4, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006799
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306800 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6801 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006802
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306803 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006804
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306805 temp &= 0x0C;
6806 temp >>= 2;
6807 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6808 CRB4 = XGINew_GetReg1(pVBInfo->P3d4, 0xB4);
6809 temp |= ((CRB4 & 0x04) << 3);
6810 return temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006811}
6812/*----------------------------------------------------------------------------*/
6813/* input */
6814/* bl[5] : 1;LVDS signal on */
6815/* bl[1] : 1;LVDS backlight on */
6816/* bl[0] : 1:LVDS VDD on */
6817/* bh: 100000b : clear bit 5, to set bit5 */
6818/* 000010b : clear bit 1, to set bit1 */
6819/* 000001b : clear bit 0, to set bit0 */
6820/*----------------------------------------------------------------------------*/
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306821void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6822 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006823{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306824 unsigned char CR4A, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006825
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306826 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6827 tempbh &= 0x23;
6828 tempbl &= 0x23;
6829 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006830
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306831 if (tempbh & 0x20) {
6832 temp = (tempbl >> 4) & 0x02;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006833
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306834 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006835
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306836 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006837
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306838 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006839
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306840 temp = XG21GPIODataTransfer(temp);
6841 temp &= ~tempbh;
6842 temp |= tempbl;
6843 XGINew_SetReg1(pVBInfo->P3d4, 0x48, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006844}
6845
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306846void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6847 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006848{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306849 unsigned char CR4A, temp;
6850 unsigned short tempbh0, tempbl0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006851
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306852 tempbh0 = tempbh;
6853 tempbl0 = tempbl;
6854 tempbh0 &= 0x20;
6855 tempbl0 &= 0x20;
6856 tempbh0 >>= 3;
6857 tempbl0 >>= 3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006858
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306859 if (tempbh & 0x20) {
6860 temp = (tempbl >> 4) & 0x02;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006861
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306862 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006863
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306864 }
6865 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006866
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306867 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6868 tempbh &= 0x03;
6869 tempbl &= 0x03;
6870 tempbh <<= 2;
6871 tempbl <<= 2; /* GPIOC,GPIOD */
6872 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6873 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006874}
6875
6876/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04006877unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006878{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306879 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006880
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306881 index = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
6882 if (index < sizeof(XGI21_LCDCapList)
6883 / sizeof(struct XGI21_LVDSCapStruct))
6884 return index;
6885 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006886}
6887
6888/* --------------------------------------------------------------------- */
6889/* Function : XGI_XG21SetPanelDelay */
6890/* Input : */
6891/* Output : */
6892/* Description : */
6893/* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6894/* : bl : 2 ; T2 : the duration signal on and Vdd on */
6895/* : bl : 3 ; T3 : the duration between CPL off and signal off */
6896/* : bl : 4 ; T4 : the duration signal off and Vdd off */
6897/* --------------------------------------------------------------------- */
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306898void XGI_XG21SetPanelDelay(unsigned short tempbl,
6899 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006900{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306901 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006902
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306903 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6904 if (tempbl == 1)
6905 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S1,
6906 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006907
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306908 if (tempbl == 2)
6909 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S2,
6910 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006911
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306912 if (tempbl == 3)
6913 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S3,
6914 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006915
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306916 if (tempbl == 4)
6917 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S4,
6918 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006919}
6920
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006921unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306922 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006923{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306924 unsigned short xres, yres, colordepth, modeflag, resindex,
6925 lvdstableindex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006926
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306927 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6928 if (ModeNo <= 0x13) {
6929 xres = pVBInfo->StResInfo[resindex].HTotal;
6930 yres = pVBInfo->StResInfo[resindex].VTotal;
6931 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6932 } else {
6933 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6934 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6935 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6936 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006937
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306938 if (!(modeflag & Charx8Dot)) {
6939 xres /= 9;
6940 xres *= 8;
6941 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006942
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306943 if (ModeNo > 0x13) {
6944 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6945 xres *= 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006946
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306947 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6948 yres *= 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006949
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306950 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006951
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306952 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6953 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6954 return 0;
Bill Pembertondda08c52010-06-17 13:10:42 -04006955
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306956 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6957 return 0;
6958
6959 if (ModeNo > 0x13) {
6960 if ((xres
6961 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6962 || (yres
6963 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
6964 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
6965 pVBInfo);
6966 if (colordepth > 2)
6967 return 0;
6968
6969 }
6970 }
6971 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006972}
6973
Bill Pemberton80adad82010-06-17 13:10:51 -04006974void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006975{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306976 unsigned char temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006977
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306978 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6979 temp = (temp & 1) << 6;
6980 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
6981 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006982
6983}
6984
Bill Pemberton80adad82010-06-17 13:10:51 -04006985void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006986{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306987 unsigned char temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006988
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306989 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6990 temp = (temp & 3) << 6;
6991 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6992 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006993
6994}
6995
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006996void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306997 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006998{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306999 unsigned char temp, Miscdata;
7000 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
7001 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
7002 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
7003 unsigned short value;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007004
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307005 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007006
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307007 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7008 & (LCDPolarity << 8)) >> 8);
7009 temp &= LCDPolarity;
7010 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007011
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307012 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007013
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307014 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7015 & LCDPolarity);
7016 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7017 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007018
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307019 XGI_SetXG21FPBits(pVBInfo);
7020 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7021 if (ModeNo <= 0x13) {
7022 xres = pVBInfo->StResInfo[resindex].HTotal;
7023 yres = pVBInfo->StResInfo[resindex].VTotal;
7024 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7025 } else {
7026 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7027 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7028 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7029 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007030
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307031 if (!(modeflag & Charx8Dot))
7032 xres = xres * 8 / 9;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007033
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307034 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007035
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307036 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7037 - xres) / 2;
7038 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7039 LVDSHBS -= xres / 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007040
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307041 if (LVDSHBS > LVDSHT)
7042 LVDSHBS -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007043
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307044 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7045 if (LVDSHRS > LVDSHT)
7046 LVDSHRS -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007047
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307048 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7049 if (LVDSHRE > LVDSHT)
7050 LVDSHRE -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007051
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307052 LVDSHBE = LVDSHBS + LVDSHT
7053 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007054
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307055 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007056
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307057 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7058 - yres) / 2;
7059 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7060 LVDSVBS += yres / 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007061
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307062 if (LVDSVBS > LVDSVT)
7063 LVDSVBS -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007064
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307065 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7066 if (LVDSVRS > LVDSVT)
7067 LVDSVRS -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007068
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307069 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7070 if (LVDSVRE > LVDSVT)
7071 LVDSVRE -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007072
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307073 LVDSVBE = LVDSVBS + LVDSVT
7074 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007075
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307076 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7077 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007078
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307079 if (!(modeflag & Charx8Dot))
7080 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007081
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307082 /* HT SR0B[1:0] CR00 */
7083 value = (LVDSHT >> 3) - 5;
7084 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7085 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007086
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307087 /* HBS SR0B[5:4] CR02 */
7088 value = (LVDSHBS >> 3) - 1;
7089 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7090 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007091
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307092 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7093 value = (LVDSHBE >> 3) - 1;
7094 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7095 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7096 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007097
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307098 /* HRS SR0B[7:6] CR04 */
7099 value = (LVDSHRS >> 3) + 2;
7100 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7101 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007102
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307103 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7104 value--;
7105 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7106 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007107
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307108 /* HRE SR0C[2] CR05[4:0] */
7109 value = (LVDSHRE >> 3) + 2;
7110 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7111 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007112
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307113 /* Panel HRE SR2F[7:2] */
7114 value--;
7115 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007116
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307117 /* VT SR0A[0] CR07[5][0] CR06 */
7118 value = LVDSVT - 2;
7119 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7120 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7121 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7122 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007123
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307124 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7125 value = LVDSVBS - 1;
7126 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7127 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7128 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7129 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007130
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307131 /* VBE SR0A[4] CR16 */
7132 value = LVDSVBE - 1;
7133 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7134 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007135
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307136 /* VRS SR0A[3] CR7[7][2] CR10 */
7137 value = LVDSVRS - 1;
7138 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7139 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7140 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7141 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007142
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307143 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
7144 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
7145 XGINew_SetReg1(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
7146 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007147
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307148 /* VRE SR0A[5] CR11[3:0] */
7149 value = LVDSVRE - 1;
7150 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7151 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007152
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307153 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
7154 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007155
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307156 for (temp = 0, value = 0; temp < 3; temp++) {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007157
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307158 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7159 XGINew_SetReg1(pVBInfo->P3c4,
7160 0x2B,
7161 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7162 XGINew_SetReg1(pVBInfo->P3c4,
7163 0x2C,
7164 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7165 value += 0x10;
7166 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007167
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307168 if (!(modeflag & Charx8Dot)) {
7169 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7170 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7171 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007172
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307173 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7174 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7175
7176 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7177 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007178
7179}
7180
7181/* no shadow case */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007182void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307183 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007184{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307185 unsigned char temp, Miscdata;
7186 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
7187 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
7188 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
7189 unsigned short value;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007190
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307191 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
7192 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7193 & (LCDPolarity << 8)) >> 8);
7194 temp &= LCDPolarity;
7195 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007196
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307197 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007198
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307199 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7200 & LCDPolarity);
7201 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7202 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007203
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307204 XGI_SetXG27FPBits(pVBInfo);
7205 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7206 if (ModeNo <= 0x13) {
7207 xres = pVBInfo->StResInfo[resindex].HTotal;
7208 yres = pVBInfo->StResInfo[resindex].VTotal;
7209 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7210 } else {
7211 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7212 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7213 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7214 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007215
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307216 if (!(modeflag & Charx8Dot))
7217 xres = xres * 8 / 9;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007218
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307219 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007220
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307221 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7222 - xres) / 2;
7223 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7224 LVDSHBS -= xres / 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007225
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307226 if (LVDSHBS > LVDSHT)
7227 LVDSHBS -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007228
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307229 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7230 if (LVDSHRS > LVDSHT)
7231 LVDSHRS -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007232
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307233 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7234 if (LVDSHRE > LVDSHT)
7235 LVDSHRE -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007236
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307237 LVDSHBE = LVDSHBS + LVDSHT
7238 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007239
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307240 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007241
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307242 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7243 - yres) / 2;
7244 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7245 LVDSVBS += yres / 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007246
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307247 if (LVDSVBS > LVDSVT)
7248 LVDSVBS -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007249
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307250 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7251 if (LVDSVRS > LVDSVT)
7252 LVDSVRS -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007253
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307254 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7255 if (LVDSVRE > LVDSVT)
7256 LVDSVRE -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007257
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307258 LVDSVBE = LVDSVBS + LVDSVT
7259 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007260
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307261 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7262 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007263
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307264 if (!(modeflag & Charx8Dot))
7265 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007266
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307267 /* HT SR0B[1:0] CR00 */
7268 value = (LVDSHT >> 3) - 5;
7269 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7270 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007271
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307272 /* HBS SR0B[5:4] CR02 */
7273 value = (LVDSHBS >> 3) - 1;
7274 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7275 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007276
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307277 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7278 value = (LVDSHBE >> 3) - 1;
7279 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7280 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7281 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007282
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307283 /* HRS SR0B[7:6] CR04 */
7284 value = (LVDSHRS >> 3) + 2;
7285 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7286 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007287
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307288 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7289 value--;
7290 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7291 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007292
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307293 /* HRE SR0C[2] CR05[4:0] */
7294 value = (LVDSHRE >> 3) + 2;
7295 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7296 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007297
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307298 /* Panel HRE SR2F[7:2] */
7299 value--;
7300 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007301
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307302 /* VT SR0A[0] CR07[5][0] CR06 */
7303 value = LVDSVT - 2;
7304 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7305 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7306 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7307 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007308
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307309 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7310 value = LVDSVBS - 1;
7311 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7312 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7313 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7314 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007315
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307316 /* VBE SR0A[4] CR16 */
7317 value = LVDSVBE - 1;
7318 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7319 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007320
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307321 /* VRS SR0A[3] CR7[7][2] CR10 */
7322 value = LVDSVRS - 1;
7323 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7324 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7325 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7326 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007327
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307328 /* Panel VRS SR35[2:0] SR34[7:0] */
7329 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
7330 XGINew_SetReg1(pVBInfo->P3c4, 0x34, value & 0xFF);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007331
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307332 /* VRE SR0A[5] CR11[3:0] */
7333 value = LVDSVRE - 1;
7334 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7335 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007336
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307337 /* Panel VRE SR3F[7:2] */
7338 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007339
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307340 for (temp = 0, value = 0; temp < 3; temp++) {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007341
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307342 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7343 XGINew_SetReg1(pVBInfo->P3c4,
7344 0x2B,
7345 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7346 XGINew_SetReg1(pVBInfo->P3c4,
7347 0x2C,
7348 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7349 value += 0x10;
7350 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007351
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307352 if (!(modeflag & Charx8Dot)) {
7353 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7354 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7355 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007356
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307357 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7358 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7359
7360 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7361 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007362
7363}
7364
7365/* --------------------------------------------------------------------- */
7366/* Function : XGI_IsLCDON */
7367/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04007368/* Output : 0 : Skip PSC Control */
7369/* 1: Disable PSC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007370/* Description : */
7371/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04007372unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007373{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307374 unsigned short tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007375
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307376 tempax = pVBInfo->VBInfo;
7377 if (tempax & SetCRT2ToDualEdge)
7378 return 0;
7379 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
7380 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007381
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307382 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007383}
7384
Bill Pemberton80adad82010-06-17 13:10:51 -04007385void XGI_EnablePWD(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007386{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307387 unsigned short index, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007388
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307389 index = XGI_GetLCDCapPtr(pVBInfo);
7390 temp = pVBInfo->LCDCapList[index].PWD_2B;
7391 XGINew_SetReg1(pVBInfo->Part4Port, 0x2B, temp);
7392 XGINew_SetReg1(pVBInfo->Part4Port, 0x2C,
7393 pVBInfo->LCDCapList[index].PWD_2C);
7394 XGINew_SetReg1(pVBInfo->Part4Port, 0x2D,
7395 pVBInfo->LCDCapList[index].PWD_2D);
7396 XGINew_SetReg1(pVBInfo->Part4Port, 0x2E,
7397 pVBInfo->LCDCapList[index].PWD_2E);
7398 XGINew_SetReg1(pVBInfo->Part4Port, 0x2F,
7399 pVBInfo->LCDCapList[index].PWD_2F);
7400 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x80); /* enable PWD */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007401}
7402
Bill Pemberton80adad82010-06-17 13:10:51 -04007403void XGI_DisablePWD(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007404{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307405 XGINew_SetRegAND(pVBInfo->Part4Port, 0x27, 0x7F); /* disable PWD */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007406}
7407
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007408/* --------------------------------------------------------------------- */
7409/* Function : XGI_DisableChISLCD */
7410/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04007411/* Output : 0 -> Not LCD Mode */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007412/* Description : */
7413/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04007414unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007415{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307416 unsigned short tempbx, tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007417
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307418 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
7419 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007420
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307421 if (tempbx & (EnableChA | DisableChA)) {
7422 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7423 return 0;
7424 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007425
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307426 if (!(tempbx & (EnableChB | DisableChB)))
7427 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007428
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307429 if (tempah & 0x01) /* Chk LCDB Mode */
7430 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007431
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307432 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007433}
7434
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007435/* --------------------------------------------------------------------- */
7436/* Function : XGI_EnableChISLCD */
7437/* Input : */
7438/* Output : 0 -> Not LCD mode */
7439/* Description : */
7440/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04007441unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007442{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307443 unsigned short tempbx, tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007444
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307445 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
7446 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007447
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307448 if (tempbx & (EnableChA | DisableChA)) {
7449 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7450 return 0;
7451 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007452
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307453 if (!(tempbx & (EnableChB | DisableChB)))
Bill Pembertondda08c52010-06-17 13:10:42 -04007454 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007455
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307456 if (tempah & 0x01) /* Chk LCDB Mode */
7457 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007458
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307459 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007460}
7461
Bill Pemberton80adad82010-06-17 13:10:51 -04007462unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007463{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307464 unsigned char tempal, tempah, tempbl, i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007465
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307466 tempah = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
7467 tempal = tempah & 0x0F;
7468 tempah = tempah & 0xF0;
7469 i = 0;
7470 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007471
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307472 while (tempbl != 0xFF) {
7473 if (tempbl & 0x80) { /* OEMUtil */
7474 tempal = tempah;
7475 tempbl = tempbl & ~(0x80);
7476 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007477
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307478 if (tempal == tempbl)
7479 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007480
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307481 i++;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007482
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307483 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7484 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007485
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307486 return i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007487}
7488
Bill Pemberton80adad82010-06-17 13:10:51 -04007489unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007490{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307491 unsigned short tempah, tempal, tempbl, i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007492
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307493 tempal = pVBInfo->LCDResInfo;
7494 tempah = pVBInfo->LCDTypeInfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007495
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307496 i = 0;
7497 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007498
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307499 while (tempbl != 0xFF) {
7500 if ((tempbl & 0x80) && (tempbl != 0x80)) {
7501 tempal = tempah;
7502 tempbl &= ~0x80;
7503 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007504
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307505 if (tempal == tempbl)
7506 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007507
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307508 i++;
7509 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7510 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007511
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307512 if (tempbl == 0xFF) {
7513 pVBInfo->LCDResInfo = Panel1024x768;
7514 pVBInfo->LCDTypeInfo = 0;
7515 i = 0;
7516 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007517
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307518 return i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007519}
7520
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307521void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
7522 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007523{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307524 unsigned short Index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007525
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307526 Index = XGI_GetLCDCapPtr(pVBInfo);
7527 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
7528 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007529
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307530 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007531}
7532
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307533void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7534 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007535{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307536 unsigned short tempbl, tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007537
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307538 if (pVBInfo->SetFlag == Win9xDOSMode) {
7539 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7540 | VB_XGI302LV | VB_XGI301C)) {
7541 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7542 return;
7543 } else
7544 /* LVDS or CH7017 */
7545 return;
7546 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007547
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307548 if (HwDeviceExtension->jChipType < XG40) {
7549 if (!XGI_DisableChISLCD(pVBInfo)) {
7550 if ((XGI_EnableChISLCD(pVBInfo)) || (pVBInfo->VBInfo
7551 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
7552 if (pVBInfo->LCDInfo & SetPWDEnable) {
7553 XGI_EnablePWD(pVBInfo);
7554 } else {
7555 pVBInfo->LCDInfo &= (~SetPWDEnable);
7556 if (pVBInfo->VBType & (VB_XGI301LV
7557 | VB_XGI302LV
7558 | VB_XGI301C)) {
7559 tempbl = 0xFD;
7560 tempah = 0x02;
7561 } else {
7562 tempbl = 0xFB;
7563 tempah = 0x00;
7564 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007565
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307566 XGI_SetPanelPower(tempah, tempbl,
7567 pVBInfo);
7568 XGI_SetPanelDelay(1, pVBInfo);
7569 }
7570 }
7571 }
7572 } /* Not 340 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007573
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307574 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7575 | VB_XGI302LV | VB_XGI301C)) {
7576 if (!(pVBInfo->SetFlag & DisableChA)) {
7577 if (pVBInfo->SetFlag & EnableChA) {
7578 XGINew_SetReg1(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
7579 } else {
7580 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
7581 XGINew_SetReg1(pVBInfo->Part1Port,
7582 0x1E, 0x20); /* Power on */
7583 }
7584 }
7585 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007586
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307587 if (!(pVBInfo->SetFlag & DisableChB)) {
7588 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
7589 & (SetCRT2ToLCD | SetCRT2ToTV
7590 | SetCRT2ToRAMDAC))) {
7591 tempah = (unsigned char) XGINew_GetReg1(
7592 pVBInfo->P3c4, 0x32);
7593 tempah &= 0xDF;
7594 if (pVBInfo->VBInfo & SetInSlaveMode) {
7595 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
7596 tempah |= 0x20;
7597 }
7598 XGINew_SetReg1(pVBInfo->P3c4, 0x32, tempah);
7599 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x20);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007600
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307601 tempah = (unsigned char) XGINew_GetReg1(
7602 pVBInfo->Part1Port, 0x2E);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007603
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307604 if (!(tempah & 0x80))
7605 XGINew_SetRegOR(pVBInfo->Part1Port,
7606 0x2E, 0x80); /* BVBDOENABLE = 1 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007607
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307608 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
7609 }
7610 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007611
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307612 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
7613 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
7614 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x00, ~0xE0,
7615 0x20); /* shampoo 0129 */
7616 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7617 if (!XGI_DisableChISLCD(pVBInfo)) {
7618 if (XGI_EnableChISLCD(pVBInfo)
7619 || (pVBInfo->VBInfo
7620 & (SetCRT2ToLCD
7621 | SetCRT2ToLCDA)))
7622 XGINew_SetRegAND(
7623 pVBInfo->Part4Port,
7624 0x2A, 0x7F); /* LVDS PLL power on */
7625 }
7626 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
7627 }
7628 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007629
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307630 tempah = 0x00;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007631
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307632 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7633 tempah = 0xc0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007634
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307635 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
7636 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7637 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7638 tempah = tempah & 0x40;
7639 if (pVBInfo->VBInfo
7640 & SetCRT2ToLCDA)
7641 tempah = tempah ^ 0xC0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007642
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307643 if (pVBInfo->SetFlag
7644 & DisableChB)
7645 tempah &= 0xBF;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007646
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307647 if (pVBInfo->SetFlag
7648 & DisableChA)
7649 tempah &= 0x7F;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007650
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307651 if (pVBInfo->SetFlag
7652 & EnableChB)
7653 tempah |= 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007654
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307655 if (pVBInfo->SetFlag
7656 & EnableChA)
7657 tempah |= 0x80;
7658 }
7659 }
7660 }
7661 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007662
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307663 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007664
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307665 if (pVBInfo->SetFlag & Win9xDOSMode) {
7666 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7667 return;
7668 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007669
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307670 if (!(pVBInfo->SetFlag & DisableChA)) {
7671 XGI_VBLongWait(pVBInfo);
7672 if (!(pVBInfo->SetFlag & GatingCRT)) {
7673 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
7674 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7675 XGI_VBLongWait(pVBInfo);
7676 }
7677 }
7678 } /* 301 */
7679 else { /* LVDS */
7680 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
7681 | SetCRT2ToLCDA))
7682 XGINew_SetRegOR(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007683
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307684 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->Part1Port,
7685 0x2E);
7686 if (!(tempah & 0x80))
7687 XGINew_SetRegOR(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007688
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307689 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F);
7690 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7691 } /* End of VB */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007692
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307693 if (HwDeviceExtension->jChipType < XG40) {
7694 if (!XGI_EnableChISLCD(pVBInfo)) {
7695 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7696 if (XGI_BacklightByDrv(pVBInfo))
7697 return;
7698 } else
7699 return;
7700 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007701
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307702 if (pVBInfo->LCDInfo & SetPWDEnable) {
7703 XGI_FirePWDEnable(pVBInfo);
7704 return;
7705 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007706
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307707 XGI_SetPanelDelay(2, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007708
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307709 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
7710 tempah = 0x01;
7711 tempbl = 0xFE; /* turn on backlght */
7712 } else {
7713 tempbl = 0xF7;
7714 tempah = 0x00;
7715 }
7716 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7717 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007718}
7719
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307720void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7721 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007722{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307723 unsigned short tempax, tempbx, tempah = 0, tempbl = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007724
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307725 if (pVBInfo->SetFlag == Win9xDOSMode)
7726 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007727
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307728 if (HwDeviceExtension->jChipType < XG40) {
7729 if ((!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7730 || (XGI_DisableChISLCD(pVBInfo))) {
7731 if (!XGI_IsLCDON(pVBInfo)) {
7732 if (pVBInfo->LCDInfo & SetPWDEnable)
7733 XGI_EnablePWD(pVBInfo);
7734 else {
7735 pVBInfo->LCDInfo &= ~SetPWDEnable;
7736 XGI_DisablePWD(pVBInfo);
7737 if (pVBInfo->VBType & (VB_XGI301LV
7738 | VB_XGI302LV
7739 | VB_XGI301C)) {
7740 tempbx = 0xFE; /* not 01h */
7741 tempax = 0;
7742 } else {
7743 tempbx = 0xF7; /* not 08h */
7744 tempax = 0x08;
7745 }
7746 XGI_SetPanelPower(tempax, tempbx,
7747 pVBInfo);
7748 XGI_SetPanelDelay(3, pVBInfo);
7749 }
7750 } /* end if (!XGI_IsLCDON(pVBInfo)) */
7751 }
7752 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007753
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307754 /*
7755 if (CH7017) {
7756 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
7757 if (!XGI_IsLCDON(pVBInfo)) {
7758 if (DISCHARGE) {
7759 tempbx = XGINew_GetCH7005(0x61);
7760 if (tempbx < 0x01) // first time we power up
7761 XGINew_SetCH7005(0x0066); // and disable power sequence
7762 else
7763 XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
7764 }
7765 }
7766 }
7767 }
7768 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007769
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307770 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7771 | VB_XGI302LV | VB_XGI301C)) {
7772 tempah = 0x3F;
7773 if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
7774 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7775 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7776 tempah = 0x7F; /* Disable Channel A */
7777 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7778 tempah = 0xBF; /* Disable Channel B */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007779
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307780 if (pVBInfo->SetFlag & DisableChB)
7781 tempah &= 0xBF; /* force to disable Cahnnel */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007782
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307783 if (pVBInfo->SetFlag & DisableChA)
7784 tempah &= 0x7F; /* Force to disable Channel B */
7785 }
7786 }
7787 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007788
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307789 XGINew_SetRegAND(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007790
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307791 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7792 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7793 || (XGI_DisableChISLCD(pVBInfo))
7794 || (XGI_IsLCDON(pVBInfo)))
7795 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
7796 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007797
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307798 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7799 & (DisableCRT2Display | SetCRT2ToLCDA
7800 | SetSimuScanMode))) {
7801 if (pVBInfo->SetFlag & GatingCRT)
7802 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
7803 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7804 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007805
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307806 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7807 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7808 & SetCRT2ToLCDA))
7809 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
7810 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007811
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307812 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007813
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307814 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
7815 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xdf);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007816
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307817 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7818 & (DisableCRT2Display | SetSimuScanMode))
7819 || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7820 && (pVBInfo->VBInfo
7821 & (SetCRT2ToRAMDAC
7822 | SetCRT2ToLCD
7823 | SetCRT2ToTV))))
7824 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007825
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307826 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7827 & (DisableCRT2Display | SetSimuScanMode))
7828 || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7829 || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7830 | SetCRT2ToLCD | SetCRT2ToTV))) {
7831 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
7832 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
7833 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
7834 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
7835 }
7836 } else { /* {301} */
7837 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
7838 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7839 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
7840 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
7841 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007842
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307843 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
7844 | SetSimuScanMode))
7845 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7846 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007847
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307848 if (HwDeviceExtension->jChipType < XG40) {
7849 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7850 || (XGI_DisableChISLCD(pVBInfo))
7851 || (XGI_IsLCDON(pVBInfo))) {
7852 if (pVBInfo->LCDInfo & SetPWDEnable) {
7853 if (pVBInfo->LCDInfo & SetPWDEnable)
7854 XGI_BacklightByDrv(pVBInfo);
7855 else {
7856 XGI_SetPanelDelay(4, pVBInfo);
7857 if (pVBInfo->VBType & VB_XGI301LV) {
7858 tempbl = 0xFD;
7859 tempah = 0x00;
7860 } else {
7861 tempbl = 0xFB;
7862 tempah = 0x04;
7863 }
7864 }
7865 }
7866 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7867 }
7868 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007869}
7870
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007871/* --------------------------------------------------------------------- */
7872/* Function : XGI_GetTVPtrIndex */
7873/* Input : */
7874/* Output : */
7875/* Description : bx 0 : ExtNTSC */
7876/* 1 : StNTSC */
7877/* 2 : ExtPAL */
7878/* 3 : StPAL */
7879/* 4 : ExtHiTV */
7880/* 5 : StHiTV */
7881/* 6 : Ext525i */
7882/* 7 : St525i */
7883/* 8 : Ext525p */
7884/* 9 : St525p */
7885/* A : Ext750p */
7886/* B : St750p */
7887/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04007888unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007889{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307890 unsigned short tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007891
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307892 if (pVBInfo->TVInfo & SetPALTV)
7893 tempbx = 2;
7894 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7895 tempbx = 4;
7896 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7897 tempbx = 6;
7898 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7899 tempbx = 8;
7900 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7901 tempbx = 10;
7902 if (pVBInfo->TVInfo & TVSimuMode)
7903 tempbx++;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007904
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307905 return tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007906}
7907
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007908/* --------------------------------------------------------------------- */
7909/* Function : XGI_OEM310Setting */
7910/* Input : */
7911/* Output : */
7912/* Description : Customized Param. for 301 */
7913/* --------------------------------------------------------------------- */
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307914void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
7915 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007916{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307917 if (pVBInfo->SetFlag & Win9xDOSMode)
7918 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007919
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307920 /* GetPart1IO(); */
7921 XGI_SetDelayComp(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007922
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307923 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7924 XGI_SetLCDCap(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007925
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307926 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7927 /* GetPart2IO() */
7928 XGI_SetPhaseIncr(pVBInfo);
7929 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7930 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007931
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307932 if (pVBInfo->VBType & VB_XGI301)
7933 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7934 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007935}
7936
Bill Pemberton80adad82010-06-17 13:10:51 -04007937void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007938{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307939 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007940
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307941 unsigned char tempah, tempbl, tempbh;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007942
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307943 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7944 | VB_XGI302LV | VB_XGI301C)) {
7945 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7946 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7947 tempbl = 0;
7948 tempbh = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007949
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307950 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7951 tempbl = pVBInfo->XGI_TVDelayList[index];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007952
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307953 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7954 | VB_XGI301LV | VB_XGI302LV
7955 | VB_XGI301C))
7956 tempbl = pVBInfo->XGI_TVDelayList2[index];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007957
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307958 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7959 tempbl = tempbl >> 4;
7960 /*
7961 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7962 tempbl = CRT2Delay1; // Get CRT2 Delay
7963 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
7964 tempbl = CRT2Delay2;
7965 */
7966 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7967 index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
7968 tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007969
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307970 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7971 tempbl = tempbh;
7972 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007973
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307974 tempbl &= 0x0F;
7975 tempbh &= 0xF0;
7976 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x2D);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007977
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307978 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7979 | SetCRT2ToTV)) { /* Channel B */
7980 tempah &= 0xF0;
7981 tempah |= tempbl;
7982 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007983
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307984 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7985 tempah &= 0x0F;
7986 tempah |= tempbh;
7987 }
7988 XGINew_SetReg1(pVBInfo->Part1Port, 0x2D, tempah);
7989 }
7990 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7991 tempbl = 0;
7992 tempbh = 0;
7993 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7994 tempah
7995 = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
7996 pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
7997 tempah &= 0x0f;
7998 tempah = tempah << 4;
7999 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2D, 0x0f,
8000 tempah);
8001 }
8002 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008003}
8004
Bill Pemberton80adad82010-06-17 13:10:51 -04008005void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008006{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308007 unsigned short tempcx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008008
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308009 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008010
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308011 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8012 | VB_XGI302LV | VB_XGI301C)) {
8013 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
8014 /* Set 301LV Capability */
8015 XGINew_SetReg1(pVBInfo->Part4Port, 0x24,
8016 (unsigned char) (tempcx & 0x1F));
8017 }
8018 /* VB Driving */
8019 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
8020 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
8021 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
8022 | EnablePLLSPLOW)) >> 8));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008023 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008024
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308025 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8026 | VB_XGI302LV | VB_XGI301C)) {
8027 if (pVBInfo->VBInfo & SetCRT2ToLCD)
8028 XGI_SetLCDCap_B(tempcx, pVBInfo);
8029 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8030 XGI_SetLCDCap_A(tempcx, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008031
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308032 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8033 if (tempcx & EnableSpectrum)
8034 SetSpectrum(pVBInfo);
8035 }
8036 } else {
8037 /* LVDS,CH7017 */
8038 XGI_SetLCDCap_A(tempcx, pVBInfo);
8039 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008040}
8041
Bill Pemberton80adad82010-06-17 13:10:51 -04008042void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008043{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308044 unsigned short temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008045
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308046 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008047
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308048 if (temp & LCDRGB18Bit) {
8049 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
8050 (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
8051 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
8052 } else {
8053 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
8054 (unsigned short) (0x30 | (tempcx & 0x00C0)));
8055 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
8056 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008057
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308058 /*
8059 if (tempcx & EnableLCD24bpp) { // 24bits
8060 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
8061 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
8062 } else {
8063 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
8064 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
8065 }
8066 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008067}
8068
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008069/* --------------------------------------------------------------------- */
8070/* Function : XGI_SetLCDCap_B */
8071/* Input : cx -> LCD Capability */
8072/* Output : */
8073/* Description : */
8074/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04008075void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008076{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308077 if (tempcx & EnableLCD24bpp) /* 24bits */
8078 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8079 (unsigned short) (((tempcx & 0x00ff) >> 6)
8080 | 0x0c));
8081 else
8082 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8083 (unsigned short) (((tempcx & 0x00ff) >> 6)
8084 | 0x18)); /* Enable Dither */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008085}
8086
Bill Pemberton80adad82010-06-17 13:10:51 -04008087void SetSpectrum(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008088{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308089 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008090
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308091 index = XGI_GetLCDCapPtr(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008092
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308093 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
8094 XGI_LongWait(pVBInfo);
8095 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
8096 XGI_LongWait(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008097
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308098 XGINew_SetReg1(pVBInfo->Part4Port, 0x31,
8099 pVBInfo->LCDCapList[index].Spectrum_31);
8100 XGINew_SetReg1(pVBInfo->Part4Port, 0x32,
8101 pVBInfo->LCDCapList[index].Spectrum_32);
8102 XGINew_SetReg1(pVBInfo->Part4Port, 0x33,
8103 pVBInfo->LCDCapList[index].Spectrum_33);
8104 XGINew_SetReg1(pVBInfo->Part4Port, 0x34,
8105 pVBInfo->LCDCapList[index].Spectrum_34);
8106 XGI_LongWait(pVBInfo);
8107 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008108}
8109
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008110/* --------------------------------------------------------------------- */
8111/* Function : XGI_SetAntiFlicker */
8112/* Input : */
8113/* Output : */
8114/* Description : Set TV Customized Param. */
8115/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008116void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308117 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008118{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308119 unsigned short tempbx, index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008120
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308121 unsigned char tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008122
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308123 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
8124 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008125
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308126 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8127 tempbx &= 0xFE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008128
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308129 if (ModeNo <= 0x13)
8130 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
8131 else
8132 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008133
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308134 tempbx += index;
8135 tempah = TVAntiFlickList[tempbx];
8136 tempah = tempah << 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008137
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308138 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008139}
8140
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308141void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
8142 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008143{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308144 unsigned short tempbx, index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008145
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308146 unsigned char tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008147
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308148 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8149 tempbx &= 0xFE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008150
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308151 if (ModeNo <= 0x13)
8152 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
8153 else
8154 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008155
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308156 tempbx += index;
8157 tempah = TVEdgeList[tempbx];
8158 tempah = tempah << 5;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008159
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308160 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008161}
8162
Bill Pemberton80adad82010-06-17 13:10:51 -04008163void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008164{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308165 unsigned short tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008166
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308167 unsigned char tempcl, tempch;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008168
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308169 unsigned long tempData;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008170
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308171 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
8172 tempData = TVPhaseList[tempbx];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008173
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308174 XGINew_SetReg1(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
8175 & 0x000000FF));
8176 XGINew_SetReg1(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
8177 & 0x0000FF00) >> 8));
8178 XGINew_SetReg1(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
8179 & 0x00FF0000) >> 16));
8180 XGINew_SetReg1(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
8181 & 0xFF000000) >> 24));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008182}
8183
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008184void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308185 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008186{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308187 unsigned short tempbx, index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008188
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308189 unsigned char tempcl, tempch, tempal, *filterPtr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008190
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308191 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008192
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308193 switch (tempbx) {
8194 case 0x00:
8195 case 0x04:
8196 filterPtr = NTSCYFilter1;
8197 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008198
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308199 case 0x01:
8200 filterPtr = PALYFilter1;
8201 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008202
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308203 case 0x02:
8204 case 0x05:
8205 case 0x0D:
8206 filterPtr = PALMYFilter1;
8207 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008208
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308209 case 0x03:
8210 filterPtr = PALNYFilter1;
8211 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008212
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308213 case 0x08:
8214 case 0x0C:
8215 filterPtr = NTSCYFilter2;
8216 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008217
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308218 case 0x0A:
8219 filterPtr = PALMYFilter2;
8220 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008221
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308222 case 0x0B:
8223 filterPtr = PALNYFilter2;
8224 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008225
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308226 case 0x09:
8227 filterPtr = PALYFilter2;
8228 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008229
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308230 default:
8231 return;
8232 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008233
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308234 if (ModeNo <= 0x13)
8235 tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
8236 else
8237 tempal
8238 = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008239
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308240 if (tempcl == 0)
8241 index = tempal * 4;
8242 else
8243 index = tempal * 7;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008244
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308245 if ((tempcl == 0) && (tempch == 1)) {
8246 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, 0);
8247 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, 0);
8248 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, 0);
8249 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8250 } else {
8251 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
8252 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
8253 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
8254 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8255 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008256
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308257 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8258 | VB_XGI302LV | VB_XGI301C)) {
8259 XGINew_SetReg1(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
8260 XGINew_SetReg1(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
8261 XGINew_SetReg1(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
8262 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008263}
8264
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008265/* --------------------------------------------------------------------- */
8266/* Function : XGI_GetTVPtrIndex2 */
8267/* Input : */
8268/* Output : bx 0 : NTSC */
8269/* 1 : PAL */
8270/* 2 : PALM */
8271/* 3 : PALN */
8272/* 4 : NTSC1024x768 */
8273/* 5 : PAL-M 1024x768 */
8274/* 6-7: reserved */
8275/* cl 0 : YFilter1 */
8276/* 1 : YFilter2 */
8277/* ch 0 : 301A */
8278/* 1 : 301B/302B/301LV/302LV */
8279/* Description : */
8280/* --------------------------------------------------------------------- */
Bill Pemberton108afbf2010-06-17 13:10:47 -04008281void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308282 unsigned char *tempch, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008283{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308284 *tempbx = 0;
8285 *tempcl = 0;
8286 *tempch = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008287
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308288 if (pVBInfo->TVInfo & SetPALTV)
8289 *tempbx = 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008290
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308291 if (pVBInfo->TVInfo & SetPALMTV)
8292 *tempbx = 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008293
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308294 if (pVBInfo->TVInfo & SetPALNTV)
8295 *tempbx = 3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008296
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308297 if (pVBInfo->TVInfo & NTSC1024x768) {
8298 *tempbx = 4;
8299 if (pVBInfo->TVInfo & SetPALMTV)
8300 *tempbx = 5;
8301 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008302
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308303 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8304 | VB_XGI302LV | VB_XGI301C)) {
8305 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
8306 & TVSimuMode)) {
8307 *tempbx += 8;
8308 *tempcl += 1;
8309 }
8310 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008311
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308312 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8313 | VB_XGI302LV | VB_XGI301C))
8314 (*tempch)++;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008315}
8316
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008317/* --------------------------------------------------------------------- */
8318/* Function : XGI_SetCRT2ModeRegs */
8319/* Input : */
8320/* Output : */
8321/* Description : Origin code for crt2group */
8322/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008323void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308324 struct xgi_hw_device_info *HwDeviceExtension,
8325 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008326{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308327 unsigned short tempbl;
8328 short tempcl;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008329
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308330 unsigned char tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008331
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308332 /* XGINew_SetReg1(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
8333 tempah = 0;
8334 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8335 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00);
8336 tempah &= ~0x10; /* BTRAMDAC */
8337 tempah |= 0x40; /* BTRAM */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008338
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308339 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8340 | SetCRT2ToLCD)) {
8341 tempah = 0x40; /* BTDRAM */
8342 if (ModeNo > 0x13) {
8343 tempcl = pVBInfo->ModeType;
8344 tempcl -= ModeVGA;
8345 if (tempcl >= 0) {
8346 tempah = (0x008 >> tempcl); /* BT Color */
8347 if (tempah == 0)
8348 tempah = 1;
8349 tempah |= 0x040;
8350 }
8351 }
8352 if (pVBInfo->VBInfo & SetInSlaveMode)
8353 tempah ^= 0x50; /* BTDAC */
8354 }
8355 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008356
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308357 /* 0210 shampoo
8358 if (pVBInfo->VBInfo & DisableCRT2Display) {
8359 tempah = 0;
8360 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008361
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308362 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8363 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
8364 tempcl = pVBInfo->ModeType;
8365 if (ModeNo > 0x13) {
8366 tempcl -= ModeVGA;
8367 if ((tempcl > 0) || (tempcl == 0)) {
8368 tempah=(0x008>>tempcl) ;
8369 if (tempah == 0)
8370 tempah = 1;
8371 tempah |= 0x040;
8372 }
8373 } else {
8374 tempah = 0x040;
8375 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008376
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308377 if (pVBInfo->VBInfo & SetInSlaveMode) {
8378 tempah = (tempah ^ 0x050);
8379 }
8380 }
8381 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008382
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308383 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8384 tempah = 0x08;
8385 tempbl = 0xf0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008386
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308387 if (pVBInfo->VBInfo & DisableCRT2Display) {
8388 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
8389 } else {
8390 tempah = 0x00;
8391 tempbl = 0xff;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008392
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308393 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8394 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
8395 if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
8396 && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
8397 tempbl &= 0xf7;
8398 tempah |= 0x01;
8399 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e,
8400 tempbl, tempah);
8401 } else {
8402 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8403 tempbl &= 0xf7;
8404 tempah |= 0x01;
8405 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008406
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308407 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
8408 | SetCRT2ToTV | SetCRT2ToLCD)) {
8409 tempbl &= 0xf8;
8410 tempah = 0x01;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008411
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308412 if (!(pVBInfo->VBInfo & SetInSlaveMode))
8413 tempah |= 0x02;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008414
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308415 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
8416 tempah = tempah ^ 0x05;
8417 if (!(pVBInfo->VBInfo
8418 & SetCRT2ToLCD))
8419 tempah = tempah ^ 0x01;
8420 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008421
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308422 if (!(pVBInfo->VBInfo
8423 & SetCRT2ToDualEdge))
8424 tempah |= 0x08;
8425 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8426 0x2e, tempbl, tempah);
8427 } else {
8428 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8429 0x2e, tempbl, tempah);
8430 }
8431 }
8432 } else {
8433 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl,
8434 tempah);
8435 }
8436 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008437
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308438 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
8439 | SetCRT2ToLCDA)) {
8440 tempah &= (~0x08);
8441 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
8442 & SetInSlaveMode))) {
8443 tempah |= 0x010;
8444 }
8445 tempah |= 0x080;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008446
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308447 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8448 /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
8449 tempah |= 0x020;
8450 if (ModeNo > 0x13) {
8451 if (pVBInfo->VBInfo & DriverMode)
8452 tempah = tempah ^ 0x20;
8453 }
8454 /* } */
8455 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008456
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308457 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
8458 tempah = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008459
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308460 if (pVBInfo->LCDInfo & SetLCDDualLink)
8461 tempah |= 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008462
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308463 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8464 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
8465 if (pVBInfo->TVInfo & RPLLDIV2XO)
8466 tempah |= 0x40;
8467 /* } */
8468 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008469
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308470 if ((pVBInfo->LCDResInfo == Panel1280x1024)
8471 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
8472 tempah |= 0x80;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008473
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308474 if (pVBInfo->LCDResInfo == Panel1280x960)
8475 tempah |= 0x80;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008476
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308477 XGINew_SetReg1(pVBInfo->Part4Port, 0x0C, tempah);
8478 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008479
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308480 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8481 | VB_XGI302LV | VB_XGI301C)) {
8482 tempah = 0;
8483 tempbl = 0xfb;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008484
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308485 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8486 tempbl = 0xff;
8487 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8488 tempah |= 0x04; /* shampoo 0129 */
8489 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008490
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308491 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x13, tempbl, tempah);
8492 tempah = 0x00;
8493 tempbl = 0xcf;
8494 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8495 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8496 tempah |= 0x30;
8497 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008498
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308499 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
8500 tempah = 0;
8501 tempbl = 0x3f;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008502
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308503 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8504 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8505 tempah |= 0xc0;
8506 }
8507 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, tempbl, tempah);
8508 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008509
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308510 tempah = 0;
8511 tempbl = 0x7f;
8512 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
8513 tempbl = 0xff;
8514 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
8515 tempah |= 0x80;
8516 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008517
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308518 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x23, tempbl, tempah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008519
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308520 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8521 if (pVBInfo->LCDInfo & SetLCDDualLink) {
8522 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x20);
8523 XGINew_SetRegOR(pVBInfo->Part4Port, 0x34, 0x10);
8524 }
8525 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008526}
8527
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308528void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8529 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008530{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308531 unsigned short tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008532
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308533 tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008534
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308535 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8536 tempbx = 0x08A0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008537
8538}
8539
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308540void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8541 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008542{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308543 unsigned short tempbx;
8544 tempbx = 0;
8545}
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008546
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308547void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
8548 unsigned short RefreshRateTableIndex,
8549 struct vb_device_info *pVBInfo)
8550{
8551 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
8552 StandTableIndex, CRT1Index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008553
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308554 pVBInfo->RVBHCMAX = 1;
8555 pVBInfo->RVBHCFACT = 1;
8556
8557 if (ModeNo <= 0x13) {
8558 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8559 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8560 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
8561 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
8562 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
8563 } else {
8564 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8565 CRT1Index
8566 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
8567 CRT1Index &= IndexMask;
8568 temp1
8569 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
8570 temp2
8571 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
8572 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
8573 tempbx
8574 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
8575 tempcx
8576 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
8577 << 8;
8578 tempcx &= 0x0100;
8579 tempcx = tempcx << 2;
8580 tempbx |= tempcx;
8581 temp1
8582 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
8583 }
8584
8585 if (temp1 & 0x01)
8586 tempbx |= 0x0100;
8587
8588 if (temp1 & 0x20)
8589 tempbx |= 0x0200;
8590 tempax += 5;
8591
8592 if (modeflag & Charx8Dot)
8593 tempax *= 8;
8594 else
8595 tempax *= 9;
8596
8597 pVBInfo->VGAHT = tempax;
8598 pVBInfo->HT = tempax;
8599 tempbx++;
8600 pVBInfo->VGAVT = tempbx;
8601 pVBInfo->VT = tempbx;
8602}
8603
8604unsigned short XGI_GetColorDepth(unsigned short ModeNo,
8605 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
8606{
8607 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
8608 short index;
8609 unsigned short modeflag;
8610
8611 if (ModeNo <= 0x13)
8612 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8613 else
8614 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8615
8616 index = (modeflag & ModeInfoFlag) - ModeEGA;
8617
8618 if (index < 0)
8619 index = 0;
8620
8621 return ColorDepth[index];
8622}
8623
8624void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8625 struct vb_device_info *pVBInfo)
8626{
8627
8628 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008629
8630}
8631
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308632void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8633 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008634{
8635
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308636 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008637
8638}
8639
Bill Pemberton80adad82010-06-17 13:10:51 -04008640void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008641{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308642 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008643}
8644
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308645void XGINew_LCD_Wait_Time(unsigned char DelayTime,
8646 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008647{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308648 unsigned short i, j;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008649
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308650 unsigned long temp, flag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008651
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308652 flag = 0;
8653 /* printk("XGINew_LCD_Wait_Time"); */
8654 /* return; */
8655 for (i = 0; i < DelayTime; i++) {
8656 for (j = 0; j < 66; j++) {
8657 temp = XGINew_GetReg3(0x61);
8658 /* temp &= 0x10000000; */
8659 temp &= 0x10;
8660 if (temp == flag)
8661 continue;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008662
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308663 flag = temp;
8664 }
8665 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008666}
8667
Bill Pemberton80adad82010-06-17 13:10:51 -04008668unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008669{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308670 unsigned short flag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008671
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308672 if (pVBInfo->IF_DEF_LVDS == 1) {
8673 return 1;
8674 } else {
8675 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
8676 if ((flag == 1) || (flag == 2))
8677 return 1; /* 301b */
8678 else
8679 return 0;
8680 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008681}
8682
Bill Pemberton80adad82010-06-17 13:10:51 -04008683void XGI_LongWait(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008684{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308685 unsigned short i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008686
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308687 i = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008688
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308689 if (!(i & 0xC0)) {
8690 for (i = 0; i < 0xFFFF; i++) {
8691 if (!(XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8692 break;
8693 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008694
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308695 for (i = 0; i < 0xFFFF; i++) {
8696 if ((XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8697 break;
8698 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008699 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008700}
8701
Bill Pemberton80adad82010-06-17 13:10:51 -04008702void XGI_VBLongWait(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008703{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308704 unsigned short tempal, temp, i, j;
8705 return;
8706 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
8707 temp = 0;
8708 for (i = 0; i < 3; i++) {
8709 for (j = 0; j < 100; j++) {
8710 tempal = XGINew_GetReg2(pVBInfo->P3da);
8711 if (temp & 0x01) { /* VBWaitMode2 */
8712 if ((tempal & 0x08))
8713 continue;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008714
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308715 if (!(tempal & 0x08))
8716 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008717
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308718 } else { /* VBWaitMode1 */
8719 if (!(tempal & 0x08))
8720 continue;
8721
8722 if ((tempal & 0x08))
8723 break;
8724 }
8725 }
8726 temp = temp ^ 0x01;
8727 }
8728 } else {
8729 XGI_LongWait(pVBInfo);
8730 }
8731 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008732}
8733
Bill Pemberton80adad82010-06-17 13:10:51 -04008734unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008735{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308736 unsigned long tempax, tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008737
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308738 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
8739 & 0xFFFF;
8740 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
8741 tempax = (tempax * pVBInfo->HT) / tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008742
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308743 return (unsigned short) tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008744}
8745
Bill Pembertone4147ab2010-06-17 13:10:50 -04008746unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308747 unsigned short ModeIdIndex,
8748 unsigned short RefreshRateTableIndex,
8749 struct xgi_hw_device_info *HwDeviceExtension,
8750 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008751{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308752 unsigned short tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008753
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308754 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8755 VCLK65 + 2 };
8756 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
8757 VCLK108_2 + 5, VCLK108_2 + 5 };
8758 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
8759 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8760 VCLK65 + 2 };
8761 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8762 VCLK65 + 2 };
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008763
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308764 unsigned short CRT2Index, VCLKIndex;
8765 unsigned short modeflag, resinfo;
8766 unsigned char *CHTVVCLKPtr = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008767
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308768 if (ModeNo <= 0x13) {
8769 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8770 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
8771 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
8772 } else {
8773 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
8774 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
8775 CRT2Index
8776 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
8777 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008778
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308779 if (pVBInfo->IF_DEF_LVDS == 0) {
8780 CRT2Index = CRT2Index >> 6; /* for LCD */
8781 if (((pVBInfo->VBInfo & SetCRT2ToLCD) | SetCRT2ToLCDA)) { /*301b*/
8782 if (pVBInfo->LCDResInfo != Panel1024x768)
8783 VCLKIndex = LCDXlat2VCLK[CRT2Index];
8784 else
8785 VCLKIndex = LCDXlat1VCLK[CRT2Index];
8786 } else { /* for TV */
8787 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8788 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
8789 if (pVBInfo->SetFlag & RPLLDIV2XO) {
8790 VCLKIndex = HiTVVCLKDIV2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008791
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308792 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008793
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308794 } else {
8795 VCLKIndex = HiTVVCLK;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008796
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308797 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008798
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308799 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008800
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308801 if (pVBInfo->SetFlag & TVSimuMode) {
8802 if (modeflag & Charx8Dot) {
8803 VCLKIndex
8804 = HiTVSimuVCLK;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008805
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308806 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008807
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308808 } else {
8809 VCLKIndex
8810 = HiTVTextVCLK;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008811
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308812 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008813
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308814 }
8815 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008816
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308817 if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
8818 if (!(pVBInfo->VBExtInfo
8819 == VB_YPbPr1080i)) {
8820 VCLKIndex
8821 = YPbPr750pVCLK;
8822 if (!(pVBInfo->VBExtInfo
8823 == VB_YPbPr750p)) {
8824 VCLKIndex
8825 = YPbPr525pVCLK;
8826 if (!(pVBInfo->VBExtInfo
8827 == VB_YPbPr525p)) {
8828 VCLKIndex
8829 = YPbPr525iVCLK_2;
8830 if (!(pVBInfo->SetFlag
8831 & RPLLDIV2XO))
8832 VCLKIndex
8833 = YPbPr525iVCLK;
8834 }
8835 }
8836 }
8837 }
8838 } else {
8839 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8840 if (pVBInfo->SetFlag
8841 & RPLLDIV2XO) {
8842 VCLKIndex = TVVCLKDIV2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008843
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308844 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008845
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308846 } else {
8847 VCLKIndex = TVVCLK;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008848
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308849 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008850
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308851 }
8852 }
8853 }
8854 } else { /* for CRT2 */
8855 VCLKIndex = (unsigned char) XGINew_GetReg2(
8856 (pVBInfo->P3ca + 0x02)); /* Port 3cch */
8857 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
8858 if (ModeNo > 0x13) {
8859 VCLKIndex
8860 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
8861 VCLKIndex &= IndexMask;
8862 }
8863 }
8864 }
8865 } else { /* LVDS */
8866 if (ModeNo <= 0x13)
8867 VCLKIndex = CRT2Index;
8868 else
8869 VCLKIndex = CRT2Index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008870
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308871 if (pVBInfo->IF_DEF_CH7005 == 1) {
8872 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
8873 VCLKIndex &= 0x1f;
8874 tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008875
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308876 if (pVBInfo->VBInfo & SetPALTV)
8877 tempbx += 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008878
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308879 if (pVBInfo->VBInfo & SetCHTVOverScan)
8880 tempbx += 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008881
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308882 switch (tempbx) {
8883 case 0:
8884 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
8885 break;
8886 case 1:
8887 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
8888 break;
8889 case 2:
8890 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
8891 break;
8892 case 3:
8893 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
8894 break;
8895 default:
8896 break;
8897 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008898
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308899 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
8900 }
8901 } else {
8902 VCLKIndex = VCLKIndex >> 6;
8903 if ((pVBInfo->LCDResInfo == Panel800x600)
8904 || (pVBInfo->LCDResInfo == Panel320x480))
8905 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
8906 else if ((pVBInfo->LCDResInfo == Panel1024x768)
8907 || (pVBInfo->LCDResInfo
8908 == Panel1024x768x75))
8909 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
8910 else
8911 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
8912 }
8913 }
8914 /* VCLKIndex = VCLKIndex&IndexMask; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008915
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308916 return VCLKIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008917}
8918