<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>V4L2 open()</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API" /><link rel="up" href="apa.html" title="Appendix A. Function Reference" /><link rel="prev" href="re63.html" title="V4L2 munmap()" /><link rel="next" href="re65.html" title="V4L2 poll()" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">V4L2 open()</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re63.html">Prev</a> </td><th width="60%" align="center">Appendix A. Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="re65.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="V4L2 open()"><a id="func-open"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>v4l2-open — Open a V4L2 device</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <fcntl.h></pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">open</b>(</code></td><td>const char *<var class="pdparam">device_name</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1" title="Arguments"><a id="id2930633"></a><h2>Arguments</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>device_name</code></em></span></dt><dd><p>Device to be opened.</p></dd><dt><span class="term"><em class="parameter"><code>flags</code></em></span></dt><dd><p>Open flags. Access mode must be <code class="constant">O_RDWR</code>. This is just a technicality, input devices still support only reading and output devices only writing.</p><p>When the <code class="constant">O_NONBLOCK</code> flag is given, the read() function and the <a class="link" href="re54.html" title="ioctl VIDIOC_QBUF, VIDIOC_DQBUF"><code class="constant">VIDIOC_DQBUF</code></a> ioctl will return the <span class="errorcode">EAGAIN</span> error code when no data is available or no buffer is in the driver outgoing queue, otherwise these functions block until data becomes available. All V4L2 drivers exchanging data with applications must support the <code class="constant">O_NONBLOCK</code> flag.</p><p>Other flags have no effect.</p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2930715"></a><h2>Description</h2><p>To open a V4L2 device applications call <code class="function">open()</code> with the desired device name. This function has no side effects; all data format parameters, current input or output, control values or other properties remain unchanged. At the first <code class="function">open()</code> call after loading the driver they will be reset to default values, drivers are never in an undefined state.</p></div><div class="refsect1" title="Return Value"><a id="id2930742"></a><h2>Return Value</h2><p>On success <code class="function">open</code> returns the new file descriptor. On error -1 is returned, and the <code class="varname">errno</code> variable is set appropriately. Possible error codes are:</p><div class="variablelist"><dl><dt><span class="term"><span class="errorcode">EACCES</span></span></dt><dd><p>The caller has no permission to access the device.</p></dd><dt><span class="term"><span class="errorcode">EBUSY</span></span></dt><dd><p>The driver does not support multiple opens and the device is already in use.</p></dd><dt><span class="term"><span class="errorcode">ENXIO</span></span></dt><dd><p>No device corresponding to this device special file exists.</p></dd><dt><span class="term"><span class="errorcode">ENOMEM</span></span></dt><dd><p>Not enough kernel memory was available to complete the request.</p></dd><dt><span class="term"><span class="errorcode">EMFILE</span></span></dt><dd><p>The process already has the maximum number of files open.</p></dd><dt><span class="term"><span class="errorcode">ENFILE</span></span></dt><dd><p>The limit on the total number of files open on the system has been reached.</p></dd></dl></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re63.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apa.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="re65.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">V4L2 munmap() </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> V4L2 poll()</td></tr></table></div></body></html>