← Documents Documentation/userspace-api/media/mediactl/media-ioc-g-topology.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / Media Controller

MEDIA_IOC_G_TOPOLOGY

Media graph의 entity, interface, pad, link와 각 속성을 version 일관성을 확인하며 한 번에 열거합니다.

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

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

1. 요약·해설

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

요약·해설

media-ioc-g-topology.rst:1-294

이 ioctl은 먼저 element 개수와 `topology_version`을 읽고, 그 개수에 맞춘 배열 pointer를 넣어 다시 호출하는 snapshot API입니다. ID는 device instance 사이에서 안정적이지 않으며, entity flag와 pad index는 `media_version` gate를 확인해야 합니다. 두 호출 사이 graph가 바뀌어 배열이 작아졌다면 `ENOSPC`를 받고 할당과 조회를 처음부터 반복합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: MC
3
4 .. _media_ioc_g_topology:
5
6 **************************
7 ioctl MEDIA_IOC_G_TOPOLOGY
8 **************************
9
10 Name
11 ====
12
13 MEDIA_IOC_G_TOPOLOGY - Enumerate the graph topology and graph element properties
14
15 Synopsis
16 ========
17
18 .. c:macro:: MEDIA_IOC_G_TOPOLOGY
19
20 ``int ioctl(int fd, MEDIA_IOC_G_TOPOLOGY, struct media_v2_topology *argp)``
21
22 Arguments
23 =========
24
25 ``fd``
26 File descriptor returned by :c:func:`open()`.
27
28 ``argp``
29 Pointer to struct :c:type:`media_v2_topology`.
30
31 Description
32 ===========
33
34 The typical usage of this ioctl is to call it twice. On the first call,
35 the structure defined at struct
36 :c:type:`media_v2_topology` should be zeroed. At
37 return, if no errors happen, this ioctl will return the
38 ``topology_version`` and the total number of entities, interfaces, pads
39 and links.
40
41 Before the second call, the userspace should allocate arrays to store
42 the graph elements that are desired, putting the pointers to them at the
43 ptr_entities, ptr_interfaces, ptr_links and/or ptr_pads, keeping the
44 other values untouched.
45
46 If the ``topology_version`` remains the same, the ioctl should fill the
47 desired arrays with the media graph elements.
48
49 .. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.3cm}|
50
51 .. c:type:: media_v2_topology
52
53 .. flat-table:: struct media_v2_topology
54 :header-rows: 0
55 :stub-columns: 0
56 :widths: 1 2 8
57
58 * - __u64
59 - ``topology_version``
60 - Version of the media graph topology. When the graph is created,
61 this field starts with zero. Every time a graph element is added
62 or removed, this field is incremented.
63
64 * - __u32
65 - ``num_entities``
66 - Number of entities in the graph
67
68 * - __u32
69 - ``reserved1``
70 - Applications and drivers shall set this to 0.
71
72 * - __u64
73 - ``ptr_entities``
74 - A pointer to a memory area where the entities array will be
75 stored, converted to a 64-bits integer. It can be zero. if zero,
76 the ioctl won't store the entities. It will just update
77 ``num_entities``
78
79 * - __u32
80 - ``num_interfaces``
81 - Number of interfaces in the graph
82
83 * - __u32
84 - ``reserved2``
85 - Applications and drivers shall set this to 0.
86
87 * - __u64
88 - ``ptr_interfaces``
89 - A pointer to a memory area where the interfaces array will be
90 stored, converted to a 64-bits integer. It can be zero. if zero,
91 the ioctl won't store the interfaces. It will just update
92 ``num_interfaces``
93
94 * - __u32
95 - ``num_pads``
96 - Total number of pads in the graph
97
98 * - __u32
99 - ``reserved3``
100 - Applications and drivers shall set this to 0.
101
102 * - __u64
103 - ``ptr_pads``
104 - A pointer to a memory area where the pads array will be stored,
105 converted to a 64-bits integer. It can be zero. if zero, the ioctl
106 won't store the pads. It will just update ``num_pads``
107
108 * - __u32
109 - ``num_links``
110 - Total number of data and interface links in the graph
111
112 * - __u32
113 - ``reserved4``
114 - Applications and drivers shall set this to 0.
115
116 * - __u64
117 - ``ptr_links``
118 - A pointer to a memory area where the links array will be stored,
119 converted to a 64-bits integer. It can be zero. if zero, the ioctl
120 won't store the links. It will just update ``num_links``
121
122 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|
123
124 .. c:type:: media_v2_entity
125
126 .. flat-table:: struct media_v2_entity
127 :header-rows: 0
128 :stub-columns: 0
129 :widths: 1 2 8
130
131 * - __u32
132 - ``id``
133 - Unique ID for the entity. Do not expect that the ID will
134 always be the same for each instance of the device. In other words,
135 do not hardcode entity IDs in an application.
136
137 * - char
138 - ``name``\ [64]
139 - Entity name as an UTF-8 NULL-terminated string. This name must be unique
140 within the media topology.
141
142 * - __u32
143 - ``function``
144 - Entity main function, see :ref:`media-entity-functions` for details.
145
146 * - __u32
147 - ``flags``
148 - Entity flags, see :ref:`media-entity-flag` for details.
149 Only valid if ``MEDIA_V2_ENTITY_HAS_FLAGS(media_version)``
150 returns true. The ``media_version`` is defined in struct
151 :c:type:`media_device_info` and can be retrieved using
152 :ref:`MEDIA_IOC_DEVICE_INFO`.
153
154 * - __u32
155 - ``reserved``\ [5]
156 - Reserved for future extensions. Drivers and applications must set
157 this array to zero.
158
159 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|
160
161 .. c:type:: media_v2_interface
162
163 .. flat-table:: struct media_v2_interface
164 :header-rows: 0
165 :stub-columns: 0
166 :widths: 1 2 8
167
168 * - __u32
169 - ``id``
170 - Unique ID for the interface. Do not expect that the ID will
171 always be the same for each instance of the device. In other words,
172 do not hardcode interface IDs in an application.
173
174 * - __u32
175 - ``intf_type``
176 - Interface type, see :ref:`media-intf-type` for details.
177
178 * - __u32
179 - ``flags``
180 - Interface flags. Currently unused.
181
182 * - __u32
183 - ``reserved``\ [9]
184 - Reserved for future extensions. Drivers and applications must set
185 this array to zero.
186
187 * - struct media_v2_intf_devnode
188 - ``devnode``
189 - Used only for device node interfaces. See
190 :c:type:`media_v2_intf_devnode` for details.
191
192 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|
193
194 .. c:type:: media_v2_intf_devnode
195
196 .. flat-table:: struct media_v2_intf_devnode
197 :header-rows: 0
198 :stub-columns: 0
199 :widths: 1 2 8
200
201 * - __u32
202 - ``major``
203 - Device node major number.
204
205 * - __u32
206 - ``minor``
207 - Device node minor number.
208
209 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|
210
211 .. c:type:: media_v2_pad
212
213 .. flat-table:: struct media_v2_pad
214 :header-rows: 0
215 :stub-columns: 0
216 :widths: 1 2 8
217
218 * - __u32
219 - ``id``
220 - Unique ID for the pad. Do not expect that the ID will
221 always be the same for each instance of the device. In other words,
222 do not hardcode pad IDs in an application.
223
224 * - __u32
225 - ``entity_id``
226 - Unique ID for the entity where this pad belongs.
227
228 * - __u32
229 - ``flags``
230 - Pad flags, see :ref:`media-pad-flag` for more details.
231
232 * - __u32
233 - ``index``
234 - Pad index, starts at 0. Only valid if ``MEDIA_V2_PAD_HAS_INDEX(media_version)``
235 returns true. The ``media_version`` is defined in struct
236 :c:type:`media_device_info` and can be retrieved using
237 :ref:`MEDIA_IOC_DEVICE_INFO`.
238
239 * - __u32
240 - ``reserved``\ [4]
241 - Reserved for future extensions. Drivers and applications must set
242 this array to zero.
243
244 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|
245
246 .. c:type:: media_v2_link
247
248 .. flat-table:: struct media_v2_link
249 :header-rows: 0
250 :stub-columns: 0
251 :widths: 1 2 8
252
253 * - __u32
254 - ``id``
255 - Unique ID for the link. Do not expect that the ID will
256 always be the same for each instance of the device. In other words,
257 do not hardcode link IDs in an application.
258
259 * - __u32
260 - ``source_id``
261 - On pad to pad links: unique ID for the source pad.
262
263 On interface to entity links: unique ID for the interface.
264
265 * - __u32
266 - ``sink_id``
267 - On pad to pad links: unique ID for the sink pad.
268
269 On interface to entity links: unique ID for the entity.
270
271 * - __u32
272 - ``flags``
273 - Link flags, see :ref:`media-link-flag` for more details.
274
275 * - __u32
276 - ``reserved``\ [6]
277 - Reserved for future extensions. Drivers and applications must set
278 this array to zero.
279
280 Return Value
281 ============
282
283 On success 0 is returned, on error -1 and the ``errno`` variable is set
284 appropriately. The generic error codes are described at the
285 :ref:`Generic Error Codes <gen-errors>` chapter.
286
287 ENOSPC
288 This is returned when either one or more of the num_entities,
289 num_interfaces, num_links or num_pads are non-zero and are
290 smaller than the actual number of elements inside the graph. This
291 may happen if the ``topology_version`` changed when compared to the
292 last time this ioctl was called. Userspace should usually free the
293 area for the pointers, zero the struct elements and call this ioctl
294 again.
295

