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

📄 init301.c

📁 移植到2410开发板上的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	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;	}	tempax = SiS_LCDHDES;	tempbx = SiS_HDE;	tempcx = SiS_HT;	if (SiS_LCDInfo & LCDNonExpanding) {		if (SiS_LCDResInfo == Panel1280x1024)			tempbx = 1280;		if (SiS_LCDResInfo == Panel1024x768)			tempbx = 1024;	}	tempcx = tempcx - tempbx;	/* HT-HDE  */	push1 = tempax;	tempax = tempax + tempbx;	/* lcdhdee  */	tempbx = SiS_HT;	if (tempax >= tempbx) {		tempax = tempax - tempbx;	}	push2 = tempax;	/* push ax   lcdhdee  */	tempcx = tempcx >> 2;	/* temp  */	tempcx = tempcx + tempax;	/* lcdhrs  */	if (tempcx >= tempbx) {		tempcx = tempcx - tempbx;	}	/* v ah,cl  */	tempax = tempcx;	tempax = tempax >> 3;	/* BPLHRS */	temp = tempax & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x14, temp);	/* Part1_14h  */	temp = (tempax & 0x00FF) + 10;	temp = temp & 0x01F;	temp = temp | (((tempcx & 0x00ff) & 0x07) << 5);	SiS_SetReg1 (SiS_Part1Port, 0x15, temp);	/* Part1_15h  */	tempbx = push2;		/* lcdhdee  */	tempcx = push1;		/* lcdhdes  */	temp = (tempcx & 0x00FF);	temp = temp & 0x07;	/* BPLHDESKEW  */	SiS_SetReg1 (SiS_Part1Port, 0x1A, temp);	/* Part1_1Ah  */	tempcx = tempcx >> 3;	/* BPLHDES */	temp = (tempcx & 0x00FF);	SiS_SetReg1 (SiS_Part1Port, 0x16, temp);	/* Part1_16h  */	if (tempbx & 0x07)		tempbx = tempbx + 8;	tempbx = tempbx >> 3;	/* BPLHDEE  */	temp = tempbx & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x17, temp);	/* Part1_17h  */	tempcx = SiS_VGAVT;	tempbx = SiS_VGAVDE;	tempcx = tempcx - tempbx;	/* GAVT-VGAVDE  */	tempbx = SiS_LCDVDES;	/* VGAVDES  */	push1 = tempbx;		/* push bx temppush1 */	if (SiS_IF_DEF_TRUMPION == 0) {		if (SiS_IF_DEF_CH7005 == 1) {			if (SiS_VBInfo & SetCRT2ToTV) {				tempax = SiS_VGAVDE;			}		}		if (SiS_LCDResInfo == Panel1024x768)			tempax = 768;		if (SiS_LCDResInfo == Panel1280x1024)			tempax = 1024;	} else		tempax = SiS_VGAVDE;	tempbx = tempbx + tempax;	tempax = SiS_VT;	/* VT  */	if (tempbx >= SiS_VT) {		tempbx = tempbx - tempax;	}	push2 = tempbx;		/* push bx  temppush2  */	tempcx = tempcx >> 1;	tempbx = tempbx + tempcx;	tempbx++;		/* BPLVRS  */	if (tempbx >= tempax) {		tempbx = tempbx - tempax;	}	temp = tempbx & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x18, temp);	/* Part1_18h  */	tempcx = tempcx >> 3;	tempcx = tempcx + tempbx;	tempcx++;		/* BPLVRE  */	temp = tempcx & 0x00FF;	temp = temp & 0x0F;	SiS_SetRegANDOR (SiS_Part1Port, 0x19, ~0x00F, temp);	/* Part1_19h  */	temp = (tempbx & 0xFF00) >> 8;	temp = temp & 0x07;	temp = temp << 3;	/* BPLDESKEW =0 */	tempbx = SiS_VGAVDE;	if (tempbx != SiS_VDE) {		temp = temp | 0x40;	}	if (SiS_SetFlag & EnableLVDSDDA) {		temp = temp | 0x40;	}	if (SiS_LCDInfo & LCDRGB18Bit) {		temp = temp | 0x80;	}	SiS_SetRegANDOR (SiS_Part1Port, 0x1A, 0x07, temp);	/* Part1_1Ah */	tempbx = push2;		/* p bx temppush2 BPLVDEE  */	tempcx = push1;		/* pop cx temppush1 NPLVDES */	push1 = (USHORT) (tempeax & 0xFFFF);	if (!(SiS_VBInfo & SetInSlaveMode)) {		if (SiS_LCDResInfo == Panel800x600) {			if (resinfo == 7)				tempcx++;		} else {			if (SiS_LCDResInfo == Panel1024x768) {				if (resinfo == 8)					tempcx++;			}		}	}	temp = (tempbx & 0xFF00) >> 8;	temp = temp & 0x07;	temp = temp << 3;	temp = temp | (((tempcx & 0xFF00) >> 8) & 0x07);	SiS_SetReg1 (SiS_Part1Port, 0x1D, temp);	/* Part1_1Dh */	temp = tempbx & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x1C, temp);	/* Part1_1Ch  */	temp = tempcx & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x1B, temp);	/* Part1_1Bh  */	tempecx = SiS_VGAVT;	tempebx = SiS_VDE;	tempeax = SiS_VGAVDE;	tempecx = tempecx - tempeax;	/* VGAVT-VGAVDE  */	tempeax = tempeax << 18;	temp = (USHORT) (tempeax % tempebx);	tempeax = tempeax / tempebx;	if (temp != 0) {		tempeax++;	}	tempebx = tempeax;	/* BPLVCFACT  */	tempvcfact = tempeax;	/*301b */	temp = (USHORT) (tempebx & 0x00FF);	SiS_SetReg1 (SiS_Part1Port, 0x37, temp);	temp = (USHORT) ((tempebx & 0x00FF00) >> 8);	SiS_SetReg1 (SiS_Part1Port, 0x36, temp);	temp = (USHORT) ((tempebx & 0x00030000) >> 16);	if (SiS_VDE == SiS_VGAVDE) {		temp = temp | 0x04;	}	SiS_SetReg1 (SiS_Part1Port, 0x35, temp);	tempecx = SiS_VGAHDE;	tempebx = SiS_HDE;	tempeax = tempecx;	tempeax = tempeax << 6;	tempeax = tempeax << 10;	tempeax = tempeax / tempebx;	if (tempebx == tempecx) {		tempeax = 65535;	}	tempecx = tempeax;	tempeax = SiS_VGAHDE;	/*301b to change HT->HDE */	tempeax = tempeax << 6;	tempeax = tempeax << 10;	tempeax = tempeax / tempecx;	tempecx = tempecx << 16;	tempeax = tempeax - 1;	tempecx = tempecx | (tempeax & 0x00FFFF);	temp = (USHORT) (tempecx & 0x00FF);	SiS_SetReg1 (SiS_Part1Port, 0x1F, temp);	/* Part1_1Fh  */	tempeax = SiS_VGAVDE;	tempeax = tempeax << 18;	/*301b */	tempeax = tempeax / tempvcfact;	tempbx = (USHORT) (tempeax & 0x0FFFF);	if (SiS_LCDResInfo == Panel1024x768)		tempbx--;	if (SiS_SetFlag & EnableLVDSDDA) {		tempbx = 1;	}	temp = ((tempbx & 0xFF00) >> 8) << 3;	temp = temp | (USHORT) (((tempecx & 0x0000FF00) >> 8) & 0x07);	SiS_SetReg1 (SiS_Part1Port, 0x20, temp);	/* Part1_20h */	temp = tempbx & 0x00FF;	SiS_SetReg1 (SiS_Part1Port, 0x21, temp);	/* Part1_21h */	tempecx = tempecx >> 16;	/* BPLHCFACT  */	temp = (USHORT) ((tempecx & 0x0000FF00) >> 8);	SiS_SetReg1 (SiS_Part1Port, 0x22, temp);	/* Part1_22h */	temp = (USHORT) (tempecx & 0x000000FF);	SiS_SetReg1 (SiS_Part1Port, 0x23, temp);	return;}/*end 301b*/voidSiS_SetTPData (){	return;}voidSiS_SetCRT2Offset (USHORT SiS_Part1Port, ULONG ROMAddr, USHORT ModeNo,		   USHORT ModeIdIndex, USHORT RefreshRateTableIndex,		   PSIS_HW_DEVICE_INFO HwDeviceExtension){	USHORT offset;	UCHAR temp;	if (SiS_VBInfo & SetInSlaveMode) {		return;	}	offset =	    SiS_GetOffset (ROMAddr, ModeNo, ModeIdIndex, RefreshRateTableIndex,			   HwDeviceExtension);	temp = (UCHAR) (offset & 0xFF);	SiS_SetReg1 (SiS_Part1Port, 0x07, temp);	temp = (UCHAR) ((offset & 0xFF00) >> 8);	SiS_SetReg1 (SiS_Part1Port, 0x09, temp);	temp = (UCHAR) (((offset >> 3) & 0xFF) + 1);	SiS_SetReg1 (SiS_Part1Port, 0x03, temp);}USHORTSiS_GetOffset (ULONG ROMAddr, USHORT ModeNo, USHORT ModeIdIndex,	       USHORT RefreshRateTableIndex,	       PSIS_HW_DEVICE_INFO HwDeviceExtension){	USHORT temp, colordepth;	USHORT modeinfo, index, infoflag;	USHORT ColorDepth[] = { 0x01, 0x02, 0x04 };	modeinfo = SiS_EModeIDTable[ModeIdIndex].Ext_ModeInfo;	infoflag = SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;	if (HwDeviceExtension->jChipType < SIS_315H) {	/* 300 series */		index = (modeinfo >> 4) & 0xFF;	} else {		/* 310 series */		index = (modeinfo >> 8) & 0xFF;	}	temp = SiS_ScreenOffset[index];	if (infoflag & InterlaceMode) {		temp = temp << 1;	}	colordepth = SiS_GetColorDepth (ROMAddr, ModeNo, ModeIdIndex);	if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {		temp = ModeNo - 0x7C;		colordepth = ColorDepth[temp];		temp = 0x6B;		if (infoflag & InterlaceMode) {			temp = temp << 1;		}		return (temp * colordepth);	} else		return (temp * colordepth);}USHORTSiS_GetColorDepth (ULONG ROMAddr, USHORT ModeNo, USHORT ModeIdIndex){	USHORT ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };	SHORT index;	USHORT modeflag;	if (ModeNo <= 0x13) {		modeflag = SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;	} else {		modeflag = SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;	}	index = (modeflag & ModeInfoFlag) - ModeEGA;	if (index < 0)		index = 0;	return (ColorDepth[index]);}voidSiS_SetCRT2Sync (USHORT BaseAddr, ULONG ROMAddr, USHORT ModeNo,		 USHORT RefreshRateTableIndex){	USHORT tempah = 0, infoflag, flag;	flag = 0;	infoflag = SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;	if (SiS_IF_DEF_LVDS == 1) {		if (SiS_VBInfo & SetCRT2ToLCD) {			tempah = SiS_LCDInfo;			if (tempah & LCDSync) {				flag = 1;			}		}	}	if (flag != 1)		tempah = infoflag >> 8;	tempah = tempah & 0xC0;	tempah = tempah | 0x20;	if (!(SiS_LCDInfo & LCDRGB18Bit))		tempah = tempah | 0x10;	if (SiS_IF_DEF_CH7005 == 1)		tempah = tempah | 0xC0;	SiS_SetRegANDOR (SiS_Part1Port, 0x19, 0x3F, tempah);}voidSiS_SetCRT2FIFO (USHORT SiS_Part1Port, ULONG ROMAddr, USHORT ModeNo,		 PSIS_HW_DEVICE_INFO HwDeviceExtension){	USHORT temp, index;	USHORT modeidindex, refreshratetableindex;	USHORT VCLK, MCLK, colorth = 0, data, data2;	ULONG eax;	UCHAR LatencyFactor[] = { 97, 88, 86, 79, 77, 00,	/*; 64  bit    BQ=2   */		00, 87, 85, 78, 76, 54,	/*; 64  bit    BQ=1   */		97, 88, 86, 79, 77, 00,	/*; 128 bit    BQ=2   */		00, 79, 77, 70, 68, 48,	/*; 128 bit    BQ=1   */		80, 72, 69, 63, 61, 00,	/*; 64  bit    BQ=2   */		00, 70, 68, 61, 59, 37,	/*; 64  bit    BQ=1   */		86, 77, 75, 68, 66, 00,	/*; 128 bit    BQ=2   */		00, 68, 66, 59, 57, 37	};			/*; 128 bit    BQ=1   */	SiS_SearchModeID (ROMAddr, ModeNo, &modeidindex);	SiS_SetFlag = SiS_SetFlag & (~ProgrammingCRT2);	SiS_SelectCRT2Rate = 0;	refreshratetableindex = SiS_GetRatePtrCRT2 (ROMAddr, ModeNo, modeidindex);	/* 11.GetRatePtr */	if (ModeNo >= 0x13) {		index = SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK;		index = index & 0x3F;		VCLK = SiS_VCLKData[index].CLOCK;	/* Get VCLK  */		index = SiS_GetReg1 (SiS_P3c4, 0x1A);		index = index & 07;		MCLK = SiS_MCLKData[index].CLOCK;	/* Get MCLK  */		data2 = SiS_ModeType - 0x02;		switch (data2) {		case 0:			colorth = 1;			break;		case 1:			colorth = 1;			break;		case 2:			colorth = 2;			break;		case 3:			colorth = 2;			break;		case 4:			colorth = 3;			break;		case 5:			colorth = 4;			break;		}		data2 = (data2 * VCLK) / MCLK;	/*  bx */		temp = SiS_GetReg1 (SiS_P3c4, 0x14);		temp = ((temp & 0x00FF) >> 6) << 1;		if (temp == 0)			temp = 1;		temp = temp << 2;		data2 = temp - data2;		if (data2 % (28 * 16)) {			data2 = data2 / (28 * 16);			data2++;		} else {			data2 = data2 / (28 * 16);		}		index = 0;		temp = SiS_GetReg1 (SiS_P3c4, 0x14);		if (temp & 0x0080)			index = index + 12;		SiS_SetReg4 (0xcf8, 0x800000A0);		eax = SiS_GetReg3 (0xcfc);		temp = (USHORT) (eax >> 24);		if (!(temp & 0x01))			index = index + 24;		SiS_SetReg4 (0xcf8, 0x80000050);		eax = SiS_GetReg3 (0xcfc);		temp = (USHORT) (eax >> 24);		if (temp & 0x01)			index = index + 6;		temp = (temp & 0x0F) >> 1;		index = index + temp;		data = LatencyFactor[index];		data = data + 15;		temp = SiS_GetReg1 (SiS_P3c4, 0x14);		if (!(temp & 0x80))			data = data + 5;		data = data + data2;		SiS_SetFlag = SiS_SetFlag | ProgrammingCRT2;		data = data * VCLK * colorth;		if (data % (MCLK << 4)) {			data = data / (MCLK << 4);			data++;		} else {			data = data / (MCLK << 4);		}		temp = 0x16;/*  Revision ID  */		temp = 0x13;/*  Revision ID  */		SiS_SetRegANDOR (SiS_Part1Port, 0x01, ~0x01F, temp);		SiS_SetRegANDOR (SiS_Part1Port, 0x02, ~0x01F, temp);	}}voidSiS_SetCRT2FIFO2 (USHORT SiS_Part1Port, ULONG ROMAddr, USHORT ModeNo,		  PSIS_HW_DEVICE_INFO HwDeviceExtension){#ifdef CONFIG_FB_SIS_315	UCHAR CombCode[] = { 1, 1, 1, 4, 3, 1, 3, 4, 4, 1, 4, 4, 5, 1, 5, 4 };	UCHAR CRT2ThLow[] =	    { 39, 63, 55, 79, 78, 102, 90, 114, 55, 87, 84, 116, 103, 135, 119,		    151 };#endif	USHORT temp, temp1, temp2, temp3;	USHORT index;	USHORT CRT1ModeNo, CRT2ModeNo;	USHORT ModeIdIndex;	USHORT RefreshRateTableIndex;	SiS_SetReg1 (SiS_Part1Port, 0x1, 0x3B);/* CRT1ModeNo=(UCHAR)SiS_GetReg1(SiS_P3d4,0x34); *//* get CRT1 ModeNo */	CRT1ModeNo = SiS_CRT1Mode;	/* CRT1ModeNo =ModeNo; */	SiS_SearchModeID (ROMAddr, CRT1ModeNo, &ModeIdIndex);	/* Get ModeID Table */	SiS_SetFlag = SiS_SetFlag & (~ProgrammingCRT2);	RefreshRateTableIndex = SiS_GetRatePtrCRT2 (ROMAddr, CRT1ModeNo, ModeIdIndex);	/* Set REFIndex-> for crt1 refreshrate */	index =	    SiS_GetVCLK2Ptr (ROMAddr, CRT1ModeNo, ModeIdIndex,			     RefreshRateTableIndex, HwDeviceExtension);	temp1 = SiS_VCLKData[index].CLOCK;	/* Get VCLK  */	temp2 = SiS_GetColorDepth (ROMAddr, CRT1ModeNo, ModeIdIndex);#ifdef CONFIG_FB_SIS_315	index = SiS_Get310DRAMType (ROMAddr);#endif	temp3 = SiS_MCLKData[index].CLOCK;	/* Get MCLK  */	temp = SiS_GetReg1 (SiS_P3c4, 0x14);	if (temp & 0x02)		temp = 16;	else		temp = 8;	temp = temp - temp1 * temp2 / temp3;	/* 16-DRamBus - DCLK*BytePerPixel/MCLK */	if ((52 * 16 % temp) == 0)		temp = 52 * 16 / temp + 40;	else		temp = 52 * 16 / temp + 40 + 1;	/* get DRAM latency */	temp1 = (SiS_GetReg1 (SiS_P3c4, 0x17) >> 3) & 0x7;	/* SR17[5:3] DRAM Queue depth */	temp2 = (SiS_GetReg1 (SiS_P3c4, 0x17) >> 6) & 0x3;	/* SR17[7:6] DRAM Grant length */#ifdef CONFIG_FB_SIS_315	if (SiS_Get310DRAMType (ROMAddr) < 2) {		for (temp3 = 0; temp3 < 16; temp3 += 2) {			if ((CombCode[temp3] == temp1)			    && (CombCode[temp3 + 1] == temp2)) {				temp3 = CRT2ThLow[temp3 >> 1];			}		}	} else {		for (temp3 = 0; temp3 < 16; temp3 += 2) {			if ((CombCode[temp3] == temp1)			    && (CombCode[temp3 + 1] == temp2)) {				temp3 = CRT2ThLow[8 + (temp3 >> 1)];			}		}	}#endif	temp += temp3;		/* CRT1 Request Period */	CRT2ModeNo = ModeNo;	/* get CRT2 ModeNo */	SiS_SearchModeID (ROMAddr, CRT2ModeNo, &ModeIdIndex);	/* Get ModeID Table */

⌨️ 快捷键说明

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