Merge branch 'thorsten' into docs-next
[sfrench/cifs-2.6.git] / Documentation / media / uapi / v4l / func-write.rst
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/media/uapi/fdl-appendix.rst.
7 ..
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10 .. _func-write:
11
12 ************
13 V4L2 write()
14 ************
15
16 Name
17 ====
18
19 v4l2-write - Write to a V4L2 device
20
21
22 Synopsis
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
33 Arguments
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
45 Description
46 ===========
47
48 :ref:`write() <func-write>` writes up to ``count`` bytes to the device
49 referenced by the file descriptor ``fd`` from the buffer starting at
50 ``buf``. When the hardware outputs are not active yet, this function
51 enables them. When ``count`` is zero, :ref:`write() <func-write>` returns 0
52 without any other effect.
53
54 When the application does not provide more data in time, the previous
55 video frame, raw VBI image, sliced VPS or WSS data is displayed again.
56 Sliced Teletext or Closed Caption data is not repeated, the driver
57 inserts a blank line instead.
58
59
60 Return Value
61 ============
62
63 On success, the number of bytes written are returned. Zero indicates
64 nothing was written. On error, -1 is returned, and the ``errno``
65 variable is set appropriately. In this case the next write will start at
66 the beginning of a new frame. Possible error codes are:
67
68 EAGAIN
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
73 EBADF
74     ``fd`` is not a valid file descriptor or is not open for writing.
75
76 EBUSY
77     The driver does not support multiple write streams and the device is
78     already in use.
79
80 EFAULT
81     ``buf`` references an inaccessible memory area.
82
83 EINTR
84     The call was interrupted by a signal before any data was written.
85
86 EIO
87     I/O error. This indicates some hardware problem.
88
89 EINVAL
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.