• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
2<HTML
3><HEAD
4><TITLE
5>V4L2 poll()</TITLE
6><META
7NAME="GENERATOR"
8CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
9REL="HOME"
10TITLE="Video for Linux Two API Specification"
11HREF="book1.htm"><LINK
12REL="UP"
13TITLE="Function Reference"
14HREF="r7624.htm"><LINK
15REL="PREVIOUS"
16TITLE="V4L2 open()"
17HREF="r14090.htm"><LINK
18REL="NEXT"
19TITLE="V4L2 read()"
20HREF="r14264.htm"></HEAD
21><BODY
22CLASS="REFENTRY"
23BGCOLOR="#FFFFFF"
24TEXT="#000000"
25LINK="#0000FF"
26VLINK="#840084"
27ALINK="#0000FF"
28><DIV
29CLASS="NAVHEADER"
30><TABLE
31SUMMARY="Header navigation table"
32WIDTH="100%"
33BORDER="0"
34CELLPADDING="0"
35CELLSPACING="0"
36><TR
37><TH
38COLSPAN="3"
39ALIGN="center"
40>Video for Linux Two API Specification: Revision 0.24</TH
41></TR
42><TR
43><TD
44WIDTH="10%"
45ALIGN="left"
46VALIGN="bottom"
47><A
48HREF="r14090.htm"
49ACCESSKEY="P"
50>Prev</A
51></TD
52><TD
53WIDTH="80%"
54ALIGN="center"
55VALIGN="bottom"
56></TD
57><TD
58WIDTH="10%"
59ALIGN="right"
60VALIGN="bottom"
61><A
62HREF="r14264.htm"
63ACCESSKEY="N"
64>Next</A
65></TD
66></TR
67></TABLE
68><HR
69ALIGN="LEFT"
70WIDTH="100%"></DIV
71><H1
72><A
73NAME="FUNC-POLL"
74></A
75>V4L2 poll()</H1
76><DIV
77CLASS="REFNAMEDIV"
78><A
79NAME="AEN14173"
80></A
81><H2
82>Name</H2
83>v4l2-poll&nbsp;--&nbsp;Wait for some event on a file descriptor</DIV
84><DIV
85CLASS="REFSYNOPSISDIV"
86><A
87NAME="AEN14176"
88></A
89><H2
90>Synopsis</H2
91><DIV
92CLASS="FUNCSYNOPSIS"
93><P
94></P
95><A
96NAME="AEN14177"
97></A
98><PRE
99CLASS="FUNCSYNOPSISINFO"
100>#include &lt;sys/poll.h&gt;</PRE
101><P
102><CODE
103><CODE
104CLASS="FUNCDEF"
105>int poll</CODE
106>(struct pollfd *ufds, unsigned int nfds, int timeout);</CODE
107></P
108><P
109></P
110></DIV
111></DIV
112><DIV
113CLASS="REFSECT1"
114><A
115NAME="AEN14188"
116></A
117><H2
118>Description</H2
119><P
120>With the <CODE
121CLASS="FUNCTION"
122>poll()</CODE
123> function applications
124can suspend execution until the driver has captured data or is ready
125to accept data for output.</P
126><P
127>When streaming I/O has been negotiated this function waits
128until a buffer has been filled or displayed and can be dequeued with
129the <A
130HREF="r12878.htm"
131><CODE
132CLASS="CONSTANT"
133>VIDIOC_DQBUF</CODE
134></A
135> ioctl. When buffers are already in the outgoing
136queue of the driver the function returns immediately.</P
137><P
138>On success <CODE
139CLASS="FUNCTION"
140>poll()</CODE
141> returns the number of
142file descriptors that have been selected (that is, file descriptors
143for which the <CODE
144CLASS="STRUCTFIELD"
145>revents</CODE
146> field of the
147respective <CODE
148CLASS="STRUCTNAME"
149>pollfd</CODE
150> structure is non-zero).
151Capture devices set the <CODE
152CLASS="CONSTANT"
153>POLLIN</CODE
154> and
155<CODE
156CLASS="CONSTANT"
157>POLLRDNORM</CODE
158> flags in the
159<CODE
160CLASS="STRUCTFIELD"
161>revents</CODE
162> field, output devices the
163<CODE
164CLASS="CONSTANT"
165>POLLOUT</CODE
166> and <CODE
167CLASS="CONSTANT"
168>POLLWRNORM</CODE
169>
170flags. When the function timed out it returns a value of zero, on
171failure it returns <SPAN
172CLASS="RETURNVALUE"
173>-1</SPAN
174> and the
175<CODE
176CLASS="VARNAME"
177>errno</CODE
178> variable is set appropriately. When the
179application did not call <A
180HREF="r12878.htm"
181><CODE
182CLASS="CONSTANT"
183>VIDIOC_QBUF</CODE
184></A
185> or <A
186HREF="r13817.htm"
187><CODE
188CLASS="CONSTANT"
189>VIDIOC_STREAMON</CODE
190></A
191> yet the
192<CODE
193CLASS="FUNCTION"
194>poll()</CODE
195> function succeeds, but sets the
196<CODE
197CLASS="CONSTANT"
198>POLLERR</CODE
199> flag in the
200<CODE
201CLASS="STRUCTFIELD"
202>revents</CODE
203> field.</P
204><P
205>When use of the <CODE
206CLASS="FUNCTION"
207>read()</CODE
208> function has
209been negotiated and the driver does not capture yet, the
210<CODE
211CLASS="FUNCTION"
212>poll</CODE
213> function starts capturing. When that fails
214it returns a <CODE
215CLASS="CONSTANT"
216>POLLERR</CODE
217> as above. Otherwise it waits
218until data has been captured and can be read. When the driver captures
219continuously (as opposed to, for example, still images) the function
220may return immediately.</P
221><P
222>When use of the <CODE
223CLASS="FUNCTION"
224>write()</CODE
225> function has
226been negotiated the <CODE
227CLASS="FUNCTION"
228>poll</CODE
229> function just waits
230until the driver is ready for a non-blocking
231<CODE
232CLASS="FUNCTION"
233>write()</CODE
234> call.</P
235><P
236>All drivers implementing the <CODE
237CLASS="FUNCTION"
238>read()</CODE
239> or
240<CODE
241CLASS="FUNCTION"
242>write()</CODE
243> function or streaming I/O must also
244support the <CODE
245CLASS="FUNCTION"
246>poll()</CODE
247> function.</P
248><P
249>For more details see the
250<CODE
251CLASS="FUNCTION"
252>poll()</CODE
253> manual page.</P
254></DIV
255><DIV
256CLASS="REFSECT1"
257><A
258NAME="AEN14227"
259></A
260><H2
261>Return Value</H2
262><P
263>On success, <CODE
264CLASS="FUNCTION"
265>poll()</CODE
266> returns the number
267structures which have non-zero <CODE
268CLASS="STRUCTFIELD"
269>revents</CODE
270>
271fields, or zero if the call timed out. On error
272<SPAN
273CLASS="RETURNVALUE"
274>-1</SPAN
275> is returned, and the
276<CODE
277CLASS="VARNAME"
278>errno</CODE
279> variable is set appropriately:</P
280><P
281></P
282><DIV
283CLASS="VARIABLELIST"
284><DL
285><DT
286><SPAN
287CLASS="ERRORCODE"
288>EBADF</SPAN
289></DT
290><DD
291><P
292>One or more of the <CODE
293CLASS="PARAMETER"
294>ufds</CODE
295> members
296specify an invalid file descriptor.</P
297></DD
298><DT
299><SPAN
300CLASS="ERRORCODE"
301>EBUSY</SPAN
302></DT
303><DD
304><P
305>The driver does not support multiple read or write
306streams and the device is already in use.</P
307></DD
308><DT
309><SPAN
310CLASS="ERRORCODE"
311>EFAULT</SPAN
312></DT
313><DD
314><P
315><CODE
316CLASS="PARAMETER"
317>ufds</CODE
318> references an inaccessible
319memory area.</P
320></DD
321><DT
322><SPAN
323CLASS="ERRORCODE"
324>EINTR</SPAN
325></DT
326><DD
327><P
328>The call was interrupted by a signal.</P
329></DD
330><DT
331><SPAN
332CLASS="ERRORCODE"
333>EINVAL</SPAN
334></DT
335><DD
336><P
337>The <CODE
338CLASS="PARAMETER"
339>nfds</CODE
340> argument is greater
341than <CODE
342CLASS="CONSTANT"
343>OPEN_MAX</CODE
344>.</P
345></DD
346></DL
347></DIV
348></DIV
349><DIV
350CLASS="NAVFOOTER"
351><HR
352ALIGN="LEFT"
353WIDTH="100%"><TABLE
354SUMMARY="Footer navigation table"
355WIDTH="100%"
356BORDER="0"
357CELLPADDING="0"
358CELLSPACING="0"
359><TR
360><TD
361WIDTH="33%"
362ALIGN="left"
363VALIGN="top"
364><A
365HREF="r14090.htm"
366ACCESSKEY="P"
367>Prev</A
368></TD
369><TD
370WIDTH="34%"
371ALIGN="center"
372VALIGN="top"
373><A
374HREF="book1.htm"
375ACCESSKEY="H"
376>Home</A
377></TD
378><TD
379WIDTH="33%"
380ALIGN="right"
381VALIGN="top"
382><A
383HREF="r14264.htm"
384ACCESSKEY="N"
385>Next</A
386></TD
387></TR
388><TR
389><TD
390WIDTH="33%"
391ALIGN="left"
392VALIGN="top"
393>V4L2 open()</TD
394><TD
395WIDTH="34%"
396ALIGN="center"
397VALIGN="top"
398><A
399HREF="r7624.htm"
400ACCESSKEY="U"
401>Up</A
402></TD
403><TD
404WIDTH="33%"
405ALIGN="right"
406VALIGN="top"
407>V4L2 read()</TD
408></TR
409></TABLE
410></DIV
411></BODY
412></HTML
413>
414