blob: d6f41a8e307f9d78d9be0b63ce3e91a5c3d2be0f [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- coding: utf-8; mode: rst -*-
2
Mauro Carvalho Chehabd2c68152016-07-09 08:54:35 -03003.. _media_ioc_g_topology:
Markus Heiser5377d912016-06-30 15:18:56 +02004
5**************************
6ioctl MEDIA_IOC_G_TOPOLOGY
7**************************
8
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -03009Name
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030010====
Markus Heiser5377d912016-06-30 15:18:56 +020011
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030012MEDIA_IOC_G_TOPOLOGY - Enumerate the graph topology and graph element properties
Markus Heiser5377d912016-06-30 15:18:56 +020013
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030014
15Synopsis
Markus Heiser5377d912016-06-30 15:18:56 +020016========
17
Mauro Carvalho Chehab5ccbb182016-08-19 16:59:55 -030018.. c:function:: int ioctl( int fd, MEDIA_IOC_G_TOPOLOGY, struct media_v2_topology *argp )
19 :name: MEDIA_IOC_G_TOPOLOGY
Markus Heiser5377d912016-06-30 15:18:56 +020020
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030021
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030022Arguments
Markus Heiser5377d912016-06-30 15:18:56 +020023=========
24
25``fd``
26 File descriptor returned by :ref:`open() <media-func-open>`.
27
Markus Heiser5377d912016-06-30 15:18:56 +020028``argp``
29
30
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030031Description
Markus Heiser5377d912016-06-30 15:18:56 +020032===========
33
34The typical usage of this ioctl is to call it twice. On the first call,
35the structure defined at struct
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -030036:c:type:`media_v2_topology` should be zeroed. At
Markus Heiser5377d912016-06-30 15:18:56 +020037return, if no errors happen, this ioctl will return the
38``topology_version`` and the total number of entities, interfaces, pads
39and links.
40
41Before the second call, the userspace should allocate arrays to store
42the graph elements that are desired, putting the pointers to them at the
43ptr_entities, ptr_interfaces, ptr_links and/or ptr_pads, keeping the
44other values untouched.
45
46If the ``topology_version`` remains the same, the ioctl should fill the
47desired arrays with the media graph elements.
48
Mauro Carvalho Chehab1367f4e2017-09-02 19:29:53 -040049.. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.5cm}|
Markus Heiser5377d912016-06-30 15:18:56 +020050
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -030051.. c:type:: media_v2_topology
Markus Heiser5377d912016-06-30 15:18:56 +020052
53.. flat-table:: struct media_v2_topology
54 :header-rows: 0
55 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -030056 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +020057
Hans Verkuil8c4fe242018-06-15 09:19:44 -040058 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +020059 - ``topology_version``
Markus Heiser5377d912016-06-30 15:18:56 +020060 - Version of the media graph topology. When the graph is created,
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030061 this field starts with zero. Every time a graph element is added
62 or removed, this field is incremented.
Markus Heiser5377d912016-06-30 15:18:56 +020063
Hans Verkuil8c4fe242018-06-15 09:19:44 -040064 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +020065 - ``num_entities``
Markus Heiser5377d912016-06-30 15:18:56 +020066 - Number of entities in the graph
67
Hans Verkuil8c4fe242018-06-15 09:19:44 -040068 * - __u32
Hans Verkuilccac77d2018-02-03 13:06:01 -050069 - ``reserved1``
Hans Verkuilccac77d2018-02-03 13:06:01 -050070 - Applications and drivers shall set this to 0.
71
Hans Verkuil8c4fe242018-06-15 09:19:44 -040072 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +020073 - ``ptr_entities``
Markus Heiser5377d912016-06-30 15:18:56 +020074 - A pointer to a memory area where the entities array will be
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030075 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``
Markus Heiser5377d912016-06-30 15:18:56 +020078
Hans Verkuil8c4fe242018-06-15 09:19:44 -040079 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +020080 - ``num_interfaces``
Markus Heiser5377d912016-06-30 15:18:56 +020081 - Number of interfaces in the graph
82
Hans Verkuil8c4fe242018-06-15 09:19:44 -040083 * - __u32
Hans Verkuilccac77d2018-02-03 13:06:01 -050084 - ``reserved2``
Hans Verkuilccac77d2018-02-03 13:06:01 -050085 - Applications and drivers shall set this to 0.
86
Hans Verkuil8c4fe242018-06-15 09:19:44 -040087 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +020088 - ``ptr_interfaces``
Markus Heiser5377d912016-06-30 15:18:56 +020089 - A pointer to a memory area where the interfaces array will be
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030090 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``
Markus Heiser5377d912016-06-30 15:18:56 +020093
Hans Verkuil8c4fe242018-06-15 09:19:44 -040094 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +020095 - ``num_pads``
Markus Heiser5377d912016-06-30 15:18:56 +020096 - Total number of pads in the graph
97
Hans Verkuil8c4fe242018-06-15 09:19:44 -040098 * - __u32
Hans Verkuilccac77d2018-02-03 13:06:01 -050099 - ``reserved3``
Hans Verkuilccac77d2018-02-03 13:06:01 -0500100 - Applications and drivers shall set this to 0.
101
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400102 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +0200103 - ``ptr_pads``
Markus Heiser5377d912016-06-30 15:18:56 +0200104 - A pointer to a memory area where the pads array will be stored,
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300105 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``
Markus Heiser5377d912016-06-30 15:18:56 +0200107
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400108 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200109 - ``num_links``
Markus Heiser5377d912016-06-30 15:18:56 +0200110 - Total number of data and interface links in the graph
111
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400112 * - __u32
Hans Verkuilccac77d2018-02-03 13:06:01 -0500113 - ``reserved4``
Hans Verkuilccac77d2018-02-03 13:06:01 -0500114 - Applications and drivers shall set this to 0.
115
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400116 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +0200117 - ``ptr_links``
Markus Heiser5377d912016-06-30 15:18:56 +0200118 - A pointer to a memory area where the links array will be stored,
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300119 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``
Markus Heiser5377d912016-06-30 15:18:56 +0200121
122
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300123.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200124
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300125.. c:type:: media_v2_entity
Markus Heiser5377d912016-06-30 15:18:56 +0200126
127.. flat-table:: struct media_v2_entity
128 :header-rows: 0
129 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300130 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200131
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400132 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200133 - ``id``
Markus Heiser5377d912016-06-30 15:18:56 +0200134 - Unique ID for the entity.
135
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400136 * - char
Mauro Carvalho Chehab8968da92016-07-13 08:43:30 -0300137 - ``name``\ [64]
Markus Heiser5377d912016-06-30 15:18:56 +0200138 - Entity name as an UTF-8 NULL-terminated string.
139
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400140 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200141 - ``function``
Hans Verkuilcccc41f2018-03-19 11:43:24 -0400142 - Entity main function, see :ref:`media-entity-functions` for details.
Markus Heiser5377d912016-06-30 15:18:56 +0200143
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400144 * - __u32
Hans Verkuild2dc6442018-03-19 11:17:17 -0400145 - ``flags``
146 - Entity flags, see :ref:`media-entity-flag` for details.
147 Only valid if ``MEDIA_V2_ENTITY_HAS_FLAGS(media_version)``
148 returns true. The ``media_version`` is defined in struct
149 :c:type:`media_device_info` and can be retrieved using
150 :ref:`MEDIA_IOC_DEVICE_INFO`.
151
152 * - __u32
153 - ``reserved``\ [5]
Markus Heiser5377d912016-06-30 15:18:56 +0200154 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300155 this array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200156
157
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300158.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200159
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300160.. c:type:: media_v2_interface
Markus Heiser5377d912016-06-30 15:18:56 +0200161
162.. flat-table:: struct media_v2_interface
163 :header-rows: 0
164 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300165 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200166
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400167 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200168 - ``id``
Markus Heiser5377d912016-06-30 15:18:56 +0200169 - Unique ID for the interface.
170
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400171 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200172 - ``intf_type``
Markus Heiser5377d912016-06-30 15:18:56 +0200173 - Interface type, see :ref:`media-intf-type` for details.
174
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400175 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200176 - ``flags``
Markus Heiser5377d912016-06-30 15:18:56 +0200177 - Interface flags. Currently unused.
178
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400179 * - __u32
Mauro Carvalho Chehab8968da92016-07-13 08:43:30 -0300180 - ``reserved``\ [9]
Markus Heiser5377d912016-06-30 15:18:56 +0200181 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300182 this array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200183
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400184 * - struct media_v2_intf_devnode
Markus Heiser5377d912016-06-30 15:18:56 +0200185 - ``devnode``
Markus Heiser5377d912016-06-30 15:18:56 +0200186 - Used only for device node interfaces. See
Hans Verkuilb0549002018-03-19 11:11:10 -0400187 :c:type:`media_v2_intf_devnode` for details.
Markus Heiser5377d912016-06-30 15:18:56 +0200188
189
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300190.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200191
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300192.. c:type:: media_v2_intf_devnode
Markus Heiser5377d912016-06-30 15:18:56 +0200193
Alexandre Courbot7eb2bcb2017-06-07 06:33:02 -0300194.. flat-table:: struct media_v2_intf_devnode
Markus Heiser5377d912016-06-30 15:18:56 +0200195 :header-rows: 0
196 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300197 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200198
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400199 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200200 - ``major``
Markus Heiser5377d912016-06-30 15:18:56 +0200201 - Device node major number.
202
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400203 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200204 - ``minor``
Markus Heiser5377d912016-06-30 15:18:56 +0200205 - Device node minor number.
206
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300207.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200208
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300209.. c:type:: media_v2_pad
Markus Heiser5377d912016-06-30 15:18:56 +0200210
211.. flat-table:: struct media_v2_pad
212 :header-rows: 0
213 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300214 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200215
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400216 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200217 - ``id``
Markus Heiser5377d912016-06-30 15:18:56 +0200218 - Unique ID for the pad.
219
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400220 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200221 - ``entity_id``
Markus Heiser5377d912016-06-30 15:18:56 +0200222 - Unique ID for the entity where this pad belongs.
223
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400224 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200225 - ``flags``
Markus Heiser5377d912016-06-30 15:18:56 +0200226 - Pad flags, see :ref:`media-pad-flag` for more details.
227
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400228 * - __u32
Hans Verkuilb0549002018-03-19 11:11:10 -0400229 - ``index``
230 - Pad index, starts at 0. Only valid if ``MEDIA_V2_PAD_HAS_INDEX(media_version)``
231 returns true. The ``media_version`` is defined in struct
232 :c:type:`media_device_info` and can be retrieved using
233 :ref:`MEDIA_IOC_DEVICE_INFO`.
234
235 * - __u32
236 - ``reserved``\ [4]
Markus Heiser5377d912016-06-30 15:18:56 +0200237 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300238 this array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200239
240
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300241.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200242
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300243.. c:type:: media_v2_link
Markus Heiser5377d912016-06-30 15:18:56 +0200244
Alexandre Courbot7eb2bcb2017-06-07 06:33:02 -0300245.. flat-table:: struct media_v2_link
Markus Heiser5377d912016-06-30 15:18:56 +0200246 :header-rows: 0
247 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300248 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200249
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400250 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200251 - ``id``
Alexandre Courbot7eb2bcb2017-06-07 06:33:02 -0300252 - Unique ID for the link.
Markus Heiser5377d912016-06-30 15:18:56 +0200253
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400254 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200255 - ``source_id``
Markus Heiser5377d912016-06-30 15:18:56 +0200256 - On pad to pad links: unique ID for the source pad.
257
Hans Verkuilafd11792018-02-03 14:18:38 -0500258 On interface to entity links: unique ID for the interface.
Markus Heiser5377d912016-06-30 15:18:56 +0200259
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400260 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200261 - ``sink_id``
Markus Heiser5377d912016-06-30 15:18:56 +0200262 - On pad to pad links: unique ID for the sink pad.
263
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300264 On interface to entity links: unique ID for the entity.
Markus Heiser5377d912016-06-30 15:18:56 +0200265
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400266 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200267 - ``flags``
Markus Heiser5377d912016-06-30 15:18:56 +0200268 - Link flags, see :ref:`media-link-flag` for more details.
269
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400270 * - __u32
Hans Verkuil793d2a92018-03-19 11:43:17 -0400271 - ``reserved``\ [6]
Markus Heiser5377d912016-06-30 15:18:56 +0200272 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300273 this array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200274
275
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -0300276Return Value
Markus Heiser5377d912016-06-30 15:18:56 +0200277============
278
279On success 0 is returned, on error -1 and the ``errno`` variable is set
280appropriately. The generic error codes are described at the
281:ref:`Generic Error Codes <gen-errors>` chapter.
282
283ENOSPC
284 This is returned when either one or more of the num_entities,
285 num_interfaces, num_links or num_pads are non-zero and are
286 smaller than the actual number of elements inside the graph. This
287 may happen if the ``topology_version`` changed when compared to the
288 last time this ioctl was called. Userspace should usually free the
289 area for the pointers, zero the struct elements and call this ioctl
290 again.