3. 한국어 전문 번역

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

이름, 호출 형식과 인자

1-30

`MEDIA_IOC_G_TOPOLOGY`는 media graph topology와 각 graph element의 속성을 열거하는 `MC` namespace ioctl입니다.

int ioctl(int fd, MEDIA_IOC_G_TOPOLOGY, struct media_v2_topology *argp);
MEDIA_IOC_G_TOPOLOGY 인자
인자설명
fd`open()`이 반환한 file descriptor
argp`struct media_v2_topology`를 가리키는 pointer

Media device의 file descriptor와 topology 교환 구조체를 전달합니다.

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

.. _media_ioc_g_topology:

**************************
ioctl MEDIA_IOC_G_TOPOLOGY
**************************

Name
====

MEDIA_IOC_G_TOPOLOGY - Enumerate the graph topology and graph element properties

Synopsis
========

.. c:macro:: MEDIA_IOC_G_TOPOLOGY

``int ioctl(int fd, MEDIA_IOC_G_TOPOLOGY, struct media_v2_topology *argp)``

Arguments
=========

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

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

두 번 호출하는 열거 절차

31-48

이 ioctl의 일반적인 사용법은 두 번 호출하는 것입니다. 첫 호출 전에 `struct media_v2_topology` 전체를 0으로 초기화합니다. 오류가 없다면 첫 호출은 `topology_version`과 entity, interface, pad, link의 전체 개수를 돌려줍니다.

