if((HwInfo->jChipType >= SIS_661) && (ModeNo > 0x13)) { if(xres >= 1600) { 
if(SiS_Pr->ChipType >= SIS_315H) { if(xres >= 1600) {  /* BIOS: == 1600 */ 
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,xres=0;  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;     xres = SiS_Pr->CHDisplay;  } else {     modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;     resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;     xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes;  }  /* The following is only done if bridge is in slave mode: */  if((HwInfo->jChipType >= SIS_661) && (ModeNo > 0x13)) {     if(xres >= 1600) {        SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x31,0x04);     }  }  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;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {     temp = tempcx - 1;     if(!(modeflag & HalfDCLK)) {        temp -= 6;        if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {           temp -= 2;           if(ModeNo > 0x13) temp -= 10;        }     }  } else {     tempcx = (tempcx + tempbx) >> 1;     temp = (tempcx & 0x00FF) + 2;     if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {        temp--;        if(!(modeflag & HalfDCLK)) {           if((modeflag & Charx8Dot)) {              temp += 4;              if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6;              if(HwInfo->jChipType >= SIS_315H) {	         if(SiS_Pr->SiS_VGAHDE == 800) temp += 2;              }           }        }     } else {        if(!(modeflag & HalfDCLK)) {           temp -= 4;           if((SiS_Pr->SiS_LCDResInfo != Panel_1280x960) &&	      (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200)) {              if(SiS_Pr->SiS_VGAHDE >= 800) {                 temp -= 7;	         if(HwInfo->jChipType < SIS_315H) {                    if(SiS_Pr->SiS_ModeType == ModeEGA) {                       if(SiS_Pr->SiS_VGAVDE == 1024) {                          temp += 15;                          if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024)		  	     temp += 7;                       }                    }	         }		 if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) {                    if(SiS_Pr->SiS_VGAHDE >= 1280) {                       if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28;		    }                 }              }           }        }     }  }  p1_7 = temp;  p1_8 = 0x00;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {     if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {        if(ModeNo <= 0x01) {	   p1_7 = 0x2a;	   if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_8 = 0x61;	   else 	      			p1_8 = 0x41;	} else if(SiS_Pr->SiS_ModeType == ModeText) {	   if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_7 = 0x54;	   else 	    			p1_7 = 0x55;	   p1_8 = 0x00;	} else if(ModeNo <= 0x13) {	   if(modeflag & HalfDCLK) {	      if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {		 p1_7 = 0x30;		 p1_8 = 0x03;	      } else {	 	 p1_7 = 0x2f;		 p1_8 = 0x02;	      }	   } else {	      p1_7 = 0x5b;	      p1_8 = 0x03;	   }	} else if( ((HwInfo->jChipType >= SIS_315H) &&	            ((ModeNo == 0x50) || (ModeNo == 0x56) || (ModeNo == 0x53))) ||	           ((HwInfo->jChipType < SIS_315H) &&		    (resinfo == SIS_RI_320x200 || resinfo == SIS_RI_320x240)) ) {	   if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {	      p1_7 = 0x30,	      p1_8 = 0x03;	   } else {	      p1_7 = 0x2f;	      p1_8 = 0x03;	   }        }     }  }  if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {     if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p)) {        p1_7 = 0x63;	if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) p1_7 = 0x55;     }     if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {        if(!(modeflag & HalfDCLK)) {	   p1_7 = 0xb2;	   if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {	      p1_7 = 0xab;	   }	}     } else {        if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {	   if(modeflag & HalfDCLK) p1_7 = 0x30;	}     }  }  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,p1_7);			/* 0x07 Horizontal Retrace Start */  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,p1_8);			/* 0x08 Horizontal Retrace End   */  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x03);                	/* 0x18 SR08 (FIFO Threshold?)   */  SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0);  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,0xFF);                	/* 0x09 Set Max VT    */  tempcx = 0x121;  tempbx = SiS_Pr->SiS_VGAVDE;                               	/* 0x0E Vertical Display End */  if     (tempbx == 357) tempbx = 350;  else if(tempbx == 360) tempbx = 350;  else if(tempbx == 375) tempbx = 350;  else if(tempbx == 405) tempbx = 400;  else if(tempbx == 420) tempbx = 400;  else if(tempbx == 525) tempbx = 480;  push2 = tempbx;  if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {     if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {      	if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {           if     (tempbx == 350) tempbx += 5;           else if(tempbx == 480) tempbx += 5;      	}     }  }  tempbx -= 2;  temp = tempbx & 0x00FF;  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp);        		/* 0x10 vertical Blank Start */  tempbx = push2;  tempbx--;  temp = tempbx & 0x00FF;#if 0  /* Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */  if(xxx()) {      if(temp == 0xdf) temp = 0xda;  }#endif  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp);  temp = 0;  if(modeflag & DoubleScanMode) temp |= 0x80;  if(HwInfo->jChipType >= SIS_661) {     if(tempbx & 0x0200)        temp |= 0x20;     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x0B,0x5F,temp);     if(tempbx & 0x0100)  tempcx |= 0x000a;     if(tempbx & 0x0400)  tempcx |= 0x1200;  } else {     SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp);     if(tempbx & 0x0100)  tempcx |= 0x0002;     if(tempbx & 0x0400)  tempcx |= 0x0600;  }  if(tempbx & 0x0200)  tempcx |= 0x0040;  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,0x00);                	/* 0x11 Vertical Blank End */  tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2;  if((ModeNo > 0x13) || (HwInfo->jChipType < SIS_315H)) {     if(resinfo != SIS_RI_1280x1024) {	tempbx += (tempax << 1);     }  } else if(HwInfo->jChipType >= SIS_315H) {     if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) {	tempbx += (tempax << 1);     }  }  if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {     tempbx -= 10;  } else {     if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {        if(SiS_Pr->SiS_TVMode & TVSetPAL) {           tempbx += 40;	   if(HwInfo->jChipType >= SIS_315H) {	      if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10;	   }	}     }  }  tempax >>= 2;  tempax++;  tempax += tempbx;  push1 = tempax;  if(SiS_Pr->SiS_TVMode & TVSetPAL) {     if(tempbx <= 513)  {     	if(tempax >= 513) tempbx = 513;     }  }  temp = tempbx & 0x00FF;  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp);			/* 0x0C Vertical Retrace Start */  tempbx--;  temp = tempbx & 0x00FF;  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp);  if(tempbx & 0x0100) tempcx |= 0x0008;  if(tempbx & 0x0200) {     SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20);  }  tempbx++;  if(tempbx & 0x0100) tempcx |= 0x0004;  if(tempbx & 0x0200) tempcx |= 0x0080;  if(tempbx & 0x0400) {     if(HwInfo->jChipType >= SIS_661)        tempcx |= 0x0800;     else if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800;     else                                    tempcx |= 0x0C00;  }  tempbx = push1;  temp = tempbx & 0x000F;  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp);        		/* 0x0D vertical Retrace End */  if(tempbx & 0x0010) tempcx |= 0x2000;  temp = tempcx & 0x00FF;  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp);              	/* 0x0A CR07 */  temp = (tempcx & 0xFF00) >> 8;  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp);              	/* 0x17 SR0A */  tempax = modeflag;  temp = (tempax & 0xFF00) >> 8;  temp = (temp >> 1) & 0x09;  if(!(SiS_Pr->SiS_VBType & VB_SIS301)) temp |= 0x01;		/* Always 8 dotclock */  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp);              	/* 0x16 SR01 */  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00);              	/* 0x0F CR14 */  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00);              	/* 0x12 CR17 */  temp = 0x00;  if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {     if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {	temp = 0x80;     }  }  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp);                	/* 0x1A SR0E */  temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02));  SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/544393fe584d333480659a4bed30f5295355df11/init301.c/clean/drivers/video/sis/init301.c