sis_301.c
来自「Linux内核源代码 为压缩文件 是<<Linux内核>>」· C语言 代码 · 共 2,841 行 · 第 1/5 页
C
2,841 行
/* Recently Update by v1.09.50 */#include <linux/config.h>#include "sis_301.h"#ifndef CONFIG_FB_SIS_LINUXBIOSBOOLEAN SetCRT2Group(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo, PHW_DEVICE_EXTENSION HwDeviceExtension){ USHORT temp; SetFlag=SetFlag|ProgrammingCRT2; SearchModeID(ROMAddr,ModeNo); temp=GetRatePtrCRT2(ROMAddr,ModeNo); if(((temp&0x02)==0) && ((VBInfo&CRT2DisplayFlag)==0)) return(FALSE); SaveCRT2Info(ModeNo); DisableBridge(BaseAddr); UnLockCRT2(BaseAddr); SetDefCRT2ExtRegs(BaseAddr); SetCRT2ModeRegs(BaseAddr,ModeNo); if(VBInfo&CRT2DisplayFlag){ LockCRT2(BaseAddr); return 0; } GetCRT2Data(ROMAddr,ModeNo); if(IF_DEF_LVDS==1){ //LVDS GetLVDSDesData(ROMAddr,ModeNo); } SetGroup1(BaseAddr,ROMAddr,ModeNo,HwDeviceExtension); if(IF_DEF_LVDS==0){ SetGroup2(BaseAddr,ROMAddr); SetGroup3(BaseAddr); SetGroup4(BaseAddr,ROMAddr,ModeNo); SetGroup5(BaseAddr,ROMAddr); }else{ //LVDS if(IF_DEF_TRUMPION==0){ ModCRT1CRTC(ROMAddr,ModeNo); } SetCRT2ECLK(ROMAddr,ModeNo); } EnableCRT2(); EnableBridge(BaseAddr); SetLockRegs(); LockCRT2(BaseAddr); return 1; }VOID overwriteregs(ULONG ROMAddr,USHORT BaseAddr){ int i; USHORT Part1Port; //reg data is for 1024x768 16bit 85hz int p1reg[0x29]={0x84,0x76,0x4B,0x21,0x00,0x00,0x00,0x00,0x1F,0x51, 0x0C,0x10,0x44,0x90,0x1E,0xFF,0x00,0x34,0x13,0x10, 0x00,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x97,0x16, 0xA3}; Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; for(i=0;i<29;i++){ SetReg1(Part1Port,(USHORT)i,(USHORT)p1reg[i]); }}VOID SetDefCRT2ExtRegs(USHORT BaseAddr){ USHORT Part1Port,Part2Port,Part4Port; USHORT temp; Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; Part2Port=BaseAddr+IND_SIS_CRT2_PORT_10; Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14; SetReg1(Part1Port,0x02,0x40); SetReg1(Part4Port,0x10,0x80); temp=(UCHAR)GetReg1(P3c4,0x16); temp=temp&0xC3; SetReg1(P3d4,0x35,temp);} USHORT GetRatePtrCRT2(ULONG ROMAddr, USHORT ModeNo){ //return bit0=>0:standard mode 1:extended mode SHORT index; // bit1=>0:crt2 no support this mode USHORT temp; // 1:crt2 support this mode USHORT ulRefIndexLength; USHORT temp1; SHORT LCDRefreshIndex[4]={0x0,0x0,0x03,0x01}; // LCDPanel:no lcd,800x600,1024x768,1280x1024 if(ModeNo<0x14) return(0); // Mode No <= 13h then return index=GetReg1(P3d4,0x33); // Get 3d4 CRTC33 index=index>>SelectCRT2Rate; //For CRT2,cl=SelectCRT2Rate=4, shr ah,cl index=index&0x0F; // Frame rate index if(index!=0) index--; if(IF_DEF_TRUMPION==1){ if(VBInfo&SetSimuScanMode){ index=0; } } if(SetFlag&ProgrammingCRT2){ if(VBInfo&SetCRT2ToLCD){ if(IF_DEF_LVDS==0){ temp=LCDResInfo; temp1=LCDRefreshIndex[temp]; if(index>temp1){ index=temp1; } }else{ index=0; } } } REFIndex=*((USHORT *)(ROMAddr+ModeIDOffset+0x04)); // si+Ext_point ulRefIndexLength =Ext2StructSize; do { temp=*((USHORT *)(ROMAddr+REFIndex)); // di => REFIndex if(temp==0xFFFF) break; temp=temp&ModeInfoFlag; if(temp<ModeType) break; REFIndex=REFIndex+ulRefIndexLength; // rate size index--; if(index<0){ if(!(VBInfo&SetCRT2ToRAMDAC)){ if(VBInfo&SetInSlaveMode){ temp1=*((USHORT *)(ROMAddr+REFIndex+0-Ext2StructSize)); if(temp1&InterlaceMode){ index=0; } } } } } while(index>=0); REFIndex=REFIndex-ulRefIndexLength; // rate size if((SetFlag&ProgrammingCRT2)){ temp1=AjustCRT2Rate(ROMAddr); }else{ temp1=0; } return(0x01|(temp1<<1));}BOOLEAN AjustCRT2Rate(ULONG ROMAddr){ USHORT tempbx=0,tempax,temp; USHORT tempextinfoflag; tempax=0; if(IF_DEF_LVDS==0){ if(VBInfo&SetCRT2ToRAMDAC){ tempax=tempax|SupportRAMDAC2; } if(VBInfo&SetCRT2ToLCD){ tempax=tempax|SupportLCD; if(LCDResInfo!=Panel1280x1024){ temp=*((UCHAR *)(ROMAddr+ModeIDOffset+0x09)); //si+Ext_ResInfo if(temp>=9){ tempax=0; } } } if(VBInfo&(SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)){ tempax=tempax|SupportTV; if(!(VBInfo&SetPALTV)){ tempextinfoflag=*((USHORT *)(ROMAddr+REFIndex+0x0)); //di+Ext_InfoFlag if(tempextinfoflag&NoSupportSimuTV){ if(VBInfo&SetInSlaveMode){ if(!(VBInfo&SetNotSimuTVMode)){ return 0; } } } } } tempbx=*((USHORT *)(ROMAddr+ModeIDOffset+0x04)); // si+Ext_point }else{ //for LVDS if(VBInfo&SetCRT2ToLCD){ tempax=tempax|SupportLCD; temp=*((UCHAR *)(ROMAddr+ModeIDOffset+0x09)); //si+Ext_ResInfo if(temp>0x08){ //1024x768 return 0; } if(LCDResInfo<Panel1024x768){ if(temp>0x07){ //800x600 return 0; } if(temp==0x04){ //512x384 return 0; } } } } for(;REFIndex>tempbx;REFIndex-=Ext2StructSize){ tempextinfoflag=*((USHORT *)(ROMAddr+REFIndex+0x0)); //di+Ext_InfoFlag if(tempextinfoflag&tempax){ return 1; } } for(REFIndex=tempbx;;REFIndex+=Ext2StructSize){ tempextinfoflag=*((USHORT *)(ROMAddr+REFIndex+0x0)); //di+Ext_InfoFlag if(tempextinfoflag==0x0FFFF){ return 0; } if(tempextinfoflag&tempax){ return 1; } } return(FALSE);}VOID SaveCRT2Info(USHORT ModeNo){ USHORT temp1,temp2,temp3; temp1=(VBInfo&SetInSlaveMode)>>8; temp2=~(SetInSlaveMode>>8); temp3=(UCHAR)GetReg1(P3d4,0x31); temp3=((temp3&temp2)|temp1); SetReg1(P3d4,0x31,(USHORT)temp3); temp3=(UCHAR)GetReg1(P3d4,0x35); temp3=temp3&0xF3; SetReg1(P3d4,0x35,(USHORT)temp3);}VOID DisableLockRegs(){ UCHAR temp3; temp3=(UCHAR)GetReg1(P3c4,0x32); temp3=temp3&0xDF; SetReg1(P3c4,0x32,(USHORT)temp3);}VOID DisableCRT2(){ UCHAR temp3; temp3=(UCHAR)GetReg1(P3c4,0x1E); temp3=temp3&0xDF; SetReg1(P3c4,0x1E,(USHORT)temp3);}void DisableBridge(USHORT BaseAddr){ USHORT Part2Port,Part1Port; Part2Port=BaseAddr+IND_SIS_CRT2_PORT_10; Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; if(IF_DEF_LVDS==0){ SetRegANDOR(Part2Port,0x00,0xDF,0x00); //Set Part2 Index0 D[5]=0 DisableLockRegs(); // SR 32 DisableCRT2(); // SR 1E }else{ DisableLockRegs(); DisableCRT2(); if(IF_DEF_TRUMPION==0){ UnLockCRT2(BaseAddr); SetRegANDOR(Part1Port,0x02,0xFF,0x40); //set Part1Port ,index 2, D6=1, } }}VOID GetCRT2Data(ULONG ROMAddr,USHORT ModeNo){ if(IF_DEF_LVDS==0){ //301 GetCRT2Data301(ROMAddr,ModeNo); return; }else{ //LVDS GetCRT2DataLVDS(ROMAddr,ModeNo); return; }}VOID GetCRT2DataLVDS(ULONG ROMAddr,USHORT ModeNo){ USHORT tempax,tempbx,OldREFIndex; OldREFIndex=(USHORT)REFIndex; //push di GetResInfo(ROMAddr,ModeNo); GetCRT2Ptr(ROMAddr,ModeNo); tempax=*((USHORT *)(ROMAddr+REFIndex)); tempax=tempax&0x0FFF; VGAHT=tempax; tempax=*((USHORT *)(ROMAddr+REFIndex+1)); tempax=tempax>>4; tempax=tempax&0x07FF; VGAVT=tempax; tempax=*((USHORT *)(ROMAddr+REFIndex+3)); tempax=tempax&0x0FFF; tempbx=*((USHORT *)(ROMAddr+REFIndex+4)); tempbx=tempbx>>4; tempbx=tempbx&0x07FF; HT=tempax; VT=tempbx; if(IF_DEF_TRUMPION==0){ if(VBInfo&SetCRT2ToLCD){ if(!(LCDInfo&LCDNonExpanding)){ if(LCDResInfo==Panel800x600){ tempax=800; tempbx=600; }else if(LCDResInfo==Panel1024x768){ tempax=1024; tempbx=768; }else{ tempax=1280; tempbx=1024; } HDE=tempax; VDE=tempbx; } } } REFIndex=OldREFIndex; //pop di return;}VOID GetCRT2Data301(ULONG ROMAddr,USHORT ModeNo){ USHORT tempax,tempbx,modeflag1,OldREFIndex; USHORT tempal,tempah,tempbl; OldREFIndex=(USHORT)REFIndex; //push di RVBHRS=50;NewFlickerMode=0;RY1COE=0; RY2COE=0;RY3COE=0;RY4COE=0; GetResInfo(ROMAddr,ModeNo); if(VBInfo&SetCRT2ToRAMDAC){ GetRAMDAC2DATA(ROMAddr,ModeNo); REFIndex=OldREFIndex; //pop di return; } GetCRT2Ptr(ROMAddr,ModeNo); tempal=*((UCHAR *)(ROMAddr+REFIndex)); tempah=*((UCHAR *)(ROMAddr+REFIndex+4)); tempax=tempal|(((tempah<<8)>>7)&0xFF00); RVBHCMAX=tempax; tempal=*((UCHAR *)(ROMAddr+REFIndex+1)); RVBHCFACT=tempal; tempax=*((USHORT *)(ROMAddr+REFIndex+2)); VGAHT=(tempax&0x0FFF); tempax=*((USHORT *)(ROMAddr+REFIndex+3)); VGAVT=((tempax>>4)&0x07FF); tempax=*((USHORT *)(ROMAddr+REFIndex+5)); tempax=(tempax&0x0FFF); tempbx=*((USHORT *)(ROMAddr+REFIndex+6)); tempbx=((tempbx>>4)&0x07FF); tempbl=tempbx&0x00FF; if(VBInfo&SetCRT2ToTV){ tempax=*((USHORT *)(ROMAddr+REFIndex+5)); tempax=(tempax&0x0FFF); HDE=tempax; tempax=*((USHORT *)(ROMAddr+REFIndex+6)); tempax=((tempax>>4)&0x07FF); VDE=tempax; //skipp something about hivisiontv tempax=*((USHORT *)(ROMAddr+REFIndex+8)); tempbl=(tempax>>8); tempax=tempax&0x0FFF; modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); // si+St_ModeFlag if(modeflag1&HalfDCLK){ tempax=*((USHORT *)(ROMAddr+REFIndex+10)); } RVBHRS=tempax; NewFlickerMode=(tempbl&0x080); tempax=*((USHORT *)(ROMAddr+REFIndex+12)); RY1COE=(tempax&0x00FF); RY2COE=((tempax&0xFF00)>>8); tempax=*((USHORT *)(ROMAddr+REFIndex+14)); RY3COE=(tempax&0x00FF); RY4COE=((tempax&0xFF00)>>8); if(!(VBInfo&SetPALTV)){ tempax=NTSCHT; tempbx=NTSCVT; }else{ tempax=PALHT; tempbx=PALVT; } } HT=tempax; VT=tempbx; if(!(VBInfo&SetCRT2ToLCD)){ REFIndex=OldREFIndex; //pop di return; } tempax=1024; if(VGAVDE==350){ //cx->VGAVDE tempbx=560; }else if(VGAVDE==400){ tempbx=640; }else{ tempbx=768; } if(LCDResInfo==Panel1280x1024){ tempax=1280; if(VGAVDE==360){ tempbx=768; }else if(VGAVDE==375){ tempbx=800; }else if(VGAVDE==405){ tempbx=864; }else{ tempbx=1024; } } HDE=tempax; VDE=tempbx; REFIndex=OldREFIndex; //pop di return; }VOID GetResInfo(ULONG ROMAddr,USHORT ModeNo){ USHORT temp,xres,yres,modeflag1; if(ModeNo<=0x13){ temp=(USHORT)*((UCHAR *)(ROMAddr+ModeIDOffset+0x05)); // si+St_ResInfo xres=StResInfo[temp][0]; yres=StResInfo[temp][1]; }else{ temp=(USHORT)*((UCHAR *)(ROMAddr+ModeIDOffset+0x09)); // si+Ext_ResInfo xres=ModeResInfo[temp][0]; //xres->ax yres=ModeResInfo[temp][1]; //yres->bx modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); // si+St_ModeFlag if(modeflag1&HalfDCLK){ xres=xres*2;} if(modeflag1&DoubleScanMode){yres=yres*2;} } if(!(LCDResInfo==Panel1024x768)){ if(yres==400) yres=405; if(yres==350) yres=360; if(SetFlag&LCDVESATiming){ if(yres==360) yres=375; } } VGAHDE=xres; HDE=xres; VGAVDE=yres; VDE=yres;}VOID GetLVDSDesData(ULONG ROMAddr,USHORT ModeNo){ USHORT old_REFIndex,tempax; old_REFIndex=(USHORT)REFIndex; //push di REFIndex=GetLVDSDesPtr(ROMAddr,ModeNo); tempax=*((USHORT *)(ROMAddr+REFIndex)); tempax=tempax&0x0FFF; LCDHDES=tempax; if(LCDInfo&LCDNonExpanding){ //hw walk-a-round if(LCDResInfo>=Panel1024x768){ if(ModeNo<=0x13){ LCDHDES=320; } } } tempax=*((USHORT *)(ROMAddr+REFIndex+1)); tempax=tempax>>4; tempax=tempax&0x07FF; LCDVDES=tempax; REFIndex=old_REFIndex; //pop di return; }VOID GetRAMDAC2DATA(ULONG ROMAddr,USHORT ModeNo){ USHORT tempax,tempbx,tempbh,modeflag1,t1=0,t2; RVBHCMAX=1;RVBHCFACT=1; if(ModeNo<=0x13){ tempax=*((UCHAR *)(ROMAddr+REFIndex+10)); tempbx=*((USHORT *)(ROMAddr+REFIndex+16)); }else{ t1=*((UCHAR *)(ROMAddr+REFIndex+0x2)); //Ext_CRT1CRTC=2 t1=t1&0x03F; //[06/29/2000] fix bug for vbios >=v1.07.00 t1=t1*CRT1Len; REFIndex=*((USHORT *)(ROMAddr+0x204)); // Get CRT1Table REFIndex=REFIndex+t1; t1=*((UCHAR *)(ROMAddr+REFIndex+0)); t2=*((UCHAR *)(ROMAddr+REFIndex+14)); tempax=(t1&0xFF)|((t2&0x03)<<8); tempbx=*((USHORT *)(ROMAddr+REFIndex+6)); t1=*((UCHAR *)(ROMAddr+REFIndex+13)); t1=(t1&0x01)<<2; } tempbh=tempbx>>8; tempbh=((tempbh&0x20)>>4)|(tempbh&0x01); tempbh=tempbh|t1; tempbx=(tempbx&0xFF)|(tempbh<<8); tempax=tempax+5; modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); // si+St_ModeFlag if(modeflag1&Charx8Dot){ tempax=tempax*8; }else{ tempax=tempax*9; } VGAHT=tempax; HT=tempax; tempbx++; VGAVT=tempbx; VT=tempbx;}VOID GetCRT2Ptr(ULONG ROMAddr,USHORT ModeNo){ USHORT tempcl,tempbx,tempal,tempax,CRT2PtrData; if(IF_DEF_LVDS==0){ if(VBInfo&SetCRT2ToLCD){ //LCD tempbx=0; //default tempbx=0 -> ExtLCD1Data tempcl=LCDDataLen; if(LCDResInfo==Panel1024x768){ tempbx=0; }else if(LCDResInfo==Panel1280x1024){ tempbx=1; } if(!(SetFlag&LCDVESATiming)) tempbx+=5; }else if(VBInfo&SetPALTV){ tempcl=TVDataLen; tempbx=3; }else{ tempbx=4; tempcl=TVDataLen; } if(SetFlag&TVSimuMode){ tempbx=tempbx+4; } if(ModeNo<=0x13){ tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); // si+St_CRT2CRTC }else{ tempal=*((UCHAR *)(ROMAddr+REFIndex+4)); //di+Ext_CRT2CRTC } tempal=tempal&0x1F; tempax=tempal*tempcl; REFIndex=*((USHORT *)(ROMAddr+tempbx*2+0x20E)); REFIndex+=tempax; }else{ //for LVDS tempcl=LVDSDataLen; tempbx=LCDResInfo-Panel800x600; if(LCDInfo&LCDNonExpanding){ tempbx=tempbx+3; } if(ModeNo<=0x13){ tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); // si+St_CRT2CRTC }else{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?