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

📄 ddhalsrv.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
字号:
/*
 * $Workfile: DDHALSRV.CPP $
 * $Revision: 5 $
 * $Date: 4/07/00 8:49a $
 * $Modtime: 4/07/00 8:38a $
 * $Author: Sarma $
 *
 * Copyright (c) 1998 National Semiconductor Corporation.
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of National 
 * Semiconductor Corporation. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into
 * with National Semiconductor Corporation.
 * This code is supplied as is.
 *
 */

/*
 *$Log: /CE/Platform/Nsc/Drivers/Video/gxvideo/base/DDHALSRV.CPP $
 * 
 * 5     4/07/00 8:49a Sarma
 * Removed Cyrix Corporation from the legal/confidentail information.
 * 
 * 4     3/29/00 9:21a Sarma
 * This file will be disabled for directdraw interface and that to
 * directdraw will be used.
 * 
 * 3     7/20/99 2:21p Sarma
 * Added Power Handler function in Misc.cpp and supporting functions for
 * power management
 * 
 * 2     11/12/98 3:14p Sarma
 * Added Confidential copyright to files with VSS keywords for
 * log/history.
 *$History: DDHALSRV.CPP $
 * 
 * *****************  Version 5  *****************
 * User: Sarma        Date: 4/07/00    Time: 8:49a
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Removed Cyrix Corporation from the legal/confidentail information.
 * 
 * *****************  Version 4  *****************
 * User: Sarma        Date: 3/29/00    Time: 9:21a
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * This file will be disabled for directdraw interface and that to
 * directdraw will be used.
 * 
 * *****************  Version 3  *****************
 * User: Sarma        Date: 7/20/99    Time: 2:21p
 * Updated in $/wince/v2.1/gxvideo
 * Added Power Handler function in Misc.cpp and supporting functions for
 * power management
 * 
 * *****************  Version 2  *****************
 * User: Sarma        Date: 11/12/98   Time: 3:14p
 * Updated in $/wince/v2.1/gxvideo
 * Added Confidential copyright to files with VSS keywords for
 * log/history.
*/


#include "precomp.h"

//To stop this file from compilation for ddraw was not possible.
#ifndef DD_SUPPORT

typedef unsigned long HGPE;
typedef unsigned long HGPESurf;

#define PGPE(hGPE) (*(GPE **)&hGPE)
#define PGPESURF(hGPESurf) (*(GPESurf **)&hGPESurf)

HGPE DDHAL_GetGPE()
{
	DEBUGMSG( GPE_ZONE_INIT,(TEXT("In DDHAL_GetGPE\r\n")));
	return (HGPE)GetGPE();
}

void GPE_GetPhysicalVideoMemory(
	HGPE pGPE,
	unsigned long *pPhysicalBase,
	unsigned long *pSize )
{
	PGPE(pGPE)->GetPhysicalVideoMemory( pPhysicalBase, pSize );
	DEBUGMSG(GPE_ZONE_INIT,(TEXT("GPE_GetPhysicalVideoMemory: physical base: %08x size: %d\r\n"),
		*pPhysicalBase, *pSize ));
}

SCODE GPE_AllocVideoSurface
	(HGPE pGPE,
	HGPESurf *ppSurf,
	int width,
	int height,
	EGPEFormat format,
	int *pOffsetInVideoMemory )
{
	SCODE rc;
	GPESurf *pSurf;
	rc = PGPE(pGPE)->AllocSurface( &pSurf, width, height, format, GPE_REQUIRE_VIDEO_MEMORY );
	if( !FAILED(rc) )
	{
		*pOffsetInVideoMemory = pSurf->OffsetInVideoMemory();
		DEBUGMSG(GPE_ZONE_INIT,(TEXT("GPE_AllocVideoSurface: offset in video memory: %08x\r\n"),
			pSurf->OffsetInVideoMemory() ));
		*ppSurf = (HGPESurf)pSurf;
	}
	return rc;
}

