1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> 2 <HTML 3 ><HEAD 4 ><TITLE 5 >V4L2 write()</TITLE 6 ><META 7 NAME="GENERATOR" 8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK 9 REL="HOME" 10 TITLE="Video for Linux Two API Specification" 11 HREF="book1.htm"><LINK 12 REL="UP" 13 TITLE="Function Reference" 14 HREF="r7624.htm"><LINK 15 REL="PREVIOUS" 16 TITLE="V4L2 select()" 17 HREF="r14390.htm"><LINK 18 REL="NEXT" 19 TITLE="V4L2 Driver Programming" 20 HREF="c14592.htm"></HEAD 21 ><BODY 22 CLASS="REFENTRY" 23 BGCOLOR="#FFFFFF" 24 TEXT="#000000" 25 LINK="#0000FF" 26 VLINK="#840084" 27 ALINK="#0000FF" 28 ><DIV 29 CLASS="NAVHEADER" 30 ><TABLE 31 SUMMARY="Header navigation table" 32 WIDTH="100%" 33 BORDER="0" 34 CELLPADDING="0" 35 CELLSPACING="0" 36 ><TR 37 ><TH 38 COLSPAN="3" 39 ALIGN="center" 40 >Video for Linux Two API Specification: Revision 0.24</TH 41 ></TR 42 ><TR 43 ><TD 44 WIDTH="10%" 45 ALIGN="left" 46 VALIGN="bottom" 47 ><A 48 HREF="r14390.htm" 49 ACCESSKEY="P" 50 >Prev</A 51 ></TD 52 ><TD 53 WIDTH="80%" 54 ALIGN="center" 55 VALIGN="bottom" 56 ></TD 57 ><TD 58 WIDTH="10%" 59 ALIGN="right" 60 VALIGN="bottom" 61 ><A 62 HREF="c14592.htm" 63 ACCESSKEY="N" 64 >Next</A 65 ></TD 66 ></TR 67 ></TABLE 68 ><HR 69 ALIGN="LEFT" 70 WIDTH="100%"></DIV 71 ><H1 72 ><A 73 NAME="FUNC-WRITE" 74 ></A 75 >V4L2 write()</H1 76 ><DIV 77 CLASS="REFNAMEDIV" 78 ><A 79 NAME="AEN14500" 80 ></A 81 ><H2 82 >Name</H2 83 >v4l2-write -- Write to a V4L2 device</DIV 84 ><DIV 85 CLASS="REFSYNOPSISDIV" 86 ><A 87 NAME="AEN14503" 88 ></A 89 ><H2 90 >Synopsis</H2 91 ><DIV 92 CLASS="FUNCSYNOPSIS" 93 ><P 94 ></P 95 ><A 96 NAME="AEN14504" 97 ></A 98 ><PRE 99 CLASS="FUNCSYNOPSISINFO" 100 >#include <unistd.h></PRE 101 ><P 102 ><CODE 103 ><CODE 104 CLASS="FUNCDEF" 105 >ssize_t write</CODE 106 >(int fd, void *buf, size_t count);</CODE 107 ></P 108 ><P 109 ></P 110 ></DIV 111 ></DIV 112 ><DIV 113 CLASS="REFSECT1" 114 ><A 115 NAME="AEN14515" 116 ></A 117 ><H2 118 >Arguments</H2 119 ><P 120 ></P 121 ><DIV 122 CLASS="VARIABLELIST" 123 ><DL 124 ><DT 125 ><CODE 126 CLASS="PARAMETER" 127 >fd</CODE 128 ></DT 129 ><DD 130 ><P 131 >File descriptor returned by <A 132 HREF="r14090.htm" 133 ><CODE 134 CLASS="FUNCTION" 135 >open()</CODE 136 ></A 137 >.</P 138 ></DD 139 ><DT 140 ><CODE 141 CLASS="PARAMETER" 142 >buf</CODE 143 ></DT 144 ><DD 145 ><P 146 ></P 147 ></DD 148 ><DT 149 ><CODE 150 CLASS="PARAMETER" 151 >count</CODE 152 ></DT 153 ><DD 154 ><P 155 ></P 156 ></DD 157 ></DL 158 ></DIV 159 ></DIV 160 ><DIV 161 CLASS="REFSECT1" 162 ><A 163 NAME="AEN14535" 164 ></A 165 ><H2 166 >Description</H2 167 ><P 168 ><CODE 169 CLASS="FUNCTION" 170 >write()</CODE 171 > writes up to 172 <CODE 173 CLASS="PARAMETER" 174 >count</CODE 175 > bytes to the device referenced by the 176 file descriptor <CODE 177 CLASS="PARAMETER" 178 >fd</CODE 179 > from the buffer starting at 180 <CODE 181 CLASS="PARAMETER" 182 >buf</CODE 183 >. When the hardware outputs are not active 184 yet, this function enables them. When <CODE 185 CLASS="PARAMETER" 186 >count</CODE 187 > is 188 zero, <CODE 189 CLASS="FUNCTION" 190 >write()</CODE 191 > returns 192 <SPAN 193 CLASS="RETURNVALUE" 194 >0</SPAN 195 > without any other effect.</P 196 ><P 197 >When the application does not provide more data in time, the 198 previous video frame, raw VBI image, sliced VPS or WSS data is 199 displayed again. Sliced Teletext or Closed Caption data is not 200 repeated, the driver inserts a blank line instead.</P 201 ></DIV 202 ><DIV 203 CLASS="REFSECT1" 204 ><A 205 NAME="AEN14546" 206 ></A 207 ><H2 208 >Return Value</H2 209 ><P 210 >On success, the number of bytes written are returned. Zero 211 indicates nothing was written. On error, <SPAN 212 CLASS="RETURNVALUE" 213 >-1</SPAN 214 > 215 is returned, and the <CODE 216 CLASS="VARNAME" 217 >errno</CODE 218 > variable is set 219 appropriately. In this case the next write will start at the beginning 220 of a new frame. Possible error codes are:</P 221 ><P 222 ></P 223 ><DIV 224 CLASS="VARIABLELIST" 225 ><DL 226 ><DT 227 ><SPAN 228 CLASS="ERRORCODE" 229 >EAGAIN</SPAN 230 ></DT 231 ><DD 232 ><P 233 >Non-blocking I/O has been selected using the <A 234 HREF="r14090.htm" 235 ><CODE 236 CLASS="CONSTANT" 237 >O_NONBLOCK</CODE 238 ></A 239 > flag and no 240 buffer space was available to write the data immediately.</P 241 ></DD 242 ><DT 243 ><SPAN 244 CLASS="ERRORCODE" 245 >EBADF</SPAN 246 ></DT 247 ><DD 248 ><P 249 ><CODE 250 CLASS="PARAMETER" 251 >fd</CODE 252 > is not a valid file 253 descriptor or is not open for writing.</P 254 ></DD 255 ><DT 256 ><SPAN 257 CLASS="ERRORCODE" 258 >EBUSY</SPAN 259 ></DT 260 ><DD 261 ><P 262 >The driver does not support multiple write streams and the 263 device is already in use.</P 264 ></DD 265 ><DT 266 ><SPAN 267 CLASS="ERRORCODE" 268 >EFAULT</SPAN 269 ></DT 270 ><DD 271 ><P 272 ><CODE 273 CLASS="PARAMETER" 274 >buf</CODE 275 > references an inaccessible 276 memory area.</P 277 ></DD 278 ><DT 279 ><SPAN 280 CLASS="ERRORCODE" 281 >EINTR</SPAN 282 ></DT 283 ><DD 284 ><P 285 >The call was interrupted by a signal before any 286 data was written.</P 287 ></DD 288 ><DT 289 ><SPAN 290 CLASS="ERRORCODE" 291 >EIO</SPAN 292 ></DT 293 ><DD 294 ><P 295 >I/O error. This indicates some hardware problem.</P 296 ></DD 297 ><DT 298 ><SPAN 299 CLASS="ERRORCODE" 300 >EINVAL</SPAN 301 ></DT 302 ><DD 303 ><P 304 >The <CODE 305 CLASS="FUNCTION" 306 >write()</CODE 307 > function is not 308 supported by this driver, not on this device, or generally not on this 309 type of device.</P 310 ></DD 311 ></DL 312 ></DIV 313 ></DIV 314 ><DIV 315 CLASS="NAVFOOTER" 316 ><HR 317 ALIGN="LEFT" 318 WIDTH="100%"><TABLE 319 SUMMARY="Footer navigation table" 320 WIDTH="100%" 321 BORDER="0" 322 CELLPADDING="0" 323 CELLSPACING="0" 324 ><TR 325 ><TD 326 WIDTH="33%" 327 ALIGN="left" 328 VALIGN="top" 329 ><A 330 HREF="r14390.htm" 331 ACCESSKEY="P" 332 >Prev</A 333 ></TD 334 ><TD 335 WIDTH="34%" 336 ALIGN="center" 337 VALIGN="top" 338 ><A 339 HREF="book1.htm" 340 ACCESSKEY="H" 341 >Home</A 342 ></TD 343 ><TD 344 WIDTH="33%" 345 ALIGN="right" 346 VALIGN="top" 347 ><A 348 HREF="c14592.htm" 349 ACCESSKEY="N" 350 >Next</A 351 ></TD 352 ></TR 353 ><TR 354 ><TD 355 WIDTH="33%" 356 ALIGN="left" 357 VALIGN="top" 358 >V4L2 select()</TD 359 ><TD 360 WIDTH="34%" 361 ALIGN="center" 362 VALIGN="top" 363 ><A 364 HREF="r7624.htm" 365 ACCESSKEY="U" 366 >Up</A 367 ></TD 368 ><TD 369 WIDTH="33%" 370 ALIGN="right" 371 VALIGN="top" 372 >V4L2 Driver Programming</TD 373 ></TR 374 ></TABLE 375 ></DIV 376 ></BODY 377 ></HTML 378 > 379