xref: /openbmc/linux/Documentation/userspace-api/media/mediactl/media-ioc-enum-entities.rst (revision 8be98d2f2a0a262f8bf8a0bc1fdf522b3c7aab17)
1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2937e6805SMauro Carvalho Chehab.. c:namespace:: MC
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _media_ioc_enum_entities:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab*****************************
754f38fcaSMauro Carvalho Chehabioctl MEDIA_IOC_ENUM_ENTITIES
854f38fcaSMauro Carvalho Chehab*****************************
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho ChehabName
1154f38fcaSMauro Carvalho Chehab====
1254f38fcaSMauro Carvalho Chehab
1354f38fcaSMauro Carvalho ChehabMEDIA_IOC_ENUM_ENTITIES - Enumerate entities and their properties
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
18937e6805SMauro Carvalho Chehab.. c:macro:: MEDIA_IOC_ENUM_ENTITIES
1954f38fcaSMauro Carvalho Chehab
20937e6805SMauro Carvalho Chehab``int ioctl(int fd, MEDIA_IOC_ENUM_ENTITIES, struct media_entity_desc *argp)``
2154f38fcaSMauro Carvalho Chehab
2254f38fcaSMauro Carvalho ChehabArguments
2354f38fcaSMauro Carvalho Chehab=========
2454f38fcaSMauro Carvalho Chehab
2554f38fcaSMauro Carvalho Chehab``fd``
26937e6805SMauro Carvalho Chehab    File descriptor returned by :c:func:`open()`.
2754f38fcaSMauro Carvalho Chehab
2854f38fcaSMauro Carvalho Chehab``argp``
2954f38fcaSMauro Carvalho Chehab    Pointer to struct :c:type:`media_entity_desc`.
3054f38fcaSMauro Carvalho Chehab
3154f38fcaSMauro Carvalho ChehabDescription
3254f38fcaSMauro Carvalho Chehab===========
3354f38fcaSMauro Carvalho Chehab
3454f38fcaSMauro Carvalho ChehabTo query the attributes of an entity, applications set the id field of a
3554f38fcaSMauro Carvalho Chehabstruct :c:type:`media_entity_desc` structure and
3654f38fcaSMauro Carvalho Chehabcall the MEDIA_IOC_ENUM_ENTITIES ioctl with a pointer to this
3754f38fcaSMauro Carvalho Chehabstructure. The driver fills the rest of the structure or returns an
3854f38fcaSMauro Carvalho ChehabEINVAL error code when the id is invalid.
3954f38fcaSMauro Carvalho Chehab
4054f38fcaSMauro Carvalho Chehab.. _media-ent-id-flag-next:
4154f38fcaSMauro Carvalho Chehab
4254f38fcaSMauro Carvalho ChehabEntities can be enumerated by or'ing the id with the
4354f38fcaSMauro Carvalho Chehab``MEDIA_ENT_ID_FLAG_NEXT`` flag. The driver will return information
4454f38fcaSMauro Carvalho Chehababout the entity with the smallest id strictly larger than the requested
4554f38fcaSMauro Carvalho Chehabone ('next entity'), or the ``EINVAL`` error code if there is none.
4654f38fcaSMauro Carvalho Chehab
4754f38fcaSMauro Carvalho ChehabEntity IDs can be non-contiguous. Applications must *not* try to
4854f38fcaSMauro Carvalho Chehabenumerate entities by calling MEDIA_IOC_ENUM_ENTITIES with increasing
4954f38fcaSMauro Carvalho Chehabid's until they get an error.
5054f38fcaSMauro Carvalho Chehab
5154f38fcaSMauro Carvalho Chehab.. c:type:: media_entity_desc
5254f38fcaSMauro Carvalho Chehab
53*fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{1.5cm}|p{1.7cm}|p{1.6cm}|p{1.5cm}|p{10.6cm}|
5454f38fcaSMauro Carvalho Chehab
5554f38fcaSMauro Carvalho Chehab.. flat-table:: struct media_entity_desc
5654f38fcaSMauro Carvalho Chehab    :header-rows:  0
5754f38fcaSMauro Carvalho Chehab    :stub-columns: 0
5854f38fcaSMauro Carvalho Chehab    :widths: 2 2 1 8
5954f38fcaSMauro Carvalho Chehab
6054f38fcaSMauro Carvalho Chehab    *  -  __u32
6154f38fcaSMauro Carvalho Chehab       -  ``id``
6254f38fcaSMauro Carvalho Chehab       -
6354f38fcaSMauro Carvalho Chehab       -  Entity ID, set by the application. When the ID is or'ed with
6454f38fcaSMauro Carvalho Chehab	  ``MEDIA_ENT_ID_FLAG_NEXT``, the driver clears the flag and returns
6554f38fcaSMauro Carvalho Chehab	  the first entity with a larger ID. Do not expect that the ID will
6654f38fcaSMauro Carvalho Chehab	  always be the same for each instance of the device. In other words,
6754f38fcaSMauro Carvalho Chehab	  do not hardcode entity IDs in an application.
6854f38fcaSMauro Carvalho Chehab
6954f38fcaSMauro Carvalho Chehab    *  -  char
7054f38fcaSMauro Carvalho Chehab       -  ``name``\ [32]
7154f38fcaSMauro Carvalho Chehab       -
7254f38fcaSMauro Carvalho Chehab       -  Entity name as an UTF-8 NULL-terminated string. This name must be unique
7354f38fcaSMauro Carvalho Chehab          within the media topology.
7454f38fcaSMauro Carvalho Chehab
7554f38fcaSMauro Carvalho Chehab    *  -  __u32
7654f38fcaSMauro Carvalho Chehab       -  ``type``
7754f38fcaSMauro Carvalho Chehab       -
7854f38fcaSMauro Carvalho Chehab       -  Entity type, see :ref:`media-entity-functions` for details.
7954f38fcaSMauro Carvalho Chehab
8054f38fcaSMauro Carvalho Chehab    *  -  __u32
8154f38fcaSMauro Carvalho Chehab       -  ``revision``
8254f38fcaSMauro Carvalho Chehab       -
8354f38fcaSMauro Carvalho Chehab       -  Entity revision. Always zero (obsolete)
8454f38fcaSMauro Carvalho Chehab
8554f38fcaSMauro Carvalho Chehab    *  -  __u32
8654f38fcaSMauro Carvalho Chehab       -  ``flags``
8754f38fcaSMauro Carvalho Chehab       -
8854f38fcaSMauro Carvalho Chehab       -  Entity flags, see :ref:`media-entity-flag` for details.
8954f38fcaSMauro Carvalho Chehab
9054f38fcaSMauro Carvalho Chehab    *  -  __u32
9154f38fcaSMauro Carvalho Chehab       -  ``group_id``
9254f38fcaSMauro Carvalho Chehab       -
9354f38fcaSMauro Carvalho Chehab       -  Entity group ID. Always zero (obsolete)
9454f38fcaSMauro Carvalho Chehab
9554f38fcaSMauro Carvalho Chehab    *  -  __u16
9654f38fcaSMauro Carvalho Chehab       -  ``pads``
9754f38fcaSMauro Carvalho Chehab       -
9854f38fcaSMauro Carvalho Chehab       -  Number of pads
9954f38fcaSMauro Carvalho Chehab
10054f38fcaSMauro Carvalho Chehab    *  -  __u16
10154f38fcaSMauro Carvalho Chehab       -  ``links``
10254f38fcaSMauro Carvalho Chehab       -
10354f38fcaSMauro Carvalho Chehab       -  Total number of outbound links. Inbound links are not counted in
10454f38fcaSMauro Carvalho Chehab	  this field.
10554f38fcaSMauro Carvalho Chehab
10654f38fcaSMauro Carvalho Chehab    *  -  __u32
10754f38fcaSMauro Carvalho Chehab       -  ``reserved[4]``
10854f38fcaSMauro Carvalho Chehab       -
10954f38fcaSMauro Carvalho Chehab       -  Reserved for future extensions. Drivers and applications must set
11054f38fcaSMauro Carvalho Chehab          the array to zero.
11154f38fcaSMauro Carvalho Chehab
11254f38fcaSMauro Carvalho Chehab    *  -  union {
11354f38fcaSMauro Carvalho Chehab       -  (anonymous)
11454f38fcaSMauro Carvalho Chehab
11554f38fcaSMauro Carvalho Chehab    *  -  struct
11654f38fcaSMauro Carvalho Chehab       -  ``dev``
11754f38fcaSMauro Carvalho Chehab       -
11854f38fcaSMauro Carvalho Chehab       -  Valid for (sub-)devices that create a single device node.
11954f38fcaSMauro Carvalho Chehab
12054f38fcaSMauro Carvalho Chehab    *  -
12154f38fcaSMauro Carvalho Chehab       -  __u32
12254f38fcaSMauro Carvalho Chehab       -  ``major``
12354f38fcaSMauro Carvalho Chehab       -  Device node major number.
12454f38fcaSMauro Carvalho Chehab
12554f38fcaSMauro Carvalho Chehab    *  -
12654f38fcaSMauro Carvalho Chehab       -  __u32
12754f38fcaSMauro Carvalho Chehab       -  ``minor``
12854f38fcaSMauro Carvalho Chehab       -  Device node minor number.
12954f38fcaSMauro Carvalho Chehab
13054f38fcaSMauro Carvalho Chehab    *  -  __u8
13154f38fcaSMauro Carvalho Chehab       -  ``raw``\ [184]
13254f38fcaSMauro Carvalho Chehab       -
13354f38fcaSMauro Carvalho Chehab       -
13454f38fcaSMauro Carvalho Chehab    *  - }
13554f38fcaSMauro Carvalho Chehab       -
13654f38fcaSMauro Carvalho Chehab
13754f38fcaSMauro Carvalho ChehabReturn Value
13854f38fcaSMauro Carvalho Chehab============
13954f38fcaSMauro Carvalho Chehab
14054f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
14154f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
14254f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
14354f38fcaSMauro Carvalho Chehab
14454f38fcaSMauro Carvalho ChehabEINVAL
14554f38fcaSMauro Carvalho Chehab    The struct :c:type:`media_entity_desc` ``id``
14654f38fcaSMauro Carvalho Chehab    references a non-existing entity.
147