^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: V4L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _func-write:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) V4L2 write()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) v4l2-write - Write to a V4L2 device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .. c:function:: ssize_t write( int fd, void *buf, size_t count )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ``fd``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) File descriptor returned by :c:func:`open()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ``buf``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Buffer with data to be written
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ``count``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Number of bytes at the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) :c:func:`write()` writes up to ``count`` bytes to the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) referenced by the file descriptor ``fd`` from the buffer starting at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ``buf``. When the hardware outputs are not active yet, this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) enables them. When ``count`` is zero, :c:func:`write()` returns 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) without any other effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) When the application does not provide more data in time, the previous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) video frame, raw VBI image, sliced VPS or WSS data is displayed again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) Sliced Teletext or Closed Caption data is not repeated, the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) inserts a blank line instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) On success, the number of bytes written are returned. Zero indicates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) nothing was written. On error, -1 is returned, and the ``errno``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) variable is set appropriately. In this case the next write will start at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) the beginning of a new frame. Possible error codes are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) EAGAIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) Non-blocking I/O has been selected using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) :ref:`O_NONBLOCK <func-open>` flag and no buffer space was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) available to write the data immediately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) EBADF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ``fd`` is not a valid file descriptor or is not open for writing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) EBUSY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) The driver does not support multiple write streams and the device is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) already in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) EFAULT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) ``buf`` references an inaccessible memory area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) EINTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) The call was interrupted by a signal before any data was written.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) EIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) I/O error. This indicates some hardware problem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) The :c:func:`write()` function is not supported by this driver,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) not on this device, or generally not on this type of device.