요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: DTV.dmx
.. _DMX_REQBUFS:
*****************
ioctl DMX_REQBUFS
*****************
Name
====
DMX_REQBUFS - Initiate Memory Mapping and/or DMA buffer I/O
.. warning:: this API is still experimental
Synopsis
========
.. c:macro:: DMX_REQBUFS
``int ioctl(int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`dmx_requestbuffers`.
Description
===========
This ioctl is used to initiate a memory mapped or DMABUF based demux I/O.
Memory mapped buffers are located in device memory and must be allocated
with this ioctl before they can be mapped into the application's address
space. User buffers are allocated by applications themselves, and this
ioctl is merely used to switch the driver into user pointer I/O mode and
to setup some internal structures. Similarly, DMABUF buffers are
allocated by applications through a device driver, and this ioctl only
configures the driver into DMABUF I/O mode without performing any direct
allocation.
To allocate device buffers applications initialize all fields of the
struct :c:type:`dmx_requestbuffers` structure. They set the ``count`` field
to the desired number of buffers, and ``size`` to the size of each
buffer.
When the ioctl is called with a pointer to this structure, the driver will
attempt to allocate the requested number of buffers and it stores the actual
number allocated in the ``count`` field. The ``count`` can be smaller than the number requested, even zero, when the driver runs out of free memory. A larger
number is also possible when the driver requires more buffers to
function correctly. The actual allocated buffer size can is returned
at ``size``, and can be smaller than what's requested.
When this I/O method is not supported, the ioctl returns an ``EOPNOTSUPP``
error code.
Applications can call :ref:`DMX_REQBUFS` again to change the number of
buffers, however this cannot succeed when any buffers are still mapped.
A ``count`` value of zero frees all buffers, after aborting or finishing
any DMA in progress.
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.
EOPNOTSUPP
The the requested I/O method is not supported.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
이름, 실험 상태와 호출 형식
1-22이 문서는 GFDL-1.1-no-invariants-or-later 라이선스와 `DTV.dmx` C namespace를 사용하며 `DMX_REQBUFS` ioctl을 설명합니다.
`DMX_REQBUFS`는 Memory Mapping 및 DMABUF 기반 I/O를 시작하는 실험적 API입니다.
호출 형식은 `int ioctl(int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp)`입니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: DTV.dmx
.. _DMX_REQBUFS:
*****************
ioctl DMX_REQBUFS
*****************
Name
====
DMX_REQBUFS - Initiate Memory Mapping and/or DMA buffer I/O
.. warning:: this API is still experimental
Synopsis
========
.. c:macro:: DMX_REQBUFS
``int ioctl(int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp)``
인자와 I/O 방식별 역할
23-45`fd`는 `open()`이 반환한 file descriptor이고, `argp`는 `struct dmx_requestbuffers`를 가리킵니다.
이 ioctl은 memory-mapped 또는 DMABUF 기반 demux I/O를 시작하는 데 사용합니다.
memory-mapped 버퍼는 장치 메모리에 있으므로 애플리케이션 주소 공간에 매핑하기 전에 이 ioctl로 할당해야 합니다.
user buffer는 애플리케이션이 직접 할당합니다. 이 경우 ioctl은 직접 메모리를 할당하지 않고 드라이버를 user pointer I/O 모드로 전환하며 내부 구조만 준비합니다.
DMABUF 버퍼도 애플리케이션이 장치 드라이버를 통해 할당합니다. 이 ioctl은 직접 할당 없이 드라이버를 DMABUF I/O 모드로 구성합니다.
버퍼 소유자와 ioctl의 동작을 구분합니다.
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`dmx_requestbuffers`.
Description
===========
This ioctl is used to initiate a memory mapped or DMABUF based demux I/O.
Memory mapped buffers are located in device memory and must be allocated
with this ioctl before they can be mapped into the application's address
space. User buffers are allocated by applications themselves, and this
ioctl is merely used to switch the driver into user pointer I/O mode and
to setup some internal structures. Similarly, DMABUF buffers are
allocated by applications through a device driver, and this ioctl only
configures the driver into DMABUF I/O mode without performing any direct
allocation.
요청 수량과 실제 할당 결과
46-60장치 버퍼를 할당하려면 `struct dmx_requestbuffers`의 모든 필드를 초기화하고, `count`에 원하는 버퍼 수를, `size`에 버퍼 하나의 크기를 설정합니다.
드라이버는 요청한 수의 버퍼 할당을 시도하고 실제 할당한 수를 `count`에 기록합니다.
메모리가 부족하면 실제 `count`가 요청보다 작거나 0일 수 있고, 드라이버가 정상 동작에 더 많은 버퍼를 요구하면 요청보다 클 수도 있습니다.
실제 버퍼 크기는 `size`로 반환되며 요청한 값보다 작을 수 있습니다. 원문 56행의 문법 오류가 있는 문장은 이 의미로 번역하되 원문은 그대로 보존합니다.
요청한 I/O 방식을 지원하지 않으면 `EOPNOTSUPP`를 반환합니다.
count와 size는 요청값이면서 결과값입니다.
To allocate device buffers applications initialize all fields of the
struct :c:type:`dmx_requestbuffers` structure. They set the ``count`` field
to the desired number of buffers, and ``size`` to the size of each
buffer.
When the ioctl is called with a pointer to this structure, the driver will
attempt to allocate the requested number of buffers and it stores the actual
number allocated in the ``count`` field. The ``count`` can be smaller than the number requested, even zero, when the driver runs out of free memory. A larger
number is also possible when the driver requires more buffers to
function correctly. The actual allocated buffer size can is returned
at ``size``, and can be smaller than what's requested.
When this I/O method is not supported, the ioctl returns an ``EOPNOTSUPP``
error code.
버퍼 수 변경과 해제
61-66애플리케이션은 `DMX_REQBUFS`를 다시 호출해 버퍼 수를 바꿀 수 있지만, 아직 매핑된 버퍼가 하나라도 있으면 성공할 수 없습니다.
`count`를 0으로 지정하면 진행 중인 DMA를 중단하거나 완료한 뒤 모든 버퍼를 해제합니다.
활성 매핑과 DMA를 정리한 뒤 버퍼 집합을 바꿉니다.
Applications can call :ref:`DMX_REQBUFS` again to change the number of
buffers, however this cannot succeed when any buffers are still mapped.
A ``count`` value of zero frees all buffers, after aborting or finishing
any DMA in progress.
반환값과 EOPNOTSUPP
67-75성공하면 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 적절히 설정하며, 공통 오류는 `Generic Error Codes <gen-errors>` 장에서 설명합니다.
요청한 I/O 방식의 지원 여부를 나타냅니다.
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.
EOPNOTSUPP
The the requested I/O method is not supported.
요약·해설
dmx-reqbufs.rst:1-75REQBUFS에서 count와 size는 요청값이자 결과값입니다. MMAP에서는 장치 버퍼를 할당하고, user pointer와 DMABUF에서는 애플리케이션 소유 버퍼에 맞춰 드라이버 모드를 구성합니다.