aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/DocBook/media/v4l/func-open.xml
blob: 7595d07a8c72d4be090c982dc902ff96ab9357db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<refentry id="func-open">
  <refmeta>
    <refentrytitle>V4L2 open()</refentrytitle>
    &manvol;
  </refmeta>

  <refnamediv>
    <refname>v4l2-open</refname>
    <refpurpose>Open a V4L2 device</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcsynopsisinfo>#include &lt;fcntl.h&gt;</funcsynopsisinfo>
      <funcprototype>
	<funcdef>int <function>open</function></funcdef>
	<paramdef>const char *<parameter>device_name</parameter></paramdef>
	<paramdef>int <parameter>flags</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>

  <refsect1>
    <title>Arguments</title>

    <variablelist>
      <varlistentry>
	<term><parameter>device_name</parameter></term>
	<listitem>
	  <para>Device to be opened.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter>flags</parameter></term>
	<listitem>
	  <para>Open flags. Access mode must be
<constant>O_RDWR</constant>. This is just a technicality, input devices
still support only reading and output devices only writing.</para>
	  <para>When the <constant>O_NONBLOCK</constant> flag is
given, the read() function and the &VIDIOC-DQBUF; ioctl will return
the &EAGAIN; 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 <constant>O_NONBLOCK</constant> flag.</para>
	  <para>Other flags have no effect.</para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>Description</title>

    <para>To open a V4L2 device applications call
<function>open()</function> 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 <function>open()</function> call after loading the driver
they will be reset to default values, drivers are never in an
undefined state.</para>
  </refsect1>
  <refsect1>
    <title>Return Value</title>

    <para>On success <function>open</function> returns the new file
descriptor. On error -1 is returned, and the <varname>errno</varname>
variable is set appropriately. Possible error codes are:</para>

    <variablelist>
      <varlistentry>
	<term><errorcode>EACCES</errorcode></term>
	<listitem>
	  <para>The caller has no permission to access the
device.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>EBUSY</errorcode></term>
	<listitem>
	  <para>The driver does not support multiple opens and the
device is already in use.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>ENXIO</errorcode></term>
	<listitem>
	  <para>No device corresponding to this device special file
exists.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>ENOMEM</errorcode></term>
	<listitem>
	  <para>Not enough kernel memory was available to complete the
request.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>EMFILE</errorcode></term>
	<listitem>
	  <para>The  process  already  has  the  maximum number of
files open.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>ENFILE</errorcode></term>
	<listitem>
	  <para>The limit on the total number of files open on the
system has been reached.</para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
</refentry>

<!--
Local Variables:
mode: sgml
sgml-parent-document: "v4l2.sgml"
indent-tabs-mode: nil
End:
-->