Esempio n. 1
0
static enum PVRSRV_ERROR PVRSRVDevicePrePowerStateKM(IMG_BOOL bAllDevices,
					 u32 ui32DeviceIndex,
					 enum PVR_POWER_STATE eNewPowerState)
{
	enum PVRSRV_ERROR eError;
	struct SYS_DATA *psSysData;
	struct PVRSRV_POWER_DEV *psPowerDevice;
	enum PVR_POWER_STATE eNewDevicePowerState;

	eError = SysAcquireData(&psSysData);
	if (eError != PVRSRV_OK)
		return eError;

	psPowerDevice = psSysData->psPowerDeviceList;
	while (psPowerDevice) {
		if (bAllDevices ||
		    (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)) {
			eNewDevicePowerState =
			    (eNewPowerState == PVRSRV_POWER_Unspecified) ?
					psPowerDevice->eDefaultPowerState :
					eNewPowerState;

			if (psPowerDevice->eCurrentPowerState !=
			    eNewDevicePowerState) {
				if (psPowerDevice->pfnPrePower != NULL) {
					eError =
					    psPowerDevice->
					    pfnPrePower(psPowerDevice->
							hDevCookie,
							eNewDevicePowerState,
							psPowerDevice->
							eCurrentPowerState);
					if (eError != PVRSRV_OK) {
						pr_err
						   ("pfnPrePower failed (%u)\n",
						     eError);
						return eError;
					}
				}

				eError = SysDevicePrePowerState(
					     psPowerDevice->ui32DeviceIndex,
					     eNewDevicePowerState,
					     psPowerDevice->eCurrentPowerState);
				if (eError != PVRSRV_OK) {
					pr_err("SysDevicePrePowerState failed "
						"(%u)\n", eError);
					return eError;
				}
			}
		}

		psPowerDevice = psPowerDevice->psNext;
	}

	return PVRSRV_OK;
}
Esempio n. 2
0
PVRSRV_ERROR PVRSRVDevicePrePowerStateKM_AnyVaCb(PVRSRV_POWER_DEV *psPowerDevice, va_list va)
{
	PVRSRV_DEV_POWER_STATE	eNewDevicePowerState;
	PVRSRV_ERROR			eError;


	IMG_BOOL				bAllDevices;
	IMG_UINT32				ui32DeviceIndex;
	PVRSRV_DEV_POWER_STATE	eNewPowerState;


	bAllDevices = va_arg(va, IMG_BOOL);
	ui32DeviceIndex = va_arg(va, IMG_UINT32);
	eNewPowerState = va_arg(va, PVRSRV_DEV_POWER_STATE);

	if (bAllDevices || (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex))
	{
		eNewDevicePowerState = (eNewPowerState == PVRSRV_DEV_POWER_STATE_DEFAULT) ?
							psPowerDevice->eDefaultPowerState : eNewPowerState;

		if (psPowerDevice->eCurrentPowerState != eNewDevicePowerState)
		{
			if (psPowerDevice->pfnPrePower != IMG_NULL)
			{

				eError = psPowerDevice->pfnPrePower(psPowerDevice->hDevCookie,
													eNewDevicePowerState,
													psPowerDevice->eCurrentPowerState);
				if (eError != PVRSRV_OK)
				{
					return eError;
				}
			}


			eError = SysDevicePrePowerState(psPowerDevice->ui32DeviceIndex,
											eNewDevicePowerState,
											psPowerDevice->eCurrentPowerState);
			if (eError != PVRSRV_OK)
			{
				return eError;
			}
		}
	}

	return  PVRSRV_OK;
}