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

📄 hal_blt.c

📁 一款SmartPhone的驱动代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		// write bitblt with ROP
		halWriteReg16(REG8008_BLT_COMMAND, 0x0000);
		halWriteReg16(REG800A_BLT_COMMAND, (unsigned short)lpBlt->ROP);
	}
	
	halWriteReg16(REG800C_BLT_SOURCE_START_ADDR0, (unsigned short)phase);
	halWriteReg16(REG8014_BLT_MEM_ADDR_OFFSET, (unsigned short)(stride >> 1));

	
	halWriteReg16(REG8010_BLT_DEST_START_ADDR0, (unsigned short)dstAddr);
	halWriteReg16(REG8012_BLT_DEST_START_ADDR1, (unsigned short)(dstAddr>>16));

	halWriteReg16(REG8018_BLT_WIDTH, (unsigned short)(lpBlt->DstWidth-1));
	halWriteReg16(REG801C_BLT_HEIGHT, (unsigned short)(lpBlt->DstHeight-1));

	// Engage the blt engine.
	// 强制为线性入		???????????
	halWriteReg16(REG8002_BLT_CTRL, 0x05);
	//halWriteReg16(REG8002_BLT_CTRL, lpCtrlInfo->Reg8000MSW);

	// start
	halWriteReg16(REG8000_BLT_CTRL, 0x0001);
	
	// WaitForBltEnd();
	while( !(halReadReg16(REG8004_BLT_STATUS) & 0x0001) );

	
	dst = (unsigned short *)(HalInfo.dwMemoryAddress);

	// calculate the number of 16 bit words per one blt line
	nWords = phase + ((lpBlt->DstWidth-phase)*lpCtrlInfo->BytesPerPixel + 1)/2;
	nTotalWords = nWords * lpBlt->DstHeight;

	// Word aligned
	w16 = (unsigned short *)(memaddress & 0xFFFFFFFE);

	while (nTotalWords > 0)
	{
		// read the FIFO status
		
		// ???????????????????????
		*dst = (unsigned short)*w16 ++;
		nTotalWords --;
	}
	
	//halWriteReg16(REG8000_BLT_CTRL, 0x0 );

}

/****************************************************************************
; Function:	Performs Pattern Fill Blit with ROP or Transparent.
; Source :
;	PatStart : video memory offset to the start of the pattern.
;	Pattern Phase:
;		lpBlt->PatternX : x - coord of the first pattern pixel
;		lpBlt->PatternY : y - coord of the first pattern pixel
; Destination rectangle:
;	lpBlt->DstLeft
;	lpBlt->DstTop
;	lpBlt->DstWidth
;	lpBlt->DstHeight

; Transparent Pattern Fill Blt:
;	- transparent color in lpBlt->ColorBg
;	Solid Pattern Fill Blt:
;	- ROP in lpBlt->ROP

; Note:
;    Some cases cannot be handled by hardware.
;    PatStart is assumed to be aligned on 64 byte boundary for 8 Bpp mode,
;    on 128 boundary for 15/16 Bpp modes
;****************************************************************************/
void PatternFillBlt(LPBLT_INFO		lpBlt,
					LPBLTCTRL_INFO	lpCtrlInfo )
{
	short			BytesPerPixel;
	unsigned long	dstAddr;
	unsigned long	patAddr;
		
	if (lpBlt->DstWidth == 0 || lpBlt->DstHeight == 0)
		return;

	BytesPerPixel = lpCtrlInfo->BytesPerPixel;

	// Wait for any pending blit to end
	WaitForBltEnd();
	
	// Copy the pattern in the video memory. Here we place it in the
	// first 128 byte aligned address in the offscreen memory.
	patAddr = (lpCtrlInfo->OffscreenOffset+127L) & 0xffffff80L;
	
	// ????????
	memcpy((unsigned char *)(patAddr),
				lpBlt->Pattern,(8*8*lpCtrlInfo->BytesPerPixel));

	//memcpy((unsigned char *)(gLinBufAddr+patAddr),
	//			lpBlt->Pattern,(8*8*lpCtrlInfo->BytesPerPixel));
	
	// The pattern is 8pixels*8lines.
	// Adjust pattern start for x,y start phases
	// add 8*PhaseY*BytesPerPixel + PhaseX*BytesPerPixel
	patAddr += lpBlt->PatternY*BytesPerPixel*8 + lpBlt->PatternX*BytesPerPixel;

	// program relevant blt registers
	halWriteReg16(REG800C_BLT_SOURCE_START_ADDR0, (unsigned short)patAddr);
	halWriteReg16(REG800E_BLT_SOURCE_START_ADDR1, (unsigned short)(patAddr>>16));

	if (lpBlt->Attribute & ATTR_TRANSPARENT )
	{
		halWriteReg16(REG8020_BLT_BACKGROUND_COLOR, (unsigned short)lpBlt->ColorBg);
		halWriteReg16(REG8008_BLT_COMMAND, 0x0007);
		halWriteReg16(REG800A_BLT_COMMAND, 0x0000);
	}
	else
	{
		halWriteReg16(REG8008_BLT_COMMAND, 0x0006);
		halWriteReg16(REG800A_BLT_COMMAND, (unsigned short)lpBlt->ROP);
	}

	halWriteReg16(REG8014_BLT_MEM_ADDR_OFFSET, (unsigned short)(lpCtrlInfo->Stride/2));

	dstAddr = (unsigned long)lpBlt->DstLeft*BytesPerPixel + 
			(unsigned long)lpBlt->DstTop * lpCtrlInfo->Stride;
	halWriteReg16(REG8010_BLT_DEST_START_ADDR0, (unsigned short)dstAddr);
	halWriteReg16(REG8012_BLT_DEST_START_ADDR1, (unsigned short)(dstAddr>>16));

	halWriteReg16(REG8018_BLT_WIDTH, (unsigned short)(lpBlt->DstWidth-1));
	halWriteReg16(REG801C_BLT_HEIGHT, (unsigned short)(lpBlt->DstHeight-1));

	// Engage the blt engine.

	halWriteReg16(REG8002_BLT_CTRL, lpCtrlInfo->Reg8000MSW);

	halWriteReg16(REG8000_BLT_CTRL, 0x0001);	

}

