📄 ddipu_sdc.h
字号:
//------------------------------------------------------------------------------
//
// Copyright (C) 2004-2005, MOTOROLA, INC. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// MOTOROLA, INC.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//
// File: ddipu_sdc.h
//
// IPU DirectDrawdisplay class header
//
//------------------------------------------------------------------------------
#ifndef __DDIPU_SDC_H__
#define __DDIPU_SDC_H__
//------------------------------------------------------------------------------
// Defines
#define VIDEO_REG_PATH TEXT("Drivers\\Display\\DDIPU_SDC")
#define VIDEO_ROW_RES TEXT("CxScreen")
#define VIDEO_COL_RES TEXT("CyScreen")
#define PIXEL_DEPTH TEXT("Bpp")
#define PANEL_TYPE TEXT("PanelType")
#define TV_SUPPORT TEXT("TVSupported")
#define SUPPORTED_PANEL_TYPES TEXT("SupportedPanelTypes")
#define DISPLAY_ROTATION TEXT("System\\GDI\\Rotation")
#define VIDEO_MEM_SIZE TEXT("VideoMemSize")
#define DEFAULT_VIDEO_MEM_SIZE (1024*1024) // 1M bytes for default video RAM size
#define MAX_BUSY_RETRY (5)
#define MAX_NUM_MODES 3
//--------------------------------------------------------
// DrvEscape return codes
//--------------------------------------------------------
#define ESC_FAILED (-1)
#define ESC_NOT_SUPPORTED (0)
#define ESC_SUCCESS (1)
#ifndef PLAT_WPC
#ifndef PLAT_SMARTPHONE
//--------------------------------------------------------
// FOURCC codes supported
//--------------------------------------------------------
#define MAKE_FOURCC( ch0, ch1, ch2, ch3 ) \
( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \
( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
/* packed formats */
#define FOURCC_YUY2 MAKE_FOURCC('Y','U','Y','2')
/* planar formats */
#define FOURCC_YV12 MAKE_FOURCC('Y','V','1','2')
#define FOURCC_YUV12 FOURCC_YV12
// Define Custom pixel formats
enum EDDGPEPixelFormat_extension
{
ddgpePixelFormat_YV12 = ddgpePixelFormat_CustomFormat,
};
#endif // #ifdef PLAT_SMARTPHONE
#endif // #ifdef PLAT_WPC
//------------------------------------------------------------------------------
// Types
typedef enum displayMode
{
DISPLAY_240x320x16bpp_default, // QVGA display mode
//DISPLAY_240x320x8bpp, //currently not supported
//DISPLAY_240x320x18bpp, //currently not supported
//DISPLAY_240x320x32bpp, //currently not supported
DISPLAY_640x480x16bpp, // VGA display mode
DISPLAY_720x480x16bpp, // NTSC TV mode
numModes, // This enum should be ended by numModes
}displayMode_c;
typedef enum displayPanel
{
DISPLAY_SHARP_LQ035Q7DB02, // QVGA display
DISPLAY_NEC_NL6448BC20, // QVGA display
numPanels, // This enum should be ended by numPanels
}displayPanel_c;
#define DISPLAY_PANEL_DEFAULT DISPLAY_SHARP_LQ035Q7DB02
typedef struct overlaySurf{
BOOL isOverlayWindowRunning;
UINT32 nBufPhysicalAddr;
// Overlay features
UINT16 Width;
UINT16 Height;
UINT16 WidthHw;
UINT16 HeightHw;
RECT SrcRect;
UINT16 LineStride;
UINT16 XOffset;
UINT16 YOffset;
UINT16 Bpp;
UINT16 Transparency; // 255 indicate totally transparent, ie. not displayed on LCD screen
// 0 indicate totally opaque, ie. overlay on LCD screen
BOOL isUpsideDown;
UINT32 ColorKeyMask; // 0 indicate no color key is used
UINT32 ColorKeyPlane;
}overlaySurf_t, *pOverlaySurf_t;
typedef enum PPConfiguration{
PPConfiguration_Overlay, // Configured for video overlay
PPConfiguration_TV, // Configured for TV output UI processing
PPConfiguration_None,
} PPConfiguration_c;
typedef struct PPOverlayOpDataStruct{
ppConfigData configData;
ppBuffers bufs;
}ppOverlayOpData, *pPpOverlayOpData;
//------------------------------------------------------------------------------
// Functions
class DDIPU_SDCSurf;
class DDIPU_SDC : public DDGPE
{
protected:
LPVOID m_pVideoMemory; // Virtual Address of the video memory
HANDLE m_hLAWMapping; // Handle for file mapping
ULONG m_nLAWPhysical; // Physical Linear Access Window (LAW) address
PUCHAR m_pLAW; // Mapped Linear Access Window (LAW) address
ULONG m_nVideoMemorySize; // Size in bytes of actual video RAM total
SurfaceHeap *m_pVideoMemoryHeap; // Base entry representing all video memory
GPEModeEx m_ModeInfoEx; // local mode info
DDGPESurf *m_pVisibleOverlay; // Visible overlay surface
DWORD m_dwPanelType; // LCD Panel identifier
PANEL_INFO *m_CurrentPanel; // Panel Information
GPEMode *m_SupportedModes; // Array of supported modes
RECT m_rcWorkRect;
BOOL m_bSetMode;
UINT m_nScreenBpp;
ULONG m_nScreenStride; // byte count of a single scan line
ULONG m_nSurfacePixelAlign; // Surface Pixel alignments
private:
// For Graphic window (overlay)
pOverlaySurf_t m_pOverlaySurfaceOp;
// Synchronization when changing modes
CRITICAL_SECTION m_csDrawLock;
// For Post-processing
HANDLE m_hPP; // Handle to Post-processor driver
HANDLE m_hPPEOFEvent; // EOF event handle for PP
ppConfigData m_ppData_Overlay; // Configuration data for PP for Overlay
BOOL m_bOverlayConfiggedForTV; // Boolean that tells whether the m_ppData_Overlay
// is configured for LCD or TV mode.
DDIPU_SDCSurf *m_pPpOverlaySurface1; // Temp surface used in PP
DDIPU_SDCSurf *m_pPpOverlaySurface2; // Temp surface used in PP
BOOL m_bPPBusy; // boolean to control access to PP
CRITICAL_SECTION m_csPPLock; // Critical section for PP
PPConfiguration_c m_PPConfiguration; // Describes how PP is currently configured
UINT32 m_iLastOverlayUpdateTime; // Used to measure interval since overlay was updated
HANDLE m_hPPOverlayThread; // Thread to handle PP operations
HANDLE m_hWritePPOverlayQueue; // Write handle to PP overlay queue
HANDLE m_hReadPPOverlayQueue; // Read handle to PP overlay queue
CRITICAL_SECTION m_csOverlayShutdown; // Synchronization for shutting down overlays
// For TV-out mode
BOOL m_bTVSupported;
BOOL m_bTVNTSCOut;
BOOL m_bTVModeActive; // is TV out mode active?
DDIPU_SDCSurf *m_pTVBuffer1; // Surface for TV mode UI output
HANDLE m_hSDCBGEOFEvent; // Event for SDC BG EOF
HANDLE m_hTVUpdateRequest; // Event to request TV buffer update
DirtyRect *m_pDirtyRect; // TV Dirty Rectangle object
CRITICAL_SECTION m_csDirtyRect; // Critical section for Dirty Rectangle
UINT32 m_iNumDirtyRegions;
HANDLE m_hTVUpdateThread; // Thread to update TV buffer
ppConfigData m_ppData_TV; // Configuration data for PP for TV
// For software cursor
BOOL m_CursorDisabled;
BOOL m_CursorVisible;
BOOL m_CursorForcedOff;
RECTL m_CursorRect;
POINTL m_CursorSize;
POINTL m_CursorHotspot;
// allocate enough backing store for a 64x64 cursor on a 32bpp (4 bytes per pixel) screen
UCHAR m_CursorBackingStore[64 * 64 * 4];
UCHAR m_CursorXorShape[64 * 64];
UCHAR m_CursorAndShape[64 * 64];
// For power handling
CEDEVICE_POWER_STATE m_Dx; // Current device state
TCHAR m_szDevName[MAX_PATH]; // Device name
TCHAR m_szGuidClass[MAX_PATH]; // Class GUID
private:
// ddipu_sdc_power.cpp
VOID SetDisplayPower(CEDEVICE_POWER_STATE dx); // display hardware power control function
#ifdef PLAT_PMC
static BOOL CallSetDisplayPower(PVOID handle, CEDEVICE_POWER_STATE cspDx, CEDEVICE_POWER_STATE cspCurrectDx);
#endif
VIDEO_POWER_STATE PmToVideoPowerState(CEDEVICE_POWER_STATE dx); // video power state to Power Manager device power state conversion functions
CEDEVICE_POWER_STATE VideoToPmPowerState(VIDEO_POWER_STATE vps);
BOOL ConvertStringToGuid(LPCTSTR pszGuid, GUID *pGuid); // String to GUID conversion function
BOOL AdvertisePowerInterface(HMODULE hInst);
// ddipu_sdc_overlay.cpp
static void PPOverlayThread(LPVOID lpParameter);
void PPOverlayRoutine(void);
void SetPPConfigForOverlay(DDGPESurf * pSurf);
void OverlayWindowSetup(void);
void SetupOverlayPosition(pOverlaySurf_t pOverlaySurf, LONG x, LONG Y);
// ddipu_sdc_misc.cpp
BOOL GetTVModeSupportFromRegistry(VOID);
DWORD GetPanelTypeFromRegistry(VOID);
BOOL GetVMemSizeFromRegistry(VOID);
VOID LoadFreescaleLogo(GPESurf * pSurf);
VOID LoadFreescaleLogo(VOID *pFramePointer);
// ddipu_sdc.cpp
BOOL Init(VOID);
BOOL InitHardware(VOID);
BOOL SetupVideoMemory(VOID);
VOID Cleanup(VOID);
// ddipu_sdc_tv.cpp
static void TVUpdateThread(LPVOID lpParameter);
void TVUpdateRoutine(void);
void TVUpdateBuffer(void);
void SetPPConfigForTV(RECT srcRect);
public:
// ddipu_sdc.cpp
DDIPU_SDC(BOOL *pbRet);
~DDIPU_SDC(VOID);
SCODE SetMode(int modeId, HPALETTE *pPalette);
SCODE GetModeInfo(GPEMode *pMode, int modeNo);
SCODE GetModeInfoEx(GPEModeEx *pModeEx, int modeNo);
int NumModes(VOID);
VOID GetPhysicalVideoMemory(PULONG pPhysicalMemoryBase, PULONG pVideoMemorySize);
int GetBpp(VOID);
// ddipu_sdc_line.cpp
SCODE Line(GPELineParms *pLineParms, EGPEPhase phase);
SCODE WrappedEmulatedLine(GPELineParms *pLineParms);
// ddipu_sdc_blt.cpp
SCODE BltPrepare(GPEBltParms *pBltParms);
SCODE WrapEmulatedBlt(GPEBltParms *pBltParms);
SCODE BltComplete(GPEBltParms *pBltParms);
// ddipu_sdc_surf.cpp
SCODE AllocSurface(GPESurf **ppSurf, int width, int height, EGPEFormat format, int surfaceFlags);
SCODE AllocSurface(DDGPESurf **ppSurf, int width, int height, EGPEFormat format, EDDGPEPixelFormat pixelFormat, int surfaceFlags);
VOID SetVisibleSurface( GPESurf *pSurf, BOOL bWaitForVBlank = FALSE);
DWORD Flip(LPDDHAL_FLIPDATA pd);
// ddipu_sdc_misc.cpp
ULONG DrvEscapeGAPI(ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);
ULONG DrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);
int GetGameXInfo(ULONG iEsc, ULONG cjIn, void *pvIn, ULONG cjOut, void *pvOut);
SCODE SetPalette(const PALETTEENTRY *src,unsigned short firstEntry,unsigned short numEntries ) {return S_OK;}
VOID WaitForNotBusy(DisplayPlane dispPlane);
int IsBusy(VOID);
int InVBlank();
DWORD WaitForVerticalBlank(LPDDHAL_WAITFORVERTICALBLANKDATA pd);
// ddipu_sdc_cursor.cpp
SCODE SetPointerShape(GPESurf *pMask, GPESurf *pColorSurf, int xHot, int yHot, int cx, int cy);
SCODE MovePointer(int x, int y);
VOID CursorOn(VOID);
VOID CursorOff(VOID);
VOID PointerBltPrepare(GPEBltParms *pBltParms);
// ddipu_sdc_rotate.cpp
int GetRotateModeFromReg(VOID);
VOID SetRotateParams(VOID);
int SetRotation(DWORD dwMode, DWORD dwRotation);
BOOL IsRotated(VOID);
// ddipu_sdc_overlay.cpp
DWORD UpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA pd);
DWORD SetOverlayPosition(LPDDHAL_SETOVERLAYPOSITIONDATA pd);
VOID SetVisibleSurfaceOverlay(DDGPESurf *pSurf, RECTL *pRcl);
HRESULT EnableOverlay(DDGPESurf *pOverlaySurf);
HRESULT DisableOverlay(VOID);
VOID WaitForNotBusyOverlay(VOID);
friend VOID buildDDHALInfo( LPDDHALINFO lpddhi, DWORD modeidx );
};
class DDIPU_SDCSurf : public DDGPESurf
{
private:
SurfaceHeap * m_pHeap;
public:
DDIPU_SDCSurf(int width, int height, ULONG offset, PVOID pBits, int stride,
EGPEFormat format, EDDGPEPixelFormat pixelFormat,
SurfaceHeap *pHeap);
~DDIPU_SDCSurf(VOID);
};
#endif //_DDIPU_SDC_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -