3 * Mode initializing code (CRT1 section) for
4 * for SiS 300/305/540/630/730 and
5 * SiS 315/550/650/M650/651/661FX/M661FX/740/741/M741/330/660/M660/760/M760
6 * (Universal module for Linux kernel framebuffer and XFree86 4.x)
8 * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
10 * If distributed as part of the Linux kernel, the following license terms
13 * * This program is free software; you can redistribute it and/or modify
14 * * it under the terms of the GNU General Public License as published by
15 * * the Free Software Foundation; either version 2 of the named License,
16 * * or any later version.
18 * * This program is distributed in the hope that it will be useful,
19 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * * GNU General Public License for more details.
23 * * You should have received a copy of the GNU General Public License
24 * * along with this program; if not, write to the Free Software
25 * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
27 * Otherwise, the following license terms apply:
29 * * Redistribution and use in source and binary forms, with or without
30 * * modification, are permitted provided that the following conditions
32 * * 1) Redistributions of source code must retain the above copyright
33 * * notice, this list of conditions and the following disclaimer.
34 * * 2) Redistributions in binary form must reproduce the above copyright
35 * * notice, this list of conditions and the following disclaimer in the
36 * * documentation and/or other materials provided with the distribution.
37 * * 3) All advertising materials mentioning features or use of this software
38 * * must display the following acknowledgement: "This product includes
39 * * software developed by Thomas Winischhofer, Vienna, Austria."
40 * * 4) The name of the author may not be used to endorse or promote products
41 * * derived from this software without specific prior written permission.
43 * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
44 * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
46 * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
47 * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48 * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
52 * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 * Author: Thomas Winischhofer <thomas@winischhofer.net>
56 * Formerly based on non-functional code-fragements for 300 series by SiS, Inc.
59 * TW says: This code looks awful, I know. But please don't do anything about
60 * this otherwise debugging will be hell.
61 * The code is extremely fragile as regards the different chipsets, different
62 * video bridges and combinations thereof. If anything is changed, extreme
63 * care has to be taken that that change doesn't break it for other chipsets,
64 * bridges or combinations thereof.
65 * All comments in this file are by me, regardless if they are marked TW or not.
79 #if defined(ALLOC_PRAGMA)
80 #pragma alloc_text(PAGE,SiSSetMode)
81 #pragma alloc_text(PAGE,SiSInit)
84 /*********************************************/
85 /* POINTER INITIALIZATION */
86 /*********************************************/
89 InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
91 SiS_Pr->SiS_StResInfo = SiS_StResInfo;
92 SiS_Pr->SiS_ModeResInfo = SiS_ModeResInfo;
93 SiS_Pr->SiS_StandTable = SiS_StandTable;
95 SiS_Pr->SiS_NTSCPhase = SiS_NTSCPhase;
96 SiS_Pr->SiS_PALPhase = SiS_PALPhase;
97 SiS_Pr->SiS_NTSCPhase2 = SiS_NTSCPhase2;
98 SiS_Pr->SiS_PALPhase2 = SiS_PALPhase2;
99 SiS_Pr->SiS_PALMPhase = SiS_PALMPhase;
100 SiS_Pr->SiS_PALNPhase = SiS_PALNPhase;
101 SiS_Pr->SiS_PALMPhase2 = SiS_PALMPhase2;
102 SiS_Pr->SiS_PALNPhase2 = SiS_PALNPhase2;
103 SiS_Pr->SiS_SpecialPhase = SiS_SpecialPhase;
104 SiS_Pr->SiS_SpecialPhaseM = SiS_SpecialPhaseM;
105 SiS_Pr->SiS_SpecialPhaseJ = SiS_SpecialPhaseJ;
107 SiS_Pr->SiS_NTSCTiming = SiS_NTSCTiming;
108 SiS_Pr->SiS_PALTiming = SiS_PALTiming;
109 SiS_Pr->SiS_HiTVSt1Timing = SiS_HiTVSt1Timing;
110 SiS_Pr->SiS_HiTVSt2Timing = SiS_HiTVSt2Timing;
112 SiS_Pr->SiS_HiTVExtTiming = SiS_HiTVExtTiming;
113 SiS_Pr->SiS_HiTVGroup3Data = SiS_HiTVGroup3Data;
114 SiS_Pr->SiS_HiTVGroup3Simu = SiS_HiTVGroup3Simu;
116 SiS_Pr->SiS_HiTVTextTiming = SiS_HiTVTextTiming;
117 SiS_Pr->SiS_HiTVGroup3Text = SiS_HiTVGroup3Text;
120 SiS_Pr->SiS_StPALData = SiS_StPALData;
121 SiS_Pr->SiS_ExtPALData = SiS_ExtPALData;
122 SiS_Pr->SiS_StNTSCData = SiS_StNTSCData;
123 SiS_Pr->SiS_ExtNTSCData = SiS_ExtNTSCData;
124 SiS_Pr->SiS_St1HiTVData = SiS_StHiTVData;
125 SiS_Pr->SiS_St2HiTVData = SiS_St2HiTVData;
126 SiS_Pr->SiS_ExtHiTVData = SiS_ExtHiTVData;
127 SiS_Pr->SiS_St525iData = SiS_StNTSCData;
128 SiS_Pr->SiS_St525pData = SiS_St525pData;
129 SiS_Pr->SiS_St750pData = SiS_St750pData;
130 SiS_Pr->SiS_Ext525iData = SiS_ExtNTSCData;
131 SiS_Pr->SiS_Ext525pData = SiS_ExtNTSCData;
132 SiS_Pr->SiS_Ext750pData = SiS_Ext750pData;
134 SiS_Pr->pSiS_OutputSelect = &SiS_OutputSelect;
135 SiS_Pr->pSiS_SoftSetting = &SiS_SoftSetting;
137 SiS_Pr->SiS_LCD1280x960Data = SiS_LCD1280x960Data;
138 SiS_Pr->SiS_ExtLCD1400x1050Data = SiS_ExtLCD1400x1050Data;
139 SiS_Pr->SiS_ExtLCD1600x1200Data = SiS_ExtLCD1600x1200Data;
140 SiS_Pr->SiS_StLCD1400x1050Data = SiS_StLCD1400x1050Data;
141 SiS_Pr->SiS_StLCD1600x1200Data = SiS_StLCD1600x1200Data;
142 SiS_Pr->SiS_NoScaleData1400x1050 = SiS_NoScaleData1400x1050;
143 SiS_Pr->SiS_NoScaleData1600x1200 = SiS_NoScaleData1600x1200;
144 SiS_Pr->SiS_ExtLCD1280x768Data = SiS_ExtLCD1280x768Data;
145 SiS_Pr->SiS_StLCD1280x768Data = SiS_StLCD1280x768Data;
146 SiS_Pr->SiS_NoScaleData1280x768 = SiS_NoScaleData1280x768;
147 SiS_Pr->SiS_NoScaleData = SiS_NoScaleData;
149 SiS_Pr->SiS_LVDS320x480Data_1 = SiS_LVDS320x480Data_1;
150 SiS_Pr->SiS_LVDS800x600Data_1 = SiS_LVDS800x600Data_1;
151 SiS_Pr->SiS_LVDS800x600Data_2 = SiS_LVDS800x600Data_2;
152 SiS_Pr->SiS_LVDS1024x768Data_1 = SiS_LVDS1024x768Data_1;
153 SiS_Pr->SiS_LVDS1024x768Data_2 = SiS_LVDS1024x768Data_2;
154 SiS_Pr->SiS_LVDS1280x1024Data_1 = SiS_LVDS1280x1024Data_1;
155 SiS_Pr->SiS_LVDS1280x1024Data_2 = SiS_LVDS1280x1024Data_2;
156 SiS_Pr->SiS_LVDS1400x1050Data_1 = SiS_LVDS1400x1050Data_1;
157 SiS_Pr->SiS_LVDS1400x1050Data_2 = SiS_LVDS1400x1050Data_2;
158 SiS_Pr->SiS_LVDS1600x1200Data_1 = SiS_LVDS1600x1200Data_1;
159 SiS_Pr->SiS_LVDS1600x1200Data_2 = SiS_LVDS1600x1200Data_2;
160 SiS_Pr->SiS_LVDS1280x768Data_1 = SiS_LVDS1280x768Data_1;
161 SiS_Pr->SiS_LVDS1280x768Data_2 = SiS_LVDS1280x768Data_2;
162 SiS_Pr->SiS_LVDS1024x600Data_1 = SiS_LVDS1024x600Data_1;
163 SiS_Pr->SiS_LVDS1024x600Data_2 = SiS_LVDS1024x600Data_2;
164 SiS_Pr->SiS_LVDS1152x768Data_1 = SiS_LVDS1152x768Data_1;
165 SiS_Pr->SiS_LVDS1152x768Data_2 = SiS_LVDS1152x768Data_2;
166 SiS_Pr->SiS_LVDSXXXxXXXData_1 = SiS_LVDSXXXxXXXData_1;
167 SiS_Pr->SiS_LVDS1280x960Data_1 = SiS_LVDS1280x960Data_1;
168 SiS_Pr->SiS_LVDS1280x960Data_2 = SiS_LVDS1280x960Data_2;
169 SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1;
170 SiS_Pr->SiS_LVDS1280x960Data_1 = SiS_LVDS1280x1024Data_1;
171 SiS_Pr->SiS_LVDS1280x960Data_2 = SiS_LVDS1280x1024Data_2;
172 SiS_Pr->SiS_LVDS640x480Data_1 = SiS_LVDS640x480Data_1;
173 SiS_Pr->SiS_LVDS640x480Data_2 = SiS_LVDS640x480Data_2;
175 SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS_LVDSBARCO1366Data_1;
176 SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS_LVDSBARCO1366Data_2;
177 SiS_Pr->SiS_LVDSBARCO1024Data_1 = SiS_LVDSBARCO1024Data_1;
178 SiS_Pr->SiS_LVDSBARCO1024Data_2 = SiS_LVDSBARCO1024Data_2;
179 SiS_Pr->SiS_LVDS848x480Data_1 = SiS_LVDS848x480Data_1;
180 SiS_Pr->SiS_LVDS848x480Data_2 = SiS_LVDS848x480Data_2;
182 SiS_Pr->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData;
183 SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData;
185 SiS_Pr->SiS_LCDA1024x768Data_1 = SiS_LCDA1024x768Data_1;
186 SiS_Pr->SiS_LCDA1024x768Data_2 = SiS_LCDA1024x768Data_2;
187 SiS_Pr->SiS_LCDA1280x1024Data_1 = SiS_LCDA1280x1024Data_1;
188 SiS_Pr->SiS_LCDA1280x1024Data_2 = SiS_LCDA1280x1024Data_2;
189 SiS_Pr->SiS_LCDA1400x1050Data_1 = SiS_LCDA1400x1050Data_1;
190 SiS_Pr->SiS_LCDA1400x1050Data_2 = SiS_LCDA1400x1050Data_2;
191 SiS_Pr->SiS_LCDA1600x1200Data_1 = SiS_LCDA1600x1200Data_1;
192 SiS_Pr->SiS_LCDA1600x1200Data_2 = SiS_LCDA1600x1200Data_2;
194 SiS_Pr->LVDS1024x768Des_1 = SiS_PanelType1076_1;
195 SiS_Pr->LVDS1280x1024Des_1 = SiS_PanelType1210_1;
196 SiS_Pr->LVDS1400x1050Des_1 = SiS_PanelType1296_1;
197 SiS_Pr->LVDS1600x1200Des_1 = SiS_PanelType1600_1;
198 SiS_Pr->LVDS1024x768Des_2 = SiS_PanelType1076_2;
199 SiS_Pr->LVDS1280x1024Des_2 = SiS_PanelType1210_2;
200 SiS_Pr->LVDS1400x1050Des_2 = SiS_PanelType1296_2;
201 SiS_Pr->LVDS1600x1200Des_2 = SiS_PanelType1600_2;
203 SiS_Pr->SiS_PanelTypeNS_1 = SiS_PanelTypeNS_1;
204 SiS_Pr->SiS_PanelTypeNS_2 = SiS_PanelTypeNS_2;
206 SiS_Pr->SiS_CHTVUNTSCDesData = SiS_CHTVUNTSCDesData;
207 SiS_Pr->SiS_CHTVONTSCDesData = SiS_CHTVONTSCDesData;
208 SiS_Pr->SiS_CHTVUPALDesData = SiS_CHTVUPALDesData;
209 SiS_Pr->SiS_CHTVOPALDesData = SiS_CHTVOPALDesData;
211 SiS_Pr->SiS_LVDSCRT11280x768_1 = SiS_LVDSCRT11280x768_1;
212 SiS_Pr->SiS_LVDSCRT11024x600_1 = SiS_LVDSCRT11024x600_1;
213 SiS_Pr->SiS_LVDSCRT11152x768_1 = SiS_LVDSCRT11152x768_1;
214 SiS_Pr->SiS_LVDSCRT11280x768_1_H = SiS_LVDSCRT11280x768_1_H;
215 SiS_Pr->SiS_LVDSCRT11024x600_1_H = SiS_LVDSCRT11024x600_1_H;
216 SiS_Pr->SiS_LVDSCRT11152x768_1_H = SiS_LVDSCRT11152x768_1_H;
217 SiS_Pr->SiS_LVDSCRT11280x768_2 = SiS_LVDSCRT11280x768_2;
218 SiS_Pr->SiS_LVDSCRT11024x600_2 = SiS_LVDSCRT11024x600_2;
219 SiS_Pr->SiS_LVDSCRT11152x768_2 = SiS_LVDSCRT11152x768_2;
220 SiS_Pr->SiS_LVDSCRT11280x768_2_H = SiS_LVDSCRT11280x768_2_H;
221 SiS_Pr->SiS_LVDSCRT11024x600_2_H = SiS_LVDSCRT11024x600_2_H;
222 SiS_Pr->SiS_LVDSCRT11152x768_2_H = SiS_LVDSCRT11152x768_2_H;
223 SiS_Pr->SiS_LVDSCRT1320x480_1 = SiS_LVDSCRT1320x480_1;
224 SiS_Pr->SiS_LVDSCRT1XXXxXXX_1 = SiS_LVDSCRT1XXXxXXX_1;
225 SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H = SiS_LVDSCRT1XXXxXXX_1_H;
226 SiS_Pr->SiS_LVDSCRT1640x480_1 = SiS_LVDSCRT1640x480_1;
227 SiS_Pr->SiS_LVDSCRT1640x480_1_H = SiS_LVDSCRT1640x480_1_H;
228 SiS_Pr->SiS_LVDSCRT1640x480_2 = SiS_LVDSCRT1640x480_2;
229 SiS_Pr->SiS_LVDSCRT1640x480_2_H = SiS_LVDSCRT1640x480_2_H;
230 SiS_Pr->SiS_LVDSCRT1640x480_3 = SiS_LVDSCRT1640x480_3;
231 SiS_Pr->SiS_LVDSCRT1640x480_3_H = SiS_LVDSCRT1640x480_3_H;
236 InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
238 InitCommonPointer(SiS_Pr, HwInfo);
240 SiS_StandTable[0x04].CRTC[4] = 0x2b;
241 SiS_StandTable[0x05].CRTC[4] = 0x2b;
242 SiS_StandTable[0x06].CRTC[4] = 0x54;
243 SiS_StandTable[0x06].CRTC[5] = 0x80;
244 SiS_StandTable[0x0d].CRTC[4] = 0x2b;
245 SiS_StandTable[0x0e].CRTC[4] = 0x54;
246 SiS_StandTable[0x0e].CRTC[5] = 0x80;
247 SiS_StandTable[0x11].CRTC[4] = 0x54;
248 SiS_StandTable[0x11].CRTC[5] = 0x80;
249 SiS_StandTable[0x11].CRTC[16] = 0x83;
250 SiS_StandTable[0x11].CRTC[17] = 0x85;
251 SiS_StandTable[0x12].CRTC[4] = 0x54;
252 SiS_StandTable[0x12].CRTC[5] = 0x80;
253 SiS_StandTable[0x12].CRTC[16] = 0x83;
254 SiS_StandTable[0x12].CRTC[17] = 0x85;
255 SiS_StandTable[0x13].CRTC[5] = 0xa0;
256 SiS_StandTable[0x17].CRTC[5] = 0xa0;
257 SiS_StandTable[0x1a].CRTC[4] = 0x54;
258 SiS_StandTable[0x1a].CRTC[5] = 0x80;
259 SiS_StandTable[0x1a].CRTC[16] = 0xea;
260 SiS_StandTable[0x1a].CRTC[17] = 0x8c;
261 SiS_StandTable[0x1b].CRTC[4] = 0x54;
262 SiS_StandTable[0x1b].CRTC[5] = 0x80;
263 SiS_StandTable[0x1b].CRTC[16] = 0xea;
264 SiS_StandTable[0x1b].CRTC[17] = 0x8c;
265 SiS_StandTable[0x1c].CRTC[4] = 0x54;
266 SiS_StandTable[0x1c].CRTC[5] = 0x80;
268 SiS_Pr->SiS_SModeIDTable = (SiS_StStruct *)SiS300_SModeIDTable;
269 SiS_Pr->SiS_VBModeIDTable = (SiS_VBModeStruct *)SiS300_VBModeIDTable;
270 SiS_Pr->SiS_EModeIDTable = (SiS_ExtStruct *)SiS300_EModeIDTable;
271 SiS_Pr->SiS_RefIndex = (SiS_Ext2Struct *)SiS300_RefIndex;
272 SiS_Pr->SiS_CRT1Table = (SiS_CRT1TableStruct *)SiS300_CRT1Table;
273 if(HwInfo->jChipType == SIS_300) {
274 SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_300; /* 300 */
276 SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS300_MCLKData_630; /* 630, 730 */
278 SiS_Pr->SiS_VCLKData = (SiS_VCLKDataStruct *)SiS300_VCLKData;
279 SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS300_VCLKData;
280 SiS_Pr->SiS_ScreenOffset = SiS300_ScreenOffset;
282 SiS_Pr->SiS_SR15 = SiS300_SR15;
285 SiS_Pr->pSiS_SR07 = &SiS300_SR07;
286 SiS_Pr->SiS_CR40 = SiS300_CR40;
287 SiS_Pr->SiS_CR49 = SiS300_CR49;
288 SiS_Pr->pSiS_SR1F = &SiS300_SR1F;
289 SiS_Pr->pSiS_SR21 = &SiS300_SR21;
290 SiS_Pr->pSiS_SR22 = &SiS300_SR22;
291 SiS_Pr->pSiS_SR23 = &SiS300_SR23;
292 SiS_Pr->pSiS_SR24 = &SiS300_SR24;
293 SiS_Pr->SiS_SR25 = SiS300_SR25;
294 SiS_Pr->pSiS_SR31 = &SiS300_SR31;
295 SiS_Pr->pSiS_SR32 = &SiS300_SR32;
296 SiS_Pr->pSiS_SR33 = &SiS300_SR33;
297 SiS_Pr->pSiS_CRT2Data_1_2 = &SiS300_CRT2Data_1_2;
298 SiS_Pr->pSiS_CRT2Data_4_D = &SiS300_CRT2Data_4_D;
299 SiS_Pr->pSiS_CRT2Data_4_E = &SiS300_CRT2Data_4_E;
300 SiS_Pr->pSiS_CRT2Data_4_10 = &SiS300_CRT2Data_4_10;
301 SiS_Pr->pSiS_RGBSenseData = &SiS300_RGBSenseData;
302 SiS_Pr->pSiS_VideoSenseData = &SiS300_VideoSenseData;
303 SiS_Pr->pSiS_YCSenseData = &SiS300_YCSenseData;
304 SiS_Pr->pSiS_RGBSenseData2 = &SiS300_RGBSenseData2;
305 SiS_Pr->pSiS_VideoSenseData2 = &SiS300_VideoSenseData2;
306 SiS_Pr->pSiS_YCSenseData2 = &SiS300_YCSenseData2;
309 SiS_Pr->SiS_StLCD1024x768Data = (SiS_LCDDataStruct *)SiS300_StLCD1024x768Data;
310 SiS_Pr->SiS_ExtLCD1024x768Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1024x768Data;
311 SiS_Pr->SiS_St2LCD1024x768Data = (SiS_LCDDataStruct *)SiS300_St2LCD1024x768Data;
312 SiS_Pr->SiS_StLCD1280x1024Data = (SiS_LCDDataStruct *)SiS300_StLCD1280x1024Data;
313 SiS_Pr->SiS_ExtLCD1280x1024Data = (SiS_LCDDataStruct *)SiS300_ExtLCD1280x1024Data;
314 SiS_Pr->SiS_St2LCD1280x1024Data = (SiS_LCDDataStruct *)SiS300_St2LCD1280x1024Data;
315 SiS_Pr->SiS_NoScaleData1024x768 = (SiS_LCDDataStruct *)SiS300_NoScaleData1024x768;
316 SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS300_NoScaleData1280x1024;
318 SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl;
319 SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl;
321 SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTblLVDS;
324 SiS_Pr->SiS_CHTVUPALData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData;
325 SiS_Pr->SiS_CHTVOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData;
326 SiS_Pr->SiS_CHTVUPALMData = SiS_CHTVUNTSCData; /* not supported on 300 series */
327 SiS_Pr->SiS_CHTVOPALMData = SiS_CHTVONTSCData; /* not supported on 300 series */
328 SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData; /* not supported on 300 series */
329 SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData; /* not supported on 300 series */
330 SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVSOPALData;
332 SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS300_PanelType00_1;
333 SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS300_PanelType01_1;
334 SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS300_PanelType02_1;
335 SiS_Pr->SiS_PanelType03_1 = (SiS_LVDSDesStruct *)SiS300_PanelType03_1;
336 SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1;
337 SiS_Pr->SiS_PanelType05_1 = (SiS_LVDSDesStruct *)SiS300_PanelType05_1;
338 SiS_Pr->SiS_PanelType06_1 = (SiS_LVDSDesStruct *)SiS300_PanelType06_1;
339 SiS_Pr->SiS_PanelType07_1 = (SiS_LVDSDesStruct *)SiS300_PanelType07_1;
340 SiS_Pr->SiS_PanelType08_1 = (SiS_LVDSDesStruct *)SiS300_PanelType08_1;
341 SiS_Pr->SiS_PanelType09_1 = (SiS_LVDSDesStruct *)SiS300_PanelType09_1;
342 SiS_Pr->SiS_PanelType0a_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0a_1;
343 SiS_Pr->SiS_PanelType0b_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0b_1;
344 SiS_Pr->SiS_PanelType0c_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0c_1;
345 SiS_Pr->SiS_PanelType0d_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0d_1;
346 SiS_Pr->SiS_PanelType0e_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0e_1;
347 SiS_Pr->SiS_PanelType0f_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0f_1;
348 SiS_Pr->SiS_PanelType00_2 = (SiS_LVDSDesStruct *)SiS300_PanelType00_2;
349 SiS_Pr->SiS_PanelType01_2 = (SiS_LVDSDesStruct *)SiS300_PanelType01_2;
350 SiS_Pr->SiS_PanelType02_2 = (SiS_LVDSDesStruct *)SiS300_PanelType02_2;
351 SiS_Pr->SiS_PanelType03_2 = (SiS_LVDSDesStruct *)SiS300_PanelType03_2;
352 SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2;
353 SiS_Pr->SiS_PanelType05_2 = (SiS_LVDSDesStruct *)SiS300_PanelType05_2;
354 SiS_Pr->SiS_PanelType06_2 = (SiS_LVDSDesStruct *)SiS300_PanelType06_2;
355 SiS_Pr->SiS_PanelType07_2 = (SiS_LVDSDesStruct *)SiS300_PanelType07_2;
356 SiS_Pr->SiS_PanelType08_2 = (SiS_LVDSDesStruct *)SiS300_PanelType08_2;
357 SiS_Pr->SiS_PanelType09_2 = (SiS_LVDSDesStruct *)SiS300_PanelType09_2;
358 SiS_Pr->SiS_PanelType0a_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0a_2;
359 SiS_Pr->SiS_PanelType0b_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0b_2;
360 SiS_Pr->SiS_PanelType0c_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0c_2;
361 SiS_Pr->SiS_PanelType0d_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0d_2;
362 SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0e_2;
363 SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0f_2;
365 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
366 SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1a;
367 SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2a;
369 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
370 SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1b;
371 SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2b;
374 SiS_Pr->SiS_LVDSCRT1800x600_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1;
375 SiS_Pr->SiS_LVDSCRT11024x768_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1;
376 SiS_Pr->SiS_LVDSCRT11280x1024_1 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1;
377 SiS_Pr->SiS_LVDSCRT1800x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1_H;
378 SiS_Pr->SiS_LVDSCRT11024x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1_H;
379 SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1_H;
380 SiS_Pr->SiS_LVDSCRT1800x600_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2;
381 SiS_Pr->SiS_LVDSCRT11024x768_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2;
382 SiS_Pr->SiS_LVDSCRT11280x1024_2 = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2;
383 SiS_Pr->SiS_LVDSCRT1800x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2_H;
384 SiS_Pr->SiS_LVDSCRT11024x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2_H;
385 SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2_H;
386 SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UNTSC;
387 SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1ONTSC;
388 SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UPAL;
389 SiS_Pr->SiS_CHTVCRT1OPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1OPAL;
390 SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1SOPAL;
391 SiS_Pr->SiS_CHTVReg_UNTSC = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UNTSC;
392 SiS_Pr->SiS_CHTVReg_ONTSC = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_ONTSC;
393 SiS_Pr->SiS_CHTVReg_UPAL = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UPAL;
394 SiS_Pr->SiS_CHTVReg_OPAL = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_OPAL;
395 SiS_Pr->SiS_CHTVReg_UPALM = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UNTSC; /* not supported on 300 series */
396 SiS_Pr->SiS_CHTVReg_OPALM = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_ONTSC; /* not supported on 300 series */
397 SiS_Pr->SiS_CHTVReg_UPALN = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UPAL; /* not supported on 300 series */
398 SiS_Pr->SiS_CHTVReg_OPALN = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_OPAL; /* not supported on 300 series */
399 SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_SOPAL;
400 SiS_Pr->SiS_CHTVVCLKUNTSC = SiS300_CHTVVCLKUNTSC;
401 SiS_Pr->SiS_CHTVVCLKONTSC = SiS300_CHTVVCLKONTSC;
402 SiS_Pr->SiS_CHTVVCLKUPAL = SiS300_CHTVVCLKUPAL;
403 SiS_Pr->SiS_CHTVVCLKOPAL = SiS300_CHTVVCLKOPAL;
404 SiS_Pr->SiS_CHTVVCLKUPALM = SiS300_CHTVVCLKUNTSC; /* not supported on 300 series */
405 SiS_Pr->SiS_CHTVVCLKOPALM = SiS300_CHTVVCLKONTSC; /* not supported on 300 series */
406 SiS_Pr->SiS_CHTVVCLKUPALN = SiS300_CHTVVCLKUPAL; /* not supported on 300 series */
407 SiS_Pr->SiS_CHTVVCLKOPALN = SiS300_CHTVVCLKOPAL; /* not supported on 300 series */
408 SiS_Pr->SiS_CHTVVCLKSOPAL = SiS300_CHTVVCLKSOPAL;
410 SiS_Pr->SiS_CRT2Part2_1024x768_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_1;
411 SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_1;
412 SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_1;
413 SiS_Pr->SiS_CRT2Part2_1600x1200_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_1;
414 SiS_Pr->SiS_CRT2Part2_1024x768_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_2;
415 SiS_Pr->SiS_CRT2Part2_1280x1024_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_2;
416 SiS_Pr->SiS_CRT2Part2_1400x1050_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_2;
417 SiS_Pr->SiS_CRT2Part2_1600x1200_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_2;
418 SiS_Pr->SiS_CRT2Part2_1024x768_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_3;
419 SiS_Pr->SiS_CRT2Part2_1280x1024_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_3;
420 SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_3;
421 SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_3;
423 /* LCDResInfo will on 300 series be translated to 315 series definitions */
424 SiS_Pr->SiS_Panel320x480 = Panel_320x480;
425 SiS_Pr->SiS_Panel640x480 = Panel_640x480;
426 SiS_Pr->SiS_Panel800x600 = Panel_800x600;
427 SiS_Pr->SiS_Panel1024x768 = Panel_1024x768;
428 SiS_Pr->SiS_Panel1280x1024 = Panel_1280x1024;
429 SiS_Pr->SiS_Panel1280x960 = Panel_1280x960;
430 SiS_Pr->SiS_Panel1024x600 = Panel_1024x600;
431 SiS_Pr->SiS_Panel1152x768 = Panel_1152x768;
432 SiS_Pr->SiS_Panel1280x768 = Panel_1280x768;
433 SiS_Pr->SiS_Panel1600x1200 = 255; /* Something illegal */
434 SiS_Pr->SiS_Panel1400x1050 = 255;
435 SiS_Pr->SiS_Panel640x480_2 = 255;
436 SiS_Pr->SiS_Panel640x480_3 = 255;
437 SiS_Pr->SiS_Panel1152x864 = 255;
438 SiS_Pr->SiS_PanelMax = Panel_320x480; /* highest value */
439 SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* Lowest value LVDS */
440 SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */
441 SiS_Pr->SiS_PanelCustom = Panel_Custom;
442 SiS_Pr->SiS_PanelBarco1366 = Panel_Barco1366;
448 InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
450 InitCommonPointer(SiS_Pr, HwInfo);
452 SiS_StandTable[0x04].CRTC[4] = 0x2c;
453 SiS_StandTable[0x05].CRTC[4] = 0x2c;
454 SiS_StandTable[0x06].CRTC[4] = 0x55;
455 SiS_StandTable[0x06].CRTC[5] = 0x81;
456 SiS_StandTable[0x0d].CRTC[4] = 0x2c;
457 SiS_StandTable[0x0e].CRTC[4] = 0x55;
458 SiS_StandTable[0x0e].CRTC[5] = 0x81;
459 SiS_StandTable[0x11].CRTC[4] = 0x55;
460 SiS_StandTable[0x11].CRTC[5] = 0x81;
461 SiS_StandTable[0x11].CRTC[16] = 0x82;
462 SiS_StandTable[0x11].CRTC[17] = 0x84;
463 SiS_StandTable[0x12].CRTC[4] = 0x55;
464 SiS_StandTable[0x12].CRTC[5] = 0x81;
465 SiS_StandTable[0x12].CRTC[16] = 0x82;
466 SiS_StandTable[0x12].CRTC[17] = 0x84;
467 SiS_StandTable[0x13].CRTC[5] = 0xb1;
468 SiS_StandTable[0x17].CRTC[5] = 0xb1;
469 SiS_StandTable[0x1a].CRTC[4] = 0x55;
470 SiS_StandTable[0x1a].CRTC[5] = 0x81;
471 SiS_StandTable[0x1a].CRTC[16] = 0xe9;
472 SiS_StandTable[0x1a].CRTC[17] = 0x8b;
473 SiS_StandTable[0x1b].CRTC[4] = 0x55;
474 SiS_StandTable[0x1b].CRTC[5] = 0x81;
475 SiS_StandTable[0x1b].CRTC[16] = 0xe9;
476 SiS_StandTable[0x1b].CRTC[17] = 0x8b;
477 SiS_StandTable[0x1c].CRTC[4] = 0x55;
478 SiS_StandTable[0x1c].CRTC[5] = 0x81;
480 SiS_Pr->SiS_SModeIDTable = (SiS_StStruct *)SiS310_SModeIDTable;
481 SiS_Pr->SiS_EModeIDTable = (SiS_ExtStruct *)SiS310_EModeIDTable;
482 SiS_Pr->SiS_RefIndex = (SiS_Ext2Struct *)SiS310_RefIndex;
483 SiS_Pr->SiS_CRT1Table = (SiS_CRT1TableStruct *)SiS310_CRT1Table;
484 if(HwInfo->jChipType >= SIS_661) {
485 SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_660; /* 661/741/760 */
486 } else if(HwInfo->jChipType == SIS_330) {
487 SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_330; /* 330 */
488 } else if(HwInfo->jChipType > SIS_315PRO) {
489 SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_650; /* 550, 650, 740 */
491 SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_315; /* 315 */
493 SiS_Pr->SiS_MCLKData_1 = (SiS_MCLKDataStruct *)SiS310_MCLKData_1;
494 SiS_Pr->SiS_VCLKData = (SiS_VCLKDataStruct *)SiS310_VCLKData;
495 SiS_Pr->SiS_VBVCLKData = (SiS_VBVCLKDataStruct *)SiS310_VBVCLKData;
496 SiS_Pr->SiS_ScreenOffset = SiS310_ScreenOffset;
498 SiS_Pr->SiS_SR15 = SiS310_SR15;
501 SiS_Pr->pSiS_SR07 = &SiS310_SR07;
502 SiS_Pr->SiS_CR40 = SiS310_CR40;
503 SiS_Pr->SiS_CR49 = SiS310_CR49;
504 SiS_Pr->pSiS_SR1F = &SiS310_SR1F;
505 SiS_Pr->pSiS_SR21 = &SiS310_SR21;
506 SiS_Pr->pSiS_SR22 = &SiS310_SR22;
507 SiS_Pr->pSiS_SR23 = &SiS310_SR23;
508 SiS_Pr->pSiS_SR24 = &SiS310_SR24;
509 SiS_Pr->SiS_SR25 = SiS310_SR25;
510 SiS_Pr->pSiS_SR31 = &SiS310_SR31;
511 SiS_Pr->pSiS_SR32 = &SiS310_SR32;
512 SiS_Pr->pSiS_SR33 = &SiS310_SR33;
513 SiS_Pr->pSiS_CRT2Data_1_2 = &SiS310_CRT2Data_1_2;
514 SiS_Pr->pSiS_CRT2Data_4_D = &SiS310_CRT2Data_4_D;
515 SiS_Pr->pSiS_CRT2Data_4_E = &SiS310_CRT2Data_4_E;
516 SiS_Pr->pSiS_CRT2Data_4_10 = &SiS310_CRT2Data_4_10;
517 SiS_Pr->pSiS_RGBSenseData = &SiS310_RGBSenseData;
518 SiS_Pr->pSiS_VideoSenseData = &SiS310_VideoSenseData;
519 SiS_Pr->pSiS_YCSenseData = &SiS310_YCSenseData;
520 SiS_Pr->pSiS_RGBSenseData2 = &SiS310_RGBSenseData2;
521 SiS_Pr->pSiS_VideoSenseData2 = &SiS310_VideoSenseData2;
522 SiS_Pr->pSiS_YCSenseData2 = &SiS310_YCSenseData2;
525 SiS_Pr->SiS_StLCD1024x768Data = (SiS_LCDDataStruct *)SiS310_StLCD1024x768Data;
526 SiS_Pr->SiS_ExtLCD1024x768Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1024x768Data;
527 SiS_Pr->SiS_St2LCD1024x768Data = (SiS_LCDDataStruct *)SiS310_St2LCD1024x768Data;
528 SiS_Pr->SiS_StLCD1280x1024Data = (SiS_LCDDataStruct *)SiS310_StLCD1280x1024Data;
529 SiS_Pr->SiS_ExtLCD1280x1024Data = (SiS_LCDDataStruct *)SiS310_ExtLCD1280x1024Data;
530 SiS_Pr->SiS_St2LCD1280x1024Data = (SiS_LCDDataStruct *)SiS310_St2LCD1280x1024Data;
531 SiS_Pr->SiS_NoScaleData1024x768 = (SiS_LCDDataStruct *)SiS310_NoScaleData1024x768;
532 SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS310_NoScaleData1280x1024;
534 SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl;
535 SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTblLVDS;
537 SiS_Pr->SiS_CHTVUPALData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALData;
538 SiS_Pr->SiS_CHTVOPALData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALData;
539 SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALMData;
540 SiS_Pr->SiS_CHTVOPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALMData;
541 SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALNData;
542 SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALNData;
543 SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS310_CHTVSOPALData;
545 SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS310_PanelType00_1;
546 SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS310_PanelType01_1;
547 SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS310_PanelType02_1;
548 SiS_Pr->SiS_PanelType03_1 = (SiS_LVDSDesStruct *)SiS310_PanelType03_1;
549 SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS310_PanelType04_1;
550 SiS_Pr->SiS_PanelType05_1 = (SiS_LVDSDesStruct *)SiS310_PanelType05_1;
551 SiS_Pr->SiS_PanelType06_1 = (SiS_LVDSDesStruct *)SiS310_PanelType06_1;
552 SiS_Pr->SiS_PanelType07_1 = (SiS_LVDSDesStruct *)SiS310_PanelType07_1;
553 SiS_Pr->SiS_PanelType08_1 = (SiS_LVDSDesStruct *)SiS310_PanelType08_1;
554 SiS_Pr->SiS_PanelType09_1 = (SiS_LVDSDesStruct *)SiS310_PanelType09_1;
555 SiS_Pr->SiS_PanelType0a_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0a_1;
556 SiS_Pr->SiS_PanelType0b_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0b_1;
557 SiS_Pr->SiS_PanelType0c_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0c_1;
558 SiS_Pr->SiS_PanelType0d_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0d_1;
559 SiS_Pr->SiS_PanelType0e_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0e_1;
560 SiS_Pr->SiS_PanelType0f_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0f_1;
561 SiS_Pr->SiS_PanelType00_2 = (SiS_LVDSDesStruct *)SiS310_PanelType00_2;
562 SiS_Pr->SiS_PanelType01_2 = (SiS_LVDSDesStruct *)SiS310_PanelType01_2;
563 SiS_Pr->SiS_PanelType02_2 = (SiS_LVDSDesStruct *)SiS310_PanelType02_2;
564 SiS_Pr->SiS_PanelType03_2 = (SiS_LVDSDesStruct *)SiS310_PanelType03_2;
565 SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS310_PanelType04_2;
566 SiS_Pr->SiS_PanelType05_2 = (SiS_LVDSDesStruct *)SiS310_PanelType05_2;
567 SiS_Pr->SiS_PanelType06_2 = (SiS_LVDSDesStruct *)SiS310_PanelType06_2;
568 SiS_Pr->SiS_PanelType07_2 = (SiS_LVDSDesStruct *)SiS310_PanelType07_2;
569 SiS_Pr->SiS_PanelType08_2 = (SiS_LVDSDesStruct *)SiS310_PanelType08_2;
570 SiS_Pr->SiS_PanelType09_2 = (SiS_LVDSDesStruct *)SiS310_PanelType09_2;
571 SiS_Pr->SiS_PanelType0a_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0a_2;
572 SiS_Pr->SiS_PanelType0b_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0b_2;
573 SiS_Pr->SiS_PanelType0c_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0c_2;
574 SiS_Pr->SiS_PanelType0d_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0d_2;
575 SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0e_2;
576 SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0f_2;
578 SiS_Pr->SiS_CRT2Part2_1024x768_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_1;
579 SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_1;
580 SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_1;
581 SiS_Pr->SiS_CRT2Part2_1600x1200_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_1;
582 SiS_Pr->SiS_CRT2Part2_1024x768_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_2;
583 SiS_Pr->SiS_CRT2Part2_1280x1024_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_2;
584 SiS_Pr->SiS_CRT2Part2_1400x1050_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_2;
585 SiS_Pr->SiS_CRT2Part2_1600x1200_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_2;
586 SiS_Pr->SiS_CRT2Part2_1024x768_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_3;
587 SiS_Pr->SiS_CRT2Part2_1280x1024_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_3;
588 SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_3;
589 SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_3;
591 SiS_Pr->SiS_LVDSCRT1800x600_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1;
592 SiS_Pr->SiS_LVDSCRT11024x768_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1;
593 SiS_Pr->SiS_LVDSCRT11280x1024_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1;
594 SiS_Pr->SiS_LVDSCRT11400x1050_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1;
595 SiS_Pr->SiS_LVDSCRT11600x1200_1 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1;
596 SiS_Pr->SiS_LVDSCRT1800x600_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1_H;
597 SiS_Pr->SiS_LVDSCRT11024x768_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1_H;
598 SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1_H;
599 SiS_Pr->SiS_LVDSCRT11400x1050_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1_H;
600 SiS_Pr->SiS_LVDSCRT11600x1200_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1_H;
601 SiS_Pr->SiS_LVDSCRT1800x600_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2;
602 SiS_Pr->SiS_LVDSCRT11024x768_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2;
603 SiS_Pr->SiS_LVDSCRT11280x1024_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2;
604 SiS_Pr->SiS_LVDSCRT11400x1050_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2;
605 SiS_Pr->SiS_LVDSCRT11600x1200_2 = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2;
606 SiS_Pr->SiS_LVDSCRT1800x600_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2_H;
607 SiS_Pr->SiS_LVDSCRT11024x768_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2_H;
608 SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2_H;
609 SiS_Pr->SiS_LVDSCRT11400x1050_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2_H;
610 SiS_Pr->SiS_LVDSCRT11600x1200_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2_H;
611 SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UNTSC;
612 SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1ONTSC;
613 SiS_Pr->SiS_CHTVCRT1UPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UPAL;
614 SiS_Pr->SiS_CHTVCRT1OPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL;
615 SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL;
617 SiS_Pr->SiS_CHTVReg_UNTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UNTSC;
618 SiS_Pr->SiS_CHTVReg_ONTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_ONTSC;
619 SiS_Pr->SiS_CHTVReg_UPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPAL;
620 SiS_Pr->SiS_CHTVReg_OPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPAL;
621 SiS_Pr->SiS_CHTVReg_UPALM = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPALM;
622 SiS_Pr->SiS_CHTVReg_OPALM = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALM;
623 SiS_Pr->SiS_CHTVReg_UPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPALN;
624 SiS_Pr->SiS_CHTVReg_OPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALN;
625 SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPAL;
627 SiS_Pr->SiS_LCDACRT11024x768_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1;
628 SiS_Pr->SiS_LCDACRT11280x1024_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1;
629 SiS_Pr->SiS_LCDACRT11400x1050_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_1;
630 SiS_Pr->SiS_LCDACRT11600x1200_1 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_1;
631 SiS_Pr->SiS_LCDACRT11024x768_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1_H;
632 SiS_Pr->SiS_LCDACRT11280x1024_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1_H;
633 SiS_Pr->SiS_LCDACRT11400x1050_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_1_H;
634 SiS_Pr->SiS_LCDACRT11600x1200_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_1_H;
635 SiS_Pr->SiS_LCDACRT11024x768_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_2;
636 SiS_Pr->SiS_LCDACRT11280x1024_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2;
637 SiS_Pr->SiS_LCDACRT11400x1050_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2;
638 SiS_Pr->SiS_LCDACRT11600x1200_2 = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2;
639 SiS_Pr->SiS_LCDACRT11024x768_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_2_H;
640 SiS_Pr->SiS_LCDACRT11280x1024_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2_H;
641 SiS_Pr->SiS_LCDACRT11400x1050_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2_H;
642 SiS_Pr->SiS_LCDACRT11600x1200_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2_H;
644 SiS_Pr->SiS_CHTVVCLKUNTSC = SiS310_CHTVVCLKUNTSC;
645 SiS_Pr->SiS_CHTVVCLKONTSC = SiS310_CHTVVCLKONTSC;
646 SiS_Pr->SiS_CHTVVCLKUPAL = SiS310_CHTVVCLKUPAL;
647 SiS_Pr->SiS_CHTVVCLKOPAL = SiS310_CHTVVCLKOPAL;
648 SiS_Pr->SiS_CHTVVCLKUPALM = SiS310_CHTVVCLKUPALM;
649 SiS_Pr->SiS_CHTVVCLKOPALM = SiS310_CHTVVCLKOPALM;
650 SiS_Pr->SiS_CHTVVCLKUPALN = SiS310_CHTVVCLKUPALN;
651 SiS_Pr->SiS_CHTVVCLKOPALN = SiS310_CHTVVCLKOPALN;
652 SiS_Pr->SiS_CHTVVCLKSOPAL = SiS310_CHTVVCLKOPAL;
654 SiS_Pr->SiS_Panel320x480 = Panel_320x480;
655 SiS_Pr->SiS_Panel640x480 = Panel_640x480;
656 SiS_Pr->SiS_Panel800x600 = Panel_800x600;
657 SiS_Pr->SiS_Panel1024x768 = Panel_1024x768;
658 SiS_Pr->SiS_Panel1280x1024 = Panel_1280x1024;
659 SiS_Pr->SiS_Panel1280x960 = Panel_1280x960;
660 SiS_Pr->SiS_Panel1600x1200 = Panel_1600x1200;
661 SiS_Pr->SiS_Panel1400x1050 = Panel_1400x1050;
662 SiS_Pr->SiS_Panel1152x768 = Panel_1152x768;
663 SiS_Pr->SiS_Panel1152x864 = Panel_1152x864;
664 SiS_Pr->SiS_Panel1280x768 = Panel_1280x768;
665 SiS_Pr->SiS_Panel1024x600 = Panel_1024x600;
666 SiS_Pr->SiS_Panel640x480_2 = Panel_640x480_2;
667 SiS_Pr->SiS_Panel640x480_3 = Panel_640x480_3;
668 SiS_Pr->SiS_PanelMax = Panel_320x480; /* highest value */
669 SiS_Pr->SiS_PanelMinLVDS = Panel_800x600; /* lowest value LVDS/LCDA */
670 SiS_Pr->SiS_PanelMin301 = Panel_1024x768; /* lowest value 301 */
671 SiS_Pr->SiS_PanelCustom = Panel_Custom;
672 SiS_Pr->SiS_PanelBarco1366 = 255;
677 SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
679 switch(HwInfo->jChipType) {
692 InitTo310Pointer(SiS_Pr, HwInfo);
700 InitTo300Pointer(SiS_Pr, HwInfo);
708 /*********************************************/
709 /* HELPER: Get ModeID */
710 /*********************************************/
713 SiS_GetModeID(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth, BOOLEAN FSTN)
715 USHORT ModeIndex = 0;
720 if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth];
721 else if(VDisplay == 240) {
722 if(FSTN) ModeIndex = ModeIndex_320x240_FSTN[Depth];
723 else ModeIndex = ModeIndex_320x240[Depth];
727 if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth];
730 if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth];
733 if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth];
734 else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth];
737 if(!(VBFlags & CRT1_LCDA)) {
738 if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth];
739 else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth];
743 if(!(VBFlags & CRT1_LCDA)) {
744 if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth];
748 if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth];
749 else if(!(VBFlags & CRT1_LCDA)) {
750 if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth];
754 if(!(VBFlags & CRT1_LCDA)) {
755 if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth];
759 if(!(VBFlags & CRT1_LCDA)) {
760 if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth];
764 if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth];
765 else if(!(VBFlags & CRT1_LCDA)) {
766 if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth];
767 else if(VGAEngine == SIS_300_VGA) {
768 if(VDisplay == 600) ModeIndex = ModeIndex_1024x600[Depth];
773 if(!(VBFlags & CRT1_LCDA)) {
774 if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth];
775 else if(VGAEngine == SIS_300_VGA) {
776 if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth];
781 if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth];
782 else if(!(VBFlags & CRT1_LCDA)) {
783 if(VDisplay == 960) ModeIndex = ModeIndex_1280x960[Depth];
784 else if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth];
785 else if(VDisplay == 768) {
786 if(VGAEngine == SIS_300_VGA) {
787 ModeIndex = ModeIndex_300_1280x768[Depth];
789 ModeIndex = ModeIndex_310_1280x768[Depth];
795 if(!(VBFlags & CRT1_LCDA)) {
796 if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth];
797 else if(VGAEngine == SIS_300_VGA) {
798 if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth];
803 if(VGAEngine == SIS_315_VGA) {
804 if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth];
808 if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth];
811 if(!(VBFlags & CRT1_LCDA)) {
812 if(VDisplay == 1440) ModeIndex = ModeIndex_1920x1440[Depth];
816 if(!(VBFlags & CRT1_LCDA)) {
817 if(VDisplay == 1536) {
818 if(VGAEngine == SIS_300_VGA) {
819 ModeIndex = ModeIndex_300_2048x1536[Depth];
821 ModeIndex = ModeIndex_310_2048x1536[Depth];
832 SiS_GetModeID_LCD(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay,
833 int Depth, BOOLEAN FSTN, USHORT CustomT, int LCDwidth, int LCDheight)
835 USHORT ModeIndex = 0;
837 if(VBFlags & (VB_LVDS | VB_30xBDH)) {
842 if(CustomT != CUT_PANEL848) {
843 if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth];
844 else if(VDisplay == 240) {
845 if(!FSTN) ModeIndex = ModeIndex_320x240[Depth];
846 else if(VGAEngine == SIS_315_VGA) {
847 ModeIndex = ModeIndex_320x240_FSTN[Depth];
853 if(CustomT != CUT_PANEL848) {
854 if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth];
858 if(CustomT != CUT_PANEL848) {
859 if(VDisplay == 384) {
860 if(LCDwidth != 1024 || LCDheight != 600) {
861 ModeIndex = ModeIndex_512x384[Depth];
867 if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth];
868 else if(VDisplay == 400) {
869 if(CustomT != CUT_PANEL848) ModeIndex = ModeIndex_640x400[Depth];
873 if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth];
876 if(CustomT == CUT_PANEL848) {
877 if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth];
881 if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth];
882 else if(VGAEngine == SIS_300_VGA) {
883 if((VDisplay == 600) && (LCDheight == 600)) {
884 ModeIndex = ModeIndex_1024x600[Depth];
889 if(VGAEngine == SIS_300_VGA) {
890 if((VDisplay == 768) && (LCDheight == 768)) {
891 ModeIndex = ModeIndex_1152x768[Depth];
896 if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth];
897 else if(VGAEngine == SIS_315_VGA) {
898 if((VDisplay == 768) && (LCDheight == 768)) {
899 ModeIndex = ModeIndex_310_1280x768[Depth];
904 if(VGAEngine == SIS_300_VGA) {
905 if(CustomT == CUT_BARCO1366) {
906 if(VDisplay == 1024) ModeIndex = ModeIndex_300_1360x1024[Depth];
909 if(CustomT == CUT_PANEL848) {
910 if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth];
914 if(VGAEngine == SIS_315_VGA) {
915 if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth];
919 if(VGAEngine == SIS_315_VGA) {
920 if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth];
925 } else if(VBFlags & VB_SISBRIDGE) {
930 if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth];
931 else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth];
934 if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth];
937 if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth];
940 if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth];
941 else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth];
944 if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth];
947 if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth];
950 if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth];
951 else if(VDisplay == 768) {
952 if((LCDheight == 768) ||
953 ((LCDheight == 1024) && (VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)))) {
954 if(VGAEngine == SIS_300_VGA) {
955 ModeIndex = ModeIndex_300_1280x768[Depth];
957 ModeIndex = ModeIndex_310_1280x768[Depth];
960 } else if(VDisplay == 960) {
961 if((LCDheight == 960) ||
962 ((LCDheight == 1024) && (VBFlags & (VB_301|VB_301B|VB_301C|VB_302B)))) {
963 ModeIndex = ModeIndex_1280x960[Depth];
968 if(VGAEngine == SIS_315_VGA) {
969 if(VBFlags & (VB_301B | VB_301C | VB_302B | VB_302LV | VB_302ELV)) {
970 if(LCDheight != 1200) {
971 if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth];
977 if(VBFlags & (VB_301C | VB_302B | VB_302LV | VB_302ELV)) {
978 if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth];
988 SiS_GetModeID_TV(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth)
990 USHORT ModeIndex = 0;
992 if(VBFlags & VB_CHRONTEL) {
997 if(VGAEngine == SIS_315_VGA) {
998 if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth];
1002 if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth];
1003 else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth];
1006 if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth];
1009 if(VGAEngine == SIS_315_VGA) {
1010 if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth];
1015 } else if(VBFlags & VB_SISTVBRIDGE) {
1020 if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth];
1021 else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth];
1024 if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth];
1027 if( ((VBFlags & TV_YPBPR) && (VBFlags & (TV_YPBPR525P | TV_YPBPR750P | TV_YPBPR1080I))) ||
1028 (VBFlags & TV_HIVISION) ||
1029 ((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) ) {
1030 if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth];
1034 if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth];
1035 else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth];
1038 if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) {
1039 if(VDisplay == 480) {
1040 if((VBFlags & TV_YPBPR) || (VBFlags & (TV_NTSC | TV_PALM)))
1041 ModeIndex = ModeIndex_720x480[Depth];
1042 } else if(VDisplay == 576) {
1043 if((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL))
1044 ModeIndex = ModeIndex_720x576[Depth];
1049 if((!(VBFlags & TV_HIVISION)) && (!((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I)))) {
1050 if((!(VBFlags & (TV_YPBPR | TV_PALM))) && (VBFlags & TV_PAL)) {
1051 if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth];
1056 if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth];
1057 else if(VDisplay == 480) {
1058 if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) {
1059 ModeIndex = ModeIndex_800x480[Depth];
1064 if(VDisplay == 768) {
1065 if(VBFlags & (VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)) {
1066 ModeIndex = ModeIndex_1024x768[Depth];
1068 } else if(VDisplay == 576) {
1069 if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) {
1070 ModeIndex = ModeIndex_1024x576[Depth];
1075 if((VBFlags & TV_HIVISION) || ((VBFlags & TV_YPBPR) && (VBFlags & TV_YPBPR1080I))) {
1076 if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth];
1077 else if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth];
1086 SiS_GetModeID_VGA2(int VGAEngine, ULONG VBFlags, int HDisplay, int VDisplay, int Depth)
1088 USHORT ModeIndex = 0;
1090 if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0;
1095 if(VDisplay == 200) ModeIndex = ModeIndex_320x200[Depth];
1096 else if(VDisplay == 240) ModeIndex = ModeIndex_320x240[Depth];
1099 if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth];
1102 if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth];
1105 if(VDisplay == 480) ModeIndex = ModeIndex_640x480[Depth];
1106 else if(VDisplay == 400) ModeIndex = ModeIndex_640x400[Depth];
1109 if(VDisplay == 480) ModeIndex = ModeIndex_720x480[Depth];
1110 else if(VDisplay == 576) ModeIndex = ModeIndex_720x576[Depth];
1113 if(VDisplay == 576) ModeIndex = ModeIndex_768x576[Depth];
1116 if(VDisplay == 600) ModeIndex = ModeIndex_800x600[Depth];
1117 else if(VDisplay == 480) ModeIndex = ModeIndex_800x480[Depth];
1120 if(VDisplay == 480) ModeIndex = ModeIndex_848x480[Depth];
1123 if(VDisplay == 480) ModeIndex = ModeIndex_856x480[Depth];
1126 if(VDisplay == 768) ModeIndex = ModeIndex_1024x768[Depth];
1127 else if(VDisplay == 576) ModeIndex = ModeIndex_1024x576[Depth];
1130 if(VDisplay == 864) ModeIndex = ModeIndex_1152x864[Depth];
1131 else if(VGAEngine == SIS_300_VGA) {
1132 if(VDisplay == 768) ModeIndex = ModeIndex_1152x768[Depth];
1136 if(VDisplay == 768) {
1137 if(VGAEngine == SIS_300_VGA) {
1138 ModeIndex = ModeIndex_300_1280x768[Depth];
1140 ModeIndex = ModeIndex_310_1280x768[Depth];
1142 } else if(VDisplay == 1024) ModeIndex = ModeIndex_1280x1024[Depth];
1143 else if(VDisplay == 720) ModeIndex = ModeIndex_1280x720[Depth];
1144 else if(VDisplay == 960) ModeIndex = ModeIndex_1280x960[Depth];
1147 if(VDisplay == 768) ModeIndex = ModeIndex_1360x768[Depth];
1150 if(VGAEngine == SIS_315_VGA) {
1151 if(VDisplay == 1050) ModeIndex = ModeIndex_1400x1050[Depth];
1155 if(VGAEngine == SIS_315_VGA) {
1156 if(VBFlags & (VB_301B|VB_301C|VB_302B)) {
1157 if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth];
1167 /*********************************************/
1168 /* HELPER: SetReg, GetReg */
1169 /*********************************************/
1172 SiS_SetReg(SISIOADDRESS port, USHORT index, USHORT data)
1174 OutPortByte(port,index);
1175 OutPortByte(port + 1,data);
1179 SiS_SetRegByte(SISIOADDRESS port, USHORT data)
1181 OutPortByte(port,data);
1185 SiS_SetRegShort(SISIOADDRESS port, USHORT data)
1187 OutPortWord(port,data);
1191 SiS_SetRegLong(SISIOADDRESS port, ULONG data)
1193 OutPortLong(port,data);
1197 SiS_GetReg(SISIOADDRESS port, USHORT index)
1199 OutPortByte(port,index);
1200 return(InPortByte(port + 1));
1204 SiS_GetRegByte(SISIOADDRESS port)
1206 return(InPortByte(port));
1210 SiS_GetRegShort(SISIOADDRESS port)
1212 return(InPortWord(port));
1216 SiS_GetRegLong(SISIOADDRESS port)
1218 return(InPortLong(port));
1222 SiS_SetRegANDOR(SISIOADDRESS Port,USHORT Index,USHORT DataAND,USHORT DataOR)
1226 temp = SiS_GetReg(Port,Index);
1227 temp = (temp & (DataAND)) | DataOR;
1228 SiS_SetReg(Port,Index,temp);
1232 SiS_SetRegAND(SISIOADDRESS Port,USHORT Index,USHORT DataAND)
1236 temp = SiS_GetReg(Port,Index);
1238 SiS_SetReg(Port,Index,temp);
1242 SiS_SetRegOR(SISIOADDRESS Port,USHORT Index,USHORT DataOR)
1246 temp = SiS_GetReg(Port,Index);
1248 SiS_SetReg(Port,Index,temp);
1251 /*********************************************/
1252 /* HELPER: DisplayOn, DisplayOff */
1253 /*********************************************/
1256 SiS_DisplayOn(SiS_Private *SiS_Pr)
1258 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x00);
1262 SiS_DisplayOff(SiS_Private *SiS_Pr)
1264 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x20);
1268 /*********************************************/
1269 /* HELPER: Init Port Addresses */
1270 /*********************************************/
1273 SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr)
1275 SiS_Pr->SiS_P3c4 = BaseAddr + 0x14;
1276 SiS_Pr->SiS_P3d4 = BaseAddr + 0x24;
1277 SiS_Pr->SiS_P3c0 = BaseAddr + 0x10;
1278 SiS_Pr->SiS_P3ce = BaseAddr + 0x1e;
1279 SiS_Pr->SiS_P3c2 = BaseAddr + 0x12;
1280 SiS_Pr->SiS_P3ca = BaseAddr + 0x1a;
1281 SiS_Pr->SiS_P3c6 = BaseAddr + 0x16;
1282 SiS_Pr->SiS_P3c7 = BaseAddr + 0x17;
1283 SiS_Pr->SiS_P3c8 = BaseAddr + 0x18;
1284 SiS_Pr->SiS_P3c9 = BaseAddr + 0x19;
1285 SiS_Pr->SiS_P3cb = BaseAddr + 0x1b;
1286 SiS_Pr->SiS_P3cd = BaseAddr + 0x1d;
1287 SiS_Pr->SiS_P3da = BaseAddr + 0x2a;
1288 SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04; /* Digital video interface registers (LCD) */
1289 SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10; /* 301 TV Encoder registers */
1290 SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12; /* 301 Macrovision registers */
1291 SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14; /* 301 VGA2 (and LCD) registers */
1292 SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2; /* 301 palette address port registers */
1293 SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14; /* DDC Port ( = P3C4, SR11/0A) */
1294 SiS_Pr->SiS_VidCapt = BaseAddr + SIS_VIDEO_CAPTURE;
1295 SiS_Pr->SiS_VidPlay = BaseAddr + SIS_VIDEO_PLAYBACK;
1298 /*********************************************/
1299 /* HELPER: GetSysFlags */
1300 /*********************************************/
1303 SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1305 unsigned char cr5f, temp1, temp2;
1307 /* 661 and newer: NEVER write non-zero to SR11[7:4] */
1308 /* (SR11 is used for DDC and in enable/disablebridge) */
1309 SiS_Pr->SiS_SensibleSR11 = FALSE;
1310 SiS_Pr->SiS_MyCR63 = 0x63;
1311 if(HwInfo->jChipType >= SIS_661) {
1312 SiS_Pr->SiS_SensibleSR11 = TRUE;
1313 SiS_Pr->SiS_MyCR63 = 0x53;
1316 /* You should use the macros, not these flags directly */
1318 SiS_Pr->SiS_SysFlags = 0;
1319 if(HwInfo->jChipType == SIS_650) {
1320 cr5f = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0;
1321 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x5c,0x07);
1322 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8;
1323 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x5c,0xf8);
1324 temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8;
1325 if((!temp1) || (temp2)) {
1330 SiS_Pr->SiS_SysFlags |= SF_IsM650; break;
1334 SiS_Pr->SiS_SysFlags |= SF_Is651; break;
1339 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5c) & 0xf8;
1341 case 0x00: SiS_Pr->SiS_SysFlags |= SF_IsM652; break;
1342 case 0x40: SiS_Pr->SiS_SysFlags |= SF_IsM653; break;
1343 default: SiS_Pr->SiS_SysFlags |= SF_IsM650; break;
1347 SiS_Pr->SiS_SysFlags |= SF_Is652; break;
1349 SiS_Pr->SiS_SysFlags |= SF_IsM650; break;
1355 /*********************************************/
1356 /* HELPER: Init PCI & Engines */
1357 /*********************************************/
1360 SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1362 switch(HwInfo->jChipType) {
1367 /* Set - PCI LINEAR ADDRESSING ENABLE (0x80)
1368 * - RELOCATED VGA IO (0x20)
1369 * - MMIO ENABLE (0x1)
1371 SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1);
1372 /* - Enable 2D (0x40)
1373 * - Enable 3D (0x02)
1374 * - Enable 3D Vertex command fetch (0x10) ?
1375 * - Enable 3D command parser (0x08) ?
1377 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A);
1389 SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1);
1390 /* - Enable 2D (0x40)
1391 * - Enable 3D (0x02)
1392 * - Enable 3D vertex command fetch (0x10)
1393 * - Enable 3D command parser (0x08)
1394 * - Enable 3D G/L transformation engine (0x80)
1396 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0xDA);
1399 SiS_SetReg(SiS_Pr->SiS_P3c4,0x20,0xa1);
1400 /* No 3D engine ! */
1401 /* - Enable 2D (0x40)
1403 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x40);
1407 /*********************************************/
1408 /* HELPER: SetLVDSetc */
1409 /*********************************************/
1412 SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1416 SiS_Pr->SiS_IF_DEF_LVDS = 0;
1417 SiS_Pr->SiS_IF_DEF_TRUMPION = 0;
1418 SiS_Pr->SiS_IF_DEF_CH70xx = 0;
1419 SiS_Pr->SiS_IF_DEF_DSTN = 0;
1420 SiS_Pr->SiS_IF_DEF_FSTN = 0;
1421 SiS_Pr->SiS_IF_DEF_CONEX = 0;
1423 SiS_Pr->SiS_ChrontelInit = 0;
1425 switch(HwInfo->jChipType) {
1430 /* Check for SiS30x first */
1431 temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00);
1432 if((temp == 1) || (temp == 2)) return;
1433 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37);
1434 temp = (temp & 0x0E) >> 1;
1435 if((temp >= 2) && (temp <= 5)) SiS_Pr->SiS_IF_DEF_LVDS = 1;
1436 if(temp == 3) SiS_Pr->SiS_IF_DEF_TRUMPION = 1;
1437 if((temp == 4) || (temp == 5)) {
1438 /* Save power status (and error check) - UNUSED */
1439 SiS_Pr->SiS_Backup70xx = SiS_GetCH700x(SiS_Pr, 0x0e);
1440 SiS_Pr->SiS_IF_DEF_CH70xx = 1;
1449 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37);
1450 temp = (temp & 0x0E) >> 1;
1451 if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1;
1452 if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2;
1458 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1459 temp = (temp & 0xe0) >> 5;
1460 if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1;
1461 if(temp == 3) SiS_Pr->SiS_IF_DEF_CH70xx = 2;
1462 if(temp == 4) SiS_Pr->SiS_IF_DEF_CONEX = 1; /* Not yet supported */
1470 /*********************************************/
1471 /* HELPER: Enable DSTN/FSTN */
1472 /*********************************************/
1475 SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable)
1477 SiS_Pr->SiS_IF_DEF_DSTN = enable ? 1 : 0;
1481 SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable)
1483 SiS_Pr->SiS_IF_DEF_FSTN = enable ? 1 : 0;
1486 /*********************************************/
1487 /* HELPER: Determine ROM usage */
1488 /*********************************************/
1491 SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1493 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
1495 if((ROMAddr) && (HwInfo->UseROM)) {
1496 if((ROMAddr[0x00] != 0x55) || (ROMAddr[0x01] != 0xAA)) {
1497 SiS_Pr->SiS_UseROM = FALSE;
1498 } else if(HwInfo->jChipType == SIS_300) {
1499 /* 300: We check if the code starts below 0x220 by
1500 * checking the jmp instruction at the beginning
1501 * of the BIOS image.
1503 if((ROMAddr[3] == 0xe9) &&
1504 ((ROMAddr[5] << 8) | ROMAddr[4]) > 0x21a)
1505 SiS_Pr->SiS_UseROM = TRUE;
1507 SiS_Pr->SiS_UseROM = FALSE;
1508 } else if(HwInfo->jChipType < SIS_315H) {
1510 /* Rest of 300 series: We don't use the ROM image if
1511 * the BIOS version < 2.0.0 as such old BIOSes don't
1512 * have the needed data at the expected locations.
1514 if(ROMAddr[0x06] < '2') SiS_Pr->SiS_UseROM = FALSE;
1515 else SiS_Pr->SiS_UseROM = TRUE;
1517 /* Sony's VAIO BIOS 1.09 follows the standard, so perhaps
1518 * the others do as well
1520 SiS_Pr->SiS_UseROM = TRUE;
1523 /* 315/330 series stick to the standard */
1524 SiS_Pr->SiS_UseROM = TRUE;
1526 } else SiS_Pr->SiS_UseROM = FALSE;
1530 /*********************************************/
1531 /* HELPER: SET SEGMENT REGISTERS */
1532 /*********************************************/
1535 SiS_SetSegRegLower(SiS_Private *SiS_Pr, USHORT value)
1540 temp = SiS_GetRegByte(SiS_Pr->SiS_P3cb) & 0xf0;
1541 temp |= (value >> 4);
1542 SiS_SetRegByte(SiS_Pr->SiS_P3cb, temp);
1543 temp = SiS_GetRegByte(SiS_Pr->SiS_P3cd) & 0xf0;
1544 temp |= (value & 0x0f);
1545 SiS_SetRegByte(SiS_Pr->SiS_P3cd, temp);
1549 SiS_SetSegRegUpper(SiS_Private *SiS_Pr, USHORT value)
1554 temp = SiS_GetRegByte(SiS_Pr->SiS_P3cb) & 0x0f;
1555 temp |= (value & 0xf0);
1556 SiS_SetRegByte(SiS_Pr->SiS_P3cb, temp);
1557 temp = SiS_GetRegByte(SiS_Pr->SiS_P3cd) & 0x0f;
1558 temp |= (value << 4);
1559 SiS_SetRegByte(SiS_Pr->SiS_P3cd, temp);
1563 SiS_SetSegmentReg(SiS_Private *SiS_Pr, USHORT value)
1565 SiS_SetSegRegLower(SiS_Pr, value);
1566 SiS_SetSegRegUpper(SiS_Pr, value);
1570 SiS_ResetSegmentReg(SiS_Private *SiS_Pr)
1572 SiS_SetSegmentReg(SiS_Pr, 0);
1576 SiS_SetSegmentRegOver(SiS_Private *SiS_Pr, USHORT value)
1578 USHORT temp = value >> 8;
1581 temp |= (temp << 4);
1582 SiS_SetReg(SiS_Pr->SiS_P3c4,0x1d,temp);
1583 SiS_SetSegmentReg(SiS_Pr, value);
1587 SiS_ResetSegmentRegOver(SiS_Private *SiS_Pr)
1589 SiS_SetSegmentRegOver(SiS_Pr, 0);
1593 SiS_ResetSegmentRegisters(SiS_Private *SiS_Pr,PSIS_HW_INFO HwInfo)
1595 if((IS_SIS65x) || (HwInfo->jChipType >= SIS_661)) {
1596 SiS_ResetSegmentReg(SiS_Pr);
1597 SiS_ResetSegmentRegOver(SiS_Pr);
1601 /*********************************************/
1602 /* HELPER: GetVBType */
1603 /*********************************************/
1606 SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1608 USHORT flag=0, rev=0, nolcd=0;
1610 SiS_Pr->SiS_VBType = 0;
1612 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) return;
1614 flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00);
1616 if(flag > 3) return;
1618 rev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01);
1621 SiS_Pr->SiS_VBType = VB_SIS302B;
1622 } else if(flag == 1) {
1623 SiS_Pr->SiS_VBType = VB_SIS301;
1625 SiS_Pr->SiS_VBType = VB_SIS301C;
1626 } else if(rev >= 0xB0) {
1627 SiS_Pr->SiS_VBType = VB_SIS301B;
1628 /* Check if 30xB DH version (no LCD support, use Panel Link instead) */
1629 nolcd = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x23);
1630 if(!(nolcd & 0x02)) SiS_Pr->SiS_VBType |= VB_NoLCD;
1633 if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS301C | VB_SIS302B)) {
1635 SiS_Pr->SiS_VBType &= ~(VB_SIS301B | VB_SIS301C | VB_SIS302B | VB_NoLCD);
1637 flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x39);
1639 SiS_Pr->SiS_VBType |= VB_SIS302LV;
1641 SiS_Pr->SiS_VBType |= VB_SIS302ELV;
1643 SiS_Pr->SiS_VBType |= VB_SIS301LV;
1649 /*********************************************/
1650 /* HELPER: GetDRAMSize */
1651 /*********************************************/
1655 GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1657 ULONG AdapterMemorySize = 0;
1662 switch(HwInfo->jChipType) {
1667 counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
1668 AdapterMemorySize = 1 << ((counter & 0xF0) >> 4);
1671 if(counter == 0x02) {
1672 AdapterMemorySize += (AdapterMemorySize / 2); /* DDR asymetric */
1673 } else if(counter != 0) {
1674 AdapterMemorySize <<= 1; /* SINGLE_CHANNEL_2_RANK or DUAL_CHANNEL_1_RANK */
1676 AdapterMemorySize *= (1024*1024);
1680 counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
1681 AdapterMemorySize = 1 << ((counter & 0xF0) >> 4);
1684 AdapterMemorySize <<= 1;
1686 AdapterMemorySize *= (1024*1024);
1692 counter = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x3F;
1694 AdapterMemorySize = counter * 4;
1695 AdapterMemorySize *= (1024*1024);
1702 counter = (SiS_GetReg(SiS_Pr->SiS_P3c4,0x79) & 0xf0) >> 4;
1703 AdapterMemorySize = 1 << counter;
1704 AdapterMemorySize *= (1024*1024);
1713 AdapterMemorySize = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x3F;
1714 AdapterMemorySize++;
1715 AdapterMemorySize *= (1024*1024);
1722 return AdapterMemorySize;
1726 /*********************************************/
1727 /* HELPER: Check RAM size */
1728 /*********************************************/
1732 SiS_CheckMemorySize(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
1733 USHORT ModeNo, USHORT ModeIdIndex)
1735 USHORT memorysize,modeflag;
1738 if(SiS_Pr->UseCustomMode) {
1739 modeflag = SiS_Pr->CModeFlag;
1741 if(ModeNo <= 0x13) {
1742 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
1744 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1748 memorysize = modeflag & MemoryInfoFlag;
1749 memorysize >>= MemorySizeShift; /* Get required memory size */
1752 temp = GetDRAMSize(SiS_Pr, HwInfo); /* Get adapter memory size (in MB) */
1753 temp /= (1024*1024);
1755 if(temp < memorysize) return(FALSE);
1760 /*********************************************/
1761 /* HELPER: Get DRAM type */
1762 /*********************************************/
1766 SiS_Get310DRAMType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1770 if(*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) {
1771 data = *SiS_Pr->pSiS_SoftSetting & 0x03;
1773 if(HwInfo->jChipType >= SIS_661) {
1774 data = SiS_GetReg(SiS_Pr->SiS_P3d4,0x78) & 0x07;
1775 } else if(IS_SIS550650740) {
1776 data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x07;
1777 } else { /* 315, 330 */
1778 data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3a) & 0x03;
1779 if(HwInfo->jChipType == SIS_330) {
1781 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0x30;
1783 case 0x00: data = 1; break;
1784 case 0x10: data = 3; break;
1785 case 0x20: data = 3; break;
1786 case 0x30: data = 2; break;
1799 SiS_GetMCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1803 index = SiS_Get310DRAMType(SiS_Pr, HwInfo);
1804 if(HwInfo->jChipType >= SIS_661) {
1805 return(SiS_Pr->SiS_MCLKData_0[index].CLOCK);
1806 } else if(index >= 4) {
1808 return(SiS_Pr->SiS_MCLKData_1[index].CLOCK);
1810 return(SiS_Pr->SiS_MCLKData_0[index].CLOCK);
1815 /*********************************************/
1816 /* HELPER: ClearBuffer */
1817 /*********************************************/
1821 SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
1823 UCHAR *VideoMemoryAddress = HwInfo->pjVideoMemoryAddress;
1824 ULONG AdapterMemorySize = (ULONG)HwInfo->ulVideoMemorySize;
1828 if(SiS_Pr->SiS_ModeType >= ModeEGA) {
1830 AdapterMemorySize = GetDRAMSize(SiS_Pr, HwInfo);
1831 SiS_SetMemory(VideoMemoryAddress,AdapterMemorySize,0);
1833 pBuffer = (USHORT *)VideoMemoryAddress;
1834 for(i=0; i<0x4000; i++)
1835 pBuffer[i] = 0x0000;
1838 pBuffer = (USHORT *)VideoMemoryAddress;
1839 if(SiS_Pr->SiS_ModeType < ModeCGA) {
1840 for(i=0; i<0x4000; i++)
1841 pBuffer[i] = 0x0720;
1843 SiS_SetMemory(VideoMemoryAddress,0x8000,0);
1849 /*********************************************/
1850 /* HELPER: SearchModeID */
1851 /*********************************************/
1854 SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex)
1856 UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO;
1858 if(*ModeNo <= 0x13) {
1860 if((*ModeNo) <= 0x05) (*ModeNo) |= 0x01;
1862 for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) {
1863 if(SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == (*ModeNo)) break;
1864 if(SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF) return FALSE;
1867 if(*ModeNo == 0x07) {
1868 if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */
1869 /* else 350 lines */
1871 if(*ModeNo <= 0x03) {
1872 if(!(VGAINFO & 0x80)) (*ModeIdIndex)++;
1873 if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */
1874 /* else 350 lines */
1876 /* else 200 lines */
1880 for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) {
1881 if(SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == (*ModeNo)) break;
1882 if(SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) return FALSE;
1889 /*********************************************/
1890 /* HELPER: GetModePtr */
1891 /*********************************************/
1894 SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex)
1898 if(ModeNo <= 0x13) {
1899 index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_StTableIndex;
1901 if(SiS_Pr->SiS_ModeType <= 0x02) index = 0x1B; /* 02 -> ModeEGA */
1907 /*********************************************/
1908 /* HELPER: LowModeTests */
1909 /*********************************************/
1912 SiS_DoLowModeTest(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo)
1914 USHORT temp,temp1,temp2;
1916 if((ModeNo != 0x03) && (ModeNo != 0x10) && (ModeNo != 0x12))
1918 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x11);
1919 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x11,0x80);
1920 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00);
1921 SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,0x55);
1922 temp2 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x00);
1923 SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,temp1);
1924 SiS_SetReg(SiS_Pr->SiS_P3d4,0x11,temp);
1925 if((HwInfo->jChipType >= SIS_315H) ||
1926 (HwInfo->jChipType == SIS_300)) {
1927 if(temp2 == 0x55) return(0);
1930 if(temp2 != 0x55) return(1);
1932 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01);
1939 SiS_SetLowModeTest(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo)
1941 if(SiS_DoLowModeTest(SiS_Pr, ModeNo, HwInfo)) {
1942 SiS_Pr->SiS_SetFlag |= LowModeTests;
1946 /*********************************************/
1947 /* HELPER: GetColorDepth */
1948 /*********************************************/
1951 SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex)
1953 USHORT ColorDepth[6] = { 1, 2, 4, 4, 6, 8};
1957 /* Do NOT check UseCustomMode, will skrew up FIFO */
1958 if(ModeNo == 0xfe) {
1959 modeflag = SiS_Pr->CModeFlag;
1962 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
1964 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1967 index = (modeflag & ModeInfoFlag) - ModeEGA;
1968 if(index < 0) index = 0;
1969 return(ColorDepth[index]);
1972 /*********************************************/
1973 /* HELPER: GetOffset */
1974 /*********************************************/
1977 SiS_GetOffset(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
1978 USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo)
1980 USHORT temp,colordepth,infoflag;
1982 if(SiS_Pr->UseCustomMode) {
1983 infoflag = SiS_Pr->CInfoFlag;
1984 temp = SiS_Pr->CHDisplay / 16;
1986 infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1987 temp = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeOffset;
1988 temp = SiS_Pr->SiS_ScreenOffset[temp];
1991 colordepth = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex);
1993 if(infoflag & InterlaceMode) temp <<= 1;
1997 if( ( ((ModeNo >= 0x26) && (ModeNo <= 0x28)) ||
2001 (SiS_Pr->UseCustomMode && (SiS_Pr->CHDisplay % 16)) ) {
2009 /*********************************************/
2011 /*********************************************/
2014 SiS_SetSeqRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo)
2019 SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03); /* Set SR0 */
2021 SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0];
2023 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
2024 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
2027 if(HwInfo->jChipType >= SIS_661) {
2028 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
2029 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2030 SRdata |= 0x01; /* 8 dot clock */
2033 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
2034 if(SiS_Pr->SiS_VBType & VB_NoLCD) {
2035 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2036 SRdata |= 0x01; /* 8 dot clock */
2042 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2043 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
2044 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
2045 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2046 SRdata |= 0x01; /* 8 dot clock */
2050 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
2051 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2052 SRdata |= 0x01; /* 8 dot clock */
2057 SRdata |= 0x20; /* screen off */
2059 SiS_SetReg(SiS_Pr->SiS_P3c4,0x01,SRdata);
2061 for(i = 2; i <= 4; i++) {
2062 SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1];
2063 SiS_SetReg(SiS_Pr->SiS_P3c4,i,SRdata);
2067 /*********************************************/
2069 /*********************************************/
2072 SiS_SetMiscRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex, PSIS_HW_INFO HwInfo)
2076 Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC;
2078 if(HwInfo->jChipType < SIS_661) {
2079 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
2080 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
2086 SiS_SetRegByte(SiS_Pr->SiS_P3c2,Miscdata);
2089 /*********************************************/
2091 /*********************************************/
2094 SiS_SetCRTCRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
2095 USHORT StandTableIndex)
2100 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* Unlock CRTC */
2102 for(i = 0; i <= 0x18; i++) {
2103 CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i];
2104 SiS_SetReg(SiS_Pr->SiS_P3d4,i,CRTCdata); /* Set CRTC(3d4) */
2106 if( ( (HwInfo->jChipType == SIS_630) ||
2107 (HwInfo->jChipType == SIS_730) ) &&
2108 (HwInfo->jChipRevision >= 0x30) ) { /* for 630S0 */
2109 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2110 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
2111 SiS_SetReg(SiS_Pr->SiS_P3d4,0x18,0xFE);
2117 /*********************************************/
2119 /*********************************************/
2122 SiS_SetATTRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex,
2123 PSIS_HW_INFO HwInfo)
2128 for(i = 0; i <= 0x13; i++) {
2129 ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[i];
2131 if((i <= 0x0f) || (i == 0x11)) {
2138 /* Pixel shift. If screen on LCD or TV is shifted left or right,
2139 * this might be the cause.
2141 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
2142 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ARdata=0;
2144 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2145 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
2146 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
2147 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0;
2151 if(HwInfo->jChipType >= SIS_661) {
2152 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
2153 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0;
2155 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
2156 if(HwInfo->jChipType >= SIS_315H) {
2157 if(IS_SIS550650740660) {
2158 /* 315, 330 don't do this */
2159 if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
2160 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0;
2166 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0;
2170 SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */
2171 SiS_SetRegByte(SiS_Pr->SiS_P3c0,i); /* set index */
2172 SiS_SetRegByte(SiS_Pr->SiS_P3c0,ARdata); /* set data */
2174 SiS_GetRegByte(SiS_Pr->SiS_P3da); /* reset 3da */
2175 SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x14); /* set index */
2176 SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x00); /* set data */
2178 SiS_GetRegByte(SiS_Pr->SiS_P3da);
2179 SiS_SetRegByte(SiS_Pr->SiS_P3c0,0x20); /* Enable Attribute */
2180 SiS_GetRegByte(SiS_Pr->SiS_P3da);
2183 /*********************************************/
2185 /*********************************************/
2188 SiS_SetGRCRegs(SiS_Private *SiS_Pr, USHORT StandTableIndex)
2193 for(i = 0; i <= 0x08; i++) {
2194 GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i];
2195 SiS_SetReg(SiS_Pr->SiS_P3ce,i,GRdata);
2198 if(SiS_Pr->SiS_ModeType > ModeVGA) {
2199 /* 256 color disable */
2200 SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF);
2204 /*********************************************/
2205 /* CLEAR EXTENDED REGISTERS */
2206 /*********************************************/
2209 SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
2213 for(i = 0x0A; i <= 0x0E; i++) {
2214 SiS_SetReg(SiS_Pr->SiS_P3c4,i,0x00);
2217 if(HwInfo->jChipType >= SIS_315H) {
2218 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE);
2222 /*********************************************/
2224 /*********************************************/
2227 SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
2229 if(HwInfo->jChipType >= SIS_315H) {
2230 if(HwInfo->jChipType < SIS_661) {
2231 if(SiS_Pr->SiS_IF_DEF_LVDS == 0) return;
2234 if((SiS_Pr->SiS_IF_DEF_LVDS == 0) &&
2235 (!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) {
2240 if(HwInfo->jChipType >= SIS_315H) {
2241 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xCF,0x20);
2243 SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x20);
2245 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[1].SR2B);
2246 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[1].SR2C);
2247 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80);
2248 if(HwInfo->jChipType >= SIS_315H) {
2249 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x10);
2251 SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x10);
2253 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[0].SR2B);
2254 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[0].SR2C);
2255 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80);
2258 /*********************************************/
2260 /*********************************************/
2263 SiS_SetCRT1Sync(SiS_Private *SiS_Pr, USHORT RefreshRateTableIndex)
2267 if(SiS_Pr->UseCustomMode) {
2268 sync = SiS_Pr->CInfoFlag >> 8;
2270 sync = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
2275 SiS_SetRegByte(SiS_Pr->SiS_P3c2,sync);
2278 /*********************************************/
2280 /*********************************************/
2284 SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2285 USHORT RefreshRateTableIndex, USHORT *ResIndex,
2286 USHORT *DisplayType)
2288 USHORT modeflag = 0;
2290 if(ModeNo <= 0x13) {
2291 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
2292 *ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2294 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2295 *ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2300 *DisplayType = SiS_Pr->SiS_LCDResInfo;
2301 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 32;
2302 if(modeflag & HalfDCLK) *DisplayType += 16;
2304 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
2305 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
2307 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 2;
2308 if(modeflag & HalfDCLK) *DisplayType += 1;
2310 } else if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) {
2311 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
2313 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) *DisplayType += 2;
2314 if(modeflag & HalfDCLK) *DisplayType += 1;
2322 SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2323 USHORT RefreshRateTableIndex,
2324 PSIS_HW_INFO HwInfo)
2327 USHORT temp,i,j,modeflag;
2329 USHORT ResIndex,DisplayType;
2330 const SiS_LCDACRT1DataStruct *LCDACRT1Ptr = NULL;
2333 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* unlock cr0-7 */
2335 if(SiS_Pr->UseCustomMode) {
2337 modeflag = SiS_Pr->CModeFlag;
2339 for(i=0,j=0;i<=07;i++,j++) {
2340 SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]);
2342 for(j=0x10;i<=10;i++,j++) {
2343 SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]);
2345 for(j=0x15;i<=12;i++,j++) {
2346 SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->CCRT1CRTC[i]);
2348 for(j=0x0A;i<=15;i++,j++) {
2349 SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->CCRT1CRTC[i]);
2352 temp = SiS_Pr->CCRT1CRTC[16] & 0xE0;
2353 SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp);
2355 temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5;
2356 if(modeflag & DoubleScanMode) temp |= 0x80;
2357 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp);
2361 if(ModeNo <= 0x13) {
2362 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
2364 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2367 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2371 SiS_GetLCDACRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, &ResIndex, &DisplayType);
2373 switch(DisplayType) {
2374 case Panel_1024x768 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break;
2375 case Panel_1280x1024 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1; break;
2376 case Panel_1400x1050 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1; break;
2377 case Panel_1600x1200 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1; break;
2378 case Panel_1024x768 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1_H; break;
2379 case Panel_1280x1024 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1_H; break;
2380 case Panel_1400x1050 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1_H; break;
2381 case Panel_1600x1200 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1_H; break;
2382 case Panel_1024x768 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2; break;
2383 case Panel_1280x1024 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2; break;
2384 case Panel_1400x1050 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2; break;
2385 case Panel_1600x1200 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2; break;
2386 case Panel_1024x768 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2_H; break;
2387 case Panel_1280x1024 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2_H; break;
2388 case Panel_1400x1050 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2_H; break;
2389 case Panel_1600x1200 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2_H; break;
2390 case 100: LCDACRT1Ptr = Compaq1280x1024_LCDACRT1_1; break;
2391 case 101: LCDACRT1Ptr = Compaq1280x1024_LCDACRT1_1_H; break;
2392 case 102: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2; break;
2393 case 103: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2_H; break;
2394 case 104: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_1; break;
2395 case 105: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_1_H; break;
2396 case 106: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_2; break;
2397 case 107: LCDACRT1Ptr = Clevo1024x768_LCDACRT1_2_H; break;
2398 default: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break;
2401 for(i=0, j=0; i<=0x07; i++, j++) {
2402 SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]);
2404 for(i=0x10, j=8; i<=0x12; i++, j++) {
2405 SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]);
2407 for(i=0x15, j=11; i<=0x16; i++, j++) {
2408 SiS_SetReg(SiS_Pr->SiS_P3d4,i,(LCDACRT1Ptr+ResIndex)->CR[j]);
2410 for(i=0x0A, j=13; i<=0x0C; i++, j++) {
2411 SiS_SetReg(SiS_Pr->SiS_P3c4,i,(LCDACRT1Ptr+ResIndex)->CR[j]);
2414 temp = (LCDACRT1Ptr+ResIndex)->CR[16] & 0xE0;
2415 SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp);
2417 temp = ((LCDACRT1Ptr+ResIndex)->CR[16] & 0x01) << 5;
2418 if(modeflag & DoubleScanMode) temp |= 0x80;
2419 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp);
2425 index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
2427 for(i=0,j=0;i<=07;i++,j++) {
2428 SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]);
2430 for(j=0x10;i<=10;i++,j++) {
2431 SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]);
2433 for(j=0x15;i<=12;i++,j++) {
2434 SiS_SetReg(SiS_Pr->SiS_P3d4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]);
2436 for(j=0x0A;i<=15;i++,j++) {
2437 SiS_SetReg(SiS_Pr->SiS_P3c4,j,SiS_Pr->SiS_CRT1Table[index].CR[i]);
2440 temp = SiS_Pr->SiS_CRT1Table[index].CR[16] & 0xE0;
2441 SiS_SetReg(SiS_Pr->SiS_P3c4,0x0E,temp);
2443 temp = ((SiS_Pr->SiS_CRT1Table[index].CR[16]) & 0x01) << 5;
2444 if(modeflag & DoubleScanMode) temp |= 0x80;
2445 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,temp);
2450 if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F);
2453 /*********************************************/
2454 /* OFFSET & PITCH */
2455 /*********************************************/
2456 /* (partly overruled by SetPitch() in XF86) */
2457 /*********************************************/
2460 SiS_SetCRT1Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2461 USHORT RefreshRateTableIndex,
2462 PSIS_HW_INFO HwInfo)
2464 USHORT temp, DisplayUnit, infoflag;
2466 if(SiS_Pr->UseCustomMode) {
2467 infoflag = SiS_Pr->CInfoFlag;
2469 infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
2472 DisplayUnit = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,
2473 RefreshRateTableIndex,HwInfo);
2475 temp = (DisplayUnit >> 8) & 0x0f;
2476 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,temp);
2478 temp = DisplayUnit & 0xFF;
2479 SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,temp);
2481 if(infoflag & InterlaceMode) DisplayUnit >>= 1;
2484 temp = (DisplayUnit & 0xff00) >> 8;
2485 if (DisplayUnit & 0xff) temp++;
2487 SiS_SetReg(SiS_Pr->SiS_P3c4,0x10,temp);
2490 /*********************************************/
2492 /*********************************************/
2495 SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2496 PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex)
2498 USHORT index=0, clka, clkb;
2500 if(SiS_Pr->UseCustomMode) {
2501 clka = SiS_Pr->CSR2B;
2502 clkb = SiS_Pr->CSR2C;
2504 index = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
2505 if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2506 clka = SiS_Pr->SiS_VBVCLKData[index].Part4_A;
2507 clkb = SiS_Pr->SiS_VBVCLKData[index].Part4_B;
2509 clka = SiS_Pr->SiS_VCLKData[index].SR2B;
2510 clkb = SiS_Pr->SiS_VCLKData[index].SR2C;
2514 if(HwInfo->jChipType >= SIS_315H) {
2515 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF);
2517 SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00);
2520 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2B,clka);
2521 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2C,clkb);
2523 if(HwInfo->jChipType >= SIS_315H) {
2524 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01);
2526 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x80);
2530 /*********************************************/
2532 /*********************************************/
2536 SiS_DoCalcDelay(SiS_Private *SiS_Pr, USHORT MCLK, USHORT VCLK, USHORT colordepth, USHORT key)
2538 const UCHAR ThLowA[] = { 61, 3,52, 5,68, 7,100,11,
2539 43, 3,42, 5,54, 7, 78,11,
2540 34, 3,37, 5,47, 7, 67,11 };
2542 const UCHAR ThLowB[] = { 81, 4,72, 6,88, 8,120,12,
2543 55, 4,54, 6,66, 8, 90,12,
2544 42, 4,45, 6,55, 8, 75,12 };
2546 const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 };
2548 USHORT tempah, tempal, tempcl, tempbx, temp;
2551 tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18);
2558 tempcl = ThTiming[tempal];
2559 tempbx = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16);
2561 tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
2567 tempal = ThLowA[tempbx + 1];
2569 tempal += ThLowA[tempbx];
2571 tempal = ThLowB[tempbx + 1];
2573 tempal += ThLowB[tempbx];
2575 longtemp = tempal * VCLK * colordepth;
2576 temp = longtemp % (MCLK * 16);
2577 longtemp /= (MCLK * 16);
2578 if(temp) longtemp++;
2579 return((USHORT)longtemp);
2583 SiS_CalcDelay(SiS_Private *SiS_Pr, USHORT VCLK, USHORT colordepth, USHORT MCLK)
2585 USHORT tempax, tempbx;
2587 tempbx = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 0);
2588 tempax = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 1);
2589 if(tempax < 4) tempax = 4;
2591 if(tempbx < tempax) tempbx = tempax;
2596 SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo,
2597 USHORT RefreshRateTableIndex)
2599 USHORT ThresholdLow = 0;
2600 USHORT index, VCLK, MCLK, colorth=0;
2601 USHORT tempah, temp;
2605 if(SiS_Pr->UseCustomMode) {
2606 VCLK = SiS_Pr->CSRClock;
2608 index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2610 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */
2613 switch (SiS_Pr->SiS_ModeType - ModeEGA) { /* Get half colordepth */
2614 case 0 : colorth = 1; break;
2615 case 1 : colorth = 1; break;
2616 case 2 : colorth = 2; break;
2617 case 3 : colorth = 2; break;
2618 case 4 : colorth = 3; break;
2619 case 5 : colorth = 4; break;
2622 index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A);
2624 MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */
2626 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
2628 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,tempah);
2631 ThresholdLow = SiS_CalcDelay(SiS_Pr, VCLK, colorth, MCLK);
2633 if(ThresholdLow < 0x13) break;
2634 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x16,0xfc);
2635 ThresholdLow = 0x13;
2636 tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16);
2638 if(!(tempah)) break;
2641 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3f,tempah);
2644 } else ThresholdLow = 2;
2646 /* Write CRT/CPU threshold low, CRT/Engine threshold high */
2647 temp = (ThresholdLow << 4) | 0x0f;
2648 SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,temp);
2650 temp = (ThresholdLow & 0x10) << 1;
2651 if(ModeNo > 0x13) temp |= 0x40;
2652 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp);
2655 SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09);
2657 /* Write CRT/CPU threshold high */
2658 temp = ThresholdLow + 3;
2659 if(temp > 0x0f) temp = 0x0f;
2660 SiS_SetReg(SiS_Pr->SiS_P3c4,0x09,temp);
2664 SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR key, PSIS_HW_INFO HwInfo)
2667 const UCHAR LatencyFactor[] = {
2668 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */
2669 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */
2670 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */
2671 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */
2672 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */
2673 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */
2674 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */
2675 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */
2677 const UCHAR LatencyFactor730[] = {
2682 137,130,128, /* --- Table ends with this entry, data below */
2683 137,130,128, /* to avoid using illegal values */
2696 if(HwInfo->jChipType == SIS_730) {
2697 index = ((key & 0x0f) * 3) + ((key & 0xC0) >> 6);
2698 data = LatencyFactor730[index];
2700 index = (key & 0xE0) >> 5;
2701 if(key & 0x10) index +=6;
2702 if(!(key & 0x01)) index += 24;
2703 data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
2704 if(data & 0x0080) index += 12;
2705 data = LatencyFactor[index];
2711 SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, USHORT ModeNo,
2712 PSIS_HW_INFO HwInfo,
2713 USHORT RefreshRateTableIndex)
2715 USHORT i,index,data,VCLK,MCLK,colorth=0;
2716 ULONG B,eax,bl,data2;
2717 USHORT ThresholdLow=0;
2719 0x01,0x21,0x41,0x61,0x81,
2720 0x31,0x51,0x71,0x91,0xb1,
2721 0x00,0x20,0x40,0x60,0x80,
2722 0x30,0x50,0x70,0x90,0xb0,
2725 UCHAR FQBQData730[]= {
2736 if(SiS_Pr->UseCustomMode) {
2737 VCLK = SiS_Pr->CSRClock;
2739 index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2741 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */
2744 index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A);
2746 MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */
2748 data2 = SiS_Pr->SiS_ModeType - ModeEGA; /* Get half colordepth */
2750 case 0 : colorth = 1; break;
2751 case 1 : colorth = 1; break;
2752 case 2 : colorth = 2; break;
2753 case 3 : colorth = 2; break;
2754 case 4 : colorth = 3; break;
2755 case 5 : colorth = 4; break;
2758 if(HwInfo->jChipType == SIS_730) {
2761 B = SiS_CalcDelay2(SiS_Pr, FQBQData730[i], HwInfo) * VCLK * colorth;
2762 bl = B / (MCLK * 16);
2764 if(B == bl * 16 * MCLK) {
2771 if(FQBQData730[i+1] == 0xFF) {
2772 ThresholdLow = 0x13;
2780 } while(FQBQData730[i] != 0xFF);
2785 B = SiS_CalcDelay2(SiS_Pr, FQBQData[i], HwInfo) * VCLK * colorth;
2786 bl = B / (MCLK * 16);
2788 if(B == bl * 16 * MCLK) {
2795 if(FQBQData[i+1] == 0xFF) {
2796 ThresholdLow = 0x13;
2804 } while(FQBQData[i] != 0xFF);
2808 if(HwInfo->jChipType == SIS_730) {
2812 ThresholdLow = 0x02;
2815 /* Write foreground and background queue */
2816 if(HwInfo->jChipType == SIS_730) {
2818 data2 = FQBQData730[i];
2819 data2 = (data2 & 0xC0) >> 5;
2823 SiS_SetRegLong(0xcf8,0x80000050);
2824 eax = SiS_GetRegLong(0xcfc);
2827 SiS_SetRegLong(0xcfc,eax);
2829 /* We use pci functions X offers. We use pcitag 0, because
2830 * we want to read/write to the host bridge (which is always
2831 * 00:00.0 on 630, 730 and 540), not the VGA device.
2833 eax = pciReadLong(0x00000000, 0x50);
2836 pciWriteLong(0x00000000, 0x50, eax);
2839 /* Write GUI grant timer (PCI config 0xA3) */
2840 data2 = FQBQData730[i] << 8;
2841 data2 = (data2 & 0x0f00) | ((data2 & 0x3000) >> 8);
2845 SiS_SetRegLong(0xcf8,0x800000A0);
2846 eax = SiS_GetRegLong(0xcfc);
2849 SiS_SetRegLong(0xcfc,eax);
2851 eax = pciReadLong(0x00000000, 0xA0);
2854 pciWriteLong(0x00000000, 0xA0, eax);
2859 data2 = FQBQData[i];
2860 data2 = (data2 & 0xf0) >> 4;
2864 SiS_SetRegLong(0xcf8,0x80000050);
2865 eax = SiS_GetRegLong(0xcfc);
2868 SiS_SetRegLong(0xcfc,eax);
2870 eax = pciReadLong(0x00000000, 0x50);
2873 pciWriteLong(0x00000000, 0x50, eax);
2876 /* Write GUI grant timer (PCI config 0xA3) */
2877 data2 = FQBQData[i];
2882 SiS_SetRegLong(0xcf8,0x800000A0);
2883 eax = SiS_GetRegLong(0xcfc);
2886 SiS_SetRegLong(0xcfc,eax);
2888 eax = pciReadLong(0x00000000, 0xA0);
2891 pciWriteLong(0x00000000, 0xA0, eax);
2896 /* Write CRT/CPU threshold low, CRT/Engine threshold high */
2897 data = ((ThresholdLow & 0x0f) << 4) | 0x0f;
2898 SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,data);
2900 data = (ThresholdLow & 0x10) << 1;
2901 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data);
2904 SiS_SetReg(SiS_Pr->SiS_P3c4,0x3B,0x09);
2906 /* Write CRT/CPU threshold high (gap = 3) */
2907 data = ThresholdLow + 3;
2908 if(data > 0x0f) data = 0x0f;
2909 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data);
2915 SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2916 PSIS_HW_INFO HwInfo)
2920 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); /* disable auto-threshold */
2922 if(SiS_Pr->UseCustomMode) {
2923 modeflag = SiS_Pr->CModeFlag;
2925 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2928 if(HwInfo->jChipType >= SIS_661) {
2929 SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE);
2930 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0);
2932 if(!(modeflag & HalfDCLK)) {
2933 SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34);
2934 if(ModeNo != 0x38) {
2935 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01);
2941 if( (!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) {
2942 SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0x34);
2943 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0);
2944 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01);
2946 SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE);
2947 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0);
2950 SiS_SetReg(SiS_Pr->SiS_P3c4,0x08,0xAE);
2951 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0);
2957 /*********************************************/
2958 /* MODE REGISTERS */
2959 /*********************************************/
2962 SiS_SetVCLKState(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
2963 USHORT ModeNo, USHORT RefreshRateTableIndex,
2966 USHORT data, data2=0;
2967 USHORT VCLK, index=0;
2969 if(ModeNo <= 0x13) VCLK = 0;
2971 if(SiS_Pr->UseCustomMode) {
2972 VCLK = SiS_Pr->CSRClock;
2974 index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,
2975 RefreshRateTableIndex,HwInfo);
2976 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;
2980 if(HwInfo->jChipType < SIS_315H) { /* 300 series */
2983 if(VCLK > 150) data2 |= 0x80;
2984 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data2);
2987 if(VCLK >= 150) data2 |= 0x08;
2988 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data2);
2990 } else { /* 315 series */
2993 if(VCLK >= 166) data |= 0x0c;
2994 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data);
2997 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7);
3002 if((VCLK >= 135) && (VCLK < 160)) data2 = 0x02;
3003 else if((VCLK >= 160) && (VCLK < 260)) data2 = 0x01;
3004 else if(VCLK >= 260) data2 = 0x00;
3006 if(HwInfo->jChipType == SIS_540) {
3007 if((VCLK == 203) || (VCLK < 234)) data2 = 0x02;
3010 if(HwInfo->jChipType < SIS_315H) {
3011 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data2); /* DAC speed */
3013 if(HwInfo->jChipType > SIS_315PRO) {
3014 /* This "if" is done in 330 and 650/LVDS/301LV BIOSes; Not in 315 BIOS */
3015 if(ModeNo > 0x13) data2 &= 0xfc;
3017 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data2); /* DAC speed */
3022 SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
3023 USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex)
3026 USHORT infoflag=0,modeflag;
3027 USHORT resindex,xres;
3036 if(SiS_Pr->UseCustomMode) {
3037 modeflag = SiS_Pr->CModeFlag;
3038 infoflag = SiS_Pr->CInfoFlag;
3041 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3042 infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
3045 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
3049 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
3054 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F);
3056 if(ModeNo > 0x13) data = infoflag;
3061 if(SiS_Pr->SiS_ModeType > 0x02) {
3063 data2 |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2);
3068 xf86DrvMsg(0, X_INFO, "Debug: Mode infoflag = %x, Chiptype %d\n",
3069 data, HwInfo->jChipType);
3072 if(data & InterlaceMode) data2 |= 0x20;
3073 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x06,0xC0,data2);
3075 if(SiS_Pr->UseCustomMode) {
3076 xres = SiS_Pr->CHDisplay;
3078 resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex);
3079 if(ModeNo <= 0x13) {
3080 xres = SiS_Pr->SiS_StResInfo[resindex].HTotal;
3082 xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal;
3086 if(HwInfo->jChipType != SIS_300) {
3088 if(infoflag & InterlaceMode) {
3089 if(xres <= 800) data = 0x0020;
3090 else if(xres <= 1024) data = 0x0035;
3093 SiS_SetReg(SiS_Pr->SiS_P3d4,0x19,(data & 0x00FF));
3094 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,(data >> 8));
3097 if(modeflag & HalfDCLK) {
3098 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x08);
3101 if(HwInfo->jChipType == SIS_300) {
3102 if(modeflag & LineCompareOff) {
3103 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x08);
3105 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xF7);
3108 if(modeflag & LineCompareOff) {
3109 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,0x08);
3111 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7);
3113 if(SiS_Pr->SiS_ModeType == ModeEGA) {
3115 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x40);
3121 /* 315 BIOS sets SR17 at this point */
3122 if(HwInfo->jChipType == SIS_315PRO) {
3123 data = SiS_Get310DRAMType(SiS_Pr, HwInfo);
3124 data = SiS_Pr->SiS_SR15[2][data];
3125 if(SiS_Pr->SiS_ModeType == ModeText) {
3128 data2 = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,
3129 RefreshRateTableIndex,HwInfo);
3131 if(infoflag & InterlaceMode) data2 >>= 1;
3132 data3 = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex) >> 1;
3140 SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data);
3143 /* 330 BIOS sets SR17 at this point */
3144 if(HwInfo->jChipType == SIS_330) {
3145 data = SiS_Get310DRAMType(SiS_Pr, HwInfo);
3146 data = SiS_Pr->SiS_SR15[2][data];
3147 if(SiS_Pr->SiS_ModeType <= ModeEGA) {
3150 if(SiS_Pr->UseCustomMode) {
3151 data2 = SiS_Pr->CSRClock;
3153 data2 = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,
3154 RefreshRateTableIndex,HwInfo);
3155 data2 = SiS_Pr->SiS_VCLKData[data2].CLOCK;
3158 data3 = SiS_GetColorDepth(SiS_Pr,ModeNo,ModeIdIndex) >> 1;
3163 longdata = SiS_GetMCLK(SiS_Pr, HwInfo) * 1024;
3165 data2 = longdata / data2;
3167 if(SiS_Pr->SiS_ModeType != Mode16Bpp) {
3168 if(data2 >= 0x19c) data = 0xba;
3169 else if(data2 >= 0x140) data = 0x7a;
3170 else if(data2 >= 0x101) data = 0x3a;
3171 else if(data2 >= 0xf5) data = 0x32;
3172 else if(data2 >= 0xe2) data = 0x2a;
3173 else if(data2 >= 0xc4) data = 0x22;
3174 else if(data2 >= 0xac) data = 0x1a;
3175 else if(data2 >= 0x9e) data = 0x12;
3176 else if(data2 >= 0x8e) data = 0x0a;
3179 if(data2 >= 0x127) data = 0xba;
3183 SiS_SetReg(SiS_Pr->SiS_P3c4,0x17,data);
3188 if(SiS_Pr->SiS_ModeType != ModeText) {
3190 if(SiS_Pr->SiS_ModeType != ModeEGA) {
3194 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x21,0x1F,data);
3196 SiS_SetVCLKState(SiS_Pr, HwInfo, ModeNo, RefreshRateTableIndex, ModeIdIndex);
3199 if(HwInfo->jChipType >= SIS_315H) {
3200 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) {
3201 SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x2c);
3203 SiS_SetReg(SiS_Pr->SiS_P3d4,0x52,0x6c);
3205 #if 0 /* What is SR0E[D5:6]? */
3206 if(HwInfo->jChipType >= SIS_661) {
3208 if((ModeNo == 6) || ((ModeNo >= 0x0e) && (ModeNo <= 0x13))) {
3211 if(SiS_Pr->SiS_ModeType != ModeVGA) {
3212 if(SiS_Pr->UseCustomMode) {
3213 if((xres >= 640) && (SiS_Pr->CVDisplay >= 480)) {
3216 if((xres > 1280) && (SiS_Pr->CVDisplay > 1024)) {
3220 } else if(ModeNo > 0x13) { /* These are in the CRT1 table, and set by CRT1CRTC */
3221 if(resinfo >= SIS_RI_640x480) {
3222 if(resinfo <= SIS_RI_2048x1536) {
3224 if(resinfo > SIS_RI_1280x1024) {
3226 if(resinfo != SIS_RI_1600x1200) {
3227 data = SiS_GetReg(SiS_Pr->SiS_P3c4,0x0e);
3229 SiS_SetReg(SiS_Pr->SiS_P3c4,0x0e);
3234 if(resinfo == SIS_RI_1152x864) {
3237 if(resinfo == SIS_RI_1400x1050) { /* TW */
3242 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0e,data);
3249 /*********************************************/
3251 /*********************************************/
3255 SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port)
3259 OutPortByte(port, 0);
3261 for (i=0; i < (256 * 3); i++) {
3262 OutPortByte(port, 0);
3268 SiS_WriteDAC(SiS_Private *SiS_Pr, SISIOADDRESS DACData, USHORT shiftflag,
3269 USHORT dl, USHORT ah, USHORT al, USHORT dh)
3294 SiS_SetRegByte(DACData,(USHORT)dh);
3295 SiS_SetRegByte(DACData,(USHORT)bh);
3296 SiS_SetRegByte(DACData,(USHORT)bl);
3300 SiS_LoadDAC(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
3301 USHORT ModeNo, USHORT ModeIdIndex)
3304 USHORT time,i,j,k,m,n,o;
3305 USHORT si,di,bx,dl,al,ah,dh;
3307 SISIOADDRESS DACAddr, DACData;
3308 const USHORT *table = NULL;
3310 if(ModeNo <= 0x13) {
3311 data = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
3313 if(SiS_Pr->UseCustomMode) {
3314 data = SiS_Pr->CModeFlag;
3316 data = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3320 data &= DACInfoFlag;
3322 if(data == 0x00) table = SiS_MDA_DAC;
3323 if(data == 0x08) table = SiS_CGA_DAC;
3324 if(data == 0x10) table = SiS_EGA_DAC;
3327 table = SiS_VGA_DAC;
3329 if(time == 256) j = 16;
3332 if( ( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && /* 301B-DH LCD */
3333 (SiS_Pr->SiS_VBType & VB_NoLCD) ) ||
3334 (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) || /* LCDA */
3335 (!(SiS_Pr->SiS_SetFlag & ProgrammingCRT2)) ) { /* Programming CRT1 */
3336 DACAddr = SiS_Pr->SiS_P3c8;
3337 DACData = SiS_Pr->SiS_P3c9;
3339 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF);
3342 DACAddr = SiS_Pr->SiS_Part5Port;
3343 DACData = SiS_Pr->SiS_Part5Port + 1;
3346 SiS_SetRegByte(DACAddr,0x00);
3348 for(i=0; i<j; i++) {
3350 for(k=0; k<3; k++) {
3352 if(data & 0x01) data2 = 0x2A;
3353 if(data & 0x02) data2 += 0x15;
3354 if(shiftflag) data2 <<= 2;
3355 SiS_SetRegByte(DACData, data2);
3361 for(i = 16; i < 32; i++) {
3363 if(shiftflag) data <<= 2;
3364 for(k = 0; k < 3; k++) SiS_SetRegByte(DACData, data);
3367 for(m = 0; m < 9; m++) {
3371 for(n = 0; n < 3; n++) {
3372 for(o = 0; o < 5; o++) {
3377 SiS_WriteDAC(SiS_Pr, DACData, shiftflag, dl, ah, al, dh);
3380 for(o = 0; o < 3; o++) {
3385 SiS_WriteDAC(SiS_Pr, DACData, shiftflag, dl, ah, al, dh);
3394 /*********************************************/
3395 /* SET CRT1 REGISTER GROUP */
3396 /*********************************************/
3399 SiS_SetCRT1Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
3400 USHORT ModeNo, USHORT ModeIdIndex)
3402 USHORT StandTableIndex,RefreshRateTableIndex;
3404 SiS_Pr->SiS_CRT1Mode = ModeNo;
3405 StandTableIndex = SiS_GetModePtr(SiS_Pr, ModeNo, ModeIdIndex);
3406 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
3407 if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2)) {
3408 SiS_DisableBridge(SiS_Pr, HwInfo);
3412 SiS_ResetSegmentRegisters(SiS_Pr, HwInfo);
3414 SiS_SetSeqRegs(SiS_Pr, StandTableIndex, HwInfo);
3415 SiS_SetMiscRegs(SiS_Pr, StandTableIndex, HwInfo);
3416 SiS_SetCRTCRegs(SiS_Pr, HwInfo, StandTableIndex);
3417 SiS_SetATTRegs(SiS_Pr, StandTableIndex, HwInfo);
3418 SiS_SetGRCRegs(SiS_Pr, StandTableIndex);
3419 SiS_ClearExt1Regs(SiS_Pr,HwInfo);
3420 SiS_ResetCRT1VCLK(SiS_Pr, HwInfo);
3422 SiS_Pr->SiS_SelectCRT2Rate = 0;
3423 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
3426 xf86DrvMsgVerb(0, X_PROBED, 4, "(init: VBType=0x%04x, VBInfo=0x%04x)\n",
3427 SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo);
3430 if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) {
3431 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
3432 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
3436 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
3437 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
3440 RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
3442 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3443 SiS_Pr->SiS_SetFlag &= ~ProgrammingCRT2;
3446 if(RefreshRateTableIndex != 0xFFFF) {
3447 SiS_SetCRT1Sync(SiS_Pr, RefreshRateTableIndex);
3448 SiS_SetCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
3449 SiS_SetCRT1Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
3450 SiS_SetCRT1VCLK(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex);
3454 if(HwInfo->jChipType == SIS_300) {
3455 SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo,HwInfo,RefreshRateTableIndex);
3456 } else if((HwInfo->jChipType == SIS_630) ||
3457 (HwInfo->jChipType == SIS_730) ||
3458 (HwInfo->jChipType == SIS_540)) {
3459 SiS_SetCRT1FIFO_630(SiS_Pr, ModeNo, HwInfo, RefreshRateTableIndex);
3463 if(HwInfo->jChipType >= SIS_315H) {
3464 SiS_SetCRT1FIFO_310(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
3468 SiS_SetCRT1ModeRegs(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3470 SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex);
3473 if(SiS_Pr->SiS_flag_clearbuffer) {
3474 SiS_ClearBuffer(SiS_Pr,HwInfo,ModeNo);
3478 if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) {
3479 SiS_WaitRetrace1(SiS_Pr);
3480 SiS_DisplayOn(SiS_Pr);
3484 /*********************************************/
3485 /* HELPER: ENABLE CRT1 */
3486 /*********************************************/
3489 SiS_HandleCRT1(SiS_Private *SiS_Pr)
3491 SiS_SetRegAND(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0xbf);
3493 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x01)) {
3494 if((SiS_GetReg(SiS_Pr->SiS_P3c4,0x15) & 0x0a) ||
3495 (SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x01)) {
3496 SiS_SetRegOR(SiS_Pr->SiS_P3d4,SiS_Pr->SiS_MyCR63,0x40);
3502 /*********************************************/
3503 /* HELPER: SET VIDEO REGISTERS */
3504 /*********************************************/
3507 SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
3509 if((IS_SIS651) || (IS_SISM650)) {
3510 SiS_SetReg(SiS_Pr->SiS_VidCapt, 0x3f, 0x00); /* Fiddle with capture regs */
3511 SiS_SetReg(SiS_Pr->SiS_VidCapt, 0x00, 0x00);
3512 SiS_SetReg(SiS_Pr->SiS_VidPlay, 0x00, 0x86); /* (BIOS does NOT unlock) */
3513 SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x30, 0xfe); /* Fiddle with video regs */
3514 SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x3f, 0xef);
3516 /* !!! This does not support modes < 0x13 !!! */
3519 /*********************************************/
3520 /* XFree86: SET SCREEN PITCH */
3521 /*********************************************/
3525 SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn)
3527 SISPtr pSiS = SISPTR(pScrn);
3528 UShort HDisplay = pSiS->scrnPitch >> 3;
3530 SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,(HDisplay & 0xFF));
3531 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,(HDisplay>>8));
3535 SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn)
3537 SISPtr pSiS = SISPTR(pScrn);
3538 UShort HDisplay = pSiS->scrnPitch2 >> 3;
3541 if(pSiS->VGAEngine == SIS_315_VGA)
3542 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2F, 0x01);
3544 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24, 0x01);
3546 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(HDisplay & 0xFF));
3547 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0xF0,(HDisplay >> 8));
3551 SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn)
3553 SISPtr pSiS = SISPTR(pScrn);
3554 BOOLEAN isslavemode = FALSE;
3556 if( (pSiS->VBFlags & VB_VIDEOBRIDGE) &&
3557 ( ((pSiS->VGAEngine == SIS_300_VGA) &&
3558 (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) ||
3559 ((pSiS->VGAEngine == SIS_315_VGA) &&
3560 (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) {
3564 /* We need to set pitch for CRT1 if bridge is in slave mode, too */
3565 if((pSiS->VBFlags & DISPTYPE_DISP1) || (isslavemode)) {
3566 SiS_SetPitchCRT1(SiS_Pr, pScrn);
3568 /* We must not set the pitch for CRT2 if bridge is in slave mode */
3569 if((pSiS->VBFlags & DISPTYPE_DISP2) && (!isslavemode)) {
3570 SiS_SetPitchCRT2(SiS_Pr, pScrn);
3575 /*********************************************/
3577 /*********************************************/
3580 /* We need pScrn for setting the pitch correctly */
3582 SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch)
3585 SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,USHORT ModeNo)
3590 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
3591 SISIOADDRESS BaseAddr = HwInfo->ulIOAddress;
3592 unsigned char backupreg=0;
3596 SiS_Pr->UseCustomMode = FALSE;
3597 SiS_Pr->CRT1UsesCustomMode = FALSE;
3600 if(SiS_Pr->UseCustomMode) {
3604 SiSInitPtr(SiS_Pr, HwInfo);
3605 SiSRegInit(SiS_Pr, BaseAddr);
3606 SiS_GetSysFlags(SiS_Pr, HwInfo);
3609 if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
3612 SiS_Pr->SiS_VGAINFO = 0x11;
3614 SiSInitPCIetc(SiS_Pr, HwInfo);
3615 SiSSetLVDSetc(SiS_Pr, HwInfo);
3616 SiSDetermineROMUsage(SiS_Pr, HwInfo);
3618 if(!SiS_Pr->UseCustomMode) {
3619 ModeNo = ((ModeNo & 0x80) << 8) | (ModeNo & 0x7f);
3623 /* We never clear the buffer in X */
3627 if(ModeNo & 0x8000) {
3629 SiS_Pr->SiS_flag_clearbuffer = 0;
3631 SiS_Pr->SiS_flag_clearbuffer = 1;
3635 KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05);
3637 SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86);
3639 SiS_UnLockCRT2(SiS_Pr, HwInfo);
3641 if(!SiS_Pr->UseCustomMode) {
3642 if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE;
3647 SiS_GetVBType(SiS_Pr, HwInfo);
3649 /* Init/restore some VB registers */
3651 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
3652 if(HwInfo->jChipType >= SIS_315H) {
3653 SiS_UnLockCRT2(SiS_Pr,HwInfo);
3654 if(ROMAddr && SiS_Pr->SiS_UseROM) {
3655 if(HwInfo->jChipType < SIS_330) {
3656 temp = ROMAddr[VB310Data_1_2_Offset];
3658 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
3660 if(HwInfo->jChipType > SIS_330) {
3661 temp = ROMAddr[0x7e];
3662 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x7b) >= 100) temp |= 0x40;
3663 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
3666 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10);
3668 SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c);
3670 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
3672 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
3676 /* Get VB information (connectors, connected devices) */
3677 SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, (SiS_Pr->UseCustomMode) ? 0 : 1);
3678 SiS_SetYPbPr(SiS_Pr, HwInfo);
3679 SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
3680 SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
3681 SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo);
3684 /* 3. Check memory size (Kernel framebuffer driver only) */
3685 temp = SiS_CheckMemorySize(SiS_Pr, HwInfo, ModeNo, ModeIdIndex);
3686 if(!temp) return(0);
3689 if(HwInfo->jChipType >= SIS_315H) {
3691 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x08) {
3692 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
3693 if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode;
3694 } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) {
3695 SiS_Pr->SiS_SetFlag |= SetDOSMode;
3700 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
3702 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
3703 if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20);
3704 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
3705 } else if(IS_SIS661741660760) {
3706 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
3707 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
3708 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef);
3713 if(SiS_Pr->UseCustomMode) {
3714 SiS_Pr->CRT1UsesCustomMode = TRUE;
3715 SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock;
3716 SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag;
3718 SiS_Pr->CRT1UsesCustomMode = FALSE;
3721 /* Set mode on CRT1 */
3722 if( (SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) ||
3723 (!(SiS_Pr->SiS_VBInfo & SwitchCRT2)) ) {
3724 SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex);
3727 /* Set mode on CRT2 */
3728 if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA)) {
3729 if( (SiS_Pr->SiS_VBType & VB_SISVB) ||
3730 (SiS_Pr->SiS_IF_DEF_LVDS == 1) ||
3731 (SiS_Pr->SiS_IF_DEF_CH70xx != 0) ||
3732 (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) {
3733 SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo);
3737 SiS_HandleCRT1(SiS_Pr);
3739 SiS_StrangeStuff(SiS_Pr, HwInfo);
3741 SiS_DisplayOn(SiS_Pr);
3742 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF);
3744 if(HwInfo->jChipType >= SIS_315H) {
3745 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
3746 if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) {
3747 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
3752 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
3753 if(HwInfo->jChipType >= SIS_315H) {
3754 if(HwInfo->jChipType < SIS_661) {
3755 if(SiS_IsVAMode(SiS_Pr,HwInfo)) {
3756 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01);
3758 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE);
3762 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg);
3764 if((IS_SIS650) && (SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & 0xfc)) {
3765 if((ModeNo == 0x03) || (ModeNo == 0x10)) {
3766 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x80);
3767 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x56,0x08);
3771 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) {
3772 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc);
3774 } else if((HwInfo->jChipType == SIS_630) ||
3775 (HwInfo->jChipType == SIS_730)) {
3776 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg);
3782 /* SetPitch: Adapt to virtual size & position */
3783 if((ModeNo > 0x13) && (dosetpitch)) {
3784 SiS_SetPitch(SiS_Pr, pScrn);
3787 /* Backup/Set ModeNo in BIOS scratch area */
3788 SiS_GetSetModeID(pScrn, ModeNo);
3792 #ifndef LINUX_XF86 /* We never lock registers in XF86 */
3793 if(KeepLockReg == 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86);
3794 else SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00);
3800 /*********************************************/
3801 /* XFree86: SiSBIOSSetMode() */
3802 /* for non-Dual-Head mode */
3803 /*********************************************/
3807 SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn,
3808 DisplayModePtr mode, BOOLEAN IsCustom)
3810 SISPtr pSiS = SISPTR(pScrn);
3813 SiS_Pr->UseCustomMode = FALSE;
3815 if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
3817 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n",
3819 (mode->Flags & V_INTERLACE ? SiS_Pr->CVDisplay * 2 :
3820 (mode->Flags & V_DBLSCAN ? SiS_Pr->CVDisplay / 2 :
3821 SiS_Pr->CVDisplay)));
3823 return(SiSSetMode(SiS_Pr, HwInfo, pScrn, ModeNo, TRUE));
3827 ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes);
3828 if(!ModeNo) return FALSE;
3830 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo);
3832 return(SiSSetMode(SiS_Pr, HwInfo, pScrn, ModeNo, TRUE));
3835 /*********************************************/
3836 /* XFree86: SiSBIOSSetModeCRT2() */
3837 /* for Dual-Head modes */
3838 /*********************************************/
3840 SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn,
3841 DisplayModePtr mode, BOOLEAN IsCustom)
3845 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
3846 SISIOADDRESS BaseAddr = HwInfo->ulIOAddress;
3848 unsigned char backupreg=0;
3849 SISPtr pSiS = SISPTR(pScrn);
3851 SISEntPtr pSiSEnt = pSiS->entityPrivate;
3854 SiS_Pr->UseCustomMode = FALSE;
3856 /* Remember: Custom modes for CRT2 are ONLY supported
3857 * -) on 315/330 series,
3858 * -) on the 30x/B/C, and
3859 * -) if CRT2 is LCD or VGA
3862 if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
3868 BOOLEAN havecustommodes = pSiS->HaveCustomModes;
3871 if(pSiS->MergedFB) havecustommodes = pSiS->HaveCustomModes2;
3874 ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, havecustommodes);
3875 if(!ModeNo) return FALSE;
3879 SiSRegInit(SiS_Pr, BaseAddr);
3880 SiSInitPtr(SiS_Pr, HwInfo);
3881 SiS_GetSysFlags(SiS_Pr, HwInfo);
3882 SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
3883 SiSInitPCIetc(SiS_Pr, HwInfo);
3884 SiSSetLVDSetc(SiS_Pr, HwInfo);
3885 SiSDetermineROMUsage(SiS_Pr, HwInfo);
3887 /* Save mode info so we can set it from within SetMode for CRT1 */
3889 if(pSiS->DualHeadMode) {
3890 pSiSEnt->CRT2ModeNo = ModeNo;
3891 pSiSEnt->CRT2DMode = mode;
3892 pSiSEnt->CRT2IsCustom = IsCustom;
3893 pSiSEnt->CRT2CR30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
3894 pSiSEnt->CRT2CR31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31);
3895 pSiSEnt->CRT2CR35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
3896 pSiSEnt->CRT2CR38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
3898 /* We can't set CRT2 mode before CRT1 mode is set */
3899 if(pSiSEnt->CRT1ModeNo == -1) {
3900 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3901 "Setting CRT2 mode delayed until after setting CRT1 mode\n");
3905 pSiSEnt->CRT2ModeSet = TRUE;
3909 /* We don't clear the buffer under X */
3910 SiS_Pr->SiS_flag_clearbuffer=0;
3912 if(SiS_Pr->UseCustomMode) {
3914 USHORT temptemp = SiS_Pr->CVDisplay;
3916 if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1;
3917 else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1;
3919 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3920 "Setting custom mode %dx%d on CRT2\n",
3921 SiS_Pr->CHDisplay, temptemp);
3925 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3926 "Setting standard mode 0x%x on CRT2\n", ModeNo);
3930 SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86);
3932 SiS_UnLockCRT2(SiS_Pr, HwInfo);
3934 if(!SiS_Pr->UseCustomMode) {
3935 if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE;
3940 SiS_GetVBType(SiS_Pr, HwInfo);
3942 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
3943 if(HwInfo->jChipType >= SIS_315H) {
3944 SiS_UnLockCRT2(SiS_Pr,HwInfo);
3945 if(ROMAddr && SiS_Pr->SiS_UseROM) {
3946 if(HwInfo->jChipType < SIS_330) {
3947 temp = ROMAddr[VB310Data_1_2_Offset];
3949 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
3951 if(HwInfo->jChipType > SIS_330) {
3952 temp = ROMAddr[0x7e];
3953 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x7b) >= 100) temp |= 0x40;
3954 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,temp);
3957 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10);
3959 SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c);
3961 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
3963 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
3967 /* Get VB information (connectors, connected devices) */
3968 if(!SiS_Pr->UseCustomMode) {
3969 SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 1);
3971 /* If this is a custom mode, we don't check the modeflag for CRT2Mode */
3972 SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 0);
3974 SiS_SetYPbPr(SiS_Pr, HwInfo);
3975 SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
3976 SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
3977 SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo);
3979 /* Set mode on CRT2 */
3980 if( (SiS_Pr->SiS_VBType & VB_SISVB) ||
3981 (SiS_Pr->SiS_IF_DEF_LVDS == 1) ||
3982 (SiS_Pr->SiS_IF_DEF_CH70xx != 0) ||
3983 (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) {
3984 SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo);
3987 SiS_StrangeStuff(SiS_Pr, HwInfo);
3989 SiS_DisplayOn(SiS_Pr);
3990 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF);
3992 if(HwInfo->jChipType >= SIS_315H) {
3993 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
3994 if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) {
3995 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
4000 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
4001 if(HwInfo->jChipType >= SIS_315H) {
4002 if(HwInfo->jChipType < SIS_661) {
4003 if(SiS_IsVAMode(SiS_Pr,HwInfo)) {
4004 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01);
4006 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE);
4010 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg);
4012 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) {
4013 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc);
4015 } else if((HwInfo->jChipType == SIS_630) ||
4016 (HwInfo->jChipType == SIS_730)) {
4017 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg);
4021 /* SetPitch: Adapt to virtual size & position */
4022 SiS_SetPitchCRT2(SiS_Pr, pScrn);
4027 /*********************************************/
4028 /* XFree86: SiSBIOSSetModeCRT1() */
4029 /* for Dual-Head modes */
4030 /*********************************************/
4033 SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, ScrnInfoPtr pScrn,
4034 DisplayModePtr mode, BOOLEAN IsCustom)
4036 SISPtr pSiS = SISPTR(pScrn);
4037 SISIOADDRESS BaseAddr = HwInfo->ulIOAddress;
4038 USHORT ModeIdIndex, ModeNo=0;
4041 SISEntPtr pSiSEnt = pSiS->entityPrivate;
4042 UCHAR backupcr30, backupcr31, backupcr38, backupcr35, backupp40d=0;
4043 BOOLEAN backupcustom;
4046 SiS_Pr->UseCustomMode = FALSE;
4048 if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
4050 USHORT temptemp = SiS_Pr->CVDisplay;
4052 if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1;
4053 else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1;
4055 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
4056 "Setting custom mode %dx%d on CRT1\n",
4057 SiS_Pr->CHDisplay, temptemp);
4062 ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->VBFlags, pSiS->HaveCustomModes);
4063 if(!ModeNo) return FALSE;
4065 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
4066 "Setting standard mode 0x%x on CRT1\n", ModeNo);
4069 SiSInitPtr(SiS_Pr, HwInfo);
4070 SiSRegInit(SiS_Pr, BaseAddr);
4071 SiS_GetSysFlags(SiS_Pr, HwInfo);
4072 SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
4073 SiSInitPCIetc(SiS_Pr, HwInfo);
4074 SiSSetLVDSetc(SiS_Pr, HwInfo);
4075 SiSDetermineROMUsage(SiS_Pr, HwInfo);
4077 /* We don't clear the buffer under X */
4078 SiS_Pr->SiS_flag_clearbuffer = 0;
4080 SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86);
4082 SiS_UnLockCRT2(SiS_Pr, HwInfo);
4084 if(!SiS_Pr->UseCustomMode) {
4085 if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE;
4090 /* Determine VBType */
4091 SiS_GetVBType(SiS_Pr, HwInfo);
4093 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
4094 if(HwInfo->jChipType >= SIS_315H) {
4095 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
4097 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
4101 /* Get VB information (connectors, connected devices) */
4102 /* (We don't care if the current mode is a CRT2 mode) */
4103 SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, 0);
4104 SiS_SetYPbPr(SiS_Pr, HwInfo);
4105 SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
4106 SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
4107 SiS_SetLowModeTest(SiS_Pr, ModeNo, HwInfo);
4109 if(HwInfo->jChipType >= SIS_315H) {
4111 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x08) {
4112 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
4113 if(ModeNo != 0x10) SiS_Pr->SiS_SetFlag |= SetDOSMode;
4114 } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) {
4115 SiS_Pr->SiS_SetFlag |= SetDOSMode;
4120 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
4122 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
4123 if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20);
4124 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
4125 } else if(IS_SIS661741660760) {
4126 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
4127 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
4128 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x3a,0xef);
4133 /* Set mode on CRT1 */
4134 SiS_SetCRT1Group(SiS_Pr, HwInfo, ModeNo, ModeIdIndex);
4135 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
4136 SiS_SetCRT2Group(SiS_Pr, HwInfo, ModeNo);
4139 /* SetPitch: Adapt to virtual size & position */
4140 SiS_SetPitchCRT1(SiS_Pr, pScrn);
4143 if(pSiS->DualHeadMode) {
4144 pSiSEnt->CRT1ModeNo = ModeNo;
4145 pSiSEnt->CRT1DMode = mode;
4149 if(SiS_Pr->UseCustomMode) {
4150 SiS_Pr->CRT1UsesCustomMode = TRUE;
4151 SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock;
4152 SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag;
4154 SiS_Pr->CRT1UsesCustomMode = FALSE;
4157 /* Reset CRT2 if changing mode on CRT1 */
4159 if(pSiS->DualHeadMode) {
4160 if(pSiSEnt->CRT2ModeNo != -1) {
4161 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
4162 "(Re-)Setting mode for CRT2\n");
4163 backupcustom = SiS_Pr->UseCustomMode;
4164 backupcr30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
4165 backupcr31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31);
4166 backupcr35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
4167 backupcr38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
4168 if(SiS_Pr->SiS_VBType & VB_SISVB) {
4169 /* Backup LUT-enable */
4170 if(pSiSEnt->CRT2ModeSet) {
4171 backupp40d = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x0d) & 0x08;
4174 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
4175 SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,pSiSEnt->CRT2CR30);
4176 SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,pSiSEnt->CRT2CR31);
4177 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,pSiSEnt->CRT2CR35);
4178 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,pSiSEnt->CRT2CR38);
4180 SiSBIOSSetModeCRT2(SiS_Pr, HwInfo, pSiSEnt->pScrn_1,
4181 pSiSEnt->CRT2DMode, pSiSEnt->CRT2IsCustom);
4182 SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,backupcr30);
4183 SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,backupcr31);
4184 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupcr35);
4185 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupcr38);
4186 if(SiS_Pr->SiS_VBType & VB_SISVB) {
4187 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d, ~0x08, backupp40d);
4189 SiS_Pr->UseCustomMode = backupcustom;
4194 /* Warning: From here, the custom mode entries in SiS_Pr are
4195 * possibly overwritten
4198 SiS_HandleCRT1(SiS_Pr);
4200 SiS_StrangeStuff(SiS_Pr, HwInfo);
4202 SiS_DisplayOn(SiS_Pr);
4203 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF);
4205 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
4206 if(HwInfo->jChipType >= SIS_315H) {
4207 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg);
4208 } else if((HwInfo->jChipType == SIS_630) ||
4209 (HwInfo->jChipType == SIS_730)) {
4210 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg);
4214 /* Backup/Set ModeNo in BIOS scratch area */
4215 SiS_GetSetModeID(pScrn,ModeNo);
4219 #endif /* Linux_XF86 */
4224 SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4226 const USHORT PanelTypeTable300[16] = {
4227 0xc101, 0xc117, 0x0121, 0xc135, 0xc142, 0xc152, 0xc162, 0xc072,
4228 0xc181, 0xc192, 0xc1a1, 0xc1b6, 0xc1c2, 0xc0d2, 0xc1e2, 0xc1f2
4230 const USHORT PanelTypeTable31030x[16] = {
4231 0xc102, 0xc112, 0x0122, 0xc132, 0xc142, 0xc152, 0xc169, 0xc179,
4232 0x0189, 0xc192, 0xc1a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
4234 const USHORT PanelTypeTable310LVDS[16] = {
4235 0xc111, 0xc122, 0xc133, 0xc144, 0xc155, 0xc166, 0xc177, 0xc188,
4236 0xc199, 0xc0aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
4238 USHORT tempax,tempbx,temp;
4240 if(HwInfo->jChipType < SIS_315H) {
4242 tempax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18);
4243 tempbx = tempax & 0x0F;
4244 if(!(tempax & 0x10)){
4245 if(SiS_Pr->SiS_IF_DEF_LVDS == 1){
4247 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x38);
4248 if(temp & 0x40) tempbx |= 0x08;
4249 if(temp & 0x20) tempbx |= 0x02;
4250 if(temp & 0x01) tempbx |= 0x01;
4251 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x39);
4252 if(temp & 0x80) tempbx |= 0x04;
4257 tempbx = PanelTypeTable300[tempbx];
4259 temp = tempbx & 0x00FF;
4260 SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,temp);
4261 temp = (tempbx & 0xFF00) >> 8;
4262 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp);
4266 if(HwInfo->jChipType >= SIS_661) return 0;
4268 tempax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1a);
4271 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
4273 /* TODO: Include HUGE detection routine
4274 (Probably not worth bothering)
4278 temp = tempax & 0xff;
4280 tempbx = PanelTypeTable310LVDS[tempax];
4282 tempbx = PanelTypeTable31030x[tempax];
4283 temp = tempbx & 0xff;
4285 SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,temp);
4286 tempbx = (tempbx & 0xff00) >> 8;
4287 temp = tempbx & 0xc1;
4288 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp);
4289 if(SiS_Pr->SiS_VBType & VB_SISVB) {
4290 temp = tempbx & 0x04;
4291 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x39,0xfb,temp);
4300 /* ================ XFREE86 ================= */
4302 /* Helper functions */
4306 SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags)
4308 SISPtr pSiS = SISPTR(pScrn);
4309 int out_n, out_dn, out_div, out_sbit, out_scale;
4310 int depth = pSiS->CurrentLayout.bitsPerPixel;
4311 unsigned int vclk[5];
4319 pSiS->SiS_Pr->CModeFlag = 0;
4321 pSiS->SiS_Pr->CDClock = mode->Clock;
4323 pSiS->SiS_Pr->CHDisplay = mode->HDisplay;
4324 pSiS->SiS_Pr->CHSyncStart = mode->HSyncStart;
4325 pSiS->SiS_Pr->CHSyncEnd = mode->HSyncEnd;
4326 pSiS->SiS_Pr->CHTotal = mode->HTotal;
4328 pSiS->SiS_Pr->CVDisplay = mode->VDisplay;
4329 pSiS->SiS_Pr->CVSyncStart = mode->VSyncStart;
4330 pSiS->SiS_Pr->CVSyncEnd = mode->VSyncEnd;
4331 pSiS->SiS_Pr->CVTotal = mode->VTotal;
4333 pSiS->SiS_Pr->CFlags = mode->Flags;
4335 if(pSiS->SiS_Pr->CFlags & V_INTERLACE) {
4336 pSiS->SiS_Pr->CVDisplay >>= 1;
4337 pSiS->SiS_Pr->CVSyncStart >>= 1;
4338 pSiS->SiS_Pr->CVSyncEnd >>= 1;
4339 pSiS->SiS_Pr->CVTotal >>= 1;
4341 if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) {
4342 /* pSiS->SiS_Pr->CDClock <<= 1; */
4343 pSiS->SiS_Pr->CVDisplay <<= 1;
4344 pSiS->SiS_Pr->CVSyncStart <<= 1;
4345 pSiS->SiS_Pr->CVSyncEnd <<= 1;
4346 pSiS->SiS_Pr->CVTotal <<= 1;
4349 pSiS->SiS_Pr->CHBlankStart = pSiS->SiS_Pr->CHDisplay;
4350 pSiS->SiS_Pr->CHBlankEnd = pSiS->SiS_Pr->CHTotal;
4351 pSiS->SiS_Pr->CVBlankStart = pSiS->SiS_Pr->CVSyncStart - 1;
4352 pSiS->SiS_Pr->CVBlankEnd = pSiS->SiS_Pr->CVTotal;
4354 if(SiS_compute_vclk(pSiS->SiS_Pr->CDClock, &out_n, &out_dn, &out_div, &out_sbit, &out_scale)) {
4355 pSiS->SiS_Pr->CSR2B = (out_div == 2) ? 0x80 : 0x00;
4356 pSiS->SiS_Pr->CSR2B |= ((out_n - 1) & 0x7f);
4357 pSiS->SiS_Pr->CSR2C = (out_dn - 1) & 0x1f;
4358 pSiS->SiS_Pr->CSR2C |= (((out_scale - 1) & 3) << 5);
4359 pSiS->SiS_Pr->CSR2C |= ((out_sbit & 0x01) << 7);
4361 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sb %d sc %d\n",
4362 pSiS->SiS_Pr->CDClock, out_n, out_dn, out_div, out_sbit, out_scale);
4365 SiSCalcClock(pScrn, pSiS->SiS_Pr->CDClock, 2, vclk);
4366 pSiS->SiS_Pr->CSR2B = (vclk[VLDidx] == 2) ? 0x80 : 0x00;
4367 pSiS->SiS_Pr->CSR2B |= (vclk[Midx] - 1) & 0x7f;
4368 pSiS->SiS_Pr->CSR2C = (vclk[Nidx] - 1) & 0x1f;
4369 if(vclk[Pidx] <= 4) {
4370 /* postscale 1,2,3,4 */
4371 pSiS->SiS_Pr->CSR2C |= ((vclk[Pidx] - 1) & 3) << 5;
4374 pSiS->SiS_Pr->CSR2C |= (((vclk[Pidx] / 2) - 1) & 3) << 5;
4375 pSiS->SiS_Pr->CSR2C |= 0x80;
4378 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sc %d\n",
4379 pSiS->SiS_Pr->CDClock, vclk[Midx], vclk[Nidx], vclk[VLDidx], vclk[Pidx]);
4383 pSiS->SiS_Pr->CSRClock = (pSiS->SiS_Pr->CDClock / 1000) + 1;
4385 pSiS->SiS_Pr->CCRT1CRTC[0] = ((pSiS->SiS_Pr->CHTotal >> 3) - 5) & 0xff;
4386 pSiS->SiS_Pr->CCRT1CRTC[1] = (pSiS->SiS_Pr->CHDisplay >> 3) - 1;
4387 pSiS->SiS_Pr->CCRT1CRTC[2] = (pSiS->SiS_Pr->CHBlankStart >> 3) - 1;
4388 pSiS->SiS_Pr->CCRT1CRTC[3] = (((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x1F) | 0x80;
4389 pSiS->SiS_Pr->CCRT1CRTC[4] = (pSiS->SiS_Pr->CHSyncStart >> 3) + 3;
4390 pSiS->SiS_Pr->CCRT1CRTC[5] = ((((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) |
4391 (((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3) & 0x1F);
4393 pSiS->SiS_Pr->CCRT1CRTC[6] = (pSiS->SiS_Pr->CVTotal - 2) & 0xFF;
4394 pSiS->SiS_Pr->CCRT1CRTC[7] = (((pSiS->SiS_Pr->CVTotal - 2) & 0x100) >> 8)
4395 | (((pSiS->SiS_Pr->CVDisplay - 1) & 0x100) >> 7)
4396 | ((pSiS->SiS_Pr->CVSyncStart & 0x100) >> 6)
4397 | (((pSiS->SiS_Pr->CVBlankStart - 1) & 0x100) >> 5)
4399 | (((pSiS->SiS_Pr->CVTotal - 2) & 0x200) >> 4)
4400 | (((pSiS->SiS_Pr->CVDisplay - 1) & 0x200) >> 3)
4401 | ((pSiS->SiS_Pr->CVSyncStart & 0x200) >> 2);
4403 pSiS->SiS_Pr->CCRT1CRTC[16] = ((((pSiS->SiS_Pr->CVBlankStart - 1) & 0x200) >> 4) >> 5); /* cr9 */
4406 if (mode->VScan >= 32)
4407 regp->CRTC[9] |= 0x1F;
4408 else if (mode->VScan > 1)
4409 regp->CRTC[9] |= mode->VScan - 1;
4412 pSiS->SiS_Pr->CCRT1CRTC[8] = (pSiS->SiS_Pr->CVSyncStart ) & 0xFF; /* cr10 */
4413 pSiS->SiS_Pr->CCRT1CRTC[9] = ((pSiS->SiS_Pr->CVSyncEnd ) & 0x0F) | 0x80; /* cr11 */
4414 pSiS->SiS_Pr->CCRT1CRTC[10] = (pSiS->SiS_Pr->CVDisplay - 1) & 0xFF; /* cr12 */
4415 pSiS->SiS_Pr->CCRT1CRTC[11] = (pSiS->SiS_Pr->CVBlankStart - 1) & 0xFF; /* cr15 */
4416 pSiS->SiS_Pr->CCRT1CRTC[12] = (pSiS->SiS_Pr->CVBlankEnd - 1) & 0xFF; /* cr16 */
4418 pSiS->SiS_Pr->CCRT1CRTC[13] =
4419 GETBITSTR((pSiS->SiS_Pr->CVTotal -2), 10:10, 0:0) |
4420 GETBITSTR((pSiS->SiS_Pr->CVDisplay -1), 10:10, 1:1) |
4421 GETBITSTR((pSiS->SiS_Pr->CVBlankStart-1), 10:10, 2:2) |
4422 GETBITSTR((pSiS->SiS_Pr->CVSyncStart ), 10:10, 3:3) |
4423 GETBITSTR((pSiS->SiS_Pr->CVBlankEnd -1), 8:8, 4:4) |
4424 GETBITSTR((pSiS->SiS_Pr->CVSyncEnd ), 4:4, 5:5) ;
4426 pSiS->SiS_Pr->CCRT1CRTC[14] =
4427 GETBITSTR((pSiS->SiS_Pr->CHTotal >> 3) - 5, 9:8, 1:0) |
4428 GETBITSTR((pSiS->SiS_Pr->CHDisplay >> 3) - 1, 9:8, 3:2) |
4429 GETBITSTR((pSiS->SiS_Pr->CHBlankStart >> 3) - 1, 9:8, 5:4) |
4430 GETBITSTR((pSiS->SiS_Pr->CHSyncStart >> 3) + 3, 9:8, 7:6) ;
4433 pSiS->SiS_Pr->CCRT1CRTC[15] =
4434 GETBITSTR((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1, 7:6, 1:0) |
4435 GETBITSTR((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3, 5:5, 2:2) ;
4439 pSiS->SiS_Pr->CModeFlag |= 0x223b;
4442 pSiS->SiS_Pr->CModeFlag |= 0x227d;
4445 pSiS->SiS_Pr->CModeFlag |= 0x22ff;
4451 if(pSiS->SiS_Pr->CFlags & V_DBLSCAN)
4452 pSiS->SiS_Pr->CModeFlag |= DoubleScanMode;
4454 if((pSiS->SiS_Pr->CVDisplay >= 1024) ||
4455 (pSiS->SiS_Pr->CVTotal >= 1024) ||
4456 (pSiS->SiS_Pr->CHDisplay >= 1024))
4457 pSiS->SiS_Pr->CModeFlag |= LineCompareOff;
4459 if(pSiS->SiS_Pr->CFlags & V_CLKDIV2)
4460 pSiS->SiS_Pr->CModeFlag |= HalfDCLK;
4462 pSiS->SiS_Pr->CInfoFlag = 0x0007;
4464 if(pSiS->SiS_Pr->CFlags & V_NHSYNC)
4465 pSiS->SiS_Pr->CInfoFlag |= 0x4000;
4467 if(pSiS->SiS_Pr->CFlags & V_NVSYNC)
4468 pSiS->SiS_Pr->CInfoFlag |= 0x8000;
4470 if(pSiS->SiS_Pr->CFlags & V_INTERLACE)
4471 pSiS->SiS_Pr->CInfoFlag |= InterlaceMode;
4473 pSiS->SiS_Pr->UseCustomMode = TRUE;
4475 xf86DrvMsg(0, X_INFO, "Custom mode %dx%d:\n",
4476 pSiS->SiS_Pr->CHDisplay,pSiS->SiS_Pr->CVDisplay);
4477 xf86DrvMsg(0, X_INFO, "Modeflag %04x, Infoflag %04x\n",
4478 pSiS->SiS_Pr->CModeFlag, pSiS->SiS_Pr->CInfoFlag);
4479 xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n",
4480 pSiS->SiS_Pr->CCRT1CRTC[0],
4481 pSiS->SiS_Pr->CCRT1CRTC[1],
4482 pSiS->SiS_Pr->CCRT1CRTC[2],
4483 pSiS->SiS_Pr->CCRT1CRTC[3],
4484 pSiS->SiS_Pr->CCRT1CRTC[4],
4485 pSiS->SiS_Pr->CCRT1CRTC[5],
4486 pSiS->SiS_Pr->CCRT1CRTC[6],
4487 pSiS->SiS_Pr->CCRT1CRTC[7]);
4488 xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n",
4489 pSiS->SiS_Pr->CCRT1CRTC[8],
4490 pSiS->SiS_Pr->CCRT1CRTC[9],
4491 pSiS->SiS_Pr->CCRT1CRTC[10],
4492 pSiS->SiS_Pr->CCRT1CRTC[11],
4493 pSiS->SiS_Pr->CCRT1CRTC[12],
4494 pSiS->SiS_Pr->CCRT1CRTC[13],
4495 pSiS->SiS_Pr->CCRT1CRTC[14],
4496 pSiS->SiS_Pr->CCRT1CRTC[15]);
4497 xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", pSiS->SiS_Pr->CCRT1CRTC[16]);
4498 xf86DrvMsg(0, X_INFO, "Clock: 0x%02x, 0x%02x, %d\n",
4499 pSiS->SiS_Pr->CSR2B,
4500 pSiS->SiS_Pr->CSR2C,
4501 pSiS->SiS_Pr->CSRClock);
4506 /* Build a list of supported modes */
4508 SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi)
4510 SISPtr pSiS = SISPTR(pScrn);
4511 unsigned short VRE, VBE, VRS, VBS, VDE, VT;
4512 unsigned short HRE, HBE, HRS, HBS, HDE, HT;
4513 unsigned char sr_data, cr_data, cr_data2, cr_data3;
4514 unsigned char sr2b, sr2c;
4515 float num, denum, postscalar, divider;
4516 int A, B, C, D, E, F, temp, i, j, k, l, index, vclkindex;
4517 DisplayModePtr new = NULL, current = NULL, first = NULL;
4518 BOOLEAN done = FALSE;
4520 DisplayModePtr backup = NULL;
4523 pSiS->backupmodelist = NULL;
4524 pSiS->AddedPlasmaModes = FALSE;
4526 /* Initialize our pointers */
4527 if(pSiS->VGAEngine == SIS_300_VGA) {
4529 InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext);
4533 } else if(pSiS->VGAEngine == SIS_315_VGA) {
4535 InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext);
4542 while(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag != 0xFFFF) {
4544 index = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRT1CRTC;
4546 /* 0x5a (320x240) is a pure FTSN mode, not DSTN! */
4548 (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID == 0x5a)) {
4553 (pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) &&
4554 (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240) &&
4555 (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID != 0x5a)) {
4560 if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
4561 memset(new, 0, sizeof(DisplayModeRec));
4562 if(!(new->name = xalloc(10))) {
4566 if(!first) first = new;
4568 current->next = new;
4569 new->prev = current;
4574 sprintf(current->name, "%dx%d", pSiS->SiS_Pr->SiS_RefIndex[i].XRes,
4575 pSiS->SiS_Pr->SiS_RefIndex[i].YRes);
4577 current->status = MODE_OK;
4579 current->type = M_T_DEFAULT;
4581 vclkindex = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRTVCLK;
4582 if(pSiS->VGAEngine == SIS_300_VGA) vclkindex &= 0x3F;
4584 sr2b = pSiS->SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
4585 sr2c = pSiS->SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
4587 divider = (sr2b & 0x80) ? 2.0 : 1.0;
4588 postscalar = (sr2c & 0x80) ?
4589 ( (((sr2c >> 5) & 0x03) == 0x02) ? 6.0 : 8.0) : (((sr2c >> 5) & 0x03) + 1.0);
4590 num = (sr2b & 0x7f) + 1.0;
4591 denum = (sr2c & 0x1f) + 1.0;
4594 xf86DrvMsg(0, X_INFO, "------------\n");
4595 xf86DrvMsg(0, X_INFO, "sr2b: %x sr2c %x div %f ps %f num %f denum %f\n",
4596 sr2b, sr2c, divider, postscalar, num, denum);
4599 current->Clock = (int)(14318 * (divider / postscalar) * (num / denum));
4601 sr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[14];
4602 /* inSISIDXREG(SISSR, 0x0b, sr_data); */
4604 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[0];
4605 /* inSISIDXREG(SISCR, 0x00, cr_data); */
4607 /* Horizontal total */
4608 HT = (cr_data & 0xff) |
4609 ((unsigned short) (sr_data & 0x03) << 8);
4612 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[1];
4613 /* inSISIDXREG(SISCR, 0x01, cr_data); */
4615 /* Horizontal display enable end */
4616 HDE = (cr_data & 0xff) |
4617 ((unsigned short) (sr_data & 0x0C) << 6);
4620 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[4];
4621 /* inSISIDXREG(SISCR, 0x04, cr_data); */
4623 /* Horizontal retrace (=sync) start */
4624 HRS = (cr_data & 0xff) |
4625 ((unsigned short) (sr_data & 0xC0) << 2);
4628 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[2];
4629 /* inSISIDXREG(SISCR, 0x02, cr_data); */
4631 /* Horizontal blank start */
4632 HBS = (cr_data & 0xff) |
4633 ((unsigned short) (sr_data & 0x30) << 4);
4635 sr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[15];
4636 /* inSISIDXREG(SISSR, 0x0c, sr_data); */
4638 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[3];
4639 /* inSISIDXREG(SISCR, 0x03, cr_data); */
4641 cr_data2 = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[5];
4642 /* inSISIDXREG(SISCR, 0x05, cr_data2); */
4644 /* Horizontal blank end */
4645 HBE = (cr_data & 0x1f) |
4646 ((unsigned short) (cr_data2 & 0x80) >> 2) |
4647 ((unsigned short) (sr_data & 0x03) << 6);
4649 /* Horizontal retrace (=sync) end */
4650 HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3);
4652 temp = HBE - ((E - 1) & 255);
4653 B = (temp > 0) ? temp : (temp + 256);
4655 temp = HRE - ((E + F + 3) & 63);
4656 C = (temp > 0) ? temp : (temp + 64);
4660 if((pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) &&
4661 ((pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 200) ||
4662 (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240))) {
4664 /* Terrible hack, but correct CRTC data for
4665 * these modes only produces a black screen...
4666 * (HRE is 0, leading into a too large C and
4667 * a negative D. The CRT controller does not
4668 * seem to like correcting HRE to 50
4670 current->HDisplay = 320;
4671 current->HSyncStart = 328;
4672 current->HSyncEnd = 376;
4673 current->HTotal = 400;
4677 current->HDisplay = (E * 8);
4678 current->HSyncStart = (E * 8) + (F * 8);
4679 current->HSyncEnd = (E * 8) + (F * 8) + (C * 8);
4680 current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8);
4685 xf86DrvMsg(0, X_INFO,
4686 "H: A %d B %d C %d D %d E %d F %d HT %d HDE %d HRS %d HBS %d HBE %d HRE %d\n",
4687 A, B, C, D, E, F, HT, HDE, HRS, HBS, HBE, HRE);
4690 sr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[13];
4691 /* inSISIDXREG(SISSR, 0x0A, sr_data); */
4693 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[6];
4694 /* inSISIDXREG(SISCR, 0x06, cr_data); */
4696 cr_data2 = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[7];
4697 /* inSISIDXREG(SISCR, 0x07, cr_data2); */
4699 /* Vertical total */
4700 VT = (cr_data & 0xFF) |
4701 ((unsigned short) (cr_data2 & 0x01) << 8) |
4702 ((unsigned short)(cr_data2 & 0x20) << 4) |
4703 ((unsigned short) (sr_data & 0x01) << 10);
4706 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[10];
4707 /* inSISIDXREG(SISCR, 0x12, cr_data); */
4709 /* Vertical display enable end */
4710 VDE = (cr_data & 0xff) |
4711 ((unsigned short) (cr_data2 & 0x02) << 7) |
4712 ((unsigned short) (cr_data2 & 0x40) << 3) |
4713 ((unsigned short) (sr_data & 0x02) << 9);
4716 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[8];
4717 /* inSISIDXREG(SISCR, 0x10, cr_data); */
4719 /* Vertical retrace (=sync) start */
4720 VRS = (cr_data & 0xff) |
4721 ((unsigned short) (cr_data2 & 0x04) << 6) |
4722 ((unsigned short) (cr_data2 & 0x80) << 2) |
4723 ((unsigned short) (sr_data & 0x08) << 7);
4726 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[11];
4727 /* inSISIDXREG(SISCR, 0x15, cr_data); */
4729 cr_data3 = (pSiS->SiS_Pr->SiS_CRT1Table[index].CR[16] & 0x01) << 5;
4730 /* inSISIDXREG(SISCR, 0x09, cr_data3); */
4732 /* Vertical blank start */
4733 VBS = (cr_data & 0xff) |
4734 ((unsigned short) (cr_data2 & 0x08) << 5) |
4735 ((unsigned short) (cr_data3 & 0x20) << 4) |
4736 ((unsigned short) (sr_data & 0x04) << 8);
4738 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[12];
4739 /* inSISIDXREG(SISCR, 0x16, cr_data); */
4741 /* Vertical blank end */
4742 VBE = (cr_data & 0xff) |
4743 ((unsigned short) (sr_data & 0x10) << 4);
4744 temp = VBE - ((E - 1) & 511);
4745 B = (temp > 0) ? temp : (temp + 512);
4747 cr_data = pSiS->SiS_Pr->SiS_CRT1Table[index].CR[9];
4748 /* inSISIDXREG(SISCR, 0x11, cr_data); */
4750 /* Vertical retrace (=sync) end */
4751 VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1);
4752 temp = VRE - ((E + F - 1) & 31);
4753 C = (temp > 0) ? temp : (temp + 32);
4757 current->VDisplay = VDE + 1;
4758 current->VSyncStart = VRS + 1;
4759 current->VSyncEnd = ((VRS & ~0x1f) | VRE) + 1;
4760 if(VRE <= (VRS & 0x1f)) current->VSyncEnd += 32;
4761 current->VTotal = E + D + C + F;
4764 current->VDisplay = E;
4765 current->VSyncStart = E + D;
4766 current->VSyncEnd = E + D + C;
4767 current->VTotal = E + D + C + F;
4771 xf86DrvMsg(0, X_INFO,
4772 "V: A %d B %d C %d D %d E %d F %d VT %d VDE %d VRS %d VBS %d VBE %d VRE %d\n",
4773 A, B, C, D, E, F, VT, VDE, VRS, VBS, VBE, VRE);
4776 if(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag & 0x4000)
4777 current->Flags |= V_NHSYNC;
4779 current->Flags |= V_PHSYNC;
4781 if(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag & 0x8000)
4782 current->Flags |= V_NVSYNC;
4784 current->Flags |= V_PVSYNC;
4786 if(pSiS->SiS_Pr->SiS_RefIndex[i].Ext_InfoFlag & 0x0080)
4787 current->Flags |= V_INTERLACE;
4790 while(pSiS->SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID != 0xff) {
4791 if(pSiS->SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID ==
4792 pSiS->SiS_Pr->SiS_RefIndex[i].ModeID) {
4793 if(pSiS->SiS_Pr->SiS_EModeIDTable[j].Ext_ModeFlag & DoubleScanMode) {
4794 current->Flags |= V_DBLSCAN;
4801 if(current->Flags & V_INTERLACE) {
4802 current->VDisplay <<= 1;
4803 current->VSyncStart <<= 1;
4804 current->VSyncEnd <<= 1;
4805 current->VTotal <<= 1;
4806 current->VTotal |= 1;
4808 if(current->Flags & V_DBLSCAN) {
4809 current->Clock >>= 1;
4810 current->VDisplay >>= 1;
4811 current->VSyncStart >>= 1;
4812 current->VSyncEnd >>= 1;
4813 current->VTotal >>= 1;
4817 if((backup = xalloc(sizeof(DisplayModeRec)))) {
4818 if(!pSiS->backupmodelist) pSiS->backupmodelist = backup;
4820 pSiS->backupmodelist->next = backup;
4821 backup->prev = pSiS->backupmodelist;
4823 backup->next = NULL;
4824 backup->HDisplay = current->HDisplay;
4825 backup->HSyncStart = current->HSyncStart;
4826 backup->HSyncEnd = current->HSyncEnd;
4827 backup->HTotal = current->HTotal;
4828 backup->VDisplay = current->VDisplay;
4829 backup->VSyncStart = current->VSyncStart;
4830 backup->VSyncEnd = current->VSyncEnd;
4831 backup->VTotal = current->VTotal;
4832 backup->Flags = current->Flags;
4833 backup->Clock = current->Clock;
4838 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
4839 "Built-in: %s %.2f %d %d %d %d %d %d %d %d\n",
4840 current->name, (float)current->Clock / 1000,
4841 current->HDisplay, current->HSyncStart, current->HSyncEnd, current->HTotal,
4842 current->VDisplay, current->VSyncStart, current->VSyncEnd, current->VTotal);
4844 (void)VBS; (void)HBS; (void)A;
4850 /* Add non-standard LCD modes for panel's detailed timings */
4852 if(!includelcdmodes) return first;
4854 if(pSiS->SiS_Pr->CP_Vendor) {
4855 xf86DrvMsg(0, X_INFO, "Checking database for vendor %x, product %x\n",
4856 pSiS->SiS_Pr->CP_Vendor, pSiS->SiS_Pr->CP_Product);
4860 while((!done) && (SiS_PlasmaTable[i].vendor) && (pSiS->SiS_Pr->CP_Vendor)) {
4862 if(SiS_PlasmaTable[i].vendor == pSiS->SiS_Pr->CP_Vendor) {
4864 for(j=0; j<SiS_PlasmaTable[i].productnum; j++) {
4866 if(SiS_PlasmaTable[i].product[j] == pSiS->SiS_Pr->CP_Product) {
4868 xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
4869 "Identified %s panel, adding specific modes\n",
4870 SiS_PlasmaTable[i].plasmaname);
4872 for(k=0; k<SiS_PlasmaTable[i].modenum; k++) {
4875 if(!(SiS_PlasmaTable[i].plasmamodes[k] & 0x80)) continue;
4877 if(!(SiS_PlasmaTable[i].plasmamodes[k] & 0x40)) continue;
4880 if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
4882 memset(new, 0, sizeof(DisplayModeRec));
4883 if(!(new->name = xalloc(10))) {
4887 if(!first) first = new;
4889 current->next = new;
4890 new->prev = current;
4895 pSiS->AddedPlasmaModes = TRUE;
4897 l = SiS_PlasmaTable[i].plasmamodes[k] & 0x3f;
4899 sprintf(current->name, "%dx%d", SiS_PlasmaMode[l].HDisplay,
4900 SiS_PlasmaMode[l].VDisplay);
4902 current->status = MODE_OK;
4904 current->type = M_T_BUILTIN;
4906 current->Clock = SiS_PlasmaMode[l].clock;
4907 current->SynthClock = current->Clock;
4909 current->HDisplay = SiS_PlasmaMode[l].HDisplay;
4910 current->HSyncStart = current->HDisplay + SiS_PlasmaMode[l].HFrontPorch;
4911 current->HSyncEnd = current->HSyncStart + SiS_PlasmaMode[l].HSyncWidth;
4912 current->HTotal = SiS_PlasmaMode[l].HTotal;
4914 current->VDisplay = SiS_PlasmaMode[l].VDisplay;
4915 current->VSyncStart = current->VDisplay + SiS_PlasmaMode[l].VFrontPorch;
4916 current->VSyncEnd = current->VSyncStart + SiS_PlasmaMode[l].VSyncWidth;
4917 current->VTotal = SiS_PlasmaMode[l].VTotal;
4919 current->CrtcHDisplay = current->HDisplay;
4920 current->CrtcHBlankStart = current->HSyncStart;
4921 current->CrtcHSyncStart = current->HSyncStart;
4922 current->CrtcHSyncEnd = current->HSyncEnd;
4923 current->CrtcHBlankEnd = current->HSyncEnd;
4924 current->CrtcHTotal = current->HTotal;
4926 current->CrtcVDisplay = current->VDisplay;
4927 current->CrtcVBlankStart = current->VSyncStart;
4928 current->CrtcVSyncStart = current->VSyncStart;
4929 current->CrtcVSyncEnd = current->VSyncEnd;
4930 current->CrtcVBlankEnd = current->VSyncEnd;
4931 current->CrtcVTotal = current->VTotal;
4933 if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_HSYNCP)
4934 current->Flags |= V_PHSYNC;
4936 current->Flags |= V_NHSYNC;
4938 if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_VSYNCP)
4939 current->Flags |= V_PVSYNC;
4941 current->Flags |= V_NVSYNC;
4943 if(current->HDisplay > pSiS->LCDwidth)
4944 pSiS->LCDwidth = pSiS->SiS_Pr->CP_MaxX = current->HDisplay;
4945 if(current->VDisplay > pSiS->LCDheight)
4946 pSiS->LCDheight = pSiS->SiS_Pr->CP_MaxY = current->VDisplay;
4959 if(pSiS->SiS_Pr->CP_HaveCustomData) {
4961 for(i=0; i<7; i++) {
4963 if(pSiS->SiS_Pr->CP_DataValid[i]) {
4965 if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
4967 memset(new, 0, sizeof(DisplayModeRec));
4968 if(!(new->name = xalloc(10))) {
4972 if(!first) first = new;
4974 current->next = new;
4975 new->prev = current;
4980 sprintf(current->name, "%dx%d", pSiS->SiS_Pr->CP_HDisplay[i],
4981 pSiS->SiS_Pr->CP_VDisplay[i]);
4983 current->status = MODE_OK;
4985 current->type = M_T_BUILTIN;
4987 current->Clock = pSiS->SiS_Pr->CP_Clock[i];
4988 current->SynthClock = current->Clock;
4990 current->HDisplay = pSiS->SiS_Pr->CP_HDisplay[i];
4991 current->HSyncStart = pSiS->SiS_Pr->CP_HSyncStart[i];
4992 current->HSyncEnd = pSiS->SiS_Pr->CP_HSyncEnd[i];
4993 current->HTotal = pSiS->SiS_Pr->CP_HTotal[i];
4995 current->VDisplay = pSiS->SiS_Pr->CP_VDisplay[i];
4996 current->VSyncStart = pSiS->SiS_Pr->CP_VSyncStart[i];
4997 current->VSyncEnd = pSiS->SiS_Pr->CP_VSyncEnd[i];
4998 current->VTotal = pSiS->SiS_Pr->CP_VTotal[i];
5000 current->CrtcHDisplay = current->HDisplay;
5001 current->CrtcHBlankStart = pSiS->SiS_Pr->CP_HBlankStart[i];
5002 current->CrtcHSyncStart = current->HSyncStart;
5003 current->CrtcHSyncEnd = current->HSyncEnd;
5004 current->CrtcHBlankEnd = pSiS->SiS_Pr->CP_HBlankEnd[i];
5005 current->CrtcHTotal = current->HTotal;
5007 current->CrtcVDisplay = current->VDisplay;
5008 current->CrtcVBlankStart = pSiS->SiS_Pr->CP_VBlankStart[i];
5009 current->CrtcVSyncStart = current->VSyncStart;
5010 current->CrtcVSyncEnd = current->VSyncEnd;
5011 current->CrtcVBlankEnd = pSiS->SiS_Pr->CP_VBlankEnd[i];
5012 current->CrtcVTotal = current->VTotal;
5014 if(pSiS->SiS_Pr->CP_SyncValid[i]) {
5015 if(pSiS->SiS_Pr->CP_HSync_P[i])
5016 current->Flags |= V_PHSYNC;
5018 current->Flags |= V_NHSYNC;
5020 if(pSiS->SiS_Pr->CP_VSync_P[i])
5021 current->Flags |= V_PVSYNC;
5023 current->Flags |= V_NVSYNC;
5025 /* No sync data? Use positive sync... */
5026 current->Flags |= V_PHSYNC;
5027 current->Flags |= V_PVSYNC;
5037 /* Build a list of supported modes */
5039 SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber)
5041 SISPtr pSiS = SISPTR(pScrn);
5044 /* Initialize our pointers */
5045 if(pSiS->VGAEngine == SIS_300_VGA) {
5047 InitTo300Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext);
5051 } else if(pSiS->VGAEngine == SIS_315_VGA) {
5053 InitTo310Pointer(pSiS->SiS_Pr, &pSiS->sishw_ext);
5059 if(modenumber <= 0x13) return modenumber;
5062 while(pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_ModeID != 0xff) {
5063 if(pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_ModeID == modenumber) {
5064 return (int)pSiS->SiS_Pr->SiS_EModeIDTable[i].Ext_VESAID;
5070 #endif /* Xfree86 */
5074 sisfb_mode_rate_to_dclock(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
5075 unsigned char modeno, unsigned char rateindex)
5077 USHORT ModeNo = modeno;
5078 USHORT ModeIdIndex = 0, ClockIndex = 0;
5079 USHORT RefreshRateTableIndex = 0;
5082 if(HwInfo->jChipType < SIS_315H) {
5084 InitTo300Pointer(SiS_Pr, HwInfo);
5090 InitTo310Pointer(SiS_Pr, HwInfo);
5096 if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) {;
5097 printk(KERN_ERR "Could not find mode %x\n", ModeNo);
5101 RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
5102 RefreshRateTableIndex += (rateindex - 1);
5103 ClockIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
5104 if(HwInfo->jChipType < SIS_315H) {
5107 Clock = SiS_Pr->SiS_VCLKData[ClockIndex].CLOCK * 1000;
5113 sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
5114 unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex)
5116 USHORT ModeNo = modeno;
5117 USHORT ModeIdIndex = 0, CRT1Index = 0;
5118 USHORT RefreshRateTableIndex = 0;
5119 unsigned char sr_data, cr_data, cr_data2;
5121 if(HwInfo->jChipType < SIS_315H) {
5123 InitTo300Pointer(SiS_Pr, HwInfo);
5129 InitTo310Pointer(SiS_Pr, HwInfo);
5135 if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return FALSE;
5137 RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
5138 RefreshRateTableIndex += (rateindex - 1);
5139 CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5141 sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14];
5142 cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[0];
5143 *htotal = (((cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8)) + 5) * 8;
5145 sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13];
5146 cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[6];
5147 cr_data2 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7];
5148 *vtotal = ((cr_data & 0xFF) |
5149 ((unsigned short)(cr_data2 & 0x01) << 8) |
5150 ((unsigned short)(cr_data2 & 0x20) << 4) |
5151 ((unsigned short)(sr_data & 0x01) << 10)) + 2;
5153 if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & InterlaceMode)
5160 sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
5161 unsigned char modeno, unsigned char rateindex,
5162 ULONG *left_margin, ULONG *right_margin,
5163 ULONG *upper_margin, ULONG *lower_margin,
5164 ULONG *hsync_len, ULONG *vsync_len,
5165 ULONG *sync, ULONG *vmode)
5167 USHORT ModeNo = modeno;
5168 USHORT ModeIdIndex = 0, index = 0;
5169 USHORT RefreshRateTableIndex = 0;
5170 unsigned short VRE, VBE, VRS, VBS, VDE, VT;
5171 unsigned short HRE, HBE, HRS, HBS, HDE, HT;
5172 unsigned char sr_data, cr_data, cr_data2, cr_data3;
5173 int A, B, C, D, E, F, temp, j;
5175 if(HwInfo->jChipType < SIS_315H) {
5177 InitTo300Pointer(SiS_Pr, HwInfo);
5183 InitTo310Pointer(SiS_Pr, HwInfo);
5189 if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return 0;
5191 RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
5192 RefreshRateTableIndex += (rateindex - 1);
5193 index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5195 sr_data = SiS_Pr->SiS_CRT1Table[index].CR[14];
5197 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[0];
5199 /* Horizontal total */
5200 HT = (cr_data & 0xff) |
5201 ((unsigned short) (sr_data & 0x03) << 8);
5204 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[1];
5206 /* Horizontal display enable end */
5207 HDE = (cr_data & 0xff) |
5208 ((unsigned short) (sr_data & 0x0C) << 6);
5211 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[4];
5213 /* Horizontal retrace (=sync) start */
5214 HRS = (cr_data & 0xff) |
5215 ((unsigned short) (sr_data & 0xC0) << 2);
5218 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[2];
5220 /* Horizontal blank start */
5221 HBS = (cr_data & 0xff) |
5222 ((unsigned short) (sr_data & 0x30) << 4);
5224 sr_data = SiS_Pr->SiS_CRT1Table[index].CR[15];
5226 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[3];
5228 cr_data2 = SiS_Pr->SiS_CRT1Table[index].CR[5];
5230 /* Horizontal blank end */
5231 HBE = (cr_data & 0x1f) |
5232 ((unsigned short) (cr_data2 & 0x80) >> 2) |
5233 ((unsigned short) (sr_data & 0x03) << 6);
5235 /* Horizontal retrace (=sync) end */
5236 HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3);
5238 temp = HBE - ((E - 1) & 255);
5239 B = (temp > 0) ? temp : (temp + 256);
5241 temp = HRE - ((E + F + 3) & 63);
5242 C = (temp > 0) ? temp : (temp + 64);
5246 if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes == 320) &&
5247 ((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 200) ||
5248 (SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 240))) {
5250 /* Terrible hack, but the correct CRTC data for
5251 * these modes only produces a black screen...
5253 *left_margin = (400 - 376);
5254 *right_margin = (328 - 320);
5255 *hsync_len = (376 - 328);
5259 *left_margin = D * 8;
5260 *right_margin = F * 8;
5265 sr_data = SiS_Pr->SiS_CRT1Table[index].CR[13];
5267 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[6];
5269 cr_data2 = SiS_Pr->SiS_CRT1Table[index].CR[7];
5271 /* Vertical total */
5272 VT = (cr_data & 0xFF) |
5273 ((unsigned short) (cr_data2 & 0x01) << 8) |
5274 ((unsigned short)(cr_data2 & 0x20) << 4) |
5275 ((unsigned short) (sr_data & 0x01) << 10);
5278 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[10];
5280 /* Vertical display enable end */
5281 VDE = (cr_data & 0xff) |
5282 ((unsigned short) (cr_data2 & 0x02) << 7) |
5283 ((unsigned short) (cr_data2 & 0x40) << 3) |
5284 ((unsigned short) (sr_data & 0x02) << 9);
5287 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[8];
5289 /* Vertical retrace (=sync) start */
5290 VRS = (cr_data & 0xff) |
5291 ((unsigned short) (cr_data2 & 0x04) << 6) |
5292 ((unsigned short) (cr_data2 & 0x80) << 2) |
5293 ((unsigned short) (sr_data & 0x08) << 7);
5296 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[11];
5298 cr_data3 = (SiS_Pr->SiS_CRT1Table[index].CR[16] & 0x01) << 5;
5300 /* Vertical blank start */
5301 VBS = (cr_data & 0xff) |
5302 ((unsigned short) (cr_data2 & 0x08) << 5) |
5303 ((unsigned short) (cr_data3 & 0x20) << 4) |
5304 ((unsigned short) (sr_data & 0x04) << 8);
5306 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[12];
5308 /* Vertical blank end */
5309 VBE = (cr_data & 0xff) |
5310 ((unsigned short) (sr_data & 0x10) << 4);
5311 temp = VBE - ((E - 1) & 511);
5312 B = (temp > 0) ? temp : (temp + 512);
5314 cr_data = SiS_Pr->SiS_CRT1Table[index].CR[9];
5316 /* Vertical retrace (=sync) end */
5317 VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1);
5318 temp = VRE - ((E + F - 1) & 31);
5319 C = (temp > 0) ? temp : (temp + 32);
5327 if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x8000)
5328 *sync &= ~FB_SYNC_VERT_HIGH_ACT;
5330 *sync |= FB_SYNC_VERT_HIGH_ACT;
5332 if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x4000)
5333 *sync &= ~FB_SYNC_HOR_HIGH_ACT;
5335 *sync |= FB_SYNC_HOR_HIGH_ACT;
5337 *vmode = FB_VMODE_NONINTERLACED;
5338 if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x0080)
5339 *vmode = FB_VMODE_INTERLACED;
5342 while(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID != 0xff) {
5343 if(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeID ==
5344 SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID) {
5345 if(SiS_Pr->SiS_EModeIDTable[j].Ext_ModeFlag & DoubleScanMode) {
5346 *vmode = FB_VMODE_DOUBLE;
5354 if((*vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
5355 #if 0 /* Do this? */
5356 *upper_margin <<= 1;
5357 *lower_margin <<= 1;
5360 } else if((*vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
5361 *upper_margin >>= 1;
5362 *lower_margin >>= 1;