Merge tag 'nfs-for-4.21-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
[sfrench/cifs-2.6.git] / Documentation / media / uapi / v4l / func-open.rst
1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/media/uapi/fdl-appendix.rst.
7 ..
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10 .. _func-open:
11
12 ***********
13 V4L2 open()
14 ***********
15
16 Name
17 ====
18
19 v4l2-open - Open a V4L2 device
20
21
22 Synopsis
23 ========
24
25 .. code-block:: c
26
27     #include <fcntl.h>
28
29
30 .. c:function:: int open( const char *device_name, int flags )
31     :name: v4l2-open
32
33 Arguments
34 =========
35
36 ``device_name``
37     Device to be opened.
38
39 ``flags``
40     Open flags. Access mode must be ``O_RDWR``. This is just a
41     technicality, input devices still support only reading and output
42     devices only writing.
43
44     When the ``O_NONBLOCK`` flag is given, the :ref:`read() <func-read>`
45     function and the :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will
46     return the ``EAGAIN`` error code when no data is available or no
47     buffer is in the driver outgoing queue, otherwise these functions
48     block until data becomes available. All V4L2 drivers exchanging data
49     with applications must support the ``O_NONBLOCK`` flag.
50
51     Other flags have no effect.
52
53
54 Description
55 ===========
56
57 To open a V4L2 device applications call :ref:`open() <func-open>` with the
58 desired device name. This function has no side effects; all data format
59 parameters, current input or output, control values or other properties
60 remain unchanged. At the first :ref:`open() <func-open>` call after loading the
61 driver they will be reset to default values, drivers are never in an
62 undefined state.
63
64
65 Return Value
66 ============
67
68 On success :ref:`open() <func-open>` returns the new file descriptor. On error
69 -1 is returned, and the ``errno`` variable is set appropriately.
70 Possible error codes are:
71
72 EACCES
73     The caller has no permission to access the device.
74
75 EBUSY
76     The driver does not support multiple opens and the device is already
77     in use.
78
79 ENXIO
80     No device corresponding to this device special file exists.
81
82 ENOMEM
83     Not enough kernel memory was available to complete the request.
84
85 EMFILE
86     The process already has the maximum number of files open.
87
88 ENFILE
89     The limit on the total number of files open on the system has been
90     reached.