두 번째 호출 전에는 필요한 graph element 배열을 userspace에서 할당하고, 그 주소를 `ptr_entities`, `ptr_interfaces`, `ptr_links`, `ptr_pads` 가운데 원하는 field에 넣습니다. 첫 호출에서 받은 나머지 값은 그대로 유지해야 합니다.

두 호출 사이에 `topology_version`이 그대로라면 두 번째 호출이 요청한 배열을 media graph element로 채웁니다. 버전이 바뀌었다면 개수가 달라졌을 수 있으므로 `ENOSPC` 처리 절차를 따라 다시 시작해야 합니다.

`topology_version`은 첫 호출과 두 번째 호출이 같은 graph 세대를 보았는지 확인하는 일관성 token입니다. 이를 device 재시작 이후에도 유지되는 topology의 영구 식별자로 사용해서는 안 됩니다.

안정적인 topology snapshot 획득
media_v2_topology 전체를 0으로 초기화첫 번째 MEDIA_IOC_G_TOPOLOGY 호출topology_version과 네 종류의 element 개수 확인원하는 entity, interface, pad, link 배열 할당해당 ptr_* field에 배열 주소를 64-bit 정수로 저장두 번째 MEDIA_IOC_G_TOPOLOGY 호출버전이 유지되면 채워진 배열을 사용하고 ENOSPC이면 처음부터 재시도

개수 조회와 배열 채우기를 분리하고 topology version으로 두 호출 사이의 변경을 감지합니다.

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

The typical usage of this ioctl is to call it twice. On the first call,
the structure defined at struct
:c:type:`media_v2_topology` should be zeroed. At
return, if no errors happen, this ioctl will return the
``topology_version`` and the total number of entities, interfaces, pads
and links.

