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

📄 fimgse2d.h

📁 Samsung公司S3C6400芯片的BSP源码包
💻 H
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//

//
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

Module Name:    FIMGSE2D.h

Abstract:       defines for FIMGSE-2D Graphics Accelerator

Notes:
// Header to define the FIMGSE-2D class

--*/
#ifndef __FIMGSE2D_H__
#define __FIMGSE2D_H__

#include "regctrl_g2d.h"

#define Assert(a) {if (!(a)) {printf("\n %s(line %d) \n", __FILE__, __LINE__); }}

#define G2D_MAX_WIDTH				(2048)
#define G2D_MAX_HEIGHT				(2048)

#define G2D_ROTATION_0_DEG_BIT	        (0x1<<0)
#define G2D_ROTATION_90_DEG_BIT	        (0x1<<1)
#define G2D_ROTATION_180_DEG_BIT        (0x1<<2)
#define G2D_ROTATION_270_DEG_BIT        (0x1<<3)

#define G2D_NO_FLIP                     (0x1<<0)
#define G2D_X_FLIP                      (0x1<<4)
#define G2D_Y_FLIP                      (0x1<<5)

// ROP_REG (0x410)
#define G2D_OPERAND3_PAT_BIT            (0<<13)
#define G2D_OPERAND3_FG_BIT             (1<<13)

#define G2D_TRANSPARENT_BIT		(1<<9)
#define G2D_OPAQUE_BIT			(0<<9)

#define G2D_NO_ALPHA_BIT                (0<<10)
#define G2D_PP_ALPHA_SOURCE_BIT         (1<<10)
#define G2D_ALPHA_BIT                   (2<<10)
//#define G2D_PP_ALPHA_THIRD_BIT          (3<<10)
#define G2D_FADING_BIT                  (4<<10)

// Color_Mode_Reg (0x200)
#define G2D_COLOR_15BPP_BIT             (1<<0)
#define G2D_COLOR_16BPP_BIT             (1<<1)
#define G2D_COLOR_18BPP_BIT             (1<<2)
#define G2D_COLOR_24BPP_BIT             (1<<3)

// CMD0_REG (Line) (0x100)
#define G2D_REND_POINT_BIT              (1<<0)
#define G2D_REND_LINE_BIT               (1<<1)
#define G2D_MAJOR_COORD_X_BIT           (1<<8)
#define G2D_MAJOR_COORD_Y_BIT           (0<<8)
#define G2D_NOT_DRAW_LAST_POINT_BIT     (1<<9)
#define G2D_DRAW_LAST_POINT_BIT         ~(1<<9)

// CMD1_REG (BitBlt) (0x104)
#define G2D_STRETCH_BITBLT_BIT          (1<<1)
#define G2D_NORMAL_BITBLT_BIT           (1<<0)

#define ABS(v)                          (((v)>=0) ? (v):(-(v)))
#define START_ASCII                     (0x20)
#define FIFO_NUM			32
#define OPAQUE_ENABLE                   (0<<9)

// Set fading and alpha value
#define FADING_OFFSET_DISABLE           (0x0<<8)
#define ALPHA_VALUE_DISABLE             (0xff<<0)

#define G2D_DE_STATUS_FA_BIT            (1<<9)

#define FONT8BY8			(0)
#define FONT8BY15			(1)
#define FONT8BY16T			(2)
#define FONT8BY16			(3)

#define HOST2SCREEN			(0)
#define SCREEN2SCREEN		(1)

