UFX_PROPRIETARY_CHARGER_DETECT callback function (ufxproprietarycharger.h)
The filter driver's implementation to detect if a charger is attached and get details about the charger.
Syntax
UFX_PROPRIETARY_CHARGER_DETECT UfxProprietaryChargerDetect;
NTSTATUS UfxProprietaryChargerDetect(
[in] PVOID Context,
[out] PUFX_PROPRIETARY_CHARGER DetectedCharger
)
{...}
Parameters
[in] Context
A pointer to a driver-defined context.
[out] DetectedCharger
A pointer to a UFX_PROPRIETARY_CHARGER structure that the driver fills with charger information.
Return value
If the operation is successful, the callback function must return STATUS_SUCCESS, or another status value for which NT_SUCCESS(status) equals TRUE. Otherwise it must return a status value for which NT_SUCCESS(status) equals FALSE.
Remarks
To support handling of proprietary chargers, the USB lower filter driver must publish support. During the publishing process, the driver also registers its implementation of this callback function. For more information, see USB filter driver for supporting proprietary chargers.
In this callback function, the driver assigns the charger a GUID and sets the minimum required Dx state when the device is connected for charging.
Examples
NTSTATUS
UsbLowerFilter_ProprietaryChargerDetect(
__in PVOID Context,
__out PUFX_PROPRIETARY_CHARGER DetectedCharger
)
{
NTSTATUS Status = STATUS_SUCCESS;
PPDCP_CONTEXT PdcpContext = NULL;
PAGED_CODE();
PdcpContext = DeviceGetUsbLowerFilterContext((WDFDEVICE)Context);
// Clear our event
KeClearEvent(&PdcpContext>AbortOperation);
// Wait for a while
Timeout.QuadPart = WDF_REL_TIMEOUT_IN_MS(PdcpContext>DetectionDelayInms);
Status = KeWaitForSingleObject(
&PdcpContext>AbortOperation,
Executive,
KernelMode,
FALSE,
&Timeout);
switch (Status)
{
case STATUS_SUCCESS:
// The abort event was set. Abort.
Status = STATUS_REQUEST_ABORTED;
break;
case STATUS_TIMEOUT:
// Timed out, detection has completed successfully.
// Check if we want to fail this.
if (PdcpContext>RejectNextRequest)
{
PdcpContext->RejectNextRequest = FALSE;
Status = STATUS_UNSUCCESSFUL;
}
else if (!PdcpContext->PdcpChargerAttached)
{
Status = STATUS_NOT_FOUND;
}
else
{
Status = STATUS_SUCCESS;
}
break;
default:
break;
}
if (NT_SUCCESS(Status))
{
PdcpContext->PdcpChargerDetected = TRUE;
DetectedCharger->ChargerId = GUID_USBFN_PROPRIETARY_CHARGER;
DetectedCharger->DxState = PowerDeviceD2;
}
return Status;
}
Requirements
Requirement | Value |
---|---|
Target Platform | Windows |
Minimum KMDF version | 1.0 |
Minimum UMDF version | 2.0 |
Header | ufxproprietarycharger.h |
IRQL | PASSIVE_LEVEL |