init301.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:314k
- 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 tempbx = 768;
- }
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024){
- tempax = 1280;
- 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 tempbx = 1024;
- }
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960){
- tempax = 1280;
- 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 tempbx = 960;
- }
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050){
- tempax = 1400;
- tempbx = 1050;
- }
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) {
- tempax = SiS_Pr->SiS_VGAHDE;
- tempbx = SiS_Pr->SiS_VGAVDE;
- }
- SiS_Pr->SiS_HDE = tempax;
- SiS_Pr->SiS_VDE = tempbx;
- return;
- }
- }
- USHORT
- SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT resindex;
- if(ModeNo<=0x13)
- resindex=SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
- else
- resindex=SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- return(resindex);
- }
- /* TW: Checked against 650/301LV, 650/LVDS, 630/LVDS, 630/301 and 630/301B BIOS */
- void
- SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT xres,yres,modeflag=0,resindex;
- resindex = SiS_GetResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex);
- 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;
- }
- /* TW: Inserted entire if-section from 650/LVDS BIOS 1.10.07: */
- if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) {
- if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & CRT2IsVGA)) {
- if(yres == 350) yres = 400;
- }
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x3a) & 0x01) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34) == 0x12)
- yres = 400;
- }
- }
- if(ModeNo > 0x13) {
- if(SiS_Pr->SiS_IF_DEF_FSTN == 1){
- xres *= 2;
- yres *= 2;
- } else {
- if(modeflag & HalfDCLK) xres *= 2;
- if(modeflag & DoubleScanMode) yres *= 2;
- }
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- /* TW: Inserted from 650/301LV BIOS */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- if(xres == 720) xres = 640;
- } else {
- if(xres == 720) xres = 640;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
- if(yres == 400) yres = 405;
- if(yres == 350) yres = 360;
- if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
- if(yres == 360) yres = 375;
- }
- }
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768){
- if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
- if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) {
- if(yres == 350) yres = 357;
- if(yres == 400) yres = 420;
- if(yres == 480) yres = 525;
- }
- }
- }
- /* TW: Inserted for 630/301B */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(xres == 720) xres = 640;
- }
- }
- }
- } else {
- if(xres == 720) xres = 640;
- /* TW: Inserted from 650/LVDS and 630/LVDS BIOS */
- if(SiS_Pr->SiS_SetFlag & CRT2IsVGA) {
- yres = 400;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480;
- } else {
- if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480;
- }
- }
- }
- SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres;
- SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres;
- }
- /* TW: Checked against 650/301 and 650/LVDS (1.10.07) BIOS; modified for new panel resolutions */
- /* TW: Done differently in 630/301B BIOS; but same effect; checked against 630/301 */
- void
- SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT tempbx=0,tempal=0;
- USHORT Flag,resinfo=0;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
- tempbx = 15;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- tempbx = 20;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx = 21;
- if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 22;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
- tempbx = 23;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx = 24;
- if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 25;
- } else if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) {
- tempbx = 13;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx++;
- } else {
- tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_Panel1024x768;
- if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
- tempbx += 5;
- /* GetRevisionID(); */
- /* TW: BIOS only adds 5 once */
- tempbx += 5;
- }
- }
- } else {
- #ifdef oldHV /* TV */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV){
- if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_SetFlag &= (~TVSimuMode); /* TW: Was "(!TVSimuMode)" - WRONG */
- tempbx = 2;
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) tempbx = 12; /* TW: Was 10! - WRONG */
- }
- } else {
- #endif
- if(SiS_Pr->SiS_VBInfo & SetPALTV) tempbx = 3;
- else tempbx = 4;
- if(SiS_Pr->SiS_SetFlag & TVSimuMode) tempbx += 5;
- #ifdef oldHV
- }
- #endif
- }
- if(ModeNo <= 0x13)
- tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- else
- tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- tempal &= 0x3F;
- if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
- && (SiS_Pr->SiS_VBInfo & (SetCRT2ToTV-SetCRT2ToHiVisionTV))) { /* TW: Added -Hivision (BIOS) */
- if(tempal == 0x06) tempal = 0x07;
- }
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if((ModeNo == 0x31) || (ModeNo == 0x32)) tempal = 6;
- }
- *CRT2Index = tempbx;
- *ResIndex = tempal;
- } else { /* LVDS */
- Flag = 1;
- tempbx = 0;
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
- Flag = 0;
- tempbx = 10;
- if(SiS_Pr->SiS_VBInfo & SetPALTV) tempbx += 2;
- if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
- }
- }
- if(Flag == 1) {
- tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_PanelMinLVDS;
- if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) {
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 3;
- } else {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- tempbx = 8;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx++;
- }
- if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
- tempbx = 7;
- }
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) tempbx = 6;
- /* TW: Inserted from 630/LVDS 2.04.5c BIOS */
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
- tempbx = 15;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2;
- }
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) {
- tempbx = 16;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 2;
- }
- }
- }
- if(ModeNo <= 0x13)
- tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- else {
- tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
- if(SiS_Pr->SiS_IF_DEF_FSTN){
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){
- tempbx = 14;
- tempal = 6;
- }
- }
- /* TW: Inserted from 650/LVDS BIOS */
- if(SiS_Pr->SiS_SetFlag & CRT2IsVGA) {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempal = 7;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* TW: Inserted from 630/LVDS (2.04.5c) and 630/301B (II) BIOS */
- if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) tempal++;
- }
- }
- /* TW: Inserted from 630/301B BIOS */
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(ModeNo > 0x13) {
- if((resinfo == 0x0c) || (resinfo == 0x0d)) /* 720 */
- tempal = 6;
- }
- }
- *CRT2Index = tempbx;
- *ResIndex = tempal & 0x1F;
- }
- }
- void
- SiS_GetCRT2PtrA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,USHORT *CRT2Index,
- USHORT *ResIndex)
- {
- USHORT tempbx,tempal;
- tempbx = SiS_Pr->SiS_LCDResInfo;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
- tempbx = 4;
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- tempbx = 3;
- } else {
- tempbx -= SiS_Pr->SiS_Panel1024x768;
- }
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 5;
- if(ModeNo <= 0x13)
- tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- else
- tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- *CRT2Index = tempbx;
- *ResIndex = tempal & 0x1F;
- }
- /* TW: New from 650/301LVx BIOS */
- void
- SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,USHORT *CRT2Index,
- USHORT *ResIndex)
- {
- USHORT tempbx,tempal;
- if(ModeNo <= 0x13)
- tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- else
- tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- tempbx = SiS_Pr->SiS_LCDResInfo;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 16;
- else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx += 32;
- *CRT2Index = tempbx;
- *ResIndex = tempal & 0x3F;
- }
- /* TW: Checked against all (incl 650/LVDS (1.10.07), 630/301B, 630/301) BIOSes */
- USHORT
- SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- SHORT LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01,
- 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01 };
- USHORT RefreshRateTableIndex,i,backup_i;
- USHORT modeflag,index,temp,backupindex;
- 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(ModeNo < 0x14) return(0xFFFF);
- /* TW: CR33 holds refresh rate index for CRT1 [3:0] and CRT2 [7:4].
- * On LVDS machines, CRT2 index is always 0 and will be
- * set to 0 by the following code; this causes the function
- * to take the first non-interlaced mode in SiS_Ext2Struct
- */
- index = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x33);
- index >>= SiS_Pr->SiS_SelectCRT2Rate;
- index &= 0x0F;
- backupindex = index;
- if(index > 0) index--;
- if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0;
- } else {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if(HwDeviceExtension->jChipType < SIS_315H) index = 0;
- else if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) index = backupindex = 0;
- }
- }
- }
- if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- index = 0;
- }
- }
- if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- /* TW: This is not done in 630/301B BIOS */
- temp = LCDRefreshIndex[SiS_Pr->SiS_LCDResInfo];
- if(index > temp) index = temp;
- } else {
- index = 0;
- }
- }
- }
- RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
- ModeNo = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID;
- /* TW: Inserted from 650/LVDS 1.10.07, 650/301LVx 1.10.6s */
- if(HwDeviceExtension->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)
- RefreshRateTableIndex++;
- }
- }
- }
- i = 0;
- do {
- if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i].ModeID != ModeNo) break;
- temp = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
- temp &= ModeInfoFlag;
- 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[RefreshRateTableIndex + i - 1].Ext_InfoFlag;
- if(temp & InterlaceMode) {
- i++;
- }
- }
- }
- i--;
- if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) {
- backup_i = i;
- if (!(SiS_AdjustCRT2Rate(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,&i,HwDeviceExtension))) {
- /* TW: This is for avoiding random data to be used; i is
- * in an undefined state if no matching CRT2 mode is
- * found.
- */
- i = backup_i;
- }
- }
- return(RefreshRateTableIndex + i);
- }
- /* Checked against all (incl 650/LVDS (1.10.07), 630/301) BIOSes */
- BOOLEAN
- SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,USHORT *i,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT tempax,tempbx,resinfo;
- USHORT modeflag,infoflag;
- if (ModeNo <= 0x13)
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- tempbx = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID;
- tempax = 0;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- /* TW: For 301, 301B, 302B, 301LV, 302LV */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
- tempax |= SupportRAMDAC2;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- tempax |= SupportTV;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if(resinfo == 0x0a) tempax |= SupportTV1024;
- }
- }
- }
- }
- if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
- tempax |= SupportLCD;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) {
- if((resinfo == 6) && (SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) {
- tempax |= SupportAllCRT2;
- (*i) = 0; /* TW: Restore RefreshTableIndex (BIOS 650/301LVx 1.10.6s) */
- return(1);
- } else {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) {
- if((resinfo == 6) && (SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) {
- return(0);
- } else {
- if((resinfo >= 9) && (resinfo != 0x14)) {
- tempax = 0;
- return(0);
- }
- }
- }
- }
- }
- }
- }
- } else {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
- if((resinfo != 0x0f) && ((resinfo == 4) || (resinfo >= 8))) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) {
- if((resinfo != 0x10) && (resinfo > 8)) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
- if((resinfo != 0x0e) && (resinfo > 8)) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
- if(resinfo > 9) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
- if(resinfo > 8) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
- if((resinfo == 4) || (resinfo > 7)) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
- if((resinfo == 4) || (resinfo == 3) || (resinfo > 6)) return(0);
- }
- }
- }
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
- tempax |= SupportHiVisionTV;
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode){
- if(resinfo == 4) return(0);
- if(resinfo == 3) {
- if(SiS_Pr->SiS_SetFlag & TVSimuMode) return(0);
- }
- if(resinfo > 7) return(0);
- }
- } else {
- #endif
- if(SiS_Pr->SiS_VBInfo & (SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) {
- tempax |= SupportTV;
- tempax |= SupportTV1024;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- if((SiS_Pr->SiS_VBInfo & SetNotSimuMode) && (SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if(resinfo != 8) {
- if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
- ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 4)) ) {
- tempax &= ~(SupportTV1024);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
- ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) {
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
- }
- }
- } else {
- if( (resinfo != 3) ||
- (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
- (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if(resinfo == 3) return(0);
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
- }
- }
- } else return(0);
- }
- }
- }
- } else {
- tempax &= ~(SupportTV1024);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
- ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) {
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
- }
- }
- } else {
- if( (resinfo != 3) ||
- (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
- (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if(resinfo == 3) return(0);
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
- }
- }
- } else return(0);
- }
- }
- } else { /* slavemode */
- if(resinfo != 8) {
- if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
- ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 4) ) ) {
- tempax &= ~(SupportTV1024);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
- ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) {
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
- }
- }
- } else {
- if( (resinfo != 3) ||
- (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
- (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if(resinfo == 3) return(0);
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
- }
- }
- } else return(0);
- }
- }
- }
- }
- } else { /* 301 */
- tempax &= ~(SupportTV1024);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
- ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) {
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
- }
- }
- } else {
- if( (resinfo != 3) ||
- (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
- (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if(resinfo == 3) return(0);
- if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
- }
- }
- } else return(0);
- }
- }
- }
- #ifdef oldHV
- }
- #endif
- } else { /* TW: for LVDS */
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- tempax |= SupportCHTV;
- }
- }
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- tempax |= SupportLCD;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) {
- if((resinfo != 0x14) && (resinfo > 0x09)) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
- if((resinfo != 0x0f) && (resinfo > 0x08)) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) {
- if((resinfo != 0x10) && (resinfo > 0x08)) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- if((resinfo != 0x15) && (resinfo > 0x09)) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
- if(resinfo > 0x09) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
- if(resinfo > 0x08) return(0);
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600){
- if(resinfo > 0x07) return(0);
- if(resinfo == 0x04) return(0);
- }
- }
- }
- /* TW: Look backwards in table for matching CRT2 mode */
- for(; SiS_Pr->SiS_RefIndex[RefreshRateTableIndex+(*i)].ModeID == tempbx; (*i)--) {
- infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag;
- if(infoflag & tempax) {
- return(1);
- }
- if ((*i) == 0) break;
- }
- /* TW: 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)++) {
- infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag;
- if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID != tempbx) {
- return(0);
- }
- if(infoflag & tempax) {
- return(1);
- }
- }
- return(1);
- }
- /* Checked against 650/LVDS (1.10.07) and 650/301LV BIOS */
- void
- SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo)
- {
- USHORT temp1,temp2;
- /* TW: We store CRT1 ModeNo in CR34 */
- SiS_SetReg1(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);
- }
- /* TW: Checked against 650+301, 650/LVDS (1.10.07) and 650/301LVx (1.10.6s) BIOS */
- void
- SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
- USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT tempax,tempbx,temp;
- USHORT modeflag, resinfo=0;
- UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect;
- if (ModeNo<=0x13)
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- 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_ModeType = modeflag & ModeInfoFlag;
- tempbx = 0;
- if(SiS_BridgeIsOn(SiS_Pr,BaseAddr,HwDeviceExtension) == 0) { /* TW: "== 0" inserted from 630/301B BIOS */
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(SiS_Pr->SiS_HiVision & 0x03) { /* TW: New from 650/301LVx 1.10.6s */
- temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode); /* 0x83 */
- temp |= SetCRT2ToHiVisionTV; /* 0x80 */
- }
- if(SiS_Pr->SiS_HiVision & 0x04) { /* TW: New from 650/301LVx 1.10.6s */
- temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode); /* 0x83 */
- temp |= SetCRT2ToSVIDEO; /* 0x08 */
- }
- #if 0 /* TW: Not in 650/301LVx 1.10.6s BIOS */
- if(SiS_Pr->SiS_VBType & VB_SIS30xLV) {
- temp &= 0xbf; /* 301lvds disable CRT2RAMDAC */
- }
- #endif
- if(SiS_Pr->SiS_IF_DEF_FSTN) { /* fstn must set CR30=0x21 */
- temp = (SetCRT2ToLCD | SetSimuScanMode);
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,temp);
- }
- tempbx |= temp;
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31);
- tempax = temp << 8;
- tempax &= (LoadDACFlag | DriverMode | SetDispDevSwitch | /* TW: Inserted from 650/LVDS+301LV BIOS */
- SetNotSimuMode | SetPALTV); /* TW: Inserted from 650/LVDS+301LV BIOS */
- tempbx |= tempax;
- temp = SetCHTVOverScan | SetInSlaveMode | DisableCRT2Display;
- temp = 0xFFFF ^ temp;
- tempbx &= temp;
- #ifdef SIS315H
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- if(SiS_Pr->SiS_VBType & (VB_SIS302B | VB_SIS30xLV | VB_SIS30xNEW)) {
- if((SiS_GetReg1(SiS_Pr->SiS_P3d4, 0x36) & 0x0f) == SiS_Pr->SiS_Panel1400x1050) {
- if(tempbx & SetCRT2ToLCD) {
- if(ModeNo <= 0x13) {
- if(SiS_CRT2IsLCD(SiS_Pr, BaseAddr)) {
- if(!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & (SetNotSimuMode >> 8))) {
- SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,0x03);
- }
- }
- }
- }
- }
- if((temp & (EnableDualEdge | SetToLCDA))
- == (EnableDualEdge | SetToLCDA)) /* TW: BIOS only tests these bits, added "& ..." */
- tempbx |= SetCRT2ToLCDA;
- }
- /* TW: Inserted from 650/LVDS 1.10.07 BIOS: */
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if(temp & SetToLCDA)
- tempbx |= SetCRT2ToLCDA;
- if(temp & EnableLVDSHiVision)
- tempbx |= SetCRT2ToHiVisionTV;
- }
- }
- #endif
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- temp = SetCRT2ToLCDA | SetCRT2ToSCART | SetCRT2ToLCD |
- SetCRT2ToRAMDAC | SetCRT2ToSVIDEO | SetCRT2ToAVIDEO; /* = 0x807C; */
- if(SiS_Pr->SiS_IF_DEF_HiVision == 1)
- temp |= SetCRT2ToHiVisionTV; /* = 0x80FC; */
- } else {
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0)
- temp = SetCRT2ToLCDA | SetCRT2ToSCART |
- SetCRT2ToLCD | SetCRT2ToHiVisionTV |
- SetCRT2ToAVIDEO | SetCRT2ToSVIDEO; /* = 0x80bc */
- else
- temp = SetCRT2ToLCDA | SetCRT2ToLCD;
- } else {
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0)
- temp = SetCRT2ToTV | SetCRT2ToLCD;
- else
- temp = SetCRT2ToLCD;
- }
- }
- if(!(tempbx & temp)) {
- tempax = DisableCRT2Display;
- tempbx = 0;
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS==0) {
- if(tempbx & SetCRT2ToLCDA) {
- tempbx &= (0xFF00|SwitchToCRT2|SetSimuScanMode);
- } else if(tempbx & SetCRT2ToRAMDAC) {
- tempbx &= (0xFF00|SetCRT2ToRAMDAC|SwitchToCRT2|SetSimuScanMode);
- } else if((tempbx & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD)) ){
- tempbx &= (0xFF00|SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode);
- } else if(tempbx & SetCRT2ToSCART){
- tempbx &= (0xFF00|SetCRT2ToSCART|SwitchToCRT2|SetSimuScanMode);
- tempbx |= SetPALTV;
- }
- #if 0 /* TW: Not done in 650/301LVx 1.10.6s BIOS */
- } else if(tempbx & SetCRT2ToHiVisionTV){
- tempbx &= (0xFF00|SetCRT2ToHiVisionTV|SwitchToCRT2|SetSimuScanMode);
- tempbx |= SetPALTV;
- }
- #endif
- } else { /* LVDS */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(tempbx & SetCRT2ToLCDA)
- tempbx &= (0xFF00|SwitchToCRT2|SetSimuScanMode);
- }
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
- if(tempbx & SetCRT2ToTV)
- tempbx &= (0xFF00|SetCRT2ToTV|SwitchToCRT2|SetSimuScanMode);
- }
- if(tempbx & SetCRT2ToLCD) {
- tempbx &= (0xFF00|SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode);
- }
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(tempbx & SetCRT2ToLCDA)
- tempbx |= SetCRT2ToLCD;
- }
- }
- if(tempax & DisableCRT2Display) {
- if(!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) {
- tempbx = SetSimuScanMode | DisableCRT2Display;
- }
- }
- if(!(tempbx & DriverMode)){
- tempbx |= SetSimuScanMode;
- }
- /* TW: LVDS (LCD/TV) and 630+301B (LCD) can only be slave in 8bpp modes */
- if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_ModeType <= ModeVGA) ) {
- modeflag &= (~CRT2Mode);
- }
- if( (HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
- if(SiS_Pr->SiS_ModeType <= ModeVGA) {
- if(tempbx & SetCRT2ToLCD) {
- modeflag &= (~CRT2Mode);
- }
- }
- }
- /* TW end */
- if(!(tempbx & SetSimuScanMode)){
- if(tempbx & SwitchToCRT2) {
- if(!(modeflag & CRT2Mode)) {
- if( (HwDeviceExtension->jChipType >= SIS_315H) &&
- (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) {
- if(resinfo != 0x0a)
- tempbx |= SetSimuScanMode;
- } else {
- tempbx |= SetSimuScanMode;
- }
- }
- } else {
- if(!(SiS_BridgeIsEnable(SiS_Pr,BaseAddr,HwDeviceExtension))) {
- if(!(tempbx & DriverMode)) {
- if(SiS_BridgeInSlave(SiS_Pr)) {
- tempbx |= SetSimuScanMode; /* TW: from BIOS 650/301/301LV/LVDS */
- }
- }
- }
- }
- }
- if(!(tempbx & DisableCRT2Display)) {
- if(tempbx & DriverMode) {
- if(tempbx & SetSimuScanMode) {
- if(!(modeflag & CRT2Mode)) {
- if( (HwDeviceExtension->jChipType >= SIS_315H) &&
- (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) {
- if(resinfo != 0x0a) { /* TW: Inserted from 650/301 BIOS */
- tempbx |= SetInSlaveMode;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(tempbx & SetCRT2ToTV) {
- if(!(tempbx & SetNotSimuMode))
- SiS_Pr->SiS_SetFlag |= TVSimuMode;
- }
- }
- } /* TW: Inserted from 650/301 BIOS */
- } else {
- tempbx |= SetInSlaveMode;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(tempbx & SetCRT2ToTV) {
- if(!(tempbx & SetNotSimuMode))
- SiS_Pr->SiS_SetFlag |= TVSimuMode;
- }
- }
- }
- }
- }
- } else {
- tempbx |= SetInSlaveMode;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(tempbx & SetCRT2ToTV) {
- if(!(tempbx & SetNotSimuMode))
- SiS_Pr->SiS_SetFlag |= TVSimuMode;
- }
- }
- }
- }
-
- if(SiS_Pr->SiS_CHOverScan) {
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35);
- if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1) )
- tempbx |= SetCHTVOverScan;
- }
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x79);
- if( (temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1) )
- tempbx |= SetCHTVOverScan;
- }
- }
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS==0) {
- #ifdef SIS300
- if((HwDeviceExtension->jChipType==SIS_630)||
- (HwDeviceExtension->jChipType==SIS_730)) {
- if(ROMAddr && SiS_Pr->SiS_UseROM) {
- OutputSelect = ROMAddr[0xfe];
- }
- if(!(OutputSelect & EnablePALMN))
- SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0x3F);
- if(tempbx & SetCRT2ToTV) {
- if(tempbx & SetPALTV) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35);
- /* temp &= 0xC0; */ /* TW: BIOS only tests 0x40, not 0x80 */
- if(temp & 0x40)
- tempbx &= (~SetPALTV);
- }
- }
- }
- #endif
- #ifdef SIS315H
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(ROMAddr && SiS_Pr->SiS_UseROM) {
- OutputSelect = ROMAddr[0xf3];
- }
- if(!(OutputSelect & EnablePALMN))
- SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0x3F);
- if(tempbx & SetCRT2ToTV) {
- if(tempbx & SetPALTV) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- if(temp & 0x40)
- tempbx &= (~SetPALTV);
- }
- }
- }
- #endif
- }
- SiS_Pr->SiS_VBInfo=tempbx;
- #ifdef TWDEBUG
- #ifdef LINUX_KERNEL
- printk(KERN_INFO "sisfb: (VBInfo= 0x%04x, SetFlag=0x%04x)n", SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag);
- #endif
- #ifdef LINUX_XF86
- xf86DrvMsg(0, X_PROBED, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)n", SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag);
- #endif
- #endif
- #if 0 /* TW: Incomplete! (But does not seem to be required) */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* TW: From A901/630+301B BIOS */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80)
- }
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80)
- if( [si] == 3) ModeIdIndex = 0x3f2b;
- }
- }
- SiS_SetRegAND(SiS_Pr->SiS_P3d4, 0x31, 0xF7);
- if(ModeNo == 0x13) bp+4 = 0x03;
- } else {
- /* From 650/301LVx BIOS: */
- SiS_SetRegAND(SiS_Pr->SiS_P3d4, 0x31, 0xF7);
- if(ModeNo == 0x13) bp+4 = 0x03;
- else bp+4 = ModeNo;
- }
- #endif
- /* TW: 630/301B and 650/301 (not 301LV!) BIOSes do more here, but this seems for DOS mode */
- }
- void
- SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT tempax,tempbx,temp;
- USHORT temp1,temp2,modeflag=0,tempcx;
- USHORT StandTableIndex,CRT1Index;
- USHORT ResInfo,DisplayType;
- const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr = NULL;
- SiS_Pr->SiS_RVBHCMAX = 1;
- SiS_Pr->SiS_RVBHCFACT = 1;
- if(ModeNo <= 0x13){
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- StandTableIndex = SiS_GetModePtr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex);
- tempax = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[0];
- tempbx = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[6];
- temp1 = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[7];
- } else {
- if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ) {
- temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,&ResInfo,&DisplayType);
- if(temp == 0) return;
- switch(DisplayType) {
- case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break;
- case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break;
- case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break;
- case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break;
- case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break;
- case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break;
- case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break;
- case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break;
- case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break;
- case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break;
- case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; 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;
- 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;
- }
- temp1 = (LVDSCRT1Ptr+ResInfo)->CR[0];
- temp2 = (LVDSCRT1Ptr+ResInfo)->CR[14];
- tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
- tempbx = (LVDSCRT1Ptr+ResInfo)->CR[6];
- tempcx = (LVDSCRT1Ptr+ResInfo)->CR[13]<<8;
- tempcx = tempcx & 0x0100;
- tempcx = tempcx << 2;
- tempbx = tempbx | tempcx;
- temp1 = (LVDSCRT1Ptr+ResInfo)->CR[7];
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- CRT1Index &= 0x3F;
- }
- temp1 = (USHORT)SiS_Pr->SiS_CRT1Table[CRT1Index].CR[0];
- temp2 = (USHORT)SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14];
- tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
- tempbx = (USHORT)SiS_Pr->SiS_CRT1Table[CRT1Index].CR[6];
- tempcx = (USHORT)SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]<<8;
- tempcx = tempcx & 0x0100;
- tempcx = tempcx << 2;
- tempbx = tempbx | tempcx;
- temp1 = (USHORT)SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7];
- }
- }
- if(temp1 & 0x01) tempbx |= 0x0100;
- if(temp1 & 0x20) tempbx |= 0x0200;
- tempax += 5;
- /* Charx8Dot is no more used (and assumed), so we set it */
- modeflag |= Charx8Dot;
- if(modeflag & Charx8Dot) tempax *= 8;
- else tempax *= 9;
- /* TW: From 650/301LVx 1.10.6s */
- if(modeflag & HalfDCLK) tempax <<= 1;
- SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax;
- tempbx++;
- SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx;
- }
- void
- SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
- {
- if(HwDeviceExtension->jChipType >= SIS_315H)
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01);
- else
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01);
- }
- void
- SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
- {
- if(HwDeviceExtension->jChipType >= SIS_315H)
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE);
- else
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE);
- }
- void
- SiS_EnableCRT2(SiS_Private *SiS_Pr)
- {
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
- }
- /* Checked against all BIOSes */
- void
- SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
- {
- USHORT tempah,pushax,temp=0;
- UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase;
- if (SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== TW: For 30xB/LV ===== */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* 300 series */
- if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- }
- if(SiS_Is301B(SiS_Pr,BaseAddr)) {
- 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,HwDeviceExtension,BaseAddr);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40);
- if( (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr))) ||
- (!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) ) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04);
- }
- } else {
- /* 310 series */
- #ifdef SIS650301NEW /* From 650/301LVx 1.10.6s */
- if(!(SiS_IsM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- tempah = 0xef;
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- tempah = 0xf7;
- }
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah);
- }
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
- } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
- }
- SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00);
- pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_DisplayOff(SiS_Pr);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF);
- } else {
- SiS_DisplayOff(SiS_Pr);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
- temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp);
- }
- tempah = 0x3f;
- if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- tempah = 0x7f;
- if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- tempah = 0xbf;
- }
- }
- SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah);
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
- if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf);
- }
- if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr))) {
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00);
- }
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax);
- #else /* TW: From 650/301LV BIOS */
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- }
- /* TW: 301B dependent code starts here in 650/301LV BIOS */
- if(SiS_Is301B(SiS_Pr,BaseAddr)) {
- tempah = 0x3f;
- SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah);
- }
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF);
- SiS_DisplayOff(SiS_Pr);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
- temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp);
- /* TW: Inserted from 650/301LV BIOS */
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 4);
- } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 4);
- }
- }
- } else if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr))) {
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00);
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 4);
- } else if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00);
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 4);
- } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00);
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 4);
- }
- }
- } /* TW: 650/301LV end */
- #endif
- }
- } else { /* ============ TW: For 301 ================ */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x0B);
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1);
- }
- }
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */
- SiS_DisplayOff(SiS_Pr);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
- }
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp);
- } else {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */
- }
- }
- } else { /* ============ TW: For LVDS =============*/
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* 300 series */
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
- #if 0 /* TW: Implemented this for power saving, but it's not worth
- * the problems
- */
- if(SiS_Pr->SiS_Backup70xx == 0xff) {
- SiS_Pr->SiS_Backup70xx = SiS_GetCH700x(SiS_Pr,0x0e);
- }
- #endif
- SiS_SetCH700x(SiS_Pr,0x090E);
- }
- if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x11) & 0x08)) {
- if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
- if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
- SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
- if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) {
- SiS_DisplayOff(SiS_Pr);
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- }
- }
- }
- SiS_DisplayOff(SiS_Pr);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
- SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40);
- if( (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr))) ||
- (!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) ) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04);
- }
- } else {
- /* 310 series */
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_Chrontel701xBLOff(SiS_Pr);
- SiS_Chrontel701xOff(SiS_Pr);
- } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_Chrontel701xBLOff(SiS_Pr);
- SiS_Chrontel701xOff(SiS_Pr);
- }
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetCH701x(SiS_Pr,0x0149);
- } else if(SiS_IsTVOrYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetCH701x(SiS_Pr,0x0149);
- }
- }
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_DisplayOff(SiS_Pr);
- } else if(!(SiS_IsTVOrYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_DisplayOff(SiS_Pr);
- }
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
- } else if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
- }
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
- } else if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
- }
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
- }
- if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff);
- } else {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
- }
- SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr);
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
- } else if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
- }
- #if 0 /* TW: BIOS code makes no sense */
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- /* Nothing there! */
- }
- }
- }
- #endif
- } /* 310 series */
- } /* LVDS */
- }
- /* TW: Checked against all BIOSes */
- void
- SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- USHORT temp=0,tempah,pushax,temp1;
- UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* TW: ====== For 301B et al ====== */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* 300 series */
- if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB);
- if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) {
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0);
- }
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */
- /* DoSomeThingPCI_On(SiS_Pr) */
- SiS_DisplayOn(SiS_Pr);
- SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr);
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF);
- if(SiS_BridgeInSlave(SiS_Pr)) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F);
- } else {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40);
- }
- if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
- if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
- if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
- }
- SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x00);
- }
- }
- } else {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */
- if(SiS_BridgeInSlave(SiS_Pr)) {
- tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
- }
- SiS_SetReg1(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 */
- if(SiS_Is301B(SiS_Pr,BaseAddr)) {
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0);
- SiS_DisplayOn(SiS_Pr);
- } else {
- SiS_VBLongWait(SiS_Pr);
- SiS_DisplayOn(SiS_Pr);
- SiS_VBLongWait(SiS_Pr);
- }
- }
- } else {
- /* 310 series */
- #ifdef SIS650301NEW /* TW: From 650/301LVx 1.10.6s */
- if(!(SiS_IsM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- tempah = 0x10;
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- tempah = 0x08;
- }
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah);
- }
- SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00);
- SiS_DisplayOff(SiS_Pr);
- pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06);
- if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
- (SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) ) {
- if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
- }
- }
- if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
- if(SiS_BridgeInSlave(SiS_Pr)) {
- tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
- }
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
- }
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20);
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20);
- tempah = 0xc0;
- if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- tempah = 0x80;
- if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- tempah = 0x40;
- }
- }
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah);
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
- if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
- ((SiS_CRT2IsLCD(SiS_Pr,BaseAddr))) ) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
- SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01);
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax);
- SiS_DisplayOn(SiS_Pr);
- SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff);
- if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
- }
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c);
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x05);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x60);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x00);
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40);
- #else /* TW: From 650/301LV BIOS (different PanelDelay!) */
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfd,0x02);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 0);
- } else if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfd,0x02);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 0);
- }
- /* TW: --- end --- */
- if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
- if(SiS_BridgeInSlave(SiS_Pr)) {
- tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
- }
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */
- /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0x7F); */ /* TW: Not done in 650/301LV BIOS */
- temp=SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
- if (!(temp & 0x80))
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */
- if(SiS_Is301B(SiS_Pr,BaseAddr)) {
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xc0);
- if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) /* TW: "if" new from 650/301LV BIOS */
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F);
- } else {
- SiS_VBLongWait(SiS_Pr);
- SiS_DisplayOn(SiS_Pr);
- if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) { /* TW: "if" new from 650/301LV BIOS */
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F);
- SiS_VBLongWait(SiS_Pr);
- }
- }
- /* TW: Entire section from 650/301LV BIOS */
- if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- /* if (!(SiS_WeHaveBacklightCtrl(HwDeviceExtension, BaseAddr))) { */ /* TW: BIOS code makes no sense */
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
- SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x01);
- /* } */
- } else if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) {
- /* if (!(SiS_WeHaveBacklightCtrl(HwDeviceExtension, BaseAddr))) { */ /* TW: BIOS code makes no sense */
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
- SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x01);
- /* } */
- }
- }
- #endif
- }
- } else { /* ============ TW: For 301 ================ */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x0B);
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0);
- }
- }
- temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */
- if(SiS_BridgeInSlave(SiS_Pr)) {
- tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
- }
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
- if(!(temp & 0x80))
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */
- SiS_VBLongWait(SiS_Pr);
- SiS_DisplayOn(SiS_Pr);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
- }
- SiS_VBLongWait(SiS_Pr);
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) {
- SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1);
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x03);
- }
- }
- }
- } else { /* =================== TW: For LVDS ================== */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* 300 series */
- if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB);
- if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 0);
- }
- }
- SiS_EnableCRT2(SiS_Pr);
- SiS_DisplayOn(SiS_Pr);
- SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr);
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF);
- if(SiS_BridgeInSlave(SiS_Pr)) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F);
- } else {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40);
- }
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
- if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr))) {
- #if 0 /* TW: Implemented this for power saving, but it's not worth
- * the problems
- */
- if(SiS_Pr->SiS_Backup70xx != 0xff) {
- SiS_SetCH700x(SiS_Pr,((SiS_Pr->SiS_Backup70xx<<8)|0x0E));
- SiS_Pr->SiS_Backup70xx = 0xff;
- } else
- #endif
- SiS_SetCH700x(SiS_Pr,0x0B0E);
- }
- }
- if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) {
- if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
- if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
- if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
- SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
- }
- SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7);
- }
- }
- }
- } else {
- /* 310 series */
- #if 0 /* BIOS code makes no sense */
- if(SiS_IsVAMode()) {
- if(SiS_IsLCDOrLCDA()) {
- }
- }
- #endif
- SiS_EnableCRT2(SiS_Pr);
- SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr);
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- temp = SiS_GetCH701x(SiS_Pr,0x66);
- temp &= 0x20;
- SiS_Chrontel701xBLOff(SiS_Pr);
- }
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
- temp1 = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
- if (!(temp1 & 0x80))
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- if(temp) {
- SiS_Chrontel701xBLOn(SiS_Pr);
- }
- }
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
- }
- if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
- }
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- if(SiS_IsTVOrYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_Chrontel701xOn(SiS_Pr,HwDeviceExtension, BaseAddr);
- }
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_ChrontelDoSomething1(SiS_Pr,HwDeviceExtension, BaseAddr);
- } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_ChrontelDoSomething1(SiS_Pr,HwDeviceExtension, BaseAddr);
- }
- }
- if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
- if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- SiS_Chrontel701xBLOn(SiS_Pr);
- SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr);
- } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) {
- /* if(!SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) { */ /* TW: makes no sense */
- SiS_Chrontel701xBLOn(SiS_Pr);
- SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr);
- /* } */
- }
- }
- }
- } /* 310 series */
- } /* LVDS */
- }
- void
- SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress;
- /* TW: Switch on LCD backlight on SiS30x */
- if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
- (SiS_CRT2IsLCD(SiS_Pr,BaseAddr)) ) {
- if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
- SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
- }
- if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) {
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
- }
- }
- }
- void
- SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress;
- /* TW: Switch off LCD backlight on SiS30x */
- if( (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) ||
- (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
- }
- if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr))) {
- if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00);
- }
- }
- }
- }
- BOOLEAN
- SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp,temp1;
- UCHAR *ROMAddr;
- if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff;
- temp >>= 4;
- temp = 1 << temp;
- temp1 = (ROMAddr[0x23c] << 8) | ROMAddr[0x23b];
- if(temp1 & temp) return(1);
- else return(0);
- } else {
- return(0);
- }
- }
- BOOLEAN
- SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp,temp1;
- UCHAR *ROMAddr;
- if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) {
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff;
- temp >>= 4;
- temp = 1 << temp;
- temp1 = (ROMAddr[0x23e] << 8) | ROMAddr[0x23d];
- if(temp1 & temp) return(1);
- else return(0);
- } else {
- return(0);
- }
- }
- void
- SiS_SetPanelDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT DelayTime)
- {
- USHORT PanelID, DelayIndex, Delay, temp;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 300 series, LVDS */
- PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
- DelayIndex = PanelID >> 4;
- if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) {
- 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((ROMAddr) && (SiS_Pr->SiS_UseROM)) {
- if(ROMAddr[0x220] & 0x40) {
- if(!(DelayTime & 0x01)) {
- Delay = (USHORT)ROMAddr[0x225];
- } else {
- Delay = (USHORT)ROMAddr[0x226];
- }
- }
- }
- }
- SiS_ShortDelay(SiS_Pr,Delay);
- } else { /* 300 series, 301(B) */
- PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
- temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18);
- if(!(temp & 0x10)) PanelID = 0x12;
- DelayIndex = PanelID >> 4;
- if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) {
- 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((ROMAddr) && (SiS_Pr->SiS_UseROM)) {
- if(ROMAddr[0x220] & 0x40) {
- if(!(DelayTime & 0x01)) {
- Delay = (USHORT)ROMAddr[0x225];
- } else {
- Delay = (USHORT)ROMAddr[0x226];
- }
- }
- }
- }
- SiS_ShortDelay(SiS_Pr,Delay);
- }
- } else {
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* 310/325 series, LVDS */
- /* TW: Not currently used */
- } else { /* 310/325 series, 301(B) */
- PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
- DelayIndex = PanelID >> 4;
- if(!(DelayTime & 0x01)) {
- Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0];
- } else {
- Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1];
- }
- SiS_DDC2Delay(SiS_Pr, Delay * 4);
- }
- }
- }
- void
- SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay)
- {
- while(delay--) {
- SiS_GenericDelay(SiS_Pr,0x19df);
- }
- }
- void
- SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay)
- {
- while(delay--) {
- SiS_GenericDelay(SiS_Pr,0x42);
- }
- }
- void
- SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay)
- {
- USHORT temp,flag;
- flag = SiS_GetReg3(0x61) & 0x10;
- while(delay) {
- temp = SiS_GetReg3(0x61) & 0x10;
- if(temp == flag) continue;
- flag = temp;
- delay--;
- }
- }
- BOOLEAN
- SiS_Is301B(SiS_Private *SiS_Pr, USHORT BaseAddr)
- {
- USHORT flag;
- flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01);
- if(flag >= 0x0B0) return(1);
- else return(0);
- }
- BOOLEAN
- SiS_CRT2IsLCD(SiS_Private *SiS_Pr, USHORT BaseAddr)
- {
- USHORT flag;
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(flag & 0x20) return(1);
- else return(0);
- }
- BOOLEAN
- SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- #ifdef SIS315H
- USHORT flag;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- if(flag & EnableDualEdge) return(1);
- else return(0);
- } else
- #endif
- return(0);
- }
- BOOLEAN
- SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- #ifdef SIS315H
- USHORT flag;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- if((flag & EnableDualEdge) && (flag & SetToLCDA)) return(1);
- #if 0 /* Not done in 650/301LVx 1.10.6s, but in 650/301LV */
- else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(flag) return(1);
- else return(0);
- }
- #endif
- else
- return(0);
- } else
- #endif
- return(0);
- }
- BOOLEAN
- SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- #ifdef SIS315H
- USHORT flag;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x79);
- if(flag & 0x10) return(1);
- else return(0);
- } else
- #endif
- return(0);
- }
- #if 0
- BOOLEAN
- SiS_Is315E(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- #ifdef SIS315H
- USHORT flag;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f);
- if(flag & 0x10) return(1);
- else return(0);
- } else
- #endif
- return(0);
- }
- #endif
- BOOLEAN
- SiS_IsM650or651(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- #ifdef SIS315H
- USHORT flag;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f);
- flag &= 0xF0;
- if((flag == 0xb0) || (flag == 0x90)) return 0;
- else return 1;
- } else
- #endif
- return 1;
- }
- BOOLEAN
- SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- #ifdef SIS315H
- USHORT flag;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- if(flag & 0x08) return(1);
- else return(0);
- } else
- #endif
- return(0);
- }
- BOOLEAN
- SiS_IsTVOrYPbPr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- USHORT flag;
- #ifdef SIS315H
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(flag & SetCRT2ToTV) return(1);
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- if(flag & 0x08) return(1);
- else return(0);
- } else
- #endif
- {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(flag & SetCRT2ToTV) return(1);
- }
- return(0);
- }
- BOOLEAN
- SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
- {
- USHORT flag;
- #ifdef SIS315H
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(flag & SetCRT2ToLCD) return(1);
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- if(flag & SetToLCDA) return(1);
- else return(0);
- } else
- #endif
- {
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(flag & SetCRT2ToLCD) return(1);
- }
- return(0);
- }
- BOOLEAN
- SiS_IsDisableCRT2(SiS_Private *SiS_Pr, USHORT BaseAddr)
- {
- USHORT flag;
- flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
- if(flag & 0x20) return(0);
- else return(1);
- }
- BOOLEAN
- SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT flag;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- return(0); /* TW: Changed from 1 to 0! */
- } else {
- #if 0 /* TW: Commented for test on bridge-less systems */
- if(HwDeviceExtension->jChipType >= SIS_315H) { /* TW: New (from 630/301B BIOS - not done there) */
- #endif
- flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00);
- if((flag == 1) || (flag == 2)) return(0); /* TW: Changed from 1 to 0! */
- else return(1); /* TW: Changed from 0 to 1! */
- #if 0
- } else return(0); /* TW: New (from 630/301B BIOS - always return 0) */
- #endif
- }
- }
- BOOLEAN
- SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT flag;
- if(!(SiS_BridgeIsOn(SiS_Pr,BaseAddr,HwDeviceExtension))) {
- flag = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00);
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* 300 series (630/301B 2.04.5a) */
- flag &= 0xa0;
- if((flag == 0x80) || (flag == 0x20)) return 0;
- else return 1;
- } else {
- /* 310/325 series (650/301LVx 1.10.6s) */
- flag &= 0x50;
- if((flag == 0x40) || (flag == 0x10)) return 0;
- else return 1;
- }
- }
- return 1;
- }
- BOOLEAN
- SiS_BridgeInSlave(SiS_Private *SiS_Pr)
- {
- USHORT flag1;
- flag1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31);
- if(flag1 & (SetInSlaveMode >> 8)) return 1;
- else return 0;
- }
- /* TW: New from 650/301LV(x) 1.10.6s BIOS */
- void
- SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp;
- SiS_Pr->SiS_HiVision = 0;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- #if 0 /* TW: Old */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
- SiS_Pr->SiS_HiVision = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- SiS_Pr->SiS_HiVision &= 0x38;
- SiS_Pr->SiS_HiVision >>= 3;
- }
- #endif /* TW: New from 650/301LVx BIOS 1.10.6s */
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
- if(temp & 0x40) {
- temp &= 0x30;
- switch(temp) {
- case 0x00: SiS_Pr->SiS_HiVision = 4; break;
- case 0x10: SiS_Pr->SiS_HiVision = 1; break;
- case 0x20: SiS_Pr->SiS_HiVision = 2; break;
- default: SiS_Pr->SiS_HiVision = 3; break;
- }
- }
- }
- }
- }
- /* TW: Checked against 630/LVDS 2.08, 650/LVDS and 650/301LV BIOS */
- BOOLEAN
- SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,
- USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp,modeflag,resinfo=0;
- const unsigned char SiS300SeriesLCDRes[] =
- { 0, 1, 2, 3, 7, 4, 5, 8,
- 0, 0, 0, 0, 0, 0, 0, 0 };
- SiS_Pr->SiS_LCDResInfo = 0;
- SiS_Pr->SiS_LCDTypeInfo = 0;
- SiS_Pr->SiS_LCDInfo = 0;
- if (ModeNo<=0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
- if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return 0;
- if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2))) return 0;
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
- /* FSTN: Fake CR36 (TypeInfo 2, ResInfo SiS_Panel320x480) */
- if(SiS_Pr->SiS_IF_DEF_FSTN){
- temp = 0x20 | SiS_Pr->SiS_Panel320x480;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp);
- }
- SiS_Pr->SiS_LCDTypeInfo = temp >> 4;
- temp &= 0x0f;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- /* TW: Translate 300 series LCDRes to 310/325 series for unified usage */
- temp = SiS300SeriesLCDRes[temp];
- }
- SiS_Pr->SiS_LCDResInfo = temp;
- if(SiS_Pr->SiS_IF_DEF_FSTN){
- SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel320x480;
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301)
- SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMin301;
- } else {
- if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMinLVDS)
- SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMinLVDS;
- }
- if(SiS_Pr->SiS_LCDResInfo > SiS_Pr->SiS_PanelMax)
- SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel1024x768;
- temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37);
- if(SiS_Pr->SiS_IF_DEF_FSTN){
- /* TW: Fake LVDS bridge for FSTN */
- temp = 0x04;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,temp);
- }
- SiS_Pr->SiS_LCDInfo = temp;
- /* TW: Inserted entire 315-block from 650/LVDS/301+LVx BIOSes */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- if(ModeNo == 0x3a || ModeNo == 0x4d || ModeNo == 0x65) {
- SiS_Pr->SiS_LCDInfo |= LCDNonExpanding;
- }
- }
- }
- }
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x01) {
- SiS_Pr->SiS_LCDInfo &= 0xFFEF;
- SiS_Pr->SiS_LCDInfo |= LCDPass11;
- }
- } else {
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if((ROMAddr) && SiS_Pr->SiS_UseROM) {
- if(!(ROMAddr[0x235] & 0x02)) {
- SiS_Pr->SiS_LCDInfo &= 0xEF;
- }
- }
- } else {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if((SiS_Pr->SiS_SetFlag & CRT2IsVGA) && ((ModeNo == 0x03) || (ModeNo == 0x10))) {
- SiS_Pr->SiS_LCDInfo &= 0xEF;
- }
- }
- }
- }
- #ifdef LINUX_KERNEL
- printk(KERN_INFO "sisfb: (LCDInfo = 0x%x LCDResInfo = 0x%x LCDTypeInfo = 0x%x)n",
- SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo);
- #endif
- #ifdef LINUX_XF86
- xf86DrvMsg(0, X_PROBED, "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)n",
- SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo);
- #endif
- /* TW: With Trumpion, always Expanding */
- if(SiS_Pr->SiS_IF_DEF_TRUMPION != 0){
- SiS_Pr->SiS_LCDInfo &= (~LCDNonExpanding);
- }
- if(!((HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & CRT2IsVGA))) {
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
- if(ModeNo > 0x13) {
- if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) {
- if((resinfo == 7) || (resinfo == 3)) {
- SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
- }
- }
- }
- }
- if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
- SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
- }
- }
- if(modeflag & HalfDCLK) {
- if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) {
- if(!(SiS_Pr->SiS_LCDInfo & LCDNonExpanding)) {
- if(!(((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (HwDeviceExtension->jChipType < SIS_315H)) &&
- (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480))) {
- if(ModeNo > 0x13) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
- if(resinfo == 4) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; /* 512x384 */
- } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
- if(resinfo == 3) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; /* 400x300 */
- }
- }
- } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
- } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
- } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
- }
- }
- /* TW: wdr: if (VBInfo & LCD) && (VBInfo & (SetSimuScanMode | SwitchToCRT2)) { */
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) {
- SiS_Pr->SiS_SetFlag |= LCDVESATiming;
- }
- } else {
- SiS_Pr->SiS_SetFlag |= LCDVESATiming;
- }
- /* TW: Inserted from 650/301LVx BIOS 1.10.6s */
- if(SiS_Pr->SiS_VBType & VB_SIS30xNEW) {
- temp = 0x00;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) temp = 0x04;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x04;
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) temp = 0x04;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x39,temp);
- } else if((HwDeviceExtension->jChipType > SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 0)) {
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x39,0x00);
- }
- return 1;
- }
- void
- SiS_PresetScratchregister(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- return;
- /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x21); */
- /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x31,0x41); */
- /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x32,0x28); */
- /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x33,0x22); */
- /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,0x43); */
- /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,0x01); */
- /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,0x00); */
- }
- void
- SiS_LongWait(SiS_Private *SiS_Pr)
- {
- USHORT i;
- i = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F);
- if(!(i & 0xC0)) {
- for(i=0; i<0xFFFF; i++) {
- if(!(SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08))
- break;
- }
- for(i=0; i<0xFFFF; i++) {
- if((SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08))
- break;
- }
- }
- }
- void
- SiS_VBLongWait(SiS_Private *SiS_Pr)
- {
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
- SiS_VBWait(SiS_Pr);
- } else {
- SiS_LongWait(SiS_Pr);
- }
- return;
- }
- void
- SiS_VBWait(SiS_Private *SiS_Pr)
- {
- USHORT tempal,temp,i,j;
- temp = 0;
- for(i=0; i<3; i++) {
- for(j=0; j<100; j++) {
- tempal = SiS_GetReg2(SiS_Pr->SiS_P3da);
- if(temp & 0x01) {
- if((tempal & 0x08)) continue;
- if(!(tempal & 0x08)) break;
- } else {
- if(!(tempal & 0x08)) continue;
- if((tempal & 0x08)) break;
- }
- }
- temp ^= 0x01;
- }
- }
- void
- SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return;
- }
- if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) {
- SiS_WaitRetrace1(SiS_Pr,HwDeviceExtension);
- } else {
- SiS_WaitRetrace2(SiS_Pr,HwDeviceExtension);
- }
- } else {
- if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) {
- SiS_WaitRetrace1(SiS_Pr,HwDeviceExtension);
- } else {
- SiS_WaitRetrace2(SiS_Pr,HwDeviceExtension);
- }
- }
- }
- void
- SiS_WaitRetrace1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT i,watchdog;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return;
- watchdog = 65535;
- while( (SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08) && --watchdog);
- watchdog = 65535;
- while( (!(SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog);
- } else {
- #if 0 /* TW: Not done in A901 BIOS */
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return;
- }
- #endif
- for(i=0; i<10; i++) {
- watchdog = 65535;
- while( (SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08) && --watchdog);
- if(watchdog) break;
- }
- for(i=0; i<10; i++) {
- watchdog = 65535;
- while( (!(SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog);
- if(watchdog) break;
- }
- }
- }
- void
- SiS_WaitRetraceDDC(SiS_Private *SiS_Pr)
- {
- USHORT watchdog;
- if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return;
- watchdog = 65535;
- while( (SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08) && --watchdog);
- watchdog = 65535;
- while( (!(SiS_GetReg2(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog);
- }
- void
- SiS_WaitRetrace2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT i,watchdog,temp;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- watchdog = 65535;
- while( (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x30) & 0x02) && --watchdog);
- watchdog = 65535;
- while( (!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x30) & 0x02)) && --watchdog);
- } else {
- for(i=0; i<10; i++) {
- watchdog = 65535;
- while( (temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x25) & 0x02) && --watchdog);
- if(watchdog) break;
- }
- for(i=0; i<10; i++) {
- watchdog = 65535;
- while( (!(temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x25) & 0x02)) && --watchdog);
- if(watchdog) break;
- }
- }
- }
- /* =========== Set and Get register routines ========== */
- void
- SiS_SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR)
- {
- USHORT temp;
- temp = SiS_GetReg1(Port,Index); /* SiS_Pr->SiS_Part1Port index 02 */
- temp = (temp & (DataAND)) | DataOR;
- SiS_SetReg1(Port,Index,temp);
- }
- void
- SiS_SetRegAND(USHORT Port,USHORT Index,USHORT DataAND)
- {
- USHORT temp;
- temp = SiS_GetReg1(Port,Index); /* SiS_Pr->SiS_Part1Port index 02 */
- temp &= DataAND;
- SiS_SetReg1(Port,Index,temp);
- }
- void SiS_SetRegOR(USHORT Port,USHORT Index,USHORT DataOR)
- {
- USHORT temp;
- temp = SiS_GetReg1(Port,Index); /* SiS_Pr->SiS_Part1Port index 02 */
- temp |= DataOR;
- SiS_SetReg1(Port,Index,temp);
- }
- /* ========================================================= */
- /* TW: Set 301 TV Encoder (and some LCD relevant) registers */
- /* TW: Checked against 650/301LV, 650/301LVx and 630/301B (I+II) */
- void
- SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo,
- USHORT ModeIdIndex,USHORT RefreshRateTableIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT i, j, tempax, tempbx, tempcx, temp, temp1;
- USHORT push1, push2;
- const UCHAR *PhasePoint;
- const UCHAR *TimingPoint;
- const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL;
- USHORT modeflag, resinfo, crt2crtc, resindex, CRT2Index;
- ULONG longtemp, tempeax, tempebx, temp2, tempecx;
- const UCHAR atable[] = {
- 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02,
- 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02
- };
- /* TW: Inserted from 650/301LV BIOS */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- /* TW: Inserted from 650/301LVx 1.10.6s: (Is at end of SetGroup2!) */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xfc,0x03);
- temp = 1;
- if(ModeNo<=0x13) temp = 3;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp);
- }
- }
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if((ModeNo == 0x4a) || (ModeNo == 0x38)) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72);
- }
- }
- }
- }
- return;
- }
- if(ModeNo<=0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
- resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
- crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
- resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- }
- tempcx = SiS_Pr->SiS_VBInfo;
- tempax = (tempcx & 0x00FF) << 8;
- tempbx = (tempcx & 0x00FF) | ((tempcx & 0x00FF) << 8);
- tempbx &= 0x0410;
- temp = (tempax & 0x0800) >> 8;
- temp >>= 1;
- temp |= (((tempbx & 0xFF00) >> 8) << 1);
- temp |= ((tempbx & 0x00FF) >> 3);
- temp ^= 0x0C;
- PhasePoint = SiS_Pr->SiS_PALPhase;
- TimingPoint = SiS_Pr->SiS_PALTiming;
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { /* PALPhase */
- temp ^= 0x01;
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- TimingPoint = SiS_Pr->SiS_HiTVSt2Timing;
- if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
- if(modeflag & Charx8Dot) TimingPoint = SiS_Pr->SiS_HiTVSt1Timing;
- else TimingPoint = SiS_Pr->SiS_HiTVTextTiming;
- }
- } else TimingPoint = SiS_Pr->SiS_HiTVExtTiming;
- } else {
- #endif
- if(SiS_Pr->SiS_VBInfo & SetPALTV){
- TimingPoint = SiS_Pr->SiS_PALTiming;
- PhasePoint = SiS_Pr->SiS_PALPhase;
- if( (SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) &&
- ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
- (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
- PhasePoint = SiS_Pr->SiS_PALPhase2;
- }
- } else {
- temp |= 0x10;
- TimingPoint = SiS_Pr->SiS_NTSCTiming;
- PhasePoint = SiS_Pr->SiS_NTSCPhase;
- if( (SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) &&
- ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
- (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
- PhasePoint = SiS_Pr->SiS_NTSCPhase2;
- }
- }
- #ifdef oldHV
- }
- #endif
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,temp);
- temp = 0;
- if((HwDeviceExtension->jChipType == SIS_630)||
- (HwDeviceExtension->jChipType == SIS_730)) {
- temp = 0x35;
- }
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- temp = 0x38;
- }
- if(temp) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
- temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,temp);
- if(temp1 & 0x40) {
- PhasePoint = SiS_Pr->SiS_PALMPhase;
- if( (SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) &&
- ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
- (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
- PhasePoint = SiS_Pr->SiS_PALMPhase2;
- }
- }
- if(temp1 & 0x80) {
- PhasePoint = SiS_Pr->SiS_PALNPhase;
- if( (SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) &&
- ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
- (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
- PhasePoint = SiS_Pr->SiS_PALNPhase2;
- }
- }
- }
- }
- }
- #ifdef SIS315H
- /* TW: Inserted from 650/301LV BIOS */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 650/301LV : 301LV | 302LV */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
- if((ModeNo == 0x4a) || (ModeNo == 0x38)) {
- PhasePoint = SiS_Pr->SiS_SpecialPhase;
- }
- }
- }
- }
- }
- #endif
- for(i=0x31, j=0; i<=0x34; i++, j++){
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,PhasePoint[j]);
- }
- for(i=0x01, j=0; i<=0x2D; i++, j++){
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
- }
- for(i=0x39; i<=0x45; i++, j++){
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
- }
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(!(SiS_Pr->SiS_ModeType & 0x07))
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F);
- } else {
- SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F);
- }
- }
- SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x0A,SiS_Pr->SiS_NewFlickerMode);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x35,SiS_Pr->SiS_RY1COE);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x36,SiS_Pr->SiS_RY2COE);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE);
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) tempax = 950;
- else {
- #endif
- if(SiS_Pr->SiS_VBInfo & SetPALTV) tempax = 520;
- else tempax = 440;
- #ifdef oldHV
- }
- #endif
- if( ( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_HiVision == 3) ) && (SiS_Pr->SiS_VDE <= tempax) ) ||
- ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (SiS_Pr->SiS_HiVision != 3) &&
- ( (SiS_Pr->SiS_VGAHDE == 1024) || ((SiS_Pr->SiS_VGAHDE != 1024) && (SiS_Pr->SiS_VDE <= tempax)) ) ) ) {
- tempax -= SiS_Pr->SiS_VDE;
- tempax >>= 2;
- tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
- temp = (tempax & 0xFF00) >> 8;
- temp += (USHORT)TimingPoint[0];
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp);
- temp = (tempax & 0xFF00) >> 8;
- temp += (USHORT)TimingPoint[1];
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp);
- if( (SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) &&
- (SiS_Pr->SiS_HiVision != 3) &&
- (SiS_Pr->SiS_VGAHDE >= 1024) ) {
- if(SiS_Pr->SiS_VBInfo & SetPALTV) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x19);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x52);
- } else {
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x17);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x1d);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x0b);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x11);
- }
- }
- }
- }
- tempcx = SiS_Pr->SiS_HT;
- /* TW: Inserted from 650/301LVx 1.10.6s */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) {
- tempcx >>= 1;
- }
- }
- tempcx--;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- tempcx--;
- }
- temp = tempcx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1B,temp);
- temp = (tempcx & 0xFF00) >> 8;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,temp);
- tempcx++;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- tempcx++;
- }
- tempcx >>= 1;
- push1 = tempcx;
- tempcx += 7;
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) tempcx -= 4;
- #endif
- temp = (tempcx & 0x00FF) << 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,temp);
- tempbx = TimingPoint[j] | ((TimingPoint[j+1]) << 8);
- tempbx += tempcx;
- push2 = tempbx;
- temp = tempbx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,temp);
- temp = ((tempbx & 0xFF00) >> 8) << 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0F,temp);
- tempbx = push2;
- tempbx += 8;
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
- tempbx -= 4;
- tempcx = tempbx;
- }
- #endif
- temp = (tempbx & 0x00FF) << 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,temp);
- j += 2;
- tempcx += ((TimingPoint[j] | ((TimingPoint[j+1]) << 8)));
- temp = tempcx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,temp);
- temp = ((tempcx & 0xFF00) >> 8) << 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x28,0x0F,temp);
- tempcx += 8;
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) tempcx -= 4;
- #endif
- temp = (tempcx & 0xFF) << 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,temp);
- tempcx = push1;
- j += 2;
- tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8));
- temp = (tempcx & 0x00FF) << 4;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,temp);
- tempcx -= 11;
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
- tempax = SiS_GetVGAHT2(SiS_Pr) - 1;
- tempcx = tempax;
- }
- temp = tempcx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2E,temp);
- tempbx = SiS_Pr->SiS_VDE;
- if(SiS_Pr->SiS_VGAVDE == 360) tempbx = 746;
- if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 746;
- if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 853;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempbx >>= 1;
- } else {
- if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) {
- tempbx >>= 1;
- if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
- if(ModeNo <= 0x13) {
- if(crt2crtc == 1) {
- tempbx++;
- }
- }
- } else {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- if(crt2crtc == 4) /* TW: BIOS calls GetRatePtrCRT2 here - does not make sense */
- if(SiS_Pr->SiS_ModeType <= 3) tempbx++;
- }
- }
- }
- }
- tempbx -= 2;
- temp = tempbx & 0x00FF;
- #ifdef oldHV
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- if(ModeNo == 0x2f) temp++;
- }
- }
- #endif
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2F,temp);
- tempax = (tempcx & 0xFF00) | (tempax & 0x00FF);
- tempbx = ((tempbx & 0xFF00) << 6) | (tempbx & 0x00FF);
- tempax |= (tempbx & 0xFF00);
- #ifdef oldHV
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) {
- #endif
- if(HwDeviceExtension->jChipType < SIS_315H) {
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART)) { /* TW: New from 630/301B (II) BIOS */
- tempax |= 0x1000;
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) tempax |= 0x2000;
- }
- } else {
- tempax |= 0x1000;
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) tempax |= 0x2000;
- }
- #ifdef oldHV
- }
- #endif
- temp = (tempax & 0xFF00) >> 8;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,temp);
- /* TW: Inserted from 650/301LVx 1.10.6s */
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) ||
- (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) ) {
- SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x10,0x60);
- }
- }
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* tv gatingno */
- tempbx = SiS_Pr->SiS_VDE;
- if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) {
- tempbx >>= 1;
- }
- tempbx -= 3;
- tempbx &= 0x03ff;
- temp = ((tempbx & 0xFF00) >> 8) << 5;
- temp |= 0x18;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x46,temp);
- temp = tempbx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x47,temp);
- if(HwDeviceExtension->jChipType >= SIS_315H) { /* TW: Inserted from 650/301LVx 1.10.6s */
- tempax = 0;
- if(SiS_Pr->SiS_HiVision & 0x07) {
- if(SiS_Pr->SiS_HiVision & 0x04) tempax = 0x1000;
- else if(SiS_Pr->SiS_HiVision & 0x01) tempax = 0x3000;
- else tempax = 0x5000;
- }
- temp = (tempax & 0xFF00) >> 8;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4d,temp);
- }
- }
- tempbx &= 0x00FF;
- if(!(modeflag & HalfDCLK)) {
- tempcx = SiS_Pr->SiS_VGAHDE;
- if(tempcx >= SiS_Pr->SiS_HDE){
- tempbx |= 0x2000;
- tempax &= 0x00FF;
- }
- }
- tempcx = 0x0101;
- if(SiS_Pr->SiS_VBInfo & (SetPALTV | SetCRT2ToTV)) { /*301b- TW: BIOS BUG? */
- if(!(SiS_Pr->SiS_HiVision & 0x03)) {
- if(SiS_Pr->SiS_VGAHDE >= 1024) {
- if(!(modeflag & HalfDCLK)) { /* TW: This check not in 630/301B */
- tempcx = 0x1920;
- if(SiS_Pr->SiS_VGAHDE >= 1280) {
- tempcx = 0x1420;
- tempbx &= 0xDFFF;
- }
- }
- }
- }
- }
- if(!(tempbx & 0x2000)){
- if(modeflag & HalfDCLK) {
- tempcx = (tempcx & 0xFF00) | (((tempcx & 0x00FF) << 1) & 0xff);
- }
- push1 = tempbx;
- tempeax = SiS_Pr->SiS_VGAHDE;
- tempebx = (tempcx & 0xFF00) >> 8;
- longtemp = tempeax * tempebx;
- tempecx = tempcx & 0x00FF;
- longtemp /= tempecx;
- longtemp <<= 0x0d;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- longtemp <<= 3;
- }
- tempecx = SiS_Pr->SiS_HDE;
- temp2 = longtemp % tempecx;
- tempeax = longtemp / tempecx;
- if(temp2 != 0) tempeax++;
- tempax = (USHORT)tempeax;
- tempbx = push1;
- tempcx = (tempcx & 0xff00) | (((tempax & 0xFF00) >> 8) >> 5);
- tempbx |= (tempax & 0x1F00);
- tempax = ((tempax & 0x00FF) << 8) | (tempax & 0x00FF);
- }
- temp = (tempax & 0xFF00) >> 8;
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x44,temp);
- temp = (tempbx & 0xFF00) >> 8;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,temp);
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- temp = tempcx & 0x00FF;
- if(tempbx & 0x2000) temp = 0;
- temp |= 0x18;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xE0,temp);
- if(SiS_Pr->SiS_VBInfo & SetPALTV) {
- tempbx = 0x0382; /* TW: BIOS; Was 0x0364; */
- tempcx = 0x007e; /* TW: BIOS; Was 0x009c; */
- } else {
- tempbx = 0x0369; /* TW: BIOS; Was 0x0346; */