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

Linux 6.18.37 · Userspace API / Media / DVB / Demux

ioctl DMX_QBUF, DMX_DQBUF

드라이버의 incoming/outgoing queue와 버퍼를 교환합니다.

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

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

1. 요약·해설

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

요약·해설

dmx-qbuf.rst:1-85

QBUF는 빈 캡처 버퍼나 채운 출력 버퍼를 드라이버에 넘기고, DQBUF는 완료된 캡처 버퍼를 회수합니다. 큐잉된 페이지는 dequeue 또는 장치 close까지 물리 메모리에 고정됩니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: DTV.dmx
3
4 .. _DMX_QBUF:
5
6 *************************
7 ioctl DMX_QBUF, DMX_DQBUF
8 *************************
9
10 Name
11 ====
12
13 DMX_QBUF - DMX_DQBUF - Exchange a buffer with the driver
14
15 .. warning:: this API is still experimental
16
17 Synopsis
18 ========
19
20 .. c:macro:: DMX_QBUF
21
22 ``int ioctl(int fd, DMX_QBUF, struct dmx_buffer *argp)``
23
24 .. c:macro:: DMX_DQBUF
25
26 ``int ioctl(int fd, DMX_DQBUF, struct dmx_buffer *argp)``
27
28 Arguments
29 =========
30
31 ``fd``
32 File descriptor returned by :c:func:`open()`.
33
34 ``argp``
35 Pointer to struct :c:type:`dmx_buffer`.
36
37 Description
38 ===========
39
40 Applications call the ``DMX_QBUF`` ioctl to enqueue an empty
41 (capturing) or filled (output) buffer in the driver's incoming queue.
42 The semantics depend on the selected I/O method.
43
44 To enqueue a buffer applications set the ``index`` field. Valid index
45 numbers range from zero to the number of buffers allocated with
46 :ref:`DMX_REQBUFS` (struct :c:type:`dmx_requestbuffers` ``count``) minus
47 one. The contents of the struct :c:type:`dmx_buffer` returned
48 by a :ref:`DMX_QUERYBUF` ioctl will do as well.
49
50 When ``DMX_QBUF`` is called with a pointer to this structure, it locks the
51 memory pages of the buffer in physical memory, so they cannot be swapped
52 out to disk. Buffers remain locked until dequeued, until the
53 device is closed.
54
55 Applications call the ``DMX_DQBUF`` ioctl to dequeue a filled
56 (capturing) buffer from the driver's outgoing queue.
57 They just set the ``index`` field with the buffer ID to be queued.
58 When ``DMX_DQBUF`` is called with a pointer to struct :c:type:`dmx_buffer`,
59 the driver fills the remaining fields or returns an error code.
60
61 By default ``DMX_DQBUF`` blocks when no buffer is in the outgoing
62 queue. When the ``O_NONBLOCK`` flag was given to the
63 :c:func:`open()` function, ``DMX_DQBUF`` returns
64 immediately with an ``EAGAIN`` error code when no buffer is available.
65
66 The struct :c:type:`dmx_buffer` structure is specified in
67 :ref:`buffer`.
68
69 Return Value
70 ============
71
72 On success 0 is returned, on error -1 and the ``errno`` variable is set
73 appropriately. The generic error codes are described at the
74 :ref:`Generic Error Codes <gen-errors>` chapter.
75
76 EAGAIN
77 Non-blocking I/O has been selected using ``O_NONBLOCK`` and no
78 buffer was in the outgoing queue.
79
80 EINVAL
81 The ``index`` is out of bounds, or no buffers have been allocated yet.
82
83 EIO
84 ``DMX_DQBUF`` failed due to an internal error. Can also indicate
85 temporary problems like signal loss or CRC errors.
86

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

이름, 실험 상태와 호출 형식

1-26

이 문서는 GFDL-1.1-no-invariants-or-later 라이선스와 `DTV.dmx` C namespace를 사용하며 `DMX_QBUF`와 `DMX_DQBUF` ioctl을 설명합니다.

두 ioctl은 드라이버와 버퍼를 교환하며 아직 실험적 API입니다.

호출 형식은 각각 `int ioctl(int fd, DMX_QBUF, struct dmx_buffer *argp)`와 `int ioctl(int fd, DMX_DQBUF, struct dmx_buffer *argp)`입니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: DTV.dmx

.. _DMX_QBUF:

*************************
ioctl DMX_QBUF, DMX_DQBUF
*************************

Name
====

DMX_QBUF - DMX_DQBUF - Exchange a buffer with the driver

.. warning:: this API is still experimental

Synopsis
========

.. c:macro:: DMX_QBUF

``int ioctl(int fd, DMX_QBUF, struct dmx_buffer *argp)``

.. c:macro:: DMX_DQBUF

``int ioctl(int fd, DMX_DQBUF, struct dmx_buffer *argp)``

인자와 큐잉 방향

27-42

`fd`는 `open()`이 반환한 file descriptor이고, `argp`는 `struct dmx_buffer`를 가리킵니다.

