blob: 4e1c59238371a274012e9bb995376160193cd03a [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``
Hans Verkuilb4ae6752018-08-04 05:48:36 -040029 Pointer to struct :c:type:`media_v2_topology`.
Markus Heiser5377d912016-06-30 15:18:56 +020030
31
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030032Description
Markus Heiser5377d912016-06-30 15:18:56 +020033===========
34
35The typical usage of this ioctl is to call it twice. On the first call,
36the structure defined at struct
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -030037:c:type:`media_v2_topology` should be zeroed. At
Markus Heiser5377d912016-06-30 15:18:56 +020038return, if no errors happen, this ioctl will return the
39``topology_version`` and the total number of entities, interfaces, pads
40and links.
41
42Before the second call, the userspace should allocate arrays to store
43the graph elements that are desired, putting the pointers to them at the
44ptr_entities, ptr_interfaces, ptr_links and/or ptr_pads, keeping the
45other values untouched.
46
47If the ``topology_version`` remains the same, the ioctl should fill the
48desired arrays with the media graph elements.
49
Mauro Carvalho Chehab1367f4e2017-09-02 19:29:53 -040050.. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.5cm}|
Markus Heiser5377d912016-06-30 15:18:56 +020051
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -030052.. c:type:: media_v2_topology
Markus Heiser5377d912016-06-30 15:18:56 +020053
54.. flat-table:: struct media_v2_topology
55 :header-rows: 0
56 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -030057 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +020058
Hans Verkuil8c4fe242018-06-15 09:19:44 -040059 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +020060 - ``topology_version``
Markus Heiser5377d912016-06-30 15:18:56 +020061 - Version of the media graph topology. When the graph is created,
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030062 this field starts with zero. Every time a graph element is added
63 or removed, this field is incremented.
Markus Heiser5377d912016-06-30 15:18:56 +020064
Hans Verkuil8c4fe242018-06-15 09:19:44 -040065 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +020066 - ``num_entities``
Markus Heiser5377d912016-06-30 15:18:56 +020067 - Number of entities in the graph
68
Hans Verkuil8c4fe242018-06-15 09:19:44 -040069 * - __u32
Hans Verkuilccac77d2018-02-03 13:06:01 -050070 - ``reserved1``
Hans Verkuilccac77d2018-02-03 13:06:01 -050071 - Applications and drivers shall set this to 0.
72
Hans Verkuil8c4fe242018-06-15 09:19:44 -040073 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +020074 - ``ptr_entities``
Markus Heiser5377d912016-06-30 15:18:56 +020075 - A pointer to a memory area where the entities array will be
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030076 stored, converted to a 64-bits integer. It can be zero. if zero,
77 the ioctl won't store the entities. It will just update
78 ``num_entities``
Markus Heiser5377d912016-06-30 15:18:56 +020079
Hans Verkuil8c4fe242018-06-15 09:19:44 -040080 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +020081 - ``num_interfaces``
Markus Heiser5377d912016-06-30 15:18:56 +020082 - Number of interfaces in the graph
83
Hans Verkuil8c4fe242018-06-15 09:19:44 -040084 * - __u32
Hans Verkuilccac77d2018-02-03 13:06:01 -050085 - ``reserved2``
Hans Verkuilccac77d2018-02-03 13:06:01 -050086 - Applications and drivers shall set this to 0.
87
Hans Verkuil8c4fe242018-06-15 09:19:44 -040088 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +020089 - ``ptr_interfaces``
Markus Heiser5377d912016-06-30 15:18:56 +020090 - A pointer to a memory area where the interfaces array will be
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030091 stored, converted to a 64-bits integer. It can be zero. if zero,
92 the ioctl won't store the interfaces. It will just update
93 ``num_interfaces``
Markus Heiser5377d912016-06-30 15:18:56 +020094
Hans Verkuil8c4fe242018-06-15 09:19:44 -040095 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +020096 - ``num_pads``
Markus Heiser5377d912016-06-30 15:18:56 +020097 - Total number of pads in the graph
98
Hans Verkuil8c4fe242018-06-15 09:19:44 -040099 * - __u32
Hans Verkuilccac77d2018-02-03 13:06:01 -0500100 - ``reserved3``
Hans Verkuilccac77d2018-02-03 13:06:01 -0500101 - Applications and drivers shall set this to 0.
102
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400103 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +0200104 - ``ptr_pads``
Markus Heiser5377d912016-06-30 15:18:56 +0200105 - A pointer to a memory area where the pads array will be stored,
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300106 converted to a 64-bits integer. It can be zero. if zero, the ioctl
107 won't store the pads. It will just update ``num_pads``
Markus Heiser5377d912016-06-30 15:18:56 +0200108
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400109 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200110 - ``num_links``
Markus Heiser5377d912016-06-30 15:18:56 +0200111 - Total number of data and interface links in the graph
112
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400113 * - __u32
Hans Verkuilccac77d2018-02-03 13:06:01 -0500114 - ``reserved4``
Hans Verkuilccac77d2018-02-03 13:06:01 -0500115 - Applications and drivers shall set this to 0.
116
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400117 * - __u64
Markus Heiser5377d912016-06-30 15:18:56 +0200118 - ``ptr_links``
Markus Heiser5377d912016-06-30 15:18:56 +0200119 - A pointer to a memory area where the links array will be stored,
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300120 converted to a 64-bits integer. It can be zero. if zero, the ioctl
121 won't store the links. It will just update ``num_links``
Markus Heiser5377d912016-06-30 15:18:56 +0200122
123
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300124.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200125
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300126.. c:type:: media_v2_entity
Markus Heiser5377d912016-06-30 15:18:56 +0200127
128.. flat-table:: struct media_v2_entity
129 :header-rows: 0
130 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300131 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200132
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400133 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200134 - ``id``
Hans Verkuil86014942018-06-29 07:31:20 -0400135 - Unique ID for the entity. Do not expect that the ID will
136 always be the same for each instance of the device. In other words,
137 do not hardcode entity IDs in an application.
Markus Heiser5377d912016-06-30 15:18:56 +0200138
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400139 * - char
Mauro Carvalho Chehab8968da92016-07-13 08:43:30 -0300140 - ``name``\ [64]
Hans Verkuil86014942018-06-29 07:31:20 -0400141 - Entity name as an UTF-8 NULL-terminated string. This name must be unique
142 within the media topology.
Markus Heiser5377d912016-06-30 15:18:56 +0200143
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400144 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200145 - ``function``
Hans Verkuilcccc41f2018-03-19 11:43:24 -0400146 - Entity main function, see :ref:`media-entity-functions` for details.
Markus Heiser5377d912016-06-30 15:18:56 +0200147
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400148 * - __u32
Hans Verkuild2dc6442018-03-19 11:17:17 -0400149 - ``flags``
150 - Entity flags, see :ref:`media-entity-flag` for details.
151 Only valid if ``MEDIA_V2_ENTITY_HAS_FLAGS(media_version)``
152 returns true. The ``media_version`` is defined in struct
153 :c:type:`media_device_info` and can be retrieved using
154 :ref:`MEDIA_IOC_DEVICE_INFO`.
155
156 * - __u32
157 - ``reserved``\ [5]
Markus Heiser5377d912016-06-30 15:18:56 +0200158 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300159 this array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200160
161
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300162.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200163
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300164.. c:type:: media_v2_interface
Markus Heiser5377d912016-06-30 15:18:56 +0200165
166.. flat-table:: struct media_v2_interface
167 :header-rows: 0
168 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300169 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200170
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400171 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200172 - ``id``
Hans Verkuil86014942018-06-29 07:31:20 -0400173 - Unique ID for the interface. Do not expect that the ID will
174 always be the same for each instance of the device. In other words,
175 do not hardcode interface IDs in an application.
Markus Heiser5377d912016-06-30 15:18:56 +0200176
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400177 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200178 - ``intf_type``
Markus Heiser5377d912016-06-30 15:18:56 +0200179 - Interface type, see :ref:`media-intf-type` for details.
180
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400181 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200182 - ``flags``
Markus Heiser5377d912016-06-30 15:18:56 +0200183 - Interface flags. Currently unused.
184
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400185 * - __u32
Mauro Carvalho Chehab8968da92016-07-13 08:43:30 -0300186 - ``reserved``\ [9]
Markus Heiser5377d912016-06-30 15:18:56 +0200187 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300188 this array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200189
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400190 * - struct media_v2_intf_devnode
Markus Heiser5377d912016-06-30 15:18:56 +0200191 - ``devnode``
Markus Heiser5377d912016-06-30 15:18:56 +0200192 - Used only for device node interfaces. See
Hans Verkuilb0549002018-03-19 11:11:10 -0400193 :c:type:`media_v2_intf_devnode` for details.
Markus Heiser5377d912016-06-30 15:18:56 +0200194
195
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300196.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200197
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300198.. c:type:: media_v2_intf_devnode
Markus Heiser5377d912016-06-30 15:18:56 +0200199
Alexandre Courbot7eb2bcb2017-06-07 06:33:02 -0300200.. flat-table:: struct media_v2_intf_devnode
Markus Heiser5377d912016-06-30 15:18:56 +0200201 :header-rows: 0
202 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300203 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200204
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400205 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200206 - ``major``
Markus Heiser5377d912016-06-30 15:18:56 +0200207 - Device node major number.
208
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400209 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200210 - ``minor``
Markus Heiser5377d912016-06-30 15:18:56 +0200211 - Device node minor number.
212
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300213.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200214
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300215.. c:type:: media_v2_pad
Markus Heiser5377d912016-06-30 15:18:56 +0200216
217.. flat-table:: struct media_v2_pad
218 :header-rows: 0
219 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300220 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200221
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400222 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200223 - ``id``
Hans Verkuil86014942018-06-29 07:31:20 -0400224 - Unique ID for the pad. Do not expect that the ID will
225 always be the same for each instance of the device. In other words,
226 do not hardcode pad IDs in an application.
Markus Heiser5377d912016-06-30 15:18:56 +0200227
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400228 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200229 - ``entity_id``
Markus Heiser5377d912016-06-30 15:18:56 +0200230 - Unique ID for the entity where this pad belongs.
231
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400232 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200233 - ``flags``
Markus Heiser5377d912016-06-30 15:18:56 +0200234 - Pad flags, see :ref:`media-pad-flag` for more details.
235
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400236 * - __u32
Hans Verkuilb0549002018-03-19 11:11:10 -0400237 - ``index``
238 - Pad index, starts at 0. Only valid if ``MEDIA_V2_PAD_HAS_INDEX(media_version)``
239 returns true. The ``media_version`` is defined in struct
240 :c:type:`media_device_info` and can be retrieved using
241 :ref:`MEDIA_IOC_DEVICE_INFO`.
242
243 * - __u32
244 - ``reserved``\ [4]
Markus Heiser5377d912016-06-30 15:18:56 +0200245 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300246 this array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200247
248
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300249.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
Markus Heiser5377d912016-06-30 15:18:56 +0200250
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300251.. c:type:: media_v2_link
Markus Heiser5377d912016-06-30 15:18:56 +0200252
Alexandre Courbot7eb2bcb2017-06-07 06:33:02 -0300253.. flat-table:: struct media_v2_link
Markus Heiser5377d912016-06-30 15:18:56 +0200254 :header-rows: 0
255 :stub-columns: 0
Mauro Carvalho Chehab89268142016-07-06 07:31:59 -0300256 :widths: 1 2 8
Markus Heiser5377d912016-06-30 15:18:56 +0200257
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400258 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200259 - ``id``
Hans Verkuil86014942018-06-29 07:31:20 -0400260 - Unique ID for the link. Do not expect that the ID will
261 always be the same for each instance of the device. In other words,
262 do not hardcode link IDs in an application.
Markus Heiser5377d912016-06-30 15:18:56 +0200263
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400264 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200265 - ``source_id``
Markus Heiser5377d912016-06-30 15:18:56 +0200266 - On pad to pad links: unique ID for the source pad.
267
Hans Verkuilafd11792018-02-03 14:18:38 -0500268 On interface to entity links: unique ID for the interface.
Markus Heiser5377d912016-06-30 15:18:56 +0200269
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400270 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200271 - ``sink_id``
Markus Heiser5377d912016-06-30 15:18:56 +0200272 - On pad to pad links: unique ID for the sink pad.
273
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300274 On interface to entity links: unique ID for the entity.
Markus Heiser5377d912016-06-30 15:18:56 +0200275
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400276 * - __u32
Markus Heiser5377d912016-06-30 15:18:56 +0200277 - ``flags``
Markus Heiser5377d912016-06-30 15:18:56 +0200278 - Link flags, see :ref:`media-link-flag` for more details.
279
Hans Verkuil8c4fe242018-06-15 09:19:44 -0400280 * - __u32
Hans Verkuil793d2a92018-03-19 11:43:17 -0400281 - ``reserved``\ [6]
Markus Heiser5377d912016-06-30 15:18:56 +0200282 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300283 this array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200284
285
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -0300286Return Value
Markus Heiser5377d912016-06-30 15:18:56 +0200287============
288
289On success 0 is returned, on error -1 and the ``errno`` variable is set
290appropriately. The generic error codes are described at the
291:ref:`Generic Error Codes <gen-errors>` chapter.
292
293ENOSPC
294 This is returned when either one or more of the num_entities,
295 num_interfaces, num_links or num_pads are non-zero and are
296 smaller than the actual number of elements inside the graph. This
297 may happen if the ``topology_version`` changed when compared to the
298 last time this ioctl was called. Userspace should usually free the
299 area for the pointers, zero the struct elements and call this ioctl
300 again.