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

📄 mbxmain.h

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 H
字号:
/***************************************************************************
 * Name        : mbxmain.h
 * Title       : MBX WinCE driver GPE class header
 * Author(s)   : Imagination Technologies
 * Created	   : 2nd January 2003
 *
 * Copyright   : 2003 by Imagination Technologies. All rights reserved.
 *             : No part of this software, either material or conceptual 
 *             : may be copied or distributed, transmitted, transcribed,
 *             : stored in a retrieval system or translated into any 
 *             : human or computer language in any form by any means,
 *             : electronic, mechanical, manual or other-wise, or 
 *             : disclosed to third parties without the express written
 *             : permission of Imagination Technologies Limited, Unit 8,
 *             : HomePark Industrial Estate, King's Langley, Hertfordshire,
 *             : WD4 8LZ, U.K.
 *
 * Description : MBX WinCE driver GPE class.
 *
 * Platform    : WinCE
 *
 * Modifications:-
 * $Log: mbxmain.h $
 * y
 * added coarse grain sync.
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 ****************************************************************************/

#pragma once

#include "drvescape.h"
#include "winresman.h"

#if (gdwCPRN148HwFix == 0)
#define MAX_BRUSH_SIZE 31
#else
#define MAX_BRUSH_SIZE 32
#endif

#define MAX_SP_ENTRIES	20



enum BLTSTATE
{
	BLT_Idle = 0,
	BLT_Setup,
	BLT_InProgress,		/* 1 to 3 clip regions processed */
	BLT_InContProgress,	/* after a batch of 4 clip regions processed */
	BLT_Complete,
	BLT_Verify,
	BLT_Terminate
};


#if defined (ROTATE_ENABLE)
class MBXSurf : public GPESurfRotate
#else
class MBXSurf : public GPESurf
#endif
{
private:
    MemNode       * m_pclMemNode;
public:
					MBXSurf(INT nWidth, INT nHeight, INT nStride, EGPEFormat eFormat, MemNode *pclNode, LONG m_lRotate);
					MBXSurf(int nWidth, int nHeight, void *pvBits, int nStride, EGPEFormat eFormat);
	virtual			~MBXSurf(void);
	ULONG			GetFreeVideoMem ();
	ULONG			GetPhysAddr () {return m_pclMemNode->m_psDevMemHandle->uiDevAddr.uiAddr;}
	PVRSRV_MEM_INFO *GetMemInfo() {return m_pclMemNode->m_psDevMemHandle;}
	void			SetBuffer (ADDRESS pvAddr) { m_pVirtAddr = pvAddr;}
	void			SetStride(LONG lStride) {m_nStrideBytes = lStride;}
	void			SetSize(INT nWidth, INT nHeight) { m_nWidth = nWidth; m_nHeight = nHeight;}

#if defined (INCLUDE_DXHAL)
	void			SetMemNode(MemNode *psMem) { m_pclMemNode = psMem;}
#endif /* INCLUDE_DXHAL */

	BOOL			IsRotate();
	BOOL			m_bIsRotated;
	BOOL			m_lRotationAngle; // Surface rotation Angle in degrees

};