Before the second call, the userspace should allocate arrays to store
the graph elements that are desired, putting the pointers to them at the
ptr_entities, ptr_interfaces, ptr_links and/or ptr_pads, keeping the
other values untouched.

If the ``topology_version`` remains the same, the ioctl should fill the
desired arrays with the media graph elements.

struct media_v2_topology

49-121

`struct media_v2_topology`는 topology 세대 번호와 네 종류 element의 개수 및 userspace 배열 주소를 함께 전달합니다. `ptr_*`가 0인 종류는 배열을 쓰지 않고 대응하는 `num_*`만 갱신합니다.

struct media_v2_topology
필드설명
__u64 topology_versionMedia graph topology의 version. Graph 생성 시 0에서 시작하고 graph element가 추가되거나 제거될 때마다 증가
__u32 num_entitiesGraph 안의 entity 개수
__u32 reserved1미래 확장용. 반드시 0
__u64 ptr_entitiesEntity 배열을 저장할 memory area의 pointer를 64-bit 정수로 변환한 값. 0이면 entity 배열을 쓰지 않고 num_entities만 갱신
__u32 num_interfacesGraph 안의 interface 개수
__u32 reserved2미래 확장용. 반드시 0
__u64 ptr_interfacesInterface 배열 pointer의 64-bit 정수 표현. 0이면 배열을 쓰지 않고 num_interfaces만 갱신
__u32 num_padsGraph 안의 전체 pad 개수
__u32 reserved3미래 확장용. 반드시 0
__u64 ptr_padsPad 배열 pointer의 64-bit 정수 표현. 0이면 배열을 쓰지 않고 num_pads만 갱신
__u32 num_linksGraph 안의 data link와 interface link 전체 개수
__u32 reserved4미래 확장용. 반드시 0
__u64 ptr_linksLink 배열 pointer의 64-bit 정수 표현. 0이면 배열을 쓰지 않고 num_links만 갱신

모든 reserved field는 application과 driver가 0으로 설정해야 합니다.

Pointer field를 선택적으로 0으로 둘 수 있으므로 application은 필요한 element 종류만 가져올 수 있습니다. 다만 non-zero `num_*` 값은 제공한 배열의 수용량으로 해석되므로 실제 개수보다 작으면 `ENOSPC`가 발생합니다.

.. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.3cm}|

.. c:type:: media_v2_topology

.. flat-table:: struct media_v2_topology
    :header-rows:  0
    :stub-columns: 0
    :widths: 1 2 8

    *  -  __u64
       -  ``topology_version``
       -  Version of the media graph topology. When the graph is created,
	  this field starts with zero. Every time a graph element is added
	  or removed, this field is incremented.

    *  -  __u32
       -  ``num_entities``
       -  Number of entities in the graph

    *  -  __u32
       -  ``reserved1``
       -  Applications and drivers shall set this to 0.

    *  -  __u64
       -  ``ptr_entities``
       -  A pointer to a memory area where the entities array will be
	  stored, converted to a 64-bits integer. It can be zero. if zero,
	  the ioctl won't store the entities. It will just update
	  ``num_entities``

    *  -  __u32
       -  ``num_interfaces``
       -  Number of interfaces in the graph

    *  -  __u32
       -  ``reserved2``
       -  Applications and drivers shall set this to 0.

    *  -  __u64
       -  ``ptr_interfaces``
       -  A pointer to a memory area where the interfaces array will be
	  stored, converted to a 64-bits integer. It can be zero. if zero,
	  the ioctl won't store the interfaces. It will just update
	  ``num_interfaces``

    *  -  __u32
       -  ``num_pads``
       -  Total number of pads in the graph

    *  -  __u32
       -  ``reserved3``
       -  Applications and drivers shall set this to 0.

    *  -  __u64
       -  ``ptr_pads``
       -  A pointer to a memory area where the pads array will be stored,
	  converted to a 64-bits integer. It can be zero. if zero, the ioctl
	  won't store the pads. It will just update ``num_pads``

    *  -  __u32
       -  ``num_links``
       -  Total number of data and interface links in the graph

    *  -  __u32
       -  ``reserved4``
       -  Applications and drivers shall set this to 0.

    *  -  __u64
       -  ``ptr_links``
       -  A pointer to a memory area where the links array will be stored,
	  converted to a 64-bits integer. It can be zero. if zero, the ioctl
	  won't store the links. It will just update ``num_links``

