3.2. Registering Video Capture Devices

This time we need to add more functions for our camera device.

static struct video_device my_camera
        "My Camera",
        camera_read,      /* no read */
        NULL,             /* no write */
        camera_poll,      /* no poll */
        NULL,             /* no special init function */
        NULL              /* no private data */

We need a read() function which is used for capturing data from the card, and we need a poll function so that a driver can wait for the next frame to be captured.

We use the extra video capability flags that did not apply to the radio interface. The video related flags are

Table 3-1. Capture Capabilities

VID_TYPE_CAPTUREWe support image capture
VID_TYPE_TELETEXTA teletext capture device (vbi{n])
VID_TYPE_OVERLAYThe image can be directly overlaid onto the frame buffer
VID_TYPE_CHROMAKEYChromakey can be used to select which parts of the image to display
VID_TYPE_CLIPPINGIt is possible to give the board a list of rectangles to draw around.
VID_TYPE_FRAMERAMThe video capture goes into the video memory and actually changes it. Applications need to know this so they can clean up after the card
VID_TYPE_SCALESThe image can be scaled to various sizes, rather than being a single fixed size.
VID_TYPE_MONOCHROMEThe capture will be monochrome. This isn't a complete answer to the question since a mono camera on a colour capture card will still produce mono output.
VID_TYPE_SUBCAPTUREThe card allows only part of its field of view to be captured. This enables applications to avoid copying all of a large image into memory when only some section is relevant.

We set VID_TYPE_CAPTURE so that we are seen as a capture card, VID_TYPE_CHROMAKEY so the application knows it is time to draw in virulent purple, and VID_TYPE_SCALES because we can be resized.

Our setup is fairly similar. This time we also want an interrupt line for the 'frame captured' signal. Not all cards have this so some of them cannot handle poll().

static int io = 0x320;
static int irq = 11;

int __init mycamera_init(struct video_init *v)
        if(check_region(io, MY_IO_SIZE))
                      "mycamera: port 0x%03X is in use.\n", io);
                return -EBUSY;

                return -EINVAL;
        request_region(io, MY_IO_SIZE, "mycamera");
        return 0;


This is little changed from the needs of the radio card. We specify VFL_TYPE_GRABBER this time as we want to be allocated a /dev/video name.