1 <refentry id="func-open">
3 <refentrytitle>V4L2 open()</refentrytitle>
8 <refname>v4l2-open</refname>
9 <refpurpose>Open a V4L2 device</refpurpose>
14 <funcsynopsisinfo>#include <fcntl.h></funcsynopsisinfo>
16 <funcdef>int <function>open</function></funcdef>
17 <paramdef>const char *<parameter>device_name</parameter></paramdef>
18 <paramdef>int <parameter>flags</parameter></paramdef>
24 <title>Arguments</title>
28 <term><parameter>device_name</parameter></term>
30 <para>Device to be opened.</para>
34 <term><parameter>flags</parameter></term>
36 <para>Open flags. Access mode must be
37 <constant>O_RDWR</constant>. This is just a technicality, input devices
38 still support only reading and output devices only writing.</para>
39 <para>When the <constant>O_NONBLOCK</constant> flag is
40 given, the read() function and the &VIDIOC-DQBUF; ioctl will return
41 the &EAGAIN; when no data is available or no buffer is in the driver
42 outgoing queue, otherwise these functions block until data becomes
43 available. All V4L2 drivers exchanging data with applications must
44 support the <constant>O_NONBLOCK</constant> flag.</para>
45 <para>Other flags have no effect.</para>
51 <title>Description</title>
53 <para>To open a V4L2 device applications call
54 <function>open()</function> with the desired device name. This
55 function has no side effects; all data format parameters, current
56 input or output, control values or other properties remain unchanged.
57 At the first <function>open()</function> call after loading the driver
58 they will be reset to default values, drivers are never in an
59 undefined state.</para>
62 <title>Return Value</title>
64 <para>On success <function>open</function> returns the new file
65 descriptor. On error -1 is returned, and the <varname>errno</varname>
66 variable is set appropriately. Possible error codes are:</para>
70 <term><errorcode>EACCES</errorcode></term>
72 <para>The caller has no permission to access the
77 <term><errorcode>EBUSY</errorcode></term>
79 <para>The driver does not support multiple opens and the
80 device is already in use.</para>
84 <term><errorcode>ENXIO</errorcode></term>
86 <para>No device corresponding to this device special file
91 <term><errorcode>ENOMEM</errorcode></term>
93 <para>Not enough kernel memory was available to complete the
98 <term><errorcode>EMFILE</errorcode></term>
100 <para>The process already has the maximum number of
105 <term><errorcode>ENFILE</errorcode></term>
107 <para>The limit on the total number of files open on the
108 system has been reached.</para>
118 sgml-parent-document: "v4l2.sgml"
119 indent-tabs-mode: nil