SCODE GPE_WrapSurface
	(HGPE pGPE,
	HGPESurf *ppSurf,
	int width,
	int height,
	EGPEFormat format,
	unsigned char *pBits,
	int stride )
{
	GPESurf *pSurf = new GPESurf( width, height, pBits, stride, format );
	if( !pSurf )
		return E_OUTOFMEMORY;
	*ppSurf = (HGPESurf)pSurf;
	return S_OK;
}

SCODE GPE_BltExpanded
	(HGPE pGPE,
	HGPESurf pDst,
	HGPESurf pSrc,
	HGPESurf pPattern,
	CONST RECT *prclDst,
	CONST RECT *prclSrc,
	ULONG solidColor,
	ULONG bltFlags,
	ULONG rop4)
{
	GPEBltParms parms;
	SCODE rc;

//	if( PGPE(pGPE)->SurfaceBusyFlipping( PGPESURF(pDst) ) )
//	{
//		if( bltFlags & 0x100 )	// TBD: Review, - need const
//			PGPE(pGPE)->WaitForVBlank();
//		else
//			return DDERR_WASSTILLDRAWING;
//	}

	memset( (void *)&parms, 0, sizeof(parms) );

	parms.pDst = PGPESURF(pDst);
	parms.pSrc = PGPESURF(pSrc);
	// parms.pMask = (GPESurf *)NULL;
	parms.pBrush = PGPESURF(pPattern);
	parms.prclDst = (RECTL *)prclDst;
	parms.prclSrc = (RECTL *)prclSrc;
	// parms.prclClip = (RECTL *)NULL;
	parms.solidColor = solidColor;
	parms.bltFlags = bltFlags;
	parms.rop4 = rop4;
	// parms.prclMask = (RECTL *)NULL;
	// parms.pptlBrush = (POINTL *)NULL;
	// parms.xPositive = 0;
	// parms.yPositive = 0;
	// parms.pLookup = (unsigned long *)NULL;
	// parms.pConvert = (ColorConverter::*)(unsigned long)NULL;
	// parms.pColorConverter = (ColorConverter *)NULL;

	rc = PGPE(pGPE)->BltPrepare( &parms );
	if( FAILED(rc) )
		return rc;
	rc = (PGPE(pGPE)->*(parms.pBlt))( &parms );
	if( FAILED(rc) )
		return rc;
	return PGPE(pGPE)->BltComplete( &parms );
}


SCODE GPE_SetPalette
	(HGPE pGPE,
	const PALETTEENTRY *pSrc,
	USHORT firstEntry,
	USHORT numEntries)
{
	PALETTEENTRY *pEntries = (PALETTEENTRY *)pSrc;
	return PGPE(pGPE)->SetPalette(pEntries,firstEntry,numEntries);
}

SCODE GPE_GetModeInfo
	(HGPE pGPE,
	GPEMode *pMode,
	int modeNo)
{
	return PGPE(pGPE)->GetModeInfo(pMode,modeNo);
}

int GPE_NumModes(HGPE pGPE)
{
	return PGPE(pGPE)->NumModes();
}

SCODE GPE_SetMode
	(HGPE pGPE,
	int modeId)
{
	return PGPE(pGPE)->SetMode( modeId, (HPALETTE *)NULL );
}

int GPE_InVBlank(HGPE pGPE)
{
	return PGPE(pGPE)->InVBlank();
}

int GPE_GetModeId(HGPE pGPE)
{
	return PGPE(pGPE)->GetModeId();
}

int GPE_ScreenHeight(HGPE pGPE)
{
	return PGPE(pGPE)->ScreenHeight();
}

int GPE_ScreenWidth(HGPE pGPE)
{
	return PGPE(pGPE)->ScreenWidth();
}

void GPE_PowerHandler(HGPE pGPE, int bOff)
{
	PGPE(pGPE)->PowerHandler( bOff );
}

HGPESurf GPE_PrimarySurface(HGPE pGPE)
{
	return (HGPESurf)(PGPE(pGPE)->PrimarySurface());
}