/****************************************************************************
; Function:	
; Input :	
; Output :	
;****************************************************************************/
void ColorExpandBlt( void )
{


}

/****************************************************************************
; Function:	
; Input :	
; Output :	
;****************************************************************************/
void ColorExpandMoveBlt( void )
{
	

}

/****************************************************************************
; Function:	
; Input :	
; Output :	
;****************************************************************************/
void TransparentMoveBlt( void )
{
	

}

/****************************************************************************
; Function:	Performs rectangular Move Blit with ROP or Transparent.
; Move Blt
;	Transparent Blt:
;	- transparent color in lpBlt->ColorBg
; Move Blit:
;	- ROP in lpBlt->ROP
; Note:
;	Source and destination rectangles must not overlap for the Transparent
;	Move Blt.
;****************************************************************************/
void MoveBlt(LPBLT_INFO		lpBlt,
			 LPBLTCTRL_INFO	lpCtrlInfo )
{
	short			direction;
	short			BytesPerPixel,stride;
	unsigned long	dstAddr,srcAddr;

	if (lpBlt->DstWidth == 0 || lpBlt->DstHeight == 0)
		return;
	
	BytesPerPixel = lpCtrlInfo->BytesPerPixel;
	stride = lpCtrlInfo->Stride;

	srcAddr = MAIN_WINDOW_ADDRESS + (unsigned long)lpBlt->SrcLeft * BytesPerPixel 
					+ (unsigned long)lpBlt->SrcTop * stride;
	dstAddr = MAIN_WINDOW_ADDRESS + (unsigned long)lpBlt->DstLeft * BytesPerPixel + 
				(unsigned long)lpBlt->DstTop * stride;

	// If the blit is not transparent, determine the direction of the blt.
	// Transparent blt supports only positive direction.
	
	direction = 0;	

	if (!(lpBlt->Attribute & ATTR_TRANSPARENT))
	{
		if (RectOverlap(lpBlt))
		{
			if (dstAddr > srcAddr)
			{
				direction = 1;
				srcAddr += (unsigned long)stride*(lpBlt->SrcHeight-1)+
						(unsigned long)BytesPerPixel*(lpBlt->SrcWidth-1);
				dstAddr += (unsigned long)stride*(lpBlt->DstHeight-1)+
						(unsigned long)BytesPerPixel*(lpBlt->DstWidth-1);
			}
		}
	}

	// wait for any pending blit to end
	WaitForBltEnd();

	// program the BLT stride
	halWriteReg16(REG8014_BLT_MEM_ADDR_OFFSET, (unsigned short)(stride/2));

	// Set the Source addr
	halWriteReg16(REG800C_BLT_SOURCE_START_ADDR0, (unsigned short)srcAddr);
	halWriteReg16(REG800E_BLT_SOURCE_START_ADDR1, (unsigned short)(srcAddr>>16));

	// Set the Destination addr
	halWriteReg16(REG8010_BLT_DEST_START_ADDR0, (unsigned short)dstAddr);
	halWriteReg16(REG8012_BLT_DEST_START_ADDR1, (unsigned short)(dstAddr>>16));

	halWriteReg16(REG8018_BLT_WIDTH, (unsigned short)(lpBlt->DstWidth-1));
	halWriteReg16(REG801C_BLT_HEIGHT, (unsigned short)(lpBlt->DstHeight-1));

	// set the blt type
	if (lpBlt->Attribute & ATTR_TRANSPARENT)
	{
		halWriteReg16(REG8020_BLT_BACKGROUND_COLOR, (unsigned short)lpBlt->ColorBg);
		halWriteReg16(REG8008_BLT_COMMAND, 0x0005);
		halWriteReg16(REG800A_BLT_COMMAND, 0x0000);
	}
	else
	{
		if (direction)
		{
			halWriteReg16(REG8008_BLT_COMMAND, 0x0003);
			halWriteReg16(REG800A_BLT_COMMAND, (unsigned short)lpBlt->ROP);
		}
		else
		{
			halWriteReg16(REG8008_BLT_COMMAND, 0x0002);
			halWriteReg16(REG800A_BLT_COMMAND, (unsigned short)lpBlt->ROP);
		}
	}

	// Engage the blt engine.
	halWriteReg16( REG8002_BLT_CTRL, lpCtrlInfo->Reg8000MSW );
	halWriteReg16( REG8000_BLT_CTRL, 0x0001 );

}

