Commit | Line | Data |
---|---|---|
5377d91f MH |
1 | .. -*- coding: utf-8; mode: rst -*- |
2 | ||
3 | .. _func-open: | |
4 | ||
5 | *********** | |
6 | V4L2 open() | |
7 | *********** | |
8 | ||
9 | *man v4l2-open(2)* | |
10 | ||
11 | Open a V4L2 device | |
12 | ||
13 | ||
14 | Synopsis | |
15 | ======== | |
16 | ||
17 | .. code-block:: c | |
18 | ||
19 | #include <fcntl.h> | |
20 | ||
21 | ||
22 | .. c:function:: int open( const char *device_name, int flags ) | |
23 | ||
24 | Arguments | |
25 | ========= | |
26 | ||
27 | ``device_name`` | |
28 | Device to be opened. | |
29 | ||
30 | ``flags`` | |
31 | Open flags. Access mode must be ``O_RDWR``. This is just a | |
32 | technicality, input devices still support only reading and output | |
33 | devices only writing. | |
34 | ||
35 | When the ``O_NONBLOCK`` flag is given, the read() function and the | |
af4a4d0d | 36 | :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will return the EAGAIN |
5377d91f MH |
37 | error code when no data is available or no buffer is in the driver |
38 | outgoing queue, otherwise these functions block until data becomes | |
39 | available. All V4L2 drivers exchanging data with applications must | |
40 | support the ``O_NONBLOCK`` flag. | |
41 | ||
42 | Other flags have no effect. | |
43 | ||
44 | ||
45 | Description | |
46 | =========== | |
47 | ||
48 | To open a V4L2 device applications call :c:func:`open()` with the | |
49 | desired device name. This function has no side effects; all data format | |
50 | parameters, current input or output, control values or other properties | |
51 | remain unchanged. At the first :c:func:`open()` call after loading the | |
52 | driver they will be reset to default values, drivers are never in an | |
53 | undefined state. | |
54 | ||
55 | ||
56 | Return Value | |
57 | ============ | |
58 | ||
59 | On success :c:func:`open()` returns the new file descriptor. On error | |
60 | -1 is returned, and the ``errno`` variable is set appropriately. | |
61 | Possible error codes are: | |
62 | ||
63 | EACCES | |
64 | The caller has no permission to access the device. | |
65 | ||
66 | EBUSY | |
67 | The driver does not support multiple opens and the device is already | |
68 | in use. | |
69 | ||
70 | ENXIO | |
71 | No device corresponding to this device special file exists. | |
72 | ||
73 | ENOMEM | |
74 | Not enough kernel memory was available to complete the request. | |
75 | ||
76 | EMFILE | |
77 | The process already has the maximum number of files open. | |
78 | ||
79 | ENFILE | |
80 | The limit on the total number of files open on the system has been | |
81 | reached. | |
82 | ||
83 | ||
84 | .. ------------------------------------------------------------------------------ | |
85 | .. This file was automatically converted from DocBook-XML with the dbxml | |
86 | .. library (https://github.com/return42/sphkerneldoc). The origin XML comes | |
87 | .. from the linux kernel, refer to: | |
88 | .. | |
89 | .. * https://github.com/torvalds/linux/tree/master/Documentation/DocBook | |
90 | .. ------------------------------------------------------------------------------ |