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

📄 cgating.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
字号:
/***************************************************************************
 * Name        : cgating.c
 * Title       : MBX WinCE driver Core Gating
 * Author(s)   : Imagination Technologies
 * Created	   : 2nd April 2003
 *
 * Copyright   : 2003 by Imagination Technologies. 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 : MBX WinCE driver Core clock gating.
 *
 * Platform    : WinCE
 *
 * Modifications:-
 * $Log: cgating.c $
 * 
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 ****************************************************************************/

#if defined TIMED2DGATING && !defined NO_2D_CLOCKCONTROL

#include <windows.h>

#include "services_headers.h"
#include "cgating.h"

static HANDLE hGateThread;
static HANDLE hBkLightEvent;

/*****************************************************************************
 FunctionName   : GateThreadProc
 Inputs         : PVOID pvParameter (PPVRSRV_DEV_INFO psDevInfo)
 Outputs        : none
 Returns        : dummy value
 Globals used   : none
 Description    : This is the function that controls clock gating and backlighting.
                : It spends it's time waiting for an event or a timout.
*****************************************************************************/
static ULONG GateThreadProc (PVOID pvParameter)
{
	ULONG	ulRtn;
	ULONG	ulPrevOpsCount;

	PPVRSRV_DEV_INFO psDevInfo = (PPVRSRV_DEV_INFO)pvParameter;

	ulPrevOpsCount = 0xFFFFFFFF;

	while(TRUE)
	{
		ulRtn = WaitForSingleObject(hBkLightEvent, GATE_SAMPLE_PERIOD);

		if (ulRtn == WAIT_TIMEOUT)
		{
			/* if we've had any ops */
			if (psDevInfo->sDeviceSpecific.s3D.ui32OpsCount != 0)
			{
				/* but none since we last checked */
				if ((psDevInfo->sDeviceSpecific.s3D.ui32OpsCount == ulPrevOpsCount) &&
					(PVRSRVAcquireSlavePort(psDevInfo, PVRSRV_SLAVEPORT_2D, IMG_FALSE) == PVRSRV_OK))
				{
					/*
						We have to be really careful with the implementation.
						Make sure we can't gate 2D after we've ungated 2D in
						the display driver
					*/
					
					//FIXME: protection required for low power modes and transitions?

					if(SysCoreDisable(psDevInfo, DEV_CGCORE_MBX_2D, IMG_FALSE) == PVRSRV_OK)
					{
						/* re-initialise ops after gating */
						psDevInfo->sDeviceSpecific.s3D.ui32OpsCount = 0;
						ulPrevOpsCount = 0;
					}

					if(PVRSRVReleaseSlavePort (psDevInfo, PVRSRV_SLAVEPORT_2D) != PVRSRV_OK)
					{
						PVR_DPF((PVR_DBG_ERROR,"PVRSRVReleaseSlavePort: failed to release slaveport"));
					}		

				}
				else
				{
					/* record the op count to test against on the next check */
					ulPrevOpsCount = psDevInfo->sDeviceSpecific.s3D.ui32OpsCount;
				}
			}
		}
		else
		{
			PVR_DPF((PVR_DBG_MESSAGE, "An event ... %lX", ulRtn));
			break;
		}
	}

	return (0);
}


/*****************************************************************************
 FunctionName   : CreateGatingThread
 Inputs         : PPVRSRV_DEV_INFO psDevInfo
 Outputs        : none
 Returns        : none
 Globals used   : none
 Description    : Creates a thread to handle core clock gating
*****************************************************************************/
void CreateGatingThread (PPVRSRV_DEV_INFO psDevInfo)
{
	/* init count */
	psDevInfo->sDeviceSpecific.s3D.ui32OpsCount = 0;

	if ((hGateThread = CreateThread(NULL, 0, GateThreadProc, psDevInfo, 0, NULL)) == NULL)
	{
		PVR_DPF((PVR_DBG_ERROR, "Unable to create thread for core clock gating."));
	}
	else
	{
		hBkLightEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
	}
}


/*****************************************************************************
 FunctionName   : DestroyGatingThread
 Inputs         : PPVRSRV_DEV_INFO psDevInfo
 Outputs        : none
 Returns        : none
 Globals used   : none
 Description    : Destroys the thread which handles core clock gating
*****************************************************************************/
void DestroyGatingThread (PPVRSRV_DEV_INFO  psDevInfo)
{
	if (SetEvent(hBkLightEvent))
	{
		WaitForSingleObject(hGateThread, INFINITE);
		CloseHandle(hGateThread);
		CloseHandle(hBkLightEvent);
	}
}

#endif /* TIMED2DGATING && !NO_2D_CLOCKCONTROL*/

/********************************** end of file ******************************/

⌨️ 快捷键说明

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