Commit | Line | Data |
---|---|---|
d7636e0b | 1 | |
d7636e0b | 2 | #include <asm/io.h> |
d80aaa01 | 3 | #include <linux/delay.h> |
d7636e0b | 4 | #include <linux/types.h> |
5 | #include <linux/version.h> | |
6 | #include "XGIfb.h" | |
d7636e0b | 7 | |
d7636e0b | 8 | |
9 | #include "vb_def.h" | |
10 | #include "vgatypes.h" | |
11 | #include "vb_struct.h" | |
12 | #include "vb_util.h" | |
13 | #include "vb_table.h" | |
14 | ||
15 | ||
16 | ||
17 | #define IndexMask 0xff | |
18 | #ifndef XGI_MASK_DUAL_CHIP | |
19 | #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */ | |
20 | #endif | |
21 | ||
22 | ||
23 | ||
80adad85 | 24 | unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo); |
82d6eb5b | 25 | unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
21df8fc8 PS |
26 | struct xgi_hw_device_info *HwDeviceExtension, |
27 | struct vb_device_info *pVBInfo); | |
80adad85 | 28 | unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo); |
82d6eb5b | 29 | |
80adad85 BP |
30 | unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo); |
31 | unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo); | |
32 | unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo); | |
82d6eb5b | 33 | unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
21df8fc8 PS |
34 | unsigned short ModeIdIndex, |
35 | unsigned short RefreshRateTableIndex, | |
36 | unsigned short *i, struct vb_device_info *pVBInfo); | |
82d6eb5b | 37 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
21df8fc8 PS |
38 | unsigned short *ModeIdIndex, |
39 | struct vb_device_info *pVBInfo); | |
82d6eb5b BP |
40 | unsigned char XGI_GetLCDInfo(unsigned short ModeNo, |
41 | unsigned short ModeIdIndex, | |
80adad85 | 42 | struct vb_device_info *pVBInfo); |
e4147abe | 43 | unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 44 | unsigned short ModeNo); |
80adad85 | 45 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo); |
21df8fc8 | 46 | unsigned char XGI_GetModePtr(unsigned short ModeNo, |
82d6eb5b | 47 | unsigned short ModeIdIndex, |
80adad85 | 48 | struct vb_device_info *pVBInfo); |
82d6eb5b | 49 | unsigned short XGI_GetOffset(unsigned short ModeNo, |
21df8fc8 PS |
50 | unsigned short ModeIdIndex, |
51 | unsigned short RefreshRateTableIndex, | |
52 | struct xgi_hw_device_info *HwDeviceExtension, | |
53 | struct vb_device_info *pVBInfo); | |
e4147abe | 54 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
21df8fc8 PS |
55 | unsigned short ModeNo, |
56 | unsigned short ModeIdIndex, | |
57 | struct vb_device_info *pVBInfo); | |
82d6eb5b | 58 | unsigned short XGI_GetResInfo(unsigned short ModeNo, |
21df8fc8 PS |
59 | unsigned short ModeIdIndex, |
60 | struct vb_device_info *pVBInfo); | |
82d6eb5b | 61 | unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
21df8fc8 PS |
62 | unsigned short ModeIdIndex, |
63 | struct vb_device_info *pVBInfo); | |
80adad85 | 64 | unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo); |
82d6eb5b | 65 | unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
21df8fc8 PS |
66 | unsigned short ModeIdIndex, |
67 | unsigned short RefreshRateTableIndex, | |
68 | struct xgi_hw_device_info *HwDeviceExtension, | |
69 | struct vb_device_info *pVBInfo); | |
80adad85 BP |
70 | void XGI_VBLongWait(struct vb_device_info *pVBInfo); |
71 | void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo); | |
72 | void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
73 | void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
74 | void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
75 | void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
76 | void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
77 | void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
78 | void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
79 | void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
80 | void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
81 | void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
82 | void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
83 | void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
84 | void XGI_FirePWDEnable(struct vb_device_info *pVBInfo); | |
85 | void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
86 | void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
87 | void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo); | |
88 | void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, struct vb_device_info *pVBInfo); | |
89 | void XGI_EnablePWD(struct vb_device_info *pVBInfo); | |
90 | void XGI_DisablePWD(struct vb_device_info *pVBInfo); | |
91 | void XGI_AutoThreshold(struct vb_device_info *pVBInfo); | |
92 | void XGI_SetTap4Regs(struct vb_device_info *pVBInfo); | |
93 | ||
94 | void XGI_DisplayOn(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo); | |
95 | void XGI_DisplayOff(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo); | |
96 | void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
97 | void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
98 | void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo); | |
99 | void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
100 | void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex, unsigned short ModeNo); | |
101 | void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo, unsigned short RefreshRateTableIndex); | |
102 | void XGI_WaitDisply(struct vb_device_info *pVBInfo); | |
103 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo); | |
104 | void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
105 | void XGI_SetMiscRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo); | |
106 | void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short StandTableIndex, struct vb_device_info *pVBInfo); | |
107 | void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
108 | void XGI_SetGRCRegs(unsigned short StandTableIndex, struct vb_device_info *pVBInfo); | |
109 | void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo); | |
110 | ||
111 | void XGI_SetSync(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
112 | void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension); | |
113 | void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension); | |
114 | void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo, struct vb_device_info *pVBInfo); | |
115 | void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
116 | void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
117 | void XGI_SetCRT1FIFO(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
118 | void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
119 | void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
120 | ||
121 | void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
122 | void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al, unsigned short dh, struct vb_device_info *pVBInfo); | |
123 | /*void XGI_ClearBuffer(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, struct vb_device_info *pVBInfo);*/ | |
124 | void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
125 | void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, | |
21df8fc8 | 126 | struct vb_device_info *pVBInfo); |
80adad85 | 127 | void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); |
8922967e | 128 | unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo); |
80adad85 | 129 | void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
130 | unsigned short RefreshRateTableIndex, |
131 | struct xgi_hw_device_info *HwDeviceExtension, | |
132 | struct vb_device_info *pVBInfo); | |
80adad85 BP |
133 | void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); |
134 | void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
135 | void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
136 | void XGI_GetVBType(struct vb_device_info *pVBInfo); | |
137 | void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
138 | void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
139 | void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
140 | void InitTo330Pointer(unsigned char, struct vb_device_info *pVBInfo); | |
141 | void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, struct vb_device_info *pVBInfo); | |
142 | void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
143 | void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
144 | void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
145 | void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
146 | void XGI_SetDelayComp(struct vb_device_info *pVBInfo); | |
147 | void XGI_SetLCDCap(struct vb_device_info *pVBInfo); | |
148 | void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo); | |
149 | void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo); | |
150 | void SetSpectrum(struct vb_device_info *pVBInfo); | |
151 | void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
152 | void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
153 | void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo); | |
154 | void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
108afbf8 | 155 | void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char* tempcl, |
21df8fc8 | 156 | unsigned char *tempch, struct vb_device_info *pVBInfo); |
80adad85 BP |
157 | unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo); |
158 | void XGI_SetCRT2ModeRegs(unsigned short ModeNo, struct xgi_hw_device_info *, struct vb_device_info *pVBInfo); | |
159 | void XGI_CloseCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo); | |
160 | void XGI_OpenCRTC(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo); | |
161 | void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo); | |
162 | void XGI_UnLockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo); | |
163 | void XGI_LockCRT2(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo); | |
164 | void XGINew_EnableCRT2(struct vb_device_info *pVBInfo); | |
80adad85 BP |
165 | void XGI_LongWait(struct vb_device_info *pVBInfo); |
166 | void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo); | |
108afbf8 | 167 | void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
21df8fc8 | 168 | struct vb_device_info *pVBInfo); |
108afbf8 | 169 | unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
21df8fc8 PS |
170 | unsigned short ModeNo, |
171 | unsigned short ModeIdIndex, | |
172 | struct vb_device_info *pVBInfo); | |
108afbf8 | 173 | void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
80adad85 BP |
174 | unsigned char *di_1, struct vb_device_info *pVBInfo); |
175 | unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo); | |
176 | unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo); | |
177 | struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo); | |
178 | void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo); | |
179 | void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo); | |
180 | unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo); | |
181 | unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo); | |
182 | void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo); | |
183 | void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo); | |
184 | void XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo); | |
185 | unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
186 | void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
187 | void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo); | |
188 | unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo); | |
189 | ||
190 | extern void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVBInfo); | |
d7636e0b | 191 | |
82d6eb5b BP |
192 | /* unsigned short XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */ |
193 | ||
194 | ||
8922967e | 195 | static unsigned short XGINew_MDA_DAC[] = { |
82d6eb5b BP |
196 | 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}; | |
204 | ||
8922967e | 205 | static unsigned short XGINew_CGA_DAC[] = { |
82d6eb5b BP |
206 | 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}; | |
214 | ||
8922967e | 215 | static unsigned short XGINew_EGA_DAC[] = { |
82d6eb5b BP |
216 | 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}; | |
224 | ||
8922967e | 225 | static unsigned short XGINew_VGA_DAC[] = { |
82d6eb5b BP |
226 | 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}; | |
d7636e0b | 236 | |
80adad85 | 237 | void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) |
d7636e0b | 238 | { |
21df8fc8 PS |
239 | 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; | |
245 | ||
246 | /* add for new UNIVGABIOS */ | |
247 | /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */ | |
248 | /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */ | |
249 | ||
250 | 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 | } | |
d7636e0b | 261 | |
21df8fc8 PS |
262 | 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; | |
268 | ||
269 | 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; | |
277 | ||
278 | 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; | |
291 | ||
292 | 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; | |
299 | ||
300 | 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; | |
310 | ||
311 | 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; | |
325 | ||
326 | pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH; | |
327 | pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV; | |
328 | pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table; | |
329 | ||
330 | pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC; | |
331 | pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC; | |
332 | pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL; | |
333 | pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL; | |
334 | ||
335 | /* 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; | |
d7636e0b | 340 | |
21df8fc8 PS |
341 | if ((ChipType == XG21) || (ChipType == XG27)) |
342 | pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList; | |
d7636e0b | 343 | |
21df8fc8 PS |
344 | pVBInfo->XGI_TVDelayList = XGI301TVDelayList; |
345 | pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2; | |
d7636e0b | 346 | |
21df8fc8 | 347 | pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition; |
d7636e0b | 348 | |
21df8fc8 PS |
349 | if (ChipType >= XG20) |
350 | pVBInfo->pXGINew_CR97 = &XG20_CR97; | |
d7636e0b | 351 | |
21df8fc8 PS |
352 | 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; | |
363 | ||
364 | } | |
365 | ||
366 | 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 | } | |
373 | ||
374 | } | |
d7636e0b | 375 | |
e4147abe | 376 | unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
377 | unsigned short ModeNo) |
378 | { | |
51973d7f | 379 | unsigned short ModeIdIndex; |
21df8fc8 PS |
380 | /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */ |
381 | struct vb_device_info VBINF; | |
382 | struct vb_device_info *pVBInfo = &VBINF; | |
383 | pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; | |
384 | pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; | |
385 | pVBInfo->IF_DEF_LVDS = 0; | |
386 | pVBInfo->IF_DEF_CH7005 = 0; | |
387 | pVBInfo->IF_DEF_LCDA = 1; | |
388 | pVBInfo->IF_DEF_CH7017 = 0; | |
389 | pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */ | |
390 | pVBInfo->IF_DEF_VideoCapture = 0; | |
391 | pVBInfo->IF_DEF_ScaleLCD = 0; | |
392 | pVBInfo->IF_DEF_OEMUtil = 0; | |
393 | pVBInfo->IF_DEF_PWD = 0; | |
394 | ||
395 | 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 | } | |
d7636e0b | 409 | |
21df8fc8 PS |
410 | 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; | |
428 | ||
429 | 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 | } | |
d7636e0b | 439 | |
21df8fc8 PS |
440 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
441 | XGI_GetVBType(pVBInfo); | |
d7636e0b | 442 | |
21df8fc8 PS |
443 | 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); | |
453 | ||
454 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ | |
455 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); | |
456 | ||
457 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); | |
458 | ||
459 | XGI_GetVGAType(HwDeviceExtension, pVBInfo); | |
460 | ||
461 | 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); */ | |
467 | ||
468 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { | |
469 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, | |
470 | ModeIdIndex, pVBInfo); | |
471 | ||
472 | 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 | } | |
487 | ||
488 | 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; | |
494 | ||
495 | case VB_CHIP_302: | |
496 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, | |
497 | pVBInfo); /*add for CRT2 */ | |
498 | break; | |
499 | ||
500 | default: | |
501 | break; | |
502 | } | |
503 | } | |
504 | ||
505 | 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; | |
514 | ||
515 | 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 | } | |
524 | ||
525 | pVBInfo->SetFlag = 0; | |
526 | if (pVBInfo->IF_DEF_CH7007 != 1) | |
527 | pVBInfo->VBInfo = DisableCRT2Display; | |
528 | ||
529 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); | |
530 | ||
531 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, | |
532 | pVBInfo); | |
533 | ||
534 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
535 | /* | |
536 | if (HwDeviceExtension->jChipType == XG21) | |
537 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0x80, 0x80); | |
538 | */ | |
539 | } | |
d7636e0b | 540 | |
21df8fc8 PS |
541 | /* |
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); | |
d7636e0b | 551 | |
21df8fc8 PS |
552 | if (temp == 0) |
553 | return (0); | |
d7636e0b | 554 | |
21df8fc8 PS |
555 | XGI_DisplayOff(HwDeviceExtension, pVBInfo) ; |
556 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); | |
557 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
558 | */ | |
d7636e0b | 559 | |
21df8fc8 PS |
560 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
561 | ||
562 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ | |
563 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); | |
564 | } | |
565 | ||
566 | return 1; | |
d7636e0b | 567 | } |
568 | ||
21df8fc8 PS |
569 | void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, |
570 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
571 | struct vb_device_info *pVBInfo) | |
572 | { | |
573 | unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp; | |
574 | ||
575 | unsigned short XGINew_P3cc = pVBInfo->P3cc; | |
576 | ||
577 | /* 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); | |
587 | ||
588 | /* if (pVBInfo->IF_DEF_ExpLink) */ | |
589 | if (HwDeviceExtension->jChipType == XG27) { | |
590 | if (pVBInfo->IF_DEF_LVDS == 0) | |
591 | XGI_SetDefaultVCLK(pVBInfo); | |
592 | } | |
593 | ||
594 | temp = ~ProgrammingCRT2; | |
595 | pVBInfo->SetFlag &= temp; | |
596 | pVBInfo->SelectCRT2Rate = 0; | |
597 | ||
598 | 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 | } | |
605 | ||
606 | 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 | } | |
619 | ||
620 | 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 | } | |
635 | ||
636 | if (HwDeviceExtension->jChipType >= XG21) { | |
637 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38); | |
638 | if (temp & 0xA0) { | |
639 | ||
640 | /* 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); | |
649 | ||
650 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, | |
651 | RefreshRateTableIndex); | |
652 | ||
653 | if (HwDeviceExtension->jChipType == XG27) | |
654 | XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex, | |
655 | ModeNo); | |
656 | else | |
657 | XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex, | |
658 | ModeNo); | |
659 | ||
660 | 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 | } | |
671 | ||
672 | pVBInfo->SetFlag &= (~ProgrammingCRT2); | |
673 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); | |
674 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, | |
675 | RefreshRateTableIndex, pVBInfo); | |
676 | ||
677 | /* XGI_LoadCharacter(); //dif ifdef TVFont */ | |
678 | ||
679 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); | |
680 | /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */ | |
681 | } | |
d7636e0b | 682 | |
108afbf8 | 683 | unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 684 | struct vb_device_info *pVBInfo) |
d7636e0b | 685 | { |
21df8fc8 | 686 | unsigned char index; |
d7636e0b | 687 | |
21df8fc8 PS |
688 | 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 */ | |
d7636e0b | 697 | } |
698 | ||
21df8fc8 PS |
699 | /* |
700 | unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) { | |
701 | return (0); | |
d7636e0b | 702 | } |
703 | */ | |
704 | ||
21df8fc8 PS |
705 | /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) { |
706 | return( 0 ) ; | |
d7636e0b | 707 | } |
708 | */ | |
709 | ||
82d6eb5b | 710 | void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex, |
21df8fc8 | 711 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
d7636e0b | 712 | { |
21df8fc8 | 713 | unsigned char tempah, SRdata; |
d7636e0b | 714 | |
21df8fc8 | 715 | unsigned short i, modeflag; |
d7636e0b | 716 | |
21df8fc8 PS |
717 | if (ModeNo <= 0x13) |
718 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
719 | else | |
720 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
721 | ||
722 | XGINew_SetReg1(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ | |
723 | tempah = pVBInfo->StandTable[StandTableIndex].SR[0]; | |
724 | ||
725 | 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 | } | |
d7636e0b | 734 | |
21df8fc8 PS |
735 | tempah |= 0x20; /* screen off */ |
736 | XGINew_SetReg1(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ | |
d7636e0b | 737 | |
21df8fc8 PS |
738 | 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 | } | |
d7636e0b | 742 | } |
743 | ||
21df8fc8 PS |
744 | void XGI_SetMiscRegs(unsigned short StandTableIndex, |
745 | struct vb_device_info *pVBInfo) | |
d7636e0b | 746 | { |
21df8fc8 | 747 | unsigned char Miscdata; |
d7636e0b | 748 | |
21df8fc8 PS |
749 | 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 | */ | |
d7636e0b | 757 | |
21df8fc8 | 758 | XGINew_SetReg3(pVBInfo->P3c2, Miscdata); /* Set Misc(3c2) */ |
d7636e0b | 759 | } |
760 | ||
e4147abe | 761 | void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 762 | unsigned short StandTableIndex, struct vb_device_info *pVBInfo) |
d7636e0b | 763 | { |
21df8fc8 PS |
764 | unsigned char CRTCdata; |
765 | unsigned short i; | |
d7636e0b | 766 | |
21df8fc8 PS |
767 | CRTCdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); |
768 | CRTCdata &= 0x7f; | |
769 | XGINew_SetReg1(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ | |
d7636e0b | 770 | |
21df8fc8 PS |
771 | 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 | */ | |
d7636e0b | 784 | } |
785 | ||
82d6eb5b | 786 | void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex, |
21df8fc8 PS |
787 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
788 | { | |
789 | unsigned char ARdata; | |
790 | unsigned short i, modeflag; | |
d7636e0b | 791 | |
21df8fc8 PS |
792 | if (ModeNo <= 0x13) |
793 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
794 | else | |
795 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
796 | ||
797 | 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 | } | |
813 | ||
814 | XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */ | |
815 | XGINew_SetReg3(pVBInfo->P3c0, i); /* set index */ | |
816 | XGINew_SetReg3(pVBInfo->P3c0, ARdata); /* set data */ | |
817 | } | |
d7636e0b | 818 | |
21df8fc8 PS |
819 | 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); | |
824 | } | |
825 | ||
826 | void XGI_SetGRCRegs(unsigned short StandTableIndex, | |
827 | struct vb_device_info *pVBInfo) | |
d7636e0b | 828 | { |
21df8fc8 PS |
829 | unsigned char GRdata; |
830 | unsigned short i; | |
d7636e0b | 831 | |
21df8fc8 PS |
832 | 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 | } | |
d7636e0b | 836 | |
21df8fc8 PS |
837 | 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 | } | |
d7636e0b | 842 | } |
843 | ||
80adad85 | 844 | void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
d7636e0b | 845 | { |
21df8fc8 | 846 | unsigned short i; |
d7636e0b | 847 | |
21df8fc8 PS |
848 | for (i = 0x0A; i <= 0x0E; i++) |
849 | XGINew_SetReg1(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ | |
d7636e0b | 850 | } |
851 | ||
80adad85 | 852 | unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
d7636e0b | 853 | { |
854 | ||
21df8fc8 PS |
855 | 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); | |
d7636e0b | 858 | |
21df8fc8 PS |
859 | 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); | |
d7636e0b | 862 | |
21df8fc8 PS |
863 | XGINew_SetRegAND(pVBInfo->P3c4, 0x31, ~0x30); |
864 | return 0; | |
d7636e0b | 865 | } |
866 | ||
e4147abe | 867 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
21df8fc8 PS |
868 | unsigned short ModeNo, unsigned short ModeIdIndex, |
869 | struct vb_device_info *pVBInfo) | |
870 | { | |
871 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, | |
872 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, | |
873 | 0x01, 0x01 }; | |
d7636e0b | 874 | |
21df8fc8 | 875 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
d7636e0b | 876 | |
21df8fc8 PS |
877 | if (ModeNo <= 0x13) |
878 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
879 | else | |
880 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 881 | |
21df8fc8 PS |
882 | if (pVBInfo->IF_DEF_CH7005 == 1) { |
883 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
884 | if (modeflag & HalfDCLK) | |
885 | return 0; | |
886 | } | |
887 | } | |
d7636e0b | 888 | |
21df8fc8 PS |
889 | if (ModeNo < 0x14) |
890 | return 0xFFFF; | |
891 | ||
892 | index = XGINew_GetReg1(pVBInfo->P3d4, 0x33); | |
893 | index = index >> pVBInfo->SelectCRT2Rate; | |
894 | index &= 0x0F; | |
895 | ||
896 | if (pVBInfo->LCDInfo & LCDNonExpanding) | |
897 | index = 0; | |
898 | ||
899 | if (index > 0) | |
900 | index--; | |
901 | ||
902 | if (pVBInfo->SetFlag & ProgrammingCRT2) { | |
903 | if (pVBInfo->IF_DEF_CH7005 == 1) { | |
904 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
905 | index = 0; | |
906 | } | |
907 | ||
908 | 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]; | |
920 | ||
921 | if (index > temp) | |
922 | index = temp; | |
923 | } else { | |
924 | index = 0; | |
925 | } | |
926 | } | |
927 | } | |
928 | ||
929 | 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 | } | |
954 | ||
955 | 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--; | |
967 | ||
968 | } 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)); */ | |
984 | } | |
985 | ||
986 | unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, | |
987 | unsigned short ModeIdIndex, | |
988 | unsigned short RefreshRateTableIndex, unsigned short *i, | |
989 | struct vb_device_info *pVBInfo) | |
d7636e0b | 990 | { |
21df8fc8 PS |
991 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
992 | ||
993 | if (ModeNo <= 0x13) | |
994 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */ | |
995 | else | |
996 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
997 | ||
998 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
999 | tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID; | |
1000 | tempax = 0; | |
1001 | ||
1002 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
1003 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { | |
1004 | tempax |= SupportRAMDAC2; | |
1005 | ||
1006 | if (pVBInfo->VBType & VB_XGI301C) | |
1007 | tempax |= SupportCRT2in301C; | |
1008 | } | |
1009 | ||
1010 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */ | |
1011 | tempax |= SupportLCD; | |
1012 | ||
1013 | 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 | } | |
1024 | ||
1025 | 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; | |
1032 | ||
1033 | if (resinfo == 3) | |
1034 | return 0; | |
1035 | ||
1036 | if (resinfo > 7) | |
1037 | return 0; | |
1038 | } | |
1039 | } else { | |
1040 | tempax |= SupportHiVisionTV; | |
1041 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
1042 | if (resinfo == 4) | |
1043 | return 0; | |
1044 | ||
1045 | if (resinfo == 3) { | |
1046 | if (pVBInfo->SetFlag | |
1047 | & TVSimuMode) | |
1048 | return 0; | |
1049 | } | |
1050 | ||
1051 | if (resinfo > 7) | |
1052 | return 0; | |
1053 | } | |
1054 | } | |
1055 | } else { | |
1056 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
1057 | | SetCRT2ToSVIDEO | SetCRT2ToSCART | |
1058 | | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) { | |
1059 | tempax |= SupportTV; | |
1060 | ||
1061 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | |
1062 | | VB_XGI301LV | VB_XGI302LV | |
1063 | | VB_XGI301C)) { | |
1064 | tempax |= SupportTV1024; | |
1065 | } | |
1066 | ||
1067 | 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 | } | |
1085 | ||
1086 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { | |
1087 | tempax |= SupportLCD; | |
1088 | ||
1089 | if (resinfo > 0x08) | |
1090 | return 0; /* 1024x768 */ | |
1091 | ||
1092 | if (pVBInfo->LCDResInfo < Panel1024x768) { | |
1093 | if (resinfo > 0x07) | |
1094 | return 0; /* 800x600 */ | |
1095 | ||
1096 | if (resinfo == 0x04) | |
1097 | return 0; /* 512x384 */ | |
1098 | } | |
1099 | } | |
1100 | } | |
1101 | ||
1102 | 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; | |
1108 | ||
1109 | if ((*i) == 0) | |
1110 | break; | |
1111 | } | |
1112 | ||
1113 | 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 | } | |
d7636e0b | 1121 | |
21df8fc8 PS |
1122 | if (infoflag & tempax) |
1123 | return 1; | |
1124 | } | |
1125 | return 1; | |
d7636e0b | 1126 | } |
1127 | ||
21df8fc8 PS |
1128 | void XGI_SetSync(unsigned short RefreshRateTableIndex, |
1129 | struct vb_device_info *pVBInfo) | |
1130 | { | |
1131 | unsigned short sync, temp; | |
1132 | ||
1133 | 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) */ | |
1138 | } | |
d7636e0b | 1139 | |
82d6eb5b | 1140 | void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
1141 | unsigned short RefreshRateTableIndex, |
1142 | struct vb_device_info *pVBInfo, | |
1143 | struct xgi_hw_device_info *HwDeviceExtension) | |
d7636e0b | 1144 | { |
21df8fc8 PS |
1145 | unsigned char index, data; |
1146 | unsigned short i; | |
d7636e0b | 1147 | |
21df8fc8 PS |
1148 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */ |
1149 | index = index & IndexMask; | |
d7636e0b | 1150 | |
21df8fc8 PS |
1151 | data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); |
1152 | data &= 0x7F; | |
1153 | XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ | |
d7636e0b | 1154 | |
21df8fc8 PS |
1155 | for (i = 0; i < 8; i++) |
1156 | pVBInfo->TimingH[0].data[i] | |
1157 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i]; | |
d7636e0b | 1158 | |
21df8fc8 PS |
1159 | for (i = 0; i < 7; i++) |
1160 | pVBInfo->TimingV[0].data[i] | |
1161 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8]; | |
d7636e0b | 1162 | |
21df8fc8 | 1163 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
d7636e0b | 1164 | |
21df8fc8 | 1165 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
d7636e0b | 1166 | |
21df8fc8 PS |
1167 | if (pVBInfo->ModeType > 0x03) |
1168 | XGINew_SetReg1(pVBInfo->P3d4, 0x14, 0x4F); | |
1169 | } | |
d7636e0b | 1170 | |
21df8fc8 PS |
1171 | void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
1172 | struct xgi_hw_device_info *HwDeviceExtension) | |
1173 | { | |
1174 | unsigned char data, data1, pushax; | |
1175 | unsigned short i, j; | |
d7636e0b | 1176 | |
21df8fc8 PS |
1177 | /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */ |
1178 | /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */ | |
1179 | /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ | |
d7636e0b | 1180 | |
21df8fc8 PS |
1181 | data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */ |
1182 | data &= 0x7F; | |
1183 | XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); | |
d7636e0b | 1184 | |
21df8fc8 PS |
1185 | data = pVBInfo->TimingH[0].data[0]; |
1186 | XGINew_SetReg1(pVBInfo->P3d4, 0, data); | |
d7636e0b | 1187 | |
21df8fc8 PS |
1188 | for (i = 0x01; i <= 0x04; i++) { |
1189 | data = pVBInfo->TimingH[0].data[i]; | |
1190 | XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 1), data); | |
1191 | } | |
d7636e0b | 1192 | |
21df8fc8 PS |
1193 | for (i = 0x05; i <= 0x06; i++) { |
1194 | data = pVBInfo->TimingH[0].data[i]; | |
1195 | XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i + 6), data); | |
1196 | } | |
d7636e0b | 1197 | |
21df8fc8 PS |
1198 | 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); | |
1204 | ||
1205 | 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 | } | |
d7636e0b | 1232 | } |
1233 | ||
21df8fc8 PS |
1234 | void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo, |
1235 | struct vb_device_info *pVBInfo) | |
1236 | { | |
1237 | unsigned char data; | |
1238 | unsigned short i, j; | |
1239 | ||
1240 | /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */ | |
1241 | /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */ | |
1242 | /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ | |
1243 | ||
1244 | for (i = 0x00; i <= 0x01; i++) { | |
1245 | data = pVBInfo->TimingV[0].data[i]; | |
1246 | XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 6), data); | |
1247 | } | |
1248 | ||
1249 | for (i = 0x02; i <= 0x03; i++) { | |
1250 | data = pVBInfo->TimingV[0].data[i]; | |
1251 | XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); | |
1252 | } | |
1253 | ||
1254 | for (i = 0x04; i <= 0x05; i++) { | |
1255 | data = pVBInfo->TimingV[0].data[i]; | |
1256 | XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); | |
1257 | } | |
1258 | ||
1259 | 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); | |
1265 | ||
1266 | data = pVBInfo->TimingV[0].data[6]; | |
1267 | data &= 0x80; | |
1268 | data = data >> 2; | |
1269 | ||
1270 | if (ModeNo <= 0x13) | |
1271 | i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
1272 | else | |
1273 | i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1274 | ||
1275 | i &= DoubleScanMode; | |
1276 | if (i) | |
1277 | data |= 0x80; | |
1278 | ||
1279 | j = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x09); | |
1280 | j &= 0x5F; | |
1281 | data |= j; | |
1282 | XGINew_SetReg1(pVBInfo->P3d4, 0x09, data); | |
1283 | } | |
d7636e0b | 1284 | |
1285 | /* --------------------------------------------------------------------- */ | |
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 | /* --------------------------------------------------------------------- */ | |
82d6eb5b | 1291 | void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
1292 | unsigned short RefreshRateTableIndex, |
1293 | struct vb_device_info *pVBInfo) | |
1294 | { | |
1295 | unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; | |
1296 | unsigned short Temp1, Temp2, Temp3; | |
1297 | ||
1298 | 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); | |
1312 | ||
1313 | 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] */ | |
1323 | ||
1324 | 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] */ | |
1329 | ||
1330 | 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 */ | |
1351 | ||
1352 | 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] */ | |
1357 | ||
1358 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ | |
1359 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ | |
1360 | ||
1361 | 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] */ | |
1365 | ||
1366 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ | |
1367 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ | |
1368 | ||
1369 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ | |
1370 | if (Tempax < Tempcx) /* HRE < HRS */ | |
1371 | Temp2 |= 0x40; /* Temp2 + 0x40 */ | |
1372 | ||
1373 | 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); | |
1380 | ||
1381 | 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 */ | |
1391 | ||
1392 | 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] */ | |
1403 | ||
1404 | 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] */ | |
1412 | ||
1413 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ | |
1414 | if (Tempax < Temp3) /* VRE < VRS */ | |
1415 | Temp2 |= 0x20; /* VRE + 0x20 */ | |
1416 | ||
1417 | 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 | } | |
d7636e0b | 1427 | } |
1428 | ||
82d6eb5b | 1429 | void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
1430 | unsigned short RefreshRateTableIndex, |
1431 | struct vb_device_info *pVBInfo) | |
d7636e0b | 1432 | { |
82d6eb5b | 1433 | unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
d7636e0b | 1434 | |
21df8fc8 PS |
1435 | 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); | |
1449 | ||
1450 | 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] */ | |
1460 | ||
1461 | 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 */ | |
1478 | ||
1479 | 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] */ | |
1482 | ||
1483 | 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] */ | |
1486 | ||
1487 | 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] */ | |
1491 | ||
1492 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ | |
1493 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ | |
1494 | ||
1495 | 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]*/ | |
1499 | ||
1500 | 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); | |
1506 | ||
1507 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */ | |
1508 | XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */ | |
1509 | ||
1510 | 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] */ | |
1521 | ||
1522 | 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] */ | |
1531 | ||
1532 | if (Tempbx <= Tempcx) /* VRE <= VRS */ | |
1533 | Tempbx |= 0x20; /* VRE + 0x20 */ | |
1534 | ||
1535 | 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 | } | |
d7636e0b | 1540 | } |
1541 | ||
d7636e0b | 1542 | /* --------------------------------------------------------------------- */ |
1543 | /* Function : XGI_SetXG21LCD */ | |
1544 | /* Input : */ | |
1545 | /* Output : FCLK duty cycle, FCLK delay compensation */ | |
1546 | /* Description : All values set zero */ | |
1547 | /* --------------------------------------------------------------------- */ | |
80adad85 | 1548 | void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, |
21df8fc8 | 1549 | unsigned short RefreshRateTableIndex, unsigned short ModeNo) |
d7636e0b | 1550 | { |
82d6eb5b BP |
1551 | unsigned short Data, Temp, b3CC; |
1552 | unsigned short XGI_P3cc; | |
d7636e0b | 1553 | |
21df8fc8 PS |
1554 | XGI_P3cc = pVBInfo->P3cc; |
1555 | ||
1556 | 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 | } | |
d7636e0b | 1566 | |
21df8fc8 | 1567 | Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); |
d7636e0b | 1568 | |
21df8fc8 PS |
1569 | if (Temp & 0x01) { |
1570 | XGINew_SetRegOR(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */ | |
1571 | XGINew_SetRegOR(pVBInfo->P3c4, 0x09, 0x40); | |
1572 | } | |
d7636e0b | 1573 | |
21df8fc8 PS |
1574 | XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
1575 | ||
1576 | XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20); | |
1577 | XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80); | |
1578 | ||
1579 | 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 | } | |
1592 | } | |
1593 | ||
1594 | void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, | |
1595 | unsigned short RefreshRateTableIndex, unsigned short ModeNo) | |
1596 | { | |
1597 | unsigned short Data, Temp, b3CC; | |
1598 | unsigned short XGI_P3cc; | |
1599 | ||
1600 | XGI_P3cc = pVBInfo->P3cc; | |
1601 | ||
1602 | 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); | |
1606 | ||
1607 | 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 | } | |
1612 | ||
1613 | 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 | } | |
1619 | ||
1620 | XGI_SetXG27FPBits(pVBInfo); | |
1621 | ||
1622 | XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ | |
1623 | ||
1624 | XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ | |
1625 | XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ | |
1626 | ||
1627 | 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 | } | |
1640 | } | |
d7636e0b | 1641 | |
1642 | /* --------------------------------------------------------------------- */ | |
21df8fc8 | 1643 | /* Function : XGI_UpdateXG21CRTC */ |
d7636e0b | 1644 | /* Input : */ |
21df8fc8 PS |
1645 | /* Output : CRT1 CRTC */ |
1646 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ | |
d7636e0b | 1647 | /* --------------------------------------------------------------------- */ |
21df8fc8 PS |
1648 | void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo, |
1649 | unsigned short RefreshRateTableIndex) | |
1650 | { | |
1651 | int i, index = -1; | |
1652 | ||
1653 | 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 | } | |
1675 | ||
1676 | 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 | } | |
1686 | } | |
1687 | ||
e4147abe | 1688 | void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
1689 | unsigned short ModeNo, unsigned short ModeIdIndex, |
1690 | unsigned short RefreshRateTableIndex, | |
1691 | struct vb_device_info *pVBInfo) | |
d7636e0b | 1692 | { |
82d6eb5b | 1693 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
d7636e0b | 1694 | |
21df8fc8 | 1695 | unsigned char data; |
d7636e0b | 1696 | |
21df8fc8 | 1697 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
d7636e0b | 1698 | |
21df8fc8 PS |
1699 | 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 | } | |
d7636e0b | 1708 | |
21df8fc8 PS |
1709 | if (modeflag & HalfDCLK) |
1710 | tempax = tempax >> 1; | |
d7636e0b | 1711 | |
21df8fc8 PS |
1712 | if (ModeNo > 0x13) { |
1713 | if (modeflag & HalfDCLK) | |
1714 | tempax = tempax << 1; | |
d7636e0b | 1715 | |
21df8fc8 | 1716 | temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
d7636e0b | 1717 | |
21df8fc8 PS |
1718 | if (temp & InterlaceMode) |
1719 | tempbx = tempbx >> 1; | |
d7636e0b | 1720 | |
21df8fc8 PS |
1721 | if (modeflag & DoubleScanMode) |
1722 | tempbx = tempbx << 1; | |
1723 | } | |
d7636e0b | 1724 | |
21df8fc8 | 1725 | tempcx = 8; |
d7636e0b | 1726 | |
21df8fc8 PS |
1727 | /* if (!(modeflag & Charx8Dot)) */ |
1728 | /* tempcx = 9; */ | |
d7636e0b | 1729 | |
21df8fc8 PS |
1730 | 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; | |
d7636e0b | 1744 | |
21df8fc8 PS |
1745 | if (tempbx & 0x01) |
1746 | tempax |= 0x02; | |
d7636e0b | 1747 | |
21df8fc8 PS |
1748 | if (tempbx & 0x02) |
1749 | tempax |= 0x40; | |
d7636e0b | 1750 | |
21df8fc8 PS |
1751 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
1752 | data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x07); | |
1753 | data &= 0xFF; | |
1754 | tempax = 0; | |
d7636e0b | 1755 | |
21df8fc8 PS |
1756 | if (tempbx & 0x04) |
1757 | tempax |= 0x02; | |
d7636e0b | 1758 | |
21df8fc8 PS |
1759 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
1760 | XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp); | |
d7636e0b | 1761 | } |
1762 | ||
82d6eb5b | 1763 | unsigned short XGI_GetResInfo(unsigned short ModeNo, |
21df8fc8 | 1764 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
d7636e0b | 1765 | { |
82d6eb5b | 1766 | unsigned short resindex; |
d7636e0b | 1767 | |
21df8fc8 PS |
1768 | 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; | |
1773 | } | |
1774 | ||
1775 | void 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) | |
1779 | { | |
1780 | unsigned short temp, ah, al, temp2, i, DisplayUnit; | |
1781 | ||
1782 | /* GetOffset */ | |
1783 | temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; | |
1784 | temp = temp >> 8; | |
1785 | temp = pVBInfo->ScreenOffset[temp]; | |
1786 | ||
1787 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
1788 | temp2 &= InterlaceMode; | |
1789 | ||
1790 | if (temp2) | |
1791 | temp = temp << 1; | |
1792 | ||
1793 | temp2 = pVBInfo->ModeType - ModeEGA; | |
1794 | ||
1795 | 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 | } | |
d7636e0b | 1817 | |
21df8fc8 PS |
1818 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
1819 | temp = temp * temp2 + temp2 / 2; | |
1820 | else | |
1821 | temp *= temp2; | |
1822 | ||
1823 | /* 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); | |
1832 | ||
1833 | temp = (unsigned char) temp2; | |
1834 | temp &= 0xFF; /* al */ | |
1835 | XGINew_SetReg1(pVBInfo->P3d4, 0x13, temp); | |
1836 | ||
1837 | /* SetDisplayUnit */ | |
1838 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
1839 | temp2 &= InterlaceMode; | |
1840 | if (temp2) | |
1841 | DisplayUnit >>= 1; | |
1842 | ||
1843 | DisplayUnit = DisplayUnit << 5; | |
1844 | ah = (DisplayUnit & 0xff00) >> 8; | |
1845 | al = DisplayUnit & 0x00ff; | |
1846 | if (al == 0) | |
1847 | ah += 1; | |
1848 | else | |
1849 | ah += 2; | |
d7636e0b | 1850 | |
21df8fc8 PS |
1851 | if (HwDeviceExtension->jChipType >= XG20) |
1852 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) | |
1853 | ah -= 1; | |
d7636e0b | 1854 | |
21df8fc8 PS |
1855 | XGINew_SetReg1(pVBInfo->P3c4, 0x10, ah); |
1856 | } | |
d7636e0b | 1857 | |
82d6eb5b | 1858 | void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
1859 | struct xgi_hw_device_info *HwDeviceExtension, |
1860 | unsigned short RefreshRateTableIndex, | |
1861 | struct vb_device_info *pVBInfo) | |
d7636e0b | 1862 | { |
108afbf8 | 1863 | unsigned char index, data; |
21df8fc8 PS |
1864 | unsigned short vclkindex; |
1865 | ||
1866 | 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 | } | |
d7636e0b | 1898 | |
21df8fc8 PS |
1899 | 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 | } | |
1913 | } | |
d7636e0b | 1914 | |
82d6eb5b | 1915 | void XGI_SetCRT1FIFO(unsigned short ModeNo, |
21df8fc8 PS |
1916 | struct xgi_hw_device_info *HwDeviceExtension, |
1917 | struct vb_device_info *pVBInfo) | |
1918 | { | |
1919 | unsigned short data; | |
1920 | ||
1921 | data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D); | |
1922 | data &= 0xfe; | |
1923 | XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ | |
1924 | ||
1925 | 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 | } | |
d7636e0b | 1946 | |
21df8fc8 PS |
1947 | if (HwDeviceExtension->jChipType == XG21) |
1948 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ | |
1949 | } | |
d7636e0b | 1950 | |
e4147abe | 1951 | void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
1952 | unsigned short ModeNo, unsigned short ModeIdIndex, |
1953 | unsigned short RefreshRateTableIndex, | |
1954 | struct vb_device_info *pVBInfo) | |
1955 | { | |
1956 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, | |
1957 | xres; | |
d7636e0b | 1958 | |
21df8fc8 PS |
1959 | 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 */ | |
d7636e0b | 1965 | |
21df8fc8 PS |
1966 | if (XGINew_GetReg1(pVBInfo->P3d4, 0x31) & 0x01) |
1967 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); | |
d7636e0b | 1968 | |
21df8fc8 PS |
1969 | if (ModeNo > 0x13) |
1970 | data = infoflag; | |
1971 | else | |
1972 | data = 0; | |
d7636e0b | 1973 | |
21df8fc8 | 1974 | data2 = 0; |
d7636e0b | 1975 | |
21df8fc8 PS |
1976 | 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 | } | |
d7636e0b | 1984 | |
21df8fc8 | 1985 | data &= InterlaceMode; |
d7636e0b | 1986 | |
21df8fc8 PS |
1987 | if (data) |
1988 | data2 |= 0x20; | |
d7636e0b | 1989 | |
21df8fc8 PS |
1990 | 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 */ | |
1997 | ||
1998 | data = 0x0000; | |
1999 | if (infoflag & InterlaceMode) { | |
2000 | if (xres == 1024) | |
2001 | data = 0x0035; | |
2002 | else if (xres == 1280) | |
2003 | data = 0x0048; | |
2004 | } | |
d7636e0b | 2005 | |
21df8fc8 PS |
2006 | data2 = data & 0x00FF; |
2007 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFF, data2); | |
2008 | data2 = (data & 0xFF00) >> 8; | |
2009 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFC, data2); | |
d7636e0b | 2010 | |
21df8fc8 PS |
2011 | if (modeflag & HalfDCLK) |
2012 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xF7, 0x08); | |
2013 | ||
2014 | data2 = 0; | |
2015 | ||
2016 | if (modeflag & LineCompareOff) | |
2017 | data2 |= 0x08; | |
2018 | ||
2019 | if (ModeNo > 0x13) { | |
2020 | if (pVBInfo->ModeType == ModeEGA) | |
2021 | data2 |= 0x40; | |
2022 | } | |
2023 | ||
2024 | 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); | |
2032 | ||
2033 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, | |
2034 | pVBInfo); | |
2035 | ||
2036 | /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */ | |
2037 | /* if (XGINew_IF_DEF_NEW_LOWRES) */ | |
2038 | /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); //030305 fix lowresolution bug */ | |
2039 | ||
2040 | data = XGINew_GetReg1(pVBInfo->P3d4, 0x31); | |
2041 | ||
2042 | 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 | } | |
d7636e0b | 2063 | |
d7636e0b | 2064 | } |
2065 | ||
21df8fc8 PS |
2066 | void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
2067 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, | |
2068 | struct vb_device_info *pVBInfo) | |
d7636e0b | 2069 | { |
21df8fc8 PS |
2070 | unsigned short data, data2 = 0; |
2071 | short VCLK; | |
d7636e0b | 2072 | |
21df8fc8 | 2073 | unsigned char index; |
d7636e0b | 2074 | |
21df8fc8 PS |
2075 | 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 | } | |
d7636e0b | 2082 | |
21df8fc8 PS |
2083 | data = XGINew_GetReg1(pVBInfo->P3c4, 0x32); |
2084 | data &= 0xf3; | |
2085 | if (VCLK >= 200) | |
2086 | data |= 0x0c; /* VCLK > 200 */ | |
d7636e0b | 2087 | |
21df8fc8 PS |
2088 | if (HwDeviceExtension->jChipType >= XG20) |
2089 | data &= ~0x04; /* 2 pixel mode */ | |
d7636e0b | 2090 | |
21df8fc8 | 2091 | XGINew_SetReg1(pVBInfo->P3c4, 0x32, data); |
d7636e0b | 2092 | |
21df8fc8 PS |
2093 | 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 | } | |
d7636e0b | 2100 | |
21df8fc8 PS |
2101 | /* 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; | |
2112 | ||
2113 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x07, 0xFC, data2); | |
2114 | if (HwDeviceExtension->jChipType >= XG27) | |
2115 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); | |
d7636e0b | 2116 | |
d7636e0b | 2117 | } |
2118 | ||
2119 | ||
21df8fc8 PS |
2120 | /* |
2121 | void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) | |
2122 | { | |
2123 | unsigned short modeflag; | |
d7636e0b | 2124 | |
21df8fc8 PS |
2125 | if (ModeNo > 0x13) |
2126 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
2127 | else | |
2128 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
2129 | ||
2130 | 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); | |
2149 | } | |
2150 | */ | |
d7636e0b | 2151 | |
21df8fc8 PS |
2152 | void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
2153 | struct vb_device_info *pVBInfo) | |
2154 | { | |
2155 | unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al, | |
2156 | ah, dh, *table = NULL; | |
d7636e0b | 2157 | |
21df8fc8 PS |
2158 | if (ModeNo <= 0x13) |
2159 | data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
2160 | else | |
2161 | data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
2162 | ||
2163 | data &= DACInfoFlag; | |
2164 | time = 64; | |
2165 | ||
2166 | 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 | } | |
d7636e0b | 2176 | |
21df8fc8 PS |
2177 | if (time == 256) |
2178 | j = 16; | |
2179 | else | |
2180 | j = time; | |
d7636e0b | 2181 | |
21df8fc8 PS |
2182 | XGINew_SetReg3(pVBInfo->P3c6, 0xFF); |
2183 | XGINew_SetReg3(pVBInfo->P3c8, 0x00); | |
d7636e0b | 2184 | |
21df8fc8 PS |
2185 | for (i = 0; i < j; i++) { |
2186 | data = table[i]; | |
d7636e0b | 2187 | |
21df8fc8 PS |
2188 | for (k = 0; k < 3; k++) { |
2189 | data2 = 0; | |
d7636e0b | 2190 | |
21df8fc8 PS |
2191 | if (data & 0x01) |
2192 | data2 = 0x2A; | |
d7636e0b | 2193 | |
21df8fc8 PS |
2194 | if (data & 0x02) |
2195 | data2 += 0x15; | |
d7636e0b | 2196 | |
21df8fc8 PS |
2197 | XGINew_SetReg3(pVBInfo->P3c9, data2); |
2198 | data = data >> 2; | |
2199 | } | |
2200 | } | |
d7636e0b | 2201 | |
21df8fc8 PS |
2202 | if (time == 256) { |
2203 | for (i = 16; i < 32; i++) { | |
2204 | data = table[i]; | |
2205 | ||
2206 | for (k = 0; k < 3; k++) | |
2207 | XGINew_SetReg3(pVBInfo->P3c9, data); | |
2208 | } | |
2209 | ||
2210 | si = 32; | |
2211 | ||
2212 | for (m = 0; m < 9; m++) { | |
2213 | di = si; | |
2214 | bx = si + 0x04; | |
2215 | dl = 0; | |
2216 | ||
2217 | 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 | } | |
2225 | ||
2226 | si -= 2; | |
2227 | ||
2228 | 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 | } | |
2235 | ||
2236 | dl++; | |
2237 | } | |
2238 | ||
2239 | si += 5; | |
2240 | } | |
2241 | } | |
2242 | } | |
d7636e0b | 2243 | |
21df8fc8 PS |
2244 | void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al, |
2245 | unsigned short dh, struct vb_device_info *pVBInfo) | |
2246 | { | |
2247 | unsigned short temp, bh, bl; | |
d7636e0b | 2248 | |
21df8fc8 PS |
2249 | bh = ah; |
2250 | bl = al; | |
d7636e0b | 2251 | |
21df8fc8 PS |
2252 | 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); | |
2269 | } | |
d7636e0b | 2270 | |
21df8fc8 PS |
2271 | void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
2272 | struct xgi_hw_device_info *HwDeviceExtension, | |
2273 | struct vb_device_info *pVBInfo) | |
2274 | { | |
2275 | unsigned short RefreshRateTableIndex; | |
2276 | /* unsigned short temp ; */ | |
d7636e0b | 2277 | |
21df8fc8 | 2278 | /* pVBInfo->SelectCRT2Rate = 0; */ |
d7636e0b | 2279 | |
21df8fc8 PS |
2280 | 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); | |
2289 | } | |
d7636e0b | 2290 | |
21df8fc8 PS |
2291 | void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
2292 | struct vb_device_info *pVBInfo) | |
2293 | { | |
2294 | unsigned short resindex, xres, yres, modeflag; | |
d7636e0b | 2295 | |
21df8fc8 PS |
2296 | 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 */ | |
d7636e0b | 2300 | |
21df8fc8 PS |
2301 | /* if (ModeNo > 0x13) */ |
2302 | /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */ | |
2303 | /* else */ | |
2304 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */ | |
d7636e0b | 2305 | |
21df8fc8 PS |
2306 | 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 */ | |
d7636e0b | 2310 | |
21df8fc8 | 2311 | /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */ |
d7636e0b | 2312 | |
21df8fc8 PS |
2313 | 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; | |
d7636e0b | 2323 | |
21df8fc8 PS |
2324 | if (modeflag & DoubleScanMode) |
2325 | yres = yres << 1; | |
2326 | } | |
2327 | /* if (modeflag & Charx8Dot) */ | |
2328 | /* { */ | |
d7636e0b | 2329 | |
21df8fc8 PS |
2330 | if (xres == 720) |
2331 | xres = 640; | |
d7636e0b | 2332 | |
21df8fc8 PS |
2333 | /* } */ |
2334 | pVBInfo->VGAHDE = xres; | |
2335 | pVBInfo->HDE = xres; | |
2336 | pVBInfo->VGAVDE = yres; | |
2337 | pVBInfo->VDE = yres; | |
2338 | } | |
d7636e0b | 2339 | |
21df8fc8 PS |
2340 | void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
2341 | unsigned short RefreshRateTableIndex, | |
2342 | struct vb_device_info *pVBInfo) | |
2343 | { | |
2344 | unsigned short tempbx; | |
2345 | struct XGI330_LVDSDataStruct *LCDPtr = NULL; | |
2346 | struct XGI330_CHTVDataStruct *TVPtr = NULL; | |
d7636e0b | 2347 | |
21df8fc8 | 2348 | tempbx = 2; |
d7636e0b | 2349 | |
21df8fc8 PS |
2350 | 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 | } | |
d7636e0b | 2370 | |
21df8fc8 PS |
2371 | 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 | } | |
2393 | } | |
d7636e0b | 2394 | |
21df8fc8 PS |
2395 | void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
2396 | unsigned short RefreshRateTableIndex, | |
2397 | struct xgi_hw_device_info *HwDeviceExtension, | |
2398 | struct vb_device_info *pVBInfo) | |
2399 | { | |
2400 | 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; | |
2407 | ||
2408 | if (ModeNo <= 0x13) | |
2409 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
2410 | else | |
2411 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; | |
2412 | ||
2413 | index = index & IndexMask; | |
2414 | ||
2415 | if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1) | |
2416 | && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) { | |
2417 | tempbx = 0; | |
2418 | ||
2419 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
2420 | LCDPtr | |
2421 | = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr( | |
2422 | tempbx, ModeNo, | |
2423 | ModeIdIndex, | |
2424 | RefreshRateTableIndex, | |
2425 | pVBInfo); | |
2426 | ||
2427 | for (i = 0; i < 8; i++) | |
2428 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; | |
2429 | } | |
2430 | ||
2431 | 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); | |
2440 | ||
2441 | for (i = 0; i < 8; i++) | |
2442 | pVBInfo->TimingH[0].data[i] | |
2443 | = CH7007TV_TimingHPtr[0].data[i]; | |
2444 | } | |
2445 | } | |
2446 | ||
2447 | /* 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 | */ | |
2452 | ||
2453 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); | |
2454 | ||
2455 | 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 | } | |
2461 | ||
2462 | tempbx = 1; | |
2463 | ||
2464 | 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 | } | |
2474 | ||
2475 | 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); | |
2484 | ||
2485 | 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 | */ | |
2495 | ||
2496 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); | |
2497 | ||
2498 | 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]); | |
2505 | ||
2506 | } | |
2507 | } | |
2508 | } | |
d7636e0b | 2509 | |
21df8fc8 PS |
2510 | void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
2511 | unsigned short RefreshRateTableIndex, | |
2512 | struct vb_device_info *pVBInfo) | |
2513 | { | |
2514 | 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; | |
d7636e0b | 2518 | |
21df8fc8 PS |
2519 | if (ModeNo > 0x13) |
2520 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
2521 | else | |
2522 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
2523 | ||
2524 | 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 | } | |
2537 | ||
2538 | 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 | } | |
2557 | ||
2558 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); | |
2559 | push1 = tempbx; | |
2560 | push2 = tempax; | |
2561 | ||
2562 | /* 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 | } | |
2580 | ||
2581 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { | |
2582 | pVBInfo->HDE = tempax; | |
2583 | pVBInfo->VDE = tempbx; | |
2584 | pVBInfo->VGAHDE = tempax; | |
2585 | pVBInfo->VGAVDE = tempbx; | |
2586 | } | |
2587 | ||
2588 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) | |
2589 | && (pVBInfo->LCDInfo & EnableScalingLCD)) { | |
2590 | tempax = pVBInfo->HDE; | |
2591 | tempbx = pVBInfo->VDE; | |
2592 | } | |
2593 | ||
2594 | tempax = pVBInfo->HT; | |
2595 | ||
2596 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2597 | tempbx = LCDPtr1->LCDHDES; | |
2598 | else | |
2599 | tempbx = LCDPtr->LCDHDES; | |
2600 | ||
2601 | tempcx = pVBInfo->HDE; | |
2602 | tempbx = tempbx & 0x0fff; | |
2603 | tempcx += tempbx; | |
2604 | ||
2605 | if (tempcx >= tempax) | |
2606 | tempcx -= tempax; | |
2607 | ||
2608 | XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); | |
2609 | ||
2610 | tempcx = tempcx >> 3; | |
2611 | tempbx = tempbx >> 3; | |
2612 | ||
2613 | XGINew_SetReg1(pVBInfo->Part1Port, 0x16, | |
2614 | (unsigned short) (tempbx & 0xff)); | |
2615 | XGINew_SetReg1(pVBInfo->Part1Port, 0x17, | |
2616 | (unsigned short) (tempcx & 0xff)); | |
2617 | ||
2618 | tempax = pVBInfo->HT; | |
2619 | ||
2620 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2621 | tempbx = LCDPtr1->LCDHRS; | |
2622 | else | |
2623 | tempbx = LCDPtr->LCDHRS; | |
2624 | ||
2625 | tempcx = push2; | |
2626 | ||
2627 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2628 | tempcx = LCDPtr1->LCDHSync; | |
2629 | ||
2630 | tempcx += tempbx; | |
2631 | ||
2632 | if (tempcx >= tempax) | |
2633 | tempcx -= tempax; | |
2634 | ||
2635 | tempax = tempbx & 0x07; | |
2636 | tempax = tempax >> 5; | |
2637 | tempcx = tempcx >> 3; | |
2638 | tempbx = tempbx >> 3; | |
2639 | ||
2640 | tempcx &= 0x1f; | |
2641 | tempax |= tempcx; | |
2642 | ||
2643 | XGINew_SetReg1(pVBInfo->Part1Port, 0x15, tempax); | |
2644 | XGINew_SetReg1(pVBInfo->Part1Port, 0x14, | |
2645 | (unsigned short) (tempbx & 0xff)); | |
2646 | ||
2647 | tempax = pVBInfo->VT; | |
2648 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2649 | tempbx = LCDPtr1->LCDVDES; | |
2650 | else | |
2651 | tempbx = LCDPtr->LCDVDES; | |
2652 | tempcx = pVBInfo->VDE; | |
2653 | ||
2654 | tempbx = tempbx & 0x0fff; | |
2655 | tempcx += tempbx; | |
2656 | if (tempcx >= tempax) | |
2657 | tempcx -= tempax; | |
2658 | ||
2659 | XGINew_SetReg1(pVBInfo->Part1Port, 0x1b, | |
2660 | (unsigned short) (tempbx & 0xff)); | |
2661 | XGINew_SetReg1(pVBInfo->Part1Port, 0x1c, | |
2662 | (unsigned short) (tempcx & 0xff)); | |
2663 | ||
2664 | tempbx = (tempbx >> 8) & 0x07; | |
2665 | tempcx = (tempcx >> 8) & 0x07; | |
2666 | ||
2667 | XGINew_SetReg1(pVBInfo->Part1Port, 0x1d, | |
2668 | (unsigned short) ((tempcx << 3) | |
2669 | | tempbx)); | |
2670 | ||
2671 | tempax = pVBInfo->VT; | |
2672 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2673 | tempbx = LCDPtr1->LCDVRS; | |
2674 | else | |
2675 | tempbx = LCDPtr->LCDVRS; | |
d7636e0b | 2676 | |
21df8fc8 PS |
2677 | /* tempbx = tempbx >> 4; */ |
2678 | tempcx = push1; | |
d7636e0b | 2679 | |
21df8fc8 PS |
2680 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2681 | tempcx = LCDPtr1->LCDVSync; | |
d7636e0b | 2682 | |
21df8fc8 PS |
2683 | tempcx += tempbx; |
2684 | if (tempcx >= tempax) | |
2685 | tempcx -= tempax; | |
d7636e0b | 2686 | |
21df8fc8 PS |
2687 | XGINew_SetReg1(pVBInfo->Part1Port, 0x18, |
2688 | (unsigned short) (tempbx & 0xff)); | |
2689 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f, | |
2690 | (unsigned short) (tempcx & 0x0f)); | |
d7636e0b | 2691 | |
21df8fc8 | 2692 | tempax = ((tempbx >> 8) & 0x07) << 3; |
d7636e0b | 2693 | |
21df8fc8 PS |
2694 | tempbx = pVBInfo->VGAVDE; |
2695 | if (tempbx != pVBInfo->VDE) | |
2696 | tempax |= 0x40; | |
d7636e0b | 2697 | |
21df8fc8 PS |
2698 | if (pVBInfo->LCDInfo & EnableLVDSDDA) |
2699 | tempax |= 0x40; | |
d7636e0b | 2700 | |
21df8fc8 PS |
2701 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1a, 0x07, |
2702 | tempax); | |
d7636e0b | 2703 | |
21df8fc8 PS |
2704 | tempcx = pVBInfo->VGAVT; |
2705 | tempbx = pVBInfo->VDE; | |
2706 | tempax = pVBInfo->VGAVDE; | |
2707 | tempcx -= tempax; | |
d7636e0b | 2708 | |
21df8fc8 PS |
2709 | temp = tempax; /* 0430 ylshieh */ |
2710 | temp1 = (temp << 18) / tempbx; | |
d7636e0b | 2711 | |
21df8fc8 | 2712 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
d7636e0b | 2713 | |
21df8fc8 PS |
2714 | if (tempdx != 0) |
2715 | temp1 += 1; | |
d7636e0b | 2716 | |
21df8fc8 PS |
2717 | temp2 = temp1; |
2718 | push3 = temp2; | |
d7636e0b | 2719 | |
21df8fc8 PS |
2720 | XGINew_SetReg1(pVBInfo->Part1Port, 0x37, |
2721 | (unsigned short) (temp2 & 0xff)); | |
2722 | XGINew_SetReg1(pVBInfo->Part1Port, 0x36, | |
2723 | (unsigned short) ((temp2 >> 8) & 0xff)); | |
d7636e0b | 2724 | |
21df8fc8 PS |
2725 | tempbx = (unsigned short) (temp2 >> 16); |
2726 | tempax = tempbx & 0x03; | |
d7636e0b | 2727 | |
21df8fc8 PS |
2728 | tempbx = pVBInfo->VGAVDE; |
2729 | if (tempbx == pVBInfo->VDE) | |
2730 | tempax |= 0x04; | |
d7636e0b | 2731 | |
21df8fc8 | 2732 | XGINew_SetReg1(pVBInfo->Part1Port, 0x35, tempax); |
d7636e0b | 2733 | |
21df8fc8 PS |
2734 | 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)); | |
d7636e0b | 2746 | |
21df8fc8 PS |
2747 | 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 | } | |
d7636e0b | 2755 | |
21df8fc8 PS |
2756 | tempcx = pVBInfo->VGAHDE; |
2757 | tempbx = pVBInfo->HDE; | |
d7636e0b | 2758 | |
21df8fc8 | 2759 | temp1 = tempcx << 16; |
d7636e0b | 2760 | |
21df8fc8 | 2761 | tempax = (unsigned short) (temp1 / tempbx); |
d7636e0b | 2762 | |
21df8fc8 PS |
2763 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
2764 | tempax = 65535; | |
d7636e0b | 2765 | |
21df8fc8 PS |
2766 | temp3 = tempax; |
2767 | temp1 = pVBInfo->VGAHDE << 16; | |
d7636e0b | 2768 | |
21df8fc8 PS |
2769 | temp1 /= temp3; |
2770 | temp3 = temp3 << 16; | |
2771 | temp1 -= 1; | |
d7636e0b | 2772 | |
21df8fc8 | 2773 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
d7636e0b | 2774 | |
21df8fc8 PS |
2775 | tempax = (unsigned short) (temp3 & 0xff); |
2776 | XGINew_SetReg1(pVBInfo->Part1Port, 0x1f, tempax); | |
d7636e0b | 2777 | |
21df8fc8 PS |
2778 | temp1 = pVBInfo->VGAVDE << 18; |
2779 | temp1 = temp1 / push3; | |
2780 | tempbx = (unsigned short) (temp1 & 0xffff); | |
d7636e0b | 2781 | |
21df8fc8 PS |
2782 | if (pVBInfo->LCDResInfo == Panel1024x768) |
2783 | tempbx -= 1; | |
d7636e0b | 2784 | |
21df8fc8 PS |
2785 | 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)); | |
d7636e0b | 2791 | |
21df8fc8 | 2792 | temp3 = temp3 >> 16; |
d7636e0b | 2793 | |
21df8fc8 PS |
2794 | if (modeflag & HalfDCLK) |
2795 | temp3 = temp3 >> 1; | |
d7636e0b | 2796 | |
21df8fc8 PS |
2797 | XGINew_SetReg1(pVBInfo->Part1Port, 0x22, |
2798 | (unsigned short) ((temp3 >> 8) & 0xff)); | |
2799 | XGINew_SetReg1(pVBInfo->Part1Port, 0x23, | |
2800 | (unsigned short) (temp3 & 0xff)); | |
2801 | } | |
2802 | } | |
2803 | } | |
d7636e0b | 2804 | |
21df8fc8 PS |
2805 | void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
2806 | unsigned short RefreshRateTableIndex, | |
2807 | struct vb_device_info *pVBInfo) | |
2808 | { | |
2809 | unsigned char di_0, di_1, tempal; | |
2810 | int i; | |
2811 | ||
2812 | 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); | |
2816 | ||
2817 | 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 | } | |
d7636e0b | 2832 | } |
2833 | ||
21df8fc8 PS |
2834 | void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
2835 | struct vb_device_info *pVBInfo) | |
2836 | { | |
2837 | unsigned short tempcl, tempch, temp, tempbl, tempax; | |
2838 | ||
2839 | 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); | |
2844 | ||
2845 | 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); | |
2856 | ||
2857 | if (!(temp & 0x40)) | |
2858 | tempcl |= ActiveCRT1; | |
2859 | } | |
2860 | } | |
2861 | ||
2862 | temp = XGINew_GetReg1(pVBInfo->Part1Port, 0x2e); | |
2863 | temp &= 0x0f; | |
2864 | ||
2865 | 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; | |
2869 | ||
2870 | temp &= 0x05; | |
2871 | ||
2872 | if (!(tempcl & ActiveLCD)) | |
2873 | if (temp == 0x01) | |
2874 | tempcl |= ActiveCRT2; | |
2875 | ||
2876 | if (temp == 0x04) | |
2877 | tempcl |= ActiveLCD; | |
2878 | ||
2879 | if (temp == 0x05) { | |
2880 | temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x00); | |
2881 | ||
2882 | if (!(temp & 0x08)) | |
2883 | tempch |= ActiveAVideo; | |
2884 | ||
2885 | if (!(temp & 0x04)) | |
2886 | tempch |= ActiveSVideo; | |
2887 | ||
2888 | if (temp & 0x02) | |
2889 | tempch |= ActiveSCART; | |
2890 | ||
2891 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
2892 | if (temp & 0x01) | |
2893 | tempch |= ActiveHiTV; | |
2894 | } | |
2895 | ||
2896 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
2897 | temp = XGINew_GetReg1( | |
2898 | pVBInfo->Part2Port, | |
2899 | 0x4d); | |
2900 | ||
2901 | if (temp & 0x10) | |
2902 | tempch |= ActiveYPbPr; | |
2903 | } | |
2904 | ||
2905 | if (tempch != 0) | |
2906 | tempcl |= ActiveTV; | |
2907 | } | |
2908 | } | |
2909 | ||
2910 | 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); | |
2920 | ||
2921 | if (!(pVBInfo->SetFlag & ReserveTVOption)) | |
2922 | XGINew_SetReg1(pVBInfo->P3d4, 0x3e, tempch); | |
2923 | } else { | |
2924 | return; | |
2925 | } | |
2926 | } | |
d7636e0b | 2927 | |
21df8fc8 PS |
2928 | void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, |
2929 | struct vb_device_info *pVBInfo) | |
2930 | { | |
2931 | /* | |
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; | |
2939 | } | |
d7636e0b | 2940 | |
21df8fc8 PS |
2941 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
2942 | { | |
2943 | unsigned short flag, tempbx, tempah; | |
2944 | ||
2945 | 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 | } | |
2973 | ||
2974 | if (tempbx & (VB_XGI301B | VB_XGI302B)) { | |
2975 | flag = XGINew_GetReg1( | |
2976 | pVBInfo->Part4Port, | |
2977 | 0x23); | |
2978 | ||
2979 | 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 | */ | |
2992 | ||
2993 | } | |
2994 | ||
2995 | void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, | |
2996 | struct xgi_hw_device_info *HwDeviceExtension, | |
2997 | struct vb_device_info *pVBInfo) | |
2998 | { | |
2999 | unsigned short tempax, push, tempbx, temp, modeflag; | |
3000 | ||
3001 | if (ModeNo <= 0x13) | |
3002 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
3003 | else | |
3004 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
3005 | ||
3006 | pVBInfo->SetFlag = 0; | |
3007 | pVBInfo->ModeType = modeflag & ModeInfoFlag; | |
3008 | tempbx = 0; | |
3009 | ||
3010 | 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; | |
3022 | ||
3023 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38); | |
3024 | ||
3025 | if (pVBInfo->IF_DEF_LCDA == 1) { | |
3026 | ||
3027 | 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; | |
3038 | ||
3039 | 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; | |
3049 | ||
3050 | if (temp & SetToLCDA) | |
3051 | tempbx | |
3052 | |= SetCRT2ToLCDA; | |
3053 | } | |
3054 | } | |
3055 | } | |
3056 | } | |
3057 | } | |
3058 | ||
3059 | 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; | |
3077 | ||
3078 | if (temp != YPbPrMode1080i) { | |
3079 | tempbx | |
3080 | &= (~SetCRT2ToHiVisionTV); | |
3081 | tempbx | |
3082 | |= SetCRT2ToYPbPr; | |
3083 | } | |
3084 | } | |
3085 | ||
3086 | /* tempbx |= SetCRT2ToYPbPr; */ | |
3087 | } | |
3088 | } | |
3089 | } | |
3090 | ||
3091 | tempax = push; /* restore CR31 */ | |
3092 | ||
3093 | 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 | } | |
3114 | ||
3115 | if (!(tempbx & temp)) { | |
3116 | tempax |= DisableCRT2Display; | |
3117 | tempbx = 0; | |
3118 | } | |
3119 | ||
3120 | 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 | } | |
3137 | ||
3138 | /* 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 | } | |
3152 | ||
3153 | if (!(pVBInfo->VBType & VB_NoLCD)) { | |
3154 | if (tempbx & SetCRT2ToLCD) { | |
3155 | tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | |
3156 | | SetSimuScanMode); | |
3157 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); | |
3158 | } | |
3159 | } | |
3160 | ||
3161 | if (tempbx & SetCRT2ToSCART) { | |
3162 | tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | |
3163 | | SetSimuScanMode); | |
3164 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); | |
3165 | } | |
3166 | ||
3167 | if (pVBInfo->IF_DEF_YPbPr == 1) { | |
3168 | if (tempbx & SetCRT2ToYPbPr) | |
3169 | tempbx &= (0xFF00 | SwitchToCRT2 | |
3170 | | SetSimuScanMode); | |
3171 | } | |
3172 | ||
3173 | if (pVBInfo->IF_DEF_HiVision == 1) { | |
3174 | if (tempbx & SetCRT2ToHiVisionTV) | |
3175 | tempbx &= (0xFF00 | SetCRT2ToHiVisionTV | |
3176 | | SwitchToCRT2 | |
3177 | | SetSimuScanMode); | |
3178 | } | |
3179 | ||
3180 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ | |
3181 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) | |
3182 | tempbx = DisableCRT2Display; | |
3183 | } | |
3184 | ||
3185 | 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 | } | |
3194 | ||
3195 | 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 | } | |
3225 | ||
3226 | /* 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 | } | |
3235 | ||
3236 | pVBInfo->VBInfo = tempbx; | |
3237 | } | |
3238 | ||
3239 | void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, | |
3240 | struct vb_device_info *pVBInfo) | |
3241 | { | |
3242 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; | |
3243 | ||
3244 | tempbx = 0; | |
3245 | resinfo = 0; | |
3246 | ||
3247 | 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 | } | |
3258 | ||
3259 | 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 | } | |
3280 | ||
3281 | if (pVBInfo->IF_DEF_CH7017 == 1) { | |
3282 | tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35); | |
3283 | ||
3284 | if (tempbx & TVOverScan) | |
3285 | tempbx |= SetCHTVOverScan; | |
3286 | } | |
3287 | ||
3288 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */ | |
3289 | tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35); | |
3290 | ||
3291 | if (tempbx & TVOverScan) | |
3292 | tempbx |= SetCHTVOverScan; | |
3293 | } | |
3294 | ||
3295 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
3296 | if (pVBInfo->VBInfo & SetCRT2ToSCART) | |
3297 | tempbx |= SetPALTV; | |
3298 | } | |
3299 | ||
3300 | if (pVBInfo->IF_DEF_YPbPr == 1) { | |
3301 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
3302 | index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x35); | |
3303 | index1 &= YPbPrMode; | |
3304 | ||
3305 | if (index1 == YPbPrMode525i) | |
3306 | tempbx |= SetYPbPrMode525i; | |
3307 | ||
3308 | if (index1 == YPbPrMode525p) | |
3309 | tempbx = tempbx | SetYPbPrMode525p; | |
3310 | if (index1 == YPbPrMode750p) | |
3311 | tempbx = tempbx | SetYPbPrMode750p; | |
3312 | } | |
3313 | } | |
3314 | ||
3315 | if (pVBInfo->IF_DEF_HiVision == 1) { | |
3316 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
3317 | tempbx = tempbx | SetYPbPrMode1080i | SetPALTV; | |
3318 | } | |
3319 | ||
3320 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ | |
3321 | if ((pVBInfo->VBInfo & SetInSlaveMode) | |
3322 | && (!(pVBInfo->VBInfo & SetNotSimuMode))) | |
3323 | tempbx |= TVSimuMode; | |
3324 | ||
3325 | if (!(tempbx & SetPALTV) && (modeflag > 13) && (resinfo | |
3326 | == 8)) /* NTSC 1024x768, */ | |
3327 | tempbx |= NTSC1024x768; | |
3328 | ||
3329 | tempbx |= RPLLDIV2XO; | |
3330 | ||
3331 | 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; | |
3348 | } | |
3349 | ||
3350 | unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, | |
3351 | struct vb_device_info *pVBInfo) | |
3352 | { | |
3353 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; | |
3354 | ||
3355 | pVBInfo->LCDResInfo = 0; | |
3356 | pVBInfo->LCDTypeInfo = 0; | |
3357 | pVBInfo->LCDInfo = 0; | |
3358 | ||
3359 | 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 | } | |
3365 | ||
3366 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ | |
3367 | tempbx = temp & 0x0F; | |
3368 | ||
3369 | if (tempbx == 0) | |
3370 | tempbx = Panel1024x768; /* default */ | |
3371 | ||
3372 | /* 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; | |
3380 | ||
3381 | 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 | } | |
3390 | ||
3391 | pVBInfo->LCDResInfo = tempbx; | |
3392 | ||
3393 | /* End of LCD75 */ | |
3394 | ||
3395 | if (pVBInfo->IF_DEF_OEMUtil == 1) | |
3396 | pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4; | |
3397 | ||
3398 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) | |
3399 | return 0; | |
3400 | ||
3401 | tempbx = 0; | |
3402 | ||
3403 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); | |
3404 | ||
3405 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); | |
3406 | ||
3407 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding)) | |
3408 | temp &= ~EnableScalingLCD; | |
3409 | ||
3410 | tempbx |= temp; | |
3411 | ||
3412 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); | |
3413 | ||
3414 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; | |
3415 | ||
3416 | 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 | } | |
3422 | ||
3423 | if (pVBInfo->IF_DEF_CH7017 == 1) { | |
3424 | if (tempax & LCDDualLink) | |
3425 | tempbx |= SetLCDDualLink; | |
3426 | } | |
3427 | ||
3428 | 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 | } | |
3434 | ||
3435 | /* | |
3436 | if (tempax & LCDBToA) { | |
3437 | tempbx |= SetLCDBToA; | |
3438 | } | |
3439 | */ | |
3440 | ||
3441 | 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 | } | |
3458 | ||
3459 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
3460 | if (pVBInfo->VBInfo & SetNotSimuMode) | |
3461 | tempbx |= LCDVESATiming; | |
3462 | } else { | |
3463 | tempbx |= LCDVESATiming; | |
3464 | } | |
3465 | ||
3466 | pVBInfo->LCDInfo = tempbx; | |
3467 | ||
3468 | 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 | } | |
3477 | ||
3478 | 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 | } | |
3495 | ||
3496 | /* | |
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 | */ | |
3508 | ||
3509 | return 1; | |
3510 | } | |
3511 | ||
3512 | unsigned char XGI_SearchModeID(unsigned short ModeNo, | |
3513 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) | |
3514 | { | |
21df8fc8 PS |
3515 | 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 | } | |
3525 | ||
3526 | 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 | } | |
3540 | ||
21df8fc8 PS |
3541 | return 1; |
3542 | } | |
d7636e0b | 3543 | |
3544 | /* win2000 MM adapter not support standard mode! */ | |
3545 | ||
8922967e | 3546 | #if 0 |
8922967e | 3547 | static unsigned char XGINew_CheckMemorySize( |
21df8fc8 PS |
3548 | struct xgi_hw_device_info *HwDeviceExtension, |
3549 | unsigned short ModeNo, | |
3550 | unsigned short ModeIdIndex, | |
3551 | struct vb_device_info *pVBInfo) | |
3552 | { | |
3553 | unsigned short memorysize, modeflag, temp, temp1, tmp; | |
3554 | ||
3555 | /* | |
3556 | if ((HwDeviceExtension->jChipType == XGI_650) || | |
3557 | (HwDeviceExtension->jChipType == XGI_650M)) { | |
3558 | return 1; | |
3559 | } | |
3560 | */ | |
3561 | ||
3562 | if (ModeNo <= 0x13) | |
3563 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
3564 | else | |
3565 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
3566 | ||
3567 | /* ModeType = modeflag&ModeInfoFlag; // Get mode type */ | |
3568 | ||
3569 | memorysize = modeflag & MemoryInfoFlag; | |
3570 | memorysize = memorysize > MemorySizeShift; | |
3571 | memorysize++; /* Get memory size */ | |
3572 | ||
3573 | temp = XGINew_GetReg1(pVBInfo->P3c4, 0x14); /* Get DRAM Size */ | |
3574 | tmp = temp; | |
3575 | ||
3576 | 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; | |
d7636e0b | 3604 | } |
8922967e | 3605 | #endif |
d7636e0b | 3606 | |
21df8fc8 PS |
3607 | /* |
3608 | void 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) | |
3609 | { | |
3610 | unsigned short data ; | |
3611 | unsigned short ModeFlag ; | |
3612 | ||
3613 | data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F); | |
3614 | data &= 0x7F; | |
3615 | XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data); | |
3616 | ||
3617 | 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 | } | |
d7636e0b | 3628 | } |
d7636e0b | 3629 | */ |
3630 | ||
21df8fc8 PS |
3631 | void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, |
3632 | struct vb_device_info *pVBInfo) | |
3633 | { | |
3634 | ||
3635 | 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 | } | |
d7636e0b | 3649 | |
21df8fc8 | 3650 | } |
d7636e0b | 3651 | |
21df8fc8 PS |
3652 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */ |
3653 | ||
3654 | } | |
3655 | ||
3656 | 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 | } | |
3669 | ||
3670 | } | |
3671 | } | |
d7636e0b | 3672 | |
21df8fc8 PS |
3673 | void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, |
3674 | struct vb_device_info *pVBInfo) | |
3675 | { | |
d7636e0b | 3676 | |
21df8fc8 PS |
3677 | 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 | } | |
d7636e0b | 3685 | |
21df8fc8 PS |
3686 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */ |
3687 | /* if (IsCH7007TVMode(pVBInfo) == 0) */ | |
3688 | { | |
3689 | } | |
3690 | } | |
d7636e0b | 3691 | |
21df8fc8 PS |
3692 | 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 | } | |
d7636e0b | 3697 | |
21df8fc8 PS |
3698 | if (pVBInfo->IF_DEF_LVDS == 0) |
3699 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */ | |
3700 | } | |
d7636e0b | 3701 | |
21df8fc8 | 3702 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
d7636e0b | 3703 | } |
3704 | ||
80adad85 | 3705 | void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
d7636e0b | 3706 | { |
21df8fc8 PS |
3707 | while ((XGINew_GetReg2(pVBInfo->P3da) & 0x01)) |
3708 | break; | |
d7636e0b | 3709 | |
21df8fc8 PS |
3710 | while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01)) |
3711 | break; | |
d7636e0b | 3712 | } |
3713 | ||
80adad85 | 3714 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
d7636e0b | 3715 | { |
21df8fc8 PS |
3716 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, |
3717 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, | |
3718 | 0x05, 0x00 }; | |
d7636e0b | 3719 | |
108afbf8 | 3720 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
d7636e0b | 3721 | |
108afbf8 | 3722 | unsigned char CR17, CR63, SR31; |
21df8fc8 PS |
3723 | unsigned short temp; |
3724 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; | |
d7636e0b | 3725 | |
21df8fc8 PS |
3726 | int i; |
3727 | XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86); | |
d7636e0b | 3728 | |
21df8fc8 PS |
3729 | /* [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)); | |
d7636e0b | 3733 | |
21df8fc8 PS |
3734 | 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); | |
d7636e0b | 3737 | |
21df8fc8 PS |
3738 | XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
3739 | XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); | |
d7636e0b | 3740 | |
21df8fc8 PS |
3741 | CR17 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x17); |
3742 | XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); | |
d7636e0b | 3743 | |
21df8fc8 PS |
3744 | SR1F = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x1F); |
3745 | XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); | |
d7636e0b | 3746 | |
21df8fc8 PS |
3747 | 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)); | |
d7636e0b | 3751 | |
21df8fc8 | 3752 | XGINew_SetReg1(pVBInfo->P3d4, 0x11, 0x00); |
d7636e0b | 3753 | |
21df8fc8 PS |
3754 | for (i = 0; i < 8; i++) |
3755 | XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); | |
d7636e0b | 3756 | |
21df8fc8 PS |
3757 | for (i = 8; i < 11; i++) |
3758 | XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 8), | |
3759 | CRTCData[i]); | |
d7636e0b | 3760 | |
21df8fc8 PS |
3761 | for (i = 11; i < 13; i++) |
3762 | XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 4), | |
3763 | CRTCData[i]); | |
d7636e0b | 3764 | |
21df8fc8 PS |
3765 | for (i = 13; i < 16; i++) |
3766 | XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i - 3), | |
3767 | CRTCData[i]); | |
d7636e0b | 3768 | |
21df8fc8 PS |
3769 | XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
3770 | & 0xE0)); | |
d7636e0b | 3771 | |
21df8fc8 PS |
3772 | XGINew_SetReg1(pVBInfo->P3c4, 0x31, 0x00); |
3773 | XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B); | |
3774 | XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE1); | |
d7636e0b | 3775 | |
21df8fc8 | 3776 | XGINew_SetReg3(pVBInfo->P3c8, 0x00); |
d7636e0b | 3777 | |
21df8fc8 PS |
3778 | 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 | } | |
d7636e0b | 3786 | |
21df8fc8 PS |
3787 | XGI_VBLongWait(pVBInfo); |
3788 | XGI_VBLongWait(pVBInfo); | |
3789 | XGI_VBLongWait(pVBInfo); | |
d7636e0b | 3790 | |
d80aaa01 | 3791 | mdelay(1); |
d7636e0b | 3792 | |
21df8fc8 PS |
3793 | XGI_WaitDisply(pVBInfo); |
3794 | temp = XGINew_GetReg2(pVBInfo->P3c2); | |
d7636e0b | 3795 | |
21df8fc8 PS |
3796 | if (temp & 0x10) |
3797 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x20); | |
3798 | else | |
3799 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x00); | |
d7636e0b | 3800 | |
21df8fc8 PS |
3801 | /* alan, avoid display something, set BLACK DAC if not restore DAC */ |
3802 | XGINew_SetReg3(pVBInfo->P3c8, 0x00); | |
d7636e0b | 3803 | |
21df8fc8 PS |
3804 | 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 | } | |
d7636e0b | 3809 | |
21df8fc8 PS |
3810 | XGINew_SetReg1(pVBInfo->P3c4, 0x01, SR01); |
3811 | XGINew_SetReg1(pVBInfo->P3d4, 0x63, CR63); | |
3812 | XGINew_SetReg1(pVBInfo->P3c4, 0x31, SR31); | |
d7636e0b | 3813 | |
21df8fc8 PS |
3814 | /* [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); | |
d7636e0b | 3818 | } |
3819 | ||
8922967e | 3820 | #if 0 |
8922967e | 3821 | static void XGI_WaitDisplay(struct vb_device_info *pVBInfo) |
d7636e0b | 3822 | { |
21df8fc8 PS |
3823 | while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01)); |
3824 | while (XGINew_GetReg2(pVBInfo->P3da) & 0x01); | |
d7636e0b | 3825 | } |
8922967e | 3826 | #endif |
d7636e0b | 3827 | |
108afbf8 | 3828 | unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
21df8fc8 PS |
3829 | struct xgi_hw_device_info *HwDeviceExtension, |
3830 | struct vb_device_info *pVBInfo) | |
3831 | { | |
51973d7f | 3832 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
21df8fc8 PS |
3833 | |
3834 | 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; | |
d7636e0b | 3861 | } |
3862 | ||
80adad85 | 3863 | void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
d7636e0b | 3864 | { |
21df8fc8 PS |
3865 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) |
3866 | XGINew_SetRegOR(pVBInfo->Part1Port, 0x01, 0x40); | |
d7636e0b | 3867 | } |
3868 | ||
80adad85 | 3869 | void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo) |
d7636e0b | 3870 | { |
21df8fc8 PS |
3871 | unsigned short temp1, temp2; |
3872 | ||
3873 | 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); | |
3877 | } | |
3878 | ||
3879 | void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, | |
3880 | struct vb_device_info *pVBInfo) | |
3881 | { | |
3882 | unsigned short xres, yres, modeflag, resindex; | |
3883 | ||
3884 | 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 */ | |
3893 | ||
3894 | /* | |
3895 | if (pVBInfo->IF_DEF_FSTN) { | |
3896 | xres *= 2; | |
3897 | yres *= 2; | |
3898 | } else { | |
3899 | */ | |
3900 | if (modeflag & HalfDCLK) | |
3901 | xres *= 2; | |
3902 | ||
3903 | if (modeflag & DoubleScanMode) | |
3904 | yres *= 2; | |
3905 | /* } */ | |
3906 | } | |
d7636e0b | 3907 | |
21df8fc8 PS |
3908 | 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 | } | |
3916 | ||
3917 | if (pVBInfo->LCDResInfo == Panel1280x1024) { | |
3918 | if (yres == 400) | |
3919 | yres = 405; | |
3920 | else if (yres == 350) | |
3921 | yres = 360; | |
3922 | ||
3923 | if (pVBInfo->LCDInfo & LCDVESATiming) { | |
3924 | if (yres == 360) | |
3925 | yres = 375; | |
3926 | } | |
3927 | } | |
3928 | ||
3929 | 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 | } | |
3943 | ||
3944 | if (xres == 720) | |
3945 | xres = 640; | |
3946 | } | |
d7636e0b | 3947 | |
21df8fc8 PS |
3948 | pVBInfo->VGAHDE = xres; |
3949 | pVBInfo->HDE = xres; | |
3950 | pVBInfo->VGAVDE = yres; | |
3951 | pVBInfo->VDE = yres; | |
d7636e0b | 3952 | } |
3953 | ||
80adad85 | 3954 | unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
d7636e0b | 3955 | { |
3956 | ||
a65fd09a DC |
3957 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && |
3958 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ | |
21df8fc8 | 3959 | return 1; |
d7636e0b | 3960 | |
21df8fc8 | 3961 | return 0; |
d7636e0b | 3962 | } |
3963 | ||
21df8fc8 PS |
3964 | void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, |
3965 | unsigned short RefreshRateTableIndex, | |
3966 | struct vb_device_info *pVBInfo) | |
3967 | { | |
3968 | unsigned short tempax = 0, tempbx, modeflag, resinfo; | |
d7636e0b | 3969 | |
21df8fc8 PS |
3970 | struct XGI_LCDDataStruct *LCDPtr = NULL; |
3971 | struct XGI_TVDataStruct *TVPtr = NULL; | |
d7636e0b | 3972 | |
21df8fc8 PS |
3973 | 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 | } | |
d7636e0b | 3980 | |
21df8fc8 PS |
3981 | pVBInfo->NewFlickerMode = 0; |
3982 | pVBInfo->RVBHRS = 50; | |
3983 | ||
3984 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { | |
3985 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
3986 | pVBInfo); | |
3987 | return; | |
3988 | } | |
3989 | ||
3990 | tempbx = 4; | |
3991 | ||
3992 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
3993 | LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx, | |
3994 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
3995 | pVBInfo); | |
3996 | ||
3997 | 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; | |
4003 | ||
4004 | if (pVBInfo->LCDResInfo == Panel1024x768) { | |
4005 | tempax = 1024; | |
4006 | tempbx = 768; | |
4007 | ||
4008 | 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; | |
4052 | ||
4053 | 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 | } | |
4067 | ||
4068 | if (pVBInfo->LCDInfo & LCDNonExpanding) { | |
4069 | tempax = pVBInfo->VGAHDE; | |
4070 | tempbx = pVBInfo->VGAVDE; | |
4071 | } | |
4072 | ||
4073 | pVBInfo->HDE = tempax; | |
4074 | pVBInfo->VDE = tempbx; | |
4075 | return; | |
4076 | } | |
4077 | ||
4078 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { | |
4079 | tempbx = 4; | |
4080 | TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx, | |
4081 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
4082 | pVBInfo); | |
4083 | ||
4084 | 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; | |
4092 | ||
4093 | 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; | |
4100 | ||
4101 | if (pVBInfo->VGAVDE == 350) | |
4102 | pVBInfo->TVInfo |= TVSimuMode; | |
4103 | ||
4104 | tempax = ExtHiTVHT; | |
4105 | tempbx = ExtHiTVVT; | |
4106 | ||
4107 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
4108 | if (pVBInfo->TVInfo & TVSimuMode) { | |
4109 | tempax = StHiTVHT; | |
4110 | tempbx = StHiTVVT; | |
4111 | ||
4112 | 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 | } | |
4123 | ||
4124 | 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 | } | |
4143 | ||
4144 | pVBInfo->HT = tempax; | |
4145 | pVBInfo->VT = tempbx; | |
4146 | return; | |
4147 | } | |
4148 | } | |
4149 | ||
4150 | void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, | |
4151 | unsigned short RefreshRateTableIndex, | |
4152 | struct vb_device_info *pVBInfo) | |
d7636e0b | 4153 | { |
108afbf8 | 4154 | unsigned char di_0, di_1, tempal; |
d7636e0b | 4155 | |
21df8fc8 PS |
4156 | 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); | |
4160 | ||
4161 | 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 | } | |
d7636e0b | 4170 | |
21df8fc8 | 4171 | XGINew_SetReg1(pVBInfo->Part4Port, 0x00, 0x12); |
d7636e0b | 4172 | |
21df8fc8 PS |
4173 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
4174 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x28); | |
4175 | else | |
4176 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x08); | |
d7636e0b | 4177 | } |
4178 | ||
d7636e0b | 4179 | /* --------------------------------------------------------------------- */ |
4180 | /* Function : XGI_GETLCDVCLKPtr */ | |
4181 | /* Input : */ | |
4182 | /* Output : al -> VCLK Index */ | |
4183 | /* Description : */ | |
4184 | /* --------------------------------------------------------------------- */ | |
108afbf8 | 4185 | void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, |
21df8fc8 PS |
4186 | struct vb_device_info *pVBInfo) |
4187 | { | |
4188 | unsigned short index; | |
4189 | ||
4190 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
4191 | if (pVBInfo->IF_DEF_ScaleLCD == 1) { | |
4192 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
4193 | return; | |
4194 | } | |
4195 | ||
4196 | /* index = XGI_GetLCDCapPtr(pVBInfo); */ | |
4197 | index = XGI_GetLCDCapPtr1(pVBInfo); | |
4198 | ||
4199 | 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 | } | |
4206 | } | |
4207 | return; | |
4208 | } | |
4209 | ||
4210 | unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, | |
4211 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
4212 | struct vb_device_info *pVBInfo) | |
d7636e0b | 4213 | { |
d7636e0b | 4214 | |
21df8fc8 PS |
4215 | unsigned short index, modeflag; |
4216 | unsigned short tempbx; | |
4217 | unsigned char tempal; | |
4218 | unsigned char *CHTVVCLKPtr = NULL; | |
d7636e0b | 4219 | |
21df8fc8 PS |
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 | } | |
d7636e0b | 4350 | |
21df8fc8 | 4351 | } |
d7636e0b | 4352 | |
21df8fc8 PS |
4353 | tempal = (unsigned char) XGINew_GetReg2((pVBInfo->P3ca + 0x02)); |
4354 | tempal = tempal >> 2; | |
4355 | tempal &= 0x03; | |
d7636e0b | 4356 | |
21df8fc8 PS |
4357 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */ |
4358 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ | |
d7636e0b | 4359 | |
21df8fc8 PS |
4360 | if (ModeNo <= 0x13) |
4361 | return tempal; | |
d7636e0b | 4362 | |
21df8fc8 PS |
4363 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; |
4364 | return tempal; | |
d7636e0b | 4365 | } |
4366 | ||
21df8fc8 PS |
4367 | void 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 | } | |
d7636e0b | 4386 | |
8922967e | 4387 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
21df8fc8 PS |
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 | ||
4409 | unsigned 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]; | |
d7636e0b | 4426 | |
21df8fc8 PS |
4427 | if (infoflag & InterlaceMode) |
4428 | temp = temp << 1; | |
d7636e0b | 4429 | |
21df8fc8 PS |
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 | } | |
d7636e0b | 4442 | } |
4443 | ||
21df8fc8 PS |
4444 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
4445 | { | |
4446 | XGINew_SetReg1(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */ | |
4447 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */ | |
4448 | } | |
d7636e0b | 4449 | |
21df8fc8 PS |
4450 | void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
4451 | struct xgi_hw_device_info *HwDeviceExtension, | |
4452 | unsigned short RefreshRateTableIndex, | |
4453 | struct vb_device_info *pVBInfo) | |
d7636e0b | 4454 | { |
21df8fc8 | 4455 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; |
d7636e0b | 4456 | |
21df8fc8 PS |
4457 | if (ModeNo > 0x13) { |
4458 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
4459 | CRT1Index &= IndexMask; | |
4460 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
4461 | } | |
d7636e0b | 4462 | |
21df8fc8 PS |
4463 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
4464 | HwDeviceExtension, pVBInfo); | |
4465 | XGI_SetCRT2FIFO(pVBInfo); | |
4466 | /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */ | |
d7636e0b | 4467 | |
21df8fc8 PS |
4468 | for (tempcx = 4; tempcx < 7; tempcx++) |
4469 | XGINew_SetReg1(pVBInfo->Part1Port, tempcx, 0x0); | |
d7636e0b | 4470 | |
21df8fc8 PS |
4471 | XGINew_SetReg1(pVBInfo->Part1Port, 0x50, 0x00); |
4472 | XGINew_SetReg1(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ | |
4473 | } | |
d7636e0b | 4474 | |
21df8fc8 PS |
4475 | void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
4476 | struct xgi_hw_device_info *HwDeviceExtension, | |
4477 | unsigned short RefreshRateTableIndex, | |
4478 | struct vb_device_info *pVBInfo) | |
4479 | { | |
4480 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, | |
4481 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; | |
d7636e0b | 4482 | |
21df8fc8 PS |
4483 | if (ModeNo > 0x13) { |
4484 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
4485 | CRT1Index &= IndexMask; | |
4486 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
4487 | } | |
4488 | ||
4489 | if (ModeNo <= 0x13) | |
4490 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4491 | else | |
4492 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
4493 | ||
4494 | /* 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; | |
4507 | ||
4508 | 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 | } | |
4519 | ||
4520 | tempbx += 4; | |
4521 | tempcx += 4; | |
4522 | ||
4523 | if (tempcx > (pVBInfo->VGAHT / 2)) | |
4524 | tempcx = pVBInfo->VGAHT / 2; | |
4525 | ||
4526 | temp = tempbx & 0x00FF; | |
4527 | ||
4528 | 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; | |
4541 | ||
4542 | 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 | } | |
4555 | ||
4556 | if (tempcx > pVBInfo->VGAHT) | |
4557 | tempcx = pVBInfo->VGAHT; | |
4558 | ||
4559 | temp = tempbx & 0x00FF; | |
4560 | XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp); | |
4561 | } | |
d7636e0b | 4562 | |
21df8fc8 PS |
4563 | 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; | |
4573 | ||
4574 | if (pVBInfo->IF_DEF_CH7005 == 1) { | |
4575 | if (pVBInfo->VBInfo & 0x0C) | |
4576 | temp--; | |
d7636e0b | 4577 | } |
21df8fc8 PS |
4578 | |
4579 | 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); | |
4586 | ||
4587 | 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 */ | |
4592 | ||
4593 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { | |
4594 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; | |
4595 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; | |
4596 | ||
4597 | if (temp & 0x04) | |
4598 | tempbx |= 0x0100; | |
4599 | ||
4600 | if (temp & 0x080) | |
4601 | tempbx |= 0x0200; | |
4602 | ||
4603 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; | |
4604 | ||
4605 | if (temp & 0x08) | |
4606 | tempbx |= 0x0400; | |
4607 | ||
4608 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; | |
4609 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); | |
4610 | } | |
4611 | ||
4612 | 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; | |
4618 | ||
4619 | if (modeflag & DoubleScanMode) | |
4620 | tempax |= 0x80; | |
4621 | ||
4622 | if (modeflag & HalfDCLK) | |
4623 | tempax |= 0x40; | |
4624 | ||
4625 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); | |
d7636e0b | 4626 | } |
4627 | ||
21df8fc8 PS |
4628 | void 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) | |
4632 | { | |
4633 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, | |
4634 | modeflag, CRT1Index; | |
d7636e0b | 4635 | |
21df8fc8 PS |
4636 | 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 | } | |
4645 | ||
4646 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) | |
4647 | return; | |
4648 | ||
4649 | temp = 0xFF; /* set MAX HT */ | |
4650 | XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp); | |
4651 | /* if (modeflag & Charx8Dot) */ | |
4652 | /* tempcx = 0x08; */ | |
4653 | /* else */ | |
4654 | tempcx = 0x08; | |
4655 | ||
4656 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) | |
4657 | modeflag |= Charx8Dot; | |
4658 | ||
4659 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ | |
4660 | ||
4661 | if (modeflag & HalfDCLK) | |
4662 | tempax = tempax >> 1; | |
4663 | ||
4664 | tempax = (tempax / tempcx) - 1; | |
4665 | tempbx |= ((tempax & 0x00FF) << 8); | |
4666 | temp = tempax & 0x00FF; | |
4667 | XGINew_SetReg1(pVBInfo->Part1Port, 0x04, temp); | |
4668 | ||
4669 | temp = (tempbx & 0xFF00) >> 8; | |
4670 | ||
4671 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
4672 | if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
4673 | | VB_XGI302LV | VB_XGI301C))) | |
4674 | temp += 2; | |
4675 | ||
4676 | 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 | } | |
4687 | ||
4688 | XGINew_SetReg1(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */ | |
4689 | XGINew_SetReg1(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */ | |
4690 | ||
4691 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ | |
4692 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
4693 | tempax = pVBInfo->VGAHT; | |
4694 | else | |
4695 | tempax = XGI_GetVGAHT2(pVBInfo); | |
4696 | } | |
4697 | ||
4698 | if (tempax >= pVBInfo->VGAHT) | |
4699 | tempax = pVBInfo->VGAHT; | |
4700 | ||
4701 | if (modeflag & HalfDCLK) | |
4702 | tempax = tempax >> 1; | |
4703 | ||
4704 | 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; | |
4721 | ||
4722 | 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 | } | |
4749 | ||
4750 | 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 | } | |
4765 | ||
4766 | XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */ | |
4767 | XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */ | |
4768 | ||
4769 | 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 | } | |
4777 | ||
4778 | 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 | } | |
4793 | ||
4794 | 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 | } | |
4810 | ||
4811 | 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 | } | |
4827 | ||
4828 | 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 */ | |
4831 | ||
4832 | tempbx = pVBInfo->VGAVT; | |
4833 | push1 = tempbx; | |
4834 | tempcx = 0x121; | |
4835 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ | |
4836 | ||
4837 | 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; | |
4847 | ||
4848 | push2 = tempbx; | |
4849 | ||
4850 | 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); | |
4869 | ||
4870 | if (tempbx & 0x0100) | |
4871 | tempcx |= 0x0002; | |
4872 | ||
4873 | tempax = 0x000B; | |
4874 | ||
4875 | if (modeflag & DoubleScanMode) | |
4876 | tempax |= 0x08000; | |
4877 | ||
4878 | if (tempbx & 0x0200) | |
4879 | tempcx |= 0x0040; | |
4880 | ||
4881 | temp = (tempax & 0xFF00) >> 8; | |
4882 | XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp); | |
4883 | ||
4884 | if (tempbx & 0x0400) | |
4885 | tempcx |= 0x0600; | |
4886 | ||
4887 | 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; | |
5005 | } | |
5006 | ||
5007 | void 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) | |
d7636e0b | 5011 | { |
21df8fc8 PS |
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; | |
d7636e0b | 5452 | } |
5453 | ||
21df8fc8 PS |
5454 | void 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 | } | |
d7636e0b | 5672 | |
5673 | /* --------------------------------------------------------------------- */ | |
21df8fc8 | 5674 | /* Function : XGI_GetTap4Ptr */ |
d7636e0b | 5675 | /* Input : */ |
21df8fc8 | 5676 | /* Output : di -> Tap4 Reg. Setting Pointer */ |
d7636e0b | 5677 | /* Description : */ |
5678 | /* --------------------------------------------------------------------- */ | |
21df8fc8 PS |
5679 | struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, |
5680 | struct vb_device_info *pVBInfo) | |
d7636e0b | 5681 | { |
21df8fc8 | 5682 | unsigned short tempax, tempbx, i; |
d7636e0b | 5683 | |
21df8fc8 | 5684 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
d7636e0b | 5685 | |
21df8fc8 PS |
5686 | if (tempcx == 0) { |
5687 | tempax = pVBInfo->VGAHDE; | |
5688 | tempbx = pVBInfo->HDE; | |
5689 | } else { | |
5690 | tempax = pVBInfo->VGAVDE; | |
5691 | tempbx = pVBInfo->VDE; | |
5692 | } | |
d7636e0b | 5693 | |
21df8fc8 PS |
5694 | if (tempax < tempbx) |
5695 | return &EnlargeTap4Timing[0]; | |
5696 | else if (tempax == tempbx) | |
5697 | return &NoScaleTap4Timing[0]; /* 1:1 */ | |
5698 | else | |
5699 | Tap4TimingPtr = NTSCTap4Timing; /* NTSC */ | |
5700 | ||
5701 | if (pVBInfo->TVInfo & SetPALTV) | |
5702 | Tap4TimingPtr = PALTap4Timing; | |
5703 | ||
5704 | 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 | } | |
d7636e0b | 5712 | |
21df8fc8 PS |
5713 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
5714 | Tap4TimingPtr = HiTVTap4Timing; | |
5715 | ||
5716 | i = 0; | |
5717 | while (Tap4TimingPtr[i].DE != 0xFFFF) { | |
5718 | if (Tap4TimingPtr[i].DE == tempax) | |
5719 | break; | |
5720 | i++; | |
5721 | } | |
5722 | return &Tap4TimingPtr[i]; | |
d7636e0b | 5723 | } |
5724 | ||
21df8fc8 PS |
5725 | void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) |
5726 | { | |
5727 | unsigned short i, j; | |
d7636e0b | 5728 | |
21df8fc8 PS |
5729 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; |
5730 | ||
5731 | if (!(pVBInfo->VBType & VB_XGI301C)) | |
5732 | return; | |
5733 | ||
5734 | #ifndef Tap4 | |
5735 | XGINew_SetRegAND(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */ | |
5736 | #else /* Tap4 Setting */ | |
5737 | ||
5738 | 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]); | |
5741 | ||
5742 | 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 | } | |
5747 | ||
5748 | 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 */ | |
5752 | #endif | |
d7636e0b | 5753 | } |
5754 | ||
21df8fc8 PS |
5755 | void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, |
5756 | struct vb_device_info *pVBInfo) | |
5757 | { | |
5758 | unsigned short i; | |
5759 | unsigned char *tempdi; | |
5760 | unsigned short modeflag; | |
5761 | ||
5762 | 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 */ | |
5766 | ||
5767 | 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 | } | |
d7636e0b | 5775 | |
21df8fc8 PS |
5776 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) |
5777 | return; | |
5778 | ||
5779 | 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 | } | |
5784 | ||
5785 | if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo | |
5786 | & SetCRT2ToYPbPr)) { | |
5787 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
5788 | return; | |
5789 | ||
5790 | tempdi = pVBInfo->HiTVGroup3Data; | |
5791 | if (pVBInfo->SetFlag & TVSimuMode) { | |
5792 | tempdi = pVBInfo->HiTVGroup3Simu; | |
5793 | if (!(modeflag & Charx8Dot)) | |
5794 | tempdi = pVBInfo->HiTVGroup3Text; | |
5795 | } | |
5796 | ||
5797 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
5798 | tempdi = pVBInfo->Ren525pGroup3; | |
5799 | ||
5800 | if (pVBInfo->TVInfo & SetYPbPrMode750p) | |
5801 | tempdi = pVBInfo->Ren750pGroup3; | |
5802 | ||
5803 | for (i = 0; i <= 0x3E; i++) | |
5804 | XGINew_SetReg1(pVBInfo->Part3Port, i, tempdi[i]); | |
5805 | ||
5806 | 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 | ||
5814 | void 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) | |
5818 | { | |
5819 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; | |
5820 | ||
5821 | unsigned long tempebx, tempeax, templong; | |
5822 | ||
5823 | 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 */ | |
5827 | ||
5828 | temp = pVBInfo->RVBHCFACT; | |
5829 | XGINew_SetReg1(pVBInfo->Part4Port, 0x13, temp); | |
5830 | ||
5831 | 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); | |
5838 | ||
5839 | temp = ((tempcx & 0xFF00) >> 8) << 3; | |
5840 | temp2 |= temp; | |
5841 | ||
5842 | tempcx = pVBInfo->VGAVT - 1; | |
5843 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) | |
5844 | tempcx -= 5; | |
5845 | ||
5846 | 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; | |
5853 | ||
5854 | if (modeflag & HalfDCLK) | |
5855 | tempbx = tempbx >> 1; | |
5856 | ||
5857 | if (XGI_IsLCDDualLink(pVBInfo)) | |
5858 | tempbx = tempbx >> 1; | |
5859 | ||
5860 | 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 | } | |
5878 | ||
5879 | 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); | |
5887 | ||
5888 | tempebx = pVBInfo->VDE; | |
5889 | ||
5890 | if (tempcx & SetCRT2ToHiVisionTV) { | |
5891 | if (!(temp & 0xE000)) | |
5892 | tempbx = tempbx >> 1; | |
5893 | } | |
5894 | ||
5895 | tempcx = pVBInfo->RVBHRS; | |
5896 | temp = tempcx & 0x00FF; | |
5897 | XGINew_SetReg1(pVBInfo->Part4Port, 0x18, temp); | |
5898 | ||
5899 | tempeax = pVBInfo->VGAVDE; | |
5900 | tempcx |= 0x04000; | |
5901 | ||
5902 | if (tempeax <= tempebx) { | |
5903 | tempcx = (tempcx & (~0x4000)); | |
5904 | tempeax = pVBInfo->VGAVDE; | |
5905 | } else { | |
5906 | tempeax -= tempebx; | |
5907 | } | |
5908 | ||
5909 | templong = (tempeax * 256 * 1024) % tempebx; | |
5910 | tempeax = (tempeax * 256 * 1024) / tempebx; | |
5911 | tempebx = tempeax; | |
5912 | ||
5913 | if (templong != 0) | |
5914 | tempebx++; | |
5915 | ||
5916 | temp = (unsigned short) (tempebx & 0x000000FF); | |
5917 | XGINew_SetReg1(pVBInfo->Part4Port, 0x1B, temp); | |
5918 | ||
5919 | 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); | |
5926 | ||
5927 | /* 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; | |
5935 | ||
5936 | if (XGI_IsLCDDualLink(pVBInfo)) | |
5937 | tempax = tempax >> 1; | |
5938 | ||
5939 | /* 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; | |
5952 | ||
5953 | /* | |
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 | */ | |
5974 | ||
5975 | 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); | |
5980 | ||
5981 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { | |
5982 | if (pVBInfo->VGAHDE > 800) | |
5983 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x1E, 0x08); | |
5984 | ||
5985 | } | |
5986 | temp = 0x0036; | |
5987 | ||
5988 | 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 | } | |
5999 | ||
6000 | 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 */ | |
6011 | ||
6012 | if (pVBInfo->ISXPDOS == 0) | |
6013 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
6014 | pVBInfo); | |
d7636e0b | 6015 | } |
6016 | ||
21df8fc8 PS |
6017 | void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
6018 | struct vb_device_info *pVBInfo) | |
6019 | { | |
6020 | unsigned short Pindex, Pdata; | |
6021 | ||
6022 | 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; | |
6032 | } | |
d7636e0b | 6033 | |
21df8fc8 PS |
6034 | void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, |
6035 | unsigned short ModeIdIndex, | |
6036 | unsigned short RefreshRateTableIndex, | |
6037 | struct vb_device_info *pVBInfo) | |
6038 | { | |
6039 | unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table; | |
d7636e0b | 6040 | |
21df8fc8 | 6041 | struct XGI330_LCDDataTablStruct *tempdi = NULL; |
d7636e0b | 6042 | |
21df8fc8 | 6043 | tempbx = BX; |
d7636e0b | 6044 | |
21df8fc8 PS |
6045 | 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 | } | |
d7636e0b | 6052 | |
21df8fc8 PS |
6053 | tempal = tempal & 0x0f; |
6054 | ||
6055 | 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 | } | |
6062 | ||
6063 | 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 | } | |
6071 | ||
6072 | if (tempbx & 0x01) | |
6073 | tempal = (tempal >> 4); | |
6074 | ||
6075 | tempal = (tempal & 0x0f); | |
6076 | } | |
d7636e0b | 6077 | |
21df8fc8 | 6078 | tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */ |
d7636e0b | 6079 | |
21df8fc8 PS |
6080 | 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); */ | |
6088 | ||
6089 | 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 | } | |
d7636e0b | 6119 | |
21df8fc8 PS |
6120 | if (tempdi == NULL) /* OEMUtil */ |
6121 | return NULL; | |
d7636e0b | 6122 | |
21df8fc8 PS |
6123 | table = tempbx; |
6124 | i = 0; | |
d7636e0b | 6125 | |
21df8fc8 PS |
6126 | while (tempdi[i].PANELID != 0xff) { |
6127 | tempdx = pVBInfo->LCDResInfo; | |
6128 | if (tempbx & 0x0080) { /* OEMUtil */ | |
6129 | tempbx &= (~0x0080); | |
6130 | tempdx = pVBInfo->LCDTypeInfo; | |
6131 | } | |
d7636e0b | 6132 | |
21df8fc8 PS |
6133 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
6134 | tempdx &= (~PanelResInfo); | |
d7636e0b | 6135 | |
21df8fc8 PS |
6136 | if (tempdi[i].PANELID == tempdx) { |
6137 | tempbx = tempdi[i].MASK; | |
6138 | tempdx = pVBInfo->LCDInfo; | |
d7636e0b | 6139 | |
21df8fc8 PS |
6140 | if (ModeNo <= 0x13) /* alan 09/10/2003 */ |
6141 | tempdx |= SetLCDStdMode; | |
d7636e0b | 6142 | |
21df8fc8 PS |
6143 | if (modeflag & HalfDCLK) |
6144 | tempdx |= SetLCDLowResolution; | |
d7636e0b | 6145 | |
21df8fc8 PS |
6146 | tempbx &= tempdx; |
6147 | if (tempbx == tempdi[i].CAP) | |
6148 | break; | |
6149 | } | |
6150 | i++; | |
6151 | } | |
d7636e0b | 6152 | |
21df8fc8 PS |
6153 | 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; | |
d7636e0b | 6503 | } |
6504 | ||
21df8fc8 PS |
6505 | void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, |
6506 | unsigned short ModeIdIndex, | |
6507 | unsigned short RefreshRateTableIndex, | |
6508 | struct vb_device_info *pVBInfo) | |
6509 | { | |
6510 | unsigned short i, tempdx, tempbx, tempal, modeflag, table; | |
6511 | struct XGI330_TVDataTablStruct *tempdi = NULL; | |
d7636e0b | 6512 | |
21df8fc8 | 6513 | tempbx = BX; |
d7636e0b | 6514 | |
21df8fc8 PS |
6515 | 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 | } | |
d7636e0b | 6522 | |
21df8fc8 PS |
6523 | tempal = tempal & 0x3f; |
6524 | table = tempbx; | |
6525 | ||
6526 | switch (tempbx) { | |
6527 | case 0: | |
6528 | tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/ | |
6529 | if (pVBInfo->IF_DEF_CH7007 == 1) | |
6530 | tempdi = XGI_EPLCHTVCRT1Ptr; | |
6531 | ||
6532 | break; | |
6533 | case 1: | |
6534 | tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/ | |
6535 | if (pVBInfo->IF_DEF_CH7007 == 1) | |
6536 | tempdi = XGI_EPLCHTVCRT1Ptr; | |
6537 | ||
6538 | 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 | } | |
d7636e0b | 6557 | |
21df8fc8 PS |
6558 | if (tempdi == NULL) /* OEMUtil */ |
6559 | return NULL; | |
d7636e0b | 6560 | |
21df8fc8 | 6561 | tempdx = pVBInfo->TVInfo; |
d7636e0b | 6562 | |
21df8fc8 PS |
6563 | if (pVBInfo->VBInfo & SetInSlaveMode) |
6564 | tempdx = tempdx | SetTVLockMode; | |
d7636e0b | 6565 | |
21df8fc8 PS |
6566 | if (modeflag & HalfDCLK) |
6567 | tempdx = tempdx | SetTVLowResolution; | |
d7636e0b | 6568 | |
21df8fc8 | 6569 | i = 0; |
d7636e0b | 6570 | |
21df8fc8 PS |
6571 | while (tempdi[i].MASK != 0xffff) { |
6572 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) | |
6573 | break; | |
6574 | i++; | |
6575 | } | |
d7636e0b | 6576 | |
21df8fc8 PS |
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; | |
d7636e0b | 6646 | } |
6647 | ||
d7636e0b | 6648 | /* --------------------------------------------------------------------- */ |
6649 | /* Function : XGI_BacklightByDrv */ | |
6650 | /* Input : */ | |
dda08c59 | 6651 | /* Output : 1 -> Skip backlight control */ |
d7636e0b | 6652 | /* Description : */ |
6653 | /* --------------------------------------------------------------------- */ | |
80adad85 | 6654 | unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo) |
d7636e0b | 6655 | { |
21df8fc8 | 6656 | unsigned char tempah; |
d7636e0b | 6657 | |
21df8fc8 PS |
6658 | tempah = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x3A); |
6659 | if (tempah & BacklightControlBit) | |
6660 | return 1; | |
6661 | else | |
6662 | return 0; | |
d7636e0b | 6663 | } |
6664 | ||
d7636e0b | 6665 | /* --------------------------------------------------------------------- */ |
6666 | /* Function : XGI_FirePWDDisable */ | |
6667 | /* Input : */ | |
6668 | /* Output : */ | |
6669 | /* Description : Turn off VDD & Backlight : Fire disable procedure */ | |
6670 | /* --------------------------------------------------------------------- */ | |
6671 | /* | |
80adad85 | 6672 | void XGI_FirePWDDisable(struct vb_device_info *pVBInfo) |
d7636e0b | 6673 | { |
21df8fc8 | 6674 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x00, 0xFC); |
d7636e0b | 6675 | } |
6676 | */ | |
6677 | ||
6678 | /* --------------------------------------------------------------------- */ | |
6679 | /* Function : XGI_FirePWDEnable */ | |
6680 | /* Input : */ | |
6681 | /* Output : */ | |
6682 | /* Description : Turn on VDD & Backlight : Fire enable procedure */ | |
6683 | /* --------------------------------------------------------------------- */ | |
80adad85 | 6684 | void XGI_FirePWDEnable(struct vb_device_info *pVBInfo) |
d7636e0b | 6685 | { |
21df8fc8 | 6686 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x03, 0xFC); |
d7636e0b | 6687 | } |
6688 | ||
21df8fc8 PS |
6689 | void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
6690 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6691 | { |
21df8fc8 | 6692 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
d7636e0b | 6693 | } |
6694 | ||
21df8fc8 PS |
6695 | void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
6696 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6697 | { |
6698 | ||
21df8fc8 | 6699 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
d7636e0b | 6700 | } |
6701 | ||
d7636e0b | 6702 | /* --------------------------------------------------------------------- */ |
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 | /* --------------------------------------------------------------------- */ | |
80adad85 | 6712 | void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo) |
d7636e0b | 6713 | { |
21df8fc8 | 6714 | unsigned short index; |
d7636e0b | 6715 | |
21df8fc8 | 6716 | index = XGI_GetLCDCapPtr(pVBInfo); |
d7636e0b | 6717 | |
21df8fc8 | 6718 | if (tempbl == 1) |
d80aaa01 | 6719 | mdelay(pVBInfo->LCDCapList[index].PSC_S1); |
d7636e0b | 6720 | |
21df8fc8 | 6721 | if (tempbl == 2) |
d80aaa01 | 6722 | mdelay(pVBInfo->LCDCapList[index].PSC_S2); |
d7636e0b | 6723 | |
21df8fc8 | 6724 | if (tempbl == 3) |
d80aaa01 | 6725 | mdelay(pVBInfo->LCDCapList[index].PSC_S3); |
d7636e0b | 6726 | |
21df8fc8 | 6727 | if (tempbl == 4) |
d80aaa01 | 6728 | mdelay(pVBInfo->LCDCapList[index].PSC_S4); |
d7636e0b | 6729 | } |
6730 | ||
d7636e0b | 6731 | /* --------------------------------------------------------------------- */ |
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 | /* --------------------------------------------------------------------- */ | |
21df8fc8 PS |
6741 | void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, |
6742 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6743 | { |
21df8fc8 PS |
6744 | 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); | |
d7636e0b | 6748 | } |
6749 | ||
8922967e | 6750 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
d7636e0b | 6751 | { |
21df8fc8 PS |
6752 | unsigned char ujRet = 0; |
6753 | unsigned char i = 0; | |
d7636e0b | 6754 | |
21df8fc8 PS |
6755 | for (i = 0; i < 8; i++) { |
6756 | ujRet = ujRet << 1; | |
6757 | /* ujRet |= GETBITS(ujDate >> i, 0:0); */ | |
6758 | ujRet |= (ujDate >> i) & 1; | |
6759 | } | |
d7636e0b | 6760 | |
6761 | return ujRet; | |
6762 | } | |
6763 | ||
6764 | /*----------------------------------------------------------------------------*/ | |
6765 | /* output */ | |
6766 | /* bl[5] : LVDS signal */ | |
6767 | /* bl[1] : LVDS backlight */ | |
6768 | /* bl[0] : LVDS VDD */ | |
6769 | /*----------------------------------------------------------------------------*/ | |
80adad85 | 6770 | unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) |
d7636e0b | 6771 | { |
21df8fc8 | 6772 | unsigned char CR4A, temp; |
d7636e0b | 6773 | |
21df8fc8 PS |
6774 | CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A); |
6775 | XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ | |
d7636e0b | 6776 | |
21df8fc8 | 6777 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48); |
d7636e0b | 6778 | |
21df8fc8 PS |
6779 | temp = XG21GPIODataTransfer(temp); |
6780 | temp &= 0x23; | |
6781 | XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A); | |
6782 | return temp; | |
d7636e0b | 6783 | } |
6784 | ||
6785 | /*----------------------------------------------------------------------------*/ | |
6786 | /* output */ | |
6787 | /* bl[5] : LVDS signal */ | |
6788 | /* bl[1] : LVDS backlight */ | |
6789 | /* bl[0] : LVDS VDD */ | |
6790 | /*----------------------------------------------------------------------------*/ | |
80adad85 | 6791 | unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) |
d7636e0b | 6792 | { |
21df8fc8 | 6793 | unsigned char CR4A, CRB4, temp; |
d7636e0b | 6794 | |
21df8fc8 PS |
6795 | CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A); |
6796 | XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ | |
d7636e0b | 6797 | |
21df8fc8 | 6798 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48); |
d7636e0b | 6799 | |
21df8fc8 PS |
6800 | 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; | |
d7636e0b | 6806 | } |
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 | /*----------------------------------------------------------------------------*/ | |
21df8fc8 PS |
6816 | void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
6817 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6818 | { |
21df8fc8 | 6819 | unsigned char CR4A, temp; |
d7636e0b | 6820 | |
21df8fc8 PS |
6821 | CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A); |
6822 | tempbh &= 0x23; | |
6823 | tempbl &= 0x23; | |
6824 | XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ | |
d7636e0b | 6825 | |
21df8fc8 PS |
6826 | if (tempbh & 0x20) { |
6827 | temp = (tempbl >> 4) & 0x02; | |
d7636e0b | 6828 | |
21df8fc8 | 6829 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */ |
d7636e0b | 6830 | |
21df8fc8 | 6831 | } |
d7636e0b | 6832 | |
21df8fc8 | 6833 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48); |
d7636e0b | 6834 | |
21df8fc8 PS |
6835 | temp = XG21GPIODataTransfer(temp); |
6836 | temp &= ~tempbh; | |
6837 | temp |= tempbl; | |
6838 | XGINew_SetReg1(pVBInfo->P3d4, 0x48, temp); | |
d7636e0b | 6839 | } |
6840 | ||
21df8fc8 PS |
6841 | void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
6842 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6843 | { |
21df8fc8 PS |
6844 | unsigned char CR4A, temp; |
6845 | unsigned short tempbh0, tempbl0; | |
d7636e0b | 6846 | |
21df8fc8 PS |
6847 | tempbh0 = tempbh; |
6848 | tempbl0 = tempbl; | |
6849 | tempbh0 &= 0x20; | |
6850 | tempbl0 &= 0x20; | |
6851 | tempbh0 >>= 3; | |
6852 | tempbl0 >>= 3; | |
d7636e0b | 6853 | |
21df8fc8 PS |
6854 | if (tempbh & 0x20) { |
6855 | temp = (tempbl >> 4) & 0x02; | |
d7636e0b | 6856 | |
21df8fc8 | 6857 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */ |
d7636e0b | 6858 | |
21df8fc8 PS |
6859 | } |
6860 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); | |
d7636e0b | 6861 | |
21df8fc8 PS |
6862 | 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); | |
d7636e0b | 6869 | } |
6870 | ||
6871 | /* --------------------------------------------------------------------- */ | |
80adad85 | 6872 | unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo) |
d7636e0b | 6873 | { |
21df8fc8 | 6874 | unsigned short index; |
d7636e0b | 6875 | |
21df8fc8 PS |
6876 | index = XGINew_GetReg1(pVBInfo->P3d4, 0x36); |
6877 | if (index < sizeof(XGI21_LCDCapList) | |
6878 | / sizeof(struct XGI21_LVDSCapStruct)) | |
6879 | return index; | |
6880 | return 0; | |
d7636e0b | 6881 | } |
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 | /* --------------------------------------------------------------------- */ | |
21df8fc8 PS |
6893 | void XGI_XG21SetPanelDelay(unsigned short tempbl, |
6894 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6895 | { |
21df8fc8 | 6896 | unsigned short index; |
d7636e0b | 6897 | |
21df8fc8 PS |
6898 | index = XGI_GetLVDSOEMTableIndex(pVBInfo); |
6899 | if (tempbl == 1) | |
d80aaa01 | 6900 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1); |
d7636e0b | 6901 | |
21df8fc8 | 6902 | if (tempbl == 2) |
d80aaa01 | 6903 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2); |
d7636e0b | 6904 | |
21df8fc8 | 6905 | if (tempbl == 3) |
d80aaa01 | 6906 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3); |
d7636e0b | 6907 | |
21df8fc8 | 6908 | if (tempbl == 4) |
d80aaa01 | 6909 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4); |
d7636e0b | 6910 | } |
6911 | ||
82d6eb5b | 6912 | unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, |
21df8fc8 PS |
6913 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
6914 | { | |
6915 | unsigned short xres, yres, colordepth, modeflag, resindex, | |
6916 | lvdstableindex; | |
6917 | ||
6918 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
6919 | if (ModeNo <= 0x13) { | |
6920 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
6921 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
6922 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ | |
6923 | } else { | |
6924 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
6925 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
6926 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */ | |
6927 | } | |
6928 | ||
6929 | if (!(modeflag & Charx8Dot)) { | |
6930 | xres /= 9; | |
6931 | xres *= 8; | |
6932 | } | |
6933 | ||
6934 | if (ModeNo > 0x13) { | |
6935 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) | |
6936 | xres *= 2; | |
6937 | ||
6938 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) | |
6939 | yres *= 2; | |
6940 | ||
6941 | } | |
6942 | ||
6943 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); | |
6944 | if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE)) | |
6945 | return 0; | |
6946 | ||
6947 | if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) | |
6948 | return 0; | |
6949 | ||
6950 | if (ModeNo > 0x13) { | |
6951 | if ((xres | |
6952 | != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE)) | |
6953 | || (yres | |
6954 | != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) { | |
6955 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, | |
6956 | pVBInfo); | |
6957 | if (colordepth > 2) | |
6958 | return 0; | |
6959 | ||
6960 | } | |
6961 | } | |
6962 | return 1; | |
d7636e0b | 6963 | } |
6964 | ||
80adad85 | 6965 | void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
d7636e0b | 6966 | { |
21df8fc8 | 6967 | unsigned char temp; |
d7636e0b | 6968 | |
21df8fc8 PS |
6969 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
6970 | temp = (temp & 1) << 6; | |
6971 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */ | |
6972 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ | |
d7636e0b | 6973 | |
6974 | } | |
6975 | ||
80adad85 | 6976 | void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
d7636e0b | 6977 | { |
21df8fc8 | 6978 | unsigned char temp; |
d7636e0b | 6979 | |
21df8fc8 PS |
6980 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
6981 | temp = (temp & 3) << 6; | |
6982 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ | |
6983 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ | |
d7636e0b | 6984 | |
6985 | } | |
6986 | ||
82d6eb5b | 6987 | void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
6988 | struct vb_device_info *pVBInfo) |
6989 | { | |
6990 | unsigned char temp, Miscdata; | |
6991 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; | |
6992 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; | |
6993 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; | |
6994 | unsigned short value; | |
6995 | ||
6996 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); | |
6997 | ||
6998 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability | |
6999 | & (LCDPolarity << 8)) >> 8); | |
7000 | temp &= LCDPolarity; | |
7001 | Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc); | |
7002 | ||
7003 | XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp); | |
7004 | ||
7005 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability | |
7006 | & LCDPolarity); | |
7007 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */ | |
7008 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */ | |
7009 | ||
7010 | XGI_SetXG21FPBits(pVBInfo); | |
7011 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
7012 | if (ModeNo <= 0x13) { | |
7013 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
7014 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
7015 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ | |
7016 | } else { | |
7017 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
7018 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
7019 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */ | |
7020 | } | |
7021 | ||
7022 | if (!(modeflag & Charx8Dot)) | |
7023 | xres = xres * 8 / 9; | |
7024 | ||
7025 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; | |
7026 | ||
7027 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE | |
7028 | - xres) / 2; | |
7029 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) | |
7030 | LVDSHBS -= xres / 4; | |
7031 | ||
7032 | if (LVDSHBS > LVDSHT) | |
7033 | LVDSHBS -= LVDSHT; | |
7034 | ||
7035 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; | |
7036 | if (LVDSHRS > LVDSHT) | |
7037 | LVDSHRS -= LVDSHT; | |
7038 | ||
7039 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; | |
7040 | if (LVDSHRE > LVDSHT) | |
7041 | LVDSHRE -= LVDSHT; | |
7042 | ||
7043 | LVDSHBE = LVDSHBS + LVDSHT | |
7044 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; | |
7045 | ||
7046 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; | |
7047 | ||
7048 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE | |
7049 | - yres) / 2; | |
7050 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) | |
7051 | LVDSVBS += yres / 2; | |
7052 | ||
7053 | if (LVDSVBS > LVDSVT) | |
7054 | LVDSVBS -= LVDSVT; | |
7055 | ||
7056 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; | |
7057 | if (LVDSVRS > LVDSVT) | |
7058 | LVDSVRS -= LVDSVT; | |
7059 | ||
7060 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC; | |
7061 | if (LVDSVRE > LVDSVT) | |
7062 | LVDSVRE -= LVDSVT; | |
7063 | ||
7064 | LVDSVBE = LVDSVBS + LVDSVT | |
7065 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; | |
7066 | ||
7067 | temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); | |
7068 | XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ | |
7069 | ||
7070 | if (!(modeflag & Charx8Dot)) | |
7071 | XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1); | |
7072 | ||
7073 | /* HT SR0B[1:0] CR00 */ | |
7074 | value = (LVDSHT >> 3) - 5; | |
7075 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); | |
7076 | XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF)); | |
7077 | ||
7078 | /* HBS SR0B[5:4] CR02 */ | |
7079 | value = (LVDSHBS >> 3) - 1; | |
7080 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); | |
7081 | XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF)); | |
7082 | ||
7083 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ | |
7084 | value = (LVDSHBE >> 3) - 1; | |
7085 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); | |
7086 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); | |
7087 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); | |
7088 | ||
7089 | /* HRS SR0B[7:6] CR04 */ | |
7090 | value = (LVDSHRS >> 3) + 2; | |
7091 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); | |
7092 | XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF)); | |
7093 | ||
7094 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ | |
7095 | value--; | |
7096 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); | |
7097 | XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF)); | |
7098 | ||
7099 | /* HRE SR0C[2] CR05[4:0] */ | |
7100 | value = (LVDSHRE >> 3) + 2; | |
7101 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); | |
7102 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); | |
7103 | ||
7104 | /* Panel HRE SR2F[7:2] */ | |
7105 | value--; | |
7106 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); | |
7107 | ||
7108 | /* VT SR0A[0] CR07[5][0] CR06 */ | |
7109 | value = LVDSVT - 2; | |
7110 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); | |
7111 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); | |
7112 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); | |
7113 | XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF)); | |
7114 | ||
7115 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ | |
7116 | value = LVDSVBS - 1; | |
7117 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); | |
7118 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); | |
7119 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); | |
7120 | XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF)); | |
7121 | ||
7122 | /* VBE SR0A[4] CR16 */ | |
7123 | value = LVDSVBE - 1; | |
7124 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); | |
7125 | XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF)); | |
7126 | ||
7127 | /* VRS SR0A[3] CR7[7][2] CR10 */ | |
7128 | value = LVDSVRS - 1; | |
7129 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); | |
7130 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); | |
7131 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); | |
7132 | XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF)); | |
7133 | ||
7134 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ | |
7135 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9); | |
7136 | XGINew_SetReg1(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); | |
7137 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); | |
7138 | ||
7139 | /* VRE SR0A[5] CR11[3:0] */ | |
7140 | value = LVDSVRE - 1; | |
7141 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); | |
7142 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); | |
7143 | ||
7144 | /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */ | |
7145 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C); | |
7146 | ||
7147 | for (temp = 0, value = 0; temp < 3; temp++) { | |
7148 | ||
7149 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value); | |
7150 | XGINew_SetReg1(pVBInfo->P3c4, | |
7151 | 0x2B, | |
7152 | pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1); | |
7153 | XGINew_SetReg1(pVBInfo->P3c4, | |
7154 | 0x2C, | |
7155 | pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2); | |
7156 | value += 0x10; | |
7157 | } | |
d7636e0b | 7158 | |
21df8fc8 PS |
7159 | if (!(modeflag & Charx8Dot)) { |
7160 | XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */ | |
7161 | XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */ | |
7162 | XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/ | |
d7636e0b | 7163 | |
21df8fc8 PS |
7164 | XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */ |
7165 | XGINew_SetReg3(pVBInfo->P3c0, 0x20); | |
d7636e0b | 7166 | |
21df8fc8 PS |
7167 | XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */ |
7168 | } | |
d7636e0b | 7169 | |
7170 | } | |
7171 | ||
7172 | /* no shadow case */ | |
82d6eb5b | 7173 | void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
7174 | struct vb_device_info *pVBInfo) |
7175 | { | |
7176 | unsigned char temp, Miscdata; | |
7177 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; | |
7178 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; | |
7179 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; | |
7180 | unsigned short value; | |
7181 | ||
7182 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); | |
7183 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability | |
7184 | & (LCDPolarity << 8)) >> 8); | |
7185 | temp &= LCDPolarity; | |
7186 | Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc); | |
7187 | ||
7188 | XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp); | |
7189 | ||
7190 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability | |
7191 | & LCDPolarity); | |
7192 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */ | |
7193 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */ | |
7194 | ||
7195 | XGI_SetXG27FPBits(pVBInfo); | |
7196 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
7197 | if (ModeNo <= 0x13) { | |
7198 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
7199 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
7200 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ | |
7201 | } else { | |
7202 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
7203 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
7204 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */ | |
7205 | } | |
7206 | ||
7207 | if (!(modeflag & Charx8Dot)) | |
7208 | xres = xres * 8 / 9; | |
7209 | ||
7210 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; | |
d7636e0b | 7211 | |
21df8fc8 PS |
7212 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE |
7213 | - xres) / 2; | |
7214 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) | |
7215 | LVDSHBS -= xres / 4; | |
7216 | ||
7217 | if (LVDSHBS > LVDSHT) | |
7218 | LVDSHBS -= LVDSHT; | |
7219 | ||
7220 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; | |
7221 | if (LVDSHRS > LVDSHT) | |
7222 | LVDSHRS -= LVDSHT; | |
7223 | ||
7224 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; | |
7225 | if (LVDSHRE > LVDSHT) | |
7226 | LVDSHRE -= LVDSHT; | |
7227 | ||
7228 | LVDSHBE = LVDSHBS + LVDSHT | |
7229 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; | |
7230 | ||
7231 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; | |
d7636e0b | 7232 | |
21df8fc8 PS |
7233 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE |
7234 | - yres) / 2; | |
7235 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) | |
7236 | LVDSVBS += yres / 2; | |
7237 | ||
7238 | if (LVDSVBS > LVDSVT) | |
7239 | LVDSVBS -= LVDSVT; | |
7240 | ||
7241 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; | |
7242 | if (LVDSVRS > LVDSVT) | |
7243 | LVDSVRS -= LVDSVT; | |
7244 | ||
7245 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC; | |
7246 | if (LVDSVRE > LVDSVT) | |
7247 | LVDSVRE -= LVDSVT; | |
7248 | ||
7249 | LVDSVBE = LVDSVBS + LVDSVT | |
7250 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; | |
7251 | ||
7252 | temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); | |
7253 | XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ | |
7254 | ||
7255 | if (!(modeflag & Charx8Dot)) | |
7256 | XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1); | |
7257 | ||
7258 | /* HT SR0B[1:0] CR00 */ | |
7259 | value = (LVDSHT >> 3) - 5; | |
7260 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); | |
7261 | XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF)); | |
7262 | ||
7263 | /* HBS SR0B[5:4] CR02 */ | |
7264 | value = (LVDSHBS >> 3) - 1; | |
7265 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); | |
7266 | XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF)); | |
7267 | ||
7268 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ | |
7269 | value = (LVDSHBE >> 3) - 1; | |
7270 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); | |
7271 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); | |
7272 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); | |
7273 | ||
7274 | /* HRS SR0B[7:6] CR04 */ | |
7275 | value = (LVDSHRS >> 3) + 2; | |
7276 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); | |
7277 | XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF)); | |
7278 | ||
7279 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ | |
7280 | value--; | |
7281 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); | |
7282 | XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF)); | |
7283 | ||
7284 | /* HRE SR0C[2] CR05[4:0] */ | |
7285 | value = (LVDSHRE >> 3) + 2; | |
7286 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); | |
7287 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); | |
7288 | ||
7289 | /* Panel HRE SR2F[7:2] */ | |
7290 | value--; | |
7291 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); | |
7292 | ||
7293 | /* VT SR0A[0] CR07[5][0] CR06 */ | |
7294 | value = LVDSVT - 2; | |
7295 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); | |
7296 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); | |
7297 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); | |
7298 | XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF)); | |
7299 | ||
7300 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ | |
7301 | value = LVDSVBS - 1; | |
7302 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); | |
7303 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); | |
7304 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); | |
7305 | XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF)); | |
7306 | ||
7307 | /* VBE SR0A[4] CR16 */ | |
7308 | value = LVDSVBE - 1; | |
7309 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); | |
7310 | XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF)); | |
7311 | ||
7312 | /* VRS SR0A[3] CR7[7][2] CR10 */ | |
7313 | value = LVDSVRS - 1; | |
7314 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); | |
7315 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); | |
7316 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); | |
7317 | XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF)); | |
7318 | ||
7319 | /* Panel VRS SR35[2:0] SR34[7:0] */ | |
7320 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8); | |
7321 | XGINew_SetReg1(pVBInfo->P3c4, 0x34, value & 0xFF); | |
7322 | ||
7323 | /* VRE SR0A[5] CR11[3:0] */ | |
7324 | value = LVDSVRE - 1; | |
7325 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); | |
7326 | XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); | |
7327 | ||
7328 | /* Panel VRE SR3F[7:2] */ | |
7329 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC); | |
7330 | ||
7331 | for (temp = 0, value = 0; temp < 3; temp++) { | |
7332 | ||
7333 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value); | |
7334 | XGINew_SetReg1(pVBInfo->P3c4, | |
7335 | 0x2B, | |
7336 | pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1); | |
7337 | XGINew_SetReg1(pVBInfo->P3c4, | |
7338 | 0x2C, | |
7339 | pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2); | |
7340 | value += 0x10; | |
7341 | } | |
d7636e0b | 7342 | |
21df8fc8 PS |
7343 | if (!(modeflag & Charx8Dot)) { |
7344 | XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */ | |
7345 | XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */ | |
7346 | XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/ | |
d7636e0b | 7347 | |
21df8fc8 PS |
7348 | XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */ |
7349 | XGINew_SetReg3(pVBInfo->P3c0, 0x20); | |
d7636e0b | 7350 | |
21df8fc8 PS |
7351 | XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */ |
7352 | } | |
d7636e0b | 7353 | |
7354 | } | |
7355 | ||
7356 | /* --------------------------------------------------------------------- */ | |
7357 | /* Function : XGI_IsLCDON */ | |
7358 | /* Input : */ | |
dda08c59 BP |
7359 | /* Output : 0 : Skip PSC Control */ |
7360 | /* 1: Disable PSC */ | |
d7636e0b | 7361 | /* Description : */ |
7362 | /* --------------------------------------------------------------------- */ | |
80adad85 | 7363 | unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
d7636e0b | 7364 | { |
21df8fc8 | 7365 | unsigned short tempax; |
d7636e0b | 7366 | |
21df8fc8 PS |
7367 | tempax = pVBInfo->VBInfo; |
7368 | if (tempax & SetCRT2ToDualEdge) | |
7369 | return 0; | |
7370 | else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode)) | |
7371 | return 1; | |
d7636e0b | 7372 | |
21df8fc8 | 7373 | return 0; |
d7636e0b | 7374 | } |
7375 | ||
80adad85 | 7376 | void XGI_EnablePWD(struct vb_device_info *pVBInfo) |
d7636e0b | 7377 | { |
21df8fc8 | 7378 | unsigned short index, temp; |
d7636e0b | 7379 | |
21df8fc8 PS |
7380 | index = XGI_GetLCDCapPtr(pVBInfo); |
7381 | temp = pVBInfo->LCDCapList[index].PWD_2B; | |
7382 | XGINew_SetReg1(pVBInfo->Part4Port, 0x2B, temp); | |
7383 | XGINew_SetReg1(pVBInfo->Part4Port, 0x2C, | |
7384 | pVBInfo->LCDCapList[index].PWD_2C); | |
7385 | XGINew_SetReg1(pVBInfo->Part4Port, 0x2D, | |
7386 | pVBInfo->LCDCapList[index].PWD_2D); | |
7387 | XGINew_SetReg1(pVBInfo->Part4Port, 0x2E, | |
7388 | pVBInfo->LCDCapList[index].PWD_2E); | |
7389 | XGINew_SetReg1(pVBInfo->Part4Port, 0x2F, | |
7390 | pVBInfo->LCDCapList[index].PWD_2F); | |
7391 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x80); /* enable PWD */ | |
d7636e0b | 7392 | } |
7393 | ||
80adad85 | 7394 | void XGI_DisablePWD(struct vb_device_info *pVBInfo) |
d7636e0b | 7395 | { |
21df8fc8 | 7396 | XGINew_SetRegAND(pVBInfo->Part4Port, 0x27, 0x7F); /* disable PWD */ |
d7636e0b | 7397 | } |
7398 | ||
d7636e0b | 7399 | /* --------------------------------------------------------------------- */ |
7400 | /* Function : XGI_DisableChISLCD */ | |
7401 | /* Input : */ | |
dda08c59 | 7402 | /* Output : 0 -> Not LCD Mode */ |
d7636e0b | 7403 | /* Description : */ |
7404 | /* --------------------------------------------------------------------- */ | |
80adad85 | 7405 | unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
d7636e0b | 7406 | { |
21df8fc8 | 7407 | unsigned short tempbx, tempah; |
d7636e0b | 7408 | |
21df8fc8 PS |
7409 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
7410 | tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E)); | |
d7636e0b | 7411 | |
21df8fc8 PS |
7412 | if (tempbx & (EnableChA | DisableChA)) { |
7413 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ | |
7414 | return 0; | |
7415 | } | |
d7636e0b | 7416 | |
21df8fc8 PS |
7417 | if (!(tempbx & (EnableChB | DisableChB))) |
7418 | return 0; | |
d7636e0b | 7419 | |
21df8fc8 PS |
7420 | if (tempah & 0x01) /* Chk LCDB Mode */ |
7421 | return 1; | |
d7636e0b | 7422 | |
21df8fc8 | 7423 | return 0; |
d7636e0b | 7424 | } |
7425 | ||
d7636e0b | 7426 | /* --------------------------------------------------------------------- */ |
7427 | /* Function : XGI_EnableChISLCD */ | |
7428 | /* Input : */ | |
7429 | /* Output : 0 -> Not LCD mode */ | |
7430 | /* Description : */ | |
7431 | /* --------------------------------------------------------------------- */ | |
80adad85 | 7432 | unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
d7636e0b | 7433 | { |
21df8fc8 | 7434 | unsigned short tempbx, tempah; |
d7636e0b | 7435 | |
21df8fc8 PS |
7436 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
7437 | tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E)); | |
d7636e0b | 7438 | |
21df8fc8 PS |
7439 | if (tempbx & (EnableChA | DisableChA)) { |
7440 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ | |
7441 | return 0; | |
7442 | } | |
d7636e0b | 7443 | |
21df8fc8 | 7444 | if (!(tempbx & (EnableChB | DisableChB))) |
dda08c59 | 7445 | return 0; |
d7636e0b | 7446 | |
21df8fc8 PS |
7447 | if (tempah & 0x01) /* Chk LCDB Mode */ |
7448 | return 1; | |
d7636e0b | 7449 | |
21df8fc8 | 7450 | return 0; |
d7636e0b | 7451 | } |
7452 | ||
80adad85 | 7453 | unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
d7636e0b | 7454 | { |
21df8fc8 | 7455 | unsigned char tempal, tempah, tempbl, i; |
d7636e0b | 7456 | |
21df8fc8 PS |
7457 | tempah = XGINew_GetReg1(pVBInfo->P3d4, 0x36); |
7458 | tempal = tempah & 0x0F; | |
7459 | tempah = tempah & 0xF0; | |
7460 | i = 0; | |
7461 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
d7636e0b | 7462 | |
21df8fc8 PS |
7463 | while (tempbl != 0xFF) { |
7464 | if (tempbl & 0x80) { /* OEMUtil */ | |
7465 | tempal = tempah; | |
7466 | tempbl = tempbl & ~(0x80); | |
7467 | } | |
d7636e0b | 7468 | |
21df8fc8 PS |
7469 | if (tempal == tempbl) |
7470 | break; | |
d7636e0b | 7471 | |
21df8fc8 | 7472 | i++; |
d7636e0b | 7473 | |
21df8fc8 PS |
7474 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
7475 | } | |
d7636e0b | 7476 | |
21df8fc8 | 7477 | return i; |
d7636e0b | 7478 | } |
7479 | ||
80adad85 | 7480 | unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
d7636e0b | 7481 | { |
21df8fc8 | 7482 | unsigned short tempah, tempal, tempbl, i; |
d7636e0b | 7483 | |
21df8fc8 PS |
7484 | tempal = pVBInfo->LCDResInfo; |
7485 | tempah = pVBInfo->LCDTypeInfo; | |
d7636e0b | 7486 | |
21df8fc8 PS |
7487 | i = 0; |
7488 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
d7636e0b | 7489 | |
21df8fc8 PS |
7490 | while (tempbl != 0xFF) { |
7491 | if ((tempbl & 0x80) && (tempbl != 0x80)) { | |
7492 | tempal = tempah; | |
7493 | tempbl &= ~0x80; | |
7494 | } | |
d7636e0b | 7495 | |
21df8fc8 PS |
7496 | if (tempal == tempbl) |
7497 | break; | |
d7636e0b | 7498 | |
21df8fc8 PS |
7499 | i++; |
7500 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
7501 | } | |
d7636e0b | 7502 | |
21df8fc8 PS |
7503 | if (tempbl == 0xFF) { |
7504 | pVBInfo->LCDResInfo = Panel1024x768; | |
7505 | pVBInfo->LCDTypeInfo = 0; | |
7506 | i = 0; | |
7507 | } | |
d7636e0b | 7508 | |
21df8fc8 | 7509 | return i; |
d7636e0b | 7510 | } |
7511 | ||
21df8fc8 PS |
7512 | void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, |
7513 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7514 | { |
21df8fc8 | 7515 | unsigned short Index; |
d7636e0b | 7516 | |
21df8fc8 PS |
7517 | Index = XGI_GetLCDCapPtr(pVBInfo); |
7518 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; | |
7519 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; | |
d7636e0b | 7520 | |
21df8fc8 | 7521 | return; |
d7636e0b | 7522 | } |
7523 | ||
21df8fc8 PS |
7524 | void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
7525 | struct vb_device_info *pVBInfo) | |
7526 | { | |
7527 | unsigned short tempbl, tempah; | |
d7636e0b | 7528 | |
21df8fc8 PS |
7529 | if (pVBInfo->SetFlag == Win9xDOSMode) { |
7530 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
7531 | | VB_XGI302LV | VB_XGI301C)) { | |
7532 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
7533 | return; | |
7534 | } else | |
7535 | /* LVDS or CH7017 */ | |
7536 | return; | |
7537 | } | |
d7636e0b | 7538 | |
21df8fc8 PS |
7539 | if (HwDeviceExtension->jChipType < XG40) { |
7540 | if (!XGI_DisableChISLCD(pVBInfo)) { | |
7541 | if ((XGI_EnableChISLCD(pVBInfo)) || (pVBInfo->VBInfo | |
7542 | & (SetCRT2ToLCD | SetCRT2ToLCDA))) { | |
7543 | if (pVBInfo->LCDInfo & SetPWDEnable) { | |
7544 | XGI_EnablePWD(pVBInfo); | |
7545 | } else { | |
7546 | pVBInfo->LCDInfo &= (~SetPWDEnable); | |
7547 | if (pVBInfo->VBType & (VB_XGI301LV | |
7548 | | VB_XGI302LV | |
7549 | | VB_XGI301C)) { | |
7550 | tempbl = 0xFD; | |
7551 | tempah = 0x02; | |
7552 | } else { | |
7553 | tempbl = 0xFB; | |
7554 | tempah = 0x00; | |
7555 | } | |
7556 | ||
7557 | XGI_SetPanelPower(tempah, tempbl, | |
7558 | pVBInfo); | |
7559 | XGI_SetPanelDelay(1, pVBInfo); | |
7560 | } | |
7561 | } | |
7562 | } | |
7563 | } /* Not 340 */ | |
7564 | ||
7565 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
7566 | | VB_XGI302LV | VB_XGI301C)) { | |
7567 | if (!(pVBInfo->SetFlag & DisableChA)) { | |
7568 | if (pVBInfo->SetFlag & EnableChA) { | |
7569 | XGINew_SetReg1(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */ | |
7570 | } else { | |
7571 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */ | |
7572 | XGINew_SetReg1(pVBInfo->Part1Port, | |
7573 | 0x1E, 0x20); /* Power on */ | |
7574 | } | |
7575 | } | |
7576 | } | |
7577 | ||
7578 | if (!(pVBInfo->SetFlag & DisableChB)) { | |
7579 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo | |
7580 | & (SetCRT2ToLCD | SetCRT2ToTV | |
7581 | | SetCRT2ToRAMDAC))) { | |
7582 | tempah = (unsigned char) XGINew_GetReg1( | |
7583 | pVBInfo->P3c4, 0x32); | |
7584 | tempah &= 0xDF; | |
7585 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
7586 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) | |
7587 | tempah |= 0x20; | |
7588 | } | |
7589 | XGINew_SetReg1(pVBInfo->P3c4, 0x32, tempah); | |
7590 | XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x20); | |
7591 | ||
7592 | tempah = (unsigned char) XGINew_GetReg1( | |
7593 | pVBInfo->Part1Port, 0x2E); | |
7594 | ||
7595 | if (!(tempah & 0x80)) | |
7596 | XGINew_SetRegOR(pVBInfo->Part1Port, | |
7597 | 0x2E, 0x80); /* BVBDOENABLE = 1 */ | |
7598 | ||
7599 | XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */ | |
7600 | } | |
7601 | } | |
7602 | ||
7603 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) | |
7604 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { | |
7605 | XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x00, ~0xE0, | |
7606 | 0x20); /* shampoo 0129 */ | |
7607 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { | |
7608 | if (!XGI_DisableChISLCD(pVBInfo)) { | |
7609 | if (XGI_EnableChISLCD(pVBInfo) | |
7610 | || (pVBInfo->VBInfo | |
7611 | & (SetCRT2ToLCD | |
7612 | | SetCRT2ToLCDA))) | |
7613 | XGINew_SetRegAND( | |
7614 | pVBInfo->Part4Port, | |
7615 | 0x2A, 0x7F); /* LVDS PLL power on */ | |
7616 | } | |
7617 | XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */ | |
7618 | } | |
7619 | } | |
7620 | ||
7621 | tempah = 0x00; | |
7622 | ||
7623 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
7624 | tempah = 0xc0; | |
7625 | ||
7626 | if (!(pVBInfo->VBInfo & SetSimuScanMode)) { | |
7627 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
7628 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { | |
7629 | tempah = tempah & 0x40; | |
7630 | if (pVBInfo->VBInfo | |
7631 | & SetCRT2ToLCDA) | |
7632 | tempah = tempah ^ 0xC0; | |
7633 | ||
7634 | if (pVBInfo->SetFlag | |
7635 | & DisableChB) | |
7636 | tempah &= 0xBF; | |
7637 | ||
7638 | if (pVBInfo->SetFlag | |
7639 | & DisableChA) | |
7640 | tempah &= 0x7F; | |
7641 | ||
7642 | if (pVBInfo->SetFlag | |
7643 | & EnableChB) | |
7644 | tempah |= 0x40; | |
7645 | ||
7646 | if (pVBInfo->SetFlag | |
7647 | & EnableChA) | |
7648 | tempah |= 0x80; | |
7649 | } | |
7650 | } | |
7651 | } | |
7652 | } | |
7653 | ||
7654 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */ | |
7655 | ||
7656 | if (pVBInfo->SetFlag & Win9xDOSMode) { | |
7657 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
7658 | return; | |
7659 | } | |
7660 | ||
7661 | if (!(pVBInfo->SetFlag & DisableChA)) { | |
7662 | XGI_VBLongWait(pVBInfo); | |
7663 | if (!(pVBInfo->SetFlag & GatingCRT)) { | |
7664 | XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo); | |
7665 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
7666 | XGI_VBLongWait(pVBInfo); | |
7667 | } | |
7668 | } | |
7669 | } /* 301 */ | |
7670 | else { /* LVDS */ | |
7671 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | |
7672 | | SetCRT2ToLCDA)) | |
7673 | XGINew_SetRegOR(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */ | |
7674 | ||
7675 | tempah = (unsigned char) XGINew_GetReg1(pVBInfo->Part1Port, | |
7676 | 0x2E); | |
7677 | if (!(tempah & 0x80)) | |
7678 | XGINew_SetRegOR(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */ | |
7679 | ||
7680 | XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); | |
7681 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
7682 | } /* End of VB */ | |
7683 | ||
7684 | if (HwDeviceExtension->jChipType < XG40) { | |
7685 | if (!XGI_EnableChISLCD(pVBInfo)) { | |
7686 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
7687 | if (XGI_BacklightByDrv(pVBInfo)) | |
7688 | return; | |
7689 | } else | |
7690 | return; | |
7691 | } | |
7692 | ||
7693 | if (pVBInfo->LCDInfo & SetPWDEnable) { | |
7694 | XGI_FirePWDEnable(pVBInfo); | |
7695 | return; | |
7696 | } | |
7697 | ||
7698 | XGI_SetPanelDelay(2, pVBInfo); | |
7699 | ||
7700 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { | |
7701 | tempah = 0x01; | |
7702 | tempbl = 0xFE; /* turn on backlght */ | |
7703 | } else { | |
7704 | tempbl = 0xF7; | |
7705 | tempah = 0x00; | |
7706 | } | |
7707 | XGI_SetPanelPower(tempah, tempbl, pVBInfo); | |
7708 | } | |
d7636e0b | 7709 | } |
7710 | ||
21df8fc8 PS |
7711 | void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
7712 | struct vb_device_info *pVBInfo) | |
7713 | { | |
7714 | unsigned short tempax, tempbx, tempah = 0, tempbl = 0; | |
7715 | ||
7716 | if (pVBInfo->SetFlag == Win9xDOSMode) | |
7717 | return; | |
7718 | ||
7719 | if (HwDeviceExtension->jChipType < XG40) { | |
7720 | if ((!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) | |
7721 | || (XGI_DisableChISLCD(pVBInfo))) { | |
7722 | if (!XGI_IsLCDON(pVBInfo)) { | |
7723 | if (pVBInfo->LCDInfo & SetPWDEnable) | |
7724 | XGI_EnablePWD(pVBInfo); | |
7725 | else { | |
7726 | pVBInfo->LCDInfo &= ~SetPWDEnable; | |
7727 | XGI_DisablePWD(pVBInfo); | |
7728 | if (pVBInfo->VBType & (VB_XGI301LV | |
7729 | | VB_XGI302LV | |
7730 | | VB_XGI301C)) { | |
7731 | tempbx = 0xFE; /* not 01h */ | |
7732 | tempax = 0; | |
7733 | } else { | |
7734 | tempbx = 0xF7; /* not 08h */ | |
7735 | tempax = 0x08; | |
7736 | } | |
7737 | XGI_SetPanelPower(tempax, tempbx, | |
7738 | pVBInfo); | |
7739 | XGI_SetPanelDelay(3, pVBInfo); | |
7740 | } | |
7741 | } /* end if (!XGI_IsLCDON(pVBInfo)) */ | |
7742 | } | |
7743 | } | |
d7636e0b | 7744 | |
21df8fc8 PS |
7745 | /* |
7746 | if (CH7017) { | |
7747 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) { | |
7748 | if (!XGI_IsLCDON(pVBInfo)) { | |
7749 | if (DISCHARGE) { | |
7750 | tempbx = XGINew_GetCH7005(0x61); | |
7751 | if (tempbx < 0x01) // first time we power up | |
7752 | XGINew_SetCH7005(0x0066); // and disable power sequence | |
7753 | else | |
7754 | XGINew_SetCH7005(0x5f66); // leave VDD on - disable power | |
7755 | } | |
7756 | } | |
7757 | } | |
7758 | } | |
7759 | */ | |
7760 | ||
7761 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
7762 | | VB_XGI302LV | VB_XGI301C)) { | |
7763 | tempah = 0x3F; | |
7764 | if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) { | |
7765 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
7766 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { | |
7767 | tempah = 0x7F; /* Disable Channel A */ | |
7768 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) | |
7769 | tempah = 0xBF; /* Disable Channel B */ | |
7770 | ||
7771 | if (pVBInfo->SetFlag & DisableChB) | |
7772 | tempah &= 0xBF; /* force to disable Cahnnel */ | |
7773 | ||
7774 | if (pVBInfo->SetFlag & DisableChA) | |
7775 | tempah &= 0x7F; /* Force to disable Channel B */ | |
7776 | } | |
7777 | } | |
7778 | } | |
7779 | ||
7780 | XGINew_SetRegAND(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */ | |
7781 | ||
7782 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { | |
7783 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) | |
7784 | || (XGI_DisableChISLCD(pVBInfo)) | |
7785 | || (XGI_IsLCDON(pVBInfo))) | |
7786 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */ | |
7787 | } | |
7788 | ||
7789 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo | |
7790 | & (DisableCRT2Display | SetCRT2ToLCDA | |
7791 | | SetSimuScanMode))) { | |
7792 | if (pVBInfo->SetFlag & GatingCRT) | |
7793 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); | |
7794 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); | |
7795 | } | |
7796 | ||
7797 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
7798 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo | |
7799 | & SetCRT2ToLCDA)) | |
7800 | XGINew_SetRegAND(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */ | |
7801 | } | |
7802 | ||
7803 | XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */ | |
7804 | ||
7805 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) | |
7806 | XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xdf); | |
7807 | ||
7808 | if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo | |
7809 | & (DisableCRT2Display | SetSimuScanMode)) | |
7810 | || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) | |
7811 | && (pVBInfo->VBInfo | |
7812 | & (SetCRT2ToRAMDAC | |
7813 | | SetCRT2ToLCD | |
7814 | | SetCRT2ToTV)))) | |
7815 | XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */ | |
7816 | ||
7817 | if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo | |
7818 | & (DisableCRT2Display | SetSimuScanMode)) | |
7819 | || (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) | |
7820 | || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | |
7821 | | SetCRT2ToLCD | SetCRT2ToTV))) { | |
7822 | tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */ | |
7823 | XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */ | |
7824 | XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */ | |
7825 | XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */ | |
7826 | } | |
7827 | } else { /* {301} */ | |
7828 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { | |
7829 | XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */ | |
7830 | XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */ | |
7831 | XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */ | |
7832 | } | |
7833 | ||
7834 | if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA | |
7835 | | SetSimuScanMode)) | |
7836 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); | |
7837 | } | |
d7636e0b | 7838 | |
21df8fc8 PS |
7839 | if (HwDeviceExtension->jChipType < XG40) { |
7840 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) | |
7841 | || (XGI_DisableChISLCD(pVBInfo)) | |
7842 | || (XGI_IsLCDON(pVBInfo))) { | |
7843 | if (pVBInfo->LCDInfo & SetPWDEnable) { | |
7844 | if (pVBInfo->LCDInfo & SetPWDEnable) | |
7845 | XGI_BacklightByDrv(pVBInfo); | |
7846 | else { | |
7847 | XGI_SetPanelDelay(4, pVBInfo); | |
7848 | if (pVBInfo->VBType & VB_XGI301LV) { | |
7849 | tempbl = 0xFD; | |
7850 | tempah = 0x00; | |
7851 | } else { | |
7852 | tempbl = 0xFB; | |
7853 | tempah = 0x04; | |
7854 | } | |
7855 | } | |
7856 | } | |
7857 | XGI_SetPanelPower(tempah, tempbl, pVBInfo); | |
7858 | } | |
7859 | } | |
7860 | } | |
d7636e0b | 7861 | |
7862 | /* --------------------------------------------------------------------- */ | |
7863 | /* Function : XGI_GetTVPtrIndex */ | |
7864 | /* Input : */ | |
7865 | /* Output : */ | |
7866 | /* Description : bx 0 : ExtNTSC */ | |
7867 | /* 1 : StNTSC */ | |
7868 | /* 2 : ExtPAL */ | |
7869 | /* 3 : StPAL */ | |
7870 | /* 4 : ExtHiTV */ | |
7871 | /* 5 : StHiTV */ | |
7872 | /* 6 : Ext525i */ | |
7873 | /* 7 : St525i */ | |
7874 | /* 8 : Ext525p */ | |
7875 | /* 9 : St525p */ | |
7876 | /* A : Ext750p */ | |
7877 | /* B : St750p */ | |
7878 | /* --------------------------------------------------------------------- */ | |
80adad85 | 7879 | unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) |
d7636e0b | 7880 | { |
21df8fc8 | 7881 | unsigned short tempbx = 0; |
d7636e0b | 7882 | |
21df8fc8 PS |
7883 | if (pVBInfo->TVInfo & SetPALTV) |
7884 | tempbx = 2; | |
7885 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) | |
7886 | tempbx = 4; | |
7887 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
7888 | tempbx = 6; | |
7889 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
7890 | tempbx = 8; | |
7891 | if (pVBInfo->TVInfo & SetYPbPrMode750p) | |
7892 | tempbx = 10; | |
7893 | if (pVBInfo->TVInfo & TVSimuMode) | |
7894 | tempbx++; | |
d7636e0b | 7895 | |
21df8fc8 | 7896 | return tempbx; |
d7636e0b | 7897 | } |
7898 | ||
d7636e0b | 7899 | /* --------------------------------------------------------------------- */ |
7900 | /* Function : XGI_OEM310Setting */ | |
7901 | /* Input : */ | |
7902 | /* Output : */ | |
7903 | /* Description : Customized Param. for 301 */ | |
7904 | /* --------------------------------------------------------------------- */ | |
21df8fc8 PS |
7905 | void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, |
7906 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7907 | { |
21df8fc8 PS |
7908 | if (pVBInfo->SetFlag & Win9xDOSMode) |
7909 | return; | |
d7636e0b | 7910 | |
21df8fc8 PS |
7911 | /* GetPart1IO(); */ |
7912 | XGI_SetDelayComp(pVBInfo); | |
d7636e0b | 7913 | |
21df8fc8 PS |
7914 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
7915 | XGI_SetLCDCap(pVBInfo); | |
d7636e0b | 7916 | |
21df8fc8 PS |
7917 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
7918 | /* GetPart2IO() */ | |
7919 | XGI_SetPhaseIncr(pVBInfo); | |
7920 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); | |
7921 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); | |
d7636e0b | 7922 | |
21df8fc8 PS |
7923 | if (pVBInfo->VBType & VB_XGI301) |
7924 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); | |
7925 | } | |
d7636e0b | 7926 | } |
7927 | ||
80adad85 | 7928 | void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
d7636e0b | 7929 | { |
21df8fc8 PS |
7930 | unsigned short index; |
7931 | ||
7932 | unsigned char tempah, tempbl, tempbh; | |
7933 | ||
7934 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
7935 | | VB_XGI302LV | VB_XGI301C)) { | |
7936 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA | |
7937 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { | |
7938 | tempbl = 0; | |
7939 | tempbh = 0; | |
7940 | ||
7941 | index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */ | |
7942 | tempbl = pVBInfo->XGI_TVDelayList[index]; | |
7943 | ||
7944 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | |
7945 | | VB_XGI301LV | VB_XGI302LV | |
7946 | | VB_XGI301C)) | |
7947 | tempbl = pVBInfo->XGI_TVDelayList2[index]; | |
7948 | ||
7949 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
7950 | tempbl = tempbl >> 4; | |
7951 | /* | |
7952 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) | |
7953 | tempbl = CRT2Delay1; // Get CRT2 Delay | |
7954 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) | |
7955 | tempbl = CRT2Delay2; | |
7956 | */ | |
7957 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
7958 | index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */ | |
7959 | tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation; | |
7960 | ||
7961 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) | |
7962 | tempbl = tempbh; | |
7963 | } | |
7964 | ||
7965 | tempbl &= 0x0F; | |
7966 | tempbh &= 0xF0; | |
7967 | tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x2D); | |
7968 | ||
7969 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD | |
7970 | | SetCRT2ToTV)) { /* Channel B */ | |
7971 | tempah &= 0xF0; | |
7972 | tempah |= tempbl; | |
7973 | } | |
7974 | ||
7975 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */ | |
7976 | tempah &= 0x0F; | |
7977 | tempah |= tempbh; | |
7978 | } | |
7979 | XGINew_SetReg1(pVBInfo->Part1Port, 0x2D, tempah); | |
7980 | } | |
7981 | } else if (pVBInfo->IF_DEF_LVDS == 1) { | |
7982 | tempbl = 0; | |
7983 | tempbh = 0; | |
7984 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { | |
7985 | tempah | |
7986 | = pVBInfo->LCDCapList[XGI_GetLCDCapPtr( | |
7987 | pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */ | |
7988 | tempah &= 0x0f; | |
7989 | tempah = tempah << 4; | |
7990 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2D, 0x0f, | |
7991 | tempah); | |
7992 | } | |
7993 | } | |
d7636e0b | 7994 | } |
7995 | ||
80adad85 | 7996 | void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
d7636e0b | 7997 | { |
21df8fc8 PS |
7998 | unsigned short tempcx; |
7999 | ||
8000 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; | |
8001 | ||
8002 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
8003 | | VB_XGI302LV | VB_XGI301C)) { | |
8004 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */ | |
8005 | /* Set 301LV Capability */ | |
8006 | XGINew_SetReg1(pVBInfo->Part4Port, 0x24, | |
8007 | (unsigned char) (tempcx & 0x1F)); | |
8008 | } | |
8009 | /* VB Driving */ | |
8010 | XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, | |
8011 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), | |
8012 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW | |
8013 | | EnablePLLSPLOW)) >> 8)); | |
d7636e0b | 8014 | } |
d7636e0b | 8015 | |
21df8fc8 PS |
8016 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
8017 | | VB_XGI302LV | VB_XGI301C)) { | |
8018 | if (pVBInfo->VBInfo & SetCRT2ToLCD) | |
8019 | XGI_SetLCDCap_B(tempcx, pVBInfo); | |
8020 | else if (pVBInfo->VBInfo & SetCRT2ToLCDA) | |
8021 | XGI_SetLCDCap_A(tempcx, pVBInfo); | |
8022 | ||
8023 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { | |
8024 | if (tempcx & EnableSpectrum) | |
8025 | SetSpectrum(pVBInfo); | |
8026 | } | |
8027 | } else { | |
8028 | /* LVDS,CH7017 */ | |
8029 | XGI_SetLCDCap_A(tempcx, pVBInfo); | |
8030 | } | |
d7636e0b | 8031 | } |
8032 | ||
80adad85 | 8033 | void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo) |
d7636e0b | 8034 | { |
21df8fc8 | 8035 | unsigned short temp; |
d7636e0b | 8036 | |
21df8fc8 | 8037 | temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); |
d7636e0b | 8038 | |
21df8fc8 PS |
8039 | if (temp & LCDRGB18Bit) { |
8040 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, | |
8041 | (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */ | |
8042 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); | |
8043 | } else { | |
8044 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, | |
8045 | (unsigned short) (0x30 | (tempcx & 0x00C0))); | |
8046 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); | |
8047 | } | |
d7636e0b | 8048 | |
21df8fc8 PS |
8049 | /* |
8050 | if (tempcx & EnableLCD24bpp) { // 24bits | |
8051 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0))); | |
8052 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); | |
8053 | } else { | |
8054 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither | |
8055 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); | |
8056 | } | |
8057 | */ | |
d7636e0b | 8058 | } |
8059 | ||
d7636e0b | 8060 | /* --------------------------------------------------------------------- */ |
8061 | /* Function : XGI_SetLCDCap_B */ | |
8062 | /* Input : cx -> LCD Capability */ | |
8063 | /* Output : */ | |
8064 | /* Description : */ | |
8065 | /* --------------------------------------------------------------------- */ | |
80adad85 | 8066 | void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo) |
d7636e0b | 8067 | { |
21df8fc8 PS |
8068 | if (tempcx & EnableLCD24bpp) /* 24bits */ |
8069 | XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0, | |
8070 | (unsigned short) (((tempcx & 0x00ff) >> 6) | |
8071 | | 0x0c)); | |
8072 | else | |
8073 | XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0, | |
8074 | (unsigned short) (((tempcx & 0x00ff) >> 6) | |
8075 | | 0x18)); /* Enable Dither */ | |
d7636e0b | 8076 | } |
8077 | ||
80adad85 | 8078 | void SetSpectrum(struct vb_device_info *pVBInfo) |
d7636e0b | 8079 | { |
21df8fc8 | 8080 | unsigned short index; |
d7636e0b | 8081 | |
21df8fc8 | 8082 | index = XGI_GetLCDCapPtr(pVBInfo); |
d7636e0b | 8083 | |
21df8fc8 PS |
8084 | XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */ |
8085 | XGI_LongWait(pVBInfo); | |
8086 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ | |
8087 | XGI_LongWait(pVBInfo); | |
d7636e0b | 8088 | |
21df8fc8 PS |
8089 | XGINew_SetReg1(pVBInfo->Part4Port, 0x31, |
8090 | pVBInfo->LCDCapList[index].Spectrum_31); | |
8091 | XGINew_SetReg1(pVBInfo->Part4Port, 0x32, | |
8092 | pVBInfo->LCDCapList[index].Spectrum_32); | |
8093 | XGINew_SetReg1(pVBInfo->Part4Port, 0x33, | |
8094 | pVBInfo->LCDCapList[index].Spectrum_33); | |
8095 | XGINew_SetReg1(pVBInfo->Part4Port, 0x34, | |
8096 | pVBInfo->LCDCapList[index].Spectrum_34); | |
8097 | XGI_LongWait(pVBInfo); | |
8098 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ | |
d7636e0b | 8099 | } |
8100 | ||
d7636e0b | 8101 | /* --------------------------------------------------------------------- */ |
8102 | /* Function : XGI_SetAntiFlicker */ | |
8103 | /* Input : */ | |
8104 | /* Output : */ | |
8105 | /* Description : Set TV Customized Param. */ | |
8106 | /* --------------------------------------------------------------------- */ | |
82d6eb5b | 8107 | void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 8108 | struct vb_device_info *pVBInfo) |
d7636e0b | 8109 | { |
21df8fc8 | 8110 | unsigned short tempbx, index; |
d7636e0b | 8111 | |
21df8fc8 | 8112 | unsigned char tempah; |
d7636e0b | 8113 | |
21df8fc8 PS |
8114 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
8115 | return; | |
d7636e0b | 8116 | |
21df8fc8 PS |
8117 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
8118 | tempbx &= 0xFE; | |
d7636e0b | 8119 | |
21df8fc8 PS |
8120 | if (ModeNo <= 0x13) |
8121 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; | |
8122 | else | |
8123 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; | |
d7636e0b | 8124 | |
21df8fc8 PS |
8125 | tempbx += index; |
8126 | tempah = TVAntiFlickList[tempbx]; | |
8127 | tempah = tempah << 4; | |
d7636e0b | 8128 | |
21df8fc8 | 8129 | XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
d7636e0b | 8130 | } |
8131 | ||
21df8fc8 PS |
8132 | void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, |
8133 | struct vb_device_info *pVBInfo) | |
d7636e0b | 8134 | { |
21df8fc8 | 8135 | unsigned short tempbx, index; |
d7636e0b | 8136 | |
21df8fc8 | 8137 | unsigned char tempah; |
d7636e0b | 8138 | |
21df8fc8 PS |
8139 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
8140 | tempbx &= 0xFE; | |
d7636e0b | 8141 | |
21df8fc8 PS |
8142 | if (ModeNo <= 0x13) |
8143 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; | |
8144 | else | |
8145 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; | |
d7636e0b | 8146 | |
21df8fc8 PS |
8147 | tempbx += index; |
8148 | tempah = TVEdgeList[tempbx]; | |
8149 | tempah = tempah << 5; | |
d7636e0b | 8150 | |
21df8fc8 | 8151 | XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
d7636e0b | 8152 | } |
8153 | ||
80adad85 | 8154 | void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
d7636e0b | 8155 | { |
21df8fc8 | 8156 | unsigned short tempbx; |
d7636e0b | 8157 | |
21df8fc8 | 8158 | unsigned char tempcl, tempch; |
d7636e0b | 8159 | |
21df8fc8 | 8160 | unsigned long tempData; |
d7636e0b | 8161 | |
21df8fc8 PS |
8162 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
8163 | tempData = TVPhaseList[tempbx]; | |
d7636e0b | 8164 | |
21df8fc8 PS |
8165 | XGINew_SetReg1(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
8166 | & 0x000000FF)); | |
8167 | XGINew_SetReg1(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData | |
8168 | & 0x0000FF00) >> 8)); | |
8169 | XGINew_SetReg1(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData | |
8170 | & 0x00FF0000) >> 16)); | |
8171 | XGINew_SetReg1(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData | |
8172 | & 0xFF000000) >> 24)); | |
d7636e0b | 8173 | } |
8174 | ||
82d6eb5b | 8175 | void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
8176 | struct vb_device_info *pVBInfo) |
8177 | { | |
8178 | unsigned short tempbx, index; | |
8179 | ||
8180 | unsigned char tempcl, tempch, tempal, *filterPtr; | |
8181 | ||
8182 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ | |
8183 | ||
8184 | switch (tempbx) { | |
8185 | case 0x00: | |
8186 | case 0x04: | |
8187 | filterPtr = NTSCYFilter1; | |
8188 | break; | |
8189 | ||
8190 | case 0x01: | |
8191 | filterPtr = PALYFilter1; | |
8192 | break; | |
8193 | ||
8194 | case 0x02: | |
8195 | case 0x05: | |
8196 | case 0x0D: | |
8197 | filterPtr = PALMYFilter1; | |
8198 | break; | |
8199 | ||
8200 | case 0x03: | |
8201 | filterPtr = PALNYFilter1; | |
8202 | break; | |
8203 | ||
8204 | case 0x08: | |
8205 | case 0x0C: | |
8206 | filterPtr = NTSCYFilter2; | |
8207 | break; | |
8208 | ||
8209 | case 0x0A: | |
8210 | filterPtr = PALMYFilter2; | |
8211 | break; | |
8212 | ||
8213 | case 0x0B: | |
8214 | filterPtr = PALNYFilter2; | |
8215 | break; | |
8216 | ||
8217 | case 0x09: | |
8218 | filterPtr = PALYFilter2; | |
8219 | break; | |
d7636e0b | 8220 | |
21df8fc8 PS |
8221 | default: |
8222 | return; | |
8223 | } | |
8224 | ||
8225 | if (ModeNo <= 0x13) | |
8226 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; | |
8227 | else | |
8228 | tempal | |
8229 | = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; | |
8230 | ||
8231 | if (tempcl == 0) | |
8232 | index = tempal * 4; | |
8233 | else | |
8234 | index = tempal * 7; | |
8235 | ||
8236 | if ((tempcl == 0) && (tempch == 1)) { | |
8237 | XGINew_SetReg1(pVBInfo->Part2Port, 0x35, 0); | |
8238 | XGINew_SetReg1(pVBInfo->Part2Port, 0x36, 0); | |
8239 | XGINew_SetReg1(pVBInfo->Part2Port, 0x37, 0); | |
8240 | XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]); | |
8241 | } else { | |
8242 | XGINew_SetReg1(pVBInfo->Part2Port, 0x35, filterPtr[index++]); | |
8243 | XGINew_SetReg1(pVBInfo->Part2Port, 0x36, filterPtr[index++]); | |
8244 | XGINew_SetReg1(pVBInfo->Part2Port, 0x37, filterPtr[index++]); | |
8245 | XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]); | |
8246 | } | |
8247 | ||
8248 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
8249 | | VB_XGI302LV | VB_XGI301C)) { | |
8250 | XGINew_SetReg1(pVBInfo->Part2Port, 0x48, filterPtr[index++]); | |
8251 | XGINew_SetReg1(pVBInfo->Part2Port, 0x49, filterPtr[index++]); | |
8252 | XGINew_SetReg1(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); | |
8253 | } | |
8254 | } | |
d7636e0b | 8255 | |
8256 | /* --------------------------------------------------------------------- */ | |
8257 | /* Function : XGI_GetTVPtrIndex2 */ | |
8258 | /* Input : */ | |
8259 | /* Output : bx 0 : NTSC */ | |
8260 | /* 1 : PAL */ | |
8261 | /* 2 : PALM */ | |
8262 | /* 3 : PALN */ | |
8263 | /* 4 : NTSC1024x768 */ | |
8264 | /* 5 : PAL-M 1024x768 */ | |
8265 | /* 6-7: reserved */ | |
8266 | /* cl 0 : YFilter1 */ | |
8267 | /* 1 : YFilter2 */ | |
8268 | /* ch 0 : 301A */ | |
8269 | /* 1 : 301B/302B/301LV/302LV */ | |
8270 | /* Description : */ | |
8271 | /* --------------------------------------------------------------------- */ | |
108afbf8 | 8272 | void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, |
21df8fc8 | 8273 | unsigned char *tempch, struct vb_device_info *pVBInfo) |
d7636e0b | 8274 | { |
21df8fc8 PS |
8275 | *tempbx = 0; |
8276 | *tempcl = 0; | |
8277 | *tempch = 0; | |
d7636e0b | 8278 | |
21df8fc8 PS |
8279 | if (pVBInfo->TVInfo & SetPALTV) |
8280 | *tempbx = 1; | |
d7636e0b | 8281 | |
21df8fc8 PS |
8282 | if (pVBInfo->TVInfo & SetPALMTV) |
8283 | *tempbx = 2; | |
d7636e0b | 8284 | |
21df8fc8 PS |
8285 | if (pVBInfo->TVInfo & SetPALNTV) |
8286 | *tempbx = 3; | |
d7636e0b | 8287 | |
21df8fc8 PS |
8288 | if (pVBInfo->TVInfo & NTSC1024x768) { |
8289 | *tempbx = 4; | |
8290 | if (pVBInfo->TVInfo & SetPALMTV) | |
8291 | *tempbx = 5; | |
8292 | } | |
d7636e0b | 8293 | |
21df8fc8 PS |
8294 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
8295 | | VB_XGI302LV | VB_XGI301C)) { | |
8296 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo | |
8297 | & TVSimuMode)) { | |
8298 | *tempbx += 8; | |
8299 | *tempcl += 1; | |
8300 | } | |
8301 | } | |
d7636e0b | 8302 | |
21df8fc8 PS |
8303 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
8304 | | VB_XGI302LV | VB_XGI301C)) | |
8305 | (*tempch)++; | |
d7636e0b | 8306 | } |
8307 | ||
d7636e0b | 8308 | /* --------------------------------------------------------------------- */ |
8309 | /* Function : XGI_SetCRT2ModeRegs */ | |
8310 | /* Input : */ | |
8311 | /* Output : */ | |
8312 | /* Description : Origin code for crt2group */ | |
8313 | /* --------------------------------------------------------------------- */ | |
82d6eb5b | 8314 | void XGI_SetCRT2ModeRegs(unsigned short ModeNo, |
21df8fc8 PS |
8315 | struct xgi_hw_device_info *HwDeviceExtension, |
8316 | struct vb_device_info *pVBInfo) | |
8317 | { | |
8318 | unsigned short tempbl; | |
8319 | short tempcl; | |
8320 | ||
8321 | unsigned char tempah; | |
8322 | ||
8323 | /* XGINew_SetReg1(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */ | |
8324 | tempah = 0; | |
8325 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
8326 | tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); | |
8327 | tempah &= ~0x10; /* BTRAMDAC */ | |
8328 | tempah |= 0x40; /* BTRAM */ | |
8329 | ||
8330 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
8331 | | SetCRT2ToLCD)) { | |
8332 | tempah = 0x40; /* BTDRAM */ | |
8333 | if (ModeNo > 0x13) { | |
8334 | tempcl = pVBInfo->ModeType; | |
8335 | tempcl -= ModeVGA; | |
8336 | if (tempcl >= 0) { | |
8337 | tempah = (0x008 >> tempcl); /* BT Color */ | |
8338 | if (tempah == 0) | |
8339 | tempah = 1; | |
8340 | tempah |= 0x040; | |
8341 | } | |
8342 | } | |
8343 | if (pVBInfo->VBInfo & SetInSlaveMode) | |
8344 | tempah ^= 0x50; /* BTDAC */ | |
8345 | } | |
8346 | } | |
d7636e0b | 8347 | |
21df8fc8 PS |
8348 | /* 0210 shampoo |
8349 | if (pVBInfo->VBInfo & DisableCRT2Display) { | |
8350 | tempah = 0; | |
8351 | } | |
d7636e0b | 8352 | |
21df8fc8 PS |
8353 | XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); |
8354 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) { | |
8355 | tempcl = pVBInfo->ModeType; | |
8356 | if (ModeNo > 0x13) { | |
8357 | tempcl -= ModeVGA; | |
8358 | if ((tempcl > 0) || (tempcl == 0)) { | |
8359 | tempah=(0x008>>tempcl) ; | |
8360 | if (tempah == 0) | |
8361 | tempah = 1; | |
8362 | tempah |= 0x040; | |
8363 | } | |
8364 | } else { | |
8365 | tempah = 0x040; | |
8366 | } | |
8367 | ||
8368 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
8369 | tempah = (tempah ^ 0x050); | |
8370 | } | |
8371 | } | |
8372 | */ | |
8373 | ||
8374 | XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); | |
8375 | tempah = 0x08; | |
8376 | tempbl = 0xf0; | |
8377 | ||
8378 | if (pVBInfo->VBInfo & DisableCRT2Display) { | |
8379 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, tempah); | |
8380 | } else { | |
8381 | tempah = 0x00; | |
8382 | tempbl = 0xff; | |
8383 | ||
8384 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
8385 | | SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
8386 | if ((pVBInfo->VBInfo & SetCRT2ToLCDA) | |
8387 | && (!(pVBInfo->VBInfo & SetSimuScanMode))) { | |
8388 | tempbl &= 0xf7; | |
8389 | tempah |= 0x01; | |
8390 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, | |
8391 | tempbl, tempah); | |
8392 | } else { | |
8393 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
8394 | tempbl &= 0xf7; | |
8395 | tempah |= 0x01; | |
8396 | } | |
8397 | ||
8398 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | |
8399 | | SetCRT2ToTV | SetCRT2ToLCD)) { | |
8400 | tempbl &= 0xf8; | |
8401 | tempah = 0x01; | |
8402 | ||
8403 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) | |
8404 | tempah |= 0x02; | |
8405 | ||
8406 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { | |
8407 | tempah = tempah ^ 0x05; | |
8408 | if (!(pVBInfo->VBInfo | |
8409 | & SetCRT2ToLCD)) | |
8410 | tempah = tempah ^ 0x01; | |
8411 | } | |
8412 | ||
8413 | if (!(pVBInfo->VBInfo | |
8414 | & SetCRT2ToDualEdge)) | |
8415 | tempah |= 0x08; | |
8416 | XGINew_SetRegANDOR(pVBInfo->Part1Port, | |
8417 | 0x2e, tempbl, tempah); | |
8418 | } else { | |
8419 | XGINew_SetRegANDOR(pVBInfo->Part1Port, | |
8420 | 0x2e, tempbl, tempah); | |
8421 | } | |
8422 | } | |
8423 | } else { | |
8424 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, | |
8425 | tempah); | |
8426 | } | |
8427 | } | |
d7636e0b | 8428 | |
21df8fc8 PS |
8429 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
8430 | | SetCRT2ToLCDA)) { | |
8431 | tempah &= (~0x08); | |
8432 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo | |
8433 | & SetInSlaveMode))) { | |
8434 | tempah |= 0x010; | |
8435 | } | |
8436 | tempah |= 0x080; | |
8437 | ||
8438 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
8439 | /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */ | |
8440 | tempah |= 0x020; | |
8441 | if (ModeNo > 0x13) { | |
8442 | if (pVBInfo->VBInfo & DriverMode) | |
8443 | tempah = tempah ^ 0x20; | |
8444 | } | |
8445 | /* } */ | |
8446 | } | |
8447 | ||
8448 | XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); | |
8449 | tempah = 0; | |
8450 | ||
8451 | if (pVBInfo->LCDInfo & SetLCDDualLink) | |
8452 | tempah |= 0x40; | |
8453 | ||
8454 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
8455 | /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */ | |
8456 | if (pVBInfo->TVInfo & RPLLDIV2XO) | |
8457 | tempah |= 0x40; | |
8458 | /* } */ | |
8459 | } | |
8460 | ||
8461 | if ((pVBInfo->LCDResInfo == Panel1280x1024) | |
8462 | || (pVBInfo->LCDResInfo == Panel1280x1024x75)) | |
8463 | tempah |= 0x80; | |
8464 | ||
8465 | if (pVBInfo->LCDResInfo == Panel1280x960) | |
8466 | tempah |= 0x80; | |
8467 | ||
8468 | XGINew_SetReg1(pVBInfo->Part4Port, 0x0C, tempah); | |
8469 | } | |
d7636e0b | 8470 | |
21df8fc8 PS |
8471 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
8472 | | VB_XGI302LV | VB_XGI301C)) { | |
8473 | tempah = 0; | |
8474 | tempbl = 0xfb; | |
8475 | ||
8476 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { | |
8477 | tempbl = 0xff; | |
8478 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) | |
8479 | tempah |= 0x04; /* shampoo 0129 */ | |
8480 | } | |
8481 | ||
8482 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x13, tempbl, tempah); | |
8483 | tempah = 0x00; | |
8484 | tempbl = 0xcf; | |
8485 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
8486 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
8487 | tempah |= 0x30; | |
8488 | } | |
8489 | ||
8490 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2c, tempbl, tempah); | |
8491 | tempah = 0; | |
8492 | tempbl = 0x3f; | |
8493 | ||
8494 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
8495 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
8496 | tempah |= 0xc0; | |
8497 | } | |
8498 | XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, tempbl, tempah); | |
8499 | } | |
d7636e0b | 8500 | |
21df8fc8 PS |
8501 | tempah = 0; |
8502 | tempbl = 0x7f; | |
8503 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) { | |
8504 | tempbl = 0xff; | |
8505 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) | |
8506 | tempah |= 0x80; | |
8507 | } | |
d7636e0b | 8508 | |
21df8fc8 | 8509 | XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
d7636e0b | 8510 | |
21df8fc8 PS |
8511 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
8512 | if (pVBInfo->LCDInfo & SetLCDDualLink) { | |
8513 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x20); | |
8514 | XGINew_SetRegOR(pVBInfo->Part4Port, 0x34, 0x10); | |
8515 | } | |
8516 | } | |
d7636e0b | 8517 | } |
8518 | ||
21df8fc8 PS |
8519 | void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
8520 | struct vb_device_info *pVBInfo) | |
d7636e0b | 8521 | { |
21df8fc8 | 8522 | unsigned short tempbx; |
d7636e0b | 8523 | |
21df8fc8 | 8524 | tempbx = 0; |
d7636e0b | 8525 | |
21df8fc8 PS |
8526 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
8527 | tempbx = 0x08A0; | |
d7636e0b | 8528 | |
8529 | } | |
8530 | ||
21df8fc8 PS |
8531 | void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
8532 | struct vb_device_info *pVBInfo) | |
8533 | { | |
8534 | unsigned short tempbx; | |
8535 | tempbx = 0; | |
d7636e0b | 8536 | } |
8537 | ||
21df8fc8 PS |
8538 | void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex, |
8539 | unsigned short RefreshRateTableIndex, | |
8540 | struct vb_device_info *pVBInfo) | |
8541 | { | |
8542 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, | |
8543 | StandTableIndex, CRT1Index; | |
d7636e0b | 8544 | |
21df8fc8 PS |
8545 | pVBInfo->RVBHCMAX = 1; |
8546 | pVBInfo->RVBHCFACT = 1; | |
d7636e0b | 8547 | |
21df8fc8 PS |
8548 | if (ModeNo <= 0x13) { |
8549 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
8550 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
8551 | tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0]; | |
8552 | tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6]; | |
8553 | temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7]; | |
8554 | } else { | |
8555 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
8556 | CRT1Index | |
8557 | = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
8558 | CRT1Index &= IndexMask; | |
8559 | temp1 | |
8560 | = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0]; | |
8561 | temp2 | |
8562 | = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; | |
8563 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); | |
8564 | tempbx | |
8565 | = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8]; | |
8566 | tempcx | |
8567 | = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] | |
8568 | << 8; | |
8569 | tempcx &= 0x0100; | |
8570 | tempcx = tempcx << 2; | |
8571 | tempbx |= tempcx; | |
8572 | temp1 | |
8573 | = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; | |
8574 | } | |
d7636e0b | 8575 | |
21df8fc8 PS |
8576 | if (temp1 & 0x01) |
8577 | tempbx |= 0x0100; | |
d7636e0b | 8578 | |
21df8fc8 PS |
8579 | if (temp1 & 0x20) |
8580 | tempbx |= 0x0200; | |
8581 | tempax += 5; | |
d7636e0b | 8582 | |
21df8fc8 PS |
8583 | if (modeflag & Charx8Dot) |
8584 | tempax *= 8; | |
8585 | else | |
8586 | tempax *= 9; | |
d7636e0b | 8587 | |
21df8fc8 PS |
8588 | pVBInfo->VGAHT = tempax; |
8589 | pVBInfo->HT = tempax; | |
8590 | tempbx++; | |
8591 | pVBInfo->VGAVT = tempbx; | |
8592 | pVBInfo->VT = tempbx; | |
d7636e0b | 8593 | } |
8594 | ||
21df8fc8 PS |
8595 | unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
8596 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) | |
8597 | { | |
8598 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; | |
8599 | short index; | |
8600 | unsigned short modeflag; | |
d7636e0b | 8601 | |
21df8fc8 PS |
8602 | if (ModeNo <= 0x13) |
8603 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
8604 | else | |
8605 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 8606 | |
21df8fc8 | 8607 | index = (modeflag & ModeInfoFlag) - ModeEGA; |
d7636e0b | 8608 | |
21df8fc8 PS |
8609 | if (index < 0) |
8610 | index = 0; | |
d7636e0b | 8611 | |
21df8fc8 | 8612 | return ColorDepth[index]; |
d7636e0b | 8613 | } |
8614 | ||
21df8fc8 PS |
8615 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
8616 | struct vb_device_info *pVBInfo) | |
d7636e0b | 8617 | { |
8618 | ||
21df8fc8 | 8619 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
d7636e0b | 8620 | |
8621 | } | |
8622 | ||
21df8fc8 PS |
8623 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
8624 | struct vb_device_info *pVBInfo) | |
d7636e0b | 8625 | { |
d7636e0b | 8626 | |
21df8fc8 | 8627 | XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
d7636e0b | 8628 | |
21df8fc8 | 8629 | } |
d7636e0b | 8630 | |
21df8fc8 | 8631 | void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
d7636e0b | 8632 | { |
21df8fc8 PS |
8633 | XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
8634 | } | |
d7636e0b | 8635 | |
80adad85 | 8636 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
d7636e0b | 8637 | { |
21df8fc8 | 8638 | unsigned short flag; |
d7636e0b | 8639 | |
21df8fc8 PS |
8640 | if (pVBInfo->IF_DEF_LVDS == 1) { |
8641 | return 1; | |
8642 | } else { | |
8643 | flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00); | |
8644 | if ((flag == 1) || (flag == 2)) | |
8645 | return 1; /* 301b */ | |
8646 | else | |
8647 | return 0; | |
8648 | } | |
d7636e0b | 8649 | } |
8650 | ||
80adad85 | 8651 | void XGI_LongWait(struct vb_device_info *pVBInfo) |
d7636e0b | 8652 | { |
21df8fc8 | 8653 | unsigned short i; |
d7636e0b | 8654 | |
21df8fc8 | 8655 | i = XGINew_GetReg1(pVBInfo->P3c4, 0x1F); |
d7636e0b | 8656 | |
21df8fc8 PS |
8657 | if (!(i & 0xC0)) { |
8658 | for (i = 0; i < 0xFFFF; i++) { | |
8659 | if (!(XGINew_GetReg2(pVBInfo->P3da) & 0x08)) | |
8660 | break; | |
8661 | } | |
d7636e0b | 8662 | |
21df8fc8 PS |
8663 | for (i = 0; i < 0xFFFF; i++) { |
8664 | if ((XGINew_GetReg2(pVBInfo->P3da) & 0x08)) | |
8665 | break; | |
8666 | } | |
d7636e0b | 8667 | } |
d7636e0b | 8668 | } |
8669 | ||
80adad85 | 8670 | void XGI_VBLongWait(struct vb_device_info *pVBInfo) |
d7636e0b | 8671 | { |
21df8fc8 PS |
8672 | unsigned short tempal, temp, i, j; |
8673 | return; | |
8674 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { | |
8675 | temp = 0; | |
8676 | for (i = 0; i < 3; i++) { | |
8677 | for (j = 0; j < 100; j++) { | |
8678 | tempal = XGINew_GetReg2(pVBInfo->P3da); | |
8679 | if (temp & 0x01) { /* VBWaitMode2 */ | |
8680 | if ((tempal & 0x08)) | |
8681 | continue; | |
8682 | ||
8683 | if (!(tempal & 0x08)) | |
8684 | break; | |
8685 | ||
8686 | } else { /* VBWaitMode1 */ | |
8687 | if (!(tempal & 0x08)) | |
8688 | continue; | |
8689 | ||
8690 | if ((tempal & 0x08)) | |
8691 | break; | |
8692 | } | |
8693 | } | |
8694 | temp = temp ^ 0x01; | |
8695 | } | |
8696 | } else { | |
8697 | XGI_LongWait(pVBInfo); | |
8698 | } | |
8699 | return; | |
d7636e0b | 8700 | } |
8701 | ||
80adad85 | 8702 | unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
d7636e0b | 8703 | { |
21df8fc8 | 8704 | unsigned long tempax, tempbx; |
d7636e0b | 8705 | |
21df8fc8 PS |
8706 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
8707 | & 0xFFFF; | |
8708 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; | |
8709 | tempax = (tempax * pVBInfo->HT) / tempbx; | |
d7636e0b | 8710 | |
21df8fc8 | 8711 | return (unsigned short) tempax; |
d7636e0b | 8712 | } |
8713 | ||
e4147abe | 8714 | unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
21df8fc8 PS |
8715 | unsigned short ModeIdIndex, |
8716 | unsigned short RefreshRateTableIndex, | |
8717 | struct xgi_hw_device_info *HwDeviceExtension, | |
8718 | struct vb_device_info *pVBInfo) | |
8719 | { | |
8720 | unsigned short tempbx; | |
8721 | ||
8722 | unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2, | |
8723 | VCLK65 + 2 }; | |
8724 | unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5, | |
8725 | VCLK108_2 + 5, VCLK108_2 + 5 }; | |
8726 | unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 }; | |
8727 | unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2, | |
8728 | VCLK65 + 2 }; | |
8729 | unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2, | |
8730 | VCLK65 + 2 }; | |
8731 | ||
8732 | unsigned short CRT2Index, VCLKIndex; | |
8733 | unsigned short modeflag, resinfo; | |
8734 | unsigned char *CHTVVCLKPtr = NULL; | |
8735 | ||
8736 | if (ModeNo <= 0x13) { | |
8737 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ | |
8738 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; | |
8739 | CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
8740 | } else { | |
8741 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */ | |
8742 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
8743 | CRT2Index | |
8744 | = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; | |
8745 | } | |
8746 | ||
8747 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
8748 | CRT2Index = CRT2Index >> 6; /* for LCD */ | |
a65fd09a | 8749 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/ |
21df8fc8 PS |
8750 | if (pVBInfo->LCDResInfo != Panel1024x768) |
8751 | VCLKIndex = LCDXlat2VCLK[CRT2Index]; | |
8752 | else | |
8753 | VCLKIndex = LCDXlat1VCLK[CRT2Index]; | |
8754 | } else { /* for TV */ | |
8755 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
8756 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
8757 | if (pVBInfo->SetFlag & RPLLDIV2XO) { | |
8758 | VCLKIndex = HiTVVCLKDIV2; | |
8759 | ||
8760 | VCLKIndex += 25; | |
8761 | ||
8762 | } else { | |
8763 | VCLKIndex = HiTVVCLK; | |
8764 | ||
8765 | VCLKIndex += 25; | |
8766 | ||
8767 | } | |
8768 | ||
8769 | if (pVBInfo->SetFlag & TVSimuMode) { | |
8770 | if (modeflag & Charx8Dot) { | |
8771 | VCLKIndex | |
8772 | = HiTVSimuVCLK; | |
8773 | ||
8774 | VCLKIndex += 25; | |
8775 | ||
8776 | } else { | |
8777 | VCLKIndex | |
8778 | = HiTVTextVCLK; | |
8779 | ||
8780 | VCLKIndex += 25; | |
8781 | ||
8782 | } | |
8783 | } | |
8784 | ||
8785 | if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */ | |
8786 | if (!(pVBInfo->VBExtInfo | |
8787 | == VB_YPbPr1080i)) { | |
8788 | VCLKIndex | |
8789 | = YPbPr750pVCLK; | |
8790 | if (!(pVBInfo->VBExtInfo | |
8791 | == VB_YPbPr750p)) { | |
8792 | VCLKIndex | |
8793 | = YPbPr525pVCLK; | |
8794 | if (!(pVBInfo->VBExtInfo | |
8795 | == VB_YPbPr525p)) { | |
8796 | VCLKIndex | |
8797 | = YPbPr525iVCLK_2; | |
8798 | if (!(pVBInfo->SetFlag | |
8799 | & RPLLDIV2XO)) | |
8800 | VCLKIndex | |
8801 | = YPbPr525iVCLK; | |
8802 | } | |
8803 | } | |
8804 | } | |
8805 | } | |
8806 | } else { | |
8807 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
8808 | if (pVBInfo->SetFlag | |
8809 | & RPLLDIV2XO) { | |
8810 | VCLKIndex = TVVCLKDIV2; | |
8811 | ||
8812 | VCLKIndex += 25; | |
8813 | ||
8814 | } else { | |
8815 | VCLKIndex = TVVCLK; | |
8816 | ||
8817 | VCLKIndex += 25; | |
8818 | ||
8819 | } | |
8820 | } | |
8821 | } | |
8822 | } else { /* for CRT2 */ | |
8823 | VCLKIndex = (unsigned char) XGINew_GetReg2( | |
8824 | (pVBInfo->P3ca + 0x02)); /* Port 3cch */ | |
8825 | VCLKIndex = ((VCLKIndex >> 2) & 0x03); | |
8826 | if (ModeNo > 0x13) { | |
8827 | VCLKIndex | |
8828 | = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */ | |
8829 | VCLKIndex &= IndexMask; | |
8830 | } | |
8831 | } | |
8832 | } | |
8833 | } else { /* LVDS */ | |
8834 | if (ModeNo <= 0x13) | |
8835 | VCLKIndex = CRT2Index; | |
8836 | else | |
8837 | VCLKIndex = CRT2Index; | |
8838 | ||
8839 | if (pVBInfo->IF_DEF_CH7005 == 1) { | |
8840 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) { | |
8841 | VCLKIndex &= 0x1f; | |
8842 | tempbx = 0; | |
8843 | ||
8844 | if (pVBInfo->VBInfo & SetPALTV) | |
8845 | tempbx += 2; | |
8846 | ||
8847 | if (pVBInfo->VBInfo & SetCHTVOverScan) | |
8848 | tempbx += 1; | |
8849 | ||
8850 | switch (tempbx) { | |
8851 | case 0: | |
8852 | CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC; | |
8853 | break; | |
8854 | case 1: | |
8855 | CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC; | |
8856 | break; | |
8857 | case 2: | |
8858 | CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL; | |
8859 | break; | |
8860 | case 3: | |
8861 | CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL; | |
8862 | break; | |
8863 | default: | |
8864 | break; | |
8865 | } | |
8866 | ||
8867 | VCLKIndex = CHTVVCLKPtr[VCLKIndex]; | |
8868 | } | |
8869 | } else { | |
8870 | VCLKIndex = VCLKIndex >> 6; | |
8871 | if ((pVBInfo->LCDResInfo == Panel800x600) | |
8872 | || (pVBInfo->LCDResInfo == Panel320x480)) | |
8873 | VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; | |
8874 | else if ((pVBInfo->LCDResInfo == Panel1024x768) | |
8875 | || (pVBInfo->LCDResInfo | |
8876 | == Panel1024x768x75)) | |
8877 | VCLKIndex = LVDSXlat2VCLK[VCLKIndex]; | |
8878 | else | |
8879 | VCLKIndex = LVDSXlat3VCLK[VCLKIndex]; | |
8880 | } | |
8881 | } | |
8882 | /* VCLKIndex = VCLKIndex&IndexMask; */ | |
8883 | ||
8884 | return VCLKIndex; | |
d7636e0b | 8885 | } |
8886 |