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

📄 pdpmarathon.cpp

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
{
	ENTER("PDP_Contrast");

	ASSERT(pContrast!=0);
	if(bGet)
	{
		*pContrast=m_Contrast;
	}
	else
	{
		m_Contrast=*pContrast;
		ApplyDisplayAdjustment();
	}
	UpdateDisplay();
	EXIT("PDP_Contrast");
	return PDP_ERROR_OK;
}

/*****************************************************************************
 FUNCTION	: 	PDP_Gamma
    
 DESCRIPTION: 	Gets/Sets the Gamma for the current display
 			 
 PARAMETERS	: 	PPDP_GAMMA pGamma
 				BOOL bGet			  

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_Gamma(PPDP_GAMMA pGamma, BOOL bGet)
{
	ENTER("PDP_Gamma");
	
	ASSERT(pGamma!=0);
	if(bGet)
	{
		*pGamma=m_Gamma;
	}
	else
	{
		m_Gamma=*pGamma;
		ApplyDisplayAdjustment();
	}
	UpdateDisplay();

	EXIT("PDP_Gamma");
	return PDP_ERROR_OK;
}

/*****************************************************************************
 FUNCTION	: 	PDP_Brightness
    
 Description: 	Get/Set the Brightness of the Display
 			 
 PARAMETERS	: 	PPDP_BRIGHTNESS pBrightness
 				BOOL bGet			  

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_Brightness(PPDP_BRIGHTNESS pBrightness, BOOL bGet)
{
	ENTER("PDP_Brightness");

	ASSERT(pBrightness!=0);
	if(bGet)
	{
		*pBrightness=m_Brightness;
	}
	else
	{
		m_Brightness=*pBrightness;
		ApplyDisplayAdjustment();
	}
	UpdateDisplay();
	
	EXIT("PDP_Brightness");
	return PDP_ERROR_OK;
}



/*************************************** Power Management ********************/

