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

📄 pdpmarathon.cpp

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		{
			dwColor=n<<8;
			dwColor|=psCur->byRed;
			dwColor<<=8;
			dwColor|=psCur->byGreen;
			dwColor<<=8;
			dwColor|=psCur->byBlue;
			m_asPalette[n]=*psCur;
			/* we need to guarantee that the write has gone through so use the blocking write*/
			m_cRegControl.WriteBlockingReg(PDP_PALETTEDATA,dwColor);
		}
	}	
	if(!bGet)
	{
		UpdateDisplay();
	}
	EXIT("PDP_Palette");
	return PDP_ERROR_OK;
}

/*****************************************************************************
 FUNCTION	: 	PDP_CursorPos
    
 DESCRIPTION: 	Get/Set the current cursor position
 			 
 PARAMETERS	: 	PPDP_CURSORPOS psCursorPos
 				BOOL bGet			  

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_CursorPos(PPDP_CURSORPOS psCursorPos, BOOL bGet)
{
	DWORD dwPosVal;
	WORD wScaledXPos,wScaledYPos;
	ASSERT(psCursorPos!=0);

	if(bGet)
	{
		/* Should return the Params here, but we haven't stored them yet*/
		*psCursorPos=m_sCursorPos;
	}
	else
	{
		/* Store the Values as well here*/
		m_sCursorPos=*psCursorPos;
		
		/* Clip the values so that we don't try and go all the way off the edge of the screen! */
		if(m_sCursorPos.nXpos<-63)
			m_sCursorPos.nXpos=-63;
		if(m_sCursorPos.nYpos<-63)
			m_sCursorPos.nYpos=-63;

		wScaledXPos  = m_sCursorPos.nXpos ;
		wScaledYPos = m_sCursorPos.nYpos;

		if(m_bLineDouble)
		{
			wScaledYPos*=2;
		}

		if(m_bPixelDouble)
		{
			wScaledXPos*=2;
		}
		if(wScaledXPos<-63)
			wScaledXPos=-63;
		if(wScaledYPos<-63)
			wScaledYPos=-63;

		dwPosVal = (((DWORD)wScaledXPos)&0xfff)<<12;
		dwPosVal |= (((DWORD)wScaledYPos)&0xfff);
		*m_cRegControl.m_pdwCurPos=dwPosVal;
	}		
	UpdateDisplay();

	return PDP_ERROR_OK;
}

/*****************************************************************************
 FUNCTION	: 	PDP_CursorProperties
    
 DESCRIPTION: 	Gets/Sets the current cursor properties.
 			 
 PARAMETERS	: 	PPDP_CURSOR_PROPERTIES pCursorProperties
 				BOOL bGet			  

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_CursorProperties(PPDP_CURSOR_SHAPEINFO pCursorShapeInfo, BOOL bGet)
{
	int				nXpos,nYpos;
	PDP_TEMPCURSOR	sCursor;
	PDP_ERROR		FnRetVal = PDP_ERROR_OK;
 

//	ENTER("PDP_CursorProperties");
	ASSERT(pCursorShapeInfo!=0);

	/* Cursor buffer is pre-allocated in PDP_Init to make sure it is allocated in */
	/* ODFB for display refresh uage. In VGA mode, mask buffer will be psuhed out to LM. */
	/* This does not impact performance. */
	/* 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);
	{
		DWORD dwTemp;
		dwTemp=*m_cRegControl.m_pdwCurMask;
		if(m_bLineDouble)
		{
			dwTemp|=0x40000000;
		}

		if(m_bPixelDouble)
		{
			dwTemp|=0x80000000;
		}

		*m_cRegControl.m_pdwCurMask=dwTemp;
	}


	if(bGet)
	{
		*pCursorShapeInfo=m_sCursorShapeInfo;
	}
	else
	{
		m_sCursorShapeInfo=*pCursorShapeInfo;

		nXpos=m_sCursorPos.nXpos;
		nYpos=m_sCursorPos.nYpos;
		if (pCursorShapeInfo->pvScan0)
		{
			if (!pCursorShapeInfo->Colors)
			{
				/* Note that because there are two masks, the height is double.*/
				if ((pCursorShapeInfo->Width != 32 && pCursorShapeInfo->Height != 64)) 
				{
					return (PDP_ERROR_OK+1);
				}

				/* Iterate over scanlines in the cursor. For each scanline, iterate over */
				/* the bytes in the scanline. Each byte needs to be interleaved. This */
				/* resolves into 8 pixels.*/
				EncodeTempCursor(pCursorShapeInfo);
				ApplyRotation(&sCursor);
				DecodeTempCursor(sCursor);

			}
			else
			{
				return (PDP_ERROR_OK+2);
			}
			
			m_sCursorShapeInfo.wCursor_Attribs = PDP_CURSOR_ENABLE;
			DP_SetPlaneVisible				( CURSOR_STREAM, DP_TRUE );
		}
		else
		{
			DP_SetPlaneVisible				( CURSOR_STREAM, DP_FALSE );
			m_sCursorShapeInfo.wCursor_Attribs = 0;

		}
	}
	UpdateDisplay();	 