struct media_v2_entity

122-158

`struct media_v2_entity`는 topology 안의 entity 하나를 설명합니다. `id`는 현재 device instance에서만 의미가 있으므로 application에 고정값으로 넣어서는 안 됩니다.

struct media_v2_entity
필드설명
__u32 idEntity의 unique ID. Device instance마다 같다고 기대할 수 없으며 hardcode 금지
char name[64]Media topology 안에서 unique한 UTF-8 NUL-terminated entity 이름
__u32 functionEntity의 주 기능. media-entity-functions 참조
__u32 flagsEntity flag. `MEDIA_V2_ENTITY_HAS_FLAGS(media_version)`이 true일 때만 유효하며 media-entity-flag 참조
__u32 reserved[5]미래 확장용. Driver와 application 모두 배열 전체를 0으로 설정

Entity 이름, 주 기능, 조건부 flag와 확장용 공간을 보존합니다.

`flags`의 유효성 판정에 쓰는 `media_version`은 `struct media_device_info`에 있으며 `MEDIA_IOC_DEVICE_INFO`로 조회합니다. Version gate를 확인하지 않고 flag를 해석하면 오래된 Media API 결과를 잘못 읽을 수 있습니다.

.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|

.. c:type:: media_v2_entity

.. flat-table:: struct media_v2_entity
    :header-rows:  0
    :stub-columns: 0
    :widths: 1 2 8

    *  -  __u32
       -  ``id``
       -  Unique ID for the entity. Do not expect that the ID will
	  always be the same for each instance of the device. In other words,
	  do not hardcode entity IDs in an application.

    *  -  char
       -  ``name``\ [64]
       -  Entity name as an UTF-8 NULL-terminated string. This name must be unique
          within the media topology.

    *  -  __u32
       -  ``function``
       -  Entity main function, see :ref:`media-entity-functions` for details.

    *  -  __u32
       -  ``flags``
       -  Entity flags, see :ref:`media-entity-flag` for details.
	  Only valid if ``MEDIA_V2_ENTITY_HAS_FLAGS(media_version)``
	  returns true. The ``media_version`` is defined in struct
	  :c:type:`media_device_info` and can be retrieved using
	  :ref:`MEDIA_IOC_DEVICE_INFO`.

    *  -  __u32
       -  ``reserved``\ [5]
       -  Reserved for future extensions. Drivers and applications must set
	  this array to zero.

struct media_v2_interface와 devnode

159-208

`struct media_v2_interface`는 userspace가 graph와 상호작용하는 interface를 설명합니다. Interface ID도 device instance 사이에서 안정적이지 않으므로 hardcode해서는 안 됩니다.

struct media_v2_interface
필드설명
__u32 idInterface의 unique ID. Device instance마다 달라질 수 있으며 hardcode 금지
__u32 intf_typeInterface type. media-intf-type 참조
__u32 flagsInterface flag. 현재는 사용하지 않음
__u32 reserved[9]미래 확장용. Driver와 application 모두 배열 전체를 0으로 설정
struct media_v2_intf_devnode devnodeDevice node interface에만 사용하는 major/minor 정보

Interface 종류와 device node 연결 정보를 제공합니다.

struct media_v2_intf_devnode
필드설명
__u32 majorDevice node major number
__u32 minorDevice node minor number

Device node를 식별하는 두 번호입니다.

`devnode`는 모든 interface에 공통으로 해석하는 payload가 아니라 device node interface일 때만 사용하는 값입니다.

.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|

.. c:type:: media_v2_interface

.. flat-table:: struct media_v2_interface
    :header-rows:  0
    :stub-columns: 0
    :widths: 1 2 8

    *  -  __u32
       -  ``id``
       -  Unique ID for the interface. Do not expect that the ID will
	  always be the same for each instance of the device. In other words,
	  do not hardcode interface IDs in an application.

    *  -  __u32
       -  ``intf_type``
       -  Interface type, see :ref:`media-intf-type` for details.

    *  -  __u32
       -  ``flags``
       -  Interface flags. Currently unused.

    *  -  __u32
       -  ``reserved``\ [9]
       -  Reserved for future extensions. Drivers and applications must set
	  this array to zero.

    *  -  struct media_v2_intf_devnode
       -  ``devnode``
       -  Used only for device node interfaces. See
	  :c:type:`media_v2_intf_devnode` for details.