/*****************************************************************************
 FUNCTION	: 	PDP_Power
    
 DESCRIPTION: 	Sets the Powerstate of the current display
 			 
 PARAMETERS	:  	DWORD dwState,DWORD dwLoss			  

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

#ifdef SUPPORT_POWER_STATE

void  PDPMarathon::PDP_Power(PVR_POWER_STATE eState, DWORD dwFlags)
{
	DWORD dwValue;
#ifndef OSV_PPC
	PDP_TEMPCURSOR sCursor;
	DWORD	dwPosVal;
#endif

	if ((dwFlags & PVRSRV_PRE_STATE_CHANGE_MASK) == 0)
	{
		if (eState != PVRSRV_POWER_STATE_D3)
		{
		PDP_PostPLLChange();
		}

		/* until this API is optimized to not use the PDP API there will be some disturbance going from d3 to any other state*/
		if ((m_eLastState==PVRSRV_POWER_STATE_D3) && ( eState!=PVRSRV_POWER_STATE_D3))
		{
			/* first do a full on power up , we can then apply other low power mode settings from there.*/
			SysCoreEnable(m_sDevData.psDevInfoKM,DEV_CGCORE_PDP_GRAPHICS, IMG_TRUE);
			*m_cRegControl.m_pdwBackground=0x0;
			PDP_SetMode(&m_sModeStruct,FALSE);
			/* Now restore whatever state we had for gamma etc*/
			ApplyDisplayAdjustment();
			/* And the Cursor*/
			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);
		#ifndef OSV_PPC /* No cursor in PPC */
			if(	m_sCursorShapeInfo.wCursor_Attribs == PDP_CURSOR_ENABLE)
			{
				DP_SetPlaneVisible( CURSOR_STREAM, DP_TRUE );
			}
			else
			{
				DP_SetPlaneVisible( CURSOR_STREAM, DP_TRUE );
			}

			ApplyRotation(&sCursor);
			DecodeTempCursor(sCursor);
			dwPosVal = (((DWORD)m_sCursorPos.nXpos)&0xfff)<<12;
			dwPosVal |= (((DWORD)m_sCursorPos.nYpos)&0xfff);
			*m_cRegControl.m_pdwCurPos=dwPosVal;

		#endif /* OSV_PPC */


			/* if we are in 8 bit mode then we need to handle the palette*/
			if(m_sModeStruct.wBitsPerPixel==8)
			{
				PDP_Palette(&m_asPalette[0],0,256,FALSE);
				/* do something for the pallete (this requires us to store it first!)*/
				/* lets come back to this later*/
			}		

			/* The final thing should be the overlay*/
			if(OverlayFieldsValid())
			{
				IMG_BOOL bUpdateOnVSync;

				SysCoreEnable(m_sDevData.psDevInfoKM,DEV_CGCORE_PDP_OVERLAY, IMG_TRUE);
				m_dwUpdateFields= PDP_OVL_DSTPOS|PDP_OVL_SRCPOS	| PDP_OVL_ADDRESS | PDP_OVL_FORMAT | 
									PDP_OVL_CKEY | PDP_OVL_WHS | PDP_OVL_DEINTERLACE | PDP_OVL_VISIBLITY | PDP_OVL_FORMAT;
		  		m_dwOldOvlDestWidth =0;
		  		m_dwOldOvlSrcWidth  =0;
		  		m_dwOldOvlDestHeight=0;
		  		m_dwOldOvlSrcHeight =0;

				/* Apply overlay changes immediately - not on VSync. */
				bUpdateOnVSync = IMG_FALSE;
				ApplyOverlayChanges(bUpdateOnVSync, NULL, NULL);
			}
			/* that should be everything powered up (I think!)*/
		}

		switch (eState)
		{
			case PVRSRV_POWER_STATE_D0:		
				/* make sure everything is powered up!*/
				/* First Bring up the Cores*/
				SysCoreEnable(m_sDevData.psDevInfoKM,DEV_CGCORE_PDP_GRAPHICS, IMG_TRUE);
				if(OverlayFieldsValid() && 	m_bOvlVisible)
				{		/* If the overlay is being used*/
					SysCoreEnable(m_sDevData.psDevInfoKM,DEV_CGCORE_PDP_OVERLAY, IMG_TRUE);
				}

				SysSetPWM(m_dwPWMPort, m_dwBacklightPeriod, m_dwBacklight); // switch backlight on

				/* now bring up the address generators*/
				/* turn off the address fetches*/
				dwValue=*m_cRegControl.m_pdwSTR1Base;
				dwValue |= 0x80000000;
				*m_cRegControl.m_pdwSTR1Base=dwValue;
				if(OverlayFieldsValid() && 	m_bOvlVisible)
				{		/* If the overlay is being used*/
					dwValue=*m_cRegControl.m_pdwSTR2Base;
					dwValue |= 0x80000000;
					*m_cRegControl.m_pdwSTR2Base=dwValue;
				}
				if(m_sCursorShapeInfo.wCursor_Attribs == PDP_CURSOR_ENABLE)
				{
					dwValue=*m_cRegControl.m_pdwCurBase;
					dwValue |= 0x80000000;
					*m_cRegControl.m_pdwCurBase=dwValue;
				}

				/* Finally the Syncs*/
				dwValue=*m_cRegControl.m_pdwSyncCtrl;
				dwValue |= 0x80000000;
				*m_cRegControl.m_pdwSyncCtrl=dwValue;

				if(m_bUserOutputMask)
				{
					*m_cRegControl.m_pdwOutputMask=m_dwUserFullPowerMask;
				}
				else
				{
					*m_cRegControl.m_pdwOutputMask=m_dwDefaultFullPowerMask;
				}
			break;

			case PVRSRV_POWER_STATE_D1:		
				/* make sure everything is powered up!*/
				/* First Bring up the Cores*/
				SysCoreEnable(m_sDevData.psDevInfoKM,DEV_CGCORE_PDP_GRAPHICS, IMG_TRUE);
				SysSetPWM(m_dwPWMPort,m_dwBacklightPeriod,m_dwBacklight); // switch backlight on
				if(OverlayFieldsValid() && 	m_bOvlVisible)
				{		/* If the overlay is being used*/
					SysCoreEnable(m_sDevData.psDevInfoKM,DEV_CGCORE_PDP_OVERLAY, IMG_TRUE);
				}

				/* now bring up the address generators*/
				/* turn off the address fetches*/
				dwValue=*m_cRegControl.m_pdwSTR1Base;
				dwValue |= 0x80000000;
				*m_cRegControl.m_pdwSTR1Base=dwValue;
				if(OverlayFieldsValid() && 	m_bOvlVisible)
				{		/* If the overlay is being used*/
					dwValue=*m_cRegControl.m_pdwSTR2Base;
					dwValue |= 0x80000000;
					*m_cRegControl.m_pdwSTR2Base=dwValue;
				}
				if(m_sCursorShapeInfo.wCursor_Attribs == PDP_CURSOR_ENABLE)
				{
					dwValue=*m_cRegControl.m_pdwCurBase;
					dwValue |= 0x80000000;
					*m_cRegControl.m_pdwCurBase=dwValue;
				}

				/* Finally the Syncs*/
				/* if this is a low refresh display then set it into a low refresh mode?*/
				dwValue=*m_cRegControl.m_pdwSyncCtrl;
				dwValue |= 0x80000000;
				*m_cRegControl.m_pdwSyncCtrl=dwValue;

				if(m_bUserOutputMask)
				{
					*m_cRegControl.m_pdwOutputMask=m_dwUserLowPowerMask;
				}
				else
				{
					*m_cRegControl.m_pdwOutputMask=m_dwDefaultLowPowerMask;
				}
		
//				SysSetPixClkFrequency(m_dwPixClock);
			break;

			case PVRSRV_POWER_STATE_D2:
				SysSetPWM(m_dwPWMPort, m_dwBacklightPeriod, m_dwBacklight); // switch backlight on
				break;

			case PVRSRV_POWER_STATE_D3:		
				/* Turn off the syncs*/
				dwValue=*m_cRegControl.m_pdwSyncCtrl;
				dwValue &= (~0x80000000);
				*m_cRegControl.m_pdwSyncCtrl=dwValue;

				/* Turn off the Cores*/
				SysSetPixClkFrequency(0);
				SysCoreDisable(m_sDevData.psDevInfoKM, DEV_CGCORE_PDP_GRAPHICS, IMG_TRUE);
				SysCoreDisable(m_sDevData.psDevInfoKM, DEV_CGCORE_PDP_OVERLAY, IMG_TRUE);
			break;
		}

		m_eLastState = eState;
	}
	else
	{
		if (m_eLastState != PVRSRV_POWER_STATE_D3)
		{
			PDP_PrePLLChange();
		}
		if(eState==PVRSRV_POWER_STATE_D3)
		{
//			DWORD dwStatus;
			/* We have to turn off the syncs first,*/
			/* Then the Address generators*/
			/* then turn off the core.*/
			if(*m_cRegControl.m_pdwSyncCtrl&0x80000000)
			{
				m_cRegControl.SendRegs();	/* Will wait until all regs are cleared.*/
			}
			*m_cRegControl.m_pdwBackground=0xffffff;
			/* turn off the address fetches*/
			dwValue=*m_cRegControl.m_pdwSTR1Base;
			dwValue &= (~0x80000000);
			*m_cRegControl.m_pdwSTR1Base=dwValue;
		
			dwValue=*m_cRegControl.m_pdwSTR2Base;
			dwValue &= (~0x80000000);
			*m_cRegControl.m_pdwSTR2Base=dwValue;

			dwValue=*m_cRegControl.m_pdwCurBase;
			dwValue &= (~0x80000000);
			*m_cRegControl.m_pdwCurBase=dwValue;			
			while(GetCurrentScanLine());		// Wait until We are on line zero
			while(!GetCurrentScanLine());		// Wait until We are off line zero
			while(GetCurrentScanLine());		// Wait until line zero again

/*			PDP_WaitVBlank(PDPWAITVB_BLOCKEND,&dwStatus);
			PDP_WaitVBlank(PDPWAITVB_BLOCKBEGIN,&dwStatus);
			PDP_WaitVBlank(PDPWAITVB_BLOCKEND,&dwStatus);
			PDP_WaitVBlank(PDPWAITVB_BLOCKBEGIN,&dwStatus);
*/			SysSetPWM(m_dwPWMPort,m_dwBacklightPeriod,0); // Turn backlight off
		}
	}
}