//	EXIT("PDP_CursorProperties");
	return FnRetVal;
}

/*****************************************************************************
 FUNCTION	: 	PDP_Init
    
 DESCRIPTION: 	Initialsed the PDP Pipeline
 			 
 PARAMETERS	: 			  

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/

PDP_ERROR PDPMarathon::PDP_Init()
{
	PDP_ERROR FnRetVal = PDP_ERROR_OK;  /* Return value for this function.*/
	HKEY	hConfig = (HKEY)INVALID_HANDLE_VALUE;
	ULONG	ulRet, ulValue,ulSize, ulType = 0;
	PDP_EnumerateModesList	sModes;
	ENTER("PDP_Init");

	/* Get the Device Data for the PDP hardware */
	if(PVRSRVAcquireDeviceData (NULL,	
								0,		
								&m_sDevData,
								PVRSRV_DEVICE_TYPE_PDP) != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "Failed to get Device Info"));
		FnRetVal=PDP_ERROR_GENERIC;
	}
	else
	{
		DP_pui32BaseAddress=(PDWORD)m_sDevData.psDevInfoKM->sDevLocation.pvRegsBaseKM;
		/* Set up default values etc for things*/
		m_nOvlTop		=	0;
		m_nOvlLeft		=	0;
		m_nOvlBottom	=	0;
		m_nOvlRight		=	0;
		m_bDestValid	=	FALSE;
			
			/* Source position*/
		m_wOvlSrcTop	=	0;
		m_wOvlSrcLeft	=	0;
		m_wOvlSrcBottom	=	0;
		m_wOvlSrcRight	=	0;
		m_bSrcValid		=	FALSE;

		 /* Width and Height for source and destination */
	  	m_dwOldOvlDestWidth =0;
	  	m_dwOldOvlSrcWidth  =0;
	  	m_dwOldOvlDestHeight=0;
	  	m_dwOldOvlSrcHeight =0;

			/* Colorkey*/
		m_dwOvlCKeyValue=	0;
		m_bCKeyOn		=	FALSE;

			/* Pixel Format*/
		m_eOvlPixFmt	=	PDP_OVL_INVALID;
		m_bPixFmtValid	=	FALSE;
							
			/* Visibility*/
		m_bOvlVisible		=	FALSE;


			/* Address*/
		m_bAddressValid	=	FALSE;
		/* Base address of overlay in RGB mode, and address of Y plane in planar modes*/
		m_pvOvlBase		=	0;			
		m_pvOvlUBase	=	0;
		m_pvOvlVBase	=	0;

			/* Buffer Dimensions*/
		m_bWHSValid		=	FALSE;
		m_wWidth		=	0;			/* Width of overlay data in pixels*/
		m_wHeight		=	0;			/* Height of overlay data in lines*/
		m_wStride		=	0;			/* Stride of overlay in pixels*/

			/* Deinterlacing;*/
	 	m_DeInterlace	  =	PDP_WEAVE;	/* Can be either WEAVE, BOB_ODDD or BOB_EVEN*/
		m_dwUpdateFields = PDP_OVL_CKEY; /* must be applied*/

		m_Gamma=100;
		m_Contrast=128;
		m_Brightness=128;

		m_VidGamma=100;
		m_VidContrast=128;
		m_VidBrightness=128;

		m_sCursorShapeInfo.wCursor_Attribs = 0;
		m_pLoaderMem = NULL;

		m_bOverlayConfigMemAllocated = IMG_FALSE;
		m_ui32OverlayConfigMemIndex = 0;

		m_pAllocMem = NULL;

	#ifdef SUPPORT_POWER_STATE
		m_eLastState=PVRSRV_POWER_STATE_D0;
	#endif
		m_dwBacklight=0x3FF;

		m_dwCursorRotation=DMDO_0;
		m_sDevData.psDevInfoKM->sDeviceSpecific.sDisplay.bIsDirty=IMG_TRUE;

		m_dwStr1=0;
		m_dwStr2=0;
		m_dwStr3=0;
		m_dwSync=0;


		ulRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT(POWERVR_REG_ROOT), 0, 0, &hConfig);

		// Trap this error because using an invalid hConfig has been know to cause an exception error in PocketPC
		if (ulRet != ERROR_SUCCESS)
		{
			PVR_DPF((PVR_DBG_ERROR, "Failed to get Panel Info"));
			FnRetVal = PDP_ERROR_GENERIC;
		}
		else
		{
			///////////////////////////////////////////////////////////// Load main panel value

			GetPanelRegInfo(hConfig, TEXT("Panel"),	TRUE);				// Get the Internal panel config.
			GetPanelRegInfo(hConfig, TEXT("PanelExt"), FALSE);			// Get the external panel config.

			/////////////////////////////////////////////////////////////////////////////////////

			m_dwInternal=m_dwPanel;
			m_dwExternal=m_dwPanelOther;

			m_sDisplayConfig.sLcdInternal.bValid=IMG_TRUE;
			m_sDisplayConfig.sLcdInternal.eLcdSource=PVR_SOURCE_PDP;
			m_sDisplayConfig.sLcdInternal.bActivate=IMG_TRUE;

			m_sDisplayConfig.sLcdExternal.bValid=IMG_FALSE;

			m_sDisplayConfig.sConnectSurface.eSurface=PVR_DESKTOP; 
    		/* Border Colour & Refresh Rate fields only valid if surface PVR_SECONDARYSURFACE */
    		m_sDisplayConfig.sConnectSurface.ui32BorderColour=0;   /* Border colour if required */
    		m_sDisplayConfig.sConnectSurface.ui32RefreshRate=60;    /* Recommendation only */


			ulSize	= sizeof(ULONG);
			ulRet = RegQueryValueEx (hConfig, TEXT("OutputMask"), 0, &ulType, (PUCHAR)&ulValue, &ulSize);
			if((ulRet == ERROR_SUCCESS) && (ulType == REG_DWORD))
			{
				// we have got our output mask so store it.
				m_dwDefaultLowPowerMask=ulValue;
			}
			else
			{
				m_dwDefaultLowPowerMask=0;
			}
			m_dwDefaultFullPowerMask=0;
			
	  		if (hConfig != INVALID_HANDLE_VALUE)
	  		{
				RegCloseKey(hConfig);
	  		}

	#ifdef DEBUG
			SysWriteLEDData(m_dwPanel);
			SysWriteLEDBits((BYTE)m_dwPanel);
	#endif
			PDPConstructModeTable((PDP_TIMINGSELECT)m_dwPanel,&sModes);

			m_wModeCount=sModes.wCount;
			m_psModeList=sModes.psModeList;
		}
		
		/* Allocate an array of overlay configuration buffers if required. */
		if (m_bOverlayConfigMemAllocated == IMG_FALSE)
		{
			for (int i = 0; i < NUM_OVERLAY_CONFIG_BUFFERS; i++)
			{
				/* Allocate some memory for the overlay configuration buffer (for overlay register writes). */
				if(PVRSRVAllocDeviceMem(&m_sDevData, 
										0,
										128 * sizeof(IMG_UINT32), 
										8,
										&(m_apOverlayConfigMem[i])) != PVRSRV_OK)			
				{
						PVR_DPF((PVR_DBG_ERROR, "PDP_Init: Call to PVRSRVAllocDeviceMem failed\n"));
						return PDP_ERROR_GENERIC;
				}
			}

			/* Overlay config buffers have now been allocated */
			m_bOverlayConfigMemAllocated = IMG_TRUE;
			m_ui32OverlayConfigMemIndex = 0;
		}

		// Pre-allocate 8KB space on ODFB for cursor buffer
		// Cursor buffer needs to be allocated in ODFB to avoid to access LM during SDRAM self-refresh
		// This is not needed for PPC since no HW cursor is available in PPC 
		if(m_pAllocMem == NULL)
		{
			// Attempt to allocate cursor buffer in internal memory 
			if(PVRSRVAllocDeviceMem(&m_sDevData, 
								PVRSRV_MEMFLG_CONTIGIOUS | PVRSRV_MEMFLG_ALTERNATE_HEAP,
								64*64*2, 
								8,
								&m_pAllocMem) != PVRSRV_OK)
			{
				PVR_DPF((PVR_DBG_ERROR, "Unable to Allocate Memory for Cursor!\n"));
				FnRetVal=PDP_ERROR_GENERIC;
			}
		}
	}

	if(g_PDPHandle==NULL)
	{
		g_PDPHandle=(PDPHANDLE)this;
	}
	EXIT("PDP_Init");
	return FnRetVal;
}

void PDPMarathon::GetPanelRegInfo(HKEY hConfig, TCHAR *szRegKey, BOOL bConnentedToPDP)
{
	ULONG	ulRet, ulValue,ulSize, ulType = 0;
	DWORD	dwPanel, dwLCDPort, dwPWMPort;

	ulSize = sizeof(ULONG);

	ulRet = RegQueryValueEx (hConfig, szRegKey, 0, &ulType, (PUCHAR)&ulValue, &ulSize);

	if((ulRet == ERROR_SUCCESS) && (ulType == REG_DWORD))		/* Binary format*/
	{
		dwLCDPort	= ulValue & PDP_REGISTRY_PANEL_LCDPORT ? 2 : 1;
		dwPWMPort	= ulValue & PDP_REGISTRY_PANEL_PWMPORT ? 1 : 0;
		dwPanel		= ulValue & PDP_REGISTRY_PANEL_INX_MASK;

#ifdef DEBUG
		if(dwPanel == PDP_REGISTRY_PANEL_OVERRIDE)
		{
			/* get the switch settings here!*/
			dwPanel = SysReadUserSwitches() & PDP_REGISTRY_PANEL_INX_MASK;

			PVR_DPF((PVR_DBG_WARNING, "Override with a switch value of 0x%x",dwPanel)); 
		}
		else
#endif
		{
			PVR_DPF((PVR_DBG_WARNING, "Override with a registry value of 0x%x",ulValue));
		}	
	}
	else
	{
		PVR_DPF((PVR_DBG_WARNING, "Using the default Sharp Panel on LCD port 1, PWM port 0"));

		dwPanel		= PDP_SHARP_LQ057Q3DC02;
		dwLCDPort	= 1;
		dwPWMPort	= 0;
	}

	if(bConnentedToPDP)
	{
		m_dwPanel			= dwPanel;		
		m_dwPanelLCDPort	= dwLCDPort;
		m_dwPWMPort			= dwPWMPort;
	}
	else
	{
		m_dwPanelOther			= dwPanel;
		m_dwPanelLCDPortOther	= dwLCDPort;
		m_dwPWMPortOther		= dwPWMPort;
	}
}

/******************************** Display Adjustment**************************/

/*****************************************************************************
 FUNCTION	: 	PDP_Contrast
    
 DESCRIPTION: 	Gets/Sets the Contrast for the current Display
 			 
 PARAMETERS	: 	PPDP_CONTRAST pContrast
 				BOOL bGet			  

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_Contrast(PPDP_CONTRAST pContrast, BOOL bGet)

⌨️ 快捷键说明

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