📄 displaycommon.c
字号:
/*!****************************************************************************
@File displaycommon.c
@Title Device specific routines
@Author Imagination Technologies
@date 18 / 9 / 03
@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 Generic
@Description Device specific functions
@DoxygenVer
******************************************************************************/
/******************************************************************************
Modifications :-
$Log: displaycommon.c $
*****************************************************************************/
#include "services_headers.h"
#include "sharedutils.h"
#if defined (SUPPORT_PDP_DISPLAY)
#include "pdp.h"
#endif
#if defined (SUPPORT_J_DISPLAY)
#include "jdisplay.h"
#endif
#if defined (SUPPORT_CLCDC_DISPLAY)
#include "clcdc.h"
#endif
#define MAX_PENDING_FLIPS 16
/*!
******************************************************************************
@Function InitDisplayDeviceInfo
@Description
Allocates and sets up the display device devinfo
@Input psDevInfo - device info. structure
@Input psDevId
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR InitDisplayDeviceInfo(PVRSRV_DEV_INFO **ppsDevInfo,
PVRSRV_DEVICE_IDENTIFIER *psDevId)
{
PVRSRV_ERROR eError = PVRSRV_OK;
PVRSRV_DEV_INFO *psDevInfo;
PVRSRV_DEV_LOCATION *psDevLocation;
IMG_VOID *pvLinBase;
/* Allocate device control block */
if(HostAllocMem( PVRSRV_HOST_NON_PAGEABLE_HEAP,
sizeof(PVRSRV_DEV_INFO),
(IMG_VOID **)&psDevInfo, 0) != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"InitDisplayDeviceInfo : Failed to alloc memory for DevInfo"));
return (PVRSRV_ERROR_OUT_OF_MEMORY);
}
HostMemSet (psDevInfo, 0, sizeof(PVRSRV_DEV_INFO));
/* copy psDevId into new psDevInfo */
psDevInfo->sDevId = *psDevId;
/* setup the DevLocation */
SysFindLocation(psDevInfo);
/* save pointer de-refs */
psDevLocation = &psDevInfo->sDevLocation;
/* Map Regs */
if (psDevLocation->ui32RegSize)
{
pvLinBase = HostMapPhysToLin(ENV_SysPAddrToCpuPAddr(psDevLocation->sRegsPhysBase),
psDevLocation->ui32RegSize,
CACHETYPE_UNCACHED | EXTRA_CACHETYPE_SHARED);
if (pvLinBase == (IMG_CPU_VIRTADDR)0)
{
PVR_DPF((PVR_DBG_ERROR,"InitDisplayDeviceInfo : Failed to map in regs\n"));
return PVRSRV_ERROR_BAD_MAPPING;
}
psDevLocation->pvRegsBaseKM = pvLinBase;
}
else
{
psDevLocation->pvRegsBaseKM = 0;
}
/* setup some device specifics */
switch(psDevId->eDeviceType)
{
#if defined (SUPPORT_PDP_DISPLAY)
case PVRSRV_DEVICE_TYPE_PDP :
{
psDevInfo->pfnInitDevice = DevInitPDP;
break;
}
#endif
#if defined(SUPPORT_J_DISPLAY)
case PVRSRV_DEVICE_TYPE_JDISPLAY :
{
psDevInfo->pfnInitDevice = DevInitJDisplay;
psDevInfo->pfnDeInitDevice = DevDeInitJDisplay;
psDevInfo->pfnDeviceISR = JDisplayIsr;
psDevInfo->sDeviceSpecific.sDisplay.pfnFlipDisplay = JDisplayFlipDisplay;
psDevInfo->pfnProcessCommands = DevProcessCommandsJDisplay;
psDevInfo->pfnDummyProcessCommands = DevDummyProcessCommandsJDisplay;
psDevInfo->sDeviceSpecific.sDisplay.pfnUpdateDisplay = IMG_NULL;
break;
}
#endif
#if defined(SUPPORT_CLCDC_DISPLAY)
case PVRSRV_DEVICE_TYPE_CLCDC :
{
psDevInfo->pfnInitDevice = DevInitCLCDC;
psDevInfo->pfnDeInitDevice = DevDeInitCLCDC;
psDevInfo->pfnDeviceISR = CLCDCIsr;
psDevInfo->sDeviceSpecific.sDisplay.pfnFlipDisplay = IMG_NULL;
psDevInfo->pfnProcessCommands = DevProcessCommandsCLCDC;
psDevInfo->pfnDummyProcessCommands = DevDummyProcessCommandsCLCDC;
psDevInfo->sDeviceSpecific.sDisplay.pfnUpdateDisplay = IMG_NULL;
break;
}
#endif
default:
{
PVR_DPF((PVR_DBG_ERROR,"InitDisplayDeviceInfo : unsupported device type\n"));
return PVRSRV_ERROR_INVALID_DEVICE;
}
}
/* return the new devinfo */
*ppsDevInfo = psDevInfo;
/* initialise the display */
SysInitDisplay();
return eError;
}
/*!
******************************************************************************
@Function DeInitDisplayDeviceInfo
@Description
DeAllocates devinfo and associated sub structures
@Input psDevInfo - device info. structure
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR DeInitDisplayDeviceInfo(PVRSRV_DEV_INFO *psDevInfo)
{
PVRSRV_DEV_LOCATION *psDevLocation = &psDevInfo->sDevLocation;
PVRSRV_ERROR eError = PVRSRV_OK;
/* de-initialise the display */
SysDeInitDisplay();
/* UnMap Regs */
if (psDevLocation->ui32RegSize)
{
HostUnMapPhysToLin (psDevLocation->pvRegsBaseKM, psDevLocation->ui32RegSize);
}
/* DeAllocate devinfo */
HostFreeMem(PVRSRV_HOST_NON_PAGEABLE_HEAP, psDevInfo);
return eError;
}
/*!
******************************************************************************
@Function EnableDisplayDevice
@Description
Enables a display device
@Input psDevInfo - device info. structure
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR EnableDisplayDevice(PVRSRV_DEV_INFO *psDevInfo)
{
PVRSRV_ERROR eError = PVRSRV_OK;
/* let's boot the device! */
eError = psDevInfo->pfnInitDevice(psDevInfo);
return eError;
}
/*!
******************************************************************************
@Function DisableDisplayDevice
@Description
Disables a display device
@Input psDevInfo - device info. structure
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR DisableDisplayDevice(PVRSRV_DEV_INFO *psDevInfo)
{
PVRSRV_ERROR eError = PVRSRV_OK;
/* let's disable the device! */
eError = psDevInfo->pfnDeInitDevice(psDevInfo);
return eError;
}
/*!
******************************************************************************
@Function InitVsyncFlipQueue
@Description init's the internal vsync flip Q
@input psDevInfo : device info structure
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR InitVsyncFlipQueue (PVRSRV_DEV_INFO *psDevInfo)
{
IMG_UINT32 i;
DEVICEDISPLAY *psDisplay = &psDevInfo->sDeviceSpecific.sDisplay;
VSYNC_FLIP_CMD_INFO *psFlip;
if(HostAllocMem( PVRSRV_HOST_NON_PAGEABLE_HEAP,
sizeof(VSYNC_FLIP_CMD_INFO)*MAX_PENDING_FLIPS,
(IMG_VOID **)&psDisplay->psVSyncFlipMem, 0) != PVRSRV_OK)
{
return PVRSRV_ERROR_OUT_OF_MEMORY;
}
psFlip = psDisplay->psVSyncFlipHead = psDisplay->psVSyncFlipMem;
psDisplay->psVSyncFlipTail = &psDisplay->psVSyncFlipHead[MAX_PENDING_FLIPS-1];
HostMemSet(psFlip, 0, MAX_PENDING_FLIPS * sizeof(VSYNC_FLIP_CMD_INFO));
for(i=0; i<(MAX_PENDING_FLIPS-1); i++)
{
/* link nodes */
psFlip[i].psNext = &psFlip[i+1];
}
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function DeInitVsyncFlipQueue
@Description de-init's the internal vsync flip Q
@input psDevInfo : device info structure
@Return none
******************************************************************************/
IMG_VOID DeInitVsyncFlipQueue (PVRSRV_DEV_INFO *psDevInfo)
{
DEVICEDISPLAY *psDisplay = &psDevInfo->sDeviceSpecific.sDisplay;
HostFreeMem(PVRSRV_HOST_NON_PAGEABLE_HEAP, psDisplay->psVSyncFlipMem);
}
/*!
******************************************************************************
@Function Flip
@Description
calls HW flip function
@input psDevInfo : device info structure
@input psFlipCmd : flip cmd
@Return none
******************************************************************************/
IMG_VOID Flip (PVRSRV_DEV_INFO *psDevInfo, VSYNC_FLIP_CMD_INFO *psFlipCmd)
{
if (psFlipCmd->bValidCmd)
{
if (psFlipCmd->bThisIsOverlayFlip)
{
/* Perform an overlay flip */
psDevInfo->sDeviceSpecific.sDisplay.pfnFlipOverlay (psDevInfo, (IMG_VOID*) psFlipCmd);
}
else
{
/* make display HW flip now */
psDevInfo->sDeviceSpecific.sDisplay.pfnFlipDisplay (psDevInfo, psFlipCmd->ui32FlipPhysAddr);
}
/* update surface read op */
psFlipCmd->psFromSyncInfo->ui32ReadOpsComplete++;
psFlipCmd->psToSyncInfo->ui32ReadOpsComplete++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -