4 * Mode initializing code (CRT2 section)
5 * for SiS 300/305/540/630/730 and
6 * SiS 315/550/650/M650/651/661FX/M661xX/740/741(GX)/M741/330/660/M660/760/M760
7 * (Universal module for Linux kernel framebuffer and XFree86/X.org 4.x)
9 * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
11 * If distributed as part of the Linux kernel, the following license terms
14 * * This program is free software; you can redistribute it and/or modify
15 * * it under the terms of the GNU General Public License as published by
16 * * the Free Software Foundation; either version 2 of the named License,
17 * * or any later version.
19 * * This program is distributed in the hope that it will be useful,
20 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * * GNU General Public License for more details.
24 * * You should have received a copy of the GNU General Public License
25 * * along with this program; if not, write to the Free Software
26 * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
28 * Otherwise, the following license terms apply:
30 * * Redistribution and use in source and binary forms, with or without
31 * * modification, are permitted provided that the following conditions
33 * * 1) Redistributions of source code must retain the above copyright
34 * * notice, this list of conditions and the following disclaimer.
35 * * 2) Redistributions in binary form must reproduce the above copyright
36 * * notice, this list of conditions and the following disclaimer in the
37 * * documentation and/or other materials provided with the distribution.
38 * * 3) The name of the author may not be used to endorse or promote products
39 * * derived from this software without specific prior written permission.
41 * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
42 * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
45 * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
50 * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 * Author: Thomas Winischhofer <thomas@winischhofer.net>
54 * Formerly based on non-functional code-fragements for 300 series by SiS, Inc.
57 * TW says: This code looks awful, I know. But please don't do anything about
58 * this otherwise debugging will be hell.
59 * The code is extremely fragile as regards the different chipsets, different
60 * video bridges and combinations thereof. If anything is changed, extreme
61 * care has to be taken that that change doesn't break it for other chipsets,
62 * bridges or combinations thereof.
63 * All comments in this file are by me, regardless if marked TW or not.
68 #define SET_EMI /* 302LV/ELV: Set EMI values */
71 #define COMPAL_HACK /* Needed for Compal 1400x1050 (EMI) */
72 #define COMPAQ_HACK /* Needed for Inventec/Compaq 1280x1024 (EMI) */
73 #define ASUS_HACK /* Needed for Asus A2H 1024x768 (EMI) */
85 #define SiS_I2CDELAY 1000
86 #define SiS_I2CDELAYSHORT 150
88 static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr);
90 /*********************************************/
91 /* HELPER: Lock/Unlock CRT2 */
92 /*********************************************/
95 SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
97 if(HwInfo->jChipType >= SIS_315H)
98 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01);
100 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01);
104 SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
106 if(HwInfo->jChipType >= SIS_315H)
107 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE);
109 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE);
112 /*********************************************/
113 /* HELPER: Write SR11 */
114 /*********************************************/
117 SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, USHORT DataOR)
119 if(HwInfo->jChipType >= SIS_661) {
123 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,DataAND,DataOR);
126 /*********************************************/
127 /* HELPER: Get Pointer to LCD structure */
128 /*********************************************/
132 GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
134 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
136 USHORT romindex = 0, reg = 0, idx = 0;
138 /* Use the BIOS tables only for LVDS panels; TMDS is unreliable
139 * due to the variaty of panels the BIOS doesn't know about.
140 * Exception: If the BIOS has better knowledge (such as in case
141 * of machines with a 301C and a panel that does not support DDC)
142 * use the BIOS data as well.
145 if((SiS_Pr->SiS_ROMNew) &&
146 ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || (!SiS_Pr->PanelSelfDetected))) {
148 if(HwInfo->jChipType < SIS_661) reg = 0x3c;
151 idx = (SiS_GetReg(SiS_Pr->SiS_P3d4,reg) & 0x1f) * 26;
154 myptr = (UCHAR *)&SiS_LCDStruct661[idx];
156 romindex = SISGETROMW(0x100);
159 myptr = &ROMAddr[romindex];
166 GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
168 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
171 /* Use the BIOS tables only for LVDS panels; TMDS is unreliable
172 * due to the variaty of panels the BIOS doesn't know about.
173 * Exception: If the BIOS has better knowledge (such as in case
174 * of machines with a 301C and a panel that does not support DDC)
175 * use the BIOS data as well.
178 if((SiS_Pr->SiS_ROMNew) &&
179 ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || (!SiS_Pr->PanelSelfDetected))) {
180 romptr = SISGETROMW(0x102);
181 romptr += ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) * SiS_Pr->SiS661LCD2TableSize);
188 /*********************************************/
189 /* Adjust Rate for CRT2 */
190 /*********************************************/
193 SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
194 USHORT RRTI, USHORT *i, PSIS_HW_INFO HwInfo)
196 USHORT checkmask=0,modeid,infoflag;
198 modeid = SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID;
200 if(SiS_Pr->SiS_VBType & VB_SISVB) {
202 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
204 checkmask |= SupportRAMDAC2;
205 if(HwInfo->jChipType >= SIS_315H) {
206 checkmask |= SupportRAMDAC2_135;
207 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
208 checkmask |= SupportRAMDAC2_162;
209 if(SiS_Pr->SiS_VBType & VB_SIS301C) {
210 checkmask |= SupportRAMDAC2_202;
215 } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
217 checkmask |= SupportLCD;
218 if(HwInfo->jChipType >= SIS_315H) {
219 if(SiS_Pr->SiS_VBType & VB_SISVB) {
220 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) {
221 if(modeid == 0x2e) checkmask |= Support64048060Hz;
226 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
228 checkmask |= SupportHiVision;
230 } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) {
232 checkmask |= SupportTV;
233 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
234 checkmask |= SupportTV1024;
235 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
236 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {
237 checkmask |= SupportYPbPr750p;
246 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
247 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
248 checkmask |= SupportCHTV;
252 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
253 checkmask |= SupportLCD;
258 /* Look backwards in table for matching CRT2 mode */
259 for(; SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) {
260 infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag;
261 if(infoflag & checkmask) return TRUE;
265 /* Look through the whole mode-section of the table from the beginning
266 * for a matching CRT2 mode if no mode was found yet.
268 for((*i) = 0; ; (*i)++) {
269 if(SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID != modeid) break;
270 infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag;
271 if(infoflag & checkmask) return TRUE;
276 /*********************************************/
278 /*********************************************/
281 SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
284 SHORT LCDRefreshIndex[] = { 0x00, 0x00, 0x01, 0x01,
285 0x01, 0x01, 0x01, 0x01,
286 0x01, 0x01, 0x01, 0x01,
287 0x01, 0x01, 0x01, 0x01,
288 0x00, 0x00, 0x00, 0x00 };
289 USHORT RRTI,i,backup_i;
290 USHORT modeflag,index,temp,backupindex;
292 /* Do NOT check for UseCustomMode here, will skrew up FIFO */
293 if(ModeNo == 0xfe) return 0;
296 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
298 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
301 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
302 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
303 if(modeflag & HalfDCLK) return 0;
307 if(ModeNo < 0x14) return 0xFFFF;
309 index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F;
312 if(index > 0) index--;
314 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
315 if(SiS_Pr->SiS_VBType & VB_SISVB) {
316 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
317 if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0;
318 else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0;
320 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
321 if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) {
322 temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)];
323 if(index > temp) index = temp;
327 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0;
328 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
329 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0;
334 RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
335 ModeNo = SiS_Pr->SiS_RefIndex[RRTI].ModeID;
337 if(HwInfo->jChipType >= SIS_315H) {
338 if(!(SiS_Pr->SiS_VBInfo & DriverMode)) {
339 if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) ||
340 (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) {
341 if(backupindex <= 1) RRTI++;
348 if(SiS_Pr->SiS_RefIndex[RRTI + i].ModeID != ModeNo) break;
349 temp = SiS_Pr->SiS_RefIndex[RRTI + i].Ext_InfoFlag;
350 temp &= ModeTypeMask;
351 if(temp < SiS_Pr->SiS_ModeType) break;
354 } while(index != 0xFFFF);
356 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
357 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
358 temp = SiS_Pr->SiS_RefIndex[RRTI + i - 1].Ext_InfoFlag;
359 if(temp & InterlaceMode) i++;
365 if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) {
367 if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i, HwInfo))) {
375 /*********************************************/
376 /* STORE CRT2 INFO in CR34 */
377 /*********************************************/
380 SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo)
384 /* Store CRT1 ModeNo in CR34 */
385 SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo);
386 temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8;
387 temp2 = ~(SetInSlaveMode >> 8);
388 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1);
391 /*********************************************/
392 /* HELPER: GET SOME DATA FROM BIOS ROM */
393 /*********************************************/
397 SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
399 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
402 if(SiS_Pr->SiS_UseROM) {
403 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
404 temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f);
405 temp1 = SISGETROMW(0x23b);
406 if(temp1 & temp) return TRUE;
413 SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
415 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
418 if(SiS_Pr->SiS_UseROM) {
419 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
420 temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f);
421 temp1 = SISGETROMW(0x23d);
422 if(temp1 & temp) return TRUE;
429 /*********************************************/
430 /* HELPER: DELAY FUNCTIONS */
431 /*********************************************/
434 SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime)
438 for(i=0; i<delaytime; i++) {
439 j += SiS_GetReg(SiS_Pr->SiS_P3c4,0x05);
443 #if defined(SIS300) || defined(SIS315H)
445 SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay)
449 flag = SiS_GetRegByte(0x61) & 0x10;
452 temp = SiS_GetRegByte(0x61) & 0x10;
453 if(temp == flag) continue;
462 SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay)
465 SiS_GenericDelay(SiS_Pr,0x19df);
470 #if defined(SIS300) || defined(SIS315H)
472 SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay)
475 SiS_GenericDelay(SiS_Pr,0x42);
481 SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime)
483 #if defined(SIS300) || defined(SIS315H)
484 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
485 USHORT PanelID, DelayIndex, Delay=0;
488 if(HwInfo->jChipType < SIS_315H) {
492 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
493 if(SiS_Pr->SiS_VBType & VB_SISVB) {
494 if(SiS_Pr->SiS_VBType & VB_SIS301) PanelID &= 0xf7;
495 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12;
497 DelayIndex = PanelID >> 4;
498 if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) {
501 if(DelayTime >= 2) DelayTime -= 2;
502 if(!(DelayTime & 0x01)) {
503 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0];
505 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1];
507 if(SiS_Pr->SiS_UseROM) {
508 if(ROMAddr[0x220] & 0x40) {
509 if(!(DelayTime & 0x01)) Delay = (USHORT)ROMAddr[0x225];
510 else Delay = (USHORT)ROMAddr[0x226];
514 SiS_ShortDelay(SiS_Pr, Delay);
522 if((HwInfo->jChipType >= SIS_661) ||
523 (HwInfo->jChipType <= SIS_315PRO) ||
524 (HwInfo->jChipType == SIS_330) ||
525 (SiS_Pr->SiS_ROMNew)) {
527 if(!(DelayTime & 0x01)) {
528 SiS_DDC2Delay(SiS_Pr, 0x1000);
530 SiS_DDC2Delay(SiS_Pr, 0x4000);
533 } else if((SiS_Pr->SiS_IF_DEF_LVDS == 1) /* ||
534 (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) ||
535 (SiS_Pr->SiS_CustomT == CUT_CLEVO1400) */ ) { /* 315 series, LVDS; Special */
537 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
538 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
539 if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) {
540 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1b) & 0x10)) PanelID = 0x12;
542 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
543 DelayIndex = PanelID & 0x0f;
545 DelayIndex = PanelID >> 4;
547 if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) {
550 if(DelayTime >= 2) DelayTime -= 2;
551 if(!(DelayTime & 0x01)) {
552 Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0];
554 Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1];
556 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
557 if(ROMAddr[0x13c] & 0x40) {
558 if(!(DelayTime & 0x01)) {
559 Delay = (USHORT)ROMAddr[0x17e];
561 Delay = (USHORT)ROMAddr[0x17f];
566 SiS_ShortDelay(SiS_Pr, Delay);
569 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 315 series, all bridges */
571 DelayIndex = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4;
572 if(!(DelayTime & 0x01)) {
573 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0];
575 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1];
578 SiS_DDC2Delay(SiS_Pr, Delay);
589 SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
590 USHORT DelayTime, USHORT DelayLoop)
593 for(i=0; i<DelayLoop; i++) {
594 SiS_PanelDelay(SiS_Pr, HwInfo, DelayTime);
599 /*********************************************/
600 /* HELPER: WAIT-FOR-RETRACE FUNCTIONS */
601 /*********************************************/
604 SiS_WaitRetrace1(SiS_Private *SiS_Pr)
608 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return;
609 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return;
612 while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog);
614 while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog);
617 #if defined(SIS300) || defined(SIS315H)
619 SiS_WaitRetrace2(SiS_Private *SiS_Pr, USHORT reg)
624 while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog);
626 while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog);
631 SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
633 if(HwInfo->jChipType < SIS_315H) {
635 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
636 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return;
638 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) {
639 SiS_WaitRetrace1(SiS_Pr);
641 SiS_WaitRetrace2(SiS_Pr, 0x25);
646 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) {
647 SiS_WaitRetrace1(SiS_Pr);
649 SiS_WaitRetrace2(SiS_Pr, 0x30);
656 SiS_VBWait(SiS_Private *SiS_Pr)
658 USHORT tempal,temp,i,j;
662 for(j=0; j<100; j++) {
663 tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da);
665 if((tempal & 0x08)) continue;
668 if(!(tempal & 0x08)) continue;
677 SiS_VBLongWait(SiS_Private *SiS_Pr)
679 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
682 SiS_WaitRetrace1(SiS_Pr);
686 /*********************************************/
688 /*********************************************/
692 SiS_Is301B(SiS_Private *SiS_Pr)
694 if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return TRUE;
700 SiS_CRT2IsLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
704 if(HwInfo->jChipType == SIS_730) {
705 flag = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13);
706 if(flag & 0x20) return TRUE;
708 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
709 if(flag & 0x20) return TRUE;
714 SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
719 if(HwInfo->jChipType >= SIS_315H) {
720 if((HwInfo->jChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) {
721 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
722 if(flag & EnableDualEdge) return TRUE;
730 SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
735 if(HwInfo->jChipType >= SIS_315H) {
736 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
737 if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE;
745 SiS_IsVAorLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
747 if(SiS_IsVAMode(SiS_Pr,HwInfo)) return TRUE;
748 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) return TRUE;
754 SiS_IsDualLink(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
757 if(HwInfo->jChipType >= SIS_315H) {
758 if((SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ||
759 (SiS_IsVAMode(SiS_Pr, HwInfo))) {
760 if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return TRUE;
769 SiS_TVEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
771 if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return TRUE;
772 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS301LV302LV)) {
773 if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE;
781 SiS_LCDAEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
783 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return TRUE;
790 SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
792 if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) {
793 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return TRUE;
801 SiS_IsNotM650orLater(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
805 if(HwInfo->jChipType == SIS_650) {
806 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f);
808 /* Check for revision != A0 only */
809 if((flag == 0xe0) || (flag == 0xc0) ||
810 (flag == 0xb0) || (flag == 0x90)) return FALSE;
811 } else if(HwInfo->jChipType >= SIS_661) return FALSE;
818 SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
822 if(HwInfo->jChipType >= SIS_315H) {
823 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
824 if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */
832 SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
836 if(HwInfo->jChipType >= SIS_315H) {
837 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
838 if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 */
846 SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
850 if(HwInfo->jChipType >= SIS_315H) {
851 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
852 if(flag & SetCRT2ToTV) return TRUE;
853 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
854 if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */
855 if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 - TW */
857 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
858 if(flag & SetCRT2ToTV) return TRUE;
866 SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
870 if(HwInfo->jChipType >= SIS_315H) {
871 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
872 if(flag & SetCRT2ToLCD) return TRUE;
873 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
874 if(flag & SetToLCDA) return TRUE;
876 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
877 if(flag & SetCRT2ToLCD) return TRUE;
884 SiS_BridgeIsOn(SiS_Private *SiS_Pr)
888 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
890 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
891 flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00);
892 if((flag == 1) || (flag == 2)) return TRUE;
898 SiS_BridgeIsEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
902 if(SiS_BridgeIsOn(SiS_Pr)) {
903 flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00);
904 if(HwInfo->jChipType < SIS_315H) {
906 if((flag == 0x80) || (flag == 0x20)) return TRUE;
909 if((flag == 0x40) || (flag == 0x10)) return TRUE;
916 SiS_BridgeInSlavemode(SiS_Private *SiS_Pr)
920 flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31);
921 if(flag1 & (SetInSlaveMode >> 8)) return TRUE;
925 /*********************************************/
926 /* GET VIDEO BRIDGE CONFIG INFO */
927 /*********************************************/
929 /* Setup general purpose IO for Chrontel communication */
931 SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo)
933 unsigned long acpibase;
936 if(!(SiS_Pr->SiS_ChSW)) return;
939 SiS_SetRegLong(0xcf8,0x80000874); /* get ACPI base */
940 acpibase = SiS_GetRegLong(0xcfc);
942 acpibase = pciReadLong(0x00000800, 0x74);
945 temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */
947 SiS_SetRegShort((USHORT)(acpibase + 0x3c), temp);
948 temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c));
949 temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */
951 if(!(myvbinfo & SetCRT2ToTV)) temp |= 0x0100;
952 SiS_SetRegShort((USHORT)(acpibase + 0x3a), temp);
953 temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a));
957 SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
958 PSIS_HW_INFO HwInfo, int checkcrt2mode)
960 USHORT tempax,tempbx,temp;
961 USHORT modeflag, resinfo=0;
964 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
965 } else if(SiS_Pr->UseCustomMode) {
966 modeflag = SiS_Pr->CModeFlag;
968 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
969 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
972 SiS_Pr->SiS_SetFlag = 0;
974 SiS_Pr->SiS_ModeType = modeflag & ModeTypeMask;
977 if(SiS_BridgeIsOn(SiS_Pr)) {
978 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
980 if(HwInfo->jChipType < SIS_661) {
981 /* NO - YPbPr not set yet ! */
982 if(SiS_Pr->SiS_YPbPr & <all ypbpr except 525i>) {
983 temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */
984 temp |= SetCRT2ToHiVision; /* 0x80 */
986 if(SiS_Pr->SiS_YPbPr & <ypbpr525i>) {
987 temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */
988 temp |= SetCRT2ToSVIDEO; /* 0x08 */
993 tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8;
994 tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV);
998 if(HwInfo->jChipType >= SIS_315H) {
999 if(SiS_Pr->SiS_VBType & VB_SISLCDA) {
1000 if(ModeNo == 0x03) {
1001 /* Mode 0x03 is never in driver mode */
1002 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf);
1004 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) {
1005 /* Reset LCDA setting if not driver mode */
1006 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc);
1009 if(SiS_Pr->SiS_UseLCDA) {
1010 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) {
1011 if((ModeNo <= 0x13) || (!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) {
1012 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA));
1017 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1018 if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) {
1019 tempbx |= SetCRT2ToLCDA;
1023 if(SiS_Pr->SiS_VBType & (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV)) {
1024 tempbx &= ~(SetCRT2ToRAMDAC);
1027 if(HwInfo->jChipType >= SIS_661) {
1028 tempbx &= ~(SetCRT2ToYPbPr525750 | SetCRT2ToHiVision);
1029 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1030 if(SiS_Pr->SiS_VBType & VB_SISYPBPR) {
1032 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0;
1033 if(temp == 0x60) tempbx |= SetCRT2ToHiVision;
1034 else tempbx |= SetCRT2ToYPbPr525750;
1036 } else if(SiS_Pr->SiS_VBType & VB_SISHIVISION) {
1038 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0;
1039 if(temp == 0x60) tempbx |= SetCRT2ToHiVision;
1044 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
1045 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1046 if(temp & SetToLCDA) {
1047 tempbx |= SetCRT2ToLCDA;
1049 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1050 if(temp & EnableCHYPbPr) {
1051 tempbx |= SetCRT2ToCHYPbPr;
1057 #endif /* SIS315H */
1059 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1060 temp = SetCRT2ToSVIDEO |
1067 SetCRT2ToYPbPr525750;
1069 if(HwInfo->jChipType >= SIS_315H) {
1070 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1071 temp = SetCRT2ToAVIDEO |
1078 temp = SetCRT2ToLCDA |
1082 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1083 temp = SetCRT2ToTV | SetCRT2ToLCD;
1085 temp = SetCRT2ToLCD;
1090 if(!(tempbx & temp)) {
1091 tempax = DisableCRT2Display;
1095 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1096 USHORT clearmask = ( DriverMode |
1097 DisableCRT2Display |
1104 if(tempbx & SetCRT2ToLCDA) tempbx &= (clearmask | SetCRT2ToLCDA);
1105 if(tempbx & SetCRT2ToRAMDAC) tempbx &= (clearmask | SetCRT2ToRAMDAC);
1106 if(tempbx & SetCRT2ToLCD) tempbx &= (clearmask | SetCRT2ToLCD);
1107 if(tempbx & SetCRT2ToSCART) tempbx &= (clearmask | SetCRT2ToSCART);
1108 if(tempbx & SetCRT2ToHiVision) tempbx &= (clearmask | SetCRT2ToHiVision);
1109 if(tempbx & SetCRT2ToYPbPr525750) tempbx &= (clearmask | SetCRT2ToYPbPr525750);
1111 if(HwInfo->jChipType >= SIS_315H) {
1112 if(tempbx & SetCRT2ToLCDA) {
1113 tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode);
1116 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1117 if(tempbx & SetCRT2ToTV) {
1118 tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode);
1121 if(tempbx & SetCRT2ToLCD) {
1122 tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode);
1124 if(HwInfo->jChipType >= SIS_315H) {
1125 if(tempbx & SetCRT2ToLCDA) {
1126 tempbx |= SetCRT2ToLCD;
1131 if(tempax & DisableCRT2Display) {
1132 if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
1133 tempbx = SetSimuScanMode | DisableCRT2Display;
1137 if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode;
1139 /* LVDS/CHRONTEL (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */
1140 if(SiS_Pr->SiS_ModeType <= ModeVGA) {
1141 if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) ||
1142 ((SiS_Pr->SiS_VBType & VB_NoLCD) && (tempbx & SetCRT2ToLCD)) ) {
1143 modeflag &= (~CRT2Mode);
1147 if(!(tempbx & SetSimuScanMode)) {
1148 if(tempbx & SwitchCRT2) {
1149 if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) {
1150 if( (HwInfo->jChipType >= SIS_315H) &&
1151 (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) {
1152 if(resinfo != SIS_RI_1600x1200) {
1153 tempbx |= SetSimuScanMode;
1156 tempbx |= SetSimuScanMode;
1160 if(SiS_BridgeIsEnabled(SiS_Pr,HwInfo)) {
1161 if(!(tempbx & DriverMode)) {
1162 if(SiS_BridgeInSlavemode(SiS_Pr)) {
1163 tempbx |= SetSimuScanMode;
1170 if(!(tempbx & DisableCRT2Display)) {
1171 if(tempbx & DriverMode) {
1172 if(tempbx & SetSimuScanMode) {
1173 if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) {
1174 if( (HwInfo->jChipType >= SIS_315H) &&
1175 (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) {
1176 if(resinfo != SIS_RI_1600x1200) {
1177 tempbx |= SetInSlaveMode;
1180 tempbx |= SetInSlaveMode;
1185 tempbx |= SetInSlaveMode;
1191 SiS_Pr->SiS_VBInfo = tempbx;
1193 if(HwInfo->jChipType == SIS_630) {
1194 SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo);
1199 printk(KERN_DEBUG "sisfb: (VBInfo= 0x%04x, SetFlag=0x%04x)\n",
1200 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag);
1203 xf86DrvMsgVerb(0, X_PROBED, 3, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n",
1204 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag);
1209 /*********************************************/
1210 /* DETERMINE YPbPr MODE */
1211 /*********************************************/
1214 SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1219 /* Note: This variable is only used on 30xLV systems.
1220 * CR38 has a different meaning on LVDS/CH7019 systems.
1221 * On 661 and later, these bits moved to CR35.
1223 * On 301, 301B, only HiVision 1080i is supported.
1224 * On 30xLV, 301C, only YPbPr 1080i is supported.
1227 SiS_Pr->SiS_YPbPr = 0;
1228 if(HwInfo->jChipType >= SIS_661) return;
1230 if(SiS_Pr->SiS_VBType) {
1231 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
1232 SiS_Pr->SiS_YPbPr = YPbPrHiVision;
1236 if(HwInfo->jChipType >= SIS_315H) {
1237 if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_SIS301C)) {
1238 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1240 switch((temp >> 4)) {
1241 case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break;
1242 case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break;
1243 case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break;
1244 case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break;
1252 /*********************************************/
1253 /* DETERMINE TVMode flag */
1254 /*********************************************/
1257 SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo)
1259 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
1260 USHORT temp, temp1, resinfo = 0, romindex = 0;
1261 UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect;
1263 SiS_Pr->SiS_TVMode = 0;
1265 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return;
1266 if(SiS_Pr->UseCustomMode) return;
1269 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1272 if(HwInfo->jChipType < SIS_661) {
1274 if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL;
1276 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1278 if((HwInfo->jChipType == SIS_630) ||
1279 (HwInfo->jChipType == SIS_730)) {
1282 } else if(HwInfo->jChipType >= SIS_315H) {
1285 if(HwInfo->jChipType >= SIS_330) romindex = 0x11b;
1288 if(romindex && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) {
1289 OutputSelect = ROMAddr[romindex];
1290 if(!(OutputSelect & EnablePALMN)) {
1291 SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F);
1294 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp);
1295 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
1296 if(temp1 & EnablePALM) { /* 0x40 */
1297 SiS_Pr->SiS_TVMode |= TVSetPALM;
1298 SiS_Pr->SiS_TVMode &= ~TVSetPAL;
1299 } else if(temp1 & EnablePALN) { /* 0x80 */
1300 SiS_Pr->SiS_TVMode |= TVSetPALN;
1303 if(temp1 & EnableNTSCJ) { /* 0x40 */
1304 SiS_Pr->SiS_TVMode |= TVSetNTSCJ;
1308 /* Translate HiVision/YPbPr to our new flags */
1309 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
1310 if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p;
1311 else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p;
1312 else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision;
1313 else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i;
1314 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) {
1315 SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision;
1316 SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750;
1317 } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) {
1318 SiS_Pr->SiS_TVMode |= TVSetPAL;
1321 } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1322 if(SiS_Pr->SiS_CHOverScan) {
1323 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
1324 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
1325 if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) {
1326 SiS_Pr->SiS_TVMode |= TVSetCHOverScan;
1328 } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
1329 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79);
1330 if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) {
1331 SiS_Pr->SiS_TVMode |= TVSetCHOverScan;
1334 if(SiS_Pr->SiS_CHSOverScan) {
1335 SiS_Pr->SiS_TVMode |= TVSetCHOverScan;
1338 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
1339 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1340 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
1341 if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM;
1342 else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN;
1344 if(temp & EnableNTSCJ) {
1345 SiS_Pr->SiS_TVMode |= TVSetNTSCJ;
1351 } else { /* 661 and later */
1353 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
1355 SiS_Pr->SiS_TVMode |= TVSetPAL;
1357 SiS_Pr->SiS_TVMode |= TVSetPALN;
1358 } else if(temp1 & 0x04) {
1359 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1360 SiS_Pr->SiS_TVMode &= ~TVSetPAL;
1362 SiS_Pr->SiS_TVMode |= TVSetPALM;
1366 SiS_Pr->SiS_TVMode |= TVSetNTSCJ;
1369 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
1370 if(SiS_Pr->SiS_CHOverScan) {
1371 if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) {
1372 SiS_Pr->SiS_TVMode |= TVSetCHOverScan;
1376 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1377 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
1379 if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i;
1380 else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p;
1381 else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p;
1382 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
1383 SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL);
1385 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) {
1386 if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) {
1387 SiS_Pr->SiS_TVMode |= TVAspect169;
1389 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39);
1391 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) {
1392 SiS_Pr->SiS_TVMode |= TVAspect169;
1394 SiS_Pr->SiS_TVMode |= TVAspect43LB;
1397 SiS_Pr->SiS_TVMode |= TVAspect43;
1404 if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL;
1406 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1408 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
1409 SiS_Pr->SiS_TVMode |= TVSetPAL;
1410 SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ);
1411 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
1412 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) {
1413 SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN);
1417 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
1418 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
1419 SiS_Pr->SiS_TVMode |= TVSetTVSimuMode;
1423 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
1424 /* BIOS sets TVNTSC1024 without checking 525p here. Wrong? */
1425 if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr525p | TVSetYPbPr750p))) {
1426 if(resinfo == SIS_RI_1024x768) {
1427 SiS_Pr->SiS_TVMode |= TVSetNTSC1024;
1432 SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO;
1433 if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) &&
1434 (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
1435 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO;
1436 } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) {
1437 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO;
1438 } else if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
1439 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
1440 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO;
1446 SiS_Pr->SiS_VBInfo &= ~SetPALTV;
1449 xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo);
1453 /*********************************************/
1455 /*********************************************/
1458 SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr)
1460 USHORT temp = SiS_Pr->SiS_LCDResInfo;
1461 /* Translate my LCDResInfo to BIOS value */
1462 if(temp == Panel_1280x768_2) temp = Panel_1280x768;
1463 if(temp == Panel_1280x800_2) temp = Panel_1280x800;
1468 SiS_GetLCDInfoBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1475 xf86DrvMsg(0, X_INFO, "Paneldata driver: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n",
1476 SiS_Pr->PanelHT, SiS_Pr->PanelVT,
1477 SiS_Pr->PanelHRS, SiS_Pr->PanelHRE,
1478 SiS_Pr->PanelVRS, SiS_Pr->PanelVRE,
1479 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK,
1480 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A,
1481 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B);
1484 if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) {
1485 if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) {
1486 SiS_Pr->SiS_NeedRomModeData = TRUE;
1487 SiS_Pr->PanelHT = temp;
1489 if((temp = SISGETROMW(8)) != SiS_Pr->PanelVT) {
1490 SiS_Pr->SiS_NeedRomModeData = TRUE;
1491 SiS_Pr->PanelVT = temp;
1493 SiS_Pr->PanelHRS = SISGETROMW(10);
1494 SiS_Pr->PanelHRE = SISGETROMW(12);
1495 SiS_Pr->PanelVRS = SISGETROMW(14);
1496 SiS_Pr->PanelVRE = SISGETROMW(16);
1497 SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315;
1498 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].CLOCK =
1499 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (USHORT)((UCHAR)ROMAddr[18]);
1500 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2B =
1501 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_A = ROMAddr[19];
1502 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C =
1503 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20];
1506 xf86DrvMsg(0, X_INFO, "Paneldata BIOS: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n",
1507 SiS_Pr->PanelHT, SiS_Pr->PanelVT,
1508 SiS_Pr->PanelHRS, SiS_Pr->PanelHRE,
1509 SiS_Pr->PanelVRS, SiS_Pr->PanelVRE,
1510 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK,
1511 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A,
1512 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B);
1520 SiS_CheckScaling(SiS_Private *SiS_Pr, USHORT resinfo, const UCHAR *nonscalingmodes)
1523 while(nonscalingmodes[i] != 0xff) {
1524 if(nonscalingmodes[i++] == resinfo) {
1525 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ||
1526 (SiS_Pr->UsePanelScaler == -1)) {
1527 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1535 SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1536 PSIS_HW_INFO HwInfo)
1539 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
1540 const unsigned char SiS300SeriesLCDRes[] =
1541 { 0, 1, 2, 3, 7, 4, 5, 8,
1542 0, 0, 10, 0, 0, 0, 0, 15 };
1545 UCHAR *myptr = NULL;
1547 USHORT temp,modeflag,resinfo=0,modexres=0,modeyres=0;
1548 BOOLEAN panelcanscale = FALSE;
1550 SiS_Pr->SiS_LCDResInfo = 0;
1551 SiS_Pr->SiS_LCDTypeInfo = 0;
1552 SiS_Pr->SiS_LCDInfo = 0;
1553 SiS_Pr->PanelHRS = 999; /* HSync start */
1554 SiS_Pr->PanelHRE = 999; /* HSync end */
1555 SiS_Pr->PanelVRS = 999; /* VSync start */
1556 SiS_Pr->PanelVRE = 999; /* VSync end */
1557 SiS_Pr->SiS_NeedRomModeData = FALSE;
1559 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return;
1561 if(ModeNo <= 0x13) {
1562 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
1563 } else if(SiS_Pr->UseCustomMode) {
1564 modeflag = SiS_Pr->CModeFlag;
1566 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1567 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1568 modexres = SiS_Pr->SiS_ModeResInfo[resinfo].HTotal;
1569 modeyres = SiS_Pr->SiS_ModeResInfo[resinfo].VTotal;
1572 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
1574 /* For broken BIOSes: Assume 1024x768 */
1575 if(temp == 0) temp = 0x02;
1577 if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) {
1578 SiS_Pr->SiS_LCDTypeInfo = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x7c) >> 2;
1579 } else if((HwInfo->jChipType < SIS_315H) || (HwInfo->jChipType >= SIS_661)) {
1580 SiS_Pr->SiS_LCDTypeInfo = temp >> 4;
1582 SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1;
1586 if(HwInfo->jChipType < SIS_315H) {
1587 /* Very old BIOSes only know 7 sizes (NetVista 2179, 1.01g) */
1588 if(SiS_Pr->SiS_VBType & VB_SIS301) {
1589 if(temp < 0x0f) temp &= 0x07;
1591 /* Translate 300 series LCDRes to 315 series for unified usage */
1592 temp = SiS300SeriesLCDRes[temp];
1596 /* Translate to our internal types */
1597 if(HwInfo->jChipType == SIS_550) {
1598 if(temp == Panel310_640x480_2) temp = Panel_640x480_2;
1599 if(temp == Panel310_640x480_3) temp = Panel_640x480_3;
1602 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* SiS LVDS */
1603 if(temp == Panel310_1280x768) {
1604 temp = Panel_1280x768_2;
1606 if(SiS_Pr->SiS_ROMNew) {
1607 if(temp == Panel661_1280x800) {
1608 temp = Panel_1280x800_2;
1613 SiS_Pr->SiS_LCDResInfo = temp;
1615 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
1616 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
1617 SiS_Pr->SiS_LCDResInfo = Panel_Barco1366;
1618 } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
1619 SiS_Pr->SiS_LCDResInfo = Panel_848x480;
1623 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1624 if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301)
1625 SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMin301;
1627 if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMinLVDS)
1628 SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMinLVDS;
1631 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37);
1632 SiS_Pr->SiS_LCDInfo = temp & ~0x000e;
1633 /* Need temp below! */
1635 /* These can't scale no matter what */
1636 switch(SiS_Pr->SiS_LCDResInfo) {
1637 case Panel_1280x960:
1638 SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD;
1641 panelcanscale = (SiS_Pr->SiS_LCDInfo & DontExpandLCD) ? TRUE : FALSE;
1643 if(!SiS_Pr->UsePanelScaler) SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD;
1644 else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1646 /* Dual link, Pass 1:1 BIOS default, etc. */
1648 if(HwInfo->jChipType >= SIS_661) {
1649 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
1650 if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11;
1652 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
1653 if(SiS_Pr->SiS_ROMNew) {
1654 if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1655 } else if((myptr = GetLCDStructPtr661(SiS_Pr, HwInfo))) {
1656 if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1659 } else if(HwInfo->jChipType >= SIS_315H) {
1660 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
1661 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11;
1663 if((SiS_Pr->SiS_ROMNew) && (!(SiS_Pr->PanelSelfDetected))) {
1664 SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit);
1665 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
1666 if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit;
1667 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
1668 if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1670 } else if(!(SiS_Pr->SiS_ROMNew)) {
1671 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
1672 if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) &&
1673 (SiS_Pr->SiS_LCDResInfo == Panel_1024x768)) {
1674 SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1676 if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) ||
1677 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) ||
1678 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) ||
1679 (SiS_Pr->SiS_LCDResInfo == Panel_1680x1050)) {
1680 SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1688 if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) {
1689 /* Always center screen on LVDS (if scaling is disabled) */
1690 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
1691 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
1692 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
1693 /* Always center screen on SiS LVDS (if scaling is disabled) */
1694 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
1696 /* By default, pass 1:1 on SiS TMDS (if scaling is supported) */
1697 if(panelcanscale) SiS_Pr->SiS_LCDInfo |= LCDPass11;
1698 if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
1702 SiS_Pr->PanelVCLKIdx300 = VCLK65_300;
1703 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315;
1705 switch(SiS_Pr->SiS_LCDResInfo) {
1706 case Panel_320x480: SiS_Pr->PanelXRes = 320; SiS_Pr->PanelYRes = 480;
1707 SiS_Pr->PanelHT = 400; SiS_Pr->PanelVT = 525;
1708 SiS_Pr->PanelVCLKIdx300 = VCLK28;
1709 SiS_Pr->PanelVCLKIdx315 = VCLK28;
1711 case Panel_640x480_2:
1712 case Panel_640x480_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480;
1713 SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3;
1714 SiS_Pr->PanelVCLKIdx300 = VCLK28;
1715 SiS_Pr->PanelVCLKIdx315 = VCLK28;
1717 case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480;
1718 SiS_Pr->PanelVRE = 3;
1719 SiS_Pr->PanelVCLKIdx300 = VCLK28;
1720 SiS_Pr->PanelVCLKIdx315 = VCLK28;
1722 case Panel_800x600: SiS_Pr->PanelXRes = 800; SiS_Pr->PanelYRes = 600;
1723 SiS_Pr->PanelHT = 1056; SiS_Pr->PanelVT = 628;
1724 SiS_Pr->PanelHRS = 40; SiS_Pr->PanelHRE = 128;
1725 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 4;
1726 SiS_Pr->PanelVCLKIdx300 = VCLK40;
1727 SiS_Pr->PanelVCLKIdx315 = VCLK40;
1729 case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600;
1730 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800;
1731 SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136;
1732 SiS_Pr->PanelVRS = 2 /* 88 */ ; SiS_Pr->PanelVRE = 6;
1733 SiS_Pr->PanelVCLKIdx300 = VCLK65_300;
1734 SiS_Pr->PanelVCLKIdx315 = VCLK65_315;
1736 case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768;
1737 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806;
1738 SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136;
1739 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1740 if(HwInfo->jChipType < SIS_315H) {
1741 SiS_Pr->PanelHRS = 23;
1742 SiS_Pr->PanelVRE = 5;
1744 SiS_Pr->PanelVCLKIdx300 = VCLK65_300;
1745 SiS_Pr->PanelVCLKIdx315 = VCLK65_315;
1746 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1748 case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768;
1749 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806;
1750 SiS_Pr->PanelHRS = 24;
1751 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1752 if(HwInfo->jChipType < SIS_315H) {
1753 SiS_Pr->PanelHRS = 23;
1754 SiS_Pr->PanelVRE = 5;
1756 SiS_Pr->PanelVCLKIdx300 = VCLK65_300;
1757 SiS_Pr->PanelVCLKIdx315 = VCLK65_315;
1759 case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864;
1761 case Panel_1280x720: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 720;
1762 SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750;
1763 SiS_Pr->PanelHRS = 110; SiS_Pr->PanelHRE = 40;
1764 SiS_Pr->PanelVRS = 5; SiS_Pr->PanelVRE = 5;
1765 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x720;
1766 /* Data above for TMDS (projector); get from BIOS for LVDS */
1767 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1769 case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768;
1770 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
1771 SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 806;
1772 SiS_Pr->PanelVCLKIdx300 = VCLK81_300; /* ? */
1773 SiS_Pr->PanelVCLKIdx315 = VCLK81_315; /* ? */
1775 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802;
1776 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRS = 112;
1777 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1778 SiS_Pr->PanelVCLKIdx300 = VCLK81_300;
1779 SiS_Pr->PanelVCLKIdx315 = VCLK81_315;
1782 case Panel_1280x768_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768;
1783 SiS_Pr->PanelHT = 1660; SiS_Pr->PanelVT = 806;
1784 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112;
1785 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1786 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x768_2;
1787 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1789 case Panel_1280x800: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800;
1790 SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 816;
1791 SiS_Pr->PanelHRS = 21; SiS_Pr->PanelHRE = 24;
1792 SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3;
1793 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315;
1794 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1796 case Panel_1280x800_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800;
1797 SiS_Pr->PanelHT = 1552; SiS_Pr->PanelVT = 812;
1798 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112;
1799 SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3;
1800 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315_2;
1801 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1803 case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960;
1804 SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000;
1805 SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300;
1806 SiS_Pr->PanelVCLKIdx315 = VCLK108_3_315;
1807 if(resinfo == SIS_RI_1280x1024) {
1808 SiS_Pr->PanelVCLKIdx300 = VCLK100_300;
1809 SiS_Pr->PanelVCLKIdx315 = VCLK100_315;
1812 case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024;
1813 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066;
1814 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112;
1815 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3;
1816 SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300;
1817 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315;
1818 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1820 case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050;
1821 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066;
1822 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; /* HRE OK for LVDS, not for LCDA */
1823 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3;
1824 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315;
1825 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1827 case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200;
1828 SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250;
1829 SiS_Pr->PanelHRS = 64; SiS_Pr->PanelHRE = 192;
1830 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3;
1831 SiS_Pr->PanelVCLKIdx315 = VCLK162_315;
1832 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1834 case Panel_1680x1050: SiS_Pr->PanelXRes = 1680; SiS_Pr->PanelYRes = 1050;
1835 SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066;
1836 SiS_Pr->PanelHRS = 26; SiS_Pr->PanelHRE = 76;
1837 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1838 SiS_Pr->PanelVCLKIdx315 = VCLK121_315;
1839 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo);
1841 case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024;
1842 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066;
1844 case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480;
1845 SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525;
1847 case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX;
1848 SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY;
1849 SiS_Pr->PanelHT = SiS_Pr->CHTotal;
1850 SiS_Pr->PanelVT = SiS_Pr->CVTotal;
1851 if(SiS_Pr->CP_PreferredIndex != -1) {
1852 SiS_Pr->PanelXRes = SiS_Pr->CP_HDisplay[SiS_Pr->CP_PreferredIndex];
1853 SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex];
1854 SiS_Pr->PanelHT = SiS_Pr->CP_HTotal[SiS_Pr->CP_PreferredIndex];
1855 SiS_Pr->PanelVT = SiS_Pr->CP_VTotal[SiS_Pr->CP_PreferredIndex];
1856 SiS_Pr->PanelHRS = SiS_Pr->CP_HSyncStart[SiS_Pr->CP_PreferredIndex];
1857 SiS_Pr->PanelHRE = SiS_Pr->CP_HSyncEnd[SiS_Pr->CP_PreferredIndex];
1858 SiS_Pr->PanelVRS = SiS_Pr->CP_VSyncStart[SiS_Pr->CP_PreferredIndex];
1859 SiS_Pr->PanelVRE = SiS_Pr->CP_VSyncEnd[SiS_Pr->CP_PreferredIndex];
1860 SiS_Pr->PanelHRS -= SiS_Pr->PanelXRes;
1861 SiS_Pr->PanelHRE -= SiS_Pr->PanelHRS;
1862 SiS_Pr->PanelVRS -= SiS_Pr->PanelYRes;
1863 SiS_Pr->PanelVRE -= SiS_Pr->PanelVRS;
1864 if(SiS_Pr->CP_PrefClock) {
1866 SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315;
1867 SiS_Pr->PanelVCLKIdx300 = VCLK_CUSTOM_300;
1868 if(HwInfo->jChipType < SIS_315H) idx = VCLK_CUSTOM_300;
1869 else idx = VCLK_CUSTOM_315;
1870 SiS_Pr->SiS_VCLKData[idx].CLOCK =
1871 SiS_Pr->SiS_VBVCLKData[idx].CLOCK = SiS_Pr->CP_PrefClock;
1872 SiS_Pr->SiS_VCLKData[idx].SR2B =
1873 SiS_Pr->SiS_VBVCLKData[idx].Part4_A = SiS_Pr->CP_PrefSR2B;
1874 SiS_Pr->SiS_VCLKData[idx].SR2C =
1875 SiS_Pr->SiS_VBVCLKData[idx].Part4_B = SiS_Pr->CP_PrefSR2C;
1879 default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768;
1880 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806;
1885 if( (SiS_Pr->SiS_IF_DEF_FSTN) ||
1886 (SiS_Pr->SiS_IF_DEF_DSTN) ||
1887 (SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
1888 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) ||
1889 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) {
1890 SiS_Pr->PanelHRS = 999;
1891 SiS_Pr->PanelHRE = 999;
1894 if( (SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
1895 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) ||
1896 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) {
1897 SiS_Pr->PanelVRS = 999;
1898 SiS_Pr->PanelVRE = 999;
1901 /* DontExpand overrule */
1902 if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
1904 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (modeflag & NoSupportLCDScale)) {
1905 /* No scaling for this mode on any panel (LCD=CRT2)*/
1906 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1909 switch(SiS_Pr->SiS_LCDResInfo) {
1912 case Panel_1152x864:
1913 case Panel_1280x768: /* TMDS only */
1914 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1917 case Panel_800x600: {
1918 static const UCHAR nonscalingmodes[] = {
1919 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, 0xff
1921 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1924 case Panel_1024x768: {
1925 static const UCHAR nonscalingmodes[] = {
1926 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1927 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1930 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1933 case Panel_1280x720: {
1934 static const UCHAR nonscalingmodes[] = {
1935 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1936 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1939 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1940 if(SiS_Pr->PanelHT == 1650) {
1941 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1945 case Panel_1280x768_2: { /* LVDS only */
1946 static const UCHAR nonscalingmodes[] = {
1947 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1948 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1949 SIS_RI_1152x768,0xff
1951 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1953 case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) {
1954 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1960 case Panel_1280x800: { /* SiS TMDS special (Averatec 6200 series) */
1961 static const UCHAR nonscalingmodes[] = {
1962 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1963 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1964 SIS_RI_1152x768,SIS_RI_1280x720,SIS_RI_1280x768,0xff
1966 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1969 case Panel_1280x800_2: { /* SiS LVDS */
1970 static const UCHAR nonscalingmodes[] = {
1971 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1972 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1973 SIS_RI_1152x768,0xff
1975 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1977 case SIS_RI_1280x720:
1978 case SIS_RI_1280x768: if(SiS_Pr->UsePanelScaler == -1) {
1979 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1985 case Panel_1280x960: {
1986 static const UCHAR nonscalingmodes[] = {
1987 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1988 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1989 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800,
1992 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1995 case Panel_1280x1024: {
1996 static const UCHAR nonscalingmodes[] = {
1997 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1998 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1999 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800,
2000 SIS_RI_1280x960,0xff
2002 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2005 case Panel_1400x1050: {
2006 static const UCHAR nonscalingmodes[] = {
2007 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
2008 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
2009 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x768,SIS_RI_1280x800,SIS_RI_1280x960,
2012 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2014 case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) {
2015 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
2018 case SIS_RI_1280x1024: SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
2023 case Panel_1600x1200: {
2024 static const UCHAR nonscalingmodes[] = {
2025 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
2026 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
2027 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800,
2028 SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,0xff
2030 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2033 case Panel_1680x1050: {
2034 static const UCHAR nonscalingmodes[] = {
2035 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
2036 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
2037 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,
2040 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2046 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2047 if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
2048 SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */
2053 if(HwInfo->jChipType < SIS_315H) {
2054 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2055 if(SiS_Pr->SiS_UseROM) {
2056 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
2057 if(!(ROMAddr[0x235] & 0x02)) {
2058 SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD);
2062 } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
2063 if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) {
2064 SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD);
2072 if(modexres == SiS_Pr->PanelXRes && modeyres == SiS_Pr->PanelYRes) {
2073 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
2076 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
2077 SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11);
2080 switch(SiS_Pr->SiS_LCDResInfo) {
2082 SiS_Pr->SiS_LCDInfo |= LCDPass11;
2084 case Panel_1280x800:
2085 /* Don't pass 1:1 by default (TMDS special) */
2086 if(SiS_Pr->CenterScreen == -1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
2088 case Panel_1280x960:
2089 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
2092 if((!SiS_Pr->CP_PrefClock) ||
2093 (modexres > SiS_Pr->PanelXRes) || (modeyres > SiS_Pr->PanelYRes)) {
2094 SiS_Pr->SiS_LCDInfo |= LCDPass11;
2099 if(SiS_Pr->UseCustomMode) {
2100 SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11);
2103 /* (In)validate LCDPass11 flag */
2104 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2105 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
2109 if(!((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) {
2111 if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) {
2112 if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) {
2113 if(ModeNo == 0x12) {
2114 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
2115 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2117 } else if(ModeNo > 0x13) {
2118 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) {
2119 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2120 if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) {
2121 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2129 if(modeflag & HalfDCLK) {
2130 if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) {
2131 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2132 } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
2133 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2134 } else if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) {
2135 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2136 } else if(ModeNo > 0x13) {
2137 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
2138 if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2139 } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) {
2140 if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2148 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2149 if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) {
2150 SiS_Pr->SiS_SetFlag |= LCDVESATiming;
2153 SiS_Pr->SiS_SetFlag |= LCDVESATiming;
2158 printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n",
2159 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo);
2163 xf86DrvMsgVerb(0, X_PROBED, 4,
2164 "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n",
2165 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag);
2169 /*********************************************/
2171 /*********************************************/
2174 SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2175 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
2177 USHORT CRT2Index,VCLKIndex=0,VCLKIndexGEN=0;
2178 USHORT modeflag,resinfo,tempbx;
2179 const UCHAR *CHTVVCLKPtr = NULL;
2181 if(ModeNo <= 0x13) {
2182 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
2183 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
2184 CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2185 VCLKIndexGEN = (SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)) >> 2) & 0x03;
2187 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2188 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2189 CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2190 VCLKIndexGEN = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2191 if(HwInfo->jChipType < SIS_315H) VCLKIndexGEN &= 0x3f;
2194 if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */
2196 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
2199 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */
2201 if(HwInfo->jChipType < SIS_315H) {
2202 VCLKIndex = SiS_Pr->PanelVCLKIdx300;
2203 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) {
2204 VCLKIndex = VCLKIndexGEN;
2207 VCLKIndex = SiS_Pr->PanelVCLKIdx315;
2208 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) {
2210 /* Only those whose IndexGEN doesn't match VBVCLK array */
2211 case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; break;
2212 case SIS_RI_720x480: VCLKIndex = VCLK_720x480; break;
2213 case SIS_RI_720x576: VCLKIndex = VCLK_720x576; break;
2214 case SIS_RI_768x576: VCLKIndex = VCLK_768x576; break;
2215 case SIS_RI_848x480: VCLKIndex = VCLK_848x480; break;
2216 case SIS_RI_856x480: VCLKIndex = VCLK_856x480; break;
2217 case SIS_RI_800x480: VCLKIndex = VCLK_800x480; break;
2218 case SIS_RI_1024x576: VCLKIndex = VCLK_1024x576; break;
2219 case SIS_RI_1152x864: VCLKIndex = VCLK_1152x864; break;
2220 case SIS_RI_1360x768: VCLKIndex = VCLK_1360x768; break;
2221 default: VCLKIndex = VCLKIndexGEN;
2224 if(ModeNo <= 0x13) {
2225 if(HwInfo->jChipType <= SIS_315PRO) {
2226 if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42;
2228 if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00;
2231 if(HwInfo->jChipType <= SIS_315PRO) {
2232 if(VCLKIndex == 0) VCLKIndex = 0x41;
2233 if(VCLKIndex == 1) VCLKIndex = 0x43;
2234 if(VCLKIndex == 4) VCLKIndex = 0x44;
2239 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */
2241 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
2242 if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2;
2243 else VCLKIndex = HiTVVCLK;
2244 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
2245 if(modeflag & Charx8Dot) VCLKIndex = HiTVSimuVCLK;
2246 else VCLKIndex = HiTVTextVCLK;
2248 } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK;
2249 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2;
2250 else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2;
2251 else VCLKIndex = TVVCLK;
2253 if(HwInfo->jChipType < SIS_315H) VCLKIndex += TVCLKBASE_300;
2254 else VCLKIndex += TVCLKBASE_315;
2258 VCLKIndex = VCLKIndexGEN;
2259 if(HwInfo->jChipType < SIS_315H) {
2261 if( (HwInfo->jChipType == SIS_630) &&
2262 (HwInfo->jChipRevision >= 0x30)) {
2263 if(VCLKIndex == 0x14) VCLKIndex = 0x34;
2265 /* Better VGA2 clock for 1280x1024@75 */
2266 if(VCLKIndex == 0x17) VCLKIndex = 0x45;
2271 } else { /* If not programming CRT2 */
2273 VCLKIndex = VCLKIndexGEN;
2274 if(HwInfo->jChipType < SIS_315H) {
2276 if( (HwInfo->jChipType != SIS_630) &&
2277 (HwInfo->jChipType != SIS_300) ) {
2278 if(VCLKIndex == 0x1b) VCLKIndex = 0x48;
2286 VCLKIndex = CRT2Index;
2288 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
2290 if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) {
2294 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1;
2295 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
2297 if(SiS_Pr->SiS_ModeType > ModeVGA) {
2298 if(SiS_Pr->SiS_CHSOverScan) tempbx = 8;
2300 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
2302 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1;
2303 } else if(SiS_Pr->SiS_TVMode & TVSetPALN) {
2305 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1;
2309 case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break;
2310 case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break;
2311 case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break;
2312 case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break;
2313 case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break;
2314 case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break;
2315 case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break;
2316 case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break;
2317 case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break;
2318 default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break;
2320 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
2322 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
2324 if(HwInfo->jChipType < SIS_315H) {
2325 VCLKIndex = SiS_Pr->PanelVCLKIdx300;
2327 VCLKIndex = SiS_Pr->PanelVCLKIdx315;
2330 /* Special Timing: Barco iQ Pro R series */
2331 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44;
2333 /* Special Timing: 848x480 parallel lvds */
2334 if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
2335 if(HwInfo->jChipType < SIS_315H) {
2336 VCLKIndex = VCLK34_300;
2337 /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */
2339 VCLKIndex = VCLK34_315;
2340 /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */
2346 VCLKIndex = VCLKIndexGEN;
2347 if(HwInfo->jChipType < SIS_315H) {
2349 if( (HwInfo->jChipType == SIS_630) &&
2350 (HwInfo->jChipRevision >= 0x30) ) {
2351 if(VCLKIndex == 0x14) VCLKIndex = 0x2e;
2357 } else { /* if not programming CRT2 */
2359 VCLKIndex = VCLKIndexGEN;
2360 if(HwInfo->jChipType < SIS_315H) {
2362 if( (HwInfo->jChipType != SIS_630) &&
2363 (HwInfo->jChipType != SIS_300) ) {
2364 if(VCLKIndex == 0x1b) VCLKIndex = 0x48;
2367 if(HwInfo->jChipType == SIS_730) {
2368 if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */
2369 if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */
2380 xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex);
2386 /*********************************************/
2387 /* SET CRT2 MODE TYPE REGISTERS */
2388 /*********************************************/
2391 SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2392 PSIS_HW_INFO HwInfo)
2394 USHORT i,j,modeflag;
2395 USHORT tempcl,tempah=0;
2396 #if defined(SIS300) || defined(SIS315H)
2400 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
2401 USHORT tempah2, tempbl2;
2404 if(ModeNo <= 0x13) {
2405 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
2406 } else if(SiS_Pr->UseCustomMode) {
2407 modeflag = SiS_Pr->CModeFlag;
2409 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2412 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
2414 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40);
2415 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7);
2419 for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0);
2420 if(HwInfo->jChipType >= SIS_315H) {
2421 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0x7F);
2424 tempcl = SiS_Pr->SiS_ModeType;
2426 if(HwInfo->jChipType < SIS_315H) {
2428 #ifdef SIS300 /* ---- 300 series ---- */
2430 /* For 301BDH: (with LCD via LVDS) */
2431 if(SiS_Pr->SiS_VBType & VB_NoLCD) {
2432 tempbl = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32);
2435 if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
2439 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,tempbl);
2444 if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */
2445 tempah = ((0x10 >> tempcl) | 0x80);
2447 } else tempah = 0x80;
2449 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0;
2455 #ifdef SIS315H /* ------- 315/330 series ------ */
2457 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
2458 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
2459 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08);
2465 if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */
2466 tempah = (0x08 >> tempcl);
2467 if (tempah == 0) tempah = 1;
2470 } else tempah = 0x40;
2472 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50;
2474 #endif /* SIS315H */
2478 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0;
2480 if(HwInfo->jChipType < SIS_315H) {
2481 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah);
2483 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2484 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah);
2485 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
2487 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah);
2489 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah);
2494 if(SiS_Pr->SiS_VBType & VB_SISVB) {
2497 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
2500 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
2502 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
2507 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0;
2509 if(HwInfo->jChipType < SIS_315H) {
2511 tempah = (tempah << 5) & 0xFF;
2512 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah);
2513 tempah = (tempah >> 5) & 0xFF;
2517 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah);
2521 if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) {
2526 if(SiS_Pr->SiS_VBType & VB_SIS301) {
2527 if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah &= ~0x80;
2530 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
2531 if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) {
2532 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2538 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah);
2541 if(SiS_Pr->SiS_VBType & VB_SIS301) {
2542 if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah = 0;
2545 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempah |= 0x40;
2547 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
2548 if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) {
2553 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah);
2557 if(HwInfo->jChipType >= SIS_315H) {
2560 /* LVDS can only be slave in 8bpp modes */
2562 if((modeflag & CRT2Mode) && (SiS_Pr->SiS_ModeType > ModeVGA)) {
2563 if(SiS_Pr->SiS_VBInfo & DriverMode) {
2568 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
2572 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
2576 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
2580 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah);
2587 if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) {
2592 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0;
2594 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah);
2603 if(SiS_Pr->SiS_VBType & VB_SISVB) {
2605 if(HwInfo->jChipType >= SIS_315H) {
2608 unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01);
2610 /* The following is nearly unpreditable and varies from machine
2611 * to machine. Especially the 301DH seems to be a real trouble
2612 * maker. Some BIOSes simply set the registers (like in the
2613 * NoLCD-if-statements here), some set them according to the
2614 * LCDA stuff. It is very likely that some machines are not
2615 * treated correctly in the following, very case-orientated
2616 * code. What do I do then...?
2619 /* 740 variants match for 30xB, 301B-DH, 30xLV */
2622 tempah = 0x04; /* For all bridges */
2624 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2626 if(SiS_IsDualEdge(SiS_Pr, HwInfo)) {
2630 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);
2633 /* The following two are responsible for eventually wrong colors
2634 * in TV output. The DH (VB_NoLCD) conditions are unknown; the
2635 * b0 was found in some 651 machine (Pim; P4_23=0xe5); the b1 version
2636 * in a 650 box (Jake). What is the criteria?
2639 if((IS_SIS740) || (HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) {
2642 if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) ||
2643 ((SiS_Pr->SiS_ROMNew) && (!(ROMAddr[0x5b] & 0x04)))) {
2647 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,tempah);
2648 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl);
2649 } else if(SiS_Pr->SiS_VBType & VB_SIS301) {
2650 /* Fixes "TV-blue-bug" on 315+301 */
2651 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */
2652 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f);
2653 } else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
2654 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */
2655 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0);
2656 } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) {
2657 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xB-DH rev b0 (or "DH on 651"?) */
2658 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0);
2660 tempah = 0x30; tempah2 = 0xc0; /* For 30xB (and 301BDH rev b1) */
2661 tempbl = 0xcf; tempbl2 = 0x3f;
2662 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2663 tempah = tempah2 = 0x00;
2664 if(SiS_IsDualEdge(SiS_Pr, HwInfo)) {
2665 tempbl = tempbl2 = 0xff;
2668 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah);
2669 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2);
2674 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0x00;
2675 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,0x7f,tempah);
2679 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2681 if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) tempah = 0x80;
2683 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah);
2686 #endif /* SIS315H */
2688 } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
2691 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f);
2693 if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) ||
2694 ((SiS_Pr->SiS_VBType & VB_NoLCD) &&
2695 (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) {
2696 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F);
2698 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x23,0x80);
2704 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
2705 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80);
2706 if(SiS_Pr->SiS_VBType & VB_SIS301C) {
2707 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3A,0xC0);
2714 if(HwInfo->jChipType >= SIS_315H) {
2716 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
2720 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2722 if(SiS_IsDualEdge(SiS_Pr, HwInfo)) tempbl = 0xff;
2724 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);
2726 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
2727 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
2730 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30);
2732 } else if(HwInfo->jChipType == SIS_550) {
2734 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
2735 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30);
2746 /*********************************************/
2747 /* GET RESOLUTION DATA */
2748 /*********************************************/
2751 SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex)
2753 if(ModeNo <= 0x13) return((USHORT)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo);
2754 else return((USHORT)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO);
2758 SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
2759 PSIS_HW_INFO HwInfo)
2761 USHORT xres,yres,modeflag=0,resindex;
2763 if(SiS_Pr->UseCustomMode) {
2764 xres = SiS_Pr->CHDisplay;
2765 if(SiS_Pr->CModeFlag & HalfDCLK) xres *= 2;
2766 SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres;
2767 yres = SiS_Pr->CVDisplay;
2768 if(SiS_Pr->CModeFlag & DoubleScanMode) yres *= 2;
2769 SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres;
2773 resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex);
2775 if(ModeNo <= 0x13) {
2776 xres = SiS_Pr->SiS_StResInfo[resindex].HTotal;
2777 yres = SiS_Pr->SiS_StResInfo[resindex].VTotal;
2779 xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal;
2780 yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal;
2781 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2784 if(!SiS_Pr->SiS_IF_DEF_DSTN && !SiS_Pr->SiS_IF_DEF_FSTN) {
2786 if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) {
2787 if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) {
2788 if(yres == 350) yres = 400;
2790 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) {
2791 if(ModeNo == 0x12) yres = 400;
2795 if(modeflag & HalfDCLK) xres *= 2;
2796 if(modeflag & DoubleScanMode) yres *= 2;
2800 if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
2803 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCDA | SetCRT2ToLCD | SetCRT2ToHiVision)) {
2804 if(xres == 720) xres = 640;
2808 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
2809 switch(SiS_Pr->SiS_LCDResInfo) {
2810 case Panel_1024x768:
2811 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
2812 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2813 if(yres == 350) yres = 357;
2814 if(yres == 400) yres = 420;
2815 if(yres == 480) yres = 525;
2819 case Panel_1280x1024:
2820 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2821 /* BIOS bug - does this regardless of scaling */
2822 if(yres == 400) yres = 405;
2824 if(yres == 350) yres = 360;
2825 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
2826 if(yres == 360) yres = 375;
2829 case Panel_1600x1200:
2830 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
2831 if(yres == 1024) yres = 1056;
2839 if(SiS_Pr->SiS_VBType & VB_SISVB) {
2840 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) {
2841 if(xres == 720) xres = 640;
2843 } else if(xres == 720) xres = 640;
2845 if(SiS_Pr->SiS_SetFlag & SetDOSMode) {
2847 if(HwInfo->jChipType >= SIS_315H) {
2848 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480;
2850 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480;
2852 if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) yres = 480;
2856 SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres;
2857 SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres;
2860 /*********************************************/
2861 /* GET CRT2 TIMING DATA */
2862 /*********************************************/
2865 SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2866 USHORT RefreshRateTableIndex, USHORT *ResIndex,
2867 USHORT *DisplayType)
2871 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2872 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2873 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE;
2875 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
2876 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE;
2880 if(ModeNo <= 0x13) {
2881 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
2882 (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2884 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2885 (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2888 (*ResIndex) &= 0x3F;
2890 if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
2891 (*DisplayType) = 18;
2892 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++;
2893 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
2894 (*DisplayType) += 2;
2895 if(SiS_Pr->SiS_ModeType > ModeVGA) {
2896 if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 99;
2898 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
2899 (*DisplayType) = 18; /* PALM uses NTSC data */
2900 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++;
2901 } else if(SiS_Pr->SiS_TVMode & TVSetPALN) {
2902 (*DisplayType) = 20; /* PALN uses PAL data */
2903 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++;
2907 switch(SiS_Pr->SiS_LCDResInfo) {
2908 case Panel_640x480: (*DisplayType) = 50; break;
2909 case Panel_640x480_2: (*DisplayType) = 52; break;
2910 case Panel_640x480_3: (*DisplayType) = 54; break;
2911 case Panel_800x600: (*DisplayType) = 0; break;
2912 case Panel_1024x600: (*DisplayType) = 23; break;
2913 case Panel_1024x768: (*DisplayType) = 4; break;
2914 case Panel_1152x768: (*DisplayType) = 27; break;
2915 case Panel_1280x768: (*DisplayType) = 40; break;
2916 case Panel_1280x1024: (*DisplayType) = 8; break;
2917 case Panel_1400x1050: (*DisplayType) = 14; break;
2918 case Panel_1600x1200: (*DisplayType) = 36; break;
2919 default: return FALSE;
2922 if(modeflag & HalfDCLK) (*DisplayType)++;
2924 switch(SiS_Pr->SiS_LCDResInfo) {
2926 case Panel_640x480_2:
2927 case Panel_640x480_3:
2930 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2;
2933 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
2934 (*DisplayType) = 12;
2935 if(modeflag & HalfDCLK) (*DisplayType)++;
2940 if(SiS_Pr->SiS_IF_DEF_FSTN) {
2941 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){
2942 (*DisplayType) = 22;
2951 SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
2952 USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex,
2953 PSIS_HW_INFO HwInfo)
2955 USHORT tempbx=0,tempal=0,resinfo=0;
2957 if(ModeNo <= 0x13) {
2958 tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2960 tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2961 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2964 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_IF_DEF_LVDS == 0)) {
2966 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */
2968 tempbx = SiS_Pr->SiS_LCDResInfo;
2969 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 32;
2971 if(SiS_Pr->SiS_LCDResInfo == Panel_1680x1050) {
2972 if (resinfo == SIS_RI_1280x800) tempal = 9;
2973 else if(resinfo == SIS_RI_1400x1050) tempal = 11;
2974 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x800) ||
2975 (SiS_Pr->SiS_LCDResInfo == Panel_1280x800_2)) {
2976 if (resinfo == SIS_RI_1280x768) tempal = 9;
2979 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
2980 /* Pass 1:1 only (center-screen handled outside) */
2981 /* This is never called for the panel's native resolution */
2982 /* since Pass1:1 will not be set in this case */
2984 if(ModeNo >= 0x13) {
2985 tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS;
2990 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
2991 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
2992 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2994 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++;
3002 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
3003 /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */
3005 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
3007 if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14;
3009 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
3010 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7;
3011 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6;
3013 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5;
3015 if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3;
3017 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5;
3025 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) {
3026 if(tempal == 6) tempal = 7;
3027 if((resinfo == SIS_RI_720x480) ||
3028 (resinfo == SIS_RI_720x576) ||
3029 (resinfo == SIS_RI_768x576)) {
3031 if(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetPALN)) {
3032 if(resinfo == SIS_RI_720x480) tempal = 9;
3035 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
3036 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {
3037 if(resinfo == SIS_RI_1024x768) tempal = 8;
3039 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {
3040 if((resinfo == SIS_RI_720x576) ||
3041 (resinfo == SIS_RI_768x576)) {
3044 if(resinfo == SIS_RI_1280x720) tempal = 9;
3050 *CRT2Index = tempbx;
3053 } else { /* LVDS, 301B-DH (if running on LCD) */
3056 if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
3059 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1;
3060 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
3062 if(SiS_Pr->SiS_ModeType > ModeVGA) {
3063 if(SiS_Pr->SiS_CHSOverScan) tempbx = 99;
3065 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
3067 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1;
3068 } else if(SiS_Pr->SiS_TVMode & TVSetPALN) {
3070 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1;
3076 switch(SiS_Pr->SiS_LCDResInfo) {
3077 case Panel_640x480: tempbx = 6; break;
3078 case Panel_640x480_2:
3079 case Panel_640x480_3: tempbx = 30; break;
3080 case Panel_800x600: tempbx = 0; break;
3081 case Panel_1024x600: tempbx = 15; break;
3082 case Panel_1024x768: tempbx = 2; break;
3083 case Panel_1152x768: tempbx = 17; break;
3084 case Panel_1280x768: tempbx = 18; break;
3085 case Panel_1280x1024: tempbx = 4; break;
3086 case Panel_1400x1050: tempbx = 8; break;
3087 case Panel_1600x1200: tempbx = 21; break;
3088 case Panel_Barco1366: tempbx = 80; break;
3091 switch(SiS_Pr->SiS_LCDResInfo) {
3093 case Panel_640x480_2:
3094 case Panel_640x480_3:
3097 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
3100 if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 7;
3102 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
3104 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
3105 } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
3107 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
3110 if((SiS_Pr->SiS_CustomT != CUT_BARCO1366) &&
3111 (SiS_Pr->SiS_CustomT != CUT_PANEL848)) {
3112 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) &&
3113 (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
3120 (*CRT2Index) = tempbx;
3121 (*ResIndex) = tempal & 0x1F;
3126 SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3127 USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo)
3129 USHORT tempax=0,tempbx=0;
3130 USHORT temp1=0,modeflag=0,tempcx=0;
3133 SiS_Pr->SiS_RVBHCMAX = 1;
3134 SiS_Pr->SiS_RVBHCFACT = 1;
3136 if(ModeNo <= 0x13) {
3138 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
3139 index = SiS_GetModePtr(SiS_Pr,ModeNo,ModeIdIndex);
3141 tempax = SiS_Pr->SiS_StandTable[index].CRTC[0];
3142 tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6];
3143 temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7];
3147 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3148 index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3150 tempax = SiS_Pr->SiS_CRT1Table[index].CR[0];
3151 tempax |= (SiS_Pr->SiS_CRT1Table[index].CR[14] << 8);
3153 tempbx = SiS_Pr->SiS_CRT1Table[index].CR[6];
3154 tempcx = SiS_Pr->SiS_CRT1Table[index].CR[13] << 8;
3158 temp1 = SiS_Pr->SiS_CRT1Table[index].CR[7];
3162 if(temp1 & 0x01) tempbx |= 0x0100;
3163 if(temp1 & 0x20) tempbx |= 0x0200;
3167 /* Charx8Dot is no more used (and assumed), so we set it */
3168 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
3169 modeflag |= Charx8Dot;
3172 if(modeflag & Charx8Dot) tempax *= 8;
3175 if(modeflag & HalfDCLK) tempax <<= 1;
3179 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax;
3180 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx;
3184 SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3185 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
3187 USHORT CRT2Index, ResIndex;
3188 const SiS_LVDSDataStruct *LVDSData = NULL;
3190 SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
3192 if(SiS_Pr->SiS_VBType & VB_SISVB) {
3193 SiS_Pr->SiS_RVBHCMAX = 1;
3194 SiS_Pr->SiS_RVBHCFACT = 1;
3195 SiS_Pr->SiS_NewFlickerMode = 0;
3196 SiS_Pr->SiS_RVBHRS = 50;
3197 SiS_Pr->SiS_RY1COE = 0;
3198 SiS_Pr->SiS_RY2COE = 0;
3199 SiS_Pr->SiS_RY3COE = 0;
3200 SiS_Pr->SiS_RY4COE = 0;
3203 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3206 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3207 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
3208 if(SiS_Pr->UseCustomMode) {
3209 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->CHTotal;
3210 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3213 ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3215 ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS;
3217 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT;
3218 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT;
3219 SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT;
3220 SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT;
3223 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3224 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3227 /* This handles custom modes and custom panels */
3228 SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes;
3229 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes;
3230 SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3231 SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3232 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE);
3233 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE);
3236 SiS_CalcLCDACRT1Timing(SiS_Pr,ModeNo,ModeIdIndex);
3242 /* 301BDH needs LVDS Data */
3243 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
3244 SiS_Pr->SiS_IF_DEF_LVDS = 1;
3247 SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
3248 &CRT2Index, &ResIndex, HwInfo);
3250 /* 301BDH needs LVDS Data */
3251 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
3252 SiS_Pr->SiS_IF_DEF_LVDS = 0;
3255 switch (CRT2Index) {
3256 case 0: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break;
3257 case 1: LVDSData = SiS_Pr->SiS_LVDS800x600Data_2; break;
3258 case 2: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break;
3259 case 3: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break;
3260 case 4: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_1; break;
3261 case 5: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_2; break;
3262 case 6: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break;
3263 case 7: LVDSData = SiS_Pr->SiS_LVDSXXXxXXXData_1; break;
3264 case 8: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_1; break;
3265 case 9: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_2; break;
3266 case 10: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break;
3267 case 11: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break;
3268 case 12: LVDSData = SiS_Pr->SiS_CHTVUPALData; break;
3269 case 13: LVDSData = SiS_Pr->SiS_CHTVOPALData; break;
3270 case 14: LVDSData = SiS_Pr->SiS_LVDS320x480Data_1; break;
3271 case 15: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break;
3272 case 16: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_2; break;
3273 case 17: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_1; break;
3274 case 18: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_2; break;
3275 case 19: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_1; break;
3276 case 20: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_2; break;
3277 case 21: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_1; break;
3278 case 22: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_2; break;
3279 case 30: LVDSData = SiS_Pr->SiS_LVDS640x480Data_2; break;
3280 case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break;
3281 case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break;
3282 case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break;
3283 case 83: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_2; break;
3284 case 84: LVDSData = SiS_Pr->SiS_LVDS848x480Data_1; break;
3285 case 85: LVDSData = SiS_Pr->SiS_LVDS848x480Data_2; break;
3286 case 90: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break;
3287 case 91: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break;
3288 case 92: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break;
3289 case 93: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break;
3290 case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; /* Super Overscan */
3291 default: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break;
3294 SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT;
3295 SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT;
3296 SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT;
3297 SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT;
3299 if(!(SiS_Pr->SiS_VBType & VB_SISVB)) {
3300 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
3301 if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) {
3302 SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes;
3303 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes;
3304 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
3305 if(ResIndex < 0x08) {
3306 SiS_Pr->SiS_HDE = 1280;
3307 SiS_Pr->SiS_VDE = 1024;
3317 SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3318 USHORT RefreshRateTableIndex,
3319 PSIS_HW_INFO HwInfo)
3321 UCHAR *ROMAddr = NULL;
3322 USHORT tempax,tempbx,modeflag,romptr=0;
3323 USHORT resinfo,CRT2Index,ResIndex;
3324 const SiS_LCDDataStruct *LCDPtr = NULL;
3325 const SiS_TVDataStruct *TVPtr = NULL;
3330 if(ModeNo <= 0x13) {
3331 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
3332 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
3333 } else if(SiS_Pr->UseCustomMode) {
3334 modeflag = SiS_Pr->CModeFlag;
3337 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3338 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
3340 resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661;
3341 if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) &&
3342 (SiS_Pr->SiS_SetFlag & LCDVESATiming) &&
3343 (resinfo661 >= 0) &&
3344 (SiS_Pr->SiS_NeedRomModeData) ) {
3345 if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) {
3346 if((romptr = (SISGETROMW(21)))) {
3347 romptr += (resinfo661 * 10);
3348 ROMAddr = HwInfo->pjVirtualRomBase;
3355 SiS_Pr->SiS_NewFlickerMode = 0;
3356 SiS_Pr->SiS_RVBHRS = 50;
3357 SiS_Pr->SiS_RY1COE = 0;
3358 SiS_Pr->SiS_RY2COE = 0;
3359 SiS_Pr->SiS_RY3COE = 0;
3360 SiS_Pr->SiS_RY4COE = 0;
3362 SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex,HwInfo);
3364 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){
3366 if(SiS_Pr->UseCustomMode) {
3368 SiS_Pr->SiS_RVBHCMAX = 1;
3369 SiS_Pr->SiS_RVBHCFACT = 1;
3370 SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal;
3371 SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal;
3372 SiS_Pr->SiS_HT = SiS_Pr->CHTotal;
3373 SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3374 SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE;
3375 SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE;
3379 SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
3383 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
3385 SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
3386 &CRT2Index,&ResIndex,HwInfo);
3389 case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break;
3390 case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break;
3391 case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break;
3392 case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break;
3393 case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break;
3394 case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break;
3395 case 8: TVPtr = SiS_Pr->SiS_StPALData; break;
3396 case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break;
3397 case 10: TVPtr = SiS_Pr->SiS_St525iData; break;
3398 case 11: TVPtr = SiS_Pr->SiS_St525pData; break;
3399 case 12: TVPtr = SiS_Pr->SiS_St750pData; break;
3400 case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break;
3401 case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break;
3402 default: TVPtr = SiS_Pr->SiS_StPALData; break;
3405 SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX;
3406 SiS_Pr->SiS_RVBHCFACT = (TVPtr+ResIndex)->RVBHCFACT;
3407 SiS_Pr->SiS_VGAHT = (TVPtr+ResIndex)->VGAHT;
3408 SiS_Pr->SiS_VGAVT = (TVPtr+ResIndex)->VGAVT;
3409 SiS_Pr->SiS_HDE = (TVPtr+ResIndex)->TVHDE;
3410 SiS_Pr->SiS_VDE = (TVPtr+ResIndex)->TVVDE;
3411 SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS;
3412 SiS_Pr->SiS_NewFlickerMode = (TVPtr+ResIndex)->FlickerMode;
3413 if(modeflag & HalfDCLK) {
3414 SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS;
3417 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
3419 if((resinfo == SIS_RI_1024x768) ||
3420 (resinfo == SIS_RI_1280x1024) ||
3421 (resinfo == SIS_RI_1280x720)) {
3422 SiS_Pr->SiS_NewFlickerMode = 0x40;
3425 if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode;
3427 SiS_Pr->SiS_HT = ExtHiTVHT;
3428 SiS_Pr->SiS_VT = ExtHiTVVT;
3429 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
3430 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
3431 SiS_Pr->SiS_HT = StHiTVHT;
3432 SiS_Pr->SiS_VT = StHiTVVT;
3434 if(!(modeflag & Charx8Dot)) {
3435 SiS_Pr->SiS_HT = StHiTextTVHT;
3436 SiS_Pr->SiS_VT = StHiTextTVVT;
3442 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
3444 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {
3445 SiS_Pr->SiS_HT = 1650;
3446 SiS_Pr->SiS_VT = 750;
3447 } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {
3448 SiS_Pr->SiS_HT = NTSCHT;
3449 SiS_Pr->SiS_VT = NTSCVT;
3451 SiS_Pr->SiS_HT = NTSCHT;
3452 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT;
3453 SiS_Pr->SiS_VT = NTSCVT;
3458 SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE;
3459 SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE;
3460 SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE;
3461 SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE;
3463 if(modeflag & HalfDCLK) {
3464 SiS_Pr->SiS_RY1COE = 0x00;
3465 SiS_Pr->SiS_RY2COE = 0xf4;
3466 SiS_Pr->SiS_RY3COE = 0x10;
3467 SiS_Pr->SiS_RY4COE = 0x38;
3470 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
3471 SiS_Pr->SiS_HT = NTSCHT;
3472 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT;
3473 SiS_Pr->SiS_VT = NTSCVT;
3475 SiS_Pr->SiS_HT = PALHT;
3476 SiS_Pr->SiS_VT = PALVT;
3481 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
3483 SiS_Pr->SiS_RVBHCMAX = 1;
3484 SiS_Pr->SiS_RVBHCFACT = 1;
3486 if(SiS_Pr->UseCustomMode) {
3488 SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal;
3489 SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal;
3490 SiS_Pr->SiS_HT = SiS_Pr->CHTotal;
3491 SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3492 SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE;
3493 SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE;
3497 BOOLEAN gotit = FALSE;
3499 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
3501 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT;
3502 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT;
3503 SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3504 SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3507 } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) {
3510 SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr];
3511 SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1];
3512 SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8);
3513 SiS_Pr->SiS_VGAVT = ROMAddr[romptr+4] | ((ROMAddr[romptr+3] & 0xf0) << 4);
3514 SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8);
3515 SiS_Pr->SiS_VT = ROMAddr[romptr+7] | ((ROMAddr[romptr+6] & 0xf0) << 4);
3516 if(SiS_Pr->SiS_VGAHT) gotit = TRUE;
3518 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
3519 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
3520 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT;
3521 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT;
3522 SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3523 SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3532 SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
3533 &CRT2Index,&ResIndex,HwInfo);
3536 case Panel_1024x768 : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break;
3537 case Panel_1024x768 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break;
3538 case Panel_1280x720 :
3539 case Panel_1280x720 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x720Data; break;
3540 case Panel_1280x768_2 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x768_2Data; break;
3541 case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break;
3542 case Panel_1280x800 :
3543 case Panel_1280x800 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x800Data; break;
3544 case Panel_1280x800_2 :
3545 case Panel_1280x800_2+ 32: LCDPtr = SiS_Pr->SiS_LCD1280x800_2Data; break;
3546 case Panel_1280x960 :
3547 case Panel_1280x960 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break;
3548 case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break;
3549 case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break;
3550 case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break;
3551 case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break;
3552 case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break;
3553 case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break;
3554 case Panel_1680x1050 :
3555 case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break;
3556 case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break;
3558 case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break;
3559 case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break;
3561 default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break;
3565 xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex);
3568 SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX;
3569 SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT;
3570 SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT;
3571 SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT;
3572 SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT;
3573 SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT;
3577 tempax = SiS_Pr->PanelXRes;
3578 tempbx = SiS_Pr->PanelYRes;
3580 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
3581 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
3582 if(HwInfo->jChipType < SIS_315H) {
3583 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560;
3584 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640;
3587 if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527;
3588 else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620;
3589 else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775;
3590 else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775;
3591 else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560;
3592 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640;
3594 } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x960) {
3595 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700;
3596 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800;
3597 else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960;
3598 } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
3599 if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768;
3600 else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800;
3601 else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864;
3602 } else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) {
3603 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
3604 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875;
3605 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000;
3609 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3610 tempax = SiS_Pr->SiS_VGAHDE;
3611 tempbx = SiS_Pr->SiS_VGAVDE;
3614 SiS_Pr->SiS_HDE = tempax;
3615 SiS_Pr->SiS_VDE = tempbx;
3621 SiS_GetCRT2Data(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
3622 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
3625 if(SiS_Pr->SiS_VBType & VB_SISVB) {
3627 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
3628 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
3630 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
3631 /* Need LVDS Data for LCD on 301B-DH */
3632 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
3634 SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
3640 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
3645 /*********************************************/
3646 /* GET LVDS DES (SKEW) DATA */
3647 /*********************************************/
3650 SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
3651 USHORT RefreshRateTableIndex, USHORT *PanelIndex,
3652 USHORT *ResIndex, PSIS_HW_INFO HwInfo)
3656 if(ModeNo <= 0x13) {
3657 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
3658 (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3660 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3661 (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3664 (*ResIndex) &= 0x1F;
3667 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
3668 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
3670 if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) (*PanelIndex) += 2;
3671 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*PanelIndex) += 1;
3672 /* Nothing special needed for SOverscan */
3673 /* PALM uses NTSC data, PALN uses PAL data */
3677 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
3678 *PanelIndex = SiS_Pr->SiS_LCDTypeInfo;
3679 if(HwInfo->jChipType >= SIS_661) {
3680 /* As long as we don's use the BIOS tables, we
3681 * need to convert the TypeInfo as for 315 series
3683 (*PanelIndex) = SiS_Pr->SiS_LCDResInfo - 1;
3685 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3686 (*PanelIndex) += 16;
3687 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
3689 if(modeflag & HalfDCLK) (*PanelIndex)++;
3694 if(SiS_Pr->SiS_SetFlag & SetDOSMode) {
3695 if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) {
3697 if(HwInfo->jChipType < SIS_315H) {
3698 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) (*ResIndex)++;
3705 SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex,
3706 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
3709 USHORT PanelIndex,ResIndex;
3710 const SiS_LVDSDesStruct *PanelDesPtr = NULL;
3712 SiS_Pr->SiS_LCDHDES = 0;
3713 SiS_Pr->SiS_LCDVDES = 0;
3715 if( (SiS_Pr->UseCustomMode) ||
3716 (SiS_Pr->SiS_LCDResInfo == Panel_Custom) ||
3717 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ||
3718 ((SiS_Pr->SiS_VBType & VB_SISVB) &&
3719 (SiS_Pr->SiS_LCDInfo & DontExpandLCD) &&
3720 (SiS_Pr->SiS_LCDInfo & LCDPass11)) ) {
3724 if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3727 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3728 /* non-pass 1:1 only, see above */
3729 if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) {
3730 SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2);
3732 if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) {
3733 SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2);
3736 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) {
3737 switch(SiS_Pr->SiS_CustomT) {
3738 case CUT_UNIWILL1024:
3739 case CUT_UNIWILL10242:
3741 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
3742 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3746 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
3747 if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) {
3748 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3756 SiS_GetLVDSDesPtr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
3757 &PanelIndex, &ResIndex, HwInfo);
3759 switch(PanelIndex) {
3760 case 0: PanelDesPtr = SiS_Pr->SiS_PanelType00_1; break; /* --- */
3761 case 1: PanelDesPtr = SiS_Pr->SiS_PanelType01_1; break;
3762 case 2: PanelDesPtr = SiS_Pr->SiS_PanelType02_1; break;
3763 case 3: PanelDesPtr = SiS_Pr->SiS_PanelType03_1; break;
3764 case 4: PanelDesPtr = SiS_Pr->SiS_PanelType04_1; break;
3765 case 5: PanelDesPtr = SiS_Pr->SiS_PanelType05_1; break;
3766 case 6: PanelDesPtr = SiS_Pr->SiS_PanelType06_1; break;
3767 case 7: PanelDesPtr = SiS_Pr->SiS_PanelType07_1; break;
3768 case 8: PanelDesPtr = SiS_Pr->SiS_PanelType08_1; break;
3769 case 9: PanelDesPtr = SiS_Pr->SiS_PanelType09_1; break;
3770 case 10: PanelDesPtr = SiS_Pr->SiS_PanelType0a_1; break;
3771 case 11: PanelDesPtr = SiS_Pr->SiS_PanelType0b_1; break;
3772 case 12: PanelDesPtr = SiS_Pr->SiS_PanelType0c_1; break;
3773 case 13: PanelDesPtr = SiS_Pr->SiS_PanelType0d_1; break;
3774 case 14: PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; break;
3775 case 15: PanelDesPtr = SiS_Pr->SiS_PanelType0f_1; break;
3776 case 16: PanelDesPtr = SiS_Pr->SiS_PanelType00_2; break; /* --- */
3777 case 17: PanelDesPtr = SiS_Pr->SiS_PanelType01_2; break;
3778 case 18: PanelDesPtr = SiS_Pr->SiS_PanelType02_2; break;
3779 case 19: PanelDesPtr = SiS_Pr->SiS_PanelType03_2; break;
3780 case 20: PanelDesPtr = SiS_Pr->SiS_PanelType04_2; break;
3781 case 21: PanelDesPtr = SiS_Pr->SiS_PanelType05_2; break;
3782 case 22: PanelDesPtr = SiS_Pr->SiS_PanelType06_2; break;
3783 case 23: PanelDesPtr = SiS_Pr->SiS_PanelType07_2; break;
3784 case 24: PanelDesPtr = SiS_Pr->SiS_PanelType08_2; break;
3785 case 25: PanelDesPtr = SiS_Pr->SiS_PanelType09_2; break;
3786 case 26: PanelDesPtr = SiS_Pr->SiS_PanelType0a_2; break;
3787 case 27: PanelDesPtr = SiS_Pr->SiS_PanelType0b_2; break;
3788 case 28: PanelDesPtr = SiS_Pr->SiS_PanelType0c_2; break;
3789 case 29: PanelDesPtr = SiS_Pr->SiS_PanelType0d_2; break;
3790 case 30: PanelDesPtr = SiS_Pr->SiS_PanelType0e_2; break;
3791 case 31: PanelDesPtr = SiS_Pr->SiS_PanelType0f_2; break;
3792 case 32: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_1; break; /* pass 1:1 */
3793 case 33: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_2; break;
3794 case 50: PanelDesPtr = SiS_Pr->SiS_CHTVUNTSCDesData; break; /* TV */
3795 case 51: PanelDesPtr = SiS_Pr->SiS_CHTVONTSCDesData; break;
3796 case 52: PanelDesPtr = SiS_Pr->SiS_CHTVUPALDesData; break;
3797 case 53: PanelDesPtr = SiS_Pr->SiS_CHTVOPALDesData; break;
3801 SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES;
3802 SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES;
3804 if((ModeNo <= 0x13) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
3805 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
3806 if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3807 if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 632;
3808 } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) {
3809 if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) {
3810 if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) {
3811 if(HwInfo->jChipType < SIS_315H) {
3812 if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320;
3814 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480;
3815 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804;
3816 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704;
3817 if(!(modeflag & HalfDCLK)) {
3818 SiS_Pr->SiS_LCDHDES = 320;
3819 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632;
3820 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 542;
3830 /*********************************************/
3831 /* DISABLE VIDEO BRIDGE */
3832 /*********************************************/
3834 /* NEVER use any variables (VBInfo), this will be called
3835 * from outside the context of modeswitch!
3836 * MUST call getVBType before calling this
3839 SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
3842 USHORT tempah,pushax=0,modenum;
3846 if(SiS_Pr->SiS_VBType & VB_SISVB) {
3848 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== For 30xB/LV ===== */
3850 if(HwInfo->jChipType < SIS_315H) {
3852 #ifdef SIS300 /* 300 series */
3854 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) {
3855 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
3856 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE);
3858 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08);
3860 SiS_PanelDelay(SiS_Pr, HwInfo, 3);
3862 if(SiS_Is301B(SiS_Pr)) {
3863 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f);
3864 SiS_ShortDelay(SiS_Pr,1);
3866 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF);
3867 SiS_DisplayOff(SiS_Pr);
3868 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
3869 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
3870 SiS_UnLockCRT2(SiS_Pr,HwInfo);
3871 if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
3872 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80);
3873 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40);
3875 if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) ||
3876 (!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) ) {
3877 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
3878 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
3879 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
3881 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04);
3889 #ifdef SIS315H /* 315 series */
3891 BOOLEAN custom1 = ((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) ||
3892 (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) ? TRUE : FALSE;
3894 modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34) & 0x7f;
3896 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
3899 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
3900 if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) {
3901 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
3905 if( (modenum <= 0x13) ||
3906 (SiS_IsVAMode(SiS_Pr,HwInfo)) ||
3907 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ) {
3908 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE);
3909 if(custom1) SiS_PanelDelay(SiS_Pr, HwInfo, 3);
3913 SiS_DDC2Delay(SiS_Pr,0xff00);
3914 SiS_DDC2Delay(SiS_Pr,0xe000);
3915 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00);
3916 pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06);
3918 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
3920 SiS_PanelDelay(SiS_Pr, HwInfo, 3);
3925 if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) {
3926 if(HwInfo->jChipType < SIS_340) {
3928 if(SiS_IsVAMode(SiS_Pr,HwInfo)) tempah = 0xf7;
3929 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah);
3933 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
3934 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,~0x10);
3938 if(SiS_IsDualEdge(SiS_Pr,HwInfo)) {
3940 if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) tempah = 0xbf;
3942 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah);
3944 if((SiS_IsVAMode(SiS_Pr,HwInfo)) ||
3945 ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) {
3947 SiS_DisplayOff(SiS_Pr);
3948 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
3949 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
3951 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
3952 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF);
3956 if((!(SiS_IsVAMode(SiS_Pr,HwInfo))) ||
3957 ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) {
3959 if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) {
3960 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf);
3961 SiS_DisplayOff(SiS_Pr);
3963 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
3965 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
3966 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
3969 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
3970 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00);
3971 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
3972 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
3973 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp);
3977 if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) {
3978 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
3981 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
3985 if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) {
3986 if(!(SiS_CRT2IsLCD(SiS_Pr,HwInfo))) {
3987 if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) {
3988 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
3993 SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax);
3995 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
3996 if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) {
3997 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 20);
4003 if((SiS_IsVAMode(SiS_Pr,HwInfo)) ||
4004 (!(SiS_IsDualEdge(SiS_Pr,HwInfo)))) {
4005 if((!(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo))) ||
4006 (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo)))) {
4007 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
4008 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
4009 SiS_PanelDelay(SiS_Pr, HwInfo, 4);
4016 #endif /* SIS315H */
4020 } else { /* ============ For 301 ================ */
4022 if(HwInfo->jChipType < SIS_315H) {
4024 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) {
4025 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08);
4026 SiS_PanelDelay(SiS_Pr, HwInfo, 3);
4031 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */
4032 SiS_DisplayOff(SiS_Pr);
4034 if(HwInfo->jChipType >= SIS_315H) {
4035 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
4038 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */
4040 if(HwInfo->jChipType >= SIS_315H) {
4041 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00);
4042 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
4043 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4044 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp);
4047 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */
4048 if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) ||
4049 (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) {
4050 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
4051 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04);
4058 } else { /* ============ For LVDS =============*/
4060 if(HwInfo->jChipType < SIS_315H) {
4062 #ifdef SIS300 /* 300 series */
4064 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
4065 SiS_SetCH700x(SiS_Pr,0x090E);
4068 if(HwInfo->jChipType == SIS_730) {
4069 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) {
4070 SiS_WaitVBRetrace(SiS_Pr,HwInfo);
4072 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) {
4073 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08);
4074 SiS_PanelDelay(SiS_Pr, HwInfo, 3);
4077 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) {
4078 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
4079 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) {
4080 SiS_WaitVBRetrace(SiS_Pr,HwInfo);
4081 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) {
4082 SiS_DisplayOff(SiS_Pr);
4084 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08);
4085 SiS_PanelDelay(SiS_Pr, HwInfo, 3);
4091 SiS_DisplayOff(SiS_Pr);
4093 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
4095 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
4096 SiS_UnLockCRT2(SiS_Pr,HwInfo);
4097 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80);
4098 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40);
4100 if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) ||
4101 (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) {
4102 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
4103 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04);
4110 #ifdef SIS315H /* 315 series */
4112 if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) {
4113 if(HwInfo->jChipType < SIS_340) {
4114 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18);
4118 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
4120 if(HwInfo->jChipType == SIS_740) {
4121 temp = SiS_GetCH701x(SiS_Pr,0x61);
4123 SiS_SetCH701x(SiS_Pr,0xac76);
4124 SiS_SetCH701x(SiS_Pr,0x0066);
4127 if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ||
4128 (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) {
4129 SiS_SetCH701x(SiS_Pr,0x3e49);
4133 if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ||
4134 (SiS_IsVAMode(SiS_Pr,HwInfo)) ) {
4135 SiS_Chrontel701xBLOff(SiS_Pr);
4136 SiS_Chrontel701xOff(SiS_Pr,HwInfo);
4139 if(HwInfo->jChipType != SIS_740) {
4140 if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ||
4141 (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) {
4142 SiS_SetCH701x(SiS_Pr,0x0149);
4148 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4149 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08);
4150 SiS_PanelDelay(SiS_Pr, HwInfo, 3);
4153 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) ||
4154 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ||
4155 (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo))) ) {
4156 SiS_DisplayOff(SiS_Pr);
4159 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) ||
4160 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ||
4161 (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) {
4162 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
4165 if(HwInfo->jChipType == SIS_740) {
4166 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
4169 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
4171 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) ||
4172 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ||
4173 (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) {
4174 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
4177 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4178 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4179 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
4180 if(HwInfo->jChipType == SIS_550) {
4181 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf);
4182 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef);
4186 if(HwInfo->jChipType == SIS_740) {
4187 if(SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) {
4188 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
4190 } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) {
4191 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
4195 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
4196 if(SiS_IsDualEdge(SiS_Pr,HwInfo)) {
4197 /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */
4199 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
4203 SiS_UnLockCRT2(SiS_Pr,HwInfo);
4205 if(HwInfo->jChipType == SIS_550) {
4206 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); /* DirectDVD PAL?*/
4207 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); /* VB clock / 4 ? */
4208 } else if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) ||
4209 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ||
4210 (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) {
4211 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
4214 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4215 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4216 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) {
4217 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
4218 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04);
4223 #endif /* SIS315H */
4231 /*********************************************/
4232 /* ENABLE VIDEO BRIDGE */
4233 /*********************************************/
4235 /* NEVER use any variables (VBInfo), this will be called
4236 * from outside the context of a mode switch!
4237 * MUST call getVBType before calling this
4240 SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4242 USHORT temp=0,tempah;
4244 USHORT temp1,pushax=0;
4245 BOOLEAN delaylong = FALSE;
4248 if(SiS_Pr->SiS_VBType & VB_SISVB) {
4250 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ====== For 301B et al ====== */
4252 if(HwInfo->jChipType < SIS_315H) {
4254 #ifdef SIS300 /* 300 series */
4256 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4257 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
4258 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
4259 } else if(SiS_Pr->SiS_VBType & VB_NoLCD) {
4260 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00);
4262 if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_NoLCD)) {
4263 if(!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) {
4264 SiS_PanelDelay(SiS_Pr, HwInfo, 0);
4269 if((SiS_Pr->SiS_VBType & VB_NoLCD) &&
4270 (SiS_CRT2IsLCD(SiS_Pr, HwInfo))) {
4272 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */
4273 SiS_DisplayOn(SiS_Pr);
4274 SiS_UnLockCRT2(SiS_Pr,HwInfo);
4275 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF);
4276 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4277 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F);
4279 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40);
4281 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
4282 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
4283 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) {
4284 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4286 SiS_WaitVBRetrace(SiS_Pr,HwInfo);
4287 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00);
4293 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */
4294 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4295 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
4296 if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
4298 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp);
4299 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4300 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */
4301 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0);
4302 SiS_DisplayOn(SiS_Pr);
4303 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
4304 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4305 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
4306 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) {
4307 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4309 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
4321 #ifdef SIS315H /* 315 series */
4324 UCHAR r30=0, r31=0, r32=0, r33=0, cr36=0;
4325 /* USHORT emidelay=0; */
4328 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
4329 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef);
4331 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
4332 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
4337 if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) {
4338 if(HwInfo->jChipType < SIS_340) {
4340 if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) {
4341 if(SiS_TVEnabled(SiS_Pr, HwInfo)) tempah = 0x18;
4344 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah);
4348 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
4350 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00);
4351 SiS_DisplayOff(SiS_Pr);
4352 pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06);
4354 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
4357 if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) {
4358 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
4359 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2);
4360 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
4361 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2);
4362 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
4363 SiS_GenericDelay(SiS_Pr, 0x4500);
4368 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) {
4369 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10);
4375 if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) {
4377 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
4378 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4379 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
4380 if(!(tempah & SetCRT2ToRAMDAC)) {
4381 if(!(SiS_LCDAEnabled(SiS_Pr, HwInfo))) temp |= 0x20;
4384 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp);
4386 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */
4388 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
4389 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
4391 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
4392 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
4397 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20);
4401 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20);
4402 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
4405 if(SiS_IsDualEdge(SiS_Pr, HwInfo)) {
4407 if(!(SiS_IsVAMode(SiS_Pr, HwInfo))) tempah = 0x40;
4409 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah);
4411 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
4413 SiS_PanelDelay(SiS_Pr, HwInfo, 2);
4415 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10);
4416 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
4418 if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) {
4420 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
4421 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
4422 SiS_GenericDelay(SiS_Pr, 0x500);
4425 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c);
4427 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
4429 cr36 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
4431 if(SiS_Pr->SiS_ROMNew) {
4432 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
4433 USHORT romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo);
4435 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */
4437 SiS_Pr->EMI_31 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 0];
4438 SiS_Pr->EMI_32 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 1];
4439 SiS_Pr->EMI_33 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 2];
4440 if(ROMAddr[romptr + 1] & 0x10) SiS_Pr->EMI_30 = 0x40;
4441 /* emidelay = SISGETROMW((romptr + 0x22)); */
4442 SiS_Pr->HaveEMI = SiS_Pr->HaveEMILCD = SiS_Pr->OverruleEMI = TRUE;
4447 /* Compal 1400x1050: 0x05, 0x60, 0x00 YES (1.10.7w; CR36=69) */
4448 /* Compal 1400x1050: 0x0d, 0x70, 0x40 YES (1.10.7x; CR36=69) */
4449 /* Acer 1280x1024: 0x12, 0xd0, 0x6b NO (1.10.9k; CR36=73) */
4450 /* Compaq 1280x1024: 0x0d, 0x70, 0x6b YES (1.12.04b; CR36=03) */
4451 /* Clevo 1024x768: 0x05, 0x60, 0x33 NO (1.10.8e; CR36=12, DL!) */
4452 /* Clevo 1024x768: 0x0d, 0x70, 0x40 (if type == 3) YES (1.10.8y; CR36=?2) */
4453 /* Clevo 1024x768: 0x05, 0x60, 0x33 (if type != 3) YES (1.10.8y; CR36=?2) */
4454 /* Asus 1024x768: ? ? (1.10.8o; CR36=?2) */
4455 /* Asus 1024x768: 0x08, 0x10, 0x3c (problematic) YES (1.10.8q; CR36=22) */
4457 if(SiS_Pr->HaveEMI) {
4458 r30 = SiS_Pr->EMI_30; r31 = SiS_Pr->EMI_31;
4459 r32 = SiS_Pr->EMI_32; r33 = SiS_Pr->EMI_33;
4464 /* EMI_30 is read at driver start; however, the BIOS sets this
4465 * (if it is used) only if the LCD is in use. In case we caught
4466 * the machine while on TV output, this bit is not set and we
4467 * don't know if it should be set - hence our detection is wrong.
4468 * Work-around this here:
4471 if((!SiS_Pr->HaveEMI) || (!SiS_Pr->HaveEMILCD)) {
4472 switch((cr36 & 0x0f)) {
4475 if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) r30 &= ~0x40;
4476 if(!SiS_Pr->HaveEMI) {
4477 r31 = 0x05; r32 = 0x60; r33 = 0x33;
4478 if((cr36 & 0xf0) == 0x30) {
4479 r31 = 0x0d; r32 = 0x70; r33 = 0x40;
4483 case 3: /* 1280x1024 */
4484 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) r30 |= 0x40;
4485 if(!SiS_Pr->HaveEMI) {
4486 r31 = 0x12; r32 = 0xd0; r33 = 0x6b;
4487 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
4488 r31 = 0x0d; r32 = 0x70; r33 = 0x6b;
4492 case 9: /* 1400x1050 */
4494 if(!SiS_Pr->HaveEMI) {
4495 r31 = 0x05; r32 = 0x60; r33 = 0x00;
4496 if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) {
4497 r31 = 0x0d; r32 = 0x70; r33 = 0x40; /* BIOS values */
4501 case 11: /* 1600x1200 - unknown */
4503 if(!SiS_Pr->HaveEMI) {
4504 r31 = 0x05; r32 = 0x60; r33 = 0x00;
4509 /* BIOS values don't work so well sometimes */
4510 if(!SiS_Pr->OverruleEMI) {
4512 if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) {
4513 if((cr36 & 0x0f) == 0x09) {
4514 r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x00;
4519 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
4520 if((cr36 & 0x0f) == 0x03) {
4521 r30 = 0x20; r31 = 0x12; r32 = 0xd0; r33 = 0x6b;
4526 if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) {
4527 if((cr36 & 0x0f) == 0x02) {
4528 /* r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 2 */
4529 /* r30 = 0x20; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 3 */
4530 /* r30 = 0x60; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 4 */
4531 /* r30 = 0x20; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 5 */
4537 if(!(SiS_Pr->OverruleEMI && (!r30) && (!r31) && (!r32) && (!r33))) {
4538 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */
4539 SiS_GenericDelay(SiS_Pr, 0x500);
4541 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,r31);
4542 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,r32);
4543 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x33,r33);
4544 #endif /* SET_EMI */
4546 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10);
4549 if( (SiS_LCDAEnabled(SiS_Pr, HwInfo)) ||
4550 (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) {
4552 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5);
4554 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5);
4557 SiS_WaitVBRetrace(SiS_Pr,HwInfo);
4558 if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) {
4559 SiS_GenericDelay(SiS_Pr, 0x500);
4561 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); /* Enable */
4568 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) {
4569 if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) {
4570 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10);
4572 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10);
4574 SiS_WaitVBRetrace(SiS_Pr,HwInfo);
4575 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
4576 SiS_GenericDelay(SiS_Pr, 0x500);
4578 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
4582 SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax);
4583 SiS_DisplayOn(SiS_Pr);
4584 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xff);
4588 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) {
4589 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
4592 #endif /* SIS315H */
4596 } else { /* ============ For 301 ================ */
4598 if(HwInfo->jChipType < SIS_315H) {
4599 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4600 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00);
4601 SiS_PanelDelay(SiS_Pr, HwInfo, 0);
4605 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */
4606 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4607 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
4608 if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
4610 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp);
4612 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */
4614 if(HwInfo->jChipType >= SIS_315H) {
4615 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E);
4616 if(!(temp & 0x80)) {
4617 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */
4621 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */
4623 SiS_VBLongWait(SiS_Pr);
4624 SiS_DisplayOn(SiS_Pr);
4625 if(HwInfo->jChipType >= SIS_315H) {
4626 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
4628 SiS_VBLongWait(SiS_Pr);
4630 if(HwInfo->jChipType < SIS_315H) {
4631 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4632 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4633 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00);
4639 } else { /* =================== For LVDS ================== */
4641 if(HwInfo->jChipType < SIS_315H) {
4643 #ifdef SIS300 /* 300 series */
4645 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4646 if(HwInfo->jChipType == SIS_730) {
4647 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4648 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4649 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4651 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00);
4652 if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) {
4653 SiS_PanelDelay(SiS_Pr, HwInfo, 0);
4657 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4658 SiS_DisplayOn(SiS_Pr);
4659 SiS_UnLockCRT2(SiS_Pr,HwInfo);
4660 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF);
4661 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4662 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F);
4664 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40);
4667 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
4668 if(!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) {
4669 SiS_WaitVBRetrace(SiS_Pr, HwInfo);
4670 SiS_SetCH700x(SiS_Pr,0x0B0E);
4674 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4675 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
4676 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
4677 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) {
4678 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4679 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4681 SiS_WaitVBRetrace(SiS_Pr, HwInfo);
4682 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00);
4691 #ifdef SIS315H /* 315 series */
4693 if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) {
4694 if(HwInfo->jChipType < SIS_340) {
4695 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18);
4699 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4700 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4701 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00);
4702 SiS_PanelDelay(SiS_Pr, HwInfo, 0);
4706 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4707 SiS_UnLockCRT2(SiS_Pr,HwInfo);
4709 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
4711 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4712 temp = SiS_GetCH701x(SiS_Pr,0x66);
4714 SiS_Chrontel701xBLOff(SiS_Pr);
4717 if(HwInfo->jChipType != SIS_550) {
4718 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
4721 if(HwInfo->jChipType == SIS_740) {
4722 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4723 if(SiS_IsLCDOrLCDA(SiS_Pr, HwInfo)) {
4724 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
4729 temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E);
4730 if(!(temp1 & 0x80)) {
4731 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
4734 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4736 SiS_Chrontel701xBLOn(SiS_Pr, HwInfo);
4740 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4741 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4742 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
4743 if(HwInfo->jChipType == SIS_550) {
4744 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x40);
4745 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x10);
4748 } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) {
4749 if(HwInfo->jChipType != SIS_740) {
4750 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
4754 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) {
4755 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
4758 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4759 if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) {
4760 SiS_Chrontel701xOn(SiS_Pr,HwInfo);
4762 if( (SiS_IsVAMode(SiS_Pr,HwInfo)) ||
4763 (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) {
4764 SiS_ChrontelDoSomething1(SiS_Pr,HwInfo);
4768 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4769 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) {
4770 if( (SiS_IsVAMode(SiS_Pr,HwInfo)) ||
4771 (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) {
4772 SiS_Chrontel701xBLOn(SiS_Pr, HwInfo);
4773 SiS_ChrontelInitTVVSync(SiS_Pr,HwInfo);
4776 } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4777 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) {
4778 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) {
4779 SiS_PanelDelay(SiS_Pr, HwInfo, 1);
4780 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00);
4785 #endif /* SIS315H */
4793 /*********************************************/
4794 /* SET PART 1 REGISTER GROUP */
4795 /*********************************************/
4797 /* Set CRT2 OFFSET / PITCH */
4799 SiS_SetCRT2Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
4800 USHORT RRTI, PSIS_HW_INFO HwInfo)
4805 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return;
4807 offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI,HwInfo);
4809 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) ||
4810 (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) {
4814 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF));
4815 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8));
4816 temp = (UCHAR)(((offset >> 3) & 0xFF) + 1);
4817 if(offset % 8) temp++;
4818 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp);
4821 /* Set CRT2 sync and PanelLink mode */
4823 SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT RefreshRateTableIndex,
4824 PSIS_HW_INFO HwInfo)
4826 USHORT tempah=0,tempbl,infoflag;
4830 if(SiS_Pr->UseCustomMode) {
4831 infoflag = SiS_Pr->CInfoFlag;
4833 infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4836 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */
4838 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
4840 } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) {
4841 tempah = SiS_Pr->SiS_LCDInfo;
4842 } else tempah = infoflag >> 8;
4845 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4846 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
4847 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
4848 (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
4851 if( (SiS_Pr->SiS_IF_DEF_FSTN) ||
4852 (SiS_Pr->SiS_IF_DEF_DSTN) ||
4853 (SiS_Pr->SiS_IF_DEF_TRUMPION) ||
4854 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) {
4858 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
4859 if(HwInfo->jChipType >= SIS_315H) {
4862 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah);
4863 /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */
4865 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0);
4868 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4871 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
4873 if(HwInfo->jChipType < SIS_315H) {
4875 #ifdef SIS300 /* ---- 300 series --- */
4877 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */
4879 tempah = infoflag >> 8;
4881 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
4882 if(SiS_Pr->SiS_LCDInfo & LCDSync) {
4883 tempah = SiS_Pr->SiS_LCDInfo;
4884 tempbl = (tempah >> 6) & 0x03;
4889 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4891 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4892 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
4893 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl);
4896 } else { /* 630 - 301 */
4898 tempah = infoflag >> 8;
4901 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4902 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4910 #ifdef SIS315H /* ------- 315 series ------ */
4912 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 315 - LVDS */
4915 if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) &&
4916 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) {
4917 tempah = infoflag >> 8;
4918 if(SiS_Pr->SiS_LCDInfo & LCDSync) {
4919 tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6);
4921 } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) &&
4922 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) {
4923 tempah = infoflag >> 8;
4926 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37);
4927 tempbl = (tempah >> 6) & 0x03;
4929 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04;
4933 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4934 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0;
4935 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4936 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
4937 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
4938 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl);
4942 } else { /* 315 - TMDS */
4944 tempah = tempbl = infoflag >> 8;
4945 if(!SiS_Pr->UseCustomMode) {
4947 if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
4948 if(ModeNo <= 0x13) {
4949 tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02));
4952 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4953 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
4954 if(SiS_Pr->SiS_LCDInfo & LCDSync) {
4955 tempah = SiS_Pr->SiS_LCDInfo;
4956 tempbl = (tempah >> 6) & 0x03;
4963 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4964 if(SiS_Pr->SiS_VBType & VB_NoLCD) {
4965 /* Imitate BIOS bug */
4966 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0;
4968 if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
4971 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah);
4973 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4974 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
4975 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
4976 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl);
4982 #endif /* SIS315H */
4987 /* Set CRT2 FIFO on 300/630/730 */
4990 SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo,
4991 PSIS_HW_INFO HwInfo)
4993 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
4995 USHORT modeidindex,refreshratetableindex;
4996 USHORT VCLK=0,MCLK,colorth=0,data2=0;
4997 USHORT tempal, tempah, tempbx, tempcl, tempax;
4998 USHORT CRT1ModeNo,CRT2ModeNo;
4999 USHORT SelectRate_backup;
5001 const UCHAR LatencyFactor[] = {
5002 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */
5003 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */
5004 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */
5005 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */
5006 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */
5007 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */
5008 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */
5009 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */
5011 const UCHAR LatencyFactor730[] = {
5016 137,130,128, /* <-- last entry, data below */
5017 137,130,128, /* to avoid using illegal values */
5029 const UCHAR ThLowB[] = {
5030 81, 4, 72, 6, 88, 8,120,12,
5031 55, 4, 54, 6, 66, 8, 90,12,
5032 42, 4, 45, 6, 55, 8, 75,12
5034 const UCHAR ThTiming[] = {
5035 1, 2, 2, 3, 0, 1, 1, 2
5038 SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate;
5040 if(!SiS_Pr->CRT1UsesCustomMode) {
5042 CRT1ModeNo = SiS_Pr->SiS_CRT1Mode; /* get CRT1 ModeNo */
5043 SiS_SearchModeID(SiS_Pr, &CRT1ModeNo, &modeidindex);
5044 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
5045 SiS_Pr->SiS_SelectCRT2Rate = 0;
5046 refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex, HwInfo);
5048 if(CRT1ModeNo >= 0x13) {
5049 index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK;
5051 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */
5053 colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex); /* Get colordepth */
5055 if(!colorth) colorth++;
5061 VCLK = SiS_Pr->CSRClock_CRT1; /* Get VCLK */
5062 data2 = (SiS_Pr->CModeFlag_CRT1 & ModeTypeMask) - 2;
5063 switch(data2) { /* Get color depth */
5064 case 0 : colorth = 1; break;
5065 case 1 : colorth = 1; break;
5066 case 2 : colorth = 2; break;
5067 case 3 : colorth = 2; break;
5068 case 4 : colorth = 3; break;
5069 case 5 : colorth = 4; break;
5070 default: colorth = 2;
5075 if(CRT1ModeNo >= 0x13) {
5076 if(HwInfo->jChipType == SIS_300) {
5077 index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A);
5079 index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A);
5082 MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */
5084 data2 = (colorth * VCLK) / MCLK;
5086 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
5087 temp = ((temp & 0x00FF) >> 6) << 1;
5088 if(temp == 0) temp = 1;
5092 data2 = temp - data2;
5094 if((28 * 16) % data2) {
5095 data2 = (28 * 16) / data2;
5098 data2 = (28 * 16) / data2;
5101 if(HwInfo->jChipType == SIS_300) {
5103 tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18);
5110 tempcl = ThTiming[tempal];
5111 tempbx = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16);
5113 tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
5118 tempal = ThLowB[tempbx + 1];
5120 tempal += ThLowB[tempbx];
5123 } else if(HwInfo->jChipType == SIS_730) {
5126 SiS_SetRegLong(0xcf8,0x80000050);
5127 eax = SiS_GetRegLong(0xcfc);
5129 eax = pciReadLong(0x00000000, 0x50);
5131 tempal = (USHORT)(eax >> 8);
5136 SiS_SetRegLong(0xcf8,0x800000A0);
5137 eax = SiS_GetRegLong(0xcfc);
5139 eax = pciReadLong(0x00000000, 0xA0);
5141 temp = (USHORT)(eax >> 28);
5145 tempbx = tempal; /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */
5146 tempbx = 0; /* -- do it like the BIOS anyway... */
5154 data = LatencyFactor730[tempbx];
5156 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
5157 if(!(temp & 0x80)) data += 5;
5162 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
5163 if(temp & 0x0080) index += 12;
5166 SiS_SetRegLong(0xcf8,0x800000A0);
5167 eax = SiS_GetRegLong(0xcfc);
5169 /* We use pci functions X offers. We use tag 0, because
5170 * we want to read/write to the host bridge (which is always
5171 * 00:00.0 on 630, 730 and 540), not the VGA device.
5173 eax = pciReadLong(0x00000000, 0xA0);
5175 temp = (USHORT)(eax >> 24);
5176 if(!(temp&0x01)) index += 24;
5179 SiS_SetRegLong(0xcf8,0x80000050);
5180 eax = SiS_GetRegLong(0xcfc);
5182 eax = pciReadLong(0x00000000, 0x50);
5184 temp=(USHORT)(eax >> 24);
5185 if(temp & 0x01) index += 6;
5187 temp = (temp & 0x0F) >> 1;
5190 data = LatencyFactor[index];
5192 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
5193 if(!(temp & 0x80)) data += 5;
5196 data += data2; /* CRT1 Request Period */
5198 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
5199 SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup;
5201 if(!SiS_Pr->UseCustomMode) {
5203 CRT2ModeNo = ModeNo;
5204 SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex);
5206 refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex, HwInfo);
5208 index = SiS_GetVCLK2Ptr(SiS_Pr,CRT2ModeNo,modeidindex,
5209 refreshratetableindex,HwInfo);
5210 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */
5212 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
5213 if(SiS_Pr->SiS_UseROM) {
5214 if(ROMAddr[0x220] & 0x01) {
5215 VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8);
5223 VCLK = SiS_Pr->CSRClock; /* Get VCLK */
5227 colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex); /* Get colordepth */
5229 if(!colorth) colorth++;
5231 data = data * VCLK * colorth;
5232 if(data % (MCLK << 4)) {
5233 data = data / (MCLK << 4);
5236 data = data / (MCLK << 4);
5239 if(data <= 6) data = 6;
5240 if(data > 0x14) data = 0x14;
5242 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x01);
5243 if(HwInfo->jChipType == SIS_300) {
5244 if(data <= 0x0f) temp = (temp & (~0x1F)) | 0x13;
5245 else temp = (temp & (~0x1F)) | 0x16;
5246 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
5247 temp = (temp & (~0x1F)) | 0x13;
5250 if( ( (HwInfo->jChipType == SIS_630) ||
5251 (HwInfo->jChipType == SIS_730) ) &&
5252 (HwInfo->jChipRevision >= 0x30) ) /* 630s or 730(s?) */
5254 temp = (temp & (~0x1F)) | 0x1b;
5256 temp = (temp & (~0x1F)) | 0x16;
5259 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp);
5261 if( (HwInfo->jChipType == SIS_630) &&
5262 (HwInfo->jChipRevision >= 0x30) ) /* 630s, NOT 730 */
5264 if(data > 0x13) data = 0x13;
5266 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data);
5268 } else { /* If mode <= 0x13, we just restore everything */
5270 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
5271 SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup;
5277 /* Set CRT2 FIFO on 315/330 series */
5280 SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
5282 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B);
5283 if( (HwInfo->jChipType == SIS_760) &&
5284 (SiS_Pr->SiS_SysFlags & SF_760LFB) &&
5285 (SiS_Pr->SiS_ModeType == Mode32Bpp) &&
5286 (SiS_Pr->SiS_VGAHDE >= 1280) &&
5287 (SiS_Pr->SiS_VGAVDE >= 1024) ) {
5288 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2f,0x03);
5289 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3b);
5290 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4d,0xc0);
5291 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2f,0x01);
5292 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4d,0xc0);
5293 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x02,0x6e);
5295 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3f,0x04);
5302 SiS_GetVGAHT2(SiS_Private *SiS_Pr)
5304 ULONG tempax,tempbx;
5306 tempbx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX;
5307 tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT;
5308 tempax = (tempax * SiS_Pr->SiS_HT) / tempbx;
5309 return((USHORT)tempax);
5312 /* Set Part 1 / SiS bridge slave mode */
5314 SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex,
5315 PSIS_HW_INFO HwInfo,USHORT RefreshRateTableIndex)
5318 USHORT tempax,tempbx,tempcx,temp;
5319 USHORT resinfo,modeflag,xres=0;
5320 unsigned char p1_7, p1_8;
5322 if(ModeNo <= 0x13) {
5323 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
5324 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
5325 } else if(SiS_Pr->UseCustomMode) {
5326 modeflag = SiS_Pr->CModeFlag;
5328 xres = SiS_Pr->CHDisplay;
5330 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5331 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
5332 xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes;
5335 /* The following is only done if bridge is in slave mode: */
5337 if((HwInfo->jChipType >= SIS_661) && (ModeNo > 0x13)) {
5339 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x31,0x04);
5343 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */
5345 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot;
5347 if(modeflag & Charx8Dot) tempcx = 0x08;
5350 tempax = SiS_Pr->SiS_VGAHDE; /* 0x04 Horizontal Display End */
5351 if(modeflag & HalfDCLK) tempax >>= 1;
5352 tempax = ((tempax / tempcx) - 1) & 0xff;
5356 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,temp);
5358 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
5359 if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
5363 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
5364 if(resinfo == SIS_RI_800x600) temp -= 2;
5366 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */
5368 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */
5371 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr);
5372 if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT;
5373 if(modeflag & HalfDCLK) tempax >>= 1;
5374 tempax = (tempax / tempcx) - 5;
5377 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
5379 if(!(modeflag & HalfDCLK)) {
5381 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
5383 if(ModeNo > 0x13) temp -= 10;
5387 tempcx = (tempcx + tempbx) >> 1;
5388 temp = (tempcx & 0x00FF) + 2;
5389 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
5391 if(!(modeflag & HalfDCLK)) {
5392 if((modeflag & Charx8Dot)) {
5394 if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6;
5395 if(HwInfo->jChipType >= SIS_315H) {
5396 if(SiS_Pr->SiS_VGAHDE == 800) temp += 2;
5401 if(!(modeflag & HalfDCLK)) {
5403 if((SiS_Pr->SiS_LCDResInfo != Panel_1280x960) &&
5404 (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200)) {
5405 if(SiS_Pr->SiS_VGAHDE >= 800) {
5407 if(HwInfo->jChipType < SIS_315H) {
5408 if(SiS_Pr->SiS_ModeType == ModeEGA) {
5409 if(SiS_Pr->SiS_VGAVDE == 1024) {
5411 if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024)
5416 if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) {
5417 if(SiS_Pr->SiS_VGAHDE >= 1280) {
5418 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28;
5430 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
5431 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
5432 if(ModeNo <= 0x01) {
5434 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_8 = 0x61;
5436 } else if(SiS_Pr->SiS_ModeType == ModeText) {
5437 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_7 = 0x54;
5440 } else if(ModeNo <= 0x13) {
5441 if(modeflag & HalfDCLK) {
5442 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
5453 } else if( ((HwInfo->jChipType >= SIS_315H) &&
5454 ((ModeNo == 0x50) || (ModeNo == 0x56) || (ModeNo == 0x53))) ||
5455 ((HwInfo->jChipType < SIS_315H) &&
5456 (resinfo == SIS_RI_320x200 || resinfo == SIS_RI_320x240)) ) {
5457 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
5468 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
5469 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p)) {
5471 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) p1_7 = 0x55;
5473 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
5474 if(!(modeflag & HalfDCLK)) {
5476 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {
5481 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {
5482 if(modeflag & HalfDCLK) p1_7 = 0x30;
5487 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,p1_7); /* 0x07 Horizontal Retrace Start */
5488 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,p1_8); /* 0x08 Horizontal Retrace End */
5490 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */
5492 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0);
5494 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */
5497 tempbx = SiS_Pr->SiS_VGAVDE; /* 0x0E Vertical Display End */
5498 if (tempbx == 357) tempbx = 350;
5499 else if(tempbx == 360) tempbx = 350;
5500 else if(tempbx == 375) tempbx = 350;
5501 else if(tempbx == 405) tempbx = 400;
5502 else if(tempbx == 420) tempbx = 400;
5503 else if(tempbx == 525) tempbx = 480;
5505 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
5506 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
5507 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
5508 if (tempbx == 350) tempbx += 5;
5509 else if(tempbx == 480) tempbx += 5;
5514 temp = tempbx & 0x00FF;
5515 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */
5519 temp = tempbx & 0x00FF;
5521 /* Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */
5523 if(temp == 0xdf) temp = 0xda;
5526 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp);
5529 if(modeflag & DoubleScanMode) temp |= 0x80;
5530 if(HwInfo->jChipType >= SIS_661) {
5531 if(tempbx & 0x0200) temp |= 0x20;
5532 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x0B,0x5F,temp);
5533 if(tempbx & 0x0100) tempcx |= 0x000a;
5534 if(tempbx & 0x0400) tempcx |= 0x1200;
5536 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp);
5537 if(tempbx & 0x0100) tempcx |= 0x0002;
5538 if(tempbx & 0x0400) tempcx |= 0x0600;
5541 if(tempbx & 0x0200) tempcx |= 0x0040;
5543 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */
5545 tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2;
5547 if((ModeNo > 0x13) || (HwInfo->jChipType < SIS_315H)) {
5548 if(resinfo != SIS_RI_1280x1024) {
5549 tempbx += (tempax << 1);
5551 } else if(HwInfo->jChipType >= SIS_315H) {
5552 if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) {
5553 tempbx += (tempax << 1);
5557 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
5560 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
5561 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
5563 if(HwInfo->jChipType >= SIS_315H) {
5564 if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10;
5573 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
5575 if(tempax >= 513) tempbx = 513;
5578 temp = tempbx & 0x00FF;
5579 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* 0x0C Vertical Retrace Start */
5582 temp = tempbx & 0x00FF;
5583 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp);
5585 if(tempbx & 0x0100) tempcx |= 0x0008;
5587 if(tempbx & 0x0200) {
5588 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20);
5592 if(tempbx & 0x0100) tempcx |= 0x0004;
5593 if(tempbx & 0x0200) tempcx |= 0x0080;
5594 if(tempbx & 0x0400) {
5595 if(HwInfo->jChipType >= SIS_661) tempcx |= 0x0800;
5596 else if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800;
5597 else tempcx |= 0x0C00;
5601 temp = tempbx & 0x000F;
5602 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */
5604 if(tempbx & 0x0010) tempcx |= 0x2000;
5606 temp = tempcx & 0x00FF;
5607 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */
5609 temp = (tempcx & 0xFF00) >> 8;
5610 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */
5613 temp = (tempax & 0xFF00) >> 8;
5614 temp = (temp >> 1) & 0x09;
5615 if(!(SiS_Pr->SiS_VBType & VB_SIS301)) temp |= 0x01; /* Always 8 dotclock */
5616 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* 0x16 SR01 */
5618 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */
5620 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */
5623 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
5624 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {
5628 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* 0x1A SR0E */
5630 temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02));
5631 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp);
5635 * This is used for LVDS, LCDA and Chrontel TV output
5636 * 300/LVDS+TV, 300/301B-DH, 315/LVDS+TV, 315/LCDA
5639 SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5640 PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex)
5642 USHORT modeflag,resinfo;
5643 USHORT push2,tempax,tempbx,tempcx,temp;
5644 ULONG tempeax=0,tempebx,tempecx,tempvcfact=0;
5645 BOOLEAN islvds = FALSE, issis = FALSE, chkdclkfirst = FALSE;
5653 if(ModeNo <= 0x13) {
5654 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
5655 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
5657 crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5659 } else if(SiS_Pr->UseCustomMode) {
5660 modeflag = SiS_Pr->CModeFlag;
5666 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5667 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
5669 crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5673 /* is lvds if really LVDS, or 301B-DH with external LVDS transmitter */
5674 if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) {
5678 /* is really sis if sis bridge, but not 301B-DH */
5679 if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
5683 if((HwInfo->jChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) {
5684 if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) {
5685 chkdclkfirst = TRUE;
5690 if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
5692 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10);
5693 } else if(IS_SIS740) {
5695 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04);
5696 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x03);
5697 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
5698 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10);
5702 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04);
5703 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00);
5704 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
5705 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f);
5706 if(SiS_Pr->SiS_VBType & VB_SIS301C) {
5707 if((SiS_Pr->SiS_LCDResInfo == Panel_1024x768) ||
5708 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) {
5709 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x20);
5719 tempax = SiS_Pr->SiS_LCDHDES;
5721 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5722 if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) {
5723 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) &&
5724 (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) {
5731 temp = (tempax & 0x0007);
5732 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* BPLHDESKEW[2:0] */
5733 temp = (tempax >> 3) & 0x00FF;
5734 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* BPLHDESKEW[10:3] */
5736 tempbx = SiS_Pr->SiS_HDE;
5737 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5738 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) ||
5739 (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) {
5742 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5743 tempbx = SiS_Pr->PanelXRes;
5748 if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT;
5751 if(temp & 0x07) temp += 8;
5753 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* BPLHDEE */
5755 tempcx = (SiS_Pr->SiS_HT - tempbx) >> 2;
5757 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5758 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5759 if(SiS_Pr->PanelHRS != 999) tempcx = SiS_Pr->PanelHRS;
5764 if(tempcx >= SiS_Pr->SiS_HT) tempcx -= SiS_Pr->SiS_HT;
5766 temp = (tempcx >> 3) & 0x00FF;
5767 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5768 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
5769 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
5773 case 0x0d: temp = 0x56; break;
5774 case 0x10: temp = 0x60; break;
5775 case 0x13: temp = 0x5f; break;
5785 case 0x5e: temp = 0x54; break;
5790 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* BPLHRS */
5792 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5794 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5796 if(SiS_Pr->PanelHRE != 999) {
5797 temp = tempcx + SiS_Pr->PanelHRE;
5798 if(temp >= SiS_Pr->SiS_HT) temp -= SiS_Pr->SiS_HT;
5807 temp |= ((tempcx & 0x07) << 5);
5809 if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20; /* WRONG? BIOS loads cl, not ah */
5811 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* BPLHRE */
5815 tempax = SiS_Pr->SiS_VGAVDE;
5816 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5817 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5818 tempax = SiS_Pr->PanelYRes;
5822 tempbx = SiS_Pr->SiS_LCDVDES + tempax;
5823 if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT;
5827 tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE;
5828 if(HwInfo->jChipType < SIS_315H) {
5829 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5830 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5831 tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->PanelYRes;
5835 if(islvds) tempcx >>= 1;
5838 if( (SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
5839 (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) &&
5840 (SiS_Pr->PanelVRS != 999) ) {
5841 tempcx = SiS_Pr->PanelVRS;
5846 if(HwInfo->jChipType < SIS_315H) tempbx++;
5847 else if(issis) tempbx++;
5850 if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; /* BPLVRS */
5852 temp = tempbx & 0x00FF;
5853 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
5854 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
5855 if(ModeNo == 0x10) temp = 0xa9;
5858 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp);
5863 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5864 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5865 if(SiS_Pr->PanelVRE != 999) tempcx = SiS_Pr->PanelVRE;
5870 temp = tempcx & 0x000F;
5871 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* BPLVRE */
5873 temp = ((tempbx >> 8) & 0x07) << 3;
5874 if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) {
5875 if(SiS_Pr->SiS_HDE != 640) {
5876 if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40;
5878 } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40;
5879 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40;
5881 if((HwInfo->jChipType >= SIS_315H) ||
5882 (HwInfo->jChipRevision >= 0x30)) {
5884 if((SiS_Pr->SiS_IF_DEF_CH70xx == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
5885 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x03) temp |= 0x80;
5887 /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit mutliplexed) via VGA2 */
5888 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
5889 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
5890 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80;
5892 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80;
5896 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,tempbx,temp);
5898 tempbx = push2; /* BPLVDEE */
5900 tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */
5902 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5903 switch(SiS_Pr->SiS_LCDResInfo) {
5905 tempbx = SiS_Pr->SiS_VGAVDE - 1;
5906 tempcx = SiS_Pr->SiS_VGAVDE;
5909 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
5910 if(resinfo == SIS_RI_800x600) tempcx++;
5913 case Panel_1024x600:
5914 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
5915 if(resinfo == SIS_RI_1024x600) tempcx++;
5916 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
5917 if(resinfo == SIS_RI_800x600) tempcx++;
5921 case Panel_1024x768:
5922 if(HwInfo->jChipType < SIS_315H) {
5923 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
5924 if(resinfo == SIS_RI_1024x768) tempcx++;
5931 temp = ((tempbx >> 8) & 0x07) << 3;
5932 temp = temp | ((tempcx >> 8) & 0x07);
5933 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp);
5934 /* if(SiS_Pr->SiS_IF_DEF_FSTN) tempbx++; */
5935 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,tempbx);
5936 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,tempcx);
5938 /* Vertical scaling */
5940 if(HwInfo->jChipType < SIS_315H) {
5942 #ifdef SIS300 /* 300 series */
5943 tempeax = SiS_Pr->SiS_VGAVDE << 6;
5944 temp = (tempeax % (ULONG)SiS_Pr->SiS_VDE);
5945 tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE;
5948 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempeax = 0x3F;
5950 temp = (USHORT)(tempeax & 0x00FF);
5951 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */
5957 #ifdef SIS315H /* 315 series */
5958 tempeax = SiS_Pr->SiS_VGAVDE << 18;
5959 tempebx = SiS_Pr->SiS_VDE;
5960 temp = (tempeax % tempebx);
5961 tempeax = tempeax / tempebx;
5963 tempvcfact = tempeax;
5965 temp = (USHORT)(tempeax & 0x00FF);
5966 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp);
5967 temp = (USHORT)((tempeax & 0x00FF00) >> 8);
5968 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp);
5969 temp = (USHORT)((tempeax & 0x00030000) >> 16);
5970 if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04;
5971 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp);
5973 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) {
5974 temp = (USHORT)(tempeax & 0x00FF);
5975 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3c,temp);
5976 temp = (USHORT)((tempeax & 0x00FF00) >> 8);
5977 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3b,temp);
5978 temp = (USHORT)(((tempeax & 0x00030000) >> 16) << 6);
5979 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0x3f,temp);
5981 if(SiS_Pr->SiS_VDE != SiS_Pr->SiS_VGAVDE) temp |= 0x08;
5982 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x30,0xf3,temp);
5988 /* Horizontal scaling */
5990 tempeax = SiS_Pr->SiS_VGAHDE; /* 1f = ( (VGAHDE * 65536) / ( (VGAHDE * 65536) / HDE ) ) - 1*/
5992 if(modeflag & HalfDCLK) tempeax >>= 1;
5994 tempebx = tempeax << 16;
5995 if(SiS_Pr->SiS_HDE == tempeax) {
5998 tempecx = tempebx / SiS_Pr->SiS_HDE;
5999 if(HwInfo->jChipType >= SIS_315H) {
6000 if(tempebx % SiS_Pr->SiS_HDE) tempecx++;
6004 if(HwInfo->jChipType >= SIS_315H) {
6005 tempeax = (tempebx / tempecx) - 1;
6007 tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1;
6009 tempecx = (tempecx << 16) | (tempeax & 0xFFFF);
6010 temp = (USHORT)(tempecx & 0x00FF);
6011 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp);
6013 if(HwInfo->jChipType >= SIS_315H) {
6014 tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact;
6015 tempbx = (USHORT)(tempeax & 0xFFFF);
6017 tempeax = SiS_Pr->SiS_VGAVDE << 6;
6018 tempbx = tempvcfact & 0x3f;
6019 if(tempbx == 0) tempbx = 64;
6021 tempbx = (USHORT)(tempeax & 0xFFFF);
6023 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tempbx--;
6024 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) {
6025 if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) tempbx = 1;
6026 else if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) tempbx = 1;
6029 temp = ((tempbx >> 8) & 0x07) << 3;
6030 temp = temp | ((tempecx >> 8) & 0x07);
6031 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp);
6032 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,tempbx);
6034 tempecx >>= 16; /* BPLHCFACT */
6036 if(modeflag & HalfDCLK) tempecx >>= 1;
6038 temp = (USHORT)((tempecx & 0xFF00) >> 8);
6039 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp);
6040 temp = (USHORT)(tempecx & 0x00FF);
6041 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp);
6044 if(HwInfo->jChipType >= SIS_315H) {
6045 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
6046 if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)) {
6047 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20);
6051 if(HwInfo->jChipType == SIS_740) {
6052 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03);
6054 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x23);
6062 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
6064 UCHAR TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 };
6065 UCHAR TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 };
6066 UCHAR TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 };
6068 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xbf);
6069 for(i=0; i<5; i++) {
6070 SiS_SetTrumpionBlock(SiS_Pr, &SiS300_TrumpionData[crt2crtc][0]);
6072 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
6073 if(ModeNo == 0x13) {
6074 for(i=0; i<4; i++) {
6075 SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode13[0]);
6077 } else if(ModeNo == 0x10) {
6078 for(i=0; i<4; i++) {
6079 SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode10_1[0]);
6080 SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode10_2[0]);
6084 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40);
6089 if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) {
6090 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x25,0x00);
6091 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x26,0x00);
6092 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x27,0x00);
6093 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x28,0x87);
6094 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x29,0x5A);
6095 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2A,0x4B);
6096 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x07,0x03);
6097 tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */
6098 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 ||
6099 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1;
6101 temp = tempax & 0x00FF;
6102 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,temp);
6103 temp = ((tempax & 0xFF00) >> 8) << 3;
6104 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp);
6105 tempax += 32; /* Blpe=lBlps+32 */
6106 temp = tempax & 0x00FF;
6107 if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0;
6108 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,temp);
6109 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml=0 */
6110 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00);
6112 tempax = SiS_Pr->SiS_VDE;
6113 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 ||
6114 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1;
6116 temp = tempax & 0x00FF;
6117 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,temp);
6118 temp = ((tempax & 0xFF00) >> 8) << 3;
6119 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp);
6121 tempeax = SiS_Pr->SiS_HDE;
6122 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 ||
6123 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempeax >>= 1;
6124 tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */
6126 temp = (USHORT)(tempeax % tempebx);
6127 tempeax = tempeax / tempebx;
6129 temp = (USHORT)(tempeax & 0x003F);
6130 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp);
6131 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */
6132 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3E,0x00);
6133 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3D,0x10);
6134 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00);
6136 tempax = SiS_Pr->SiS_HDE;
6137 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 ||
6138 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1;
6139 tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */
6141 temp = tempax & 0x00FF;
6142 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp);
6143 temp = ((tempax & 0xFF00) >> 8) << 3;
6144 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp);
6146 tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */
6147 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 ||
6148 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1;
6149 tempeax = (tempax * pushcx);
6150 tempebx = 0x00100000 + tempeax;
6151 temp = (USHORT)tempebx & 0x000000FF;
6152 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,temp);
6153 temp = (USHORT)((tempebx & 0x0000FF00) >> 8);
6154 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,temp);
6155 temp = (USHORT)((tempebx & 0x00FF0000) >> 16);
6156 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp);
6157 temp = (USHORT)(((tempebx & 0x01000000) >> 24) << 7);
6158 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp);
6160 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03);
6161 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0x50);
6162 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,0x00);
6163 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x01);
6164 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0x38);
6166 if(SiS_Pr->SiS_IF_DEF_FSTN) {
6167 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2b,0x02);
6168 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2c,0x00);
6169 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x00);
6170 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,0x0c);
6171 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,0x00);
6172 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,0x00);
6173 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,0x80);
6174 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,0xA0);
6175 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3a,0x00);
6176 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3b,0xf0);
6177 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3c,0x00);
6178 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3d,0x10);
6179 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3e,0x00);
6180 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3f,0x00);
6181 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,0x10);
6182 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,0x25);
6183 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,0x80);
6184 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,0x14);
6185 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x44,0x03);
6186 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,0x0a);
6189 #endif /* SIS315H */
6194 SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6195 PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex)
6197 #if defined(SIS300) || defined(SIS315H)
6198 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
6200 USHORT temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0;
6201 USHORT pushbx=0, CRT1Index=0, modeflag, resinfo=0;
6206 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
6207 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex);
6211 if(ModeNo <= 0x13) {
6212 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
6213 } else if(SiS_Pr->UseCustomMode) {
6214 modeflag = SiS_Pr->CModeFlag;
6216 CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
6217 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
6218 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6221 SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
6223 if( ! ((HwInfo->jChipType >= SIS_315H) &&
6224 (SiS_Pr->SiS_IF_DEF_LVDS == 1) &&
6225 (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) {
6227 if(HwInfo->jChipType < SIS_315H ) {
6229 SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo, HwInfo);
6233 SiS_SetCRT2FIFO_310(SiS_Pr, HwInfo);
6237 /* 1. Horizontal setup */
6239 if(HwInfo->jChipType < SIS_315H ) {
6241 #ifdef SIS300 /* ------------- 300 series --------------*/
6243 temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
6244 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */
6246 temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4;
6247 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */
6249 temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
6250 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */
6252 pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA2HRS 0x0B,0x0C */
6253 tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2;
6254 tempbx = pushbx + tempcx;
6264 #ifdef SIS315H /* ------------------- 315/330 series --------------- */
6266 tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */
6267 if(modeflag & HalfDCLK) {
6268 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6271 tempax = SiS_Pr->SiS_VGAHDE >> 1;
6272 tempcx = SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE + tempax;
6273 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
6274 tempcx = SiS_Pr->SiS_HT - tempax;
6279 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,tempcx); /* CRT2 Horizontal Total */
6280 temp = (tempcx >> 4) & 0xF0;
6281 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp); /* CRT2 Horizontal Total Overflow [7:4] */
6283 tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HDEE 0x0A,0x0C */
6284 tempbx = SiS_Pr->SiS_VGAHDE;
6287 if(modeflag & HalfDCLK) {
6293 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,tempbx); /* CRT2 Horizontal Display Enable End */
6302 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6303 if(HwInfo->jChipType >= SIS_661) {
6304 if((SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) ||
6305 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) {
6306 if(resinfo == SIS_RI_1280x1024) {
6307 tempcx = (tempcx & 0xff00) | 0x30;
6308 } else if(resinfo == SIS_RI_1600x1200) {
6309 tempcx = (tempcx & 0xff00) | 0xff;
6315 #endif /* SIS315H */
6317 } /* 315/330 series */
6319 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6321 if(SiS_Pr->UseCustomMode) {
6322 tempbx = SiS_Pr->CHSyncStart + bridgeadd;
6323 tempcx = SiS_Pr->CHSyncEnd + bridgeadd;
6324 tempax = SiS_Pr->SiS_VGAHT;
6325 if(modeflag & HalfDCLK) tempax >>= 1;
6327 if(tempcx > tempax) tempcx = tempax;
6330 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
6331 unsigned char cr4, cr14, cr5, cr15;
6332 if(SiS_Pr->UseCustomMode) {
6333 cr4 = SiS_Pr->CCRT1CRTC[4];
6334 cr14 = SiS_Pr->CCRT1CRTC[14];
6335 cr5 = SiS_Pr->CCRT1CRTC[5];
6336 cr15 = SiS_Pr->CCRT1CRTC[15];
6338 cr4 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4];
6339 cr14 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14];
6340 cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5];
6341 cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15];
6343 tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */
6344 tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */
6346 tempcx |= (tempbx & 0xFF00);
6347 tempbx += bridgeadd;
6348 tempcx += bridgeadd;
6349 tempax = SiS_Pr->SiS_VGAHT;
6350 if(modeflag & HalfDCLK) tempax >>= 1;
6352 if(tempcx > tempax) tempcx = tempax;
6355 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) {
6357 tempcx = 1044; /* HWCursor bug! */
6362 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,tempbx); /* CRT2 Horizontal Retrace Start */
6364 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,tempcx); /* CRT2 Horizontal Retrace End */
6366 temp = ((tempbx >> 8) & 0x0F) | ((pushbx >> 4) & 0xF0);
6367 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* Overflow */
6369 /* 2. Vertical setup */
6371 tempcx = SiS_Pr->SiS_VGAVT - 1;
6372 temp = tempcx & 0x00FF;
6374 if(HwInfo->jChipType < SIS_661) {
6375 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
6376 if(HwInfo->jChipType < SIS_315H) {
6377 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
6378 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) {
6385 } else if(HwInfo->jChipType >= SIS_315H) {
6389 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp); /* CRT2 Vertical Total */
6391 tempbx = SiS_Pr->SiS_VGAVDE - 1;
6392 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,tempbx); /* CRT2 Vertical Display Enable End */
6394 temp = ((tempbx >> 5) & 0x38) | ((tempcx >> 8) & 0x07);
6395 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow */
6397 if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) {
6404 if(tempcx < 4) tempcx = 4;
6409 tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
6410 tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
6413 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6414 if(SiS_Pr->UseCustomMode) {
6415 tempbx = SiS_Pr->CVSyncStart;
6416 tempcx = SiS_Pr->CVSyncEnd;
6418 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
6419 unsigned char cr8, cr7, cr13;
6420 if(SiS_Pr->UseCustomMode) {
6421 cr8 = SiS_Pr->CCRT1CRTC[8];
6422 cr7 = SiS_Pr->CCRT1CRTC[7];
6423 cr13 = SiS_Pr->CCRT1CRTC[13];
6424 tempcx = SiS_Pr->CCRT1CRTC[9];
6426 cr8 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8];
6427 cr7 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7];
6428 cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13];
6429 tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9];
6432 if(cr7 & 0x04) tempbx |= 0x0100;
6433 if(cr7 & 0x80) tempbx |= 0x0200;
6434 if(cr13 & 0x08) tempbx |= 0x0400;
6437 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,tempbx); /* CRT2 Vertical Retrace Start */
6439 temp = ((tempbx >> 4) & 0x70) | (tempcx & 0x0F);
6440 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,temp); /* CRT2 Vert. Retrace End; Overflow */
6442 /* 3. Panel delay compensation */
6444 if(HwInfo->jChipType < SIS_315H) {
6446 #ifdef SIS300 /* ---------- 300 series -------------- */
6448 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6450 if(HwInfo->jChipType == SIS_300) {
6452 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) temp = 0x2c;
6453 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20;
6455 if(SiS_Pr->SiS_VBType & VB_SIS301) {
6456 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20;
6458 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x960) temp = 0x24;
6459 if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) temp = 0x2c;
6460 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08;
6461 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
6462 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c;
6465 if(SiS_Pr->SiS_UseROM) {
6466 if(ROMAddr[0x220] & 0x80) {
6467 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision)
6468 temp = ROMAddr[0x221];
6469 else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision)
6470 temp = ROMAddr[0x222];
6471 else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)
6472 temp = ROMAddr[0x223];
6474 temp = ROMAddr[0x224];
6478 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
6479 if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c;
6484 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
6485 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) temp = 0x04;
6487 if(SiS_Pr->SiS_UseROM) {
6488 if(ROMAddr[0x220] & 0x80) {
6489 temp = ROMAddr[0x220] & 0x3c;
6492 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
6493 if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c;
6497 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */
6503 #ifdef SIS315H /* --------------- 315/330 series ---------------*/
6505 if(HwInfo->jChipType < SIS_661) {
6507 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
6509 if(HwInfo->jChipType == SIS_740) temp = 0x03;
6512 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a;
6514 if(HwInfo->jChipType == SIS_650) {
6515 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
6516 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F;
6520 if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) {
6523 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
6524 if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0;
6528 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp); /* Panel Link Delay Compensation */
6534 if(modeflag & DoubleScanMode) tempax |= 0x80;
6535 if(modeflag & HalfDCLK) tempax |= 0x40;
6536 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax);
6538 #endif /* SIS315H */
6544 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6545 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
6546 /* For 301BDH with LCD, we set up the Panel Link */
6547 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex);
6548 } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
6549 SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex);
6552 if(HwInfo->jChipType < SIS_315H) {
6553 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex);
6555 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
6556 if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
6557 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex);
6560 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex);
6566 /*********************************************/
6567 /* SET PART 2 REGISTER GROUP */
6568 /*********************************************/
6572 SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo)
6574 const UCHAR *tableptr = NULL;
6577 a = SiS_Pr->SiS_VGAHDE;
6578 b = SiS_Pr->SiS_HDE;
6580 a = SiS_Pr->SiS_VGAVDE;
6581 b = SiS_Pr->SiS_VDE;
6585 tableptr = SiS_Part2CLVX_1;
6587 tableptr = SiS_Part2CLVX_2;
6589 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
6590 tableptr = SiS_Part2CLVX_4;
6592 tableptr = SiS_Part2CLVX_3;
6594 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
6595 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) tableptr = SiS_Part2CLVX_3;
6596 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tableptr = SiS_Part2CLVX_3;
6597 else tableptr = SiS_Part2CLVX_5;
6598 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
6599 tableptr = SiS_Part2CLVX_6;
6602 if((tableptr[p] | tableptr[p+1] << 8) == a) break;
6604 } while((tableptr[p] | tableptr[p+1] << 8) != 0xffff);
6605 if((tableptr[p] | tableptr[p+1] << 8) == 0xffff) p -= 0x42;
6608 return((UCHAR *)&tableptr[p]);
6612 SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6613 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
6619 if(!(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV))) return;
6621 tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0, HwInfo);
6622 for(i = 0x80, j = 0; i <= 0xbf; i++, j++) {
6623 SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]);
6625 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
6626 tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1, HwInfo);
6627 for(i = 0xc0, j = 0; i <= 0xff; i++, j++) {
6628 SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]);
6632 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp |= 0x04;
6633 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xeb,temp);
6637 SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
6638 USHORT RefreshRateTableIndex,USHORT *CRT2Index,
6639 USHORT *ResIndex,PSIS_HW_INFO HwInfo)
6642 if(HwInfo->jChipType < SIS_315H) return FALSE;
6645 (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6647 (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6649 (*ResIndex) &= 0x3f;
6652 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
6653 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
6658 if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) {
6659 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
6660 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) (*CRT2Index) = 206;
6663 return(((*CRT2Index) != 0));
6669 SiS_Group2LCDSpecial(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT crt2crtc)
6672 const UCHAR atable[] = {
6673 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02,
6674 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02
6677 if(!SiS_Pr->UseCustomMode) {
6678 if( ( ( (HwInfo->jChipType == SIS_630) ||
6679 (HwInfo->jChipType == SIS_730) ) &&
6680 (HwInfo->jChipRevision > 2) ) &&
6681 (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) &&
6682 (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) &&
6683 (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) {
6684 if(ModeNo == 0x13) {
6685 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9);
6686 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC);
6687 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6);
6689 if((crt2crtc & 0x3F) == 4) {
6690 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B);
6691 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13);
6692 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5);
6693 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08);
6694 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2);
6699 if(HwInfo->jChipType < SIS_315H) {
6700 if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) {
6703 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
6704 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
6710 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff);
6713 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
6714 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
6716 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28);
6720 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18);
6721 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]);
6727 /* For ECS A907. Highly preliminary. */
6729 SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
6730 USHORT ModeIdIndex, USHORT RefreshRateTableIndex,
6733 USHORT crt2crtc, resindex;
6735 const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL;
6737 if(HwInfo->jChipType != SIS_300) return;
6738 if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return;
6739 if(SiS_Pr->UseCustomMode) return;
6741 if(ModeNo <= 0x13) {
6742 crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6744 crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6747 resindex = crt2crtc & 0x3F;
6748 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1;
6749 else CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2;
6751 /* The BIOS code (1.16.51,56) is obviously a fragment! */
6753 CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1;
6757 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]);
6758 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]);
6759 for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) {
6760 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
6762 for(j = 0x1c; j <= 0x1d; i++, j++ ) {
6763 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
6765 for(j = 0x1f; j <= 0x21; i++, j++ ) {
6766 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
6768 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]);
6769 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]);
6774 SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo)
6776 if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return;
6777 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) return;
6778 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) return;
6780 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
6781 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) {
6782 const UCHAR specialtv[] = {
6783 0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53,
6784 0x13,0x40,0x34,0xf4,0x63,0xbb,0xcc,0x7a,
6785 0x58,0xe4,0x73,0xda,0x13
6788 for(i = 0x1c, j = 0; i <= 0x30; i++, j++) {
6789 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,specialtv[j]);
6791 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,0x72);
6792 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750)) {
6793 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
6794 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x14);
6795 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1b);
6797 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x14); /* 15 */
6798 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1a); /* 1b */
6803 if((ModeNo == 0x38) || (ModeNo == 0x4a) || (ModeNo == 0x64) ||
6804 (ModeNo == 0x52) || (ModeNo == 0x58) || (ModeNo == 0x5c)) {
6805 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); /* 21 */
6806 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); /* 5a */
6808 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1a); /* 21 */
6809 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x53); /* 5a */
6815 SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo)
6819 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
6820 if(SiS_Pr->SiS_VGAVDE == 525) {
6822 if(SiS_Pr->SiS_ModeType <= ModeVGA) {
6824 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp += 2;
6826 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp);
6827 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3);
6828 } else if(SiS_Pr->SiS_VGAVDE == 420) {
6830 if(SiS_Pr->SiS_ModeType <= ModeVGA) {
6832 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++;
6834 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp);
6838 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
6839 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) {
6840 if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
6841 SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x1a,0x03);
6842 /* Not always for LV, see SetGrp2 */
6845 if(ModeNo <= 0x13) temp = 3;
6846 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0b,temp);
6849 /* 651+301C, for 1280x768 - do I really need that? */
6850 if((SiS_Pr->SiS_PanelXRes == 1280) && (SiS_Pr->SiS_PanelYRes == 768)) {
6851 if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) {
6852 if(((SiS_Pr->SiS_HDE == 640) && (SiS_Pr->SiS_VDE == 480)) ||
6853 ((SiS_Pr->SiS_HDE == 320) && (SiS_Pr->SiS_VDE == 240))) {
6854 SiS_SetReg(SiS_Part2Port,0x01,0x2b);
6855 SiS_SetReg(SiS_Part2Port,0x02,0x13);
6856 SiS_SetReg(SiS_Part2Port,0x04,0xe5);
6857 SiS_SetReg(SiS_Part2Port,0x05,0x08);
6858 SiS_SetReg(SiS_Part2Port,0x06,0xe2);
6859 SiS_SetReg(SiS_Part2Port,0x1c,0x21);
6860 SiS_SetReg(SiS_Part2Port,0x1d,0x45);
6861 SiS_SetReg(SiS_Part2Port,0x1f,0x0b);
6862 SiS_SetReg(SiS_Part2Port,0x20,0x00);
6863 SiS_SetReg(SiS_Part2Port,0x21,0xa9);
6864 SiS_SetReg(SiS_Part2Port,0x23,0x0b);
6865 SiS_SetReg(SiS_Part2Port,0x25,0x04);
6874 SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT RefreshRateTableIndex,
6875 PSIS_HW_INFO HwInfo)
6877 USHORT i, j, tempax, tempbx, tempcx, tempch, tempcl, temp;
6878 USHORT push2, modeflag, crt2crtc, bridgeoffset;
6880 const UCHAR *PhasePoint;
6881 const UCHAR *TimingPoint;
6883 USHORT resindex, CRT2Index;
6884 const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL;
6886 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
6889 if(ModeNo <= 0x13) {
6890 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
6891 crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
6892 } else if(SiS_Pr->UseCustomMode) {
6893 modeflag = SiS_Pr->CModeFlag;
6896 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6897 crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
6901 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToAVIDEO)) temp |= 0x08;
6902 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) temp |= 0x04;
6903 if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) temp |= 0x02;
6904 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp |= 0x01;
6906 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) temp |= 0x10;
6908 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp);
6910 PhasePoint = SiS_Pr->SiS_PALPhase;
6911 TimingPoint = SiS_Pr->SiS_PALTiming;
6913 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
6915 TimingPoint = SiS_Pr->SiS_HiTVExtTiming;
6916 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
6917 TimingPoint = SiS_Pr->SiS_HiTVSt2Timing;
6918 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
6919 TimingPoint = SiS_Pr->SiS_HiTVSt1Timing;
6921 if(!(modeflag & Charx8Dot)) TimingPoint = SiS_Pr->SiS_HiTVTextTiming;
6926 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
6928 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) TimingPoint = &SiS_YPbPrTable[2][0];
6929 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) TimingPoint = &SiS_YPbPrTable[1][0];
6930 else TimingPoint = &SiS_YPbPrTable[0][0];
6932 PhasePoint = SiS_Pr->SiS_NTSCPhase;
6934 } else if(SiS_Pr->SiS_TVMode & TVSetPAL) {
6936 if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
6937 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6938 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6939 PhasePoint = SiS_Pr->SiS_PALPhase2;
6944 TimingPoint = SiS_Pr->SiS_NTSCTiming;
6945 PhasePoint = SiS_Pr->SiS_NTSCPhase;
6946 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {
6947 PhasePoint = SiS_Pr->SiS_PALPhase;
6950 if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
6951 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6952 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6953 PhasePoint = SiS_Pr->SiS_NTSCPhase2;
6954 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {
6955 PhasePoint = SiS_Pr->SiS_PALPhase2;
6961 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
6962 PhasePoint = SiS_Pr->SiS_PALMPhase;
6963 if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
6964 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6965 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6966 PhasePoint = SiS_Pr->SiS_PALMPhase2;
6970 if(SiS_Pr->SiS_TVMode & TVSetPALN) {
6971 PhasePoint = SiS_Pr->SiS_PALNPhase;
6972 if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
6973 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6974 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6975 PhasePoint = SiS_Pr->SiS_PALNPhase2;
6979 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) {
6980 PhasePoint = SiS_Pr->SiS_SpecialPhase;
6981 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
6982 PhasePoint = SiS_Pr->SiS_SpecialPhaseM;
6983 } else if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {
6984 PhasePoint = SiS_Pr->SiS_SpecialPhaseJ;
6988 for(i=0x31, j=0; i<=0x34; i++, j++) {
6989 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,PhasePoint[j]);
6992 for(i=0x01, j=0; i<=0x2D; i++, j++) {
6993 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
6995 for(i=0x39; i<=0x45; i++, j++) {
6996 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
6999 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
7000 if(SiS_Pr->SiS_ModeType != ModeText) {
7001 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F);
7005 SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x0A,SiS_Pr->SiS_NewFlickerMode);
7007 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x35,SiS_Pr->SiS_RY1COE);
7008 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x36,SiS_Pr->SiS_RY2COE);
7009 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE);
7010 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE);
7012 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950;
7013 else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520;
7014 else tempax = 440; /* NTSC, YPbPr 525, 750 */
7016 if( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) && (SiS_Pr->SiS_VDE <= tempax) ) ||
7017 ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) &&
7018 ((SiS_Pr->SiS_VGAHDE == 1024) || (SiS_Pr->SiS_VDE <= tempax)) ) ) {
7020 tempax -= SiS_Pr->SiS_VDE;
7024 temp = tempax + (USHORT)TimingPoint[0];
7025 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp);
7027 temp = tempax + (USHORT)TimingPoint[1];
7028 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp);
7030 if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) {
7031 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
7032 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); /* 19 */
7033 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); /* 52 */
7035 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17);
7036 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1d);
7042 tempcx = SiS_Pr->SiS_HT;
7043 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1;
7045 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx--;
7046 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,tempcx);
7047 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,((tempcx >> 8) & 0x0f));
7049 tempcx = SiS_Pr->SiS_HT >> 1;
7050 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1;
7052 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4;
7053 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,((tempcx << 4) & 0xf0));
7055 tempbx = TimingPoint[j] | (TimingPoint[j+1] << 8);
7057 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x24,tempbx);
7058 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0F,((tempbx >> 4) & 0xf0));
7061 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
7065 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,((tempbx << 4) & 0xf0));
7068 tempcx += (TimingPoint[j] | (TimingPoint[j+1] << 8));
7069 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x27,tempcx);
7070 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x28,0x0F,((tempcx >> 4) & 0xf0));
7073 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4;
7074 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,((tempcx << 4) & 0xf0));
7076 tempcx = SiS_Pr->SiS_HT >> 1;
7077 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1;
7079 tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8));
7080 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,((tempcx << 4) & 0xf0));
7083 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
7084 tempcx = SiS_GetVGAHT2(SiS_Pr) - 1;
7086 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2E,tempcx);
7088 tempbx = SiS_Pr->SiS_VDE;
7089 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
7090 if(SiS_Pr->SiS_VGAVDE == 360) tempbx = 746;
7091 if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 746;
7092 if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 853;
7093 } else if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) &&
7094 (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) {
7096 if(HwInfo->jChipType >= SIS_315H) {
7097 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
7098 if((ModeNo <= 0x13) && (crt2crtc == 1)) tempbx++;
7099 } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
7100 if(SiS_Pr->SiS_ModeType <= ModeVGA) {
7101 if(crt2crtc == 4) tempbx++;
7105 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
7106 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
7107 if((ModeNo == 0x2f) || (ModeNo == 0x5d) || (ModeNo == 0x5e)) tempbx++;
7109 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
7110 if(ModeNo == 0x03) tempbx++; /* From 1.10.7w - doesn't make sense */
7115 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2F,tempbx);
7117 temp = (tempcx >> 8) & 0x0F;
7118 temp |= ((tempbx >> 2) & 0xC0);
7119 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) {
7121 if(SiS_Pr->SiS_VBInfo & SetCRT2ToAVIDEO) temp |= 0x20;
7123 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp);
7125 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) {
7126 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xdf,((tempbx & 0x0400) >> 5));
7131 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
7132 for(i=0x01, j=0; i<=0x2D; i++, j++) {
7133 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
7135 for(i=0x39; i<=0x45; i++, j++) {
7136 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
7141 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
7142 tempbx = SiS_Pr->SiS_VDE;
7143 if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) &&
7144 (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) ) {
7148 temp = ((tempbx >> 3) & 0x60) | 0x18;
7149 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp);
7150 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,tempbx);
7152 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) {
7153 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xbf,((tempbx & 0x0400) >> 4));
7158 if(!(modeflag & HalfDCLK)) {
7159 if(SiS_Pr->SiS_VGAHDE >= SiS_Pr->SiS_HDE) {
7165 tempch = tempcl = 0x01;
7166 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
7167 if(SiS_Pr->SiS_VGAHDE >= 1024) {
7168 if((!(modeflag & HalfDCLK)) || (HwInfo->jChipType < SIS_315H)) {
7171 if(SiS_Pr->SiS_VGAHDE >= 1280) {
7179 if(!(tempbx & 0x20)) {
7180 if(modeflag & HalfDCLK) tempcl <<= 1;
7181 longtemp = ((SiS_Pr->SiS_VGAHDE * tempch) / tempcl) << 13;
7182 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) longtemp <<= 3;
7183 tempax = longtemp / SiS_Pr->SiS_HDE;
7184 if(longtemp % SiS_Pr->SiS_HDE) tempax++;
7185 tempbx |= ((tempax >> 8) & 0x1F);
7186 tempcx = tempax >> 13;
7189 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax);
7190 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,tempbx);
7192 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
7195 if(tempbx & 0x20) tempcx = 0;
7196 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xF8,tempcx);
7198 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
7205 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4B,tempbx);
7206 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4C,tempcx);
7207 temp = (tempcx & 0x0300) >> 6;
7208 temp |= ((tempbx >> 8) & 0x03);
7209 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
7211 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp |= 0x20;
7212 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) temp |= 0x40;
7214 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4D,temp);
7216 temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43);
7217 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,(temp - 3));
7219 SiS_SetTVSpecial(SiS_Pr, ModeNo);
7221 if(SiS_Pr->SiS_VBType & VB_SIS301C) {
7223 if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8;
7224 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xf7,temp);
7229 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
7230 if(!(SiS_Pr->SiS_TVMode & TVSetNTSC1024)) {
7231 temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01);
7232 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,(temp - 1));
7234 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF);
7237 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
7238 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
7239 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,0x00);
7243 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) return;
7245 /* From here: Part2 LCD setup */
7247 tempbx = SiS_Pr->SiS_HDE;
7248 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1;
7249 tempbx--; /* RHACTE = HDE - 1 */
7250 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,tempbx);
7251 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,((tempbx >> 4) & 0xf0));
7254 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
7255 if(SiS_Pr->SiS_ModeType == ModeEGA) {
7256 if(SiS_Pr->SiS_VGAHDE >= 1024) {
7258 if(HwInfo->jChipType >= SIS_315H) {
7259 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
7266 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,temp);
7268 tempbx = SiS_Pr->SiS_VDE - 1;
7269 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x03,tempbx);
7270 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,((tempbx >> 8) & 0x07));
7272 tempcx = SiS_Pr->SiS_VT - 1;
7273 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x19,tempcx);
7274 temp = (tempcx >> 3) & 0xE0;
7275 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
7276 /* Enable dithering; only do this for 32bpp mode */
7277 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {
7281 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1A,0x0f,temp);
7283 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x09,0xF0);
7284 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x0A,0xF0);
7286 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB);
7287 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF);
7290 if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
7291 &CRT2Index, &resindex, HwInfo)) {
7293 case 200: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break;
7294 case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3; break;
7295 default: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break;
7298 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]);
7299 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]);
7300 for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) {
7301 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
7303 for(j = 0x1c; j <= 0x1d; i++, j++ ) {
7304 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
7306 for(j = 0x1f; j <= 0x21; i++, j++ ) {
7307 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
7309 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]);
7310 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]);
7312 SiS_SetGroup2_Tail(SiS_Pr, ModeNo);
7318 /* Checked for 1024x768, 1280x1024, 1400x1050, 1600x1200 */
7319 /* Clevo dual-link 1024x768 */
7320 /* Compaq 1280x1024 has HT 1696 sometimes (calculation OK, if given HT is correct) */
7321 /* Acer: OK, but uses different setting for VESA timing at 640/800/1024 and 640x400 */
7323 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
7324 if((SiS_Pr->SiS_LCDInfo & LCDPass11) || (SiS_Pr->PanelYRes == SiS_Pr->SiS_VDE)) {
7325 tempbx = SiS_Pr->SiS_VDE - 1;
7326 tempcx = SiS_Pr->SiS_VT - 1;
7328 tempbx = SiS_Pr->SiS_VDE + ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VDE) / 2);
7329 tempcx = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VDE) / 2);
7332 tempbx = SiS_Pr->PanelYRes;
7333 tempcx = SiS_Pr->SiS_VT;
7335 if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) {
7336 tempax = SiS_Pr->PanelYRes;
7337 /* if(SiS_Pr->SiS_VGAVDE == 525) tempax += 0x3c; */ /* 651+301C */
7338 if(SiS_Pr->PanelYRes < SiS_Pr->SiS_VDE) {
7339 tempax = tempcx = 0;
7341 tempax -= SiS_Pr->SiS_VDE;
7345 tempcx -= tempax; /* lcdvdes */
7346 tempbx -= tempax; /* lcdvdee */
7349 /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */
7352 xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx);
7355 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */
7356 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */
7358 temp = (tempbx >> 5) & 0x38;
7359 temp |= ((tempcx >> 8) & 0x07);
7360 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp);
7362 tempax = SiS_Pr->SiS_VDE;
7363 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
7364 tempax = SiS_Pr->PanelYRes;
7366 tempcx = (SiS_Pr->SiS_VT - tempax) >> 4;
7367 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
7368 if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) {
7369 tempcx = (SiS_Pr->SiS_VT - tempax) / 10;
7373 tempbx = ((SiS_Pr->SiS_VT + SiS_Pr->SiS_VDE) >> 1) - 1;
7374 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
7375 if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) {
7376 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { /* ? */
7377 tempax = SiS_Pr->SiS_VT - SiS_Pr->PanelYRes;
7378 if(tempax % 4) { tempax >>= 2; tempax++; }
7379 else { tempax >>= 2; }
7380 tempbx -= (tempax - 1);
7383 if(tempbx <= SiS_Pr->SiS_VDE) tempbx = SiS_Pr->SiS_VDE + 1;
7387 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
7389 if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (crt2crtc == 6)) {
7390 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
7397 /* non-expanding: lcdvrs = ((VT + VDE) / 2) - 10 */
7399 if(SiS_Pr->UseCustomMode) {
7400 tempbx = SiS_Pr->CVSyncStart;
7404 xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx);
7407 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */
7409 temp = (tempbx >> 4) & 0xF0;
7410 tempbx += (tempcx + 1);
7411 temp |= (tempbx & 0x0F);
7413 if(SiS_Pr->UseCustomMode) {
7415 temp |= (SiS_Pr->CVSyncEnd & 0x0f);
7419 xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f));
7422 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp);
7425 SiS_Group2LCDSpecial(SiS_Pr, HwInfo, ModeNo, crt2crtc);
7429 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) bridgeoffset += 2;
7430 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) bridgeoffset++;
7431 if(SiS_IsDualLink(SiS_Pr, HwInfo)) bridgeoffset++;
7434 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
7435 if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) {
7436 temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2);
7437 if(SiS_IsDualLink(SiS_Pr, HwInfo)) temp >>= 1;
7440 temp += bridgeoffset;
7441 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1F,temp); /* lcdhdes */
7442 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0F,((temp >> 4) & 0xf0));
7444 tempcx = SiS_Pr->SiS_HT;
7445 tempax = tempbx = SiS_Pr->SiS_HDE;
7446 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
7447 if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) {
7448 tempax = SiS_Pr->PanelXRes;
7449 tempbx = SiS_Pr->PanelXRes - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2);
7452 if(SiS_IsDualLink(SiS_Pr, HwInfo)) {
7459 xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx);
7462 tempbx += bridgeoffset;
7464 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,tempbx); /* lcdhdee */
7465 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,((tempbx >> 8) & 0x0f));
7467 tempcx = (tempcx - tempax) >> 2;
7472 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
7473 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
7474 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
7475 if(SiS_Pr->SiS_HDE == 1280) tempbx = (tempbx & 0xff00) | 0x47;
7480 if(SiS_Pr->UseCustomMode) {
7481 tempbx = SiS_Pr->CHSyncStart;
7482 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1;
7483 tempbx += bridgeoffset;
7487 xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx);
7490 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */
7491 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0));
7496 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
7497 if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) tempcx >>= 2;
7501 if(SiS_Pr->UseCustomMode) {
7502 tempbx = SiS_Pr->CHSyncEnd;
7503 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1;
7504 tempbx += bridgeoffset;
7508 xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx);
7511 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */
7513 SiS_SetGroup2_Tail(SiS_Pr, ModeNo);
7516 SiS_Set300Part2Regs(SiS_Pr, HwInfo, ModeIdIndex, RefreshRateTableIndex, ModeNo);
7519 } /* CRT2-LCD from table */
7523 /*********************************************/
7524 /* SET PART 3 REGISTER GROUP */
7525 /*********************************************/
7528 SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7529 PSIS_HW_INFO HwInfo)
7532 const UCHAR *tempdi;
7534 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
7537 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x00,0x00);
7542 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
7543 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA);
7544 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xC8);
7546 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xF5);
7547 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xB7);
7550 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
7551 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x13,0xFA);
7552 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x14,0xC8);
7553 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x3D,0xA8);
7557 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
7558 tempdi = SiS_Pr->SiS_HiTVGroup3Data;
7559 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
7560 tempdi = SiS_Pr->SiS_HiTVGroup3Simu;
7562 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
7563 if(!(SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) {
7564 tempdi = SiS_HiTVGroup3_1;
7565 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempdi = SiS_HiTVGroup3_2;
7569 for(i=0; i<=0x3E; i++) {
7570 SiS_SetReg(SiS_Pr->SiS_Part3Port,i,tempdi[i]);
7572 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) {
7573 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {
7574 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x28,0x3f);
7584 /*********************************************/
7585 /* SET PART 4 REGISTER GROUP */
7586 /*********************************************/
7590 SiS_ShiftXPos(SiS_Private *SiS_Pr, int shift)
7592 USHORT temp, temp1, temp2;
7594 temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x1f);
7595 temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x20);
7596 temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift);
7597 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,temp);
7598 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0f,((temp >> 4) & 0xf0));
7599 temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x2b) & 0x0f;
7600 temp = (USHORT)((int)(temp) + shift);
7601 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2b,0xf0,(temp & 0x0f));
7602 temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43);
7603 temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x42);
7604 temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift);
7605 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,temp);
7606 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x42,0x0f,((temp >> 4) & 0xf0));
7610 SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
7611 USHORT ModeNo, USHORT ModeIdIndex)
7613 USHORT temp, temp1, resinfo = 0;
7615 if(!(SiS_Pr->SiS_VBType & VB_SIS301C)) return;
7616 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750))) return;
7619 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
7622 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3a,0x08);
7623 temp = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x3a);
7624 if(!(temp & 0x01)) {
7625 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3a,0xdf);
7626 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xfc);
7627 if((HwInfo->jChipType < SIS_661) && (!(SiS_Pr->SiS_ROMNew))) {
7628 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xf8);
7630 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0xfb);
7631 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) temp = 0x0000;
7632 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp = 0x0002;
7633 else if(SiS_Pr->SiS_TVMode & TVSetHiVision) temp = 0x0400;
7635 if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) {
7637 if(SiS_Pr->SiS_TVMode & TVAspect43) temp1 = 4;
7638 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0f,0xfb,temp1);
7639 if(SiS_Pr->SiS_TVMode & TVAspect43LB) temp |= 0x01;
7640 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0x7c,(temp & 0xff));
7642 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x3b) & 0x03;
7643 if(temp1 == 0x01) temp |= 0x01;
7644 if(temp1 == 0x03) temp |= 0x04; /* ? why not 0x10? */
7645 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xf8,(temp & 0xff));
7647 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8));
7649 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3b,0xfd);
7652 if(HwInfo->jChipType >= SIS_661) { /* ? */
7653 if(SiS_Pr->SiS_TVMode & TVAspect43) {
7654 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {
7655 if(resinfo == SIS_RI_1024x768) {
7656 SiS_ShiftXPos(SiS_Pr, 97);
7658 SiS_ShiftXPos(SiS_Pr, 111);
7660 } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) {
7661 SiS_ShiftXPos(SiS_Pr, 136);
7670 SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7671 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
7674 USHORT temp, reg1, reg2;
7676 if(SiS_Pr->UseCustomMode) {
7677 reg1 = SiS_Pr->CSR2B;
7678 reg2 = SiS_Pr->CSR2C;
7680 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
7682 reg1 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A;
7683 reg2 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B;
7686 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
7687 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) {
7688 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x57);
7689 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,0x46);
7690 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1f,0xf6);
7692 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,reg1);
7693 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,reg2);
7696 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x01);
7697 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,reg2);
7698 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,reg1);
7700 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x12,0x00);
7702 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) temp |= 0x20;
7703 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,temp);
7707 SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7708 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
7710 USHORT tempax,tempcx,tempbx,modeflag,temp,resinfo;
7711 ULONG tempebx,tempeax,templong;
7713 if(ModeNo <= 0x13) {
7714 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
7715 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
7716 } else if(SiS_Pr->UseCustomMode) {
7717 modeflag = SiS_Pr->CModeFlag;
7720 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7721 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
7724 if(HwInfo->jChipType >= SIS_315H) {
7725 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
7726 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
7727 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e);
7732 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV)) {
7733 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
7734 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f);
7738 if(HwInfo->jChipType >= SIS_315H) {
7739 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
7740 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
7741 if(SiS_IsDualLink(SiS_Pr, HwInfo)) {
7742 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
7744 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20);
7747 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
7748 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00);
7750 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
7752 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10);
7759 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x13,SiS_Pr->SiS_RVBHCFACT);
7761 tempbx = SiS_Pr->SiS_RVBHCMAX;
7762 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x14,tempbx);
7764 temp = (tempbx >> 1) & 0x80;
7766 tempcx = SiS_Pr->SiS_VGAHT - 1;
7767 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x16,tempcx);
7769 temp |= ((tempcx >> 5) & 0x78);
7771 tempcx = SiS_Pr->SiS_VGAVT - 1;
7772 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempcx -= 5;
7773 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x17,tempcx);
7775 temp |= ((tempcx >> 8) & 0x07);
7776 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp);
7778 tempbx = SiS_Pr->SiS_VGAHDE;
7779 if(modeflag & HalfDCLK) tempbx >>= 1;
7780 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1;
7782 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
7784 if(tempbx > 800) temp = 0x60;
7785 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
7787 if(tempbx == 1024) temp = 0xA0;
7788 else if(tempbx > 1024) temp = 0xC0;
7789 } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) {
7791 if(tempbx >= 1280) temp = 0x40;
7792 else if(tempbx >= 1024) temp = 0x20;
7795 if(tempbx >= 1024) temp = 0xA0;
7798 if(SiS_Pr->SiS_VBType & VB_SIS301) {
7799 if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) temp |= 0x0A;
7802 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp);
7804 tempeax = SiS_Pr->SiS_VGAVDE;
7805 tempebx = SiS_Pr->SiS_VDE;
7806 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
7807 if(!(temp & 0xE0)) tempebx >>=1;
7810 tempcx = SiS_Pr->SiS_RVBHRS;
7811 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x18,tempcx);
7815 if(tempeax <= tempebx) {
7821 tempeax *= (256 * 1024);
7822 templong = tempeax % tempebx;
7824 if(templong) tempeax++;
7826 temp = (USHORT)(tempeax & 0x000000FF);
7827 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp);
7828 temp = (USHORT)((tempeax & 0x0000FF00) >> 8);
7829 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp);
7830 temp = (USHORT)((tempeax >> 12) & 0x70); /* sic! */
7831 temp |= (tempcx & 0x4F);
7832 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp);
7834 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
7836 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28);
7838 /* Calc Linebuffer max address and set/clear decimode */
7840 if(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p)) tempbx = 0x08;
7841 tempax = SiS_Pr->SiS_VGAHDE;
7842 if(modeflag & HalfDCLK) tempax >>= 1;
7843 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempax >>= 1;
7845 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
7847 } else { /* 651+301C: Only if TVNoHiviNoYPbPr */
7849 if(tempax == 1024) tempax *= 25;
7855 if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) ||
7856 (SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) {
7857 if(resinfo == SIS_RI_1024x768) {
7858 /* Otherwise white line at right edge */
7859 tempax = (tempax & 0xff00) | 0x20;
7865 temp = ((tempax >> 4) & 0x30) | tempbx;
7866 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1D,tempax);
7867 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp);
7869 temp = 0x0036; tempbx = 0xD0;
7870 if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
7871 temp = 0x0026; tempbx = 0xC0; /* See En/DisableBridge() */
7873 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
7874 if(!(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSetHiVision | TVSetYPbPr750p | TVSetYPbPr525p))) {
7876 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
7877 if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) {
7883 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,tempbx,temp);
7885 tempbx = SiS_Pr->SiS_HT >> 1;
7886 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1;
7888 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,tempbx);
7889 temp = (tempbx >> 5) & 0x38;
7890 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp);
7892 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
7893 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
7894 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e);
7895 /* LCD-too-dark-error-source, see FinalizeLCD() */
7897 if(HwInfo->jChipType >= SIS_315H) {
7898 if(SiS_IsDualLink(SiS_Pr, HwInfo)) {
7899 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
7901 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20);
7904 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
7905 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00);
7907 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
7909 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10);
7915 SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
7918 /*********************************************/
7919 /* SET PART 5 REGISTER GROUP */
7920 /*********************************************/
7923 SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7924 PSIS_HW_INFO HwInfo)
7927 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
7929 if(SiS_Pr->SiS_ModeType == ModeVGA) {
7930 if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))) {
7931 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
7932 SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex);
7937 /*********************************************/
7938 /* MODIFY CRT1 GROUP FOR SLAVE MODE */
7939 /*********************************************/
7942 SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7943 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
7945 USHORT tempah,i,modeflag,j;
7946 USHORT ResIndex,DisplayType;
7947 const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL;
7949 if(ModeNo <= 0x13) modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
7950 else modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7952 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
7953 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) ||
7954 (SiS_Pr->SiS_CustomT == CUT_PANEL848))
7957 if(!(SiS_GetLVDSCRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
7958 &ResIndex, &DisplayType))) {
7962 if(HwInfo->jChipType < SIS_315H) {
7963 if(SiS_Pr->SiS_SetFlag & SetDOSMode) return;
7966 switch(DisplayType) {
7967 case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break;
7968 case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break;
7969 case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break;
7970 case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break;
7971 case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break;
7972 case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break;
7973 case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break;
7974 case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break;
7975 case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break;
7976 case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break;
7977 case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break;
7978 case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2_H; break;
7979 case 12: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1; break;
7980 case 13: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H; break;
7981 case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1; break;
7982 case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1_H; break;
7983 case 16: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2; break;
7984 case 17: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2_H; break;
7985 case 18: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break;
7986 case 19: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break;
7987 case 20: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break;
7988 case 21: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break;
7989 case 22: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x480_1; break; /* FSTN */
7990 case 23: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break;
7991 case 24: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break;
7992 case 25: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break;
7993 case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break;
7994 case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1; break;
7995 case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1_H; break;
7996 case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2; break;
7997 case 30: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2_H; break;
7998 case 36: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1; break;
7999 case 37: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1_H; break;
8000 case 38: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2; break;
8001 case 39: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2_H; break;
8002 case 40: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1; break;
8003 case 41: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1_H; break;
8004 case 42: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2; break;
8005 case 43: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2_H; break;
8006 case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break;
8007 case 51: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break;
8008 case 52: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2; break;
8009 case 53: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2_H; break;
8010 case 54: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3; break;
8011 case 55: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3_H; break;
8012 case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break;
8013 default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break;
8016 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f);
8018 tempah = (LVDSCRT1Ptr + ResIndex)->CR[0];
8019 SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,tempah);
8021 for(i=0x02,j=1;i<=0x05;i++,j++){
8022 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8023 SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah);
8025 for(i=0x06,j=5;i<=0x07;i++,j++){
8026 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8027 SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah);
8029 for(i=0x10,j=7;i<=0x11;i++,j++){
8030 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8031 SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah);
8033 for(i=0x15,j=9;i<=0x16;i++,j++){
8034 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8035 SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah);
8037 for(i=0x0A,j=11;i<=0x0C;i++,j++){
8038 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8039 SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah);
8042 tempah = (LVDSCRT1Ptr + ResIndex)->CR[14];
8044 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah);
8046 tempah = (LVDSCRT1Ptr + ResIndex)->CR[14];
8049 if(modeflag & DoubleScanMode) tempah |= 0x080;
8050 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah);
8053 /*********************************************/
8055 /*********************************************/
8058 SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
8059 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
8061 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
8062 USHORT clkbase, vclkindex=0;
8065 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) || (SiS_Pr->SiS_LCDInfo & LCDPass11)) {
8066 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
8067 if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK & 0x3f) == 2) {
8068 RefreshRateTableIndex--;
8070 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex,
8071 RefreshRateTableIndex, HwInfo);
8072 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
8074 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex,
8075 RefreshRateTableIndex, HwInfo);
8078 sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
8079 sr2c = SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
8081 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
8082 if(SiS_Pr->SiS_UseROM) {
8083 if(ROMAddr[0x220] & 0x01) {
8084 sr2b = ROMAddr[0x227];
8085 sr2c = ROMAddr[0x228];
8091 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
8092 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
8097 SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x20);
8098 SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b);
8099 SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c);
8100 SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x10);
8101 SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b);
8102 SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c);
8103 SiS_SetReg(SiS_Pr->SiS_P3c4,0x31,0x00);
8104 SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase,sr2b);
8105 SiS_SetReg(SiS_Pr->SiS_P3c4,clkbase+1,sr2c);
8108 /*********************************************/
8109 /* SET UP CHRONTEL CHIPS */
8110 /*********************************************/
8113 SiS_SetCHTVReg(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
8114 USHORT RefreshRateTableIndex)
8116 #if defined(SIS300) || defined(SIS315H)
8117 USHORT temp, tempbx;
8120 USHORT TVType, resindex;
8121 const SiS_CHTVRegDataStruct *CHTVRegData = NULL;
8124 tempcl = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
8126 tempcl = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
8129 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1;
8130 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
8132 if(SiS_Pr->SiS_ModeType > ModeVGA) {
8133 if(SiS_Pr->SiS_CHSOverScan) TVType = 8;
8135 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
8137 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1;
8138 } else if(SiS_Pr->SiS_TVMode & TVSetPALN) {
8140 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1;
8144 case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break;
8145 case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break;
8146 case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break;
8147 case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break;
8148 case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break;
8149 case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break;
8150 case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break;
8151 case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break;
8152 case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break;
8153 default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break;
8155 resindex = tempcl & 0x3F;
8157 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
8161 /* Chrontel 7005 - I assume that it does not come with a 315 series chip */
8163 /* We don't support modes >800x600 */
8164 if (resindex > 5) return;
8166 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
8167 SiS_SetCH700x(SiS_Pr,0x4304); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/
8168 SiS_SetCH700x(SiS_Pr,0x6909); /* Black level for PAL (105)*/
8170 SiS_SetCH700x(SiS_Pr,0x0304); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/
8171 SiS_SetCH700x(SiS_Pr,0x7109); /* Black level for NTSC (113)*/
8174 temp = CHTVRegData[resindex].Reg[0];
8175 tempbx=((temp&0x00FF)<<8)|0x00; /* Mode register */
8176 SiS_SetCH700x(SiS_Pr,tempbx);
8177 temp = CHTVRegData[resindex].Reg[1];
8178 tempbx=((temp&0x00FF)<<8)|0x07; /* Start active video register */
8179 SiS_SetCH700x(SiS_Pr,tempbx);
8180 temp = CHTVRegData[resindex].Reg[2];
8181 tempbx=((temp&0x00FF)<<8)|0x08; /* Position overflow register */
8182 SiS_SetCH700x(SiS_Pr,tempbx);
8183 temp = CHTVRegData[resindex].Reg[3];
8184 tempbx=((temp&0x00FF)<<8)|0x0A; /* Horiz Position register */
8185 SiS_SetCH700x(SiS_Pr,tempbx);
8186 temp = CHTVRegData[resindex].Reg[4];
8187 tempbx=((temp&0x00FF)<<8)|0x0B; /* Vertical Position register */
8188 SiS_SetCH700x(SiS_Pr,tempbx);
8190 /* Set minimum flicker filter for Luma channel (SR1-0=00),
8191 minimum text enhancement (S3-2=10),
8192 maximum flicker filter for Chroma channel (S5-4=10)
8193 =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!)
8195 SiS_SetCH700x(SiS_Pr,0x2801);
8197 /* Set video bandwidth
8198 High bandwith Luma composite video filter(S0=1)
8199 low bandwith Luma S-video filter (S2-1=00)
8200 disable peak filter in S-video channel (S3=0)
8201 high bandwidth Chroma Filter (S5-4=11)
8204 SiS_SetCH700x(SiS_Pr,0xb103); /* old: 3103 */
8206 /* Register 0x3D does not exist in non-macrovision register map
8207 (Maybe this is a macrovision register?)
8210 SiS_SetCH70xx(SiS_Pr,0x003D);
8213 /* Register 0x10 only contains 1 writable bit (S0) for sensing,
8214 all other bits a read-only. Macrovision?
8216 SiS_SetCH70xxANDOR(SiS_Pr,0x0010,0x1F);
8218 /* Register 0x11 only contains 3 writable bits (S0-S2) for
8219 contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) )
8221 SiS_SetCH70xxANDOR(SiS_Pr,0x0211,0xF8);
8225 SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xEF);
8227 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */
8228 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) {
8229 if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */
8230 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
8231 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on, no need to set FSCI */
8232 } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */
8233 SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */
8234 SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0);
8235 SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0);
8236 SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0);
8237 SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0);
8238 SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0);
8239 SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0);
8240 SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0);
8241 SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */
8242 SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */
8245 if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */
8246 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
8247 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE);
8248 } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */
8250 SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */
8251 SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */
8252 SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0); /* 198b3a63 */
8253 SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0);
8254 SiS_SetCH70xxANDOR(SiS_Pr,0x041C,0xF0);
8255 SiS_SetCH70xxANDOR(SiS_Pr,0x011D,0xF0);
8256 SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0);
8257 SiS_SetCH70xxANDOR(SiS_Pr,0x051F,0xF0);
8258 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */
8259 SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */
8260 #endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */
8261 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
8262 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE);
8265 } else { /* ---- PAL ---- */
8266 /* We don't play around with FSCI in PAL mode */
8267 if(resindex == 0x04) {
8268 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
8269 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */
8271 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */
8272 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */
8280 /* Chrontel 7019 - assumed that it does not come with a 300 series chip */
8284 /* We don't support modes >1024x768 */
8285 if (resindex > 6) return;
8287 temp = CHTVRegData[resindex].Reg[0];
8288 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {
8291 tempbx=((temp & 0x00FF) << 8) | 0x00;
8292 SiS_SetCH701x(SiS_Pr,tempbx);
8294 temp = CHTVRegData[resindex].Reg[1];
8295 tempbx=((temp & 0x00FF) << 8) | 0x01;
8296 SiS_SetCH701x(SiS_Pr,tempbx);
8298 temp = CHTVRegData[resindex].Reg[2];
8299 tempbx=((temp & 0x00FF) << 8) | 0x02;
8300 SiS_SetCH701x(SiS_Pr,tempbx);
8302 temp = CHTVRegData[resindex].Reg[3];
8303 tempbx=((temp & 0x00FF) << 8) | 0x04;
8304 SiS_SetCH701x(SiS_Pr,tempbx);
8306 temp = CHTVRegData[resindex].Reg[4];
8307 tempbx=((temp & 0x00FF) << 8) | 0x03;
8308 SiS_SetCH701x(SiS_Pr,tempbx);
8310 temp = CHTVRegData[resindex].Reg[5];
8311 tempbx=((temp & 0x00FF) << 8) | 0x05;
8312 SiS_SetCH701x(SiS_Pr,tempbx);
8314 temp = CHTVRegData[resindex].Reg[6];
8315 tempbx=((temp & 0x00FF) << 8) | 0x06;
8316 SiS_SetCH701x(SiS_Pr,tempbx);
8318 temp = CHTVRegData[resindex].Reg[7];
8319 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {
8322 tempbx=((temp & 0x00FF) << 8) | 0x07;
8323 SiS_SetCH701x(SiS_Pr,tempbx);
8325 temp = CHTVRegData[resindex].Reg[8];
8326 tempbx=((temp & 0x00FF) << 8) | 0x08;
8327 SiS_SetCH701x(SiS_Pr,tempbx);
8329 temp = CHTVRegData[resindex].Reg[9];
8330 tempbx=((temp & 0x00FF) << 8) | 0x15;
8331 SiS_SetCH701x(SiS_Pr,tempbx);
8333 temp = CHTVRegData[resindex].Reg[10];
8334 tempbx=((temp & 0x00FF) << 8) | 0x1f;
8335 SiS_SetCH701x(SiS_Pr,tempbx);
8337 temp = CHTVRegData[resindex].Reg[11];
8338 tempbx=((temp & 0x00FF) << 8) | 0x0c;
8339 SiS_SetCH701x(SiS_Pr,tempbx);
8341 temp = CHTVRegData[resindex].Reg[12];
8342 tempbx=((temp & 0x00FF) << 8) | 0x0d;
8343 SiS_SetCH701x(SiS_Pr,tempbx);
8345 temp = CHTVRegData[resindex].Reg[13];
8346 tempbx=((temp & 0x00FF) << 8) | 0x0e;
8347 SiS_SetCH701x(SiS_Pr,tempbx);
8349 temp = CHTVRegData[resindex].Reg[14];
8350 tempbx=((temp & 0x00FF) << 8) | 0x0f;
8351 SiS_SetCH701x(SiS_Pr,tempbx);
8353 temp = CHTVRegData[resindex].Reg[15];
8354 tempbx=((temp & 0x00FF) << 8) | 0x10;
8355 SiS_SetCH701x(SiS_Pr,tempbx);
8357 temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02;
8358 /* D1 should be set for PAL, PAL-N and NTSC-J,
8359 but I won't do that for PAL unless somebody
8360 tells me to do so. Since the BIOS uses
8361 non-default CIV values and blacklevels,
8362 this might be compensated anyway.
8364 if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02;
8365 SiS_SetCH701x(SiS_Pr,((temp << 8) | 0x21));
8378 SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8382 /* Enable Chrontel 7019 LCD panel backlight */
8383 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8384 if(HwInfo->jChipType == SIS_740) {
8385 SiS_SetCH701x(SiS_Pr,0x6566);
8387 temp = SiS_GetCH701x(SiS_Pr,0x66);
8389 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
8395 SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr)
8399 /* Disable Chrontel 7019 LCD panel backlight */
8400 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8401 temp = SiS_GetCH701x(SiS_Pr,0x66);
8403 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
8407 #ifdef SIS315H /* ----------- 315 series only ---------- */
8410 SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8412 UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b };
8413 UCHAR table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 };
8414 UCHAR table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 };
8415 UCHAR asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 };
8416 UCHAR asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 };
8417 UCHAR table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
8418 UCHAR table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
8419 UCHAR *tableptr = NULL;
8422 /* Set up Power up/down timing */
8424 if(HwInfo->jChipType == SIS_740) {
8425 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
8426 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740;
8427 else tableptr = table1024_740;
8428 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) ||
8429 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) ||
8430 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) {
8431 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740;
8432 else tableptr = table1400_740;
8435 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
8436 tableptr = table1024_650;
8437 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) ||
8438 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) ||
8439 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) {
8440 tableptr = table1400_650;
8444 for(i=0; i<5; i++) {
8445 SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]);
8450 SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8452 UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71,
8453 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 };
8454 UCHAR table1024_740[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
8455 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 };
8456 UCHAR table1280_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8457 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 };
8458 UCHAR table1400_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8459 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 };
8460 UCHAR table1600_740[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
8461 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 };
8462 UCHAR table1024_650[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
8463 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 };
8464 UCHAR table1280_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8465 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 };
8466 UCHAR table1400_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef,
8467 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 };
8468 UCHAR table1600_650[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
8469 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a };
8470 UCHAR *tableptr = NULL;
8474 if(HwInfo->jChipType == SIS_740) {
8475 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_740;
8476 else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_740;
8477 else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_740;
8478 else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) tableptr = table1600_740;
8481 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_650;
8482 else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_650;
8483 else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_650;
8484 else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) tableptr = table1600_650;
8488 tempbh = SiS_GetCH701x(SiS_Pr,0x74);
8489 if((tempbh == 0xf6) || (tempbh == 0xc7)) {
8490 tempbh = SiS_GetCH701x(SiS_Pr,0x73);
8491 if(tempbh == 0xc8) {
8492 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) return;
8493 } else if(tempbh == 0xdb) {
8494 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) return;
8495 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) return;
8496 } else if(tempbh == 0xde) {
8497 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) return;
8501 if(HwInfo->jChipType == SIS_740) tempbh = 0x0d;
8504 for(i = 0; i < tempbh; i++) {
8505 SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]);
8507 SiS_ChrontelPowerSequencing(SiS_Pr,HwInfo);
8508 tempbh = SiS_GetCH701x(SiS_Pr,0x1e);
8510 SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e);
8512 if(HwInfo->jChipType == SIS_740) {
8513 tempbh = SiS_GetCH701x(SiS_Pr,0x1c);
8515 SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c);
8516 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03);
8517 tempbh = SiS_GetCH701x(SiS_Pr,0x64);
8519 SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64);
8520 tempbh = SiS_GetCH701x(SiS_Pr,0x03);
8522 SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03);
8527 SiS_ChrontelResetVSync(SiS_Private *SiS_Pr)
8529 unsigned char temp, temp1;
8531 temp1 = SiS_GetCH701x(SiS_Pr,0x49);
8532 SiS_SetCH701x(SiS_Pr,0x3e49);
8533 temp = SiS_GetCH701x(SiS_Pr,0x47);
8534 temp &= 0x7f; /* Use external VSYNC */
8535 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
8536 SiS_LongDelay(SiS_Pr,3);
8537 temp = SiS_GetCH701x(SiS_Pr,0x47);
8538 temp |= 0x80; /* Use internal VSYNC */
8539 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
8540 SiS_SetCH701x(SiS_Pr,(temp1 << 8) | 0x49);
8544 SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8548 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8549 if(HwInfo->jChipType == SIS_740) {
8550 temp = SiS_GetCH701x(SiS_Pr,0x1c);
8551 temp |= 0x04; /* Invert XCLK phase */
8552 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c);
8554 if(SiS_IsYPbPr(SiS_Pr, HwInfo)) {
8555 temp = SiS_GetCH701x(SiS_Pr,0x01);
8557 temp |= 0x80; /* Enable YPrPb (HDTV) */
8558 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01);
8560 if(SiS_IsChScart(SiS_Pr, HwInfo)) {
8561 temp = SiS_GetCH701x(SiS_Pr,0x01);
8563 temp |= 0xc0; /* Enable SCART + CVBS */
8564 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01);
8566 if(HwInfo->jChipType == SIS_740) {
8567 SiS_ChrontelResetVSync(SiS_Pr);
8568 SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */
8570 SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */
8571 temp = SiS_GetCH701x(SiS_Pr,0x49);
8572 if(SiS_IsYPbPr(SiS_Pr,HwInfo)) {
8573 temp = SiS_GetCH701x(SiS_Pr,0x73);
8575 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73);
8577 temp = SiS_GetCH701x(SiS_Pr,0x47);
8579 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
8580 SiS_LongDelay(SiS_Pr,2);
8581 temp = SiS_GetCH701x(SiS_Pr,0x47);
8583 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
8589 SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8593 /* Complete power down of LVDS */
8594 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8595 if(HwInfo->jChipType == SIS_740) {
8596 SiS_LongDelay(SiS_Pr,1);
8597 SiS_GenericDelay(SiS_Pr,0x16ff);
8598 SiS_SetCH701x(SiS_Pr,0xac76);
8599 SiS_SetCH701x(SiS_Pr,0x0066);
8601 SiS_LongDelay(SiS_Pr,2);
8602 temp = SiS_GetCH701x(SiS_Pr,0x76);
8604 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
8605 SiS_SetCH701x(SiS_Pr,0x0066);
8611 SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8615 if(HwInfo->jChipType == SIS_740) {
8617 temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */
8621 if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) {
8622 temp = SiS_GetCH701x(SiS_Pr,0x49);
8623 SiS_SetCH701x(SiS_Pr,0x3e49);
8625 /* Reset Chrontel 7019 datapath */
8626 SiS_SetCH701x(SiS_Pr,0x1048);
8627 SiS_LongDelay(SiS_Pr,1);
8628 SiS_SetCH701x(SiS_Pr,0x1848);
8630 if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) {
8631 SiS_ChrontelResetVSync(SiS_Pr);
8632 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49);
8637 /* Clear/set/clear GPIO */
8638 temp = SiS_GetCH701x(SiS_Pr,0x5c);
8640 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
8641 temp = SiS_GetCH701x(SiS_Pr,0x5c);
8643 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
8644 temp = SiS_GetCH701x(SiS_Pr,0x5c);
8646 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
8647 temp = SiS_GetCH701x(SiS_Pr,0x61);
8649 SiS_SetCH701xForLCD(SiS_Pr, HwInfo);
8654 /* Reset Chrontel 7019 datapath */
8655 SiS_SetCH701x(SiS_Pr,0x1048);
8656 SiS_LongDelay(SiS_Pr,1);
8657 SiS_SetCH701x(SiS_Pr,0x1848);
8662 SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8666 if(HwInfo->jChipType == SIS_740) {
8668 if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) {
8669 SiS_ChrontelResetVSync(SiS_Pr);
8674 SiS_SetCH701x(SiS_Pr,0xaf76); /* Power up LVDS block */
8675 temp = SiS_GetCH701x(SiS_Pr,0x49);
8677 if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */
8678 temp = SiS_GetCH701x(SiS_Pr,0x47);
8680 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* enable VSYNC */
8681 SiS_LongDelay(SiS_Pr,3);
8682 temp = SiS_GetCH701x(SiS_Pr,0x47);
8684 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* disable VSYNC */
8691 SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo)
8695 if(HwInfo->jChipType == SIS_740) {
8697 temp = SiS_GetCH701x(SiS_Pr,0x61);
8700 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61);
8702 SiS_SetCH701x(SiS_Pr,0x4566); /* Panel power on */
8703 SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on */
8704 SiS_LongDelay(SiS_Pr,1);
8705 SiS_GenericDelay(SiS_Pr,0x16ff);
8710 temp = SiS_GetCH701x(SiS_Pr,0x61);
8713 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61);
8716 SiS_SetCH701x(SiS_Pr,0xac76);
8717 temp = SiS_GetCH701x(SiS_Pr,0x66);
8719 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
8721 if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) {
8722 SiS_GenericDelay(SiS_Pr,0x3ff);
8724 SiS_GenericDelay(SiS_Pr,0x2ff);
8728 SiS_GenericDelay(SiS_Pr,0x2ff);
8730 temp = SiS_GetCH701x(SiS_Pr,0x76);
8732 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
8733 temp = SiS_GetCH701x(SiS_Pr,0x66);
8735 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
8736 SiS_LongDelay(SiS_Pr,1);
8742 SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8744 USHORT temp,tempcl,tempch;
8746 SiS_LongDelay(SiS_Pr, 1);
8751 temp = SiS_GetCH701x(SiS_Pr,0x66);
8752 temp &= 0x04; /* PLL stable? -> bail out */
8753 if(temp == 0x04) break;
8755 if(HwInfo->jChipType == SIS_740) {
8756 /* Power down LVDS output, PLL normal operation */
8757 SiS_SetCH701x(SiS_Pr,0xac76);
8760 SiS_SetCH701xForLCD(SiS_Pr,HwInfo);
8763 if(tempch == 3) break;
8764 SiS_ChrontelResetDB(SiS_Pr,HwInfo);
8769 temp = SiS_GetCH701x(SiS_Pr,0x76);
8770 temp &= 0xfb; /* Reset PLL */
8771 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
8772 SiS_LongDelay(SiS_Pr,2);
8773 temp = SiS_GetCH701x(SiS_Pr,0x76);
8774 temp |= 0x04; /* PLL normal operation */
8775 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
8776 if(HwInfo->jChipType == SIS_740) {
8777 SiS_SetCH701x(SiS_Pr,0xe078); /* PLL loop filter */
8779 SiS_SetCH701x(SiS_Pr,0x6078);
8781 SiS_LongDelay(SiS_Pr,2);
8784 SiS_SetCH701x(SiS_Pr,0x0077); /* MV? */
8788 SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8792 temp = SiS_GetCH701x(SiS_Pr,0x03);
8793 temp |= 0x80; /* Set datapath 1 to TV */
8794 temp &= 0xbf; /* Set datapath 2 to LVDS */
8795 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03);
8797 if(HwInfo->jChipType == SIS_740) {
8799 temp = SiS_GetCH701x(SiS_Pr,0x1c);
8800 temp &= 0xfb; /* Normal XCLK phase */
8801 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c);
8803 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03);
8805 temp = SiS_GetCH701x(SiS_Pr,0x64);
8806 temp |= 0x40; /* ? Bit not defined */
8807 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64);
8809 temp = SiS_GetCH701x(SiS_Pr,0x03);
8810 temp &= 0x3f; /* D1 input to both LVDS and TV */
8811 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03);
8813 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) {
8814 SiS_SetCH701x(SiS_Pr,0x4063); /* LVDS off */
8815 SiS_LongDelay(SiS_Pr, 1);
8816 SiS_SetCH701x(SiS_Pr,0x0063); /* LVDS on */
8817 SiS_ChrontelResetDB(SiS_Pr, HwInfo);
8818 SiS_ChrontelDoSomething2(SiS_Pr, HwInfo);
8819 SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo);
8821 temp = SiS_GetCH701x(SiS_Pr,0x66);
8823 SiS_ChrontelResetDB(SiS_Pr, HwInfo);
8824 SiS_ChrontelDoSomething2(SiS_Pr, HwInfo);
8825 SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo);
8831 SiS_ChrontelResetDB(SiS_Pr,HwInfo);
8832 SiS_ChrontelDoSomething2(SiS_Pr,HwInfo);
8833 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34);
8834 SiS_ChrontelDoSomething3(SiS_Pr,temp,HwInfo);
8835 SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on, LVDS normal operation */
8840 #endif /* 315 series */
8842 /*********************************************/
8843 /* MAIN: SET CRT2 REGISTER GROUP */
8844 /*********************************************/
8847 SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
8850 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
8852 USHORT ModeIdIndex, RefreshRateTableIndex;
8857 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
8859 if(!SiS_Pr->UseCustomMode) {
8860 SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex);
8865 /* Used for shifting CR33 */
8866 SiS_Pr->SiS_SelectCRT2Rate = 4;
8868 SiS_UnLockCRT2(SiS_Pr, HwInfo);
8870 RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
8872 SiS_SaveCRT2Info(SiS_Pr,ModeNo);
8874 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8875 SiS_DisableBridge(SiS_Pr,HwInfo);
8876 if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (HwInfo->jChipType == SIS_730)) {
8877 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,0x80);
8879 SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
8882 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
8883 SiS_LockCRT2(SiS_Pr, HwInfo);
8884 SiS_DisplayOn(SiS_Pr);
8888 SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
8890 /* Set up Panel Link for LVDS and LCDA */
8891 SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0;
8892 if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) ||
8893 ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ||
8894 ((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) {
8895 SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
8900 xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES);
8901 xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE);
8902 xf86DrvMsg(0, X_INFO, "(init301: VGAHDE 0x%03x VGAVDE 0x%03x)\n", SiS_Pr->SiS_VGAHDE, SiS_Pr->SiS_VGAVDE);
8903 xf86DrvMsg(0, X_INFO, "(init301: HT 0x%03x VT 0x%03x)\n", SiS_Pr->SiS_HT, SiS_Pr->SiS_VT);
8904 xf86DrvMsg(0, X_INFO, "(init301: VGAHT 0x%03x VGAVT 0x%03x)\n", SiS_Pr->SiS_VGAHT, SiS_Pr->SiS_VGAVT);
8908 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8909 SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex);
8912 if(SiS_Pr->SiS_VBType & VB_SISVB) {
8914 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8916 SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
8918 SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
8920 SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
8921 SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo);
8923 SiS_SetGroup4_C_ELV(SiS_Pr, HwInfo, ModeNo, ModeIdIndex);
8925 SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
8927 SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo);
8929 /* For 301BDH (Panel link initialization): */
8930 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
8931 if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) {
8932 if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) {
8933 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
8934 SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,
8935 RefreshRateTableIndex,HwInfo);
8939 SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,
8940 RefreshRateTableIndex,HwInfo);
8946 SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo);
8948 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
8949 SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo);
8952 SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo);
8954 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8955 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
8956 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
8957 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8959 SiS_SetCH701xForLCD(SiS_Pr,HwInfo);
8963 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
8964 SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex);
8972 if(HwInfo->jChipType < SIS_315H) {
8973 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8974 if(SiS_Pr->SiS_UseOEM) {
8975 if((SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_UseOEM == -1)) {
8976 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
8977 SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,
8978 RefreshRateTableIndex);
8981 SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,
8982 RefreshRateTableIndex);
8985 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
8986 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
8987 (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
8988 SetOEMLCDData2(SiS_Pr, HwInfo, ModeNo, ModeIdIndex,RefreshRateTableIndex);
8990 SiS_DisplayOn(SiS_Pr);
8997 if(HwInfo->jChipType >= SIS_315H) {
8998 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8999 if(HwInfo->jChipType < SIS_661) {
9000 SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex, HwInfo);
9001 SiS_OEM310Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex);
9003 SiS_OEM661Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex);
9005 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40);
9010 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
9011 SiS_EnableBridge(SiS_Pr, HwInfo);
9014 SiS_DisplayOn(SiS_Pr);
9016 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
9017 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
9018 /* Disable LCD panel when using TV */
9019 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFF,0x0C);
9021 /* Disable TV when using LCD */
9022 SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8);
9026 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
9027 SiS_LockCRT2(SiS_Pr,HwInfo);
9034 /*********************************************/
9035 /* ENABLE/DISABLE LCD BACKLIGHT (SIS) */
9036 /*********************************************/
9039 SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
9041 /* Switch on LCD backlight on SiS30xLV */
9042 SiS_DDC2Delay(SiS_Pr,0xff00);
9043 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
9044 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
9045 SiS_WaitVBRetrace(SiS_Pr,HwInfo);
9047 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) {
9048 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
9053 SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
9055 /* Switch off LCD backlight on SiS30xLV */
9056 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE);
9057 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
9058 SiS_DDC2Delay(SiS_Pr,0xe000);
9061 /*********************************************/
9062 /* DDC RELATED FUNCTIONS */
9063 /*********************************************/
9066 SiS_SetupDDCN(SiS_Private *SiS_Pr)
9068 SiS_Pr->SiS_DDC_NData = ~SiS_Pr->SiS_DDC_Data;
9069 SiS_Pr->SiS_DDC_NClk = ~SiS_Pr->SiS_DDC_Clk;
9070 if((SiS_Pr->SiS_DDC_Index == 0x11) && (SiS_Pr->SiS_SensibleSR11)) {
9071 SiS_Pr->SiS_DDC_NData &= 0x0f;
9072 SiS_Pr->SiS_DDC_NClk &= 0x0f;
9078 SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr)
9084 for(i=0; i<20; i++) { /* Do 20 attempts to write */
9085 mydataptr = dataptr;
9087 if(!num) return mydataptr;
9089 SiS_SetStop(SiS_Pr);
9090 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT*2);
9092 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */
9093 tempah = SiS_Pr->SiS_DDC_DeviceAddr;
9094 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */
9095 if(temp) continue; /* (ERROR: no ack) */
9096 tempah = *mydataptr++;
9097 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write register number */
9098 if(temp) continue; /* (ERROR: no ack) */
9099 for(j=0; j<num; j++) {
9100 tempah = *mydataptr++;
9101 temp = SiS_WriteDDC2Data(SiS_Pr,tempah);/* Write DAB (S0=0=write) */
9105 if(SiS_SetStop(SiS_Pr)) continue;
9112 SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr)
9114 SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */
9115 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9116 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9117 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9118 SiS_SetupDDCN(SiS_Pr);
9120 SiS_SetSwitchDDC2(SiS_Pr);
9123 dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr);
9124 if(!dataptr) return FALSE;
9127 xf86DrvMsg(0, X_INFO, "Trumpion block success\n");
9133 /* The Chrontel 700x is connected to the 630/730 via
9134 * the 630/730's DDC/I2C port.
9136 * On 630(S)T chipset, the index changed from 0x11 to
9137 * 0x0a, possibly for working around the DDC problems
9141 SiS_SetChReg(SiS_Private *SiS_Pr, USHORT tempbx, USHORT myor)
9143 USHORT tempah,temp,i;
9145 for(i=0; i<20; i++) { /* Do 20 attempts to write */
9147 SiS_SetStop(SiS_Pr);
9148 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
9150 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */
9151 tempah = SiS_Pr->SiS_DDC_DeviceAddr;
9152 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */
9153 if(temp) continue; /* (ERROR: no ack) */
9154 tempah = tempbx & 0x00FF; /* Write RAB */
9155 tempah |= myor; /* (700x: set bit 7, see datasheet) */
9156 temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
9157 if(temp) continue; /* (ERROR: no ack) */
9158 tempah = (tempbx & 0xFF00) >> 8;
9159 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write data */
9160 if(temp) continue; /* (ERROR: no ack) */
9161 if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */
9162 SiS_Pr->SiS_ChrontelInit = 1;
9170 /* Write Trumpion register */
9172 SiS_SetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx)
9174 SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */
9175 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9176 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9177 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9178 SiS_SetupDDCN(SiS_Pr);
9179 SiS_SetChReg(SiS_Pr, tempbx, 0);
9184 /* Write to Chrontel 700x */
9185 /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */
9187 SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx)
9189 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */
9191 if(!(SiS_Pr->SiS_ChrontelInit)) {
9192 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9193 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9194 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9195 SiS_SetupDDCN(SiS_Pr);
9198 if( (!(SiS_SetChReg(SiS_Pr, tempbx, 0x80))) &&
9199 (!(SiS_Pr->SiS_ChrontelInit)) ) {
9200 SiS_Pr->SiS_DDC_Index = 0x0a; /* Bit 7 = SC; Bit 6 = SD */
9201 SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */
9202 SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */
9203 SiS_SetupDDCN(SiS_Pr);
9205 SiS_SetChReg(SiS_Pr, tempbx, 0x80);
9209 /* Write to Chrontel 701x */
9210 /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */
9212 SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
9214 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9215 SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */
9216 SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */
9217 SiS_SetupDDCN(SiS_Pr);
9218 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */
9219 SiS_SetChReg(SiS_Pr, tempbx, 0);
9223 SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
9225 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
9226 SiS_SetCH700x(SiS_Pr,tempbx);
9228 SiS_SetCH701x(SiS_Pr,tempbx);
9232 SiS_GetChReg(SiS_Private *SiS_Pr, USHORT myor)
9234 USHORT tempah,temp,i;
9236 for(i=0; i<20; i++) { /* Do 20 attempts to read */
9238 SiS_SetStop(SiS_Pr);
9239 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
9241 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */
9242 tempah = SiS_Pr->SiS_DDC_DeviceAddr;
9243 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */
9244 if(temp) continue; /* (ERROR: no ack) */
9245 tempah = SiS_Pr->SiS_DDC_ReadAddr | myor; /* Write RAB (700x: | 0x80) */
9246 temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
9247 if(temp) continue; /* (ERROR: no ack) */
9248 if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */
9249 tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01;/* DAB | 0x01 = Read */
9250 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* DAB (S0=1=read) */
9251 if(temp) continue; /* (ERROR: no ack) */
9252 tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* Read byte */
9253 if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */
9254 SiS_Pr->SiS_ChrontelInit = 1;
9262 /* Read from Trumpion */
9264 SiS_GetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx)
9266 SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB */
9267 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9268 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9269 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9270 SiS_SetupDDCN(SiS_Pr);
9271 SiS_Pr->SiS_DDC_ReadAddr = tempbx;
9272 return(SiS_GetChReg(SiS_Pr,0));
9277 /* Read from Chrontel 700x */
9278 /* Parameter is [Register no (S7-S0)] */
9280 SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx)
9284 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */
9286 if(!(SiS_Pr->SiS_ChrontelInit)) {
9287 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9288 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9289 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9290 SiS_SetupDDCN(SiS_Pr);
9293 SiS_Pr->SiS_DDC_ReadAddr = tempbx;
9295 if( ((result = SiS_GetChReg(SiS_Pr,0x80)) == 0xFFFF) &&
9296 (!SiS_Pr->SiS_ChrontelInit) ) {
9298 SiS_Pr->SiS_DDC_Index = 0x0a;
9299 SiS_Pr->SiS_DDC_Data = 0x80;
9300 SiS_Pr->SiS_DDC_Clk = 0x40;
9301 SiS_SetupDDCN(SiS_Pr);
9303 result = SiS_GetChReg(SiS_Pr,0x80);
9308 /* Read from Chrontel 701x */
9309 /* Parameter is [Register no (S7-S0)] */
9311 SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
9313 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9314 SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */
9315 SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */
9316 SiS_SetupDDCN(SiS_Pr);
9317 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */
9319 SiS_Pr->SiS_DDC_ReadAddr = tempbx;
9321 return(SiS_GetChReg(SiS_Pr,0));
9324 /* Read from Chrontel 70xx */
9325 /* Parameter is [Register no (S7-S0)] */
9327 SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
9329 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
9330 return(SiS_GetCH700x(SiS_Pr, tempbx));
9332 return(SiS_GetCH701x(SiS_Pr, tempbx));
9335 /* Our own DDC functions */
9337 SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
9338 USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32)
9340 unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 };
9341 unsigned char flag, cr32;
9342 USHORT temp = 0, myadaptnum = adaptnum;
9345 if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0xFFFF;
9346 if((VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF;
9349 /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */
9351 SiS_Pr->SiS_ChrontelInit = 0; /* force re-detection! */
9353 SiS_Pr->SiS_DDC_SecAddr = 0;
9354 SiS_Pr->SiS_DDC_DeviceAddr = ddcdtype[DDCdatatype];
9355 SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_P3c4;
9356 SiS_Pr->SiS_DDC_Index = 0x11;
9359 cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32);
9362 if(VBFlags & VB_SISBRIDGE) {
9363 if(myadaptnum == 0) {
9364 if(!(cr32 & 0x20)) {
9366 if(!(cr32 & 0x10)) {
9368 if(!(cr32 & 0x08)) {
9377 if(VGAEngine == SIS_300_VGA) { /* 300 series */
9379 if(myadaptnum != 0) {
9381 if(VBFlags & VB_SISBRIDGE) {
9382 SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port;
9383 SiS_Pr->SiS_DDC_Index = 0x0f;
9387 if(!(VBFlags & VB_301)) {
9388 if((cr32 & 0x80) && (checkcr32)) {
9389 if(myadaptnum >= 1) {
9390 if(!(cr32 & 0x08)) {
9392 if(!(cr32 & 0x10)) return 0xFFFF;
9398 temp = 4 - (myadaptnum * 2);
9401 } else { /* 315/330 series */
9403 /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */
9405 if(VBFlags & VB_SISBRIDGE) {
9406 if(myadaptnum == 2) {
9411 if(myadaptnum == 1) {
9413 if(VBFlags & VB_SISBRIDGE) {
9414 SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port;
9415 SiS_Pr->SiS_DDC_Index = 0x0f;
9419 if((cr32 & 0x80) && (checkcr32)) {
9420 if(myadaptnum >= 1) {
9421 if(!(cr32 & 0x08)) {
9423 if(!(cr32 & 0x10)) return 0xFFFF;
9429 if(myadaptnum == 1) {
9431 if(VBFlags & VB_LVDS) flag = 0xff;
9437 SiS_Pr->SiS_DDC_Data = 0x02 << temp;
9438 SiS_Pr->SiS_DDC_Clk = 0x01 << temp;
9440 SiS_SetupDDCN(SiS_Pr);
9443 xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n",
9444 SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp);
9451 SiS_WriteDABDDC(SiS_Private *SiS_Pr)
9453 if(SiS_SetStart(SiS_Pr)) return 0xFFFF;
9454 if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) {
9457 if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) {
9464 SiS_PrepareReadDDC(SiS_Private *SiS_Pr)
9466 if(SiS_SetStart(SiS_Pr)) return 0xFFFF;
9467 if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) {
9474 SiS_PrepareDDC(SiS_Private *SiS_Pr)
9476 if(SiS_WriteDABDDC(SiS_Pr)) SiS_WriteDABDDC(SiS_Pr);
9477 if(SiS_PrepareReadDDC(SiS_Pr)) return(SiS_PrepareReadDDC(SiS_Pr));
9482 SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno)
9484 SiS_SetSCLKLow(SiS_Pr);
9486 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
9487 SiS_Pr->SiS_DDC_Index,
9488 SiS_Pr->SiS_DDC_NData,
9489 SiS_Pr->SiS_DDC_Data);
9491 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
9492 SiS_Pr->SiS_DDC_Index,
9493 SiS_Pr->SiS_DDC_NData,
9496 SiS_SetSCLKHigh(SiS_Pr);
9500 SiS_DoProbeDDC(SiS_Private *SiS_Pr)
9502 unsigned char mask, value;
9504 BOOLEAN failed = FALSE;
9506 SiS_SetSwitchDDC2(SiS_Pr);
9507 if(SiS_PrepareDDC(SiS_Pr)) {
9508 SiS_SetStop(SiS_Pr);
9510 xf86DrvMsg(0, X_INFO, "Probe: Prepare failed\n");
9516 if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
9517 temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
9518 SiS_SendACK(SiS_Pr, 0);
9526 xf86DrvMsg(0, X_INFO, "Probe: Read 1 failed\n");
9530 if(failed == FALSE) {
9531 temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
9532 SiS_SendACK(SiS_Pr, 1);
9534 if(temp == value) ret = 0;
9538 xf86DrvMsg(0, X_INFO, "Probe: Read 2 failed\n");
9540 if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
9541 if(temp == 0x30) ret = 0;
9545 SiS_SetStop(SiS_Pr);
9550 SiS_ProbeDDC(SiS_Private *SiS_Pr)
9555 SiS_Pr->SiS_DDC_DeviceAddr = 0xa0;
9556 if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x02;
9557 SiS_Pr->SiS_DDC_DeviceAddr = 0xa2;
9558 if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x08;
9559 SiS_Pr->SiS_DDC_DeviceAddr = 0xa6;
9560 if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x10;
9561 if(!(flag & 0x1a)) flag = 0;
9566 SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer)
9568 USHORT flag, length, i;
9569 unsigned char chksum,gotcha;
9571 if(DDCdatatype > 4) return 0xFFFF;
9574 SiS_SetSwitchDDC2(SiS_Pr);
9575 if(!(SiS_PrepareDDC(SiS_Pr))) {
9577 if(DDCdatatype != 1) length = 255;
9580 for(i=0; i<length; i++) {
9581 buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
9582 chksum += buffer[i];
9583 gotcha |= buffer[i];
9584 SiS_SendACK(SiS_Pr, 0);
9586 buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
9587 chksum += buffer[i];
9588 SiS_SendACK(SiS_Pr, 1);
9589 if(gotcha) flag = (USHORT)chksum;
9594 SiS_SetStop(SiS_Pr);
9598 /* Our private DDC functions
9600 It complies somewhat with the corresponding VESA function
9601 in arguments and return values.
9603 Since this is probably called before the mode is changed,
9604 we use our pre-detected pSiS-values instead of SiS_Pr as
9605 regards chipset and video bridge type.
9608 adaptnum: 0=CRT1(analog), 1=CRT2/LCD(digital), 2=CRT2/VGA2(analog)
9609 CRT2 DDC is only supported on SiS301, 301B, 301C, 302B.
9610 LCDA is CRT1, but DDC is read from CRT2 port.
9611 DDCdatatype: 0=Probe, 1=EDID, 2=EDID+VDIF, 3=EDID V2 (P&D), 4=EDID V2 (FPDI-2)
9612 buffer: ptr to 256 data bytes which will be filled with read data.
9614 Returns 0xFFFF if error, otherwise
9615 if DDCdatatype > 0: Returns 0 if reading OK (included a correct checksum)
9616 if DDCdatatype = 0: Returns supported DDC modes
9620 SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
9621 USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer)
9623 unsigned char sr1f,cr17=1;
9626 if(adaptnum > 2) return 0xFFFF;
9627 if(DDCdatatype > 4) return 0xFFFF;
9628 if((!(VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF;
9629 if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE) == 0xFFFF) return 0xFFFF;
9631 sr1f = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f);
9632 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1f,0x3f,0x04);
9633 if(VGAEngine == SIS_300_VGA) {
9634 cr17 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80;
9636 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x17,0x80);
9637 SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x01);
9638 SiS_SetReg(SiS_Pr->SiS_P3c4,0x00,0x03);
9641 if((sr1f) || (!cr17)) {
9642 SiS_WaitRetrace1(SiS_Pr);
9643 SiS_WaitRetrace1(SiS_Pr);
9644 SiS_WaitRetrace1(SiS_Pr);
9645 SiS_WaitRetrace1(SiS_Pr);
9648 if(DDCdatatype == 0) {
9649 result = SiS_ProbeDDC(SiS_Pr);
9651 result = SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer);
9652 if((!result) && (DDCdatatype == 1)) {
9653 if((buffer[0] == 0x00) && (buffer[1] == 0xff) &&
9654 (buffer[2] == 0xff) && (buffer[3] == 0xff) &&
9655 (buffer[4] == 0xff) && (buffer[5] == 0xff) &&
9656 (buffer[6] == 0xff) && (buffer[7] == 0x00) &&
9657 (buffer[0x12] == 1)) {
9659 if(!(buffer[0x14] & 0x80)) result = 0xFFFE;
9661 if(buffer[0x14] & 0x80) result = 0xFFFE;
9666 SiS_SetReg(SiS_Pr->SiS_P3c4,0x1f,sr1f);
9667 if(VGAEngine == SIS_300_VGA) {
9668 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x17,0x7f,cr17);
9676 checkedid1(unsigned char *buffer)
9679 if((buffer[0] != 0x00) ||
9680 (buffer[1] != 0xff) ||
9681 (buffer[2] != 0xff) ||
9682 (buffer[3] != 0xff) ||
9683 (buffer[4] != 0xff) ||
9684 (buffer[5] != 0xff) ||
9685 (buffer[6] != 0xff) ||
9686 (buffer[7] != 0x00))
9689 /* Check EDID version and revision */
9690 if((buffer[0x12] != 1) || (buffer[0x13] > 4)) return FALSE;
9692 /* Check week of manufacture for sanity */
9693 if(buffer[0x10] > 53) return FALSE;
9695 /* Check year of manufacture for sanity */
9696 if(buffer[0x11] > 40) return FALSE;
9702 checkedid2(unsigned char *buffer)
9704 USHORT year = buffer[6] | (buffer[7] << 8);
9706 /* Check EDID version */
9707 if((buffer[0] & 0xf0) != 0x20) return FALSE;
9709 /* Check week of manufacture for sanity */
9710 if(buffer[5] > 53) return FALSE;
9712 /* Check year of manufacture for sanity */
9713 if((year != 0) && ((year < 1990) || (year > 2030))) return FALSE;
9718 /* Sense the LCD parameters (CR36, CR37) via DDC */
9719 /* SiS30x(B) only */
9721 SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS)
9723 USHORT DDCdatatype, paneltype, flag, xres=0, yres=0;
9724 USHORT index, myindex, lumsize, numcodes, panelvendor, panelproduct;
9725 int maxx=0, maxy=0, prefx=0, prefy=0;
9726 unsigned char cr37=0, seekcode;
9727 BOOLEAN checkexpand = FALSE;
9728 BOOLEAN havesync = FALSE;
9729 BOOLEAN indb = FALSE;
9731 unsigned char buffer[256];
9733 for(i=0; i<7; i++) SiS_Pr->CP_DataValid[i] = FALSE;
9734 SiS_Pr->CP_HaveCustomData = FALSE;
9735 SiS_Pr->CP_MaxX = SiS_Pr->CP_MaxY = SiS_Pr->CP_MaxClock = 0;
9736 SiS_Pr->CP_PreferredX = SiS_Pr->CP_PreferredY = 0;
9737 SiS_Pr->CP_PreferredIndex = -1;
9738 SiS_Pr->CP_PrefClock = 0;
9739 SiS_Pr->PanelSelfDetected = FALSE;
9741 if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0;
9742 if(pSiS->VBFlags & VB_30xBDH) return 0;
9744 if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 1, 0, FALSE) == 0xFFFF) return 0;
9746 SiS_Pr->SiS_DDC_SecAddr = 0x00;
9748 /* Probe supported DA's */
9749 flag = SiS_ProbeDDC(SiS_Pr);
9751 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO,
9752 "CRT2 DDC capabilities 0x%x\n", flag);
9755 SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */
9757 } else if(flag & 0x08) {
9758 SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */
9760 } else if(flag & 0x02) {
9761 SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */
9763 } else return 0; /* no DDC support (or no device attached) */
9765 /* Read the entire EDID */
9768 if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) {
9769 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9770 "CRT2: DDC read failed (attempt %d), %s\n",
9771 (3-retry), (retry == 1) ? "giving up" : "retrying");
9773 if(retry == 0) return 0xFFFF;
9778 for(i=0; i<256; i+=16) {
9779 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9780 "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
9781 buffer[i], buffer[i+1], buffer[i+2], buffer[i+3],
9782 buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7],
9783 buffer[i+8], buffer[i+9], buffer[i+10], buffer[i+11],
9784 buffer[i+12], buffer[i+13], buffer[i+14], buffer[i+15]);
9788 /* Analyze EDID and retrieve LCD panel information */
9790 switch(DDCdatatype) {
9791 case 1: /* Analyze EDID V1 */
9792 /* Catch a few clear cases: */
9793 if(!(checkedid1(buffer))) {
9794 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9795 "LCD sense: EDID corrupt\n");
9799 if(!(buffer[0x14] & 0x80)) {
9800 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9801 "LCD sense: Attached display expects analog input (0x%02x)\n",
9806 if((buffer[0x18] & 0x18) != 0x08) {
9807 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9808 "LCD sense: Warning: Attached display is not of RGB but of %s type (0x%02x)\n",
9809 ((buffer[0x18] & 0x18) == 0x00) ? "monochrome/greyscale" :
9810 ( ((buffer[0x18] & 0x18) == 0x10) ? "non-RGB multicolor" :
9815 /* Now analyze the first Detailed Timing Block and see
9816 * if the preferred timing mode is stored there. If so,
9817 * check if this is a standard panel for which we already
9821 paneltype = Panel_Custom;
9822 checkexpand = FALSE;
9824 panelvendor = buffer[9] | (buffer[8] << 8);
9825 panelproduct = buffer[10] | (buffer[11] << 8);
9827 /* Overrule bogus preferred modes from database */
9828 if((indb = SiS_FindPanelFromDB(pSiS, panelvendor, panelproduct, &maxx, &maxy, &prefx, &prefy))) {
9829 if(prefx) SiS_Pr->CP_PreferredX = xres = prefx;
9830 if(prefy) SiS_Pr->CP_PreferredY = yres = prefy;
9833 if(buffer[0x18] & 0x02) {
9835 USHORT pclk = (buffer[0x36] | (buffer[0x37] << 8));
9836 USHORT phb = (buffer[0x39] | ((buffer[0x3a] & 0x0f) << 8));
9837 USHORT pvb = (buffer[0x3c] | ((buffer[0x3d] & 0x0f) << 8));
9839 if(!xres) SiS_Pr->CP_PreferredX = xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4);
9840 if(!yres) SiS_Pr->CP_PreferredY = yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4);
9843 #if 0 /* Treat as custom */
9846 paneltype = Panel_800x600;
9853 paneltype = Panel_1024x768;
9859 paneltype = Panel_1280x1024;
9861 } else if(yres == 960) {
9862 if(pSiS->VGAEngine == SIS_300_VGA) {
9863 paneltype = Panel300_1280x960;
9865 paneltype = Panel310_1280x960;
9867 } else if(yres == 768) {
9868 if( (pclk == 8100) &&
9869 (phb == (1688 - 1280)) &&
9870 (pvb == (802 - 768)) ) {
9871 paneltype = Panel_1280x768;
9872 checkexpand = FALSE;
9875 } else if(yres == 800) {
9876 if( (pclk == 6900) &&
9877 (phb == (1408 - 1280)) &&
9878 (pvb == (816 - 800)) ) {
9879 paneltype = Panel_1280x800;
9884 if(pSiS->VGAEngine == SIS_315_VGA) {
9886 paneltype = Panel310_1400x1050;
9892 if(pSiS->VGAEngine == SIS_315_VGA) {
9893 if(pSiS->VBFlags & VB_301C) {
9895 paneltype = Panel310_1600x1200;
9903 /* Save sync: This is used if "Pass 1:1" is off; in this case
9904 * we always use the panel's native mode = this "preferred mode"
9905 * we just have been analysing. Hence, we also need its sync.
9907 if((buffer[0x47] & 0x18) == 0x18) {
9908 cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20);
9911 /* What now? There is no digital separate output timing... */
9912 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
9913 "LCD sense: Unable to retrieve Sync polarity information\n");
9914 cr37 |= 0xc0; /* Default */
9919 /* Check against our database; eg. Sanyo Z2 projector reports
9920 * 1024x768 as preferred mode, although it supports 1280x720
9921 * natively in non-HDCP mode. Treat such wrongly reporting
9922 * panels as custom and fixup actual maximum resolutions.
9924 if(paneltype != Panel_Custom) {
9926 paneltype = Panel_Custom;
9927 SiS_Pr->CP_MaxX = maxx;
9928 SiS_Pr->CP_MaxY = maxy;
9929 /* Leave preferred unchanged (MUST contain a valid mode!) */
9933 /* If we still don't know what panel this is, we take it
9934 * as a custom panel and derive the timing data from the
9935 * detailed timing blocks
9937 if(paneltype == Panel_Custom) {
9939 int i, temp, base = 0x36;
9940 unsigned long estpack;
9941 const unsigned short estx[] = {
9942 720, 720, 640, 640, 640, 640, 800, 800,
9943 800, 800, 832,1024,1024,1024,1024,1280,
9946 const unsigned short esty[] = {
9947 400, 400, 480, 480, 480, 480, 600, 600,
9948 600, 600, 624, 768, 768, 768, 768,1024,
9951 const int estclk[] = {
9952 0, 0, 25100, 0, 31500, 31500, 36100, 40000,
9953 50100, 49500, 0, 0, 65100, 75200, 78700,135200,
9958 SiS_Pr->CP_Supports64048075 = TRUE;
9960 /* Find the maximum resolution */
9962 /* 1. From Established timings */
9963 estpack = (buffer[0x23] << 9) | (buffer[0x24] << 1) | ((buffer[0x25] >> 7) & 0x01);
9964 for(i=16; i>=0; i--) {
9965 if(estpack & (1 << i)) {
9966 if(estx[16 - i] > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = estx[16 - i];
9967 if(esty[16 - i] > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = esty[16 - i];
9968 if(estclk[16 - i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = estclk[16 - i];
9972 /* By default we drive the LCD at 75Hz in 640x480 mode; if
9973 * the panel does not provide this mode, use 60hz
9975 if(!(buffer[0x23] & 0x04)) SiS_Pr->CP_Supports64048075 = FALSE;
9977 /* 2. From Standard Timings */
9978 for(i=0x26; i < 0x36; i+=2) {
9979 if((buffer[i] != 0x01) && (buffer[i+1] != 0x01)) {
9980 temp = (buffer[i] + 31) * 8;
9981 if(temp > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = temp;
9982 switch((buffer[i+1] & 0xc0) >> 6) {
9983 case 0x03: temp = temp * 9 / 16; break;
9984 case 0x02: temp = temp * 4 / 5; break;
9985 case 0x01: temp = temp * 3 / 4; break;
9987 if(temp > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = temp;
9991 /* Now extract the Detailed Timings and convert them into modes */
9993 for(i = 0; i < 4; i++, base += 18) {
9995 /* Is this a detailed timing block or a monitor descriptor? */
9996 if(buffer[base] || buffer[base+1] || buffer[base+2]) {
9998 xres = buffer[base+2] | ((buffer[base+4] & 0xf0) << 4);
9999 yres = buffer[base+5] | ((buffer[base+7] & 0xf0) << 4);
10001 SiS_Pr->CP_HDisplay[i] = xres;
10002 SiS_Pr->CP_HSyncStart[i] = xres + (buffer[base+8] | ((buffer[base+11] & 0xc0) << 2));
10003 SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[base+9] | ((buffer[base+11] & 0x30) << 4));
10004 SiS_Pr->CP_HTotal[i] = xres + (buffer[base+3] | ((buffer[base+4] & 0x0f) << 8));
10005 SiS_Pr->CP_HBlankStart[i] = xres + 1;
10006 SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i];
10008 SiS_Pr->CP_VDisplay[i] = yres;
10009 SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[base+10] & 0xf0) >> 4) | ((buffer[base+11] & 0x0c) << 2));
10010 SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[base+10] & 0x0f) | ((buffer[base+11] & 0x03) << 4));
10011 SiS_Pr->CP_VTotal[i] = yres + (buffer[base+6] | ((buffer[base+7] & 0x0f) << 8));
10012 SiS_Pr->CP_VBlankStart[i] = yres + 1;
10013 SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i];
10015 SiS_Pr->CP_Clock[i] = (buffer[base] | (buffer[base+1] << 8)) * 10;
10017 SiS_Pr->CP_DataValid[i] = TRUE;
10019 /* Sort out invalid timings, interlace and too high clocks */
10020 if((SiS_Pr->CP_HDisplay[i] & 7) ||
10021 (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) ||
10022 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
10023 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) ||
10024 (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
10025 (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) ||
10026 (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) ||
10027 (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) ||
10028 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) ||
10029 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) ||
10030 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) ||
10031 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) ||
10032 (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) ||
10033 (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) ||
10034 ((!(pSiS->VBFlags & VB_301C)) &&
10035 ((SiS_Pr->CP_Clock[i] > 108200) || (SiS_Pr->CP_VDisplay[i] > 1024) ||
10036 (SiS_Pr->CP_HDisplay[i] > 1600)))) ||
10037 (buffer[base+17] & 0x80)) {
10039 SiS_Pr->CP_DataValid[i] = FALSE;
10043 SiS_Pr->CP_HaveCustomData = TRUE;
10045 if(xres > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = xres;
10046 if(yres > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = yres;
10047 if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i];
10049 if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) {
10050 SiS_Pr->CP_PreferredIndex = i;
10051 SiS_MakeClockRegs(pSiS->pScrn, SiS_Pr->CP_Clock[i], &SiS_Pr->CP_PrefSR2B, &SiS_Pr->CP_PrefSR2C);
10052 SiS_Pr->CP_PrefClock = (SiS_Pr->CP_Clock[i] / 1000) + 1;
10055 /* Extract the sync polarisation information. This only works
10056 * if the Flags indicate a digital separate output.
10058 if((buffer[base+17] & 0x18) == 0x18) {
10059 SiS_Pr->CP_HSync_P[i] = (buffer[base+17] & 0x02) ? TRUE : FALSE;
10060 SiS_Pr->CP_VSync_P[i] = (buffer[base+17] & 0x04) ? TRUE : FALSE;
10061 SiS_Pr->CP_SyncValid[i] = TRUE;
10062 if((i == SiS_Pr->CP_PreferredIndex) && (!havesync)) {
10063 cr37 |= ((((buffer[base+17] & 0x06) ^ 0x06) << 5) | 0x20);
10067 SiS_Pr->CP_SyncValid[i] = FALSE;
10072 } else if((!buffer[base]) && (!buffer[base+1]) && (!buffer[base+2]) && (!buffer[base+4])) {
10074 /* Maximum pixclock from Monitor Range Limits */
10075 if((buffer[base+3] == 0xfd) && (buffer[base+9] != 0xff)) {
10076 int maxclk = buffer[base+9] * 10;
10077 /* More than 170 is not supported anyway */
10078 if(maxclk <= 170) SiS_Pr->CP_MaxClock = maxclk * 1000;
10085 if(SiS_Pr->CP_MaxX && SiS_Pr->CP_MaxY) {
10086 paneltype = Panel_Custom;
10087 checkexpand = FALSE;
10089 SiS_Pr->CP_Vendor = panelvendor;
10090 SiS_Pr->CP_Product = panelproduct;
10095 if(paneltype && checkexpand) {
10096 /* If any of the Established low-res modes is supported, the
10097 * panel can scale automatically. For 800x600 panels, we only
10098 * check the even lower ones.
10100 if(paneltype == Panel_800x600) {
10101 if(buffer[0x23] & 0xfc) cr37 |= 0x10;
10103 if(buffer[0x23]) cr37 |= 0x10;
10109 case 3: /* Analyze EDID V2 */
10113 if(!(checkedid2(buffer))) {
10114 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10115 "LCD sense: EDID corrupt\n");
10119 if((buffer[0x41] & 0x0f) == 0x03) {
10121 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10122 "LCD sense: Display supports TMDS input on primary interface\n");
10123 } else if((buffer[0x41] & 0xf0) == 0x30) {
10125 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10126 "LCD sense: Display supports TMDS input on secondary interface\n");
10128 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10129 "LCD sense: Display does not support TMDS video interface (0x%02x)\n",
10134 SiS_Pr->CP_Vendor = panelvendor = buffer[2] | (buffer[1] << 8);
10135 SiS_Pr->CP_Product = panelproduct = buffer[3] | (buffer[4] << 8);
10137 paneltype = Panel_Custom;
10138 SiS_Pr->CP_MaxX = SiS_Pr->CP_PreferredX = xres = buffer[0x76] | (buffer[0x77] << 8);
10139 SiS_Pr->CP_MaxY = SiS_Pr->CP_PreferredY = yres = buffer[0x78] | (buffer[0x79] << 8);
10145 paneltype = Panel_800x600;
10146 checkexpand = TRUE;
10152 paneltype = Panel_1024x768;
10153 checkexpand = TRUE;
10158 if(pSiS->VGAEngine == SIS_315_VGA) {
10159 paneltype = Panel310_1280x960;
10161 paneltype = Panel300_1280x960;
10163 } else if(yres == 1024) {
10164 paneltype = Panel_1280x1024;
10165 checkexpand = TRUE;
10167 /* 1280x768 treated as custom here */
10170 if(pSiS->VGAEngine == SIS_315_VGA) {
10172 paneltype = Panel310_1400x1050;
10173 checkexpand = TRUE;
10178 if(pSiS->VGAEngine == SIS_315_VGA) {
10179 if(pSiS->VBFlags & VB_301C) {
10181 paneltype = Panel310_1600x1200;
10182 checkexpand = TRUE;
10189 /* Determine if RGB18 or RGB24 */
10191 if((buffer[index] == 0x20) || (buffer[index] == 0x34)) {
10197 /* TODO - for now, we let the panel scale */
10201 /* Now seek 4-Byte Timing codes and extract sync pol info */
10203 if(buffer[0x7e] & 0x20) { /* skip Luminance Table (if provided) */
10204 lumsize = buffer[0x80] & 0x1f;
10205 if(buffer[0x80] & 0x80) lumsize *= 3;
10206 lumsize++; /* luminance header byte */
10209 #if 0 /* "pixel rate" = pixel clock? */
10210 if(buffer[0x7e] & 0x1c) {
10211 for(i=0; i<((buffer[0x7e] & 0x1c) >> 2); i++) {
10212 if(buffer[index + (i*8) + 6] && (buffer[index + (i*8) + 7] & 0x0f)) {
10213 int clk = (buffer[index + (i*8) + 6] | ((buffer[index + (i*8) + 7] & 0x0f) << 4)) * 1000;
10214 if(clk > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = clk;
10219 index += (((buffer[0x7e] & 0x1c) >> 2) * 8); /* skip Frequency Ranges */
10220 if(buffer[0x7e] & 0x03) {
10221 for(i=0; i<(buffer[0x7e] & 0x03); i++) {
10222 if((buffer[index + (i*27) + 9]) || (buffer[index + (i*27) + 10])) {
10223 int clk = ((buffer[index + (i*27) + 9]) | ((buffer[index + (i*27) + 9]) << 8)) * 10;
10224 if(clk > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = clk;
10228 index += ((buffer[0x7e] & 0x03) * 27); /* skip Detailed Range Limits */
10229 numcodes = (buffer[0x7f] & 0xf8) >> 3;
10232 seekcode = (xres - 256) / 16;
10233 for(i=0; i<numcodes; i++) {
10234 if(buffer[myindex] == seekcode) break;
10237 if(buffer[myindex] == seekcode) {
10238 cr37 |= ((((buffer[myindex + 1] & 0x0c) ^ 0x0c) << 4) | 0x20);
10241 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
10242 "LCD sense: Unable to retrieve Sync polarity information\n");
10245 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
10246 "LCD sense: Unable to retrieve Sync polarity information\n");
10249 /* Check against our database; Eg. Sanyo projector reports
10250 * 1024x768 in non-HDPC mode, although it supports 1280x720.
10251 * Treat such wrongly reporting panels as custom.
10253 if(paneltype != Panel_Custom) {
10254 int maxx, maxy, prefx, prefy;
10255 if((SiS_FindPanelFromDB(pSiS, panelvendor, panelproduct, &maxx, &maxy, &prefx, &prefy))) {
10256 paneltype = Panel_Custom;
10257 SiS_Pr->CP_MaxX = maxx;
10258 SiS_Pr->CP_MaxY = maxy;
10260 /* Leave preferred unchanged (MUST be a valid mode!) */
10264 /* Now seek the detailed timing descriptions for custom panels */
10265 if(paneltype == Panel_Custom) {
10267 SiS_Pr->CP_Supports64048075 = TRUE;
10269 index += (numcodes * 4);
10270 numcodes = buffer[0x7f] & 0x07;
10271 for(i=0; i<numcodes; i++, index += 18) {
10272 xres = buffer[index+2] | ((buffer[index+4] & 0xf0) << 4);
10273 yres = buffer[index+5] | ((buffer[index+7] & 0xf0) << 4);
10275 SiS_Pr->CP_HDisplay[i] = xres;
10276 SiS_Pr->CP_HSyncStart[i] = xres + (buffer[index+8] | ((buffer[index+11] & 0xc0) << 2));
10277 SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[index+9] | ((buffer[index+11] & 0x30) << 4));
10278 SiS_Pr->CP_HTotal[i] = xres + (buffer[index+3] | ((buffer[index+4] & 0x0f) << 8));
10279 SiS_Pr->CP_HBlankStart[i] = xres + 1;
10280 SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i];
10282 SiS_Pr->CP_VDisplay[i] = yres;
10283 SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[index+10] & 0xf0) >> 4) | ((buffer[index+11] & 0x0c) << 2));
10284 SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[index+10] & 0x0f) | ((buffer[index+11] & 0x03) << 4));
10285 SiS_Pr->CP_VTotal[i] = yres + (buffer[index+6] | ((buffer[index+7] & 0x0f) << 8));
10286 SiS_Pr->CP_VBlankStart[i] = yres + 1;
10287 SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i];
10289 SiS_Pr->CP_Clock[i] = (buffer[index] | (buffer[index+1] << 8)) * 10;
10291 SiS_Pr->CP_DataValid[i] = TRUE;
10293 if((SiS_Pr->CP_HDisplay[i] & 7) ||
10294 (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) ||
10295 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
10296 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) ||
10297 (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
10298 (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) ||
10299 (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) ||
10300 (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) ||
10301 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) ||
10302 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) ||
10303 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) ||
10304 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) ||
10305 (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) ||
10306 (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) ||
10307 ((!(pSiS->VBFlags & VB_301C)) &&
10308 ((SiS_Pr->CP_Clock[i] > 108200) || (SiS_Pr->CP_VDisplay[i] > 1024)))) ||
10309 (buffer[index + 17] & 0x80)) {
10311 SiS_Pr->CP_DataValid[i] = FALSE;
10315 SiS_Pr->CP_HaveCustomData = TRUE;
10317 if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i];
10319 if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) {
10320 SiS_Pr->CP_PreferredIndex = i;
10321 SiS_MakeClockRegs(pSiS->pScrn, SiS_Pr->CP_Clock[i], &SiS_Pr->CP_PrefSR2B, &SiS_Pr->CP_PrefSR2C);
10322 SiS_Pr->CP_PrefClock = (SiS_Pr->CP_Clock[i] / 1000) + 1;
10324 cr37 |= ((((buffer[index + 17] & 0x06) ^ 0x06) << 5) | 0x20);
10329 SiS_Pr->CP_HSync_P[i] = (buffer[index + 17] & 0x02) ? TRUE : FALSE;
10330 SiS_Pr->CP_VSync_P[i] = (buffer[index + 17] & 0x04) ? TRUE : FALSE;
10331 SiS_Pr->CP_SyncValid[i] = TRUE;
10344 /* 1280x960 panels are always RGB24, unable to scale and use
10345 * high active sync polarity
10347 if(pSiS->VGAEngine == SIS_315_VGA) {
10348 if(paneltype == Panel310_1280x960) cr37 &= 0x0e;
10350 if(paneltype == Panel300_1280x960) cr37 &= 0x0e;
10353 for(i = 0; i < 7; i++) {
10354 if(SiS_Pr->CP_DataValid[i]) {
10355 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10356 "Non-standard LCD/DVI-D timing data no. %d:\n", i);
10357 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10358 " HDisplay %d HSync %d HSyncEnd %d HTotal %d\n",
10359 SiS_Pr->CP_HDisplay[i], SiS_Pr->CP_HSyncStart[i],
10360 SiS_Pr->CP_HSyncEnd[i], SiS_Pr->CP_HTotal[i]);
10361 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10362 " VDisplay %d VSync %d VSyncEnd %d VTotal %d\n",
10363 SiS_Pr->CP_VDisplay[i], SiS_Pr->CP_VSyncStart[i],
10364 SiS_Pr->CP_VSyncEnd[i], SiS_Pr->CP_VTotal[i]);
10365 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10366 " Pixel clock: %3.3fMhz\n", (float)SiS_Pr->CP_Clock[i] / 1000);
10367 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO,
10368 " To use this, add \"%dx%d\" to the list of Modes in the Screen section\n",
10369 SiS_Pr->CP_HDisplay[i],
10370 SiS_Pr->CP_VDisplay[i]);
10375 if(!SiS_Pr->CP_PreferredX) SiS_Pr->CP_PreferredX = SiS_Pr->CP_MaxX;
10376 if(!SiS_Pr->CP_PreferredY) SiS_Pr->CP_PreferredY = SiS_Pr->CP_MaxY;
10377 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x08);
10378 SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,paneltype);
10380 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0x0c,cr37);
10381 SiS_Pr->PanelSelfDetected = TRUE;
10383 xf86DrvMsgVerb(pSiS->pScrn->scrnIndex, X_PROBED, 3,
10384 "LCD sense: [DDC LCD results: 0x%02x, 0x%02x]\n", paneltype, cr37);
10387 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x32,~0x08);
10388 SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,0x00);
10394 SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS)
10396 USHORT DDCdatatype,flag;
10397 BOOLEAN foundcrt = FALSE;
10399 unsigned char buffer[256];
10401 if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0;
10403 if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 2, 0, FALSE) == 0xFFFF) return 0;
10405 SiS_Pr->SiS_DDC_SecAddr = 0x00;
10407 /* Probe supported DA's */
10408 flag = SiS_ProbeDDC(SiS_Pr);
10410 SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */
10412 } else if(flag & 0x08) {
10413 SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */
10415 } else if(flag & 0x02) {
10416 SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */
10419 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10420 "VGA2 sense: Do DDC answer\n");
10421 return 0; /* no DDC support (or no device attached) */
10424 /* Read the entire EDID */
10427 if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) {
10428 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10429 "VGA2 sense: DDC read failed (attempt %d), %s\n",
10430 (3-retry), (retry == 1) ? "giving up" : "retrying");
10432 if(retry == 0) return 0xFFFF;
10436 /* Analyze EDID. We don't have many chances to
10437 * distinguish a flat panel from a CRT...
10439 switch(DDCdatatype) {
10441 if(!(checkedid1(buffer))) {
10442 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR,
10443 "VGA2 sense: EDID corrupt\n");
10446 if(buffer[0x14] & 0x80) { /* Display uses digital input */
10447 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR,
10448 "VGA2 sense: Attached display expects digital input\n");
10451 SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8);
10452 SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8);
10457 if(!(checkedid2(buffer))) {
10458 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR,
10459 "VGA2 sense: EDID corrupt\n");
10462 if( ((buffer[0x41] & 0x0f) != 0x01) && /* Display does not support analog input */
10463 ((buffer[0x41] & 0x0f) != 0x02) &&
10464 ((buffer[0x41] & 0xf0) != 0x10) &&
10465 ((buffer[0x41] & 0xf0) != 0x20) ) {
10466 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR,
10467 "VGA2 sense: Attached display does not support analog input (0x%02x)\n",
10471 SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8);
10472 SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8);
10478 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10);
10486 SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh)
10490 tempbl = SiS_GetCH70xx(SiS_Pr,(tempax & 0x00FF));
10491 tempbl = (((tempbl & tempbh) << 8) | tempax);
10492 SiS_SetCH70xx(SiS_Pr,tempbl);
10495 /* Generic I2C functions for Chrontel & DDC --------- */
10498 SiS_SetSwitchDDC2(SiS_Private *SiS_Pr)
10500 SiS_SetSCLKHigh(SiS_Pr);
10501 SiS_WaitRetrace1(SiS_Pr);
10503 SiS_SetSCLKLow(SiS_Pr);
10504 SiS_WaitRetrace1(SiS_Pr);
10508 SiS_ReadDDC1Bit(SiS_Private *SiS_Pr)
10510 SiS_WaitRetrace1(SiS_Pr);
10511 return((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1);
10514 /* Set I2C start condition */
10515 /* This is done by a SD high-to-low transition while SC is high */
10517 SiS_SetStart(SiS_Private *SiS_Pr)
10519 if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */
10520 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10521 SiS_Pr->SiS_DDC_Index,
10522 SiS_Pr->SiS_DDC_NData,
10523 SiS_Pr->SiS_DDC_Data); /* SD->high */
10524 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */
10525 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10526 SiS_Pr->SiS_DDC_Index,
10527 SiS_Pr->SiS_DDC_NData,
10528 0x00); /* SD->low = start condition */
10529 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */
10533 /* Set I2C stop condition */
10534 /* This is done by a SD low-to-high transition while SC is high */
10536 SiS_SetStop(SiS_Private *SiS_Pr)
10538 if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */
10539 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10540 SiS_Pr->SiS_DDC_Index,
10541 SiS_Pr->SiS_DDC_NData,
10542 0x00); /* SD->low */
10543 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */
10544 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10545 SiS_Pr->SiS_DDC_Index,
10546 SiS_Pr->SiS_DDC_NData,
10547 SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */
10548 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */
10552 /* Write 8 bits of data */
10554 SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax)
10556 USHORT i,flag,temp;
10559 for(i=0; i<8; i++) {
10560 SiS_SetSCLKLow(SiS_Pr); /* SC->low */
10561 if(tempax & flag) {
10562 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10563 SiS_Pr->SiS_DDC_Index,
10564 SiS_Pr->SiS_DDC_NData,
10565 SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */
10567 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10568 SiS_Pr->SiS_DDC_Index,
10569 SiS_Pr->SiS_DDC_NData,
10570 0x00); /* Write bit (0) to SD */
10572 SiS_SetSCLKHigh(SiS_Pr); /* SC->high */
10575 temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */
10580 SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax)
10582 USHORT i,temp,getdata;
10585 for(i=0; i<8; i++) {
10587 SiS_SetSCLKLow(SiS_Pr);
10588 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10589 SiS_Pr->SiS_DDC_Index,
10590 SiS_Pr->SiS_DDC_NData,
10591 SiS_Pr->SiS_DDC_Data);
10592 SiS_SetSCLKHigh(SiS_Pr);
10593 temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);
10594 if(temp & SiS_Pr->SiS_DDC_Data) getdata |= 0x01;
10600 SiS_SetSCLKLow(SiS_Private *SiS_Pr)
10602 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10603 SiS_Pr->SiS_DDC_Index,
10604 SiS_Pr->SiS_DDC_NClk,
10605 0x00); /* SetSCLKLow() */
10606 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
10611 SiS_SetSCLKHigh(SiS_Private *SiS_Pr)
10613 USHORT temp, watchdog=1000;
10615 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10616 SiS_Pr->SiS_DDC_Index,
10617 SiS_Pr->SiS_DDC_NClk,
10618 SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */
10620 temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);
10621 } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog);
10624 xf86DrvMsg(0, X_INFO, "SetClkHigh failed\n");
10628 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
10632 /* Check I2C acknowledge */
10633 /* Returns 0 if ack ok, non-0 if ack not ok */
10635 SiS_CheckACK(SiS_Private *SiS_Pr)
10639 SiS_SetSCLKLow(SiS_Pr); /* (SC->low) */
10640 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10641 SiS_Pr->SiS_DDC_Index,
10642 SiS_Pr->SiS_DDC_NData,
10643 SiS_Pr->SiS_DDC_Data); /* (SD->high) */
10644 SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */
10645 tempah = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); /* Read SD */
10646 SiS_SetSCLKLow(SiS_Pr); /* SC->low = end of clock impulse */
10647 if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* Ack OK if bit = 0 */
10651 /* End of I2C functions ----------------------- */
10654 /* =============== SiS 315/330 O.E.M. ================= */
10659 GetRAMDACromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
10661 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
10664 if(HwInfo->jChipType < SIS_330) {
10665 romptr = SISGETROMW(0x128);
10666 if(SiS_Pr->SiS_VBType & VB_SIS301B302B)
10667 romptr = SISGETROMW(0x12a);
10669 romptr = SISGETROMW(0x1a8);
10670 if(SiS_Pr->SiS_VBType & VB_SIS301B302B)
10671 romptr = SISGETROMW(0x1aa);
10677 GetLCDromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
10679 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
10682 if(HwInfo->jChipType < SIS_330) {
10683 romptr = SISGETROMW(0x120);
10684 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
10685 romptr = SISGETROMW(0x122);
10687 romptr = SISGETROMW(0x1a0);
10688 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
10689 romptr = SISGETROMW(0x1a2);
10695 GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
10697 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
10700 if(HwInfo->jChipType < SIS_330) {
10701 romptr = SISGETROMW(0x114);
10702 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
10703 romptr = SISGETROMW(0x11a);
10705 romptr = SISGETROMW(0x194);
10706 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
10707 romptr = SISGETROMW(0x19a);
10713 GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
10717 if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
10718 if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) {
10719 if((index = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) {
10722 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2;
10723 else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++;
10729 index = SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F;
10730 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) index -= 5;
10731 else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6;
10734 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2;
10735 else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++;
10740 GetLCDPtrIndex(SiS_Private *SiS_Pr)
10744 index = ((SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F) - 1) * 3;
10745 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2;
10746 else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++;
10751 GetTVPtrIndex(SiS_Private *SiS_Pr)
10756 if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1;
10757 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) index = 2;
10759 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) index = 0;
10763 if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) &&
10764 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) {
10772 GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme)
10774 USHORT index = 0, temp = 0;
10776 if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1;
10777 if(SiS_Pr->SiS_TVMode & TVSetPALM) index = 2;
10778 if(SiS_Pr->SiS_TVMode & TVSetPALN) index = 3;
10779 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 6;
10780 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) {
10782 if(SiS_Pr->SiS_TVMode & TVSetPALM) index++;
10783 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 7;
10786 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
10787 if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
10788 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) {
10794 return(ULONG)(index | (temp << 16));
10798 GetOEMTVPtr661_2_OLD(SiS_Private *SiS_Pr)
10800 return(GetOEMTVPtr661_2_GEN(SiS_Pr, 8));
10805 GetOEMTVPtr661_2_NEW(SiS_Private *SiS_Pr)
10807 return(GetOEMTVPtr661_2_GEN(SiS_Pr, 6));
10812 GetOEMTVPtr661(SiS_Private *SiS_Pr)
10816 if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 2;
10817 if(SiS_Pr->SiS_ROMNew) {
10818 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) index = 4;
10819 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) index = 6;
10820 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) index = 8;
10821 if(SiS_Pr->SiS_TVMode & TVSetHiVision) index = 10;
10823 if(SiS_Pr->SiS_TVMode & TVSetHiVision) index = 4;
10824 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525i) index = 6;
10825 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) index = 8;
10826 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) index = 10;
10829 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) index++;
10835 SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
10837 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
10838 USHORT delay=0,index,myindex,temp,romptr=0;
10839 BOOLEAN dochiptest = TRUE;
10841 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
10842 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x20,0xbf);
10844 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x35,0x7f);
10847 /* Find delay (from ROM, internal tables, PCI subsystem) */
10849 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* ------------ VGA */
10851 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
10852 romptr = GetRAMDACromptr(SiS_Pr, HwInfo);
10854 if(romptr) delay = ROMAddr[romptr];
10857 if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
10860 } else if(IS_SIS740) {
10862 } else if(HwInfo->jChipType < SIS_330) {
10867 } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
10872 } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD|SetCRT2ToLCDA)) { /* ---------- LCD/LCDA */
10874 BOOLEAN gotitfrompci = FALSE;
10876 /* Could we detect a PDC for LCD or did we get a user-defined? If yes, use it */
10878 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
10879 if(SiS_Pr->PDC != -1) {
10880 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((SiS_Pr->PDC >> 1) & 0x0f));
10881 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((SiS_Pr->PDC & 0x01) << 7));
10885 if(SiS_Pr->PDCA != -1) {
10886 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((SiS_Pr->PDCA << 3) & 0xf0));
10887 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((SiS_Pr->PDCA & 0x01) << 6));
10892 /* Custom Panel? */
10894 if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) {
10895 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
10897 if((SiS_Pr->PanelXRes <= 1280) && (SiS_Pr->PanelYRes <= 1024)) {
10900 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,delay);
10903 if(SiS_Pr->SiS_VBType & VB_SIS301C) delay = 0x03;
10904 else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
10905 if(IS_SIS740) delay = 0x01;
10908 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,delay);
10913 /* This is a piece of typical SiS crap: They code the OEM LCD
10914 * delay into the code, at no defined place in the BIOS.
10915 * We now have to start doing a PCI subsystem check here.
10918 switch(SiS_Pr->SiS_CustomT) {
10919 case CUT_COMPAQ1280:
10920 case CUT_COMPAQ12802:
10921 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
10922 gotitfrompci = TRUE;
10923 dochiptest = FALSE;
10927 case CUT_CLEVO1400:
10928 case CUT_CLEVO14002:
10929 gotitfrompci = TRUE;
10930 dochiptest = FALSE;
10933 case CUT_CLEVO1024:
10934 case CUT_CLEVO10242:
10935 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
10936 gotitfrompci = TRUE;
10937 dochiptest = FALSE;
10939 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2D,delay);
10945 /* Could we find it through the PCI ID? If no, use ROM or table */
10947 if(!gotitfrompci) {
10949 index = GetLCDPtrIndexBIOS(SiS_Pr, HwInfo);
10950 myindex = GetLCDPtrIndex(SiS_Pr);
10952 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
10954 if(SiS_IsNotM650orLater(SiS_Pr, HwInfo)) {
10956 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
10957 /* Always use the second pointer on 650; some BIOSes */
10958 /* still carry old 301 data at the first location */
10959 /* romptr = SISGETROMW(0x120); */
10960 /* if(SiS_Pr->SiS_VBType & VB_SIS302LV) */
10961 romptr = SISGETROMW(0x122);
10962 if(!romptr) return;
10963 delay = ROMAddr[(romptr + index)];
10965 delay = SiS310_LCDDelayCompensation_650301LV[myindex];
10970 delay = SiS310_LCDDelayCompensation_651301LV[myindex];
10971 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV))
10972 delay = SiS310_LCDDelayCompensation_651302LV[myindex];
10976 } else if(SiS_Pr->SiS_UseROM &&
10977 (!(SiS_Pr->SiS_ROMNew)) &&
10978 (SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) &&
10979 (SiS_Pr->SiS_LCDResInfo != Panel_1280x768) &&
10980 (SiS_Pr->SiS_LCDResInfo != Panel_1280x960)) {
10982 /* Data for 1280x1024 wrong in 301B BIOS */
10983 romptr = GetLCDromptr(SiS_Pr, HwInfo);
10984 if(!romptr) return;
10985 delay = ROMAddr[(romptr + index)];
10987 } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
10989 if(IS_SIS740) delay = 0x03;
10994 delay = SiS310_LCDDelayCompensation_301[myindex];
10995 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
10996 if(IS_SIS740) delay = 0x01;
10997 else if(HwInfo->jChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex];
10998 else delay = SiS310_LCDDelayCompensation_650301LV[myindex];
10999 } else if(SiS_Pr->SiS_VBType & VB_SIS301C) {
11000 if(IS_SIS740) delay = 0x01; /* ? */
11002 } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
11003 if(IS_SIS740) delay = 0x01;
11004 else delay = SiS310_LCDDelayCompensation_3xx301B[myindex];
11009 } /* got it from PCI */
11011 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
11012 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,((delay << 4) & 0xf0));
11013 dochiptest = FALSE;
11016 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* ------------ TV */
11018 index = GetTVPtrIndex(SiS_Pr);
11020 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
11022 if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) {
11024 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
11025 /* Always use the second pointer on 650; some BIOSes */
11026 /* still carry old 301 data at the first location */
11027 /* romptr = SISGETROMW(0x114); */
11028 /* if(SiS_Pr->SiS_VBType & VB_SIS302LV) */
11029 romptr = SISGETROMW(0x11a);
11030 if(!romptr) return;
11031 delay = ROMAddr[romptr + index];
11035 delay = SiS310_TVDelayCompensation_301B[index];
11041 switch(SiS_Pr->SiS_CustomT) {
11042 case CUT_COMPAQ1280:
11043 case CUT_COMPAQ12802:
11044 case CUT_CLEVO1400:
11045 case CUT_CLEVO14002:
11047 dochiptest = FALSE;
11049 case CUT_CLEVO1024:
11050 case CUT_CLEVO10242:
11052 dochiptest = FALSE;
11055 delay = SiS310_TVDelayCompensation_651301LV[index];
11056 if(SiS_Pr->SiS_VBType & VB_SIS302LV) {
11057 delay = SiS310_TVDelayCompensation_651302LV[index];
11062 } else if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
11064 romptr = GetTVromptr(SiS_Pr, HwInfo);
11065 if(!romptr) return;
11066 delay = ROMAddr[romptr + index];
11068 } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
11070 delay = SiS310_TVDelayCompensation_LVDS[index];
11074 delay = SiS310_TVDelayCompensation_301[index];
11075 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
11077 delay = SiS310_TVDelayCompensation_740301B[index];
11078 /* LV: use 301 data? BIOS bug? */
11080 delay = SiS310_TVDelayCompensation_301B[index];
11081 if(SiS_Pr->SiS_VBType & VB_SIS301C) delay = 0x02;
11087 if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) {
11089 dochiptest = FALSE;
11096 if(SiS_Pr->SiS_VBType & VB_SISVB) {
11098 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && dochiptest) {
11100 temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4;
11101 if(temp == 8) { /* 1400x1050 BIOS (COMPAL) */
11104 } else if(temp == 6) {
11107 } else if(temp > 7) { /* 1280x1024 BIOS (which one?) */
11110 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2D,delay);
11114 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay);
11118 } else { /* LVDS */
11120 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
11121 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay);
11123 if(IS_SIS650 && (SiS_Pr->SiS_IF_DEF_CH70xx != 0)) {
11125 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,delay);
11127 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay);
11136 SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11137 USHORT ModeNo,USHORT ModeIdIndex)
11139 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
11140 USHORT index,temp,temp1,romptr=0;
11142 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p|TVSetYPbPr525p)) return;
11145 index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
11147 index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
11149 temp = GetTVPtrIndex(SiS_Pr);
11150 temp >>= 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */
11153 if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) {
11154 if(HwInfo->jChipType >= SIS_661) {
11155 temp1 = GetOEMTVPtr661(SiS_Pr);
11157 romptr = SISGETROMW(0x260);
11158 if(HwInfo->jChipType >= SIS_760) {
11159 romptr = SISGETROMW(0x360);
11161 } else if(HwInfo->jChipType >= SIS_330) {
11162 romptr = SISGETROMW(0x192);
11164 romptr = SISGETROMW(0x112);
11170 temp = ROMAddr[romptr + temp1 + index];
11172 temp = SiS310_TVAntiFlick1[temp][index];
11176 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8f,temp); /* index 0A D[6:4] */
11180 SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11181 USHORT ModeNo,USHORT ModeIdIndex)
11183 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
11184 USHORT index,temp,temp1,romptr=0;
11186 temp = temp1 = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */
11189 index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
11191 index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
11193 if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) {
11194 if(HwInfo->jChipType >= SIS_661) {
11195 romptr = SISGETROMW(0x26c);
11196 if(HwInfo->jChipType >= SIS_760) {
11197 romptr = SISGETROMW(0x36c);
11199 temp1 = GetOEMTVPtr661(SiS_Pr);
11201 } else if(HwInfo->jChipType >= SIS_330) {
11202 romptr = SISGETROMW(0x1a4);
11204 romptr = SISGETROMW(0x124);
11210 temp = ROMAddr[romptr + temp1 + index];
11212 temp = SiS310_TVEdge1[temp][index];
11215 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x3A,0x1F,temp); /* index 0A D[7:5] */
11219 SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11220 USHORT ModeNo,USHORT ModeIdIndex)
11222 USHORT index, temp, i, j;
11224 if(ModeNo <= 0x13) {
11225 index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
11227 index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
11230 temp = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */
11232 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp = 1; /* NTSC-J uses PAL */
11233 else if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 3; /* PAL-M */
11234 else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 4; /* PAL-N */
11235 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = 1; /* HiVision uses PAL */
11237 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
11238 for(i=0x35, j=0; i<=0x38; i++, j++) {
11239 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]);
11241 for(i=0x48; i<=0x4A; i++, j++) {
11242 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]);
11245 for(i=0x35, j=0; i<=0x38; i++, j++) {
11246 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter1[temp][index][j]);
11252 SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11253 USHORT ModeNo,USHORT ModeIdIndex)
11255 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
11256 USHORT index,temp,i,j,resinfo,romptr=0;
11259 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return;
11261 /* NTSC-J data not in BIOS, and already set in SetGroup2 */
11262 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) return;
11264 if((HwInfo->jChipType >= SIS_661) || SiS_Pr->SiS_ROMNew) {
11265 lindex = GetOEMTVPtr661_2_OLD(SiS_Pr) & 0xffff;
11267 for(j=0, i=0x31; i<=0x34; i++, j++) {
11268 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS661_TVPhase[lindex + j]);
11273 /* PAL-M, PAL-N not in BIOS, and already set in SetGroup2 */
11274 if(SiS_Pr->SiS_TVMode & (TVSetPALM | TVSetPALN)) return;
11277 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
11279 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
11282 temp = GetTVPtrIndex(SiS_Pr);
11283 /* 0: NTSC Graphics, 1: NTSC Text, 2: PAL Graphics,
11284 * 3: PAL Text, 4: HiTV Graphics 5: HiTV Text
11286 if(SiS_Pr->SiS_UseROM) {
11287 romptr = SISGETROMW(0x116);
11288 if(HwInfo->jChipType >= SIS_330) {
11289 romptr = SISGETROMW(0x196);
11291 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
11292 romptr = SISGETROMW(0x11c);
11293 if(HwInfo->jChipType >= SIS_330) {
11294 romptr = SISGETROMW(0x19c);
11296 if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) {
11297 romptr = SISGETROMW(0x116);
11298 if(HwInfo->jChipType >= SIS_330) {
11299 romptr = SISGETROMW(0x196);
11305 romptr += (temp << 2);
11306 for(j=0, i=0x31; i<=0x34; i++, j++) {
11307 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]);
11311 temp >>= 1; /* 0:NTSC, 1:PAL, 2:HiTV */
11312 for(j=0, i=0x31; i<=0x34; i++, j++) {
11313 if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV))
11314 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]);
11315 else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode))
11316 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]);
11318 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]);
11322 if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) {
11323 if((!(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetYPbPr525p | TVSetYPbPr750p))) && (ModeNo > 0x13)) {
11324 if((resinfo == SIS_RI_640x480) ||
11325 (resinfo == SIS_RI_800x600)) {
11326 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x31,0x21);
11327 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x32,0xf0);
11328 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x33,0xf5);
11329 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x34,0x7f);
11330 } else if(resinfo == SIS_RI_1024x768) {
11331 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x31,0x1e);
11332 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x32,0x8b);
11333 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x33,0xfb);
11334 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x34,0x7b);
11341 SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo,
11342 USHORT ModeIdIndex, USHORT RTI)
11344 USHORT delay = 0, romptr = 0, index, lcdpdcindex;
11345 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
11347 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC)))
11350 /* 1. New ROM: VGA2 and LCD/LCDA-Pass1:1 */
11351 /* (If a custom mode is used, Pass1:1 is always set; hence we do this:) */
11353 if(SiS_Pr->SiS_ROMNew) {
11354 if((SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) ||
11355 ((SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
11356 (SiS_Pr->SiS_LCDInfo & LCDPass11))) {
11358 if(SiS_Pr->UseCustomMode) {
11359 index = SiS_Pr->CSRClock;
11360 } else if(ModeNo > 0x13) {
11361 index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI,HwInfo);
11362 index = SiS_Pr->SiS_VCLKData[index].CLOCK;
11364 if(index < 25) index = 25;
11365 index = ((index / 25) - 1) << 1;
11366 if((ROMAddr[0x5b] & 0x80) || (SiS_Pr->SiS_VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD))) {
11369 romptr = SISGETROMW(0x104);
11370 delay = ROMAddr[romptr + index];
11371 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD)) {
11372 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((delay >> 1) & 0x0f));
11373 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((delay & 0x01) << 7));
11375 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((delay << 3) & 0xf0));
11376 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((delay & 0x01) << 6));
11382 /* 2. Old ROM: VGA2 and LCD/LCDA-Pass 1:1 */
11384 if(SiS_Pr->UseCustomMode) delay = 0x04;
11385 else if(ModeNo <= 0x13) delay = 0x04;
11386 else delay = (SiS_Pr->SiS_RefIndex[RTI].Ext_PDC >> 4);
11387 delay |= (delay << 8);
11389 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
11393 index = GetOEMTVPtr661(SiS_Pr);
11394 if(SiS_Pr->SiS_ROMNew) {
11395 romptr = SISGETROMW(0x106);
11396 if(SiS_Pr->SiS_VBType & VB_UMC) romptr += 12;
11397 delay = ROMAddr[romptr + index];
11400 if(index > 3) delay = 0;
11403 } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11405 /* 4. LCD, LCDA (for new ROM only LV and non-Pass 1:1) */
11407 if( (SiS_Pr->SiS_LCDResInfo != Panel_Custom) &&
11408 ((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) ) {
11410 lcdpdcindex = (SiS_Pr->SiS_VBType & VB_UMC) ? 14 : 12;
11412 /* For LVDS (and sometimes TMDS), the BIOS must know about the correct value */
11413 delay = ROMAddr[romptr + lcdpdcindex + 1]; /* LCD */
11414 delay |= (ROMAddr[romptr + lcdpdcindex] << 8); /* LCDA */
11418 /* TMDS: Set our own, since BIOS has no idea */
11419 /* (This is done on >=661 only, since <661 is calling this only for LVDS) */
11420 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
11421 switch(SiS_Pr->SiS_LCDResInfo) {
11422 case Panel_1024x768: delay = 0x0008; break;
11423 case Panel_1280x720: delay = 0x0004; break;
11424 case Panel_1280x768:
11425 case Panel_1280x768_2:delay = 0x0004; break;
11426 case Panel_1280x800:
11427 case Panel_1280x800_2:delay = 0x0004; break; /* Verified for 1280x800 */
11428 case Panel_1280x1024: delay = 0x1e04; break;
11429 case Panel_1400x1050: delay = 0x0004; break;
11430 case Panel_1600x1200: delay = 0x0400; break;
11431 case Panel_1680x1050: delay = 0x0e04; break;
11433 if((SiS_Pr->PanelXRes <= 1024) && (SiS_Pr->PanelYRes <= 768)) {
11435 } else if((SiS_Pr->PanelXRes == 1280) && (SiS_Pr->PanelYRes == 1024)) {
11437 } else if((SiS_Pr->PanelXRes <= 1400) && (SiS_Pr->PanelYRes <= 1050)) {
11439 } else if((SiS_Pr->PanelXRes <= 1600) && (SiS_Pr->PanelYRes <= 1200)) {
11447 /* Override by detected or user-set values */
11448 /* (but only if, for some reason, we can't read value from BIOS) */
11449 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->PDC != -1)) {
11450 delay = SiS_Pr->PDC & 0x1f;
11452 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) && (SiS_Pr->PDCA != -1)) {
11453 delay = (SiS_Pr->PDCA & 0x1f) << 8;
11460 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
11462 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,((delay << 3) & 0xf0));
11463 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x20,0xbf,((delay & 0x01) << 6));
11465 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0xf0,((delay >> 1) & 0x0f));
11466 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,0x7f,((delay & 0x01) << 7));
11471 SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT RTI)
11476 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11478 if(ModeNo <= 0x13) {
11479 infoflag = SiS_GetRegByte(SiS_Pr->SiS_P3ca+2);
11480 } else if(SiS_Pr->UseCustomMode) {
11481 infoflag = SiS_Pr->CInfoFlag;
11483 infoflag = SiS_Pr->SiS_RefIndex[RTI].Ext_InfoFlag;
11486 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
11487 infoflag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); /* No longer check D5 */
11492 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
11493 temp = (infoflag >> 6) | 0x0c;
11494 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
11496 if(SiS_Pr->SiS_ModeType >= Mode24Bpp) temp |= 0x10;
11498 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xe0,temp);
11501 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp = 0x20;
11503 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0f,temp);
11505 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
11506 if(SiS_Pr->SiS_ModeType >= Mode24Bpp) temp |= 0x80;
11508 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1a,0x7f,temp);
11515 SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
11517 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
11518 USHORT romptr, temp1, temp2;
11520 if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) {
11521 if(SiS_Pr->LVDSHL != -1) {
11522 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL);
11526 if(SiS_Pr->SiS_ROMNew) {
11528 if((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) {
11529 if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) {
11530 temp1 = (ROMAddr[romptr] & 0x03) | 0x0c;
11532 if(SiS_Pr->LVDSHL != -1) {
11536 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,temp2,temp1);
11538 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
11539 temp1 = (ROMAddr[romptr + 1] & 0x80) >> 1;
11540 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d,0xbf,temp1);
11548 SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11549 USHORT ModeNo,USHORT ModeIdIndex,USHORT RRTI)
11551 if((SiS_Pr->SiS_ROMNew) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) {
11552 SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI);
11553 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11554 SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI);
11555 SetPanelParms661(SiS_Pr,HwInfo);
11558 SetDelayComp(SiS_Pr,HwInfo,ModeNo);
11561 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
11562 SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex);
11563 SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex);
11564 SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex);
11565 if(SiS_Pr->SiS_VBType & VB_SIS301) {
11566 SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex);
11572 SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11573 USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI)
11575 if(SiS_Pr->SiS_VBType & VB_SISVB) {
11577 SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI);
11579 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11580 SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI);
11581 SetPanelParms661(SiS_Pr,HwInfo);
11584 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
11585 SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex);
11586 SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex);
11587 SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex);
11588 if(SiS_Pr->SiS_VBType & VB_SIS301) {
11589 SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex);
11596 * This finalizes some CRT2 registers for the very panel used.
11597 * If we have a backup if these registers, we use it; otherwise
11598 * we set the register according to most BIOSes. However, this
11599 * function looks quite different in every BIOS, so you better
11600 * pray that we have a backup...
11603 SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
11604 PSIS_HW_INFO HwInfo)
11606 USHORT tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp;
11607 USHORT resinfo,modeflag;
11609 if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) return;
11610 if(SiS_Pr->SiS_ROMNew) return;
11612 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11613 if(SiS_Pr->LVDSHL != -1) {
11614 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL);
11618 if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return;
11619 if(SiS_Pr->UseCustomMode) return;
11621 switch(SiS_Pr->SiS_CustomT) {
11622 case CUT_COMPAQ1280:
11623 case CUT_COMPAQ12802:
11624 case CUT_CLEVO1400:
11625 case CUT_CLEVO14002:
11629 if(ModeNo <= 0x13) {
11630 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
11631 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
11633 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
11634 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
11638 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4, 0x5f) & 0xf0)) {
11639 if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) {
11640 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x02);
11642 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03);
11647 if(SiS_Pr->SiS_CustomT == CUT_CLEVO1024) {
11648 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
11649 /* Maybe all panels? */
11650 if(SiS_Pr->LVDSHL == -1) {
11651 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01);
11657 if(SiS_Pr->SiS_CustomT == CUT_CLEVO10242) {
11658 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11659 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
11660 if(SiS_Pr->LVDSHL == -1) {
11661 /* Maybe all panels? */
11662 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01);
11664 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
11665 tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4;
11667 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02);
11668 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x25);
11669 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x00);
11670 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x1b);
11678 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11679 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
11680 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
11681 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00);
11683 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
11685 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10);
11687 } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
11688 if(SiS_Pr->LVDSHL == -1) {
11689 /* Maybe ACER only? */
11690 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01);
11693 tempch = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4;
11694 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
11695 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) {
11696 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1f,0x76);
11697 } else if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
11698 if(tempch == 0x03) {
11699 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02);
11700 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x25);
11701 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x00);
11702 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x1b);
11704 if((SiS_Pr->Backup == TRUE) && (SiS_Pr->Backup_Mode == ModeNo)) {
11705 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,SiS_Pr->Backup_14);
11706 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,SiS_Pr->Backup_15);
11707 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,SiS_Pr->Backup_16);
11708 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,SiS_Pr->Backup_17);
11709 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,SiS_Pr->Backup_18);
11710 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,SiS_Pr->Backup_19);
11711 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1a,SiS_Pr->Backup_1a);
11712 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,SiS_Pr->Backup_1b);
11713 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,SiS_Pr->Backup_1c);
11714 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,SiS_Pr->Backup_1d);
11715 } else if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { /* 1.10.8w */
11716 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,0x90);
11717 if(ModeNo <= 0x13) {
11718 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x11);
11719 if((resinfo == 0) || (resinfo == 2)) return;
11720 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x18);
11721 if((resinfo == 1) || (resinfo == 3)) return;
11723 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02);
11724 if((ModeNo > 0x13) && (resinfo == SIS_RI_1024x768)) {
11725 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x02); /* 1.10.7u */
11727 tempbx = 806; /* 0x326 */ /* other older BIOSes */
11729 temp = tempbx & 0xff;
11730 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp);
11731 temp = (tempbx >> 8) & 0x03;
11732 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1d,0xf8,temp);
11735 } else if(ModeNo <= 0x13) {
11737 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x70);
11738 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xff);
11739 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x48);
11740 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x12);
11742 if(!(modeflag & HalfDCLK)) {
11743 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,0x20);
11744 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,0x1a);
11745 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,0x28);
11746 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,0x00);
11747 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x4c);
11748 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xdc);
11749 if(ModeNo == 0x12) {
11752 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x95);
11753 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x19,0xdc);
11754 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1a,0x10);
11755 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x95);
11756 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1c,0x48);
11757 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1d,0x12);
11760 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x95);
11761 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x48);
11764 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,0x95);
11772 tempcl = tempbh = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01);
11776 tempbl = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x04);
11777 tempbx = (tempbh << 8) | tempbl;
11778 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
11779 if((resinfo == SIS_RI_1024x768) || (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD))) {
11780 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
11783 if(tempbx > 770) tempbx = 770;
11784 if(SiS_Pr->SiS_VGAVDE < 600) {
11785 tempax = 768 - SiS_Pr->SiS_VGAVDE;
11786 tempax >>= 4; /* 1.10.7w; 1.10.6s: 3; */
11787 if(SiS_Pr->SiS_VGAVDE <= 480) tempax >>= 4; /* 1.10.7w; 1.10.6s: < 480; >>=1; */
11793 temp = tempbx & 0xff;
11794 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,temp);
11795 temp = ((tempbx & 0xff00) >> 4) | tempcl;
11796 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,temp);
11803 /* ================= SiS 300 O.E.M. ================== */
11808 SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11809 USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex)
11811 USHORT crt2crtc=0, modeflag, myindex=0;
11815 if(ModeNo <= 0x13) {
11816 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
11817 crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
11819 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
11820 crt2crtc = SiS_Pr->SiS_RefIndex[RefTabIndex].Ext_CRT2CRTC;
11825 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
11826 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xdf);
11829 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
11830 if(modeflag & HalfDCLK) myindex = 1;
11832 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
11833 for(i=0; i<7; i++) {
11834 if(barco_p1[myindex][crt2crtc][i][0]) {
11835 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,
11836 barco_p1[myindex][crt2crtc][i][0],
11837 barco_p1[myindex][crt2crtc][i][2],
11838 barco_p1[myindex][crt2crtc][i][1]);
11842 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00);
11844 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x18);
11846 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp);
11852 GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int Flag)
11854 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
11855 USHORT tempbx=0,romptr=0;
11856 UCHAR customtable300[] = {
11857 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
11858 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
11860 UCHAR customtable630[] = {
11861 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
11862 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
11865 if(HwInfo->jChipType == SIS_300) {
11867 tempbx = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f;
11868 if(SiS_Pr->SiS_VBType & VB_SIS301) tempbx &= 0x07;
11870 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 4;
11871 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
11872 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3;
11874 if(SiS_Pr->SiS_UseROM) {
11875 if(ROMAddr[0x235] & 0x80) {
11876 tempbx = SiS_Pr->SiS_LCDTypeInfo;
11878 romptr = SISGETROMW(0x255);
11879 if(romptr) tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo];
11880 else tempbx = customtable300[SiS_Pr->SiS_LCDTypeInfo];
11881 if(tempbx == 0xFF) return 0xFFFF;
11884 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++;
11891 if(SiS_Pr->SiS_UseROM) {
11892 romptr = SISGETROMW(0x255);
11893 if(romptr) tempbx = ROMAddr[romptr + SiS_Pr->SiS_LCDTypeInfo];
11894 else tempbx = 0xff;
11896 tempbx = customtable630[SiS_Pr->SiS_LCDTypeInfo];
11898 if(tempbx == 0xFF) return 0xFFFF;
11900 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2;
11901 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
11904 tempbx = SiS_Pr->SiS_LCDTypeInfo << 2;
11905 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempbx += 2;
11906 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
11914 SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11915 USHORT ModeNo,USHORT ModeIdIndex)
11917 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
11918 USHORT index,temp,romptr=0;
11920 if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return;
11922 if(SiS_Pr->SiS_UseROM) {
11923 if(!(ROMAddr[0x237] & 0x01)) return;
11924 if(!(ROMAddr[0x237] & 0x02)) return;
11925 romptr = SISGETROMW(0x24b);
11928 /* The Panel Compensation Delay should be set according to tables
11929 * here. Unfortunately, various BIOS versions don't case about
11930 * a uniform way using eg. ROM byte 0x220, but use different
11931 * hard coded delays (0x04, 0x20, 0x18) in SetGroup1().
11932 * Thus we don't set this if the user select a custom pdc or if
11933 * we otherwise detected a valid pdc.
11935 if(SiS_Pr->PDC != -1) return;
11937 temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 0);
11939 if(SiS_Pr->UseCustomMode)
11942 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex;
11944 if(HwInfo->jChipType != SIS_300) {
11946 romptr += (temp * 2);
11947 romptr = SISGETROMW(romptr);
11949 temp = ROMAddr[romptr];
11951 if(SiS_Pr->SiS_VBType & VB_SISVB) {
11952 temp = SiS300_OEMLCDDelay2[temp][index];
11954 temp = SiS300_OEMLCDDelay3[temp][index];
11958 if(SiS_Pr->SiS_UseROM && (ROMAddr[0x235] & 0x80)) {
11960 romptr += (temp * 2);
11961 romptr = SISGETROMW(romptr);
11963 temp = ROMAddr[romptr];
11965 temp = SiS300_OEMLCDDelay5[temp][index];
11968 if(SiS_Pr->SiS_UseROM) {
11969 romptr = ROMAddr[0x249] | (ROMAddr[0x24a] << 8);
11971 romptr += (temp * 2);
11972 romptr = SISGETROMW(romptr);
11974 temp = ROMAddr[romptr];
11976 temp = SiS300_OEMLCDDelay4[temp][index];
11979 temp = SiS300_OEMLCDDelay4[temp][index];
11984 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* index 0A D[6:4] */
11988 SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11989 USHORT ModeNo,USHORT ModeIdIndex)
11991 #if 0 /* Unfinished; Data table missing */
11992 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
11995 if((SiS_Pr->SiS_UseROM) {
11996 if(!(ROMAddr[0x237] & 0x01)) return;
11997 if(!(ROMAddr[0x237] & 0x04)) return;
11998 /* No rom pointer in BIOS header! */
12001 temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 1);
12002 if(temp = 0xFFFF) return;
12004 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDHIndex;
12005 for(i=0x14, j=0; i<=0x17; i++, j++) {
12006 SiS_SetReg(SiS_Pr->SiS_Part1Port,i,SiS300_LCDHData[temp][index][j]);
12008 SiS_SetRegANDOR(SiS_SiS_Part1Port,0x1a, 0xf8, (SiS300_LCDHData[temp][index][j] & 0x07));
12010 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDVIndex;
12011 SiS_SetReg(SiS_SiS_Part1Port,0x18, SiS300_LCDVData[temp][index][0]);
12012 SiS_SetRegANDOR(SiS_SiS_Part1Port,0x19, 0xF0, SiS300_LCDVData[temp][index][1]);
12013 SiS_SetRegANDOR(SiS_SiS_Part1Port,0x1A, 0xC7, (SiS300_LCDVData[temp][index][2] & 0x38));
12014 for(i=0x1b, j=3; i<=0x1d; i++, j++) {
12015 SiS_SetReg(SiS_Pr->SiS_Part1Port,i,SiS300_LCDVData[temp][index][j]);
12021 GetOEMTVPtr(SiS_Private *SiS_Pr)
12026 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4;
12027 if(SiS_Pr->SiS_VBType & VB_SISVB) {
12028 if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) index += 2;
12029 else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) index += 3;
12030 else if(SiS_Pr->SiS_TVMode & TVSetPAL) index += 1;
12032 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) index += 2;
12033 if(SiS_Pr->SiS_TVMode & TVSetPAL) index += 1;
12039 SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12040 USHORT ModeNo,USHORT ModeIdIndex)
12042 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
12043 USHORT index,temp,romptr=0;
12045 if(SiS_Pr->SiS_UseROM) {
12046 if(!(ROMAddr[0x238] & 0x01)) return;
12047 if(!(ROMAddr[0x238] & 0x02)) return;
12048 romptr = SISGETROMW(0x241);
12051 temp = GetOEMTVPtr(SiS_Pr);
12053 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVDelayIndex;
12056 romptr += (temp * 2);
12057 romptr = SISGETROMW(romptr);
12059 temp = ROMAddr[romptr];
12061 if(SiS_Pr->SiS_VBType & VB_SISVB) {
12062 temp = SiS300_OEMTVDelay301[temp][index];
12064 temp = SiS300_OEMTVDelayLVDS[temp][index];
12068 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp);
12072 SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12073 USHORT ModeNo, USHORT ModeIdIndex)
12075 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
12076 USHORT index,temp,romptr=0;
12078 if(SiS_Pr->SiS_UseROM) {
12079 if(!(ROMAddr[0x238] & 0x01)) return;
12080 if(!(ROMAddr[0x238] & 0x04)) return;
12081 romptr = SISGETROMW(0x243);
12084 temp = GetOEMTVPtr(SiS_Pr);
12086 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVFlickerIndex;
12089 romptr += (temp * 2);
12090 romptr = SISGETROMW(romptr);
12092 temp = ROMAddr[romptr];
12094 temp = SiS300_OEMTVFlicker[temp][index];
12097 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0A,0x8F,temp);
12101 SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12102 USHORT ModeNo,USHORT ModeIdIndex)
12104 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
12105 USHORT index,i,j,temp,romptr=0;
12107 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) return;
12109 if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSetNTSCJ | TVSetPALM | TVSetPALN)) return;
12111 if(SiS_Pr->SiS_UseROM) {
12112 if(!(ROMAddr[0x238] & 0x01)) return;
12113 if(!(ROMAddr[0x238] & 0x08)) return;
12114 romptr = SISGETROMW(0x245);
12117 temp = GetOEMTVPtr(SiS_Pr);
12119 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVPhaseIndex;
12121 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
12122 for(i=0x31, j=0; i<=0x34; i++, j++) {
12123 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]);
12127 romptr += (temp * 2);
12128 romptr = SISGETROMW(romptr);
12129 romptr += (index * 4);
12130 for(i=0x31, j=0; i<=0x34; i++, j++) {
12131 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]);
12134 for(i=0x31, j=0; i<=0x34; i++, j++) {
12135 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase1[temp][index][j]);
12142 SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12143 USHORT ModeNo,USHORT ModeIdIndex)
12145 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase;
12146 USHORT index,temp,i,j,romptr=0;
12148 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVision | SetCRT2ToYPbPr525750)) return;
12150 if(SiS_Pr->SiS_UseROM) {
12151 if(!(ROMAddr[0x238] & 0x01)) return;
12152 if(!(ROMAddr[0x238] & 0x10)) return;
12153 romptr = SISGETROMW(0x247);
12156 temp = GetOEMTVPtr(SiS_Pr);
12158 if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8;
12159 else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 9;
12160 /* NTSCJ uses NTSC filters */
12162 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex;
12164 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
12165 for(i=0x35, j=0; i<=0x38; i++, j++) {
12166 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]);
12168 for(i=0x48; i<=0x4A; i++, j++) {
12169 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]);
12172 if((romptr) && (!(SiS_Pr->SiS_TVMode & (TVSetPALM|TVSetPALN)))) {
12173 romptr += (temp * 2);
12174 romptr = SISGETROMW(romptr);
12175 romptr += (index * 4);
12176 for(i=0x35, j=0; i<=0x38; i++, j++) {
12177 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,ROMAddr[romptr + j]);
12180 for(i=0x35, j=0; i<=0x38; i++, j++) {
12181 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter1[temp][index][j]);
12188 SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo)
12190 USHORT ModeIdIndex;
12191 UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO;
12193 if(*ModeNo <= 5) *ModeNo |= 1;
12195 for(ModeIdIndex=0; ; ModeIdIndex++) {
12196 if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == *ModeNo) break;
12197 if(SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == 0xFF) return 0;
12200 if(*ModeNo != 0x07) {
12201 if(*ModeNo > 0x03) return ModeIdIndex;
12202 if(VGAINFO & 0x80) return ModeIdIndex;
12206 if(VGAINFO & 0x10) ModeIdIndex++; /* 400 lines */
12207 /* else 350 lines */
12208 return ModeIdIndex;
12212 SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12213 USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTableIndex)
12215 USHORT OEMModeIdIndex=0;
12217 if(!SiS_Pr->UseCustomMode) {
12218 OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo);
12219 if(!(OEMModeIdIndex)) return;
12222 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
12223 SetOEMLCDDelay(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex);
12224 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
12225 SetOEMLCDData(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex);
12228 if(SiS_Pr->UseCustomMode) return;
12229 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
12230 SetOEMTVDelay(SiS_Pr, HwInfo, ModeNo,OEMModeIdIndex);
12231 if(SiS_Pr->SiS_VBType & VB_SISVB) {
12232 SetOEMAntiFlicker(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex);
12233 SetOEMPhaseIncr(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex);
12234 SetOEMYFilter(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex);