diff options
author | Thomas Winischhofer <thomas@winischhofer.net> | 2005-09-09 13:04:45 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-09 13:58:01 -0700 |
commit | 544393fe584d333480659a4bed30f5295355df11 (patch) | |
tree | 873b30c67cdbb5cb93e6fd816692db312ed6ddd6 /drivers/video/sis/init301.c | |
parent | 5c06e2aa6339112befdc87b350b8bf712890d7a7 (diff) |
[PATCH] sisfb update
This lifts sisfb from version 1.7.17 to version 1.8.9. Changes include:
- Added support for XGI V3XT, V5, V8, Z7 chipsets, including POSTing of
all of these chipsets.
- Added support for latest SiS chipsets (761).
- Added support for SiS76x memory "hybrid" mode.
- Added support for new LCD resolutions (eg 1280x854, 856x480).
- Fixed support for 320x240 STN panels (for embedded devices).
- Fixed many HDTV modes (525p, 750p, 1080i).
- Fixed PCI config register reading/writing to use proper kernel
functions for this purpose.
- Fixed PCI ROM handling to use the kernel's proper functions.
- Removed lots of "typedef"s.
- Removed lots of code which was for X.org/XFree86 only.
- Fixed coding style in many places.
- Removed lots of 2.4 cruft.
- Reduced stack size by unifying two previously separate structs into
one.
- Added new hooks for memory allocation (for DRM). Now the driver can
truly handle multiple cards, including memory management.
- Fixed numerous minor bugs.
Signed-off-by: Thomas Winischhofer <thomas@winischhofer.net>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
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; |