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 ioctl()</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 close()"
17HREF="r7626.htm"><LINK
18REL="NEXT"
19TITLE="ioctl VIDIOC_CROPCAP"
20HREF="r7771.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="r7626.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="r7771.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-IOCTL"
74></A
75>V4L2 ioctl()</H1
76><DIV
77CLASS="REFNAMEDIV"
78><A
79NAME="AEN7671"
80></A
81><H2
82>Name</H2
83>v4l2-ioctl&nbsp;--&nbsp;Program a V4L2 device</DIV
84><DIV
85CLASS="REFSYNOPSISDIV"
86><A
87NAME="AEN7674"
88></A
89><H2
90>Synopsis</H2
91><DIV
92CLASS="FUNCSYNOPSIS"
93><P
94></P
95><A
96NAME="AEN7675"
97></A
98><PRE
99CLASS="FUNCSYNOPSISINFO"
100>#include &lt;sys/ioctl.h&gt;</PRE
101><P
102><CODE
103><CODE
104CLASS="FUNCDEF"
105>int ioctl</CODE
106>(int fd, int request, void *argp);</CODE
107></P
108><P
109></P
110></DIV
111></DIV
112><DIV
113CLASS="REFSECT1"
114><A
115NAME="AEN7686"
116></A
117><H2
118>Arguments</H2
119><P
120></P
121><DIV
122CLASS="VARIABLELIST"
123><DL
124><DT
125><CODE
126CLASS="PARAMETER"
127>fd</CODE
128></DT
129><DD
130><P
131>File descriptor returned by <A
132HREF="r14090.htm"
133><CODE
134CLASS="FUNCTION"
135>open()</CODE
136></A
137>.</P
138></DD
139><DT
140><CODE
141CLASS="PARAMETER"
142>request</CODE
143></DT
144><DD
145><P
146>V4L2 ioctl request code as defined in the <A
147HREF="a16506.htm"
148>videodev.h</A
149> header file, for example
150VIDIOC_QUERYCAP.</P
151></DD
152><DT
153><CODE
154CLASS="PARAMETER"
155>argp</CODE
156></DT
157><DD
158><P
159>Pointer to a function parameter, usually a structure.</P
160></DD
161></DL
162></DIV
163></DIV
164><DIV
165CLASS="REFSECT1"
166><A
167NAME="AEN7707"
168></A
169><H2
170>Description</H2
171><P
172>The <CODE
173CLASS="FUNCTION"
174>ioctl()</CODE
175> function is used to program
176V4L2 devices. The argument <CODE
177CLASS="PARAMETER"
178>fd</CODE
179> must be an open
180file descriptor. An ioctl <CODE
181CLASS="PARAMETER"
182>request</CODE
183> has encoded
184in it whether the argument is an input, output or read/write
185parameter, and the size of the argument <CODE
186CLASS="PARAMETER"
187>argp</CODE
188> in
189bytes. Macros and defines specifying V4L2 ioctl requests are located
190in the <A
191HREF="a16506.htm"
192>videodev.h</A
193> header file.
194Applications should use their own copy, not include the version in the
195kernel sources on the system they compile on. All V4L2 ioctl requests,
196their respective function and parameters are specified in <A
197HREF="r7624.htm"
198>Reference I, <I
199>Function Reference</I
200></A
201>.</P
202></DIV
203><DIV
204CLASS="REFSECT1"
205><A
206NAME="AEN7716"
207></A
208><H2
209>Return Value</H2
210><P
211>On success the <CODE
212CLASS="FUNCTION"
213>ioctl()</CODE
214> function returns
215<SPAN
216CLASS="RETURNVALUE"
217>0</SPAN
218> and does not reset the
219<CODE
220CLASS="VARNAME"
221>errno</CODE
222> variable. On failure
223<SPAN
224CLASS="RETURNVALUE"
225>-1</SPAN
226> is returned, when the ioctl takes an
227output or read/write parameter it remains unmodified, and the
228<CODE
229CLASS="VARNAME"
230>errno</CODE
231> variable is set appropriately. See below for
232possible error codes. Generic errors like <SPAN
233CLASS="ERRORCODE"
234>EBADF</SPAN
235>
236or <SPAN
237CLASS="ERRORCODE"
238>EFAULT</SPAN
239> are not listed in the sections
240discussing individual ioctl requests.</P
241><P
242>Note ioctls may return undefined error codes. Since errors
243may have side effects such as a driver reset applications should
244abort on unexpected errors.</P
245><P
246></P
247><DIV
248CLASS="VARIABLELIST"
249><DL
250><DT
251><SPAN
252CLASS="ERRORCODE"
253>EBADF</SPAN
254></DT
255><DD
256><P
257><CODE
258CLASS="PARAMETER"
259>fd</CODE
260> is not a valid open file
261descriptor.</P
262></DD
263><DT
264><SPAN
265CLASS="ERRORCODE"
266>EBUSY</SPAN
267></DT
268><DD
269><P
270>The property cannot be changed right now. Typically
271this error code is returned when I/O is in progress or the driver
272supports multiple opens and another process locked the property.</P
273></DD
274><DT
275><SPAN
276CLASS="ERRORCODE"
277>EFAULT</SPAN
278></DT
279><DD
280><P
281><CODE
282CLASS="PARAMETER"
283>argp</CODE
284> references an inaccessible
285memory area.</P
286></DD
287><DT
288><SPAN
289CLASS="ERRORCODE"
290>ENOTTY</SPAN
291></DT
292><DD
293><P
294><CODE
295CLASS="PARAMETER"
296>fd</CODE
297> is  not  associated  with  a
298character special device.</P
299></DD
300><DT
301><SPAN
302CLASS="ERRORCODE"
303>EINVAL</SPAN
304></DT
305><DD
306><P
307>The <CODE
308CLASS="PARAMETER"
309>request</CODE
310> or the data pointed
311to by <CODE
312CLASS="PARAMETER"
313>argp</CODE
314> is not valid. This is a very common
315error code, see the individual ioctl requests listed in <A
316HREF="r7624.htm"
317>Reference I, <I
318>Function Reference</I
319></A
320> for actual causes.</P
321></DD
322><DT
323><SPAN
324CLASS="ERRORCODE"
325>ENOMEM</SPAN
326></DT
327><DD
328><P
329>Not enough physical or virtual memory was available to
330complete the request.</P
331></DD
332><DT
333><SPAN
334CLASS="ERRORCODE"
335>ERANGE</SPAN
336></DT
337><DD
338><P
339>The application attempted to set a control with the
340<A
341HREF="r10104.htm"
342><CODE
343CLASS="CONSTANT"
344>VIDIOC_S_CTRL</CODE
345></A
346> ioctl to a value which is out of bounds.</P
347></DD
348></DL
349></DIV
350></DIV
351><DIV
352CLASS="NAVFOOTER"
353><HR
354ALIGN="LEFT"
355WIDTH="100%"><TABLE
356SUMMARY="Footer navigation table"
357WIDTH="100%"
358BORDER="0"
359CELLPADDING="0"
360CELLSPACING="0"
361><TR
362><TD
363WIDTH="33%"
364ALIGN="left"
365VALIGN="top"
366><A
367HREF="r7626.htm"
368ACCESSKEY="P"
369>Prev</A
370></TD
371><TD
372WIDTH="34%"
373ALIGN="center"
374VALIGN="top"
375><A
376HREF="book1.htm"
377ACCESSKEY="H"
378>Home</A
379></TD
380><TD
381WIDTH="33%"
382ALIGN="right"
383VALIGN="top"
384><A
385HREF="r7771.htm"
386ACCESSKEY="N"
387>Next</A
388></TD
389></TR
390><TR
391><TD
392WIDTH="33%"
393ALIGN="left"
394VALIGN="top"
395>V4L2 close()</TD
396><TD
397WIDTH="34%"
398ALIGN="center"
399VALIGN="top"
400><A
401HREF="r7624.htm"
402ACCESSKEY="U"
403>Up</A
404></TD
405><TD
406WIDTH="33%"
407ALIGN="right"
408VALIGN="top"
409>ioctl VIDIOC_CROPCAP</TD
410></TR
411></TABLE
412></DIV
413></BODY
414></HTML
415>
416