]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - Documentation/linux_tv/media/v4l/func-open.rst
doc-rst: dev-codec: Fix a reference for _STREAMON
[mirror_ubuntu-artful-kernel.git] / Documentation / linux_tv / media / v4l / func-open.rst
CommitLineData
5377d91f
MH
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _func-open:
4
5***********
6V4L2 open()
7***********
8
9*man v4l2-open(2)*
10
11Open a V4L2 device
12
13
14Synopsis
15========
16
17.. code-block:: c
18
19 #include <fcntl.h>
20
21
b7e67f6c 22.. cpp:function:: int open( const char *device_name, int flags )
5377d91f
MH
23
24Arguments
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
cdb4af0f 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
45Description
46===========
47
760c7010 48To open a V4L2 device applications call :ref:`open() <func-open>` with the
5377d91f
MH
49desired device name. This function has no side effects; all data format
50parameters, current input or output, control values or other properties
760c7010 51remain unchanged. At the first :ref:`open() <func-open>` call after loading the
5377d91f
MH
52driver they will be reset to default values, drivers are never in an
53undefined state.
54
55
56Return Value
57============
58
760c7010 59On success :ref:`open() <func-open>` returns the new file descriptor. On error
5377d91f
MH
60-1 is returned, and the ``errno`` variable is set appropriately.
61Possible error codes are:
62
63EACCES
64 The caller has no permission to access the device.
65
66EBUSY
67 The driver does not support multiple opens and the device is already
68 in use.
69
70ENXIO
71 No device corresponding to this device special file exists.
72
73ENOMEM
74 Not enough kernel memory was available to complete the request.
75
76EMFILE
77 The process already has the maximum number of files open.
78
79ENFILE
80 The limit on the total number of files open on the system has been
81 reached.