18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: V4L 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _func-write: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci************ 78c2ecf20Sopenharmony_ciV4L2 write() 88c2ecf20Sopenharmony_ci************ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_civ4l2-write - Write to a V4L2 device 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciSynopsis 168c2ecf20Sopenharmony_ci======== 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci.. code-block:: c 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci #include <unistd.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci.. c:function:: ssize_t write( int fd, void *buf, size_t count ) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciArguments 258c2ecf20Sopenharmony_ci========= 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci``fd`` 288c2ecf20Sopenharmony_ci File descriptor returned by :c:func:`open()`. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci``buf`` 318c2ecf20Sopenharmony_ci Buffer with data to be written 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci``count`` 348c2ecf20Sopenharmony_ci Number of bytes at the buffer 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciDescription 378c2ecf20Sopenharmony_ci=========== 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci:c:func:`write()` writes up to ``count`` bytes to the device 408c2ecf20Sopenharmony_cireferenced by the file descriptor ``fd`` from the buffer starting at 418c2ecf20Sopenharmony_ci``buf``. When the hardware outputs are not active yet, this function 428c2ecf20Sopenharmony_cienables them. When ``count`` is zero, :c:func:`write()` returns 0 438c2ecf20Sopenharmony_ciwithout any other effect. 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ciWhen the application does not provide more data in time, the previous 468c2ecf20Sopenharmony_civideo frame, raw VBI image, sliced VPS or WSS data is displayed again. 478c2ecf20Sopenharmony_ciSliced Teletext or Closed Caption data is not repeated, the driver 488c2ecf20Sopenharmony_ciinserts a blank line instead. 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciReturn Value 518c2ecf20Sopenharmony_ci============ 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciOn success, the number of bytes written are returned. Zero indicates 548c2ecf20Sopenharmony_cinothing was written. On error, -1 is returned, and the ``errno`` 558c2ecf20Sopenharmony_civariable is set appropriately. In this case the next write will start at 568c2ecf20Sopenharmony_cithe beginning of a new frame. Possible error codes are: 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciEAGAIN 598c2ecf20Sopenharmony_ci Non-blocking I/O has been selected using the 608c2ecf20Sopenharmony_ci :ref:`O_NONBLOCK <func-open>` flag and no buffer space was 618c2ecf20Sopenharmony_ci available to write the data immediately. 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciEBADF 648c2ecf20Sopenharmony_ci ``fd`` is not a valid file descriptor or is not open for writing. 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciEBUSY 678c2ecf20Sopenharmony_ci The driver does not support multiple write streams and the device is 688c2ecf20Sopenharmony_ci already in use. 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ciEFAULT 718c2ecf20Sopenharmony_ci ``buf`` references an inaccessible memory area. 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciEINTR 748c2ecf20Sopenharmony_ci The call was interrupted by a signal before any data was written. 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciEIO 778c2ecf20Sopenharmony_ci I/O error. This indicates some hardware problem. 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciEINVAL 808c2ecf20Sopenharmony_ci The :c:func:`write()` function is not supported by this driver, 818c2ecf20Sopenharmony_ci not on this device, or generally not on this type of device. 82