if(HwInfo->jChipType >= SIS_315H) {  #ifdef SIS315H unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); 
if(SiS_Pr->ChipType >= SIS_315H) {  #ifdef SIS315H /* unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); */ 
SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,                    PSIS_HW_INFO HwInfo){  USHORT i,j,modeflag;  USHORT tempcl,tempah=0;#if defined(SIS300) || defined(SIS315H)  USHORT tempbl;#endif#ifdef SIS315H  UCHAR  *ROMAddr = HwInfo->pjVirtualRomBase;  USHORT tempah2, tempbl2;#endif  if(ModeNo <= 0x13) {     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;  } else if(SiS_Pr->UseCustomMode) {     modeflag = SiS_Pr->CModeFlag;  } else {     modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;  }  if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40);     SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7);  } else {     for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0);     if(HwInfo->jChipType >= SIS_315H) {        SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0x7F);     }     tempcl = SiS_Pr->SiS_ModeType;     if(HwInfo->jChipType < SIS_315H) {#ifdef SIS300    /* ---- 300 series ---- */        /* For 301BDH: (with LCD via LVDS) */        if(SiS_Pr->SiS_VBType & VB_NoLCD) {	   tempbl = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32);	   tempbl &= 0xef;	   tempbl |= 0x02;	   if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {	      tempbl |= 0x10;	      tempbl &= 0xfd;	   }	   SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,tempbl);        }        if(ModeNo > 0x13) {           tempcl -= ModeVGA;           if((tempcl > 0) || (tempcl == 0)) {      /* tempcl is USHORT -> always true! */              tempah = ((0x10 >> tempcl) | 0x80);           }        } else tempah = 0x80;        if(SiS_Pr->SiS_VBInfo & SetInSlaveMode)  tempah ^= 0xA0;#endif  /* SIS300 */     } else {#ifdef SIS315H    /* ------- 315/330 series ------ */        if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {           if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {	      SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08);           }        }        if(ModeNo > 0x13) {           tempcl -= ModeVGA;           if((tempcl > 0) || (tempcl == 0)) {  /* tempcl is USHORT -> always true! */              tempah = (0x08 >> tempcl);              if (tempah == 0) tempah = 1;              tempah |= 0x40;           }        } else tempah = 0x40;        if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50;#endif  /* SIS315H */     }     if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0;     if(HwInfo->jChipType < SIS_315H) {        SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah);     } else {        if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah);        } else if(SiS_Pr->SiS_VBType & VB_SISVB) {           if(IS_SIS740) {	      SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah);	   } else {              SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah);	   }        }     }     if(SiS_Pr->SiS_VBType & VB_SISVB) {        tempah = 0x01;        if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {      	   tempah |= 0x02;        }        if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {      	   tempah ^= 0x05;      	   if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {              tempah ^= 0x01;      	   }        }        if(SiS_Pr->SiS_VBInfo & DisableCRT2Display)  tempah = 0;        if(HwInfo->jChipType < SIS_315H) {      	   tempah = (tempah << 5) & 0xFF;      	   SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah);      	   tempah = (tempah >> 5) & 0xFF;        } else {      	   SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah);        }        if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) {      	   tempah |= 0x10;        }	tempah |= 0x80;        if(SiS_Pr->SiS_VBType & VB_SIS301) {	   if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah &= ~0x80;        }        if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {	   if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) {      	      if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {                 tempah |= 0x20;	      }      	   }        }        SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah);	tempah = 0x80;	if(SiS_Pr->SiS_VBType & VB_SIS301) {	   if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah = 0;	}	if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempah |= 0x40;        if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {	   if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) {              tempah |= 0x40;       	   }        }        SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah);     } else {  /* LVDS */        if(HwInfo->jChipType >= SIS_315H) {#ifdef SIS315H	   /* LVDS can only be slave in 8bpp modes */	   tempah = 0x80;	   if((modeflag & CRT2Mode) && (SiS_Pr->SiS_ModeType > ModeVGA)) {	      if(SiS_Pr->SiS_VBInfo & DriverMode) {	         tempah |= 0x02;	      }	   }	   if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {              tempah |= 0x02;    	   }	   if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {	      tempah ^= 0x01;	   }	   if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {	      tempah = 1;	   }    	   SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah);#endif        } else {#ifdef SIS300	   tempah = 0;	   if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) {              tempah |= 0x02;    	   }	   tempah <<= 5;	   if(SiS_Pr->SiS_VBInfo & DisableCRT2Display)  tempah = 0;	   SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah);#endif        }     }  }  /* LCDA */  if(SiS_Pr->SiS_VBType & VB_SISVB) {     if(HwInfo->jChipType >= SIS_315H) {#ifdef SIS315H        unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01);	/* The following is nearly unpreditable and varies from machine	 * to machine. Especially the 301DH seems to be a real trouble	 * maker. Some BIOSes simply set the registers (like in the	 * NoLCD-if-statements here), some set them according to the	 * LCDA stuff. It is very likely that some machines are not	 * treated correctly in the following, very case-orientated	 * code. What do I do then...?	 */	/* 740 variants match for 30xB, 301B-DH, 30xLV */        if(!(IS_SIS740)) {           tempah = 0x04;						   /* For all bridges */           tempbl = 0xfb;           if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {              tempah = 0x00;	      if(SiS_IsDualEdge(SiS_Pr, HwInfo)) {	         tempbl = 0xff;	      }           }           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);	}	/* The following two are responsible for eventually wrong colors	 * in TV output. The DH (VB_NoLCD) conditions are unknown; the	 * b0 was found in some 651 machine (Pim; P4_23=0xe5); the b1 version	 * in a 650 box (Jake). What is the criteria?	 */	if((IS_SIS740) || (HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) {	   tempah = 0x30;	   tempbl = 0xc0;	   if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) ||	      ((SiS_Pr->SiS_ROMNew) && (!(ROMAddr[0x5b] & 0x04)))) {	      tempah = 0x00;	      tempbl = 0x00;	   }	   SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,tempah);	   SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl);	} else if(SiS_Pr->SiS_VBType & VB_SIS301) {	   /* Fixes "TV-blue-bug" on 315+301 */	   SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf);     /* For 301   */	   SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f);	} else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {	   SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30);      /* For 30xLV */	   SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0);	} else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) {	   SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30);      /* For 30xB-DH rev b0 (or "DH on 651"?) */	   SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0);	} else {	   tempah = 0x30; tempah2 = 0xc0;		       /* For 30xB (and 301BDH rev b1) */	   tempbl = 0xcf; tempbl2 = 0x3f;	   if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {	      tempah = tempah2 = 0x00;	      if(SiS_IsDualEdge(SiS_Pr, HwInfo)) {		 tempbl = tempbl2 = 0xff;	      }	   }	   SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah);	   SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2);	}	if(IS_SIS740) {	   tempah = 0x80;	   if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0x00;	   SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,0x7f,tempah);	} else {	   tempah = 0x00;           tempbl = 0x7f;           if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {              tempbl = 0xff;	      if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) tempah = 0x80;           }           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah);	}#endif /* SIS315H */     } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {#ifdef SIS300        SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f);        if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) ||           ((SiS_Pr->SiS_VBType & VB_NoLCD) &&	    (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) {	   SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F);	} else {	   SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x23,0x80);	}#endif     }     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {        SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80);        if(SiS_Pr->SiS_VBType & VB_SIS301C) {	   SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3A,0xC0);        }     }  } else {  /* LVDS */#ifdef SIS315H     if(HwInfo->jChipType >= SIS_315H) {        if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {           tempah = 0x04;	   tempbl = 0xfb;           if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {              tempah = 0x00;	      if(SiS_IsDualEdge(SiS_Pr, HwInfo)) tempbl = 0xff;           }	   SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);	   if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {	      SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);	   }	   SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30);	} else if(HwInfo->jChipType == SIS_550) {	   SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);	   SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30);	}     }#endif  }}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/544393fe584d333480659a4bed30f5295355df11/init301.c/clean/drivers/video/sis/init301.c