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

📄 smi.h

📁 SM501基于ARMV4/ARMV4I平台
💻 H
📖 第 1 页 / 共 3 页
字号:
		m_pRegRW = &regRW;
		m_pRegReadData = &regReadData;
		m_regData.Init(regReadData, regRW);
		m_pRegReset = &regReset;
	}

	RWSplitReg8& operator [](int nSubscript)
	{
		// Before an indexed access, we have to reset the state to address.
		ResetToAddr();
		*m_pRegRW = (UCHAR) nSubscript;
		return m_regData;
	}
};

#define MAX_FLIP_ENTRIES    10
#define FIELDOFFSET(s,f)    (LONG_PTR)(&(((s  *)0)->f))

// types
typedef struct _FLIP_EXTENSION {
    LIST_ENTRY  ListEntry;
    ULONG       fpVidMem;
    ULONG       surfaceIndex;
} FLIP_EXTENSION, *PFLIP_EXTENSION;

typedef struct _AUTOFLIP {
    LIST_ENTRY      EmptyFrameQueue;
    PLIST_ENTRY     pCaptureEntry1;
    PLIST_ENTRY     pCaptureEntry2;
    PLIST_ENTRY     pDisplayEntry;
    FLIP_EXTENSION  FlipEntries[MAX_FLIP_ENTRIES];
} AUTOFLIP, *PAUTOFLIP;


class SMISurf;

class SMISurfList
{
public:
	SMISurf			*m_pSurf;
	UCHAR			*m_pSurfSystemBuffer;
	SMISurfList		*m_pNext;

					SMISurfList();
					~SMISurfList();
	void			Add(SMISurf *pSurf);
	void			Remove(SMISurf *pSurf);
	void			Save();
	void			Restore();
#if SMI_SURFACEDEBUG
	void			PrintList();
#endif
};

