← Documents Documentation/userspace-api/media/mediactl/media-func-ioctl.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / Media Controller

media ioctl()

Media ioctl의 request encoding, argument와 실패 contract를 정의합니다.

Source pathDocumentation/userspace-api/media/mediactl/media-func-ioctl.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

media-func-ioctl.rst:1-63

`request`에는 parameter 방향과 byte 크기가 encoding됩니다. Output 또는 read/write ioctl이 실패하면 caller의 parameter는 수정되지 않습니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: MC
3
4 .. _media-func-ioctl:
5
6 *************
7 media ioctl()
8 *************
9
10 Name
11 ====
12
13 media-ioctl - Control a media device
14
15 Synopsis
16 ========
17
18 .. code-block:: c
19
20 #include <sys/ioctl.h>
21
22 ``int ioctl(int fd, int request, void *argp)``
23
24 Arguments
25 =========
26
27 ``fd``
28 File descriptor returned by :c:func:`open()`.
29
30 ``request``
31 Media ioctl request code as defined in the media.h header file, for
32 example MEDIA_IOC_SETUP_LINK.
33
34 ``argp``
35 Pointer to a request-specific structure.
36
37 Description
38 ===========
39
40 The :ref:`ioctl() <media-func-ioctl>` function manipulates media device
41 parameters. The argument ``fd`` must be an open file descriptor.
42
43 The ioctl ``request`` code specifies the media function to be called. It
44 has encoded in it whether the argument is an input, output or read/write
45 parameter, and the size of the argument ``argp`` in bytes.
46
47 Macros and structures definitions specifying media ioctl requests and
48 their parameters are located in the media.h header file. All media ioctl
49 requests, their respective function and parameters are specified in
50 :ref:`media-user-func`.
51
52 Return Value
53 ============
54
55 On success 0 is returned, on error -1 and the ``errno`` variable is set
56 appropriately. The generic error codes are described at the
57 :ref:`Generic Error Codes <gen-errors>` chapter.
58
59 Request-specific error codes are listed in the individual requests
60 descriptions.
61
62 When an ioctl that takes an output or read/write parameter fails, the
63 parameter remains unmodified.
64

3. 한국어 전문 번역

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

이름과 선언

1-23

`media-ioctl`은 media device를 제어합니다. `<sys/ioctl.h>`를 include하고 `int ioctl(int fd, int request, void *argp)` 형식으로 호출합니다.

#include <sys/ioctl.h>

int ioctl(int fd, int request, void *argp);
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC

.. _media-func-ioctl:

*************
media ioctl()
*************

Name
====

media-ioctl - Control a media device

Synopsis
========

.. code-block:: c

    #include <sys/ioctl.h>

``int ioctl(int fd, int request, void *argp)``

Arguments

24-36
ioctl() arguments
Argument의미
fd`open()`이 반환한 file descriptor
request`media.h`에 정의된 media ioctl request code, 예: `MEDIA_IOC_SETUP_LINK`
argpRequest별 structure를 가리키는 pointer

Media Controller ioctl 호출의 세 argument입니다.

Arguments
=========

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

``request``
    Media ioctl request code as defined in the media.h header file, for
    example MEDIA_IOC_SETUP_LINK.

``argp``
    Pointer to a request-specific structure.

Request encoding과 media.h

37-51

`media-func-ioctl`의 `ioctl()` 함수는 media device parameter를 조작합니다. `fd`는 열려 있는 file descriptor여야 합니다.

`request` code는 호출할 media function을 지정합니다. Argument가 input, output 또는 read/write parameter인지와 `argp` argument의 byte 단위 크기가 code에 encoding되어 있습니다.

Media ioctl request와 parameter를 지정하는 macro와 structure 정의는 `media.h` header file에 있습니다. 모든 media ioctl request와 각각의 function·parameter는 `media-user-func` 참조에서 정의합니다.

Media ioctl 처리
open()으로 fd 획득media.h에서 request code 선택Request별 structure를 argp로 준비ioctl(fd, request, argp) 호출반환값과 errno 확인

Request code와 request별 structure가 operation을 결정합니다.

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

The :ref:`ioctl() <media-func-ioctl>` function manipulates media device
parameters. The argument ``fd`` must be an open file descriptor.

The ioctl ``request`` code specifies the media function to be called. It
has encoded in it whether the argument is an input, output or read/write
parameter, and the size of the argument ``argp`` in bytes.

Macros and structures definitions specifying media ioctl requests and
their parameters are located in the media.h header file. All media ioctl
requests, their respective function and parameters are specified in
:ref:`media-user-func`.

반환값과 실패 시 parameter

52-63

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

Request별 오류 code는 각 request의 설명에 나옵니다.

Output 또는 read/write parameter를 받는 ioctl이 실패하면 그 parameter는 수정되지 않은 상태로 남습니다.

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.

Request-specific error codes are listed in the individual requests
descriptions.

When an ioctl that takes an output or read/write parameter fails, the
parameter remains unmodified.