func-write.rst 1.9 KB
Newer Older
1 2 3 4 5 6 7 8
.. -*- coding: utf-8; mode: rst -*-

.. _func-write:

************
V4L2 write()
************

9 10
NAME
====
11

12
v4l2-write - Write to a V4L2 device
13

14
SYNOPSIS
15 16 17 18 19 20 21
========

.. code-block:: c

    #include <unistd.h>


22
.. cpp:function:: ssize_t write( int fd, void *buf, size_t count )
23

24 25

ARGUMENTS
26 27 28 29 30 31 32 33 34
=========

``fd``
    File descriptor returned by :ref:`open() <func-open>`.

``buf``
``count``


35
DESCRIPTION
36 37
===========

38
:ref:`write() <func-write>` writes up to ``count`` bytes to the device
39 40
referenced by the file descriptor ``fd`` from the buffer starting at
``buf``. When the hardware outputs are not active yet, this function
41
enables them. When ``count`` is zero, :ref:`write() <func-write>` returns 0
42 43 44 45 46 47 48 49
without any other effect.

When the application does not provide more data in time, the previous
video frame, raw VBI image, sliced VPS or WSS data is displayed again.
Sliced Teletext or Closed Caption data is not repeated, the driver
inserts a blank line instead.


50
RETURN VALUE
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
============

On success, the number of bytes written are returned. Zero indicates
nothing was written. On error, -1 is returned, and the ``errno``
variable is set appropriately. In this case the next write will start at
the beginning of a new frame. Possible error codes are:

EAGAIN
    Non-blocking I/O has been selected using the
    :ref:`O_NONBLOCK <func-open>` flag and no buffer space was
    available to write the data immediately.

EBADF
    ``fd`` is not a valid file descriptor or is not open for writing.

EBUSY
    The driver does not support multiple write streams and the device is
    already in use.

EFAULT
    ``buf`` references an inaccessible memory area.

EINTR
    The call was interrupted by a signal before any data was written.

EIO
    I/O error. This indicates some hardware problem.

EINVAL
80
    The :ref:`write() <func-write>` function is not supported by this driver,
81
    not on this device, or generally not on this type of device.