init.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:159k
- SiS_Pr->SiS_SelectCRT2Rate = 0;
- SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
- #ifdef LINUX_XF86
- xf86DrvMsg(0, X_PROBED, "(init: VBType=0x%04x, VBInfo=0x%04x)n",
- SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo);
- #endif
- if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
- }
- }
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
- }
- RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension);
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
- SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
- }
- if (RefreshRateTableIndex != 0xFFFF) {
- SiS_SetSync(SiS_Pr,ROMAddr,RefreshRateTableIndex);
- SiS_SetCRT1CRTC(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwDeviceExtension);
- SiS_SetCRT1Offset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwDeviceExtension);
- SiS_SetCRT1VCLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,RefreshRateTableIndex);
- }
- #ifdef SIS300
- if(HwDeviceExtension->jChipType == SIS_300){
- SiS_SetCRT1FIFO_300(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension,RefreshRateTableIndex);
- }
- if((HwDeviceExtension->jChipType == SIS_630)||
- (HwDeviceExtension->jChipType == SIS_730)||
- (HwDeviceExtension->jChipType == SIS_540)) {
- SiS_SetCRT1FIFO_630(SiS_Pr,ROMAddr,ModeNo,HwDeviceExtension,RefreshRateTableIndex);
- }
- #endif
- #ifdef SIS315H
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetCRT1FIFO_310(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension);
- }
- #endif
- SiS_SetCRT1ModeRegs(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,RefreshRateTableIndex);
- SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex);
- #ifndef LINUX_XF86
- if(SiS_Pr->SiS_flag_clearbuffer) {
- SiS_ClearBuffer(SiS_Pr,HwDeviceExtension,ModeNo);
- }
- #endif
- if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA))) {
- SiS_LongWait(SiS_Pr);
- SiS_DisplayOn(SiS_Pr);
- }
- }
- #ifdef LINUX_XF86
- void
- SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr)
- {
- SISPtr pSiS = SISPTR(pScrn);
- /* TW: We need to set pitch for CRT1 if bridge is in SlaveMode, too */
- if( (pSiS->VBFlags & DISPTYPE_DISP1) ||
- ( (pSiS->VBFlags & VB_VIDEOBRIDGE) &&
- ( ((pSiS->VGAEngine == SIS_300_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) ||
- ((pSiS->VGAEngine == SIS_315_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) ) {
- SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr);
- }
- if (pSiS->VBFlags & DISPTYPE_DISP2) {
- SiS_SetPitchCRT2(SiS_Pr, pScrn, BaseAddr);
- }
- }
- void
- SiS_SetPitchCRT1(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr)
- {
- SISPtr pSiS = SISPTR(pScrn);
- ULong HDisplay,temp;
- HDisplay = pSiS->scrnPitch / 8;
- SiS_SetReg1(SiS_Pr->SiS_P3d4, 0x13, (HDisplay & 0xFF));
- temp = (SiS_GetReg1(SiS_Pr->SiS_P3c4, 0x0E) & 0xF0) | (HDisplay>>8);
- SiS_SetReg1(SiS_Pr->SiS_P3c4, 0x0E, temp);
- }
- void
- SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr)
- {
- SISPtr pSiS = SISPTR(pScrn);
- ULong HDisplay,temp;
- HDisplay = pSiS->scrnPitch / 8;
- /* Unlock CRT2 */
- if (pSiS->VGAEngine == SIS_315_VGA)
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2F, 0xFF, 0x01);
- else
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x24, 0xFF, 0x01);
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07, (HDisplay & 0xFF));
- temp = (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x09) & 0xF0) | ((HDisplay >> 8) & 0xFF);
- SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x09, temp);
- }
- #endif
- /* TW: Checked against 650/301 and 630/301B BIOS */
- /* TW: Re-written for 650/301LVx 1.10.6s BIOS */
- void
- SiS_GetVBType(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT flag=0, rev=0, nolcd=0;
- SiS_Pr->SiS_VBType = 0;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) return;
- flag = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00);
- /* TW: Illegal values not welcome... */
- if(flag > 10) return;
- rev = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01);
- if (flag >= 2) {
- SiS_Pr->SiS_VBType = VB_SIS302B;
- } else if (flag == 1) {
- SiS_Pr->SiS_VBType = VB_SIS301;
- if(rev >= 0xB0) {
- SiS_Pr->SiS_VBType = VB_SIS301B;
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- nolcd = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x23);
- if(!(nolcd & 0x02))
- SiS_Pr->SiS_VBType |= VB_NoLCD;
- }
- }
- }
- if(SiS_Pr->SiS_VBType & (VB_SIS301B | VB_SIS302B)) {
- if(rev >= 0xD0) {
- SiS_Pr->SiS_VBType &= ~(VB_SIS301B | VB_SIS302B);
- SiS_Pr->SiS_VBType |= VB_SIS30xLV;
- SiS_Pr->SiS_VBType &= ~(VB_NoLCD);
- if(rev >= 0xE0) {
- SiS_Pr->SiS_VBType &= ~(VB_SIS30xLV);
- SiS_Pr->SiS_VBType |= VB_SIS30xNEW;
- }
- }
- }
- }
- /* TW: Checked against 650/301LVx 1.10.6s */
- BOOLEAN
- SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT *ModeNo,USHORT *ModeIdIndex)
- {
- UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO;
- if(*ModeNo <= 0x13) {
- if((*ModeNo) <= 5) (*ModeNo) |= 1;
- for (*ModeIdIndex=0;;(*ModeIdIndex)++) {
- if (SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == (*ModeNo)) break;
- if (SiS_Pr->SiS_SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF) return FALSE;
- }
- if(*ModeNo == 0x07) {
- if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */
- /* else 350 lines */
- }
- if(*ModeNo <= 3) {
- if(!(VGAINFO & 0x80)) (*ModeIdIndex)++;
- if(VGAINFO & 0x10) (*ModeIdIndex)++; /* 400 lines */
- /* else 350 lines */
- }
- /* else 200 lines */
- } else {
- for (*ModeIdIndex=0;;(*ModeIdIndex)++) {
- if (SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == (*ModeNo)) break;
- if (SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) return FALSE;
- }
- }
- return TRUE;
- }
- /* For SiS 300 oem util: Search VBModeID */
- BOOLEAN
- SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo)
- {
- USHORT ModeIdIndex;
- UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO;
- if(*ModeNo <= 5) *ModeNo |= 1;
- for(ModeIdIndex=0; ; ModeIdIndex++) {
- if (SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == *ModeNo) break;
- if (SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].ModeID == 0xFF) return FALSE;
- }
- if(*ModeNo != 0x07) {
- if(*ModeNo > 0x03) return ((BOOLEAN)ModeIdIndex);
- if(VGAINFO & 0x80) return ((BOOLEAN)ModeIdIndex);
- ModeIdIndex++;
- }
- if(VGAINFO & 0x10) ModeIdIndex++; /* 400 lines */
- /* else 350 lines */
- return ((BOOLEAN)ModeIdIndex);
- }
- /* TW: Checked against 630/301B, 315 1.09 and 650/301LVx 1.10.6s BIOS */
- /* TW: Modified */
- BOOLEAN
- SiS_CheckMemorySize(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT memorysize,modeflag;
- ULONG temp;
- if (ModeNo<=0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- }
- memorysize = modeflag & MemoryInfoFlag;
- memorysize >>= MemorySizeShift; /* Get required memory size */
- memorysize++;
- temp = GetDRAMSize(SiS_Pr, HwDeviceExtension); /* Get adapter memory size */
- temp /= (1024*1024); /* (in MB) */
- if(temp < memorysize) return(FALSE);
- else return(TRUE);
- }
- UCHAR
- SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- UCHAR index;
- if(ModeNo<=0x13) {
- index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_StTableIndex;
- } else {
- if(SiS_Pr->SiS_ModeType <= 0x02) index=0x1B; /* 02 -> ModeEGA */
- else index=0x0F;
- }
- return index;
- }
- /* TW: Checked against 300, 650/LVDS (1.10.07, 1.10a) and 650/301LV BIOS */
- void
- SiS_SetSeqRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex)
- {
- UCHAR SRdata;
- USHORT i;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x00,0x03); /* Set SR0 */
- SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0];
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- SRdata |= 0x01;
- }
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- SRdata |= 0x01; /* 8 dot clock */
- }
- }
- }
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- SRdata |= 0x01; /* 8 dot clock */
- }
- }
- }
- SRdata |= 0x20; /* screen off */
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x01,SRdata);
- for(i=02;i<=04;i++) {
- SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1];
- SiS_SetReg1(SiS_Pr->SiS_P3c4,i,SRdata);
- }
- }
- /* Checked against 300, 650/301LVx 1.10.6s and 650/LVDS 1.10.07 BIOS */
- void
- SiS_SetMiscRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex)
- {
- UCHAR Miscdata;
- Miscdata = SiS_Pr->SiS_StandTable[StandTableIndex].MISC;
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
- Miscdata |= 0x0C;
- }
- }
- SiS_SetReg3(SiS_Pr->SiS_P3c2,Miscdata);
- }
- /* Checked against 300, 650/LVDS (1.10.07) and 650/301LVx (1.10.6s) BIOS (630 code still there!) */
- void
- SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT StandTableIndex)
- {
- UCHAR CRTCdata;
- USHORT i;
- SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /* Unlock CRTC */
- for(i=0;i<=0x18;i++) {
- CRTCdata=SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,CRTCdata); /* Set CRTC(3d4) */
- }
- if( ( (HwDeviceExtension->jChipType == SIS_630) ||
- (HwDeviceExtension->jChipType == SIS_730) ) &&
- (HwDeviceExtension->jChipRevision >= 0x30) ) { /* for 630S0 */
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x18,0xFE);
- }
- }
- }
- }
- /* TW: Checked against 300, 650/LVDS (1.10.07), 650/301LVx (1.10.6s) and 630/301B BIOS */
- void
- SiS_SetATTRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex,USHORT ModeNo,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- UCHAR ARdata;
- USHORT i;
- for(i=0;i<=0x13;i++) {
- ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[i];
- #if 0
- if((i <= 0x0f) || (i == 0x11)) {
- if(ds:489 & 0x08) {
- continue;
- }
- }
- #endif
- if(i == 0x13) {
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ARdata=0;
- }
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0;
- }
- }
- }
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- /* TW: From 650/LVDS 1.10.07, 1.10a; 650/301LVx 1.10.6s */
- ARdata = 0;
- } else {
- if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
- ARdata=0;
- }
- }
- }
- }
- SiS_GetReg2(SiS_Pr->SiS_P3da); /* reset 3da */
- SiS_SetReg3(SiS_Pr->SiS_P3c0,i); /* set index */
- SiS_SetReg3(SiS_Pr->SiS_P3c0,ARdata); /* set data */
- }
- SiS_GetReg2(SiS_Pr->SiS_P3da); /* reset 3da */
- SiS_SetReg3(SiS_Pr->SiS_P3c0,0x14); /* set index */
- SiS_SetReg3(SiS_Pr->SiS_P3c0,0x00); /* set data */
- SiS_GetReg2(SiS_Pr->SiS_P3da); /* Enable Attribute */
- SiS_SetReg3(SiS_Pr->SiS_P3c0,0x20);
- }
- /* TW: Checked against 300, 650/LVDS (1.10.07, 1.10a) and 650/301LV BIOS */
- void
- SiS_SetGRCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex)
- {
- UCHAR GRdata;
- USHORT i;
- for(i=0;i<=0x08;i++) {
- GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; /* Get GR from file */
- SiS_SetReg1(SiS_Pr->SiS_P3ce,i,GRdata); /* Set GR(3ce) */
- }
- if(SiS_Pr->SiS_ModeType > ModeVGA) {
- SiS_SetRegAND(SiS_Pr->SiS_P3ce,0x05,0xBF); /* 256 color disable */
- }
- }
- /* TW: Checked against 650/LVDS (1.10.07, 1.10a), 650/301LVx (1.10.6s) and 630/301B BIOS */
- void
- SiS_ClearExt1Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT i;
- for(i=0x0A;i<=0x0E;i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0x00); /* Clear SR0A-SR0E */
- /* TW: New from 650/LVDS/301LV BIOSes: */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x37,0xFE);
- }
- }
- /* TW: Checked against 300, 650/LVDS (1.10.07) and 650/301LV BIOS */
- void
- SiS_SetSync(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT RefreshRateTableIndex)
- {
- USHORT sync;
- USHORT temp;
- sync = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
- sync &= 0xC0;
- temp = 0x2F | sync;
- SiS_SetReg3(SiS_Pr->SiS_P3c2,temp); /* Set Misc(3c2) */
- }
- /* TW: Checked against 300, 650/LVDS (1.10.07) and 650/301LVx (1.10.6s) BIOS */
- void
- SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- UCHAR index;
- USHORT tempah,i,modeflag,j;
- #ifdef SIS315H
- USHORT temp;
- USHORT ResInfo,DisplayType;
- const SiS_LCDACRT1DataStruct *LCDACRT1Ptr = NULL;
- #endif
- SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f); /*unlock cr0-7 */
- 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_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
- #ifdef SIS315H
- /* LCDA */
- temp = SiS_GetLCDACRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,&ResInfo,&DisplayType);
- switch(DisplayType) {
- case Panel_800x600 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_1; break;
- case Panel_1024x768 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break;
- case Panel_1280x1024 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1; break;
- case Panel_1400x1050 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1; break;
- case Panel_1600x1200 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1; break;
- case Panel_800x600 + 16 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_1_H; break;
- case Panel_1024x768 + 16 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1_H; break;
- case Panel_1280x1024 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_1_H; break;
- case Panel_1400x1050 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_1_H; break;
- case Panel_1600x1200 + 16: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_1_H; break;
- case Panel_800x600 + 32 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_2; break;
- case Panel_1024x768 + 32 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2; break;
- case Panel_1280x1024 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2; break;
- case Panel_1400x1050 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2; break;
- case Panel_1600x1200 + 32: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2; break;
- case Panel_800x600 + 48 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_2_H; break;
- case Panel_1024x768 + 48 : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_2_H; break;
- case Panel_1280x1024 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11280x1024_2_H; break;
- case Panel_1400x1050 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11400x1050_2_H; break;
- case Panel_1600x1200 + 48: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11600x1200_2_H; break;
- default: LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1; break;
- }
- tempah = (LCDACRT1Ptr+ResInfo)->CR[0];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah);
- for(i=0x01,j=1;i<=0x07;i++,j++){
- tempah = (LCDACRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x10,j=8;i<=0x12;i++,j++){
- tempah = (LCDACRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x15,j=11;i<=0x16;i++,j++){
- tempah =(LCDACRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
- }
- for(i=0x0A,j=13;i<=0x0C;i++,j++){
- tempah = (LCDACRT1Ptr+ResInfo)->CR[j];
- SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah);
- }
- tempah = (LCDACRT1Ptr+ResInfo)->CR[16];
- tempah &= 0x0E0;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah);
- tempah = (LCDACRT1Ptr+ResInfo)->CR[16];
- tempah &= 0x01;
- tempah <<= 5;
- if(modeflag & DoubleScanMode) tempah |= 0x080;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah);
- #endif
- } else {
- /* LVDS, 301, 301B, 301LV, 302LV, ... (non-LCDA) */
- index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */
- if(HwDeviceExtension->jChipType < SIS_315H) {
- index &= 0x3F;
- }
- for(i=0,j=0;i<=07;i++,j++) {
- tempah=SiS_Pr->SiS_CRT1Table[index].CR[i];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,j,tempah);
- }
- for(j=0x10;i<=10;i++,j++) {
- tempah=SiS_Pr->SiS_CRT1Table[index].CR[i];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,j,tempah);
- }
- for(j=0x15;i<=12;i++,j++) {
- tempah=SiS_Pr->SiS_CRT1Table[index].CR[i];
- SiS_SetReg1(SiS_Pr->SiS_P3d4,j,tempah);
- }
- for(j=0x0A;i<=15;i++,j++) {
- tempah=SiS_Pr->SiS_CRT1Table[index].CR[i];
- SiS_SetReg1(SiS_Pr->SiS_P3c4,j,tempah);
- }
- tempah = SiS_Pr->SiS_CRT1Table[index].CR[16];
- tempah &= 0xE0;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah);
- tempah = SiS_Pr->SiS_CRT1Table[index].CR[16];
- tempah &= 0x01;
- tempah <<= 5;
- if(modeflag & DoubleScanMode) tempah |= 0x80;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0xDF,tempah);
- }
- if(SiS_Pr->SiS_ModeType > ModeVGA) SiS_SetReg1(SiS_Pr->SiS_P3d4,0x14,0x4F);
- }
- BOOLEAN
- SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,USHORT *ResInfo,
- USHORT *DisplayType)
- {
- USHORT tempbx=0,modeflag=0;
- USHORT CRT2CRTC=0;
- if(ModeNo<=0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- CRT2CRTC = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- CRT2CRTC = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- }
- tempbx = SiS_Pr->SiS_LCDResInfo;
- if(SiS_Pr->SiS_LCDInfo & LCDNonExpanding) tempbx += 32;
- if(modeflag & HalfDCLK) tempbx += 16;
- *ResInfo = CRT2CRTC & 0x3F;
- *DisplayType = tempbx;
- return 1;
- }
- /* TW: Set offset and pitch - partly overruled by SetPitch() in XF86 */
- /* TW: Checked against 650/LVDS (1.10.07), 650/301LV and 315 BIOS */
- void
- SiS_SetCRT1Offset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- USHORT RefreshRateTableIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp, DisplayUnit, infoflag;
- infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
- DisplayUnit = SiS_GetOffset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,HwDeviceExtension);
- temp = (DisplayUnit >> 8) & 0x0f;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,temp);
- temp = DisplayUnit & 0xFF;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x13,temp);
- if(infoflag & InterlaceMode) DisplayUnit >>= 1;
- DisplayUnit <<= 5;
- temp = (DisplayUnit & 0xff00) >> 8;
- if (DisplayUnit & 0xff) temp++;
- temp++;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x10,temp);
- }
- /* TW: New from 650/LVDS 1.10.07, 630/301B and 630/LVDS BIOS */
- void
- SiS_ResetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT index;
- /* TW: We only need to do this if Panel Link is to be
- * initialized, thus on 630/LVDS/301B, and 650/LVDS
- */
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if (SiS_Pr->SiS_IF_DEF_LVDS == 0) return;
- } else {
- if( (SiS_Pr->SiS_IF_DEF_LVDS == 0) &&
- (!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) {
- return;
- }
- }
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xCF,0x20);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x20);
- }
- index = 1;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[index].SR2B);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[index].SR2C);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x31,0xcf,0x10);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x10);
- }
- index = 0;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[index].SR2B);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[index].SR2C);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80);
- }
- /* TW: Checked against 300, 650/LVDS, 650/301LVx, 315, 630/301B, 630/LVDS BIOS */
- void
- SiS_SetCRT1VCLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT RefreshRateTableIndex)
- {
- USHORT index;
- index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,HwDeviceExtension);
- if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
- && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ){
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VBVCLKData[index].Part4_A);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VBVCLKData[index].Part4_B);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x01);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80);
- }
- } else {
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xCF);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x00);
- }
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2B,SiS_Pr->SiS_VCLKData[index].SR2B);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2C,SiS_Pr->SiS_VCLKData[index].SR2C);
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x01);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2D,0x80);
- }
- }
- }
- #if 0 /* TW: Not used */
- void
- SiS_IsLowResolution(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT ModeFlag;
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0x7F);
- if(ModeNo > 0x13) {
- ModeFlag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x80);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x01,0xF7);
- }
- }
- }
- #endif
- /* TW: Checked against 300, 630/LVDS, 650/LVDS and 315 BIOS */
- void
- SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex)
- {
- USHORT data,data2,data3;
- USHORT infoflag=0,modeflag;
- USHORT resindex,xres;
- if(ModeNo > 0x13) {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
- } else {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- }
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1F,0x3F); /* DAC pedestal */
- if(ModeNo > 0x13) data = infoflag;
- else data = 0;
- data2 = 0;
- if(ModeNo > 0x13) {
- if(SiS_Pr->SiS_ModeType > 0x02) {
- data2 |= 0x02;
- data3 = (SiS_Pr->SiS_ModeType - ModeVGA) << 2;
- data2 |= data3;
- }
- }
- if(data & InterlaceMode) data2 |= 0x20;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x06,0xC0, data2);
- resindex = SiS_GetResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex);
- if(ModeNo <= 0x13) {
- xres = SiS_Pr->SiS_StResInfo[resindex].HTotal;
- } else {
- xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal;
- }
- if(HwDeviceExtension->jChipType != SIS_300) {
- data = 0x0000;
- if(infoflag & InterlaceMode) {
- if(xres == 1024) data = 0x0035;
- else data = 0x0048;
- }
- data2 = data & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x19,data2);
- data2 = (data & 0xFF00) >> 8;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x1a,0xFC,data2);
- }
- if(modeflag & HalfDCLK) {
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x01,0x08);
- }
- if(HwDeviceExtension->jChipType == SIS_300) {
- if(modeflag & LineCompareOff) {
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x08);
- } else {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xF7);
- }
- } else if(HwDeviceExtension->jChipType < SIS_315H) {
- if(modeflag & LineCompareOff) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,0x08);
- } else {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7);
- }
- /* 630 BIOS does something for mode 0x12 here */
- } else {
- if(modeflag & LineCompareOff) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,0x08);
- } else {
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7);
- }
- }
- if(HwDeviceExtension->jChipType != SIS_300) {
- if(SiS_Pr->SiS_ModeType == ModeEGA) {
- if(ModeNo > 0x13) {
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x0F,0x40);
- }
- }
- }
- #ifdef SIS315H
- /* TW: 315 BIOS sets SR17 at this point */
- if(HwDeviceExtension->jChipType == SIS_315PRO) {
- data = SiS_Get310DRAMType(SiS_Pr,ROMAddr,HwDeviceExtension);
- data = SiS_Pr->SiS_SR15[2][data];
- if(SiS_Pr->SiS_ModeType == ModeText) {
- data &= 0xc7;
- } else {
- data2 = SiS_GetOffset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,HwDeviceExtension);
- data2 >>= 1;
- if(infoflag & InterlaceMode) data2 >>= 1;
- data3 = SiS_GetColorDepth(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex);
- data3 >>= 1;
- if(data3 == 0) data3++;
- data2 /= data3;
- if(data2 >= 0x50) {
- data &= 0x0f;
- data |= 0x50;
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x17,data);
- }
- #endif
- data = 0x60;
- if(SiS_Pr->SiS_ModeType != ModeText) {
- data ^= 0x60;
- if(SiS_Pr->SiS_ModeType != ModeEGA) {
- data ^= 0xA0;
- }
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x21,0x1F,data);
- SiS_SetVCLKState(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,RefreshRateTableIndex,ModeIdIndex);
- #ifdef SIS315H
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40) {
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x52,0x2c);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x52,0x6c);
- }
- }
- #endif
- }
- /* TW: Checked against 300, 315, 650/LVDS, 650/301LVx, 630/301B and 630/LVDS BIOS */
- void
- SiS_SetVCLKState(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT ModeNo,USHORT RefreshRateTableIndex,
- USHORT ModeIdIndex)
- {
- USHORT data, data2=0;
- USHORT VCLK, index=0;
- if (ModeNo <= 0x13) VCLK = 0;
- else {
- index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
- RefreshRateTableIndex,HwDeviceExtension);
- VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;
- }
- if(HwDeviceExtension->jChipType < SIS_315H) { /* 300 series */
- data2 = 0x00;
- if(VCLK > 150) data2 |= 0x80;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data2); /* DAC speed */
- data2 = 0x00;
- if(VCLK >= 150) data2 |= 0x08; /* VCLK > 150 */
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data2);
- } else { /* 310/325 series */
- data = 0;
- if(VCLK >= 166) data |= 0x0c; /* TW: Was 200; is 166 in 650 and 315 BIOSes */
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data);
- if(VCLK >= 166) { /* TW: Was 200, is 166 in 650 and 315 BIOSes */
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7);
- }
- #if 0 /* Not done in 315 and 650/301LV/LVDS BIOSes: */
- data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); /* DAC pedestal */
- data &= 0xE7;
- if(VCLK<200) data |= 0x10;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,data); /* DAC pedestal */
- #endif
- }
- data2 = 0x03;
- if((VCLK >= 135) && (VCLK < 160)) data2 = 0x02;
- if((VCLK >= 160) && (VCLK < 260)) data2 = 0x01;
- if(VCLK >= 260) data2 = 0x00;
- /* disable 24bit palette RAM gamma correction */
- if(HwDeviceExtension->jChipType == SIS_540) {
- if((VCLK == 203) || (VCLK < 234)) data2 = 0x02;
- }
- if(HwDeviceExtension->jChipType < SIS_315H) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xFC,data2); /* DAC speed */
- } else {
- if(HwDeviceExtension->jChipType > SIS_315PRO) {
- /* TW: This "if" is done in 650/LVDS/301LV BIOSes; Not in 315 BIOS */
- if(ModeNo > 0x13) data2 &= 0xfc;
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0xF8,data2); /* DAC speed */
- }
- }
- /* TW: Checked against 650/301LVx 1.10.6s, 315, 630/301B BIOS */
- void
- SiS_LoadDAC(SiS_Private *SiS_Pr,PSIS_HW_DEVICE_INFO HwDeviceExtension,
- UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
- {
- USHORT data,data2;
- USHORT time,i,j,k;
- USHORT m,n,o;
- USHORT si,di,bx,dl;
- USHORT al,ah,dh;
- USHORT DACAddr, DACData, shiftflag;
- const USHORT *table = NULL;
- #if 0
- USHORT tempah,tempch,tempcl,tempdh,tempal,tempbx;
- #endif
- if (ModeNo<=0x13)
- data = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- data = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- #if 0
- if(!(ds:489 & 0x08)) {
- #endif
- data &= DACInfoFlag;
- time = 64;
- if(data == 0x00) table = SiS_MDA_DAC;
- if(data == 0x08) table = SiS_CGA_DAC;
- if(data == 0x10) table = SiS_EGA_DAC;
- if(data == 0x18) {
- time = 256;
- table = SiS_VGA_DAC;
- }
- if(time == 256) j = 16;
- else j = time;
- if( ( (HwDeviceExtension->jChipType < SIS_315H) && /* 630/301B */
- (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
- (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) ||
- (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) || /* LCDA */
- (!(SiS_Pr->SiS_SetFlag & ProgrammingCRT2)) ) { /* Programming CRT1 */
- DACAddr = SiS_Pr->SiS_P3c8;
- DACData = SiS_Pr->SiS_P3c9;
- shiftflag = 0;
- SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF);
- } else {
- shiftflag = 1;
- DACAddr = SiS_Pr->SiS_Part5Port;
- DACData = SiS_Pr->SiS_Part5Port + 1;
- }
- SiS_SetReg3(DACAddr,0x00);
- for(i=0; i<j; i++) {
- data = table[i];
- for(k=0; k<3; k++) {
- data2 = 0;
- if(data & 0x01) data2 = 0x2A;
- if(data & 0x02) data2 += 0x15;
- if(shiftflag) data2 <<= 2;
- SiS_SetReg3(DACData,data2);
- data >>= 2;
- }
- }
- if(time == 256) {
- for(i = 16; i < 32; i++) {
- data = table[i];
- if(shiftflag) data <<= 2;
- for(k=0; k<3; k++) SiS_SetReg3(DACData,data);
- }
- si = 32;
- for(m = 0; m < 9; m++) {
- di = si;
- bx = si + 4;
- dl = 0;
- for(n = 0; n < 3; n++) {
- for(o = 0; o < 5; o++) {
- dh = table[si];
- ah = table[di];
- al = table[bx];
- si++;
- SiS_WriteDAC(SiS_Pr,DACData,shiftflag,dl,ah,al,dh);
- }
- si -= 2;
- for(o = 0; o < 3; o++) {
- dh = table[bx];
- ah = table[di];
- al = table[si];
- si--;
- SiS_WriteDAC(SiS_Pr,DACData,shiftflag,dl,ah,al,dh);
- }
- dl++;
- } /* for n < 3 */
- si += 5;
- } /* for m < 9 */
- }
- #if 0
- } /* ds:489 & 0x08 */
- #endif
- #if 0
- if((!(ds:489 & 0x08)) && (ds:489 & 0x06)) {
- tempbx = 0;
- for(i=0; i< 256; i++) {
- SiS_SetReg3(SiS_Pr->SiS_P3c8-1,tempbx); /* 7f87 */
- tempah = SiS_GetReg3(SiS_Pr->SiS_P3c8+1); /* 7f83 */
- tempch = SiS_GetReg3(SiS_Pr->SiS_P3c8+1);
- tempcl = SiS_GetReg3(SiS_Pr->SiS_P3c8+1);
- tempdh = tempah;
- tempal = 0x4d * tempdh; /* 7fb8 */
- tempbx += tempal;
- tempal = 0x97 * tempch;
- tempbx += tempal;
- tempal = 0x1c * tempcl;
- tempbx += tempal;
- if((tempbx & 0x00ff) > 0x80) tempbx += 0x100;
- tempdh = (tempbx & 0x00ff) >> 8;
- tempch = tempdh;
- tempcl = tempdh;
- SiS_SetReg3(SiS_Pr->SiS_P3c8,(tempbx & 0xff)); /* 7f7c */
- SiS_SetReg3(SiS_Pr->SiS_P3c8+1,tempdh); /* 7f92 */
- SiS_SetReg3(SiS_Pr->SiS_P3c8+1,tempch);
- SiS_SetReg3(SiS_Pr->SiS_P3c8+1,tempcl);
- }
- }
- #endif
- }
- void
- SiS_WriteDAC(SiS_Private *SiS_Pr, USHORT DACData, USHORT shiftflag,
- USHORT dl, USHORT ah, USHORT al, USHORT dh)
- {
- USHORT temp;
- USHORT bh,bl;
- bh = ah;
- bl = al;
- if(dl != 0) {
- temp = bh;
- bh = dh;
- dh = temp;
- if(dl == 1) {
- temp = bl;
- bl = dh;
- dh = temp;
- } else {
- temp = bl;
- bl = bh;
- bh = temp;
- }
- }
- if(shiftflag) {
- dh <<= 2;
- bh <<= 2;
- bl <<= 2;
- }
- SiS_SetReg3(DACData,(USHORT)dh);
- SiS_SetReg3(DACData,(USHORT)bh);
- SiS_SetReg3(DACData,(USHORT)bl);
- }
- ULONG
- GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- ULONG AdapterMemorySize = 0;
- #ifdef SIS315H
- USHORT counter;
- #endif
- #ifdef SIS315H
- if ((HwDeviceExtension->jChipType == SIS_315H) ||
- (HwDeviceExtension->jChipType == SIS_315PRO)) {
- counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14);
- AdapterMemorySize = 1 << ((counter & 0xF0) >> 4);
- counter >>= 2;
- counter &= 0x03;
- if(counter == 0x02) {
- AdapterMemorySize += (AdapterMemorySize / 2); /* DDR asymetric */
- } else if(counter != 0) {
- AdapterMemorySize <<= 1; /* SINGLE_CHANNEL_2_RANK or DUAL_CHANNEL_1_RANK */
- }
- AdapterMemorySize *= (1024*1024);
- } else if((HwDeviceExtension->jChipType == SIS_550) ||
- (HwDeviceExtension->jChipType == SIS_640) ||
- (HwDeviceExtension->jChipType == SIS_740) ||
- (HwDeviceExtension->jChipType == SIS_650)) {
- counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F;
- counter++;
- AdapterMemorySize = counter * 4;
- AdapterMemorySize *= (1024*1024);
- }
- #endif
- #ifdef SIS300
- if ((HwDeviceExtension->jChipType==SIS_300) ||
- (HwDeviceExtension->jChipType==SIS_540) ||
- (HwDeviceExtension->jChipType==SIS_630) ||
- (HwDeviceExtension->jChipType==SIS_730)) {
- AdapterMemorySize = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F;
- AdapterMemorySize++;
- AdapterMemorySize *= (1024*1024);
- }
- #endif
- return AdapterMemorySize;
- }
- #ifndef LINUX_XF86
- void
- SiS_ClearBuffer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo)
- {
- PVOID VideoMemoryAddress = (PVOID)HwDeviceExtension->pjVideoMemoryAddress;
- ULONG AdapterMemorySize = (ULONG)HwDeviceExtension->ulVideoMemorySize;
- PUSHORT pBuffer;
- int i;
- if (SiS_Pr->SiS_ModeType>=ModeEGA) {
- if(ModeNo > 0x13) {
- AdapterMemorySize = GetDRAMSize(SiS_Pr, HwDeviceExtension);
- SiS_SetMemory(VideoMemoryAddress,AdapterMemorySize,0);
- } else {
- pBuffer = VideoMemoryAddress;
- for(i=0; i<0x4000; i++)
- pBuffer[i] = 0x0000;
- }
- } else {
- pBuffer = VideoMemoryAddress;
- if (SiS_Pr->SiS_ModeType < ModeCGA) {
- for(i=0; i<0x4000; i++)
- pBuffer[i] = 0x0720;
- } else {
- SiS_SetMemory(VideoMemoryAddress,0x8000,0);
- }
- }
- }
- #endif
- void
- SiS_DisplayOn(SiS_Private *SiS_Pr)
- {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x00);
- }
- void
- SiS_DisplayOff(SiS_Private *SiS_Pr)
- {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x01,0xDF,0x20);
- }
- /* ========================================== */
- /* SR CRTC GR */
- void
- SiS_SetReg1(USHORT port, USHORT index, USHORT data)
- {
- OutPortByte(port,index);
- OutPortByte(port+1,data);
- }
- /* ========================================== */
- /* AR(3C0) */
- void
- SiS_SetReg2(SiS_Private *SiS_Pr, USHORT port, USHORT index, USHORT data)
- {
- InPortByte(port+0x3da-0x3c0);
- OutPortByte(SiS_Pr->SiS_P3c0,index);
- OutPortByte(SiS_Pr->SiS_P3c0,data);
- OutPortByte(SiS_Pr->SiS_P3c0,0x20);
- }
- void
- SiS_SetReg3(USHORT port, USHORT data)
- {
- OutPortByte(port,data);
- }
- void
- SiS_SetReg4(USHORT port, ULONG data)
- {
- OutPortLong(port,data);
- }
- UCHAR SiS_GetReg1(USHORT port, USHORT index)
- {
- UCHAR data;
- OutPortByte(port,index);
- data = InPortByte(port+1);
- return(data);
- }
- UCHAR
- SiS_GetReg2(USHORT port)
- {
- UCHAR data;
- data= InPortByte(port);
- return(data);
- }
- ULONG
- SiS_GetReg3(USHORT port)
- {
- ULONG data;
- data = InPortLong(port);
- return(data);
- }
- void
- SiS_ClearDAC(SiS_Private *SiS_Pr, ULONG port)
- {
- int i;
- OutPortByte(port, 0);
- port++;
- for (i=0; i < (256 * 3); i++) {
- OutPortByte(port, 0);
- }
- }
- #if 0 /* TW: Unused */
- void
- SiS_SetInterlace(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT RefreshRateTableIndex)
- {
- ULONG Temp;
- USHORT data,Temp2;
- if (ModeNo<=0x13) return;
- Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x01);
- Temp++;
- Temp <<= 3;
- if(Temp == 1024) data = 0x0035;
- else if(Temp == 1280) data = 0x0048;
- else data = 0x0000;
- Temp2 = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
- Temp2 &= InterlaceMode;
- if(Temp2 == 0) data=0x0000;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x19,data);
- Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3d4,0x1A);
- Temp = (USHORT)(Temp & 0xFC);
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x1A,(USHORT)Temp);
- Temp = (ULONG)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x0f);
- Temp2 = (USHORT)Temp & 0xBF;
- if(ModeNo==0x37) Temp2 |= 0x40;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x1A,(USHORT)Temp2);
- }
- #endif
- /* TW: Checked against 650/LVDS (1.10.07), 650/301LVx (1.10.6s) and 315 BIOS */
- #ifdef SIS315H
- void
- SiS_SetCRT1FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
- PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT modeflag;
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x3D,0xFE); /* disable auto-threshold */
- if(ModeNo > 0x13) {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- if( (!(modeflag & DoubleScanMode)) || (!(modeflag & HalfDCLK))) {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,0x34);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0);
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x3D,0x01);
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,0xAE);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0);
- }
- } else {
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,0xAE);
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x09,0xF0);
- }
- }
- #endif
- #ifdef SIS300
- void
- SiS_SetCRT1FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT RefreshRateTableIndex)
- {
- USHORT ThresholdLow = 0;
- USHORT index, VCLK, MCLK, colorth=0;
- USHORT tempah, temp;
- if(ModeNo > 0x13) {
- index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- index &= 0x3F;
- VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */
- switch (SiS_Pr->SiS_ModeType - ModeEGA) { /* Get half colordepth */
- case 0 : colorth = 1; break;
- case 1 : colorth = 1; break;
- case 2 : colorth = 2; break;
- case 3 : colorth = 2; break;
- case 4 : colorth = 3; break;
- case 5 : colorth = 4; break;
- }
- index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A);
- index &= 0x07;
- MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */
- tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35);
- tempah &= 0xc3;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3c,tempah);
- do {
- ThresholdLow = SiS_CalcDelay(SiS_Pr, ROMAddr, VCLK, colorth, MCLK);
- ThresholdLow++;
- if(ThresholdLow < 0x13) break;
- SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x16,0xfc);
- ThresholdLow = 0x13;
- tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16);
- tempah >>= 6;
- if(!(tempah)) break;
- tempah--;
- tempah <<= 6;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x16,0x3f,tempah);
- } while(0);
- } else ThresholdLow = 2;
- /* Write CRT/CPU threshold low, CRT/Engine threshold high */
- temp = (ThresholdLow << 4) | 0x0f;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,temp);
- temp = (ThresholdLow & 0x10) << 1;
- if(ModeNo > 0x13) temp |= 0x40;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0f,0x9f,temp);
- /* What is this? */
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3B,0x09);
- /* Write CRT/CPU threshold high */
- temp = ThresholdLow + 3;
- if(temp > 0x0f) temp = 0x0f;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x09,temp);
- }
- USHORT
- SiS_CalcDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT VCLK, USHORT colordepth, USHORT MCLK)
- {
- USHORT tempax, tempbx;
- tempbx = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 0);
- tempax = SiS_DoCalcDelay(SiS_Pr, MCLK, VCLK, colordepth, 1);
- if(tempax < 4) tempax = 4;
- tempax -= 4;
- if(tempbx < tempax) tempbx = tempax;
- return(tempbx);
- }
- USHORT
- SiS_DoCalcDelay(SiS_Private *SiS_Pr, USHORT MCLK, USHORT VCLK, USHORT colordepth, USHORT key)
- {
- const UCHAR ThLowA[] = { 61, 3,52, 5,68, 7,100,11,
- 43, 3,42, 5,54, 7, 78,11,
- 34, 3,37, 5,47, 7, 67,11 };
- const UCHAR ThLowB[] = { 81, 4,72, 6,88, 8,120,12,
- 55, 4,54, 6,66, 8, 90,12,
- 42, 4,45, 6,55, 8, 75,12 };
- const UCHAR ThTiming[] = { 1, 2, 2, 3, 0, 1, 1, 2 };
- USHORT tempah, tempal, tempcl, tempbx, temp;
- ULONG longtemp;
- tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18);
- tempah &= 0x62;
- tempah >>= 1;
- tempal = tempah;
- tempah >>= 3;
- tempal |= tempah;
- tempal &= 0x07;
- tempcl = ThTiming[tempal];
- tempbx = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16);
- tempbx >>= 6;
- tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14);
- tempah >>= 4;
- tempah &= 0x0c;
- tempbx |= tempah;
- tempbx <<= 1;
- if(key == 0) {
- tempal = ThLowA[tempbx + 1];
- tempal *= tempcl;
- tempal += ThLowA[tempbx];
- } else {
- tempal = ThLowB[tempbx + 1];
- tempal *= tempcl;
- tempal += ThLowB[tempbx];
- }
- longtemp = tempal * VCLK * colordepth;
- temp = longtemp % (MCLK * 16);
- longtemp /= (MCLK * 16);
- if(temp) longtemp++;
- return((USHORT)longtemp);
- }
- #if 0 /* TW: Old fragment, unused */
- USHORT
- SiS_CalcDelay(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT key)
- {
- USHORT data,data2,temp0,temp1;
- UCHAR ThLowA[]= {61,3,52,5,68,7,100,11,
- 43,3,42,5,54,7, 78,11,
- 34,3,37,5,47,7, 67,11};
- UCHAR ThLowB[]= {81,4,72,6,88,8,120,12,
- 55,4,54,6,66,8, 90,12,
- 42,4,45,6,55,8, 75,12};
- UCHAR ThTiming[]= {1,2,2,3,0,1,1,2};
- data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16);
- data=data>>6;
- data2=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14);
- data2=(data2>>4)&0x0C;
- data=data|data2;
- data=data<1;
- if(key==0) {
- temp0=(USHORT)ThLowA[data];
- temp1=(USHORT)ThLowA[data+1];
- } else {
- temp0=(USHORT)ThLowB[data];
- temp1=(USHORT)ThLowB[data+1];
- }
- data2=0;
- data=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18);
- if(data&0x02) data2=data2|0x01;
- if(data&0x20) data2=data2|0x02;
- if(data&0x40) data2=data2|0x04;
- data=temp1*ThTiming[data2]+temp0;
- return(data);
- }
- #endif
- void
- SiS_SetCRT1FIFO_630(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension,
- USHORT RefreshRateTableIndex)
- {
- USHORT i,index,data,VCLK,MCLK,colorth=0;
- ULONG B,eax,bl,data2;
- USHORT ThresholdLow=0;
- UCHAR FQBQData[]= { 0x01,0x21,0x41,0x61,0x81,
- 0x31,0x51,0x71,0x91,0xb1,
- 0x00,0x20,0x40,0x60,0x80,
- 0x30,0x50,0x70,0x90,0xb0,0xFF};
- i=0;
- if(ModeNo >= 0x13) {
- index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- index &= 0x3F;
- VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */
- index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A);
- index &= 0x07;
- MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */
- data2 = SiS_Pr->SiS_ModeType - ModeEGA; /* Get half colordepth */
- switch (data2) {
- case 0 : colorth = 1; break;
- case 1 : colorth = 1; break;
- case 2 : colorth = 2; break;
- case 3 : colorth = 2; break;
- case 4 : colorth = 3; break;
- case 5 : colorth = 4; break;
- }
- do{
- B = SiS_CalcDelay2(SiS_Pr, ROMAddr, FQBQData[i]) * VCLK * colorth;
- bl = B / (MCLK * 16);
- if (B==bl*16*MCLK) {
- bl = bl + 1;
- } else {
- bl = bl + 2;
- }
- if(bl > 0x13) {
- if(FQBQData[i+1] == 0xFF) {
- ThresholdLow = 0x13;
- break;
- }
- i++;
- } else {
- ThresholdLow = bl;
- break;
- }
- } while(FQBQData[i] != 0xFF);
- }
- else {
- ThresholdLow = 0x02;
- }
- /* Write foreground and background queue */
- data2 = FQBQData[i];
- data2 = (data2 & 0xf0)>>4;
- data2 <<= 24;
- #ifndef LINUX_XF86
- SiS_SetReg4(0xcf8,0x80000050);
- eax = SiS_GetReg3(0xcfc);
- eax &= 0xf0ffffff;
- eax |= data2;
- SiS_SetReg4(0xcfc,eax);
- #else
- /* We use pci functions X offers. We use pcitag 0, because
- * we want to read/write to the host bridge (which is always
- * 00:00.0 on 630, 730 and 540), not the VGA device.
- */
- eax = pciReadLong(0x00000000, 0x50);
- eax &= 0xf0ffffff;
- eax |= data2;
- pciWriteLong(0x00000000, 0x50, eax);
- #endif
- /* TODO: write GUI grant timer (PCI config 0xA3) */
- /* Write CRT/CPU threshold low, CRT/Engine threshold high */
- data = ((ThresholdLow & 0x0f) << 4) | 0x0f;
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x08,data);
- data = (ThresholdLow & 0x10) << 1;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xDF,data);
- /* What is this? */
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x3B,0x09);
- /* Write CRT/CPU threshold high (gap = 3) */
- data = ThresholdLow + 3;
- if(data > 0x0f) data = 0x0f;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data);
- }
- USHORT
- SiS_CalcDelay2(SiS_Private *SiS_Pr, UCHAR *ROMAddr,UCHAR key)
- {
- USHORT data,index;
- UCHAR LatencyFactor[] ={ 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */
- 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */
- 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */
- 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */
- 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */
- 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */
- 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */
- 00, 68, 66, 59, 57, 37}; /*; 128 bit BQ=1 */
- index = (key & 0xE0) >> 5;
- if(key & 0x10) index +=6;
- if(!(key & 0x01)) index += 24;
- data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14);
- if(data & 0x0080) index += 12;
- data = LatencyFactor[index];
- return(data);
- }
- #endif
- /* =============== Autodetection ================ */
- /* I N C O M P L E T E */
- BOOLEAN
- SiS_GetPanelID(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- const USHORT PanelTypeTable300[16] = {
- 0xc101, 0xc117, 0x0121, 0xc135, 0xc142, 0xc152, 0xc162, 0xc072,
- 0xc181, 0xc192, 0xc1a1, 0xc1b6, 0xc1c2, 0xc0d2, 0xc1e2, 0xc1f2
- };
- const USHORT PanelTypeTable31030x[16] = {
- 0xc102, 0xc112, 0x0122, 0xc132, 0xc142, 0xc152, 0xc169, 0xc179,
- 0x0189, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
- };
- const USHORT PanelTypeTable310LVDS[16] = {
- 0xc111, 0xc122, 0xc133, 0xc144, 0xc155, 0xc166, 0xc177, 0xc188,
- 0xc199, 0xc0aa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
- };
- USHORT tempax,tempbx,tempah,temp;
- if(HwDeviceExtension->jChipType < SIS_315H) {
- tempax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x18);
- tempbx = tempax & 0x0F;
- if(!(tempax & 0x10)){
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1){
- tempbx = 0;
- temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x38);
- if(temp & 0x40) tempbx |= 0x08;
- if(temp & 0x20) tempbx |= 0x02;
- if(temp & 0x01) tempbx |= 0x01;
- temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x39);
- if(temp & 0x80) tempbx |= 0x04;
- } else {
- return 0;
- }
- }
- tempbx = PanelTypeTable300[tempbx];
- tempbx |= LCDSync;
- temp = tempbx & 0x00FF;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp);
- temp = (tempbx & 0xFF00) >> 8;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp);
- } else {
- tempax = tempah = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1a);
- tempax &= 0x1e;
- tempax >>= 1;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if(tempax == 0) {
- /* TODO: Include HUGE detection routine
- (Probably not worth bothering)
- */
- return 0;
- }
- temp = tempax & 0xff;
- tempax--;
- tempbx = PanelTypeTable310LVDS[tempax];
- } else {
- tempbx = PanelTypeTable31030x[tempax];
- temp = tempbx & 0xff;
- }
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp);
- tempbx = (tempbx & 0xff00) >> 8;
- temp = tempbx & 0xc1;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,~(LCDSyncBit|LCDRGB18Bit),temp);
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- temp = tempbx & 0x04;
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x39,0xfb,temp);
- }
- }
- return 1;
- }
- #ifdef LINUXBIOS
- void
- SiS_DetectMonitor(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
- {
- UCHAR DAC_TEST_PARMS[] = {0x0F,0x0F,0x0F};
- UCHAR DAC_CLR_PARMS[] = {0x00,0x00,0x00};
- USHORT SR1F;
- SR1F = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F); /* backup DAC pedestal */
- SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1F,0x04);
- if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
- if(!(SiS_BridgeIsOn(SiS_Pr, BaseAddr))) {
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x41);
- }
- }
- SiSSetMode(SiS_Pr,HwDeviceExtension,0x2E);
- if(HwDeviceExtension->jChipType > SIS_315PRO) {
- /* TW: On 650 only - enable CRT1 */
- SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,0xbf);
- }
- SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff);
- SiS_ClearDAC(SiS_Pr, SiS_Pr->SiS_P3c8);
- SiS_LongWait(SiS_Pr);
- SiS_LongWait(SiS_Pr);
- SiS_LongWait(SiS_Pr);
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x00);
- if(SiS_TestMonitorType(SiS_Pr, DAC_TEST_PARMS[0],DAC_TEST_PARMS[1],DAC_TEST_PARMS[2])) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x20);
- } else if(SiS_TestMonitorType(SiS_Pr, DAC_TEST_PARMS[0],DAC_TEST_PARMS[1],DAC_TEST_PARMS[2])) {
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xDF,0x20);
- }
- SiS_TestMonitorType(SiS_Pr, DAC_CLR_PARMS[0],DAC_CLR_PARMS[1],DAC_CLR_PARMS[2]);
- SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,SR1F);
- }
- USHORT
- SiS_TestMonitorType(SiS_Private *SiS_Pr, UCHAR R_DAC,UCHAR G_DAC,UCHAR B_DAC)
- {
- USHORT temp,tempbx;
- tempbx = R_DAC * 0x4d + G_DAC * 0x97 + B_DAC * 0x1c;
- if((tempbx & 0x00ff) > 0x80) tempbx += 0x100;
- tempbx = (tempbx & 0xFF00) >> 8;
- R_DAC = (UCHAR) tempbx;
- G_DAC = (UCHAR) tempbx;
- B_DAC = (UCHAR) tempbx;
- SiS_SetReg3(SiS_Pr->SiS_P3c8,0x00);
- SiS_SetReg3(SiS_Pr->SiS_P3c9,R_DAC);
- SiS_SetReg3(SiS_Pr->SiS_P3c9,G_DAC);
- SiS_SetReg3(SiS_Pr->SiS_P3c9,B_DAC);
- SiS_LongWait(SiS_Pr);
- temp=SiS_GetReg2(SiS_Pr->SiS_P3c2);
- if(temp & 0x10) return(1);
- else return(0);
- }
- void
- SiS_GetSenseStatus(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,UCHAR *ROMAddr)
- {
- USHORT tempax=0,tempbx,tempcx,temp;
- USHORT P2reg0=0,SenseModeNo=0,OutputSelect=*SiS_Pr->pSiS_OutputSelect;
- USHORT ModeIdIndex,i;
- USHORT BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1){
- SiS_GetPanelID(SiS_Pr);
- temp=LCDSense;
- temp=temp|SiS_SenseCHTV(SiS_Pr);
- tempbx=~(LCDSense|AVIDEOSense|SVIDEOSense);
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,tempbx,temp);
- } else { /* for 301 */
- if(SiS_Pr->SiS_IF_DEF_HiVision==1) { /* for HiVision */
- tempax=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x38);
- temp=tempax&0x01;
- tempax=SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A);
- temp=temp|(tempax&0x02);
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,0xA0,temp);
- } else {
- if(SiS_BridgeIsOn(SiS_Pr, BaseAddr)==0) { /* TW: Inserted "==0" */
- P2reg0 = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00);
- if(!(SiS_BridgeIsEnable(SiS_Pr, BaseAddr,HwDeviceExtension))) {
- SenseModeNo=0x2e;
- temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&SenseModeNo,&ModeIdIndex);
- SiS_Pr->SiS_SetFlag = 0x00;
- SiS_Pr->SiS_ModeType = ModeVGA;
- SiS_Pr->SiS_VBInfo = SetCRT2ToRAMDAC |LoadDACFlag |SetInSlaveMode;
- SiS_SetCRT2Group301(SiS_Pr, BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension);
- for(i=0;i<20;i++) {
- SiS_LongWait(SiS_Pr);
- }
- }
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,0x1c);
- tempax=0;
- tempbx=*SiS_Pr->pSiS_RGBSenseData;
- if(SiS_Is301B(SiS_Pr, BaseAddr)){
- tempbx=*SiS_Pr->pSiS_RGBSenseData2;
- }
- tempcx=0x0E08;
- if(SiS_Sense(SiS_Pr, tempbx,tempcx)){
- if(SiS_Sense(SiS_Pr, tempbx,tempcx)){
- tempax=tempax|Monitor2Sense;
- }
- }
- tempbx=*SiS_Pr->pSiS_YCSenseData;
- if(SiS_Is301B(SiS_Pr, BaseAddr)){
- tempbx=*SiS_Pr->pSiS_YCSenseData2;
- }
- tempcx=0x0604;
- if(SiS_Sense(SiS_Pr, tempbx,tempcx)){
- if(SiS_Sense(SiS_Pr,tempbx,tempcx)){
- tempax=tempax|SVIDEOSense;
- }
- }
- if(ROMAddr && SiS_Pr->SiS_UseROM) {
- #ifdef SIS300
- if((HwDeviceExtension->jChipType==SIS_630)||
- (HwDeviceExtension->jChipType==SIS_730)) {
- OutputSelect = ROMAddr[0xfe];
- }
- #endif
- #ifdef SIS315H
- if(HwDeviceExtension->jChipType >= SIS_315H) {
- OutputSelect = ROMAddr[0xf3];
- }
- #endif
- }
- if(OutputSelect&BoardTVType){
- tempbx=*SiS_Pr->pSiS_VideoSenseData;
- if(SiS_Is301B(SiS_Pr, BaseAddr)){
- tempbx=*SiS_Pr->pSiS_VideoSenseData2;
- }
- tempcx=0x0804;
- if(SiS_Sense(SiS_Pr, tempbx,tempcx)){
- if(SiS_Sense(SiS_Pr, tempbx,tempcx)){
- tempax=tempax|AVIDEOSense;
- }
- }
- } else {
- if(!(tempax&SVIDEOSense)){
- tempbx=*SiS_Pr->pSiS_VideoSenseData;
- if(SiS_Is301B(SiS_Pr, BaseAddr)){
- tempbx=*SiS_Pr->pSiS_VideoSenseData2;
- }
- tempcx=0x0804;
- if(SiS_Sense(SiS_Pr,tempbx,tempcx)){
- if(SiS_Sense(SiS_Pr, tempbx,tempcx)){
- tempax=tempax|AVIDEOSense;
- }
- }
- }
- }
- }
- if(SiS_SenseLCD(SiS_Pr, HwDeviceExtension)){
- tempax=tempax|LCDSense;
- }
- tempbx=0;
- tempcx=0;
- SiS_Sense(SiS_Pr, tempbx,tempcx);
- if(SiS_Pr->SiS_VBType & (VB_SIS30xLV|VB_SIS30xLVX)){ /* TW: prev. 301LV|302LV */
- tempax &= 0x00ef; /* 301lv to disable CRT2*/
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x32,~0xDF,tempax);
- SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,P2reg0);
- if(!(P2reg0&0x20)) {
- SiS_Pr->SiS_VBInfo = DisableCRT2Display;
- SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension);
- }
- }
- }
- }
- BOOLEAN
- SiS_Sense(SiS_Private *SiS_Pr, USHORT tempbx,USHORT tempcx)
- {
- USHORT temp,i,tempch;
- temp = tempbx & 0xFF;
- SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x11,temp);
- temp = (tempbx & 0xFF00) >> 8;
- temp |= (tempcx & 0x00FF);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,~0x1F,temp);
- for(i=0; i<10; i++) SiS_LongWait(SiS_Pr);
- tempch = (tempcx & 0x7F00) >> 8;
- temp = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x03);
- temp ^= 0x0E;
- temp &= tempch;
- if(temp>0) return 1;
- else return 0;
- }
- USHORT
- SiS_SenseLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp;
- temp=SiS_GetPanelID(SiS_Pr);
- if(!temp) temp=SiS_GetLCDDDCInfo(SiS_Pr, HwDeviceExtension);
- return(temp);
- }
- BOOLEAN
- SiS_GetLCDDDCInfo(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
- {
- USHORT temp;
- /*add lcd sense*/
- if(HwDeviceExtension->ulCRT2LCDType==LCD_UNKNOWN)
- return 0;
- else{
- temp=(USHORT)HwDeviceExtension->ulCRT2LCDType;
- SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp);
- return 1;
- }
- }
- USHORT
- SiS_SenseCHTV(SiS_Private *SiS_Pr)
- {
- USHORT temp,push0e,status;
- status=0;
- push0e = SiS_GetCH700x(SiS_Pr, 0x0e);
- push0e = (push0e << 8) | 0x0e;
- SiS_SetCH700x(SiS_Pr, 0x0b0e);
- SiS_SetCH700x(SiS_Pr, 0x0110);
- SiS_SetCH700x(SiS_Pr, 0x0010);
- temp = SiS_GetCH700x(SiS_Pr, 0x10);
- if(temp & 0x08) status |= SVIDEOSense;
- if(temp & 0x02) status |= AVIDEOSense;
- SiS_SetCH700x(SiS_Pr, push0e);
- return(status);
- }
- #endif /* LINUXBIOS */
- /* ================ for TC only ================= */
- #ifdef TC
- int
- INT1AReturnCode(union REGS regs)
- {
- if (regs.x.cflag)
- {
- /*printf("Error to find pci device!n"); */
- return 1;
- }
- switch(regs.h.ah)
- {
- case 0: return 0;
- break;
- case 0x81: printf("Function not supportn");
- break;
- case 0x83: printf("bad vendor idn");
- break;
- case 0x86: printf("device not foundn");
- break;
- case 0x87: printf("bad register numbern");
- break;
- case 0x88: printf("set failedn");
- break;
- case 0x89: printf("buffer too small");
- break;
- }
- return 1;
- }
- unsigned
- FindPCIIOBase(unsigned index,unsigned deviceid)
- {
- union REGS regs;
- regs.h.ah = 0xb1; /*PCI_FUNCTION_ID */
- regs.h.al = 0x02; /*FIND_PCI_DEVICE */
- regs.x.cx = deviceid;
- regs.x.dx = 0x1039;
- regs.x.si = index; /* find n-th device */
- int86(0x1A, ®s, ®s);
- if (INT1AReturnCode(regs)!=0)
- return 0;
- /* regs.h.bh *//* bus number */
- /* regs.h.bl *//* device number */
- regs.h.ah = 0xb1; /*PCI_FUNCTION_ID */
- regs.h.al = 0x09; /*READ_CONFIG_WORD */
- regs.x.cx = deviceid;
- regs.x.dx = 0x1039;
- regs.x.di = 0x18; /* register number */
- int86(0x1A, ®s, ®s);
- if (INT1AReturnCode(regs)!=0)
- return 0;
- return regs.x.cx;
- }
- void
- main(int argc, char *argv[])
- {
- SIS_HW_DEVICE_INFO HwDeviceExtension;
- USHORT temp;
- USHORT ModeNo;
- /*HwDeviceExtension.pjVirtualRomBase =(PUCHAR) MK_FP(0xC000,0); */
- /*HwDeviceExtension.pjVideoMemoryAddress = (PUCHAR)MK_FP(0xA000,0);*/
- #ifdef SIS300
- HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x6300)&0xFF80) + 0x30;
- HwDeviceExtension.jChipType = SIS_630;
- #endif
- #ifdef SIS315H
- // HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x5315)&0xFF80) + 0x30;
- // HwDeviceExtension.jChipType = SIS_550;
- HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x325)&0xFF80) + 0x30;
- HwDeviceExtension.jChipType = SIS_315H;
- #endif
- HwDeviceExtension.ujVBChipID = VB_CHIP_301;
- strcpy(HwDeviceExtension.szVBIOSVer,"0.84");
- HwDeviceExtension.bSkipDramSizing = FALSE;
- HwDeviceExtension.ulVideoMemorySize = 0;
- if(argc==2) {
- ModeNo=atoi(argv[1]);
- }
- else {
- ModeNo=0x2e;
- /*ModeNo=0x37; */ /* 1024x768x 4bpp */
- /*ModeNo=0x38; *//* 1024x768x 8bpp */
- /*ModeNo=0x4A; *//* 1024x768x 16bpp */
- /*ModeNo=0x47;*/ /* 800x600x 16bpp */
- }
- /* SiSInit(SiS_Pr, &HwDeviceExtension);*/
- SiSSetMode(SiS_Pr, &HwDeviceExtension, ModeNo);
- }
- #endif /* TC END */
- /* ================ LINUX XFREE86 ====================== */
- /* Helper functions */
- #ifdef LINUX_XF86
- USHORT
- SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode)
- {
- SISPtr pSiS = SISPTR(pScrn);
- UShort i = (pSiS->CurrentLayout.bitsPerPixel+7)/8 - 1;
- UShort ModeIndex = 0;
- switch(mode->HDisplay)
- {
- case 320:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_320x480[i];
- }
- break;
- case 512:
- if(mode->VDisplay == 384) {
- ModeIndex = ModeIndex_512x384[i];
- }
- break;
- case 640:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_640x480[i];
- }
- break;
- case 720:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_720x480[i];
- } else if(mode->VDisplay == 576) {
- ModeIndex = ModeIndex_720x576[i];
- }
- break;
- case 800:
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_800x600[i];
- } else if(pSiS->VGAEngine == SIS_315_VGA) {
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_800x480[i];
- }
- }
- break;
- case 1024:
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1024x768[i];
- } else if(pSiS->VGAEngine == SIS_315_VGA) {
- if(mode->VDisplay == 576) {
- ModeIndex = ModeIndex_1024x576[i];
- }
- } else if(pSiS->VGAEngine == SIS_300_VGA) {
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_1024x600[i];
- }
- }
- break;
- case 1152:
- if(pSiS->VGAEngine == SIS_300_VGA) {
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1152x768[i];
- }
- }
- break;
- case 1280:
- if(mode->VDisplay == 960) {
- if(pSiS->VGAEngine == SIS_300_VGA) {
- ModeIndex = ModeIndex_300_1280x960[i];
- } else {
- ModeIndex = ModeIndex_310_1280x960[i];
- }
- } else if (mode->VDisplay == 1024) {
- ModeIndex = ModeIndex_1280x1024[i];
- } else if(pSiS->VGAEngine == SIS_315_VGA) {
- if (mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1280x768[i];
- } else if (mode->VDisplay == 720) {
- ModeIndex = ModeIndex_1280x720[i];
- }
- }
- break;
- case 1400:
- if(pSiS->VGAEngine == SIS_315_VGA) {
- if(mode->VDisplay == 1050) {
- ModeIndex = ModeIndex_1400x1050[i];
- }
- }
- break;
- case 1600:
- if(mode->VDisplay == 1200) {
- ModeIndex = ModeIndex_1600x1200[i];
- }
- break;
- case 1920:
- if(mode->VDisplay == 1440) {
- ModeIndex = ModeIndex_1920x1440[i];
- }
- break;
- case 2048:
- if(pSiS->VGAEngine == SIS_315_VGA) {
- if(mode->VDisplay == 1536) {
- ModeIndex = ModeIndex_2048x1536[i];
- }
- }
- break;
- }
- return(ModeIndex);
- }
- USHORT
- SiS_CheckCalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, int VBFlags)
- {
- SISPtr pSiS = SISPTR(pScrn);
- UShort i = (pSiS->CurrentLayout.bitsPerPixel+7)/8 - 1;
- UShort ModeIndex = 0;
- if(VBFlags & CRT2_LCD) {
- if( (mode->HDisplay <= pSiS->LCDwidth) &&
- (mode->VDisplay <= pSiS->LCDheight) ) {
- if(VBFlags & VB_LVDS) { /* LCD on LVDS */
- switch(mode->HDisplay)
- {
- case 512:
- if(mode->VDisplay == 384) {
- ModeIndex = ModeIndex_512x384[i];
- }
- break;
- case 640:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_640x480[i];
- }
- break;
- case 800:
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_800x600[i];
- }
- break;
- case 1024:
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1024x768[i];
- } else if(pSiS->VGAEngine == SIS_300_VGA) {
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_1024x600[i];
- }
- }
- break;
- case 1152:
- if(pSiS->VGAEngine == SIS_300_VGA) {
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1152x768[i];
- }
- }
- break;
- case 1280:
- if(mode->VDisplay == 1024) {
- ModeIndex = ModeIndex_1280x1024[i];
- } else if(pSiS->VGAEngine == SIS_315_VGA) {
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1280x768[i];
- }
- }
- break;
- case 1400:
- if(mode->VDisplay == 1050) {
- if(pSiS->VGAEngine == SIS_315_VGA) {
- ModeIndex = ModeIndex_1400x1050[i];
- }
- }
- break;
- }
- } else { /* LCD on 301(B) */
- switch(mode->HDisplay)
- {
- case 512:
- if(mode->VDisplay == 384) {
- ModeIndex = ModeIndex_512x384[i];
- }
- break;
- case 640:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_640x480[i];
- }
- break;
- case 800:
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_800x600[i];
- }
- break;
- case 1024:
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1024x768[i];
- } /* else if(pSiS->VGAEngine == SIS_300_VGA) { -- not supported on 301(B) --
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_1024x600[i];
- }
- } */
- break;
- case 1152: /* not supported on 301(B) */
- #if 0
- if(pSiS->VGAEngine == SIS_300_VGA) {
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1152x768[i];
- }
- }
- #endif
- break;
- case 1280:
- if(mode->VDisplay == 960) {
- if(pSiS->VGAEngine == SIS_300_VGA) {
- ModeIndex = ModeIndex_300_1280x960[i];
- } else {
- ModeIndex = ModeIndex_310_1280x960[i];
- }
- } else if (mode->VDisplay == 1024) {
- ModeIndex = ModeIndex_1280x1024[i];
- }
- case 1600:
- if(mode->VDisplay == 1200) {
- ModeIndex = ModeIndex_1600x1200[i];
- }
- break;
- }
- }
- }
- } else if(VBFlags & CRT2_TV) {
- if(VBFlags & VB_CHRONTEL) { /* TV on Chrontel */
- switch(mode->HDisplay)
- {
- case 512:
- if(mode->VDisplay == 384) {
- ModeIndex = ModeIndex_512x384[i];
- }
- break;
- case 640:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_640x480[i];
- }
- break;
- case 800:
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_800x600[i];
- }
- break;
- case 1024:
- if(mode->VDisplay == 768) {
- if(pSiS->VGAEngine == SIS_315_VGA) {
- ModeIndex = ModeIndex_1024x768[i];
- }
- }
- break;
- }
- } else { /* TV on 301(B) */
- switch(mode->HDisplay)
- {
- case 512:
- if(mode->VDisplay == 384) {
- ModeIndex = ModeIndex_512x384[i];
- }
- break;
- case 640:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_640x480[i];
- }
- break;
- case 720:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_720x480[i];
- } else if(mode->VDisplay == 576) {
- ModeIndex = ModeIndex_720x576[i];
- }
- break;
- case 800:
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_800x600[i];
- }
- break;
- case 1024:
- if(mode->VDisplay == 768) {
- if(VBFlags & (VB_301B|VB_302B|VB_30xLV|VB_30xLVX)) {
- ModeIndex = ModeIndex_1024x768[i];
- }
- }
- break;
- }
- }
- } else if(VBFlags & CRT2_VGA) { /* CRT2 is VGA2 */
- switch(mode->HDisplay)
- {
- case 512:
- if(mode->VDisplay == 384) {
- ModeIndex = ModeIndex_512x384[i];
- }
- break;
- case 640:
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_640x480[i];
- }
- break;
- case 800:
- if(mode->VDisplay == 600) {
- ModeIndex = ModeIndex_800x600[i];
- } else if(pSiS->VGAEngine == SIS_315_VGA) {
- if(mode->VDisplay == 480) {
- ModeIndex = ModeIndex_800x480[i];
- }
- }
- break;
- case 1024:
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1024x768[i];
- } else if(pSiS->VGAEngine == SIS_315_VGA) {
- if(mode->VDisplay == 576) {
- ModeIndex = ModeIndex_1024x576[i];
- }
- }
- break;
- case 1152:
- if(pSiS->VGAEngine == SIS_300_VGA) {
- if(mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1152x768[i];
- }
- }
- break;
- case 1280:
- if (mode->VDisplay == 1024) {
- ModeIndex = ModeIndex_1280x1024[i];
- } else if(pSiS->VGAEngine == SIS_315_VGA) {
- if (mode->VDisplay == 768) {
- ModeIndex = ModeIndex_1280x768[i];
- } else if (mode->VDisplay == 720) {
- ModeIndex = ModeIndex_1280x720[i];
- }
- }
- break;
- case 1400:
- if(pSiS->VGAEngine == SIS_315_VGA) {
- ModeIndex = ModeIndex_1400x1050[i];
- }
- break;
- }
- } else { /* CRT1 only, no CRT2 */
- ModeIndex = SiS_CalcModeIndex(pScrn, mode);
- }
- return(ModeIndex);
- }
- #define MODEID_OFF 0x449
- unsigned char
- SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id)
- {
- return(SiS_GetSetMMIOReg(pScrn, MODEID_OFF, id));
- }
- unsigned char
- SiS_GetSetMMIOReg(ScrnInfoPtr pScrn, USHORT offset, unsigned char value)
- {
- unsigned char ret;
- unsigned char *base;
- SISPtr pSiS = SISPTR(pScrn);
- BOOLEAN mapped;
- if(pSiS->IOBase) {
- base = (unsigned char *)pSiS->IOBase;
- mapped = FALSE;
- } else {
- base = xf86MapVidMem(pScrn->scrnIndex, VIDMEM_MMIO, 0, 0x2000);
- if(!base) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "(init.c: Could not MMIO area!)n");
- return 0;
- }
- mapped = TRUE;
- }
- ret = *(base + offset);
- /* value != 0xff means: set register */
- if (value != 0xff)
- *(base + offset) = value;
- if(mapped) xf86UnMapVidMem(pScrn->scrnIndex, base, 0x2000);
- return ret;
- }
- #endif