Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/windows/wdfserial/QCMAIN.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ typedef struct _DEVICE_CONTEXT
BOOLEAN InServiceSelectiveSuspension;
ULONG SelectiveSuspendIdleTime;
BOOLEAN SelectiveSuspendInMiliSeconds;
WDF_POWER_POLICY_S0_IDLE_CAPABILITIES AssignedIdleCaps;

WMILIB_CONTEXT WmiLibInfo; // to query system power management tab
CHAR DevSerialNumber[256]; // to hold USB_STRING_DESCRIPTOR of the serial number
Expand Down
11 changes: 10 additions & 1 deletion src/windows/wdfserial/QCPNP.c
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,7 @@ NTSTATUS QCPNP_EnableSelectiveSuspend
{
idleSettings.IdleTimeout *= 1000;
}
idleSettings.Enabled = WdfTrue; // explicitly enable SS (overrides any user/registry disable)
status = WdfDeviceAssignS0IdleSettings(Device, &idleSettings);
if (status == STATUS_POWER_STATE_INVALID)
{
Expand All @@ -2129,6 +2130,8 @@ NTSTATUS QCPNP_EnableSelectiveSuspend
);
}

pDevContext->AssignedIdleCaps = idleSettings.IdleCaps;

return status;
}

Expand Down Expand Up @@ -2159,8 +2162,14 @@ NTSTATUS QCPNP_DisableSelectiveSuspend
("<%ws> QCPNP_DisableSelectiveSuspend\n", pDevContext->PortName)
);

WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings, IdleCannotWakeFromS0);
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(
&idleSettings,
(pDevContext->AssignedIdleCaps != IdleCapsInvalid)
? pDevContext->AssignedIdleCaps
: IdleCannotWakeFromS0
);
idleSettings.Enabled = WdfFalse;
idleSettings.UserControlOfIdleSettings = IdleAllowUserControl;
return WdfDeviceAssignS0IdleSettings(Device, &idleSettings);
}

Expand Down
Loading