Acquiring USBCAMD2 Features
You must acquire a pointer to the USBCAMD_INTERFACE structure before you can use the new USBCAMD2 features. To acquire the pointer, build and send an IRP_MN_QUERY_INTERFACE request from the camera minidriver's SRB_INITIALIZATION_COMPLETE handler in the AdapterReceivePacket callback function. The USBCAMD2 minidriver library processes this IRP and returns a direct-call interface of type USBCAMD_INTERFACE to the camera minidriver. The interface is essentially a table of function pointers.
The following code demonstrates how to build and send the IRP_MN_QUERY_INTERFACE request from the camera minidriver:
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_PNP,
pDeviceObject,
NULL,
0,
NULL,
&Event,
&IoStatusBlock);
if (NULL != Irp)
{
Irp->RequestorMode = KernelMode;
IrpStackNext = IoGetNextIrpStackLocation(Irp);
//
// Create an interface query out of the Irp.
//
IrpStackNext->MinorFunction = IRP_MN_QUERY_INTERFACE;
IrpStackNext->Parameters.QueryInterface.InterfaceType = (GUID*)&GUID_USBCAMD_INTERFACE;
IrpStackNext->Parameters.QueryInterface.Size = sizeof(*pUsbcamdInterface);
IrpStackNext->Parameters.QueryInterface.Version = USBCAMD_VERSION_200;
IrpStackNext->Parameters.QueryInterface.Interface = (PINTERFACE)pUsbcamdInterface;
IrpStackNext->Parameters.QueryInterface.InterfaceSpecificData = NULL;
Status = IoCallDriver(pDeviceObject, Irp);
if (STATUS_PENDING == Status)
{
//
// This waits using KernelMode so that the stack, and therefore the
// event on that stack, is not paged out.
//
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = IoStatusBlock.Status;
}
}
else
{
Status = STATUS_INSUFFICIENT_RESOURCES;
}