요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L
.. _func-write:
************
V4L2 write()
************
Name
====
v4l2-write - Write to a V4L2 device
Synopsis
========
.. code-block:: c
#include <unistd.h>
.. c:function:: ssize_t write( int fd, void *buf, size_t count )
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``buf``
Buffer with data to be written
``count``
Number of bytes at the buffer
Description
===========
:c:func:`write()` writes up to ``count`` bytes to the device
referenced by the file descriptor ``fd`` from the buffer starting at
``buf``. When the hardware outputs are not active yet, this function
enables them. When ``count`` is zero, :c:func:`write()` returns 0
without any other effect.
When the application does not provide more data in time, the previous
video frame, raw VBI image, sliced VPS or WSS data is displayed again.
Sliced Teletext or Closed Caption data is not repeated, the driver
inserts a blank line instead.
Return Value
============
On success, the number of bytes written are returned. Zero indicates
nothing was written. On error, -1 is returned, and the ``errno``
variable is set appropriately. In this case the next write will start at
the beginning of a new frame. Possible error codes are:
EAGAIN
Non-blocking I/O has been selected using the
:ref:`O_NONBLOCK <func-open>` flag and no buffer space was
available to write the data immediately.
EBADF
``fd`` is not a valid file descriptor or is not open for writing.
EBUSY
The driver does not support multiple write streams and the device is
already in use.
EFAULT
``buf`` references an inaccessible memory area.
EINTR
The call was interrupted by a signal before any data was written.
EIO
I/O error. This indicates some hardware problem.
EINVAL
The :c:func:`write()` function is not supported by this driver,
not on this device, or generally not on this type of device.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
출력 쓰기 선언과 인자
1-35`v4l2-write`는 V4L2 output 장치에 data를 씁니다. `<unistd.h>`를 포함하고 `ssize_t write(int fd, void *buf, size_t count)`를 호출합니다.
출력 장치 descriptor, source buffer와 byte 수를 전달합니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L
.. _func-write:
************
V4L2 write()
************
Name
====
v4l2-write - Write to a V4L2 device
Synopsis
========
.. code-block:: c
#include <unistd.h>
.. c:function:: ssize_t write( int fd, void *buf, size_t count )
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``buf``
Buffer with data to be written
``count``
Number of bytes at the buffer
출력 시작과 data 부족 처리
36-49`write()`는 `buf`에서 최대 `count` byte를 `fd`가 가리키는 장치에 씁니다. Hardware output이 아직 활성화되지 않았다면 이 호출이 출력을 시작합니다. `count == 0`이면 다른 효과 없이 0을 반환합니다.
Application이 제때 다음 data를 제공하지 않으면 이전 video frame, raw VBI image, sliced VPS 또는 WSS data를 다시 표시합니다. Sliced Teletext와 Closed Caption data는 반복하지 않고 driver가 그 자리에 blank line을 삽입합니다.
Data 종류에 따라 이전 payload를 반복할지 blank line으로 대체할지가 달라집니다.
첫 data가 output을 활성화하고 이후 공급 지연은 payload 종류별 policy로 처리됩니다.
Description
===========
:c:func:`write()` writes up to ``count`` bytes to the device
referenced by the file descriptor ``fd`` from the buffer starting at
``buf``. When the hardware outputs are not active yet, this function
enables them. When ``count`` is zero, :c:func:`write()` returns 0
without any other effect.
When the application does not provide more data in time, the previous
video frame, raw VBI image, sliced VPS or WSS data is displayed again.
Sliced Teletext or Closed Caption data is not repeated, the driver
inserts a blank line instead.
반환값, frame 경계와 오류
50-81성공하면 실제로 쓴 byte 수를 반환하며 0은 아무 data도 쓰지 않았음을 뜻합니다. 실패하면 -1과 적절한 `errno`를 반환하고, 다음 `write()`는 새 frame의 시작부터 기록합니다.
Buffer 공간, descriptor, stream 점유, memory와 hardware 문제를 구분합니다.
Return Value
============
On success, the number of bytes written are returned. Zero indicates
nothing was written. On error, -1 is returned, and the ``errno``
variable is set appropriately. In this case the next write will start at
the beginning of a new frame. Possible error codes are:
EAGAIN
Non-blocking I/O has been selected using the
:ref:`O_NONBLOCK <func-open>` flag and no buffer space was
available to write the data immediately.
EBADF
``fd`` is not a valid file descriptor or is not open for writing.
EBUSY
The driver does not support multiple write streams and the device is
already in use.
EFAULT
``buf`` references an inaccessible memory area.
EINTR
The call was interrupted by a signal before any data was written.
EIO
I/O error. This indicates some hardware problem.
EINVAL
The :c:func:`write()` function is not supported by this driver,
not on this device, or generally not on this type of device.
요약·해설
func-write.rst:1-81`write()`는 첫 payload로 hardware output을 시작하며 data 공급이 늦으면 video·raw VBI·VPS·WSS는 반복하고 Teletext·Closed Caption은 blank line으로 대체합니다.