1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/userspace-api/media/fdl-appendix.rst.
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
10 .. _media_ioc_g_topology:
12 **************************
13 ioctl MEDIA_IOC_G_TOPOLOGY
14 **************************
19 MEDIA_IOC_G_TOPOLOGY - Enumerate the graph topology and graph element properties
25 .. c:function:: int ioctl( int fd, MEDIA_IOC_G_TOPOLOGY, struct media_v2_topology *argp )
26 :name: MEDIA_IOC_G_TOPOLOGY
33 File descriptor returned by :ref:`open() <media-func-open>`.
36 Pointer to struct :c:type:`media_v2_topology`.
42 The typical usage of this ioctl is to call it twice. On the first call,
43 the structure defined at struct
44 :c:type:`media_v2_topology` should be zeroed. At
45 return, if no errors happen, this ioctl will return the
46 ``topology_version`` and the total number of entities, interfaces, pads
49 Before the second call, the userspace should allocate arrays to store
50 the graph elements that are desired, putting the pointers to them at the
51 ptr_entities, ptr_interfaces, ptr_links and/or ptr_pads, keeping the
52 other values untouched.
54 If the ``topology_version`` remains the same, the ioctl should fill the
55 desired arrays with the media graph elements.
57 .. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.5cm}|
59 .. c:type:: media_v2_topology
61 .. flat-table:: struct media_v2_topology
67 - ``topology_version``
68 - Version of the media graph topology. When the graph is created,
69 this field starts with zero. Every time a graph element is added
70 or removed, this field is incremented.
74 - Number of entities in the graph
78 - Applications and drivers shall set this to 0.
82 - A pointer to a memory area where the entities array will be
83 stored, converted to a 64-bits integer. It can be zero. if zero,
84 the ioctl won't store the entities. It will just update
89 - Number of interfaces in the graph
93 - Applications and drivers shall set this to 0.
97 - A pointer to a memory area where the interfaces array will be
98 stored, converted to a 64-bits integer. It can be zero. if zero,
99 the ioctl won't store the interfaces. It will just update
104 - Total number of pads in the graph
108 - Applications and drivers shall set this to 0.
112 - A pointer to a memory area where the pads array will be stored,
113 converted to a 64-bits integer. It can be zero. if zero, the ioctl
114 won't store the pads. It will just update ``num_pads``
118 - Total number of data and interface links in the graph
122 - Applications and drivers shall set this to 0.
126 - A pointer to a memory area where the links array will be stored,
127 converted to a 64-bits integer. It can be zero. if zero, the ioctl
128 won't store the links. It will just update ``num_links``
131 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
133 .. c:type:: media_v2_entity
135 .. flat-table:: struct media_v2_entity
142 - Unique ID for the entity. Do not expect that the ID will
143 always be the same for each instance of the device. In other words,
144 do not hardcode entity IDs in an application.
148 - Entity name as an UTF-8 NULL-terminated string. This name must be unique
149 within the media topology.
153 - Entity main function, see :ref:`media-entity-functions` for details.
157 - Entity flags, see :ref:`media-entity-flag` for details.
158 Only valid if ``MEDIA_V2_ENTITY_HAS_FLAGS(media_version)``
159 returns true. The ``media_version`` is defined in struct
160 :c:type:`media_device_info` and can be retrieved using
161 :ref:`MEDIA_IOC_DEVICE_INFO`.
165 - Reserved for future extensions. Drivers and applications must set
169 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
171 .. c:type:: media_v2_interface
173 .. flat-table:: struct media_v2_interface
180 - Unique ID for the interface. Do not expect that the ID will
181 always be the same for each instance of the device. In other words,
182 do not hardcode interface IDs in an application.
186 - Interface type, see :ref:`media-intf-type` for details.
190 - Interface flags. Currently unused.
194 - Reserved for future extensions. Drivers and applications must set
197 * - struct media_v2_intf_devnode
199 - Used only for device node interfaces. See
200 :c:type:`media_v2_intf_devnode` for details.
203 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
205 .. c:type:: media_v2_intf_devnode
207 .. flat-table:: struct media_v2_intf_devnode
214 - Device node major number.
218 - Device node minor number.
220 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
222 .. c:type:: media_v2_pad
224 .. flat-table:: struct media_v2_pad
231 - Unique ID for the pad. Do not expect that the ID will
232 always be the same for each instance of the device. In other words,
233 do not hardcode pad IDs in an application.
237 - Unique ID for the entity where this pad belongs.
241 - Pad flags, see :ref:`media-pad-flag` for more details.
245 - Pad index, starts at 0. Only valid if ``MEDIA_V2_PAD_HAS_INDEX(media_version)``
246 returns true. The ``media_version`` is defined in struct
247 :c:type:`media_device_info` and can be retrieved using
248 :ref:`MEDIA_IOC_DEVICE_INFO`.
252 - Reserved for future extensions. Drivers and applications must set
256 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
258 .. c:type:: media_v2_link
260 .. flat-table:: struct media_v2_link
267 - Unique ID for the link. Do not expect that the ID will
268 always be the same for each instance of the device. In other words,
269 do not hardcode link IDs in an application.
273 - On pad to pad links: unique ID for the source pad.
275 On interface to entity links: unique ID for the interface.
279 - On pad to pad links: unique ID for the sink pad.
281 On interface to entity links: unique ID for the entity.
285 - Link flags, see :ref:`media-link-flag` for more details.
289 - Reserved for future extensions. Drivers and applications must set
296 On success 0 is returned, on error -1 and the ``errno`` variable is set
297 appropriately. The generic error codes are described at the
298 :ref:`Generic Error Codes <gen-errors>` chapter.
301 This is returned when either one or more of the num_entities,
302 num_interfaces, num_links or num_pads are non-zero and are
303 smaller than the actual number of elements inside the graph. This
304 may happen if the ``topology_version`` changed when compared to the
305 last time this ioctl was called. Userspace should usually free the
306 area for the pointers, zero the struct elements and call this ioctl