Previous Next

Writing AVStream Minidrivers for Hardware

Minidrivers that manipulate hardware can supply PnP dispatch functions in the corresponding KSDEVICE_DISPATCH structure. A typical AVStream driver might support the PnP start device and query capabilities messages, as well as the power messages for hardware that supports power management.

In the vendor-supplied PnP start device dispatch routine, a minidriver can allocate context information to associate with the AVStream device. This is similar to a minidriver under stream class using the device extension to store context information.

In addition, this routine is where the minidriver receives the list of resources assigned to the device by the PnP subsystem. A minidriver can parse this list to find the interrupt assigned to the device, as well as the physical address of memory resources. Minidrivers are responsible for connecting the interrupt with IoConnectInterrupt.

Hardware that supports DMA must obtain a DMA adapter object by calling IoGetDmaAdapter. Allocate any buffers that your minidriver requires for DMA transfers with AllocateCommonBuffer.

Minidrivers should not attempt to configure hardware to support a particular filter until pins on that filter transition to KSSTATE_ACQUIRE.

Consider an example in which a piece of hardware can support both encoding and decoding, but can only perform one of these operations at a time. As such, it exposes two different types of filters: an encode filter and a decode filter.

An application builds a filter graph containing the encode filter and the minidriver loads microcode or configures the hardware for encoding at pin connection time.

The filter graph starts and the hardware is encoding. At this point, another application attempts to place a decode filter in a filter graph. When the decode pins are connected, the device configures the hardware for decoding. This interferes with the encode graph that is currently running. Thus, the rule is: do not acquire hardware resources (load microcode or configure hardware for a particular filter) until the appropriate pins on that filter transition into KSSTATE_ACQUIRE.