annotate vloopback.html @ 5:fa5d2b9d8831

Add make dist to create tarball without .svn contest
author AngelCarpintero
date Sun, 18 May 2008 19:24:57 +0000
parents 5f21a4dddc0c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1 <HTML>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
2 <HEAD>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
3 <TITLE>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
4 Video4Linux loopback API
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
5 </TITLE>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
6 <H1>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
7 Video4Linux loopback API
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
8 </H1>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
9 </HEAD>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
10 <BODY bgcolor="white">
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
11 <P>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
12 Author: Jeroen Vreeken (pe1rxq@amsat.org)<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
13 Version: 0.90<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
14 Date: 31-01-2001<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
15 </P>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
16 <P>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
17 <H2>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
18 Introduction:
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
19 </H2>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
20 This document describes the API for the Video4Linux loopback driver.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
21 The driver implements a video pipe using two video4linux devices.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
22 The first device is used by the program supplying the data,
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
23 from now on this program will be refered to with <I>'pusher'</I>.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
24 The second device acts as if it were a normall video4linux device,
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
25 it should be usable by any application that honours the video4linux
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
26 specifications. This application will from now on be refered to as
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
27 <I>'client'</I>.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
28 The calls and ioctls mentioned in this document refer to those
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
29 as described in the Video4Linux API.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
30 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
31 The loopback device has two operating modes:
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
32 <UL>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
33 <LI>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
34 A simple one-copy mode in which <I>pusher</I> specifies the
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
35 size of the images and the used palette and uses write to
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
36 push its images to the pipe.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
37 This mode is mostly for feeding fixed size images without any
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
38 knowledge about <I>client</I>.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
39 </LI>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
40 <LI>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
41 A zero-copy mode in which <I>pusher</I> regularly polls the
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
42 device if <I>client</I> does an ioctl.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
43 In this mode <I>pusher</I> has almost complete control over the
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
44 devices behaviour and it will be mainly used to implement
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
45 complex multiple tuner/channel/size configurations.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
46 With this mode it should be possible to use the Xvideo
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
47 extensions as normal video4linux capture devices.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
48 </LI>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
49 </UL>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
50 </P>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
51 <P align=left>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
52 <H2>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
53 Locating a free pipe
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
54 </H2>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
55 In order to find an unused pipe <I>pusher</I> will have to scan
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
56 the contents of /proc/video/vloopback/<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
57 Each pipe will have its own entry in the form of <I>vloopback0</I> to
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
58 <I>vloopbackN</I>, N being the total number of available pipes-1.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
59 There will also be a general <I>vloopbacks</I> file which will contain
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
60 information on all entries.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
61 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
62 Each of these files will have references to the input and output
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
63 video device and will also indicate if either of them is currently
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
64 in use.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
65 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
66 Once <I>pusher</I> has found a free pipe it can claim it by simply
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
67 opening the input device.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
68 </P>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
69 <P align=left>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
70 <H2>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
71 One-copy mode
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
72 </H2>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
73 In this mode <I>pusher</I> only has to provide images using the
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
74 <B>write()</B> call,
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
75 the driver will handle the communication with <I>client</I> or
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
76 will drop the images if the output is unused.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
77 To <I>client</I> the device will closely resemble a webcam driver.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
78 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
79 In order to use it <I>pusher</I> will open the input device.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
80 Before writing it will first have to set the palette it is going to use
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
81 by calling <B>VIDIOCSPICT</B>, and the size by calling
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
82 <B>VIDIOCSWIN</B>.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
83 After this it can call <B>write()</B> for each frame it wants to send
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
84 to the pipe.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
85 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
86 When there is no application using the device the driver will simply
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
87 drop the frames which will result in a 'no-copy' situation while
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
88 writing to an unused pipe.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
89 <I>Note: when client is using read() instead of mmap() the driver will
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
90 actually use a double copy.</I>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
91 </P>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
92 <P align=left>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
93 <H2>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
94 Zero-copy mode
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
95 </H2>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
96 In this mode the driver will forward nearly all ioctls to
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
97 <I>pusher</I>.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
98 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
99 To initiate this mode <I>pusher</I> will have to call <B>mmap()</B>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
100 with the size of the requested buffer.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
101 The driver will allocate memory for this buffer and <I>pusher</I> will
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
102 gain access to it.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
103 <I>Note: as the allocated memory might be in use by client, pusher is
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
104 NOT allowed to touch it under any circumstances with the only exeption
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
105 being between <B>VIDIOCMCAPTURE</B> and <B>VIDIOCSYNC</B>.</I><BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
106 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
107 <B>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
108 Handling ioctls
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
109 </B><BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
110 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
111 When <I>client</I> has issued an ioctl <I>pusher</I> will receive a
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
112 <B>SIGIO</B> signal.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
113 Pusher may check to see if it is comming from vloopback by calling
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
114 <B>poll()</B> first.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
115 It then has to respond by calling <B>read()</B>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
116 with a large enough buffer for the largest possible ioctl data
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
117 structure plus <B>sizeof(unsigned long int)</B>. <I>(The largest ioctl data structure is 280 bytes
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
118 in linux kernel 2.4.0-test10pre1, a buffer of 1024 bytes is recommended)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
119 </I><BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
120 The first bytes of this buffer will be the ioctl number.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
121 This number is an unsigned long int, the remaining data is the data supplied by <I>client</I>.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
122 <I>Pusher</I> will now have to handle this ioctl.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
123 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
124 If it is an ioctl requesting data <I>pusher</I> will answer it by
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
125 calling the ioctl with the requested data.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
126 If it is an ioctl setting data <I>pusher</I> will call the ioctl with
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
127 the exact same data to accept it.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
128 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
129 <B>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
130 Handling read
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
131 </B><BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
132 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
133 <I>Pusher</I> will not need to handle any read requests because the
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
134 kernel module will fake an mmap and sync call for it.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
135 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
136 <B>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
137 Starting and stopping capture
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
138 </B><BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
139 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
140 The first time <B>VIDIOCMCAPTURE</B> is called <I>pusher</I> should
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
141 initialize capture and start capturing of the requested frames into
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
142 the mmapped buffer.<BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
143 When <I>client</I> closes its device an 'ioctl' 0 will be send with
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
144 no data, <I>pusher</I> will tell the hardware to stop.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
145 <BR>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
146 </P>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
147 </BODY>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
148 </HTML>