#ifdef DD_ENABLE
class SMI : public DDGPE
#elif ROTATION_ENABLE
class SMI : public GPERotate
#else	// ! DD_ENABLE
class SMI : public GPE
#endif	// DD_ENABLE
{
protected:
    ULONG           m_nLAWPhysical;         // Physical Linear Access Window (LAW) address
    PUCHAR          m_pLAW;                 // Mapped Linear Access Window (LAW) address
    ULONG           m_nREGPhysical;         // Physical Register Access Window (REG) address
    PUCHAR          m_pREG;                 // Mapped Register Access Window (REG) address
    ULONG           m_nVideoMemorySize;     // Size in bytes of video RAM total
    ULONG           m_nVideoMemoryAvail;    // Size in bytes of video RAM available for surface allocation
	ULONG			m_nCursorMemory;		// Offset of the cursor memory
	int             m_nPanelHwcOnOff;       // Indicates whether Hwc is currently enabled/disabled: 0 - Disable, 1 - Enable
    SMISETTINGS		m_SMISettings;

	PUCHAR			m_pDPR;			 		// Memory Mapped DPR IO range
	PUCHAR			m_pMMIO;				// 2D Engine Data Port

#ifdef DD_ENABLE
	SurfaceHeap	   	*m_pVideoMemoryHeap;  	// Base entry representing all video memory
    GPEModeEx       m_ModeInfoEx;           // local mode info

    DDGPESurf      *m_pVisibleOverlay;      // Visible overlay surface
    DWORD           m_dwOverlayFlipOffset;  // Overlay flip offset
#else
    Node2D          *m_p2DVideoMemory;      // Base entry representing all video memory
    GPEMode         m_ModeInfo;             // local mode info
	DWORD			m_dwPhysicalModeID;		// ModeID for DD requirement
#endif

	BOOL			m_bSetMode;
	UINT			m_nRefreshRate;
	UINT			m_nScreenBpp;
    ULONG           m_nScreenStride;	    // byte count of a single scan line
	ULONG			m_nPanelStride;
	ULONG			m_nSurfaceBitsAlign;	// Surface bits alignments

    int             m_nXHot;                // Hot spot for cursor
    int             m_nYHot;

	int				m_nPanningX;			// Panning X,Y position
	int				m_nPanningY;

	ULONG			m_dwCxZoom;				// Current Zoom Width
	ULONG			m_dwCyZoom;				// Current Zoom Height
	BOOL			m_bZoomEnabled;			// Zoom is Enabled?

	PVOID			m_pPanelHwcBuffer;      // System memory to hold panel hwc image
	ModeInit		m_saveRestore;			// System memory to hold VGX register/memory settings
    BOOL            m_bVgxRegsMemorySaved;	// indicates whether VGX registers/memory have been saved previously
                                            // set to TRUE after save, FALSE after restore (default is FALSE)
#ifdef CMDLIST
    ULONG           m_cmdlist_address; // "CMDLISTBUF_ADDR"  = dword:{Command List buffer physical address in system memory}
    ULONG           m_cmdlist_size;    // "CMDLISTBUF_SIZE"  = dword:{Command List buffer size in bytes in system memory}
#endif // CMDLIST
    ULONG           m_sdrambase;       // "SDRAM_BASE"       = dword:{Voyager SDRAM base}

#ifdef VGXDMA
    ULONG           m_VGXDMA_address; // "VGXDMABUF_ADDR"  = dword:{VGXDMA buffer physical address in system memory}
    ULONG           m_VGXDMA_size;    // "VGXDMABUF_SIZE"  = dword:{VGXDMA buffer size in bytes in system memory}
    ULONG           VGXDMA_virtual_address;
    ULONG           VGXDMA_physical_offset;
#endif

#ifndef ROTATION_ENABLE
	WORD    		m_iRotate;
	int     		m_nScreenWidthSave;
	int     		m_nScreenHeightSave;
#endif // ROTATION_ENABLE

#ifndef DISABLE_INTERRUPT_MANAGEMENT
	// Misc - Vsync Int
	BOOL			m_bVsyncEvent;		// Waiting for Vsync?
	HANDLE			m_hVsyncEvent;		// Handle to Vsync event

#ifdef DD_ENABLE
	// Halvpe - ZVport Int
	BOOL			m_bZVPortEvent;		// Waiting for Vsync?
	HANDLE			m_hZVPortEvent;		// Handle to Vsync event

#endif

    AUTOFLIP        m_Autoflip;			// ZV port Autoflip structures
#endif

public:

	SMISurfList		m_SMISurfList;          // Linked list containing all surfaces currently in use
    // smi.cpp
					// This has two contructors for easy future class derivation
					SMI(void) { }
					SMI(SMISETTINGS *pss) { Init(pss); }
	void 			Init(SMISETTINGS *pss);
    virtual SCODE   SetMode(int modeId, HPALETTE *pPalette);
	virtual void 	SetModeHardware(int modeId);
    virtual SCODE   GetModeInfo(GPEMode *pMode, int modeNo);
#ifdef	DD_ENABLE
	virtual SCODE	GetModeInfoEx(GPEModeEx *pModeEx, int modeNo);
#endif
    virtual int     NumModes(void);
    virtual void    GetPhysicalVideoMemory(PULONG pPhysicalMemoryBase, PULONG pVideoMemorySize);
	int				GetBpp(void);
	virtual void	AdjustDefaultMode(void);
    virtual void    InitCard(void);
	virtual BYTE	GetPanelID(void);
	virtual void	SetupVideoMemory(void);
	virtual void    ZoomAPI(int nPanningX, int nPanningY, DWORD dwCxZoom, DWORD dwCyZoom, DWORD dwCxPanel, DWORD dwCyPanel);
	virtual BOOL	isZoomEnabled(void) { return m_bZoomEnabled; }
	BOOL			IsUSBDriverPresent();
	BOOL			IsAudioDriverPresent();
	BOOL			IsUART1Active();

    // misc.cpp
    virtual ULONG   DrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);
    virtual void    WaitForNotBusy(void);
    virtual int     IsBusy(void);
    virtual int     InVBlank();
	virtual void	WaitForVBlank();
	void 			InitVSyncInterrupt();
	void 			VSyncIntHandler();
	virtual BOOL 	WaitForVerticalSync();
    virtual ULONG   GetGraphicsCaps();
    virtual SCODE   SetPalette(const PALETTEENTRY *src,unsigned short firstEntry,unsigned short numEntries );
	virtual int		IsPaletteSettable();
	//void			Lock();
	void			Unlock();
	void			UnlockVGA();
	//void			LockVGA();
	ULONG			HandleSMIInfoCommand(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);
	ULONG			HandleSMIRegsCommand(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);
	ULONG			HandleSMIMiscCommand(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);
	ULONG			HandleSMIZoomCommand(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);
	ULONG			HandleSMISurfaceCommand(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);
    // Save/restore registers
	void			SaveRestore(BOOL bSave);