void GPE_SetVisibleSurface(
	HGPE pGPE,
	HGPESurf pSurf )
{
	PGPE(pGPE)->SetVisibleSurface( PGPESURF(pSurf) );
}

int GPE_FlipInProgress(HGPE pGPE)
{
	return PGPE(pGPE)->FlipInProgress();
}

void GPE_WaitForVBlank(HGPE pGPE)
{
	PGPE(pGPE)->WaitForVBlank();
}

int GPE_SurfaceBusyFlipping(
	HGPE pGPE,
	HGPESurf pSurf )
{
	return PGPE(pGPE)->SurfaceBusyFlipping( PGPESURF(pSurf) );
}

int GPE_IsBusy( HGPE pGPE )
{
	return PGPE(pGPE)->IsBusy();
}

void GPE_WaitForNotBusy( HGPE pGPE )
{
	PGPE(pGPE)->WaitForNotBusy();
}

SCODE GPE_ProcessCommandBlock( HGPE pGPE,
	unsigned char *pBlock )
{
	return PGPE(pGPE)->ProcessCommandBlock( pBlock );
}

int GPESurf_Stride(HGPESurf pSurf)
{
	return PGPESURF(pSurf)->Stride();
}

int GPESurf_Format(HGPESurf pSurf)
{
	return (int)(PGPESURF(pSurf)->Format());
}

int GPESurf_Width(HGPESurf pSurf)
{
	return PGPESURF(pSurf)->Width();
}

int GPESurf_Height(HGPESurf pSurf)
{
	return PGPESURF(pSurf)->Height();
}

int GPESurf_InVideoMemory(HGPESurf pSurf)
{
	return PGPESURF(pSurf)->InVideoMemory();
}

int GPESurf_Delete(HGPESurf pSurf)
{
	delete PGPESURF(pSurf);
	return 1;
}

unsigned long GPESurf_OffsetInVideoMemory(HGPESurf pSurf)
{
	return PGPESURF(pSurf)->OffsetInVideoMemory();
}



void DDHALNotifyCallback(DWORD cause, DWORD proc, DWORD thread)
{
}

WINGDIAPI DWORD Fn_UnUsed(void) {
    return 0;
}

const PFNVOID VTable[] = {
    (PFNVOID)DDHALNotifyCallback,
    (PFNVOID)Fn_UnUsed, // reserved by kernel
    (PFNVOID)DDHAL_GetGPE,
    (PFNVOID)GPE_GetPhysicalVideoMemory,
    (PFNVOID)GPE_AllocVideoSurface,
    (PFNVOID)GPE_WrapSurface,
    (PFNVOID)GPE_BltExpanded,
    (PFNVOID)GPE_SetPalette,
    (PFNVOID)GPE_GetModeInfo,
    (PFNVOID)GPE_NumModes,
    (PFNVOID)GPE_SetMode,
    (PFNVOID)GPE_InVBlank,
	(PFNVOID)GPE_GetModeId,
    (PFNVOID)GPE_ScreenHeight,
    (PFNVOID)GPE_ScreenWidth,
	(PFNVOID)GPE_PowerHandler,
    (PFNVOID)GPE_PrimarySurface,
    (PFNVOID)GPE_SetVisibleSurface,
    (PFNVOID)GPE_FlipInProgress,
    (PFNVOID)GPE_WaitForVBlank,
    (PFNVOID)GPE_SurfaceBusyFlipping,
    (PFNVOID)GPE_IsBusy,
    (PFNVOID)GPE_WaitForNotBusy,
    (PFNVOID)GPESurf_Stride,
    (PFNVOID)GPESurf_Format,
    (PFNVOID)GPESurf_Width,
    (PFNVOID)GPESurf_Height,
    (PFNVOID)GPESurf_InVideoMemory,
    (PFNVOID)GPESurf_Delete,
    (PFNVOID)GPESurf_OffsetInVideoMemory,
    (PFNVOID)GPE_ProcessCommandBlock
};

