Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/Documentation/DocBook/v4l/func-open.xml
10821 views
1
<refentry id="func-open">
2
<refmeta>
3
<refentrytitle>V4L2 open()</refentrytitle>
4
&manvol;
5
</refmeta>
6
7
<refnamediv>
8
<refname>v4l2-open</refname>
9
<refpurpose>Open a V4L2 device</refpurpose>
10
</refnamediv>
11
12
<refsynopsisdiv>
13
<funcsynopsis>
14
<funcsynopsisinfo>#include &lt;fcntl.h&gt;</funcsynopsisinfo>
15
<funcprototype>
16
<funcdef>int <function>open</function></funcdef>
17
<paramdef>const char *<parameter>device_name</parameter></paramdef>
18
<paramdef>int <parameter>flags</parameter></paramdef>
19
</funcprototype>
20
</funcsynopsis>
21
</refsynopsisdiv>
22
23
<refsect1>
24
<title>Arguments</title>
25
26
<variablelist>
27
<varlistentry>
28
<term><parameter>device_name</parameter></term>
29
<listitem>
30
<para>Device to be opened.</para>
31
</listitem>
32
</varlistentry>
33
<varlistentry>
34
<term><parameter>flags</parameter></term>
35
<listitem>
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>
46
</listitem>
47
</varlistentry>
48
</variablelist>
49
</refsect1>
50
<refsect1>
51
<title>Description</title>
52
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>
60
</refsect1>
61
<refsect1>
62
<title>Return Value</title>
63
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>
67
68
<variablelist>
69
<varlistentry>
70
<term><errorcode>EACCES</errorcode></term>
71
<listitem>
72
<para>The caller has no permission to access the
73
device.</para>
74
</listitem>
75
</varlistentry>
76
<varlistentry>
77
<term><errorcode>EBUSY</errorcode></term>
78
<listitem>
79
<para>The driver does not support multiple opens and the
80
device is already in use.</para>
81
</listitem>
82
</varlistentry>
83
<varlistentry>
84
<term><errorcode>ENXIO</errorcode></term>
85
<listitem>
86
<para>No device corresponding to this device special file
87
exists.</para>
88
</listitem>
89
</varlistentry>
90
<varlistentry>
91
<term><errorcode>ENOMEM</errorcode></term>
92
<listitem>
93
<para>Not enough kernel memory was available to complete the
94
request.</para>
95
</listitem>
96
</varlistentry>
97
<varlistentry>
98
<term><errorcode>EMFILE</errorcode></term>
99
<listitem>
100
<para>The process already has the maximum number of
101
files open.</para>
102
</listitem>
103
</varlistentry>
104
<varlistentry>
105
<term><errorcode>ENFILE</errorcode></term>
106
<listitem>
107
<para>The limit on the total number of files open on the
108
system has been reached.</para>
109
</listitem>
110
</varlistentry>
111
</variablelist>
112
</refsect1>
113
</refentry>
114
115
<!--
116
Local Variables:
117
mode: sgml
118
sgml-parent-document: "v4l2.sgml"
119
indent-tabs-mode: nil
120
End:
121
-->
122
123