162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci.. c:namespace:: V4L 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci.. _func-open: 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci*********** 762306a36Sopenharmony_ciV4L2 open() 862306a36Sopenharmony_ci*********** 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciName 1162306a36Sopenharmony_ci==== 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_civ4l2-open - Open a V4L2 device 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciSynopsis 1662306a36Sopenharmony_ci======== 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci.. code-block:: c 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci #include <fcntl.h> 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci.. c:function:: int open( const char *device_name, int flags ) 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciArguments 2562306a36Sopenharmony_ci========= 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci``device_name`` 2862306a36Sopenharmony_ci Device to be opened. 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci``flags`` 3162306a36Sopenharmony_ci Open flags. Access mode must be ``O_RDWR``. This is just a 3262306a36Sopenharmony_ci technicality, input devices still support only reading and output 3362306a36Sopenharmony_ci devices only writing. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci When the ``O_NONBLOCK`` flag is given, the :c:func:`read()` 3662306a36Sopenharmony_ci function and the :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will 3762306a36Sopenharmony_ci return the ``EAGAIN`` error code when no data is available or no 3862306a36Sopenharmony_ci buffer is in the driver outgoing queue, otherwise these functions 3962306a36Sopenharmony_ci block until data becomes available. All V4L2 drivers exchanging data 4062306a36Sopenharmony_ci with applications must support the ``O_NONBLOCK`` flag. 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci Other flags have no effect. 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciDescription 4562306a36Sopenharmony_ci=========== 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ciTo open a V4L2 device applications call :c:func:`open()` with the 4862306a36Sopenharmony_cidesired device name. This function has no side effects; all data format 4962306a36Sopenharmony_ciparameters, current input or output, control values or other properties 5062306a36Sopenharmony_ciremain unchanged. At the first :c:func:`open()` call after loading the 5162306a36Sopenharmony_cidriver they will be reset to default values, drivers are never in an 5262306a36Sopenharmony_ciundefined state. 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ciReturn Value 5562306a36Sopenharmony_ci============ 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ciOn success :c:func:`open()` returns the new file descriptor. On error 5862306a36Sopenharmony_ci-1 is returned, and the ``errno`` variable is set appropriately. 5962306a36Sopenharmony_ciPossible error codes are: 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ciEACCES 6262306a36Sopenharmony_ci The caller has no permission to access the device. 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ciEBUSY 6562306a36Sopenharmony_ci The driver does not support multiple opens and the device is already 6662306a36Sopenharmony_ci in use. 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ciENXIO 6962306a36Sopenharmony_ci No device corresponding to this device special file exists. 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciENOMEM 7262306a36Sopenharmony_ci Not enough kernel memory was available to complete the request. 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ciEMFILE 7562306a36Sopenharmony_ci The process already has the maximum number of files open. 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ciENFILE 7862306a36Sopenharmony_ci The limit on the total number of files open on the system has been 7962306a36Sopenharmony_ci reached. 80