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