⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init301.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 5 页
字号:
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.3 2000/12/02 01:16:16 dawes Exp $ */#include "init301.h"#ifdef CONFIG_FB_SIS_300#include "oem300.h"#endif#ifdef CONFIG_FB_SIS_315#include "oem310.h"#endifBOOLEANSiS_SetCRT2Group301 (USHORT BaseAddr, ULONG ROMAddr, USHORT ModeNo,		     PSIS_HW_DEVICE_INFO HwDeviceExtension){	USHORT ModeIdIndex;	USHORT RefreshRateTableIndex;	SiS_SetFlag = SiS_SetFlag | ProgrammingCRT2;	SiS_SearchModeID (ROMAddr, ModeNo, &ModeIdIndex);	SiS_SelectCRT2Rate = 4;	RefreshRateTableIndex =	    SiS_GetRatePtrCRT2 (ROMAddr, ModeNo, ModeIdIndex);	SiS_SaveCRT2Info (ModeNo);	SiS_DisableBridge (HwDeviceExtension, BaseAddr);	SiS_UnLockCRT2 (HwDeviceExtension, BaseAddr);	SiS_SetCRT2ModeRegs (BaseAddr, ModeNo, HwDeviceExtension);	if (SiS_VBInfo & DisableCRT2Display) {		SiS_LockCRT2 (HwDeviceExtension, BaseAddr);		SiS_DisplayOn ();		return (FALSE);	}/* SetDefCRT2ExtRegs(BaseAddr);   */	SiS_GetCRT2Data (ROMAddr, ModeNo, ModeIdIndex, RefreshRateTableIndex);	/*301b */	if (((SiS_VBType & VB_SIS301B) || (SiS_VBType & VB_SIS302B))	    && (SiS_VBInfo & SetCRT2ToLCDA)) {		SiS_GetLVDSDesData (ROMAddr, ModeNo, ModeIdIndex,				    RefreshRateTableIndex);	}	/*end 301b */	if (SiS_IF_DEF_LVDS == 1) {		SiS_GetLVDSDesData (ROMAddr, ModeNo, ModeIdIndex,				    RefreshRateTableIndex);	}	SiS_SetGroup1 (BaseAddr, ROMAddr, ModeNo, ModeIdIndex,		       HwDeviceExtension, RefreshRateTableIndex);	/*301b */	if (((SiS_VBType & VB_SIS301B) || (SiS_VBType & VB_SIS302B))	    && (SiS_VBInfo & SetCRT2ToLCDA) && (SiS_IF_DEF_LVDS == 0)) {	} else if (SiS_IF_DEF_LVDS == 0 && (!(SiS_VBInfo & SetCRT2ToLCDA))) {		SiS_SetGroup2 (BaseAddr, ROMAddr, ModeNo, ModeIdIndex,			       RefreshRateTableIndex, HwDeviceExtension);		SiS_SetGroup3 (BaseAddr, ROMAddr, ModeNo, ModeIdIndex,			       HwDeviceExtension);		SiS_SetGroup4 (BaseAddr, ROMAddr, ModeNo, ModeIdIndex,			       RefreshRateTableIndex, HwDeviceExtension);		SiS_SetGroup5 (BaseAddr, ROMAddr, ModeNo, ModeIdIndex);	} else {		if (SiS_IF_DEF_CH7005 == 1) {			SiS_SetCHTVReg (ROMAddr, ModeNo, ModeIdIndex,					RefreshRateTableIndex);		}		SiS_ModCRT1CRTC (ROMAddr, ModeNo, ModeIdIndex,				 RefreshRateTableIndex);		SiS_SetCRT2ECLK (ROMAddr, ModeNo, ModeIdIndex,				 RefreshRateTableIndex, HwDeviceExtension);	}#ifdef CONFIG_FB_SIS_300	if ((HwDeviceExtension->jChipType == SIS_540) ||	    (HwDeviceExtension->jChipType == SIS_630) ||	    (HwDeviceExtension->jChipType == SIS_730) ||	    (HwDeviceExtension->jChipType == SIS_300))		SiS_OEM300Setting (HwDeviceExtension, BaseAddr, ROMAddr,				   ModeNo);#endif#ifdef CONFIG_FB_SIS_315	if ((HwDeviceExtension->jChipType == SIS_315H) ||	/* 05/02/01 ynlai for sis550 */	    (HwDeviceExtension->jChipType == SIS_315PRO) ||	    (HwDeviceExtension->jChipType == SIS_550) ||	/* 05/02/01 ynlai for 550 */	    (HwDeviceExtension->jChipType == SIS_640) ||	/* 08/20/01 chiawen for 640/740 */	    (HwDeviceExtension->jChipType == SIS_740)) {	/* 09/03/01 chiawen for 640/740 */		SiS_OEM310Setting (HwDeviceExtension, BaseAddr, ROMAddr, ModeNo,				   ModeIdIndex);		SiS_CRT2AutoThreshold (BaseAddr);	}#endif	SiS_EnableBridge (HwDeviceExtension, BaseAddr);	SiS_DisplayOn ();	SiS_LockCRT2 (HwDeviceExtension, BaseAddr);	return 1;}voidSiS_SetGroup1 (USHORT BaseAddr, ULONG ROMAddr, USHORT ModeNo,	       USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension,	       USHORT RefreshRateTableIndex){	USHORT temp = 0, tempax = 0, tempbx = 0, tempcx = 0;	USHORT pushbx = 0, CRT1Index = 0;	USHORT modeflag, resinfo = 0;	if (ModeNo <= 0x13) {	} else {		CRT1Index = SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;		CRT1Index = CRT1Index & 0x3F;		resinfo = SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;	}	/*301b */	if (((SiS_VBType & VB_SIS301B) || (SiS_VBType & VB_SIS302B))	    && (SiS_VBInfo & SetCRT2ToLCDA)) {	} else {		SiS_SetCRT2Offset (SiS_Part1Port, ROMAddr, ModeNo, ModeIdIndex,				   RefreshRateTableIndex, HwDeviceExtension);		if (HwDeviceExtension->jChipType < SIS_315H)	/* 300 series */			SiS_SetCRT2FIFO (SiS_Part1Port, ROMAddr, ModeNo,					 HwDeviceExtension);		else		/* 310 series */			SiS_SetCRT2FIFO2 (SiS_Part1Port, ROMAddr, ModeNo,					  HwDeviceExtension);		SiS_SetCRT2Sync (BaseAddr, ROMAddr, ModeNo,				 RefreshRateTableIndex);	}	if (ModeNo <= 0x13) {		modeflag = SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;	} else {		modeflag = SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;	}	/*301b */	if (((SiS_VBType & VB_SIS301B) || (SiS_VBType & VB_SIS302B))	    && (SiS_VBInfo & SetCRT2ToLCDA)) {		SiS_SetGroup1_LCDA (BaseAddr, ROMAddr, ModeNo, ModeIdIndex,				    HwDeviceExtension, RefreshRateTableIndex);	}	/*end 301b */	else if (HwDeviceExtension->jChipType < SIS_315H) {	/* 300 series */		temp = (SiS_VGAHT - 1) & 0x0FF;	/* BTVGA2HT 0x08,0x09 */		SiS_SetReg1 (SiS_Part1Port, 0x08, temp);		temp = (((SiS_VGAHT - 1) & 0xFF00) >> 8) << 4;		SiS_SetRegANDOR (SiS_Part1Port, 0x09, ~0x0F0, temp);		temp = (SiS_VGAHDE + 12) & 0x0FF;	/* BTVGA2HDEE 0x0A,0x0C */		SiS_SetReg1 (SiS_Part1Port, 0x0A, temp);		pushbx = SiS_VGAHDE + 12;	/* bx  BTVGA@HRS 0x0B,0x0C */		tempcx = (SiS_VGAHT - SiS_VGAHDE) >> 2;	/* cx */		tempbx = pushbx + tempcx;		tempcx = tempcx << 1;		tempcx = tempcx + tempbx;		if (SiS_IF_DEF_LVDS == 0) {			if (SiS_VBInfo & SetCRT2ToRAMDAC) {				tempbx = SiS_CRT1Table[CRT1Index].CR[4];				tempbx =				    tempbx |				    ((SiS_CRT1Table[CRT1Index].CR[14] & 0xC0) <<				     2);				tempbx = (tempbx - 1) << 3;				tempcx = SiS_CRT1Table[CRT1Index].CR[5];				tempcx = tempcx & 0x1F;				temp = SiS_CRT1Table[CRT1Index].CR[15];				temp = (temp & 0x04) << (6 - 2);				tempcx = ((tempcx | temp) - 1) << 3;			}		}		/*add for hardware request */		if ((SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)) {			if (SiS_VBInfo & SetPALTV) {				tempbx = 1040;				tempcx = 1042;			} else {				tempbx = 1040;				tempcx = 1042;			}		}		temp = tempbx & 0x00FF;		SiS_SetReg1 (SiS_Part1Port, 0x0B, temp);	} else {		/* 310 series */		if (modeflag & HalfDCLK) {	/* for low resolution mode */			temp = (SiS_VGAHT / 2 - 1) & 0x0FF;	/* BTVGA2HT 0x08,0x09 */			SiS_SetReg1 (SiS_Part1Port, 0x08, temp);			temp = (((SiS_VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;			SiS_SetRegANDOR (SiS_Part1Port, 0x09, ~0x0F0, temp);			temp = (SiS_VGAHDE / 2 + 16) & 0x0FF;	/* BTVGA2HDEE 0x0A,0x0C */			SiS_SetReg1 (SiS_Part1Port, 0x0A, temp);			pushbx = SiS_VGAHDE / 2 + 16;			tempcx = ((SiS_VGAHT - SiS_VGAHDE) / 2) >> 2;	/* cx */			tempbx = pushbx + tempcx;	/* bx  BTVGA@HRS 0x0B,0x0C */			tempcx = tempcx + tempbx;			if (SiS_IF_DEF_LVDS == 0) {				if (SiS_VBInfo & SetCRT2ToRAMDAC) {					tempbx = SiS_CRT1Table[CRT1Index].CR[4];					tempbx =					    tempbx |					    ((SiS_CRT1Table					      [CRT1Index].CR[14] & 0xC0) << 2);					tempbx = (tempbx - 3) << 3;	/*(VGAHRS-3)*8 */					tempcx = SiS_CRT1Table[CRT1Index].CR[5];					tempcx = tempcx & 0x1F;					temp = SiS_CRT1Table[CRT1Index].CR[15];					temp = (temp & 0x04) << (5 - 2);	/*VGAHRE D[5] */					tempcx = ((tempcx | temp) - 3) << 3;	/* (VGAHRE-3)*8 */				}			}			tempbx += 4;			tempcx += 4;			if (tempcx > (SiS_VGAHT / 2))				tempcx = SiS_VGAHT / 2;			temp = tempbx & 0x00FF;			SiS_SetReg1 (SiS_Part1Port, 0x0B, temp);		} else {			temp = (SiS_VGAHT - 1) & 0x0FF;	/* BTVGA2HT 0x08,0x09 */			SiS_SetReg1 (SiS_Part1Port, 0x08, temp);			temp = (((SiS_VGAHT - 1) & 0xFF00) >> 8) << 4;			SiS_SetRegANDOR (SiS_Part1Port, 0x09, ~0x0F0, temp);			temp = (SiS_VGAHDE + 16) & 0x0FF;	/* BTVGA2HDEE 0x0A,0x0C */			SiS_SetReg1 (SiS_Part1Port, 0x0A, temp);			pushbx = SiS_VGAHDE + 16;			tempcx = (SiS_VGAHT - SiS_VGAHDE) >> 2;	/* cx */			tempbx = pushbx + tempcx;	/* bx  BTVGA@HRS 0x0B,0x0C */			tempcx = tempcx + tempbx;			if (SiS_IF_DEF_LVDS == 0) {				if (SiS_VBInfo & SetCRT2ToRAMDAC) {					tempbx = SiS_CRT1Table[CRT1Index].CR[4];					tempbx =					    tempbx |					    ((SiS_CRT1Table					      [CRT1Index].CR[14] & 0xC0) << 2);					tempbx = (tempbx - 3) << 3;	/*(VGAHRS-3)*8 */					tempcx = SiS_CRT1Table[CRT1Index].CR[5];					tempcx = tempcx & 0x1F;					temp = SiS_CRT1Table[CRT1Index].CR[15];					temp = (temp & 0x04) << (5 - 2);	/*VGAHRE D[5] */					tempcx = ((tempcx | temp) - 3) << 3;	/* (VGAHRE-3)*8 */					tempbx += 16;					tempcx += 16;				}			}			if (tempcx > SiS_VGAHT)				tempcx = SiS_VGAHT;			/*add for hardware request */			if ((SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)) {				if (SiS_VBInfo & SetPALTV) {					tempbx = 1040;					tempcx = 1042;				} else {					tempbx = 1040;					tempcx = 1042;				}			}			temp = tempbx & 0x00FF;			SiS_SetReg1 (SiS_Part1Port, 0x0B, temp);		}	}	tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);	tempbx = pushbx;	tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);	tempax = tempax | (tempbx & 0xFF00);	temp = (tempax & 0xFF00) >> 8;	SiS_SetReg1 (SiS_Part1Port, 0x0C, temp);	temp = tempcx & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x0D, temp);	tempcx = (SiS_VGAVT - 1);	temp = tempcx & 0x00FF;	if (SiS_IF_DEF_CH7005 == 1) {		if (SiS_VBInfo & 0x0C) {			temp--;		}	}	SiS_SetReg1 (SiS_Part1Port, 0x0E, temp);	tempbx = SiS_VGAVDE - 1;	temp = tempbx & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x0F, temp);	temp = ((tempbx & 0xFF00) << 3) >> 8;	temp = temp | ((tempcx & 0xFF00) >> 8);	SiS_SetReg1 (SiS_Part1Port, 0x12, temp);	tempax = SiS_VGAVDE;	tempbx = SiS_VGAVDE;	tempcx = SiS_VGAVT;	tempbx = (SiS_VGAVT + SiS_VGAVDE) >> 1;	/*      BTVGA2VRS     0x10,0x11   */	tempcx = ((SiS_VGAVT - SiS_VGAVDE) >> 4) + tempbx + 1;	/*      BTVGA2VRE     0x11        */	if (SiS_IF_DEF_LVDS == 0) {		if (SiS_VBInfo & SetCRT2ToRAMDAC) {			tempbx = SiS_CRT1Table[CRT1Index].CR[8];			temp = SiS_CRT1Table[CRT1Index].CR[7];			if (temp & 0x04)				tempbx = tempbx | 0x0100;			if (temp & 0x080)				tempbx = tempbx | 0x0200;			temp = SiS_CRT1Table[CRT1Index].CR[13];			if (temp & 0x08)				tempbx = tempbx | 0x0400;			temp = SiS_CRT1Table[CRT1Index].CR[9];			tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);		}	}	temp = tempbx & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x10, temp);	temp = ((tempbx & 0xFF00) >> 8) << 4;	temp = ((tempcx & 0x000F) | (temp));	SiS_SetReg1 (SiS_Part1Port, 0x11, temp);	if (SiS_IF_DEF_LVDS == 0) {		temp = 0x20;		if (SiS_LCDResInfo == Panel1280x1024)			temp = 0x20;		if (SiS_LCDResInfo == Panel1280x960)			temp = 0x24;		if (SiS_VBInfo & SetCRT2ToTV)			temp = 0x08;		if (SiS_VBInfo & SetCRT2ToHiVisionTV) {			if (SiS_VBInfo & SetInSlaveMode)				temp = 0x2c;			else				temp = 0x20;		}	} else {		temp = 0x20;	}	if (HwDeviceExtension->jChipType < SIS_315H)	/* 300 series */		SiS_SetRegANDOR (SiS_Part1Port, 0x13, ~0x03C, temp);	else {			/* 310 series */		temp >>= 2;		temp = 0x11;	/*  ynlai 05/30/2001 for delay compenation  */		SiS_SetReg1 (SiS_Part1Port, 0x2D, temp);		/*SiS_SetRegANDOR(SiS_Part1Port,0x2D,~0x00F,temp); */		SiS_SetRegAND (SiS_Part1Port, 0x13, 0xEF);	/* BDirectLCD=0 for lcd ?? */		tempax = 0;		if (modeflag & DoubleScanMode)			tempax |= 0x80;		if (modeflag & HalfDCLK)			tempax |= 0x40;		SiS_SetRegANDOR (SiS_Part1Port, 0x2C, ~0x0C0, tempax);	}	if (SiS_IF_DEF_LVDS == 0) {	/*  301  */		SiS_SetGroup1_301 (BaseAddr, ROMAddr, ModeNo, ModeIdIndex,				   HwDeviceExtension, RefreshRateTableIndex);	} else {		/*  LVDS  */		SiS_SetGroup1_LVDS (BaseAddr, ROMAddr, ModeNo, ModeIdIndex,				    HwDeviceExtension, RefreshRateTableIndex);	}}voidSiS_SetGroup1_301 (USHORT BaseAddr, ULONG ROMAddr, USHORT ModeNo,		   USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension,		   USHORT RefreshRateTableIndex){	USHORT push1, push2;	USHORT tempax, tempbx, tempcx, temp;	USHORT resinfo, modeflag;	USHORT CRT1Index;	if (ModeNo <= 0x13) {		modeflag = SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;	/* si+St_ResInfo */		resinfo = SiS_SModeIDTable[ModeIdIndex].St_ResInfo;	} else {		modeflag = SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;	/* si+Ext_ResInfo */		resinfo = SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;		CRT1Index = SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;		CRT1Index = CRT1Index & 0x3F;	}	if (!(SiS_VBInfo & SetInSlaveMode)) {		return;	}	tempax = 0xFFFF;	if (!(SiS_VBInfo & SetCRT2ToTV)) {		tempax = SiS_GetVGAHT2 ();	}	if (modeflag & Charx8Dot)		tempcx = 0x08;	else		tempcx = 0x09;	if (tempax >= SiS_VGAHT) {		tempax = SiS_VGAHT;	}	if (modeflag & HalfDCLK) {		tempax = tempax >> 1;	}	tempax = (tempax / tempcx) - 5;	tempbx = tempax;	temp = 0xFF;		/* set MAX HT */	SiS_SetReg1 (SiS_Part1Port, 0x03, temp);	tempax = SiS_VGAHDE;	/* 0x04 Horizontal Display End */	if (modeflag & HalfDCLK)		tempax = tempax >> 1;	tempax = (tempax / tempcx) - 1;	tempbx = tempbx | ((tempax & 0x00FF) << 8);	temp = tempax & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x04, temp);	temp = (tempbx & 0xFF00) >> 8;	if (SiS_VBInfo & SetCRT2ToTV) {		temp = temp + 2;		if (SiS_VBInfo & SetCRT2ToHiVisionTV) {			if (resinfo == 7)				temp = temp - 2;		}	}	SiS_SetReg1 (SiS_Part1Port, 0x05, temp);	/* 0x05 Horizontal Display Start */	SiS_SetReg1 (SiS_Part1Port, 0x06, 0x03);	/* 0x06 Horizontal Blank end     */	/* 0x07 horizontal Retrace Start */	if (SiS_VBInfo & SetCRT2ToHiVisionTV) {		temp = (tempbx & 0x00FF) - 1;		if (!(modeflag & HalfDCLK)) {			temp = temp - 6;			if (SiS_SetFlag & TVSimuMode) {				temp = temp - 4;				if (ModeNo > 0x13)					temp = temp - 10;			}		}	} else {		tempcx = tempbx & 0x00FF;		tempbx = (tempbx & 0xFF00) >> 8;		tempcx = (tempcx + tempbx) >> 1;		temp = (tempcx & 0x00FF) + 2;		if (SiS_VBInfo & SetCRT2ToTV) {			temp = temp - 1;			if (!(modeflag & HalfDCLK)) {				if ((modeflag & Charx8Dot)) {					temp = temp + 4;					if (SiS_VGAHDE >= 800) {						temp = temp - 6;					}				}			}		} else {			if (!(modeflag & HalfDCLK)) {				temp = temp - 4;				if (SiS_LCDResInfo != Panel1280x960) {					if (SiS_VGAHDE >= 800) {						temp = temp - 7;						if (SiS_ModeType == ModeEGA) {							if (SiS_VGAVDE == 1024) {								temp =								    temp + 15;								if								    (SiS_LCDResInfo								     !=								     Panel1280x1024)								{									temp =									    temp									    + 7;								}							}						}						if (SiS_VGAHDE >= 1280) {							if (SiS_LCDResInfo !=							    Panel1280x960) {								if (SiS_LCDInfo								    &								    LCDNonExpanding)								{									temp =									    temp									    +									    28;								}							}						}					}				}			}		}	}	SiS_SetReg1 (SiS_Part1Port, 0x07, temp);	/* 0x07 Horizontal Retrace Start */	SiS_SetReg1 (SiS_Part1Port, 0x08, 0);	/* 0x08 Horizontal Retrace End   */

⌨️ 快捷键说明

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