// G2D Source				0xf0
// G2D Dest					0xcc
// G2D Pattern			0xaa
// MS ROP Pattern		0xf0
// MS ROP Source		0xcc
// MS ROP Dest			0xaa
//								G2D		MS
// SRC_ONLY				0xf0	0xcc		// SRCCOPY : S
// DST_ONLY				0xcc	0xaa		// DSTCOPY : D
// PAT_ONLY				0xaa	0xf0		// PATCOPY : P
// SRC_OR_DST			0xfc	0xee		// SRCPAINT : S | D
// SRC_OR_PAT			0xfa	0xfc		// P | S --> 0xF0008A
// DST_OR_PAT			0xee	0xfa		// R2_MERGEPEN : P | D
// SRC_AND_DST		0xc0	0x88		// SRCAND : S & D
// SRC_AND_PAT		0xa0	0xc0		// MERGECOPY : S & P
// DST_AND_PAT		0x88	0xa0		// R2_MASKPEN : P & D
// SRC_XOR_DST		0x3c	0x66		// SRCINVERT : S ^ D
// SRC_XOR_PAT		0x5a	0x3c		//  X
// DST_XOR_PAT		0x66	0x5a		// PATINVERT : P ^ D
// NOTSRCCOPY			0x0f	0x33		// NOTSRCCOPY : ~S
// DSTINVERT			0x33	0x55		// DSTINVERT : ~D
// R2_NOTCOPYPEN	0x55	0x0f		// R2_NOTCOPYPEN : ~P
//
#define G2D_ROP_SRC_ONLY        (0xf0)
#define G2D_ROP_PAT_ONLY        (0xaa)
#define G2D_ROP_DST_ONLY				(0xcc)
#define G2D_ROP_SRC_OR_DST      (0xfc)
#define G2D_ROP_SRC_OR_PAT      (0xfa)
#define G2D_ROP_DST_OR_PAT      (0xee)
#define G2D_ROP_SRC_AND_DST     (0xc0) //(pat==1)? src:dst
#define G2D_ROP_SRC_AND_PAT     (0xa0)
#define G2D_ROP_DST_AND_PAT			(0x88)
#define G2D_ROP_SRC_XOR_DST			(0x3c)
#define G2D_ROP_SRC_XOR_PAT     (0x5a)
#define G2D_ROP_DST_XOR_PAT			(0x66)
#define G2D_ROP_NOTSRCCOPY			(0x0f)
#define G2D_ROP_DSTINVERT				(0x33)
#define G2D_ROP_R2_NOTCOPYPEN		(0x55)
#define G2D_NUM_SUPPORT_ROP			(15)

	typedef enum
	{
		ROP_SRC_ONLY = 0,			//O
		ROP_PAT_ONLY = 1,			//O
		ROP_DST_ONLY = 2,			//O		
		ROP_SRC_OR_DST = 3,		//O
		ROP_SRC_OR_PAT = 4,		//O
		ROP_DST_OR_PAT = 5,		//O
		ROP_SRC_AND_DST = 6,	//O
		ROP_SRC_AND_PAT = 7,	//O
		ROP_DST_AND_PAT = 8,	//N
		ROP_SRC_XOR_DST = 9,	//N
		ROP_SRC_XOR_PAT = 10,	//O
		ROP_DST_XOR_PAT = 11,	//N
		ROP_NOTSRCCOPY = 12,		//N
		ROP_DSTINVERT = 13,		//N
		ROP_R2_NOTCOPYPEN = 14		//N
	} G2D_ROP_TYPE;

	typedef enum
	{
		G2D_OPERAND3_PAT, 
		G2D_OPERAND3_FG 
	} G2D_OPERAND3;
	
	typedef enum
	{
		G2D_NO_ALPHA_MODE,
		G2D_PP_ALPHA_SOURCE_MODE,
		G2D_ALPHA_MODE,
		G2D_FADING_MODE
	} G2D_ALPHA_BLENDING_MODE;
	
	typedef enum
	{
		G2D_BLACK = 0, G2D_RED = 1, G2D_GREEN = 2, G2D_BLUE = 3, G2D_WHITE = 4, 
		G2D_YELLOW = 5, G2D_CYAN = 6, G2D_MAGENTA = 7
	} G2D_COLOR;

typedef enum
{
	PAL1, PAL2, PAL4, PAL8,
	RGB8, ARGB8, RGB16, ARGB16, RGB18, RGB24, RGB30, ARGB24,
	YC420, YC422, // Non-interleave
	CRYCBY, CBYCRY, YCRYCB, YCBYCR, YUV444 // Interleave
} CSPACE;

