1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2407e84cdSMauro Carvalho Chehab.. c:namespace:: V4L
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _func-write:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab************
754f38fcaSMauro Carvalho ChehabV4L2 write()
854f38fcaSMauro Carvalho Chehab************
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho ChehabName
1154f38fcaSMauro Carvalho Chehab====
1254f38fcaSMauro Carvalho Chehab
1354f38fcaSMauro Carvalho Chehabv4l2-write - Write to a V4L2 device
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
1854f38fcaSMauro Carvalho Chehab.. code-block:: c
1954f38fcaSMauro Carvalho Chehab
2054f38fcaSMauro Carvalho Chehab    #include <unistd.h>
2154f38fcaSMauro Carvalho Chehab
2254f38fcaSMauro Carvalho Chehab.. c:function:: ssize_t write( int fd, void *buf, size_t count )
2354f38fcaSMauro Carvalho Chehab
2454f38fcaSMauro Carvalho ChehabArguments
2554f38fcaSMauro Carvalho Chehab=========
2654f38fcaSMauro Carvalho Chehab
2754f38fcaSMauro Carvalho Chehab``fd``
28407e84cdSMauro Carvalho Chehab    File descriptor returned by :c:func:`open()`.
2954f38fcaSMauro Carvalho Chehab
3054f38fcaSMauro Carvalho Chehab``buf``
3154f38fcaSMauro Carvalho Chehab     Buffer with data to be written
3254f38fcaSMauro Carvalho Chehab
3354f38fcaSMauro Carvalho Chehab``count``
3454f38fcaSMauro Carvalho Chehab    Number of bytes at the buffer
3554f38fcaSMauro Carvalho Chehab
3654f38fcaSMauro Carvalho ChehabDescription
3754f38fcaSMauro Carvalho Chehab===========
3854f38fcaSMauro Carvalho Chehab
39407e84cdSMauro Carvalho Chehab:c:func:`write()` writes up to ``count`` bytes to the device
4054f38fcaSMauro Carvalho Chehabreferenced by the file descriptor ``fd`` from the buffer starting at
4154f38fcaSMauro Carvalho Chehab``buf``. When the hardware outputs are not active yet, this function
42407e84cdSMauro Carvalho Chehabenables them. When ``count`` is zero, :c:func:`write()` returns 0
4354f38fcaSMauro Carvalho Chehabwithout any other effect.
4454f38fcaSMauro Carvalho Chehab
4554f38fcaSMauro Carvalho ChehabWhen the application does not provide more data in time, the previous
4654f38fcaSMauro Carvalho Chehabvideo frame, raw VBI image, sliced VPS or WSS data is displayed again.
4754f38fcaSMauro Carvalho ChehabSliced Teletext or Closed Caption data is not repeated, the driver
4854f38fcaSMauro Carvalho Chehabinserts a blank line instead.
4954f38fcaSMauro Carvalho Chehab
5054f38fcaSMauro Carvalho ChehabReturn Value
5154f38fcaSMauro Carvalho Chehab============
5254f38fcaSMauro Carvalho Chehab
5354f38fcaSMauro Carvalho ChehabOn success, the number of bytes written are returned. Zero indicates
5454f38fcaSMauro Carvalho Chehabnothing was written. On error, -1 is returned, and the ``errno``
5554f38fcaSMauro Carvalho Chehabvariable is set appropriately. In this case the next write will start at
5654f38fcaSMauro Carvalho Chehabthe beginning of a new frame. Possible error codes are:
5754f38fcaSMauro Carvalho Chehab
5854f38fcaSMauro Carvalho ChehabEAGAIN
5954f38fcaSMauro Carvalho Chehab    Non-blocking I/O has been selected using the
6054f38fcaSMauro Carvalho Chehab    :ref:`O_NONBLOCK <func-open>` flag and no buffer space was
6154f38fcaSMauro Carvalho Chehab    available to write the data immediately.
6254f38fcaSMauro Carvalho Chehab
6354f38fcaSMauro Carvalho ChehabEBADF
6454f38fcaSMauro Carvalho Chehab    ``fd`` is not a valid file descriptor or is not open for writing.
6554f38fcaSMauro Carvalho Chehab
6654f38fcaSMauro Carvalho ChehabEBUSY
6754f38fcaSMauro Carvalho Chehab    The driver does not support multiple write streams and the device is
6854f38fcaSMauro Carvalho Chehab    already in use.
6954f38fcaSMauro Carvalho Chehab
7054f38fcaSMauro Carvalho ChehabEFAULT
7154f38fcaSMauro Carvalho Chehab    ``buf`` references an inaccessible memory area.
7254f38fcaSMauro Carvalho Chehab
7354f38fcaSMauro Carvalho ChehabEINTR
7454f38fcaSMauro Carvalho Chehab    The call was interrupted by a signal before any data was written.
7554f38fcaSMauro Carvalho Chehab
7654f38fcaSMauro Carvalho ChehabEIO
7754f38fcaSMauro Carvalho Chehab    I/O error. This indicates some hardware problem.
7854f38fcaSMauro Carvalho Chehab
7954f38fcaSMauro Carvalho ChehabEINVAL
80407e84cdSMauro Carvalho Chehab    The :c:func:`write()` function is not supported by this driver,
8154f38fcaSMauro Carvalho Chehab    not on this device, or generally not on this type of device.
82