#ifdef VGXDMA
    void SMI::InitVGXDMA(void);
    DWORD HandleDMAStart(DWORD cjIn, PVOID pvIn, DWORD cjOut, PVOID pvOut);
    DWORD HandleGetDMABuffer(DWORD cjIn, PVOID pvIn, DWORD cjOut, PVOID pvOut);
    DWORD WaitDMAfinished(DWORD cjIn, PVOID pvIn, DWORD cjOut, PVOID pvOut);
#endif //VGXDMA
    // cursor.cpp
    virtual SCODE   SetPointerShape(GPESurf *pMask, GPESurf *pColorSurf, int xHot, int yHot, int cx, int cy);
    virtual SCODE   MovePointer(int x, int y);
    virtual void    SetCursorColors(ULONG foreground, ULONG background);
	virtual void 	DisableCursor(void);
	virtual void   	EnableCursor(void);
	virtual void	SetupCursor(void);
	virtual void	SetCursorAddress(ULONG dwAddress);
	virtual void	AdjustCursorShape(void);

    // surf.cpp
    virtual SCODE   AllocSurface(GPESurf **ppSurf, int width, int height, EGPEFormat format, int surfaceFlags);
#ifdef	DD_ENABLE
    virtual SCODE   AllocSurface(DDGPESurf **ppSurf, int width, int height, EGPEFormat format, EDDGPEPixelFormat pixelFormat, int surfaceFlags);
	virtual void	SetVisibleSurface( GPESurf *pSurf, BOOL bWaitForVBlank = FALSE);
#else	// ! DD_ENABLE
	virtual void	SetVisibleSurface( GPESurf *pSurf);
#endif	// DD_ENABLE
	virtual int		FlipInProgress();
	virtual int		SurfaceBusyFlipping( GPESurf *pSurf );

    // Line.cpp:
    virtual SCODE   Line(GPELineParms *pLineParms, EGPEPhase phase);
	SCODE 			WrapLine(GPELineParms *pLineParms);
	SCODE			HwLine(GPELineParms *pLineParms);
	void 			SetClip(RECTL *prclBounds, short flag);
	void            RotateLineParms(GPELineParms * pParms);
	SCODE           WrapLineRotate(GPELineParms * pParms);

    // Blt.cpp:
    virtual SCODE   BltPrepare(GPEBltParms *pBltParms);
    virtual SCODE   BltComplete(GPEBltParms *pBltParms);
	SCODE			WrapBlt(GPEBltParms *pBltParms);
	SCODE			FillRect(GPEBltParms *pBltParms);
	SCODE			PatFill(GPEBltParms *pBltParms);
	SCODE			DestBlt(GPEBltParms *pBltParms);
	SCODE			SrcCopy(GPEBltParms *pBltParms);
	SCODE			SrcCopyHost(GPEBltParms *pBltParms);
	SCODE 			CSCSrcCopy(GPEBltParms *pBltParms);
	SCODE			MaskedImage(GPEBltParms *pBltParms);
	void			RotateBrush(GPESurf *pBrush, UCHAR *pjPattern, int patX, int patY);

	// Rotate.cpp
	virtual	int		GetRotateModeFromReg();
    void 			SetRotateParams();
	SCODE 			RotateCursorShape(int angle);
    virtual LONG 	DynRotate(int angle);
