1 .\" $NetBSD: video.4,v 1.5 2008/09/09 05:47:07 wiz Exp $
3 .\" Copyright (c) 2008 Patrick Mahoney
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 .\" POSSIBILITY OF SUCH DAMAGE.
32 .Nd device-independent video driver layer
38 driver provides support for various video peripherals.
39 It provides a uniform programming interface layer above different
40 underlying video hardware drivers.
41 The video layer provides a
46 commands are supported controlling the device.
48 .Pa http://v4l2spec.bytesex.org/
49 for the official V4L2 specification.
51 The device file for video operation is
53 .Sh READING VIDEO SAMPLES
54 Video data is separated into logical video samples which will
55 typically be one complete video frame.
56 With compressed formats, a video sample may be one logical chunk
57 and not one complete frame depending on the compression format.
58 Video samples may be read from
60 in one of several different modes.
62 In read mode, calls to
64 will return at most the data of one video sample.
65 If the entire sample is not read, then subsequent reads will return
66 at most the remaining data in that video sample.
68 Video samples may be mapped into memory with
70 The driver allocates internal buffers for a number of video samples
71 which are mapped into memory.
72 Initiating this mode requires several
76 to request the driver reserve buffers,
78 to query the details of each buffer,
80 to map each buffer into memory,
82 to queue the buffers for receiving video data,
84 to begin streaming of video data, and
86 to remove a filled buffer from the queue.
87 At this point the video data from the dequeued buffer is valid.
88 .Sh DEVICE CAPABILITIES
89 .Bl -tag -width indent
90 .It Dv VIDIOC_QUERYCAP (struct v4l2_capability)
91 This command queries the capabilities of the device.
92 The first three fields are informational NULL terminated strings
95 describes the driver used by this device,
97 describes the video capture card or camera, and
99 represents the bus to which the hardware device is attached.
103 field contains a number of flags indicating various features supported
104 by the driver or hardware:
106 .Bl -tag -width indent
107 .It Dv V4L2_CAP_VIDEO_CAPTURE
108 support video capturing
109 .It Dv V4L2_CAP_READWRITE
115 .It Dv V4L2_CAP_STREAMING
121 struct v4l2_capability {
124 uint8_t bus_info[32];
126 uint32_t capabilities;
127 uint32_t reserved[4];
131 .Sh STREAMING INTERFACE
132 .Bl -tag -width indent
133 .It Dv VIDIOC_REQBUFS (struct v4l2_requestbuffers)
134 This command requests that the driver reserve space for
139 .Dv V4L2_BUF_TYPE_VIDEO_CAPTURE
143 .Dv V4L2_MEMORY_MMAP .
146 represents the actual number of samples reserved which may be more
147 or fewer than requested.
149 struct v4l2_requestbuffers {
151 enum v4l2_buf_type type;
152 enum v4l2_memory memory;
153 uint32_t reserved[2];
156 .It Dv VIDIOC_QUERYBUF (struct v4l2_buffer)
157 This command should be called for each buffer in
165 must be set to a valid index from 0 to
167 and the same type and memory as used in
168 .Dv VIDIOC_QUERYBUF .
176 enum v4l2_buf_type type;
179 enum v4l2_field field;
180 struct timeval timestamp;
181 struct v4l2_timecode timecode;
183 enum v4l2_memory memory;
186 unsigned long userptr;
194 Each buffer must be mapped with a call to
200 values obtained above.
202 .Dv PROT_READ|PROT_WRITE
206 .It Dv VIDIOC_QBUF (struct v4l2_buffer)
207 This command indicates to the driver that the buffer is ready to
208 receive a video sample.
209 The following fields must be set:
211 set to a valid buffer index from 0 to
215 set to the same type used above; and
217 set to the same memory used above.
218 Each buffer should be queued with this command.
219 Order is not important.
220 .It Dv VIDIOC_STREAMON (int)
221 This command starts streaming.
222 Queued buffers will be filled with data.
224 will indicate that a buffer is done and available for reading.
225 .It Dv VIDIOC_DQBUF (struct v4l2_buffer)
226 This command dequeues an available buffer from the driver.
227 If no buffer is available, it blocks until one is, unless
231 in which case it returns
236 prior to initiating any other mode will begin streaming of video for
239 In this streaming mode
243 indicate the availability of a video frame.
246 will return at most the video data of one video sample.
247 If the entire sample is not read, then subsequent reads will return
248 at most the remaining data in that video sample.
251 .Bl -tag -width /dev/video -compact
261 device driver first appeared in
264 .An Patrick Mahoney Aq pat@polycrystal.org
266 Does not support the complete V4L2 API.
267 Only supports the capture interface.
268 Does not support writing, overlay, VBI, tuner, audio, radio, or