요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC
.. _media_ioc_enum_links:
**************************
ioctl MEDIA_IOC_ENUM_LINKS
**************************
Name
====
MEDIA_IOC_ENUM_LINKS - Enumerate all pads and links for a given entity
Synopsis
========
.. c:macro:: MEDIA_IOC_ENUM_LINKS
``int ioctl(int fd, MEDIA_IOC_ENUM_LINKS, struct media_links_enum *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`media_links_enum`.
Description
===========
To enumerate pads and/or links for a given entity, applications set the
entity field of a struct :c:type:`media_links_enum`
structure and initialize the struct
:c:type:`media_pad_desc` and struct
:c:type:`media_link_desc` structure arrays pointed by
the ``pads`` and ``links`` fields. They then call the
MEDIA_IOC_ENUM_LINKS ioctl with a pointer to this structure.
If the ``pads`` field is not NULL, the driver fills the ``pads`` array
with information about the entity's pads. The array must have enough
room to store all the entity's pads. The number of pads can be retrieved
with :ref:`MEDIA_IOC_ENUM_ENTITIES`.
If the ``links`` field is not NULL, the driver fills the ``links`` array
with information about the entity's outbound links. The array must have
enough room to store all the entity's outbound links. The number of
outbound links can be retrieved with :ref:`MEDIA_IOC_ENUM_ENTITIES`.
Only forward links that originate at one of the entity's source pads are
returned during the enumeration process.
.. c:type:: media_links_enum
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct media_links_enum
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``entity``
- Entity id, set by the application.
* - struct :c:type:`media_pad_desc`
- \*\ ``pads``
- Pointer to a pads array allocated by the application. Ignored if
NULL.
* - struct :c:type:`media_link_desc`
- \*\ ``links``
- Pointer to a links array allocated by the application. Ignored if
NULL.
* - __u32
- ``reserved[4]``
- Reserved for future extensions. Drivers and applications must set
the array to zero.
.. c:type:: media_pad_desc
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct media_pad_desc
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``entity``
- ID of the entity this pad belongs to.
* - __u16
- ``index``
- Pad index, starts at 0.
* - __u32
- ``flags``
- Pad flags, see :ref:`media-pad-flag` for more details.
* - __u32
- ``reserved[2]``
- Reserved for future extensions. Drivers and applications must set
the array to zero.
.. c:type:: media_link_desc
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct media_link_desc
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - struct :c:type:`media_pad_desc`
- ``source``
- Pad at the origin of this link.
* - struct :c:type:`media_pad_desc`
- ``sink``
- Pad at the target of this link.
* - __u32
- ``flags``
- Link flags, see :ref:`media-link-flag` for more details.
* - __u32
- ``reserved[2]``
- Reserved 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.
EINVAL
The struct :c:type:`media_links_enum` ``id``
references a non-existing entity.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
이름, 호출 형식과 arguments
1-30`MEDIA_IOC_ENUM_LINKS`는 지정한 entity의 모든 pad와 link를 열거합니다.
int ioctl(int fd, MEDIA_IOC_ENUM_LINKS, struct media_links_enum *argp);
Entity ID와 caller가 할당한 결과 배열을 전달합니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC
.. _media_ioc_enum_links:
**************************
ioctl MEDIA_IOC_ENUM_LINKS
**************************
Name
====
MEDIA_IOC_ENUM_LINKS - Enumerate all pads and links for a given entity
Synopsis
========
.. c:macro:: MEDIA_IOC_ENUM_LINKS
``int ioctl(int fd, MEDIA_IOC_ENUM_LINKS, struct media_links_enum *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`media_links_enum`.
Pad와 outbound link 열거
31-54Application은 `struct media_links_enum`의 `entity` field를 설정하고, `pads`와 `links`가 가리키는 `struct media_pad_desc` 및 `struct media_link_desc` 배열을 초기화한 뒤 ioctl을 호출합니다.
`pads`가 NULL이 아니면 driver가 entity의 모든 pad 정보를 배열에 채웁니다. 배열에는 모든 pad를 담을 공간이 있어야 하며 pad 수는 `MEDIA_IOC_ENUM_ENTITIES`로 조회합니다.
`links`가 NULL이 아니면 driver가 entity의 모든 outbound link 정보를 배열에 채웁니다. 배열에는 모든 outbound link를 담을 공간이 있어야 하며 그 수 역시 `MEDIA_IOC_ENUM_ENTITIES`로 조회합니다.
열거 과정에서는 entity의 source pad 중 하나에서 시작하는 forward link만 반환합니다.
Caller가 정확한 크기의 배열을 먼저 할당해야 합니다.
Description
===========
To enumerate pads and/or links for a given entity, applications set the
entity field of a struct :c:type:`media_links_enum`
structure and initialize the struct
:c:type:`media_pad_desc` and struct
:c:type:`media_link_desc` structure arrays pointed by
the ``pads`` and ``links`` fields. They then call the
MEDIA_IOC_ENUM_LINKS ioctl with a pointer to this structure.
If the ``pads`` field is not NULL, the driver fills the ``pads`` array
with information about the entity's pads. The array must have enough
room to store all the entity's pads. The number of pads can be retrieved
with :ref:`MEDIA_IOC_ENUM_ENTITIES`.
If the ``links`` field is not NULL, the driver fills the ``links`` array
with information about the entity's outbound links. The array must have
enough room to store all the entity's outbound links. The number of
outbound links can be retrieved with :ref:`MEDIA_IOC_ENUM_ENTITIES`.
Only forward links that originate at one of the entity's source pads are
returned during the enumeration process.
struct media_links_enum
55-82조회 대상 entity와 결과 배열 pointer를 전달합니다.
.. c:type:: media_links_enum
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct media_links_enum
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``entity``
- Entity id, set by the application.
* - struct :c:type:`media_pad_desc`
- \*\ ``pads``
- Pointer to a pads array allocated by the application. Ignored if
NULL.
* - struct :c:type:`media_link_desc`
- \*\ ``links``
- Pointer to a links array allocated by the application. Ignored if
NULL.
* - __u32
- ``reserved[4]``
- Reserved for future extensions. Drivers and applications must set
the array to zero.
struct media_pad_desc
83-109Pad 소속, index와 flag를 정의합니다.
.. c:type:: media_pad_desc
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct media_pad_desc
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``entity``
- ID of the entity this pad belongs to.
* - __u16
- ``index``
- Pad index, starts at 0.
* - __u32
- ``flags``
- Pad flags, see :ref:`media-pad-flag` for more details.
* - __u32
- ``reserved[2]``
- Reserved for future extensions. Drivers and applications must set
the array to zero.
struct media_link_desc
110-135Link의 source·sink pad와 flag를 정의합니다.
.. c:type:: media_link_desc
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct media_link_desc
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - struct :c:type:`media_pad_desc`
- ``source``
- Pad at the origin of this link.
* - struct :c:type:`media_pad_desc`
- ``sink``
- Pad at the target of this link.
* - __u32
- ``flags``
- Link flags, see :ref:`media-link-flag` for more details.
* - __u32
- ``reserved[2]``
- Reserved for future extensions. Drivers and applications must set
the array to zero.
반환값과 EINVAL
136-145성공하면 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 알맞게 설정합니다. 공통 오류는 `Generic Error Codes <gen-errors>` 장을 봅니다.
`EINVAL`은 원문 표현상 `struct media_links_enum`의 `id`가 존재하지 않는 entity를 참조할 때 발생합니다. 이 structure에서 조회 대상 ID를 전달하는 실제 field 이름은 위 표의 `entity`입니다.
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.
EINVAL
The struct :c:type:`media_links_enum` ``id``
references a non-existing entity.
요약·해설
media-ioc-enum-links.rst:1-145먼저 `MEDIA_IOC_ENUM_ENTITIES`에서 pad와 outbound link 수를 얻어 충분한 배열을 할당한 뒤 호출합니다. Inbound link는 이 ioctl의 반환 대상이 아닙니다.