doc-rst: customize RTD theme, captions & inline literal
[deliverable/linux.git] / Documentation / linux_tv / media / v4l / func-open.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 .. _func-open:
4
5 ***********
6 V4L2 open()
7 ***********
8
9 NAME
10 ====
11
12 v4l2-open - Open a V4L2 device
13
14 SYNOPSIS
15 ========
16
17 .. code-block:: c
18
19 #include <fcntl.h>
20
21
22 .. cpp:function:: int open( const char *device_name, int flags )
23
24
25 ARGUMENTS
26 =========
27
28 ``device_name``
29 Device to be opened.
30
31 ``flags``
32 Open flags. Access mode must be ``O_RDWR``. This is just a
33 technicality, input devices still support only reading and output
34 devices only writing.
35
36 When the ``O_NONBLOCK`` flag is given, the :ref:`read() <func-read>`
37 function and the :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will
38 return the ``EAGAIN`` error code when no data is available or no
39 buffer is in the driver outgoing queue, otherwise these functions
40 block until data becomes available. All V4L2 drivers exchanging data
41 with applications must support the ``O_NONBLOCK`` flag.
42
43 Other flags have no effect.
44
45
46 DESCRIPTION
47 ===========
48
49 To open a V4L2 device applications call :ref:`open() <func-open>` with the
50 desired device name. This function has no side effects; all data format
51 parameters, current input or output, control values or other properties
52 remain unchanged. At the first :ref:`open() <func-open>` call after loading the
53 driver they will be reset to default values, drivers are never in an
54 undefined state.
55
56
57 RETURN VALUE
58 ============
59
60 On success :ref:`open() <func-open>` returns the new file descriptor. On error
61 -1 is returned, and the ``errno`` variable is set appropriately.
62 Possible error codes are:
63
64 EACCES
65 The caller has no permission to access the device.
66
67 EBUSY
68 The driver does not support multiple opens and the device is already
69 in use.
70
71 ENXIO
72 No device corresponding to this device special file exists.
73
74 ENOMEM
75 Not enough kernel memory was available to complete the request.
76
77 EMFILE
78 The process already has the maximum number of files open.
79
80 ENFILE
81 The limit on the total number of files open on the system has been
82 reached.
This page took 0.039743 seconds and 5 git commands to generate.