/*****************************************************************************
 FUNCTION	: 	PDP_ScreenPowerPff
    
 DESCRIPTION: 	Sets the Powerstate of the Current Display
 			 
 PARAMETERS	:  	BOOL bOff			  

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_ScreenPowerOff(BOOL bOff)
{
	DWORD	dwValue;
	if(bOff)
	{
		/* First, check that the core is actually turned on... */
		if( (m_eLastState==PVRSRV_POWER_STATE_D0) || (m_eLastState==PVRSRV_POWER_STATE_D1) )
		{
			/* We have to turn off the syncs first,*/
			/* Then the Address generators*/
			/* then turn off the core.*/
			if(*m_cRegControl.m_pdwSyncCtrl&0x80000000)
			{
				m_cRegControl.SendRegs();	/* Will wait until all regs are cleared.*/
			}
			/* Turn off the syncs*/
			dwValue=*m_cRegControl.m_pdwSyncCtrl;
			dwValue &= (~0x80000000);
			*m_cRegControl.m_pdwSyncCtrl=dwValue;

			/* turn off the address fetches*/
			dwValue=*m_cRegControl.m_pdwSTR1Base;
			dwValue &= (~0x80000000);
			*m_cRegControl.m_pdwSTR1Base=dwValue;
		
			dwValue=*m_cRegControl.m_pdwSTR2Base;
			dwValue &= (~0x80000000);
			*m_cRegControl.m_pdwSTR2Base=dwValue;

			dwValue=*m_cRegControl.m_pdwCurBase;
			dwValue &= (~0x80000000);
			*m_cRegControl.m_pdwCurBase=dwValue;

			SysSetPWM(m_dwPWMPort,m_dwBacklightPeriod,0); // turn backlight off
			/* Turn off the Cores*/
			SysSetPixClkFrequency(0);
			SysCoreDisable(m_sDevData.psDevInfoKM, DEV_CGCORE_PDP_GRAPHICS, IMG_TRUE);
			SysCoreDisable(m_sDevData.psDevInfoKM, DEV_CGCORE_PDP_OVERLAY, IMG_TRUE);
		}
		else
		{
			/* Make sure the backlight is off even if the cores are down */
			SysSetPWM(m_dwPWMPort,m_dwBacklightPeriod,0); // Turn backlight off
		}
	}
	else
	{
#if 0 /** WT: 19-09-03 Commented out as it crashes WinCE on system restore from powerdown due to
	                   an "Error: Exception or calling API inside Power Handler" issue. Doesn't seem
					   to affect normal usage, but may need further investigation for use under
					   screensaver situations - not tested as we can't have screensavers with the
					   current system.
	  **/
		/* we here make the assumption that the graphics stream was enabled and that the display had syncs turned on.*/
		/* First Bring up the Cores*/
		DevCoreEnable(m_psDevInfo,DEV_CORE_PDP_GRAPHICS);
		if(OverlayFieldsValid() && 	m_bOvlVisible)
		{		/* If the overlay is being used*/
			DevCoreEnable(m_psDevInfo,DEV_CORE_PDP_OVERLAY);
		}

		/* now bring up the address generators*/
		/* turn off the address fetches*/
		SysSetPWM(m_dwPWMPort,m_dwBacklightPeriod,m_dwBacklight); // switch backlight on
		dwValue=*m_cRegControl.m_pdwSTR1Base;
		dwValue |= 0x80000000;
		*m_cRegControl.m_pdwSTR1Base=dwValue;
		if(OverlayFieldsValid() && 	m_bOvlVisible)
		{		/* If the overlay is being used*/
			dwValue=*m_cRegControl.m_pdwSTR2Base;
			dwValue |= 0x80000000;
			*m_cRegControl.m_pdwSTR2Base=dwValue;
		}
		if(m_sCursorShapeInfo.wCursor_Attribs == PDP_CURSOR_ENABLE)
		{
			dwValue=*m_cRegControl.m_pdwCurBase;
			dwValue |= 0x80000000;
			*m_cRegControl.m_pdwCurBase=dwValue;
		}
		SysSetPixClkFrequency(0);

		/* Finally the Syncs*/
		dwValue=*m_cRegControl.m_pdwSyncCtrl;
		dwValue |= 0x80000000;
		*m_cRegControl.m_pdwSyncCtrl=dwValue;
#endif /** END OF WT: 19-09-03 **/
	}
	return PDP_ERROR_OK;
}
#endif


/*****************************************************************************
 FUNCTION	: 	PDP_PrePLLChange
    
 DESCRIPTION: 	Prepares the PDP for a change of PLL value
 			 
 PARAMETERS	: 	
 				

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_PrePLLChange()
{
	return PDP_ERROR_OK;
}

/*****************************************************************************
 FUNCTION	: 	PDP_PostPLLChange
    
 DESCRIPTION: 	Prepares the PDP for a change of PLL value
 			 
 PARAMETERS	: 	
 				

 RETURNS	: 	PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_PostPLLChange()
{
	return PDP_ERROR_OK;
}

/******************************* Overlay support *******************************/

⌨️ 快捷键说明

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