Path: blob/master/Documentation/DocBook/v4l/func-write.xml
10821 views
<refentry id="func-write">1<refmeta>2<refentrytitle>V4L2 write()</refentrytitle>3&manvol;4</refmeta>56<refnamediv>7<refname>v4l2-write</refname>8<refpurpose>Write to a V4L2 device</refpurpose>9</refnamediv>1011<refsynopsisdiv>12<funcsynopsis>13<funcsynopsisinfo>#include <unistd.h></funcsynopsisinfo>14<funcprototype>15<funcdef>ssize_t <function>write</function></funcdef>16<paramdef>int <parameter>fd</parameter></paramdef>17<paramdef>void *<parameter>buf</parameter></paramdef>18<paramdef>size_t <parameter>count</parameter></paramdef>19</funcprototype>20</funcsynopsis>21</refsynopsisdiv>2223<refsect1>24<title>Arguments</title>2526<variablelist>27<varlistentry>28<term><parameter>fd</parameter></term>29<listitem>30<para>&fd;</para>31</listitem>32</varlistentry>33<varlistentry>34<term><parameter>buf</parameter></term>35<listitem>36<para></para>37</listitem>38</varlistentry>39<varlistentry>40<term><parameter>count</parameter></term>41<listitem>42<para></para>43</listitem>44</varlistentry>45</variablelist>46</refsect1>4748<refsect1>49<title>Description</title>5051<para><function>write()</function> writes up to52<parameter>count</parameter> bytes to the device referenced by the53file descriptor <parameter>fd</parameter> from the buffer starting at54<parameter>buf</parameter>. When the hardware outputs are not active55yet, this function enables them. When <parameter>count</parameter> is56zero, <function>write()</function> returns57<returnvalue>0</returnvalue> without any other effect.</para>5859<para>When the application does not provide more data in time, the60previous video frame, raw VBI image, sliced VPS or WSS data is61displayed again. Sliced Teletext or Closed Caption data is not62repeated, the driver inserts a blank line instead.</para>63</refsect1>6465<refsect1>66<title>Return Value</title>6768<para>On success, the number of bytes written are returned. Zero69indicates nothing was written. On error, <returnvalue>-1</returnvalue>70is returned, and the <varname>errno</varname> variable is set71appropriately. In this case the next write will start at the beginning72of a new frame. Possible error codes are:</para>7374<variablelist>75<varlistentry>76<term><errorcode>EAGAIN</errorcode></term>77<listitem>78<para>Non-blocking I/O has been selected using the <link79linkend="func-open"><constant>O_NONBLOCK</constant></link> flag and no80buffer space was available to write the data immediately.</para>81</listitem>82</varlistentry>83<varlistentry>84<term><errorcode>EBADF</errorcode></term>85<listitem>86<para><parameter>fd</parameter> is not a valid file87descriptor or is not open for writing.</para>88</listitem>89</varlistentry>90<varlistentry>91<term><errorcode>EBUSY</errorcode></term>92<listitem>93<para>The driver does not support multiple write streams and the94device is already in use.</para>95</listitem>96</varlistentry>97<varlistentry>98<term><errorcode>EFAULT</errorcode></term>99<listitem>100<para><parameter>buf</parameter> references an inaccessible101memory area.</para>102</listitem>103</varlistentry>104<varlistentry>105<term><errorcode>EINTR</errorcode></term>106<listitem>107<para>The call was interrupted by a signal before any108data was written.</para>109</listitem>110</varlistentry>111<varlistentry>112<term><errorcode>EIO</errorcode></term>113<listitem>114<para>I/O error. This indicates some hardware problem.</para>115</listitem>116</varlistentry>117<varlistentry>118<term><errorcode>EINVAL</errorcode></term>119<listitem>120<para>The <function>write()</function> function is not121supported by this driver, not on this device, or generally not on this122type of device.</para>123</listitem>124</varlistentry>125</variablelist>126</refsect1>127</refentry>128129<!--130Local Variables:131mode: sgml132sgml-parent-document: "v4l2.sgml"133indent-tabs-mode: nil134End:135-->136137138