80 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _func-open:5 6***********7V4L2 open()8***********9 10Name11====12 13v4l2-open - Open a V4L2 device14 15Synopsis16========17 18.. code-block:: c19 20 #include <fcntl.h>21 22.. c:function:: int open( const char *device_name, int flags )23 24Arguments25=========26 27``device_name``28 Device to be opened.29 30``flags``31 Open flags. Access mode must be ``O_RDWR``. This is just a32 technicality, input devices still support only reading and output33 devices only writing.34 35 When the ``O_NONBLOCK`` flag is given, the :c:func:`read()`36 function and the :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will37 return the ``EAGAIN`` error code when no data is available or no38 buffer is in the driver outgoing queue, otherwise these functions39 block until data becomes available. All V4L2 drivers exchanging data40 with applications must support the ``O_NONBLOCK`` flag.41 42 Other flags have no effect.43 44Description45===========46 47To open a V4L2 device applications call :c:func:`open()` with the48desired device name. This function has no side effects; all data format49parameters, current input or output, control values or other properties50remain unchanged. At the first :c:func:`open()` call after loading the51driver they will be reset to default values, drivers are never in an52undefined state.53 54Return Value55============56 57On success :c:func:`open()` returns the new file descriptor. On error58-1 is returned, and the ``errno`` variable is set appropriately.59Possible error codes are:60 61EACCES62 The caller has no permission to access the device.63 64EBUSY65 The driver does not support multiple opens and the device is already66 in use.67 68ENODEV69 Device not found or was removed.70 71ENOMEM72 Not enough kernel memory was available to complete the request.73 74EMFILE75 The process already has the maximum number of files open.76 77ENFILE78 The limit on the total number of files open on the system has been79 reached.80