<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML ><HEAD ><TITLE >Registering Video Capture Devices</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Video4Linux Programming" HREF="book1.html"><LINK REL="UP" TITLE="Video Capture Devices" HREF="c261.html"><LINK REL="PREVIOUS" TITLE="Video Capture Devices" HREF="c261.html"><LINK REL="NEXT" TITLE="Opening And Closing The Capture Device" HREF="x312.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Video4Linux Programming</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="c261.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Video Capture Devices</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x312.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="REGVID" ></A >Registering Video Capture Devices</H1 ><P > This time we need to add more functions for our camera device. </P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >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 */ }; </PRE ></TD ></TR ></TABLE ><P > 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. </P ><P > We use the extra video capability flags that did not apply to the radio interface. The video related flags are </P ><DIV CLASS="TABLE" ><A NAME="AEN277" ></A ><P ><B >Table 1. Capture Capabilities</B ></P ><TABLE BORDER="1" BGCOLOR="#E0E0E0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_CAPTURE</TD ><TD ALIGN="LEFT" VALIGN="TOP" >We support image capture</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_TELETEXT</TD ><TD ALIGN="LEFT" VALIGN="TOP" >A teletext capture device (vbi{n])</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_OVERLAY</TD ><TD ALIGN="LEFT" VALIGN="TOP" >The image can be directly overlaid onto the frame buffer</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_CHROMAKEY</TD ><TD ALIGN="LEFT" VALIGN="TOP" >Chromakey can be used to select which parts of the image to display</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_CLIPPING</TD ><TD ALIGN="LEFT" VALIGN="TOP" >It is possible to give the board a list of rectangles to draw around. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_FRAMERAM</TD ><TD ALIGN="LEFT" VALIGN="TOP" >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</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_SCALES</TD ><TD ALIGN="LEFT" VALIGN="TOP" >The image can be scaled to various sizes, rather than being a single fixed size.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_MONOCHROME</TD ><TD ALIGN="LEFT" VALIGN="TOP" >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.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >VID_TYPE_SUBCAPTURE</TD ><TD ALIGN="LEFT" VALIGN="TOP" >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.</TD ></TR ></TBODY ></TABLE ></DIV ><P > 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. </P ><P > 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(). </P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" > static int io = 0x320; static int irq = 11; int __init mycamera_init(struct video_init *v) { if(check_region(io, MY_IO_SIZE)) { printk(KERN_ERR "mycamera: port 0x%03X is in use.\n", io); return -EBUSY; } if(video_device_register(&my_camera, VFL_TYPE_GRABBER)==-1) return -EINVAL; request_region(io, MY_IO_SIZE, "mycamera"); return 0; } </PRE ></TD ></TR ></TABLE ><P > 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. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="c261.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="book1.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="x312.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Video Capture Devices</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c261.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Opening And Closing The Capture Device</TD ></TR ></TABLE ></DIV ></BODY ></HTML >