2016-06-30 13:18:56 +00:00
|
|
|
.. -*- coding: utf-8; mode: rst -*-
|
|
|
|
|
|
|
|
.. _func-open:
|
|
|
|
|
|
|
|
***********
|
|
|
|
V4L2 open()
|
|
|
|
***********
|
|
|
|
|
2016-07-05 18:14:35 +00:00
|
|
|
Name
|
2016-07-05 10:58:48 +00:00
|
|
|
====
|
2016-06-30 13:18:56 +00:00
|
|
|
|
2016-07-05 10:58:48 +00:00
|
|
|
v4l2-open - Open a V4L2 device
|
2016-06-30 13:18:56 +00:00
|
|
|
|
2016-07-05 18:14:35 +00:00
|
|
|
|
|
|
|
Synopsis
|
2016-06-30 13:18:56 +00:00
|
|
|
========
|
|
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
|
2016-08-19 15:00:43 +00:00
|
|
|
.. c:function:: int open( const char *device_name, int flags )
|
2016-08-19 19:53:38 +00:00
|
|
|
:name: v4l2-open
|
2016-07-05 10:58:48 +00:00
|
|
|
|
2016-07-05 18:14:35 +00:00
|
|
|
Arguments
|
2016-06-30 13:18:56 +00:00
|
|
|
=========
|
|
|
|
|
|
|
|
``device_name``
|
|
|
|
Device to be opened.
|
|
|
|
|
|
|
|
``flags``
|
|
|
|
Open flags. Access mode must be ``O_RDWR``. This is just a
|
|
|
|
technicality, input devices still support only reading and output
|
|
|
|
devices only writing.
|
|
|
|
|
2016-07-04 21:16:57 +00:00
|
|
|
When the ``O_NONBLOCK`` flag is given, the :ref:`read() <func-read>`
|
|
|
|
function and the :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will
|
|
|
|
return the ``EAGAIN`` error code when no data is available or no
|
|
|
|
buffer is in the driver outgoing queue, otherwise these functions
|
|
|
|
block until data becomes available. All V4L2 drivers exchanging data
|
|
|
|
with applications must support the ``O_NONBLOCK`` flag.
|
2016-06-30 13:18:56 +00:00
|
|
|
|
|
|
|
Other flags have no effect.
|
|
|
|
|
|
|
|
|
2016-07-05 18:14:35 +00:00
|
|
|
Description
|
2016-06-30 13:18:56 +00:00
|
|
|
===========
|
|
|
|
|
2016-07-04 15:56:17 +00:00
|
|
|
To open a V4L2 device applications call :ref:`open() <func-open>` with the
|
2016-06-30 13:18:56 +00:00
|
|
|
desired device name. This function has no side effects; all data format
|
|
|
|
parameters, current input or output, control values or other properties
|
2016-07-04 15:56:17 +00:00
|
|
|
remain unchanged. At the first :ref:`open() <func-open>` call after loading the
|
2016-06-30 13:18:56 +00:00
|
|
|
driver they will be reset to default values, drivers are never in an
|
|
|
|
undefined state.
|
|
|
|
|
|
|
|
|
2016-07-05 18:14:35 +00:00
|
|
|
Return Value
|
2016-06-30 13:18:56 +00:00
|
|
|
============
|
|
|
|
|
2016-07-04 15:56:17 +00:00
|
|
|
On success :ref:`open() <func-open>` returns the new file descriptor. On error
|
2016-06-30 13:18:56 +00:00
|
|
|
-1 is returned, and the ``errno`` variable is set appropriately.
|
|
|
|
Possible error codes are:
|
|
|
|
|
|
|
|
EACCES
|
|
|
|
The caller has no permission to access the device.
|
|
|
|
|
|
|
|
EBUSY
|
|
|
|
The driver does not support multiple opens and the device is already
|
|
|
|
in use.
|
|
|
|
|
|
|
|
ENXIO
|
|
|
|
No device corresponding to this device special file exists.
|
|
|
|
|
|
|
|
ENOMEM
|
|
|
|
Not enough kernel memory was available to complete the request.
|
|
|
|
|
|
|
|
EMFILE
|
|
|
|
The process already has the maximum number of files open.
|
|
|
|
|
|
|
|
ENFILE
|
|
|
|
The limit on the total number of files open on the system has been
|
|
|
|
reached.
|