Registering Video Capture Devices
Prev | Chapter 3. Video Capture Devices | Next

## Registering Video Capture Devices

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

    static struct video_device my_camera
    {
            "My Camera",
            VID_TYPE_OVERLAY|VID_TYPE_SCALES|\
            VID_TYPE_CAPTURE|VID_TYPE_CHROMAKEY,
            VID_HARDWARE_MYCAMERA,
            camera_open.
            camera_close,
            camera_read,      /* no read */
            NULL,             /* no write */
            camera_poll,      /* no poll */
            camera_ioctl,
            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_CAPTURE | We support image capture
VID_TYPE_TELETEXT | A teletext capture device (vbi{n])
VID_TYPE_OVERLAY | The image can be directly overlaid onto the frame buffer
VID_TYPE_CHROMAKEY | Chromakey can be used to select which parts of the image to display
VID_TYPE_CLIPPING | It is possible to give the board a list of rectangles to draw around.
VID_TYPE_FRAMERAM | The 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_SCALES | The image can be scaled to various sizes, rather than being a single fixed size.
VID_TYPE_MONOCHROME | The 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_SUBCAPTURE | The 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(!request_region(io, MY_IO_SIZE, "mycamera"))
            {
                    printk(KERN_ERR
                          "mycamera: port 0x%03X is in use.\n", io);
                    return -EBUSY;
            }

            if(video_device_register(&my_camera,
                VFL_TYPE_GRABBER)==-1) {
                    release_region(io, MY_IO_SIZE);
                    return -EINVAL;
            }
            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.

Prev | Up | Next
Chapter 3. Video Capture Devices | Home | Opening And Closing The Capture Device