typedef enum
{
	QCIF, CIF/*352x288*/, 
	QQVGA, QVGA, VGA, SVGA/*800x600*/, SXGA/*1280x1024*/, UXGA/*1600x1200*/, QXGA/*2048x1536*/,
	WVGA/*854x480*/, HD720/*1280x720*/, HD1080/*1920x1080*/
} IMG_SIZE;


typedef enum
{
	FLIP_NO, FLIP_X, FLIP_Y, FLIP_XY
} FLIP_DIR;

typedef enum
{
	ROT_0, ROT_90, ROT_180, ROT_270
} ROT_DEG;

class FIMGSE2D : public RegCtrlG2D
{
	private:
		BYTE	m_iROPMapper[G2D_NUM_SUPPORT_ROP];//	= { G2D_ROP_SRC_ONLY, G2D_ROP_PAT_ONLY, G2D_ROP_DST_ONLY,
//															G2D_ROP_SRC_OR_DST, G2D_ROP_SRC_OR_PAT, G2D_ROP_DST_OR_PAT,
//															G2D_ROP_SRC_AND_DST, G2D_ROP_SRC_AND_PAT, G2D_ROP_DST_AND_PAT,
//															G2D_ROP_SRC_XOR_DST, G2D_ROP_SRC_XOR_PAT, G2D_ROP_DST_XOR_PAT,
//															G2D_ROP_SRCINVERT, G2D_ROP_DSTINVERT, G2D_ROP_PATINVERT };
			
		DWORD  m_uFbStAddr;
		DWORD  m_uHoriRes; // Horizontal Resolution

		//  Max Window Size of clipping window
		DWORD  m_uMaxDx;
		DWORD  m_uMaxDy;

		// Coordinate (X, Y) of clipping window
		DWORD  m_uCwX1, m_uCwY1;
		DWORD  m_uCwX2, m_uCwY2;

		DWORD  m_uFgColor;
		DWORD  m_uBgColor;
		DWORD  m_uBlueScreenColor;
		DWORD  m_uColorVal[8];

		// Reference to Raster operation
		DWORD  m_uRopVal; // Raster operation value
		DWORD  m_uAlphaBlendMode;
		DWORD  m_uTransparentMode;
		DWORD  m_u3rdOprndSel;

		// Reference to alpha value
		DWORD  m_uFadingOffsetVal;
		DWORD  m_uAlphaVal;

		// Reference to image rotation
		DWORD  m_uRotOrgX, m_uRotOrgY;
		DWORD  m_uRotAngle;

		// reference to pattern of bitblt
		DWORD  m_uPatternOffsetX, m_uPatternOffsetY;

		DWORD  m_uBytes;

		BYTE   m_ucAlphaVal;
		bool m_bIsAlphaCall;
	
		// true: BitBlt enable in Host-To-Screen Font Drawing
		// false: BitBlt disable in Host-To-Screen Font Drawing	
		bool m_bIsBitBlt;

		DWORD m_uFontAddr;
		bool m_bIsScr2Scr;
	
		CSPACE m_eBpp;

		// N_24X24, B_24X24, N_16X16, T_8X16, N_8X8, N_8X15
		BYTE*  m_upFontType;
		DWORD  m_uFontWidth, m_uFontHeight;
	public:
		FIMGSE2D(); 
		virtual ~FIMGSE2D(); 
		// G2D Method		
		void Reset(void);
		void WaitForIdleStatus(void);
		bool WaitForFinish(void);
		void WaitForEmptyFifo();		

		void SetRopEtype(G2D_ROP_TYPE eRopType);
		void SetRopValue(DWORD uRopVal);

		void SetRotationOrgX(WORD usRotOrgX);
		void SetRotationOrgY(WORD usRotOrgY);	

		void SetAlphaMode(G2D_ALPHA_BLENDING_MODE eMode);		
		void SetAlphaValue(BYTE ucAlphaVal);
		void SetFadingValue(BYTE ucFadeVal);

		void EnablePlaneAlphaBlending(BYTE ucAlphaVal);
		void DisablePlaneAlphaBlending(void);

