📄 pvr_glue.c
字号:
/*!****************************************************************************
@File pvr_glue.c
@Title wince glue code
@Author Imagination Technologies
@date 16 September 2003
@Copyright Copyright 2003-2004 by Imagination Technologies Limited.
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.
@Platform wince
@Description Implements the pvr services API User bridge code
@DoxygenVer
******************************************************************************/
/******************************************************************************
Modifications :-
$Log: pvr_glue.c $
*****************************************************************************/
#include <windows.h>
#include "img_defs.h"
#include "services.h"
#include "pvr_bridge.h"
#include "pvr_debug.h"
#include "pvr3dif.h"
#include "queue.h"
#include "hostfunc_um.h"
#include "syscommon.h"
/******************************************************************************/
/* Exported Functions */
#if 0
BOOL WINAPI DllMain (HANDLE hinstDLL,
DWORD dwReason,
LPVOID lpvReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
// g_hModule = (HMODULE) hModule;
}
break;
}
return TRUE;
}
#endif
/*!
******************************************************************************
@Function PVRSRVConnect
@Description
Creates a connection to the services module and fills in the 'handle'
@input szDevicePath :
@output phServices:
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR IMG_CALLCONV PVRSRVConnect(IMG_CHAR* szDevicePath, IMG_HANDLE *phServices)
{
PVRSRV_ERROR eError;
eError = OpenServices(szDevicePath, phServices);
if(eError != PVRSRV_OK)
{
return eError;
}
return eError;
}
/*!
******************************************************************************
@Function PVRSRVDisconnect
@Description
Disconnects from the services module
@input hServices :
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR IMG_CALLCONV PVRSRVDisconnect(IMG_HANDLE hServices)
{
return CloseServices(hServices);
}
/*!
******************************************************************************
@Function PVRSRVEnumerateDevices
@Description
This function will enumerate all the devices supported by the
PowerVR services within the target system.
The function returns a list of the device IDs stored either in the services
(or constructed in the user mode glue component in certain environments)
The number of devices in the list is also returned.
The user is required to provide a buffer large enough to receive an array of
MAX_NUM_DEVICE_IDS*PVRSRV_DEVICE_IDENTIFIER structures.
In a binary layered component which does not support dynamic runtime selection,
the glue code should compile to return the supported devices statically,
e.g. multiple instances of the same
device if multiple devices are supported, or the target combination of MBX and
display device.
In the case of an environment (for instance) where one MBX1 may connect to two
display devices this code would enumerate all three devices and even
non-dynamic MBX1 selection code should retain the facility to parse the list
to find the index of the MBX device
@input hServices: Handle to services
@output puiNumDevices : On success, contains the number of devices present in the system
@output puiDevIDs : Pointer to called supplied array of PVRSRV_DEVICE_IDENTIFIER
structures. The array is assumed to be at least
PVRSRV_MAX_DEVICES long.
@return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumerateDevices( IMG_HANDLE hServices,
IMG_UINT32 *pui32NumDevices,
PVRSRV_DEVICE_IDENTIFIER *puiDevIDs)
{
PVRSRV_BRIDGE_OUT_ENUMDEVICE sOut;
IMG_UINT32 i;
if(!pui32NumDevices || !puiDevIDs)
return PVRSRV_ERROR_INVALID_PARAMS;
if(PVRSRVBridgeCall( hServices,
PVRSRV_BRIDGE_ENUM_DEVICES,
IMG_NULL,
0,
&sOut,
sizeof(PVRSRV_BRIDGE_OUT_ENUMDEVICE)))
{
return PVRSRV_ERROR_GENERIC;
}
if(sOut.eError != PVRSRV_OK)
return sOut.eError;
*pui32NumDevices = sOut.ui32NumDevices;
for(i=0; i < sOut.ui32NumDevices; i++)
{
puiDevIDs[i] = sOut.asDeviceIdentifier[i];
}
return sOut.eError;
}
/*!
******************************************************************************
@Function PVRSRVAcquireDeviceData
@Description
This returns a pointer to the device info structure for the requested device
This populates a PVRSRV_DEV_DATA structure with appropriate pointers to the
DevInfo structure for the device requested.
In a non-plug-and-play the first call to GetDeviceInfo for a device causes
device initialisation
Calls to GetDeviceInfo are reference counted
@Input hServices : Handle to services
@Input uiDevIndex : Index to the required device obtained from the
PVRSRVEnumerateDevice function
@Input eDeviceType : Required device type. If type is unknown use uiDevIndex
to locate device data
@Output psDevData :
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR IMG_CALLCONV PVRSRVAcquireDeviceData( IMG_HANDLE hServices,
IMG_UINT32 uiDevIndex,
PVRSRV_DEV_DATA *psDevData,
PVRSRV_DEVICE_TYPE eDeviceType)
{
PVRSRV_BRIDGE_OUT_ACQUIRE_DEVICEINFO sOut;
PVRSRV_BRIDGE_IN_ACQUIRE_DEVICEINFO sIn;
sIn.uiDevIndex = uiDevIndex;
sIn.eDeviceType = eDeviceType;
if(PVRSRVBridgeCall( hServices,
PVRSRV_BRIDGE_ACQUIRE_DEVICEINFO,
&sIn,
sizeof(PVRSRV_BRIDGE_IN_ACQUIRE_DEVICEINFO),
&sOut,
sizeof(PVRSRV_BRIDGE_OUT_ACQUIRE_DEVICEINFO)))
{
return PVRSRV_ERROR_GENERIC;
}
if(sOut.eError != PVRSRV_OK)
{
return(sOut.eError);
}
*psDevData = sOut.sDevData;
psDevData->hServices = hServices;
psDevData->psDevInfoUM = psDevData->psDevInfoKM;
return(sOut.eError);
}
/*!
******************************************************************************
@Function PVRSRVReleaseDeviceData
@Description
This decrements the reference count to the device info structure and when the
reference count reaches zero causes the device to be de-initialised
@Input psDevData :
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR IMG_CALLCONV PVRSRVReleaseDeviceData(PVRSRV_DEV_DATA *psDevData)
{
PVRSRV_BRIDGE_RETURN sRet;
if (psDevData == NULL)
{
return PVRSRV_ERROR_INVALID_PARAMS;
}
psDevData->psDevInfoUM = IMG_NULL;
if(PVRSRVBridgeCall( psDevData->hServices,
PVRSRV_BRIDGE_RELEASE_DEVICEINFO,
psDevData,
sizeof(PVRSRV_DEV_DATA),
(IMG_VOID *)&sRet,
sizeof(PVRSRV_BRIDGE_RETURN)))
{
return PVRSRV_ERROR_GENERIC;
}
return sRet.eError;
}
/*!
******************************************************************************
@Function PVRSRVAllocDeviceMem
@Description
Allocates device memory
@Input psDevData : DevData for the device this memory will primarily be used with
@Input ui32Flags : Some combination of PVRSRV_MEMFLG_ flags
@Input ui32Size : Number of bytes to allocate
@Input ui32Alignment :
@Output **ppsMemInfo : On success, receives a pointer to the created MEM_INFO structure
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMem( PVRSRV_DEV_DATA *psDevData,
IMG_UINT32 ui32Flags,
IMG_UINT32 ui32Size,
IMG_UINT32 ui32Alignment,
PVRSRV_MEM_INFO **ppsMemInfo)
{
PVRSRV_BRIDGE_RETURN sRet;
PVRSRV_BRIDGE_IN_ALLOCDEVICEMEM sIn;
if(!ppsMemInfo)
return PVRSRV_ERROR_INVALID_PARAMS;
sIn.psDevInfo = psDevData->psDevInfoKM;
sIn.ui32Flags = ui32Flags;
sIn.ui32Size = ui32Size;
sIn.ui32Alignment = ui32Alignment;
if(PVRSRVBridgeCall( psDevData->hServices,
PVRSRV_BRIDGE_ALLOC_DEVICEMEM,
&sIn,
sizeof(PVRSRV_BRIDGE_IN_ALLOCDEVICEMEM),
(IMG_VOID *)&sRet,
sizeof(PVRSRV_BRIDGE_RETURN)))
{
return PVRSRV_ERROR_GENERIC;
}
if(sRet.eError != PVRSRV_OK)
return sRet.eError;
*ppsMemInfo = sRet.pvData;
return sRet.eError;
}
/*!
******************************************************************************
@Function PVRFreeDeviceMem
@Description
Frees memory allocated with PVRAllocDeviceMem, including the mem_info structure
@Input psDevData :
@Input psMemInfo :
@Return PVRSRV_ERROR :
******************************************************************************/
PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMem( PVRSRV_DEV_DATA *psDevData,
PVRSRV_MEM_INFO *psMemInfo)
{
PVRSRV_BRIDGE_RETURN sRet;
PVRSRV_BRIDGE_IN_FREEDEVICEMEM sIn;
sIn.psDevInfo = psDevData->psDevInfoKM;
sIn.psMemInfo = psMemInfo;
if(PVRSRVBridgeCall( psDevData->hServices,
PVRSRV_BRIDGE_FREE_DEVICEMEM,
&sIn,
sizeof(PVRSRV_BRIDGE_IN_FREEDEVICEMEM),
(IMG_VOID *)&sRet,
sizeof(PVRSRV_BRIDGE_RETURN)))
{
return PVRSRV_ERROR_GENERIC;
}
return sRet.eError;
}
/*!
******************************************************************************
@Function PVRSRVGetFreeDeviceMem
@Description
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -