sis_301.c

来自「讲述linux的初始化过程」· C语言 代码 · 共 2,841 行 · 第 1/5 页

C
2,841
字号
	}	SetReg1(Part2Port,0x44,tempah);	tempah=tempbh;	SetRegANDOR(Part2Port,0x45,~0x03F,tempah);		if(VBInfo&SetCRT2ToTV){		return;	}	tempah=0x01;	if(LCDResInfo==Panel1280x1024){		if(ModeType==ModeEGA){					if(VGAHDE>=1024){				tempah=0x02; 			}	 	}	} 	SetReg1(Part2Port,0x0B,tempah);		tempbx=HDE-1;			//RHACTE=HDE-1	tempah=tempbx&0xFF;	SetReg1(Part2Port,0x2C,tempah);	tempah=(tempbx&0xFF00)>>8;	tempah=(tempah<<4)&0xFF;	SetRegANDOR(Part2Port,0x2B,~0x0F0,tempah);		tempbx=VDE-1;			//RTVACTEO=(VDE-1)&0xFF	tempah=tempbx&0xFF;	SetReg1(Part2Port,0x03,tempah);	tempah=((tempbx&0xFF00)>>8)&0x07;	SetRegANDOR(Part2Port,0x0C,~0x07,tempah);	tempcx=VT-1;	tempah=tempcx&0xFF;	//RVTVT=VT-1	SetReg1(Part2Port,0x19,tempah);	tempah=(tempcx&0xFF00)>>8;	tempah=(tempah<<5)&0xFF;	if(LCDInfo&LCDRGB18Bit){		tempah=tempah|0x10;	}	SetReg1(Part2Port,0x1A,tempah);		tempcx++;	if(LCDResInfo==Panel1024x768){		tempbx=768;	}else{		tempbx=1024;	}		if(tempbx==VDE){		tempax=1;	}else{		tempax=tempbx;		tempax=(tempax-VDE)>>1;	}	tempcx=tempcx-tempax; //lcdvdes	tempbx=tempbx-tempax; //lcdvdee	tempah=tempcx&0xFF;	//RVEQ1EQ=lcdvdes	SetReg1(Part2Port,0x05,tempah);	tempah=tempbx&0xFF;	//RVEQ2EQ=lcdvdee	SetReg1(Part2Port,0x06,tempah);	tempah=(tempbx&0xFF00)>>8;	tempah=(tempah<<3)&0xFF;	tempah=tempah|((tempcx&0xFF00)>>8); 			//RTVACTSE=(lcdvdes&0x700>>8)+(lcdvdee&0x700>>5);	SetReg1(Part2Port,0x02,tempah);	 	tempcx=(VT-VDE)>>4;	//(VT-VDE)>>4	tempbx=(VT+VDE)>>1;	tempah=tempbx&0xFF;	//RTVACTEE=lcdvrs	SetReg1(Part2Port,0x04,tempah);	tempah=(tempbx&0xFF00)>>8;	tempah=(tempah<<4)&0xFF;	tempbx=tempbx+tempcx+1;	tempbl=(tempbx&0x0F);	tempah=tempah|tempbl;	//RTVACTSO=lcdvrs&0x700>>4+lcdvre	SetReg1(Part2Port,0x01,tempah);	tempah=GetReg1(Part2Port,0x09);	tempah=tempah&0xF0;	SetReg1(Part2Port,0x09,tempah);	tempah=GetReg1(Part2Port,0x0A);	tempah=tempah&0xF0;	SetReg1(Part2Port,0x0A,tempah);	tempcx=(HT-HDE)>>2;	 //(HT-HDE)>>2	tempbx=(HDE+7);			//lcdhdee	tempah=tempbx&0xFF;	 //RHEQPLE=lcdhdee	SetReg1(Part2Port,0x23,tempah);	tempah=(tempbx&0xFF00)>>8;	SetRegANDOR(Part2Port,0x25,~0x0F,tempah);	SetReg1(Part2Port,0x1F,0x07);	//RHBLKE=lcdhdes	tempah=GetReg1(Part2Port,0x20);	tempah=tempah&0x0F;	SetReg1(Part2Port,0x20,tempah);	tempbx=tempbx+tempcx;	tempah=tempbx&0xFF;				//RHBURSTS=lcdhrs	SetReg1(Part2Port,0x1C,tempah);	tempah=(tempbx&0xFF00)>>8;	tempah=(tempah<<4)&0xFF; 	SetRegANDOR(Part2Port,0x1D,~0x0F0,tempah);	tempbx=tempbx+tempcx;	tempah=tempbx&0xFF;				//RHSYEXP2S=lcdhre	SetReg1(Part2Port,0x21,tempah);	tempah=GetReg1(Part2Port,0x17);	tempah=tempah&0xFB;	SetReg1(Part2Port,0x17,tempah);	tempah=GetReg1(Part2Port,0x18);	tempah=tempah&0xDF;	SetReg1(Part2Port,0x18,tempah);	return;}VOID SetGroup3(USHORT	BaseAddr){	USHORT i;	USHORT *tempdi;	USHORT	Part3Port;	Part3Port=BaseAddr+IND_SIS_CRT2_PORT_12;	if(VBInfo&SetPALTV){		tempdi=PALGroup3Data;						}else{		tempdi=NTSCGroup3Data;	}	for(i=0;i<=0x3E;i++){		SetReg1(Part3Port,i,tempdi[i]);	}	return;}VOID SetGroup4(USHORT	BaseAddr,ULONG ROMAddr,USHORT ModeNo){	USHORT	Part4Port;	USHORT tempax,tempah,tempcx,tempbx,tempbh,tempch,tempmodeflag;	long int tempebx,tempeax,templong;		Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14;	tempax=0x0c;	if(VBInfo&SetCRT2ToTV){		if(VBInfo&SetInSlaveMode){			if(!(SetFlag&TVSimuMode)){				SetFlag=SetFlag|RPLLDIV2XO;				tempax=tempax|0x04000;				}		}else{			SetFlag=SetFlag|RPLLDIV2XO;			tempax=tempax|0x04000;	 		}	}	if(LCDResInfo!=Panel1024x768){		tempax=tempax|0x08000;	}	tempah=(tempax&0xFF00)>>8;	SetReg1(Part4Port,0x0C,tempah);		tempah=RVBHCFACT;	SetReg1(Part4Port,0x13,tempah);		tempbx=RVBHCMAX;	tempah=tempbx&0xFF;	SetReg1(Part4Port,0x14,tempah);	tempbh=(((tempbx&0xFF00)>>8)<<7)&0xFF;	tempcx=VGAHT-1;	tempah=tempcx&0xFF;	SetReg1(Part4Port,0x16,tempah);	tempch=(((tempcx&0xFF00)>>8)<<3)&0xFF;	tempbh=tempbh|tempch;		tempcx=VGAVT-1;	if(!(VBInfo&SetCRT2ToTV)){		tempcx=tempcx-5;	}	tempah=tempcx&0xFF;	SetReg1(Part4Port,0x17,tempah);	tempbh=tempbh|((tempcx&0xFF00)>>8);	tempah=tempbh;	SetReg1(Part4Port,0x15,tempah);		tempcx=VBInfo;	tempbx=VGAHDE;	tempmodeflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01));		// si+St_ModeFlag	if(tempmodeflag&HalfDCLK){		tempbx=tempbx>>1;					} 	if(VBInfo&SetCRT2ToLCD){		tempah=0;		if(tempbx>800){			tempah=0x60; 		}	}else{		tempah=0x080;	}	if(LCDResInfo!=Panel1280x1024){		tempah=tempah|0x0A;	}	SetRegANDOR(Part4Port,0x0E,~0xEF,tempah);	tempebx=VDE;		tempcx=RVBHRS;	tempah=tempcx&0xFF;	SetReg1(Part4Port,0x18,tempah);	tempeax=VGAVDE;	tempcx=tempcx|0x04000;	tempeax=tempeax-tempebx;	if(tempeax<0){		tempcx=tempcx^(0x04000);		tempeax=VGAVDE;	}	templong=(tempeax*256*1024)/tempebx;	if(tempeax*256*1024-templong*tempebx>0){		tempebx=templong+1;	}else{		tempebx=templong;	} 		tempah=(USHORT)(tempebx&0xFF);	SetReg1(Part4Port,0x1B,tempah);	tempah=(USHORT)((tempebx&0xFF00)>>8);	SetReg1(Part4Port,0x1A,tempah);	tempebx=tempebx>>16;	tempah=(USHORT)(tempebx&0xFF);	tempah=(tempah<<4)&0xFF;	tempah=tempah|((tempcx&0xFF00)>>8);	SetReg1(Part4Port,0x19,tempah);		SetCRT2VCLK(BaseAddr,ROMAddr,ModeNo);}VOID SetCRT2VCLK(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo){	USHORT vclk2ptr;	USHORT tempah,temp1;	USHORT	Part4Port;	Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14;	vclk2ptr=GetVCLK2Ptr(ROMAddr,ModeNo);	SetReg1(Part4Port,0x0A,0x01);	tempah=*((UCHAR *)(ROMAddr+vclk2ptr+0x01));	//di+1	SetReg1(Part4Port,0x0B,tempah);	tempah=*((UCHAR *)(ROMAddr+vclk2ptr+0x00));	//di	SetReg1(Part4Port,0x0A,tempah);	SetReg1(Part4Port,0x12,0x00);	tempah=0x08;	if(VBInfo&SetCRT2ToRAMDAC){		tempah=tempah|0x020;	}	temp1=GetReg1(Part4Port,0x12);	tempah=tempah|temp1;	SetReg1(Part4Port,0x12,tempah);}VOID SetGroup5(USHORT	BaseAddr,ULONG ROMAddr){	USHORT	Part5Port;	USHORT Pindex,Pdata;	Part5Port=BaseAddr+IND_SIS_CRT2_PORT_14+2;	Pindex=Part5Port;	Pdata=Part5Port+1;	if(ModeType==ModeVGA){		if(!(VBInfo&(SetInSlaveMode|LoadDACFlag|CRT2DisplayFlag))){			EnableCRT2();			LoadDAC2(ROMAddr,Part5Port);		}	}	return;}VOID EnableCRT2(){	USHORT temp1;	temp1=GetReg1(P3c4,0x1E);	temp1=temp1|0x20;	SetReg1(P3c4,0x1E,temp1);		//SR 1E}VOID LoadDAC2(ULONG ROMAddr,USHORT Part5Port){	USHORT data,data2;	USHORT time,i,j,k;	USHORT m,n,o;	USHORT si,di,bx,dl;	USHORT al,ah,dh;	USHORT *table=VGA_DAC;	USHORT Pindex,Pdata;	Pindex=Part5Port;	Pdata=Part5Port+1;	data=*((USHORT *)(ROMAddr+ModeIDOffset+0x01));	data=data&DACInfoFlag;	time=64;	if(data==0x00) table=MDA_DAC;	if(data==0x08) table=CGA_DAC;	if(data==0x10) table=EGA_DAC;	if(data==0x18) {		time=256;		table=VGA_DAC;	}	if(time==256) j=16;	else j=time;	//SetReg3(P3c6,0xFF);	SetReg3(Pindex,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=data2+0x15;			SetReg3(Pdata,data2);			data=data>>2;		}	}	if(time==256) {		for(i=16;i<32;i++) {			data=table[i];			for(k=0;k<3;k++) SetReg3(Pdata,data);		}		si=32;		for(m=0;m<9;m++) {			di=si;			bx=si+0x04;			dl=0;			for(n=0;n<3;n++) {				for(o=0;o<5;o++) {					dh=table[si];					ah=table[di];					al=table[bx];					si++;					WriteDAC2(Pdata,dl,ah,al,dh);				}			// for 5				si=si-2;				for(o=0;o<3;o++) {					dh=table[bx];					ah=table[di];					al=table[si];					si--;					WriteDAC2(Pdata,dl,ah,al,dh);				}			// for 3				dl++;			}				// for 3			si=si+5;		}					// for 9	}}VOID WriteDAC2(USHORT Pdata,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;		}	}	SetReg3(Pdata,(USHORT)dh);	SetReg3(Pdata,(USHORT)bh);	SetReg3(Pdata,(USHORT)bl);}VOID LockCRT2(USHORT BaseAddr){	USHORT	Part1Port;	USHORT	Part4Port;	USHORT temp1;	Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04;	Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14;	temp1=GetReg1(Part1Port,0x24);	temp1=temp1&0xFE;	SetReg1(Part1Port,0x24,temp1);}VOID SetLockRegs(){	USHORT temp1;	if((VBInfo&SetInSlaveMode)&&(!(VBInfo&SetCRT2ToRAMDAC))){		VBLongWait();		temp1=GetReg1(P3c4,0x32);		temp1=temp1|0x20;		SetReg1(P3c4,0x32,temp1);		VBLongWait();	}}VOID EnableBridge(USHORT BaseAddr){	USHORT part2_02,part2_05;	USHORT	Part2Port,Part1Port;	Part2Port=BaseAddr+IND_SIS_CRT2_PORT_10;	Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04;	if(IF_DEF_LVDS==0){		part2_02=(UCHAR)GetReg1(Part2Port,0x02);		part2_05=(UCHAR)GetReg1(Part2Port,0x05);		SetReg1(Part2Port,0x02,0x38);		SetReg1(Part2Port,0x05,0xFF);		LongWait();		SetRegANDOR(Part2Port,0x00,~0x0E0,0x020);		WaitVBRetrace(BaseAddr);		SetReg1(Part2Port,0x02,part2_02);		SetReg1(Part2Port,0x05,part2_05);	}else{		EnableCRT2();		UnLockCRT2(BaseAddr);		SetRegANDOR(Part1Port,0x02,~0x040,0x0);	}}USHORT GetLockInfo(USHORT pattern){	USHORT temp1;	temp1=GetReg1(P3d4,0x36);	return(temp1&pattern);}	VOID GetVBInfo(USHORT BaseAddr,ULONG ROMAddr){	USHORT flag1,tempbx,tempbl,tempbh,tempah;		SetFlag=0;	tempbx=*((USHORT *)(ROMAddr+ModeIDOffset+0x01));		// si+St_ModeFlag	tempbl=tempbx&ModeInfoFlag;	ModeType=tempbl;	tempbx=0;	flag1=GetReg1(P3c4,0x38);		//call BridgeisOn	if(!(flag1&0x20)){		VBInfo=CRT2DisplayFlag;		return;	}	tempbl=GetReg1(P3d4,0x30);		tempbh=GetReg1(P3d4,0x31);	if(!(tempbl&0x07C)){		VBInfo=CRT2DisplayFlag;		return;	}	if(IF_DEF_LVDS==1){	//for LVDS		if(!(tempbl&SetCRT2ToLCD)){			VBInfo=CRT2DisplayFlag;			return;		}	}	if(IF_DEF_LVDS==0){ //for 301		if(tempbl&SetCRT2ToRAMDAC){			tempbl=tempbl&(SetCRT2ToRAMDAC|SwitchToCRT2|SetSimuScanMode);		}else if(tempbl&SetCRT2ToLCD){			tempbl=tempbl&(SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode);		}else if(tempbl&SetCRT2ToSCART){			tempbl=tempbl&(SetCRT2ToSCART|SwitchToCRT2|SetSimuScanMode);		}else if(tempbl&SetCRT2ToHiVisionTV){			tempbl=tempbl&(SetCRT2ToHiVisionTV|SwitchToCRT2|SetSimuScanMode);		}	}else{ //for LVDS		if(tempbl&SetCRT2ToLCD){			tempbl=tempbl&(SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode);		}	}	tempah=GetReg1(P3d4,0x31);	if(tempah&(CRT2DisplayFlag>>8)){		if(!(tempbl&(SwitchToCRT2|SetSimuScanMode))){			tempbx=SetSimuScanMode|CRT2DisplayFlag;			tempbh=((tempbx&0xFF00)>>8);			tempbl=tempbx&0xFF;		}	}	if(!(tempbh&(DriverMode>>8))){		tempbl=tempbl|SetSimuScanMode;	}	VBInfo=tempbl|(tempbh<<8);	if(!(VBInfo&SetSimuScanMode)){		if(!(VBInfo&SwitchToCRT2)){			if(BridgeIsEnable(BaseAddr)){				if(BridgeInSlave()){					VBInfo=VBInfo|SetSimuScanMode;				}				}		}	}	if(!((VBInfo&(SetSimuScanMode|SwitchToCRT2)))){		return;	}	if(!(VBInfo&DriverMode)){		VBInfo=VBInfo|SetInSlaveMode;		if((VBInfo&SetCRT2ToTV)&&(!(VBInfo&SetNotSimuTVMode))){			SetFlag=SetFlag|TVSimuMode;		}	 	return;	}	flag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01));		// si+St_ModeFlag	if(!(flag1&(CRT2Mode|CRT2DisplayFlag))){		VBInfo=VBInfo|SetInSlaveMode;		if((VBInfo&SetCRT2ToTV)&&(!(VBInfo&SetNotSimuTVMode))){			SetFlag=SetFlag|TVSimuMode;		}	}}BOOLEAN BridgeIsEnable(USHORT BaseAddr){	USHORT flag1;	USHORT	Part1Port;	Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04;	if(IF_DEF_LVDS==1){		return 1;	}	flag1=GetReg1(P3c4,0x38);		//call BridgeisOn	if(!(flag1&0x20)){ return 0;}	flag1=GetReg1(Part1Port,0x0);	if(flag1&0x0a0){		return 1;	}else{		return 0;	}}BOOLEAN BridgeInSlave(){	USHORT flag1;	flag1=GetReg1(P3d4,0x31);	if(flag1&(SetInSlaveMode>>8)){		return 1;	}else{		return 0;	}}BOOLEAN GetLCDResInfo(ULONG ROMAddr,USHORT P3d4){	USHORT tempah,tempbh,tempflag;					tempah=(UCHAR)GetReg1(P3d4,0x36);	tempbh=tempah;	tempah=tempah&0x0F;	if(tempah>Panel1280x1024) tempah=Panel1024x768;	LCDResInfo=tempah;	tempbh=tempbh>>4;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?