1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3.. _media_ioc_enum_links:
4
5**************************
6ioctl MEDIA_IOC_ENUM_LINKS
7**************************
8
9Name
10====
11
12MEDIA_IOC_ENUM_LINKS - Enumerate all pads and links for a given entity
13
14
15Synopsis
16========
17
18.. c:function:: int ioctl( int fd, MEDIA_IOC_ENUM_LINKS, struct media_links_enum *argp )
19    :name: MEDIA_IOC_ENUM_LINKS
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_links_enum`.
30
31
32Description
33===========
34
35To enumerate pads and/or links for a given entity, applications set the
36entity field of a struct :c:type:`media_links_enum`
37structure and initialize the struct
38:c:type:`media_pad_desc` and struct
39:c:type:`media_link_desc` structure arrays pointed by
40the ``pads`` and ``links`` fields. They then call the
41MEDIA_IOC_ENUM_LINKS ioctl with a pointer to this structure.
42
43If the ``pads`` field is not NULL, the driver fills the ``pads`` array
44with information about the entity's pads. The array must have enough
45room to store all the entity's pads. The number of pads can be retrieved
46with :ref:`MEDIA_IOC_ENUM_ENTITIES`.
47
48If the ``links`` field is not NULL, the driver fills the ``links`` array
49with information about the entity's outbound links. The array must have
50enough room to store all the entity's outbound links. The number of
51outbound links can be retrieved with :ref:`MEDIA_IOC_ENUM_ENTITIES`.
52
53Only forward links that originate at one of the entity's source pads are
54returned during the enumeration process.
55
56
57.. c:type:: media_links_enum
58
59.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
60
61.. flat-table:: struct media_links_enum
62    :header-rows:  0
63    :stub-columns: 0
64    :widths:       1 1 2
65
66    *  -  __u32
67       -  ``entity``
68       -  Entity id, set by the application.
69
70    *  -  struct :c:type:`media_pad_desc`
71       -  \*\ ``pads``
72       -  Pointer to a pads array allocated by the application. Ignored if
73	  NULL.
74
75    *  -  struct :c:type:`media_link_desc`
76       -  \*\ ``links``
77       -  Pointer to a links array allocated by the application. Ignored if
78	  NULL.
79
80    *  -  __u32
81       -  ``reserved[4]``
82       -  Reserved for future extensions. Drivers and applications must set
83          the array to zero.
84
85
86.. c:type:: media_pad_desc
87
88.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
89
90.. flat-table:: struct media_pad_desc
91    :header-rows:  0
92    :stub-columns: 0
93    :widths:       1 1 2
94
95    *  -  __u32
96       -  ``entity``
97       -  ID of the entity this pad belongs to.
98
99    *  -  __u16
100       -  ``index``
101       -  Pad index, starts at 0.
102
103    *  -  __u32
104       -  ``flags``
105       -  Pad flags, see :ref:`media-pad-flag` for more details.
106
107    *  -  __u32
108       -  ``reserved[2]``
109       -  Reserved for future extensions. Drivers and applications must set
110          the array to zero.
111
112
113
114.. c:type:: media_link_desc
115
116.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
117
118.. flat-table:: struct media_link_desc
119    :header-rows:  0
120    :stub-columns: 0
121    :widths:       1 1 2
122
123    *  -  struct :c:type:`media_pad_desc`
124       -  ``source``
125       -  Pad at the origin of this link.
126
127    *  -  struct :c:type:`media_pad_desc`
128       -  ``sink``
129       -  Pad at the target of this link.
130
131    *  -  __u32
132       -  ``flags``
133       -  Link flags, see :ref:`media-link-flag` for more details.
134
135    *  -  __u32
136       -  ``reserved[2]``
137       -  Reserved for future extensions. Drivers and applications must set
138          the array to zero.
139
140
141Return Value
142============
143
144On success 0 is returned, on error -1 and the ``errno`` variable is set
145appropriately. The generic error codes are described at the
146:ref:`Generic Error Codes <gen-errors>` chapter.
147
148EINVAL
149    The struct :c:type:`media_links_enum` ``id``
150    references a non-existing entity.
151