if(SiS_IsDualLink(SiS_Pr, HwInfo)) { 
if(SiS_IsDualLink(SiS_Pr)) { 
SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT RefreshRateTableIndex,	      PSIS_HW_INFO HwInfo){  USHORT      i, j, tempax, tempbx, tempcx, tempch, tempcl, temp;  USHORT      push2, modeflag, crt2crtc, bridgeoffset;  ULONG       longtemp;  const       UCHAR *PhasePoint;  const       UCHAR *TimingPoint;#ifdef SIS315H  USHORT      resindex, CRT2Index;  const       SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;#endif  if(ModeNo <= 0x13) {     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;     crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;  } else if(SiS_Pr->UseCustomMode) {     modeflag = SiS_Pr->CModeFlag;     crt2crtc = 0;  } else {     modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;     crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;  }  temp = 0;  if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToAVIDEO)) temp |= 0x08;  if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO)) temp |= 0x04;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART)     temp |= 0x02;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision)  temp |= 0x01;  if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) 	      temp |= 0x10;  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp);  PhasePoint  = SiS_Pr->SiS_PALPhase;  TimingPoint = SiS_Pr->SiS_PALTiming;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {     TimingPoint = SiS_Pr->SiS_HiTVExtTiming;     if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {        TimingPoint = SiS_Pr->SiS_HiTVSt2Timing;        if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {	   TimingPoint = SiS_Pr->SiS_HiTVSt1Timing;#if 0           if(!(modeflag & Charx8Dot))  TimingPoint = SiS_Pr->SiS_HiTVTextTiming;#endif        }     }  } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {     if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p)      TimingPoint = &SiS_YPbPrTable[2][0];     else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) TimingPoint = &SiS_YPbPrTable[1][0];     else					  TimingPoint = &SiS_YPbPrTable[0][0];     PhasePoint = SiS_Pr->SiS_NTSCPhase;  } else if(SiS_Pr->SiS_TVMode & TVSetPAL) {     if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&         ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||	   (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {        PhasePoint = SiS_Pr->SiS_PALPhase2;     }  } else {     TimingPoint = SiS_Pr->SiS_NTSCTiming;     PhasePoint  = SiS_Pr->SiS_NTSCPhase;     if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {	PhasePoint = SiS_Pr->SiS_PALPhase;     }     if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&	 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||	   (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {        PhasePoint = SiS_Pr->SiS_NTSCPhase2;	if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {	   PhasePoint = SiS_Pr->SiS_PALPhase2;	}     }  }  if(SiS_Pr->SiS_TVMode & TVSetPALM) {     PhasePoint = SiS_Pr->SiS_PALMPhase;     if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&	 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||	   (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {        PhasePoint = SiS_Pr->SiS_PALMPhase2;     }  }  if(SiS_Pr->SiS_TVMode & TVSetPALN) {     PhasePoint = SiS_Pr->SiS_PALNPhase;     if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&	 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||	   (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {	PhasePoint = SiS_Pr->SiS_PALNPhase2;     }  }  if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) {     PhasePoint = SiS_Pr->SiS_SpecialPhase;     if(SiS_Pr->SiS_TVMode & TVSetPALM) {        PhasePoint = SiS_Pr->SiS_SpecialPhaseM;     } else if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {        PhasePoint = SiS_Pr->SiS_SpecialPhaseJ;     }  }  for(i=0x31, j=0; i<=0x34; i++, j++) {     SiS_SetReg(SiS_Pr->SiS_Part2Port,i,PhasePoint[j]);  }  for(i=0x01, j=0; i<=0x2D; i++, j++) {     SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);  }  for(i=0x39; i<=0x45; i++, j++) {     SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);  }  if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {     if(SiS_Pr->SiS_ModeType != ModeText) {        SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F);     }  }  SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x0A,SiS_Pr->SiS_NewFlickerMode);  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x35,SiS_Pr->SiS_RY1COE);  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x36,SiS_Pr->SiS_RY2COE);  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE);  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE);  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) 	tempax = 950;  else if(SiS_Pr->SiS_TVMode & TVSetPAL)      	tempax = 520;  else 			            		tempax = 440; /* NTSC, YPbPr 525, 750 */  if( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) && (SiS_Pr->SiS_VDE <= tempax) ) ||      ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) &&        ((SiS_Pr->SiS_VGAHDE == 1024) || (SiS_Pr->SiS_VDE <= tempax)) ) ) {     tempax -= SiS_Pr->SiS_VDE;     tempax >>= 2;     tempax &= 0x00ff;     temp = tempax + (USHORT)TimingPoint[0];     SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp);     temp = tempax + (USHORT)TimingPoint[1];     SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp);     if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) {        if(SiS_Pr->SiS_TVMode & TVSetPAL) {           SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b);  /* 19 */           SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54);  /* 52 */        } else {           SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17);           SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1d);        }     }  }  tempcx = SiS_Pr->SiS_HT;  if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1;  tempcx--;  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx--;  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,tempcx);  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,((tempcx >> 8) & 0x0f));  tempcx = SiS_Pr->SiS_HT >> 1;  if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1;  tempcx += 7;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4;  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,((tempcx << 4) & 0xf0));  tempbx = TimingPoint[j] | (TimingPoint[j+1] << 8);  tempbx += tempcx;  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x24,tempbx);  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0F,((tempbx >> 4) & 0xf0));  tempbx += 8;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {     tempbx -= 4;     tempcx = tempbx;  }  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,((tempbx << 4) & 0xf0));  j += 2;  tempcx += (TimingPoint[j] | (TimingPoint[j+1] << 8));  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x27,tempcx);  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x28,0x0F,((tempcx >> 4) & 0xf0));  tempcx += 8;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4;  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,((tempcx << 4) & 0xf0));  tempcx = SiS_Pr->SiS_HT >> 1;  if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1;  j += 2;  tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8));  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,((tempcx << 4) & 0xf0));  tempcx -= 11;  if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {     tempcx = SiS_GetVGAHT2(SiS_Pr) - 1;  }  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2E,tempcx);  tempbx = SiS_Pr->SiS_VDE;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {     if(SiS_Pr->SiS_VGAVDE == 360) tempbx = 746;     if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 746;     if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 853;  } else if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) &&             (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) {     tempbx >>= 1;     if(HwInfo->jChipType >= SIS_315H) {        if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {	   if((ModeNo <= 0x13) && (crt2crtc == 1)) tempbx++;	} else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {	   if(SiS_Pr->SiS_ModeType <= ModeVGA) {	      if(crt2crtc == 4) tempbx++;	   }	}     }     if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {        if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {	   if((ModeNo == 0x2f) || (ModeNo == 0x5d) || (ModeNo == 0x5e)) tempbx++;	}	if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {	   if(ModeNo == 0x03) tempbx++; /* From 1.10.7w - doesn't make sense */        }     }  }  tempbx -= 2;  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2F,tempbx);  temp = (tempcx >> 8) & 0x0F;  temp |= ((tempbx >> 2) & 0xC0);  if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) {     temp |= 0x10;     if(SiS_Pr->SiS_VBInfo & SetCRT2ToAVIDEO) temp |= 0x20;  }  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp);  if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) {     SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xdf,((tempbx & 0x0400) >> 5));  }#if 0  /* TEST qqqq */  if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {     for(i=0x01, j=0; i<=0x2D; i++, j++) {        SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);     }     for(i=0x39; i<=0x45; i++, j++) {        SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);     }  }#endif  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {     tempbx = SiS_Pr->SiS_VDE;     if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) &&         (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) ) {        tempbx >>= 1;     }     tempbx -= 3;     temp = ((tempbx >> 3) & 0x60) | 0x18;     SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp);     SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,tempbx);     if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) {	SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xbf,((tempbx & 0x0400) >> 4));     }  }  tempbx = 0;  if(!(modeflag & HalfDCLK)) {     if(SiS_Pr->SiS_VGAHDE >= SiS_Pr->SiS_HDE) {        tempax = 0;        tempbx |= 0x20;     }  }  tempch = tempcl = 0x01;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {     if(SiS_Pr->SiS_VGAHDE >= 1024) {        if((!(modeflag & HalfDCLK)) || (HwInfo->jChipType < SIS_315H)) {           tempch = 0x19;	   tempcl = 0x20;           if(SiS_Pr->SiS_VGAHDE >= 1280) {              tempch = 0x14;              tempbx &= ~0x20;           }        }     }  }  if(!(tempbx & 0x20)) {     if(modeflag & HalfDCLK) tempcl <<= 1;     longtemp = ((SiS_Pr->SiS_VGAHDE * tempch) / tempcl) << 13;     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) longtemp <<= 3;     tempax = longtemp / SiS_Pr->SiS_HDE;     if(longtemp % SiS_Pr->SiS_HDE) tempax++;     tempbx |= ((tempax >> 8) & 0x1F);     tempcx = tempax >> 13;  }  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax);  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,tempbx);  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {     tempcx &= 0x07;     if(tempbx & 0x20) tempcx = 0;     SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xF8,tempcx);     if(SiS_Pr->SiS_TVMode & TVSetPAL) {        tempbx = 0x0382;        tempcx = 0x007e;     } else {        tempbx = 0x0369;        tempcx = 0x0061;     }     SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4B,tempbx);     SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4C,tempcx);     temp = (tempcx & 0x0300) >> 6;     temp |= ((tempbx >> 8) & 0x03);     if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {        temp |= 0x10;	if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p)      temp |= 0x20;	else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) temp |= 0x40;     }     SiS_SetReg(SiS_Pr->SiS_Part2Port,0x4D,temp);     temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43);     SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,(temp - 3));     SiS_SetTVSpecial(SiS_Pr, ModeNo);     if(SiS_Pr->SiS_VBType & VB_SIS301C) {        temp = 0;        if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8;        SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xf7,temp);     }  }  if(SiS_Pr->SiS_TVMode & TVSetPALM) {     if(!(SiS_Pr->SiS_TVMode & TVSetNTSC1024)) {        temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x01);        SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,(temp - 1));     }     SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF);  }  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {     if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {        SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,0x00);     }  }  if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) return;  /* From here: Part2 LCD setup */  tempbx = SiS_Pr->SiS_HDE;  if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1;  tempbx--;			         	/* RHACTE = HDE - 1 */  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,tempbx);  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,((tempbx >> 4) & 0xf0));  temp = 0x01;  if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {     if(SiS_Pr->SiS_ModeType == ModeEGA) {        if(SiS_Pr->SiS_VGAHDE >= 1024) {           temp = 0x02;	   if(HwInfo->jChipType >= SIS_315H) {              if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {                 temp = 0x01;	      }	   }        }     }  }  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x0B,temp);  tempbx = SiS_Pr->SiS_VDE - 1;  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x03,tempbx);  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,((tempbx >> 8) & 0x07));  tempcx = SiS_Pr->SiS_VT - 1;  SiS_SetReg(SiS_Pr->SiS_Part2Port,0x19,tempcx);  temp = (tempcx >> 3) & 0xE0;  if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {     /* Enable dithering; only do this for 32bpp mode */     if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {        temp |= 0x10;     }  }  SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1A,0x0f,temp);  SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x09,0xF0);  SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x0A,0xF0);  SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB);  SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF);#ifdef SIS315H  if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,                          			&CRT2Index, &resindex, HwInfo)) {      switch(CRT2Index) {        case 200: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1;   break;	case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3;    break;	default:  CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3;   break;      }      SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]);      SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]);      for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) {        SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);      }      for(j = 0x1c; j <= 0x1d; i++, j++ ) {        SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);      }      for(j = 0x1f; j <= 0x21; i++, j++ ) {        SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);      }      SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]);      SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]);      SiS_SetGroup2_Tail(SiS_Pr, ModeNo);  } else {#endif    /* Checked for 1024x768, 1280x1024, 1400x1050, 1600x1200 */    /*             Clevo dual-link 1024x768 */    /* 		   Compaq 1280x1024 has HT 1696 sometimes (calculation OK, if given HT is correct)  */    /*		   Acer: OK, but uses different setting for VESA timing at 640/800/1024 and 640x400 */    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {       if((SiS_Pr->SiS_LCDInfo & LCDPass11) || (SiS_Pr->PanelYRes == SiS_Pr->SiS_VDE)) {          tempbx = SiS_Pr->SiS_VDE - 1;          tempcx = SiS_Pr->SiS_VT - 1;       } else {          tempbx = SiS_Pr->SiS_VDE + ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VDE) / 2);	  tempcx = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VDE) / 2);       }    } else {       tempbx = SiS_Pr->PanelYRes;       tempcx = SiS_Pr->SiS_VT;       tempax = 1;       if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) {          tempax = SiS_Pr->PanelYRes;	  /* if(SiS_Pr->SiS_VGAVDE == 525) tempax += 0x3c;   */  /* 651+301C */          if(SiS_Pr->PanelYRes < SiS_Pr->SiS_VDE) {             tempax = tempcx = 0;          } else {             tempax -= SiS_Pr->SiS_VDE;          }          tempax >>= 1;       }       tempcx -= tempax; /* lcdvdes */       tempbx -= tempax; /* lcdvdee */    }    /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */#ifdef TWDEBUG    xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx);#endif    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx);	/* lcdvdes  */    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx);	/* lcdvdee  */    temp = (tempbx >> 5) & 0x38;    temp |= ((tempcx >> 8) & 0x07);    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp);    tempax = SiS_Pr->SiS_VDE;    if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {       tempax = SiS_Pr->PanelYRes;    }    tempcx = (SiS_Pr->SiS_VT - tempax) >> 4;    if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {       if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) {	  tempcx = (SiS_Pr->SiS_VT - tempax) / 10;       }    }    tempbx = ((SiS_Pr->SiS_VT + SiS_Pr->SiS_VDE) >> 1) - 1;    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {       if(SiS_Pr->PanelYRes != SiS_Pr->SiS_VDE) {          if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { /* ? */             tempax = SiS_Pr->SiS_VT - SiS_Pr->PanelYRes;	     if(tempax % 4) { tempax >>= 2; tempax++; }	     else           { tempax >>= 2;           }             tempbx -= (tempax - 1);	  } else {	     tempbx -= 10;	     if(tempbx <= SiS_Pr->SiS_VDE) tempbx = SiS_Pr->SiS_VDE + 1;	  }       }    }    if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {       tempbx++;       if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (crt2crtc == 6)) {          if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {	     tempbx = 770;	     tempcx = 3;	  }       }    }    /* non-expanding: lcdvrs = ((VT + VDE) / 2) - 10 */    if(SiS_Pr->UseCustomMode) {       tempbx = SiS_Pr->CVSyncStart;    }#ifdef TWDEBUG    xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx);#endif    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx);	    /* lcdvrs */    temp = (tempbx >> 4) & 0xF0;    tempbx += (tempcx + 1);    temp |= (tempbx & 0x0F);    if(SiS_Pr->UseCustomMode) {       temp &= 0xf0;       temp |= (SiS_Pr->CVSyncEnd & 0x0f);    }#ifdef TWDEBUG    xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f));#endif    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp);#ifdef SIS300    SiS_Group2LCDSpecial(SiS_Pr, HwInfo, ModeNo, crt2crtc);#endif    bridgeoffset = 7;    if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)          bridgeoffset += 2;    if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) bridgeoffset++;    if(SiS_IsDualLink(SiS_Pr, HwInfo))        		 bridgeoffset++;    temp = 0;    if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {       if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) {          temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2);	  if(SiS_IsDualLink(SiS_Pr, HwInfo)) temp >>= 1;       }    }    temp += bridgeoffset;    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1F,temp);  	     /* lcdhdes */    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0F,((temp >> 4) & 0xf0));    tempcx = SiS_Pr->SiS_HT;    tempax = tempbx = SiS_Pr->SiS_HDE;    if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {       if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) {          tempax = SiS_Pr->PanelXRes;          tempbx = SiS_Pr->PanelXRes - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2);       }    }    if(SiS_IsDualLink(SiS_Pr, HwInfo)) {       tempcx >>= 1;       tempbx >>= 1;       tempax >>= 1;    }#ifdef TWDEBUG    xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx);#endif    tempbx += bridgeoffset;    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,tempbx);	    /* lcdhdee */    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,((tempbx >> 8) & 0x0f));    tempcx = (tempcx - tempax) >> 2;    tempbx += tempcx;    push2 = tempbx;    if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {       if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {          if(SiS_Pr->SiS_LCDInfo & LCDPass11) {             if(SiS_Pr->SiS_HDE == 1280) tempbx = (tempbx & 0xff00) | 0x47;	  }       }    }    if(SiS_Pr->UseCustomMode) {       tempbx = SiS_Pr->CHSyncStart;       if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1;       tempbx += bridgeoffset;    }#ifdef TWDEBUG    xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx);#endif    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx);	    /* lcdhrs */    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0));    tempbx = push2;    tempcx <<= 1;    if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {       if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) tempcx >>= 2;    }    tempbx += tempcx;    if(SiS_Pr->UseCustomMode) {       tempbx = SiS_Pr->CHSyncEnd;       if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1;       tempbx += bridgeoffset;    }#ifdef TWDEBUG    xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx);#endif    SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx);	    /* lcdhre */    SiS_SetGroup2_Tail(SiS_Pr, ModeNo);#ifdef SIS300    SiS_Set300Part2Regs(SiS_Pr, HwInfo, ModeIdIndex, RefreshRateTableIndex, ModeNo);#endif#ifdef SIS315H  } /* CRT2-LCD from table */#endif}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/544393fe584d333480659a4bed30f5295355df11/init301.c/clean/drivers/video/sis/init301.c