		void EnablePixelAlphaBlending(void); // Only Support 24bpp 
		void DisablePixelAlphaBlending(void); // Only Support 24bpp 

		void EnableFadding(BYTE ucFadingVal);
		void DisableFadding(void);
	
		void PutPixelEcolor(DWORD uPosX, DWORD uPosY, G2D_COLOR eColor);
		void PutPixel(DWORD uPosX, DWORD uPosY, DWORD uColor);

		void PutLine(DWORD uPosX1, DWORD uPosY1, DWORD uPosX2, DWORD uPosY2, DWORD uColor, bool bIsDrawLastPoint);

		void BitBlt(WORD uSrcStX, WORD uSrcStY, WORD uSrcEndX, WORD uSrcEndY,	WORD uDstStX, WORD uDstStY, WORD uDstEndX, WORD uDstEndY);
		void StretchBlt(WORD uSrcStX, WORD uSrcStY, WORD uSrcEndX, WORD uSrcEndY,	WORD uDstStX, WORD uDstStY, WORD uDstEndX, WORD uDstEndY);	// Spec out.	
		void BitBlt(GPEBltParms *pBltParms);
		void FillRect(DWORD uDstStX, DWORD uDstStY, DWORD uDstEndX, DWORD uDstEndY, DWORD uColor);

		void RotateImage(WORD usSrcX1, WORD usSrcY1, WORD usSrcX2, WORD usSrcY2,	WORD usDestX1, WORD usDestY1, ROT_DEG eRotDegree);

		void RotateWithBitBlt(WORD usSrcX1, WORD usSrcY1, WORD usSrcX2, WORD usSrcY2,	WORD usDestX1, WORD usDestY1, ROT_DEG eRotDegree);

		void SetTransparentMode(bool bIsTransparent, G2D_COLOR eBsColor);
		void SetTransparentMode(bool bIsTransparent, DWORD uBsColor);

		void SetColorKeyOn(G2D_COLOR eColor);
		void SetColorKeyOn(DWORD uColorKey);
		void SetColorKeyOff(void);

		void RegisterPattern(WORD* uspPattern);
		void SetPatternOffset(BYTE ucPatOffsetX, BYTE ucPatOffsetY);
		void SetPatternOffsetX(BYTE ucPatOffsetX);
		void SetPatternOffsetY(BYTE ucPatOffsetY);

		void Set3rdOperand(G2D_OPERAND3 e3rdOp);
		void SetFgEcolor(G2D_COLOR eFgColor);
		void SetFgColor(DWORD uFgColor);
		void SetBgEcolor(G2D_COLOR eBgColor);
		void SetBgColor(DWORD uBgColor);
		void SetBsColor(DWORD uBsColor);		
		void SetColorMode(CSPACE eBpp);

		void InitSetting(DWORD uFbStAddr, CSPACE eBpp, DWORD uCwMaxHSz, DWORD uCwMaxVSz, DWORD uX1_Cw, DWORD uY1_Cw, DWORD uX2_Cw, DWORD uY2_Cw);
		// Reference to font
		void SetFontColor(G2D_COLOR eFontColor, G2D_COLOR eBgColor, bool bIsTransparent);
		void SetFontColor(DWORD uFontColor, DWORD uBgColor, bool bIsTransparent);
		void Printf(DWORD uPosX, DWORD uPosY, const char* cpFmt, ...);
		void GetFbAddr(DWORD *uG2dFbAddr);
		void SetFbAddr(DWORD uFbAddr);	
		void SetHoriRes(DWORD horires);
	protected:
		void SetXYIncrFormat(DWORD uDividend, DWORD uDivisor, DWORD* uResult);
		void CheckFifo(DWORD uEmptyFifo);	

	
		void GetRotationOrgXY(WORD usSrcX1, WORD usSrcY1, WORD usSrcX2, WORD usSrcY2,	WORD usDestX1, WORD usDestY1, ROT_DEG eRotDegree, WORD* usOrgX, WORD* usOrgY);

		void DisableEffect(void);

		void InitColor(CSPACE eBpp);