.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|

.. c:type:: media_v2_intf_devnode

.. flat-table:: struct media_v2_intf_devnode
    :header-rows:  0
    :stub-columns: 0
    :widths: 1 2 8

    *  -  __u32
       -  ``major``
       -  Device node major number.

    *  -  __u32
       -  ``minor``
       -  Device node minor number.

struct media_v2_pad

209-243

`struct media_v2_pad`는 entity에 속한 연결점을 나타냅니다. Pad ID 역시 device instance마다 달라질 수 있으므로 topology에서 받은 값을 사용해야 합니다.

struct media_v2_pad
필드설명
__u32 idPad의 unique ID. Device instance마다 같다고 기대할 수 없으며 hardcode 금지
__u32 entity_id이 pad가 속한 entity의 unique ID
__u32 flagsPad flag. media-pad-flag 참조
__u32 index0부터 시작하는 pad index. `MEDIA_V2_PAD_HAS_INDEX(media_version)`이 true일 때만 유효
__u32 reserved[4]미래 확장용. Driver와 application 모두 배열 전체를 0으로 설정

Pad 소속, 방향 flag, 조건부 index를 함께 전달합니다.

`index`의 version gate에 쓰는 `media_version`도 `struct media_device_info`의 값이며 `MEDIA_IOC_DEVICE_INFO`로 가져옵니다. Gate가 false이면 `index`를 의미 있는 값으로 취급하지 않습니다.

.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.5cm}|

.. c:type:: media_v2_pad

.. flat-table:: struct media_v2_pad
    :header-rows:  0
    :stub-columns: 0
    :widths: 1 2 8

    *  -  __u32
       -  ``id``
       -  Unique ID for the pad. Do not expect that the ID will
	  always be the same for each instance of the device. In other words,
	  do not hardcode pad IDs in an application.

    *  -  __u32
       -  ``entity_id``
       -  Unique ID for the entity where this pad belongs.

    *  -  __u32
       -  ``flags``
       -  Pad flags, see :ref:`media-pad-flag` for more details.

    *  -  __u32
       -  ``index``
       -  Pad index, starts at 0. Only valid if ``MEDIA_V2_PAD_HAS_INDEX(media_version)``
	  returns true. The ``media_version`` is defined in struct
	  :c:type:`media_device_info` and can be retrieved using
	  :ref:`MEDIA_IOC_DEVICE_INFO`.

    *  -  __u32
       -  ``reserved``\ [4]
       -  Reserved for future extensions. Drivers and applications must set
	  this array to zero.

반환값과 ENOSPC 재시도

280-294

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

`num_entities`, `num_interfaces`, `num_links`, `num_pads` 중 하나 이상이 non-zero이면서 실제 graph element 개수보다 작으면 `ENOSPC`를 반환합니다. 두 호출 사이에 `topology_version`이 바뀌어 graph가 커진 경우 발생할 수 있습니다.

`ENOSPC`를 받으면 userspace는 pointer가 가리키는 기존 배열을 해제하고 structure element를 다시 0으로 만든 뒤 첫 호출부터 반복하는 것이 일반적입니다. 이전 개수나 pointer를 그대로 재사용하면 다시 부족한 buffer를 제출할 수 있습니다.

ENOSPC 복구
기존 ptr_* 배열 해제media_v2_topology field를 모두 0으로 초기화개수 조회 호출부터 다시 수행새 개수에 맞춰 배열 재할당두 번째 호출로 새 topology snapshot 수집

변경된 topology를 새 snapshot으로 다시 획득합니다.

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.

ENOSPC
    This is returned when either one or more of the num_entities,
    num_interfaces, num_links or num_pads are non-zero and are
    smaller than the actual number of elements inside the graph. This
    may happen if the ``topology_version`` changed when compared to the
    last time this ioctl was called. Userspace should usually free the
    area for the pointers, zero the struct elements and call this ioctl
    again.