- if( ((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) ||
- ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 1;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 3;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 3;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 1;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 1;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 1;
- else tempcx = 0x0057;
- }
- }
-
- tempbx += tempcx;
- if(SiS_Pr->SiS_VBType & VB_SISVB) {
- tempbx++; /* BPLVRS */
- }
- if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT;
- temp = tempbx & 0x00FF;
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* Part1_18h */
-
- tempcx >>= 3;
- if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
- if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) tempcx = 3;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempcx = 5;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) tempcx = 5;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 5;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 2;
- else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 2;
- }
- }
- }
- tempcx += tempbx;
- tempcx++; /* BPLVRE */
- temp = tempcx & 0x000F;
- if(SiS_Pr->SiS_VBType & VB_SISVB) {
- temp |= 0xC0;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp); /* Part1_19h */
- } else {
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp);
- }
-
- temp = ((tempbx >> 8) & 0x07) << 3;
- if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40;
- if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40;
- if(SiS_Pr->SiS_VBType & VB_SISVB) {
- /* Don't check Part1Port,0x00 -> is not being set if LCDA! */
- /* We check SR06 instead here: */
- if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
- if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80;
- }
- } else {
- if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
- if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80;
- }
- }
- SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x07,temp); /* Part1_1Ah */
-
- tempbx = push2; /* BPLVDEE */
-
- tempcx = SiS_Pr->SiS_LCDVDES; /* NPLVDES */
- if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
- if(resinfo == SIS_RI_800x600) tempcx++;
- }
- }
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
- tempbx = tempcx = SiS_Pr->SiS_VGAVDE;
- tempbx--;
- }
-
- temp = ((tempbx >> 8) & 0x07) << 3;
- temp = temp | ((tempcx >> 8) & 0x07);
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); /* Part1_1Dh */
- temp = tempbx & 0x00FF;
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,temp); /* Part1_1Ch */
- temp = tempcx & 0x00FF;
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,temp); /* Part1_1Bh */
-
- tempeax = SiS_Pr->SiS_VGAVDE << 18;
- tempebx = SiS_Pr->SiS_VDE;
- temp = (USHORT)(tempeax % tempebx);
- tempeax = tempeax / tempebx;
- if(temp) tempeax++;
- tempvcfact = tempeax;
-
- temp = (USHORT)(tempeax & 0x00FF);
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp);
-
- temp = (USHORT)((tempeax & 0x00FF00) >> 8);
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp);
-
- temp = (USHORT)((tempeax & 0x00030000) >> 16);
- if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04;
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp);
-
- if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) {
- temp = (USHORT)(tempeax & 0x00FF);
- SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3c,temp);
- temp = (USHORT)((tempeax & 0x00FF00) >> 8);
- SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3b,temp);
- temp = (USHORT)(((tempeax & 0x00030000) >> 16) << 6);
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0x3f,temp);
- temp = 0;
- if(SiS_Pr->SiS_VDE != SiS_Pr->SiS_VGAVDE) temp |= 0x08;
- SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x30,0xf3,temp);
- }
-
- tempeax = SiS_Pr->SiS_VGAHDE << 16;
- tempebx = SiS_Pr->SiS_HDE;
- temp = tempeax % tempebx;
- tempeax /= tempebx;
- if(temp) tempeax++;
- if(tempebx == SiS_Pr->SiS_VGAHDE) tempeax = 0xFFFF;
- tempecx = tempeax;
- tempeax = ((SiS_Pr->SiS_VGAHDE << 16) / tempecx) - 1;
- tempecx = (tempecx << 16) | (tempeax & 0xFFFF);
- temp = (USHORT)(tempecx & 0x00FF);
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); /* Part1_1Fh */
-
- tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact;
- tempbx = (USHORT)(tempeax & 0x0FFFF);
-
- if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--;
-
- if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempbx = 1;
-
- temp = ((tempbx >> 8) & 0x07) << 3;
- temp = temp | ((tempecx >> 8) & 0x07);
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); /* Part1_20h */
-
- temp = tempbx & 0x00FF;
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,temp); /* Part1_21h */
-
- tempecx >>= 16; /* BPLHCFACT */
- if(modeflag & HalfDCLK) tempecx >>= 1;
- temp = (USHORT)((tempecx & 0x0000FF00) >> 8);
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); /* Part1_22h */
-
- temp = (USHORT)(tempecx & 0x000000FF);
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp);
-
- if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)) {
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20);
- }
-}
-#endif /* SIS 315 */
-
-static USHORT
-SiS_GetVGAHT2(SiS_Private *SiS_Pr)
-{
- ULONG tempax,tempbx;
-
- tempbx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX) & 0xFFFF;
- tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT;
- tempax = (tempax * SiS_Pr->SiS_HT) / tempbx;
- return((USHORT) tempax);
-}
-
-/******* Set Part 1 / SiS bridge *********/
-static void
-SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex,
- PSIS_HW_INFO HwInfo,USHORT RefreshRateTableIndex)
-{
- USHORT push1,push2;
- USHORT tempax,tempbx,tempcx,temp;
- USHORT resinfo,modeflag;
- unsigned char p1_7, p1_8;
-
- if(ModeNo <= 0x13) {
- modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
- resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
- } else {
- if(SiS_Pr->UseCustomMode) {
- modeflag = SiS_Pr->CModeFlag;
- resinfo = 0;
- } else {
- modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
- }
-
- /* The following is only done if bridge is in slave mode: */
-
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */
-
- if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot;
-
- if(modeflag & Charx8Dot) tempcx = 0x08;
- else tempcx = 0x09;
-
- tempax = SiS_Pr->SiS_VGAHDE; /* 0x04 Horizontal Display End */
- if(modeflag & HalfDCLK) tempax >>= 1;
- tempax = ((tempax / tempcx) - 1) & 0xff;
- tempbx = tempax;
-
- temp = tempax;
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,temp);
-
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
- if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
- temp += 2;
- }
- }
- if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
- if(resinfo == SIS_RI_800x600) temp -= 2;
- }
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */
-
- SiS_SetReg(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */
-
- tempax = 0xFFFF;
- if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr);
- if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT;
- if(modeflag & HalfDCLK) tempax >>= 1;
- tempax = (tempax / tempcx) - 5;
- tempcx = tempax;