#ifndef ROTATION_ENABLE
	void    		RotateRectl(RECTL *) { }
#endif // ROTATION_ENABLE
#ifdef CMDLIST
	void            SetupCmdListBuffer(void);
#endif // CMDLIST
#ifdef DD_ENABLE
	// Haldd.cpp:
	DWORD			GetScanLine(void);
	DWORD			WaitForVerticalBlank(LPDDHAL_WAITFORVERTICALBLANKDATA pd);

	// Halsurf.cpp:
	DWORD			Lock(LPDDHAL_LOCKDATA pd);
    DWORD           Flip(LPDDHAL_FLIPDATA pd);
    DWORD           Blt(LPDDHAL_BLTDATA pd);
    DWORD           CSCStretchBlt(LPDDHAL_BLTDATA pd);
    DWORD           UpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA pd);
    DWORD           SetOverlayPosition(LPDDHAL_SETOVERLAYPOSITIONDATA pd);
    //DWORD           ColorControl(LPDDHAL_COLORCONTROLDATA pd);
	void            Video_SetVerticalMode(int mode);
	void            Video_SetHorizontalMode(int mode);

	// HalVpe.cpp:
	void			VPE_Disable(void);
	void			VPE_Enable(void);
 	BOOL			VPE_IsVsync(void);
	void			VPE_SetDst(DWORD dwBase);
	void			VPE_SetDst2(DWORD dwBase);
	DWORD			VPE_GetDst(void);
	BOOL			VPE_IsEnable(void);
	BOOL			VPE_IsEvenField(void);
	DWORD			VPE_GetVPEMode(void);
	void			VPE_SetVPEMode(DWORD dwMode);
	void			VPE_SetCaptureSize(DWORD dwWidth, DWORD dwHeight);
	void			VPE_SetStride(DWORD dwStride);
	void			VPE_SetCropSize(DWORD dwLeft, DWORD dwTop);
	void			VPE_EnableOverlayWindow(DWORD dwDstOfs2);
	void			VPE_DisableOverlayWindow(void);
	void			VPE_EnableBOB(void);
	void			VPE_DisableBOB(void);
	void            VPE_EnableByteSwap(void);
	void            VPE_DisableByteSwap(void);
	void            VPE_EnableFieldSwap(void);
	void            VPE_DisableFieldSwap(void);

	BOOL 			VPE_WaitForVSync(DWORD dwTimeOut);
	void 			VPE_IntHandler();
	void			VPE_ProcessCapture();
	void			VPE_InitInterrupt();
	void			VPE_DisableInterrupt();
	void 			VPE_InitSwAutoflip(DWORD *pInput);
	int				VPE_CurrentBuffer();
    void			VPE_SetCap(DWORD dwMask, DWORD dwVal);

	ULONG			HandleSMIVPEAPI(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut);

#endif // DD_ENABLE

	DWORD			VgxSurfAddr(DWORD dwAddr);

	// panel.c
	void 			panelWaitVSync(int vsync_count);
	void 			panelPowerSequence(panel_state_t on_off, int vsync_delay);

	// modetbl.c
	void 			programMode(reg_table_t *register_table);
	unsigned long	rev();


	///////////////////////////////////////////////////////////////////////////
	// Interrupt Management: interrupt.cpp

#ifndef DISABLE_INTERRUPT_MANAGEMENT