#if defined (ROTATE_ENABLE)
class MBX : public GPERotate
#else
class MBX : public GPE
#endif
{
private:

	GPEMode			m_sModeInfo;
	PBYTE			m_pbyFBPhysBase;
	ULONG			m_ulScanLineLength;
	ULONG			m_ulPhysicalScreenX;
	ULONG			m_ulPhysicalScreenY;
	ULONG			m_ulColorDepth;
	
	LONG			m_lVisibleX;
	LONG			m_lVisibleY;

	DevMemNode		m_cl2DMemNodes;

	/* Coarse grain sync members */
	BOOL				m_bPrimaryLocked;
	BOOL				m_bHardwareUsed;
	PVRSRV_QUEUE_INFO	*m_pQueueInfo;

#ifdef USE_SW_CURSOR
	BOOL			m_bCursorDisabled;
	BOOL			m_bCursorVisible;
	BOOL			m_bCursorForcedOff;
	RECTL			m_sCursorRect;
#endif
	POINTL			m_sCursorSize;
	POINTL			m_sCursorHotspot;

	/* allocate enough backing store for a 64x64 cursor on a 32bpp (4 bytes per pixel) screen */
	BYTE			m_byCursorBackingStore[64 * 64 * 4];
	BYTE			m_byCursorXorShape[64 * 64];
	BYTE			m_byCursorAndShape[64 * 64];

	BYTE			m_bySolidLineRop;
#ifdef SW_SIM
	BOOL			m_bDoProcessBltData;
#endif

	PVRSRV_DEV_DATA m_sDevData;

	ULONG			m_ulPixelTableFormats[4];

#ifdef DEBUG
	BOOL			m_bPunt;
#endif /* #ifdef DEBUG */

	/* acceleration members */
	ULONG			m_ulSurfsPresent;
	BLTSTATE		m_eHWBltState;

#ifdef CACHE_SURFACES
	MBX1_2DSTATE	m_s2DContext;
#endif

	/* palettes */
	PALINFO			m_sPaletteInfo;

	/* VidMem allocs for various uses : */
	BYTE			*m_pbyPatternFBMem;
	ULONG			m_ulPatternFBMemPhys;
	ULONG			m_ulPatternBufSize;
	
	ULONG			m_ulDstHWFormat;
	
	ULONG			m_ulXFPStretch;
	ULONG			m_ulYFPStretch;
	
#ifdef ROTATE_ENABLE
	LONG			m_lPrimaryRotation;		// Rotation applied to primary surface in degrees
	ULONG			m_PhysDestWidth;		// Unrotated destination surface width
	ULONG			m_PhysDestHeight;		// Unrotated destination surface height
	BOOL			m_bDisableDynScrnRotation;
	LONG			m_lRotationRemap;		// Logical to physical remap of rotation in degrees.

	BOOL			m_bMapToUnrotated;

#if defined (_WINCEOSVER) && (_WINCEOSVER < 500)
	// Bug fix for Microsoft's gpe code (WinCE 4.2) that tries to make a duplicate copy of our alloc.
	void*			m_pvMostRecentAllocSurfaceAddr;			// Bug fix for WinCE 4.2
	MBXSurf*		m_psMostRecentMBXSurf;
#endif /* (_WINCEOSVER < 500) */

#endif /* ROTATE_ENABLE */

	ULONG			m_ulBltRotationHw;		// Rotation applied to the current blt as a hardware bitmask (not degrees)

	BOOL			m_bXPositive;
	BOOL			m_bYPositive;

#ifdef SUPPORT_POWER_STATE
	VIDEO_POWER_STATE m_ePowerState;
#endif

	PDP_EnumerateModesList m_sEnumerateModesList;

	BOOL			m_bForceSyncWithHost;

	/* used by various Sync Blts */
	CALLBACKS		m_sCallbacks;

	/* Sync required if MBX blit done */
	BOOL			m_bMBXBltActioned;

	/* FB alloc strategy settings */
	ULONG			m_ulReqFBStrategy;
	ULONG			m_ulPrefFBStrategy;

	/* Blit direction */
	BOOL			m_bSlavePortAquired;

	/* FullScreen Flag */
	BOOL			m_bForceSecondaryExtFullscreen;
	IMG_UINT32		m_ui32SecondaryRotationAngle;
	BOOL			m_bDualScreenIfaceLocked;

#ifndef DEBUG
	/* exception handler counters */
	ULONG			m_ulEmulatedBltExceptions;
	ULONG			m_ulEmulatedBltRotateExceptions;
#endif

	/* GAPI Legacy surface */
	MemNode		*	m_pclGAPIMemNode;
	IMG_UINT32		m_ui32GapiPhysWidth;
	IMG_UINT32		m_ui32GapiPhysHeight;
	IMG_UINT32		m_ui32GapiPhysStride;

	/* slaveport batch members */
	ULONG			m_ulSlavePortIdx;
	ULONG			m_ulaSlavePort[MAX_SP_ENTRIES];


public:
	GPEDisplayPipe	m_clDisplay;
	SURFSTATE		m_eSecondarySurfaceState;
	MBXSurf			*m_pclSecondarySurface;
	WORD			m_wSecondSurfWidth;
	WORD			m_wSecondSurfHeight;
	WORD			m_wSecondSurfStride;
	WORD			m_wSecondSurfBPP;
	PVRSRV_MEM_INFO	*m_psSecondaryMemInfo;

	BOOL			m_ulBufferIdx;
	ULONG			m_ulStrideBufSig;
	ULONG			m_ulStripeSize;
	BYTE			*m_pbyStripeLinBase;
	ULONG			m_ulStripePhyBase;

	ULONG			m_ulMaskBufPhys;
	ULONG			*m_pulMaskBufLin;
	ULONG           m_ulMaskBufferSize;

	SCODE			(GPE::*m_pfnSWBlt)(GPEBltParms *);
#if HW_VERIFY
	CHWVerify		m_clHwVer;
	SCODE			(GPE::*m_pfnHWBlt)(GPEBltParms *);
#endif

#ifdef ENABLE_2D_PROFILE
	LOCAL_PNODE		m_sActiveNode;
#endif

#ifdef DRV_VERIFIABLE
	DRV_VERIFY		m_sDrvVerify;
#endif

#ifdef LOCAL_MEMORY_SELF_REFRESH
	CRITICAL_SECTION m_LocalMemoryCS;	// Critical Section for display refresh functions
#endif

private:
#ifdef SUPPORT_M24VA
	DWORD		AcquireM24VA(DRVESC_M24VA_ACQUIRE_PARAMS *pAcquire);

	HANDLE		m_hProcessMonitorThread;
	HANDLE		m_hM24VAOwner;				/* Process ID of M24VA owner */
	HANDLE		m_hTerminateMonitorThread;	/* Used to signal to montior thread termination requires */

	BOOL		m_bOverlayUsed;				/* Overlay used while m24va in use */
#endif

	/* Resman functionsand data  */
	RESMAN_MON_THREAD_PARAMS m_sMonitorThread;

	DWORD		ResManStopThread();
	DWORD		ResManStartThread();
	DWORD		ResManTermintateProcessRequest(DRVESC_RESMAN_THREAD_TERMINATED_PARAMS	*psResManThreadTerminated);
	DWORD		ResManConnectProcess();

	IMG_BOOL	ResManSendCommand(PMC eCommand, HANDLE hCmdParam);


public:
	MBX(void);
	virtual ~MBX();
	virtual INT		NumModes(void);
	virtual SCODE	SetMode(INT nModeId, HPALETTE *hPalette);
	virtual INT		InVBlank(void);
	virtual SCODE	SetPalette(const PALETTEENTRY *psSource, USHORT usFirstEntry, USHORT usNumEntries);
	virtual SCODE	GetModeInfo(GPEMode *pclMode, INT nModeNumber);
	virtual void	WaitForNotBusy(void);
	virtual INT		IsBusy(void);
	virtual void	GetPhysicalVideoMemory(PULONG pulPhysicalMemoryBase, PULONG pulVideoMemorySize);
	virtual SCODE	Line(GPELineParms *psLineParameters, EGPEPhase phase);
	virtual SCODE	BltPrepare(GPEBltParms *psBlitParameters);
	virtual SCODE	BltComplete(GPEBltParms *psBlitParameters);
	virtual ULONG	GetGraphicsCaps();
	virtual ULONG	DrvEscape(SURFOBJ *pso, ULONG ulEsc, ULONG ulSizeIn, PVOID pvIn, ULONG ulSizeOut, PVOID pvOut);
#ifdef SUPPORT_POWER_STATE
	virtual void	PowerHandler(BOOL bOff);
#endif

	SCODE			WrappedEmulatedLine (GPELineParms *pclLineParameters);
	virtual BOOL	ContrastControl ( ULONG ulCmd, ULONG	*pulValue );

	BOOL			GetDisplayInfo(PPVR_DISPLAYINFO psDisplayInfo);
	int				ScreenStride() { return m_ulScanLineLength; }

	int				ScreenFrequency() { return m_sModeInfo.frequency; }

	int				ScreenBitDepth() { return m_ulColorDepth; }

	void *			GetPrimaryBuffer() {return (PrimarySurface()->Buffer()); }

	PULONG			GetPixelTableMasks() { return ((PULONG)&m_ulPixelTableFormats); }

	void			GetDisplayModeMasks (PULONG pulRedMask, PULONG pulGreenMask, PULONG pulBlueMask, PULONG pulAlphaMask);

	void			SyncWithHost(void);

#ifdef SUPPORT_POWER_STATE
	/* power.cpp */
	BOOL			SetPowerState(VIDEO_POWER_STATE vps);
	BOOL			SetPowerState(CEDEVICE_POWER_STATE NewDx);
	CEDEVICE_POWER_STATE GetPowerState();
	void			GPE_Power(PVR_POWER_STATE eState, ULONG ulFlags);
#endif

	/* surf.cpp */
	virtual SCODE	AllocSurface(GPESurf **surface, INT nWidth, INT nHeight, EGPEFormat eFormat, INT nSurfaceFlags);

	/* mode.cpp */
	BOOL			PrimarySurfaceSetMode( INT nModeId );
	BOOL			InitializeModes(void);
	BOOL			DeInitializeModes(void);
	void			ProfileVidMemBlts(void);
	ULONG			DoTestBlt (ULONG ulDstPhysBase, ULONG ulSrcPhysBase, ULONG ulSize, ULONG ulRot, PVRSRV_MEM_INFO *psCallbackHandle);

	/*init.cpp */
	BOOL			FindDevice(void);
	BOOL			InitializeHardware(void);
	BOOL			DeInitializeHardware(void);

	/* memory.cpp */
	LPVOID			VideoAlloc( ULONG ulBytes, ULONG ulAlignment, ULONG *pui32PhysAddr );
	VOID			VideoFree( LPVOID pMem );

	/* cursor.cpp */
	SCODE			SetPointerShape(GPESurf *pclMask, GPESurf *pclColorSurface,
									INT nHotX, INT nHotY, INT nX, INT nY);
	SCODE			MovePointer(INT nPositionX, INT nPositionY);
	void			CursorOn (void);
	void			CursorOff (void);
#ifndef SUPPORT_KYRO_AS_MBX_DEVICE
	void			MoveVisiblePort (LONG lX, LONG lY);
#endif

	/* spfuncs.cpp */
	ULONG			OverlapTest( GPEBltParms *pParms );
	BOOL			SetDstSurf( GPEBltParms *pParms );
	BOOL			SetDstSurf( GPELineParms *lineParams );
	BOOL			SetMBXPalette (	GPEBltParms *pParms,
									EGPEFormat  eSrcFormat,
									PALETTE_TYPE ePalType );

	BOOL			SetPatSurf( GPEBltParms *pParms );
	void			SetMaskSurf( GPEBltParms *pParms );
	BOOL			CanCreateMaskSurf( GPEBltParms *pParms );
	VOID			SetPatHotspot(GPEBltParms *pParms );
	BOOL			CheckSrcPalette(GPEBltParms *psParms);
	VOID			WriteDestRect(MBXSurf *pSurf, RECTL *prclDst);
	VOID			WriteClipRect(MBXSurf *pSurf, RECTL *prclClip);
	void			SlavePortInitWrites(void);
	void			SlavePortWrite(ULONG ulValue);
	void			SlavePortFlushWrites(void);
	void			SlavePortFencedWrites(void);

	/* rotate.cpp */
#ifdef ROTATE_ENABLE
	void			UnRotate(RECTL* prcRect, MBXSurf *pSurf);
	int				GetRotateModeFromReg();
	void			SetRotateParams();
	LONG			DynRotate(INT nAngle);
	LONG			LogicalToPhysRotDegrees(LONG lDegreesLogical);
	LONG			PhysToLogicalRotDegrees(LONG lDegreesPhys);
	int				LogicalToPhysRotEnum(int iRotEnumLogical);
	int				PhysToLogicalRotEnum(int iRotEnumPhys);
	int				DegreesToRotEnum(LONG lDegrees);
#endif

	/*******************************************************
	 *
	 *	 acceleration functions
	 *
	 ******************************************************/

	/* bltfuncs.cpp */

	BOOL			PrepareHardwareBlt ( GPEBltParms *psBlitParameters);
	SCODE			CompleteHWBlt ( GPEBltParms *psBlitParameters);

	SCODE			TextBlt ( GPEBltParms *pParms );
	SCODE			AATextBlt ( GPEBltParms *pParms );
	SCODE			FillBlt ( GPEBltParms *pParms );
	SCODE			PatBlt ( GPEBltParms *pParms );
	SCODE			SrcBlt ( GPEBltParms *pParms );
	SCODE			SrcPatBlt ( GPEBltParms *pParms );
	SCODE			HwVerBlt ( GPEBltParms *psParms );
	SCODE			StripedSrcBlt ( GPEBltParms *pParms );

	IMG_VOID		SurfaceUpdateBlit (IMG_UINT32 ui32PhysAddress, IMG_UINT32 ui32Value);

#ifdef LOCAL_MEMORY_SELF_REFRESH
	// Functions to allow us to signal local memory use
	SCODE			WrappedEmulatedBlt ( GPEBltParms *psParms );
	SCODE			WrappedEmulatedBltRotate ( GPEBltParms *psParms );
#endif //LOCAL_MEMORY_SELF_REFRESH
#ifndef DEBUG
	/* exception handled punt functions */
	SCODE			TryEmulatedBlt ( GPEBltParms *psParms );
	SCODE			TryEmulatedBltRotate ( GPEBltParms *psParms );
#endif

	/* line.cpp */
	SCODE			AcceleratedSolidLine (GPELineParms *pLineParms);

	//////////////////////////
	// GAPI functions
	//////////////////////////
	BOOL AllocGAPISurf(EGPEFormat eFormat);
	void SaveGapiSurf();
	void RestoreGapiSurf();
	void GapiGetGxInfo (GXDeviceInfo *pgxoi);
	void GapiDmaVRAMtoDRAM (DRVESC_GXDMA *pGxDmaInfo);
	void GapiDmaDRAMtoVRAM (DRVESC_GXDMA *pGxDmaInfo);
	void GapiIsDMAReady (DRVESC_GXDMA *pGxDmaInfo);
	void GapiScaleBlt (PGAPI_BLT pBlt);
	void GapiScaleBltSP (PGAPI_BLT pBlt);
	void GapiScaleBltCPU (PGAPI_BLT pBlt);
	void GapiScaleBltStripeBuf (PGAPI_BLT pBlt);
	#if defined(GETRAWFRAMEBUFFER) || defined (OSV_PPC)
	void GapiGetRawFramebuffer (RawFrameBufferInfo *pRawInfo); // gxinfo.h (latest PPC version)
	#endif
};

