1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2*4882a593Smuzhiyun.. c:namespace:: MC 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun.. _media_ioc_g_topology: 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun************************** 7*4882a593Smuzhiyunioctl MEDIA_IOC_G_TOPOLOGY 8*4882a593Smuzhiyun************************** 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunName 11*4882a593Smuzhiyun==== 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunMEDIA_IOC_G_TOPOLOGY - Enumerate the graph topology and graph element properties 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunSynopsis 16*4882a593Smuzhiyun======== 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun.. c:macro:: MEDIA_IOC_G_TOPOLOGY 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun``int ioctl(int fd, MEDIA_IOC_G_TOPOLOGY, struct media_v2_topology *argp)`` 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunArguments 23*4882a593Smuzhiyun========= 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun``fd`` 26*4882a593Smuzhiyun File descriptor returned by :c:func:`open()`. 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun``argp`` 29*4882a593Smuzhiyun Pointer to struct :c:type:`media_v2_topology`. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunDescription 32*4882a593Smuzhiyun=========== 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunThe typical usage of this ioctl is to call it twice. On the first call, 35*4882a593Smuzhiyunthe structure defined at struct 36*4882a593Smuzhiyun:c:type:`media_v2_topology` should be zeroed. At 37*4882a593Smuzhiyunreturn, if no errors happen, this ioctl will return the 38*4882a593Smuzhiyun``topology_version`` and the total number of entities, interfaces, pads 39*4882a593Smuzhiyunand links. 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunBefore the second call, the userspace should allocate arrays to store 42*4882a593Smuzhiyunthe graph elements that are desired, putting the pointers to them at the 43*4882a593Smuzhiyunptr_entities, ptr_interfaces, ptr_links and/or ptr_pads, keeping the 44*4882a593Smuzhiyunother values untouched. 45*4882a593Smuzhiyun 46*4882a593SmuzhiyunIf the ``topology_version`` remains the same, the ioctl should fill the 47*4882a593Smuzhiyundesired arrays with the media graph elements. 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun.. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.5cm}| 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun.. c:type:: media_v2_topology 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun.. flat-table:: struct media_v2_topology 54*4882a593Smuzhiyun :header-rows: 0 55*4882a593Smuzhiyun :stub-columns: 0 56*4882a593Smuzhiyun :widths: 1 2 8 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun * - __u64 59*4882a593Smuzhiyun - ``topology_version`` 60*4882a593Smuzhiyun - Version of the media graph topology. When the graph is created, 61*4882a593Smuzhiyun this field starts with zero. Every time a graph element is added 62*4882a593Smuzhiyun or removed, this field is incremented. 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun * - __u32 65*4882a593Smuzhiyun - ``num_entities`` 66*4882a593Smuzhiyun - Number of entities in the graph 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun * - __u32 69*4882a593Smuzhiyun - ``reserved1`` 70*4882a593Smuzhiyun - Applications and drivers shall set this to 0. 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun * - __u64 73*4882a593Smuzhiyun - ``ptr_entities`` 74*4882a593Smuzhiyun - A pointer to a memory area where the entities array will be 75*4882a593Smuzhiyun stored, converted to a 64-bits integer. It can be zero. if zero, 76*4882a593Smuzhiyun the ioctl won't store the entities. It will just update 77*4882a593Smuzhiyun ``num_entities`` 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun * - __u32 80*4882a593Smuzhiyun - ``num_interfaces`` 81*4882a593Smuzhiyun - Number of interfaces in the graph 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun * - __u32 84*4882a593Smuzhiyun - ``reserved2`` 85*4882a593Smuzhiyun - Applications and drivers shall set this to 0. 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun * - __u64 88*4882a593Smuzhiyun - ``ptr_interfaces`` 89*4882a593Smuzhiyun - A pointer to a memory area where the interfaces array will be 90*4882a593Smuzhiyun stored, converted to a 64-bits integer. It can be zero. if zero, 91*4882a593Smuzhiyun the ioctl won't store the interfaces. It will just update 92*4882a593Smuzhiyun ``num_interfaces`` 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun * - __u32 95*4882a593Smuzhiyun - ``num_pads`` 96*4882a593Smuzhiyun - Total number of pads in the graph 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun * - __u32 99*4882a593Smuzhiyun - ``reserved3`` 100*4882a593Smuzhiyun - Applications and drivers shall set this to 0. 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun * - __u64 103*4882a593Smuzhiyun - ``ptr_pads`` 104*4882a593Smuzhiyun - A pointer to a memory area where the pads array will be stored, 105*4882a593Smuzhiyun converted to a 64-bits integer. It can be zero. if zero, the ioctl 106*4882a593Smuzhiyun won't store the pads. It will just update ``num_pads`` 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun * - __u32 109*4882a593Smuzhiyun - ``num_links`` 110*4882a593Smuzhiyun - Total number of data and interface links in the graph 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun * - __u32 113*4882a593Smuzhiyun - ``reserved4`` 114*4882a593Smuzhiyun - Applications and drivers shall set this to 0. 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun * - __u64 117*4882a593Smuzhiyun - ``ptr_links`` 118*4882a593Smuzhiyun - A pointer to a memory area where the links array will be stored, 119*4882a593Smuzhiyun converted to a 64-bits integer. It can be zero. if zero, the ioctl 120*4882a593Smuzhiyun won't store the links. It will just update ``num_links`` 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun.. c:type:: media_v2_entity 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun.. flat-table:: struct media_v2_entity 127*4882a593Smuzhiyun :header-rows: 0 128*4882a593Smuzhiyun :stub-columns: 0 129*4882a593Smuzhiyun :widths: 1 2 8 130*4882a593Smuzhiyun 131*4882a593Smuzhiyun * - __u32 132*4882a593Smuzhiyun - ``id`` 133*4882a593Smuzhiyun - Unique ID for the entity. Do not expect that the ID will 134*4882a593Smuzhiyun always be the same for each instance of the device. In other words, 135*4882a593Smuzhiyun do not hardcode entity IDs in an application. 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun * - char 138*4882a593Smuzhiyun - ``name``\ [64] 139*4882a593Smuzhiyun - Entity name as an UTF-8 NULL-terminated string. This name must be unique 140*4882a593Smuzhiyun within the media topology. 141*4882a593Smuzhiyun 142*4882a593Smuzhiyun * - __u32 143*4882a593Smuzhiyun - ``function`` 144*4882a593Smuzhiyun - Entity main function, see :ref:`media-entity-functions` for details. 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun * - __u32 147*4882a593Smuzhiyun - ``flags`` 148*4882a593Smuzhiyun - Entity flags, see :ref:`media-entity-flag` for details. 149*4882a593Smuzhiyun Only valid if ``MEDIA_V2_ENTITY_HAS_FLAGS(media_version)`` 150*4882a593Smuzhiyun returns true. The ``media_version`` is defined in struct 151*4882a593Smuzhiyun :c:type:`media_device_info` and can be retrieved using 152*4882a593Smuzhiyun :ref:`MEDIA_IOC_DEVICE_INFO`. 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun * - __u32 155*4882a593Smuzhiyun - ``reserved``\ [5] 156*4882a593Smuzhiyun - Reserved for future extensions. Drivers and applications must set 157*4882a593Smuzhiyun this array to zero. 158*4882a593Smuzhiyun 159*4882a593Smuzhiyun.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun.. c:type:: media_v2_interface 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun.. flat-table:: struct media_v2_interface 164*4882a593Smuzhiyun :header-rows: 0 165*4882a593Smuzhiyun :stub-columns: 0 166*4882a593Smuzhiyun :widths: 1 2 8 167*4882a593Smuzhiyun 168*4882a593Smuzhiyun * - __u32 169*4882a593Smuzhiyun - ``id`` 170*4882a593Smuzhiyun - Unique ID for the interface. Do not expect that the ID will 171*4882a593Smuzhiyun always be the same for each instance of the device. In other words, 172*4882a593Smuzhiyun do not hardcode interface IDs in an application. 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun * - __u32 175*4882a593Smuzhiyun - ``intf_type`` 176*4882a593Smuzhiyun - Interface type, see :ref:`media-intf-type` for details. 177*4882a593Smuzhiyun 178*4882a593Smuzhiyun * - __u32 179*4882a593Smuzhiyun - ``flags`` 180*4882a593Smuzhiyun - Interface flags. Currently unused. 181*4882a593Smuzhiyun 182*4882a593Smuzhiyun * - __u32 183*4882a593Smuzhiyun - ``reserved``\ [9] 184*4882a593Smuzhiyun - Reserved for future extensions. Drivers and applications must set 185*4882a593Smuzhiyun this array to zero. 186*4882a593Smuzhiyun 187*4882a593Smuzhiyun * - struct media_v2_intf_devnode 188*4882a593Smuzhiyun - ``devnode`` 189*4882a593Smuzhiyun - Used only for device node interfaces. See 190*4882a593Smuzhiyun :c:type:`media_v2_intf_devnode` for details. 191*4882a593Smuzhiyun 192*4882a593Smuzhiyun.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun.. c:type:: media_v2_intf_devnode 195*4882a593Smuzhiyun 196*4882a593Smuzhiyun.. flat-table:: struct media_v2_intf_devnode 197*4882a593Smuzhiyun :header-rows: 0 198*4882a593Smuzhiyun :stub-columns: 0 199*4882a593Smuzhiyun :widths: 1 2 8 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun * - __u32 202*4882a593Smuzhiyun - ``major`` 203*4882a593Smuzhiyun - Device node major number. 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun * - __u32 206*4882a593Smuzhiyun - ``minor`` 207*4882a593Smuzhiyun - Device node minor number. 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 210*4882a593Smuzhiyun 211*4882a593Smuzhiyun.. c:type:: media_v2_pad 212*4882a593Smuzhiyun 213*4882a593Smuzhiyun.. flat-table:: struct media_v2_pad 214*4882a593Smuzhiyun :header-rows: 0 215*4882a593Smuzhiyun :stub-columns: 0 216*4882a593Smuzhiyun :widths: 1 2 8 217*4882a593Smuzhiyun 218*4882a593Smuzhiyun * - __u32 219*4882a593Smuzhiyun - ``id`` 220*4882a593Smuzhiyun - Unique ID for the pad. Do not expect that the ID will 221*4882a593Smuzhiyun always be the same for each instance of the device. In other words, 222*4882a593Smuzhiyun do not hardcode pad IDs in an application. 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun * - __u32 225*4882a593Smuzhiyun - ``entity_id`` 226*4882a593Smuzhiyun - Unique ID for the entity where this pad belongs. 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun * - __u32 229*4882a593Smuzhiyun - ``flags`` 230*4882a593Smuzhiyun - Pad flags, see :ref:`media-pad-flag` for more details. 231*4882a593Smuzhiyun 232*4882a593Smuzhiyun * - __u32 233*4882a593Smuzhiyun - ``index`` 234*4882a593Smuzhiyun - Pad index, starts at 0. Only valid if ``MEDIA_V2_PAD_HAS_INDEX(media_version)`` 235*4882a593Smuzhiyun returns true. The ``media_version`` is defined in struct 236*4882a593Smuzhiyun :c:type:`media_device_info` and can be retrieved using 237*4882a593Smuzhiyun :ref:`MEDIA_IOC_DEVICE_INFO`. 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun * - __u32 240*4882a593Smuzhiyun - ``reserved``\ [4] 241*4882a593Smuzhiyun - Reserved for future extensions. Drivers and applications must set 242*4882a593Smuzhiyun this array to zero. 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 245*4882a593Smuzhiyun 246*4882a593Smuzhiyun.. c:type:: media_v2_link 247*4882a593Smuzhiyun 248*4882a593Smuzhiyun.. flat-table:: struct media_v2_link 249*4882a593Smuzhiyun :header-rows: 0 250*4882a593Smuzhiyun :stub-columns: 0 251*4882a593Smuzhiyun :widths: 1 2 8 252*4882a593Smuzhiyun 253*4882a593Smuzhiyun * - __u32 254*4882a593Smuzhiyun - ``id`` 255*4882a593Smuzhiyun - Unique ID for the link. Do not expect that the ID will 256*4882a593Smuzhiyun always be the same for each instance of the device. In other words, 257*4882a593Smuzhiyun do not hardcode link IDs in an application. 258*4882a593Smuzhiyun 259*4882a593Smuzhiyun * - __u32 260*4882a593Smuzhiyun - ``source_id`` 261*4882a593Smuzhiyun - On pad to pad links: unique ID for the source pad. 262*4882a593Smuzhiyun 263*4882a593Smuzhiyun On interface to entity links: unique ID for the interface. 264*4882a593Smuzhiyun 265*4882a593Smuzhiyun * - __u32 266*4882a593Smuzhiyun - ``sink_id`` 267*4882a593Smuzhiyun - On pad to pad links: unique ID for the sink pad. 268*4882a593Smuzhiyun 269*4882a593Smuzhiyun On interface to entity links: unique ID for the entity. 270*4882a593Smuzhiyun 271*4882a593Smuzhiyun * - __u32 272*4882a593Smuzhiyun - ``flags`` 273*4882a593Smuzhiyun - Link flags, see :ref:`media-link-flag` for more details. 274*4882a593Smuzhiyun 275*4882a593Smuzhiyun * - __u32 276*4882a593Smuzhiyun - ``reserved``\ [6] 277*4882a593Smuzhiyun - Reserved for future extensions. Drivers and applications must set 278*4882a593Smuzhiyun this array to zero. 279*4882a593Smuzhiyun 280*4882a593SmuzhiyunReturn Value 281*4882a593Smuzhiyun============ 282*4882a593Smuzhiyun 283*4882a593SmuzhiyunOn success 0 is returned, on error -1 and the ``errno`` variable is set 284*4882a593Smuzhiyunappropriately. The generic error codes are described at the 285*4882a593Smuzhiyun:ref:`Generic Error Codes <gen-errors>` chapter. 286*4882a593Smuzhiyun 287*4882a593SmuzhiyunENOSPC 288*4882a593Smuzhiyun This is returned when either one or more of the num_entities, 289*4882a593Smuzhiyun num_interfaces, num_links or num_pads are non-zero and are 290*4882a593Smuzhiyun smaller than the actual number of elements inside the graph. This 291*4882a593Smuzhiyun may happen if the ``topology_version`` changed when compared to the 292*4882a593Smuzhiyun last time this ioctl was called. Userspace should usually free the 293*4882a593Smuzhiyun area for the pointers, zero the struct elements and call this ioctl 294*4882a593Smuzhiyun again. 295