A USBCAMD2 camera minidriver generally operates as follows:
The camera minidriver calls USBCAMD_DriverEntry from its DriverEntry routine. When the minidriver calls USBCAMD_DriverEntry, it passes to USBCAMD2 the minidriver's AdapterReceivePacket callback function. USBCAMD2 then registers the minidriver with the stream.sys class driver.
The camera minidriver can then receive various stream request blocks (SRBs) in its AdapterReceivePacket callback function to handle, including:
The camera minidriver determines how it must process each SRB. The minidriver can call routines in the USBCAMD2 minidriver library to assist with processing SRBs. These routines typically begin with the USBCAMD_ prefix.
For example, to specify the camera minidriver's other callback functions with USBCAMD2, the camera minidriver specifies their entry points in a USBCAMD_DEVICE_DATA2 structure. The minidriver then calls USBCAMD_InitializeNewInterface to pass the initialized USBCAMD_DEVICE_DATA2 structure to USBCAMD2. USBCAMD2 then calls the minidriver's callback functions when necessary.
Note
The USBCAMD_DEVICE_DATA structure is supported in USBCAMD2 only for purposes of backward compatibility.
The minidriver must call USBCAMD_AdapterReceivePacket to send any SRBs it does not handle to USBCAMD2 to process.
USBCAMD Library Callback Functions describe the callback functions that the minidriver implements and whether they are optional or required.
The following list of procedures illustrates the general flow of processing for SRBs sent to the camera minidriver:
Minidriver's SRB_INITIALIZE_DEVICE handler
Component
Action
Camera minidriver
Initialize USBCAMD2 by calling USBCAMD_InitializeNewInterface, indicating video or still raw processing requirements in kernel mode, such as enabling device events.
Check that the frame rate requested (VideoInfoHeader.AvgTimePerFrame) is within the upper and lower limits for the video format requested. If it exceeds the limits, the minidriver should correct the following values in pSrb->CommandData.IntersectInfo->Datarange: VideoInfoHeader.AvgTimePerFrame, VideoInfoHeader.dwBitRate.
Save the video format accepted by the camera minidriver.
USBCAMD2
Call the minidriver's CamAllocateBandwidthEx callback function to allocate bandwidth based on video-format data and get the maximum buffer size for the video format.
Camera minidriver
Calculate the isochronous channel's maximum packet size that satisfies the requested frame rate and output windows size.
Camera minidriver
Choose the closest alternate setting by calling USBCAMD_SelectAlternateInterface. The minidriver should provide USBCAMD2 with the maximum possible frame size that can be produced by the camera.
Camera minidriver
Set the hardware scaling on the camera. Set the camera controls to the stored values in the registry, or to the default setting if the first time.
Camera minidriver
Ensure that the frame rate (VideoInfoHeader.AvgTimePerFrame) falls within the limits for the video format, and correct it if it does not.