← Documents Documentation/userspace-api/media/dvb/dmx-reqbufs.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / DVB / Demux

ioctl DMX_REQBUFS

MMAP·user pointer·DMABUF demux I/O 모드를 시작하고 버퍼 집합을 협상합니다.

Source pathDocumentation/userspace-api/media/dvb/dmx-reqbufs.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

dmx-reqbufs.rst:1-75

REQBUFS에서 count와 size는 요청값이자 결과값입니다. MMAP에서는 장치 버퍼를 할당하고, user pointer와 DMABUF에서는 애플리케이션 소유 버퍼에 맞춰 드라이버 모드를 구성합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: DTV.dmx
3
4 .. _DMX_REQBUFS:
5
6 *****************
7 ioctl DMX_REQBUFS
8 *****************
9
10 Name
11 ====
12
13 DMX_REQBUFS - Initiate Memory Mapping and/or DMA buffer I/O
14
15 .. warning:: this API is still experimental
16
17 Synopsis
18 ========
19
20 .. c:macro:: DMX_REQBUFS
21
22 ``int ioctl(int fd, DMX_REQBUFS, struct dmx_requestbuffers *argp)``
23
24 Arguments
25 =========
26
27 ``fd``
28 File descriptor returned by :c:func:`open()`.
29
30 ``argp``
31 Pointer to struct :c:type:`dmx_requestbuffers`.
32
33 Description
34 ===========
35
36 This ioctl is used to initiate a memory mapped or DMABUF based demux I/O.
37
38 Memory mapped buffers are located in device memory and must be allocated
39 with this ioctl before they can be mapped into the application's address
40 space. User buffers are allocated by applications themselves, and this
41 ioctl is merely used to switch the driver into user pointer I/O mode and
42 to setup some internal structures. Similarly, DMABUF buffers are
43 allocated by applications through a device driver, and this ioctl only
44 configures the driver into DMABUF I/O mode without performing any direct
45 allocation.
46
47 To allocate device buffers applications initialize all fields of the
48 struct :c:type:`dmx_requestbuffers` structure. They set the ``count`` field
49 to the desired number of buffers, and ``size`` to the size of each
50 buffer.
51
52 When the ioctl is called with a pointer to this structure, the driver will
53 attempt to allocate the requested number of buffers and it stores the actual
54 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
55 number is also possible when the driver requires more buffers to
56 function correctly. The actual allocated buffer size can is returned
57 at ``size``, and can be smaller than what's requested.
58
59 When this I/O method is not supported, the ioctl returns an ``EOPNOTSUPP``
60 error code.
61
62 Applications can call :ref:`DMX_REQBUFS` again to change the number of
63 buffers, however this cannot succeed when any buffers are still mapped.
64 A ``count`` value of zero frees all buffers, after aborting or finishing
65 any DMA in progress.
66
67 Return Value
68 ============
69
70 On success 0 is returned, on error -1 and the ``errno`` variable is set
71 appropriately. The generic error codes are described at the
72 :ref:`Generic Error Codes <gen-errors>` chapter.
73
74 EOPNOTSUPP
75 The the requested I/O method is not supported.
76

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 모드로 구성합니다.

DMX_REQBUFS의 모드별 역할
I/O 방식할당 및 설정
MMAP드라이버가 장치 메모리 버퍼를 할당
User pointer애플리케이션이 버퍼를 할당하고 ioctl은 모드와 내부 구조를 설정
DMABUF애플리케이션이 다른 장치 드라이버를 통해 할당하고 ioctl은 모드만 설정

버퍼 소유자와 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`를 반환합니다.

버퍼 할당 협상
dmx_requestbuffers 전체 필드 초기화원하는 count와 size 설정DMX_REQBUFS 호출드라이버가 가능한 버퍼 할당실제 count와 size 확인

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를 중단하거나 완료한 뒤 모든 버퍼를 해제합니다.

REQBUFS 재구성
기존 매핑 여부 확인필요하면 munmap으로 모든 매핑 해제count 0이면 DMA 정리 후 전체 버퍼 해제새 count로 다시 호출해 버퍼 집합 구성

활성 매핑과 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>` 장에서 설명합니다.

DMX_REQBUFS 전용 오류
오류조건
EOPNOTSUPP요청한 I/O 방식을 드라이버가 지원하지 않음

요청한 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.