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 open()</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 munmap()"
17HREF="r14037.htm"><LINK
18REL="NEXT"
19TITLE="V4L2 poll()"
20HREF="r14169.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="r14037.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="r14169.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-OPEN"
74></A
75>V4L2 open()</H1
76><DIV
77CLASS="REFNAMEDIV"
78><A
79NAME="AEN14094"
80></A
81><H2
82>Name</H2
83>v4l2-open&nbsp;--&nbsp;Open a V4L2 device</DIV
84><DIV
85CLASS="REFSYNOPSISDIV"
86><A
87NAME="AEN14097"
88></A
89><H2
90>Synopsis</H2
91><DIV
92CLASS="FUNCSYNOPSIS"
93><P
94></P
95><A
96NAME="AEN14098"
97></A
98><PRE
99CLASS="FUNCSYNOPSISINFO"
100>#include &lt;fcntl.h&gt;</PRE
101><P
102><CODE
103><CODE
104CLASS="FUNCDEF"
105>int open</CODE
106>(const char *device_name, int flags);</CODE
107></P
108><P
109></P
110></DIV
111></DIV
112><DIV
113CLASS="REFSECT1"
114><A
115NAME="AEN14107"
116></A
117><H2
118>Arguments</H2
119><P
120></P
121><DIV
122CLASS="VARIABLELIST"
123><DL
124><DT
125><CODE
126CLASS="PARAMETER"
127>device_name</CODE
128></DT
129><DD
130><P
131>Device to be opened.</P
132></DD
133><DT
134><CODE
135CLASS="PARAMETER"
136>flags</CODE
137></DT
138><DD
139><P
140>Open flags. Access mode must be
141<CODE
142CLASS="CONSTANT"
143>O_RDWR</CODE
144>. This is just a technicality, input devices
145still support only reading and output devices only writing.</P
146><P
147>When the <CODE
148CLASS="CONSTANT"
149>O_NONBLOCK</CODE
150> flag is
151given, the read() function and the <A
152HREF="r12878.htm"
153><CODE
154CLASS="CONSTANT"
155>VIDIOC_DQBUF</CODE
156></A
157> ioctl will return
158the <SPAN
159CLASS="ERRORCODE"
160>EAGAIN</SPAN
161> error code when no data is available or no buffer is in the driver
162outgoing queue, otherwise these functions block until data becomes
163available. All V4L2 drivers exchanging data with applications must
164support the <CODE
165CLASS="CONSTANT"
166>O_NONBLOCK</CODE
167> flag.</P
168><P
169>Other flags have no effect.</P
170></DD
171></DL
172></DIV
173></DIV
174><DIV
175CLASS="REFSECT1"
176><A
177NAME="AEN14128"
178></A
179><H2
180>Description</H2
181><P
182>To open a V4L2 device applications call
183<CODE
184CLASS="FUNCTION"
185>open()</CODE
186> with the desired device name. This
187function has no side effects; all data format parameters, current
188input or output, control values or other properties remain unchanged.
189At the first <CODE
190CLASS="FUNCTION"
191>open()</CODE
192> call after loading the driver
193they will be reset to default values, drivers are never in an
194undefined state.</P
195></DIV
196><DIV
197CLASS="REFSECT1"
198><A
199NAME="AEN14133"
200></A
201><H2
202>Return Value</H2
203><P
204>On success <CODE
205CLASS="FUNCTION"
206>open</CODE
207> returns the new file
208descriptor. On error -1 is returned, and the <CODE
209CLASS="VARNAME"
210>errno</CODE
211>
212variable is set appropriately. Possible error codes are:</P
213><P
214></P
215><DIV
216CLASS="VARIABLELIST"
217><DL
218><DT
219><SPAN
220CLASS="ERRORCODE"
221>EACCES</SPAN
222></DT
223><DD
224><P
225>The caller has no permission to access the
226device.</P
227></DD
228><DT
229><SPAN
230CLASS="ERRORCODE"
231>EBUSY</SPAN
232></DT
233><DD
234><P
235>The driver does not support multiple opens and the
236device is already in use.</P
237></DD
238><DT
239><SPAN
240CLASS="ERRORCODE"
241>ENXIO</SPAN
242></DT
243><DD
244><P
245>No device corresponding to this device special file
246exists.</P
247></DD
248><DT
249><SPAN
250CLASS="ERRORCODE"
251>ENOMEM</SPAN
252></DT
253><DD
254><P
255>Not enough kernel memory was available to complete the
256request.</P
257></DD
258><DT
259><SPAN
260CLASS="ERRORCODE"
261>EMFILE</SPAN
262></DT
263><DD
264><P
265>The  process  already  has  the  maximum number of
266files open.</P
267></DD
268><DT
269><SPAN
270CLASS="ERRORCODE"
271>ENFILE</SPAN
272></DT
273><DD
274><P
275>The limit on the total number of files open on the
276system has been reached.</P
277></DD
278></DL
279></DIV
280></DIV
281><DIV
282CLASS="NAVFOOTER"
283><HR
284ALIGN="LEFT"
285WIDTH="100%"><TABLE
286SUMMARY="Footer navigation table"
287WIDTH="100%"
288BORDER="0"
289CELLPADDING="0"
290CELLSPACING="0"
291><TR
292><TD
293WIDTH="33%"
294ALIGN="left"
295VALIGN="top"
296><A
297HREF="r14037.htm"
298ACCESSKEY="P"
299>Prev</A
300></TD
301><TD
302WIDTH="34%"
303ALIGN="center"
304VALIGN="top"
305><A
306HREF="book1.htm"
307ACCESSKEY="H"
308>Home</A
309></TD
310><TD
311WIDTH="33%"
312ALIGN="right"
313VALIGN="top"
314><A
315HREF="r14169.htm"
316ACCESSKEY="N"
317>Next</A
318></TD
319></TR
320><TR
321><TD
322WIDTH="33%"
323ALIGN="left"
324VALIGN="top"
325>V4L2 munmap()</TD
326><TD
327WIDTH="34%"
328ALIGN="center"
329VALIGN="top"
330><A
331HREF="r7624.htm"
332ACCESSKEY="U"
333>Up</A
334></TD
335><TD
336WIDTH="33%"
337ALIGN="right"
338VALIGN="top"
339>V4L2 poll()</TD
340></TR
341></TABLE
342></DIV
343></BODY
344></HTML
345>
346