blob: e19b932492e1e5443b916c210a0c261e6af61c2f [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{
Greg Kroah-Hartman51973d72010-09-08 01:49:45 -0700379 unsigned short ModeIdIndex;
Prashant P. Shah21df8fc2010-09-03 22:12:12 +0530380 /* 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{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303515 if (ModeNo <= 5)
3516 ModeNo |= 1;
3517 if (ModeNo <= 0x13) {
3518 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
3519 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3520 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3521 break;
3522 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3523 return 0;
3524 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003525
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303526 if (ModeNo == 0x07)
3527 (*ModeIdIndex)++; /* 400 lines */
3528 if (ModeNo <= 3)
3529 (*ModeIdIndex) += 2; /* 400 lines */
3530 /* else 350 lines */
3531 } else {
3532 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
3533 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3534 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3535 break;
3536 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3537 return 0;
3538 }
3539 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003540
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303541 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003542}
3543
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003544/* win2000 MM adapter not support standard mode! */
3545
Randy Dunlap89229672010-08-10 08:46:44 -07003546#if 0
Randy Dunlap89229672010-08-10 08:46:44 -07003547static unsigned char XGINew_CheckMemorySize(
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303548 struct xgi_hw_device_info *HwDeviceExtension,
3549 unsigned short ModeNo,
3550 unsigned short ModeIdIndex,
3551 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003552{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303553 unsigned short memorysize, modeflag, temp, temp1, tmp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003554
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303555 /*
3556 if ((HwDeviceExtension->jChipType == XGI_650) ||
3557 (HwDeviceExtension->jChipType == XGI_650M)) {
3558 return 1;
3559 }
3560 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003561
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303562 if (ModeNo <= 0x13)
3563 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3564 else
3565 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003566
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303567 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003568
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303569 memorysize = modeflag & MemoryInfoFlag;
3570 memorysize = memorysize > MemorySizeShift;
3571 memorysize++; /* Get memory size */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003572
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303573 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
3574 tmp = temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003575
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303576 if (HwDeviceExtension->jChipType == XG40) {
3577 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3578 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3579 temp <<= 2;
3580 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
3581 temp <<= 1;
3582 }
3583 } else if (HwDeviceExtension->jChipType == XG42) {
3584 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3585 if ((tmp & 0x04) == 0x04) { /* Dual channels */
3586 temp <<= 1;
3587 }
3588 } else if (HwDeviceExtension->jChipType == XG45) {
3589 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
3590 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3591 temp <<= 2;
3592 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
3593 temp1 = temp;
3594 temp <<= 1;
3595 temp += temp1;
3596 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
3597 temp <<= 1;
3598 }
3599 }
3600 if (temp < memorysize)
3601 return 0;
3602 else
3603 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003604}
Randy Dunlap89229672010-08-10 08:46:44 -07003605#endif
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003606
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303607/*
3608void 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 +02003609{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303610 unsigned short data ;
3611 unsigned short ModeFlag ;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003612
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303613 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3614 data &= 0x7F;
3615 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003616
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303617 if (ModeNo > 0x13) {
3618 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3619 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
3620 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
3621 data |= 0x80;
3622 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
3623 data = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3624 data &= 0xF7;
3625 XGINew_SetReg1(pVBInfo->P3c4, 0x01, data);
3626 }
3627 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003628}
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003629*/
3630
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303631void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
3632 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003633{
3634
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303635 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3636 if (pXGIHWDE->jChipType == XG21) {
3637 if (pVBInfo->IF_DEF_LVDS == 1) {
3638 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3639 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3640 XGI_XG21SetPanelDelay(2, pVBInfo);
3641 }
3642 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3643 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3644 XGI_XG21SetPanelDelay(3, pVBInfo);
3645 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3646 } else {
3647 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3648 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003649
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303650 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003651
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303652 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003653
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303654 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003655
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303656 if (pXGIHWDE->jChipType == XG27) {
3657 if (pVBInfo->IF_DEF_LVDS == 1) {
3658 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
3659 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
3660 XGI_XG21SetPanelDelay(2, pVBInfo);
3661 }
3662 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
3663 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
3664 XGI_XG21SetPanelDelay(3, pVBInfo);
3665 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
3666 } else {
3667 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
3668 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003669
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303670 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003671}
3672
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303673void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
3674 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003675{
3676
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303677 if (pXGIHWDE->jChipType == XG21) {
3678 if (pVBInfo->IF_DEF_LVDS == 1) {
3679 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3680 XGI_XG21SetPanelDelay(3, pVBInfo);
3681 } else {
3682 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3683 }
3684 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003685
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303686 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
3687 /* if (IsCH7007TVMode(pVBInfo) == 0) */
3688 {
3689 }
3690 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003691
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303692 if (pXGIHWDE->jChipType == XG27) {
3693 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
3694 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
3695 XGI_XG21SetPanelDelay(3, pVBInfo);
3696 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003697
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303698 if (pVBInfo->IF_DEF_LVDS == 0)
3699 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
3700 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003701
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303702 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003703}
3704
Bill Pemberton80adad82010-06-17 13:10:51 -04003705void XGI_WaitDisply(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003706{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303707 while ((XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3708 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003709
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303710 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01))
3711 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003712}
3713
Bill Pemberton80adad82010-06-17 13:10:51 -04003714void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003715{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303716 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
3717 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
3718 0x05, 0x00 };
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003719
Bill Pemberton108afbf2010-06-17 13:10:47 -04003720 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003721
Bill Pemberton108afbf2010-06-17 13:10:47 -04003722 unsigned char CR17, CR63, SR31;
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303723 unsigned short temp;
3724 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003725
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303726 int i;
3727 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003728
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303729 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
3730 XGINew_SetReg1(pVBInfo->P3d4, 0x57, 0x4A);
3731 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3732 pVBInfo->P3d4, 0x53) | 0x02));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003733
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303734 SR31 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x31);
3735 CR63 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x63);
3736 SR01 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003737
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303738 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
3739 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003740
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303741 CR17 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x17);
3742 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003743
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303744 SR1F = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
3745 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003746
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303747 SR07 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x07);
3748 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
3749 SR06 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x06);
3750 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003751
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303752 XGINew_SetReg1(pVBInfo->P3d4, 0x11, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003753
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303754 for (i = 0; i < 8; i++)
3755 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003756
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303757 for (i = 8; i < 11; i++)
3758 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 8),
3759 CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003760
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303761 for (i = 11; i < 13; i++)
3762 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 4),
3763 CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003764
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303765 for (i = 13; i < 16; i++)
3766 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i - 3),
3767 CRTCData[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003768
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303769 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
3770 & 0xE0));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003771
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303772 XGINew_SetReg1(pVBInfo->P3c4, 0x31, 0x00);
3773 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
3774 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE1);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003775
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303776 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003777
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303778 for (i = 0; i < 256; i++) {
3779 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3780 (unsigned char) DAC_TEST_PARMS[0]);
3781 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3782 (unsigned char) DAC_TEST_PARMS[1]);
3783 XGINew_SetReg3((pVBInfo->P3c8 + 1),
3784 (unsigned char) DAC_TEST_PARMS[2]);
3785 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003786
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303787 XGI_VBLongWait(pVBInfo);
3788 XGI_VBLongWait(pVBInfo);
3789 XGI_VBLongWait(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003790
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303791 XGINew_LCD_Wait_Time(0x01, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003792
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303793 XGI_WaitDisply(pVBInfo);
3794 temp = XGINew_GetReg2(pVBInfo->P3c2);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003795
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303796 if (temp & 0x10)
3797 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
3798 else
3799 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003800
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303801 /* alan, avoid display something, set BLACK DAC if not restore DAC */
3802 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003803
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303804 for (i = 0; i < 256; i++) {
3805 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3806 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3807 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
3808 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003809
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303810 XGINew_SetReg1(pVBInfo->P3c4, 0x01, SR01);
3811 XGINew_SetReg1(pVBInfo->P3d4, 0x63, CR63);
3812 XGINew_SetReg1(pVBInfo->P3c4, 0x31, SR31);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003813
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303814 /* [2004/05/11] Vicent */
3815 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
3816 pVBInfo->P3d4, 0x53) & 0xFD));
3817 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003818}
3819
Randy Dunlap89229672010-08-10 08:46:44 -07003820#if 0
Randy Dunlap89229672010-08-10 08:46:44 -07003821static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003822{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303823 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01));
3824 while (XGINew_GetReg2(pVBInfo->P3da) & 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003825}
Randy Dunlap89229672010-08-10 08:46:44 -07003826#endif
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003827
Bill Pemberton108afbf2010-06-17 13:10:47 -04003828unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303829 struct xgi_hw_device_info *HwDeviceExtension,
3830 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003831{
Greg Kroah-Hartman51973d72010-09-08 01:49:45 -07003832 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003833
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303834 tempbx = pVBInfo->VBInfo;
3835 pVBInfo->SetFlag |= ProgrammingCRT2;
3836 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
3837 pVBInfo->SelectCRT2Rate = 4;
3838 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
3839 ModeIdIndex, pVBInfo);
3840 XGI_SaveCRT2Info(ModeNo, pVBInfo);
3841 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
3842 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3843 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3844 RefreshRateTableIndex, pVBInfo);
3845 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
3846 RefreshRateTableIndex, pVBInfo);
3847 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3848 RefreshRateTableIndex, pVBInfo);
3849 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3850 HwDeviceExtension, pVBInfo);
3851 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
3852 RefreshRateTableIndex, pVBInfo);
3853 XGI_SetTap4Regs(pVBInfo);
3854 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
3855 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3856 HwDeviceExtension, pVBInfo);
3857 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
3858 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
3859 XGI_AutoThreshold(pVBInfo);
3860 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003861}
3862
Bill Pemberton80adad82010-06-17 13:10:51 -04003863void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003864{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303865 if (!(pVBInfo->SetFlag & Win9xDOSMode))
3866 XGINew_SetRegOR(pVBInfo->Part1Port, 0x01, 0x40);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003867}
3868
Bill Pemberton80adad82010-06-17 13:10:51 -04003869void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003870{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303871 unsigned short temp1, temp2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003872
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303873 XGINew_SetReg1(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
3874 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
3875 temp2 = ~(SetInSlaveMode >> 8);
3876 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, temp2, temp1);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003877}
3878
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303879void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3880 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003881{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303882 unsigned short xres, yres, modeflag, resindex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003883
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303884 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
3885 if (ModeNo <= 0x13) {
3886 xres = pVBInfo->StResInfo[resindex].HTotal;
3887 yres = pVBInfo->StResInfo[resindex].VTotal;
3888 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
3889 } else {
3890 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
3891 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
3892 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003893
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303894 /*
3895 if (pVBInfo->IF_DEF_FSTN) {
3896 xres *= 2;
3897 yres *= 2;
3898 } else {
3899 */
3900 if (modeflag & HalfDCLK)
3901 xres *= 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003902
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303903 if (modeflag & DoubleScanMode)
3904 yres *= 2;
3905 /* } */
3906 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003907
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303908 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3909 if (pVBInfo->IF_DEF_LVDS == 0) {
3910 if (pVBInfo->LCDResInfo == Panel1600x1200) {
3911 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3912 if (yres == 1024)
3913 yres = 1056;
3914 }
3915 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003916
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303917 if (pVBInfo->LCDResInfo == Panel1280x1024) {
3918 if (yres == 400)
3919 yres = 405;
3920 else if (yres == 350)
3921 yres = 360;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003922
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303923 if (pVBInfo->LCDInfo & LCDVESATiming) {
3924 if (yres == 360)
3925 yres = 375;
3926 }
3927 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003928
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303929 if (pVBInfo->LCDResInfo == Panel1024x768) {
3930 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
3931 if (!(pVBInfo->LCDInfo
3932 & LCDNonExpanding)) {
3933 if (yres == 350)
3934 yres = 357;
3935 else if (yres == 400)
3936 yres = 420;
3937 else if (yres == 480)
3938 yres = 525;
3939 }
3940 }
3941 }
3942 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003943
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303944 if (xres == 720)
3945 xres = 640;
3946 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003947
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303948 pVBInfo->VGAHDE = xres;
3949 pVBInfo->HDE = xres;
3950 pVBInfo->VGAVDE = yres;
3951 pVBInfo->VDE = yres;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003952}
3953
Bill Pemberton80adad82010-06-17 13:10:51 -04003954unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003955{
3956
Dan Carpentera65fd092011-01-04 09:02:27 +03003957 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
3958 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303959 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003960
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303961 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003962}
3963
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303964void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
3965 unsigned short RefreshRateTableIndex,
3966 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003967{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303968 unsigned short tempax = 0, tempbx, modeflag, resinfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003969
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303970 struct XGI_LCDDataStruct *LCDPtr = NULL;
3971 struct XGI_TVDataStruct *TVPtr = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003972
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303973 if (ModeNo <= 0x13) {
3974 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
3975 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
3976 } else {
3977 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
3978 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3979 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003980
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303981 pVBInfo->NewFlickerMode = 0;
3982 pVBInfo->RVBHRS = 50;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003983
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303984 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3985 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3986 pVBInfo);
3987 return;
3988 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003989
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303990 tempbx = 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003991
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303992 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3993 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
3994 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3995 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02003996
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05303997 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
3998 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
3999 pVBInfo->VGAHT = LCDPtr->VGAHT;
4000 pVBInfo->VGAVT = LCDPtr->VGAVT;
4001 pVBInfo->HT = LCDPtr->LCDHT;
4002 pVBInfo->VT = LCDPtr->LCDVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004003
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304004 if (pVBInfo->LCDResInfo == Panel1024x768) {
4005 tempax = 1024;
4006 tempbx = 768;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004007
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304008 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4009 if (pVBInfo->VGAVDE == 357)
4010 tempbx = 527;
4011 else if (pVBInfo->VGAVDE == 420)
4012 tempbx = 620;
4013 else if (pVBInfo->VGAVDE == 525)
4014 tempbx = 775;
4015 else if (pVBInfo->VGAVDE == 600)
4016 tempbx = 775;
4017 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4018 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4019 else
4020 tempbx = 768;
4021 } else
4022 tempbx = 768;
4023 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4024 tempax = 1024;
4025 tempbx = 768;
4026 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4027 tempax = 1280;
4028 if (pVBInfo->VGAVDE == 360)
4029 tempbx = 768;
4030 else if (pVBInfo->VGAVDE == 375)
4031 tempbx = 800;
4032 else if (pVBInfo->VGAVDE == 405)
4033 tempbx = 864;
4034 else
4035 tempbx = 1024;
4036 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4037 tempax = 1280;
4038 tempbx = 1024;
4039 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4040 tempax = 1280;
4041 if (pVBInfo->VGAVDE == 350)
4042 tempbx = 700;
4043 else if (pVBInfo->VGAVDE == 400)
4044 tempbx = 800;
4045 else if (pVBInfo->VGAVDE == 1024)
4046 tempbx = 960;
4047 else
4048 tempbx = 960;
4049 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4050 tempax = 1400;
4051 tempbx = 1050;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004052
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304053 if (pVBInfo->VGAVDE == 1024) {
4054 tempax = 1280;
4055 tempbx = 1024;
4056 }
4057 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4058 tempax = 1600;
4059 tempbx = 1200; /* alan 10/14/2003 */
4060 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4061 if (pVBInfo->VGAVDE == 350)
4062 tempbx = 875;
4063 else if (pVBInfo->VGAVDE == 400)
4064 tempbx = 1000;
4065 }
4066 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004067
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304068 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4069 tempax = pVBInfo->VGAHDE;
4070 tempbx = pVBInfo->VGAVDE;
4071 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004072
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304073 pVBInfo->HDE = tempax;
4074 pVBInfo->VDE = tempbx;
4075 return;
4076 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004077
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304078 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4079 tempbx = 4;
4080 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4081 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4082 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004083
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304084 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4085 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4086 pVBInfo->VGAHT = TVPtr->VGAHT;
4087 pVBInfo->VGAVT = TVPtr->VGAVT;
4088 pVBInfo->HDE = TVPtr->TVHDE;
4089 pVBInfo->VDE = TVPtr->TVVDE;
4090 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4091 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004092
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304093 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4094 if (resinfo == 0x08)
4095 pVBInfo->NewFlickerMode = 0x40;
4096 else if (resinfo == 0x09)
4097 pVBInfo->NewFlickerMode = 0x40;
4098 else if (resinfo == 0x12)
4099 pVBInfo->NewFlickerMode = 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004100
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304101 if (pVBInfo->VGAVDE == 350)
4102 pVBInfo->TVInfo |= TVSimuMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004103
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304104 tempax = ExtHiTVHT;
4105 tempbx = ExtHiTVVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004106
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304107 if (pVBInfo->VBInfo & SetInSlaveMode) {
4108 if (pVBInfo->TVInfo & TVSimuMode) {
4109 tempax = StHiTVHT;
4110 tempbx = StHiTVVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004111
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304112 if (!(modeflag & Charx8Dot)) {
4113 tempax = StHiTextTVHT;
4114 tempbx = StHiTextTVVT;
4115 }
4116 }
4117 }
4118 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4119 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4120 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4121 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4122 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004123
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304124 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4125 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4126 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4127 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4128 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4129 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4130 if (pVBInfo->TVInfo & NTSC1024x768)
4131 tempax = NTSC1024x768HT;
4132 }
4133 } else {
4134 tempax = PALHT;
4135 tempbx = PALVT;
4136 if (!(pVBInfo->TVInfo & SetPALTV)) {
4137 tempax = NTSCHT;
4138 tempbx = NTSCVT;
4139 if (pVBInfo->TVInfo & NTSC1024x768)
4140 tempax = NTSC1024x768HT;
4141 }
4142 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004143
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304144 pVBInfo->HT = tempax;
4145 pVBInfo->VT = tempbx;
4146 return;
4147 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004148}
4149
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304150void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4151 unsigned short RefreshRateTableIndex,
4152 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004153{
Bill Pemberton108afbf2010-06-17 13:10:47 -04004154 unsigned char di_0, di_1, tempal;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004155
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304156 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4157 pVBInfo);
4158 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4159 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004160
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304161 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4162 /* 301 */
4163 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, 0x10);
4164 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4165 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4166 } else { /* 301b/302b/301lv/302lv */
4167 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4168 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4169 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004170
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304171 XGINew_SetReg1(pVBInfo->Part4Port, 0x00, 0x12);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004172
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304173 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4174 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x28);
4175 else
4176 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x08);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004177}
4178
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004179/* --------------------------------------------------------------------- */
4180/* Function : XGI_GETLCDVCLKPtr */
4181/* Input : */
4182/* Output : al -> VCLK Index */
4183/* Description : */
4184/* --------------------------------------------------------------------- */
Bill Pemberton108afbf2010-06-17 13:10:47 -04004185void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304186 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004187{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304188 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004189
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304190 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4191 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
4192 if (pVBInfo->LCDInfo & EnableScalingLCD)
4193 return;
4194 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004195
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304196 /* index = XGI_GetLCDCapPtr(pVBInfo); */
4197 index = XGI_GetLCDCapPtr1(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004198
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304199 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
4200 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
4201 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
4202 } else { /* LCDA */
4203 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
4204 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
4205 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004206 }
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304207 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004208}
4209
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304210unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
4211 unsigned short ModeNo, unsigned short ModeIdIndex,
4212 struct vb_device_info *pVBInfo)
4213{
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004214
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304215 unsigned short index, modeflag;
4216 unsigned short tempbx;
4217 unsigned char tempal;
4218 unsigned char *CHTVVCLKPtr = NULL;
4219
4220 if (ModeNo <= 0x13)
4221 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4222 else
4223 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4224
4225 if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
4226 & EnableScalingLCD))) { /* {LCDA/LCDB} */
4227 index = XGI_GetLCDCapPtr(pVBInfo);
4228 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
4229
4230 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
4231 return tempal;
4232
4233 /* {TV} */
4234 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4235 | VB_XGI302LV | VB_XGI301C)) {
4236 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4237 tempal = HiTVVCLKDIV2;
4238 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4239 tempal = HiTVVCLK;
4240 if (pVBInfo->TVInfo & TVSimuMode) {
4241 tempal = HiTVSimuVCLK;
4242 if (!(modeflag & Charx8Dot))
4243 tempal = HiTVTextVCLK;
4244
4245 }
4246 return tempal;
4247 }
4248
4249 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4250 tempal = YPbPr750pVCLK;
4251 return tempal;
4252 }
4253
4254 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4255 tempal = YPbPr525pVCLK;
4256 return tempal;
4257 }
4258
4259 tempal = NTSC1024VCLK;
4260
4261 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
4262 tempal = TVVCLKDIV2;
4263 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
4264 tempal = TVVCLK;
4265 }
4266
4267 if (pVBInfo->VBInfo & SetCRT2ToTV)
4268 return tempal;
4269 }
4270 /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
4271 if (ModeNo<=0x13)
4272 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4273 else
4274 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4275 *tempal = *tempal & 0x1F;
4276 tempbx = 0;
4277 if (pVBInfo->TVInfo & SetPALTV)
4278 tempbx = tempbx + 2;
4279 if (pVBInfo->TVInfo & SetCHTVOverScan)
4280 tempbx++;
4281 tempbx = tempbx << 1;
4282 } */
4283 } /* {End of VB} */
4284
4285 if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
4286 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
4287 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
4288 if (ModeNo <= 0x13) {
4289 tempal
4290 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
4291 } else {
4292 tempal
4293 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4294 }
4295
4296 tempal = tempal & 0x0F;
4297 tempbx = 0;
4298
4299 if (pVBInfo->TVInfo & SetPALTV)
4300 tempbx = tempbx + 2;
4301
4302 if (pVBInfo->TVInfo & SetCHTVOverScan)
4303 tempbx++;
4304
4305 /** tempbx = tempbx << 1; CH7007 ? **/
4306
4307 /* [Billy]07/05/29 CH7007 */
4308 if (pVBInfo->IF_DEF_CH7007 == 1) {
4309 switch (tempbx) {
4310 case 0:
4311 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
4312 break;
4313 case 1:
4314 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
4315 break;
4316 case 2:
4317 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
4318 break;
4319 case 3:
4320 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
4321 break;
4322 default:
4323 break;
4324
4325 }
4326 }
4327 /* else {
4328 switch(tempbx) {
4329 case 0:
4330 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
4331 break;
4332 case 1:
4333 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
4334 break;
4335 case 2:
4336 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
4337 break;
4338 case 3:
4339 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
4340 break;
4341 default:
4342 break;
4343 }
4344 }
4345 */
4346
4347 tempal = CHTVVCLKPtr[tempal];
4348 return tempal;
4349 }
4350
4351 }
4352
4353 tempal = (unsigned char) XGINew_GetReg2((pVBInfo->P3ca + 0x02));
4354 tempal = tempal >> 2;
4355 tempal &= 0x03;
4356
4357 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
4358 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
4359
4360 if (ModeNo <= 0x13)
4361 return tempal;
4362
4363 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
4364 return tempal;
4365}
4366
4367void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
4368 unsigned char *di_1, struct vb_device_info *pVBInfo)
4369{
4370 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
4371 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
4372 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
4373 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
4374 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
4375 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
4376 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
4377 & ProgrammingCRT2)) {
4378 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
4379 *di_1 = XGI_VBVCLKData[tempal].SR2C;
4380 }
4381 } else {
4382 *di_0 = XGI_VCLKData[tempal].SR2B;
4383 *di_1 = XGI_VCLKData[tempal].SR2C;
4384 }
4385}
4386
4387static void XGI_SetCRT2Offset(unsigned short ModeNo,
4388 unsigned short ModeIdIndex,
4389 unsigned short RefreshRateTableIndex,
4390 struct xgi_hw_device_info *HwDeviceExtension,
4391 struct vb_device_info *pVBInfo)
4392{
4393 unsigned short offset;
4394 unsigned char temp;
4395
4396 if (pVBInfo->VBInfo & SetInSlaveMode)
4397 return;
4398
4399 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4400 HwDeviceExtension, pVBInfo);
4401 temp = (unsigned char) (offset & 0xFF);
4402 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp);
4403 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4404 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, temp);
4405 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4406 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4407}
4408
4409unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
4410 unsigned short RefreshRateTableIndex,
4411 struct xgi_hw_device_info *HwDeviceExtension,
4412 struct vb_device_info *pVBInfo)
4413{
4414 unsigned short temp, colordepth, modeinfo, index, infoflag,
4415 ColorDepth[] = { 0x01, 0x02, 0x04 };
4416
4417 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4418 if (ModeNo <= 0x14)
4419 infoflag = 0;
4420 else
4421 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4422
4423 index = (modeinfo >> 8) & 0xFF;
4424
4425 temp = pVBInfo->ScreenOffset[index];
4426
4427 if (infoflag & InterlaceMode)
4428 temp = temp << 1;
4429
4430 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4431
4432 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4433 temp = ModeNo - 0x7C;
4434 colordepth = ColorDepth[temp];
4435 temp = 0x6B;
4436 if (infoflag & InterlaceMode)
4437 temp = temp << 1;
4438 return temp * colordepth;
4439 } else {
4440 return temp * colordepth;
4441 }
4442}
4443
Randy Dunlap89229672010-08-10 08:46:44 -07004444static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004445{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304446 XGINew_SetReg1(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
4447 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004448}
4449
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004450void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304451 struct xgi_hw_device_info *HwDeviceExtension,
4452 unsigned short RefreshRateTableIndex,
4453 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004454{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304455 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004456
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304457 if (ModeNo > 0x13) {
4458 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4459 CRT1Index &= IndexMask;
4460 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4461 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004462
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304463 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4464 HwDeviceExtension, pVBInfo);
4465 XGI_SetCRT2FIFO(pVBInfo);
4466 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004467
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304468 for (tempcx = 4; tempcx < 7; tempcx++)
4469 XGINew_SetReg1(pVBInfo->Part1Port, tempcx, 0x0);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004470
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304471 XGINew_SetReg1(pVBInfo->Part1Port, 0x50, 0x00);
4472 XGINew_SetReg1(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004473}
4474
Bill Pemberton82d6eb52010-06-17 13:10:46 -04004475void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304476 struct xgi_hw_device_info *HwDeviceExtension,
4477 unsigned short RefreshRateTableIndex,
4478 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004479{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304480 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4481 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004482
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304483 if (ModeNo > 0x13) {
4484 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4485 CRT1Index &= IndexMask;
4486 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004487 }
4488
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304489 if (ModeNo <= 0x13)
4490 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4491 else
4492 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004493
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304494 /* bainy change table name */
4495 if (modeflag & HalfDCLK) {
4496 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4497 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4498 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4499 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4500 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4501 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4502 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4503 pushbx = pVBInfo->VGAHDE / 2 + 16;
4504 tempcx = tempcx >> 1;
4505 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4506 tempcx += tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004507
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304508 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4509 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4510 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4511 & 0xC0) << 2);
4512 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4513 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4514 tempcx &= 0x1F;
4515 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4516 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4517 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4518 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004519
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304520 tempbx += 4;
4521 tempcx += 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004522
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304523 if (tempcx > (pVBInfo->VGAHT / 2))
4524 tempcx = pVBInfo->VGAHT / 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004525
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304526 temp = tempbx & 0x00FF;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004527
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304528 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4529 } else {
4530 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4531 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4532 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4533 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4534 temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4535 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4536 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4537 pushbx = pVBInfo->VGAHDE + 16;
4538 tempcx = tempcx >> 1;
4539 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4540 tempcx += tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004541
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304542 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4543 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4544 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
4545 & 0xC0) << 2);
4546 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4547 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4548 tempcx &= 0x1F;
4549 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4550 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4551 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4552 tempbx += 16;
4553 tempcx += 16;
4554 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004555
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304556 if (tempcx > pVBInfo->VGAHT)
4557 tempcx = pVBInfo->VGAHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004558
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304559 temp = tempbx & 0x00FF;
4560 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4561 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004562
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304563 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4564 tempbx = pushbx;
4565 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4566 tempax |= (tempbx & 0xFF00);
4567 temp = (tempax & 0xFF00) >> 8;
4568 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4569 temp = tempcx & 0x00FF;
4570 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp);
4571 tempcx = (pVBInfo->VGAVT - 1);
4572 temp = tempcx & 0x00FF;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004573
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304574 if (pVBInfo->IF_DEF_CH7005 == 1) {
4575 if (pVBInfo->VBInfo & 0x0C)
4576 temp--;
4577 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004578
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304579 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4580 tempbx = pVBInfo->VGAVDE - 1;
4581 temp = tempbx & 0x00FF;
4582 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, temp);
4583 temp = ((tempbx & 0xFF00) << 3) >> 8;
4584 temp |= ((tempcx & 0xFF00) >> 8);
4585 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004586
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304587 tempax = pVBInfo->VGAVDE;
4588 tempbx = pVBInfo->VGAVDE;
4589 tempcx = pVBInfo->VGAVT;
4590 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
4591 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004592
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304593 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4594 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4595 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004596
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304597 if (temp & 0x04)
4598 tempbx |= 0x0100;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004599
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304600 if (temp & 0x080)
4601 tempbx |= 0x0200;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004602
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304603 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004604
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304605 if (temp & 0x08)
4606 tempbx |= 0x0400;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004607
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304608 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4609 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4610 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004611
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304612 temp = tempbx & 0x00FF;
4613 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4614 temp = ((tempbx & 0xFF00) >> 8) << 4;
4615 temp = ((tempcx & 0x000F) | (temp));
4616 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, temp);
4617 tempax = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004618
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304619 if (modeflag & DoubleScanMode)
4620 tempax |= 0x80;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004621
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304622 if (modeflag & HalfDCLK)
4623 tempax |= 0x40;
4624
4625 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004626}
4627
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304628void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4629 struct xgi_hw_device_info *HwDeviceExtension,
4630 unsigned short RefreshRateTableIndex,
4631 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004632{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304633 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4634 modeflag, CRT1Index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004635
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304636 if (ModeNo <= 0x13) {
4637 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4638 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4639 } else {
4640 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4641 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4642 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4643 CRT1Index &= IndexMask;
4644 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004645
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304646 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4647 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004648
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304649 temp = 0xFF; /* set MAX HT */
4650 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4651 /* if (modeflag & Charx8Dot) */
4652 /* tempcx = 0x08; */
4653 /* else */
4654 tempcx = 0x08;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004655
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304656 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4657 modeflag |= Charx8Dot;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004658
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304659 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004660
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304661 if (modeflag & HalfDCLK)
4662 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004663
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304664 tempax = (tempax / tempcx) - 1;
4665 tempbx |= ((tempax & 0x00FF) << 8);
4666 temp = tempax & 0x00FF;
4667 XGINew_SetReg1(pVBInfo->Part1Port, 0x04, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004668
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304669 temp = (tempbx & 0xFF00) >> 8;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004670
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304671 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4672 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4673 | VB_XGI302LV | VB_XGI301C)))
4674 temp += 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004675
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304676 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4677 if (pVBInfo->VBType & VB_XGI301LV) {
4678 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4679 if (resinfo == 7)
4680 temp -= 2;
4681 }
4682 } else if (resinfo == 7) {
4683 temp -= 2;
4684 }
4685 }
4686 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004687
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304688 XGINew_SetReg1(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
4689 XGINew_SetReg1(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004690
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304691 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4692 if (pVBInfo->VBInfo & SetCRT2ToTV)
4693 tempax = pVBInfo->VGAHT;
4694 else
4695 tempax = XGI_GetVGAHT2(pVBInfo);
4696 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004697
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304698 if (tempax >= pVBInfo->VGAHT)
4699 tempax = pVBInfo->VGAHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004700
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304701 if (modeflag & HalfDCLK)
4702 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004703
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304704 tempax = (tempax / tempcx) - 5;
4705 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4706 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4707 temp = (tempbx & 0x00FF) - 1;
4708 if (!(modeflag & HalfDCLK)) {
4709 temp -= 6;
4710 if (pVBInfo->TVInfo & TVSimuMode) {
4711 temp -= 4;
4712 if (ModeNo > 0x13)
4713 temp -= 10;
4714 }
4715 }
4716 } else {
4717 /* tempcx = tempbx & 0x00FF ; */
4718 tempbx = (tempbx & 0xFF00) >> 8;
4719 tempcx = (tempcx + tempbx) >> 1;
4720 temp = (tempcx & 0x00FF) + 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004721
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304722 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4723 temp -= 1;
4724 if (!(modeflag & HalfDCLK)) {
4725 if ((modeflag & Charx8Dot)) {
4726 temp += 4;
4727 if (pVBInfo->VGAHDE >= 800)
4728 temp -= 6;
4729 }
4730 }
4731 } else {
4732 if (!(modeflag & HalfDCLK)) {
4733 temp -= 4;
4734 if (pVBInfo->LCDResInfo != Panel1280x960) {
4735 if (pVBInfo->VGAHDE >= 800) {
4736 temp -= 7;
4737 if (pVBInfo->ModeType
4738 == ModeEGA) {
4739 if (pVBInfo->VGAVDE
4740 == 1024) {
4741 temp += 15;
4742 if (pVBInfo->LCDResInfo
4743 != Panel1280x1024) {
4744 temp
4745 += 7;
4746 }
4747 }
4748 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004749
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304750 if (pVBInfo->VGAHDE >= 1280) {
4751 if (pVBInfo->LCDResInfo
4752 != Panel1280x960) {
4753 if (pVBInfo->LCDInfo
4754 & LCDNonExpanding) {
4755 temp
4756 += 28;
4757 }
4758 }
4759 }
4760 }
4761 }
4762 }
4763 }
4764 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004765
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304766 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
4767 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004768
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304769 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4770 if (pVBInfo->TVInfo & TVSimuMode) {
4771 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
4772 == 0x11) || (ModeNo == 0x13) || (ModeNo
4773 == 0x0F)) {
4774 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, 0x5b);
4775 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0x03);
4776 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004777
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304778 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
4779 if (pVBInfo->TVInfo & SetNTSCTV) {
4780 XGINew_SetReg1(pVBInfo->Part1Port,
4781 0x07, 0x2A);
4782 XGINew_SetReg1(pVBInfo->Part1Port,
4783 0x08, 0x61);
4784 } else {
4785 XGINew_SetReg1(pVBInfo->Part1Port,
4786 0x07, 0x2A);
4787 XGINew_SetReg1(pVBInfo->Part1Port,
4788 0x08, 0x41);
4789 XGINew_SetReg1(pVBInfo->Part1Port,
4790 0x0C, 0xF0);
4791 }
4792 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004793
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304794 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
4795 == 0x07)) {
4796 if (pVBInfo->TVInfo & SetNTSCTV) {
4797 XGINew_SetReg1(pVBInfo->Part1Port,
4798 0x07, 0x54);
4799 XGINew_SetReg1(pVBInfo->Part1Port,
4800 0x08, 0x00);
4801 } else {
4802 XGINew_SetReg1(pVBInfo->Part1Port,
4803 0x07, 0x55);
4804 XGINew_SetReg1(pVBInfo->Part1Port,
4805 0x08, 0x00);
4806 XGINew_SetReg1(pVBInfo->Part1Port,
4807 0x0C, 0xF0);
4808 }
4809 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004810
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304811 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
4812 == 0x0D) || (ModeNo == 0x50)) {
4813 if (pVBInfo->TVInfo & SetNTSCTV) {
4814 XGINew_SetReg1(pVBInfo->Part1Port,
4815 0x07, 0x30);
4816 XGINew_SetReg1(pVBInfo->Part1Port,
4817 0x08, 0x03);
4818 } else {
4819 XGINew_SetReg1(pVBInfo->Part1Port,
4820 0x07, 0x2f);
4821 XGINew_SetReg1(pVBInfo->Part1Port,
4822 0x08, 0x02);
4823 }
4824 }
4825 }
4826 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004827
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304828 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
4829 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
4830 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004831
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304832 tempbx = pVBInfo->VGAVT;
4833 push1 = tempbx;
4834 tempcx = 0x121;
4835 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004836
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304837 if (tempbx == 357)
4838 tempbx = 350;
4839 if (tempbx == 360)
4840 tempbx = 350;
4841 if (tempbx == 375)
4842 tempbx = 350;
4843 if (tempbx == 405)
4844 tempbx = 400;
4845 if (tempbx == 525)
4846 tempbx = 480;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004847
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304848 push2 = tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004849
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304850 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4851 if (pVBInfo->LCDResInfo == Panel1024x768) {
4852 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4853 if (tempbx == 350)
4854 tempbx += 5;
4855 if (tempbx == 480)
4856 tempbx += 5;
4857 }
4858 }
4859 }
4860 tempbx--;
4861 temp = tempbx & 0x00FF;
4862 tempbx--;
4863 temp = tempbx & 0x00FF;
4864 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
4865 tempbx = push2;
4866 tempbx--;
4867 temp = tempbx & 0x00FF;
4868 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004869
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304870 if (tempbx & 0x0100)
4871 tempcx |= 0x0002;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004872
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304873 tempax = 0x000B;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004874
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304875 if (modeflag & DoubleScanMode)
4876 tempax |= 0x08000;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004877
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304878 if (tempbx & 0x0200)
4879 tempcx |= 0x0040;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004880
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304881 temp = (tempax & 0xFF00) >> 8;
4882 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004883
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304884 if (tempbx & 0x0400)
4885 tempcx |= 0x0600;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02004886
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05304887 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
4888
4889 tempax = push1;
4890 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
4891 tempax = tempax >> 2;
4892 push1 = tempax; /* push ax */
4893
4894 if (resinfo != 0x09) {
4895 tempax = tempax << 1;
4896 tempbx += tempax;
4897 }
4898
4899 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4900 if (pVBInfo->VBType & VB_XGI301LV) {
4901 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
4902 tempbx -= 10;
4903 } else {
4904 if (pVBInfo->TVInfo & TVSimuMode) {
4905 if (pVBInfo->TVInfo & SetPALTV) {
4906 if (pVBInfo->VBType
4907 & VB_XGI301LV) {
4908 if (!(pVBInfo->TVInfo
4909 & (SetYPbPrMode525p
4910 | SetYPbPrMode750p
4911 | SetYPbPrMode1080i)))
4912 tempbx += 40;
4913 } else {
4914 tempbx += 40;
4915 }
4916 }
4917 }
4918 }
4919 } else {
4920 tempbx -= 10;
4921 }
4922 } else {
4923 if (pVBInfo->TVInfo & TVSimuMode) {
4924 if (pVBInfo->TVInfo & SetPALTV) {
4925 if (pVBInfo->VBType & VB_XGI301LV) {
4926 if (!(pVBInfo->TVInfo
4927 & (SetYPbPrMode525p
4928 | SetYPbPrMode750p
4929 | SetYPbPrMode1080i)))
4930 tempbx += 40;
4931 } else {
4932 tempbx += 40;
4933 }
4934 }
4935 }
4936 }
4937 tempax = push1;
4938 tempax = tempax >> 2;
4939 tempax++;
4940 tempax += tempbx;
4941 push1 = tempax; /* push ax */
4942
4943 if ((pVBInfo->TVInfo & SetPALTV)) {
4944 if (tempbx <= 513) {
4945 if (tempax >= 513)
4946 tempbx = 513;
4947 }
4948 }
4949
4950 temp = tempbx & 0x00FF;
4951 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4952 tempbx--;
4953 temp = tempbx & 0x00FF;
4954 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4955
4956 if (tempbx & 0x0100)
4957 tempcx |= 0x0008;
4958
4959 if (tempbx & 0x0200)
4960 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
4961
4962 tempbx++;
4963
4964 if (tempbx & 0x0100)
4965 tempcx |= 0x0004;
4966
4967 if (tempbx & 0x0200)
4968 tempcx |= 0x0080;
4969
4970 if (tempbx & 0x0400)
4971 tempcx |= 0x0C00;
4972
4973 tempbx = push1; /* pop ax */
4974 temp = tempbx & 0x00FF;
4975 temp &= 0x0F;
4976 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
4977
4978 if (tempbx & 0x0010)
4979 tempcx |= 0x2000;
4980
4981 temp = tempcx & 0x00FF;
4982 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
4983 temp = (tempcx & 0x0FF00) >> 8;
4984 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
4985 tempax = modeflag;
4986 temp = (tempax & 0xFF00) >> 8;
4987
4988 temp = (temp >> 1) & 0x09;
4989
4990 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4991 temp |= 0x01;
4992
4993 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
4994 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
4995 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
4996
4997 if (pVBInfo->LCDInfo & LCDRGB18Bit)
4998 temp = 0x80;
4999 else
5000 temp = 0x00;
5001
5002 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5003
5004 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005005}
5006
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305007void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5008 unsigned short RefreshRateTableIndex,
5009 struct xgi_hw_device_info *HwDeviceExtension,
5010 struct vb_device_info *pVBInfo)
5011{
5012 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5013 modeflag, resinfo, crt2crtc;
5014 unsigned char *TimingPoint;
5015
5016 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5017
5018 if (ModeNo <= 0x13) {
5019 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5020 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5021 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5022 } else {
5023 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5024 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5025 crt2crtc
5026 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5027 }
5028
5029 tempax = 0;
5030
5031 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5032 tempax |= 0x0800;
5033
5034 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5035 tempax |= 0x0400;
5036
5037 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5038 tempax |= 0x0200;
5039
5040 if (!(pVBInfo->TVInfo & SetPALTV))
5041 tempax |= 0x1000;
5042
5043 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5044 tempax |= 0x0100;
5045
5046 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5047 tempax &= 0xfe00;
5048
5049 tempax = (tempax & 0xff00) >> 8;
5050
5051 XGINew_SetReg1(pVBInfo->Part2Port, 0x0, tempax);
5052 TimingPoint = pVBInfo->NTSCTiming;
5053
5054 if (pVBInfo->TVInfo & SetPALTV)
5055 TimingPoint = pVBInfo->PALTiming;
5056
5057 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5058 TimingPoint = pVBInfo->HiTVExtTiming;
5059
5060 if (pVBInfo->VBInfo & SetInSlaveMode)
5061 TimingPoint = pVBInfo->HiTVSt2Timing;
5062
5063 if (pVBInfo->SetFlag & TVSimuMode)
5064 TimingPoint = pVBInfo->HiTVSt1Timing;
5065
5066 if (!(modeflag & Charx8Dot))
5067 TimingPoint = pVBInfo->HiTVTextTiming;
5068 }
5069
5070 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5071 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5072 TimingPoint = pVBInfo->YPbPr525iTiming;
5073
5074 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5075 TimingPoint = pVBInfo->YPbPr525pTiming;
5076
5077 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5078 TimingPoint = pVBInfo->YPbPr750pTiming;
5079 }
5080
5081 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5082 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]);
5083
5084 for (i = 0x39; i <= 0x45; i++, j++)
5085 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
5086
5087 if (pVBInfo->VBInfo & SetCRT2ToTV)
5088 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5089
5090 temp = pVBInfo->NewFlickerMode;
5091 temp &= 0x80;
5092 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5093
5094 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5095 tempax = 950;
5096
5097 if (pVBInfo->TVInfo & SetPALTV)
5098 tempax = 520;
5099 else
5100 tempax = 440;
5101
5102 if (pVBInfo->VDE <= tempax) {
5103 tempax -= pVBInfo->VDE;
5104 tempax = tempax >> 2;
5105 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5106 push1 = tempax;
5107 temp = (tempax & 0xFF00) >> 8;
5108 temp += (unsigned short) TimingPoint[0];
5109
5110 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5111 | VB_XGI302LV | VB_XGI301C)) {
5112 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5113 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5114 | SetCRT2ToYPbPr)) {
5115 tempcx = pVBInfo->VGAHDE;
5116 if (tempcx >= 1024) {
5117 temp = 0x17; /* NTSC */
5118 if (pVBInfo->TVInfo & SetPALTV)
5119 temp = 0x19; /* PAL */
5120 }
5121 }
5122 }
5123
5124 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5125 tempax = push1;
5126 temp = (tempax & 0xFF00) >> 8;
5127 temp += TimingPoint[1];
5128
5129 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5130 | VB_XGI302LV | VB_XGI301C)) {
5131 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5132 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5133 | SetCRT2ToYPbPr))) {
5134 tempcx = pVBInfo->VGAHDE;
5135 if (tempcx >= 1024) {
5136 temp = 0x1D; /* NTSC */
5137 if (pVBInfo->TVInfo & SetPALTV)
5138 temp = 0x52; /* PAL */
5139 }
5140 }
5141 }
5142 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, temp);
5143 }
5144
5145 /* 301b */
5146 tempcx = pVBInfo->HT;
5147
5148 if (XGI_IsLCDDualLink(pVBInfo))
5149 tempcx = tempcx >> 1;
5150
5151 tempcx -= 2;
5152 temp = tempcx & 0x00FF;
5153 XGINew_SetReg1(pVBInfo->Part2Port, 0x1B, temp);
5154
5155 temp = (tempcx & 0xFF00) >> 8;
5156 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5157
5158 tempcx = pVBInfo->HT >> 1;
5159 push1 = tempcx; /* push cx */
5160 tempcx += 7;
5161
5162 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5163 tempcx -= 4;
5164
5165 temp = tempcx & 0x00FF;
5166 temp = temp << 4;
5167 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5168
5169 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5170 tempbx += tempcx;
5171 push2 = tempbx;
5172 temp = tempbx & 0x00FF;
5173 XGINew_SetReg1(pVBInfo->Part2Port, 0x24, temp);
5174 temp = (tempbx & 0xFF00) >> 8;
5175 temp = temp << 4;
5176 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5177
5178 tempbx = push2;
5179 tempbx = tempbx + 8;
5180 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5181 tempbx = tempbx - 4;
5182 tempcx = tempbx;
5183 }
5184
5185 temp = (tempbx & 0x00FF) << 4;
5186 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5187
5188 j += 2;
5189 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5190 temp = tempcx & 0x00FF;
5191 XGINew_SetReg1(pVBInfo->Part2Port, 0x27, temp);
5192 temp = ((tempcx & 0xFF00) >> 8) << 4;
5193 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5194
5195 tempcx += 8;
5196 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5197 tempcx -= 4;
5198
5199 temp = tempcx & 0xFF;
5200 temp = temp << 4;
5201 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5202
5203 tempcx = push1; /* pop cx */
5204 j += 2;
5205 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5206 tempcx -= temp;
5207 temp = tempcx & 0x00FF;
5208 temp = temp << 4;
5209 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5210
5211 tempcx -= 11;
5212
5213 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5214 tempax = XGI_GetVGAHT2(pVBInfo);
5215 tempcx = tempax - 1;
5216 }
5217 temp = tempcx & 0x00FF;
5218 XGINew_SetReg1(pVBInfo->Part2Port, 0x2E, temp);
5219
5220 tempbx = pVBInfo->VDE;
5221
5222 if (pVBInfo->VGAVDE == 360)
5223 tempbx = 746;
5224 if (pVBInfo->VGAVDE == 375)
5225 tempbx = 746;
5226 if (pVBInfo->VGAVDE == 405)
5227 tempbx = 853;
5228
5229 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5230 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5231 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5232 | SetYPbPrMode750p)))
5233 tempbx = tempbx >> 1;
5234 } else
5235 tempbx = tempbx >> 1;
5236 }
5237
5238 tempbx -= 2;
5239 temp = tempbx & 0x00FF;
5240
5241 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5242 if (pVBInfo->VBType & VB_XGI301LV) {
5243 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5244 if (pVBInfo->VBInfo & SetInSlaveMode) {
5245 if (ModeNo == 0x2f)
5246 temp += 1;
5247 }
5248 }
5249 } else {
5250 if (pVBInfo->VBInfo & SetInSlaveMode) {
5251 if (ModeNo == 0x2f)
5252 temp += 1;
5253 }
5254 }
5255 }
5256
5257 XGINew_SetReg1(pVBInfo->Part2Port, 0x2F, temp);
5258
5259 temp = (tempcx & 0xFF00) >> 8;
5260 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5261
5262 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5263 if (pVBInfo->VBType & VB_XGI301LV) {
5264 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5265 temp |= 0x10;
5266
5267 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5268 temp |= 0x20;
5269 }
5270 } else {
5271 temp |= 0x10;
5272 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5273 temp |= 0x20;
5274 }
5275 }
5276
5277 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, temp);
5278
5279 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5280 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5281 tempbx = pVBInfo->VDE;
5282 tempcx = tempbx - 2;
5283
5284 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5285 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5286 | SetYPbPrMode750p)))
5287 tempbx = tempbx >> 1;
5288 }
5289
5290 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5291 temp = 0;
5292 if (tempcx & 0x0400)
5293 temp |= 0x20;
5294
5295 if (tempbx & 0x0400)
5296 temp |= 0x40;
5297
5298 XGINew_SetReg1(pVBInfo->Part4Port, 0x10, temp);
5299 }
5300
5301 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5302 XGINew_SetReg1(pVBInfo->Part2Port, 0x46, temp);
5303 temp = (tempbx - 3) & 0x00FF;
5304 XGINew_SetReg1(pVBInfo->Part2Port, 0x47, temp);
5305 }
5306
5307 tempbx = tempbx & 0x00FF;
5308
5309 if (!(modeflag & HalfDCLK)) {
5310 tempcx = pVBInfo->VGAHDE;
5311 if (tempcx >= pVBInfo->HDE) {
5312 tempbx |= 0x2000;
5313 tempax &= 0x00FF;
5314 }
5315 }
5316
5317 tempcx = 0x0101;
5318
5319 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5320 if (pVBInfo->VGAHDE >= 1024) {
5321 tempcx = 0x1920;
5322 if (pVBInfo->VGAHDE >= 1280) {
5323 tempcx = 0x1420;
5324 tempbx = tempbx & 0xDFFF;
5325 }
5326 }
5327 }
5328
5329 if (!(tempbx & 0x2000)) {
5330 if (modeflag & HalfDCLK)
5331 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5332
5333 push1 = tempbx;
5334 tempeax = pVBInfo->VGAHDE;
5335 tempebx = (tempcx & 0xFF00) >> 8;
5336 longtemp = tempeax * tempebx;
5337 tempecx = tempcx & 0x00FF;
5338 longtemp = longtemp / tempecx;
5339
5340 /* 301b */
5341 tempecx = 8 * 1024;
5342
5343 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5344 | VB_XGI302LV | VB_XGI301C)) {
5345 tempecx = tempecx * 8;
5346 }
5347
5348 longtemp = longtemp * tempecx;
5349 tempecx = pVBInfo->HDE;
5350 temp2 = longtemp % tempecx;
5351 tempeax = longtemp / tempecx;
5352 if (temp2 != 0)
5353 tempeax += 1;
5354
5355 tempax = (unsigned short) tempeax;
5356
5357 /* 301b */
5358 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5359 | VB_XGI302LV | VB_XGI301C)) {
5360 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5361 }
5362 /* end 301b */
5363
5364 tempbx = push1;
5365 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5366 | (tempbx & 0x00FF));
5367 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5368 | (tempax & 0x00FF));
5369 temp = (tempax & 0xFF00) >> 8;
5370 } else {
5371 temp = (tempax & 0x00FF) >> 8;
5372 }
5373
5374 XGINew_SetReg1(pVBInfo->Part2Port, 0x44, temp);
5375 temp = (tempbx & 0xFF00) >> 8;
5376 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5377 temp = tempcx & 0x00FF;
5378
5379 if (tempbx & 0x2000)
5380 temp = 0;
5381
5382 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5383 temp |= 0x18;
5384
5385 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5386 if (pVBInfo->TVInfo & SetPALTV) {
5387 tempbx = 0x0382;
5388 tempcx = 0x007e;
5389 } else {
5390 tempbx = 0x0369;
5391 tempcx = 0x0061;
5392 }
5393
5394 temp = tempbx & 0x00FF;
5395 XGINew_SetReg1(pVBInfo->Part2Port, 0x4b, temp);
5396 temp = tempcx & 0x00FF;
5397 XGINew_SetReg1(pVBInfo->Part2Port, 0x4c, temp);
5398
5399 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5400 temp = temp << 2;
5401 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5402
5403 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5404 temp |= 0x10;
5405
5406 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5407 temp |= 0x20;
5408
5409 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5410 temp |= 0x60;
5411 }
5412
5413 XGINew_SetReg1(pVBInfo->Part2Port, 0x4d, temp);
5414 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x43); /* 301b change */
5415 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5416
5417 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5418 if (pVBInfo->TVInfo & NTSC1024x768) {
5419 TimingPoint = XGI_NTSC1024AdjTime;
5420 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5421 XGINew_SetReg1(pVBInfo->Part2Port, i,
5422 TimingPoint[j]);
5423 }
5424 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, 0x72);
5425 }
5426 }
5427
5428 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5429 if (pVBInfo->VBType & VB_XGI301C) {
5430 if (pVBInfo->TVInfo & SetPALMTV)
5431 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x08,
5432 0x08); /* PALM Mode */
5433 }
5434
5435 if (pVBInfo->TVInfo & SetPALMTV) {
5436 tempax = (unsigned char) XGINew_GetReg1(pVBInfo->Part2Port,
5437 0x01);
5438 tempax--;
5439 XGINew_SetRegAND(pVBInfo->Part2Port, 0x01, tempax);
5440
5441 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5442 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xEF);
5443 }
5444
5445 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5446 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5447 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, 0x00);
5448 }
5449
5450 if (pVBInfo->VBInfo & SetCRT2ToTV)
5451 return;
5452}
5453
5454void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5455 struct xgi_hw_device_info *HwDeviceExtension,
5456 unsigned short RefreshRateTableIndex,
5457 struct vb_device_info *pVBInfo)
5458{
5459 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5460 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5461
5462 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5463
5464 if (ModeNo <= 0x13) {
5465 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5466 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5467 } else {
5468 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5469 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5470 CRT1Index
5471 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5472 CRT1Index &= IndexMask;
5473 }
5474
5475 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5476 return;
5477
5478 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5479
5480 if (XGI_IsLCDDualLink(pVBInfo))
5481 tempbx = tempbx >> 1;
5482
5483 tempbx -= 1;
5484 temp = tempbx & 0x00FF;
5485 XGINew_SetReg1(pVBInfo->Part2Port, 0x2C, temp);
5486 temp = (tempbx & 0xFF00) >> 8;
5487 temp = temp << 4;
5488 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5489 temp = 0x01;
5490
5491 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5492 if (pVBInfo->ModeType == ModeEGA) {
5493 if (pVBInfo->VGAHDE >= 1024) {
5494 temp = 0x02;
5495 if (pVBInfo->LCDInfo & LCDVESATiming)
5496 temp = 0x01;
5497 }
5498 }
5499 }
5500
5501 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, temp);
5502 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5503 push1 = tempbx;
5504 tempbx--;
5505 temp = tempbx & 0x00FF;
5506 XGINew_SetReg1(pVBInfo->Part2Port, 0x03, temp);
5507 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5508 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5509
5510 tempcx = pVBInfo->VT - 1;
5511 push2 = tempcx + 1;
5512 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5513 XGINew_SetReg1(pVBInfo->Part2Port, 0x19, temp);
5514 temp = (tempcx & 0xFF00) >> 8;
5515 temp = temp << 5;
5516 XGINew_SetReg1(pVBInfo->Part2Port, 0x1A, temp);
5517 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5518 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5519 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5520 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5521
5522 /* Customized LCDB Des no add */
5523 tempbx = 5;
5524 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5525 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5526 tempah = pVBInfo->LCDResInfo;
5527 tempah &= PanelResInfo;
5528
5529 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5530 tempbx = 1024;
5531 tempcx = 768;
5532 } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
5533 tempbx = 1280;
5534 tempcx = 1024;
5535 } else if (tempah == Panel1400x1050) {
5536 tempbx = 1400;
5537 tempcx = 1050;
5538 } else {
5539 tempbx = 1600;
5540 tempcx = 1200;
5541 }
5542
5543 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5544 tempbx = pVBInfo->HDE;
5545 tempcx = pVBInfo->VDE;
5546 }
5547
5548 pushbx = tempbx;
5549 tempax = pVBInfo->VT;
5550 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5551 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5552 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5553 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5554 tempbx = pVBInfo->LCDVDES;
5555 tempcx += tempbx;
5556
5557 if (tempcx >= tempax)
5558 tempcx -= tempax; /* lcdvdes */
5559
5560 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5561 XGINew_SetReg1(pVBInfo->Part2Port, 0x05, temp);
5562 temp = tempcx & 0x00FF;
5563 XGINew_SetReg1(pVBInfo->Part2Port, 0x06, temp);
5564 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5565 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5566 tempah = tempch;
5567 tempah = tempah << 3;
5568 tempah |= tempbh;
5569 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, tempah);
5570
5571 /* getlcdsync() */
5572 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5573 tempcx = tempbx;
5574 tempax = pVBInfo->VT;
5575 tempbx = pVBInfo->LCDVRS;
5576
5577 /* if (SetLCD_Info & EnableScalingLCD) */
5578 tempcx += tempbx;
5579 if (tempcx >= tempax)
5580 tempcx -= tempax;
5581
5582 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5583 XGINew_SetReg1(pVBInfo->Part2Port, 0x04, temp);
5584 temp = (tempbx & 0xFF00) >> 8;
5585 temp = temp << 4;
5586 temp |= (tempcx & 0x000F);
5587 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5588 tempcx = pushbx;
5589 tempax = pVBInfo->HT;
5590 tempbx = pVBInfo->LCDHDES;
5591 tempbx &= 0x0FFF;
5592
5593 if (XGI_IsLCDDualLink(pVBInfo)) {
5594 tempax = tempax >> 1;
5595 tempbx = tempbx >> 1;
5596 tempcx = tempcx >> 1;
5597 }
5598
5599 if (pVBInfo->VBType & VB_XGI302LV)
5600 tempbx += 1;
5601
5602 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5603 tempbx += 1;
5604
5605 tempcx += tempbx;
5606
5607 if (tempcx >= tempax)
5608 tempcx -= tempax;
5609
5610 temp = tempbx & 0x00FF;
5611 XGINew_SetReg1(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5612 temp = ((tempbx & 0xFF00) >> 8) << 4;
5613 XGINew_SetReg1(pVBInfo->Part2Port, 0x20, temp);
5614 temp = tempcx & 0x00FF;
5615 XGINew_SetReg1(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5616 temp = (tempcx & 0xFF00) >> 8;
5617 XGINew_SetReg1(pVBInfo->Part2Port, 0x25, temp);
5618
5619 /* getlcdsync() */
5620 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5621 tempcx = tempax;
5622 tempax = pVBInfo->HT;
5623 tempbx = pVBInfo->LCDHRS;
5624 /* if ( SetLCD_Info & EnableScalingLCD) */
5625 if (XGI_IsLCDDualLink(pVBInfo)) {
5626 tempax = tempax >> 1;
5627 tempbx = tempbx >> 1;
5628 tempcx = tempcx >> 1;
5629 }
5630
5631 if (pVBInfo->VBType & VB_XGI302LV)
5632 tempbx += 1;
5633
5634 tempcx += tempbx;
5635
5636 if (tempcx >= tempax)
5637 tempcx -= tempax;
5638
5639 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5640 XGINew_SetReg1(pVBInfo->Part2Port, 0x1C, temp);
5641
5642 temp = (tempbx & 0xFF00) >> 8;
5643 temp = temp << 4;
5644 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5645 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5646 XGINew_SetReg1(pVBInfo->Part2Port, 0x21, temp);
5647
5648 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5649 if (pVBInfo->VGAVDE == 525) {
5650 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5651 | VB_XGI301LV | VB_XGI302LV
5652 | VB_XGI301C)) {
5653 temp = 0xC6;
5654 } else
5655 temp = 0xC4;
5656
5657 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5658 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, 0xB3);
5659 }
5660
5661 if (pVBInfo->VGAVDE == 420) {
5662 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5663 | VB_XGI301LV | VB_XGI302LV
5664 | VB_XGI301C)) {
5665 temp = 0x4F;
5666 } else
5667 temp = 0x4E;
5668 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5669 }
5670 }
5671}
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005672
5673/* --------------------------------------------------------------------- */
5674/* Function : XGI_GetTap4Ptr */
5675/* Input : */
5676/* Output : di -> Tap4 Reg. Setting Pointer */
5677/* Description : */
5678/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04005679struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305680 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005681{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305682 unsigned short tempax, tempbx, i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005683
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305684 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005685
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305686 if (tempcx == 0) {
5687 tempax = pVBInfo->VGAHDE;
5688 tempbx = pVBInfo->HDE;
5689 } else {
5690 tempax = pVBInfo->VGAVDE;
5691 tempbx = pVBInfo->VDE;
5692 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005693
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305694 if (tempax < tempbx)
5695 return &EnlargeTap4Timing[0];
5696 else if (tempax == tempbx)
5697 return &NoScaleTap4Timing[0]; /* 1:1 */
5698 else
5699 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005700
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305701 if (pVBInfo->TVInfo & SetPALTV)
5702 Tap4TimingPtr = PALTap4Timing;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005703
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305704 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5705 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5706 Tap4TimingPtr = YPbPr525iTap4Timing;
5707 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5708 Tap4TimingPtr = YPbPr525pTap4Timing;
5709 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5710 Tap4TimingPtr = YPbPr750pTap4Timing;
5711 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005712
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305713 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5714 Tap4TimingPtr = HiTVTap4Timing;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005715
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305716 i = 0;
5717 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5718 if (Tap4TimingPtr[i].DE == tempax)
5719 break;
5720 i++;
5721 }
5722 return &Tap4TimingPtr[i];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005723}
5724
Bill Pemberton80adad82010-06-17 13:10:51 -04005725void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005726{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305727 unsigned short i, j;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005728
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305729 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005730
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305731 if (!(pVBInfo->VBType & VB_XGI301C))
5732 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005733
5734#ifndef Tap4
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305735 XGINew_SetRegAND(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005736#else /* Tap4 Setting */
5737
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305738 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5739 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5740 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005741
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305742 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5743 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
5744 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5745 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5746 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005747
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305748 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5749 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
5750 else
5751 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005752#endif
5753}
5754
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305755void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5756 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005757{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305758 unsigned short i;
5759 unsigned char *tempdi;
5760 unsigned short modeflag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005761
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305762 if (ModeNo <= 0x13)
5763 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5764 else
5765 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005766
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305767 XGINew_SetReg1(pVBInfo->Part3Port, 0x00, 0x00);
5768 if (pVBInfo->TVInfo & SetPALTV) {
5769 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5770 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5771 } else {
5772 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xF5);
5773 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xB7);
5774 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005775
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305776 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5777 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005778
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305779 if (pVBInfo->TVInfo & SetPALMTV) {
5780 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5781 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5782 XGINew_SetReg1(pVBInfo->Part3Port, 0x3D, 0xA8);
5783 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005784
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305785 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
5786 & SetCRT2ToYPbPr)) {
5787 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5788 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005789
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305790 tempdi = pVBInfo->HiTVGroup3Data;
5791 if (pVBInfo->SetFlag & TVSimuMode) {
5792 tempdi = pVBInfo->HiTVGroup3Simu;
5793 if (!(modeflag & Charx8Dot))
5794 tempdi = pVBInfo->HiTVGroup3Text;
5795 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005796
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305797 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5798 tempdi = pVBInfo->Ren525pGroup3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005799
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305800 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5801 tempdi = pVBInfo->Ren750pGroup3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005802
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305803 for (i = 0; i <= 0x3E; i++)
5804 XGINew_SetReg1(pVBInfo->Part3Port, i, tempdi[i]);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005805
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305806 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
5807 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5808 XGINew_SetReg1(pVBInfo->Part3Port, 0x28, 0x3f);
5809 }
5810 }
5811 return;
5812} /* {end of XGI_SetGroup3} */
5813
5814void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
5815 unsigned short RefreshRateTableIndex,
5816 struct xgi_hw_device_info *HwDeviceExtension,
5817 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005818{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305819 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005820
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305821 unsigned long tempebx, tempeax, templong;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005822
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305823 if (ModeNo <= 0x13)
5824 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5825 else
5826 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005827
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305828 temp = pVBInfo->RVBHCFACT;
5829 XGINew_SetReg1(pVBInfo->Part4Port, 0x13, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005830
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305831 tempbx = pVBInfo->RVBHCMAX;
5832 temp = tempbx & 0x00FF;
5833 XGINew_SetReg1(pVBInfo->Part4Port, 0x14, temp);
5834 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
5835 tempcx = pVBInfo->VGAHT - 1;
5836 temp = tempcx & 0x00FF;
5837 XGINew_SetReg1(pVBInfo->Part4Port, 0x16, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005838
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305839 temp = ((tempcx & 0xFF00) >> 8) << 3;
5840 temp2 |= temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005841
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305842 tempcx = pVBInfo->VGAVT - 1;
5843 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5844 tempcx -= 5;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005845
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305846 temp = tempcx & 0x00FF;
5847 XGINew_SetReg1(pVBInfo->Part4Port, 0x17, temp);
5848 temp = temp2 | ((tempcx & 0xFF00) >> 8);
5849 XGINew_SetReg1(pVBInfo->Part4Port, 0x15, temp);
5850 XGINew_SetRegOR(pVBInfo->Part4Port, 0x0D, 0x08);
5851 tempcx = pVBInfo->VBInfo;
5852 tempbx = pVBInfo->VGAHDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005853
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305854 if (modeflag & HalfDCLK)
5855 tempbx = tempbx >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005856
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305857 if (XGI_IsLCDDualLink(pVBInfo))
5858 tempbx = tempbx >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005859
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305860 if (tempcx & SetCRT2ToHiVisionTV) {
5861 temp = 0;
5862 if (tempbx <= 1024)
5863 temp = 0xA0;
5864 if (tempbx == 1280)
5865 temp = 0xC0;
5866 } else if (tempcx & SetCRT2ToTV) {
5867 temp = 0xA0;
5868 if (tempbx <= 800)
5869 temp = 0x80;
5870 } else {
5871 temp = 0x80;
5872 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5873 temp = 0;
5874 if (tempbx > 800)
5875 temp = 0x60;
5876 }
5877 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005878
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305879 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
5880 temp = 0x00;
5881 if (pVBInfo->VGAHDE == 1280)
5882 temp = 0x40;
5883 if (pVBInfo->VGAHDE == 1024)
5884 temp = 0x20;
5885 }
5886 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005887
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305888 tempebx = pVBInfo->VDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005889
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305890 if (tempcx & SetCRT2ToHiVisionTV) {
5891 if (!(temp & 0xE000))
5892 tempbx = tempbx >> 1;
5893 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005894
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305895 tempcx = pVBInfo->RVBHRS;
5896 temp = tempcx & 0x00FF;
5897 XGINew_SetReg1(pVBInfo->Part4Port, 0x18, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005898
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305899 tempeax = pVBInfo->VGAVDE;
5900 tempcx |= 0x04000;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005901
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305902 if (tempeax <= tempebx) {
5903 tempcx = (tempcx & (~0x4000));
5904 tempeax = pVBInfo->VGAVDE;
5905 } else {
5906 tempeax -= tempebx;
5907 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005908
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305909 templong = (tempeax * 256 * 1024) % tempebx;
5910 tempeax = (tempeax * 256 * 1024) / tempebx;
5911 tempebx = tempeax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005912
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305913 if (templong != 0)
5914 tempebx++;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005915
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305916 temp = (unsigned short) (tempebx & 0x000000FF);
5917 XGINew_SetReg1(pVBInfo->Part4Port, 0x1B, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005918
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305919 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
5920 XGINew_SetReg1(pVBInfo->Part4Port, 0x1A, temp);
5921 tempbx = (unsigned short) (tempebx >> 16);
5922 temp = tempbx & 0x00FF;
5923 temp = temp << 4;
5924 temp |= ((tempcx & 0xFF00) >> 8);
5925 XGINew_SetReg1(pVBInfo->Part4Port, 0x19, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005926
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305927 /* 301b */
5928 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5929 | VB_XGI302LV | VB_XGI301C)) {
5930 temp = 0x0028;
5931 XGINew_SetReg1(pVBInfo->Part4Port, 0x1C, temp);
5932 tempax = pVBInfo->VGAHDE;
5933 if (modeflag & HalfDCLK)
5934 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005935
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305936 if (XGI_IsLCDDualLink(pVBInfo))
5937 tempax = tempax >> 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005938
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305939 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
5940 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5941 if (tempax > 800)
5942 tempax -= 800;
5943 } else {
5944 if (pVBInfo->VGAHDE > 800) {
5945 if (pVBInfo->VGAHDE == 1024)
5946 tempax = (tempax * 25 / 32) - 1;
5947 else
5948 tempax = (tempax * 20 / 32) - 1;
5949 }
5950 }
5951 tempax -= 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005952
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305953 /*
5954 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5955 if (pVBInfo->VBType & VB_XGI301LV) {
5956 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
5957 if (pVBInfo->VGAHDE > 800) {
5958 if (pVBInfo->VGAHDE == 1024)
5959 tempax = (tempax * 25 / 32) - 1;
5960 else
5961 tempax = (tempax * 20 / 32) - 1;
5962 }
5963 }
5964 } else {
5965 if (pVBInfo->VGAHDE > 800) {
5966 if (pVBInfo->VGAHDE == 1024)
5967 tempax = (tempax * 25 / 32) - 1;
5968 else
5969 tempax = (tempax * 20 / 32) - 1;
5970 }
5971 }
5972 }
5973 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005974
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305975 temp = (tempax & 0xFF00) >> 8;
5976 temp = ((temp & 0x0003) << 4);
5977 XGINew_SetReg1(pVBInfo->Part4Port, 0x1E, temp);
5978 temp = (tempax & 0x00FF);
5979 XGINew_SetReg1(pVBInfo->Part4Port, 0x1D, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005980
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305981 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5982 if (pVBInfo->VGAHDE > 800)
5983 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1E, 0x08);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005984
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305985 }
5986 temp = 0x0036;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005987
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05305988 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5989 if (!(pVBInfo->TVInfo & (NTSC1024x768
5990 | SetYPbPrMode525p | SetYPbPrMode750p
5991 | SetYPbPrMode1080i))) {
5992 temp |= 0x0001;
5993 if ((pVBInfo->VBInfo & SetInSlaveMode)
5994 && (!(pVBInfo->TVInfo
5995 & TVSimuMode)))
5996 temp &= (~0x0001);
5997 }
5998 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02005999
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306000 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6001 tempbx = pVBInfo->HT;
6002 if (XGI_IsLCDDualLink(pVBInfo))
6003 tempbx = tempbx >> 1;
6004 tempbx = (tempbx >> 1) - 2;
6005 temp = ((tempbx & 0x0700) >> 8) << 3;
6006 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6007 temp = tempbx & 0x00FF;
6008 XGINew_SetReg1(pVBInfo->Part4Port, 0x22, temp);
6009 }
6010 /* end 301b */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006011
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306012 if (pVBInfo->ISXPDOS == 0)
6013 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6014 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006015}
6016
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306017void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6018 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006019{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306020 unsigned short Pindex, Pdata;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006021
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306022 Pindex = pVBInfo->Part5Port;
6023 Pdata = pVBInfo->Part5Port + 1;
6024 if (pVBInfo->ModeType == ModeVGA) {
6025 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6026 | CRT2DisplayFlag))) {
6027 XGINew_EnableCRT2(pVBInfo);
6028 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6029 }
6030 }
6031 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006032}
6033
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306034void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
6035 unsigned short ModeIdIndex,
6036 unsigned short RefreshRateTableIndex,
6037 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006038{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306039 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006040
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306041 struct XGI330_LCDDataTablStruct *tempdi = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006042
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306043 tempbx = BX;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006044
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306045 if (ModeNo <= 0x13) {
6046 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6047 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6048 } else {
6049 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6050 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6051 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006052
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306053 tempal = tempal & 0x0f;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006054
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306055 if (tempbx <= 1) { /* ExpLink */
6056 if (ModeNo <= 0x13) {
6057 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
6058 } else {
6059 tempal
6060 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6061 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006062
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306063 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6064 if (ModeNo <= 0x13)
6065 tempal
6066 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
6067 else
6068 tempal
6069 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
6070 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006071
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306072 if (tempbx & 0x01)
6073 tempal = (tempal >> 4);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006074
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306075 tempal = (tempal & 0x0f);
6076 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006077
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306078 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006079
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306080 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
6081 if ((tempbx == 5) || (tempbx) == 7)
6082 tempcx = LCDDesDataLen2;
6083 else if ((tempbx == 3) || (tempbx == 8))
6084 tempcx = LVDSDesDataLen2;
6085 }
6086 /* mov di, word ptr cs:LCDDataList[bx] */
6087 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006088
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306089 switch (tempbx) {
6090 case 0:
6091 tempdi = XGI_EPLLCDCRT1Ptr_H;
6092 break;
6093 case 1:
6094 tempdi = XGI_EPLLCDCRT1Ptr_V;
6095 break;
6096 case 2:
6097 tempdi = XGI_EPLLCDDataPtr;
6098 break;
6099 case 3:
6100 tempdi = XGI_EPLLCDDesDataPtr;
6101 break;
6102 case 4:
6103 tempdi = XGI_LCDDataTable;
6104 break;
6105 case 5:
6106 tempdi = XGI_LCDDesDataTable;
6107 break;
6108 case 6:
6109 tempdi = XGI_EPLCHLCDRegPtr;
6110 break;
6111 case 7:
6112 case 8:
6113 case 9:
6114 tempdi = NULL;
6115 break;
6116 default:
6117 break;
6118 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006119
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306120 if (tempdi == NULL) /* OEMUtil */
6121 return NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006122
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306123 table = tempbx;
6124 i = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006125
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306126 while (tempdi[i].PANELID != 0xff) {
6127 tempdx = pVBInfo->LCDResInfo;
6128 if (tempbx & 0x0080) { /* OEMUtil */
6129 tempbx &= (~0x0080);
6130 tempdx = pVBInfo->LCDTypeInfo;
6131 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006132
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306133 if (pVBInfo->LCDInfo & EnableScalingLCD)
6134 tempdx &= (~PanelResInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006135
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306136 if (tempdi[i].PANELID == tempdx) {
6137 tempbx = tempdi[i].MASK;
6138 tempdx = pVBInfo->LCDInfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006139
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306140 if (ModeNo <= 0x13) /* alan 09/10/2003 */
6141 tempdx |= SetLCDStdMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006142
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306143 if (modeflag & HalfDCLK)
6144 tempdx |= SetLCDLowResolution;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006145
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306146 tempbx &= tempdx;
6147 if (tempbx == tempdi[i].CAP)
6148 break;
6149 }
6150 i++;
6151 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006152
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306153 if (table == 0) {
6154 switch (tempdi[i].DATAPTR) {
6155 case 0:
6156 return &XGI_LVDSCRT11024x768_1_H[tempal];
6157 break;
6158 case 1:
6159 return &XGI_LVDSCRT11024x768_2_H[tempal];
6160 break;
6161 case 2:
6162 return &XGI_LVDSCRT11280x1024_1_H[tempal];
6163 break;
6164 case 3:
6165 return &XGI_LVDSCRT11280x1024_2_H[tempal];
6166 break;
6167 case 4:
6168 return &XGI_LVDSCRT11400x1050_1_H[tempal];
6169 break;
6170 case 5:
6171 return &XGI_LVDSCRT11400x1050_2_H[tempal];
6172 break;
6173 case 6:
6174 return &XGI_LVDSCRT11600x1200_1_H[tempal];
6175 break;
6176 case 7:
6177 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
6178 break;
6179 case 8:
6180 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
6181 break;
6182 case 9:
6183 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
6184 break;
6185 case 10:
6186 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
6187 break;
6188 default:
6189 break;
6190 }
6191 } else if (table == 1) {
6192 switch (tempdi[i].DATAPTR) {
6193 case 0:
6194 return &XGI_LVDSCRT11024x768_1_V[tempal];
6195 break;
6196 case 1:
6197 return &XGI_LVDSCRT11024x768_2_V[tempal];
6198 break;
6199 case 2:
6200 return &XGI_LVDSCRT11280x1024_1_V[tempal];
6201 break;
6202 case 3:
6203 return &XGI_LVDSCRT11280x1024_2_V[tempal];
6204 break;
6205 case 4:
6206 return &XGI_LVDSCRT11400x1050_1_V[tempal];
6207 break;
6208 case 5:
6209 return &XGI_LVDSCRT11400x1050_2_V[tempal];
6210 break;
6211 case 6:
6212 return &XGI_LVDSCRT11600x1200_1_V[tempal];
6213 break;
6214 case 7:
6215 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
6216 break;
6217 case 8:
6218 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
6219 break;
6220 case 9:
6221 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
6222 break;
6223 case 10:
6224 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
6225 break;
6226 default:
6227 break;
6228 }
6229 } else if (table == 2) {
6230 switch (tempdi[i].DATAPTR) {
6231 case 0:
6232 return &XGI_LVDS1024x768Data_1[tempal];
6233 break;
6234 case 1:
6235 return &XGI_LVDS1024x768Data_2[tempal];
6236 break;
6237 case 2:
6238 return &XGI_LVDS1280x1024Data_1[tempal];
6239 break;
6240 case 3:
6241 return &XGI_LVDS1280x1024Data_2[tempal];
6242 break;
6243 case 4:
6244 return &XGI_LVDS1400x1050Data_1[tempal];
6245 break;
6246 case 5:
6247 return &XGI_LVDS1400x1050Data_2[tempal];
6248 break;
6249 case 6:
6250 return &XGI_LVDS1600x1200Data_1[tempal];
6251 break;
6252 case 7:
6253 return &XGI_LVDSNoScalingData[tempal];
6254 break;
6255 case 8:
6256 return &XGI_LVDS1024x768Data_1x75[tempal];
6257 break;
6258 case 9:
6259 return &XGI_LVDS1024x768Data_2x75[tempal];
6260 break;
6261 case 10:
6262 return &XGI_LVDS1280x1024Data_1x75[tempal];
6263 break;
6264 case 11:
6265 return &XGI_LVDS1280x1024Data_2x75[tempal];
6266 break;
6267 case 12:
6268 return &XGI_LVDSNoScalingDatax75[tempal];
6269 break;
6270 default:
6271 break;
6272 }
6273 } else if (table == 3) {
6274 switch (tempdi[i].DATAPTR) {
6275 case 0:
6276 return &XGI_LVDS1024x768Des_1[tempal];
6277 break;
6278 case 1:
6279 return &XGI_LVDS1024x768Des_3[tempal];
6280 break;
6281 case 2:
6282 return &XGI_LVDS1024x768Des_2[tempal];
6283 break;
6284 case 3:
6285 return &XGI_LVDS1280x1024Des_1[tempal];
6286 break;
6287 case 4:
6288 return &XGI_LVDS1280x1024Des_2[tempal];
6289 break;
6290 case 5:
6291 return &XGI_LVDS1400x1050Des_1[tempal];
6292 break;
6293 case 6:
6294 return &XGI_LVDS1400x1050Des_2[tempal];
6295 break;
6296 case 7:
6297 return &XGI_LVDS1600x1200Des_1[tempal];
6298 break;
6299 case 8:
6300 return &XGI_LVDSNoScalingDesData[tempal];
6301 break;
6302 case 9:
6303 return &XGI_LVDS1024x768Des_1x75[tempal];
6304 break;
6305 case 10:
6306 return &XGI_LVDS1024x768Des_3x75[tempal];
6307 break;
6308 case 11:
6309 return &XGI_LVDS1024x768Des_2x75[tempal];
6310 break;
6311 case 12:
6312 return &XGI_LVDS1280x1024Des_1x75[tempal];
6313 break;
6314 case 13:
6315 return &XGI_LVDS1280x1024Des_2x75[tempal];
6316 break;
6317 case 14:
6318 return &XGI_LVDSNoScalingDesDatax75[tempal];
6319 break;
6320 default:
6321 break;
6322 }
6323 } else if (table == 4) {
6324 switch (tempdi[i].DATAPTR) {
6325 case 0:
6326 return &XGI_ExtLCD1024x768Data[tempal];
6327 break;
6328 case 1:
6329 return &XGI_StLCD1024x768Data[tempal];
6330 break;
6331 case 2:
6332 return &XGI_CetLCD1024x768Data[tempal];
6333 break;
6334 case 3:
6335 return &XGI_ExtLCD1280x1024Data[tempal];
6336 break;
6337 case 4:
6338 return &XGI_StLCD1280x1024Data[tempal];
6339 break;
6340 case 5:
6341 return &XGI_CetLCD1280x1024Data[tempal];
6342 break;
6343 case 6:
6344 return &XGI_ExtLCD1400x1050Data[tempal];
6345 break;
6346 case 7:
6347 return &XGI_StLCD1400x1050Data[tempal];
6348 break;
6349 case 8:
6350 return &XGI_CetLCD1400x1050Data[tempal];
6351 break;
6352 case 9:
6353 return &XGI_ExtLCD1600x1200Data[tempal];
6354 break;
6355 case 10:
6356 return &XGI_StLCD1600x1200Data[tempal];
6357 break;
6358 case 11:
6359 return &XGI_NoScalingData[tempal];
6360 break;
6361 case 12:
6362 return &XGI_ExtLCD1024x768x75Data[tempal];
6363 break;
6364 case 13:
6365 return &XGI_ExtLCD1024x768x75Data[tempal];
6366 break;
6367 case 14:
6368 return &XGI_CetLCD1024x768x75Data[tempal];
6369 break;
6370 case 15:
6371 return &XGI_ExtLCD1280x1024x75Data[tempal];
6372 break;
6373 case 16:
6374 return &XGI_StLCD1280x1024x75Data[tempal];
6375 break;
6376 case 17:
6377 return &XGI_CetLCD1280x1024x75Data[tempal];
6378 break;
6379 case 18:
6380 return &XGI_NoScalingDatax75[tempal];
6381 break;
6382 default:
6383 break;
6384 }
6385 } else if (table == 5) {
6386 switch (tempdi[i].DATAPTR) {
6387 case 0:
6388 return &XGI_ExtLCDDes1024x768Data[tempal];
6389 break;
6390 case 1:
6391 return &XGI_StLCDDes1024x768Data[tempal];
6392 break;
6393 case 2:
6394 return &XGI_CetLCDDes1024x768Data[tempal];
6395 break;
6396 case 3:
6397 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6398 & VB_XGI302LV))
6399 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
6400 else
6401 return &XGI_ExtLCDDes1280x1024Data[tempal];
6402 break;
6403 case 4:
6404 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6405 & VB_XGI302LV))
6406 return &XGI_StLCDDLDes1280x1024Data[tempal];
6407 else
6408 return &XGI_StLCDDes1280x1024Data[tempal];
6409 break;
6410 case 5:
6411 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6412 & VB_XGI302LV))
6413 return &XGI_CetLCDDLDes1280x1024Data[tempal];
6414 else
6415 return &XGI_CetLCDDes1280x1024Data[tempal];
6416 break;
6417 case 6:
6418 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6419 & VB_XGI302LV))
6420 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
6421 else
6422 return &XGI_ExtLCDDes1400x1050Data[tempal];
6423 break;
6424 case 7:
6425 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6426 & VB_XGI302LV))
6427 return &XGI_StLCDDLDes1400x1050Data[tempal];
6428 else
6429 return &XGI_StLCDDes1400x1050Data[tempal];
6430 break;
6431 case 8:
6432 return &XGI_CetLCDDes1400x1050Data[tempal];
6433 break;
6434 case 9:
6435 return &XGI_CetLCDDes1400x1050Data2[tempal];
6436 break;
6437 case 10:
6438 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6439 & VB_XGI302LV))
6440 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
6441 else
6442 return &XGI_ExtLCDDes1600x1200Data[tempal];
6443 break;
6444 case 11:
6445 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6446 & VB_XGI302LV))
6447 return &XGI_StLCDDLDes1600x1200Data[tempal];
6448 else
6449 return &XGI_StLCDDes1600x1200Data[tempal];
6450 break;
6451 case 12:
6452 return &XGI_NoScalingDesData[tempal];
6453 break;
6454 case 13:
6455 return &XGI_ExtLCDDes1024x768x75Data[tempal];
6456 break;
6457 case 14:
6458 return &XGI_StLCDDes1024x768x75Data[tempal];
6459 break;
6460 case 15:
6461 return &XGI_CetLCDDes1024x768x75Data[tempal];
6462 break;
6463 case 16:
6464 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6465 & VB_XGI302LV))
6466 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
6467 else
6468 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
6469 break;
6470 case 17:
6471 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6472 & VB_XGI302LV))
6473 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
6474 else
6475 return &XGI_StLCDDes1280x1024x75Data[tempal];
6476 break;
6477 case 18:
6478 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
6479 & VB_XGI302LV))
6480 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
6481 else
6482 return &XGI_CetLCDDes1280x1024x75Data[tempal];
6483 break;
6484 case 19:
6485 return &XGI_NoScalingDesDatax75[tempal];
6486 break;
6487 default:
6488 break;
6489 }
6490 } else if (table == 6) {
6491 switch (tempdi[i].DATAPTR) {
6492 case 0:
6493 return &XGI_CH7017LV1024x768[tempal];
6494 break;
6495 case 1:
6496 return &XGI_CH7017LV1400x1050[tempal];
6497 break;
6498 default:
6499 break;
6500 }
6501 }
6502 return NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006503}
6504
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006505void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306506 unsigned short ModeIdIndex,
6507 unsigned short RefreshRateTableIndex,
6508 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006509{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306510 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
6511 struct XGI330_TVDataTablStruct *tempdi = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006512
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306513 tempbx = BX;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006514
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306515 if (ModeNo <= 0x13) {
6516 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6517 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6518 } else {
6519 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6520 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6521 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006522
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306523 tempal = tempal & 0x3f;
6524 table = tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006525
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306526 switch (tempbx) {
6527 case 0:
6528 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
6529 if (pVBInfo->IF_DEF_CH7007 == 1)
6530 tempdi = XGI_EPLCHTVCRT1Ptr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006531
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306532 break;
6533 case 1:
6534 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
6535 if (pVBInfo->IF_DEF_CH7007 == 1)
6536 tempdi = XGI_EPLCHTVCRT1Ptr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006537
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306538 break;
6539 case 2:
6540 tempdi = XGI_EPLCHTVDataPtr;
6541 break;
6542 case 3:
6543 tempdi = NULL;
6544 break;
6545 case 4:
6546 tempdi = XGI_TVDataTable;
6547 break;
6548 case 5:
6549 tempdi = NULL;
6550 break;
6551 case 6:
6552 tempdi = XGI_EPLCHTVRegPtr;
6553 break;
6554 default:
6555 break;
6556 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006557
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306558 if (tempdi == NULL) /* OEMUtil */
6559 return NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006560
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306561 tempdx = pVBInfo->TVInfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006562
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306563 if (pVBInfo->VBInfo & SetInSlaveMode)
6564 tempdx = tempdx | SetTVLockMode;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006565
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306566 if (modeflag & HalfDCLK)
6567 tempdx = tempdx | SetTVLowResolution;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006568
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306569 i = 0;
6570
6571 while (tempdi[i].MASK != 0xffff) {
6572 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
6573 break;
6574 i++;
6575 }
6576
6577 if (table == 0x00) { /* 07/05/22 */
6578 } else if (table == 0x01) {
6579 } else if (table == 0x04) {
6580 switch (tempdi[i].DATAPTR) {
6581 case 0:
6582 return &XGI_ExtPALData[tempal];
6583 break;
6584 case 1:
6585 return &XGI_ExtNTSCData[tempal];
6586 break;
6587 case 2:
6588 return &XGI_StPALData[tempal];
6589 break;
6590 case 3:
6591 return &XGI_StNTSCData[tempal];
6592 break;
6593 case 4:
6594 return &XGI_ExtHiTVData[tempal];
6595 break;
6596 case 5:
6597 return &XGI_St2HiTVData[tempal];
6598 break;
6599 case 6:
6600 return &XGI_ExtYPbPr525iData[tempal];
6601 break;
6602 case 7:
6603 return &XGI_ExtYPbPr525pData[tempal];
6604 break;
6605 case 8:
6606 return &XGI_ExtYPbPr750pData[tempal];
6607 break;
6608 case 9:
6609 return &XGI_StYPbPr525iData[tempal];
6610 break;
6611 case 10:
6612 return &XGI_StYPbPr525pData[tempal];
6613 break;
6614 case 11:
6615 return &XGI_StYPbPr750pData[tempal];
6616 break;
6617 case 12: /* avoid system hang */
6618 return &XGI_ExtNTSCData[tempal];
6619 break;
6620 case 13:
6621 return &XGI_St1HiTVData[tempal];
6622 break;
6623 default:
6624 break;
6625 }
6626 } else if (table == 0x02) {
6627 switch (tempdi[i].DATAPTR) {
6628 case 0:
6629 return &XGI_CHTVUNTSCData[tempal];
6630 break;
6631 case 1:
6632 return &XGI_CHTVONTSCData[tempal];
6633 break;
6634 case 2:
6635 return &XGI_CHTVUPALData[tempal];
6636 break;
6637 case 3:
6638 return &XGI_CHTVOPALData[tempal];
6639 break;
6640 default:
6641 break;
6642 }
6643 } else if (table == 0x06) {
6644 }
6645 return NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006646}
6647
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006648/* --------------------------------------------------------------------- */
6649/* Function : XGI_BacklightByDrv */
6650/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04006651/* Output : 1 -> Skip backlight control */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006652/* Description : */
6653/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04006654unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006655{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306656 unsigned char tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006657
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306658 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x3A);
6659 if (tempah & BacklightControlBit)
6660 return 1;
6661 else
6662 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006663}
6664
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006665/* --------------------------------------------------------------------- */
6666/* Function : XGI_FirePWDDisable */
6667/* Input : */
6668/* Output : */
6669/* Description : Turn off VDD & Backlight : Fire disable procedure */
6670/* --------------------------------------------------------------------- */
6671/*
Bill Pemberton80adad82010-06-17 13:10:51 -04006672void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006673{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306674 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x00, 0xFC);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006675}
6676*/
6677
6678/* --------------------------------------------------------------------- */
6679/* Function : XGI_FirePWDEnable */
6680/* Input : */
6681/* Output : */
6682/* Description : Turn on VDD & Backlight : Fire enable procedure */
6683/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04006684void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006685{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306686 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x03, 0xFC);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006687}
6688
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306689void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6690 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006691{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306692 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006693}
6694
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306695void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6696 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006697{
6698
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306699 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006700}
6701
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006702/* --------------------------------------------------------------------- */
6703/* Function : XGI_SetPanelDelay */
6704/* Input : */
6705/* Output : */
6706/* Description : */
6707/* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6708/* : bl : 2 ; T2 : the duration signal on and Vdd on */
6709/* : bl : 3 ; T3 : the duration between CPL off and signal off */
6710/* : bl : 4 ; T4 : the duration signal off and Vdd off */
6711/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04006712void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006713{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306714 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006715
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306716 index = XGI_GetLCDCapPtr(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006717
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306718 if (tempbl == 1)
6719 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S1, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006720
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306721 if (tempbl == 2)
6722 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S2, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006723
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306724 if (tempbl == 3)
6725 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S3, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006726
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306727 if (tempbl == 4)
6728 XGINew_LCD_Wait_Time(pVBInfo->LCDCapList[index].PSC_S4, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006729}
6730
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006731/* --------------------------------------------------------------------- */
6732/* Function : XGI_SetPanelPower */
6733/* Input : */
6734/* Output : */
6735/* Description : */
6736/* I/O : ah = 0011b = 03h ; Backlight on, Power on */
6737/* = 0111b = 07h ; Backlight on, Power off */
6738/* = 1011b = 0Bh ; Backlight off, Power on */
6739/* = 1111b = 0Fh ; Backlight off, Power off */
6740/* --------------------------------------------------------------------- */
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306741void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl,
6742 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006743{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306744 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
6745 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x26, tempbl, tempah);
6746 else
6747 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x11, tempbl, tempah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006748}
6749
Randy Dunlap89229672010-08-10 08:46:44 -07006750static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006751{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306752 unsigned char ujRet = 0;
6753 unsigned char i = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006754
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306755 for (i = 0; i < 8; i++) {
6756 ujRet = ujRet << 1;
6757 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
6758 ujRet |= (ujDate >> i) & 1;
6759 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006760
6761 return ujRet;
6762}
6763
6764/*----------------------------------------------------------------------------*/
6765/* output */
6766/* bl[5] : LVDS signal */
6767/* bl[1] : LVDS backlight */
6768/* bl[0] : LVDS VDD */
6769/*----------------------------------------------------------------------------*/
Bill Pemberton80adad82010-06-17 13:10:51 -04006770unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006771{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306772 unsigned char CR4A, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006773
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306774 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6775 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006776
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306777 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006778
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306779 temp = XG21GPIODataTransfer(temp);
6780 temp &= 0x23;
6781 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6782 return temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006783}
6784
6785/*----------------------------------------------------------------------------*/
6786/* output */
6787/* bl[5] : LVDS signal */
6788/* bl[1] : LVDS backlight */
6789/* bl[0] : LVDS VDD */
6790/*----------------------------------------------------------------------------*/
Bill Pemberton80adad82010-06-17 13:10:51 -04006791unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006792{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306793 unsigned char CR4A, CRB4, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006794
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306795 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6796 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006797
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306798 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006799
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306800 temp &= 0x0C;
6801 temp >>= 2;
6802 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
6803 CRB4 = XGINew_GetReg1(pVBInfo->P3d4, 0xB4);
6804 temp |= ((CRB4 & 0x04) << 3);
6805 return temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006806}
6807/*----------------------------------------------------------------------------*/
6808/* input */
6809/* bl[5] : 1;LVDS signal on */
6810/* bl[1] : 1;LVDS backlight on */
6811/* bl[0] : 1:LVDS VDD on */
6812/* bh: 100000b : clear bit 5, to set bit5 */
6813/* 000010b : clear bit 1, to set bit1 */
6814/* 000001b : clear bit 0, to set bit0 */
6815/*----------------------------------------------------------------------------*/
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306816void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6817 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006818{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306819 unsigned char CR4A, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006820
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306821 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6822 tempbh &= 0x23;
6823 tempbl &= 0x23;
6824 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006825
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306826 if (tempbh & 0x20) {
6827 temp = (tempbl >> 4) & 0x02;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006828
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306829 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006830
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306831 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006832
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306833 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006834
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306835 temp = XG21GPIODataTransfer(temp);
6836 temp &= ~tempbh;
6837 temp |= tempbl;
6838 XGINew_SetReg1(pVBInfo->P3d4, 0x48, temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006839}
6840
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306841void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6842 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006843{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306844 unsigned char CR4A, temp;
6845 unsigned short tempbh0, tempbl0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006846
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306847 tempbh0 = tempbh;
6848 tempbl0 = tempbl;
6849 tempbh0 &= 0x20;
6850 tempbl0 &= 0x20;
6851 tempbh0 >>= 3;
6852 tempbl0 >>= 3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006853
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306854 if (tempbh & 0x20) {
6855 temp = (tempbl >> 4) & 0x02;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006856
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306857 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006858
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306859 }
6860 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006861
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306862 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6863 tempbh &= 0x03;
6864 tempbl &= 0x03;
6865 tempbh <<= 2;
6866 tempbl <<= 2; /* GPIOC,GPIOD */
6867 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6868 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006869}
6870
6871/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04006872unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006873{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306874 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006875
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306876 index = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
6877 if (index < sizeof(XGI21_LCDCapList)
6878 / sizeof(struct XGI21_LVDSCapStruct))
6879 return index;
6880 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006881}
6882
6883/* --------------------------------------------------------------------- */
6884/* Function : XGI_XG21SetPanelDelay */
6885/* Input : */
6886/* Output : */
6887/* Description : */
6888/* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6889/* : bl : 2 ; T2 : the duration signal on and Vdd on */
6890/* : bl : 3 ; T3 : the duration between CPL off and signal off */
6891/* : bl : 4 ; T4 : the duration signal off and Vdd off */
6892/* --------------------------------------------------------------------- */
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306893void XGI_XG21SetPanelDelay(unsigned short tempbl,
6894 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006895{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306896 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006897
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306898 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6899 if (tempbl == 1)
6900 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S1,
6901 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006902
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306903 if (tempbl == 2)
6904 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S2,
6905 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006906
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306907 if (tempbl == 3)
6908 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S3,
6909 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006910
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306911 if (tempbl == 4)
6912 XGINew_LCD_Wait_Time(pVBInfo->XG21_LVDSCapList[index].PSC_S4,
6913 pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006914}
6915
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006916unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306917 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006918{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306919 unsigned short xres, yres, colordepth, modeflag, resindex,
6920 lvdstableindex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006921
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306922 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6923 if (ModeNo <= 0x13) {
6924 xres = pVBInfo->StResInfo[resindex].HTotal;
6925 yres = pVBInfo->StResInfo[resindex].VTotal;
6926 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6927 } else {
6928 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6929 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6930 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6931 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006932
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306933 if (!(modeflag & Charx8Dot)) {
6934 xres /= 9;
6935 xres *= 8;
6936 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006937
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306938 if (ModeNo > 0x13) {
6939 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6940 xres *= 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006941
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306942 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6943 yres *= 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006944
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306945 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006946
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306947 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6948 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6949 return 0;
Bill Pembertondda08c52010-06-17 13:10:42 -04006950
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306951 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6952 return 0;
6953
6954 if (ModeNo > 0x13) {
6955 if ((xres
6956 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6957 || (yres
6958 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
6959 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
6960 pVBInfo);
6961 if (colordepth > 2)
6962 return 0;
6963
6964 }
6965 }
6966 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006967}
6968
Bill Pemberton80adad82010-06-17 13:10:51 -04006969void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006970{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306971 unsigned char temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006972
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306973 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6974 temp = (temp & 1) << 6;
6975 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
6976 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 +02006977
6978}
6979
Bill Pemberton80adad82010-06-17 13:10:51 -04006980void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006981{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306982 unsigned char temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006983
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306984 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6985 temp = (temp & 3) << 6;
6986 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6987 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 +02006988
6989}
6990
Bill Pemberton82d6eb52010-06-17 13:10:46 -04006991void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306992 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006993{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05306994 unsigned char temp, Miscdata;
6995 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6996 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6997 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6998 unsigned short value;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02006999
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307000 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007001
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307002 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7003 & (LCDPolarity << 8)) >> 8);
7004 temp &= LCDPolarity;
7005 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007006
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307007 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007008
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307009 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7010 & LCDPolarity);
7011 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7012 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007013
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307014 XGI_SetXG21FPBits(pVBInfo);
7015 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7016 if (ModeNo <= 0x13) {
7017 xres = pVBInfo->StResInfo[resindex].HTotal;
7018 yres = pVBInfo->StResInfo[resindex].VTotal;
7019 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7020 } else {
7021 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7022 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7023 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7024 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007025
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307026 if (!(modeflag & Charx8Dot))
7027 xres = xres * 8 / 9;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007028
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307029 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007030
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307031 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7032 - xres) / 2;
7033 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7034 LVDSHBS -= xres / 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007035
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307036 if (LVDSHBS > LVDSHT)
7037 LVDSHBS -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007038
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307039 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7040 if (LVDSHRS > LVDSHT)
7041 LVDSHRS -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007042
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307043 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7044 if (LVDSHRE > LVDSHT)
7045 LVDSHRE -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007046
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307047 LVDSHBE = LVDSHBS + LVDSHT
7048 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007049
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307050 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007051
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307052 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7053 - yres) / 2;
7054 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7055 LVDSVBS += yres / 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007056
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307057 if (LVDSVBS > LVDSVT)
7058 LVDSVBS -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007059
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307060 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7061 if (LVDSVRS > LVDSVT)
7062 LVDSVRS -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007063
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307064 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7065 if (LVDSVRE > LVDSVT)
7066 LVDSVRE -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007067
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307068 LVDSVBE = LVDSVBS + LVDSVT
7069 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007070
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307071 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7072 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007073
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307074 if (!(modeflag & Charx8Dot))
7075 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007076
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307077 /* HT SR0B[1:0] CR00 */
7078 value = (LVDSHT >> 3) - 5;
7079 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7080 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007081
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307082 /* HBS SR0B[5:4] CR02 */
7083 value = (LVDSHBS >> 3) - 1;
7084 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7085 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007086
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307087 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7088 value = (LVDSHBE >> 3) - 1;
7089 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7090 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7091 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007092
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307093 /* HRS SR0B[7:6] CR04 */
7094 value = (LVDSHRS >> 3) + 2;
7095 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7096 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007097
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307098 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7099 value--;
7100 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7101 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007102
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307103 /* HRE SR0C[2] CR05[4:0] */
7104 value = (LVDSHRE >> 3) + 2;
7105 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7106 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007107
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307108 /* Panel HRE SR2F[7:2] */
7109 value--;
7110 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007111
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307112 /* VT SR0A[0] CR07[5][0] CR06 */
7113 value = LVDSVT - 2;
7114 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7115 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7116 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7117 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007118
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307119 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7120 value = LVDSVBS - 1;
7121 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7122 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7123 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7124 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007125
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307126 /* VBE SR0A[4] CR16 */
7127 value = LVDSVBE - 1;
7128 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7129 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007130
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307131 /* VRS SR0A[3] CR7[7][2] CR10 */
7132 value = LVDSVRS - 1;
7133 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7134 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7135 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7136 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007137
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307138 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
7139 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
7140 XGINew_SetReg1(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
7141 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007142
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307143 /* VRE SR0A[5] CR11[3:0] */
7144 value = LVDSVRE - 1;
7145 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7146 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007147
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307148 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
7149 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007150
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307151 for (temp = 0, value = 0; temp < 3; temp++) {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007152
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307153 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7154 XGINew_SetReg1(pVBInfo->P3c4,
7155 0x2B,
7156 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7157 XGINew_SetReg1(pVBInfo->P3c4,
7158 0x2C,
7159 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7160 value += 0x10;
7161 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007162
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307163 if (!(modeflag & Charx8Dot)) {
7164 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7165 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7166 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007167
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307168 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7169 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7170
7171 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7172 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007173
7174}
7175
7176/* no shadow case */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04007177void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307178 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007179{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307180 unsigned char temp, Miscdata;
7181 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
7182 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
7183 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
7184 unsigned short value;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007185
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307186 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
7187 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7188 & (LCDPolarity << 8)) >> 8);
7189 temp &= LCDPolarity;
7190 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007191
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307192 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007193
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307194 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
7195 & LCDPolarity);
7196 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
7197 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007198
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307199 XGI_SetXG27FPBits(pVBInfo);
7200 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
7201 if (ModeNo <= 0x13) {
7202 xres = pVBInfo->StResInfo[resindex].HTotal;
7203 yres = pVBInfo->StResInfo[resindex].VTotal;
7204 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
7205 } else {
7206 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
7207 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
7208 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
7209 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007210
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307211 if (!(modeflag & Charx8Dot))
7212 xres = xres * 8 / 9;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007213
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307214 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007215
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307216 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
7217 - xres) / 2;
7218 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
7219 LVDSHBS -= xres / 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007220
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307221 if (LVDSHBS > LVDSHT)
7222 LVDSHBS -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007223
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307224 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
7225 if (LVDSHRS > LVDSHT)
7226 LVDSHRS -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007227
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307228 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
7229 if (LVDSHRE > LVDSHT)
7230 LVDSHRE -= LVDSHT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007231
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307232 LVDSHBE = LVDSHBS + LVDSHT
7233 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007234
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307235 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007236
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307237 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7238 - yres) / 2;
7239 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7240 LVDSVBS += yres / 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007241
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307242 if (LVDSVBS > LVDSVT)
7243 LVDSVBS -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007244
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307245 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7246 if (LVDSVRS > LVDSVT)
7247 LVDSVRS -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007248
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307249 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
7250 if (LVDSVRE > LVDSVT)
7251 LVDSVRE -= LVDSVT;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007252
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307253 LVDSVBE = LVDSVBS + LVDSVT
7254 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007255
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307256 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
7257 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007258
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307259 if (!(modeflag & Charx8Dot))
7260 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007261
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307262 /* HT SR0B[1:0] CR00 */
7263 value = (LVDSHT >> 3) - 5;
7264 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7265 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007266
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307267 /* HBS SR0B[5:4] CR02 */
7268 value = (LVDSHBS >> 3) - 1;
7269 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7270 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007271
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307272 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7273 value = (LVDSHBE >> 3) - 1;
7274 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7275 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7276 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007277
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307278 /* HRS SR0B[7:6] CR04 */
7279 value = (LVDSHRS >> 3) + 2;
7280 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7281 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007282
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307283 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7284 value--;
7285 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7286 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007287
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307288 /* HRE SR0C[2] CR05[4:0] */
7289 value = (LVDSHRE >> 3) + 2;
7290 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7291 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007292
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307293 /* Panel HRE SR2F[7:2] */
7294 value--;
7295 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007296
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307297 /* VT SR0A[0] CR07[5][0] CR06 */
7298 value = LVDSVT - 2;
7299 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7300 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7301 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7302 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007303
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307304 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7305 value = LVDSVBS - 1;
7306 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7307 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7308 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7309 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007310
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307311 /* VBE SR0A[4] CR16 */
7312 value = LVDSVBE - 1;
7313 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7314 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007315
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307316 /* VRS SR0A[3] CR7[7][2] CR10 */
7317 value = LVDSVRS - 1;
7318 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7319 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7320 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7321 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007322
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307323 /* Panel VRS SR35[2:0] SR34[7:0] */
7324 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
7325 XGINew_SetReg1(pVBInfo->P3c4, 0x34, value & 0xFF);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007326
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307327 /* VRE SR0A[5] CR11[3:0] */
7328 value = LVDSVRE - 1;
7329 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7330 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007331
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307332 /* Panel VRE SR3F[7:2] */
7333 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007334
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307335 for (temp = 0, value = 0; temp < 3; temp++) {
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007336
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307337 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
7338 XGINew_SetReg1(pVBInfo->P3c4,
7339 0x2B,
7340 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
7341 XGINew_SetReg1(pVBInfo->P3c4,
7342 0x2C,
7343 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
7344 value += 0x10;
7345 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007346
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307347 if (!(modeflag & Charx8Dot)) {
7348 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7349 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
7350 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007351
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307352 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
7353 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
7354
7355 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
7356 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007357
7358}
7359
7360/* --------------------------------------------------------------------- */
7361/* Function : XGI_IsLCDON */
7362/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04007363/* Output : 0 : Skip PSC Control */
7364/* 1: Disable PSC */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007365/* Description : */
7366/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04007367unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007368{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307369 unsigned short tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007370
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307371 tempax = pVBInfo->VBInfo;
7372 if (tempax & SetCRT2ToDualEdge)
7373 return 0;
7374 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
7375 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007376
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307377 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007378}
7379
Bill Pemberton80adad82010-06-17 13:10:51 -04007380void XGI_EnablePWD(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007381{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307382 unsigned short index, temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007383
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307384 index = XGI_GetLCDCapPtr(pVBInfo);
7385 temp = pVBInfo->LCDCapList[index].PWD_2B;
7386 XGINew_SetReg1(pVBInfo->Part4Port, 0x2B, temp);
7387 XGINew_SetReg1(pVBInfo->Part4Port, 0x2C,
7388 pVBInfo->LCDCapList[index].PWD_2C);
7389 XGINew_SetReg1(pVBInfo->Part4Port, 0x2D,
7390 pVBInfo->LCDCapList[index].PWD_2D);
7391 XGINew_SetReg1(pVBInfo->Part4Port, 0x2E,
7392 pVBInfo->LCDCapList[index].PWD_2E);
7393 XGINew_SetReg1(pVBInfo->Part4Port, 0x2F,
7394 pVBInfo->LCDCapList[index].PWD_2F);
7395 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x80); /* enable PWD */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007396}
7397
Bill Pemberton80adad82010-06-17 13:10:51 -04007398void XGI_DisablePWD(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007399{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307400 XGINew_SetRegAND(pVBInfo->Part4Port, 0x27, 0x7F); /* disable PWD */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007401}
7402
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007403/* --------------------------------------------------------------------- */
7404/* Function : XGI_DisableChISLCD */
7405/* Input : */
Bill Pembertondda08c52010-06-17 13:10:42 -04007406/* Output : 0 -> Not LCD Mode */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007407/* Description : */
7408/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04007409unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007410{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307411 unsigned short tempbx, tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007412
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307413 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
7414 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007415
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307416 if (tempbx & (EnableChA | DisableChA)) {
7417 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7418 return 0;
7419 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007420
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307421 if (!(tempbx & (EnableChB | DisableChB)))
7422 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007423
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307424 if (tempah & 0x01) /* Chk LCDB Mode */
7425 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007426
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307427 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007428}
7429
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007430/* --------------------------------------------------------------------- */
7431/* Function : XGI_EnableChISLCD */
7432/* Input : */
7433/* Output : 0 -> Not LCD mode */
7434/* Description : */
7435/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04007436unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007437{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307438 unsigned short tempbx, tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007439
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307440 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
7441 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007442
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307443 if (tempbx & (EnableChA | DisableChA)) {
7444 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7445 return 0;
7446 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007447
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307448 if (!(tempbx & (EnableChB | DisableChB)))
Bill Pembertondda08c52010-06-17 13:10:42 -04007449 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007450
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307451 if (tempah & 0x01) /* Chk LCDB Mode */
7452 return 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007453
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307454 return 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007455}
7456
Bill Pemberton80adad82010-06-17 13:10:51 -04007457unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007458{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307459 unsigned char tempal, tempah, tempbl, i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007460
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307461 tempah = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
7462 tempal = tempah & 0x0F;
7463 tempah = tempah & 0xF0;
7464 i = 0;
7465 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007466
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307467 while (tempbl != 0xFF) {
7468 if (tempbl & 0x80) { /* OEMUtil */
7469 tempal = tempah;
7470 tempbl = tempbl & ~(0x80);
7471 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007472
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307473 if (tempal == tempbl)
7474 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007475
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307476 i++;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007477
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307478 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7479 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007480
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307481 return i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007482}
7483
Bill Pemberton80adad82010-06-17 13:10:51 -04007484unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007485{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307486 unsigned short tempah, tempal, tempbl, i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007487
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307488 tempal = pVBInfo->LCDResInfo;
7489 tempah = pVBInfo->LCDTypeInfo;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007490
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307491 i = 0;
7492 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007493
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307494 while (tempbl != 0xFF) {
7495 if ((tempbl & 0x80) && (tempbl != 0x80)) {
7496 tempal = tempah;
7497 tempbl &= ~0x80;
7498 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007499
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307500 if (tempal == tempbl)
7501 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007502
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307503 i++;
7504 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
7505 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007506
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307507 if (tempbl == 0xFF) {
7508 pVBInfo->LCDResInfo = Panel1024x768;
7509 pVBInfo->LCDTypeInfo = 0;
7510 i = 0;
7511 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007512
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307513 return i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007514}
7515
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307516void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
7517 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007518{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307519 unsigned short Index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007520
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307521 Index = XGI_GetLCDCapPtr(pVBInfo);
7522 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
7523 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007524
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307525 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007526}
7527
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307528void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7529 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007530{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307531 unsigned short tempbl, tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007532
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307533 if (pVBInfo->SetFlag == Win9xDOSMode) {
7534 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7535 | VB_XGI302LV | VB_XGI301C)) {
7536 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7537 return;
7538 } else
7539 /* LVDS or CH7017 */
7540 return;
7541 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007542
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307543 if (HwDeviceExtension->jChipType < XG40) {
7544 if (!XGI_DisableChISLCD(pVBInfo)) {
7545 if ((XGI_EnableChISLCD(pVBInfo)) || (pVBInfo->VBInfo
7546 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
7547 if (pVBInfo->LCDInfo & SetPWDEnable) {
7548 XGI_EnablePWD(pVBInfo);
7549 } else {
7550 pVBInfo->LCDInfo &= (~SetPWDEnable);
7551 if (pVBInfo->VBType & (VB_XGI301LV
7552 | VB_XGI302LV
7553 | VB_XGI301C)) {
7554 tempbl = 0xFD;
7555 tempah = 0x02;
7556 } else {
7557 tempbl = 0xFB;
7558 tempah = 0x00;
7559 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007560
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307561 XGI_SetPanelPower(tempah, tempbl,
7562 pVBInfo);
7563 XGI_SetPanelDelay(1, pVBInfo);
7564 }
7565 }
7566 }
7567 } /* Not 340 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007568
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307569 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7570 | VB_XGI302LV | VB_XGI301C)) {
7571 if (!(pVBInfo->SetFlag & DisableChA)) {
7572 if (pVBInfo->SetFlag & EnableChA) {
7573 XGINew_SetReg1(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
7574 } else {
7575 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
7576 XGINew_SetReg1(pVBInfo->Part1Port,
7577 0x1E, 0x20); /* Power on */
7578 }
7579 }
7580 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007581
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307582 if (!(pVBInfo->SetFlag & DisableChB)) {
7583 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
7584 & (SetCRT2ToLCD | SetCRT2ToTV
7585 | SetCRT2ToRAMDAC))) {
7586 tempah = (unsigned char) XGINew_GetReg1(
7587 pVBInfo->P3c4, 0x32);
7588 tempah &= 0xDF;
7589 if (pVBInfo->VBInfo & SetInSlaveMode) {
7590 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
7591 tempah |= 0x20;
7592 }
7593 XGINew_SetReg1(pVBInfo->P3c4, 0x32, tempah);
7594 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x20);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007595
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307596 tempah = (unsigned char) XGINew_GetReg1(
7597 pVBInfo->Part1Port, 0x2E);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007598
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307599 if (!(tempah & 0x80))
7600 XGINew_SetRegOR(pVBInfo->Part1Port,
7601 0x2E, 0x80); /* BVBDOENABLE = 1 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007602
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307603 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
7604 }
7605 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007606
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307607 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
7608 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
7609 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x00, ~0xE0,
7610 0x20); /* shampoo 0129 */
7611 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7612 if (!XGI_DisableChISLCD(pVBInfo)) {
7613 if (XGI_EnableChISLCD(pVBInfo)
7614 || (pVBInfo->VBInfo
7615 & (SetCRT2ToLCD
7616 | SetCRT2ToLCDA)))
7617 XGINew_SetRegAND(
7618 pVBInfo->Part4Port,
7619 0x2A, 0x7F); /* LVDS PLL power on */
7620 }
7621 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
7622 }
7623 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007624
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307625 tempah = 0x00;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007626
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307627 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7628 tempah = 0xc0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007629
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307630 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
7631 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7632 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7633 tempah = tempah & 0x40;
7634 if (pVBInfo->VBInfo
7635 & SetCRT2ToLCDA)
7636 tempah = tempah ^ 0xC0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007637
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307638 if (pVBInfo->SetFlag
7639 & DisableChB)
7640 tempah &= 0xBF;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007641
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307642 if (pVBInfo->SetFlag
7643 & DisableChA)
7644 tempah &= 0x7F;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007645
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307646 if (pVBInfo->SetFlag
7647 & EnableChB)
7648 tempah |= 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007649
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307650 if (pVBInfo->SetFlag
7651 & EnableChA)
7652 tempah |= 0x80;
7653 }
7654 }
7655 }
7656 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007657
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307658 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007659
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307660 if (pVBInfo->SetFlag & Win9xDOSMode) {
7661 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7662 return;
7663 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007664
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307665 if (!(pVBInfo->SetFlag & DisableChA)) {
7666 XGI_VBLongWait(pVBInfo);
7667 if (!(pVBInfo->SetFlag & GatingCRT)) {
7668 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
7669 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7670 XGI_VBLongWait(pVBInfo);
7671 }
7672 }
7673 } /* 301 */
7674 else { /* LVDS */
7675 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
7676 | SetCRT2ToLCDA))
7677 XGINew_SetRegOR(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007678
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307679 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->Part1Port,
7680 0x2E);
7681 if (!(tempah & 0x80))
7682 XGINew_SetRegOR(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007683
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307684 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F);
7685 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7686 } /* End of VB */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007687
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307688 if (HwDeviceExtension->jChipType < XG40) {
7689 if (!XGI_EnableChISLCD(pVBInfo)) {
7690 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7691 if (XGI_BacklightByDrv(pVBInfo))
7692 return;
7693 } else
7694 return;
7695 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007696
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307697 if (pVBInfo->LCDInfo & SetPWDEnable) {
7698 XGI_FirePWDEnable(pVBInfo);
7699 return;
7700 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007701
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307702 XGI_SetPanelDelay(2, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007703
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307704 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
7705 tempah = 0x01;
7706 tempbl = 0xFE; /* turn on backlght */
7707 } else {
7708 tempbl = 0xF7;
7709 tempah = 0x00;
7710 }
7711 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7712 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007713}
7714
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307715void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7716 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007717{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307718 unsigned short tempax, tempbx, tempah = 0, tempbl = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007719
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307720 if (pVBInfo->SetFlag == Win9xDOSMode)
7721 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007722
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307723 if (HwDeviceExtension->jChipType < XG40) {
7724 if ((!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7725 || (XGI_DisableChISLCD(pVBInfo))) {
7726 if (!XGI_IsLCDON(pVBInfo)) {
7727 if (pVBInfo->LCDInfo & SetPWDEnable)
7728 XGI_EnablePWD(pVBInfo);
7729 else {
7730 pVBInfo->LCDInfo &= ~SetPWDEnable;
7731 XGI_DisablePWD(pVBInfo);
7732 if (pVBInfo->VBType & (VB_XGI301LV
7733 | VB_XGI302LV
7734 | VB_XGI301C)) {
7735 tempbx = 0xFE; /* not 01h */
7736 tempax = 0;
7737 } else {
7738 tempbx = 0xF7; /* not 08h */
7739 tempax = 0x08;
7740 }
7741 XGI_SetPanelPower(tempax, tempbx,
7742 pVBInfo);
7743 XGI_SetPanelDelay(3, pVBInfo);
7744 }
7745 } /* end if (!XGI_IsLCDON(pVBInfo)) */
7746 }
7747 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007748
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307749 /*
7750 if (CH7017) {
7751 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
7752 if (!XGI_IsLCDON(pVBInfo)) {
7753 if (DISCHARGE) {
7754 tempbx = XGINew_GetCH7005(0x61);
7755 if (tempbx < 0x01) // first time we power up
7756 XGINew_SetCH7005(0x0066); // and disable power sequence
7757 else
7758 XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
7759 }
7760 }
7761 }
7762 }
7763 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007764
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307765 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7766 | VB_XGI302LV | VB_XGI301C)) {
7767 tempah = 0x3F;
7768 if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
7769 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7770 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7771 tempah = 0x7F; /* Disable Channel A */
7772 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7773 tempah = 0xBF; /* Disable Channel B */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007774
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307775 if (pVBInfo->SetFlag & DisableChB)
7776 tempah &= 0xBF; /* force to disable Cahnnel */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007777
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307778 if (pVBInfo->SetFlag & DisableChA)
7779 tempah &= 0x7F; /* Force to disable Channel B */
7780 }
7781 }
7782 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007783
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307784 XGINew_SetRegAND(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007785
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307786 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7787 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7788 || (XGI_DisableChISLCD(pVBInfo))
7789 || (XGI_IsLCDON(pVBInfo)))
7790 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
7791 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007792
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307793 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7794 & (DisableCRT2Display | SetCRT2ToLCDA
7795 | SetSimuScanMode))) {
7796 if (pVBInfo->SetFlag & GatingCRT)
7797 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
7798 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7799 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007800
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307801 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7802 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7803 & SetCRT2ToLCDA))
7804 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
7805 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007806
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307807 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007808
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307809 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
7810 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xdf);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007811
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307812 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7813 & (DisableCRT2Display | SetSimuScanMode))
7814 || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7815 && (pVBInfo->VBInfo
7816 & (SetCRT2ToRAMDAC
7817 | SetCRT2ToLCD
7818 | SetCRT2ToTV))))
7819 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007820
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307821 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7822 & (DisableCRT2Display | SetSimuScanMode))
7823 || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7824 || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7825 | SetCRT2ToLCD | SetCRT2ToTV))) {
7826 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
7827 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
7828 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
7829 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
7830 }
7831 } else { /* {301} */
7832 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
7833 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7834 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
7835 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
7836 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007837
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307838 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
7839 | SetSimuScanMode))
7840 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7841 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007842
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307843 if (HwDeviceExtension->jChipType < XG40) {
7844 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7845 || (XGI_DisableChISLCD(pVBInfo))
7846 || (XGI_IsLCDON(pVBInfo))) {
7847 if (pVBInfo->LCDInfo & SetPWDEnable) {
7848 if (pVBInfo->LCDInfo & SetPWDEnable)
7849 XGI_BacklightByDrv(pVBInfo);
7850 else {
7851 XGI_SetPanelDelay(4, pVBInfo);
7852 if (pVBInfo->VBType & VB_XGI301LV) {
7853 tempbl = 0xFD;
7854 tempah = 0x00;
7855 } else {
7856 tempbl = 0xFB;
7857 tempah = 0x04;
7858 }
7859 }
7860 }
7861 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7862 }
7863 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007864}
7865
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007866/* --------------------------------------------------------------------- */
7867/* Function : XGI_GetTVPtrIndex */
7868/* Input : */
7869/* Output : */
7870/* Description : bx 0 : ExtNTSC */
7871/* 1 : StNTSC */
7872/* 2 : ExtPAL */
7873/* 3 : StPAL */
7874/* 4 : ExtHiTV */
7875/* 5 : StHiTV */
7876/* 6 : Ext525i */
7877/* 7 : St525i */
7878/* 8 : Ext525p */
7879/* 9 : St525p */
7880/* A : Ext750p */
7881/* B : St750p */
7882/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04007883unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007884{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307885 unsigned short tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007886
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307887 if (pVBInfo->TVInfo & SetPALTV)
7888 tempbx = 2;
7889 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7890 tempbx = 4;
7891 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7892 tempbx = 6;
7893 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7894 tempbx = 8;
7895 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7896 tempbx = 10;
7897 if (pVBInfo->TVInfo & TVSimuMode)
7898 tempbx++;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007899
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307900 return tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007901}
7902
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007903/* --------------------------------------------------------------------- */
7904/* Function : XGI_OEM310Setting */
7905/* Input : */
7906/* Output : */
7907/* Description : Customized Param. for 301 */
7908/* --------------------------------------------------------------------- */
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307909void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
7910 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007911{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307912 if (pVBInfo->SetFlag & Win9xDOSMode)
7913 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007914
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307915 /* GetPart1IO(); */
7916 XGI_SetDelayComp(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007917
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307918 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7919 XGI_SetLCDCap(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007920
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307921 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7922 /* GetPart2IO() */
7923 XGI_SetPhaseIncr(pVBInfo);
7924 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7925 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007926
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307927 if (pVBInfo->VBType & VB_XGI301)
7928 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7929 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007930}
7931
Bill Pemberton80adad82010-06-17 13:10:51 -04007932void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007933{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307934 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007935
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307936 unsigned char tempah, tempbl, tempbh;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007937
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307938 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7939 | VB_XGI302LV | VB_XGI301C)) {
7940 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7941 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7942 tempbl = 0;
7943 tempbh = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007944
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307945 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7946 tempbl = pVBInfo->XGI_TVDelayList[index];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007947
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307948 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7949 | VB_XGI301LV | VB_XGI302LV
7950 | VB_XGI301C))
7951 tempbl = pVBInfo->XGI_TVDelayList2[index];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007952
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307953 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7954 tempbl = tempbl >> 4;
7955 /*
7956 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7957 tempbl = CRT2Delay1; // Get CRT2 Delay
7958 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
7959 tempbl = CRT2Delay2;
7960 */
7961 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7962 index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
7963 tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007964
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307965 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7966 tempbl = tempbh;
7967 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007968
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307969 tempbl &= 0x0F;
7970 tempbh &= 0xF0;
7971 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x2D);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007972
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307973 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7974 | SetCRT2ToTV)) { /* Channel B */
7975 tempah &= 0xF0;
7976 tempah |= tempbl;
7977 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007978
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05307979 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7980 tempah &= 0x0F;
7981 tempah |= tempbh;
7982 }
7983 XGINew_SetReg1(pVBInfo->Part1Port, 0x2D, tempah);
7984 }
7985 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7986 tempbl = 0;
7987 tempbh = 0;
7988 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7989 tempah
7990 = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
7991 pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
7992 tempah &= 0x0f;
7993 tempah = tempah << 4;
7994 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2D, 0x0f,
7995 tempah);
7996 }
7997 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02007998}
7999
Bill Pemberton80adad82010-06-17 13:10:51 -04008000void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008001{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308002 unsigned short tempcx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008003
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308004 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008005
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308006 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8007 | VB_XGI302LV | VB_XGI301C)) {
8008 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
8009 /* Set 301LV Capability */
8010 XGINew_SetReg1(pVBInfo->Part4Port, 0x24,
8011 (unsigned char) (tempcx & 0x1F));
8012 }
8013 /* VB Driving */
8014 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
8015 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
8016 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
8017 | EnablePLLSPLOW)) >> 8));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008018 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008019
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308020 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8021 | VB_XGI302LV | VB_XGI301C)) {
8022 if (pVBInfo->VBInfo & SetCRT2ToLCD)
8023 XGI_SetLCDCap_B(tempcx, pVBInfo);
8024 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8025 XGI_SetLCDCap_A(tempcx, pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008026
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308027 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8028 if (tempcx & EnableSpectrum)
8029 SetSpectrum(pVBInfo);
8030 }
8031 } else {
8032 /* LVDS,CH7017 */
8033 XGI_SetLCDCap_A(tempcx, pVBInfo);
8034 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008035}
8036
Bill Pemberton80adad82010-06-17 13:10:51 -04008037void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008038{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308039 unsigned short temp;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008040
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308041 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008042
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308043 if (temp & LCDRGB18Bit) {
8044 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
8045 (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
8046 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
8047 } else {
8048 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
8049 (unsigned short) (0x30 | (tempcx & 0x00C0)));
8050 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
8051 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008052
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308053 /*
8054 if (tempcx & EnableLCD24bpp) { // 24bits
8055 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
8056 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
8057 } else {
8058 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
8059 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
8060 }
8061 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008062}
8063
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008064/* --------------------------------------------------------------------- */
8065/* Function : XGI_SetLCDCap_B */
8066/* Input : cx -> LCD Capability */
8067/* Output : */
8068/* Description : */
8069/* --------------------------------------------------------------------- */
Bill Pemberton80adad82010-06-17 13:10:51 -04008070void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008071{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308072 if (tempcx & EnableLCD24bpp) /* 24bits */
8073 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8074 (unsigned short) (((tempcx & 0x00ff) >> 6)
8075 | 0x0c));
8076 else
8077 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
8078 (unsigned short) (((tempcx & 0x00ff) >> 6)
8079 | 0x18)); /* Enable Dither */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008080}
8081
Bill Pemberton80adad82010-06-17 13:10:51 -04008082void SetSpectrum(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008083{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308084 unsigned short index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008085
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308086 index = XGI_GetLCDCapPtr(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008087
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308088 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
8089 XGI_LongWait(pVBInfo);
8090 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
8091 XGI_LongWait(pVBInfo);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008092
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308093 XGINew_SetReg1(pVBInfo->Part4Port, 0x31,
8094 pVBInfo->LCDCapList[index].Spectrum_31);
8095 XGINew_SetReg1(pVBInfo->Part4Port, 0x32,
8096 pVBInfo->LCDCapList[index].Spectrum_32);
8097 XGINew_SetReg1(pVBInfo->Part4Port, 0x33,
8098 pVBInfo->LCDCapList[index].Spectrum_33);
8099 XGINew_SetReg1(pVBInfo->Part4Port, 0x34,
8100 pVBInfo->LCDCapList[index].Spectrum_34);
8101 XGI_LongWait(pVBInfo);
8102 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008103}
8104
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008105/* --------------------------------------------------------------------- */
8106/* Function : XGI_SetAntiFlicker */
8107/* Input : */
8108/* Output : */
8109/* Description : Set TV Customized Param. */
8110/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008111void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308112 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008113{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308114 unsigned short tempbx, index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008115
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308116 unsigned char tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008117
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308118 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
8119 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008120
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308121 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8122 tempbx &= 0xFE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008123
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308124 if (ModeNo <= 0x13)
8125 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
8126 else
8127 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008128
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308129 tempbx += index;
8130 tempah = TVAntiFlickList[tempbx];
8131 tempah = tempah << 4;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008132
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308133 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008134}
8135
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308136void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
8137 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008138{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308139 unsigned short tempbx, index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008140
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308141 unsigned char tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008142
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308143 tempbx = XGI_GetTVPtrIndex(pVBInfo);
8144 tempbx &= 0xFE;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008145
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308146 if (ModeNo <= 0x13)
8147 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
8148 else
8149 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008150
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308151 tempbx += index;
8152 tempah = TVEdgeList[tempbx];
8153 tempah = tempah << 5;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008154
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308155 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008156}
8157
Bill Pemberton80adad82010-06-17 13:10:51 -04008158void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008159{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308160 unsigned short tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008161
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308162 unsigned char tempcl, tempch;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008163
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308164 unsigned long tempData;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008165
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308166 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
8167 tempData = TVPhaseList[tempbx];
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008168
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308169 XGINew_SetReg1(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
8170 & 0x000000FF));
8171 XGINew_SetReg1(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
8172 & 0x0000FF00) >> 8));
8173 XGINew_SetReg1(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
8174 & 0x00FF0000) >> 16));
8175 XGINew_SetReg1(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
8176 & 0xFF000000) >> 24));
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008177}
8178
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008179void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308180 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008181{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308182 unsigned short tempbx, index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008183
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308184 unsigned char tempcl, tempch, tempal, *filterPtr;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008185
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308186 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008187
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308188 switch (tempbx) {
8189 case 0x00:
8190 case 0x04:
8191 filterPtr = NTSCYFilter1;
8192 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008193
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308194 case 0x01:
8195 filterPtr = PALYFilter1;
8196 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008197
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308198 case 0x02:
8199 case 0x05:
8200 case 0x0D:
8201 filterPtr = PALMYFilter1;
8202 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008203
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308204 case 0x03:
8205 filterPtr = PALNYFilter1;
8206 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008207
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308208 case 0x08:
8209 case 0x0C:
8210 filterPtr = NTSCYFilter2;
8211 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008212
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308213 case 0x0A:
8214 filterPtr = PALMYFilter2;
8215 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008216
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308217 case 0x0B:
8218 filterPtr = PALNYFilter2;
8219 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008220
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308221 case 0x09:
8222 filterPtr = PALYFilter2;
8223 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008224
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308225 default:
8226 return;
8227 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008228
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308229 if (ModeNo <= 0x13)
8230 tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
8231 else
8232 tempal
8233 = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008234
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308235 if (tempcl == 0)
8236 index = tempal * 4;
8237 else
8238 index = tempal * 7;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008239
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308240 if ((tempcl == 0) && (tempch == 1)) {
8241 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, 0);
8242 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, 0);
8243 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, 0);
8244 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8245 } else {
8246 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
8247 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
8248 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
8249 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
8250 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008251
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308252 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8253 | VB_XGI302LV | VB_XGI301C)) {
8254 XGINew_SetReg1(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
8255 XGINew_SetReg1(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
8256 XGINew_SetReg1(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
8257 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008258}
8259
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008260/* --------------------------------------------------------------------- */
8261/* Function : XGI_GetTVPtrIndex2 */
8262/* Input : */
8263/* Output : bx 0 : NTSC */
8264/* 1 : PAL */
8265/* 2 : PALM */
8266/* 3 : PALN */
8267/* 4 : NTSC1024x768 */
8268/* 5 : PAL-M 1024x768 */
8269/* 6-7: reserved */
8270/* cl 0 : YFilter1 */
8271/* 1 : YFilter2 */
8272/* ch 0 : 301A */
8273/* 1 : 301B/302B/301LV/302LV */
8274/* Description : */
8275/* --------------------------------------------------------------------- */
Bill Pemberton108afbf2010-06-17 13:10:47 -04008276void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308277 unsigned char *tempch, struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008278{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308279 *tempbx = 0;
8280 *tempcl = 0;
8281 *tempch = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008282
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308283 if (pVBInfo->TVInfo & SetPALTV)
8284 *tempbx = 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008285
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308286 if (pVBInfo->TVInfo & SetPALMTV)
8287 *tempbx = 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008288
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308289 if (pVBInfo->TVInfo & SetPALNTV)
8290 *tempbx = 3;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008291
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308292 if (pVBInfo->TVInfo & NTSC1024x768) {
8293 *tempbx = 4;
8294 if (pVBInfo->TVInfo & SetPALMTV)
8295 *tempbx = 5;
8296 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008297
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308298 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8299 | VB_XGI302LV | VB_XGI301C)) {
8300 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
8301 & TVSimuMode)) {
8302 *tempbx += 8;
8303 *tempcl += 1;
8304 }
8305 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008306
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308307 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8308 | VB_XGI302LV | VB_XGI301C))
8309 (*tempch)++;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008310}
8311
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008312/* --------------------------------------------------------------------- */
8313/* Function : XGI_SetCRT2ModeRegs */
8314/* Input : */
8315/* Output : */
8316/* Description : Origin code for crt2group */
8317/* --------------------------------------------------------------------- */
Bill Pemberton82d6eb52010-06-17 13:10:46 -04008318void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308319 struct xgi_hw_device_info *HwDeviceExtension,
8320 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008321{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308322 unsigned short tempbl;
8323 short tempcl;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008324
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308325 unsigned char tempah;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008326
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308327 /* XGINew_SetReg1(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
8328 tempah = 0;
8329 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8330 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00);
8331 tempah &= ~0x10; /* BTRAMDAC */
8332 tempah |= 0x40; /* BTRAM */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008333
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308334 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8335 | SetCRT2ToLCD)) {
8336 tempah = 0x40; /* BTDRAM */
8337 if (ModeNo > 0x13) {
8338 tempcl = pVBInfo->ModeType;
8339 tempcl -= ModeVGA;
8340 if (tempcl >= 0) {
8341 tempah = (0x008 >> tempcl); /* BT Color */
8342 if (tempah == 0)
8343 tempah = 1;
8344 tempah |= 0x040;
8345 }
8346 }
8347 if (pVBInfo->VBInfo & SetInSlaveMode)
8348 tempah ^= 0x50; /* BTDAC */
8349 }
8350 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008351
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308352 /* 0210 shampoo
8353 if (pVBInfo->VBInfo & DisableCRT2Display) {
8354 tempah = 0;
8355 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008356
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308357 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8358 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
8359 tempcl = pVBInfo->ModeType;
8360 if (ModeNo > 0x13) {
8361 tempcl -= ModeVGA;
8362 if ((tempcl > 0) || (tempcl == 0)) {
8363 tempah=(0x008>>tempcl) ;
8364 if (tempah == 0)
8365 tempah = 1;
8366 tempah |= 0x040;
8367 }
8368 } else {
8369 tempah = 0x040;
8370 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008371
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308372 if (pVBInfo->VBInfo & SetInSlaveMode) {
8373 tempah = (tempah ^ 0x050);
8374 }
8375 }
8376 */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008377
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308378 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
8379 tempah = 0x08;
8380 tempbl = 0xf0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008381
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308382 if (pVBInfo->VBInfo & DisableCRT2Display) {
8383 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
8384 } else {
8385 tempah = 0x00;
8386 tempbl = 0xff;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008387
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308388 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
8389 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
8390 if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
8391 && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
8392 tempbl &= 0xf7;
8393 tempah |= 0x01;
8394 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e,
8395 tempbl, tempah);
8396 } else {
8397 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8398 tempbl &= 0xf7;
8399 tempah |= 0x01;
8400 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008401
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308402 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
8403 | SetCRT2ToTV | SetCRT2ToLCD)) {
8404 tempbl &= 0xf8;
8405 tempah = 0x01;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008406
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308407 if (!(pVBInfo->VBInfo & SetInSlaveMode))
8408 tempah |= 0x02;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008409
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308410 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
8411 tempah = tempah ^ 0x05;
8412 if (!(pVBInfo->VBInfo
8413 & SetCRT2ToLCD))
8414 tempah = tempah ^ 0x01;
8415 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008416
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308417 if (!(pVBInfo->VBInfo
8418 & SetCRT2ToDualEdge))
8419 tempah |= 0x08;
8420 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8421 0x2e, tempbl, tempah);
8422 } else {
8423 XGINew_SetRegANDOR(pVBInfo->Part1Port,
8424 0x2e, tempbl, tempah);
8425 }
8426 }
8427 } else {
8428 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl,
8429 tempah);
8430 }
8431 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008432
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308433 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
8434 | SetCRT2ToLCDA)) {
8435 tempah &= (~0x08);
8436 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
8437 & SetInSlaveMode))) {
8438 tempah |= 0x010;
8439 }
8440 tempah |= 0x080;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008441
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308442 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8443 /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
8444 tempah |= 0x020;
8445 if (ModeNo > 0x13) {
8446 if (pVBInfo->VBInfo & DriverMode)
8447 tempah = tempah ^ 0x20;
8448 }
8449 /* } */
8450 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008451
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308452 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
8453 tempah = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008454
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308455 if (pVBInfo->LCDInfo & SetLCDDualLink)
8456 tempah |= 0x40;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008457
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308458 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8459 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
8460 if (pVBInfo->TVInfo & RPLLDIV2XO)
8461 tempah |= 0x40;
8462 /* } */
8463 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008464
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308465 if ((pVBInfo->LCDResInfo == Panel1280x1024)
8466 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
8467 tempah |= 0x80;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008468
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308469 if (pVBInfo->LCDResInfo == Panel1280x960)
8470 tempah |= 0x80;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008471
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308472 XGINew_SetReg1(pVBInfo->Part4Port, 0x0C, tempah);
8473 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008474
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308475 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8476 | VB_XGI302LV | VB_XGI301C)) {
8477 tempah = 0;
8478 tempbl = 0xfb;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008479
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308480 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8481 tempbl = 0xff;
8482 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8483 tempah |= 0x04; /* shampoo 0129 */
8484 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008485
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308486 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x13, tempbl, tempah);
8487 tempah = 0x00;
8488 tempbl = 0xcf;
8489 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8490 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8491 tempah |= 0x30;
8492 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008493
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308494 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
8495 tempah = 0;
8496 tempbl = 0x3f;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008497
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308498 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8499 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8500 tempah |= 0xc0;
8501 }
8502 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, tempbl, tempah);
8503 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008504
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308505 tempah = 0;
8506 tempbl = 0x7f;
8507 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
8508 tempbl = 0xff;
8509 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
8510 tempah |= 0x80;
8511 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008512
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308513 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x23, tempbl, tempah);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008514
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308515 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8516 if (pVBInfo->LCDInfo & SetLCDDualLink) {
8517 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x20);
8518 XGINew_SetRegOR(pVBInfo->Part4Port, 0x34, 0x10);
8519 }
8520 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008521}
8522
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308523void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8524 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008525{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308526 unsigned short tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008527
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308528 tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008529
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308530 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8531 tempbx = 0x08A0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008532
8533}
8534
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308535void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8536 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008537{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308538 unsigned short tempbx;
8539 tempbx = 0;
8540}
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008541
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308542void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
8543 unsigned short RefreshRateTableIndex,
8544 struct vb_device_info *pVBInfo)
8545{
8546 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
8547 StandTableIndex, CRT1Index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008548
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308549 pVBInfo->RVBHCMAX = 1;
8550 pVBInfo->RVBHCFACT = 1;
8551
8552 if (ModeNo <= 0x13) {
8553 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8554 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8555 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
8556 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
8557 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
8558 } else {
8559 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8560 CRT1Index
8561 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
8562 CRT1Index &= IndexMask;
8563 temp1
8564 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
8565 temp2
8566 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
8567 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
8568 tempbx
8569 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
8570 tempcx
8571 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
8572 << 8;
8573 tempcx &= 0x0100;
8574 tempcx = tempcx << 2;
8575 tempbx |= tempcx;
8576 temp1
8577 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
8578 }
8579
8580 if (temp1 & 0x01)
8581 tempbx |= 0x0100;
8582
8583 if (temp1 & 0x20)
8584 tempbx |= 0x0200;
8585 tempax += 5;
8586
8587 if (modeflag & Charx8Dot)
8588 tempax *= 8;
8589 else
8590 tempax *= 9;
8591
8592 pVBInfo->VGAHT = tempax;
8593 pVBInfo->HT = tempax;
8594 tempbx++;
8595 pVBInfo->VGAVT = tempbx;
8596 pVBInfo->VT = tempbx;
8597}
8598
8599unsigned short XGI_GetColorDepth(unsigned short ModeNo,
8600 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
8601{
8602 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
8603 short index;
8604 unsigned short modeflag;
8605
8606 if (ModeNo <= 0x13)
8607 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8608 else
8609 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8610
8611 index = (modeflag & ModeInfoFlag) - ModeEGA;
8612
8613 if (index < 0)
8614 index = 0;
8615
8616 return ColorDepth[index];
8617}
8618
8619void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8620 struct vb_device_info *pVBInfo)
8621{
8622
8623 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008624
8625}
8626
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308627void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8628 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008629{
8630
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308631 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008632
8633}
8634
Bill Pemberton80adad82010-06-17 13:10:51 -04008635void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008636{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308637 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008638}
8639
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308640void XGINew_LCD_Wait_Time(unsigned char DelayTime,
8641 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008642{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308643 unsigned short i, j;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008644
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308645 unsigned long temp, flag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008646
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308647 flag = 0;
8648 /* printk("XGINew_LCD_Wait_Time"); */
8649 /* return; */
8650 for (i = 0; i < DelayTime; i++) {
8651 for (j = 0; j < 66; j++) {
8652 temp = XGINew_GetReg3(0x61);
8653 /* temp &= 0x10000000; */
8654 temp &= 0x10;
8655 if (temp == flag)
8656 continue;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008657
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308658 flag = temp;
8659 }
8660 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008661}
8662
Bill Pemberton80adad82010-06-17 13:10:51 -04008663unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008664{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308665 unsigned short flag;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008666
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308667 if (pVBInfo->IF_DEF_LVDS == 1) {
8668 return 1;
8669 } else {
8670 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
8671 if ((flag == 1) || (flag == 2))
8672 return 1; /* 301b */
8673 else
8674 return 0;
8675 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008676}
8677
Bill Pemberton80adad82010-06-17 13:10:51 -04008678void XGI_LongWait(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008679{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308680 unsigned short i;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008681
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308682 i = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008683
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308684 if (!(i & 0xC0)) {
8685 for (i = 0; i < 0xFFFF; i++) {
8686 if (!(XGINew_GetReg2(pVBInfo->P3da) & 0x08))
8687 break;
8688 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008689
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308690 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 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008695}
8696
Bill Pemberton80adad82010-06-17 13:10:51 -04008697void XGI_VBLongWait(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008698{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308699 unsigned short tempal, temp, i, j;
8700 return;
8701 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
8702 temp = 0;
8703 for (i = 0; i < 3; i++) {
8704 for (j = 0; j < 100; j++) {
8705 tempal = XGINew_GetReg2(pVBInfo->P3da);
8706 if (temp & 0x01) { /* VBWaitMode2 */
8707 if ((tempal & 0x08))
8708 continue;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008709
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308710 if (!(tempal & 0x08))
8711 break;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008712
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308713 } else { /* VBWaitMode1 */
8714 if (!(tempal & 0x08))
8715 continue;
8716
8717 if ((tempal & 0x08))
8718 break;
8719 }
8720 }
8721 temp = temp ^ 0x01;
8722 }
8723 } else {
8724 XGI_LongWait(pVBInfo);
8725 }
8726 return;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008727}
8728
Bill Pemberton80adad82010-06-17 13:10:51 -04008729unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008730{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308731 unsigned long tempax, tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008732
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308733 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
8734 & 0xFFFF;
8735 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
8736 tempax = (tempax * pVBInfo->HT) / tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008737
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308738 return (unsigned short) tempax;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008739}
8740
Bill Pembertone4147ab2010-06-17 13:10:50 -04008741unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308742 unsigned short ModeIdIndex,
8743 unsigned short RefreshRateTableIndex,
8744 struct xgi_hw_device_info *HwDeviceExtension,
8745 struct vb_device_info *pVBInfo)
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008746{
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308747 unsigned short tempbx;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008748
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308749 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8750 VCLK65 + 2 };
8751 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
8752 VCLK108_2 + 5, VCLK108_2 + 5 };
8753 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
8754 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8755 VCLK65 + 2 };
8756 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
8757 VCLK65 + 2 };
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008758
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308759 unsigned short CRT2Index, VCLKIndex;
8760 unsigned short modeflag, resinfo;
8761 unsigned char *CHTVVCLKPtr = NULL;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008762
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308763 if (ModeNo <= 0x13) {
8764 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
8765 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
8766 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
8767 } else {
8768 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
8769 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
8770 CRT2Index
8771 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
8772 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008773
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308774 if (pVBInfo->IF_DEF_LVDS == 0) {
8775 CRT2Index = CRT2Index >> 6; /* for LCD */
Dan Carpentera65fd092011-01-04 09:02:27 +03008776 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308777 if (pVBInfo->LCDResInfo != Panel1024x768)
8778 VCLKIndex = LCDXlat2VCLK[CRT2Index];
8779 else
8780 VCLKIndex = LCDXlat1VCLK[CRT2Index];
8781 } else { /* for TV */
8782 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8783 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
8784 if (pVBInfo->SetFlag & RPLLDIV2XO) {
8785 VCLKIndex = HiTVVCLKDIV2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008786
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308787 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008788
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308789 } else {
8790 VCLKIndex = HiTVVCLK;
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 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008795
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308796 if (pVBInfo->SetFlag & TVSimuMode) {
8797 if (modeflag & Charx8Dot) {
8798 VCLKIndex
8799 = HiTVSimuVCLK;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008800
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308801 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008802
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308803 } else {
8804 VCLKIndex
8805 = HiTVTextVCLK;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008806
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308807 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008808
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308809 }
8810 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008811
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308812 if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
8813 if (!(pVBInfo->VBExtInfo
8814 == VB_YPbPr1080i)) {
8815 VCLKIndex
8816 = YPbPr750pVCLK;
8817 if (!(pVBInfo->VBExtInfo
8818 == VB_YPbPr750p)) {
8819 VCLKIndex
8820 = YPbPr525pVCLK;
8821 if (!(pVBInfo->VBExtInfo
8822 == VB_YPbPr525p)) {
8823 VCLKIndex
8824 = YPbPr525iVCLK_2;
8825 if (!(pVBInfo->SetFlag
8826 & RPLLDIV2XO))
8827 VCLKIndex
8828 = YPbPr525iVCLK;
8829 }
8830 }
8831 }
8832 }
8833 } else {
8834 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8835 if (pVBInfo->SetFlag
8836 & RPLLDIV2XO) {
8837 VCLKIndex = TVVCLKDIV2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008838
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308839 VCLKIndex += 25;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008840
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308841 } else {
8842 VCLKIndex = TVVCLK;
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 }
8847 }
8848 }
8849 } else { /* for CRT2 */
8850 VCLKIndex = (unsigned char) XGINew_GetReg2(
8851 (pVBInfo->P3ca + 0x02)); /* Port 3cch */
8852 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
8853 if (ModeNo > 0x13) {
8854 VCLKIndex
8855 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
8856 VCLKIndex &= IndexMask;
8857 }
8858 }
8859 }
8860 } else { /* LVDS */
8861 if (ModeNo <= 0x13)
8862 VCLKIndex = CRT2Index;
8863 else
8864 VCLKIndex = CRT2Index;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008865
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308866 if (pVBInfo->IF_DEF_CH7005 == 1) {
8867 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
8868 VCLKIndex &= 0x1f;
8869 tempbx = 0;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008870
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308871 if (pVBInfo->VBInfo & SetPALTV)
8872 tempbx += 2;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008873
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308874 if (pVBInfo->VBInfo & SetCHTVOverScan)
8875 tempbx += 1;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008876
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308877 switch (tempbx) {
8878 case 0:
8879 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
8880 break;
8881 case 1:
8882 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
8883 break;
8884 case 2:
8885 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
8886 break;
8887 case 3:
8888 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
8889 break;
8890 default:
8891 break;
8892 }
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008893
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308894 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
8895 }
8896 } else {
8897 VCLKIndex = VCLKIndex >> 6;
8898 if ((pVBInfo->LCDResInfo == Panel800x600)
8899 || (pVBInfo->LCDResInfo == Panel320x480))
8900 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
8901 else if ((pVBInfo->LCDResInfo == Panel1024x768)
8902 || (pVBInfo->LCDResInfo
8903 == Panel1024x768x75))
8904 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
8905 else
8906 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
8907 }
8908 }
8909 /* VCLKIndex = VCLKIndex&IndexMask; */
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008910
Prashant P. Shah21df8fc2010-09-03 22:12:12 +05308911 return VCLKIndex;
apatard@mandriva.comd7636e02010-05-19 10:44:14 +02008912}
8913