		void SetRotationMode(DWORD uRotationType);
		void SetRotationOrg(WORD usRotOrgX, WORD usRotOrgY);
		void SetClippingWindow(DWORD uLeftTopX, DWORD uLeftTopY, DWORD uRightBottomX, DWORD uRightBottomY);
		void SetMaxScreen(DWORD uMaxX, DWORD uMaxY);
		void SetPatternMemory(DWORD uCoordX, DWORD uCoordY, WORD usColor);
		void GetPatternMemory(DWORD uCoordX, DWORD uCoordY, WORD *usColor);
		void SetCoordinateDrawingText(DWORD uStartX, DWORD uStartY, DWORD uEndX, DWORD uEndY);
		void SetFirstText(DWORD uFirstText);
		void SetNextText(DWORD uNextText);
		void SetCMDR7(DWORD uTestDrawingFbAddr);
		


		void FillMemoryForTextDrawing(DWORD uFontType, DWORD uTextDrawingFbAddr);
		void SetCoordinateSrcBlock(DWORD uStartX, DWORD uStartY, DWORD uEndX, DWORD uEndY);
		void SetCoordinateDstBlock(DWORD uStartX, DWORD uStartY, DWORD uEndX, DWORD uEndY);
		void SetFirstBitBLTData(DWORD uFirstData);
		void  SetNextBitBLTData(DWORD uNextData);
		void SetStencilKey(DWORD uIsColorKeyOn, DWORD uIsInverseOn, DWORD uIsSwapOn);
		void SetStencilMinMax(DWORD uRedMin, DWORD uRedMax, DWORD uGreenMin, DWORD uGreenMax, DWORD uBlueMin, DWORD uBlueMax);
		void GetFrmSz(DWORD *uG2dWidth, DWORD *uG2dHeight);

		void GetBppMode(CSPACE *eBpp);
		void SetColorExpansionMethod(bool bIsScr2Scr);

		void SetFontAddr(DWORD uFontAddr);
		void SetFontType(DWORD uFontType, DWORD *uFontWidth, DWORD *uFontHeight);		
		void PutString(DWORD uPosX, DWORD uPosY, char* cStr);		
		
		void InterruptEnable(void);
		void InterruptDisable(void);
		void InterruptPendingClear(void);		

		void RopOperation(bool bSrcData, bool bDstData, bool bThirdData, BYTE ucRopVal, bool *bOut);
		void RopOut(DWORD uSrcData, DWORD uDstData, DWORD uThirdData, BYTE ucRopVal, CSPACE eBpp, DWORD *uRopOut);
		void ConvertEcolorToRaw(G2D_COLOR eColor, DWORD *uRawColor) ;
		void GetFbData(DWORD uX, DWORD uY, DWORD uG2dWidth, DWORD uG2dFbAddr, CSPACE eBpp, DWORD *uFbData);
		void SetFbData(DWORD uX, DWORD uY, DWORD uG2dWidth, DWORD uG2dFbAddr, CSPACE eBpp, DWORD uFbData);
		void GetPatternOffset(BYTE *ucPatOffsetX, BYTE *ucPatOffsetY);

		void ConvertPatternToRaw(WORD uThirdDataOrg, CSPACE eBpp, DWORD *uThirdDataConverted);
		void BlendingOut(DWORD uSrcData, DWORD uDstData, BYTE ucAlphaVal, bool bFading, BYTE ucFadingOffset, DWORD *uBlendingOut);
		void Convert24bpp(DWORD uSrcData, CSPACE eBpp, bool bSwap, DWORD *uConvertedData);
		void SetEndian(bool bEndian);
		void SetReadSize(BYTE ucReadSize);
		void GetRotateCoordinate(DWORD uDstX, DWORD uDstY, DWORD uOrgX, DWORD uOrgY, DWORD uRType, DWORD *uRsltX, DWORD *uRsltY);

		void IntEnableForDeEngineFinish(void);
		void IntEnableForCmdFinish(void);
		void IntEnableForOverflow(bool bFifo, BYTE ucFifoLevel);	
		void InterruptDisAll(void);
};

#endif

⌨️ 快捷键说明

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