const DWORD SigTable[] = {
	FNSIG3(DW,DW,DW),                    //    (PFNVOID)DDHALNotifyCallback,
	FNSIG0(),                            //    (PFNVOID)Fn_UnUsed,      // reserved by kernel
	FNSIG0(),                            //    (PFNVOID)DDHAL_GetGPE,
	FNSIG3(DW,PTR,PTR),                  //    (PFNVOID)GPE_GetPhysicalVideoMemory,
	FNSIG6(DW,PTR,DW,DW,DW,PTR),         //    (PFNVOID)GPE_AllocVideoSurface,
	FNSIG7(DW,PTR,DW,DW,DW,PTR,DW),      //    (PFNVOID)GPE_WrapSurface,
	FNSIG9(DW,DW,DW,DW,PTR,PTR,DW,DW,DW),//    (PFNVOID)GPE_BltExpanded,
	FNSIG4(DW,PTR,DW,DW),                //    (PFNVOID)GPE_SetPalette,
	FNSIG3(DW,PTR,DW),                   //    (PFNVOID)GPE_GetModeInfo,
	FNSIG1(DW),                          //    (PFNVOID)GPE_NumModes,
	FNSIG2(DW,DW),                       //    (PFNVOID)GPE_SetMode,
	FNSIG1(DW),                          //    (PFNVOID)GPE_InVBlank,
	FNSIG1(DW),                          //    (PFNVOID)GPE_GETModeId,
	FNSIG1(DW),                          //    (PFNVOID)GPE_ScreenHeight,
	FNSIG1(DW),                          //    (PFNVOID)GPE_ScreenWidth,
	FNSIG2(DW,DW),                       //    (PFNVOID)GPE_PowerHandler
	FNSIG1(DW),                          //    (PFNVOID)GPE_PrimarySurface,
	FNSIG2(DW,DW),                       //    (PFNVOID)GPE_SetVisibleSurface,
	FNSIG1(DW),                          //    (PFNVOID)GPE_FlipInProgress,
	FNSIG1(DW),                          //    (PFNVOID)GPE_WaitForVBlank,
	FNSIG2(DW,DW),                       //    (PFNVOID)GPE_SurfaceBusyFlipping,
	FNSIG1(DW),                          //    (PFNVOID)GPE_IsBusy,
	FNSIG1(DW),                          //    (PFNVOID)GPE_WaitForNotBusy,
	FNSIG1(DW),                          //    (PFNVOID)GPESurf_Stride,
	FNSIG1(DW),                          //    (PFNVOID)GPESurf_Format,
	FNSIG1(DW),                          //    (PFNVOID)GPESurf_Width,
	FNSIG1(DW),                          //    (PFNVOID)GPESurf_Height,
	FNSIG1(DW),                          //    (PFNVOID)GPESurf_InVideoMemory,
	FNSIG1(DW),                          //    (PFNVOID)GPESurf_Delete,
	FNSIG1(DW),                          //    (PFNVOID)GPESurf_OffsetInVideoMemory
	FNSIG2(DW,PTR)                      //    (PFNVOID)GPE_ProcessCommandBlock
};

#define SH_DDHAL 29			// THIS MUST BE MOVED!
#define LENGTH(array) (sizeof(array)/sizeof(array[0]))

void RegisterDDHALAPI()
{
    //  Register API
//    ASSERT(LENGTH(VTable)   == LAST_DDHAL_API_INDEX + 1);
//    ASSERT(LENGTH(SigTable) == LAST_DDHAL_API_INDEX + 1);
	DEBUGMSG(GPE_ZONE_INIT,(TEXT("Creating API Set for DDHAL\r\n")));
    HANDLE hDDHALApi = CreateAPISet("DDHAL", LENGTH(VTable), VTable, SigTable);
	DEBUGMSG(GPE_ZONE_INIT,(TEXT("Registering API set %d\r\n"),hDDHALApi));
    int rc = RegisterAPISet(hDDHALApi, SH_DDHAL);
	DEBUGMSG(GPE_ZONE_INIT,(TEXT("Return from RegisterAPISet:%d\r\n"),rc));
}
#endif//DD_SUPPORT

⌨️ 快捷键说明

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