ReactOS 0.4.15-dev-5666-gc548b97
power.cpp
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/wdm/audio/backpln/portcls/power.cpp
5 * PURPOSE: Power support functions
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "private.hpp"
10
11#ifndef YDEBUG
12#define NDEBUG
13#endif
14
15#include <debug.h>
16
21 IN PVOID pvContext)
22{
26 IAdapterPowerManagement * pPower;
27
28 DPRINT("PcRegisterAdapterPowerManagement pUnknown %p pvContext %p\n", pUnknown, pvContext);
30
31 if (!pUnknown || !pvContext)
33
34
35 pDeviceObject = (PDEVICE_OBJECT)pvContext;
36 DeviceExt = (PPCLASS_DEVICE_EXTENSION)pDeviceObject->DeviceExtension;
37
38 Status = pUnknown->QueryInterface(IID_IAdapterPowerManagement, (PVOID*)&pPower);
39 if (!NT_SUCCESS(Status))
40 {
41 DPRINT1("PcRegisterAdapterPowerManagement no IAdapterPowerManagement interface %x\n", Status);
42 DeviceExt->AdapterPowerManagement = NULL;
43 return STATUS_SUCCESS;
44 }
45
46 DeviceExt->AdapterPowerManagement = pPower;
47 DPRINT("PcRegisterAdapterPowerManagement success %x\n", Status);
48 return STATUS_SUCCESS;
49}
50
55{
57
58 DPRINT("PcUnregisterAdapterPowerManagement pUnknown %p pvContext %p\n", DeviceObject);
60
61 if (!DeviceObject)
63
64 DeviceExt = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
65
66 if (DeviceExt->AdapterPowerManagement)
67 {
68 DeviceExt->AdapterPowerManagement->Release();
69 }
70 DeviceExt->AdapterPowerManagement = NULL;
71 return STATUS_SUCCESS;
72}
73
74
75
76static
77VOID
85{
87}
88
93 IN DEVICE_POWER_STATE RequestedNewState)
94{
99
101
102 if (!DeviceObject || !RequestedNewState)
104
105 DeviceExt = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
107
108 PowerState.DeviceState = RequestedNewState;
110
112 if (NT_SUCCESS(Status))
113 {
115 }
116
117
118 return Status;
119}
120
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI PcRequestNewPowerState(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_POWER_STATE RequestedNewState)
Definition: power.cpp:91
static VOID NTAPI PwrCompletionCallback(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
Definition: power.cpp:79
NTSTATUS NTAPI PcUnregisterAdapterPowerManagement(IN PDEVICE_OBJECT DeviceObject)
Definition: power.cpp:53
NTSTATUS NTAPI PcRegisterAdapterPowerManagement(IN PUNKNOWN pUnknown, IN PVOID pvContext)
Definition: power.cpp:19
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
struct _DEVICE_OBJECT * PDEVICE_OBJECT
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
Status
Definition: gdiplustypes.h:25
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
if(dx< 0)
Definition: linetemp.h:194
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
#define KernelMode
Definition: asm.h:34
@ SynchronizationEvent
NTSTATUS NTAPI PoRequestPowerIrp(_In_ PDEVICE_OBJECT DeviceObject, _In_ UCHAR MinorFunction, _In_ POWER_STATE PowerState, _In_opt_ PREQUEST_POWER_COMPLETE CompletionFunction, _In_opt_ __drv_aliasesMem PVOID Context, _Outptr_opt_ PIRP *pIrp)
Definition: power.c:647
@ PowerSystemUnspecified
Definition: ntpoapi.h:35
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
PDEVICE_OBJECT PhysicalDeviceObject
Definition: private.hpp:402
IAdapterPowerManagement * AdapterPowerManagement
Definition: private.hpp:406
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3034
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_SET_POWER
@ Executive
Definition: ketypes.h:403
unsigned char UCHAR
Definition: xmlstorage.h:181