18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: MC 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _media_ioc_g_topology: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci************************** 78c2ecf20Sopenharmony_ciioctl MEDIA_IOC_G_TOPOLOGY 88c2ecf20Sopenharmony_ci************************** 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciMEDIA_IOC_G_TOPOLOGY - Enumerate the graph topology and graph element properties 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciSynopsis 168c2ecf20Sopenharmony_ci======== 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci.. c:macro:: MEDIA_IOC_G_TOPOLOGY 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci``int ioctl(int fd, MEDIA_IOC_G_TOPOLOGY, struct media_v2_topology *argp)`` 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciArguments 238c2ecf20Sopenharmony_ci========= 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci``fd`` 268c2ecf20Sopenharmony_ci File descriptor returned by :c:func:`open()`. 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci``argp`` 298c2ecf20Sopenharmony_ci Pointer to struct :c:type:`media_v2_topology`. 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ciDescription 328c2ecf20Sopenharmony_ci=========== 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ciThe typical usage of this ioctl is to call it twice. On the first call, 358c2ecf20Sopenharmony_cithe structure defined at struct 368c2ecf20Sopenharmony_ci:c:type:`media_v2_topology` should be zeroed. At 378c2ecf20Sopenharmony_cireturn, if no errors happen, this ioctl will return the 388c2ecf20Sopenharmony_ci``topology_version`` and the total number of entities, interfaces, pads 398c2ecf20Sopenharmony_ciand links. 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciBefore the second call, the userspace should allocate arrays to store 428c2ecf20Sopenharmony_cithe graph elements that are desired, putting the pointers to them at the 438c2ecf20Sopenharmony_ciptr_entities, ptr_interfaces, ptr_links and/or ptr_pads, keeping the 448c2ecf20Sopenharmony_ciother values untouched. 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciIf the ``topology_version`` remains the same, the ioctl should fill the 478c2ecf20Sopenharmony_cidesired arrays with the media graph elements. 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.5cm}| 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci.. c:type:: media_v2_topology 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci.. flat-table:: struct media_v2_topology 548c2ecf20Sopenharmony_ci :header-rows: 0 558c2ecf20Sopenharmony_ci :stub-columns: 0 568c2ecf20Sopenharmony_ci :widths: 1 2 8 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci * - __u64 598c2ecf20Sopenharmony_ci - ``topology_version`` 608c2ecf20Sopenharmony_ci - Version of the media graph topology. When the graph is created, 618c2ecf20Sopenharmony_ci this field starts with zero. Every time a graph element is added 628c2ecf20Sopenharmony_ci or removed, this field is incremented. 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci * - __u32 658c2ecf20Sopenharmony_ci - ``num_entities`` 668c2ecf20Sopenharmony_ci - Number of entities in the graph 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci * - __u32 698c2ecf20Sopenharmony_ci - ``reserved1`` 708c2ecf20Sopenharmony_ci - Applications and drivers shall set this to 0. 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci * - __u64 738c2ecf20Sopenharmony_ci - ``ptr_entities`` 748c2ecf20Sopenharmony_ci - A pointer to a memory area where the entities array will be 758c2ecf20Sopenharmony_ci stored, converted to a 64-bits integer. It can be zero. if zero, 768c2ecf20Sopenharmony_ci the ioctl won't store the entities. It will just update 778c2ecf20Sopenharmony_ci ``num_entities`` 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci * - __u32 808c2ecf20Sopenharmony_ci - ``num_interfaces`` 818c2ecf20Sopenharmony_ci - Number of interfaces in the graph 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci * - __u32 848c2ecf20Sopenharmony_ci - ``reserved2`` 858c2ecf20Sopenharmony_ci - Applications and drivers shall set this to 0. 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci * - __u64 888c2ecf20Sopenharmony_ci - ``ptr_interfaces`` 898c2ecf20Sopenharmony_ci - A pointer to a memory area where the interfaces array will be 908c2ecf20Sopenharmony_ci stored, converted to a 64-bits integer. It can be zero. if zero, 918c2ecf20Sopenharmony_ci the ioctl won't store the interfaces. It will just update 928c2ecf20Sopenharmony_ci ``num_interfaces`` 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci * - __u32 958c2ecf20Sopenharmony_ci - ``num_pads`` 968c2ecf20Sopenharmony_ci - Total number of pads in the graph 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci * - __u32 998c2ecf20Sopenharmony_ci - ``reserved3`` 1008c2ecf20Sopenharmony_ci - Applications and drivers shall set this to 0. 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci * - __u64 1038c2ecf20Sopenharmony_ci - ``ptr_pads`` 1048c2ecf20Sopenharmony_ci - A pointer to a memory area where the pads array will be stored, 1058c2ecf20Sopenharmony_ci converted to a 64-bits integer. It can be zero. if zero, the ioctl 1068c2ecf20Sopenharmony_ci won't store the pads. It will just update ``num_pads`` 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci * - __u32 1098c2ecf20Sopenharmony_ci - ``num_links`` 1108c2ecf20Sopenharmony_ci - Total number of data and interface links in the graph 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci * - __u32 1138c2ecf20Sopenharmony_ci - ``reserved4`` 1148c2ecf20Sopenharmony_ci - Applications and drivers shall set this to 0. 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci * - __u64 1178c2ecf20Sopenharmony_ci - ``ptr_links`` 1188c2ecf20Sopenharmony_ci - A pointer to a memory area where the links array will be stored, 1198c2ecf20Sopenharmony_ci converted to a 64-bits integer. It can be zero. if zero, the ioctl 1208c2ecf20Sopenharmony_ci won't store the links. It will just update ``num_links`` 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci.. c:type:: media_v2_entity 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci.. flat-table:: struct media_v2_entity 1278c2ecf20Sopenharmony_ci :header-rows: 0 1288c2ecf20Sopenharmony_ci :stub-columns: 0 1298c2ecf20Sopenharmony_ci :widths: 1 2 8 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci * - __u32 1328c2ecf20Sopenharmony_ci - ``id`` 1338c2ecf20Sopenharmony_ci - Unique ID for the entity. Do not expect that the ID will 1348c2ecf20Sopenharmony_ci always be the same for each instance of the device. In other words, 1358c2ecf20Sopenharmony_ci do not hardcode entity IDs in an application. 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci * - char 1388c2ecf20Sopenharmony_ci - ``name``\ [64] 1398c2ecf20Sopenharmony_ci - Entity name as an UTF-8 NULL-terminated string. This name must be unique 1408c2ecf20Sopenharmony_ci within the media topology. 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci * - __u32 1438c2ecf20Sopenharmony_ci - ``function`` 1448c2ecf20Sopenharmony_ci - Entity main function, see :ref:`media-entity-functions` for details. 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci * - __u32 1478c2ecf20Sopenharmony_ci - ``flags`` 1488c2ecf20Sopenharmony_ci - Entity flags, see :ref:`media-entity-flag` for details. 1498c2ecf20Sopenharmony_ci Only valid if ``MEDIA_V2_ENTITY_HAS_FLAGS(media_version)`` 1508c2ecf20Sopenharmony_ci returns true. The ``media_version`` is defined in struct 1518c2ecf20Sopenharmony_ci :c:type:`media_device_info` and can be retrieved using 1528c2ecf20Sopenharmony_ci :ref:`MEDIA_IOC_DEVICE_INFO`. 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci * - __u32 1558c2ecf20Sopenharmony_ci - ``reserved``\ [5] 1568c2ecf20Sopenharmony_ci - Reserved for future extensions. Drivers and applications must set 1578c2ecf20Sopenharmony_ci this array to zero. 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci.. c:type:: media_v2_interface 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci.. flat-table:: struct media_v2_interface 1648c2ecf20Sopenharmony_ci :header-rows: 0 1658c2ecf20Sopenharmony_ci :stub-columns: 0 1668c2ecf20Sopenharmony_ci :widths: 1 2 8 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci * - __u32 1698c2ecf20Sopenharmony_ci - ``id`` 1708c2ecf20Sopenharmony_ci - Unique ID for the interface. Do not expect that the ID will 1718c2ecf20Sopenharmony_ci always be the same for each instance of the device. In other words, 1728c2ecf20Sopenharmony_ci do not hardcode interface IDs in an application. 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci * - __u32 1758c2ecf20Sopenharmony_ci - ``intf_type`` 1768c2ecf20Sopenharmony_ci - Interface type, see :ref:`media-intf-type` for details. 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci * - __u32 1798c2ecf20Sopenharmony_ci - ``flags`` 1808c2ecf20Sopenharmony_ci - Interface flags. Currently unused. 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci * - __u32 1838c2ecf20Sopenharmony_ci - ``reserved``\ [9] 1848c2ecf20Sopenharmony_ci - Reserved for future extensions. Drivers and applications must set 1858c2ecf20Sopenharmony_ci this array to zero. 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci * - struct media_v2_intf_devnode 1888c2ecf20Sopenharmony_ci - ``devnode`` 1898c2ecf20Sopenharmony_ci - Used only for device node interfaces. See 1908c2ecf20Sopenharmony_ci :c:type:`media_v2_intf_devnode` for details. 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci.. c:type:: media_v2_intf_devnode 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci.. flat-table:: struct media_v2_intf_devnode 1978c2ecf20Sopenharmony_ci :header-rows: 0 1988c2ecf20Sopenharmony_ci :stub-columns: 0 1998c2ecf20Sopenharmony_ci :widths: 1 2 8 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci * - __u32 2028c2ecf20Sopenharmony_ci - ``major`` 2038c2ecf20Sopenharmony_ci - Device node major number. 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci * - __u32 2068c2ecf20Sopenharmony_ci - ``minor`` 2078c2ecf20Sopenharmony_ci - Device node minor number. 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci.. c:type:: media_v2_pad 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci.. flat-table:: struct media_v2_pad 2148c2ecf20Sopenharmony_ci :header-rows: 0 2158c2ecf20Sopenharmony_ci :stub-columns: 0 2168c2ecf20Sopenharmony_ci :widths: 1 2 8 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci * - __u32 2198c2ecf20Sopenharmony_ci - ``id`` 2208c2ecf20Sopenharmony_ci - Unique ID for the pad. Do not expect that the ID will 2218c2ecf20Sopenharmony_ci always be the same for each instance of the device. In other words, 2228c2ecf20Sopenharmony_ci do not hardcode pad IDs in an application. 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci * - __u32 2258c2ecf20Sopenharmony_ci - ``entity_id`` 2268c2ecf20Sopenharmony_ci - Unique ID for the entity where this pad belongs. 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci * - __u32 2298c2ecf20Sopenharmony_ci - ``flags`` 2308c2ecf20Sopenharmony_ci - Pad flags, see :ref:`media-pad-flag` for more details. 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci * - __u32 2338c2ecf20Sopenharmony_ci - ``index`` 2348c2ecf20Sopenharmony_ci - Pad index, starts at 0. Only valid if ``MEDIA_V2_PAD_HAS_INDEX(media_version)`` 2358c2ecf20Sopenharmony_ci returns true. The ``media_version`` is defined in struct 2368c2ecf20Sopenharmony_ci :c:type:`media_device_info` and can be retrieved using 2378c2ecf20Sopenharmony_ci :ref:`MEDIA_IOC_DEVICE_INFO`. 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci * - __u32 2408c2ecf20Sopenharmony_ci - ``reserved``\ [4] 2418c2ecf20Sopenharmony_ci - Reserved for future extensions. Drivers and applications must set 2428c2ecf20Sopenharmony_ci this array to zero. 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci.. c:type:: media_v2_link 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci.. flat-table:: struct media_v2_link 2498c2ecf20Sopenharmony_ci :header-rows: 0 2508c2ecf20Sopenharmony_ci :stub-columns: 0 2518c2ecf20Sopenharmony_ci :widths: 1 2 8 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci * - __u32 2548c2ecf20Sopenharmony_ci - ``id`` 2558c2ecf20Sopenharmony_ci - Unique ID for the link. Do not expect that the ID will 2568c2ecf20Sopenharmony_ci always be the same for each instance of the device. In other words, 2578c2ecf20Sopenharmony_ci do not hardcode link IDs in an application. 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci * - __u32 2608c2ecf20Sopenharmony_ci - ``source_id`` 2618c2ecf20Sopenharmony_ci - On pad to pad links: unique ID for the source pad. 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci On interface to entity links: unique ID for the interface. 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci * - __u32 2668c2ecf20Sopenharmony_ci - ``sink_id`` 2678c2ecf20Sopenharmony_ci - On pad to pad links: unique ID for the sink pad. 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci On interface to entity links: unique ID for the entity. 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci * - __u32 2728c2ecf20Sopenharmony_ci - ``flags`` 2738c2ecf20Sopenharmony_ci - Link flags, see :ref:`media-link-flag` for more details. 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci * - __u32 2768c2ecf20Sopenharmony_ci - ``reserved``\ [6] 2778c2ecf20Sopenharmony_ci - Reserved for future extensions. Drivers and applications must set 2788c2ecf20Sopenharmony_ci this array to zero. 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ciReturn Value 2818c2ecf20Sopenharmony_ci============ 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 2848c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the 2858c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ciENOSPC 2888c2ecf20Sopenharmony_ci This is returned when either one or more of the num_entities, 2898c2ecf20Sopenharmony_ci num_interfaces, num_links or num_pads are non-zero and are 2908c2ecf20Sopenharmony_ci smaller than the actual number of elements inside the graph. This 2918c2ecf20Sopenharmony_ci may happen if the ``topology_version`` changed when compared to the 2928c2ecf20Sopenharmony_ci last time this ioctl was called. Userspace should usually free the 2938c2ecf20Sopenharmony_ci area for the pointers, zero the struct elements and call this ioctl 2948c2ecf20Sopenharmony_ci again. 295