/*****************************************************************************
 FUNCTION	:	CopyRect
 PURPOSE	:	Copies common types of a rectangle
 PARAMETERS	:	psSrc and psDst are overloaded for types RECTL and RECT.
 RETURN		:	void
	
		The assumption is that RECTL and RECT have identical member
		type, names, ordering and field sizes.
		The same assumption is made in Microsoft sample code.
		BUT... if Microsoft ever change it then this (and the whole universe) will break.

*****************************************************************************/
__forceinline void CopyRect (RECTL* psSrc, RECT* psDst)
{
	ASSERT(sizeof(RECT) == sizeof(RECTL));
	memcpy(psDst,psSrc,sizeof(RECTL));
}
__forceinline void CopyRect (RECT* psSrc, RECT* psDst)
{
	memcpy(psDst,psSrc,sizeof(RECT));
}
__forceinline void CopyRect (RECT* psSrc, RECTL* psDst)
{
	ASSERT(sizeof(RECT) == sizeof(RECTL));
	memcpy(psDst,psSrc,sizeof(RECTL));
}
__forceinline void CopyRect (RECTL* psSrc, RECTL* psDst)
{
	memcpy(psDst,psSrc,sizeof(RECTL));
}


/********************************** end of file ******************************/

⌨️ 快捷键说明

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