📄 pdpmarathon.cpp
字号:
/**************************************************************************
Name : PDPMarathon.cpp
Title : PDP Abstraction Layer
Author : Paul Buxton
Created : 30 October 2002
Copyright : 2002 by Imaginationc 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.
Description : PDP Implementation for Marathon
Platform : WinCE
Version : $Revision: 1.25 $
Modifications :
$Log: pdpmarathon.cpp $
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
--- Revision Logs Removed ---
**************************************************************************/
#ifdef SUPPORT_PDP_DISPLAY
#include <windows.h>
#include <winddi.h>
extern "C"
{
#include "services_headers.h"
// #include "pdpal.h"
#include "dp_types.h"
#include "dp_init_marathon.h"
#include "dp_hardware_dispatcher.h"
#include "regpaths.h"
#include "sccoef.h"
#include "pdptimings.h"
}
#include "pdpal.h"
#include "pdpdefs.h"
/* As these are specific to PDP, they are in here, rather than in pdpal.h which is really for the API
If any more defines are required they will be put into their own file */
#define PDP_CURSOR_COLOUR_INVERT 0x7fff
#define PDP_CURSOR_COLOUR_TRANS 0x0fff
#define PDP_CURSOR_COLOUR_WHITE 0xffff
#define PDP_CURSOR_COLOUR_BLACK 0xf000
#define CLIP(X) (X<0 ? 0 : X)
#define PDP_FORMAT_YUY2 (0xe<<27)
#define PDP_FORMAT_IMC2 (0x9<<27)
#define PDP_FORMAT_YV12 (0x9<<27)
//#define FORCE_UPDATE_ON_REDUCED_REFRESH 1
# if 1
#define ENTER(X) PVR_DPF((PVR_DBG_MESSAGE,"Entering %hs",X))
#define EXIT(X) PVR_DPF((PVR_DBG_MESSAGE,"Exiting %hs",X))
#else
#define ENTER /##/
#define EXIT /##/
#endif
#define LINEDOUBLE 0x20000000
#define PIXELDOUBLE 0x80000000
static IMG_VOID ConfigOverlay(IMG_UINT32 wOffset,
IMG_UINT32 dwValue,
IMG_UINT32* pui32OverlayConfig,
IMG_UINT32* pui32OverlayConfigSize);
/*****************************************************************************
FUNCTION : PDP_SetMode
DESCRIPTION: Gets/Sets the displaymode for the display pipeline.
PARAMETERS : PPDP_SETMODE psModeStruct
BOOL bGet
RETURNS : PDP_ERROR_OK, or an error code.
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_SetMode (PPDP_SETMODE psModeStruct, BOOL bGet)
{
DP_InitData sInitData;
PDP_TIMINGS sTimings;
PDP_ERROR FnRetVal=PDP_ERROR_OK;
DWORD dwSyncReg;
WORD wRetVal;
DWORD *pdwListLoader;
ENTER("PDP_SetMode");
ASSERT(psModeStruct!=0);
#ifdef LOCAL_MEMORY_SELF_REFRESH
SysLocalMemoryEnable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
if(m_pLoaderMem == NULL)
{ // Set up the list loader
// first allocate some memory for it
if(PVRSRVAllocDeviceMem(&m_sDevData,
PVRSRV_MEMFLG_CONTIGIOUS | PVRSRV_MEMFLG_ALTERNATE_HEAP,
128*sizeof(DWORD),
8,
&m_pLoaderMem) != PVRSRV_OK)
{
// Internal failed, lets try external
if(PVRSRVAllocDeviceMem(&m_sDevData,
PVRSRV_MEMFLG_CONTIGIOUS,
128*sizeof(DWORD),
8,
&m_pLoaderMem) != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "Unable to Allocate Memory for Cursor!\n"));
FnRetVal=PDP_ERROR_GENERIC;
}
}
// now set it up.
m_cRegControl.Init(DP_pui32BaseAddress,
m_pLoaderMem->uiDevAddr.uiAddr,
(DWORD)m_pLoaderMem->pvLinAddr ,128);
pdwListLoader= (PDWORD)m_pLoaderMem->pvLinAddr;
*pdwListLoader++=0xc4;
*pdwListLoader=0xdeadbeef;
}
if(bGet)
{
*psModeStruct=m_sModeStruct;
}
else
{
// PDUMPSTART();
// PDUMPCOMMENT("Set Mode");
m_sModeStruct=*psModeStruct;
if(GetModeTimings(m_sModeStruct.wDisplayX,m_sModeStruct.wDisplayY,60,(PDP_TIMINGSELECT)m_dwPanel,&sTimings)!=PDP_ERROR_OK)
{
PVR_DPF((PVR_DBG_ERROR, "Unable to Get Timings for the device!\n"));
FnRetVal=PDP_ERROR_INVALID_PARAMS;
/* sTimings is invalid - therefore return before it is used. */
#ifdef LOCAL_MEMORY_SELF_REFRESH
SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
return FnRetVal;
}
TimingsToRelative(&sTimings ,&m_sRelative);
m_dwBacklightPeriod=sTimings.dwBacklightPeriod;
m_bLineDouble=sTimings.bLineDouble;
m_bPixelDouble=sTimings.bPixelDouble;
sInitData.sTimingSettings.ui16HBPS = m_sRelative.HBPS;
sInitData.sTimingSettings.ui16HT = m_sRelative.HT;
sInitData.sTimingSettings.ui16HAS = m_sRelative.HAS;
sInitData.sTimingSettings.ui16HLBS = m_sRelative.HLBS;
sInitData.sTimingSettings.ui16HFPS = m_sRelative.HFPS;
sInitData.sTimingSettings.ui16HRBS = m_sRelative.HRBS;
sInitData.bCRCControl = DP_FALSE; // Doesn't seem to do anything
sInitData.bVerticalSyncSlaved = DP_FALSE; // What it sounds like
sInitData.bHorizontalSyncSlaved = DP_FALSE; // VSync Master
sInitData.bBlankingPolarity = (DP_BOOL)sTimings.bBlankingPositive; // Positive Blanking?
sInitData.bBlankSignalDisable = DP_FALSE; // Blank Signal ON
sInitData.bVerticalSyncPolarity = (DP_BOOL)sTimings.bVSync; // Positive Sync?
sInitData.bVerticalSyncDisable = DP_FALSE; // VSync On ?
sInitData.bHorizontalSyncPolarity = (DP_BOOL)sTimings.bHSync; // HSync Positive?
sInitData.bHorizontalSyncDisable = DP_FALSE; // HSync On
sInitData.bInterlaceOn = DP_FALSE; // No interlacing
sInitData.bFieldPolarity = DP_FALSE; // Field ordering?
sInitData.bCompositeSyncEnable = DP_FALSE; // Composite Sync?
sInitData.eMemoryRefreshPeriod = DP_MEMORY_REFRESH_ALWAYS;
/*DP_MEMORY_REFRESH_V_BLANK_ONLY; */
/* Specify when we can refresh memory
Valid values are
DP_MEMORY_REFRESH_ALWAYS
DP_MEMORY_REFRESH_H_BLANK_ONLY,
DP_MEMORY_REFRESH_V_BLANK_ONLY,
DP_MEMORY_REFRESH_H_AND_V_BLANK
*/
sInitData.ui8MemoryBurstLength = 0x10; /* Burst Size*/
sInitData.bVerticalScalerUnderrunControl = DP_TRUE; /* Acknowledge and Handle Underrun Status*/
/* Display Timings*/
/* These can be generated dynamically*/
/* or be predefined depending on output device*/
sInitData.sTimingSettings.ui16VBPS = m_sRelative.VBPS;
sInitData.sTimingSettings.ui16VT = m_sRelative.VT;
sInitData.sTimingSettings.ui16VAS = m_sRelative.VAS;
sInitData.sTimingSettings.ui16VTBS = m_sRelative.VTBS;
sInitData.sTimingSettings.ui16VFPS = m_sRelative.VFPS;
sInitData.sTimingSettings.ui16VBBS = m_sRelative.VBBS;
/* these are the values used for the update mode.*/
/* These should be decoded and written to the update fields of the sync reg.*/
m_eDisplayUpdate = sTimings.eDisplayUpdate;
m_wUpdateWait = sTimings.wUpdateWait;
m_bFullRateSyncs = sTimings.bFullRateSyncs;
m_bFullRateInterrupts = sTimings.bFullRateInterrupts;
m_dwPixClock = sTimings.dwClockHz;
SysSetPixClkFrequency(sTimings.dwClockHz);
wRetVal=DP_InitialiseDisplay (sInitData);
dwSyncReg=*m_cRegControl.m_pdwSyncCtrl;
dwSyncReg&=~(0x70f0000); /* Mask out the Update bits*/
switch(m_eDisplayUpdate)
{
case PDP_FULL_REFRESH:
/* do nothing here, all is as it should be */
break;
case PDP_REDUCED_REFRESH:
/* set the Updaitwait to be the specified value*/
dwSyncReg|=((m_wUpdateWait&0xf)<<16);
break;
case PDP_SINGLE_REFRESH:
dwSyncReg|=(1<<24); /* Set the Single Shot mode bit.*/
break;
}
if(!m_bFullRateInterrupts)
{
dwSyncReg|=(1<<25); /* Set the Reduced rate Interrupts bit*/
}
if(!m_bFullRateSyncs)
{
dwSyncReg|=(1<<26); /* Set the Reduced rate syncs bit*/
}
*m_cRegControl.m_pdwSyncCtrl=dwSyncReg;
wRetVal=DP_SetSourceAddress(GRAPHICS_STREAM,
DP_YUV_Y_OR_SOLE_RGB,
(PVOID) m_sModeStruct.psMemInfo->uiDevAddr.uiAddr,
m_sModeStruct.wStride/16,
DP_FALSE,
DP_SOURCE_DATA_TYPE_PROGRESSIVE);
switch(m_sModeStruct.wBitsPerPixel)
{
case 8:
wRetVal=DP_SetPixelColourFormat ( GRAPHICS_STREAM, DP_PIXEL_COLOUR_FORMAT_8_BIT_INDEXED, DP_FALSE );
DP_SetPaletteEnable(GRAPHICS_STREAM,DP_TRUE);
break;
case 16:
wRetVal=DP_SetPixelColourFormat ( GRAPHICS_STREAM, DP_PIXEL_COLOUR_FORMAT_16_BIT_RGB_565, DP_FALSE );
break;
case 24:
wRetVal=DP_SetPixelColourFormat ( GRAPHICS_STREAM, DP_PIXEL_COLOUR_FORMAT_24_BIT_RGB_888, DP_FALSE );
break;
case 32:
wRetVal=DP_SetPixelColourFormat ( GRAPHICS_STREAM, DP_PIXEL_COLOUR_FORMAT_24_BIT_RGB_888_8_BIT_ALPHA, DP_FALSE );
break;
}
m_sDisplayConfig.bSet=IMG_TRUE;
wRetVal=PDP_ConfigureDisplaySystem(&m_sDisplayConfig);
// Setup PDP hardware
wRetVal=DP_SetSourceImageSize ( GRAPHICS_STREAM, sTimings.wHActive, sTimings.wVActive );
wRetVal=DP_SetSourceFrameSize ( GRAPHICS_STREAM, sTimings.wHActive, sTimings.wVActive );
/* call set source address with the required settings*/
wRetVal=DP_SetDestinationFramePosition ( GRAPHICS_STREAM, 0, 0 );
{
WORD wScaledWidth,wScaledHeight;
wScaledWidth = sTimings.wHActive;
wScaledHeight = sTimings.wVActive;
if(m_bLineDouble)
{
wScaledHeight*=2;
}
if(m_bPixelDouble)
{
wScaledWidth*=2;
}
wRetVal=DP_SetDestinationFrameSize ( GRAPHICS_STREAM,wScaledWidth ,wScaledHeight );
}
wRetVal=DP_SetPlaneVisible ( GRAPHICS_STREAM, DP_TRUE );
/* plane is now set up, all that remains is to enable the display*/
wRetVal=DP_SetDisplayEnabled(DP_DISPLAY_ENABLED);
// do this here as Toms API does not look like it is handling it correctly.
{
DWORD dwTemp;
dwTemp=*m_cRegControl.m_pdwSTR1Mask;
if(m_bLineDouble)
{
dwTemp|=LINEDOUBLE ;
}
else
{
dwTemp&=~LINEDOUBLE;
}
if(m_bPixelDouble)
{
dwTemp|=PIXELDOUBLE;
}
else
{
dwTemp&=~PIXELDOUBLE;
}
*m_cRegControl.m_pdwSTR1Mask=dwTemp;
}
// DevCoreDisable(m_psDevInfo, DEV_CORE_PDP_OVERLAY);
SysCoreEnable(m_sDevData.psDevInfoKM, DEV_CGCORE_PDP_GRAPHICS, IMG_TRUE);
DP_SetGammaEnable(GRAPHICS_STREAM,DP_TRUE);
DP_SetGammaEnable(OVL_STREAM,DP_TRUE);
ApplyDisplayAdjustment(); /* lets leave this for the time being*/
ApplyVideoAdjustment(); /* lets leave this for the time being*/
*m_cRegControl.m_pdwMemCtrl= 0xd0303010;/* Change the Burst size and threshold*/
// *m_cRegControl.m_pdwMemCtrl= 0x18383808;/* Default Burst size and threshold*/
UpdateDisplay();
*m_cRegControl.m_pdwBorder=m_sDisplayConfig.sConnectSurface.ui32BorderColour;
SysSetPWM(m_dwPWMPort, m_dwBacklightPeriod, m_dwBacklight); // turn backlight on
// Set up the Active rect structure.
m_sActiveRect.wTop=(WORD)(*m_cRegControl.m_pdwVDE>>16)&0xffff;
m_sActiveRect.wBottom=(WORD)(*m_cRegControl.m_pdwVDE)&0xffff;
m_sActiveRect.wLeft=(WORD)(*m_cRegControl.m_pdwHDE>>16)&0xffff;
m_sActiveRect.wRight=(WORD)(*m_cRegControl.m_pdwHDE)&0xffff;
if(m_pAllocMem)
{
/* the cursor is now allocaed.*/
m_pvCursorAddress=(void *)(m_pAllocMem->uiDevAddr.uiAddr);
DP_SetPixelColourFormat(CURSOR_STREAM, DP_PIXEL_COLOUR_FORMAT_12_BIT_RGB_444_4_BIT_ALPHA, DP_FALSE );
DP_SetSourceAddress(CURSOR_STREAM,
DP_YUV_Y_OR_SOLE_RGB,
(PVOID)((DWORD)m_pvCursorAddress),
8,
DP_FALSE,
DP_SOURCE_DATA_TYPE_PROGRESSIVE);
DP_SetSourceImageSize(CURSOR_STREAM, 64, 64 );
DP_SetSourceFrameSize(CURSOR_STREAM, 64, 64 );
/* transparent color is 11100011b */
DP_SetColourKeyMode(CURSOR_STREAM,DP_FALSE,DP_TRUE,0x00ff00ff,0x00e000c0);
DP_SetAlphaBlendMode(CURSOR_STREAM,DP_ALPHA_BLEND_MODE_INVERT,0x80);
if(m_sCursorShapeInfo.wCursor_Attribs == PDP_CURSOR_ENABLE)
DP_SetPlaneVisible( CURSOR_STREAM, DP_TRUE );
else
DP_SetPlaneVisible( CURSOR_STREAM, DP_FALSE );
}
m_bUserOutputMask=FALSE;
*m_cRegControl.m_pdwOutputMask=m_dwDefaultFullPowerMask;
*m_cRegControl.m_pdwBackground=0x0;
m_dwStr1=*m_cRegControl.m_pdwSTR1Base;
m_dwStr2=*m_cRegControl.m_pdwSTR2Base;
m_dwStr3=*m_cRegControl.m_pdwCurBase;
m_dwSync=*m_cRegControl.m_pdwSyncCtrl;
RegisterPrimarySurfaceInfo();
//
// PDUMPCOMMENT("End of Set Mode");
// PDUMPSTOP();
}
#ifdef LOCAL_MEMORY_SELF_REFRESH
SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
EXIT("PDP_SetMode");
return FnRetVal;
}
/*****************************************************************************
FUNCTION : PDP_Palette
DESCRIPTION: Sets/Gets the Current Hardware Palette
PARAMETERS : PPDP_PALETTE psPalette
BYTE byStart
BYTE byCount
BOOL bGet
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_Palette(PPDP_PALETTE psPalette,WORD Start,WORD Count, BOOL bGet)
{
int n;
DWORD dwColor;
PPDP_PALETTE psCur;
ENTER("PDP_Palette");
ASSERT(psPalette!=0);
ASSERT ((Start + Count) <= 256);
for(n=Start,psCur=psPalette;n<((int)Start+Count);n++,psCur++)
{
if(bGet)
{
*psCur=m_asPalette[n];
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -