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