1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3.. _media_ioc_enum_entities:
4
5*****************************
6ioctl MEDIA_IOC_ENUM_ENTITIES
7*****************************
8
9Name
10====
11
12MEDIA_IOC_ENUM_ENTITIES - Enumerate entities and their properties
13
14
15Synopsis
16========
17
18.. c:function:: int ioctl( int fd, MEDIA_IOC_ENUM_ENTITIES, struct media_entity_desc *argp )
19    :name: MEDIA_IOC_ENUM_ENTITIES
20
21
22Arguments
23=========
24
25``fd``
26    File descriptor returned by :ref:`open() <media-func-open>`.
27
28``argp``
29    Pointer to struct :c:type:`media_entity_desc`.
30
31
32Description
33===========
34
35To query the attributes of an entity, applications set the id field of a
36struct :c:type:`media_entity_desc` structure and
37call the MEDIA_IOC_ENUM_ENTITIES ioctl with a pointer to this
38structure. The driver fills the rest of the structure or returns an
39EINVAL error code when the id is invalid.
40
41.. _media-ent-id-flag-next:
42
43Entities can be enumerated by or'ing the id with the
44``MEDIA_ENT_ID_FLAG_NEXT`` flag. The driver will return information
45about the entity with the smallest id strictly larger than the requested
46one ('next entity'), or the ``EINVAL`` error code if there is none.
47
48Entity IDs can be non-contiguous. Applications must *not* try to
49enumerate entities by calling MEDIA_IOC_ENUM_ENTITIES with increasing
50id's until they get an error.
51
52
53.. c:type:: media_entity_desc
54
55.. tabularcolumns:: |p{1.5cm}|p{1.7cm}|p{1.6cm}|p{1.5cm}|p{11.2cm}|
56
57.. flat-table:: struct media_entity_desc
58    :header-rows:  0
59    :stub-columns: 0
60    :widths: 2 2 1 8
61
62    *  -  __u32
63       -  ``id``
64       -
65       -  Entity ID, set by the application. When the ID is or'ed with
66	  ``MEDIA_ENT_ID_FLAG_NEXT``, the driver clears the flag and returns
67	  the first entity with a larger ID. Do not expect that the ID will
68	  always be the same for each instance of the device. In other words,
69	  do not hardcode entity IDs in an application.
70
71    *  -  char
72       -  ``name``\ [32]
73       -
74       -  Entity name as an UTF-8 NULL-terminated string. This name must be unique
75          within the media topology.
76
77    *  -  __u32
78       -  ``type``
79       -
80       -  Entity type, see :ref:`media-entity-functions` for details.
81
82    *  -  __u32
83       -  ``revision``
84       -
85       -  Entity revision. Always zero (obsolete)
86
87    *  -  __u32
88       -  ``flags``
89       -
90       -  Entity flags, see :ref:`media-entity-flag` for details.
91
92    *  -  __u32
93       -  ``group_id``
94       -
95       -  Entity group ID. Always zero (obsolete)
96
97    *  -  __u16
98       -  ``pads``
99       -
100       -  Number of pads
101
102    *  -  __u16
103       -  ``links``
104       -
105       -  Total number of outbound links. Inbound links are not counted in
106	  this field.
107
108    *  -  __u32
109       -  ``reserved[4]``
110       -
111       -  Reserved for future extensions. Drivers and applications must set
112          the array to zero.
113
114    *  -  union {
115       -  (anonymous)
116
117    *  -  struct
118       -  ``dev``
119       -
120       -  Valid for (sub-)devices that create a single device node.
121
122    *  -
123       -  __u32
124       -  ``major``
125       -  Device node major number.
126
127    *  -
128       -  __u32
129       -  ``minor``
130       -  Device node minor number.
131
132    *  -  __u8
133       -  ``raw``\ [184]
134       -
135       -
136    *  - }
137       -
138
139
140Return Value
141============
142
143On success 0 is returned, on error -1 and the ``errno`` variable is set
144appropriately. The generic error codes are described at the
145:ref:`Generic Error Codes <gen-errors>` chapter.
146
147EINVAL
148    The struct :c:type:`media_entity_desc` ``id``
149    references a non-existing entity.
150