| Mauro Carvalho Chehab | 8e080c2 | 2009-09-13 22:16:04 -0300 | [diff] [blame] | 1 | <refentry id="func-write"> | 
|  | 2 | <refmeta> | 
|  | 3 | <refentrytitle>V4L2 write()</refentrytitle> | 
|  | 4 | &manvol; | 
|  | 5 | </refmeta> | 
|  | 6 |  | 
|  | 7 | <refnamediv> | 
|  | 8 | <refname>v4l2-write</refname> | 
|  | 9 | <refpurpose>Write to a V4L2 device</refpurpose> | 
|  | 10 | </refnamediv> | 
|  | 11 |  | 
|  | 12 | <refsynopsisdiv> | 
|  | 13 | <funcsynopsis> | 
|  | 14 | <funcsynopsisinfo>#include <unistd.h></funcsynopsisinfo> | 
|  | 15 | <funcprototype> | 
|  | 16 | <funcdef>ssize_t <function>write</function></funcdef> | 
|  | 17 | <paramdef>int <parameter>fd</parameter></paramdef> | 
|  | 18 | <paramdef>void *<parameter>buf</parameter></paramdef> | 
|  | 19 | <paramdef>size_t <parameter>count</parameter></paramdef> | 
|  | 20 | </funcprototype> | 
|  | 21 | </funcsynopsis> | 
|  | 22 | </refsynopsisdiv> | 
|  | 23 |  | 
|  | 24 | <refsect1> | 
|  | 25 | <title>Arguments</title> | 
|  | 26 |  | 
|  | 27 | <variablelist> | 
|  | 28 | <varlistentry> | 
|  | 29 | <term><parameter>fd</parameter></term> | 
|  | 30 | <listitem> | 
|  | 31 | <para>&fd;</para> | 
|  | 32 | </listitem> | 
|  | 33 | </varlistentry> | 
|  | 34 | <varlistentry> | 
|  | 35 | <term><parameter>buf</parameter></term> | 
|  | 36 | <listitem> | 
|  | 37 | <para></para> | 
|  | 38 | </listitem> | 
|  | 39 | </varlistentry> | 
|  | 40 | <varlistentry> | 
|  | 41 | <term><parameter>count</parameter></term> | 
|  | 42 | <listitem> | 
|  | 43 | <para></para> | 
|  | 44 | </listitem> | 
|  | 45 | </varlistentry> | 
|  | 46 | </variablelist> | 
|  | 47 | </refsect1> | 
|  | 48 |  | 
|  | 49 | <refsect1> | 
|  | 50 | <title>Description</title> | 
|  | 51 |  | 
|  | 52 | <para><function>write()</function> writes up to | 
|  | 53 | <parameter>count</parameter> bytes to the device referenced by the | 
|  | 54 | file descriptor <parameter>fd</parameter> from the buffer starting at | 
|  | 55 | <parameter>buf</parameter>. When the hardware outputs are not active | 
|  | 56 | yet, this function enables them. When <parameter>count</parameter> is | 
|  | 57 | zero, <function>write()</function> returns | 
|  | 58 | <returnvalue>0</returnvalue> without any other effect.</para> | 
|  | 59 |  | 
|  | 60 | <para>When the application does not provide more data in time, the | 
|  | 61 | previous video frame, raw VBI image, sliced VPS or WSS data is | 
|  | 62 | displayed again. Sliced Teletext or Closed Caption data is not | 
|  | 63 | repeated, the driver inserts a blank line instead.</para> | 
|  | 64 | </refsect1> | 
|  | 65 |  | 
|  | 66 | <refsect1> | 
|  | 67 | <title>Return Value</title> | 
|  | 68 |  | 
|  | 69 | <para>On success, the number of bytes written are returned. Zero | 
|  | 70 | indicates nothing was written. On error, <returnvalue>-1</returnvalue> | 
|  | 71 | is returned, and the <varname>errno</varname> variable is set | 
|  | 72 | appropriately. In this case the next write will start at the beginning | 
|  | 73 | of a new frame. Possible error codes are:</para> | 
|  | 74 |  | 
|  | 75 | <variablelist> | 
|  | 76 | <varlistentry> | 
|  | 77 | <term><errorcode>EAGAIN</errorcode></term> | 
|  | 78 | <listitem> | 
|  | 79 | <para>Non-blocking I/O has been selected using the <link | 
|  | 80 | linkend="func-open"><constant>O_NONBLOCK</constant></link> flag and no | 
|  | 81 | buffer space was available to write the data immediately.</para> | 
|  | 82 | </listitem> | 
|  | 83 | </varlistentry> | 
|  | 84 | <varlistentry> | 
|  | 85 | <term><errorcode>EBADF</errorcode></term> | 
|  | 86 | <listitem> | 
|  | 87 | <para><parameter>fd</parameter> is not a valid file | 
|  | 88 | descriptor or is not open for writing.</para> | 
|  | 89 | </listitem> | 
|  | 90 | </varlistentry> | 
|  | 91 | <varlistentry> | 
|  | 92 | <term><errorcode>EBUSY</errorcode></term> | 
|  | 93 | <listitem> | 
|  | 94 | <para>The driver does not support multiple write streams and the | 
|  | 95 | device is already in use.</para> | 
|  | 96 | </listitem> | 
|  | 97 | </varlistentry> | 
|  | 98 | <varlistentry> | 
|  | 99 | <term><errorcode>EFAULT</errorcode></term> | 
|  | 100 | <listitem> | 
|  | 101 | <para><parameter>buf</parameter> references an inaccessible | 
|  | 102 | memory area.</para> | 
|  | 103 | </listitem> | 
|  | 104 | </varlistentry> | 
|  | 105 | <varlistentry> | 
|  | 106 | <term><errorcode>EINTR</errorcode></term> | 
|  | 107 | <listitem> | 
|  | 108 | <para>The call was interrupted by a signal before any | 
|  | 109 | data was written.</para> | 
|  | 110 | </listitem> | 
|  | 111 | </varlistentry> | 
|  | 112 | <varlistentry> | 
|  | 113 | <term><errorcode>EIO</errorcode></term> | 
|  | 114 | <listitem> | 
|  | 115 | <para>I/O error. This indicates some hardware problem.</para> | 
|  | 116 | </listitem> | 
|  | 117 | </varlistentry> | 
|  | 118 | <varlistentry> | 
|  | 119 | <term><errorcode>EINVAL</errorcode></term> | 
|  | 120 | <listitem> | 
|  | 121 | <para>The <function>write()</function> function is not | 
|  | 122 | supported by this driver, not on this device, or generally not on this | 
|  | 123 | type of device.</para> | 
|  | 124 | </listitem> | 
|  | 125 | </varlistentry> | 
|  | 126 | </variablelist> | 
|  | 127 | </refsect1> | 
|  | 128 | </refentry> | 
|  | 129 |  | 
|  | 130 | <!-- | 
|  | 131 | Local Variables: | 
|  | 132 | mode: sgml | 
|  | 133 | sgml-parent-document: "v4l2.sgml" | 
|  | 134 | indent-tabs-mode: nil | 
|  | 135 | End: | 
|  | 136 | --> |