diff options
Diffstat (limited to 'drivers/video/sis/init301.c')
-rw-r--r-- | drivers/video/sis/init301.c | 9630 |
1 files changed, 4331 insertions, 5299 deletions
diff --git a/drivers/video/sis/init301.c b/drivers/video/sis/init301.c index 274dacd54bb..2d88f908170 100644 --- a/drivers/video/sis/init301.c +++ b/drivers/video/sis/init301.c @@ -2,11 +2,12 @@ /* $XdotOrg$ */ /* * Mode initializing code (CRT2 section) - * for SiS 300/305/540/630/730 and - * SiS 315/550/650/M650/651/661FX/M661xX/740/741(GX)/M741/330/660/M660/760/M760 - * (Universal module for Linux kernel framebuffer and XFree86/X.org 4.x) + * for SiS 300/305/540/630/730, + * SiS 315/550/[M]650/651/[M]661[FGM]X/[M]74x[GX]/330/[M]76x[GX], + * XGI V3XT/V5/V8, Z7 + * (Universal module for Linux kernel framebuffer and X.org/XFree86 4.x) * - * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria * * If distributed as part of the Linux kernel, the following license terms * apply: @@ -38,7 +39,7 @@ * * 3) The name of the author may not be used to endorse or promote products * * derived from this software without specific prior written permission. * * - * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, @@ -54,20 +55,20 @@ * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. * Used by permission. * - * TW says: This code looks awful, I know. But please don't do anything about - * this otherwise debugging will be hell. - * The code is extremely fragile as regards the different chipsets, different - * video bridges and combinations thereof. If anything is changed, extreme - * care has to be taken that that change doesn't break it for other chipsets, - * bridges or combinations thereof. - * All comments in this file are by me, regardless if marked TW or not. - * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #if 1 #define SET_EMI /* 302LV/ELV: Set EMI values */ #endif +#if 1 +#define SET_PWD /* 301/302LV: Set PWD */ +#endif + #define COMPAL_HACK /* Needed for Compal 1400x1050 (EMI) */ #define COMPAQ_HACK /* Needed for Inventec/Compaq 1280x1024 (EMI) */ #define ASUS_HACK /* Needed for Asus A2H 1024x768 (EMI) */ @@ -85,26 +86,35 @@ #define SiS_I2CDELAY 1000 #define SiS_I2CDELAYSHORT 150 -static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr); -static void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx); +static unsigned short SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr); +#ifdef SIS_LINUX_KERNEL +static void SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); +#endif /*********************************************/ /* HELPER: Lock/Unlock CRT2 */ /*********************************************/ void -SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_UnLockCRT2(struct SiS_Private *SiS_Pr) { - if(HwInfo->jChipType >= SIS_315H) + if(SiS_Pr->ChipType == XGI_20) + return; + else if(SiS_Pr->ChipType >= SIS_315H) SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01); else SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); } -static void -SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +#ifdef SIS_LINUX_KERNEL +static +#endif +void +SiS_LockCRT2(struct SiS_Private *SiS_Pr) { - if(HwInfo->jChipType >= SIS_315H) + if(SiS_Pr->ChipType == XGI_20) + return; + else if(SiS_Pr->ChipType >= SIS_315H) SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE); else SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE); @@ -115,9 +125,9 @@ SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static void -SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, USHORT DataOR) +SiS_SetRegSR11ANDOR(struct SiS_Private *SiS_Pr, unsigned short DataAND, unsigned short DataOR) { - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { DataAND &= 0x0f; DataOR &= 0x0f; } @@ -129,12 +139,12 @@ SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, US /*********************************************/ #ifdef SIS315H -static UCHAR * -GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned char * +GetLCDStructPtr661(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - UCHAR *myptr = NULL; - USHORT romindex = 0, reg = 0, idx = 0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned char *myptr = NULL; + unsigned short romindex = 0, reg = 0, idx = 0; /* Use the BIOS tables only for LVDS panels; TMDS is unreliable * due to the variaty of panels the BIOS doesn't know about. @@ -144,15 +154,15 @@ GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) */ if((SiS_Pr->SiS_ROMNew) && - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || (!SiS_Pr->PanelSelfDetected))) { + ((SiS_Pr->SiS_VBType & VB_SISLVDS) || (!SiS_Pr->PanelSelfDetected))) { - if(HwInfo->jChipType < SIS_661) reg = 0x3c; - else reg = 0x7d; + if(SiS_Pr->ChipType < SIS_661) reg = 0x3c; + else reg = 0x7d; idx = (SiS_GetReg(SiS_Pr->SiS_P3d4,reg) & 0x1f) * 26; if(idx < (8*26)) { - myptr = (UCHAR *)&SiS_LCDStruct661[idx]; + myptr = (unsigned char *)&SiS_LCDStruct661[idx]; } romindex = SISGETROMW(0x100); if(romindex) { @@ -163,11 +173,11 @@ GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) return myptr; } -static USHORT -GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetLCDStructPtr661_2(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr = 0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr = 0; /* Use the BIOS tables only for LVDS panels; TMDS is unreliable * due to the variaty of panels the BIOS doesn't know about. @@ -177,12 +187,12 @@ GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) */ if((SiS_Pr->SiS_ROMNew) && - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || (!SiS_Pr->PanelSelfDetected))) { + ((SiS_Pr->SiS_VBType & VB_SISLVDS) || (!SiS_Pr->PanelSelfDetected))) { romptr = SISGETROMW(0x102); romptr += ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) * SiS_Pr->SiS661LCD2TableSize); } - return(romptr); + return romptr; } #endif @@ -191,186 +201,187 @@ GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static BOOLEAN -SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RRTI, USHORT *i, PSIS_HW_INFO HwInfo) +SiS_AdjustCRT2Rate(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RRTI, unsigned short *i) { - USHORT checkmask=0,modeid,infoflag; + unsigned short checkmask=0, modeid, infoflag; - modeid = SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID; + modeid = SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID; - if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { - checkmask |= SupportRAMDAC2; - if(HwInfo->jChipType >= SIS_315H) { - checkmask |= SupportRAMDAC2_135; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - checkmask |= SupportRAMDAC2_162; - if(SiS_Pr->SiS_VBType & VB_SIS301C) { - checkmask |= SupportRAMDAC2_202; - } - } - } + checkmask |= SupportRAMDAC2; + if(SiS_Pr->ChipType >= SIS_315H) { + checkmask |= SupportRAMDAC2_135; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + checkmask |= SupportRAMDAC2_162; + if(SiS_Pr->SiS_VBType & VB_SISRAMDAC202) { + checkmask |= SupportRAMDAC2_202; + } + } + } - } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - checkmask |= SupportLCD; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { - if(modeid == 0x2e) checkmask |= Support64048060Hz; - } - } - } + checkmask |= SupportLCD; + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(modeid == 0x2e) checkmask |= Support64048060Hz; + } + } + } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - checkmask |= SupportHiVision; + checkmask |= SupportHiVision; - } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { + } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { - checkmask |= SupportTV; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - checkmask |= SupportTV1024; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { - checkmask |= SupportYPbPr750p; - } - } - } + checkmask |= SupportTV; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + checkmask |= SupportTV1024; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + checkmask |= SupportYPbPr750p; + } + } + } - } + } - } else { /* LVDS */ + } else { /* LVDS */ - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - checkmask |= SupportCHTV; - } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + checkmask |= SupportCHTV; + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - checkmask |= SupportLCD; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + checkmask |= SupportLCD; + } - } + } - /* Look backwards in table for matching CRT2 mode */ - for(; SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) { - infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; - if(infoflag & checkmask) return TRUE; - if((*i) == 0) break; - } + /* Look backwards in table for matching CRT2 mode */ + for(; SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) { + infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; + if(infoflag & checkmask) return TRUE; + if((*i) == 0) break; + } - /* Look through the whole mode-section of the table from the beginning - * for a matching CRT2 mode if no mode was found yet. - */ - for((*i) = 0; ; (*i)++) { - if(SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID != modeid) break; - infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; - if(infoflag & checkmask) return TRUE; - } - return FALSE; + /* Look through the whole mode-section of the table from the beginning + * for a matching CRT2 mode if no mode was found yet. + */ + for((*i) = 0; ; (*i)++) { + if(SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID != modeid) break; + infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; + if(infoflag & checkmask) return TRUE; + } + return FALSE; } /*********************************************/ /* Get rate index */ /*********************************************/ -USHORT -SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) -{ - SHORT LCDRefreshIndex[] = { 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00 }; - USHORT RRTI,i,backup_i; - USHORT modeflag,index,temp,backupindex; +unsigned short +SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) +{ + unsigned short RRTI,i,backup_i; + unsigned short modeflag,index,temp,backupindex; + static const unsigned short LCDRefreshIndex[] = { + 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00 + }; - /* Do NOT check for UseCustomMode here, will skrew up FIFO */ - if(ModeNo == 0xfe) return 0; + /* Do NOT check for UseCustomMode here, will skrew up FIFO */ + if(ModeNo == 0xfe) return 0; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(modeflag & HalfDCLK) return 0; - } - } + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(modeflag & HalfDCLK) return 0; + } + } - if(ModeNo < 0x14) return 0xFFFF; + if(ModeNo < 0x14) return 0xFFFF; - index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F; - backupindex = index; + index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F; + backupindex = index; - if(index > 0) index--; + if(index > 0) index--; - if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0; - else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0; - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { - temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)]; - if(index > temp) index = temp; - } - } - } else { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0; - } - } - } + if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0; + else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0; + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { + temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)]; + if(index > temp) index = temp; + } + } + } else { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0; + } + } + } - RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; - ModeNo = SiS_Pr->SiS_RefIndex[RRTI].ModeID; + RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; + ModeNo = SiS_Pr->SiS_RefIndex[RRTI].ModeID; - if(HwInfo->jChipType >= SIS_315H) { - if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { - if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || - (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { - if(backupindex <= 1) RRTI++; - } - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { + if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || + (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { + if(backupindex <= 1) RRTI++; + } + } + } - i = 0; - do { - if(SiS_Pr->SiS_RefIndex[RRTI + i].ModeID != ModeNo) break; - temp = SiS_Pr->SiS_RefIndex[RRTI + i].Ext_InfoFlag; - temp &= ModeTypeMask; - if(temp < SiS_Pr->SiS_ModeType) break; - i++; - index--; - } while(index != 0xFFFF); - - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - temp = SiS_Pr->SiS_RefIndex[RRTI + i - 1].Ext_InfoFlag; - if(temp & InterlaceMode) i++; - } - } + i = 0; + do { + if(SiS_Pr->SiS_RefIndex[RRTI + i].ModeID != ModeNo) break; + temp = SiS_Pr->SiS_RefIndex[RRTI + i].Ext_InfoFlag; + temp &= ModeTypeMask; + if(temp < SiS_Pr->SiS_ModeType) break; + i++; + index--; + } while(index != 0xFFFF); + + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + temp = SiS_Pr->SiS_RefIndex[RRTI + i - 1].Ext_InfoFlag; + if(temp & InterlaceMode) i++; + } + } - i--; + i--; - if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { - backup_i = i; - if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i, HwInfo))) { - i = backup_i; - } - } + if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { + backup_i = i; + if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i))) { + i = backup_i; + } + } - return(RRTI + i); + return (RRTI + i); } /*********************************************/ @@ -378,15 +389,15 @@ SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) +SiS_SaveCRT2Info(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - USHORT temp1,temp2; + unsigned short temp1, temp2; - /* Store CRT1 ModeNo in CR34 */ - SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo); - temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; - temp2 = ~(SetInSlaveMode >> 8); - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); + /* Store CRT1 ModeNo in CR34 */ + SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo); + temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; + temp2 = ~(SetInSlaveMode >> 8); + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); } /*********************************************/ @@ -395,35 +406,35 @@ SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) #ifdef SIS300 static BOOLEAN -SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_CR36BIOSWord23b(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp,temp1; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp,temp1; - if(SiS_Pr->SiS_UseROM) { - if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); - temp1 = SISGETROMW(0x23b); - if(temp1 & temp) return TRUE; - } - } - return FALSE; + if(SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); + temp1 = SISGETROMW(0x23b); + if(temp1 & temp) return TRUE; + } + } + return FALSE; } static BOOLEAN -SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_CR36BIOSWord23d(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp,temp1; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp,temp1; - if(SiS_Pr->SiS_UseROM) { - if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); - temp1 = SISGETROMW(0x23d); - if(temp1 & temp) return TRUE; - } - } - return FALSE; + if(SiS_Pr->SiS_UseROM) { + if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { + temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); + temp1 = SISGETROMW(0x23d); + if(temp1 & temp) return TRUE; + } + } + return FALSE; } #endif @@ -432,85 +443,76 @@ SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ void -SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime) +SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime) { - USHORT i, j; + unsigned int i, j; - for(i=0; i<delaytime; i++) { - j += SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); - } + for(i = 0; i < delaytime; i++) { + j += SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); + } } #if defined(SIS300) || defined(SIS315H) static void -SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) +SiS_GenericDelay(struct SiS_Private *SiS_Pr, unsigned short delay) { - USHORT temp,flag; - - flag = SiS_GetRegByte(0x61) & 0x10; - - while(delay) { - temp = SiS_GetRegByte(0x61) & 0x10; - if(temp == flag) continue; - flag = temp; - delay--; - } + SiS_DDC2Delay(SiS_Pr, delay * 36); } #endif #ifdef SIS315H static void -SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) +SiS_LongDelay(struct SiS_Private *SiS_Pr, unsigned short delay) { - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x19df); - } + while(delay--) { + SiS_GenericDelay(SiS_Pr, 6623); + } } #endif #if defined(SIS300) || defined(SIS315H) static void -SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) +SiS_ShortDelay(struct SiS_Private *SiS_Pr, unsigned short delay) { - while(delay--) { - SiS_GenericDelay(SiS_Pr,0x42); - } + while(delay--) { + SiS_GenericDelay(SiS_Pr, 66); + } } #endif static void -SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) +SiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime) { #if defined(SIS300) || defined(SIS315H) - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT PanelID, DelayIndex, Delay=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short PanelID, DelayIndex, Delay=0; #endif - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SIS301) PanelID &= 0xf7; - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12; + if(SiS_Pr->SiS_VBType & VB_SIS301) PanelID &= 0xf7; + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12; } DelayIndex = PanelID >> 4; if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; + Delay = 3; } else { - if(DelayTime >= 2) DelayTime -= 2; - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; - } + if(DelayTime >= 2) DelayTime -= 2; + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; + } if(SiS_Pr->SiS_UseROM) { - if(ROMAddr[0x220] & 0x40) { - if(!(DelayTime & 0x01)) Delay = (USHORT)ROMAddr[0x225]; - else Delay = (USHORT)ROMAddr[0x226]; - } - } + if(ROMAddr[0x220] & 0x40) { + if(!(DelayTime & 0x01)) Delay = (unsigned short)ROMAddr[0x225]; + else Delay = (unsigned short)ROMAddr[0x226]; + } + } } SiS_ShortDelay(SiS_Pr, Delay); @@ -520,23 +522,23 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) #ifdef SIS315H - if((HwInfo->jChipType >= SIS_661) || - (HwInfo->jChipType <= SIS_315PRO) || - (HwInfo->jChipType == SIS_330) || + if((SiS_Pr->ChipType >= SIS_661) || + (SiS_Pr->ChipType <= SIS_315PRO) || + (SiS_Pr->ChipType == SIS_330) || (SiS_Pr->SiS_ROMNew)) { - if(!(DelayTime & 0x01)) { + if(!(DelayTime & 0x01)) { SiS_DDC2Delay(SiS_Pr, 0x1000); - } else { + } else { SiS_DDC2Delay(SiS_Pr, 0x4000); - } + } } else if((SiS_Pr->SiS_IF_DEF_LVDS == 1) /* || - (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || + (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || (SiS_Pr->SiS_CustomT == CUT_CLEVO1400) */ ) { /* 315 series, LVDS; Special */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); + if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { + PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1b) & 0x10)) PanelID = 0x12; } @@ -546,35 +548,35 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) DelayIndex = PanelID >> 4; } if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { - Delay = 3; - } else { - if(DelayTime >= 2) DelayTime -= 2; - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; - } + Delay = 3; + } else { + if(DelayTime >= 2) DelayTime -= 2; + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; + } if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { - if(ROMAddr[0x13c] & 0x40) { - if(!(DelayTime & 0x01)) { - Delay = (USHORT)ROMAddr[0x17e]; - } else { - Delay = (USHORT)ROMAddr[0x17f]; - } - } - } - } + if(ROMAddr[0x13c] & 0x40) { + if(!(DelayTime & 0x01)) { + Delay = (unsigned short)ROMAddr[0x17e]; + } else { + Delay = (unsigned short)ROMAddr[0x17f]; + } + } + } + } SiS_ShortDelay(SiS_Pr, Delay); } } else if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 315 series, all bridges */ DelayIndex = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; - if(!(DelayTime & 0x01)) { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; - } else { - Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; - } + if(!(DelayTime & 0x01)) { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; + } else { + Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; + } Delay <<= 8; SiS_DDC2Delay(SiS_Pr, Delay); @@ -587,12 +589,11 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) #ifdef SIS315H static void -SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT DelayTime, USHORT DelayLoop) +SiS_PanelDelayLoop(struct SiS_Private *SiS_Pr, unsigned short DelayTime, unsigned short DelayLoop) { int i; - for(i=0; i<DelayLoop; i++) { - SiS_PanelDelay(SiS_Pr, HwInfo, DelayTime); + for(i = 0; i < DelayLoop; i++) { + SiS_PanelDelay(SiS_Pr, DelayTime); } } #endif @@ -602,86 +603,86 @@ SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, /*********************************************/ void -SiS_WaitRetrace1(SiS_Private *SiS_Pr) +SiS_WaitRetrace1(struct SiS_Private *SiS_Pr) { - USHORT watchdog; + unsigned short watchdog; - if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; - if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return; + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; + if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return; - watchdog = 65535; - while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); - watchdog = 65535; - while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); + watchdog = 65535; + while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); + watchdog = 65535; + while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); } #if defined(SIS300) || defined(SIS315H) static void -SiS_WaitRetrace2(SiS_Private *SiS_Pr, USHORT reg) +SiS_WaitRetrace2(struct SiS_Private *SiS_Pr, unsigned short reg) { - USHORT watchdog; + unsigned short watchdog; - watchdog = 65535; - while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); - watchdog = 65535; - while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); + watchdog = 65535; + while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); + watchdog = 65535; + while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); } #endif static void -SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_WaitVBRetrace(struct SiS_Private *SiS_Pr) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; - } - if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { - SiS_WaitRetrace1(SiS_Pr); - } else { - SiS_WaitRetrace2(SiS_Pr, 0x25); - } + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; + } + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { + SiS_WaitRetrace1(SiS_Pr); + } else { + SiS_WaitRetrace2(SiS_Pr, 0x25); + } #endif - } else { + } else { #ifdef SIS315H - if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { - SiS_WaitRetrace1(SiS_Pr); - } else { - SiS_WaitRetrace2(SiS_Pr, 0x30); - } + if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { + SiS_WaitRetrace1(SiS_Pr); + } else { + SiS_WaitRetrace2(SiS_Pr, 0x30); + } #endif - } + } } static void -SiS_VBWait(SiS_Private *SiS_Pr) +SiS_VBWait(struct SiS_Private *SiS_Pr) { - USHORT tempal,temp,i,j; + unsigned short tempal,temp,i,j; - temp = 0; - for(i=0; i<3; i++) { - for(j=0; j<100; j++) { - tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da); - if(temp & 0x01) { - if((tempal & 0x08)) continue; - else break; - } else { - if(!(tempal & 0x08)) continue; - else break; - } - } - temp ^= 0x01; - } + temp = 0; + for(i = 0; i < 3; i++) { + for(j = 0; j < 100; j++) { + tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da); + if(temp & 0x01) { + if((tempal & 0x08)) continue; + else break; + } else { + if(!(tempal & 0x08)) continue; + else break; + } + } + temp ^= 0x01; + } } static void -SiS_VBLongWait(SiS_Private *SiS_Pr) +SiS_VBLongWait(struct SiS_Private *SiS_Pr) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_VBWait(SiS_Pr); - } else { - SiS_WaitRetrace1(SiS_Pr); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_VBWait(SiS_Pr); + } else { + SiS_WaitRetrace1(SiS_Pr); + } } /*********************************************/ @@ -690,237 +691,225 @@ SiS_VBLongWait(SiS_Private *SiS_Pr) #ifdef SIS300 static BOOLEAN -SiS_Is301B(SiS_Private *SiS_Pr) +SiS_Is301B(struct SiS_Private *SiS_Pr) { - if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return TRUE; - return FALSE; + if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return TRUE; + return FALSE; } #endif static BOOLEAN -SiS_CRT2IsLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_CRT2IsLCD(struct SiS_Private *SiS_Pr) { - USHORT flag; - - if(HwInfo->jChipType == SIS_730) { - flag = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13); - if(flag & 0x20) return TRUE; - } - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & 0x20) return TRUE; - return FALSE; + if(SiS_Pr->ChipType == SIS_730) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x20) return TRUE; + } + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & 0x20) return TRUE; + return FALSE; } BOOLEAN -SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsDualEdge(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - USHORT flag; - - if(HwInfo->jChipType >= SIS_315H) { - if((HwInfo->jChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableDualEdge) return TRUE; - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + if((SiS_Pr->ChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableDualEdge) return TRUE; + } + } #endif - return FALSE; + return FALSE; } BOOLEAN -SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsVAMode(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - USHORT flag; + unsigned short flag; - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE; - } + if(SiS_Pr->ChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE; + } #endif - return FALSE; + return FALSE; } #ifdef SIS315H static BOOLEAN -SiS_IsVAorLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsVAorLCD(struct SiS_Private *SiS_Pr) { - if(SiS_IsVAMode(SiS_Pr,HwInfo)) return TRUE; - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) return TRUE; - return FALSE; + if(SiS_IsVAMode(SiS_Pr)) return TRUE; + if(SiS_CRT2IsLCD(SiS_Pr)) return TRUE; + return FALSE; } #endif static BOOLEAN -SiS_IsDualLink(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsDualLink(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { - if((SiS_CRT2IsLCD(SiS_Pr, HwInfo)) || - (SiS_IsVAMode(SiS_Pr, HwInfo))) { - if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return TRUE; - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + if((SiS_CRT2IsLCD(SiS_Pr)) || + (SiS_IsVAMode(SiS_Pr))) { + if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return TRUE; + } + } #endif - return FALSE; + return FALSE; } #ifdef SIS315H static BOOLEAN -SiS_TVEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_TVEnabled(struct SiS_Private *SiS_Pr) { - if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return TRUE; - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS301LV302LV)) { - if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE; - } - return FALSE; + if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return TRUE; + if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { + if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_LCDAEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_LCDAEnabled(struct SiS_Private *SiS_Pr) { - if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return TRUE; - return FALSE; + if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return TRUE; + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_WeHaveBacklightCtrl(struct SiS_Private *SiS_Pr) { - if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { - if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return TRUE; - } - return FALSE; + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) { + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsNotM650orLater(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsNotM650orLater(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(HwInfo->jChipType == SIS_650) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f); - flag &= 0xF0; - /* Check for revision != A0 only */ - if((flag == 0xe0) || (flag == 0xc0) || - (flag == 0xb0) || (flag == 0x90)) return FALSE; - } else if(HwInfo->jChipType >= SIS_661) return FALSE; - return TRUE; + if(SiS_Pr->ChipType == SIS_650) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0; + /* Check for revision != A0 only */ + if((flag == 0xe0) || (flag == 0xc0) || + (flag == 0xb0) || (flag == 0x90)) return FALSE; + } else if(SiS_Pr->ChipType >= SIS_661) return FALSE; + return TRUE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsYPbPr(struct SiS_Private *SiS_Pr) { - USHORT flag; - - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ - } - return FALSE; + if(SiS_Pr->ChipType >= SIS_315H) { + /* YPrPb = 0x08 */ + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableCHYPbPr) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsChScart(struct SiS_Private *SiS_Pr) { - USHORT flag; - - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 */ - } - return FALSE; + if(SiS_Pr->ChipType >= SIS_315H) { + /* Scart = 0x04 */ + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableCHScart) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsTVOrYPbPrOrScart(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToTV) return TRUE; - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ - if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 - TW */ - } else { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToTV) return TRUE; - } - return FALSE; + if(SiS_Pr->ChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToTV) return TRUE; + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ + if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 - TW */ + } else { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToTV) return TRUE; + } + return FALSE; } #endif #ifdef SIS315H static BOOLEAN -SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_IsLCDOrLCDA(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(HwInfo->jChipType >= SIS_315H) { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return TRUE; - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(flag & SetToLCDA) return TRUE; - } else { - flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(flag & SetCRT2ToLCD) return TRUE; - } - return FALSE; + if(SiS_Pr->ChipType >= SIS_315H) { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(flag & SetToLCDA) return TRUE; + } else { + flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(flag & SetCRT2ToLCD) return TRUE; + } + return FALSE; } #endif static BOOLEAN -SiS_BridgeIsOn(SiS_Private *SiS_Pr) +SiS_HaveBridge(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - return TRUE; - } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); - if((flag == 1) || (flag == 2)) return TRUE; - } - return FALSE; + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + return TRUE; + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); + if((flag == 1) || (flag == 2)) return TRUE; + } + return FALSE; } static BOOLEAN -SiS_BridgeIsEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_BridgeIsEnabled(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; - if(SiS_BridgeIsOn(SiS_Pr)) { - flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); - if(HwInfo->jChipType < SIS_315H) { - flag &= 0xa0; - if((flag == 0x80) || (flag == 0x20)) return TRUE; - } else { - flag &= 0x50; - if((flag == 0x40) || (flag == 0x10)) return TRUE; - } - } - return FALSE; + if(SiS_HaveBridge(SiS_Pr)) { + flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + if(SiS_Pr->ChipType < SIS_315H) { + flag &= 0xa0; + if((flag == 0x80) || (flag == 0x20)) return TRUE; + } else { + flag &= 0x50; + if((flag == 0x40) || (flag == 0x10)) return TRUE; + } + } + return FALSE; } static BOOLEAN -SiS_BridgeInSlavemode(SiS_Private *SiS_Pr) +SiS_BridgeInSlavemode(struct SiS_Private *SiS_Pr) { - USHORT flag1; + unsigned short flag1; - flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); - if(flag1 & (SetInSlaveMode >> 8)) return TRUE; - return FALSE; + flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); + if(flag1 & (SetInSlaveMode >> 8)) return TRUE; + return FALSE; } /*********************************************/ @@ -928,119 +917,97 @@ SiS_BridgeInSlavemode(SiS_Private *SiS_Pr) /*********************************************/ /* Setup general purpose IO for Chrontel communication */ +#ifdef SIS300 void -SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo) +SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo) { - unsigned long acpibase; + unsigned int acpibase; unsigned short temp; if(!(SiS_Pr->SiS_ChSW)) return; -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x80000874); /* get ACPI base */ - acpibase = SiS_GetRegLong(0xcfc); +#ifdef SIS_LINUX_KERNEL + acpibase = sisfb_read_lpc_pci_dword(SiS_Pr, 0x74); #else acpibase = pciReadLong(0x00000800, 0x74); #endif acpibase &= 0xFFFF; - temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ + if(!acpibase) return; + temp = SiS_GetRegShort((acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ temp &= 0xFEFF; - SiS_SetRegShort((USHORT)(acpibase + 0x3c), temp); - temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); - temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */ + SiS_SetRegShort((acpibase + 0x3c), temp); + temp = SiS_GetRegShort((acpibase + 0x3c)); + temp = SiS_GetRegShort((acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */ temp &= 0xFEFF; if(!(myvbinfo & SetCRT2ToTV)) temp |= 0x0100; - SiS_SetRegShort((USHORT)(acpibase + 0x3a), temp); - temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); + SiS_SetRegShort((acpibase + 0x3a), temp); + temp = SiS_GetRegShort((acpibase + 0x3a)); } +#endif void -SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo, int checkcrt2mode) +SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, int checkcrt2mode) { - USHORT tempax,tempbx,temp; - USHORT modeflag, resinfo=0; + unsigned short tempax, tempbx, temp; + unsigned short modeflag, resinfo = 0; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } + SiS_Pr->SiS_SetFlag = 0; - SiS_Pr->SiS_SetFlag = 0; + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); - SiS_Pr->SiS_ModeType = modeflag & ModeTypeMask; + SiS_Pr->SiS_ModeType = modeflag & ModeTypeMask; - tempbx = 0; - if(SiS_BridgeIsOn(SiS_Pr)) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); -#if 0 - if(HwInfo->jChipType < SIS_661) { - /* NO - YPbPr not set yet ! */ - if(SiS_Pr->SiS_YPbPr & <all ypbpr except 525i>) { - temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToHiVision; /* 0x80 */ - } - if(SiS_Pr->SiS_YPbPr & <ypbpr525i>) { - temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ - temp |= SetCRT2ToSVIDEO; /* 0x08 */ - } - } -#endif - tempbx |= temp; - tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8; - tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV); - tempbx |= tempax; + if((ModeNo > 0x13) && (!SiS_Pr->UseCustomMode)) { + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } + + tempbx = 0; + + if(SiS_HaveBridge(SiS_Pr)) { + + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + tempbx |= temp; + tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8; + tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV); + tempbx |= tempax; #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SISLCDA) { + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISLCDA) { if(ModeNo == 0x03) { - /* Mode 0x03 is never in driver mode */ + /* Mode 0x03 is never in driver mode */ SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf); } if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) { - /* Reset LCDA setting if not driver mode */ + /* Reset LCDA setting if not driver mode */ SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); } if(IS_SIS650) { - if(SiS_Pr->SiS_UseLCDA) { + if(SiS_Pr->SiS_UseLCDA) { if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { if((ModeNo <= 0x13) || (!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); + SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); } } } } temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { - tempbx |= SetCRT2ToLCDA; + if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { + tempbx |= SetCRT2ToLCDA; } } - if(SiS_Pr->SiS_VBType & (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV)) { - tempbx &= ~(SetCRT2ToRAMDAC); - } - - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { /* New CR layout */ tempbx &= ~(SetCRT2ToYPbPr525750 | SetCRT2ToHiVision); - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { - if(temp & 0x04) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; - if(temp == 0x60) tempbx |= SetCRT2ToHiVision; - else tempbx |= SetCRT2ToYPbPr525750; - } - } else if(SiS_Pr->SiS_VBType & VB_SISHIVISION) { - if(temp & 0x04) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; - if(temp == 0x60) tempbx |= SetCRT2ToHiVision; + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & 0x04) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; + if(temp == 0x60) tempbx |= SetCRT2ToHiVision; + else if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { + tempbx |= SetCRT2ToYPbPr525750; } } - } + } if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); @@ -1048,7 +1015,7 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbx |= SetCRT2ToLCDA; } if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(temp & EnableCHYPbPr) { + if(temp & EnableCHYPbPr) { tempbx |= SetCRT2ToCHYPbPr; } } @@ -1057,44 +1024,49 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #endif /* SIS315H */ - if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(!(SiS_Pr->SiS_VBType & VB_SISVGA2)) { + tempbx &= ~(SetCRT2ToRAMDAC); + } + + if(SiS_Pr->SiS_VBType & VB_SISVB) { temp = SetCRT2ToSVIDEO | - SetCRT2ToAVIDEO | - SetCRT2ToSCART | - SetCRT2ToLCDA | - SetCRT2ToLCD | - SetCRT2ToRAMDAC | - SetCRT2ToHiVision | + SetCRT2ToAVIDEO | + SetCRT2ToSCART | + SetCRT2ToLCDA | + SetCRT2ToLCD | + SetCRT2ToRAMDAC | + SetCRT2ToHiVision | SetCRT2ToYPbPr525750; - } else { - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - temp = SetCRT2ToAVIDEO | + } else { + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SetCRT2ToAVIDEO | SetCRT2ToSVIDEO | SetCRT2ToSCART | SetCRT2ToLCDA | SetCRT2ToLCD | SetCRT2ToCHYPbPr; - } else { - temp = SetCRT2ToLCDA | + } else { + temp = SetCRT2ToLCDA | SetCRT2ToLCD; } } else { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - temp = SetCRT2ToTV | SetCRT2ToLCD; - } else { - temp = SetCRT2ToLCD; + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + temp = SetCRT2ToTV | SetCRT2ToLCD; + } else { + temp = SetCRT2ToLCD; } } - } + } + + if(!(tempbx & temp)) { + tempax = DisableCRT2Display; + tempbx = 0; + } - if(!(tempbx & temp)) { - tempax = DisableCRT2Display; - tempbx = 0; - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - USHORT clearmask = ( DriverMode | + unsigned short clearmask = ( DriverMode | DisableCRT2Display | LoadDACFlag | SetNotSimuMode | @@ -1102,106 +1074,104 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SetPALTV | SwitchCRT2 | SetSimuScanMode ); - if(tempbx & SetCRT2ToLCDA) tempbx &= (clearmask | SetCRT2ToLCDA); + + if(tempbx & SetCRT2ToLCDA) tempbx &= (clearmask | SetCRT2ToLCDA); if(tempbx & SetCRT2ToRAMDAC) tempbx &= (clearmask | SetCRT2ToRAMDAC); if(tempbx & SetCRT2ToLCD) tempbx &= (clearmask | SetCRT2ToLCD); if(tempbx & SetCRT2ToSCART) tempbx &= (clearmask | SetCRT2ToSCART); if(tempbx & SetCRT2ToHiVision) tempbx &= (clearmask | SetCRT2ToHiVision); if(tempbx & SetCRT2ToYPbPr525750) tempbx &= (clearmask | SetCRT2ToYPbPr525750); - } else { - if(HwInfo->jChipType >= SIS_315H) { + + } else { + + if(SiS_Pr->ChipType >= SIS_315H) { if(tempbx & SetCRT2ToLCDA) { - tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode); + tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode); } } - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(tempbx & SetCRT2ToTV) { - tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode); + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(tempbx & SetCRT2ToTV) { + tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode); } - } - if(tempbx & SetCRT2ToLCD) { - tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode); } - if(HwInfo->jChipType >= SIS_315H) { + if(tempbx & SetCRT2ToLCD) { + tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode); + } + if(SiS_Pr->ChipType >= SIS_315H) { if(tempbx & SetCRT2ToLCDA) { tempbx |= SetCRT2ToLCD; } } + } - if(tempax & DisableCRT2Display) { - if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { - tempbx = SetSimuScanMode | DisableCRT2Display; - } - } + if(tempax & DisableCRT2Display) { + if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { + tempbx = SetSimuScanMode | DisableCRT2Display; + } + } - if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode; + if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode; /* LVDS/CHRONTEL (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */ if(SiS_Pr->SiS_ModeType <= ModeVGA) { if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || ((SiS_Pr->SiS_VBType & VB_NoLCD) && (tempbx & SetCRT2ToLCD)) ) { - modeflag &= (~CRT2Mode); + modeflag &= (~CRT2Mode); } } - if(!(tempbx & SetSimuScanMode)) { - if(tempbx & SwitchCRT2) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwInfo->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != SIS_RI_1600x1200) { - tempbx |= SetSimuScanMode; - } - } else { - tempbx |= SetSimuScanMode; - } + if(!(tempbx & SetSimuScanMode)) { + if(tempbx & SwitchCRT2) { + if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { + if(resinfo != SIS_RI_1600x1200) { + tempbx |= SetSimuScanMode; + } } - } else { - if(SiS_BridgeIsEnabled(SiS_Pr,HwInfo)) { - if(!(tempbx & DriverMode)) { - if(SiS_BridgeInSlavemode(SiS_Pr)) { + } else { + if(SiS_BridgeIsEnabled(SiS_Pr)) { + if(!(tempbx & DriverMode)) { + if(SiS_BridgeInSlavemode(SiS_Pr)) { tempbx |= SetSimuScanMode; - } - } - } - } - } - - if(!(tempbx & DisableCRT2Display)) { - if(tempbx & DriverMode) { - if(tempbx & SetSimuScanMode) { - if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { - if( (HwInfo->jChipType >= SIS_315H) && - (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { - if(resinfo != SIS_RI_1600x1200) { - tempbx |= SetInSlaveMode; - } - } else { - tempbx |= SetInSlaveMode; - } - } - } - } else { - tempbx |= SetInSlaveMode; - } - } + } + } + } + } + } - } + if(!(tempbx & DisableCRT2Display)) { + if(tempbx & DriverMode) { + if(tempbx & SetSimuScanMode) { + if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { + if(resinfo != SIS_RI_1600x1200) { + tempbx |= SetInSlaveMode; + } + } + } + } else { + tempbx |= SetInSlaveMode; + } + } - SiS_Pr->SiS_VBInfo = tempbx; + } - if(HwInfo->jChipType == SIS_630) { - SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); - } + SiS_Pr->SiS_VBInfo = tempbx; -#ifdef TWDEBUG -#ifdef LINUX_KERNEL - printk(KERN_DEBUG "sisfb: (VBInfo= 0x%04x, SetFlag=0x%04x)\n", +#ifdef SIS300 + if(SiS_Pr->ChipType == SIS_630) { + SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); + } +#endif + +#ifdef SIS_LINUX_KERNEL +#if 0 + printk(KERN_DEBUG "sisfb: (init301: VBInfo= 0x%04x, SetFlag=0x%04x)\n", SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); #endif -#ifdef LINUX_XF86 - xf86DrvMsgVerb(0, X_PROBED, 3, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n", +#endif +#ifdef SIS_XORG_XF86 +#ifdef TWDEBUG + xf86DrvMsg(0, X_PROBED, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n", SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); #endif #endif @@ -1212,41 +1182,41 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ void -SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_SetYPbPr(struct SiS_Private *SiS_Pr) { - UCHAR temp; + unsigned char temp; - /* Note: This variable is only used on 30xLV systems. - * CR38 has a different meaning on LVDS/CH7019 systems. - * On 661 and later, these bits moved to CR35. - * - * On 301, 301B, only HiVision 1080i is supported. - * On 30xLV, 301C, only YPbPr 1080i is supported. - */ + /* Note: This variable is only used on 30xLV systems. + * CR38 has a different meaning on LVDS/CH7019 systems. + * On 661 and later, these bits moved to CR35. + * + * On 301, 301B, only HiVision 1080i is supported. + * On 30xLV, 301C, only YPbPr 1080i is supported. + */ - SiS_Pr->SiS_YPbPr = 0; - if(HwInfo->jChipType >= SIS_661) return; + SiS_Pr->SiS_YPbPr = 0; + if(SiS_Pr->ChipType >= SIS_661) return; - if(SiS_Pr->SiS_VBType) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - SiS_Pr->SiS_YPbPr = YPbPrHiVision; - } - } + if(SiS_Pr->SiS_VBType) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_YPbPr = YPbPrHiVision; + } + } - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_SIS301C)) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(temp & 0x08) { - switch((temp >> 4)) { - case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break; - case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break; - case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break; - case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break; - } - } - } - } + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(temp & 0x08) { + switch((temp >> 4)) { + case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break; + case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break; + case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break; + case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break; + } + } + } + } } @@ -1255,199 +1225,204 @@ SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ void -SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo) +SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp, temp1, resinfo = 0, romindex = 0; - UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp, temp1, resinfo = 0, romindex = 0; + unsigned char OutputSelect = *SiS_Pr->pSiS_OutputSelect; - SiS_Pr->SiS_TVMode = 0; + SiS_Pr->SiS_TVMode = 0; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; - if(SiS_Pr->UseCustomMode) return; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; + if(SiS_Pr->UseCustomMode) return; - if(ModeNo > 0x13) { - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; - } + if(ModeNo > 0x13) { + resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; + } - if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->ChipType < SIS_661) { - if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; + if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; - if(SiS_Pr->SiS_VBType & VB_SISVB) { - temp = 0; - if((HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730)) { - temp = 0x35; - romindex = 0xfe; - } else if(HwInfo->jChipType >= SIS_315H) { - temp = 0x38; - romindex = 0xf3; - if(HwInfo->jChipType >= SIS_330) romindex = 0x11b; - } - if(temp) { - if(romindex && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { - OutputSelect = ROMAddr[romindex]; - if(!(OutputSelect & EnablePALMN)) { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F); - } - } - temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp); - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if(temp1 & EnablePALM) { /* 0x40 */ - SiS_Pr->SiS_TVMode |= TVSetPALM; - SiS_Pr->SiS_TVMode &= ~TVSetPAL; - } else if(temp1 & EnablePALN) { /* 0x80 */ - SiS_Pr->SiS_TVMode |= TVSetPALN; - } - } else { - if(temp1 & EnableNTSCJ) { /* 0x40 */ - SiS_Pr->SiS_TVMode |= TVSetNTSCJ; - } - } - } - /* Translate HiVision/YPbPr to our new flags */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; - else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; - else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision; - else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; - if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) { - SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision; - SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750; - } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { - SiS_Pr->SiS_TVMode |= TVSetPAL; - } - } - } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_CHOverScan) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); - if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) { - SiS_Pr->SiS_TVMode |= TVSetCHOverScan; - } - } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); - if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) { - SiS_Pr->SiS_TVMode |= TVSetCHOverScan; - } - } - if(SiS_Pr->SiS_CHSOverScan) { - SiS_Pr->SiS_TVMode |= TVSetCHOverScan; - } - } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM; - else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN; - } else { - if(temp & EnableNTSCJ) { - SiS_Pr->SiS_TVMode |= TVSetNTSCJ; - } - } - } - } + if(SiS_Pr->SiS_VBType & VB_SISVB) { + temp = 0; + if((SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730)) { + temp = 0x35; + romindex = 0xfe; + } else if(SiS_Pr->ChipType >= SIS_315H) { + temp = 0x38; + if(SiS_Pr->ChipType < XGI_20) { + romindex = 0xf3; + if(SiS_Pr->ChipType >= SIS_330) romindex = 0x11b; + } + } + if(temp) { + if(romindex && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { + OutputSelect = ROMAddr[romindex]; + if(!(OutputSelect & EnablePALMN)) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F); + } + } + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(temp1 & EnablePALM) { /* 0x40 */ + SiS_Pr->SiS_TVMode |= TVSetPALM; + SiS_Pr->SiS_TVMode &= ~TVSetPAL; + } else if(temp1 & EnablePALN) { /* 0x80 */ + SiS_Pr->SiS_TVMode |= TVSetPALN; + } + } else { + if(temp1 & EnableNTSCJ) { /* 0x40 */ + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + } + /* Translate HiVision/YPbPr to our new flags */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; + else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; + else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision; + else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) { + SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision; + SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750; + } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + } + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_CHOverScan) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); + if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + if(SiS_Pr->SiS_CHSOverScan) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM; + else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN; + } else { + if(temp & EnableNTSCJ) { + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + } + } - } else { /* 661 and later */ + } else { /* 661 and later */ - temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); - if(temp1 & 0x01) { - SiS_Pr->SiS_TVMode |= TVSetPAL; - if(temp1 & 0x08) { - SiS_Pr->SiS_TVMode |= TVSetPALN; - } else if(temp1 & 0x04) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - SiS_Pr->SiS_TVMode &= ~TVSetPAL; - } - SiS_Pr->SiS_TVMode |= TVSetPALM; - } - } else { - if(temp1 & 0x02) { - SiS_Pr->SiS_TVMode |= TVSetNTSCJ; - } - } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(SiS_Pr->SiS_CHOverScan) { - if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) { - SiS_Pr->SiS_TVMode |= TVSetCHOverScan; - } - } - } - if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - temp1 &= 0xe0; - if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; - else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; - else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL); - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) { - if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) { - SiS_Pr->SiS_TVMode |= TVAspect169; - } else { - temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39); - if(temp1 & 0x02) { - if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) { - SiS_Pr->SiS_TVMode |= TVAspect169; - } else { - SiS_Pr->SiS_TVMode |= TVAspect43LB; - } - } else { - SiS_Pr->SiS_TVMode |= TVAspect43; - } - } - } - } - } + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); + if(temp1 & 0x01) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + if(temp1 & 0x08) { + SiS_Pr->SiS_TVMode |= TVSetPALN; + } else if(temp1 & 0x04) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { + SiS_Pr->SiS_TVMode &= ~TVSetPAL; + } + SiS_Pr->SiS_TVMode |= TVSetPALM; + } + } else { + if(temp1 & 0x02) { + SiS_Pr->SiS_TVMode |= TVSetNTSCJ; + } + } + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_Pr->SiS_CHOverScan) { + if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) { + SiS_Pr->SiS_TVMode |= TVSetCHOverScan; + } + } + } + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + temp1 &= 0xe0; + if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; + else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; + else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL); + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) { + if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) { + SiS_Pr->SiS_TVMode |= TVAspect169; + } else { + temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39); + if(temp1 & 0x02) { + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) { + SiS_Pr->SiS_TVMode |= TVAspect169; + } else { + SiS_Pr->SiS_TVMode |= TVAspect43LB; + } + } else { + SiS_Pr->SiS_TVMode |= TVAspect43; + } + } + } + } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL; - if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - SiS_Pr->SiS_TVMode |= TVSetPAL; - SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ); - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) { - SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN); - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + SiS_Pr->SiS_TVMode |= TVSetPAL; + SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ); + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) { + SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN); + } + } - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; - } - } + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; + } + } - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { - /* BIOS sets TVNTSC1024 without checking 525p here. Wrong? */ - if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr525p | TVSetYPbPr750p))) { - if(resinfo == SIS_RI_1024x768) { - SiS_Pr->SiS_TVMode |= TVSetNTSC1024; - } - } - } + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + if(resinfo == SIS_RI_1024x768) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { + SiS_Pr->SiS_TVMode |= TVSet525p1024; + } else if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p))) { + SiS_Pr->SiS_TVMode |= TVSetNTSC1024; + } + } + } - SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && - (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; - } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { - SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; - } else if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; - } - } + SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO; + if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && + (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } else if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; + } + } - } + } - SiS_Pr->SiS_VBInfo &= ~SetPALTV; + SiS_Pr->SiS_VBInfo &= ~SetPALTV; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo); + xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo); +#endif #endif } @@ -1455,41 +1430,46 @@ SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_IN /* GET LCD INFO */ /*********************************************/ -static USHORT -SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr) +static unsigned short +SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr) { - USHORT temp = SiS_Pr->SiS_LCDResInfo; + unsigned short temp = SiS_Pr->SiS_LCDResInfo; /* Translate my LCDResInfo to BIOS value */ - if(temp == Panel_1280x768_2) temp = Panel_1280x768; - if(temp == Panel_1280x800_2) temp = Panel_1280x800; + switch(temp) { + case Panel_1280x768_2: temp = Panel_1280x768; break; + case Panel_1280x800_2: temp = Panel_1280x800; break; + case Panel_1280x854: temp = Panel661_1280x854; break; + } return temp; } static void -SiS_GetLCDInfoBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_GetLCDInfoBIOS(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - UCHAR *ROMAddr; - USHORT temp; + unsigned char *ROMAddr; + unsigned short temp; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Paneldata driver: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n", - SiS_Pr->PanelHT, SiS_Pr->PanelVT, + SiS_Pr->PanelHT, SiS_Pr->PanelVT, SiS_Pr->PanelHRS, SiS_Pr->PanelHRE, SiS_Pr->PanelVRS, SiS_Pr->PanelVRE, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B); #endif +#endif - if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { + if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) { if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) { - SiS_Pr->SiS_NeedRomModeData = TRUE; + SiS_Pr->SiS_NeedRomModeData = TRUE; SiS_Pr->PanelHT = temp; } if((temp = SISGETROMW(8)) != SiS_Pr->PanelVT) { - SiS_Pr->SiS_NeedRomModeData = TRUE; - SiS_Pr->PanelVT = temp; + SiS_Pr->SiS_NeedRomModeData = TRUE; + SiS_Pr->PanelVT = temp; } SiS_Pr->PanelHRS = SISGETROMW(10); SiS_Pr->PanelHRE = SISGETROMW(12); @@ -1497,56 +1477,58 @@ SiS_GetLCDInfoBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_Pr->PanelVRE = SISGETROMW(16); SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].CLOCK = - SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (USHORT)((UCHAR)ROMAddr[18]); + SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (unsigned short)((unsigned char)ROMAddr[18]); SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2B = SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_A = ROMAddr[19]; SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C = SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20]; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Paneldata BIOS: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n", - SiS_Pr->PanelHT, SiS_Pr->PanelVT, + SiS_Pr->PanelHT, SiS_Pr->PanelVT, SiS_Pr->PanelHRS, SiS_Pr->PanelHRE, SiS_Pr->PanelVRS, SiS_Pr->PanelVRE, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A, SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B); #endif +#endif } #endif } static void -SiS_CheckScaling(SiS_Private *SiS_Pr, USHORT resinfo, const UCHAR *nonscalingmodes) -{ - int i = 0; - while(nonscalingmodes[i] != 0xff) { - if(nonscalingmodes[i++] == resinfo) { - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || - (SiS_Pr->UsePanelScaler == -1)) { - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - break; - } - } +SiS_CheckScaling(struct SiS_Private *SiS_Pr, unsigned short resinfo, + const unsigned char *nonscalingmodes) +{ + int i = 0; + while(nonscalingmodes[i] != 0xff) { + if(nonscalingmodes[i++] == resinfo) { + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || + (SiS_Pr->UsePanelScaler == -1)) { + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; + } + } } void -SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { + unsigned short temp,modeflag,resinfo=0,modexres=0,modeyres=0; + BOOLEAN panelcanscale = FALSE; #ifdef SIS300 - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - const unsigned char SiS300SeriesLCDRes[] = + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + static const unsigned char SiS300SeriesLCDRes[] = { 0, 1, 2, 3, 7, 4, 5, 8, 0, 0, 10, 0, 0, 0, 0, 15 }; #endif #ifdef SIS315H - UCHAR *myptr = NULL; + unsigned char *myptr = NULL; #endif - USHORT temp,modeflag,resinfo=0,modexres=0,modeyres=0; - BOOLEAN panelcanscale = FALSE; SiS_Pr->SiS_LCDResInfo = 0; SiS_Pr->SiS_LCDTypeInfo = 0; @@ -1557,14 +1539,14 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->PanelVRE = 999; /* VSync end */ SiS_Pr->SiS_NeedRomModeData = FALSE; + /* Alternative 1600x1200@60 timing for 1600x1200 LCDA */ + SiS_Pr->Alternate1600x1200 = FALSE; + if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); + + if((ModeNo > 0x13) && (!SiS_Pr->UseCustomMode)) { resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; modexres = SiS_Pr->SiS_ModeResInfo[resinfo].HTotal; modeyres = SiS_Pr->SiS_ModeResInfo[resinfo].VTotal; @@ -1575,16 +1557,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* For broken BIOSes: Assume 1024x768 */ if(temp == 0) temp = 0x02; - if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { + if((SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { SiS_Pr->SiS_LCDTypeInfo = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x7c) >> 2; - } else if((HwInfo->jChipType < SIS_315H) || (HwInfo->jChipType >= SIS_661)) { + } else if((SiS_Pr->ChipType < SIS_315H) || (SiS_Pr->ChipType >= SIS_661)) { SiS_Pr->SiS_LCDTypeInfo = temp >> 4; } else { SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; } temp &= 0x0f; #ifdef SIS300 - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { /* Very old BIOSes only know 7 sizes (NetVista 2179, 1.01g) */ if(SiS_Pr->SiS_VBType & VB_SIS301) { if(temp < 0x0f) temp &= 0x07; @@ -1595,17 +1577,22 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #endif /* Translate to our internal types */ - if(HwInfo->jChipType == SIS_550) { - if(temp == Panel310_640x480_2) temp = Panel_640x480_2; - if(temp == Panel310_640x480_3) temp = Panel_640x480_3; +#ifdef SIS315H + if(SiS_Pr->ChipType == SIS_550) { + if (temp == Panel310_1152x768) temp = Panel_320x240_2; /* Verified working */ + else if(temp == Panel310_320x240_2) temp = Panel_320x240_2; + else if(temp == Panel310_320x240_3) temp = Panel_320x240_3; + } else if(SiS_Pr->ChipType >= SIS_661) { + if(temp == Panel661_1280x854) temp = Panel_1280x854; } +#endif - if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* SiS LVDS */ + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* SiS LVDS */ if(temp == Panel310_1280x768) { temp = Panel_1280x768_2; } if(SiS_Pr->SiS_ROMNew) { - if(temp == Panel661_1280x800) { + if(temp == Panel661_1280x800) { temp = Panel_1280x800_2; } } @@ -1613,13 +1600,17 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->SiS_LCDResInfo = temp; +#ifdef SIS300 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { - SiS_Pr->SiS_LCDResInfo = Panel_Barco1366; + SiS_Pr->SiS_LCDResInfo = Panel_Barco1366; } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { - SiS_Pr->SiS_LCDResInfo = Panel_848x480; + SiS_Pr->SiS_LCDResInfo = Panel_848x480; + } else if(SiS_Pr->SiS_CustomT == CUT_PANEL856) { + SiS_Pr->SiS_LCDResInfo = Panel_856x480; } } +#endif if(SiS_Pr->SiS_VBType & VB_SISVB) { if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301) @@ -1633,10 +1624,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->SiS_LCDInfo = temp & ~0x000e; /* Need temp below! */ - /* These can't scale no matter what */ + /* These must/can't scale no matter what */ switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_320x240_1: + case Panel_320x240_2: + case Panel_320x240_3: case Panel_1280x960: SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; + break; + case Panel_640x480: + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; } panelcanscale = (SiS_Pr->SiS_LCDInfo & DontExpandLCD) ? TRUE : FALSE; @@ -1646,41 +1643,41 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* Dual link, Pass 1:1 BIOS default, etc. */ #ifdef SIS315H - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11; + if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11; } - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - if(SiS_Pr->SiS_ROMNew) { + if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { + if(SiS_Pr->SiS_ROMNew) { if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; - } else if((myptr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { - if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink; + } else if((myptr = GetLCDStructPtr661(SiS_Pr))) { + if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink; } } - } else if(HwInfo->jChipType >= SIS_315H) { + } else if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11; + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11; } if((SiS_Pr->SiS_ROMNew) && (!(SiS_Pr->PanelSelfDetected))) { - SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit); + SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit); temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); - if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit; - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit; + if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; } } else if(!(SiS_Pr->SiS_ROMNew)) { - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && + if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { + if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && (SiS_Pr->SiS_LCDResInfo == Panel_1024x768)) { SiS_Pr->SiS_LCDInfo |= LCDDualLink; } - if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || + if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || - (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || + (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || (SiS_Pr->SiS_LCDResInfo == Panel_1680x1050)) { SiS_Pr->SiS_LCDInfo |= LCDDualLink; } - } + } } } #endif @@ -1691,12 +1688,12 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } else if(SiS_Pr->SiS_VBType & VB_SISVB) { if(SiS_Pr->SiS_VBType & VB_SISLVDS) { - /* Always center screen on SiS LVDS (if scaling is disabled) */ - SiS_Pr->SiS_LCDInfo &= ~LCDPass11; + /* Always center screen on SiS LVDS (if scaling is disabled) */ + SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } else { - /* By default, pass 1:1 on SiS TMDS (if scaling is supported) */ - if(panelcanscale) SiS_Pr->SiS_LCDInfo |= LCDPass11; - if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11; + /* By default, pass 1:1 on SiS TMDS (if scaling is supported) */ + if(panelcanscale) SiS_Pr->SiS_LCDInfo |= LCDPass11; + if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11; } } @@ -1704,19 +1701,15 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; switch(SiS_Pr->SiS_LCDResInfo) { - case Panel_320x480: SiS_Pr->PanelXRes = 320; SiS_Pr->PanelYRes = 480; - SiS_Pr->PanelHT = 400; SiS_Pr->PanelVT = 525; - SiS_Pr->PanelVCLKIdx300 = VCLK28; - SiS_Pr->PanelVCLKIdx315 = VCLK28; - break; - case Panel_640x480_2: - case Panel_640x480_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; - SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3; + case Panel_320x240_1: + case Panel_320x240_2: + case Panel_320x240_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; + SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx300 = VCLK28; SiS_Pr->PanelVCLKIdx315 = VCLK28; break; case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; - SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx300 = VCLK28; SiS_Pr->PanelVCLKIdx315 = VCLK28; break; @@ -1728,52 +1721,52 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->PanelVCLKIdx315 = VCLK40; break; case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600; - SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800; SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; SiS_Pr->PanelVRS = 2 /* 88 */ ; SiS_Pr->PanelVRE = 6; - SiS_Pr->PanelVCLKIdx300 = VCLK65_300; + SiS_Pr->PanelVCLKIdx300 = VCLK65_300; SiS_Pr->PanelVCLKIdx315 = VCLK65_315; - break; + break; case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; - SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { SiS_Pr->PanelHRS = 23; - SiS_Pr->PanelVRE = 5; + SiS_Pr->PanelVRE = 5; } SiS_Pr->PanelVCLKIdx300 = VCLK65_300; SiS_Pr->PanelVCLKIdx315 = VCLK65_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768; - SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; - SiS_Pr->PanelHRS = 24; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { SiS_Pr->PanelHRS = 23; - SiS_Pr->PanelVRE = 5; + SiS_Pr->PanelVRE = 5; } - SiS_Pr->PanelVCLKIdx300 = VCLK65_300; + SiS_Pr->PanelVCLKIdx300 = VCLK65_300; SiS_Pr->PanelVCLKIdx315 = VCLK65_315; - break; + break; case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864; - break; + break; case Panel_1280x720: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 720; - SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750; + SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750; SiS_Pr->PanelHRS = 110; SiS_Pr->PanelHRE = 40; SiS_Pr->PanelVRS = 5; SiS_Pr->PanelVRE = 5; SiS_Pr->PanelVCLKIdx315 = VCLK_1280x720; /* Data above for TMDS (projector); get from BIOS for LVDS */ - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 806; SiS_Pr->PanelVCLKIdx300 = VCLK81_300; /* ? */ SiS_Pr->PanelVCLKIdx315 = VCLK81_315; /* ? */ } else { - SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802; SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRS = 112; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; SiS_Pr->PanelVCLKIdx300 = VCLK81_300; @@ -1781,77 +1774,100 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } break; case Panel_1280x768_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; - SiS_Pr->PanelHT = 1660; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHT = 1660; SiS_Pr->PanelVT = 806; SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; SiS_Pr->PanelVCLKIdx315 = VCLK_1280x768_2; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1280x800: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; - SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 816; + SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 816; SiS_Pr->PanelHRS = 21; SiS_Pr->PanelHRE = 24; SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1280x800_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; - SiS_Pr->PanelHT = 1552; SiS_Pr->PanelVT = 812; + SiS_Pr->PanelHT = 1552; SiS_Pr->PanelVT = 812; SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315_2; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); + break; + case Panel_1280x854: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 854; + SiS_Pr->PanelHT = 1664; SiS_Pr->PanelVT = 861; + SiS_Pr->PanelHRS = 16; SiS_Pr->PanelHRE = 112; + SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; + SiS_Pr->PanelVCLKIdx315 = VCLK_1280x854; + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960; - SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000; + SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000; SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; SiS_Pr->PanelVCLKIdx315 = VCLK108_3_315; - if(resinfo == SIS_RI_1280x1024) { + if(resinfo == SIS_RI_1280x1024) { SiS_Pr->PanelVCLKIdx300 = VCLK100_300; SiS_Pr->PanelVCLKIdx315 = VCLK100_315; } break; case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024; - SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050; - SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; - SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; /* HRE OK for LVDS, not for LCDA */ + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200; - SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250; + SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250; SiS_Pr->PanelHRS = 64; SiS_Pr->PanelHRE = 192; SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; SiS_Pr->PanelVCLKIdx315 = VCLK162_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + if(SiS_Pr->SiS_VBType & VB_SISTMDSLCDA) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_Pr->PanelHT = 1760; SiS_Pr->PanelVT = 1235; + SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 32; + SiS_Pr->PanelVRS = 2; SiS_Pr->PanelVRE = 4; + SiS_Pr->PanelVCLKIdx315 = VCLK130_315; + SiS_Pr->Alternate1600x1200 = TRUE; + } + } else if(SiS_Pr->SiS_IF_DEF_LVDS) { + SiS_Pr->PanelHT = 2048; SiS_Pr->PanelVT = 1320; + SiS_Pr->PanelHRS = SiS_Pr->PanelHRE = 999; + SiS_Pr->PanelVRS = SiS_Pr->PanelVRE = 999; + } + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_1680x1050: SiS_Pr->PanelXRes = 1680; SiS_Pr->PanelYRes = 1050; - SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066; + SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066; SiS_Pr->PanelHRS = 26; SiS_Pr->PanelHRE = 76; SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; SiS_Pr->PanelVCLKIdx315 = VCLK121_315; - SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); + SiS_GetLCDInfoBIOS(SiS_Pr); break; case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024; - SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; - break; + SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; + break; case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480; - SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; - break; + SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; + break; + case Panel_856x480: SiS_Pr->PanelXRes = 856; SiS_Pr->PanelYRes = 480; + SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; + break; case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX; - SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; + SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; SiS_Pr->PanelHT = SiS_Pr->CHTotal; SiS_Pr->PanelVT = SiS_Pr->CVTotal; if(SiS_Pr->CP_PreferredIndex != -1) { SiS_Pr->PanelXRes = SiS_Pr->CP_HDisplay[SiS_Pr->CP_PreferredIndex]; - SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex]; + SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex]; SiS_Pr->PanelHT = SiS_Pr->CP_HTotal[SiS_Pr->CP_PreferredIndex]; SiS_Pr->PanelVT = SiS_Pr->CP_VTotal[SiS_Pr->CP_PreferredIndex]; SiS_Pr->PanelHRS = SiS_Pr->CP_HSyncStart[SiS_Pr->CP_PreferredIndex]; @@ -1863,22 +1879,22 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_Pr->PanelVRS -= SiS_Pr->PanelYRes; SiS_Pr->PanelVRE -= SiS_Pr->PanelVRS; if(SiS_Pr->CP_PrefClock) { - int idx; - SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; + int idx; + SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; SiS_Pr->PanelVCLKIdx300 = VCLK_CUSTOM_300; - if(HwInfo->jChipType < SIS_315H) idx = VCLK_CUSTOM_300; + if(SiS_Pr->ChipType < SIS_315H) idx = VCLK_CUSTOM_300; else idx = VCLK_CUSTOM_315; - SiS_Pr->SiS_VCLKData[idx].CLOCK = - SiS_Pr->SiS_VBVCLKData[idx].CLOCK = SiS_Pr->CP_PrefClock; - SiS_Pr->SiS_VCLKData[idx].SR2B = - SiS_Pr->SiS_VBVCLKData[idx].Part4_A = SiS_Pr->CP_PrefSR2B; - SiS_Pr->SiS_VCLKData[idx].SR2C = - SiS_Pr->SiS_VBVCLKData[idx].Part4_B = SiS_Pr->CP_PrefSR2C; + SiS_Pr->SiS_VCLKData[idx].CLOCK = + SiS_Pr->SiS_VBVCLKData[idx].CLOCK = SiS_Pr->CP_PrefClock; + SiS_Pr->SiS_VCLKData[idx].SR2B = + SiS_Pr->SiS_VBVCLKData[idx].Part4_A = SiS_Pr->CP_PrefSR2B; + SiS_Pr->SiS_VCLKData[idx].SR2C = + SiS_Pr->SiS_VBVCLKData[idx].Part4_B = SiS_Pr->CP_PrefSR2C; } } break; default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; - SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; + SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; break; } @@ -1887,14 +1903,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, (SiS_Pr->SiS_IF_DEF_DSTN) || (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || - (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { SiS_Pr->PanelHRS = 999; SiS_Pr->PanelHRE = 999; } if( (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || - (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { SiS_Pr->PanelVRS = 999; SiS_Pr->PanelVRE = 999; } @@ -1912,18 +1930,18 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, case Panel_Custom: case Panel_1152x864: case Panel_1280x768: /* TMDS only */ - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; break; case Panel_800x600: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, 0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); break; } case Panel_1024x768: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 0xff @@ -1932,7 +1950,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, break; } case Panel_1280x720: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 0xff @@ -1944,7 +1962,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, break; } case Panel_1280x768_2: { /* LVDS only */ - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,0xff @@ -1952,23 +1970,23 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); switch(resinfo) { case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) { - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - break; + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; } - break; + break; } case Panel_1280x800: { /* SiS TMDS special (Averatec 6200 series) */ - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,SIS_RI_1280x720,SIS_RI_1280x768,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); - break; + break; } case Panel_1280x800_2: { /* SiS LVDS */ - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,0xff @@ -1977,66 +1995,83 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, switch(resinfo) { case SIS_RI_1280x720: case SIS_RI_1280x768: if(SiS_Pr->UsePanelScaler == -1) { - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - break; + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; } - break; + break; + } + case Panel_1280x854: { /* SiS LVDS */ + static const unsigned char nonscalingmodes[] = { + SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, + SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, + SIS_RI_1152x768,0xff + }; + SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); + switch(resinfo) { + case SIS_RI_1280x720: + case SIS_RI_1280x768: + case SIS_RI_1280x800: if(SiS_Pr->UsePanelScaler == -1) { + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; + } + break; } case Panel_1280x960: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, - 0xff + SIS_RI_1280x854,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); - break; + break; } case Panel_1280x1024: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, - SIS_RI_1280x960,0xff + SIS_RI_1280x854,SIS_RI_1280x960,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); break; } case Panel_1400x1050: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, - SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x768,SIS_RI_1280x800,SIS_RI_1280x960, - 0xff + SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x768,SIS_RI_1280x800,SIS_RI_1280x854, + SIS_RI_1280x960,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); - switch(resinfo) { + switch(resinfo) { case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) { - SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - } - break; + SiS_Pr->SiS_LCDInfo |= DontExpandLCD; + } + break; case SIS_RI_1280x1024: SiS_Pr->SiS_LCDInfo |= DontExpandLCD; - break; + break; } break; } case Panel_1600x1200: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, - SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,0xff + SIS_RI_1280x854,SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); - break; + break; } case Panel_1680x1050: { - static const UCHAR nonscalingmodes[] = { + static const unsigned char nonscalingmodes[] = { SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, - SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024, - 0xff + SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x854,SIS_RI_1280x960,SIS_RI_1360x768, + SIS_RI_1360x1024,0xff }; SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); break; @@ -2044,25 +2079,25 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } } +#ifdef SIS300 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { - SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */ + if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { + SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */ } } -#ifdef SIS300 - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(SiS_Pr->SiS_UseROM) { + if(SiS_Pr->SiS_UseROM) { if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - if(!(ROMAddr[0x235] & 0x02)) { - SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); - } + if(!(ROMAddr[0x235] & 0x02)) { + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + } } - } - } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + } + } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { - SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); + SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); } } } @@ -2080,7 +2115,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, switch(SiS_Pr->SiS_LCDResInfo) { case Panel_640x480: - SiS_Pr->SiS_LCDInfo |= LCDPass11; + SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); break; case Panel_1280x800: /* Don't pass 1:1 by default (TMDS special) */ @@ -2097,7 +2132,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, break; } - if(SiS_Pr->UseCustomMode) { + if((SiS_Pr->UseCustomMode) || (SiS_Pr->SiS_CustomT == CUT_UNKNOWNLCD)) { SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); } @@ -2107,19 +2142,19 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } /* LVDS DDA */ - if(!((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { + if(!((SiS_Pr->ChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) { if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { if(ModeNo == 0x12) { if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } } else if(ModeNo > 0x13) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) { - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { - SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { + SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } } } @@ -2128,18 +2163,18 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } if(modeflag & HalfDCLK) { - if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) { + if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) { SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } else if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) { SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; } else if(ModeNo > 0x13) { - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) { - if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; - } + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) { + if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; + } } } @@ -2148,21 +2183,21 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* VESA timing */ if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { - SiS_Pr->SiS_SetFlag |= LCDVESATiming; + SiS_Pr->SiS_SetFlag |= LCDVESATiming; } } else { SiS_Pr->SiS_SetFlag |= LCDVESATiming; } -#ifdef LINUX_KERNEL -#ifdef TWDEBUG +#ifdef SIS_LINUX_KERNEL +#if 0 printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n", SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo); #endif #endif -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 xf86DrvMsgVerb(0, X_PROBED, 4, - "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n", + "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n", SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag); #endif } @@ -2171,45 +2206,46 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* GET VCLK */ /*********************************************/ -USHORT -SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +unsigned short +SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT CRT2Index,VCLKIndex=0,VCLKIndexGEN=0; - USHORT modeflag,resinfo,tempbx; - const UCHAR *CHTVVCLKPtr = NULL; + unsigned short CRT2Index, VCLKIndex = 0, VCLKIndexGEN = 0, VCLKIndexGENCRT = 0; + unsigned short modeflag, resinfo, tempbx; + const unsigned char *CHTVVCLKPtr = NULL; if(ModeNo <= 0x13) { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; VCLKIndexGEN = (SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)) >> 2) & 0x03; + VCLKIndexGENCRT = VCLKIndexGEN; } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; VCLKIndexGEN = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; - if(HwInfo->jChipType < SIS_315H) VCLKIndexGEN &= 0x3f; + VCLKIndexGENCRT = SiS_GetRefCRTVCLK(SiS_Pr, RefreshRateTableIndex, + (SiS_Pr->SiS_SetFlag & ProgrammingCRT2) ? SiS_Pr->SiS_UseWideCRT2 : SiS_Pr->SiS_UseWide); } if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */ if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - CRT2Index >>= 6; - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ + CRT2Index >>= 6; + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { VCLKIndex = SiS_Pr->PanelVCLKIdx300; if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { - VCLKIndex = VCLKIndexGEN; + VCLKIndex = VCLKIndexGEN; } } else { VCLKIndex = SiS_Pr->PanelVCLKIdx315; if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { switch(resinfo) { - /* Only those whose IndexGEN doesn't match VBVCLK array */ - case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; break; + /* Correct those whose IndexGEN doesn't match VBVCLK array */ case SIS_RI_720x480: VCLKIndex = VCLK_720x480; break; case SIS_RI_720x576: VCLKIndex = VCLK_720x576; break; case SIS_RI_768x576: VCLKIndex = VCLK_768x576; break; @@ -2218,18 +2254,19 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, case SIS_RI_800x480: VCLKIndex = VCLK_800x480; break; case SIS_RI_1024x576: VCLKIndex = VCLK_1024x576; break; case SIS_RI_1152x864: VCLKIndex = VCLK_1152x864; break; + case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; break; case SIS_RI_1360x768: VCLKIndex = VCLK_1360x768; break; default: VCLKIndex = VCLKIndexGEN; } if(ModeNo <= 0x13) { - if(HwInfo->jChipType <= SIS_315PRO) { + if(SiS_Pr->ChipType <= SIS_315PRO) { if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42; - } else { + } else { if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00; } } - if(HwInfo->jChipType <= SIS_315PRO) { + if(SiS_Pr->ChipType <= SIS_315PRO) { if(VCLKIndex == 0) VCLKIndex = 0x41; if(VCLKIndex == 1) VCLKIndex = 0x43; if(VCLKIndex == 4) VCLKIndex = 0x44; @@ -2237,49 +2274,46 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } } - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; - else VCLKIndex = HiTVVCLK; - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - if(modeflag & Charx8Dot) VCLKIndex = HiTVSimuVCLK; - else VCLKIndex = HiTVTextVCLK; - } - } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK; - else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2; - else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; - else VCLKIndex = TVVCLK; - - if(HwInfo->jChipType < SIS_315H) VCLKIndex += TVCLKBASE_300; - else VCLKIndex += TVCLKBASE_315; - - } else { /* VGA2 */ - - VCLKIndex = VCLKIndexGEN; - if(HwInfo->jChipType < SIS_315H) { - if(ModeNo > 0x13) { - if( (HwInfo->jChipType == SIS_630) && - (HwInfo->jChipRevision >= 0x30)) { + if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; + else VCLKIndex = HiTVVCLK; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) VCLKIndex = HiTVSimuVCLK; + } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2; + else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; + else VCLKIndex = TVVCLK; + + if(SiS_Pr->ChipType < SIS_315H) VCLKIndex += TVCLKBASE_300; + else VCLKIndex += TVCLKBASE_315; + + } else { /* VGA2 */ + + VCLKIndex = VCLKIndexGENCRT; + if(SiS_Pr->ChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (SiS_Pr->ChipType == SIS_630) && + (SiS_Pr->ChipRevision >= 0x30)) { if(VCLKIndex == 0x14) VCLKIndex = 0x34; } /* Better VGA2 clock for 1280x1024@75 */ if(VCLKIndex == 0x17) VCLKIndex = 0x45; } - } - } + } + } } else { /* If not programming CRT2 */ - VCLKIndex = VCLKIndexGEN; - if(HwInfo->jChipType < SIS_315H) { - if(ModeNo > 0x13) { - if( (HwInfo->jChipType != SIS_630) && - (HwInfo->jChipType != SIS_300) ) { + VCLKIndex = VCLKIndexGENCRT; + if(SiS_Pr->ChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (SiS_Pr->ChipType != SIS_630) && + (SiS_Pr->ChipType != SIS_300) ) { if(VCLKIndex == 0x1b) VCLKIndex = 0x48; } } - } + } } } else { /* LVDS */ @@ -2288,12 +2322,12 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { - if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { + if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { VCLKIndex &= 0x1f; - tempbx = 0; + tempbx = 0; if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { + if(SiS_Pr->SiS_TVMode & TVSetPAL) { tempbx += 2; if(SiS_Pr->SiS_ModeType > ModeVGA) { if(SiS_Pr->SiS_CHSOverScan) tempbx = 8; @@ -2306,66 +2340,68 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; } } - switch(tempbx) { - case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; - case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; - case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; - case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; + switch(tempbx) { + case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; + case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; + case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; + case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break; - case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; - case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; - case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; + case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; + case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; + case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break; default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; - } - VCLKIndex = CHTVVCLKPtr[VCLKIndex]; + } + VCLKIndex = CHTVVCLKPtr[VCLKIndex]; - } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { VCLKIndex = SiS_Pr->PanelVCLKIdx300; } else { VCLKIndex = SiS_Pr->PanelVCLKIdx315; } +#ifdef SIS300 /* Special Timing: Barco iQ Pro R series */ if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44; - /* Special Timing: 848x480 parallel lvds */ - if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { - if(HwInfo->jChipType < SIS_315H) { + /* Special Timing: 848x480 and 856x480 parallel lvds panels */ + if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { + if(SiS_Pr->ChipType < SIS_315H) { VCLKIndex = VCLK34_300; - /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ + /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ } else { VCLKIndex = VCLK34_315; /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ } } +#endif - } else { + } else { - VCLKIndex = VCLKIndexGEN; - if(HwInfo->jChipType < SIS_315H) { - if(ModeNo > 0x13) { - if( (HwInfo->jChipType == SIS_630) && - (HwInfo->jChipRevision >= 0x30) ) { + VCLKIndex = VCLKIndexGENCRT; + if(SiS_Pr->ChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (SiS_Pr->ChipType == SIS_630) && + (SiS_Pr->ChipRevision >= 0x30) ) { if(VCLKIndex == 0x14) VCLKIndex = 0x2e; - } - } + } + } } - } + } } else { /* if not programming CRT2 */ - VCLKIndex = VCLKIndexGEN; - if(HwInfo->jChipType < SIS_315H) { - if(ModeNo > 0x13) { - if( (HwInfo->jChipType != SIS_630) && - (HwInfo->jChipType != SIS_300) ) { + VCLKIndex = VCLKIndexGENCRT; + if(SiS_Pr->ChipType < SIS_315H) { + if(ModeNo > 0x13) { + if( (SiS_Pr->ChipType != SIS_630) && + (SiS_Pr->ChipType != SIS_300) ) { if(VCLKIndex == 0x1b) VCLKIndex = 0x48; } #if 0 - if(HwInfo->jChipType == SIS_730) { + if(SiS_Pr->ChipType == SIS_730) { if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ } @@ -2377,11 +2413,13 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex); #endif +#endif - return(VCLKIndex); + return VCLKIndex; } /*********************************************/ @@ -2389,26 +2427,19 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT i,j,modeflag; - USHORT tempcl,tempah=0; + unsigned short i, j, modeflag, tempah=0; + short tempcl; #if defined(SIS300) || defined(SIS315H) - USHORT tempbl; + unsigned short tempbl; #endif #ifdef SIS315H - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT tempah2, tempbl2; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short tempah2, tempbl2; #endif - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - } else if(SiS_Pr->UseCustomMode) { - modeflag = SiS_Pr->CModeFlag; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { @@ -2418,18 +2449,18 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } else { for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0); - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0x7F); } tempcl = SiS_Pr->SiS_ModeType; - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* ---- 300 series ---- */ - /* For 301BDH: (with LCD via LVDS) */ - if(SiS_Pr->SiS_VBType & VB_NoLCD) { + /* For 301BDH: (with LCD via LVDS) */ + if(SiS_Pr->SiS_VBType & VB_NoLCD) { tempbl = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32); tempbl &= 0xef; tempbl |= 0x02; @@ -2438,16 +2469,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbl &= 0xfd; } SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,tempbl); - } + } - if(ModeNo > 0x13) { - tempcl -= ModeVGA; - if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ - tempah = ((0x10 >> tempcl) | 0x80); - } - } else tempah = 0x80; + if(ModeNo > 0x13) { + tempcl -= ModeVGA; + if(tempcl >= 0) { + tempah = ((0x10 >> tempcl) | 0x80); + } + } else tempah = 0x80; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; #endif /* SIS300 */ @@ -2455,22 +2486,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #ifdef SIS315H /* ------- 315/330 series ------ */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08); - } - } - - if(ModeNo > 0x13) { - tempcl -= ModeVGA; - if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ - tempah = (0x08 >> tempcl); - if (tempah == 0) tempah = 1; - tempah |= 0x40; - } - } else tempah = 0x40; + if(ModeNo > 0x13) { + tempcl -= ModeVGA; + if(tempcl >= 0) { + tempah = (0x08 >> tempcl); + if (tempah == 0) tempah = 1; + tempah |= 0x40; + } + } else tempah = 0x40; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; #endif /* SIS315H */ @@ -2478,84 +2503,89 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; - if(HwInfo->jChipType < SIS_315H) { - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); + if(SiS_Pr->ChipType < SIS_315H) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); } else { - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); - } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(IS_SIS740) { +#ifdef SIS315H + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(IS_SIS740) { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); } - } + } +#endif } if(SiS_Pr->SiS_VBType & VB_SISVB) { - tempah = 0x01; - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - tempah ^= 0x05; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - tempah ^= 0x01; - } - } + tempah = 0x01; + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + tempah |= 0x02; + } + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + tempah ^= 0x05; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + tempah ^= 0x01; + } + } - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + if(SiS_Pr->ChipType < SIS_315H) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; - tempah = (tempah << 5) & 0xFF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); - tempah = (tempah >> 5) & 0xFF; + tempah = (tempah << 5) & 0xFF; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); + tempah = (tempah >> 5) & 0xFF; - } else { + } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0x08; + else if(!(SiS_IsDualEdge(SiS_Pr))) tempah |= 0x08; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF0,tempah); + tempah &= ~0x08; - } + } - if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { - tempah |= 0x10; - } + if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { + tempah |= 0x10; + } tempah |= 0x80; - if(SiS_Pr->SiS_VBType & VB_SIS301) { + if(SiS_Pr->SiS_VBType & VB_SIS301) { if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah &= ~0x80; - } + } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - tempah |= 0x20; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempah |= 0x20; } - } - } + } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); tempah = 0x80; if(SiS_Pr->SiS_VBType & VB_SIS301) { if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah = 0; } - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempah |= 0x40; + if(SiS_IsDualLink(SiS_Pr)) tempah |= 0x40; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) { - tempah |= 0x40; - } - } + tempah |= 0x40; + } + } - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); } else { /* LVDS */ - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { #ifdef SIS315H /* LVDS can only be slave in 8bpp modes */ @@ -2566,36 +2596,30 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } } - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - tempah |= 0x02; - } + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) tempah |= 0x02; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempah ^= 0x01; - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah ^= 0x01; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - tempah = 1; - } + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 1; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); #endif - } else { + } else { #ifdef SIS300 tempah = 0; if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { - tempah |= 0x02; - } + tempah |= 0x02; + } tempah <<= 5; - if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; + if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); #endif - } + } } @@ -2603,10 +2627,10 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { #ifdef SIS315H - unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); + /* unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); */ /* The following is nearly unpreditable and varies from machine * to machine. Especially the 301DH seems to be a real trouble @@ -2619,25 +2643,28 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* 740 variants match for 30xB, 301B-DH, 30xLV */ - if(!(IS_SIS740)) { - tempah = 0x04; /* For all bridges */ - tempbl = 0xfb; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + if(!(IS_SIS740)) { + tempah = 0x04; /* For all bridges */ + tempbl = 0xfb; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = 0x00; + if(SiS_IsDualEdge(SiS_Pr)) { tempbl = 0xff; } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); } /* The following two are responsible for eventually wrong colors * in TV output. The DH (VB_NoLCD) conditions are unknown; the * b0 was found in some 651 machine (Pim; P4_23=0xe5); the b1 version * in a 650 box (Jake). What is the criteria? + * Addendum: Another combination 651+301B-DH(b1) (Rapo) needs same + * treatment like the 651+301B-DH(b0) case. Seems more to be the + * chipset than the bridge revision. */ - if((IS_SIS740) || (HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { + if((IS_SIS740) || (SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { tempah = 0x30; tempbl = 0xc0; if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || @@ -2649,20 +2676,30 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl); } else if(SiS_Pr->SiS_VBType & VB_SIS301) { /* Fixes "TV-blue-bug" on 315+301 */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */ SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); - } else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */ - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); - } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xB-DH rev b0 (or "DH on 651"?) */ + } else if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */ SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); + } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* For 301B-DH */ + tempah = 0x30; tempah2 = 0xc0; + tempbl = 0xcf; tempbl2 = 0x3f; + if(SiS_Pr->SiS_TVBlue == 0) { + tempah = tempah2 = 0x00; + } else if(SiS_Pr->SiS_TVBlue == -1) { + /* Set on 651/M650, clear on 315/650 */ + if(!(IS_SIS65x)) /* (bridgerev != 0xb0) */ { + tempah = tempah2 = 0x00; + } + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2); } else { - tempah = 0x30; tempah2 = 0xc0; /* For 30xB (and 301BDH rev b1) */ + tempah = 0x30; tempah2 = 0xc0; /* For 30xB, 301C */ tempbl = 0xcf; tempbl2 = 0x3f; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { tempah = tempah2 = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + if(SiS_IsDualEdge(SiS_Pr)) { tempbl = tempbl2 = 0xff; } } @@ -2676,23 +2713,23 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,0x7f,tempah); } else { tempah = 0x00; - tempbl = 0x7f; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempbl = 0xff; - if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) tempah = 0x80; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); + tempbl = 0x7f; + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempbl = 0xff; + if(!(SiS_IsDualEdge(SiS_Pr))) tempah = 0x80; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); } #endif /* SIS315H */ - } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { #ifdef SIS300 - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); - if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || - ((SiS_Pr->SiS_VBType & VB_NoLCD) && + if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || + ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F); } else { @@ -2702,9 +2739,9 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80); - if(SiS_Pr->SiS_VBType & VB_SIS301C) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80); + if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3A,0xC0); } } @@ -2712,16 +2749,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } else { /* LVDS */ #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - tempah = 0x04; + tempah = 0x04; tempbl = 0xfb; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - tempah = 0x00; - if(SiS_IsDualEdge(SiS_Pr, HwInfo)) tempbl = 0xff; - } + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + tempah = 0x00; + if(SiS_IsDualEdge(SiS_Pr)) tempbl = 0xff; + } SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { @@ -2730,7 +2767,7 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); - } else if(HwInfo->jChipType == SIS_550) { + } else if(SiS_Pr->ChipType == SIS_550) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); @@ -2748,212 +2785,120 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* GET RESOLUTION DATA */ /*********************************************/ -USHORT -SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) +unsigned short +SiS_GetResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - if(ModeNo <= 0x13) return((USHORT)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo); - else return((USHORT)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO); + if(ModeNo <= 0x13) + return ((unsigned short)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo); + else + return ((unsigned short)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO); } static void -SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_GetCRT2ResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT xres,yres,modeflag=0,resindex; + unsigned short xres, yres, modeflag=0, resindex; - if(SiS_Pr->UseCustomMode) { - xres = SiS_Pr->CHDisplay; - if(SiS_Pr->CModeFlag & HalfDCLK) xres *= 2; - SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; - yres = SiS_Pr->CVDisplay; - if(SiS_Pr->CModeFlag & DoubleScanMode) yres *= 2; - SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; - return; - } - - resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); + if(SiS_Pr->UseCustomMode) { + xres = SiS_Pr->CHDisplay; + if(SiS_Pr->CModeFlag & HalfDCLK) xres <<= 1; + SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; + /* DoubleScanMode-check done in CheckCalcCustomMode()! */ + SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = SiS_Pr->CVDisplay; + return; + } - if(ModeNo <= 0x13) { - xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; - } else { - xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; - yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - } + resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex); - if(!SiS_Pr->SiS_IF_DEF_DSTN && !SiS_Pr->SiS_IF_DEF_FSTN) { + if(ModeNo <= 0x13) { + xres = SiS_Pr->SiS_StResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_StResInfo[resindex].VTotal; + } else { + xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal; + yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal; + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + } - if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { - if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) { - if(yres == 350) yres = 400; - } - if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { - if(ModeNo == 0x12) yres = 400; - } - } + if(!SiS_Pr->SiS_IF_DEF_DSTN && !SiS_Pr->SiS_IF_DEF_FSTN) { - if(modeflag & HalfDCLK) xres *= 2; - if(modeflag & DoubleScanMode) yres *= 2; + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { + if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) { + if(yres == 350) yres = 400; + } + if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) { + if(ModeNo == 0x12) yres = 400; + } + } - } + if(modeflag & HalfDCLK) xres <<= 1; + if(modeflag & DoubleScanMode) yres <<= 1; - if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { + } -#if 0 - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCDA | SetCRT2ToLCD | SetCRT2ToHiVision)) { - if(xres == 720) xres = 640; - } -#endif + if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - switch(SiS_Pr->SiS_LCDResInfo) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + switch(SiS_Pr->SiS_LCDResInfo) { case Panel_1024x768: if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - if(yres == 350) yres = 357; - if(yres == 400) yres = 420; - if(yres == 480) yres = 525; - } - } + if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { + if(yres == 350) yres = 357; + if(yres == 400) yres = 420; + if(yres == 480) yres = 525; + } + } break; case Panel_1280x1024: if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { /* BIOS bug - does this regardless of scaling */ - if(yres == 400) yres = 405; + if(yres == 400) yres = 405; + } + if(yres == 350) yres = 360; + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + if(yres == 360) yres = 375; } - if(yres == 350) yres = 360; - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - if(yres == 360) yres = 375; - } break; case Panel_1600x1200: if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if(yres == 1024) yres = 1056; - } + if(yres == 1024) yres = 1056; + } break; - } - } + } + } - } else { + } else { - if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { - if(xres == 720) xres = 640; - } - } else if(xres == 720) xres = 640; + if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { + if(xres == 720) xres = 640; + } + } else if(xres == 720) xres = 640; - if(SiS_Pr->SiS_SetFlag & SetDOSMode) { - yres = 400; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; - } else { - if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; - } - if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) yres = 480; - } + if(SiS_Pr->SiS_SetFlag & SetDOSMode) { + yres = 400; + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; + } else { + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; + } + if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) yres = 480; + } - } - SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; - SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; + } + SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; + SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; } /*********************************************/ /* GET CRT2 TIMING DATA */ /*********************************************/ -static BOOLEAN -SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, USHORT *ResIndex, - USHORT *DisplayType) - { - USHORT modeflag=0; - - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE; - } - } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE; - } else - return FALSE; - - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } - - (*ResIndex) &= 0x3F; - - if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - (*DisplayType) = 18; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - (*DisplayType) += 2; - if(SiS_Pr->SiS_ModeType > ModeVGA) { - if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 99; - } - if(SiS_Pr->SiS_TVMode & TVSetPALM) { - (*DisplayType) = 18; /* PALM uses NTSC data */ - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; - } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { - (*DisplayType) = 20; /* PALN uses PAL data */ - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; - } - } - } else { - switch(SiS_Pr->SiS_LCDResInfo) { - case Panel_640x480: (*DisplayType) = 50; break; - case Panel_640x480_2: (*DisplayType) = 52; break; - case Panel_640x480_3: (*DisplayType) = 54; break; - case Panel_800x600: (*DisplayType) = 0; break; - case Panel_1024x600: (*DisplayType) = 23; break; - case Panel_1024x768: (*DisplayType) = 4; break; - case Panel_1152x768: (*DisplayType) = 27; break; - case Panel_1280x768: (*DisplayType) = 40; break; - case Panel_1280x1024: (*DisplayType) = 8; break; - case Panel_1400x1050: (*DisplayType) = 14; break; - case Panel_1600x1200: (*DisplayType) = 36; break; - default: return FALSE; - } - - if(modeflag & HalfDCLK) (*DisplayType)++; - - switch(SiS_Pr->SiS_LCDResInfo) { - case Panel_640x480: - case Panel_640x480_2: - case Panel_640x480_3: - break; - default: - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2; - } - - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - (*DisplayType) = 12; - if(modeflag & HalfDCLK) (*DisplayType)++; - } - } - -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN) { - if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){ - (*DisplayType) = 22; - } - } -#endif - - return TRUE; -} - static void -SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, - PSIS_HW_INFO HwInfo) +SiS_GetCRT2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex, unsigned short *CRT2Index, + unsigned short *ResIndex) { - USHORT tempbx=0,tempal=0,resinfo=0; + unsigned short tempbx=0, tempal=0, resinfo=0; if(ModeNo <= 0x13) { tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; @@ -2966,18 +2911,20 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ - tempbx = SiS_Pr->SiS_LCDResInfo; + tempbx = SiS_Pr->SiS_LCDResInfo; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 32; + /* patch index */ if(SiS_Pr->SiS_LCDResInfo == Panel_1680x1050) { if (resinfo == SIS_RI_1280x800) tempal = 9; else if(resinfo == SIS_RI_1400x1050) tempal = 11; } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x800) || - (SiS_Pr->SiS_LCDResInfo == Panel_1280x800_2)) { + (SiS_Pr->SiS_LCDResInfo == Panel_1280x800_2) || + (SiS_Pr->SiS_LCDResInfo == Panel_1280x854)) { if (resinfo == SIS_RI_1280x768) tempal = 9; } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { /* Pass 1:1 only (center-screen handled outside) */ /* This is never called for the panel's native resolution */ /* since Pass1:1 will not be set in this case */ @@ -2991,8 +2938,8 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - tempbx = 200; - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; + tempbx = 200; + if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; } } } @@ -3000,23 +2947,23 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, } else { /* TV */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */ - tempbx = 2; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */ + tempbx = 2; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { tempbx = 13; - if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14; - } + if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14; + } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7; - else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6; - else tempbx = 5; - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; - } else { - if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3; - else tempbx = 4; - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; - } + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6; + else tempbx = 5; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; + } else { + if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3; + else tempbx = 4; + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; + } } @@ -3024,26 +2971,34 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(ModeNo > 0x13) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) { - if(tempal == 6) tempal = 7; - if((resinfo == SIS_RI_720x480) || - (resinfo == SIS_RI_720x576) || - (resinfo == SIS_RI_768x576)) { + switch(resinfo) { + case SIS_RI_720x480: tempal = 6; - if(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetPALN)) { - if(resinfo == SIS_RI_720x480) tempal = 9; + if(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetPALN)) tempal = 9; + break; + case SIS_RI_720x576: + case SIS_RI_768x576: + case SIS_RI_1024x576: /* Not in NTSC or YPBPR mode (except 1080i)! */ + tempal = 6; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempal = 8; } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { - if(resinfo == SIS_RI_1024x768) tempal = 8; + break; + case SIS_RI_800x480: + tempal = 4; + break; + case SIS_RI_512x384: + case SIS_RI_1024x768: + tempal = 7; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempal = 8; } - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { - if((resinfo == SIS_RI_720x576) || - (resinfo == SIS_RI_768x576)) { - tempal = 8; - } - if(resinfo == SIS_RI_1280x720) tempal = 9; + break; + case SIS_RI_1280x720: + if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempal = 9; } + break; } } } @@ -3056,65 +3011,60 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, tempbx = 0; if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - tempbx = 10; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - tempbx += 2; + tempbx = 90; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + tempbx = 92; if(SiS_Pr->SiS_ModeType > ModeVGA) { if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; } - if(SiS_Pr->SiS_TVMode & TVSetPALM) { - tempbx = 90; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; - } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { - tempbx = 92; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; - } - } + if(SiS_Pr->SiS_TVMode & TVSetPALM) tempbx = 94; + else if(SiS_Pr->SiS_TVMode & TVSetPALN) tempbx = 96; + } + if(tempbx != 99) { + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++; + } } else { - switch(SiS_Pr->SiS_LCDResInfo) { - case Panel_640x480: tempbx = 6; break; - case Panel_640x480_2: - case Panel_640x480_3: tempbx = 30; break; - case Panel_800x600: tempbx = 0; break; - case Panel_1024x600: tempbx = 15; break; - case Panel_1024x768: tempbx = 2; break; - case Panel_1152x768: tempbx = 17; break; - case Panel_1280x768: tempbx = 18; break; - case Panel_1280x1024: tempbx = 4; break; - case Panel_1400x1050: tempbx = 8; break; - case Panel_1600x1200: tempbx = 21; break; + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_640x480: tempbx = 12; break; + case Panel_320x240_1: tempbx = 10; break; + case Panel_320x240_2: + case Panel_320x240_3: tempbx = 14; break; + case Panel_800x600: tempbx = 16; break; + case Panel_1024x600: tempbx = 18; break; + case Panel_1152x768: + case Panel_1024x768: tempbx = 20; break; + case Panel_1280x768: tempbx = 22; break; + case Panel_1280x1024: tempbx = 24; break; + case Panel_1400x1050: tempbx = 26; break; + case Panel_1600x1200: tempbx = 28; break; +#ifdef SIS300 case Panel_Barco1366: tempbx = 80; break; +#endif } switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_320x240_1: + case Panel_320x240_2: + case Panel_320x240_3: case Panel_640x480: - case Panel_640x480_2: - case Panel_640x480_3: break; default: if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } - if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 7; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 30; +#ifdef SIS300 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { tempbx = 82; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; - } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { + } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { tempbx = 84; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; } - - if((SiS_Pr->SiS_CustomT != CUT_BARCO1366) && - (SiS_Pr->SiS_CustomT != CUT_PANEL848)) { - if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && - (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { - tempal = 0; - } - } +#endif } @@ -3124,12 +3074,11 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, } static void -SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) +SiS_GetRAMDAC2DATA(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT tempax=0,tempbx=0; - USHORT temp1=0,modeflag=0,tempcx=0; - USHORT index; + unsigned short tempax=0, tempbx=0, index, dotclock; + unsigned short temp1=0, modeflag=0, tempcx=0; SiS_Pr->SiS_RVBHCMAX = 1; SiS_Pr->SiS_RVBHCFACT = 1; @@ -3143,10 +3092,12 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6]; temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7]; + dotclock = (modeflag & Charx8Dot) ? 8 : 9; + } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + index = SiS_GetRefCRT1CRTC(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWideCRT2); tempax = SiS_Pr->SiS_CRT1Table[index].CR[0]; tempax |= (SiS_Pr->SiS_CRT1Table[index].CR[14] << 8); @@ -3158,22 +3109,16 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, tempbx |= tempcx; temp1 = SiS_Pr->SiS_CRT1Table[index].CR[7]; + dotclock = 8; + } if(temp1 & 0x01) tempbx |= 0x0100; if(temp1 & 0x20) tempbx |= 0x0200; tempax += 5; - - /* Charx8Dot is no more used (and assumed), so we set it */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - modeflag |= Charx8Dot; - } - - if(modeflag & Charx8Dot) tempax *= 8; - else tempax *= 9; - - if(modeflag & HalfDCLK) tempax <<= 1; + tempax *= dotclock; + if(modeflag & HalfDCLK) tempax <<= 1; tempbx++; @@ -3182,13 +3127,56 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, } static void -SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_CalcPanelLinkTiming(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex) +{ + unsigned short ResIndex; + + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + if(SiS_Pr->UseCustomMode) { + ResIndex = SiS_Pr->CHTotal; + if(SiS_Pr->CModeFlag & HalfDCLK) ResIndex <<= 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = ResIndex; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + } else { + if(ModeNo < 0x13) { + ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS; + } + if(ResIndex == 0x09) { + if(SiS_Pr->Alternate1600x1200) ResIndex = 0x20; /* 1600x1200 LCDA */ + else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) ResIndex = 0x21; /* 1600x1200 LVDS */ + } + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT; + SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT; + SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT; + } + } else { + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + } + } else { + /* This handles custom modes and custom panels */ + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; + SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE); + SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE); + } +} + +static void +SiS_GetCRT2DataLVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT CRT2Index, ResIndex; - const SiS_LVDSDataStruct *LVDSData = NULL; + unsigned short CRT2Index, ResIndex, backup; + const struct SiS_LVDSData *LVDSData = NULL; - SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex); if(SiS_Pr->SiS_VBType & VB_SISVB) { SiS_Pr->SiS_RVBHCMAX = 1; @@ -3199,133 +3187,94 @@ SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, SiS_Pr->SiS_RY2COE = 0; SiS_Pr->SiS_RY3COE = 0; SiS_Pr->SiS_RY4COE = 0; + SiS_Pr->SiS_RVBHRS2 = 0; } if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { #ifdef SIS315H - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - if(SiS_Pr->UseCustomMode) { - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; - } else { - if(ModeNo < 0x13) { - ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS; - } - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT; - SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT; - SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT; - } - } else { - SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT; - } - } else { - /* This handles custom modes and custom panels */ - SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; - SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; - SiS_Pr->SiS_HT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VT = SiS_Pr->PanelVT; - SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE); - SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE); - } - - SiS_CalcLCDACRT1Timing(SiS_Pr,ModeNo,ModeIdIndex); - + SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex); #endif } else { /* 301BDH needs LVDS Data */ + backup = SiS_Pr->SiS_IF_DEF_LVDS; if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { SiS_Pr->SiS_IF_DEF_LVDS = 1; } SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, - &CRT2Index, &ResIndex, HwInfo); + &CRT2Index, &ResIndex); - /* 301BDH needs LVDS Data */ - if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - SiS_Pr->SiS_IF_DEF_LVDS = 0; - } + SiS_Pr->SiS_IF_DEF_LVDS = backup; - switch (CRT2Index) { - case 0: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; - case 1: LVDSData = SiS_Pr->SiS_LVDS800x600Data_2; break; - case 2: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; - case 3: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break; - case 4: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_1; break; - case 5: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_2; break; - case 6: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break; - case 7: LVDSData = SiS_Pr->SiS_LVDSXXXxXXXData_1; break; - case 8: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_1; break; - case 9: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_2; break; - case 10: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break; - case 11: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break; - case 12: LVDSData = SiS_Pr->SiS_CHTVUPALData; break; - case 13: LVDSData = SiS_Pr->SiS_CHTVOPALData; break; - case 14: LVDSData = SiS_Pr->SiS_LVDS320x480Data_1; break; - case 15: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break; - case 16: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_2; break; - case 17: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_1; break; - case 18: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_2; break; - case 19: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_1; break; - case 20: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_2; break; - case 21: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_1; break; - case 22: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_2; break; - case 30: LVDSData = SiS_Pr->SiS_LVDS640x480Data_2; break; + switch(CRT2Index) { + case 10: LVDSData = SiS_Pr->SiS_LVDS320x240Data_1; break; + case 14: LVDSData = SiS_Pr->SiS_LVDS320x240Data_2; break; + case 12: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break; + case 16: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; + case 18: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break; + case 20: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; +#ifdef SIS300 case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break; case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break; case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break; - case 83: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_2; break; case 84: LVDSData = SiS_Pr->SiS_LVDS848x480Data_1; break; case 85: LVDSData = SiS_Pr->SiS_LVDS848x480Data_2; break; - case 90: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break; - case 91: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break; - case 92: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break; - case 93: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break; - case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; /* Super Overscan */ - default: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; +#endif + case 90: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break; + case 91: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break; + case 92: LVDSData = SiS_Pr->SiS_CHTVUPALData; break; + case 93: LVDSData = SiS_Pr->SiS_CHTVOPALData; break; + case 94: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break; + case 95: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break; + case 96: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break; + case 97: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break; + case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; } - SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT; - SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT; - SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; - SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; - - if(!(SiS_Pr->SiS_VBType & VB_SISVB)) { - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { - if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) { - SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; - SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; - if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { - if(ResIndex < 0x08) { - SiS_Pr->SiS_HDE = 1280; - SiS_Pr->SiS_VDE = 1024; - } - } - } + if(LVDSData) { + SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT; + SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT; + SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; + SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; + } else { + SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + + if( (!(SiS_Pr->SiS_VBType & VB_SISVB)) && + (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && + (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) ) { + if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || + (SiS_Pr->SiS_SetFlag & SetDOSMode) ) { + SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; + SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; +#ifdef SIS300 + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + if(ResIndex < 0x08) { + SiS_Pr->SiS_HDE = 1280; + SiS_Pr->SiS_VDE = 1024; + } + } +#endif } } } } static void -SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, - PSIS_HW_INFO HwInfo) -{ - UCHAR *ROMAddr = NULL; - USHORT tempax,tempbx,modeflag,romptr=0; - USHORT resinfo,CRT2Index,ResIndex; - const SiS_LCDDataStruct *LCDPtr = NULL; - const SiS_TVDataStruct *TVPtr = NULL; +SiS_GetCRT2Data301(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned char *ROMAddr = NULL; + unsigned short tempax, tempbx, modeflag, romptr=0; + unsigned short resinfo, CRT2Index, ResIndex; + const struct SiS_LCDData *LCDPtr = NULL; + const struct SiS_TVData *TVPtr = NULL; #ifdef SIS315H - SHORT resinfo661; + short resinfo661; #endif if(ModeNo <= 0x13) { @@ -3340,67 +3289,69 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, #ifdef SIS315H resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661; if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && - (SiS_Pr->SiS_SetFlag & LCDVESATiming) && - (resinfo661 >= 0) && + (SiS_Pr->SiS_SetFlag & LCDVESATiming) && + (resinfo661 >= 0) && (SiS_Pr->SiS_NeedRomModeData) ) { - if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { + if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) { if((romptr = (SISGETROMW(21)))) { - romptr += (resinfo661 * 10); - ROMAddr = HwInfo->pjVirtualRomBase; + romptr += (resinfo661 * 10); + ROMAddr = SiS_Pr->VirtualRomBase; } } } #endif } - + SiS_Pr->SiS_NewFlickerMode = 0; SiS_Pr->SiS_RVBHRS = 50; SiS_Pr->SiS_RY1COE = 0; SiS_Pr->SiS_RY2COE = 0; SiS_Pr->SiS_RY3COE = 0; SiS_Pr->SiS_RY4COE = 0; + SiS_Pr->SiS_RVBHRS2 = 0; - SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex,HwInfo); + SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex); - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { if(SiS_Pr->UseCustomMode) { - SiS_Pr->SiS_RVBHCMAX = 1; - SiS_Pr->SiS_RVBHCFACT = 1; - SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal; - SiS_Pr->SiS_HT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VT = SiS_Pr->CVTotal; + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; - SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; + SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; + + tempax = SiS_Pr->CHTotal; + if(modeflag & HalfDCLK) tempax <<= 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; } else { - SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwInfo); + &CRT2Index,&ResIndex); switch(CRT2Index) { - case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; - case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; - case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; - case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break; - case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break; - case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break; - case 8: TVPtr = SiS_Pr->SiS_StPALData; break; - case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; - case 10: TVPtr = SiS_Pr->SiS_St525iData; break; - case 11: TVPtr = SiS_Pr->SiS_St525pData; break; - case 12: TVPtr = SiS_Pr->SiS_St750pData; break; - case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break; - case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break; - default: TVPtr = SiS_Pr->SiS_StPALData; break; + case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; + case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; + case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; + case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break; + case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break; + case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break; + case 8: TVPtr = SiS_Pr->SiS_StPALData; break; + case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; + case 10: TVPtr = SiS_Pr->SiS_St525iData; break; + case 11: TVPtr = SiS_Pr->SiS_St525pData; break; + case 12: TVPtr = SiS_Pr->SiS_St750pData; break; + case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break; + case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break; + default: TVPtr = SiS_Pr->SiS_StPALData; break; } SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX; @@ -3409,73 +3360,77 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, SiS_Pr->SiS_VGAVT = (TVPtr+ResIndex)->VGAVT; SiS_Pr->SiS_HDE = (TVPtr+ResIndex)->TVHDE; SiS_Pr->SiS_VDE = (TVPtr+ResIndex)->TVVDE; - SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS; - SiS_Pr->SiS_NewFlickerMode = (TVPtr+ResIndex)->FlickerMode; + SiS_Pr->SiS_RVBHRS2 = (TVPtr+ResIndex)->RVBHRS2 & 0x0fff; if(modeflag & HalfDCLK) { - SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; + SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; + if(SiS_Pr->SiS_RVBHRS2) { + SiS_Pr->SiS_RVBHRS2 = ((SiS_Pr->SiS_RVBHRS2 + 3) >> 1) - 3; + tempax = ((TVPtr+ResIndex)->RVBHRS2 >> 12) & 0x07; + if((TVPtr+ResIndex)->RVBHRS2 & 0x8000) SiS_Pr->SiS_RVBHRS2 -= tempax; + else SiS_Pr->SiS_RVBHRS2 += tempax; + } + } else { + SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS; } + SiS_Pr->SiS_NewFlickerMode = ((TVPtr+ResIndex)->FlickerMode) << 7; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if((resinfo == SIS_RI_1024x768) || - (resinfo == SIS_RI_1280x1024) || - (resinfo == SIS_RI_1280x720)) { + if((resinfo == SIS_RI_960x600) || + (resinfo == SIS_RI_1024x768) || + (resinfo == SIS_RI_1280x1024) || + (resinfo == SIS_RI_1280x720)) { SiS_Pr->SiS_NewFlickerMode = 0x40; } - if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; + if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; - SiS_Pr->SiS_HT = ExtHiTVHT; - SiS_Pr->SiS_VT = ExtHiTVVT; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - SiS_Pr->SiS_HT = StHiTVHT; - SiS_Pr->SiS_VT = StHiTVVT; -#if 0 - if(!(modeflag & Charx8Dot)) { - SiS_Pr->SiS_HT = StHiTextTVHT; - SiS_Pr->SiS_VT = StHiTextTVVT; - } -#endif - } - } + SiS_Pr->SiS_HT = ExtHiTVHT; + SiS_Pr->SiS_VT = ExtHiTVVT; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { + SiS_Pr->SiS_HT = StHiTVHT; + SiS_Pr->SiS_VT = StHiTVVT; + } + } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { - SiS_Pr->SiS_HT = 1650; - SiS_Pr->SiS_VT = 750; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { + SiS_Pr->SiS_HT = 1650; + SiS_Pr->SiS_VT = 750; } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { SiS_Pr->SiS_HT = NTSCHT; + if(SiS_Pr->SiS_TVMode & TVSet525p1024) SiS_Pr->SiS_HT = NTSC2HT; SiS_Pr->SiS_VT = NTSCVT; - } else { - SiS_Pr->SiS_HT = NTSCHT; + } else { + SiS_Pr->SiS_HT = NTSCHT; if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; - SiS_Pr->SiS_VT = NTSCVT; - } + SiS_Pr->SiS_VT = NTSCVT; + } } else { - SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE; - SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE; - SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE; - SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE; + SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE; + SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE; + SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE; + SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE; - if(modeflag & HalfDCLK) { - SiS_Pr->SiS_RY1COE = 0x00; - SiS_Pr->SiS_RY2COE = 0xf4; - SiS_Pr->SiS_RY3COE = 0x10; - SiS_Pr->SiS_RY4COE = 0x38; - } + if(modeflag & HalfDCLK) { + SiS_Pr->SiS_RY1COE = 0x00; + SiS_Pr->SiS_RY2COE = 0xf4; + SiS_Pr->SiS_RY3COE = 0x10; + SiS_Pr->SiS_RY4COE = 0x38; + } - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { - SiS_Pr->SiS_HT = NTSCHT; + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { + SiS_Pr->SiS_HT = NTSCHT; if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; - SiS_Pr->SiS_VT = NTSCVT; - } else { - SiS_Pr->SiS_HT = PALHT; - SiS_Pr->SiS_VT = PALVT; - } + SiS_Pr->SiS_VT = NTSCVT; + } else { + SiS_Pr->SiS_HT = PALHT; + SiS_Pr->SiS_VT = PALVT; + } } @@ -3486,42 +3441,53 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(SiS_Pr->UseCustomMode) { - SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal; - SiS_Pr->SiS_HT = SiS_Pr->CHTotal; - SiS_Pr->SiS_VT = SiS_Pr->CVTotal; SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; - SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; + SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; + + tempax = SiS_Pr->CHTotal; + if(modeflag & HalfDCLK) tempax <<= 1; + SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax; + SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal; } else { - BOOLEAN gotit = FALSE; + BOOLEAN gotit = FALSE; - if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { + if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { - SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; - SiS_Pr->SiS_HT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; + SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VT = SiS_Pr->PanelVT; gotit = TRUE; } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) { #ifdef SIS315H SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr]; - SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1]; - SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8); - SiS_Pr->SiS_VGAVT = ROMAddr[romptr+4] | ((ROMAddr[romptr+3] & 0xf0) << 4); - SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8); - SiS_Pr->SiS_VT = ROMAddr[romptr+7] | ((ROMAddr[romptr+6] & 0xf0) << 4); + SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1]; + SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8); + SiS_Pr->SiS_VGAVT = (ROMAddr[romptr+4] << 4) | ((ROMAddr[romptr+3] & 0xf0) >> 4); + SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8); + SiS_Pr->SiS_VT = (ROMAddr[romptr+7] << 4) | ((ROMAddr[romptr+6] & 0xf0) >> 4); + SiS_Pr->SiS_RVBHRS2 = ROMAddr[romptr+8] | ((ROMAddr[romptr+9] & 0x0f) << 8); + if((SiS_Pr->SiS_RVBHRS2) && (modeflag & HalfDCLK)) { + SiS_Pr->SiS_RVBHRS2 = ((SiS_Pr->SiS_RVBHRS2 + 3) >> 1) - 3; + tempax = (ROMAddr[romptr+9] >> 4) & 0x07; + if(ROMAddr[romptr+9] & 0x80) SiS_Pr->SiS_RVBHRS2 -= tempax; + else SiS_Pr->SiS_RVBHRS2 += tempax; + } if(SiS_Pr->SiS_VGAHT) gotit = TRUE; else { SiS_Pr->SiS_LCDInfo |= DontExpandLCD; SiS_Pr->SiS_LCDInfo &= ~LCDPass11; + SiS_Pr->SiS_RVBHCMAX = 1; + SiS_Pr->SiS_RVBHCFACT = 1; SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; - SiS_Pr->SiS_HT = SiS_Pr->PanelHT; - SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; + SiS_Pr->SiS_HT = SiS_Pr->PanelHT; + SiS_Pr->SiS_VT = SiS_Pr->PanelVT; + SiS_Pr->SiS_RVBHRS2 = 0; gotit = TRUE; } #endif @@ -3530,28 +3496,30 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(!gotit) { - SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, - &CRT2Index,&ResIndex,HwInfo); + SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, + &CRT2Index,&ResIndex); - switch(CRT2Index) { + switch(CRT2Index) { case Panel_1024x768 : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; case Panel_1024x768 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break; case Panel_1280x720 : case Panel_1280x720 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x720Data; break; case Panel_1280x768_2 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x768_2Data; break; - case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break; + case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break; case Panel_1280x800 : case Panel_1280x800 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x800Data; break; case Panel_1280x800_2 : case Panel_1280x800_2+ 32: LCDPtr = SiS_Pr->SiS_LCD1280x800_2Data; break; + case Panel_1280x854 : + case Panel_1280x854 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x854Data; break; case Panel_1280x960 : case Panel_1280x960 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break; - case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; - case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; - case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; - case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; - case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; - case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; + case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; + case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; + case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; + case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; + case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; + case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; case Panel_1680x1050 : case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break; case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break; @@ -3559,271 +3527,340 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break; case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; #endif - default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; - } + default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; + } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG - xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); + xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); +#endif #endif - SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; - SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; - SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; - SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; - SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; - SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; + SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; + SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; + SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; + SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; + SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; + SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; } tempax = SiS_Pr->PanelXRes; - tempbx = SiS_Pr->PanelYRes; + tempbx = SiS_Pr->PanelYRes; - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - if(HwInfo->jChipType < SIS_315H) { - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; - } - } else { - if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; - else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; - else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; - else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; - else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; - } - } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x960) { - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; - else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; - } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { - if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; - else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; - else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; - } else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_1024x768: + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + if(SiS_Pr->ChipType < SIS_315H) { + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; + } + } else { + if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; + else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; + else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; + else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; + else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; + } + break; + case Panel_1280x960: + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; + else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; + break; + case Panel_1280x1024: + if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; + else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; + else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; + break; + case Panel_1600x1200: if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; - else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; - } - } + if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; + else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; + } + break; + } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - tempax = SiS_Pr->SiS_VGAHDE; - tempbx = SiS_Pr->SiS_VGAVDE; - } + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + tempax = SiS_Pr->SiS_VGAHDE; + tempbx = SiS_Pr->SiS_VGAVDE; + } - SiS_Pr->SiS_HDE = tempax; - SiS_Pr->SiS_VDE = tempbx; + SiS_Pr->SiS_HDE = tempax; + SiS_Pr->SiS_VDE = tempbx; } } } static void -SiS_GetCRT2Data(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_GetCRT2Data(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - } else { - if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - /* Need LVDS Data for LCD on 301B-DH */ - SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - } else { - SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); - } - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } else { + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + /* Need LVDS Data for LCD on 301B-DH */ + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } else { + SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + } - } else { + } else { - SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); - } + } } /*********************************************/ /* GET LVDS DES (SKEW) DATA */ /*********************************************/ -static void -SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, USHORT *PanelIndex, - USHORT *ResIndex, PSIS_HW_INFO HwInfo) +static const struct SiS_LVDSDes * +SiS_GetLVDSDesPtr(struct SiS_Private *SiS_Pr) { - USHORT modeflag; + const struct SiS_LVDSDes *PanelDesPtr = NULL; - if(ModeNo <= 0x13) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - } else { - modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - } +#ifdef SIS300 + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDTypeInfo == 4) { + if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { + PanelDesPtr = SiS_Pr->SiS_PanelType04_1a; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + PanelDesPtr = SiS_Pr->SiS_PanelType04_2a; + } + } else if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { + PanelDesPtr = SiS_Pr->SiS_PanelType04_1b; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + PanelDesPtr = SiS_Pr->SiS_PanelType04_2b; + } + } + } + } + } +#endif + return PanelDesPtr; +} - (*ResIndex) &= 0x1F; - (*PanelIndex) = 0; +static void +SiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned short modeflag, ResIndex; + const struct SiS_LVDSDes *PanelDesPtr = NULL; - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - (*PanelIndex) = 50; - if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) (*PanelIndex) += 2; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*PanelIndex) += 1; - /* Nothing special needed for SOverscan */ - /* PALM uses NTSC data, PALN uses PAL data */ - } - } + SiS_Pr->SiS_LCDHDES = 0; + SiS_Pr->SiS_LCDVDES = 0; + /* Some special cases */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - *PanelIndex = SiS_Pr->SiS_LCDTypeInfo; - if(HwInfo->jChipType >= SIS_661) { - /* As long as we don's use the BIOS tables, we - * need to convert the TypeInfo as for 315 series - */ - (*PanelIndex) = SiS_Pr->SiS_LCDResInfo - 1; - } - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - (*PanelIndex) += 16; - if(SiS_Pr->SiS_LCDInfo & LCDPass11) { - (*PanelIndex) = 32; - if(modeflag & HalfDCLK) (*PanelIndex)++; + + /* Trumpion */ + if(SiS_Pr->SiS_IF_DEF_TRUMPION) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } } + return; } - } - if(SiS_Pr->SiS_SetFlag & SetDOSMode) { - if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) { - (*ResIndex) = 7; - if(HwInfo->jChipType < SIS_315H) { - if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) (*ResIndex)++; - } + /* 640x480 on LVDS */ + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDResInfo == Panel_640x480 && SiS_Pr->SiS_LCDTypeInfo == 3) { + SiS_Pr->SiS_LCDHDES = 8; + if (SiS_Pr->SiS_VGAVDE >= 480) SiS_Pr->SiS_LCDVDES = 512; + else if(SiS_Pr->SiS_VGAVDE >= 400) SiS_Pr->SiS_LCDVDES = 436; + else if(SiS_Pr->SiS_VGAVDE >= 350) SiS_Pr->SiS_LCDVDES = 440; + return; + } } - } -} - -static void -SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) -{ - USHORT modeflag; - USHORT PanelIndex,ResIndex; - const SiS_LVDSDesStruct *PanelDesPtr = NULL; - SiS_Pr->SiS_LCDHDES = 0; - SiS_Pr->SiS_LCDVDES = 0; + } /* LCD */ if( (SiS_Pr->UseCustomMode) || (SiS_Pr->SiS_LCDResInfo == Panel_Custom) || (SiS_Pr->SiS_CustomT == CUT_PANEL848) || - ((SiS_Pr->SiS_VBType & VB_SISVB) && - (SiS_Pr->SiS_LCDInfo & DontExpandLCD) && - (SiS_Pr->SiS_LCDInfo & LCDPass11)) ) { + (SiS_Pr->SiS_CustomT == CUT_PANEL856) || + (SiS_Pr->SiS_LCDInfo & LCDPass11) ) { return; } - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if(ModeNo <= 0x13) ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + + if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { #ifdef SIS315H if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { - /* non-pass 1:1 only, see above */ - if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { - SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); + /* non-pass 1:1 only, see above */ + if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); } if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) { SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2); } } if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { - switch(SiS_Pr->SiS_CustomT) { - case CUT_UNIWILL1024: - case CUT_UNIWILL10242: - case CUT_CLEVO1400: + switch(SiS_Pr->SiS_CustomT) { + case CUT_UNIWILL1024: + case CUT_UNIWILL10242: + case CUT_CLEVO1400: if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; } break; } - if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_1280x1024: if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) { SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; } + break; + case Panel_1280x800: /* Verified for Averatec 6240 */ + case Panel_1280x800_2: /* Verified for Asus A4L */ + case Panel_1280x854: /* Not verified yet FIXME */ + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + break; } } #endif } else { - SiS_GetLVDSDesPtr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, - &PanelIndex, &ResIndex, HwInfo); - - switch(PanelIndex) { - case 0: PanelDesPtr = SiS_Pr->SiS_PanelType00_1; break; /* --- */ - case 1: PanelDesPtr = SiS_Pr->SiS_PanelType01_1; break; - case 2: PanelDesPtr = SiS_Pr->SiS_PanelType02_1; break; - case 3: PanelDesPtr = SiS_Pr->SiS_PanelType03_1; break; - case 4: PanelDesPtr = SiS_Pr->SiS_PanelType04_1; break; - case 5: PanelDesPtr = SiS_Pr->SiS_PanelType05_1; break; - case 6: PanelDesPtr = SiS_Pr->SiS_PanelType06_1; break; - case 7: PanelDesPtr = SiS_Pr->SiS_PanelType07_1; break; - case 8: PanelDesPtr = SiS_Pr->SiS_PanelType08_1; break; - case 9: PanelDesPtr = SiS_Pr->SiS_PanelType09_1; break; - case 10: PanelDesPtr = SiS_Pr->SiS_PanelType0a_1; break; - case 11: PanelDesPtr = SiS_Pr->SiS_PanelType0b_1; break; - case 12: PanelDesPtr = SiS_Pr->SiS_PanelType0c_1; break; - case 13: PanelDesPtr = SiS_Pr->SiS_PanelType0d_1; break; - case 14: PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; break; - case 15: PanelDesPtr = SiS_Pr->SiS_PanelType0f_1; break; - case 16: PanelDesPtr = SiS_Pr->SiS_PanelType00_2; break; /* --- */ - case 17: PanelDesPtr = SiS_Pr->SiS_PanelType01_2; break; - case 18: PanelDesPtr = SiS_Pr->SiS_PanelType02_2; break; - case 19: PanelDesPtr = SiS_Pr->SiS_PanelType03_2; break; - case 20: PanelDesPtr = SiS_Pr->SiS_PanelType04_2; break; - case 21: PanelDesPtr = SiS_Pr->SiS_PanelType05_2; break; - case 22: PanelDesPtr = SiS_Pr->SiS_PanelType06_2; break; - case 23: PanelDesPtr = SiS_Pr->SiS_PanelType07_2; break; - case 24: PanelDesPtr = SiS_Pr->SiS_PanelType08_2; break; - case 25: PanelDesPtr = SiS_Pr->SiS_PanelType09_2; break; - case 26: PanelDesPtr = SiS_Pr->SiS_PanelType0a_2; break; - case 27: PanelDesPtr = SiS_Pr->SiS_PanelType0b_2; break; - case 28: PanelDesPtr = SiS_Pr->SiS_PanelType0c_2; break; - case 29: PanelDesPtr = SiS_Pr->SiS_PanelType0d_2; break; - case 30: PanelDesPtr = SiS_Pr->SiS_PanelType0e_2; break; - case 31: PanelDesPtr = SiS_Pr->SiS_PanelType0f_2; break; - case 32: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_1; break; /* pass 1:1 */ - case 33: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_2; break; - case 50: PanelDesPtr = SiS_Pr->SiS_CHTVUNTSCDesData; break; /* TV */ - case 51: PanelDesPtr = SiS_Pr->SiS_CHTVONTSCDesData; break; - case 52: PanelDesPtr = SiS_Pr->SiS_CHTVUPALDesData; break; - case 53: PanelDesPtr = SiS_Pr->SiS_CHTVOPALDesData; break; - default: return; - } - - SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; - SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; + if((SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + + if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) { + if(ResIndex <= 3) SiS_Pr->SiS_LCDHDES = 256; + } + + } else if((PanelDesPtr = SiS_GetLVDSDesPtr(SiS_Pr))) { + + SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; + SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; + + } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + + if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); + } + if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2); + } else { + if(SiS_Pr->ChipType < SIS_315H) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } else { + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_800x600: + case Panel_1024x768: + case Panel_1280x1024: + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT; + break; + case Panel_1400x1050: + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + break; + } + } + } + + } else { + + if(SiS_Pr->ChipType < SIS_315H) { +#ifdef SIS300 + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_800x600: + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } else { + SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT + 3; + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT; + if(SiS_Pr->SiS_VGAVDE == 400) SiS_Pr->SiS_LCDVDES -= 2; + else SiS_Pr->SiS_LCDVDES -= 4; + } + break; + case Panel_1024x768: + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } else { + SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT - 1; + if(SiS_Pr->SiS_VGAVDE <= 400) SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 8; + if(SiS_Pr->SiS_VGAVDE <= 350) SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 12; + } + break; + case Panel_1024x600: + default: + if( (SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) && + (SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) ) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } else { + SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT - 1; + } + break; + } + + switch(SiS_Pr->SiS_LCDTypeInfo) { + case 1: + SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; + break; + case 3: /* 640x480 only? */ + SiS_Pr->SiS_LCDHDES = 8; + if (SiS_Pr->SiS_VGAVDE >= 480) SiS_Pr->SiS_LCDVDES = 512; + else if(SiS_Pr->SiS_VGAVDE >= 400) SiS_Pr->SiS_LCDVDES = 436; + else if(SiS_Pr->SiS_VGAVDE >= 350) SiS_Pr->SiS_LCDVDES = 440; + break; + } +#endif + } else { +#ifdef SIS315H + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_1024x768: + case Panel_1280x1024: + if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { + SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; + } + break; + case Panel_320x240_1: + case Panel_320x240_2: + case Panel_320x240_3: + SiS_Pr->SiS_LCDVDES = 524; + break; + } +#endif + } + } if((ModeNo <= 0x13) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { - modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 632; - } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { - if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { - if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) { - if(HwInfo->jChipType < SIS_315H) { + } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { + if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { + if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) { + if(SiS_Pr->ChipType < SIS_315H) { if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320; } else { - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480; - if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804; +#ifdef SIS315H + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480; + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804; if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704; - if(!(modeflag & HalfDCLK)) { - SiS_Pr->SiS_LCDHDES = 320; - if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632; + if(!(modeflag & HalfDCLK)) { + SiS_Pr->SiS_LCDHDES = 320; + if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632; if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 542; - } - } - } - } - } + } +#endif + } + } + } + } } } } @@ -3832,54 +3869,90 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, /* DISABLE VIDEO BRIDGE */ /*********************************************/ +#ifdef SIS315H +static int +SiS_HandlePWD(struct SiS_Private *SiS_Pr) +{ + int ret = 0; +#ifdef SET_PWD + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr); + unsigned char drivermode = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40; + unsigned short temp; + + if( (SiS_Pr->SiS_VBType & VB_SISPWD) && + (romptr) && + (SiS_Pr->SiS_PWDOffset) ) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2b,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 0]); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2c,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 1]); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2d,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 2]); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2e,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 3]); + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2f,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 4]); + temp = 0x00; + if((ROMAddr[romptr + 2] & (0x06 << 1)) && !drivermode) { + temp = 0x80; + ret = 1; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x27,0x7f,temp); +#ifdef SIS_XORG_XF86 +#ifdef TWDEBUG + xf86DrvMsg(0, 0, "Setting PWD %x\n", temp); +#endif +#endif + } +#endif + return ret; +} +#endif + /* NEVER use any variables (VBInfo), this will be called * from outside the context of modeswitch! * MUST call getVBType before calling this */ void -SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_DisableBridge(struct SiS_Private *SiS_Pr) { #ifdef SIS315H - USHORT tempah,pushax=0,modenum; + unsigned short tempah, pushax=0, modenum; #endif - USHORT temp=0; + unsigned short temp=0; if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== For 30xB/LV ===== */ + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* ===== For 30xB/C/LV ===== */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); } else { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); } - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + SiS_PanelDelay(SiS_Pr, 3); } if(SiS_Is301B(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); SiS_ShortDelay(SiS_Pr,1); - } + } SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); SiS_DisplayOff(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_UnLockCRT2(SiS_Pr,HwInfo); - if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + SiS_UnLockCRT2(SiS_Pr); + if(!(SiS_Pr->SiS_VBType & VB_SISLVDS)) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); } - if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) ) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + if( (!(SiS_CRT2IsLCD(SiS_Pr))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { + SiS_PanelDelay(SiS_Pr, 2); + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); } else { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); } } @@ -3889,130 +3962,127 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H /* 315 series */ + int didpwd = 0; BOOLEAN custom1 = ((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) ? TRUE : FALSE; modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34) & 0x7f; - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { #ifdef SET_EMI - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISEMI) { if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); } } #endif - if( (modenum <= 0x13) || - (SiS_IsVAMode(SiS_Pr,HwInfo)) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); - if(custom1) SiS_PanelDelay(SiS_Pr, HwInfo, 3); + + didpwd = SiS_HandlePWD(SiS_Pr); + + if( (modenum <= 0x13) || + (SiS_IsVAMode(SiS_Pr)) || + (!(SiS_IsDualEdge(SiS_Pr))) ) { + if(!didpwd) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xfe); + if(custom1) SiS_PanelDelay(SiS_Pr, 3); + } else { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xfc); + } } if(!custom1) { SiS_DDC2Delay(SiS_Pr,0xff00); SiS_DDC2Delay(SiS_Pr,0xe000); - SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); - pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); + SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); + pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); if(IS_SIS740) { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); } - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + SiS_PanelDelay(SiS_Pr, 3); } - } + } - if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { - if(HwInfo->jChipType < SIS_340) { - tempah = 0xef; - if(SiS_IsVAMode(SiS_Pr,HwInfo)) tempah = 0xf7; - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } + if(!(SiS_IsNotM650orLater(SiS_Pr))) { + /* if(SiS_Pr->ChipType < SIS_340) {*/ + tempah = 0xef; + if(SiS_IsVAMode(SiS_Pr)) tempah = 0xf7; + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); + /*}*/ } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,~0x10); } tempah = 0x3f; - if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + if(SiS_IsDualEdge(SiS_Pr)) { tempah = 0x7f; - if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) tempah = 0xbf; + if(!(SiS_IsVAMode(SiS_Pr))) tempah = 0xbf; } SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); - if((SiS_IsVAMode(SiS_Pr,HwInfo)) || - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { + if((SiS_IsVAMode(SiS_Pr)) || + ((SiS_Pr->SiS_VBType & VB_SISLVDS) && (modenum <= 0x13))) { SiS_DisplayOff(SiS_Pr); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_PanelDelay(SiS_Pr, 2); } SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); } - if((!(SiS_IsVAMode(SiS_Pr,HwInfo))) || - ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { + if((!(SiS_IsVAMode(SiS_Pr))) || + ((SiS_Pr->SiS_VBType & VB_SISLVDS) && (modenum <= 0x13))) { - if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { + if(!(SiS_IsDualEdge(SiS_Pr))) { SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); SiS_DisplayOff(SiS_Pr); } SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_PanelDelay(SiS_Pr, 2); } SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); } - if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + if(SiS_IsNotM650orLater(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - - if(!custom1) { - - if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { - if(!(SiS_CRT2IsLCD(SiS_Pr,HwInfo))) { - if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); - } - } - } + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { - SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); + if( (!(SiS_IsVAMode(SiS_Pr))) && + (!(SiS_CRT2IsLCD(SiS_Pr))) && + (!(SiS_IsDualEdge(SiS_Pr))) ) { - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 20); - } - } - - } else { + if(custom1) SiS_PanelDelay(SiS_Pr, 2); + if(!didpwd) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); + } + if(custom1) SiS_PanelDelay(SiS_Pr, 4); + } - if((SiS_IsVAMode(SiS_Pr,HwInfo)) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo)))) { - if((!(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo))) || - (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo)))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); - SiS_PanelDelay(SiS_Pr, HwInfo, 4); + if(!custom1) { + SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + if(SiS_IsVAorLCD(SiS_Pr)) { + SiS_PanelDelayLoop(SiS_Pr, 3, 20); } } - } - } + + } #endif /* SIS315H */ @@ -4020,36 +4090,36 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } else { /* ============ For 301 ================ */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, 3); } #endif } - SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ - SiS_DisplayOff(SiS_Pr); + SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ + SiS_DisplayOff(SiS_Pr); - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); + if(SiS_Pr->ChipType >= SIS_315H) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); } - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ - if(HwInfo->jChipType >= SIS_315H) { - temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); + if(SiS_Pr->ChipType >= SIS_315H) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); } else { #ifdef SIS300 - SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ - if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ + if( (!(SiS_CRT2IsLCD(SiS_Pr))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { + SiS_PanelDelay(SiS_Pr, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); } #endif } @@ -4058,34 +4128,34 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } else { /* ============ For LVDS =============*/ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - SiS_SetCH700x(SiS_Pr,0x090E); + SiS_SetCH700x(SiS_Pr,0x0E,0x09); } - if(HwInfo->jChipType == SIS_730) { + if(SiS_Pr->ChipType == SIS_730) { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { - SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_WaitVBRetrace(SiS_Pr); } - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, 3); } } else { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_WaitVBRetrace(SiS_Pr,HwInfo); + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_WaitVBRetrace(SiS_Pr); if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) { SiS_DisplayOff(SiS_Pr); - } - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); - SiS_PanelDelay(SiS_Pr, HwInfo, 3); - } - } + } + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, 3); + } + } } } @@ -4094,14 +4164,14 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_UnLockCRT2(SiS_Pr); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); - if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || - (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + if( (!(SiS_CRT2IsLCD(SiS_Pr))) || + (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { + SiS_PanelDelay(SiS_Pr, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); } #endif /* SIS300 */ @@ -4110,113 +4180,113 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H /* 315 series */ - if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { - if(HwInfo->jChipType < SIS_340) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18); - } - } + if(!(SiS_IsNotM650orLater(SiS_Pr))) { + /*if(SiS_Pr->ChipType < SIS_340) { */ /* XGI needs this */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18); + /* } */ + } if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x61); if(temp < 1) { - SiS_SetCH701x(SiS_Pr,0xac76); - SiS_SetCH701x(SiS_Pr,0x0066); + SiS_SetCH701x(SiS_Pr,0x76,0xac); + SiS_SetCH701x(SiS_Pr,0x66,0x00); } - if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { - SiS_SetCH701x(SiS_Pr,0x3e49); + if( (!(SiS_IsDualEdge(SiS_Pr))) || + (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) { + SiS_SetCH701x(SiS_Pr,0x49,0x3e); } } - if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (SiS_IsVAMode(SiS_Pr,HwInfo)) ) { + if( (!(SiS_IsDualEdge(SiS_Pr))) || + (SiS_IsVAMode(SiS_Pr)) ) { SiS_Chrontel701xBLOff(SiS_Pr); - SiS_Chrontel701xOff(SiS_Pr,HwInfo); + SiS_Chrontel701xOff(SiS_Pr); } - if(HwInfo->jChipType != SIS_740) { - if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { - SiS_SetCH701x(SiS_Pr,0x0149); - } + if(SiS_Pr->ChipType != SIS_740) { + if( (!(SiS_IsDualEdge(SiS_Pr))) || + (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) { + SiS_SetCH701x(SiS_Pr,0x49,0x01); + } } } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); - SiS_PanelDelay(SiS_Pr, HwInfo, 3); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); + SiS_PanelDelay(SiS_Pr, 3); } if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo))) ) { + (!(SiS_IsDualEdge(SiS_Pr))) || + (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr))) ) { SiS_DisplayOff(SiS_Pr); } if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + (!(SiS_IsDualEdge(SiS_Pr))) || + (!(SiS_IsVAMode(SiS_Pr))) ) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); } - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); } SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + (!(SiS_IsDualEdge(SiS_Pr))) || + (!(SiS_IsVAMode(SiS_Pr))) ) { SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_CRT2IsLCD(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); - if(HwInfo->jChipType == SIS_550) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); + if(SiS_Pr->ChipType == SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); } } } else { - if(HwInfo->jChipType == SIS_740) { - if(SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); + if(SiS_Pr->ChipType == SIS_740) { + if(SiS_IsLCDOrLCDA(SiS_Pr)) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); } - } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { + } else if(SiS_IsVAMode(SiS_Pr)) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); } } if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { + if(SiS_IsDualEdge(SiS_Pr)) { /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */ } else { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); } } - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_UnLockCRT2(SiS_Pr); - if(HwInfo->jChipType == SIS_550) { + if(SiS_Pr->ChipType == SIS_550) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); /* DirectDVD PAL?*/ SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); /* VB clock / 4 ? */ } else if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || - (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || - (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { + (!(SiS_IsDualEdge(SiS_Pr))) || + (!(SiS_IsVAMode(SiS_Pr))) ) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 2); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); } } } @@ -4237,78 +4307,81 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) * from outside the context of a mode switch! * MUST call getVBType before calling this */ -static void -SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +#ifdef SIS_LINUX_KERNEL +static +#endif +void +SiS_EnableBridge(struct SiS_Private *SiS_Pr) { - USHORT temp=0,tempah; + unsigned short temp=0, tempah; #ifdef SIS315H - USHORT temp1,pushax=0; + unsigned short temp1, pushax=0; BOOLEAN delaylong = FALSE; #endif if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ====== For 301B et al ====== */ + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* ====== For 301B et al ====== */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); } - if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_NoLCD)) { - if(!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 0); + if(SiS_Pr->SiS_VBType & (VB_SISLVDS | VB_NoLCD)) { + if(!(SiS_CR36BIOSWord23d(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 0); } } } if((SiS_Pr->SiS_VBType & VB_NoLCD) && - (SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { + (SiS_CRT2IsLCD(SiS_Pr))) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */ - SiS_DisplayOn(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_DisplayOn(SiS_Pr); + SiS_UnLockCRT2(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); if(SiS_BridgeInSlavemode(SiS_Pr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); - } + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); + } if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - } - SiS_WaitVBRetrace(SiS_Pr,HwInfo); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); - } + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 1); + } + SiS_WaitVBRetrace(SiS_Pr); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); + } } } else { temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ - if(SiS_BridgeInSlavemode(SiS_Pr)) { - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; - } - SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + if(SiS_BridgeInSlavemode(SiS_Pr)) { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); SiS_DisplayOn(SiS_Pr); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - } + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 1); + } SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); - } + } } } @@ -4322,31 +4395,32 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H /* 315 series */ #ifdef SET_EMI - UCHAR r30=0, r31=0, r32=0, r33=0, cr36=0; - /* USHORT emidelay=0; */ + unsigned char r30=0, r31=0, r32=0, r33=0, cr36=0; + int didpwd = 0; + /* unsigned short emidelay=0; */ #endif - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef); #ifdef SET_EMI - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISEMI) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); } #endif } - if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { - if(HwInfo->jChipType < SIS_340) { + if(!(SiS_IsNotM650orLater(SiS_Pr))) { + /*if(SiS_Pr->ChipType < SIS_340) { */ tempah = 0x10; - if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { - if(SiS_TVEnabled(SiS_Pr, HwInfo)) tempah = 0x18; - else tempah = 0x08; + if(SiS_LCDAEnabled(SiS_Pr)) { + if(SiS_TVEnabled(SiS_Pr)) tempah = 0x18; + else tempah = 0x08; } SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah); - } + /*}*/ } - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); SiS_DisplayOff(SiS_Pr); @@ -4355,42 +4429,51 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); } - if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { - if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_GenericDelay(SiS_Pr, 0x4500); + didpwd = SiS_HandlePWD(SiS_Pr); + + if(SiS_IsVAorLCD(SiS_Pr)) { + if(!didpwd) { + if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { + SiS_PanelDelayLoop(SiS_Pr, 3, 2); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); + SiS_PanelDelayLoop(SiS_Pr, 3, 2); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_GenericDelay(SiS_Pr, 17664); + } + } + } else { + SiS_PanelDelayLoop(SiS_Pr, 3, 2); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_GenericDelay(SiS_Pr, 17664); } } } if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + SiS_PanelDelayLoop(SiS_Pr, 3, 10); delaylong = TRUE; } } - if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { + if(!(SiS_IsVAMode(SiS_Pr))) { - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; + temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; if(SiS_BridgeInSlavemode(SiS_Pr)) { - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) { - if(!(SiS_LCDAEnabled(SiS_Pr, HwInfo))) temp |= 0x20; + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) { + if(!(SiS_LCDAEnabled(SiS_Pr))) temp |= 0x20; } - } - SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); + } + SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + SiS_PanelDelay(SiS_Pr, 2); } } else { @@ -4402,38 +4485,48 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); + if(SiS_Pr->SiS_VBType & VB_SISPOWER) { + if( (SiS_LCDAEnabled(SiS_Pr)) || + (SiS_CRT2IsLCD(SiS_Pr)) ) { + /* Enable "LVDS PLL power on" (even on 301C) */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x2a,0x7f); + /* Enable "LVDS Driver Power on" (even on 301C) */ + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x7f); + } + } + tempah = 0xc0; - if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { + if(SiS_IsDualEdge(SiS_Pr)) { tempah = 0x80; - if(!(SiS_IsVAMode(SiS_Pr, HwInfo))) tempah = 0x40; + if(!(SiS_IsVAMode(SiS_Pr))) tempah = 0x40; } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { - SiS_PanelDelay(SiS_Pr, HwInfo, 2); + SiS_PanelDelay(SiS_Pr, 2); SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { #ifdef SET_EMI - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); - SiS_GenericDelay(SiS_Pr, 0x500); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); + SiS_GenericDelay(SiS_Pr, 2048); } #endif SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISEMI) { #ifdef SET_EMI cr36 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); if(SiS_Pr->SiS_ROMNew) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo); + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr); if(romptr) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ SiS_Pr->EMI_30 = 0; SiS_Pr->EMI_31 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 0]; SiS_Pr->EMI_32 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 1]; @@ -4511,21 +4604,21 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) if(!SiS_Pr->OverruleEMI) { #ifdef COMPAL_HACK if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) { - if((cr36 & 0x0f) == 0x09) { + if((cr36 & 0x0f) == 0x09) { r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x00; } } #endif #ifdef COMPAQ_HACK if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { - if((cr36 & 0x0f) == 0x03) { + if((cr36 & 0x0f) == 0x03) { r30 = 0x20; r31 = 0x12; r32 = 0xd0; r33 = 0x6b; } } #endif #ifdef ASUS_HACK if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { - if((cr36 & 0x0f) == 0x02) { + if((cr36 & 0x0f) == 0x02) { /* r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 2 */ /* r30 = 0x20; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 3 */ /* r30 = 0x60; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 4 */ @@ -4533,11 +4626,11 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } } #endif - } + } if(!(SiS_Pr->OverruleEMI && (!r30) && (!r31) && (!r32) && (!r33))) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ - SiS_GenericDelay(SiS_Pr, 0x500); + SiS_GenericDelay(SiS_Pr, 2048); } SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,r31); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,r32); @@ -4547,36 +4640,44 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); #ifdef SET_EMI - if( (SiS_LCDAEnabled(SiS_Pr, HwInfo)) || - (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { - if(r30 & 0x40) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5); + if( (SiS_LCDAEnabled(SiS_Pr)) || + (SiS_CRT2IsLCD(SiS_Pr)) ) { + if(r30 & 0x40) { + /*SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x2a,0x80);*/ + SiS_PanelDelayLoop(SiS_Pr, 3, 5); if(delaylong) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5); + SiS_PanelDelayLoop(SiS_Pr, 3, 5); delaylong = FALSE; } - SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_WaitVBRetrace(SiS_Pr); + SiS_WaitVBRetrace(SiS_Pr); if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { - SiS_GenericDelay(SiS_Pr, 0x500); + SiS_GenericDelay(SiS_Pr, 1280); } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); /* Enable */ - } + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); /* Enable */ + /*SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x2a,0x7f);*/ + } } #endif } } - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + if(SiS_IsVAorLCD(SiS_Pr)) { + SiS_PanelDelayLoop(SiS_Pr, 3, 10); if(delaylong) { - SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); + SiS_PanelDelayLoop(SiS_Pr, 3, 10); } - SiS_WaitVBRetrace(SiS_Pr,HwInfo); - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_GenericDelay(SiS_Pr, 0x500); + SiS_WaitVBRetrace(SiS_Pr); + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_GenericDelay(SiS_Pr, 2048); + SiS_WaitVBRetrace(SiS_Pr); + } + if(!didpwd) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); + } else { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x03); } - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); } } @@ -4586,7 +4687,7 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); } @@ -4596,26 +4697,26 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } else { /* ============ For 301 ================ */ - if(HwInfo->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); - SiS_PanelDelay(SiS_Pr, HwInfo, 0); + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); + SiS_PanelDelay(SiS_Pr, 0); } } temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ if(SiS_BridgeInSlavemode(SiS_Pr)) { - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); - if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); + if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; } SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ - if(HwInfo->jChipType >= SIS_315H) { - temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); - if(!(temp & 0x80)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */ + if(SiS_Pr->ChipType >= SIS_315H) { + temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); + if(!(temp & 0x80)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */ } } @@ -4623,15 +4724,15 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) SiS_VBLongWait(SiS_Pr); SiS_DisplayOn(SiS_Pr); - if(HwInfo->jChipType >= SIS_315H) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + if(SiS_Pr->ChipType >= SIS_315H) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); } SiS_VBLongWait(SiS_Pr); - if(HwInfo->jChipType < SIS_315H) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + SiS_PanelDelay(SiS_Pr, 1); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); } } @@ -4639,49 +4740,49 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } else { /* =================== For LVDS ================== */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(HwInfo->jChipType == SIS_730) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_PanelDelay(SiS_Pr, HwInfo, 1); + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(SiS_Pr->ChipType == SIS_730) { + SiS_PanelDelay(SiS_Pr, 1); + SiS_PanelDelay(SiS_Pr, 1); + SiS_PanelDelay(SiS_Pr, 1); } - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); - if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 0); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); + if(!(SiS_CR36BIOSWord23d(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 0); } } SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); SiS_DisplayOn(SiS_Pr); - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_UnLockCRT2(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); if(SiS_BridgeInSlavemode(SiS_Pr)) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { - if(!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { - SiS_WaitVBRetrace(SiS_Pr, HwInfo); - SiS_SetCH700x(SiS_Pr,0x0B0E); - } + if(!(SiS_CRT2IsLCD(SiS_Pr))) { + SiS_WaitVBRetrace(SiS_Pr); + SiS_SetCH700x(SiS_Pr,0x0E,0x0B); + } } - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { - if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { - if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - } - SiS_WaitVBRetrace(SiS_Pr, HwInfo); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); - } + if(SiS_CRT2IsLCD(SiS_Pr)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { + if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { + SiS_PanelDelay(SiS_Pr, 1); + SiS_PanelDelay(SiS_Pr, 1); + } + SiS_WaitVBRetrace(SiS_Pr); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); + } } } @@ -4691,94 +4792,94 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) #ifdef SIS315H /* 315 series */ - if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { - if(HwInfo->jChipType < SIS_340) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18); - } + if(!(SiS_IsNotM650orLater(SiS_Pr))) { + /*if(SiS_Pr->ChipType < SIS_340) {*/ /* XGI needs this */ + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18); + /*}*/ } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); - SiS_PanelDelay(SiS_Pr, HwInfo, 0); - } + if(SiS_CRT2IsLCD(SiS_Pr)) { + SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00); + SiS_PanelDelay(SiS_Pr, 0); + } } SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); - SiS_UnLockCRT2(SiS_Pr,HwInfo); + SiS_UnLockCRT2(SiS_Pr); SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetCH701x(SiS_Pr,0x66); + temp = SiS_GetCH701x(SiS_Pr,0x66); temp &= 0x20; SiS_Chrontel701xBLOff(SiS_Pr); } - if(HwInfo->jChipType != SIS_550) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); + if(SiS_Pr->ChipType != SIS_550) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); } - if(HwInfo->jChipType == SIS_740) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(SiS_IsLCDOrLCDA(SiS_Pr, HwInfo)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); + if(SiS_Pr->ChipType == SIS_740) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_IsLCDOrLCDA(SiS_Pr)) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); } } } temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); if(!(temp1 & 0x80)) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(temp) { - SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); + if(temp) { + SiS_Chrontel701xBLOn(SiS_Pr); } } if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { + if(SiS_CRT2IsLCD(SiS_Pr)) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); - if(HwInfo->jChipType == SIS_550) { + if(SiS_Pr->ChipType == SIS_550) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x40); SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x10); } } - } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { - if(HwInfo->jChipType != SIS_740) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); + } else if(SiS_IsVAMode(SiS_Pr)) { + if(SiS_Pr->ChipType != SIS_740) { + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); } } - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); } if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) { - SiS_Chrontel701xOn(SiS_Pr,HwInfo); - } - if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || - (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) { - SiS_ChrontelDoSomething1(SiS_Pr,HwInfo); - } + if(SiS_IsTVOrYPbPrOrScart(SiS_Pr)) { + SiS_Chrontel701xOn(SiS_Pr); + } + if( (SiS_IsVAMode(SiS_Pr)) || + (SiS_IsLCDOrLCDA(SiS_Pr)) ) { + SiS_ChrontelDoSomething1(SiS_Pr); + } } if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || - (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) { - SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); - SiS_ChrontelInitTVVSync(SiS_Pr,HwInfo); - } - } + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + if( (SiS_IsVAMode(SiS_Pr)) || + (SiS_IsLCDOrLCDA(SiS_Pr)) ) { + SiS_Chrontel701xBLOn(SiS_Pr); + SiS_ChrontelInitTVVSync(SiS_Pr); + } + } } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { - if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { - if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { - SiS_PanelDelay(SiS_Pr, HwInfo, 1); - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); + if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) { + if(SiS_CRT2IsLCD(SiS_Pr)) { + SiS_PanelDelay(SiS_Pr, 1); + SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00); } } } @@ -4797,243 +4898,204 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /* Set CRT2 OFFSET / PITCH */ static void -SiS_SetCRT2Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RRTI, PSIS_HW_INFO HwInfo) +SiS_SetCRT2Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RRTI) { - USHORT offset; - UCHAR temp; + unsigned short offset; + unsigned char temp; - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; - offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI,HwInfo); + offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI); - if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) || - (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) { - offset >>= 1; - } + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF)); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8)); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF)); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8)); - temp = (UCHAR)(((offset >> 3) & 0xFF) + 1); - if(offset % 8) temp++; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp); + temp = (unsigned char)(((offset >> 3) & 0xFF) + 1); + if(offset & 0x07) temp++; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp); } /* Set CRT2 sync and PanelLink mode */ static void -SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT RefreshRateTableIndex, - PSIS_HW_INFO HwInfo) +SiS_SetCRT2Sync(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short RefreshRateTableIndex) { - USHORT tempah=0,tempbl,infoflag; + unsigned short tempah=0, tempbl, infoflag; - tempbl = 0xC0; + tempbl = 0xC0; - if(SiS_Pr->UseCustomMode) { - infoflag = SiS_Pr->CInfoFlag; - } else { - infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; - } + if(SiS_Pr->UseCustomMode) { + infoflag = SiS_Pr->CInfoFlag; + } else { + infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; + } - if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ + if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tempah = 0; - } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) { - tempah = SiS_Pr->SiS_LCDInfo; - } else tempah = infoflag >> 8; - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || - (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { - tempah |= 0xf0; - } - if( (SiS_Pr->SiS_IF_DEF_FSTN) || - (SiS_Pr->SiS_IF_DEF_DSTN) || - (SiS_Pr->SiS_IF_DEF_TRUMPION) || - (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { - tempah |= 0x30; - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(HwInfo->jChipType >= SIS_315H) { - tempah >>= 3; - tempah &= 0x18; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); - /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */ - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); - } - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + tempah = 0; + } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) { + tempah = SiS_Pr->SiS_LCDInfo; + } else tempah = infoflag >> 8; + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + tempah |= 0xf0; + } + if( (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN) || + (SiS_Pr->SiS_IF_DEF_TRUMPION) || + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) { + tempah |= 0x30; + } + if( (SiS_Pr->SiS_IF_DEF_FSTN) || + (SiS_Pr->SiS_IF_DEF_DSTN) ) { + tempah &= ~0xc0; + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->ChipType >= SIS_315H) { + tempah >>= 3; + tempah &= 0x18; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); + /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */ + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); + } + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + } - } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* ---- 300 series --- */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */ + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* 630 - 301B(-DH) */ - tempah = infoflag >> 8; - tempbl = 0; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - tempah = SiS_Pr->SiS_LCDInfo; - tempbl = (tempah >> 6) & 0x03; - } - } - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - tempah |= 0xc0; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); - } + tempah = infoflag >> 8; + tempbl = 0; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; + tempbl = (tempah >> 6) & 0x03; + } + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + tempah |= 0xc0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } - } else { /* 630 - 301 */ + } else { /* 630 - 301 */ - tempah = infoflag >> 8; - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + tempah = ((infoflag >> 8) & 0xc0) | 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - } + } #endif /* SIS300 */ - } else { + } else { #ifdef SIS315H /* ------- 315 series ------ */ - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 315 - LVDS */ + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* 315 - LVDS */ - tempbl = 0; - if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && - (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { - tempah = infoflag >> 8; - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); - } - } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && - (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) { - tempah = infoflag >> 8; - tempbl = 0x03; - } else { - tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); - tempbl = (tempah >> 6) & 0x03; - tempbl |= 0x08; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04; - } - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); - } - } + tempbl = 0; + if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && + (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { + tempah = infoflag >> 8; + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); + } + } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) { + tempah = infoflag >> 8; + tempbl = 0x03; + } else { + tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); + tempbl = (tempah >> 6) & 0x03; + tempbl |= 0x08; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04; + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } + } - } else { /* 315 - TMDS */ + } else { /* 315 - TMDS */ - tempah = tempbl = infoflag >> 8; - if(!SiS_Pr->UseCustomMode) { - tempbl = 0; - if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - if(ModeNo <= 0x13) { - tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); - } - } - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - if(SiS_Pr->SiS_LCDInfo & LCDSync) { - tempah = SiS_Pr->SiS_LCDInfo; + tempah = tempbl = infoflag >> 8; + if(!SiS_Pr->UseCustomMode) { + tempbl = 0; + if((SiS_Pr->SiS_VBType & VB_SIS30xC) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + if(ModeNo <= 0x13) { + tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); + } + } + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(SiS_Pr->SiS_LCDInfo & LCDSync) { + tempah = SiS_Pr->SiS_LCDInfo; tempbl = (tempah >> 6) & 0x03; } - } - } - } - tempah &= 0xC0; - tempah |= 0x20; - if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; - if(SiS_Pr->SiS_VBType & VB_NoLCD) { - /* Imitate BIOS bug */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0; - } - if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { - tempah >>= 3; - tempah &= 0x18; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah); - } else { - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); - } - } - } + } + } + } + tempah &= 0xC0; + tempah |= 0x20; + if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; + if(SiS_Pr->SiS_VBType & VB_NoLCD) { + /* Imitate BIOS bug */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0; + } + if((SiS_Pr->SiS_VBType & VB_SIS30xC) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { + tempah >>= 3; + tempah &= 0x18; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah); + } else { + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); + } + } + } - } + } #endif /* SIS315H */ } } } -/* Set CRT2 FIFO on 300/630/730 */ +/* Set CRT2 FIFO on 300/540/630/730 */ #ifdef SIS300 static void -SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, - PSIS_HW_INFO HwInfo) -{ - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT temp,index; - USHORT modeidindex,refreshratetableindex; - USHORT VCLK=0,MCLK,colorth=0,data2=0; - USHORT tempal, tempah, tempbx, tempcl, tempax; - USHORT CRT1ModeNo,CRT2ModeNo; - USHORT SelectRate_backup; - ULONG data,eax; - const UCHAR LatencyFactor[] = { - 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */ - 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */ - 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */ - 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */ - 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */ - 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */ - 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */ - 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */ - }; - const UCHAR LatencyFactor730[] = { - 69, 63, 61, - 86, 79, 77, - 103, 96, 94, - 120,113,111, - 137,130,128, /* <-- last entry, data below */ - 137,130,128, /* to avoid using illegal values */ - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - 137,130,128, - }; - const UCHAR ThLowB[] = { - 81, 4, 72, 6, 88, 8,120,12, - 55, 4, 54, 6, 66, 8, 90,12, - 42, 4, 45, 6, 55, 8, 75,12 - }; - const UCHAR ThTiming[] = { - 1, 2, 2, 3, 0, 1, 1, 2 +SiS_SetCRT2FIFO_300(struct SiS_Private *SiS_Pr,unsigned short ModeNo) +{ + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short temp, index, modeidindex, refreshratetableindex; + unsigned short VCLK = 0, MCLK, colorth = 0, data2 = 0; + unsigned short tempbx, tempcl, CRT1ModeNo, CRT2ModeNo, SelectRate_backup; + unsigned int data, pci50, pciA0; + static const unsigned char colortharray[] = { + 1, 1, 2, 2, 3, 4 }; SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; @@ -5044,232 +5106,159 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, SiS_SearchModeID(SiS_Pr, &CRT1ModeNo, &modeidindex); SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); SiS_Pr->SiS_SelectCRT2Rate = 0; - refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex, HwInfo); + refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex); if(CRT1ModeNo >= 0x13) { - index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; - index &= 0x3F; - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + /* Get VCLK */ + index = SiS_GetRefCRTVCLK(SiS_Pr, refreshratetableindex, SiS_Pr->SiS_UseWide); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; - colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex); /* Get colordepth */ - colorth >>= 1; - if(!colorth) colorth++; + /* Get colordepth */ + colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex) >> 1; + if(!colorth) colorth++; } } else { CRT1ModeNo = 0xfe; - VCLK = SiS_Pr->CSRClock_CRT1; /* Get VCLK */ - data2 = (SiS_Pr->CModeFlag_CRT1 & ModeTypeMask) - 2; - switch(data2) { /* Get color depth */ - case 0 : colorth = 1; break; - case 1 : colorth = 1; break; - case 2 : colorth = 2; break; - case 3 : colorth = 2; break; - case 4 : colorth = 3; break; - case 5 : colorth = 4; break; - default: colorth = 2; - } + + /* Get VCLK */ + VCLK = SiS_Pr->CSRClock_CRT1; + + /* Get color depth */ + colorth = colortharray[((SiS_Pr->CModeFlag_CRT1 & ModeTypeMask) - 2)]; } if(CRT1ModeNo >= 0x13) { - if(HwInfo->jChipType == SIS_300) { - index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); - } else { - index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); - } - index &= 0x07; - MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ + /* Get MCLK */ + if(SiS_Pr->ChipType == SIS_300) { + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); + } else { + index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); + } + index &= 0x07; + MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; - data2 = (colorth * VCLK) / MCLK; + temp = ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) >> 6) & 0x03) << 1; + if(!temp) temp++; + temp <<= 2; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - temp = ((temp & 0x00FF) >> 6) << 1; - if(temp == 0) temp = 1; - temp <<= 2; - temp &= 0xff; + data2 = temp - ((colorth * VCLK) / MCLK); - data2 = temp - data2; + temp = (28 * 16) % data2; + data2 = (28 * 16) / data2; + if(temp) data2++; - if((28 * 16) % data2) { - data2 = (28 * 16) / data2; - data2++; - } else { - data2 = (28 * 16) / data2; - } + if(SiS_Pr->ChipType == SIS_300) { - if(HwInfo->jChipType == SIS_300) { - - tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18); - tempah &= 0x62; - tempah >>= 1; - tempal = tempah; - tempah >>= 3; - tempal |= tempah; - tempal &= 0x07; - tempcl = ThTiming[tempal]; - tempbx = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16); - tempbx >>= 6; - tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - tempah >>= 4; - tempah &= 0x0c; - tempbx |= tempah; - tempbx <<= 1; - tempal = ThLowB[tempbx + 1]; - tempal *= tempcl; - tempal += ThLowB[tempbx]; - data = tempal; - - } else if(HwInfo->jChipType == SIS_730) { - -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x80000050); - eax = SiS_GetRegLong(0xcfc); + SiS_GetFIFOThresholdIndex300(SiS_Pr, &tempbx, &tempcl); + data = SiS_GetFIFOThresholdB300(tempbx, tempcl); + + } else { + +#ifdef SIS_LINUX_KERNEL + pci50 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); + pciA0 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xa0); #else - eax = pciReadLong(0x00000000, 0x50); + pci50 = pciReadLong(0x00000000, 0x50); + pciA0 = pciReadLong(0x00000000, 0xA0); #endif - tempal = (USHORT)(eax >> 8); - tempal &= 0x06; - tempal <<= 5; -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x800000A0); - eax = SiS_GetRegLong(0xcfc); -#else - eax = pciReadLong(0x00000000, 0xA0); -#endif - temp = (USHORT)(eax >> 28); - temp &= 0x0F; - tempal |= temp; - - tempbx = tempal; /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */ - tempbx = 0; /* -- do it like the BIOS anyway... */ - tempax = tempbx; - tempbx &= 0xc0; - tempbx >>= 6; - tempax &= 0x0f; - tempax *= 3; - tempbx += tempax; - - data = LatencyFactor730[tempbx]; - data += 15; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; + if(SiS_Pr->ChipType == SIS_730) { - } else { + index = (unsigned short)(((pciA0 >> 28) & 0x0f) * 3); + index += (unsigned short)(((pci50 >> 9)) & 0x03); - index = 0; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - if(temp & 0x0080) index += 12; + /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */ + index = 0; /* -- do it like the BIOS anyway... */ -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x800000A0); - eax = SiS_GetRegLong(0xcfc); -#else - /* We use pci functions X offers. We use tag 0, because - * we want to read/write to the host bridge (which is always - * 00:00.0 on 630, 730 and 540), not the VGA device. - */ - eax = pciReadLong(0x00000000, 0xA0); -#endif - temp = (USHORT)(eax >> 24); - if(!(temp&0x01)) index += 24; - -#ifdef LINUX_KERNEL - SiS_SetRegLong(0xcf8,0x80000050); - eax = SiS_GetRegLong(0xcfc); -#else - eax = pciReadLong(0x00000000, 0x50); -#endif - temp=(USHORT)(eax >> 24); - if(temp & 0x01) index += 6; + } else { - temp = (temp & 0x0F) >> 1; - index += temp; + pci50 >>= 24; + pciA0 >>= 24; - data = LatencyFactor[index]; - data += 15; - temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); - if(!(temp & 0x80)) data += 5; - } + index = (pci50 >> 1) & 0x07; - data += data2; /* CRT1 Request Period */ + if(pci50 & 0x01) index += 6; + if(!(pciA0 & 0x01)) index += 24; - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; + if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80) index += 12; - if(!SiS_Pr->UseCustomMode) { + } - CRT2ModeNo = ModeNo; - SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); + data = SiS_GetLatencyFactor630(SiS_Pr, index) + 15; + if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80)) data += 5; - refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex, HwInfo); + } - index = SiS_GetVCLK2Ptr(SiS_Pr,CRT2ModeNo,modeidindex, - refreshratetableindex,HwInfo); - VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ + data += data2; /* CRT1 Request Period */ - if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { - if(SiS_Pr->SiS_UseROM) { - if(ROMAddr[0x220] & 0x01) { - VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8); - } - } - } + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; - } else { + if(!SiS_Pr->UseCustomMode) { - CRT2ModeNo = 0xfe; - VCLK = SiS_Pr->CSRClock; /* Get VCLK */ + CRT2ModeNo = ModeNo; + SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); - } + refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex); - colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex); /* Get colordepth */ - colorth >>= 1; - if(!colorth) colorth++; + /* Get VCLK */ + index = SiS_GetVCLK2Ptr(SiS_Pr, CRT2ModeNo, modeidindex, refreshratetableindex); + VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; - data = data * VCLK * colorth; - if(data % (MCLK << 4)) { - data = data / (MCLK << 4); - data++; - } else { - data = data / (MCLK << 4); - } + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { + if(SiS_Pr->SiS_UseROM) { + if(ROMAddr[0x220] & 0x01) { + VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8); + } + } + } - if(data <= 6) data = 6; - if(data > 0x14) data = 0x14; + } else { - temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x01); - if(HwInfo->jChipType == SIS_300) { - if(data <= 0x0f) temp = (temp & (~0x1F)) | 0x13; - else temp = (temp & (~0x1F)) | 0x16; - if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { - temp = (temp & (~0x1F)) | 0x13; - } - } else { - if( ( (HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730) ) && - (HwInfo->jChipRevision >= 0x30) ) /* 630s or 730(s?) */ - { - temp = (temp & (~0x1F)) | 0x1b; - } else { - temp = (temp & (~0x1F)) | 0x16; - } - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); + /* Get VCLK */ + CRT2ModeNo = 0xfe; + VCLK = SiS_Pr->CSRClock; - if( (HwInfo->jChipType == SIS_630) && - (HwInfo->jChipRevision >= 0x30) ) /* 630s, NOT 730 */ - { - if(data > 0x13) data = 0x13; - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); + } + + /* Get colordepth */ + colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex) >> 1; + if(!colorth) colorth++; + + data = data * VCLK * colorth; + temp = data % (MCLK << 4); + data = data / (MCLK << 4); + if(temp) data++; + + if(data < 6) data = 6; + else if(data > 0x14) data = 0x14; + + if(SiS_Pr->ChipType == SIS_300) { + temp = 0x16; + if((data <= 0x0f) || (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) + temp = 0x13; + } else { + temp = 0x16; + if(( (SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730) ) && + (SiS_Pr->ChipRevision >= 0x30)) + temp = 0x1b; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp); + + if((SiS_Pr->ChipType == SIS_630) && + (SiS_Pr->ChipRevision >= 0x30)) { + if(data > 0x13) data = 0x13; + } + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); } else { /* If mode <= 0x13, we just restore everything */ - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; - SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; } } @@ -5278,10 +5267,10 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, /* Set CRT2 FIFO on 315/330 series */ #ifdef SIS315H static void -SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_SetCRT2FIFO_310(struct SiS_Private *SiS_Pr) { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B); - if( (HwInfo->jChipType == SIS_760) && + if( (SiS_Pr->ChipType == SIS_760) && (SiS_Pr->SiS_SysFlags & SF_760LFB) && (SiS_Pr->SiS_ModeType == Mode32Bpp) && (SiS_Pr->SiS_VGAHDE >= 1280) && @@ -5299,337 +5288,162 @@ SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } #endif -static USHORT -SiS_GetVGAHT2(SiS_Private *SiS_Pr) +static unsigned short +SiS_GetVGAHT2(struct SiS_Private *SiS_Pr) { - ULONG tempax,tempbx; + unsigned int tempax,tempbx; tempbx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX; tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT; tempax = (tempax * SiS_Pr->SiS_HT) / tempbx; - return((USHORT)tempax); + return (unsigned short)tempax; } /* Set Part 1 / SiS bridge slave mode */ static void -SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo,USHORT RefreshRateTableIndex) -{ - USHORT push1,push2; - USHORT tempax,tempbx,tempcx,temp; - USHORT resinfo,modeflag,xres=0; - unsigned char p1_7, p1_8; +SiS_SetGroup1_301(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned short temp, modeflag, i, j, xres=0, VGAVDE; + static const unsigned short CRTranslation[] = { + /* CR0 CR1 CR2 CR3 CR4 CR5 CR6 CR7 */ + 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, + /* CR8 CR9 SR0A SR0B SR0C SR0D SR0E CR0F */ + 0x00, 0x0b, 0x17, 0x18, 0x19, 0x00, 0x1a, 0x00, + /* CR10 CR11 CR12 CR13 CR14 CR15 CR16 CR17 */ + 0x0c, 0x0d, 0x0e, 0x00, 0x0f, 0x10, 0x11, 0x00 + }; if(ModeNo <= 0x13) { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; } else if(SiS_Pr->UseCustomMode) { modeflag = SiS_Pr->CModeFlag; - resinfo = 0; xres = SiS_Pr->CHDisplay; } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes; } /* The following is only done if bridge is in slave mode: */ - if((HwInfo->jChipType >= SIS_661) && (ModeNo > 0x13)) { - if(xres >= 1600) { + if(SiS_Pr->ChipType >= SIS_315H) { + if(xres >= 1600) { /* BIOS: == 1600 */ SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x31,0x04); } } - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */ - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot; + SiS_Pr->CHTotal = 8224; /* Max HT, 0x2020, results in 0x3ff in registers */ - if(modeflag & Charx8Dot) tempcx = 0x08; - else tempcx = 0x09; - - tempax = SiS_Pr->SiS_VGAHDE; /* 0x04 Horizontal Display End */ - if(modeflag & HalfDCLK) tempax >>= 1; - tempax = ((tempax / tempcx) - 1) & 0xff; - tempbx = tempax; - - temp = tempax; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,temp); + SiS_Pr->CHDisplay = SiS_Pr->SiS_VGAHDE; + if(modeflag & HalfDCLK) SiS_Pr->CHDisplay >>= 1; + SiS_Pr->CHBlankStart = SiS_Pr->CHDisplay; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { - temp += 2; - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(resinfo == SIS_RI_800x600) temp -= 2; - } - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */ - - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */ - - tempax = 0xFFFF; - if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr); - if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT; - if(modeflag & HalfDCLK) tempax >>= 1; - tempax = (tempax / tempcx) - 5; - tempcx = tempax; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - temp = tempcx - 1; - if(!(modeflag & HalfDCLK)) { - temp -= 6; - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - temp -= 2; - if(ModeNo > 0x13) temp -= 10; - } - } - } else { - tempcx = (tempcx + tempbx) >> 1; - temp = (tempcx & 0x00FF) + 2; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - temp--; - if(!(modeflag & HalfDCLK)) { - if((modeflag & Charx8Dot)) { - temp += 4; - if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VGAHDE == 800) temp += 2; - } - } - } - } else { - if(!(modeflag & HalfDCLK)) { - temp -= 4; - if((SiS_Pr->SiS_LCDResInfo != Panel_1280x960) && - (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200)) { - if(SiS_Pr->SiS_VGAHDE >= 800) { - temp -= 7; - if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->SiS_ModeType == ModeEGA) { - if(SiS_Pr->SiS_VGAVDE == 1024) { - temp += 15; - if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) - temp += 7; - } - } - } - if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) { - if(SiS_Pr->SiS_VGAHDE >= 1280) { - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28; - } - } - } - } - } - } + SiS_Pr->CHBlankStart += 16; } - p1_7 = temp; - p1_8 = 0x00; - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - if(ModeNo <= 0x01) { - p1_7 = 0x2a; - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_8 = 0x61; - else p1_8 = 0x41; - } else if(SiS_Pr->SiS_ModeType == ModeText) { - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_7 = 0x54; - else p1_7 = 0x55; - p1_8 = 0x00; - } else if(ModeNo <= 0x13) { - if(modeflag & HalfDCLK) { - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { - p1_7 = 0x30; - p1_8 = 0x03; - } else { - p1_7 = 0x2f; - p1_8 = 0x02; - } - } else { - p1_7 = 0x5b; - p1_8 = 0x03; - } - } else if( ((HwInfo->jChipType >= SIS_315H) && - ((ModeNo == 0x50) || (ModeNo == 0x56) || (ModeNo == 0x53))) || - ((HwInfo->jChipType < SIS_315H) && - (resinfo == SIS_RI_320x200 || resinfo == SIS_RI_320x240)) ) { - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { - p1_7 = 0x30, - p1_8 = 0x03; - } else { - p1_7 = 0x2f; - p1_8 = 0x03; - } - } - } + SiS_Pr->CHBlankEnd = 32; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { + if(xres == 1600) SiS_Pr->CHBlankEnd += 80; } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p)) { - p1_7 = 0x63; - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) p1_7 = 0x55; - } - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - if(!(modeflag & HalfDCLK)) { - p1_7 = 0xb2; - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { - p1_7 = 0xab; - } - } - } else { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { - if(modeflag & HalfDCLK) p1_7 = 0x30; - } - } + temp = SiS_Pr->SiS_VGAHT - 96; + if(!(modeflag & HalfDCLK)) temp -= 32; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x04); + temp |= ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x0b) & 0xc0) << 2); + temp -= 3; + temp <<= 3; + } else { + if(SiS_Pr->SiS_RVBHRS2) temp = SiS_Pr->SiS_RVBHRS2; } + SiS_Pr->CHSyncStart = temp; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,p1_7); /* 0x07 Horizontal Retrace Start */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,p1_8); /* 0x08 Horizontal Retrace End */ + SiS_Pr->CHSyncEnd = 0xffe8; /* results in 0x2000 in registers */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */ + SiS_Pr->CVTotal = 2049; /* Max VT, 0x0801, results in 0x7ff in registers */ - SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); + VGAVDE = SiS_Pr->SiS_VGAVDE; + if (VGAVDE == 357) VGAVDE = 350; + else if(VGAVDE == 360) VGAVDE = 350; + else if(VGAVDE == 375) VGAVDE = 350; + else if(VGAVDE == 405) VGAVDE = 400; + else if(VGAVDE == 420) VGAVDE = 400; + else if(VGAVDE == 525) VGAVDE = 480; + else if(VGAVDE == 1056) VGAVDE = 1024; + SiS_Pr->CVDisplay = VGAVDE; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ + SiS_Pr->CVBlankStart = SiS_Pr->CVDisplay; - tempcx = 0x121; - tempbx = SiS_Pr->SiS_VGAVDE; /* 0x0E Vertical Display End */ - if (tempbx == 357) tempbx = 350; - else if(tempbx == 360) tempbx = 350; - else if(tempbx == 375) tempbx = 350; - else if(tempbx == 405) tempbx = 400; - else if(tempbx == 420) tempbx = 400; - else if(tempbx == 525) tempbx = 480; - push2 = tempbx; - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { - if (tempbx == 350) tempbx += 5; - else if(tempbx == 480) tempbx += 5; - } - } - } - tempbx -= 2; - temp = tempbx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */ - - tempbx = push2; - tempbx--; - temp = tempbx & 0x00FF; -#if 0 - /* Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */ - if(xxx()) { - if(temp == 0xdf) temp = 0xda; - } -#endif - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp); - - temp = 0; - if(modeflag & DoubleScanMode) temp |= 0x80; - if(HwInfo->jChipType >= SIS_661) { - if(tempbx & 0x0200) temp |= 0x20; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x0B,0x5F,temp); - if(tempbx & 0x0100) tempcx |= 0x000a; - if(tempbx & 0x0400) tempcx |= 0x1200; - } else { - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp); - if(tempbx & 0x0100) tempcx |= 0x0002; - if(tempbx & 0x0400) tempcx |= 0x0600; - } + SiS_Pr->CVBlankEnd = 1; + if(ModeNo == 0x3c) SiS_Pr->CVBlankEnd = 226; - if(tempbx & 0x0200) tempcx |= 0x0040; + temp = (SiS_Pr->SiS_VGAVT - VGAVDE) >> 1; + SiS_Pr->CVSyncStart = VGAVDE + temp; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */ + temp >>= 3; + SiS_Pr->CVSyncEnd = SiS_Pr->CVSyncStart + temp; - tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2; + SiS_CalcCRRegisters(SiS_Pr, 0); + SiS_Pr->CCRT1CRTC[16] &= ~0xE0; - if((ModeNo > 0x13) || (HwInfo->jChipType < SIS_315H)) { - if(resinfo != SIS_RI_1280x1024) { - tempbx += (tempax << 1); - } - } else if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) { - tempbx += (tempax << 1); - } + for(i = 0; i <= 7; i++) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[i]); } - - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - tempbx -= 10; - } else { - if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - tempbx += 40; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10; - } - } - } - } - tempax >>= 2; - tempax++; - tempax += tempbx; - push1 = tempax; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if(tempbx <= 513) { - if(tempax >= 513) tempbx = 513; - } + for(i = 0x10, j = 8; i <= 0x12; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); } - temp = tempbx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* 0x0C Vertical Retrace Start */ - - tempbx--; - temp = tempbx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); - - if(tempbx & 0x0100) tempcx |= 0x0008; - - if(tempbx & 0x0200) { - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20); + for(i = 0x15, j = 11; i <= 0x16; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); } - tempbx++; - - if(tempbx & 0x0100) tempcx |= 0x0004; - if(tempbx & 0x0200) tempcx |= 0x0080; - if(tempbx & 0x0400) { - if(HwInfo->jChipType >= SIS_661) tempcx |= 0x0800; - else if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800; - else tempcx |= 0x0C00; + for(i = 0x0a, j = 13; i <= 0x0c; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]); } - tempbx = push1; - temp = tempbx & 0x000F; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */ - - if(tempbx & 0x0010) tempcx |= 0x2000; - - temp = tempcx & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */ - - temp = (tempcx & 0xFF00) >> 8; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */ + temp = SiS_Pr->CCRT1CRTC[16] & 0xE0; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,CRTranslation[0x0E],0x1F,temp); - tempax = modeflag; - temp = (tempax & 0xFF00) >> 8; - temp = (temp >> 1) & 0x09; - if(!(SiS_Pr->SiS_VBType & VB_SIS301)) temp |= 0x01; /* Always 8 dotclock */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* 0x16 SR01 */ + temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5; + if(modeflag & DoubleScanMode) temp |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,CRTranslation[0x09],0x5F,temp); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */ + temp = 0; + temp |= (SiS_GetReg(SiS_Pr->SiS_P3c4,0x01) & 0x01); + if(modeflag & HalfDCLK) temp |= 0x08; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* SR01: HalfDCLK[3], 8/9 div dotclock[0] */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* CR14: (text mode: underline location) */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* CR17: n/a */ - temp = 0x00; + temp = 0; if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { - if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { - temp = 0x80; - } + temp = (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) << 7; } - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* 0x1A SR0E */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* SR0E, dither[7] */ temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); /* ? */ + +#ifdef SIS_XORG_XF86 +#ifdef TWDEBUG + xf86DrvMsg(0, X_INFO, "%d %d %d %d %d %d %d %d (%d %d %d %d)\n", + SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal, + SiS_Pr->CVDisplay, SiS_Pr->CVSyncStart, SiS_Pr->CVSyncEnd, SiS_Pr->CVTotal, + SiS_Pr->CHBlankStart, SiS_Pr->CHBlankEnd, SiS_Pr->CVBlankStart, SiS_Pr->CVBlankEnd); + + xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", + SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1], + SiS_Pr->CCRT1CRTC[2], SiS_Pr->CCRT1CRTC[3], + SiS_Pr->CCRT1CRTC[4], SiS_Pr->CCRT1CRTC[5], + SiS_Pr->CCRT1CRTC[6], SiS_Pr->CCRT1CRTC[7]); + xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n", + SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9], + SiS_Pr->CCRT1CRTC[10], SiS_Pr->CCRT1CRTC[11], + SiS_Pr->CCRT1CRTC[12], SiS_Pr->CCRT1CRTC[13], + SiS_Pr->CCRT1CRTC[14], SiS_Pr->CCRT1CRTC[15]); + xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", SiS_Pr->CCRT1CRTC[16]); +#endif +#endif } /* Setup panel link @@ -5637,18 +5451,18 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, * 300/LVDS+TV, 300/301B-DH, 315/LVDS+TV, 315/LCDA */ static void -SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT modeflag,resinfo; - USHORT push2,tempax,tempbx,tempcx,temp; - ULONG tempeax=0,tempebx,tempecx,tempvcfact=0; + unsigned short modeflag, resinfo = 0; + unsigned short push2, tempax, tempbx, tempcx, temp; + unsigned int tempeax = 0, tempebx, tempecx, tempvcfact = 0; BOOLEAN islvds = FALSE, issis = FALSE, chkdclkfirst = FALSE; #ifdef SIS300 - USHORT crt2crtc; + unsigned short crt2crtc = 0; #endif #ifdef SIS315H - USHORT pushcx; + unsigned short pushcx; #endif if(ModeNo <= 0x13) { @@ -5659,15 +5473,11 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #endif } else if(SiS_Pr->UseCustomMode) { modeflag = SiS_Pr->CModeFlag; - resinfo = 0; -#ifdef SIS300 - crt2crtc = 0; -#endif } else { modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; #ifdef SIS300 - crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; #endif } @@ -5681,14 +5491,14 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, issis = TRUE; } - if((HwInfo->jChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) { + if((SiS_Pr->ChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) { if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { chkdclkfirst = TRUE; } } #ifdef SIS315H - if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { if(IS_SIS330) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); } else if(IS_SIS740) { @@ -5704,7 +5514,7 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); } else if(SiS_Pr->SiS_VBType & VB_SISVB) { SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); - if(SiS_Pr->SiS_VBType & VB_SIS301C) { + if(SiS_Pr->SiS_VBType & VB_SIS30xC) { if((SiS_Pr->SiS_LCDResInfo == Panel_1024x768) || (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x20); @@ -5720,10 +5530,10 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempax = SiS_Pr->SiS_LCDHDES; if(islvds) { if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { - if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) && - (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { - tempax -= 8; + if(!SiS_Pr->SiS_IF_DEF_FSTN && !SiS_Pr->SiS_IF_DEF_DSTN) { + if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) && + (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { + tempax -= 8; } } } @@ -5736,13 +5546,14 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbx = SiS_Pr->SiS_HDE; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) || - (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) { - tempbx >>= 1; - } if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { tempbx = SiS_Pr->PanelXRes; } + if((SiS_Pr->SiS_LCDResInfo == Panel_320x240_1) || + (SiS_Pr->SiS_LCDResInfo == Panel_320x240_2) || + (SiS_Pr->SiS_LCDResInfo == Panel_320x240_3)) { + tempbx >>= 1; + } } tempax += tempbx; @@ -5767,25 +5578,25 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, temp = (tempcx >> 3) & 0x00FF; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { if(SiS_Pr->SiS_IF_DEF_TRUMPION) { - if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - switch(ModeNo) { - case 0x04: - case 0x05: - case 0x0d: temp = 0x56; break; - case 0x10: temp = 0x60; break; - case 0x13: temp = 0x5f; break; - case 0x40: - case 0x41: - case 0x4f: - case 0x43: - case 0x44: - case 0x62: - case 0x56: - case 0x53: - case 0x5d: - case 0x5e: temp = 0x54; break; - } - } + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { + switch(ModeNo) { + case 0x04: + case 0x05: + case 0x0d: temp = 0x56; break; + case 0x10: temp = 0x60; break; + case 0x13: temp = 0x5f; break; + case 0x40: + case 0x41: + case 0x4f: + case 0x43: + case 0x44: + case 0x62: + case 0x56: + case 0x53: + case 0x5d: + case 0x5e: temp = 0x54; break; + } + } } } SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* BPLHRS */ @@ -5793,12 +5604,12 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { temp += 2; if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - temp += 8; - if(SiS_Pr->PanelHRE != 999) { - temp = tempcx + SiS_Pr->PanelHRE; + temp += 8; + if(SiS_Pr->PanelHRE != 999) { + temp = tempcx + SiS_Pr->PanelHRE; if(temp >= SiS_Pr->SiS_HT) temp -= SiS_Pr->SiS_HT; temp >>= 3; - } + } } } else { temp += 10; @@ -5806,9 +5617,6 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, temp &= 0x1F; temp |= ((tempcx & 0x07) << 5); -#if 0 - if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20; /* WRONG? BIOS loads cl, not ah */ -#endif SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* BPLHRE */ /* Vertical */ @@ -5826,9 +5634,9 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, push2 = tempbx; tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { + if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->PanelYRes; } } @@ -5844,19 +5652,19 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(issis) tempbx++; } else { tempbx += tempcx; - if(HwInfo->jChipType < SIS_315H) tempbx++; + if(SiS_Pr->ChipType < SIS_315H) tempbx++; else if(issis) tempbx++; } - if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; /* BPLVRS */ + if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; temp = tempbx & 0x00FF; if(SiS_Pr->SiS_IF_DEF_TRUMPION) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(ModeNo == 0x10) temp = 0xa9; + if(ModeNo == 0x10) temp = 0xa9; } } - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* BPLVRS */ tempcx >>= 3; tempcx++; @@ -5879,13 +5687,13 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; tempbx = 0x87; - if((HwInfo->jChipType >= SIS_315H) || - (HwInfo->jChipRevision >= 0x30)) { + if((SiS_Pr->ChipType >= SIS_315H) || + (SiS_Pr->ChipRevision >= 0x30)) { tempbx = 0x07; if((SiS_Pr->SiS_IF_DEF_CH70xx == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x03) temp |= 0x80; } - /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit mutliplexed) via VGA2 */ + /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit multiplexed) via VGA2 */ if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80; @@ -5896,59 +5704,58 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,tempbx,temp); - tempbx = push2; /* BPLVDEE */ + tempbx = push2; /* BPLVDEE */ - tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */ + tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */ if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { switch(SiS_Pr->SiS_LCDResInfo) { case Panel_640x480: - tempbx = SiS_Pr->SiS_VGAVDE - 1; - tempcx = SiS_Pr->SiS_VGAVDE; + tempbx = SiS_Pr->SiS_VGAVDE - 1; + tempcx = SiS_Pr->SiS_VGAVDE; break; case Panel_800x600: - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == SIS_RI_800x600) tempcx++; - } + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_800x600) tempcx++; + } break; case Panel_1024x600: - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == SIS_RI_1024x600) tempcx++; - if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_1024x600) tempcx++; + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { if(resinfo == SIS_RI_800x600) tempcx++; } - } + } break; case Panel_1024x768: - if(HwInfo->jChipType < SIS_315H) { - if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - if(resinfo == SIS_RI_1024x768) tempcx++; + if(SiS_Pr->ChipType < SIS_315H) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + if(resinfo == SIS_RI_1024x768) tempcx++; } - } + } break; } } temp = ((tempbx >> 8) & 0x07) << 3; - temp = temp | ((tempcx >> 8) & 0x07); + temp |= ((tempcx >> 8) & 0x07); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); - /* if(SiS_Pr->SiS_IF_DEF_FSTN) tempbx++; */ SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,tempbx); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,tempcx); /* Vertical scaling */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* 300 series */ tempeax = SiS_Pr->SiS_VGAVDE << 6; - temp = (tempeax % (ULONG)SiS_Pr->SiS_VDE); - tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE; + temp = (tempeax % (unsigned int)SiS_Pr->SiS_VDE); + tempeax = tempeax / (unsigned int)SiS_Pr->SiS_VDE; if(temp) tempeax++; if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempeax = 0x3F; - temp = (USHORT)(tempeax & 0x00FF); + temp = (unsigned short)(tempeax & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */ tempvcfact = temp; #endif /* SIS300 */ @@ -5963,20 +5770,20 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(temp) tempeax++; tempvcfact = tempeax; - temp = (USHORT)(tempeax & 0x00FF); + temp = (unsigned short)(tempeax & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp); - temp = (USHORT)((tempeax & 0x00FF00) >> 8); + temp = (unsigned short)((tempeax & 0x00FF00) >> 8); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp); - temp = (USHORT)((tempeax & 0x00030000) >> 16); + temp = (unsigned short)((tempeax & 0x00030000) >> 16); if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp); - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) { - temp = (USHORT)(tempeax & 0x00FF); + if(SiS_Pr->SiS_VBType & VB_SISPART4SCALER) { + temp = (unsigned short)(tempeax & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3c,temp); - temp = (USHORT)((tempeax & 0x00FF00) >> 8); + temp = (unsigned short)((tempeax & 0x00FF00) >> 8); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3b,temp); - temp = (USHORT)(((tempeax & 0x00030000) >> 16) << 6); + temp = (unsigned short)(((tempeax & 0x00030000) >> 16) << 6); SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0x3f,temp); temp = 0; if(SiS_Pr->SiS_VDE != SiS_Pr->SiS_VGAVDE) temp |= 0x08; @@ -5997,29 +5804,29 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempecx = 0xFFFF; } else { tempecx = tempebx / SiS_Pr->SiS_HDE; - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(tempebx % SiS_Pr->SiS_HDE) tempecx++; } } - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { tempeax = (tempebx / tempecx) - 1; } else { tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; } tempecx = (tempecx << 16) | (tempeax & 0xFFFF); - temp = (USHORT)(tempecx & 0x00FF); + temp = (unsigned short)(tempecx & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; - tempbx = (USHORT)(tempeax & 0xFFFF); + tempbx = (unsigned short)(tempeax & 0xFFFF); } else { tempeax = SiS_Pr->SiS_VGAVDE << 6; tempbx = tempvcfact & 0x3f; if(tempbx == 0) tempbx = 64; tempeax /= tempbx; - tempbx = (USHORT)(tempeax & 0xFFFF); + tempbx = (unsigned short)(tempeax & 0xFFFF); } if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tempbx--; if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { @@ -6032,24 +5839,24 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,tempbx); - tempecx >>= 16; /* BPLHCFACT */ + tempecx >>= 16; /* BPLHCFACT */ if(!chkdclkfirst) { if(modeflag & HalfDCLK) tempecx >>= 1; } - temp = (USHORT)((tempecx & 0xFF00) >> 8); + temp = (unsigned short)((tempecx & 0xFF00) >> 8); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); - temp = (USHORT)(tempecx & 0x00FF); + temp = (unsigned short)(tempecx & 0x00FF); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)) { + if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SISLVDS)) { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20); } } else { if(islvds) { - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03); } else { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x23); @@ -6061,17 +5868,26 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #ifdef SIS300 if(SiS_Pr->SiS_IF_DEF_TRUMPION) { - int i; - UCHAR TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 }; - UCHAR TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 }; - UCHAR TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 }; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned char *trumpdata; + int i, j = crt2crtc; + unsigned char TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 }; + unsigned char TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 }; + unsigned char TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 }; + + if(SiS_Pr->SiS_UseROM) { + trumpdata = &ROMAddr[0x8001 + (j * 80)]; + } else { + if(SiS_Pr->SiS_LCDTypeInfo == 0x0e) j += 7; + trumpdata = &SiS300_TrumpionData[j][0]; + } SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xbf); for(i=0; i<5; i++) { - SiS_SetTrumpionBlock(SiS_Pr, &SiS300_TrumpionData[crt2crtc][0]); + SiS_SetTrumpionBlock(SiS_Pr, trumpdata); } if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(ModeNo == 0x13) { + if(ModeNo == 0x13) { for(i=0; i<4; i++) { SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode13[0]); } @@ -6095,67 +5911,66 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetReg(SiS_Pr->SiS_Part1Port,0x29,0x5A); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2A,0x4B); SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x07,0x03); - tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; + tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; tempax += 64; - temp = tempax & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,temp); - temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,tempax & 0xff); + temp = (tempax >> 8) << 3; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp); - tempax += 32; /* Blpe=lBlps+32 */ - temp = tempax & 0x00FF; - if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,temp); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml=0 */ - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00); + tempax += 32; /* Blpe = lBlps+32 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,tempax & 0xff); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml = 0 */ + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x3C,~0x007); tempax = SiS_Pr->SiS_VDE; - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; tempax >>= 1; - temp = tempax & 0x00FF; - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,temp); - temp = ((tempax & 0xFF00) >> 8) << 3; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,tempax & 0xff); + temp = (tempax >> 8) << 3; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp); tempeax = SiS_Pr->SiS_HDE; - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempeax >>= 1; - tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */ - tempebx = 128; - temp = (USHORT)(tempeax % tempebx); - tempeax = tempeax / tempebx; + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempeax >>= 1; + tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */ + temp = tempeax & 0x7f; + tempeax >>= 7; if(temp) tempeax++; - temp = (USHORT)(tempeax & 0x003F); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp); - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ + temp = tempeax & 0x3f; + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,temp); + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3E,0x00); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3D,0x10); - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00); + SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x3C,~0x040); tempax = SiS_Pr->SiS_HDE; - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; - tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */ + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; + tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */ pushcx = tempax; temp = tempax & 0x00FF; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp); temp = ((tempax & 0xFF00) >> 8) << 3; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp); - tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ - if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || - SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; - tempeax = (tempax * pushcx); - tempebx = 0x00100000 + tempeax; - temp = (USHORT)tempebx & 0x000000FF; + tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ + if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 || + SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1; + tempeax = tempax * pushcx; + temp = tempeax & 0xFF; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,temp); - temp = (USHORT)((tempebx & 0x0000FF00) >> 8); + temp = (tempeax & 0xFF00) >> 8; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,temp); - temp = (USHORT)((tempebx & 0x00FF0000) >> 16); + temp = ((tempeax & 0xFF0000) >> 16) | 0x10; SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp); - temp = (USHORT)(((tempebx & 0x01000000) >> 24) << 7); + temp = ((tempeax & 0x01000000) >> 24) << 7; SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03); @@ -6192,20 +6007,20 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* Set Part 1 */ static void -SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) +SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { #if defined(SIS300) || defined(SIS315H) - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; #endif - USHORT temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0; - USHORT pushbx=0, CRT1Index=0, modeflag, resinfo=0; + unsigned short temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0; + unsigned short pushbx=0, CRT1Index=0, modeflag, resinfo=0; #ifdef SIS315H - USHORT tempbl=0; + unsigned short tempbl=0; #endif if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); return; } @@ -6214,47 +6029,47 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } else if(SiS_Pr->UseCustomMode) { modeflag = SiS_Pr->CModeFlag; } else { - CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; + CRT1Index = SiS_GetRefCRT1CRTC(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWideCRT2); resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; } - SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); - if( ! ((HwInfo->jChipType >= SIS_315H) && + if( ! ((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) { - if(HwInfo->jChipType < SIS_315H ) { + if(SiS_Pr->ChipType < SIS_315H ) { #ifdef SIS300 - SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo, HwInfo); + SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo); #endif } else { #ifdef SIS315H - SiS_SetCRT2FIFO_310(SiS_Pr, HwInfo); + SiS_SetCRT2FIFO_310(SiS_Pr); #endif } /* 1. Horizontal setup */ - if(HwInfo->jChipType < SIS_315H ) { + if(SiS_Pr->ChipType < SIS_315H ) { #ifdef SIS300 /* ------------- 300 series --------------*/ - temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ + temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ - temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ + temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ - temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ - SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ + temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ + SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA2HRS 0x0B,0x0C */ - tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; - tempbx = pushbx + tempcx; - tempcx <<= 1; - tempcx += tempbx; + tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; + tempbx = pushbx + tempcx; + tempcx <<= 1; + tempcx += tempbx; bridgeadd = 12; @@ -6301,7 +6116,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, bridgeadd = 16; if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { if((SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { if(resinfo == SIS_RI_1280x1024) { @@ -6319,7 +6134,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->UseCustomMode) { + if(SiS_Pr->UseCustomMode) { tempbx = SiS_Pr->CHSyncStart + bridgeadd; tempcx = SiS_Pr->CHSyncEnd + bridgeadd; tempax = SiS_Pr->SiS_VGAHT; @@ -6341,22 +6156,22 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; } - tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */ - tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */ + tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */ + tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */ tempcx &= 0x00FF; tempcx |= (tempbx & 0xFF00); - tempbx += bridgeadd; - tempcx += bridgeadd; + tempbx += bridgeadd; + tempcx += bridgeadd; tempax = SiS_Pr->SiS_VGAHT; if(modeflag & HalfDCLK) tempax >>= 1; tempax--; if(tempcx > tempax) tempcx = tempax; - } + } - if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { - tempbx = 1040; - tempcx = 1044; /* HWCursor bug! */ - } + if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSet525p1024)) { + tempbx = 1040; + tempcx = 1044; /* HWCursor bug! */ + } } @@ -6372,18 +6187,18 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempcx = SiS_Pr->SiS_VGAVT - 1; temp = tempcx & 0x00FF; - if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->ChipType < SIS_661) { if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) { temp--; } - } + } } else { - temp--; - } - } else if(HwInfo->jChipType >= SIS_315H) { + temp--; + } + } else if(SiS_Pr->ChipType >= SIS_315H) { temp--; } } @@ -6395,9 +6210,9 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, temp = ((tempbx >> 5) & 0x38) | ((tempcx >> 8) & 0x07); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow */ - if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { - tempbx++; - tempax = tempbx; + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) { + tempbx++; + tempax = tempbx; tempcx++; tempcx -= tempax; tempcx >>= 2; @@ -6407,8 +6222,8 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempcx += tempbx; tempcx++; } else { - tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */ - tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */ + tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */ + tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */ } if(SiS_Pr->SiS_VBType & VB_SISVB) { @@ -6416,7 +6231,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbx = SiS_Pr->CVSyncStart; tempcx = SiS_Pr->CVSyncEnd; } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { unsigned char cr8, cr7, cr13; if(SiS_Pr->UseCustomMode) { cr8 = SiS_Pr->CCRT1CRTC[8]; @@ -6429,11 +6244,11 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; } - tempbx = cr8; - if(cr7 & 0x04) tempbx |= 0x0100; - if(cr7 & 0x80) tempbx |= 0x0200; - if(cr13 & 0x08) tempbx |= 0x0400; - } + tempbx = cr8; + if(cr7 & 0x04) tempbx |= 0x0100; + if(cr7 & 0x80) tempbx |= 0x0200; + if(cr13 & 0x08) tempbx |= 0x0400; + } } SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,tempbx); /* CRT2 Vertical Retrace Start */ @@ -6442,13 +6257,13 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* 3. Panel delay compensation */ - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { #ifdef SIS300 /* ---------- 300 series -------------- */ if(SiS_Pr->SiS_VBType & VB_SISVB) { temp = 0x20; - if(HwInfo->jChipType == SIS_300) { + if(SiS_Pr->ChipType == SIS_300) { temp = 0x10; if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) temp = 0x2c; if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20; @@ -6460,24 +6275,23 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) temp = 0x2c; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; - else temp = 0x20; - } + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; + else temp = 0x20; + } if(SiS_Pr->SiS_UseROM) { if(ROMAddr[0x220] & 0x80) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) - temp = ROMAddr[0x221]; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) + temp = ROMAddr[0x221]; else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = ROMAddr[0x222]; else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = ROMAddr[0x223]; else temp = ROMAddr[0x224]; - temp &= 0x3c; } } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c; + if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC; } } else { @@ -6487,15 +6301,17 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } if(SiS_Pr->SiS_UseROM) { if(ROMAddr[0x220] & 0x80) { - temp = ROMAddr[0x220] & 0x3c; + temp = ROMAddr[0x220]; } } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c; + if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC; } - } + } - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ + temp &= 0x3c; + + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ #endif /* SIS300 */ @@ -6503,16 +6319,16 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #ifdef SIS315H /* --------------- 315/330 series ---------------*/ - if(HwInfo->jChipType < SIS_661) { + if(SiS_Pr->ChipType < SIS_661) { if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if(HwInfo->jChipType == SIS_740) temp = 0x03; - else temp = 0x00; + if(SiS_Pr->ChipType == SIS_740) temp = 0x03; + else temp = 0x00; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a; tempbl = 0xF0; - if(HwInfo->jChipType == SIS_650) { + if(SiS_Pr->ChipType == SIS_650) { if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F; } @@ -6531,10 +6347,10 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } /* < 661 */ - tempax = 0; - if(modeflag & DoubleScanMode) tempax |= 0x80; - if(modeflag & HalfDCLK) tempax |= 0x40; - SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); + tempax = 0; + if(modeflag & DoubleScanMode) tempax |= 0x80; + if(modeflag & HalfDCLK) tempax |= 0x40; + SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); #endif /* SIS315H */ @@ -6544,21 +6360,21 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBType & VB_SISVB) { if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - /* For 301BDH with LCD, we set up the Panel Link */ - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + /* For 301BDH with LCD, we set up the Panel Link */ + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } } else { - if(HwInfo->jChipType < SIS_315H) { - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + if(SiS_Pr->ChipType < SIS_315H) { + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } else { if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex); - } + if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex,RefreshRateTableIndex); + } } else { - SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex); + SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex,RefreshRateTableIndex); } } } @@ -6569,11 +6385,11 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ #ifdef SIS315H -static UCHAR * -SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo) +static unsigned char * +SiS_GetGroup2CLVXPtr(struct SiS_Private *SiS_Pr, int tabletype) { - const UCHAR *tableptr = NULL; - USHORT a, b, p = 0; + const unsigned char *tableptr = NULL; + unsigned short a, b, p = 0; a = SiS_Pr->SiS_VGAHDE; b = SiS_Pr->SiS_HDE; @@ -6606,25 +6422,25 @@ SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo) if((tableptr[p] | tableptr[p+1] << 8) == 0xffff) p -= 0x42; } p += 2; - return((UCHAR *)&tableptr[p]); + return ((unsigned char *)&tableptr[p]); } static void -SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetGroup2_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - UCHAR *tableptr; + unsigned char *tableptr; + unsigned char temp; int i, j; - UCHAR temp; - if(!(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV))) return; + if(!(SiS_Pr->SiS_VBType & VB_SISTAP4SCALER)) return; - tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0, HwInfo); + tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0); for(i = 0x80, j = 0; i <= 0xbf; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); } if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1, HwInfo); + tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1); for(i = 0xc0, j = 0; i <= 0xff; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); } @@ -6635,12 +6451,12 @@ SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } static BOOLEAN -SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, - USHORT RefreshRateTableIndex,USHORT *CRT2Index, - USHORT *ResIndex,PSIS_HW_INFO HwInfo) +SiS_GetCRT2Part2Ptr(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex,unsigned short *CRT2Index, + unsigned short *ResIndex) { - if(HwInfo->jChipType < SIS_315H) return FALSE; + if(SiS_Pr->ChipType < SIS_315H) return FALSE; if(ModeNo <= 0x13) (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; @@ -6661,82 +6477,79 @@ SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, if(SiS_Pr->SiS_SetFlag & LCDVESATiming) (*CRT2Index) = 206; } } - return(((*CRT2Index) != 0)); + return (((*CRT2Index) != 0)); } #endif #ifdef SIS300 static void -SiS_Group2LCDSpecial(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT crt2crtc) +SiS_Group2LCDSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short crt2crtc) { - USHORT tempcx; - const UCHAR atable[] = { + unsigned short tempcx; + static const unsigned char atable[] = { 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 }; if(!SiS_Pr->UseCustomMode) { - if( ( ( (HwInfo->jChipType == SIS_630) || - (HwInfo->jChipType == SIS_730) ) && - (HwInfo->jChipRevision > 2) ) && - (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) && - (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && - (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { - if(ModeNo == 0x13) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6); - } else { - if((crt2crtc & 0x3F) == 4) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2); - } - } + if( ( ( (SiS_Pr->ChipType == SIS_630) || + (SiS_Pr->ChipType == SIS_730) ) && + (SiS_Pr->ChipRevision > 2) ) && + (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) && + (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && + (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { + if(ModeNo == 0x13) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6); + } else if((crt2crtc & 0x3F) == 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2); + } } - if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { - crt2crtc &= 0x1f; - tempcx = 0; - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - tempcx += 7; - } - } - tempcx += crt2crtc; - if(crt2crtc >= 4) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff); - } + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { + crt2crtc &= 0x1f; + tempcx = 0; + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + tempcx += 7; + } + } + tempcx += crt2crtc; + if(crt2crtc >= 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff); + } - if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - if(crt2crtc == 4) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28); - } - } - } - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18); - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); - } + if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + if(crt2crtc == 4) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28); + } + } + } + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); + } } } } /* For ECS A907. Highly preliminary. */ static void -SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeIdIndex, USHORT RefreshRateTableIndex, - USHORT ModeNo) +SiS_Set300Part2Regs(struct SiS_Private *SiS_Pr, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, + unsigned short ModeNo) { - USHORT crt2crtc, resindex; - int i,j; - const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; + const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL; + unsigned short crt2crtc, resindex; + int i, j; - if(HwInfo->jChipType != SIS_300) return; - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(SiS_Pr->ChipType != SIS_300) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) return; if(SiS_Pr->UseCustomMode) return; if(ModeNo <= 0x13) { @@ -6758,13 +6571,13 @@ SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } for(j = 0x1c; j <= 0x1d; i++, j++ ) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } for(j = 0x1f; j <= 0x21; i++, j++ ) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); } SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); @@ -6772,15 +6585,15 @@ SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, #endif static void -SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) +SiS_SetTVSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) return; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) return; if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) return; if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { - const UCHAR specialtv[] = { + const unsigned char specialtv[] = { 0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53, 0x13,0x40,0x34,0xf4,0x63,0xbb,0xcc,0x7a, 0x58,0xe4,0x73,0xda,0x13 @@ -6813,16 +6626,16 @@ SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) } static void -SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) +SiS_SetGroup2_Tail(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - USHORT temp; + unsigned short temp; if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { if(SiS_Pr->SiS_VGAVDE == 525) { temp = 0xc3; if(SiS_Pr->SiS_ModeType <= ModeVGA) { temp++; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp += 2; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) temp += 2; } SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3); @@ -6830,7 +6643,7 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) temp = 0x4d; if(SiS_Pr->SiS_ModeType <= ModeVGA) { temp++; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) temp++; } SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); } @@ -6838,7 +6651,7 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) { - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(SiS_Pr->SiS_VBType & VB_SIS30xB) { SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x1a,0x03); /* Not always for LV, see SetGrp2 */ } @@ -6872,17 +6685,17 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) } static void -SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT RefreshRateTableIndex, - PSIS_HW_INFO HwInfo) -{ - USHORT i, j, tempax, tempbx, tempcx, tempch, tempcl, temp; - USHORT push2, modeflag, crt2crtc, bridgeoffset; - ULONG longtemp; - const UCHAR *PhasePoint; - const UCHAR *TimingPoint; +SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned short i, j, tempax, tempbx, tempcx, tempch, tempcl, temp; + unsigned short push2, modeflag, crt2crtc, bridgeoffset; + unsigned int longtemp, PhaseIndex; + BOOLEAN newtvphase; + const unsigned char *TimingPoint; #ifdef SIS315H - USHORT resindex, CRT2Index; - const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; + unsigned short resindex, CRT2Index; + const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; #endif @@ -6908,9 +6721,16 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp); - PhasePoint = SiS_Pr->SiS_PALPhase; + PhaseIndex = 0x01; /* SiS_PALPhase */ TimingPoint = SiS_Pr->SiS_PALTiming; + newtvphase = FALSE; + if( (SiS_Pr->SiS_VBType & VB_SIS30xBLV) && + ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || + (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { + newtvphase = TRUE; + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { TimingPoint = SiS_Pr->SiS_HiTVExtTiming; @@ -6918,82 +6738,54 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr TimingPoint = SiS_Pr->SiS_HiTVSt2Timing; if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; -#if 0 - if(!(modeflag & Charx8Dot)) TimingPoint = SiS_Pr->SiS_HiTVTextTiming; -#endif } } } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) TimingPoint = &SiS_YPbPrTable[2][0]; - else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) TimingPoint = &SiS_YPbPrTable[1][0]; - else TimingPoint = &SiS_YPbPrTable[0][0]; + i = 0; + if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) i = 2; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) i = 1; + + TimingPoint = &SiS_YPbPrTable[i][0]; - PhasePoint = SiS_Pr->SiS_NTSCPhase; + PhaseIndex = 0x00; /* SiS_NTSCPhase */ } else if(SiS_Pr->SiS_TVMode & TVSetPAL) { - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALPhase2; - } + if(newtvphase) PhaseIndex = 0x09; /* SiS_PALPhase2 */ } else { TimingPoint = SiS_Pr->SiS_NTSCTiming; - PhasePoint = SiS_Pr->SiS_NTSCPhase; - if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - PhasePoint = SiS_Pr->SiS_PALPhase; - } - - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_NTSCPhase2; - if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - PhasePoint = SiS_Pr->SiS_PALPhase2; - } - } - - } + PhaseIndex = (SiS_Pr->SiS_TVMode & TVSetNTSCJ) ? 0x01 : 0x00; /* SiS_PALPhase : SiS_NTSCPhase */ + if(newtvphase) PhaseIndex += 8; /* SiS_PALPhase2 : SiS_NTSCPhase2 */ - if(SiS_Pr->SiS_TVMode & TVSetPALM) { - PhasePoint = SiS_Pr->SiS_PALMPhase; - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALMPhase2; - } } - if(SiS_Pr->SiS_TVMode & TVSetPALN) { - PhasePoint = SiS_Pr->SiS_PALNPhase; - if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && - ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || - (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) { - PhasePoint = SiS_Pr->SiS_PALNPhase2; - } + if(SiS_Pr->SiS_TVMode & (TVSetPALM | TVSetPALN)) { + PhaseIndex = (SiS_Pr->SiS_TVMode & TVSetPALM) ? 0x02 : 0x03; /* SiS_PALMPhase : SiS_PALNPhase */ + if(newtvphase) PhaseIndex += 8; /* SiS_PALMPhase2 : SiS_PALNPhase2 */ } if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { - PhasePoint = SiS_Pr->SiS_SpecialPhase; if(SiS_Pr->SiS_TVMode & TVSetPALM) { - PhasePoint = SiS_Pr->SiS_SpecialPhaseM; + PhaseIndex = 0x05; /* SiS_SpecialPhaseM */ } else if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - PhasePoint = SiS_Pr->SiS_SpecialPhaseJ; + PhaseIndex = 0x11; /* SiS_SpecialPhaseJ */ + } else { + PhaseIndex = 0x10; /* SiS_SpecialPhase */ } } - for(i=0x31, j=0; i<=0x34; i++, j++) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,i,PhasePoint[j]); + for(i = 0x31, j = 0; i <= 0x34; i++, j++) { + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_TVPhase[(PhaseIndex * 4) + j]); } - for(i=0x01, j=0; i<=0x2D; i++, j++) { + for(i = 0x01, j = 0; i <= 0x2D; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); } - for(i=0x39; i<=0x45; i++, j++) { + for(i = 0x39; i <= 0x45; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); } @@ -7010,28 +6802,32 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE); - if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950; - else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; - else tempax = 440; /* NTSC, YPbPr 525, 750 */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950; + else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempax = 680; + else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; + else tempax = 440; /* NTSC, YPbPr 525 */ - if( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) && (SiS_Pr->SiS_VDE <= tempax) ) || + if( ((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && (SiS_Pr->SiS_VDE <= tempax)) || ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) && ((SiS_Pr->SiS_VGAHDE == 1024) || (SiS_Pr->SiS_VDE <= tempax)) ) ) { tempax -= SiS_Pr->SiS_VDE; - tempax >>= 2; + tempax >>= 1; + if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) { + tempax >>= 1; + } tempax &= 0x00ff; - temp = tempax + (USHORT)TimingPoint[0]; + temp = tempax + (unsigned short)TimingPoint[0]; SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); - temp = tempax + (USHORT)TimingPoint[1]; + temp = tempax + (unsigned short)TimingPoint[1]; SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) { if(SiS_Pr->SiS_TVMode & TVSetPAL) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); /* 19 */ - SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); /* 52 */ + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); + SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); } else { SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1d); @@ -7041,14 +6837,14 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr } tempcx = SiS_Pr->SiS_HT; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; tempcx--; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx--; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) tempcx--; SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,tempcx); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,((tempcx >> 8) & 0x0f)); tempcx = SiS_Pr->SiS_HT >> 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; tempcx += 7; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,((tempcx << 4) & 0xf0)); @@ -7075,7 +6871,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,((tempcx << 4) & 0xf0)); tempcx = SiS_Pr->SiS_HT >> 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1; j += 2; tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8)); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,((tempcx << 4) & 0xf0)); @@ -7094,7 +6890,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr } else if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) { tempbx >>= 1; - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { if((ModeNo <= 0x13) && (crt2crtc == 1)) tempbx++; } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { @@ -7123,23 +6919,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr } SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp); - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISPART4OVERFLOW) { SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xdf,((tempbx & 0x0400) >> 5)); } -#if 0 - /* TEST qqqq */ - if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { - for(i=0x01, j=0; i<=0x2D; i++, j++) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); - } - for(i=0x39; i<=0x45; i++, j++) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); - } - } -#endif - - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { tempbx = SiS_Pr->SiS_VDE; if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) ) { @@ -7150,7 +6934,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,tempbx); - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISPART4OVERFLOW) { SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xbf,((tempbx & 0x0400) >> 4)); } } @@ -7165,14 +6949,17 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr tempch = tempcl = 0x01; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - if(SiS_Pr->SiS_VGAHDE >= 1024) { - if((!(modeflag & HalfDCLK)) || (HwInfo->jChipType < SIS_315H)) { - tempch = 0x19; + if(SiS_Pr->SiS_VGAHDE >= 960) { + if((!(modeflag & HalfDCLK)) || (SiS_Pr->ChipType < SIS_315H)) { tempcl = 0x20; - if(SiS_Pr->SiS_VGAHDE >= 1280) { - tempch = 0x14; + if(SiS_Pr->SiS_VGAHDE >= 1280) { + tempch = 20; tempbx &= ~0x20; - } + } else if(SiS_Pr->SiS_VGAHDE >= 1024) { + tempch = 25; + } else { + tempch = 25; /* OK */ + } } } } @@ -7180,7 +6967,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr if(!(tempbx & 0x20)) { if(modeflag & HalfDCLK) tempcl <<= 1; longtemp = ((SiS_Pr->SiS_VGAHDE * tempch) / tempcl) << 13; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) longtemp <<= 3; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) longtemp <<= 3; tempax = longtemp / SiS_Pr->SiS_HDE; if(longtemp % SiS_Pr->SiS_HDE) tempax++; tempbx |= ((tempax >> 8) & 0x1F); @@ -7190,7 +6977,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,tempbx); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { tempcx &= 0x07; if(tempbx & 0x20) tempcx = 0; @@ -7219,7 +7006,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetTVSpecial(SiS_Pr, ModeNo); - if(SiS_Pr->SiS_VBType & VB_SIS301C) { + if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { temp = 0; if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8; SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xf7,temp); @@ -7246,7 +7033,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr /* From here: Part2 LCD setup */ tempbx = SiS_Pr->SiS_HDE; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; tempbx--; /* RHACTE = HDE - 1 */ SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,tempbx); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,((tempbx >> 4) & 0xf0)); @@ -7256,10 +7043,8 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr if(SiS_Pr->SiS_ModeType == ModeEGA) { if(SiS_Pr->SiS_VGAHDE >= 1024) { temp = 0x02; - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { - temp = 0x01; - } + if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { + temp = 0x01; } } } @@ -7289,11 +7074,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr #ifdef SIS315H if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, - &CRT2Index, &resindex, HwInfo)) { + &CRT2Index, &resindex)) { switch(CRT2Index) { + case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3; break; + default: case 200: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; - case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3; break; - default: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break; } SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); @@ -7312,7 +7097,6 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr SiS_SetGroup2_Tail(SiS_Pr, ModeNo); - } else { #endif @@ -7349,9 +7133,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */ SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */ @@ -7401,9 +7187,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr tempbx = SiS_Pr->CVSyncStart; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */ @@ -7416,26 +7204,30 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr temp |= (SiS_Pr->CVSyncEnd & 0x0f); } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f)); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); #ifdef SIS300 - SiS_Group2LCDSpecial(SiS_Pr, HwInfo, ModeNo, crt2crtc); + SiS_Group2LCDSpecial(SiS_Pr, ModeNo, crt2crtc); #endif bridgeoffset = 7; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) bridgeoffset += 2; - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) bridgeoffset++; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) bridgeoffset++; + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) bridgeoffset += 2; + if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) bridgeoffset += 2; /* OK for Averatec 1280x800 (301C) */ + if(SiS_IsDualLink(SiS_Pr)) bridgeoffset++; + else if(SiS_Pr->SiS_VBType & VB_SIS302LV) bridgeoffset++; /* OK for Asus A4L 1280x800 */ + /* Higher bridgeoffset shifts to the LEFT */ temp = 0; if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) { - temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); - if(SiS_IsDualLink(SiS_Pr, HwInfo)) temp >>= 1; + temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); + if(SiS_IsDualLink(SiS_Pr)) temp >>= 1; } } temp += bridgeoffset; @@ -7450,15 +7242,17 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr tempbx = SiS_Pr->PanelXRes - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); } } - if(SiS_IsDualLink(SiS_Pr, HwInfo)) { + if(SiS_IsDualLink(SiS_Pr)) { tempcx >>= 1; tempbx >>= 1; tempax >>= 1; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx); #endif +#endif tempbx += bridgeoffset; @@ -7480,13 +7274,16 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr if(SiS_Pr->UseCustomMode) { tempbx = SiS_Pr->CHSyncStart; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(modeflag & HalfDCLK) tempbx <<= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; tempbx += bridgeoffset; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */ SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0)); @@ -7501,20 +7298,23 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr if(SiS_Pr->UseCustomMode) { tempbx = SiS_Pr->CHSyncEnd; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(modeflag & HalfDCLK) tempbx <<= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; tempbx += bridgeoffset; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx); #endif +#endif SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */ SiS_SetGroup2_Tail(SiS_Pr, ModeNo); #ifdef SIS300 - SiS_Set300Part2Regs(SiS_Pr, HwInfo, ModeIdIndex, RefreshRateTableIndex, ModeNo); + SiS_Set300Part2Regs(SiS_Pr, ModeIdIndex, RefreshRateTableIndex, ModeNo); #endif #ifdef SIS315H } /* CRT2-LCD from table */ @@ -7526,11 +7326,10 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr /*********************************************/ static void -SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_SetGroup3(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT i; - const UCHAR *tempdi; + unsigned short i; + const unsigned char *tempdi; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; @@ -7570,7 +7369,7 @@ SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, for(i=0; i<=0x3E; i++) { SiS_SetReg(SiS_Pr->SiS_Part3Port,i,tempdi[i]); } - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) { if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { SiS_SetReg(SiS_Pr->SiS_Part3Port,0x28,0x3f); } @@ -7587,35 +7386,43 @@ SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ #ifdef SIS315H +#if 0 static void -SiS_ShiftXPos(SiS_Private *SiS_Pr, int shift) +SiS_ShiftXPos(struct SiS_Private *SiS_Pr, int shift) { - USHORT temp, temp1, temp2; + unsigned short temp, temp1, temp2; temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x1f); temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x20); - temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); + temp = (unsigned short)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,temp); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0f,((temp >> 4) & 0xf0)); temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x2b) & 0x0f; - temp = (USHORT)((int)(temp) + shift); + temp = (unsigned short)((int)(temp) + shift); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2b,0xf0,(temp & 0x0f)); temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x42); - temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); + temp = (unsigned short)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,temp); SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x42,0x0f,((temp >> 4) & 0xf0)); } +#endif static void -SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex) +SiS_SetGroup4_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT temp, temp1, resinfo = 0; + unsigned short temp, temp1, resinfo = 0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; - if(!(SiS_Pr->SiS_VBType & VB_SIS301C)) return; + if(!(SiS_Pr->SiS_VBType & VB_SIS30xCLV)) return; if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750))) return; + if(SiS_Pr->ChipType >= XGI_20) return; + + if((SiS_Pr->ChipType >= SIS_661) && (SiS_Pr->SiS_ROMNew)) { + if(!(ROMAddr[0x61] & 0x04)) return; + } + if(ModeNo > 0x13) { resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } @@ -7625,7 +7432,7 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, if(!(temp & 0x01)) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3a,0xdf); SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xfc); - if((HwInfo->jChipType < SIS_661) && (!(SiS_Pr->SiS_ROMNew))) { + if((SiS_Pr->ChipType < SIS_661) && (!(SiS_Pr->SiS_ROMNew))) { SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xf8); } SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0xfb); @@ -7633,24 +7440,29 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp = 0x0002; else if(SiS_Pr->SiS_TVMode & TVSetHiVision) temp = 0x0400; else temp = 0x0402; - if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { + if((SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { temp1 = 0; if(SiS_Pr->SiS_TVMode & TVAspect43) temp1 = 4; SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0f,0xfb,temp1); if(SiS_Pr->SiS_TVMode & TVAspect43LB) temp |= 0x01; SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0x7c,(temp & 0xff)); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); + if(ModeNo > 0x13) { + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x39,0xfd); + } } else { temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x3b) & 0x03; if(temp1 == 0x01) temp |= 0x01; if(temp1 == 0x03) temp |= 0x04; /* ? why not 0x10? */ SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xf8,(temp & 0xff)); - } - SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); - if(ModeNo > 0x13) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3b,0xfd); + SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); + if(ModeNo > 0x13) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3b,0xfd); + } } - if(HwInfo->jChipType >= SIS_661) { /* ? */ +#if 0 + if(SiS_Pr->ChipType >= SIS_661) { /* ? */ if(SiS_Pr->SiS_TVMode & TVAspect43) { if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { if(resinfo == SIS_RI_1024x768) { @@ -7663,29 +7475,30 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } } } +#endif + } + } #endif static void -SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetCRT2VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT vclkindex; - USHORT temp, reg1, reg2; + unsigned short vclkindex, temp, reg1, reg2; if(SiS_Pr->UseCustomMode) { reg1 = SiS_Pr->CSR2B; reg2 = SiS_Pr->CSR2C; } else { - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, - HwInfo); + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); reg1 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; reg2 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { - if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { + if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSet525p1024)) { SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x57); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,0x46); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1f,0xf6); @@ -7705,11 +7518,35 @@ SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, } static void -SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetDualLinkEtc(struct SiS_Private *SiS_Pr) +{ + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) { + if((SiS_CRT2IsLCD(SiS_Pr)) || + (SiS_IsVAMode(SiS_Pr))) { + if(SiS_Pr->SiS_LCDInfo & LCDDualLink) { + SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); + } else { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20); + } + } + } + } + if(SiS_Pr->SiS_VBType & VB_SISEMI) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); +#ifdef SET_EMI + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); +#endif + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); + } +} + +static void +SiS_SetGroup4(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - USHORT tempax,tempcx,tempbx,modeflag,temp,resinfo; - ULONG tempebx,tempeax,templong; + unsigned short tempax, tempcx, tempbx, modeflag, temp, resinfo; + unsigned int tempebx, tempeax, templong; if(ModeNo <= 0x13) { modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; @@ -7722,38 +7559,24 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; } - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); - } + if(SiS_Pr->ChipType >= SIS_315H) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { + if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { + SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); + } } } - if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV)) { + if(SiS_Pr->SiS_VBType & (VB_SIS30xCLV | VB_SIS302LV)) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); } } - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { - if(SiS_IsDualLink(SiS_Pr, HwInfo)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20); - } - - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); -#ifdef SET_EMI - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); -#endif - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); - } - } - return; + SiS_SetDualLinkEtc(SiS_Pr); + return; } } @@ -7777,16 +7600,16 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp); tempbx = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempbx >>= 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(modeflag & HalfDCLK) tempbx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { temp = 0; if(tempbx > 800) temp = 0x60; } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { temp = 0; - if(tempbx == 1024) temp = 0xA0; - else if(tempbx > 1024) temp = 0xC0; + if(tempbx > 1024) temp = 0xC0; + else if(tempbx >= 960) temp = 0xA0; } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { temp = 0; if(tempbx >= 1280) temp = 0x40; @@ -7796,8 +7619,13 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(tempbx >= 1024) temp = 0xA0; } + temp |= SiS_Pr->Init_P4_0E; + if(SiS_Pr->SiS_VBType & VB_SIS301) { - if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) temp |= 0x0A; + if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { + temp &= 0xf0; + temp |= 0x0A; + } } SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp); @@ -7824,15 +7652,15 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempeax /= tempebx; if(templong) tempeax++; - temp = (USHORT)(tempeax & 0x000000FF); + temp = (unsigned short)(tempeax & 0x000000FF); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp); - temp = (USHORT)((tempeax & 0x0000FF00) >> 8); + temp = (unsigned short)((tempeax & 0x0000FF00) >> 8); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp); - temp = (USHORT)((tempeax >> 12) & 0x70); /* sic! */ + temp = (unsigned short)((tempeax >> 12) & 0x70); /* sic! */ temp |= (tempcx & 0x4F); SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28); @@ -7840,23 +7668,26 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, tempbx = 0; if(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p)) tempbx = 0x08; tempax = SiS_Pr->SiS_VGAHDE; - if(modeflag & HalfDCLK) tempax >>= 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempax >>= 1; + if(modeflag & HalfDCLK) tempax >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempax >>= 1; if(tempax > 800) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { tempax -= 800; - } else { /* 651+301C: Only if TVNoHiviNoYPbPr */ + } else { tempbx = 0x08; - if(tempax == 1024) tempax *= 25; - else tempax *= 20; + if(tempax == 960) tempax *= 25; /* Correct */ + else if(tempax == 1024) tempax *= 25; + else tempax *= 20; temp = tempax % 32; tempax /= 32; if(temp) tempax++; tempax++; - if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) || - (SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) { - if(resinfo == SIS_RI_1024x768) { - /* Otherwise white line at right edge */ + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(resinfo == SIS_RI_1024x768 || + resinfo == SIS_RI_1024x576 || + resinfo == SIS_RI_1280x1024 || + resinfo == SIS_RI_1280x720) { + /* Otherwise white line or garbage at right edge */ tempax = (tempax & 0xff00) | 0x20; } } @@ -7868,7 +7699,7 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp); temp = 0x0036; tempbx = 0xD0; - if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { temp = 0x0026; tempbx = 0xC0; /* See En/DisableBridge() */ } if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { @@ -7884,36 +7715,24 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,tempbx,temp); tempbx = SiS_Pr->SiS_HT >> 1; - if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; + if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1; tempbx -= 2; SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,tempbx); temp = (tempbx >> 5) & 0x38; SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); /* LCD-too-dark-error-source, see FinalizeLCD() */ } - if(HwInfo->jChipType >= SIS_315H) { - if(SiS_IsDualLink(SiS_Pr, HwInfo)) { - SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c); - } else { - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20); - } - } - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); -#ifdef SET_EMI - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); -#endif - SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); - } } + SiS_SetDualLinkEtc(SiS_Pr); + } /* 301B */ - SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } /*********************************************/ @@ -7921,8 +7740,7 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_SetGroup5(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; @@ -7930,7 +7748,7 @@ SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_ModeType == ModeVGA) { if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))) { SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); - SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex); } } } @@ -7939,116 +7757,156 @@ SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /* MODIFY CRT1 GROUP FOR SLAVE MODE */ /*********************************************/ -static void -SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) -{ - USHORT tempah,i,modeflag,j; - USHORT ResIndex,DisplayType; - const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL; +static BOOLEAN +SiS_GetLVDSCRT1Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex, unsigned short *ResIndex, + unsigned short *DisplayType) + { + unsigned short modeflag = 0; + BOOLEAN checkhd = TRUE; - if(ModeNo <= 0x13) modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; - else modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + /* Pass 1:1 not supported here */ + + if(ModeNo <= 0x13) { + modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + } else { + modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + } + + (*ResIndex) &= 0x3F; + + if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { + + (*DisplayType) = 80; + if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) { + (*DisplayType) = 82; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 84; + } + } + if((*DisplayType) != 84) { + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++; + } + + } else { + + (*DisplayType = 0); + switch(SiS_Pr->SiS_LCDResInfo) { + case Panel_320x240_1: (*DisplayType) = 50; + checkhd = FALSE; + break; + case Panel_320x240_2: (*DisplayType) = 14; + break; + case Panel_320x240_3: (*DisplayType) = 18; + break; + case Panel_640x480: (*DisplayType) = 10; + break; + case Panel_1024x600: (*DisplayType) = 26; + break; + default: return TRUE; + } + + if(checkhd) { + if(modeflag & HalfDCLK) (*DisplayType)++; + } + + if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) { + if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2; + } + + } + + return TRUE; +} + +static void +SiS_ModCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) +{ + unsigned short tempah, i, modeflag, j, ResIndex, DisplayType; + const struct SiS_LVDSCRT1Data *LVDSCRT1Ptr=NULL; + static const unsigned short CRIdx[] = { + 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x10, 0x11, 0x15, 0x16 + }; if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || - (SiS_Pr->SiS_CustomT == CUT_PANEL848)) + (SiS_Pr->SiS_CustomT == CUT_PANEL848) || + (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) return; + if(SiS_Pr->SiS_IF_DEF_LVDS) { + if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return; + } + } else if(SiS_Pr->SiS_VBType & VB_SISVB) { + if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return; + } else return; + + if(SiS_Pr->SiS_LCDInfo & LCDPass11) return; + + if(SiS_Pr->ChipType < SIS_315H) { + if(SiS_Pr->SiS_SetFlag & SetDOSMode) return; + } + if(!(SiS_GetLVDSCRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, &ResIndex, &DisplayType))) { return; } - if(HwInfo->jChipType < SIS_315H) { - if(SiS_Pr->SiS_SetFlag & SetDOSMode) return; + switch(DisplayType) { + case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_1; break; /* xSTN */ + case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_2; break; /* xSTN */ + case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_2_H; break; /* xSTN */ + case 18: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_3; break; /* xSTN */ + case 19: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_3_H; break; /* xSTN */ + case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break; + case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break; +#if 0 /* Works better with calculated numbers */ + case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break; + case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break; + case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break; + case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break; +#endif + case 80: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break; + case 81: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break; + case 82: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break; + case 83: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; + case 84: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break; } - switch(DisplayType) { - case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break; - case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break; - case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break; - case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break; - case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; - case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break; - case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break; - case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break; - case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break; - case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break; - case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break; - case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2_H; break; - case 12: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1; break; - case 13: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H; break; - case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1; break; - case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1_H; break; - case 16: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2; break; - case 17: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2_H; break; - case 18: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break; - case 19: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break; - case 20: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break; - case 21: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; - case 22: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x480_1; break; /* FSTN */ - case 23: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break; - case 24: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break; - case 25: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break; - case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break; - case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1; break; - case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1_H; break; - case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2; break; - case 30: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2_H; break; - case 36: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1; break; - case 37: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1_H; break; - case 38: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2; break; - case 39: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2_H; break; - case 40: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1; break; - case 41: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1_H; break; - case 42: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2; break; - case 43: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2_H; break; - case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break; - case 51: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break; - case 52: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2; break; - case 53: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2_H; break; - case 54: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3; break; - case 55: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3_H; break; - case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break; - default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; - } - - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); - - tempah = (LVDSCRT1Ptr + ResIndex)->CR[0]; - SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,tempah); - - for(i=0x02,j=1;i<=0x05;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x06,j=5;i<=0x07;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x10,j=7;i<=0x11;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x15,j=9;i<=0x16;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah); - } - for(i=0x0A,j=11;i<=0x0C;i++,j++){ - tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; - SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah); - } - - tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; - tempah &= 0xE0; - SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); - - tempah = (LVDSCRT1Ptr + ResIndex)->CR[14]; - tempah &= 0x01; - tempah <<= 5; - if(modeflag & DoubleScanMode) tempah |= 0x080; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); + if(LVDSCRT1Ptr) { + + SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); + + for(i = 0; i <= 10; i++) { + tempah = (LVDSCRT1Ptr + ResIndex)->CR[i]; + SiS_SetReg(SiS_Pr->SiS_P3d4,CRIdx[i],tempah); + } + + for(i = 0x0A, j = 11; i <= 0x0C; i++, j++) { + tempah = (LVDSCRT1Ptr + ResIndex)->CR[j]; + SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah); + } + + tempah = (LVDSCRT1Ptr + ResIndex)->CR[14] & 0xE0; + SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah); + + if(ModeNo <= 0x13) modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; + else modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; + + tempah = ((LVDSCRT1Ptr + ResIndex)->CR[14] & 0x01) << 5; + if(modeflag & DoubleScanMode) tempah |= 0x80; + SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah); + + } else { + + SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex); + + } } /*********************************************/ @@ -8056,24 +7914,24 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) +SiS_SetCRT2ECLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT clkbase, vclkindex=0; - UCHAR sr2b, sr2c; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short clkbase, vclkindex = 0; + unsigned char sr2b, sr2c; - if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) || (SiS_Pr->SiS_LCDInfo & LCDPass11)) { - SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); - if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK & 0x3f) == 2) { - RefreshRateTableIndex--; - } - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, - RefreshRateTableIndex, HwInfo); - SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; + if(SiS_Pr->SiS_LCDInfo & LCDPass11) { + SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); + if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK == 2) { + RefreshRateTableIndex--; + } + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex); + SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; } else { - vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, - RefreshRateTableIndex, HwInfo); + vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, + RefreshRateTableIndex); } sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; @@ -8082,7 +7940,7 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { if(SiS_Pr->SiS_UseROM) { if(ROMAddr[0x220] & 0x01) { - sr2b = ROMAddr[0x227]; + sr2b = ROMAddr[0x227]; sr2c = ROMAddr[0x228]; } } @@ -8091,7 +7949,7 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, clkbase = 0x02B; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { - clkbase += 3; + clkbase += 3; } } @@ -8111,368 +7969,331 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, /*********************************************/ static void -SiS_SetCHTVReg(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - USHORT RefreshRateTableIndex) +SiS_SetCHTVReg(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefreshRateTableIndex) { -#if defined(SIS300) || defined(SIS315H) - USHORT temp, tempbx; -#endif - USHORT tempcl; - USHORT TVType, resindex; - const SiS_CHTVRegDataStruct *CHTVRegData = NULL; + unsigned short TVType, resindex; + const struct SiS_CHTVRegData *CHTVRegData = NULL; - if(ModeNo <= 0x13) - tempcl = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; - else - tempcl = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; + if(ModeNo <= 0x13) + resindex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; + else + resindex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; - TVType = 0; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - TVType += 2; - if(SiS_Pr->SiS_ModeType > ModeVGA) { - if(SiS_Pr->SiS_CHSOverScan) TVType = 8; - } - if(SiS_Pr->SiS_TVMode & TVSetPALM) { - TVType = 4; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; - } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { - TVType = 6; - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; - } - } - switch(TVType) { - case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break; - case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break; - case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break; - case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; - case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break; - case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break; - case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break; - case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break; - case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break; - default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; - } - resindex = tempcl & 0x3F; + resindex &= 0x3F; + + TVType = 0; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + TVType += 2; + if(SiS_Pr->SiS_ModeType > ModeVGA) { + if(SiS_Pr->SiS_CHSOverScan) TVType = 8; + } + if(SiS_Pr->SiS_TVMode & TVSetPALM) { + TVType = 4; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { + TVType = 6; + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; + } + } + + switch(TVType) { + case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break; + case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break; + case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break; + case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; + case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break; + case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break; + case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break; + case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break; + case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break; + default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; + } - if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { + + if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { #ifdef SIS300 - /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ + /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ - /* We don't support modes >800x600 */ - if (resindex > 5) return; + /* We don't support modes >800x600 */ + if (resindex > 5) return; - if(SiS_Pr->SiS_TVMode & TVSetPAL) { - SiS_SetCH700x(SiS_Pr,0x4304); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ - SiS_SetCH700x(SiS_Pr,0x6909); /* Black level for PAL (105)*/ - } else { - SiS_SetCH700x(SiS_Pr,0x0304); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ - SiS_SetCH700x(SiS_Pr,0x7109); /* Black level for NTSC (113)*/ - } - - temp = CHTVRegData[resindex].Reg[0]; - tempbx=((temp&0x00FF)<<8)|0x00; /* Mode register */ - SiS_SetCH700x(SiS_Pr,tempbx); - temp = CHTVRegData[resindex].Reg[1]; - tempbx=((temp&0x00FF)<<8)|0x07; /* Start active video register */ - SiS_SetCH700x(SiS_Pr,tempbx); - temp = CHTVRegData[resindex].Reg[2]; - tempbx=((temp&0x00FF)<<8)|0x08; /* Position overflow register */ - SiS_SetCH700x(SiS_Pr,tempbx); - temp = CHTVRegData[resindex].Reg[3]; - tempbx=((temp&0x00FF)<<8)|0x0A; /* Horiz Position register */ - SiS_SetCH700x(SiS_Pr,tempbx); - temp = CHTVRegData[resindex].Reg[4]; - tempbx=((temp&0x00FF)<<8)|0x0B; /* Vertical Position register */ - SiS_SetCH700x(SiS_Pr,tempbx); - - /* Set minimum flicker filter for Luma channel (SR1-0=00), + if(SiS_Pr->SiS_TVMode & TVSetPAL) { + SiS_SetCH700x(SiS_Pr,0x04,0x43); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ + SiS_SetCH700x(SiS_Pr,0x09,0x69); /* Black level for PAL (105)*/ + } else { + SiS_SetCH700x(SiS_Pr,0x04,0x03); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ + SiS_SetCH700x(SiS_Pr,0x09,0x71); /* Black level for NTSC (113)*/ + } + + SiS_SetCH700x(SiS_Pr,0x00,CHTVRegData[resindex].Reg[0]); /* Mode register */ + SiS_SetCH700x(SiS_Pr,0x07,CHTVRegData[resindex].Reg[1]); /* Start active video register */ + SiS_SetCH700x(SiS_Pr,0x08,CHTVRegData[resindex].Reg[2]); /* Position overflow register */ + SiS_SetCH700x(SiS_Pr,0x0a,CHTVRegData[resindex].Reg[3]); /* Horiz Position register */ + SiS_SetCH700x(SiS_Pr,0x0b,CHTVRegData[resindex].Reg[4]); /* Vertical Position register */ + + /* Set minimum flicker filter for Luma channel (SR1-0=00), minimum text enhancement (S3-2=10), maximum flicker filter for Chroma channel (S5-4=10) =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!) - */ - SiS_SetCH700x(SiS_Pr,0x2801); + */ + SiS_SetCH700x(SiS_Pr,0x01,0x28); - /* Set video bandwidth + /* Set video bandwidth High bandwith Luma composite video filter(S0=1) low bandwith Luma S-video filter (S2-1=00) disable peak filter in S-video channel (S3=0) high bandwidth Chroma Filter (S5-4=11) =00110001=0x31 - */ - SiS_SetCH700x(SiS_Pr,0xb103); /* old: 3103 */ + */ + SiS_SetCH700x(SiS_Pr,0x03,0xb1); /* old: 3103 */ - /* Register 0x3D does not exist in non-macrovision register map + /* Register 0x3D does not exist in non-macrovision register map (Maybe this is a macrovision register?) - */ + */ #ifndef SIS_CP - SiS_SetCH70xx(SiS_Pr,0x003D); + SiS_SetCH70xx(SiS_Pr,0x3d,0x00); #endif - /* Register 0x10 only contains 1 writable bit (S0) for sensing, - all other bits a read-only. Macrovision? - */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0010,0x1F); + /* Register 0x10 only contains 1 writable bit (S0) for sensing, + all other bits a read-only. Macrovision? + */ + SiS_SetCH70xxANDOR(SiS_Pr,0x10,0x00,0x1F); - /* Register 0x11 only contains 3 writable bits (S0-S2) for - contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) ) - */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0211,0xF8); + /* Register 0x11 only contains 3 writable bits (S0-S2) for + contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) ) + */ + SiS_SetCH70xxANDOR(SiS_Pr,0x11,0x02,0xF8); - /* Clear DSEN - */ - SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xEF); - - if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */ - if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) { - if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on, no need to set FSCI */ - } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ - } - } else { - if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); - } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ + /* Clear DSEN + */ + SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x00,0xEF); + + if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */ + if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) { + if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on, no need to set FSCI */ + } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x18,0x01,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x19,0x0C,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1a,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1b,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1d,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1e,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1f,0x00,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x01,0xEF); /* Loop filter on for mode 23 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x00,0xFE); /* ACIV off, need to set FSCI */ + } + } else { + if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); + } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ #if 0 - SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0); /* 198b3a63 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x041C,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x011D,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x051F,0xF0); - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ -#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); + SiS_SetCH70xxANDOR(SiS_Pr,0x18,0x01,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ + SiS_SetCH70xxANDOR(SiS_Pr,0x19,0x09,0xF0); /* FSCI for mode 24 is 428,554,851 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x1a,0x08,0xF0); /* 198b3a63 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x1b,0x0b,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x04,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1d,0x01,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1e,0x06,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x1f,0x05,0xF0); + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off for mode 24 */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x00,0xFE); * ACIV off, need to set FSCI */ +#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); + } } - } - } else { /* ---- PAL ---- */ - /* We don't play around with FSCI in PAL mode */ + } else { /* ---- PAL ---- */ + /* We don't play around with FSCI in PAL mode */ if(resindex == 0x04) { - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on */ } else { - SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ - SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ + SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */ + SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on */ } - } - + } + #endif /* 300 */ - } else { + } else { - /* Chrontel 7019 - assumed that it does not come with a 300 series chip */ + /* Chrontel 7019 - assumed that it does not come with a 300 series chip */ #ifdef SIS315H - /* We don't support modes >1024x768 */ - if (resindex > 6) return; - - temp = CHTVRegData[resindex].Reg[0]; - if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - temp |= 0x10; - } - tempbx=((temp & 0x00FF) << 8) | 0x00; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[1]; - tempbx=((temp & 0x00FF) << 8) | 0x01; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[2]; - tempbx=((temp & 0x00FF) << 8) | 0x02; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[3]; - tempbx=((temp & 0x00FF) << 8) | 0x04; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[4]; - tempbx=((temp & 0x00FF) << 8) | 0x03; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[5]; - tempbx=((temp & 0x00FF) << 8) | 0x05; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[6]; - tempbx=((temp & 0x00FF) << 8) | 0x06; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[7]; - if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { - temp = 0x66; - } - tempbx=((temp & 0x00FF) << 8) | 0x07; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[8]; - tempbx=((temp & 0x00FF) << 8) | 0x08; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[9]; - tempbx=((temp & 0x00FF) << 8) | 0x15; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[10]; - tempbx=((temp & 0x00FF) << 8) | 0x1f; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[11]; - tempbx=((temp & 0x00FF) << 8) | 0x0c; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[12]; - tempbx=((temp & 0x00FF) << 8) | 0x0d; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[13]; - tempbx=((temp & 0x00FF) << 8) | 0x0e; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[14]; - tempbx=((temp & 0x00FF) << 8) | 0x0f; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = CHTVRegData[resindex].Reg[15]; - tempbx=((temp & 0x00FF) << 8) | 0x10; - SiS_SetCH701x(SiS_Pr,tempbx); - - temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02; - /* D1 should be set for PAL, PAL-N and NTSC-J, - but I won't do that for PAL unless somebody - tells me to do so. Since the BIOS uses - non-default CIV values and blacklevels, - this might be compensated anyway. - */ - if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02; - SiS_SetCH701x(SiS_Pr,((temp << 8) | 0x21)); + unsigned short temp; + + /* We don't support modes >1024x768 */ + if (resindex > 6) return; + + temp = CHTVRegData[resindex].Reg[0]; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp |= 0x10; + SiS_SetCH701x(SiS_Pr,0x00,temp); + + SiS_SetCH701x(SiS_Pr,0x01,CHTVRegData[resindex].Reg[1]); + SiS_SetCH701x(SiS_Pr,0x02,CHTVRegData[resindex].Reg[2]); + SiS_SetCH701x(SiS_Pr,0x04,CHTVRegData[resindex].Reg[3]); + SiS_SetCH701x(SiS_Pr,0x03,CHTVRegData[resindex].Reg[4]); + SiS_SetCH701x(SiS_Pr,0x05,CHTVRegData[resindex].Reg[5]); + SiS_SetCH701x(SiS_Pr,0x06,CHTVRegData[resindex].Reg[6]); + + temp = CHTVRegData[resindex].Reg[7]; + if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp = 0x66; + SiS_SetCH701x(SiS_Pr,0x07,temp); + + SiS_SetCH701x(SiS_Pr,0x08,CHTVRegData[resindex].Reg[8]); + SiS_SetCH701x(SiS_Pr,0x15,CHTVRegData[resindex].Reg[9]); + SiS_SetCH701x(SiS_Pr,0x1f,CHTVRegData[resindex].Reg[10]); + SiS_SetCH701x(SiS_Pr,0x0c,CHTVRegData[resindex].Reg[11]); + SiS_SetCH701x(SiS_Pr,0x0d,CHTVRegData[resindex].Reg[12]); + SiS_SetCH701x(SiS_Pr,0x0e,CHTVRegData[resindex].Reg[13]); + SiS_SetCH701x(SiS_Pr,0x0f,CHTVRegData[resindex].Reg[14]); + SiS_SetCH701x(SiS_Pr,0x10,CHTVRegData[resindex].Reg[15]); + + temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02; + /* D1 should be set for PAL, PAL-N and NTSC-J, + but I won't do that for PAL unless somebody + tells me to do so. Since the BIOS uses + non-default CIV values and blacklevels, + this might be compensated anyway. + */ + if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02; + SiS_SetCH701x(SiS_Pr,0x21,temp); #endif /* 315 */ - } + } #ifdef SIS_CP - SIS_CP_INIT301_CP3 + SIS_CP_INIT301_CP3 #endif } +#ifdef SIS315H /* ----------- 315 series only ---------- */ + void -SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; - /* Enable Chrontel 7019 LCD panel backlight */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(HwInfo->jChipType == SIS_740) { - SiS_SetCH701x(SiS_Pr,0x6566); - } else { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp |= 0x20; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - } - } + /* Enable Chrontel 7019 LCD panel backlight */ + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_Pr->ChipType == SIS_740) { + SiS_SetCH701x(SiS_Pr,0x66,0x65); + } else { + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp |= 0x20; + SiS_SetCH701x(SiS_Pr,0x66,temp); + } + } } void -SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr) +SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; - /* Disable Chrontel 7019 LCD panel backlight */ - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - temp = SiS_GetCH701x(SiS_Pr,0x66); - temp &= 0xDF; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - } + /* Disable Chrontel 7019 LCD panel backlight */ + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + temp = SiS_GetCH701x(SiS_Pr,0x66); + temp &= 0xDF; + SiS_SetCH701x(SiS_Pr,0x66,temp); + } } -#ifdef SIS315H /* ----------- 315 series only ---------- */ - static void -SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) -{ - UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; - UCHAR table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; - UCHAR table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; - UCHAR asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; - UCHAR asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; - UCHAR table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; - UCHAR table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; - UCHAR *tableptr = NULL; +SiS_ChrontelPowerSequencing(struct SiS_Private *SiS_Pr) +{ + static const unsigned char regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; + static const unsigned char table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; + static const unsigned char table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; + static const unsigned char asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; + static const unsigned char asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; + static const unsigned char table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; + static const unsigned char table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; + const unsigned char *tableptr = NULL; int i; /* Set up Power up/down timing */ - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; - else tableptr = table1024_740; + if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; + else tableptr = table1024_740; } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || - (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740; else tableptr = table1400_740; } else return; } else { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - tableptr = table1024_650; + tableptr = table1024_650; } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || - (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || + (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { - tableptr = table1400_650; + tableptr = table1400_650; } else return; } for(i=0; i<5; i++) { - SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); + SiS_SetCH701x(SiS_Pr, regtable[i], tableptr[i]); } } static void -SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) -{ - UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, - 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 }; - UCHAR table1024_740[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, - 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1280_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1400_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; - UCHAR table1600_740[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 }; - UCHAR table1024_650[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, - 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 }; - UCHAR table1280_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 }; - UCHAR table1400_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, - 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 }; - UCHAR table1600_650[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, - 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a }; - UCHAR *tableptr = NULL; - USHORT tempbh; +SiS_SetCH701xForLCD(struct SiS_Private *SiS_Pr) +{ + const unsigned char *tableptr = NULL; + unsigned short tempbh; int i; + static const unsigned char regtable[] = { + 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, + 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 + }; + static const unsigned char table1024_740[] = { + 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, + 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 + }; + static const unsigned char table1280_740[] = { + 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 + }; + static const unsigned char table1400_740[] = { + 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 + }; + static const unsigned char table1600_740[] = { + 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 + }; + static const unsigned char table1024_650[] = { + 0x60, 0x02, 0x00, 0x07, 0x40, 0xed, + 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 + }; + static const unsigned char table1280_650[] = { + 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 + }; + static const unsigned char table1400_650[] = { + 0x60, 0x03, 0x11, 0x00, 0x40, 0xef, + 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 + }; + static const unsigned char table1600_650[] = { + 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3, + 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a + }; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_740; else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_740; else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_740; @@ -8499,138 +8320,139 @@ SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } } - if(HwInfo->jChipType == SIS_740) tempbh = 0x0d; - else tempbh = 0x0c; + if(SiS_Pr->ChipType == SIS_740) tempbh = 0x0d; + else tempbh = 0x0c; for(i = 0; i < tempbh; i++) { - SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); + SiS_SetCH701x(SiS_Pr, regtable[i], tableptr[i]); } - SiS_ChrontelPowerSequencing(SiS_Pr,HwInfo); + SiS_ChrontelPowerSequencing(SiS_Pr); tempbh = SiS_GetCH701x(SiS_Pr,0x1e); tempbh |= 0xc0; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e); + SiS_SetCH701x(SiS_Pr,0x1e,tempbh); - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { tempbh = SiS_GetCH701x(SiS_Pr,0x1c); tempbh &= 0xfb; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c); + SiS_SetCH701x(SiS_Pr,0x1c,tempbh); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); tempbh = SiS_GetCH701x(SiS_Pr,0x64); tempbh |= 0x40; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64); + SiS_SetCH701x(SiS_Pr,0x64,tempbh); tempbh = SiS_GetCH701x(SiS_Pr,0x03); tempbh &= 0x3f; - SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03); + SiS_SetCH701x(SiS_Pr,0x03,tempbh); } } static void -SiS_ChrontelResetVSync(SiS_Private *SiS_Pr) +SiS_ChrontelResetVSync(struct SiS_Private *SiS_Pr) { unsigned char temp, temp1; temp1 = SiS_GetCH701x(SiS_Pr,0x49); - SiS_SetCH701x(SiS_Pr,0x3e49); + SiS_SetCH701x(SiS_Pr,0x49,0x3e); temp = SiS_GetCH701x(SiS_Pr,0x47); temp &= 0x7f; /* Use external VSYNC */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_LongDelay(SiS_Pr,3); + SiS_SetCH701x(SiS_Pr,0x47,temp); + SiS_LongDelay(SiS_Pr, 3); temp = SiS_GetCH701x(SiS_Pr,0x47); temp |= 0x80; /* Use internal VSYNC */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_SetCH701x(SiS_Pr,(temp1 << 8) | 0x49); + SiS_SetCH701x(SiS_Pr,0x47,temp); + SiS_SetCH701x(SiS_Pr,0x49,temp1); } static void -SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x1c); temp |= 0x04; /* Invert XCLK phase */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); + SiS_SetCH701x(SiS_Pr,0x1c,temp); } - if(SiS_IsYPbPr(SiS_Pr, HwInfo)) { + if(SiS_IsYPbPr(SiS_Pr)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; temp |= 0x80; /* Enable YPrPb (HDTV) */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); + SiS_SetCH701x(SiS_Pr,0x01,temp); } - if(SiS_IsChScart(SiS_Pr, HwInfo)) { + if(SiS_IsChScart(SiS_Pr)) { temp = SiS_GetCH701x(SiS_Pr,0x01); temp &= 0x3f; temp |= 0xc0; /* Enable SCART + CVBS */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); + SiS_SetCH701x(SiS_Pr,0x01,temp); } - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { SiS_ChrontelResetVSync(SiS_Pr); - SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + SiS_SetCH701x(SiS_Pr,0x49,0x20); /* Enable TV path */ } else { - SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ + SiS_SetCH701x(SiS_Pr,0x49,0x20); /* Enable TV path */ temp = SiS_GetCH701x(SiS_Pr,0x49); - if(SiS_IsYPbPr(SiS_Pr,HwInfo)) { + if(SiS_IsYPbPr(SiS_Pr)) { temp = SiS_GetCH701x(SiS_Pr,0x73); temp |= 0x60; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73); + SiS_SetCH701x(SiS_Pr,0x73,temp); } temp = SiS_GetCH701x(SiS_Pr,0x47); temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); - SiS_LongDelay(SiS_Pr,2); + SiS_SetCH701x(SiS_Pr,0x47,temp); + SiS_LongDelay(SiS_Pr, 2); temp = SiS_GetCH701x(SiS_Pr,0x47); temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); + SiS_SetCH701x(SiS_Pr,0x47,temp); } } } static void -SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; /* Complete power down of LVDS */ if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { - if(HwInfo->jChipType == SIS_740) { - SiS_LongDelay(SiS_Pr,1); - SiS_GenericDelay(SiS_Pr,0x16ff); - SiS_SetCH701x(SiS_Pr,0xac76); - SiS_SetCH701x(SiS_Pr,0x0066); + if(SiS_Pr->ChipType == SIS_740) { + SiS_LongDelay(SiS_Pr, 1); + SiS_GenericDelay(SiS_Pr, 5887); + SiS_SetCH701x(SiS_Pr,0x76,0xac); + SiS_SetCH701x(SiS_Pr,0x66,0x00); } else { - SiS_LongDelay(SiS_Pr,2); + SiS_LongDelay(SiS_Pr, 2); temp = SiS_GetCH701x(SiS_Pr,0x76); temp &= 0xfc; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - SiS_SetCH701x(SiS_Pr,0x0066); + SiS_SetCH701x(SiS_Pr,0x76,temp); + SiS_SetCH701x(SiS_Pr,0x66,0x00); } } } static void -SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ChrontelResetDB(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */ temp &= 0x01; if(!temp) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { temp = SiS_GetCH701x(SiS_Pr,0x49); - SiS_SetCH701x(SiS_Pr,0x3e49); + SiS_SetCH701x(SiS_Pr,0x49,0x3e); } + /* Reset Chrontel 7019 datapath */ - SiS_SetCH701x(SiS_Pr,0x1048); - SiS_LongDelay(SiS_Pr,1); - SiS_SetCH701x(SiS_Pr,0x1848); + SiS_SetCH701x(SiS_Pr,0x48,0x10); + SiS_LongDelay(SiS_Pr, 1); + SiS_SetCH701x(SiS_Pr,0x48,0x18); - if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { SiS_ChrontelResetVSync(SiS_Pr); - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49); + SiS_SetCH701x(SiS_Pr,0x49,temp); } } else { @@ -8638,72 +8460,72 @@ SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /* Clear/set/clear GPIO */ temp = SiS_GetCH701x(SiS_Pr,0x5c); temp &= 0xef; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + SiS_SetCH701x(SiS_Pr,0x5c,temp); temp = SiS_GetCH701x(SiS_Pr,0x5c); temp |= 0x10; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + SiS_SetCH701x(SiS_Pr,0x5c,temp); temp = SiS_GetCH701x(SiS_Pr,0x5c); temp &= 0xef; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); + SiS_SetCH701x(SiS_Pr,0x5c,temp); temp = SiS_GetCH701x(SiS_Pr,0x61); if(!temp) { - SiS_SetCH701xForLCD(SiS_Pr, HwInfo); + SiS_SetCH701xForLCD(SiS_Pr); } } } else { /* 650 */ /* Reset Chrontel 7019 datapath */ - SiS_SetCH701x(SiS_Pr,0x1048); - SiS_LongDelay(SiS_Pr,1); - SiS_SetCH701x(SiS_Pr,0x1848); + SiS_SetCH701x(SiS_Pr,0x48,0x10); + SiS_LongDelay(SiS_Pr, 1); + SiS_SetCH701x(SiS_Pr,0x48,0x18); } } static void -SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { + if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { SiS_ChrontelResetVSync(SiS_Pr); } } else { - SiS_SetCH701x(SiS_Pr,0xaf76); /* Power up LVDS block */ + SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* Power up LVDS block */ temp = SiS_GetCH701x(SiS_Pr,0x49); temp &= 1; if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */ temp = SiS_GetCH701x(SiS_Pr,0x47); temp &= 0x70; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* enable VSYNC */ - SiS_LongDelay(SiS_Pr,3); + SiS_SetCH701x(SiS_Pr,0x47,temp); /* enable VSYNC */ + SiS_LongDelay(SiS_Pr, 3); temp = SiS_GetCH701x(SiS_Pr,0x47); temp |= 0x80; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* disable VSYNC */ + SiS_SetCH701x(SiS_Pr,0x47,temp); /* disable VSYNC */ } } } static void -SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) +SiS_ChrontelDoSomething3(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - USHORT temp,temp1; + unsigned short temp,temp1; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x61); if(temp < 1) { temp++; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); + SiS_SetCH701x(SiS_Pr,0x61,temp); } - SiS_SetCH701x(SiS_Pr,0x4566); /* Panel power on */ - SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on */ - SiS_LongDelay(SiS_Pr,1); - SiS_GenericDelay(SiS_Pr,0x16ff); + SiS_SetCH701x(SiS_Pr,0x66,0x45); /* Panel power on */ + SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* All power on */ + SiS_LongDelay(SiS_Pr, 1); + SiS_GenericDelay(SiS_Pr, 5887); } else { /* 650 */ @@ -8711,38 +8533,38 @@ SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo temp = SiS_GetCH701x(SiS_Pr,0x61); if(temp < 2) { temp++; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); + SiS_SetCH701x(SiS_Pr,0x61,temp); temp1 = 1; } - SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x76,0xac); temp = SiS_GetCH701x(SiS_Pr,0x66); temp |= 0x5f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); + SiS_SetCH701x(SiS_Pr,0x66,temp); if(ModeNo > 0x13) { - if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { - SiS_GenericDelay(SiS_Pr,0x3ff); + if(SiS_WeHaveBacklightCtrl(SiS_Pr)) { + SiS_GenericDelay(SiS_Pr, 1023); } else { - SiS_GenericDelay(SiS_Pr,0x2ff); + SiS_GenericDelay(SiS_Pr, 767); } } else { if(!temp1) - SiS_GenericDelay(SiS_Pr,0x2ff); + SiS_GenericDelay(SiS_Pr, 767); } temp = SiS_GetCH701x(SiS_Pr,0x76); temp |= 0x03; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); + SiS_SetCH701x(SiS_Pr,0x76,temp); temp = SiS_GetCH701x(SiS_Pr,0x66); temp &= 0x7f; - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); - SiS_LongDelay(SiS_Pr,1); + SiS_SetCH701x(SiS_Pr,0x66,temp); + SiS_LongDelay(SiS_Pr, 1); } } static void -SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ChrontelDoSomething2(struct SiS_Private *SiS_Pr) { - USHORT temp,tempcl,tempch; + unsigned short temp,tempcl,tempch; SiS_LongDelay(SiS_Pr, 1); tempcl = 3; @@ -8753,87 +8575,87 @@ SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) temp &= 0x04; /* PLL stable? -> bail out */ if(temp == 0x04) break; - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { /* Power down LVDS output, PLL normal operation */ - SiS_SetCH701x(SiS_Pr,0xac76); + SiS_SetCH701x(SiS_Pr,0x76,0xac); } - SiS_SetCH701xForLCD(SiS_Pr,HwInfo); + SiS_SetCH701xForLCD(SiS_Pr); if(tempcl == 0) { if(tempch == 3) break; - SiS_ChrontelResetDB(SiS_Pr,HwInfo); + SiS_ChrontelResetDB(SiS_Pr); tempcl = 3; tempch++; } tempcl--; temp = SiS_GetCH701x(SiS_Pr,0x76); temp &= 0xfb; /* Reset PLL */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - SiS_LongDelay(SiS_Pr,2); + SiS_SetCH701x(SiS_Pr,0x76,temp); + SiS_LongDelay(SiS_Pr, 2); temp = SiS_GetCH701x(SiS_Pr,0x76); temp |= 0x04; /* PLL normal operation */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); - if(HwInfo->jChipType == SIS_740) { - SiS_SetCH701x(SiS_Pr,0xe078); /* PLL loop filter */ + SiS_SetCH701x(SiS_Pr,0x76,temp); + if(SiS_Pr->ChipType == SIS_740) { + SiS_SetCH701x(SiS_Pr,0x78,0xe0); /* PLL loop filter */ } else { - SiS_SetCH701x(SiS_Pr,0x6078); + SiS_SetCH701x(SiS_Pr,0x78,0x60); } - SiS_LongDelay(SiS_Pr,2); + SiS_LongDelay(SiS_Pr, 2); } while(0); - SiS_SetCH701x(SiS_Pr,0x0077); /* MV? */ + SiS_SetCH701x(SiS_Pr,0x77,0x00); /* MV? */ } static void -SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr) { - USHORT temp; + unsigned short temp; temp = SiS_GetCH701x(SiS_Pr,0x03); temp |= 0x80; /* Set datapath 1 to TV */ temp &= 0xbf; /* Set datapath 2 to LVDS */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); + SiS_SetCH701x(SiS_Pr,0x03,temp); - if(HwInfo->jChipType == SIS_740) { + if(SiS_Pr->ChipType == SIS_740) { temp = SiS_GetCH701x(SiS_Pr,0x1c); temp &= 0xfb; /* Normal XCLK phase */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); + SiS_SetCH701x(SiS_Pr,0x1c,temp); SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); temp = SiS_GetCH701x(SiS_Pr,0x64); temp |= 0x40; /* ? Bit not defined */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64); + SiS_SetCH701x(SiS_Pr,0x64,temp); temp = SiS_GetCH701x(SiS_Pr,0x03); temp &= 0x3f; /* D1 input to both LVDS and TV */ - SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); + SiS_SetCH701x(SiS_Pr,0x03,temp); if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) { - SiS_SetCH701x(SiS_Pr,0x4063); /* LVDS off */ + SiS_SetCH701x(SiS_Pr,0x63,0x40); /* LVDS off */ SiS_LongDelay(SiS_Pr, 1); - SiS_SetCH701x(SiS_Pr,0x0063); /* LVDS on */ - SiS_ChrontelResetDB(SiS_Pr, HwInfo); - SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); - SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); + SiS_SetCH701x(SiS_Pr,0x63,0x00); /* LVDS on */ + SiS_ChrontelResetDB(SiS_Pr); + SiS_ChrontelDoSomething2(SiS_Pr); + SiS_ChrontelDoSomething3(SiS_Pr, 0); } else { temp = SiS_GetCH701x(SiS_Pr,0x66); if(temp != 0x45) { - SiS_ChrontelResetDB(SiS_Pr, HwInfo); - SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); - SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); + SiS_ChrontelResetDB(SiS_Pr); + SiS_ChrontelDoSomething2(SiS_Pr); + SiS_ChrontelDoSomething3(SiS_Pr, 0); } } } else { /* 650 */ - SiS_ChrontelResetDB(SiS_Pr,HwInfo); - SiS_ChrontelDoSomething2(SiS_Pr,HwInfo); + SiS_ChrontelResetDB(SiS_Pr); + SiS_ChrontelDoSomething2(SiS_Pr); temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34); - SiS_ChrontelDoSomething3(SiS_Pr,temp,HwInfo); - SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on, LVDS normal operation */ + SiS_ChrontelDoSomething3(SiS_Pr,temp); + SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* All power on, LVDS normal operation */ } @@ -8845,15 +8667,12 @@ SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ BOOLEAN -SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { #ifdef SIS300 - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; -#endif - USHORT ModeIdIndex, RefreshRateTableIndex; -#if 0 - USHORT temp; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; #endif + unsigned short ModeIdIndex, RefreshRateTableIndex; SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; @@ -8866,37 +8685,37 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) /* Used for shifting CR33 */ SiS_Pr->SiS_SelectCRT2Rate = 4; - SiS_UnLockCRT2(SiS_Pr, HwInfo); + SiS_UnLockCRT2(SiS_Pr); - RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex); SiS_SaveCRT2Info(SiS_Pr,ModeNo); if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_DisableBridge(SiS_Pr,HwInfo); - if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (HwInfo->jChipType == SIS_730)) { + SiS_DisableBridge(SiS_Pr); + if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->ChipType == SIS_730)) { SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,0x80); } - SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex); } if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { - SiS_LockCRT2(SiS_Pr, HwInfo); + SiS_LockCRT2(SiS_Pr); SiS_DisplayOn(SiS_Pr); return TRUE; } - SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); /* Set up Panel Link for LVDS and LCDA */ SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) || - ((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { - SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + ((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS30xBLV)) ) { + SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } -#ifdef LINUX_XF86 +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES); xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE); @@ -8907,86 +8726,79 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) #endif if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); + SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); #ifdef SIS315H - SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); #endif - SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); + SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex); + SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); #ifdef SIS315H - SiS_SetGroup4_C_ELV(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); + SiS_SetGroup4_C_ELV(SiS_Pr, ModeNo, ModeIdIndex); #endif - SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); + SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex); - SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex); - /* For 301BDH (Panel link initialization): */ - if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { - if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) { - if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) { - if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { - SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwInfo); - } - } - } - SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex, - RefreshRateTableIndex,HwInfo); - } - } + /* For 301BDH (Panel link initialization): */ + if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { + + if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) { + if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { + SiS_ModCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + } + SiS_SetCRT2ECLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); + } + } } else { - SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); + SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex); - if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { - SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo); - } + SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); - SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo); + SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); - if(SiS_Pr->SiS_SetFlag & LowModeTests) { - if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { - if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { + if(SiS_Pr->SiS_SetFlag & LowModeTests) { + if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { + if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { + if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { #ifdef SIS315H - SiS_SetCH701xForLCD(SiS_Pr,HwInfo); + SiS_SetCH701xForLCD(SiS_Pr); #endif - } - } - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); - } - } - } + } + } + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); + } + } + } } #ifdef SIS300 - if(HwInfo->jChipType < SIS_315H) { + if(SiS_Pr->ChipType < SIS_315H) { if(SiS_Pr->SiS_SetFlag & LowModeTests) { if(SiS_Pr->SiS_UseOEM) { if((SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_UseOEM == -1)) { if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { - SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, - RefreshRateTableIndex); + SiS_OEM300Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } } else { - SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, - RefreshRateTableIndex); + SiS_OEM300Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } } if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || + if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { - SetOEMLCDData2(SiS_Pr, HwInfo, ModeNo, ModeIdIndex,RefreshRateTableIndex); + SetOEMLCDData2(SiS_Pr, ModeNo, ModeIdIndex,RefreshRateTableIndex); } SiS_DisplayOn(SiS_Pr); } @@ -8995,21 +8807,21 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) #endif #ifdef SIS315H - if(HwInfo->jChipType >= SIS_315H) { + if(SiS_Pr->ChipType >= SIS_315H) { if(SiS_Pr->SiS_SetFlag & LowModeTests) { - if(HwInfo->jChipType < SIS_661) { - SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); - SiS_OEM310Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); + if(SiS_Pr->ChipType < SIS_661) { + SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex); + SiS_OEM310Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } else { - SiS_OEM661Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); + SiS_OEM661Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); } - SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); + SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); } } #endif if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_EnableBridge(SiS_Pr, HwInfo); + SiS_EnableBridge(SiS_Pr); } SiS_DisplayOn(SiS_Pr); @@ -9017,15 +8829,15 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* Disable LCD panel when using TV */ - SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFF,0x0C); + SiS_SetRegSR11ANDOR(SiS_Pr,0xFF,0x0C); } else { /* Disable TV when using LCD */ - SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8); + SiS_SetCH70xxANDOR(SiS_Pr,0x0e,0x01,0xf8); } } if(SiS_Pr->SiS_SetFlag & LowModeTests) { - SiS_LockCRT2(SiS_Pr,HwInfo); + SiS_LockCRT2(SiS_Pr); } return TRUE; @@ -9037,13 +8849,13 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) /*********************************************/ void -SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr) { /* Switch on LCD backlight on SiS30xLV */ SiS_DDC2Delay(SiS_Pr,0xff00); if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); - SiS_WaitVBRetrace(SiS_Pr,HwInfo); + SiS_WaitVBRetrace(SiS_Pr); } if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) { SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); @@ -9051,12 +8863,11 @@ SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } void -SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr) { /* Switch off LCD backlight on SiS30xLV */ SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); - SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); - SiS_DDC2Delay(SiS_Pr,0xe000); + SiS_DDC2Delay(SiS_Pr,0xff00); } /*********************************************/ @@ -9064,7 +8875,7 @@ SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) /*********************************************/ static void -SiS_SetupDDCN(SiS_Private *SiS_Pr) +SiS_SetupDDCN(struct SiS_Private *SiS_Pr) { SiS_Pr->SiS_DDC_NData = ~SiS_Pr->SiS_DDC_Data; SiS_Pr->SiS_DDC_NClk = ~SiS_Pr->SiS_DDC_Clk; @@ -9075,12 +8886,12 @@ SiS_SetupDDCN(SiS_Private *SiS_Pr) } #ifdef SIS300 -static UCHAR * -SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr) +static unsigned char * +SiS_SetTrumpBlockLoop(struct SiS_Private *SiS_Pr, unsigned char *dataptr) { int i, j, num; - USHORT tempah,temp; - UCHAR *mydataptr; + unsigned short tempah,temp; + unsigned char *mydataptr; for(i=0; i<20; i++) { /* Do 20 attempts to write */ mydataptr = dataptr; @@ -9088,7 +8899,7 @@ SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr) if(!num) return mydataptr; if(i) { SiS_SetStop(SiS_Pr); - SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT*2); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 2); } if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ tempah = SiS_Pr->SiS_DDC_DeviceAddr; @@ -9110,12 +8921,12 @@ SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr) } static BOOLEAN -SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr) +SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr) { SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */ SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); SiS_SetSwitchDDC2(SiS_Pr); @@ -9124,9 +8935,11 @@ SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr) dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr); if(!dataptr) return FALSE; } +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Trumpion block success\n"); #endif +#endif return TRUE; } #endif @@ -9139,155 +8952,121 @@ SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr) */ static BOOLEAN -SiS_SetChReg(SiS_Private *SiS_Pr, USHORT tempbx, USHORT myor) +SiS_SetChReg(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val, unsigned short myor) { - USHORT tempah,temp,i; + unsigned short temp, i; for(i=0; i<20; i++) { /* Do 20 attempts to write */ if(i) { - SiS_SetStop(SiS_Pr); - SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); - } - if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ - if(temp) continue; /* (ERROR: no ack) */ - tempah = tempbx & 0x00FF; /* Write RAB */ - tempah |= myor; /* (700x: set bit 7, see datasheet) */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* (ERROR: no ack) */ - tempah = (tempbx & 0xFF00) >> 8; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write data */ - if(temp) continue; /* (ERROR: no ack) */ - if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */ + SiS_SetStop(SiS_Pr); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 4); + } + if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ + temp = SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr); /* Write DAB (S0=0=write) */ + if(temp) continue; /* (ERROR: no ack) */ + temp = SiS_WriteDDC2Data(SiS_Pr, (reg | myor)); /* Write RAB (700x: set bit 7, see datasheet) */ + if(temp) continue; /* (ERROR: no ack) */ + temp = SiS_WriteDDC2Data(SiS_Pr, val); /* Write data */ + if(temp) continue; /* (ERROR: no ack) */ + if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */ SiS_Pr->SiS_ChrontelInit = 1; return TRUE; } return FALSE; } -#if 0 -#ifdef SIS300 -/* Write Trumpion register */ -static void -SiS_SetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx) -{ - SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */ - SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ - SiS_SetupDDCN(SiS_Pr); - SiS_SetChReg(SiS_Pr, tempbx, 0); -} -#endif -#endif - /* Write to Chrontel 700x */ -/* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ void -SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) +SiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) { SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); + if(!(SiS_Pr->SiS_ChrontelInit)) { SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); } - if( (!(SiS_SetChReg(SiS_Pr, tempbx, 0x80))) && + if( (!(SiS_SetChReg(SiS_Pr, reg, val, 0x80))) && (!(SiS_Pr->SiS_ChrontelInit)) ) { - SiS_Pr->SiS_DDC_Index = 0x0a; /* Bit 7 = SC; Bit 6 = SD */ - SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Index = 0x0a; + SiS_Pr->SiS_DDC_Data = 0x80; + SiS_Pr->SiS_DDC_Clk = 0x40; SiS_SetupDDCN(SiS_Pr); - SiS_SetChReg(SiS_Pr, tempbx, 0x80); + SiS_SetChReg(SiS_Pr, reg, val, 0x80); } } /* Write to Chrontel 701x */ /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ void -SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) +SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) { SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); - SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ - SiS_SetChReg(SiS_Pr, tempbx, 0); + SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ + SiS_SetChReg(SiS_Pr, reg, val, 0); } -static void -SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +#ifdef SIS_LINUX_KERNEL +static +#endif +void +SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) { if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) - SiS_SetCH700x(SiS_Pr,tempbx); + SiS_SetCH700x(SiS_Pr, reg, val); else - SiS_SetCH701x(SiS_Pr,tempbx); + SiS_SetCH701x(SiS_Pr, reg, val); } -static USHORT -SiS_GetChReg(SiS_Private *SiS_Pr, USHORT myor) +static unsigned short +SiS_GetChReg(struct SiS_Private *SiS_Pr, unsigned short myor) { - USHORT tempah,temp,i; + unsigned short tempah, temp, i; for(i=0; i<20; i++) { /* Do 20 attempts to read */ if(i) { - SiS_SetStop(SiS_Pr); - SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); - } - if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr; - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ - if(temp) continue; /* (ERROR: no ack) */ - tempah = SiS_Pr->SiS_DDC_ReadAddr | myor; /* Write RAB (700x: | 0x80) */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); - if(temp) continue; /* (ERROR: no ack) */ - if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */ - tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01;/* DAB | 0x01 = Read */ - temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* DAB (S0=1=read) */ - if(temp) continue; /* (ERROR: no ack) */ - tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* Read byte */ - if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */ + SiS_SetStop(SiS_Pr); + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 4); + } + if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ + temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_DeviceAddr); /* Write DAB (S0=0=write) */ + if(temp) continue; /* (ERROR: no ack) */ + temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_ReadAddr | myor); /* Write RAB (700x: | 0x80) */ + if(temp) continue; /* (ERROR: no ack) */ + if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */ + temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_DeviceAddr | 0x01);/* DAB (S0=1=read) */ + if(temp) continue; /* (ERROR: no ack) */ + tempah = SiS_ReadDDC2Data(SiS_Pr); /* Read byte */ + if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */ SiS_Pr->SiS_ChrontelInit = 1; - return(tempah); + return tempah; } return 0xFFFF; } -#if 0 -#ifdef SIS300 -/* Read from Trumpion */ -static USHORT -SiS_GetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx) -{ - SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB */ - SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ - SiS_SetupDDCN(SiS_Pr); - SiS_Pr->SiS_DDC_ReadAddr = tempbx; - return(SiS_GetChReg(SiS_Pr,0)); -} -#endif -#endif - /* Read from Chrontel 700x */ /* Parameter is [Register no (S7-S0)] */ -USHORT -SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) +unsigned short +SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempbx) { - USHORT result; + unsigned short result; SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ + SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); + if(!(SiS_Pr->SiS_ChrontelInit)) { SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); } @@ -9303,52 +9082,69 @@ SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) result = SiS_GetChReg(SiS_Pr,0x80); } - return(result); + return result; } /* Read from Chrontel 701x */ /* Parameter is [Register no (S7-S0)] */ -USHORT -SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) +unsigned short +SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempbx) { SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ - SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ - SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ + SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ + SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ SiS_SetupDDCN(SiS_Pr); SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ SiS_Pr->SiS_DDC_ReadAddr = tempbx; - return(SiS_GetChReg(SiS_Pr,0)); + return SiS_GetChReg(SiS_Pr,0); } /* Read from Chrontel 70xx */ /* Parameter is [Register no (S7-S0)] */ -static USHORT -SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) +#ifdef SIS_LINUX_KERNEL +static +#endif +unsigned short +SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempbx) { if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) - return(SiS_GetCH700x(SiS_Pr, tempbx)); + return SiS_GetCH700x(SiS_Pr, tempbx); else - return(SiS_GetCH701x(SiS_Pr, tempbx)); + return SiS_GetCH701x(SiS_Pr, tempbx); +} + +void +SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg, + unsigned char myor, unsigned short myand) +{ + unsigned short tempbl; + + tempbl = (SiS_GetCH70xx(SiS_Pr, (reg & 0xFF)) & myand) | myor; + SiS_SetCH70xx(SiS_Pr, reg, tempbl); } /* Our own DDC functions */ -static USHORT -SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, - USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32) +#ifndef SIS_XORG_XF86 +static +#endif +unsigned short +SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, + unsigned short adaptnum, unsigned short DDCdatatype, BOOLEAN checkcr32, + unsigned int VBFlags2) { unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 }; unsigned char flag, cr32; - USHORT temp = 0, myadaptnum = adaptnum; + unsigned short temp = 0, myadaptnum = adaptnum; if(adaptnum != 0) { - if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0xFFFF; - if((VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF; - } - + if(!(VBFlags2 & VB2_SISTMDSBRIDGE)) return 0xFFFF; + if((VBFlags2 & VB2_30xBDH) && (adaptnum == 1)) return 0xFFFF; + } + /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */ - + SiS_Pr->SiS_ChrontelInit = 0; /* force re-detection! */ SiS_Pr->SiS_DDC_SecAddr = 0; @@ -9360,7 +9156,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32); #if 0 - if(VBFlags & VB_SISBRIDGE) { + if(VBFlags2 & VB2_SISBRIDGE) { if(myadaptnum == 0) { if(!(cr32 & 0x20)) { myadaptnum = 2; @@ -9376,20 +9172,20 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, #endif if(VGAEngine == SIS_300_VGA) { /* 300 series */ - + if(myadaptnum != 0) { flag = 0; - if(VBFlags & VB_SISBRIDGE) { + if(VBFlags2 & VB2_SISBRIDGE) { SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; SiS_Pr->SiS_DDC_Index = 0x0f; } } - if(!(VBFlags & VB_301)) { + if(!(VBFlags2 & VB2_301)) { if((cr32 & 0x80) && (checkcr32)) { if(myadaptnum >= 1) { if(!(cr32 & 0x08)) { - myadaptnum = 1; + myadaptnum = 1; if(!(cr32 & 0x10)) return 0xFFFF; } } @@ -9401,17 +9197,17 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, } else { /* 315/330 series */ - /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ + /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ - if(VBFlags & VB_SISBRIDGE) { + if(VBFlags2 & VB2_SISBRIDGE) { if(myadaptnum == 2) { myadaptnum = 1; - } + } } if(myadaptnum == 1) { - flag = 0; - if(VBFlags & VB_SISBRIDGE) { + flag = 0; + if(VBFlags2 & VB2_SISBRIDGE) { SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; SiS_Pr->SiS_DDC_Index = 0x0f; } @@ -9429,93 +9225,96 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, temp = myadaptnum; if(myadaptnum == 1) { temp = 0; - if(VBFlags & VB_LVDS) flag = 0xff; + if(VBFlags2 & VB2_LVDS) flag = 0xff; } if(flag) temp = 0; } - + SiS_Pr->SiS_DDC_Data = 0x02 << temp; SiS_Pr->SiS_DDC_Clk = 0x01 << temp; SiS_SetupDDCN(SiS_Pr); +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n", SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp); #endif - +#endif return 0; } -static USHORT -SiS_WriteDABDDC(SiS_Private *SiS_Pr) +static unsigned short +SiS_WriteDABDDC(struct SiS_Private *SiS_Pr) { if(SiS_SetStart(SiS_Pr)) return 0xFFFF; if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) { - return 0xFFFF; + return 0xFFFF; } if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) { - return 0xFFFF; + return 0xFFFF; } - return(0); + return 0; } -static USHORT -SiS_PrepareReadDDC(SiS_Private *SiS_Pr) +static unsigned short +SiS_PrepareReadDDC(struct SiS_Private *SiS_Pr) { if(SiS_SetStart(SiS_Pr)) return 0xFFFF; if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) { - return 0xFFFF; + return 0xFFFF; } - return(0); + return 0; } -static USHORT -SiS_PrepareDDC(SiS_Private *SiS_Pr) +static unsigned short +SiS_PrepareDDC(struct SiS_Private *SiS_Pr) { if(SiS_WriteDABDDC(SiS_Pr)) SiS_WriteDABDDC(SiS_Pr); - if(SiS_PrepareReadDDC(SiS_Pr)) return(SiS_PrepareReadDDC(SiS_Pr)); - return(0); + if(SiS_PrepareReadDDC(SiS_Pr)) return (SiS_PrepareReadDDC(SiS_Pr)); + return 0; } static void -SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno) +SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno) { SiS_SetSCLKLow(SiS_Pr); if(yesno) { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, SiS_Pr->SiS_DDC_Data); } else { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, 0); } SiS_SetSCLKHigh(SiS_Pr); } -static USHORT -SiS_DoProbeDDC(SiS_Private *SiS_Pr) +static unsigned short +SiS_DoProbeDDC(struct SiS_Private *SiS_Pr) { unsigned char mask, value; - USHORT temp, ret=0; + unsigned short temp, ret=0; BOOLEAN failed = FALSE; SiS_SetSwitchDDC2(SiS_Pr); if(SiS_PrepareDDC(SiS_Pr)) { SiS_SetStop(SiS_Pr); +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Probe: Prepare failed\n"); #endif - return(0xFFFF); +#endif + return 0xFFFF; } mask = 0xf0; value = 0x20; if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { - temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); SiS_SendACK(SiS_Pr, 0); if(temp == 0) { mask = 0xff; @@ -9523,34 +9322,41 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr) } else { failed = TRUE; ret = 0xFFFF; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Probe: Read 1 failed\n"); #endif +#endif } } if(failed == FALSE) { - temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); SiS_SendACK(SiS_Pr, 1); temp &= mask; if(temp == value) ret = 0; else { ret = 0xFFFF; +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "Probe: Read 2 failed\n"); #endif +#endif if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { if(temp == 0x30) ret = 0; } } } SiS_SetStop(SiS_Pr); - return(ret); + return ret; } -static USHORT -SiS_ProbeDDC(SiS_Private *SiS_Pr) +#ifndef SIS_XORG_XF86 +static +#endif +unsigned short +SiS_ProbeDDC(struct SiS_Private *SiS_Pr) { - USHORT flag; + unsigned short flag; flag = 0x180; SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; @@ -9560,16 +9366,19 @@ SiS_ProbeDDC(SiS_Private *SiS_Pr) SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x10; if(!(flag & 0x1a)) flag = 0; - return(flag); + return flag; } -static USHORT -SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) +#ifndef SIS_XORG_XF86 +static +#endif +unsigned short +SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, unsigned char *buffer) { - USHORT flag, length, i; + unsigned short flag, length, i; unsigned char chksum,gotcha; - if(DDCdatatype > 4) return 0xFFFF; + if(DDCdatatype > 4) return 0xFFFF; flag = 0; SiS_SetSwitchDDC2(SiS_Pr); @@ -9579,21 +9388,21 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) chksum = 0; gotcha = 0; for(i=0; i<length; i++) { - buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); chksum += buffer[i]; gotcha |= buffer[i]; SiS_SendACK(SiS_Pr, 0); } - buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); + buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr); chksum += buffer[i]; SiS_SendACK(SiS_Pr, 1); - if(gotcha) flag = (USHORT)chksum; + if(gotcha) flag = (unsigned short)chksum; else flag = 0xFFFF; } else { flag = 0xFFFF; } SiS_SetStop(SiS_Pr); - return(flag); + return flag; } /* Our private DDC functions @@ -9617,17 +9426,25 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) if DDCdatatype = 0: Returns supported DDC modes */ -USHORT -SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, - USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer) +unsigned short +SiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, + unsigned short adaptnum, unsigned short DDCdatatype, unsigned char *buffer, + unsigned int VBFlags2) { - unsigned char sr1f,cr17=1; - USHORT result; + unsigned char sr1f, cr17=1; + unsigned short result; - if(adaptnum > 2) return 0xFFFF; - if(DDCdatatype > 4) return 0xFFFF; - if((!(VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF; - if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE) == 0xFFFF) return 0xFFFF; + if(adaptnum > 2) + return 0xFFFF; + + if(DDCdatatype > 4) + return 0xFFFF; + + if((!(VBFlags2 & VB2_VIDEOBRIDGE)) && (adaptnum > 0)) + return 0xFFFF; + + if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE, VBFlags2) == 0xFFFF) + return 0xFFFF; sr1f = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f); SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1f,0x3f,0x04); @@ -9656,10 +9473,12 @@ SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, (buffer[4] == 0xff) && (buffer[5] == 0xff) && (buffer[6] == 0xff) && (buffer[7] == 0x00) && (buffer[0x12] == 1)) { - if(adaptnum == 1) { - if(!(buffer[0x14] & 0x80)) result = 0xFFFE; - } else { - if(buffer[0x14] & 0x80) result = 0xFFFE; + if(!SiS_Pr->DDCPortMixup) { + if(adaptnum == 1) { + if(!(buffer[0x14] & 0x80)) result = 0xFFFE; + } else { + if(buffer[0x14] & 0x80) result = 0xFFFE; + } } } } @@ -9671,832 +9490,10 @@ SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, return result; } -#ifdef LINUX_XF86 - -static BOOLEAN -checkedid1(unsigned char *buffer) -{ - /* Check header */ - if((buffer[0] != 0x00) || - (buffer[1] != 0xff) || - (buffer[2] != 0xff) || - (buffer[3] != 0xff) || - (buffer[4] != 0xff) || - (buffer[5] != 0xff) || - (buffer[6] != 0xff) || - (buffer[7] != 0x00)) - return FALSE; - - /* Check EDID version and revision */ - if((buffer[0x12] != 1) || (buffer[0x13] > 4)) return FALSE; - - /* Check week of manufacture for sanity */ - if(buffer[0x10] > 53) return FALSE; - - /* Check year of manufacture for sanity */ - if(buffer[0x11] > 40) return FALSE; - - return TRUE; -} - -static BOOLEAN -checkedid2(unsigned char *buffer) -{ - USHORT year = buffer[6] | (buffer[7] << 8); - - /* Check EDID version */ - if((buffer[0] & 0xf0) != 0x20) return FALSE; - - /* Check week of manufacture for sanity */ - if(buffer[5] > 53) return FALSE; - - /* Check year of manufacture for sanity */ - if((year != 0) && ((year < 1990) || (year > 2030))) return FALSE; - - return TRUE; -} - -/* Sense the LCD parameters (CR36, CR37) via DDC */ -/* SiS30x(B) only */ -USHORT -SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS) -{ - USHORT DDCdatatype, paneltype, flag, xres=0, yres=0; - USHORT index, myindex, lumsize, numcodes, panelvendor, panelproduct; - int maxx=0, maxy=0, prefx=0, prefy=0; - unsigned char cr37=0, seekcode; - BOOLEAN checkexpand = FALSE; - BOOLEAN havesync = FALSE; - BOOLEAN indb = FALSE; - int retry, i; - unsigned char buffer[256]; - - for(i=0; i<7; i++) SiS_Pr->CP_DataValid[i] = FALSE; - SiS_Pr->CP_HaveCustomData = FALSE; - SiS_Pr->CP_MaxX = SiS_Pr->CP_MaxY = SiS_Pr->CP_MaxClock = 0; - SiS_Pr->CP_PreferredX = SiS_Pr->CP_PreferredY = 0; - SiS_Pr->CP_PreferredIndex = -1; - SiS_Pr->CP_PrefClock = 0; - SiS_Pr->PanelSelfDetected = FALSE; - - if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; - if(pSiS->VBFlags & VB_30xBDH) return 0; - - if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 1, 0, FALSE) == 0xFFFF) return 0; - - SiS_Pr->SiS_DDC_SecAddr = 0x00; - - /* Probe supported DA's */ - flag = SiS_ProbeDDC(SiS_Pr); -#ifdef TWDEBUG - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - "CRT2 DDC capabilities 0x%x\n", flag); -#endif - if(flag & 0x10) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */ - DDCdatatype = 4; - } else if(flag & 0x08) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */ - DDCdatatype = 3; - } else if(flag & 0x02) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ - DDCdatatype = 1; - } else return 0; /* no DDC support (or no device attached) */ - - /* Read the entire EDID */ - retry = 2; - do { - if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "CRT2: DDC read failed (attempt %d), %s\n", - (3-retry), (retry == 1) ? "giving up" : "retrying"); - retry--; - if(retry == 0) return 0xFFFF; - } else break; - } while(1); - -#ifdef TWDEBUG - for(i=0; i<256; i+=16) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - buffer[i], buffer[i+1], buffer[i+2], buffer[i+3], - buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7], - buffer[i+8], buffer[i+9], buffer[i+10], buffer[i+11], - buffer[i+12], buffer[i+13], buffer[i+14], buffer[i+15]); - } -#endif - - /* Analyze EDID and retrieve LCD panel information */ - paneltype = 0; - switch(DDCdatatype) { - case 1: /* Analyze EDID V1 */ - /* Catch a few clear cases: */ - if(!(checkedid1(buffer))) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: EDID corrupt\n"); - return 0; - } - - if(!(buffer[0x14] & 0x80)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Attached display expects analog input (0x%02x)\n", - buffer[0x14]); - return 0; - } - - if((buffer[0x18] & 0x18) != 0x08) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Warning: Attached display is not of RGB but of %s type (0x%02x)\n", - ((buffer[0x18] & 0x18) == 0x00) ? "monochrome/greyscale" : - ( ((buffer[0x18] & 0x18) == 0x10) ? "non-RGB multicolor" : - "undefined"), - buffer[0x18]); - } - - /* Now analyze the first Detailed Timing Block and see - * if the preferred timing mode is stored there. If so, - * check if this is a standard panel for which we already - * know the timing. - */ - - paneltype = Panel_Custom; - checkexpand = FALSE; - - panelvendor = buffer[9] | (buffer[8] << 8); - panelproduct = buffer[10] | (buffer[11] << 8); - - /* Overrule bogus preferred modes from database */ - if((indb = SiS_FindPanelFromDB(pSiS, panelvendor, panelproduct, &maxx, &maxy, &prefx, &prefy))) { - if(prefx) SiS_Pr->CP_PreferredX = xres = prefx; - if(prefy) SiS_Pr->CP_PreferredY = yres = prefy; - } - - if(buffer[0x18] & 0x02) { - - USHORT pclk = (buffer[0x36] | (buffer[0x37] << 8)); - USHORT phb = (buffer[0x39] | ((buffer[0x3a] & 0x0f) << 8)); - USHORT pvb = (buffer[0x3c] | ((buffer[0x3d] & 0x0f) << 8)); - - if(!xres) SiS_Pr->CP_PreferredX = xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4); - if(!yres) SiS_Pr->CP_PreferredY = yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4); - - switch(xres) { -#if 0 /* Treat as custom */ - case 800: - if(yres == 600) { - paneltype = Panel_800x600; - checkexpand = TRUE; - } - break; -#endif - case 1024: - if(yres == 768) { - paneltype = Panel_1024x768; - checkexpand = TRUE; - } - break; - case 1280: - if(yres == 1024) { - paneltype = Panel_1280x1024; - checkexpand = TRUE; - } else if(yres == 960) { - if(pSiS->VGAEngine == SIS_300_VGA) { - paneltype = Panel300_1280x960; - } else { - paneltype = Panel310_1280x960; - } - } else if(yres == 768) { - if( (pclk == 8100) && - (phb == (1688 - 1280)) && - (pvb == (802 - 768)) ) { - paneltype = Panel_1280x768; - checkexpand = FALSE; - cr37 |= 0x10; - } - } else if(yres == 800) { - if( (pclk == 6900) && - (phb == (1408 - 1280)) && - (pvb == (816 - 800)) ) { - paneltype = Panel_1280x800; - } - } - break; - case 1400: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(yres == 1050) { - paneltype = Panel310_1400x1050; - checkexpand = TRUE; - } - } - break; - case 1600: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_301C) { - if(yres == 1200) { - paneltype = Panel310_1600x1200; - checkexpand = TRUE; - } - } - } - break; - } - - /* Save sync: This is used if "Pass 1:1" is off; in this case - * we always use the panel's native mode = this "preferred mode" - * we just have been analysing. Hence, we also need its sync. - */ - if((buffer[0x47] & 0x18) == 0x18) { - cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20); - havesync = TRUE; - } else { - /* What now? There is no digital separate output timing... */ - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "LCD sense: Unable to retrieve Sync polarity information\n"); - cr37 |= 0xc0; /* Default */ - } - - } - - /* Check against our database; eg. Sanyo Z2 projector reports - * 1024x768 as preferred mode, although it supports 1280x720 - * natively in non-HDCP mode. Treat such wrongly reporting - * panels as custom and fixup actual maximum resolutions. - */ - if(paneltype != Panel_Custom) { - if(indb) { - paneltype = Panel_Custom; - SiS_Pr->CP_MaxX = maxx; - SiS_Pr->CP_MaxY = maxy; - /* Leave preferred unchanged (MUST contain a valid mode!) */ - } - } - - /* If we still don't know what panel this is, we take it - * as a custom panel and derive the timing data from the - * detailed timing blocks - */ - if(paneltype == Panel_Custom) { - - int i, temp, base = 0x36; - unsigned long estpack; - const unsigned short estx[] = { - 720, 720, 640, 640, 640, 640, 800, 800, - 800, 800, 832,1024,1024,1024,1024,1280, - 1152 - }; - const unsigned short esty[] = { - 400, 400, 480, 480, 480, 480, 600, 600, - 600, 600, 624, 768, 768, 768, 768,1024, - 870 - }; - const int estclk[] = { - 0, 0, 25100, 0, 31500, 31500, 36100, 40000, - 50100, 49500, 0, 0, 65100, 75200, 78700,135200, - 0 - }; - - paneltype = 0; - SiS_Pr->CP_Supports64048075 = TRUE; - - /* Find the maximum resolution */ - - /* 1. From Established timings */ - estpack = (buffer[0x23] << 9) | (buffer[0x24] << 1) | ((buffer[0x25] >> 7) & 0x01); - for(i=16; i>=0; i--) { - if(estpack & (1 << i)) { - if(estx[16 - i] > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = estx[16 - i]; - if(esty[16 - i] > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = esty[16 - i]; - if(estclk[16 - i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = estclk[16 - i]; - } - } - - /* By default we drive the LCD at 75Hz in 640x480 mode; if - * the panel does not provide this mode, use 60hz - */ - if(!(buffer[0x23] & 0x04)) SiS_Pr->CP_Supports64048075 = FALSE; - - /* 2. From Standard Timings */ - for(i=0x26; i < 0x36; i+=2) { - if((buffer[i] != 0x01) && (buffer[i+1] != 0x01)) { - temp = (buffer[i] + 31) * 8; - if(temp > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = temp; - switch((buffer[i+1] & 0xc0) >> 6) { - case 0x03: temp = temp * 9 / 16; break; - case 0x02: temp = temp * 4 / 5; break; - case 0x01: temp = temp * 3 / 4; break; - } - if(temp > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = temp; - } - } - - /* Now extract the Detailed Timings and convert them into modes */ - - for(i = 0; i < 4; i++, base += 18) { - - /* Is this a detailed timing block or a monitor descriptor? */ - if(buffer[base] || buffer[base+1] || buffer[base+2]) { - - xres = buffer[base+2] | ((buffer[base+4] & 0xf0) << 4); - yres = buffer[base+5] | ((buffer[base+7] & 0xf0) << 4); - - SiS_Pr->CP_HDisplay[i] = xres; - SiS_Pr->CP_HSyncStart[i] = xres + (buffer[base+8] | ((buffer[base+11] & 0xc0) << 2)); - SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[base+9] | ((buffer[base+11] & 0x30) << 4)); - SiS_Pr->CP_HTotal[i] = xres + (buffer[base+3] | ((buffer[base+4] & 0x0f) << 8)); - SiS_Pr->CP_HBlankStart[i] = xres + 1; - SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i]; - - SiS_Pr->CP_VDisplay[i] = yres; - SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[base+10] & 0xf0) >> 4) | ((buffer[base+11] & 0x0c) << 2)); - SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[base+10] & 0x0f) | ((buffer[base+11] & 0x03) << 4)); - SiS_Pr->CP_VTotal[i] = yres + (buffer[base+6] | ((buffer[base+7] & 0x0f) << 8)); - SiS_Pr->CP_VBlankStart[i] = yres + 1; - SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i]; - - SiS_Pr->CP_Clock[i] = (buffer[base] | (buffer[base+1] << 8)) * 10; - - SiS_Pr->CP_DataValid[i] = TRUE; - - /* Sort out invalid timings, interlace and too high clocks */ - if((SiS_Pr->CP_HDisplay[i] & 7) || - (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) || - (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) || - (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) || - (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) || - (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) || - (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) || - (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) || - (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) || - (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) || - (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) || - ((!(pSiS->VBFlags & VB_301C)) && - ((SiS_Pr->CP_Clock[i] > 108200) || (SiS_Pr->CP_VDisplay[i] > 1024) || - (SiS_Pr->CP_HDisplay[i] > 1600)))) || - (buffer[base+17] & 0x80)) { - - SiS_Pr->CP_DataValid[i] = FALSE; - - } else { - - SiS_Pr->CP_HaveCustomData = TRUE; - - if(xres > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = xres; - if(yres > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = yres; - if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; - - if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) { - SiS_Pr->CP_PreferredIndex = i; - SiS_MakeClockRegs(pSiS->pScrn, SiS_Pr->CP_Clock[i], &SiS_Pr->CP_PrefSR2B, &SiS_Pr->CP_PrefSR2C); - SiS_Pr->CP_PrefClock = (SiS_Pr->CP_Clock[i] / 1000) + 1; - } - - /* Extract the sync polarisation information. This only works - * if the Flags indicate a digital separate output. - */ - if((buffer[base+17] & 0x18) == 0x18) { - SiS_Pr->CP_HSync_P[i] = (buffer[base+17] & 0x02) ? TRUE : FALSE; - SiS_Pr->CP_VSync_P[i] = (buffer[base+17] & 0x04) ? TRUE : FALSE; - SiS_Pr->CP_SyncValid[i] = TRUE; - if((i == SiS_Pr->CP_PreferredIndex) && (!havesync)) { - cr37 |= ((((buffer[base+17] & 0x06) ^ 0x06) << 5) | 0x20); - havesync = TRUE; - } - } else { - SiS_Pr->CP_SyncValid[i] = FALSE; - } - - } - - } else if((!buffer[base]) && (!buffer[base+1]) && (!buffer[base+2]) && (!buffer[base+4])) { - - /* Maximum pixclock from Monitor Range Limits */ - if((buffer[base+3] == 0xfd) && (buffer[base+9] != 0xff)) { - int maxclk = buffer[base+9] * 10; - /* More than 170 is not supported anyway */ - if(maxclk <= 170) SiS_Pr->CP_MaxClock = maxclk * 1000; - } - - } - - } - - if(SiS_Pr->CP_MaxX && SiS_Pr->CP_MaxY) { - paneltype = Panel_Custom; - checkexpand = FALSE; - cr37 |= 0x10; - SiS_Pr->CP_Vendor = panelvendor; - SiS_Pr->CP_Product = panelproduct; - } - - } - - if(paneltype && checkexpand) { - /* If any of the Established low-res modes is supported, the - * panel can scale automatically. For 800x600 panels, we only - * check the even lower ones. - */ - if(paneltype == Panel_800x600) { - if(buffer[0x23] & 0xfc) cr37 |= 0x10; - } else { - if(buffer[0x23]) cr37 |= 0x10; - } - } - - break; - - case 3: /* Analyze EDID V2 */ - case 4: - index = 0; - - if(!(checkedid2(buffer))) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: EDID corrupt\n"); - return 0; - } - - if((buffer[0x41] & 0x0f) == 0x03) { - index = 0x42 + 3; - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Display supports TMDS input on primary interface\n"); - } else if((buffer[0x41] & 0xf0) == 0x30) { - index = 0x46 + 3; - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Display supports TMDS input on secondary interface\n"); - } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "LCD sense: Display does not support TMDS video interface (0x%02x)\n", - buffer[0x41]); - return 0; - } - - SiS_Pr->CP_Vendor = panelvendor = buffer[2] | (buffer[1] << 8); - SiS_Pr->CP_Product = panelproduct = buffer[3] | (buffer[4] << 8); - - paneltype = Panel_Custom; - SiS_Pr->CP_MaxX = SiS_Pr->CP_PreferredX = xres = buffer[0x76] | (buffer[0x77] << 8); - SiS_Pr->CP_MaxY = SiS_Pr->CP_PreferredY = yres = buffer[0x78] | (buffer[0x79] << 8); - - switch(xres) { -#if 0 - case 800: - if(yres == 600) { - paneltype = Panel_800x600; - checkexpand = TRUE; - } - break; -#endif - case 1024: - if(yres == 768) { - paneltype = Panel_1024x768; - checkexpand = TRUE; - } - break; - case 1280: - if(yres == 960) { - if(pSiS->VGAEngine == SIS_315_VGA) { - paneltype = Panel310_1280x960; - } else { - paneltype = Panel300_1280x960; - } - } else if(yres == 1024) { - paneltype = Panel_1280x1024; - checkexpand = TRUE; - } - /* 1280x768 treated as custom here */ - break; - case 1400: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(yres == 1050) { - paneltype = Panel310_1400x1050; - checkexpand = TRUE; - } - } - break; - case 1600: - if(pSiS->VGAEngine == SIS_315_VGA) { - if(pSiS->VBFlags & VB_301C) { - if(yres == 1200) { - paneltype = Panel310_1600x1200; - checkexpand = TRUE; - } - } - } - break; - } - - /* Determine if RGB18 or RGB24 */ - if(index) { - if((buffer[index] == 0x20) || (buffer[index] == 0x34)) { - cr37 |= 0x01; - } - } - - if(checkexpand) { - /* TODO - for now, we let the panel scale */ - cr37 |= 0x10; - } - - /* Now seek 4-Byte Timing codes and extract sync pol info */ - index = 0x80; - if(buffer[0x7e] & 0x20) { /* skip Luminance Table (if provided) */ - lumsize = buffer[0x80] & 0x1f; - if(buffer[0x80] & 0x80) lumsize *= 3; - lumsize++; /* luminance header byte */ - index += lumsize; - } -#if 0 /* "pixel rate" = pixel clock? */ - if(buffer[0x7e] & 0x1c) { - for(i=0; i<((buffer[0x7e] & 0x1c) >> 2); i++) { - if(buffer[index + (i*8) + 6] && (buffer[index + (i*8) + 7] & 0x0f)) { - int clk = (buffer[index + (i*8) + 6] | ((buffer[index + (i*8) + 7] & 0x0f) << 4)) * 1000; - if(clk > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = clk; - } - } - } -#endif - index += (((buffer[0x7e] & 0x1c) >> 2) * 8); /* skip Frequency Ranges */ - if(buffer[0x7e] & 0x03) { - for(i=0; i<(buffer[0x7e] & 0x03); i++) { - if((buffer[index + (i*27) + 9]) || (buffer[index + (i*27) + 10])) { - int clk = ((buffer[index + (i*27) + 9]) | ((buffer[index + (i*27) + 9]) << 8)) * 10; - if(clk > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = clk; - } - } - } - index += ((buffer[0x7e] & 0x03) * 27); /* skip Detailed Range Limits */ - numcodes = (buffer[0x7f] & 0xf8) >> 3; - if(numcodes) { - myindex = index; - seekcode = (xres - 256) / 16; - for(i=0; i<numcodes; i++) { - if(buffer[myindex] == seekcode) break; - myindex += 4; - } - if(buffer[myindex] == seekcode) { - cr37 |= ((((buffer[myindex + 1] & 0x0c) ^ 0x0c) << 4) | 0x20); - havesync = TRUE; - } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "LCD sense: Unable to retrieve Sync polarity information\n"); - } - } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, - "LCD sense: Unable to retrieve Sync polarity information\n"); - } - - /* Check against our database; Eg. Sanyo projector reports - * 1024x768 in non-HDPC mode, although it supports 1280x720. - * Treat such wrongly reporting panels as custom. - */ - if(paneltype != Panel_Custom) { - int maxx, maxy, prefx, prefy; - if((SiS_FindPanelFromDB(pSiS, panelvendor, panelproduct, &maxx, &maxy, &prefx, &prefy))) { - paneltype = Panel_Custom; - SiS_Pr->CP_MaxX = maxx; - SiS_Pr->CP_MaxY = maxy; - cr37 |= 0x10; - /* Leave preferred unchanged (MUST be a valid mode!) */ - } - } - - /* Now seek the detailed timing descriptions for custom panels */ - if(paneltype == Panel_Custom) { - - SiS_Pr->CP_Supports64048075 = TRUE; - - index += (numcodes * 4); - numcodes = buffer[0x7f] & 0x07; - for(i=0; i<numcodes; i++, index += 18) { - xres = buffer[index+2] | ((buffer[index+4] & 0xf0) << 4); - yres = buffer[index+5] | ((buffer[index+7] & 0xf0) << 4); - - SiS_Pr->CP_HDisplay[i] = xres; - SiS_Pr->CP_HSyncStart[i] = xres + (buffer[index+8] | ((buffer[index+11] & 0xc0) << 2)); - SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[index+9] | ((buffer[index+11] & 0x30) << 4)); - SiS_Pr->CP_HTotal[i] = xres + (buffer[index+3] | ((buffer[index+4] & 0x0f) << 8)); - SiS_Pr->CP_HBlankStart[i] = xres + 1; - SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i]; - - SiS_Pr->CP_VDisplay[i] = yres; - SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[index+10] & 0xf0) >> 4) | ((buffer[index+11] & 0x0c) << 2)); - SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[index+10] & 0x0f) | ((buffer[index+11] & 0x03) << 4)); - SiS_Pr->CP_VTotal[i] = yres + (buffer[index+6] | ((buffer[index+7] & 0x0f) << 8)); - SiS_Pr->CP_VBlankStart[i] = yres + 1; - SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i]; - - SiS_Pr->CP_Clock[i] = (buffer[index] | (buffer[index+1] << 8)) * 10; - - SiS_Pr->CP_DataValid[i] = TRUE; - - if((SiS_Pr->CP_HDisplay[i] & 7) || - (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) || - (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) || - (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) || - (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) || - (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) || - (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) || - (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) || - (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) || - (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) || - (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) || - (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) || - ((!(pSiS->VBFlags & VB_301C)) && - ((SiS_Pr->CP_Clock[i] > 108200) || (SiS_Pr->CP_VDisplay[i] > 1024)))) || - (buffer[index + 17] & 0x80)) { - - SiS_Pr->CP_DataValid[i] = FALSE; - - } else { - - SiS_Pr->CP_HaveCustomData = TRUE; - - if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i]; - - if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) { - SiS_Pr->CP_PreferredIndex = i; - SiS_MakeClockRegs(pSiS->pScrn, SiS_Pr->CP_Clock[i], &SiS_Pr->CP_PrefSR2B, &SiS_Pr->CP_PrefSR2C); - SiS_Pr->CP_PrefClock = (SiS_Pr->CP_Clock[i] / 1000) + 1; - if(!havesync) { - cr37 |= ((((buffer[index + 17] & 0x06) ^ 0x06) << 5) | 0x20); - havesync = TRUE; - } - } - - SiS_Pr->CP_HSync_P[i] = (buffer[index + 17] & 0x02) ? TRUE : FALSE; - SiS_Pr->CP_VSync_P[i] = (buffer[index + 17] & 0x04) ? TRUE : FALSE; - SiS_Pr->CP_SyncValid[i] = TRUE; - - } - } - - cr37 |= 0x10; - - } - - break; - - } - - /* 1280x960 panels are always RGB24, unable to scale and use - * high active sync polarity - */ - if(pSiS->VGAEngine == SIS_315_VGA) { - if(paneltype == Panel310_1280x960) cr37 &= 0x0e; - } else { - if(paneltype == Panel300_1280x960) cr37 &= 0x0e; - } - - for(i = 0; i < 7; i++) { - if(SiS_Pr->CP_DataValid[i]) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "Non-standard LCD/DVI-D timing data no. %d:\n", i); - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - " HDisplay %d HSync %d HSyncEnd %d HTotal %d\n", - SiS_Pr->CP_HDisplay[i], SiS_Pr->CP_HSyncStart[i], - SiS_Pr->CP_HSyncEnd[i], SiS_Pr->CP_HTotal[i]); - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - " VDisplay %d VSync %d VSyncEnd %d VTotal %d\n", - SiS_Pr->CP_VDisplay[i], SiS_Pr->CP_VSyncStart[i], - SiS_Pr->CP_VSyncEnd[i], SiS_Pr->CP_VTotal[i]); - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - " Pixel clock: %3.3fMhz\n", (float)SiS_Pr->CP_Clock[i] / 1000); - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, - " To use this, add \"%dx%d\" to the list of Modes in the Screen section\n", - SiS_Pr->CP_HDisplay[i], - SiS_Pr->CP_VDisplay[i]); - } - } - - if(paneltype) { - if(!SiS_Pr->CP_PreferredX) SiS_Pr->CP_PreferredX = SiS_Pr->CP_MaxX; - if(!SiS_Pr->CP_PreferredY) SiS_Pr->CP_PreferredY = SiS_Pr->CP_MaxY; - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x08); - SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,paneltype); - cr37 &= 0xf1; - SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0x0c,cr37); - SiS_Pr->PanelSelfDetected = TRUE; -#ifdef TWDEBUG - xf86DrvMsgVerb(pSiS->pScrn->scrnIndex, X_PROBED, 3, - "LCD sense: [DDC LCD results: 0x%02x, 0x%02x]\n", paneltype, cr37); -#endif - } else { - SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x32,~0x08); - SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,0x00); - } - return 0; -} - -USHORT -SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS) -{ - USHORT DDCdatatype,flag; - BOOLEAN foundcrt = FALSE; - int retry; - unsigned char buffer[256]; - - if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0; - - if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 2, 0, FALSE) == 0xFFFF) return 0; - - SiS_Pr->SiS_DDC_SecAddr = 0x00; - - /* Probe supported DA's */ - flag = SiS_ProbeDDC(SiS_Pr); - if(flag & 0x10) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */ - DDCdatatype = 4; - } else if(flag & 0x08) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */ - DDCdatatype = 3; - } else if(flag & 0x02) { - SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */ - DDCdatatype = 1; - } else { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "VGA2 sense: Do DDC answer\n"); - return 0; /* no DDC support (or no device attached) */ - } - - /* Read the entire EDID */ - retry = 2; - do { - if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, - "VGA2 sense: DDC read failed (attempt %d), %s\n", - (3-retry), (retry == 1) ? "giving up" : "retrying"); - retry--; - if(retry == 0) return 0xFFFF; - } else break; - } while(1); - - /* Analyze EDID. We don't have many chances to - * distinguish a flat panel from a CRT... - */ - switch(DDCdatatype) { - case 1: - if(!(checkedid1(buffer))) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "VGA2 sense: EDID corrupt\n"); - return 0; - } - if(buffer[0x14] & 0x80) { /* Display uses digital input */ - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "VGA2 sense: Attached display expects digital input\n"); - return 0; - } - SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8); - SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8); - foundcrt = TRUE; - break; - case 3: - case 4: - if(!(checkedid2(buffer))) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "VGA2 sense: EDID corrupt\n"); - return 0; - } - if( ((buffer[0x41] & 0x0f) != 0x01) && /* Display does not support analog input */ - ((buffer[0x41] & 0x0f) != 0x02) && - ((buffer[0x41] & 0xf0) != 0x10) && - ((buffer[0x41] & 0xf0) != 0x20) ) { - xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR, - "VGA2 sense: Attached display does not support analog input (0x%02x)\n", - buffer[0x41]); - return 0; - } - SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8); - SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8); - foundcrt = TRUE; - break; - } - - if(foundcrt) { - SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10); - } - return(0); -} - -#endif - -void -SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh) -{ - USHORT tempbl; - - tempbl = SiS_GetCH70xx(SiS_Pr,(tempax & 0x00FF)); - tempbl = (((tempbl & tempbh) << 8) | tempax); - SiS_SetCH70xx(SiS_Pr,tempbl); -} - /* Generic I2C functions for Chrontel & DDC --------- */ static void -SiS_SetSwitchDDC2(SiS_Private *SiS_Pr) +SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr) { SiS_SetSCLKHigh(SiS_Pr); SiS_WaitRetrace1(SiS_Pr); @@ -10505,125 +9502,127 @@ SiS_SetSwitchDDC2(SiS_Private *SiS_Pr) SiS_WaitRetrace1(SiS_Pr); } -USHORT -SiS_ReadDDC1Bit(SiS_Private *SiS_Pr) +unsigned short +SiS_ReadDDC1Bit(struct SiS_Private *SiS_Pr) { SiS_WaitRetrace1(SiS_Pr); - return((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1); + return ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1); } /* Set I2C start condition */ /* This is done by a SD high-to-low transition while SC is high */ -static USHORT -SiS_SetStart(SiS_Private *SiS_Pr) +static unsigned short +SiS_SetStart(struct SiS_Private *SiS_Pr) { - if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ + if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - SiS_Pr->SiS_DDC_Data); /* SD->high */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* SD->high */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - 0x00); /* SD->low = start condition */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* SD->low = start condition */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */ return 0; } /* Set I2C stop condition */ /* This is done by a SD low-to-high transition while SC is high */ -static USHORT -SiS_SetStop(SiS_Private *SiS_Pr) +static unsigned short +SiS_SetStop(struct SiS_Private *SiS_Pr) { - if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ + if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - 0x00); /* SD->low */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* SD->low */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ - if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ + if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */ return 0; } /* Write 8 bits of data */ -static USHORT -SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) +static unsigned short +SiS_WriteDDC2Data(struct SiS_Private *SiS_Pr, unsigned short tempax) { - USHORT i,flag,temp; + unsigned short i,flag,temp; flag = 0x80; - for(i=0; i<8; i++) { - SiS_SetSCLKLow(SiS_Pr); /* SC->low */ + for(i = 0; i < 8; i++) { + SiS_SetSCLKLow(SiS_Pr); /* SC->low */ if(tempax & flag) { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */ } else { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - 0x00); /* Write bit (0) to SD */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + 0x00); /* Write bit (0) to SD */ } - SiS_SetSCLKHigh(SiS_Pr); /* SC->high */ + SiS_SetSCLKHigh(SiS_Pr); /* SC->high */ flag >>= 1; } - temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */ - return(temp); + temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */ + return temp; } -static USHORT -SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) +static unsigned short +SiS_ReadDDC2Data(struct SiS_Private *SiS_Pr) { - USHORT i,temp,getdata; + unsigned short i, temp, getdata; - getdata=0; - for(i=0; i<8; i++) { + getdata = 0; + for(i = 0; i < 8; i++) { getdata <<= 1; SiS_SetSCLKLow(SiS_Pr); SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, SiS_Pr->SiS_DDC_Data); SiS_SetSCLKHigh(SiS_Pr); temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); if(temp & SiS_Pr->SiS_DDC_Data) getdata |= 0x01; } - return(getdata); + return getdata; } -static USHORT -SiS_SetSCLKLow(SiS_Private *SiS_Pr) +static unsigned short +SiS_SetSCLKLow(struct SiS_Private *SiS_Pr) { SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NClk, - 0x00); /* SetSCLKLow() */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NClk, + 0x00); /* SetSCLKLow() */ SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); return 0; } -static USHORT -SiS_SetSCLKHigh(SiS_Private *SiS_Pr) +static unsigned short +SiS_SetSCLKHigh(struct SiS_Private *SiS_Pr) { - USHORT temp, watchdog=1000; + unsigned short temp, watchdog=1000; SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NClk, + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NClk, SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */ do { temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog); if (!watchdog) { +#ifdef SIS_XORG_XF86 #ifdef TWDEBUG xf86DrvMsg(0, X_INFO, "SetClkHigh failed\n"); #endif +#endif return 0xFFFF; } SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); @@ -10632,21 +9631,21 @@ SiS_SetSCLKHigh(SiS_Private *SiS_Pr) /* Check I2C acknowledge */ /* Returns 0 if ack ok, non-0 if ack not ok */ -static USHORT -SiS_CheckACK(SiS_Private *SiS_Pr) +static unsigned short +SiS_CheckACK(struct SiS_Private *SiS_Pr) { - USHORT tempah; + unsigned short tempah; SiS_SetSCLKLow(SiS_Pr); /* (SC->low) */ SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, - SiS_Pr->SiS_DDC_Index, - SiS_Pr->SiS_DDC_NData, - SiS_Pr->SiS_DDC_Data); /* (SD->high) */ + SiS_Pr->SiS_DDC_Index, + SiS_Pr->SiS_DDC_NData, + SiS_Pr->SiS_DDC_Data); /* (SD->high) */ SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */ tempah = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); /* Read SD */ SiS_SetSCLKLow(SiS_Pr); /* SC->low = end of clock impulse */ - if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* Ack OK if bit = 0 */ - else return(0); + if(tempah & SiS_Pr->SiS_DDC_Data) return 1; /* Ack OK if bit = 0 */ + return 0; } /* End of I2C functions ----------------------- */ @@ -10656,67 +9655,67 @@ SiS_CheckACK(SiS_Private *SiS_Pr) #ifdef SIS315H -static USHORT -GetRAMDACromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetRAMDACromptr(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr; - if(HwInfo->jChipType < SIS_330) { + if(SiS_Pr->ChipType < SIS_330) { romptr = SISGETROMW(0x128); - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) + if(SiS_Pr->SiS_VBType & VB_SIS30xB) romptr = SISGETROMW(0x12a); } else { romptr = SISGETROMW(0x1a8); - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) + if(SiS_Pr->SiS_VBType & VB_SIS30xB) romptr = SISGETROMW(0x1aa); } - return(romptr); + return romptr; } -static USHORT -GetLCDromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetLCDromptr(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr; - if(HwInfo->jChipType < SIS_330) { + if(SiS_Pr->ChipType < SIS_330) { romptr = SISGETROMW(0x120); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) romptr = SISGETROMW(0x122); } else { romptr = SISGETROMW(0x1a0); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) romptr = SISGETROMW(0x1a2); } - return(romptr); + return romptr; } -static USHORT -GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetTVromptr(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr; - if(HwInfo->jChipType < SIS_330) { + if(SiS_Pr->ChipType < SIS_330) { romptr = SISGETROMW(0x114); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) romptr = SISGETROMW(0x11a); } else { romptr = SISGETROMW(0x194); - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) romptr = SISGETROMW(0x19a); } - return(romptr); + return romptr; } -static USHORT -GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +static unsigned short +GetLCDPtrIndexBIOS(struct SiS_Private *SiS_Pr) { - USHORT index; + unsigned short index; - if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { + if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { + if(!(SiS_IsNotM650orLater(SiS_Pr))) { if((index = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) { index >>= 4; index *= 3; @@ -10729,7 +9728,12 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) index = SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F; if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) index -= 5; - else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6; + if(SiS_Pr->SiS_VBType & VB_SIS301C) { /* 1.15.20 and later (not VB specific) */ + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 5; + if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768) index -= 5; + } else { + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6; + } index--; index *= 3; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; @@ -10737,10 +9741,10 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) return index; } -static USHORT -GetLCDPtrIndex(SiS_Private *SiS_Pr) +static unsigned short +GetLCDPtrIndex(struct SiS_Private *SiS_Pr) { - USHORT index; + unsigned short index; index = ((SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F) - 1) * 3; if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; @@ -10748,10 +9752,10 @@ GetLCDPtrIndex(SiS_Private *SiS_Pr) return index; } -static USHORT -GetTVPtrIndex(SiS_Private *SiS_Pr) +static unsigned short +GetTVPtrIndex(struct SiS_Private *SiS_Pr) { - USHORT index; + unsigned short index; index = 0; if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; @@ -10769,10 +9773,10 @@ GetTVPtrIndex(SiS_Private *SiS_Pr) return index; } -static ULONG -GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme) +static unsigned int +GetOEMTVPtr661_2_GEN(struct SiS_Private *SiS_Pr, int addme) { - USHORT index = 0, temp = 0; + unsigned short index = 0, temp = 0; if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; if(SiS_Pr->SiS_TVMode & TVSetPALM) index = 2; @@ -10784,7 +9788,7 @@ GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme) if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 7; } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { index += addme; @@ -10792,25 +9796,25 @@ GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme) } temp += 0x0100; } - return(ULONG)(index | (temp << 16)); + return (unsigned int)(index | (temp << 16)); } -static ULONG -GetOEMTVPtr661_2_OLD(SiS_Private *SiS_Pr) +static unsigned int +GetOEMTVPtr661_2_OLD(struct SiS_Private *SiS_Pr) { - return(GetOEMTVPtr661_2_GEN(SiS_Pr, 8)); + return (GetOEMTVPtr661_2_GEN(SiS_Pr, 8)); } #if 0 -static ULONG -GetOEMTVPtr661_2_NEW(SiS_Private *SiS_Pr) +static unsigned int +GetOEMTVPtr661_2_NEW(struct SiS_Private *SiS_Pr) { - return(GetOEMTVPtr661_2_GEN(SiS_Pr, 6)); + return (GetOEMTVPtr661_2_GEN(SiS_Pr, 6)); } #endif static int -GetOEMTVPtr661(SiS_Private *SiS_Pr) +GetOEMTVPtr661(struct SiS_Private *SiS_Pr) { int index = 0; @@ -10833,10 +9837,10 @@ GetOEMTVPtr661(SiS_Private *SiS_Pr) } static void -SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) +SetDelayComp(struct SiS_Private *SiS_Pr, unsigned short ModeNo) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT delay=0,index,myindex,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short delay=0,index,myindex,temp,romptr=0; BOOLEAN dochiptest = TRUE; if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { @@ -10848,19 +9852,19 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) /* Find delay (from ROM, internal tables, PCI subsystem) */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* ------------ VGA */ - + if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { - romptr = GetRAMDACromptr(SiS_Pr, HwInfo); + romptr = GetRAMDACromptr(SiS_Pr); } if(romptr) delay = ROMAddr[romptr]; else { delay = 0x04; - if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(SiS_Pr->SiS_VBType & VB_SIS30xB) { if(IS_SIS650) { delay = 0x0a; } else if(IS_SIS740) { delay = 0x00; - } else if(HwInfo->jChipType < SIS_330) { + } else if(SiS_Pr->ChipType < SIS_330) { delay = 0x0c; } else { delay = 0x0c; @@ -10901,8 +9905,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,delay); } else { delay = 0x0c; - if(SiS_Pr->SiS_VBType & VB_SIS301C) delay = 0x03; - else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SIS301C) { + delay = 0x03; + if((SiS_Pr->PanelXRes > 1280) && (SiS_Pr->PanelYRes > 1024)) { + delay = 0x00; + } + } else if(SiS_Pr->SiS_VBType & VB_SISLVDS) { if(IS_SIS740) delay = 0x01; else delay = 0x03; } @@ -10947,12 +9955,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) if(!gotitfrompci) { - index = GetLCDPtrIndexBIOS(SiS_Pr, HwInfo); + index = GetLCDPtrIndexBIOS(SiS_Pr); myindex = GetLCDPtrIndex(SiS_Pr); - if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { - if(SiS_IsNotM650orLater(SiS_Pr, HwInfo)) { + if(SiS_IsNotM650orLater(SiS_Pr)) { if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { /* Always use the second pointer on 650; some BIOSes */ @@ -10978,11 +9986,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) (!(SiS_Pr->SiS_ROMNew)) && (SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) && (SiS_Pr->SiS_LCDResInfo != Panel_1280x768) && - (SiS_Pr->SiS_LCDResInfo != Panel_1280x960)) { + (SiS_Pr->SiS_LCDResInfo != Panel_1280x960) && + (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200) && + ((romptr = GetLCDromptr(SiS_Pr)))) { /* Data for 1280x1024 wrong in 301B BIOS */ - romptr = GetLCDromptr(SiS_Pr, HwInfo); - if(!romptr) return; + /* Data for 1600x1200 wrong in 301C BIOS */ delay = ROMAddr[(romptr + index)]; } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { @@ -10993,14 +10002,15 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } else { delay = SiS310_LCDDelayCompensation_301[myindex]; - if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { if(IS_SIS740) delay = 0x01; - else if(HwInfo->jChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex]; + else if(SiS_Pr->ChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex]; else delay = SiS310_LCDDelayCompensation_650301LV[myindex]; } else if(SiS_Pr->SiS_VBType & VB_SIS301C) { if(IS_SIS740) delay = 0x01; /* ? */ else delay = 0x03; - } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { + if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) delay = 0x00; /* experience */ + } else if(SiS_Pr->SiS_VBType & VB_SIS30xB) { if(IS_SIS740) delay = 0x01; else delay = SiS310_LCDDelayCompensation_3xx301B[myindex]; } @@ -11013,14 +10023,14 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,((delay << 4) & 0xf0)); dochiptest = FALSE; } - + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* ------------ TV */ index = GetTVPtrIndex(SiS_Pr); - - if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { - if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { + + if(SiS_IsNotM650orLater(SiS_Pr)) { if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { /* Always use the second pointer on 650; some BIOSes */ @@ -11062,7 +10072,7 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } else if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { - romptr = GetTVromptr(SiS_Pr, HwInfo); + romptr = GetTVromptr(SiS_Pr); if(!romptr) return; delay = ROMAddr[romptr + index]; @@ -11073,7 +10083,7 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } else { delay = SiS310_TVDelayCompensation_301[index]; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { if(IS_SIS740) { delay = SiS310_TVDelayCompensation_740301B[index]; /* LV: use 301 data? BIOS bug? */ @@ -11085,18 +10095,18 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } - if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { + if(SiS_LCDAEnabled(SiS_Pr)) { delay &= 0x0f; dochiptest = FALSE; } - + } else return; /* Write delay */ if(SiS_Pr->SiS_VBType & VB_SISVB) { - if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && dochiptest) { + if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS) && dochiptest) { temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; if(temp == 8) { /* 1400x1050 BIOS (COMPAL) */ @@ -11134,11 +10144,10 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) } static void -SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetAntiFlicker(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,temp1,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,temp1,romptr=0; if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p|TVSetYPbPr525p)) return; @@ -11152,14 +10161,14 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, temp1 = temp; if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { temp1 = GetOEMTVPtr661(SiS_Pr); temp1 >>= 1; romptr = SISGETROMW(0x260); - if(HwInfo->jChipType >= SIS_760) { + if(SiS_Pr->ChipType >= SIS_760) { romptr = SISGETROMW(0x360); } - } else if(HwInfo->jChipType >= SIS_330) { + } else if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x192); } else { romptr = SISGETROMW(0x112); @@ -11178,11 +10187,10 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetEdgeEnhance(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,temp1,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,temp1,romptr=0; temp = temp1 = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ @@ -11192,14 +10200,14 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { - if(HwInfo->jChipType >= SIS_661) { + if(SiS_Pr->ChipType >= SIS_661) { romptr = SISGETROMW(0x26c); - if(HwInfo->jChipType >= SIS_760) { + if(SiS_Pr->ChipType >= SIS_760) { romptr = SISGETROMW(0x36c); } temp1 = GetOEMTVPtr661(SiS_Pr); temp1 >>= 1; - } else if(HwInfo->jChipType >= SIS_330) { + } else if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x1a4); } else { romptr = SISGETROMW(0x124); @@ -11217,10 +10225,9 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetYFilter(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) { - USHORT index, temp, i, j; + unsigned short index, temp, i, j; if(ModeNo <= 0x13) { index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; @@ -11235,7 +10242,7 @@ SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 4; /* PAL-N */ if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = 1; /* HiVision uses PAL */ - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { for(i=0x35, j=0; i<=0x38; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); } @@ -11250,23 +10257,22 @@ SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetPhaseIncr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,i,j,resinfo,romptr=0; - ULONG lindex; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,i,j,resinfo,romptr=0; + unsigned int lindex; if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; /* NTSC-J data not in BIOS, and already set in SetGroup2 */ if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) return; - if((HwInfo->jChipType >= SIS_661) || SiS_Pr->SiS_ROMNew) { + if((SiS_Pr->ChipType >= SIS_661) || SiS_Pr->SiS_ROMNew) { lindex = GetOEMTVPtr661_2_OLD(SiS_Pr) & 0xffff; lindex <<= 2; for(j=0, i=0x31; i<=0x34; i++, j++) { - SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS661_TVPhase[lindex + j]); + SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_TVPhase[lindex + j]); } return; } @@ -11286,17 +10292,17 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, */ if(SiS_Pr->SiS_UseROM) { romptr = SISGETROMW(0x116); - if(HwInfo->jChipType >= SIS_330) { + if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x196); } - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { romptr = SISGETROMW(0x11c); - if(HwInfo->jChipType >= SIS_330) { + if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x19c); } if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) { romptr = SISGETROMW(0x116); - if(HwInfo->jChipType >= SIS_330) { + if(SiS_Pr->ChipType >= SIS_330) { romptr = SISGETROMW(0x196); } } @@ -11311,7 +10317,7 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, index = temp % 2; temp >>= 1; /* 0:NTSC, 1:PAL, 2:HiTV */ for(j=0, i=0x31; i<=0x34; i++, j++) { - if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) + if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]); @@ -11320,7 +10326,7 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } } - if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) { + if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) { if((!(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetYPbPr525p | TVSetYPbPr750p))) && (ModeNo > 0x13)) { if((resinfo == SIS_RI_640x480) || (resinfo == SIS_RI_800x600)) { @@ -11339,11 +10345,11 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, - USHORT ModeIdIndex, USHORT RTI) +SetDelayComp661(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RTI) { - USHORT delay = 0, romptr = 0, index, lcdpdcindex; - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; + unsigned short delay = 0, romptr = 0, index, lcdpdcindex; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC))) return; @@ -11359,7 +10365,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, if(SiS_Pr->UseCustomMode) { index = SiS_Pr->CSRClock; } else if(ModeNo > 0x13) { - index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI,HwInfo); + index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI); index = SiS_Pr->SiS_VCLKData[index].CLOCK; } if(index < 25) index = 25; @@ -11387,7 +10393,36 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, else delay = (SiS_Pr->SiS_RefIndex[RTI].Ext_PDC >> 4); delay |= (delay << 8); - if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + if(SiS_Pr->ChipType >= XGI_20) { + + delay = 0x0606; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + + delay = 0x0404; + if(SiS_Pr->SiS_XGIROM) { + index = GetTVPtrIndex(SiS_Pr); + if((romptr = SISGETROMW(0x35e))) { + delay = (ROMAddr[romptr + index] & 0x0f) << 1; + delay |= (delay << 8); + } + } + + if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { + if(SiS_Pr->ChipType == XGI_40 && SiS_Pr->ChipRevision == 0x02) { + delay -= 0x0404; + } + } + } + + } else if(SiS_Pr->ChipType >= SIS_340) { + + delay = 0x0606; + if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { + delay = 0x0404; + } + /* TODO (eventually) */ + + } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* 3. TV */ @@ -11406,7 +10441,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, /* 4. LCD, LCDA (for new ROM only LV and non-Pass 1:1) */ if( (SiS_Pr->SiS_LCDResInfo != Panel_Custom) && - ((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) ) { + ((romptr = GetLCDStructPtr661_2(SiS_Pr))) ) { lcdpdcindex = (SiS_Pr->SiS_VBType & VB_UMC) ? 14 : 12; @@ -11426,6 +10461,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, case Panel_1280x768_2:delay = 0x0004; break; case Panel_1280x800: case Panel_1280x800_2:delay = 0x0004; break; /* Verified for 1280x800 */ + case Panel_1280x854: delay = 0x0004; break; /* FIXME */ case Panel_1280x1024: delay = 0x1e04; break; case Panel_1400x1050: delay = 0x0004; break; case Panel_1600x1200: delay = 0x0400; break; @@ -11469,10 +10505,10 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, } static void -SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT RTI) +SetCRT2SyncDither661(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short RTI) { - USHORT infoflag; - UCHAR temp; + unsigned short infoflag; + unsigned char temp; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { @@ -11513,12 +10549,16 @@ SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, US } static void -SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) +SetPanelParms661(struct SiS_Private *SiS_Pr) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT romptr, temp1, temp2; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short romptr, temp1, temp2; + + if(SiS_Pr->SiS_VBType & (VB_SISLVDS | VB_SIS30xC)) { + SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x24,0x0f); + } - if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { if(SiS_Pr->LVDSHL != -1) { SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); } @@ -11526,8 +10566,8 @@ SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) if(SiS_Pr->SiS_ROMNew) { - if((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) { - if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { + if((romptr = GetLCDStructPtr661_2(SiS_Pr))) { + if(SiS_Pr->SiS_VBType & VB_SISLVDS) { temp1 = (ROMAddr[romptr] & 0x03) | 0x0c; temp2 = 0xfc; if(SiS_Pr->LVDSHL != -1) { @@ -11546,48 +10586,47 @@ SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) } static void -SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex,USHORT RRTI) +SiS_OEM310Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RRTI) { if((SiS_Pr->SiS_ROMNew) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { - SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI); + SetDelayComp661(SiS_Pr, ModeNo, ModeIdIndex, RRTI); if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI); - SetPanelParms661(SiS_Pr,HwInfo); + SetCRT2SyncDither661(SiS_Pr, ModeNo, RRTI); + SetPanelParms661(SiS_Pr); } } else { - SetDelayComp(SiS_Pr,HwInfo,ModeNo); + SetDelayComp(SiS_Pr,ModeNo); } if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { - SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); - SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); - SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetAntiFlicker(SiS_Pr,ModeNo,ModeIdIndex); + SetPhaseIncr(SiS_Pr,ModeNo,ModeIdIndex); + SetYFilter(SiS_Pr,ModeNo,ModeIdIndex); if(SiS_Pr->SiS_VBType & VB_SIS301) { - SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetEdgeEnhance(SiS_Pr,ModeNo,ModeIdIndex); } } } static void -SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI) +SiS_OEM661Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + unsigned short ModeIdIndex, unsigned short RRTI) { if(SiS_Pr->SiS_VBType & VB_SISVB) { - SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI); + SetDelayComp661(SiS_Pr, ModeNo, ModeIdIndex, RRTI); if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { - SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI); - SetPanelParms661(SiS_Pr,HwInfo); + SetCRT2SyncDither661(SiS_Pr, ModeNo, RRTI); + SetPanelParms661(SiS_Pr); } if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); - SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); - SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetPhaseIncr(SiS_Pr, ModeNo, ModeIdIndex); + SetYFilter(SiS_Pr, ModeNo, ModeIdIndex); + SetAntiFlicker(SiS_Pr, ModeNo, ModeIdIndex); if(SiS_Pr->SiS_VBType & VB_SIS301) { - SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); + SetEdgeEnhance(SiS_Pr, ModeNo, ModeIdIndex); } } } @@ -11601,13 +10640,12 @@ SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, * pray that we have a backup... */ static void -SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, - PSIS_HW_INFO HwInfo) +SiS_FinalizeLCD(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - USHORT tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp; - USHORT resinfo,modeflag; + unsigned short tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp; + unsigned short resinfo,modeflag; - if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) return; + if(!(SiS_Pr->SiS_VBType & VB_SISLVDS)) return; if(SiS_Pr->SiS_ROMNew) return; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { @@ -11678,7 +10716,7 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { - if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { + if(SiS_Pr->SiS_VBType & VB_SISEMI) { SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); #ifdef SET_EMI SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); @@ -11806,11 +10844,11 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, #ifdef SIS300 static void -SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex) +SetOEMLCDData2(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex, + unsigned short RefTabIndex) { - USHORT crt2crtc=0, modeflag, myindex=0; - UCHAR temp; + unsigned short crt2crtc=0, modeflag, myindex=0; + unsigned char temp; int i; if(ModeNo <= 0x13) { @@ -11849,21 +10887,21 @@ SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } } -static USHORT -GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int Flag) +static unsigned short +GetOEMLCDPtr(struct SiS_Private *SiS_Pr, int Flag) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT tempbx=0,romptr=0; - UCHAR customtable300[] = { - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short tempbx=0,romptr=0; + static const unsigned char customtable300[] = { + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }; - UCHAR customtable630[] = { - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + static const unsigned char customtable630[] = { + 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }; - if(HwInfo->jChipType == SIS_300) { + if(SiS_Pr->ChipType == SIS_300) { tempbx = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f; if(SiS_Pr->SiS_VBType & VB_SIS301) tempbx &= 0x07; @@ -11912,11 +10950,10 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int Flag) } static void -SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMLCDDelay(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,romptr=0; if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return; @@ -11927,22 +10964,22 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } /* The Panel Compensation Delay should be set according to tables - * here. Unfortunately, various BIOS versions don't case about + * here. Unfortunately, various BIOS versions don't care about * a uniform way using eg. ROM byte 0x220, but use different * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). - * Thus we don't set this if the user select a custom pdc or if + * Thus we don't set this if the user selected a custom pdc or if * we otherwise detected a valid pdc. */ if(SiS_Pr->PDC != -1) return; - temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 0); + temp = GetOEMLCDPtr(SiS_Pr, 0); if(SiS_Pr->UseCustomMode) index = 0; else index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex; - if(HwInfo->jChipType != SIS_300) { + if(SiS_Pr->ChipType != SIS_300) { if(romptr) { romptr += (temp * 2); romptr = SISGETROMW(romptr); @@ -11986,12 +11023,11 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMLCDData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { #if 0 /* Unfinished; Data table missing */ - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp; if((SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x237] & 0x01)) return; @@ -11999,8 +11035,8 @@ SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, /* No rom pointer in BIOS header! */ } - temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 1); - if(temp = 0xFFFF) return; + temp = GetOEMLCDPtr(SiS_Pr, 1); + if(temp == 0xFFFF) return; index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDHIndex; for(i=0x14, j=0; i<=0x17; i++, j++) { @@ -12018,10 +11054,10 @@ SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, #endif } -static USHORT -GetOEMTVPtr(SiS_Private *SiS_Pr) +static unsigned short +GetOEMTVPtr(struct SiS_Private *SiS_Pr) { - USHORT index; + unsigned short index; index = 0; if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4; @@ -12037,11 +11073,10 @@ GetOEMTVPtr(SiS_Private *SiS_Pr) } static void -SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMTVDelay(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,romptr=0; if(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; @@ -12070,11 +11105,10 @@ SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex) +SetOEMAntiFlicker(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,romptr=0; if(SiS_Pr->SiS_UseROM) { if(!(ROMAddr[0x238] & 0x01)) return; @@ -12099,11 +11133,10 @@ SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMPhaseIncr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,i,j,temp,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,i,j,temp,romptr=0; if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) return; @@ -12119,7 +11152,7 @@ SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVPhaseIndex; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { for(i=0x31, j=0; i<=0x34; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]); } @@ -12140,11 +11173,10 @@ SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } static void -SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo,USHORT ModeIdIndex) +SetOEMYFilter(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) { - UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; - USHORT index,temp,i,j,romptr=0; + unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; + unsigned short index,temp,i,j,romptr=0; if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVision | SetCRT2ToYPbPr525750)) return; @@ -12162,7 +11194,7 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex; - if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { + if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { for(i=0x35, j=0; i<=0x38; i++, j++) { SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); } @@ -12185,11 +11217,11 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } } -static USHORT -SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo) +static unsigned short +SiS_SearchVBModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo) { - USHORT ModeIdIndex; - UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; + unsigned short ModeIdIndex; + unsigned char VGAINFO = SiS_Pr->SiS_VGAINFO; if(*ModeNo <= 5) *ModeNo |= 1; @@ -12210,10 +11242,10 @@ SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo) } static void -SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, - USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTableIndex) +SiS_OEM300Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short RefTableIndex) { - USHORT OEMModeIdIndex=0; + unsigned short OEMModeIdIndex = 0; if(!SiS_Pr->UseCustomMode) { OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo); @@ -12221,18 +11253,18 @@ SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, } if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { - SetOEMLCDDelay(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMLCDDelay(SiS_Pr, ModeNo, OEMModeIdIndex); if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { - SetOEMLCDData(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMLCDData(SiS_Pr, ModeNo, OEMModeIdIndex); } } if(SiS_Pr->UseCustomMode) return; if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { - SetOEMTVDelay(SiS_Pr, HwInfo, ModeNo,OEMModeIdIndex); + SetOEMTVDelay(SiS_Pr, ModeNo,OEMModeIdIndex); if(SiS_Pr->SiS_VBType & VB_SISVB) { - SetOEMAntiFlicker(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); - SetOEMPhaseIncr(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); - SetOEMYFilter(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); + SetOEMAntiFlicker(SiS_Pr, ModeNo, OEMModeIdIndex); + SetOEMPhaseIncr(SiS_Pr, ModeNo, OEMModeIdIndex); + SetOEMYFilter(SiS_Pr, ModeNo, OEMModeIdIndex); } } } |