protected:
	BOOL			m_bStandardISR;			// Standard or SMI handler
	BOOL			m_bIntInitDone;			// Successful initialization

	// +++ Used only if (m_bStandardISR == TRUE)
	HANDLE			m_hIsrHandle;			// Standard ISR handle
	GIISR_INFO		m_GIISRInfo;			// GIISR Interrupt Info
	// --- Used only if (m_bStandardISR == TRUE)

	BOOL			StartIntThread(INTERRUPT_INFO& IntInfo, VGXINTENTRY pfnIntEntry);
	void			StopIntThread(INTERRUPT_INFO& IntInfo);

public:
	DWORD			InterruptThread();
	void			InitInterrupt();
	BOOL			RegisterHandler(VGXINTHANDLER Handler, DWORD dwMask);
	void			DisableHandler(DWORD dwMask);

#endif

	// End of Interrupt Management definition
	///////////////////////////////////////////////////////////////////////////


	///////////////////////////////////////////////////////////////////////////
	// Power Management: power.cpp

protected:
	// If m_bProtectClockSource is TRUE, the clock source will never be changed
	// by the power management functions, therefore allowing only 'divider' and
	// 'shift' fields to be configurable. This is added to resolve a hardware
	// issue with clock sources being different. When the screen mode is being
	// set, panel and crt clock sources are set to the appropriate values.
	// Because of the mentioned hardware issue, MCLK and M2XCLK clock sources
	// have to match the clock sources for P2XCLK and V2XCLK.
	BOOL			m_bProtectClockSource;

	BOOL			m_bInPowerHandler;			// In PowerHandler
	VGX_POWER_STATE	m_PowerState;				// Current Power State
	DWORD			m_dwGateSave;				// Saved Gate register
	DWORD			m_dwClockSave;				// Saved Clock register
	DWORD			m_dwPLL2Output;				// Saved PLL2 output frequency

	HANDLE			m_hPMThread;				// Power Management thread handle
	HANDLE			m_hPMMessageQueue;			// Power Management message queue
	HANDLE			m_hPMNotifications;			// Power Management notifications

	DWORD			m_dwPowerOnLastRequested;	// Tick count of the last request
												//   of full power mode
	DWORD			m_dwReducedLastRequested;	// Tick count of the last request
												//   of reduced power mode
	DWORD			m_dwMinimalLastRequested;	// Tick count of the last request
												//   of minimal power mode

	DWORD			m_dwTicksToReduced;			// Number of ticks to reduced state
	DWORD			m_dwTicksToMinimal;			// Number of ticks to minimal state

	BOOL			m_bMonitorEnabled;			// Controls the power monitor's actibity
	BOOL			m_bPowerStateLocked;		// Locks the specified power state

	MODULE_POWER_INFO m_PowerInfo[VGXPM_MODULE_COUNT];
	CLOCK_ARRAY		m_ClockInfo;				// Clock values for different modes

	CRITICAL_SECTION m_PowerCriticalSection;	// To ensure non-reenterability

public:
	DWORD			InitPowerManagement();
	DWORD			StartPowerManagement();
	DWORD			StartPowerThread();
	void			ResetPowerManagement();

	virtual void	PowerHandler(BOOL bOff);

	DWORD			HandleSetPowerManagement(DWORD cjIn, PVOID pvIn, DWORD cjOut, PVOID pvOut);
	DWORD			HandleGetPowerManagement(DWORD cjIn, PVOID pvIn, DWORD cjOut, PVOID pvOut);
	DWORD			HandleSMIPowerManagement(DWORD cjIn, PVOID pvIn, DWORD cjOut, PVOID pvOut);

	DWORD			GetTicksSince(DWORD Mark);
	DWORD			GetTickCountSafe();

	void			PowerHook(VGXPM_MODULES Module, VGX_POWER_STATE MinPower);

	DWORD			SetPowerManagement(VIDEO_POWER_STATE PowerState);
	DWORD			SetVGXPowerManagement(VGX_POWER_STATE PowerState);
	VOID			EnsureAtLeast(VGX_POWER_STATE MinimalPowerState);

⌨️ 快捷键说明

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