요약·해설과 원문, 전문 번역을 서로 분리했습니다. 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
.. _VIDIOC_REMOVE_BUFS:
************************
ioctl VIDIOC_REMOVE_BUFS
************************
Name
====
VIDIOC_REMOVE_BUFS - Removes buffers from a queue
Synopsis
========
.. c:macro:: VIDIOC_REMOVE_BUFS
``int ioctl(int fd, VIDIOC_REMOVE_BUFS, struct v4l2_remove_buffers *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`v4l2_remove_buffers`.
Description
===========
Applications can optionally call the :ref:`VIDIOC_REMOVE_BUFS` ioctl to
remove buffers from a queue.
:ref:`VIDIOC_CREATE_BUFS` ioctl support is mandatory to enable :ref:`VIDIOC_REMOVE_BUFS`.
This ioctl is available if the ``V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS`` capability
is set on the queue when :c:func:`VIDIOC_REQBUFS` or :c:func:`VIDIOC_CREATE_BUFS`
are invoked.
.. c:type:: v4l2_remove_buffers
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct v4l2_remove_buffers
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``index``
- The starting buffer index to remove. This field is ignored if count == 0.
* - __u32
- ``count``
- The number of buffers to be removed with indices 'index' until 'index + count - 1'.
All buffers in this range must be valid and in DEQUEUED state.
:ref:`VIDIOC_REMOVE_BUFS` will always check the validity of ``type`, if it is
invalid it returns ``EINVAL`` error code.
If count is set to 0 :ref:`VIDIOC_REMOVE_BUFS` will do nothing and return 0.
* - __u32
- ``type``
- Type of the stream or buffers, this is the same as the struct
:c:type:`v4l2_format` ``type`` field. See
:c:type:`v4l2_buf_type` for valid values.
* - __u32
- ``reserved``\ [13]
- A place holder for future extensions. Drivers and applications
must set the array to zero.
Return Value
============
On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter. If an error occurs, no
buffers will be freed and one of the error codes below will be returned:
EBUSY
File I/O is in progress.
One or more of the buffers in the range ``index`` to ``index + count - 1`` are not
in DEQUEUED state.
EINVAL
One or more of the buffers in the range ``index`` to ``index + count - 1`` do not
exist in the queue.
The buffer type (``type`` field) is not valid.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
목적, 호출 형식과 인자
1-30`VIDIOC_REMOVE_BUFS`는 queue에서 연속된 일부 buffer를 선택적으로 제거합니다. `struct v4l2_remove_buffers`가 제거 범위와 buffer type을 지정합니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L
.. _VIDIOC_REMOVE_BUFS:
************************
ioctl VIDIOC_REMOVE_BUFS
************************
Name
====
VIDIOC_REMOVE_BUFS - Removes buffers from a queue
Synopsis
========
.. c:macro:: VIDIOC_REMOVE_BUFS
``int ioctl(int fd, VIDIOC_REMOVE_BUFS, struct v4l2_remove_buffers *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`v4l2_remove_buffers`.
지원 조건
31-40이 기능을 활성화하려면 드라이버가 `VIDIOC_CREATE_BUFS`를 지원해야 합니다. `VIDIOC_REQBUFS` 또는 `VIDIOC_CREATE_BUFS` 결과에서 queue capability `V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS`가 설정돼 있어야 호출할 수 있습니다.
Description
===========
Applications can optionally call the :ref:`VIDIOC_REMOVE_BUFS` ioctl to
remove buffers from a queue.
:ref:`VIDIOC_CREATE_BUFS` ioctl support is mandatory to enable :ref:`VIDIOC_REMOVE_BUFS`.
This ioctl is available if the ``V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS`` capability
is set on the queue when :c:func:`VIDIOC_REQBUFS` or :c:func:`VIDIOC_CREATE_BUFS`
are invoked.
struct v4l2_remove_buffers
41-69`index`부터 `index + count - 1`까지의 연속 구간을 지정합니다.
`count = 0`이면 buffer를 제거하지 않고 0을 반환하지만 `type`의 유효성은 항상 검사하므로 잘못된 type에는 `EINVAL`입니다.
.. c:type:: v4l2_remove_buffers
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct v4l2_remove_buffers
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``index``
- The starting buffer index to remove. This field is ignored if count == 0.
* - __u32
- ``count``
- The number of buffers to be removed with indices 'index' until 'index + count - 1'.
All buffers in this range must be valid and in DEQUEUED state.
:ref:`VIDIOC_REMOVE_BUFS` will always check the validity of ``type`, if it is
invalid it returns ``EINVAL`` error code.
If count is set to 0 :ref:`VIDIOC_REMOVE_BUFS` will do nothing and return 0.
* - __u32
- ``type``
- Type of the stream or buffers, this is the same as the struct
:c:type:`v4l2_format` ``type`` field. See
:c:type:`v4l2_buf_type` for valid values.
* - __u32
- ``reserved``\ [13]
- A place holder for future extensions. Drivers and applications
must set the array to zero.
반환값과 원자적 오류
70-86성공하면 0을 반환합니다. 오류가 하나라도 발생하면 buffer를 전혀 해제하지 않는 원자적 동작이며 -1과 `errno`를 반환합니다.
상태 또는 범위가 잘못되면 전체 요청을 거부합니다.
Return Value
============
On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter. If an error occurs, no
buffers will be freed and one of the error codes below will be returned:
EBUSY
File I/O is in progress.
One or more of the buffers in the range ``index`` to ``index + count - 1`` are not
in DEQUEUED state.
EINVAL
One or more of the buffers in the range ``index`` to ``index + count - 1`` do not
exist in the queue.
The buffer type (``type`` field) is not valid.
요약·해설
vidioc-remove-bufs.rst:1-86부분 제거는 전체 범위가 유효하고 dequeue된 경우에만 성공하며 실패 시 아무 buffer도 해제하지 않습니다.