/****************************************************************************
; Function:	
; Input :	
; Output :	
;****************************************************************************/
void ClearMainWindowMemory( LPBLTCTRL_INFO	lpCtrlInfo )
{
	unsigned	long  LinBufAddr = 0;

	LinBufAddr = (T_VOID *)(MAIN_WINDOW_ADDRESS+HalInfo.dwMemoryAddress);
	memset((unsigned char *)LinBufAddr, 0xff, lpCtrlInfo->TotalVmem-MAIN_WINDOW_ADDRESS );

	return;
}

/****************************************************************************
; Function:	
; Input :	
; Output :	
;****************************************************************************
int DoBitBLT(LPBLT_INFO			lpBlt, 
			 LPBLTCTRL_INFO		lpCtrlInfo,
			 unsigned long		Memaddr,
			 unsigned char		Command )
{
	BLT_INFO	BltInfo;

	//InitModeInfo( lpCtrlInfo );

	switch( Command )
	{
		case BLT_WRITE:		// Write BitBLT with ROP
			WriteBlt( lpBlt, lpCtrlInfo, Memaddr );
			break;
		case BLT_READ:		// Read  BitBLT
			ReadBlt( lpBlt, lpCtrlInfo, Memaddr );
			break;
		case BLT_MOVE_POS:	// Move  BitBLT positive with ROP
			MoveBlt( lpBlt, lpCtrlInfo );
			break;
		case BLT_MOVE_NEG:	// Move  BitBLT negative with ROP
			MoveBlt( lpBlt, lpCtrlInfo );
			break;
		case BLT_WRITE_TRN:	// Write BitBLT with transparency
			
			break;
		case BLT_MOVE_POS_TRN:	// Move  BitBLT positive with transparency
			
			break;
		case BLT_PAT_FILL:	// Pattern Fill BitBLT with ROP
			PatternFillBlt( lpBlt, lpCtrlInfo );
			break;
		case BLT_PAT_FILL_TRN:	// Pattern Fill with tranparency
			PatternFillBlt( lpBlt, lpCtrlInfo );
			break;
		case BLT_CLR_EXPAND:	// Color Expand BitBLT
			
			break;
		case BLT_CLR_EXPAND_TRN:// Color Expand BitBLT with tranparency
			
			break;
		case BLT_MOVE_CLR_EXPAND:// Move BitBLT with color expand
			
			break;
		case BLT_MOVE_CLR_EXPAND_TRN:// Move BitBLT with color expand and tranparency
			
			break;
		case BLT_SOLID_FILL:	// Solid Fill BitBLT
			SolidFillBlt( lpBlt, lpCtrlInfo );
			break;
	}
	return ;
}*/

⌨️ 快捷键说明

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