Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: V4L
0003 
0004 .. _func-open:
0005 
0006 ***********
0007 V4L2 open()
0008 ***********
0009 
0010 Name
0011 ====
0012 
0013 v4l2-open - Open a V4L2 device
0014 
0015 Synopsis
0016 ========
0017 
0018 .. code-block:: c
0019 
0020     #include <fcntl.h>
0021 
0022 .. c:function:: int open( const char *device_name, int flags )
0023 
0024 Arguments
0025 =========
0026 
0027 ``device_name``
0028     Device to be opened.
0029 
0030 ``flags``
0031     Open flags. Access mode must be ``O_RDWR``. This is just a
0032     technicality, input devices still support only reading and output
0033     devices only writing.
0034 
0035     When the ``O_NONBLOCK`` flag is given, the :c:func:`read()`
0036     function and the :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will
0037     return the ``EAGAIN`` error code when no data is available or no
0038     buffer is in the driver outgoing queue, otherwise these functions
0039     block until data becomes available. All V4L2 drivers exchanging data
0040     with applications must support the ``O_NONBLOCK`` flag.
0041 
0042     Other flags have no effect.
0043 
0044 Description
0045 ===========
0046 
0047 To open a V4L2 device applications call :c:func:`open()` with the
0048 desired device name. This function has no side effects; all data format
0049 parameters, current input or output, control values or other properties
0050 remain unchanged. At the first :c:func:`open()` call after loading the
0051 driver they will be reset to default values, drivers are never in an
0052 undefined state.
0053 
0054 Return Value
0055 ============
0056 
0057 On success :c:func:`open()` returns the new file descriptor. On error
0058 -1 is returned, and the ``errno`` variable is set appropriately.
0059 Possible error codes are:
0060 
0061 EACCES
0062     The caller has no permission to access the device.
0063 
0064 EBUSY
0065     The driver does not support multiple opens and the device is already
0066     in use.
0067 
0068 ENXIO
0069     No device corresponding to this device special file exists.
0070 
0071 ENOMEM
0072     Not enough kernel memory was available to complete the request.
0073 
0074 EMFILE
0075     The process already has the maximum number of files open.
0076 
0077 ENFILE
0078     The limit on the total number of files open on the system has been
0079     reached.