SonyDCam

SUMMARY

Sonydcam is a sample WDM stream class video capture driver that supports two IEEE 1394 digital cameras:

The same driver may be able to support other digital cameras that conform to 1394-based Digital Camera Specification from 1394 Trade Association.

Digital camera supported by Sonydcam.sys is a data source that produces digital image data without any other input connection. It manifests itself in a DirectShow graph as a WDM Streaming Capture Device and as a capture filter that has output capture stream supporting image sizes of 320x240 with a UYVY color space. Its de-compressor, Msyuv.dll, is part of the OS delivery, and it can convert image data format from UYVY to RGB16, RGB8, or to a Direct Draw surface if the video card supports UYVY format.

BUILDING THE SAMPLE

The sample is built with the standard DDK BUILD utility in the standard checked or free DDK build environment.

Sonydcam is a Plug and Play driver, and the Image.inf shipped with Windows OS is used to install detected devices. It cannot be manually installed. The sample Sonydcam.inf, which is a subset of Image.inf, can be used as an installation file template.

The 1394Dcam sample is completely contained in one directory.

RESOURCES

The site http://www.1394TA.org contains many other IEEE 1394 bus-related articles and specifications.

The site http://www.microsoft.com/hwdev contains some of the class driver support for IEEE 1394 bus on both Windows® 98 and Windows 2000.

CODE TOUR

File Manifest

File		Description
1394DCam.htm	The documentation for this sample (this file)
SOURCES		The generic file for building the code sample
SonyDCam.inf	A sample installation file
SonyDCam.c	DriverEntry(), Initialize and un-initialize device
DCamPkt.c	Process stream class's SRB_* packets 
CtrlPkt.c	Process stream control packet, like querying and setting streaming state
DataPkt.c	Process stream read data packet.
Callback.c	Process callbacks from controller driver for either a filled buffer or a bus reset
Device.c	Process reading and writing to device's registers
CapProp.c	Process VideoProcAmp and CameraControl properties
CapProp.h	Function prototypes for CapProp.c
Dbg.h		Debug preprocessor
DcamDef.h	Function prototypes
DcamPkt.h	Function prototypes and major structure definition
PropData.h	Static streaming properties for Sony digital camera
PropDta2.h	Static streaming properties for TI digital camera 
SonyDCam.h	Function prototypes for sonydcam.c
StrmData.h	Supported stream format
SonyDCam.rc	Resource file mainly for version
 

Programming Tour

 

In DriverEntry(), it initializes the hardware initialization structure including registers its entry point functions.

HwReceivePacket field describes the entry point for receiving SRBs (Stream Request Packet) from stream class driver. Here is a possible sequence of SRBs that this driver may receive.

  1. SRB_INITIALIZE_DEVICE to initialize the device, and called after DriverEntry().
  2. SRB_GET_STREAM_INFO to get supported stream format.
  3. SRB_GET_DATA_INTERSECTION to query a supported format given some key fields.
  4. SRB_OPEN_STREAM to open a stream with supply format from SRB_GET_DATA_INTERSECTION. Two additional entry point functions are register for this stream for controlling the streaming state (Srb->StreamObject->ReceiveControlPacket) and for streaming data (Srb->StreamObject->ReceiveDataPacket).
  5. SRB_CLOSE_STREAM to close the open stream.
  6. SRB_UNINITIALIZE_DEVICE to indicate that a device has been unloaded or removed.

This driver also register entry points for canceling packets (HwCancelPacket) and for notifying if a packet has timeout (HwRequestTimeoutHandler).

There are two callback functions used in this driver. DCamIsochCallback() is called from the controller driver when an attached buffer is filled with data. DCamBusResetNotification() is called also from controller driver to indicate a bus reset has occurred. Both are executed in DISPATCH_LEVEL.

This web site can provide additional and detail information about stream class architecture and its interface:

http://www.microsoft.com/hwdev

 

Bus Reset

Since this driver supports a PnP device, there are some special cases. For example, (1) unplug this camera while streaming, or (2) plug in a 2nd device into the same controller that has a device already streaming. In either case, it triggered a bus reset from the controller. After a reset, the controller invalidate its clients' bandwidth and channel; however, after the bus reset, the streaming device should continue to source isochronous video data according to IEEE 1394 digital camera specification.

For a device that has been removed, it will receive a SRB_SURPRISE_REMOVAL. It then must cancel all pending reads and prepare to be unloaded. In this case, this driver is likely to receive SRB_UNINITIALIZE_DEVICE before SRB_CLOSE_STREAM. If a driver still has pending reads SRB, stream class driver will not send SRB_CLOSE_STREAM even after its client application is closed.

For a device that is still plugged in, it will get a notification callback from the controller to restore to its original state, including freeing and reallocating channel and bandwidth (but not resource), and restore to its original streaming state. In this sample, the device is re-initialize and restarted. This is only necessary if the device stop sourcing isochronous video data. Re-initializing the device is also necessary if a device was attached but suspended (loss power) and awaken. In this case, it will also get a bus reset callback notification.

 

Frame rate and dropped frames

Digital cameras support discrete frame rates; however, a client application can request to stream at any rate. It is required by WDM video capture driver to match or down shift to its next frame rate from the requested frame rate. Over sampling can cause synchronization problems.

The dropped frame information is calculated instead of actual count, and it is based on the capture rate and the actual counts of frames captured. After a buffer is attached to the controller driver, sonydcam is in passive mode waiting for the data to be filled. If its controller misses the data, a dropped frame, it cannot know that; and the controller does not report that information back to it. That is why the frame rate information is calculated.

 

Work items

Sonydcam is not persisting property settings between reboots. It should.

Sonydcam is not power management enabled. It should. Currently, it has " DontSuspendIfStreamsAreRunning" set in its INF, and ought to be removed, and process D3->D0 and D0->D3 power state change.

Top of page

© 1999 Microsoft Corporation