1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
4 .. _media_ioc_g_topology:
6 **************************
7 ioctl MEDIA_IOC_G_TOPOLOGY
8 **************************
13 MEDIA_IOC_G_TOPOLOGY - Enumerate the graph topology and graph element properties
18 .. c:macro:: MEDIA_IOC_G_TOPOLOGY
20 ``int ioctl(int fd, MEDIA_IOC_G_TOPOLOGY, struct media_v2_topology *argp)``
26 File descriptor returned by :c:func:`open()`.
29 Pointer to struct :c:type:`media_v2_topology`.
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
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.
46 If the ``topology_version`` remains the same, the ioctl should fill the
47 desired arrays with the media graph elements.
49 .. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.5cm}|
51 .. c:type:: media_v2_topology
53 .. flat-table:: struct media_v2_topology
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.
66 - Number of entities in the graph
70 - Applications and drivers shall set this to 0.
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
81 - Number of interfaces in the graph
85 - Applications and drivers shall set this to 0.
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
96 - Total number of pads in the graph
100 - Applications and drivers shall set this to 0.
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``
110 - Total number of data and interface links in the graph
114 - Applications and drivers shall set this to 0.
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``
122 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
124 .. c:type:: media_v2_entity
126 .. flat-table:: struct media_v2_entity
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.
139 - Entity name as an UTF-8 NULL-terminated string. This name must be unique
140 within the media topology.
144 - Entity main function, see :ref:`media-entity-functions` for details.
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`.
156 - Reserved for future extensions. Drivers and applications must set
159 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
161 .. c:type:: media_v2_interface
163 .. flat-table:: struct media_v2_interface
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.
176 - Interface type, see :ref:`media-intf-type` for details.
180 - Interface flags. Currently unused.
184 - Reserved for future extensions. Drivers and applications must set
187 * - struct media_v2_intf_devnode
189 - Used only for device node interfaces. See
190 :c:type:`media_v2_intf_devnode` for details.
192 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
194 .. c:type:: media_v2_intf_devnode
196 .. flat-table:: struct media_v2_intf_devnode
203 - Device node major number.
207 - Device node minor number.
209 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
211 .. c:type:: media_v2_pad
213 .. flat-table:: struct media_v2_pad
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.
226 - Unique ID for the entity where this pad belongs.
230 - Pad flags, see :ref:`media-pad-flag` for more details.
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`.
241 - Reserved for future extensions. Drivers and applications must set
244 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
246 .. c:type:: media_v2_link
248 .. flat-table:: struct media_v2_link
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.
261 - On pad to pad links: unique ID for the source pad.
263 On interface to entity links: unique ID for the interface.
267 - On pad to pad links: unique ID for the sink pad.
269 On interface to entity links: unique ID for the entity.
273 - Link flags, see :ref:`media-link-flag` for more details.
277 - Reserved for future extensions. Drivers and applications must set
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.
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