애플리케이션은 `DMX_QBUF`로 캡처용 빈 버퍼 또는 출력용으로 채운 버퍼를 드라이버의 incoming queue에 넣습니다. 구체적인 의미는 선택한 I/O 방식에 따라 달라집니다.

QBUF와 DQBUF 방향
항목설명
DMX_QBUF애플리케이션에서 드라이버 incoming queue로 버퍼 전달
DMX_DQBUF드라이버 outgoing queue에서 채워진 캡처 버퍼 회수

애플리케이션 관점의 버퍼 이동 방향입니다.


Arguments
=========

``fd``
    File descriptor returned by :c:func:`open()`.

``argp``
    Pointer to struct :c:type:`dmx_buffer`.

Description
===========

Applications call the ``DMX_QBUF`` ioctl to enqueue an empty
(capturing) or filled (output) buffer in the driver's incoming queue.
The semantics depend on the selected I/O method.

인덱스, 페이지 고정과 dequeue

43-60

버퍼를 큐에 넣을 때 애플리케이션은 `index` 필드를 설정합니다. 유효 범위는 0부터 `DMX_REQBUFS`로 할당한 버퍼 수, 즉 `struct dmx_requestbuffers.count`에서 1을 뺀 값까지입니다.

`DMX_QUERYBUF`가 반환한 `struct dmx_buffer`의 내용도 그대로 큐잉 인자로 사용할 수 있습니다.

`DMX_QBUF`를 호출하면 해당 버퍼의 메모리 페이지가 물리 메모리에 고정되어 디스크로 swap out되지 않습니다. 버퍼가 dequeue되거나 장치를 닫을 때까지 고정 상태가 유지됩니다.

애플리케이션은 `DMX_DQBUF`로 드라이버 outgoing queue에서 채워진 캡처 버퍼를 꺼냅니다. 원문은 `index`에 큐잉할 버퍼 ID를 설정한다고 표현하며, 호출 시 드라이버가 나머지 필드를 채우거나 오류를 반환합니다.

Demux 버퍼 교환
DMX_REQBUFS로 버퍼 할당DMX_QUERYBUF로 index별 정보 조회DMX_QBUF로 버퍼를 incoming queue에 등록드라이버가 버퍼를 처리하고 outgoing queue로 이동DMX_DQBUF로 완료 버퍼와 채워진 필드 회수

할당한 버퍼가 드라이버를 거쳐 다시 사용자 공간으로 돌아옵니다.


To enqueue a buffer applications set the ``index`` field. Valid index
numbers range from zero to the number of buffers allocated with
:ref:`DMX_REQBUFS` (struct :c:type:`dmx_requestbuffers` ``count``) minus
one. The contents of the struct :c:type:`dmx_buffer` returned
by a :ref:`DMX_QUERYBUF` ioctl will do as well.

When ``DMX_QBUF`` is called with a pointer to this structure, it locks the
memory pages of the buffer in physical memory, so they cannot be swapped
out to disk. Buffers remain locked until dequeued, until the
device is closed.

Applications call the ``DMX_DQBUF`` ioctl to dequeue a filled
(capturing) buffer from the driver's outgoing queue.
They just set the ``index`` field with the buffer ID to be queued.
When ``DMX_DQBUF`` is called with a pointer to struct :c:type:`dmx_buffer`,
the driver fills the remaining fields or returns an error code.

차단과 비차단 dequeue

61-68

기본적으로 outgoing queue에 버퍼가 없으면 `DMX_DQBUF`는 버퍼가 생길 때까지 차단됩니다.

`open()`에 `O_NONBLOCK`을 지정한 경우에는 버퍼가 없을 때 기다리지 않고 즉시 `EAGAIN`을 반환합니다.

`struct dmx_buffer` 구조체 정의는 `buffer` 참조 절에서 확인합니다.

By default ``DMX_DQBUF`` blocks when no buffer is in the outgoing
queue. When the ``O_NONBLOCK`` flag was given to the
:c:func:`open()` function, ``DMX_DQBUF`` returns
immediately with an ``EAGAIN`` error code when no buffer is available.

The struct :c:type:`dmx_buffer` structure is specified in
:ref:`buffer`.

반환값과 오류

69-85

성공하면 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 적절히 설정하며, 공통 오류는 `Generic Error Codes <gen-errors>` 장에서 설명합니다.

DMX_QBUF·DMX_DQBUF 오류
오류조건
EAGAINO_NONBLOCK을 사용했고 outgoing queue에 버퍼가 없음
EINVALindex가 범위를 벗어났거나 아직 버퍼를 할당하지 않음
EIODMX_DQBUF 내부 오류. 신호 손실이나 CRC 오류 같은 일시적 문제일 수도 있음

큐 상태, 인덱스와 내부 오류를 구분합니다.

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.

EAGAIN
    Non-blocking I/O has been selected using ``O_NONBLOCK`` and no
    buffer was in the outgoing queue.

EINVAL
    The ``index`` is out of bounds, or no buffers have been allocated yet.

EIO
    ``DMX_DQBUF`` failed due to an internal error. Can also indicate
    temporary problems like signal loss or CRC errors.