Chapter 3. Video Capture Devices

Table of Contents

Video Capture Device Types
Registering Video Capture Devices
Opening And Closing The Capture Device
Interrupt Handling
Reading The Video Image
Video Ioctl Handling
Other Functionality

Video Capture Device Types

The video capture devices share the same interfaces as radio devices. In order to explain the video capture interface I will use the example of a camera that has no tuners or audio input. This keeps the example relatively clean. To get both combine the two driver examples.

Video capture devices divide into four categories. A little technology backgrounder. Full motion video even at television resolution (which is actually fairly low) is pretty resource-intensive. You are continually passing megabytes of data every second from the capture card to the display. several alternative approaches have emerged because copying this through the processor and the user program is a particularly bad idea .

The first is to add the television image onto the video output directly. This is also how some 3D cards work. These basic cards can generally drop the video into any chosen rectangle of the display. Cards like this, which include most mpeg1 cards that used the feature connector, aren't very friendly in a windowing environment. They don't understand windows or clipping. The video window is always on the top of the display.

Chroma keying is a technique used by cards to get around this. It is an old television mixing trick where you mark all the areas you wish to replace with a single clear colour that isn't used in the image - TV people use an incredibly bright blue while computing people often use a particularly virulent purple. Bright blue occurs on the desktop. Anyone with virulent purple windows has another problem besides their TV overlay.

The third approach is to copy the data from the capture card to the video card, but to do it directly across the PCI bus. This relieves the processor from doing the work but does require some smartness on the part of the video capture chip, as well as a suitable video card. Programming this kind of card and more so debugging it can be extremely tricky. There are some quite complicated interactions with the display and you may also have to cope with various chipset bugs that show up when PCI cards start talking to each other.

To keep our example fairly simple we will assume a card that supports overlaying a flat rectangular image onto the frame buffer output, and which can also capture stuff into processor memory.