diff options
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap/media/0014-media-Entities-pads-and-links-enumeration.patch')
-rw-r--r-- | extras/recipes-kernel/linux/linux-omap/media/0014-media-Entities-pads-and-links-enumeration.patch | 889 |
1 files changed, 889 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap/media/0014-media-Entities-pads-and-links-enumeration.patch b/extras/recipes-kernel/linux/linux-omap/media/0014-media-Entities-pads-and-links-enumeration.patch new file mode 100644 index 00000000..cc9e8761 --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap/media/0014-media-Entities-pads-and-links-enumeration.patch | |||
@@ -0,0 +1,889 @@ | |||
1 | From d7784ca094970b836c99e5f2a6344811625753a3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
3 | Date: Wed, 9 Dec 2009 12:40:01 +0100 | ||
4 | Subject: [PATCH 14/43] media: Entities, pads and links enumeration | ||
5 | |||
6 | Create the following two ioctls and implement them at the media device | ||
7 | level to enumerate entities, pads and links. | ||
8 | |||
9 | - MEDIA_IOC_ENUM_ENTITIES: Enumerate entities and their properties | ||
10 | - MEDIA_IOC_ENUM_LINKS: Enumerate all pads and links for a given entity | ||
11 | |||
12 | Entity IDs can be non-contiguous. Userspace applications should | ||
13 | enumerate entities using the MEDIA_ENT_ID_FLAG_NEXT flag. When the flag | ||
14 | is set in the entity ID, the MEDIA_IOC_ENUM_ENTITIES will return the | ||
15 | next entity with an ID bigger than the requested one. | ||
16 | |||
17 | Only forward links that originate at one of the entity's source pads are | ||
18 | returned during the enumeration process. | ||
19 | |||
20 | Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
21 | Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> | ||
22 | --- | ||
23 | Documentation/DocBook/media-entities.tmpl | 8 + | ||
24 | Documentation/DocBook/v4l/media-controller.xml | 2 + | ||
25 | .../DocBook/v4l/media-ioc-device-info.xml | 3 +- | ||
26 | .../DocBook/v4l/media-ioc-enum-entities.xml | 308 ++++++++++++++++++++ | ||
27 | Documentation/DocBook/v4l/media-ioc-enum-links.xml | 202 +++++++++++++ | ||
28 | drivers/media/media-device.c | 123 ++++++++ | ||
29 | include/linux/media.h | 85 ++++++ | ||
30 | include/media/media-entity.h | 24 +-- | ||
31 | 8 files changed, 731 insertions(+), 24 deletions(-) | ||
32 | create mode 100644 Documentation/DocBook/v4l/media-ioc-enum-entities.xml | ||
33 | create mode 100644 Documentation/DocBook/v4l/media-ioc-enum-links.xml | ||
34 | |||
35 | diff --git a/Documentation/DocBook/media-entities.tmpl b/Documentation/DocBook/media-entities.tmpl | ||
36 | index 6af3375..6e7dae4 100644 | ||
37 | --- a/Documentation/DocBook/media-entities.tmpl | ||
38 | +++ b/Documentation/DocBook/media-entities.tmpl | ||
39 | @@ -92,6 +92,8 @@ | ||
40 | <!ENTITY VIDIOC-UNSUBSCRIBE-EVENT "<link linkend='vidioc-subscribe-event'><constant>VIDIOC_UNSUBSCRIBE_EVENT</constant></link>"> | ||
41 | |||
42 | <!ENTITY MEDIA-IOC-DEVICE-INFO "<link linkend='media-ioc-device-info'><constant>MEDIA_IOC_DEVICE_INFO</constant></link>"> | ||
43 | +<!ENTITY MEDIA-IOC-ENUM-ENTITIES "<link linkend='media-ioc-enum-entities'><constant>MEDIA_IOC_ENUM_ENTITIES</constant></link>"> | ||
44 | +<!ENTITY MEDIA-IOC-ENUM-LINKS "<link linkend='media-ioc-enum-links'><constant>MEDIA_IOC_ENUM_LINKS</constant></link>"> | ||
45 | |||
46 | <!-- Types --> | ||
47 | <!ENTITY v4l2-std-id "<link linkend='v4l2-std-id'>v4l2_std_id</link>"> | ||
48 | @@ -188,6 +190,10 @@ | ||
49 | <!ENTITY v4l2-window "struct <link linkend='v4l2-window'>v4l2_window</link>"> | ||
50 | |||
51 | <!ENTITY media-device-info "struct <link linkend='media-device-info'>media_device_info</link>"> | ||
52 | +<!ENTITY media-entity-desc "struct <link linkend='media-entity-desc'>media_entity_desc</link>"> | ||
53 | +<!ENTITY media-links-enum "struct <link linkend='media-links-enum'>media_links_enum</link>"> | ||
54 | +<!ENTITY media-pad-desc "struct <link linkend='media-pad-desc'>media_pad_desc</link>"> | ||
55 | +<!ENTITY media-link-desc "struct <link linkend='media-link-desc'>media_link_desc</link>"> | ||
56 | |||
57 | <!-- Error Codes --> | ||
58 | <!ENTITY EACCES "<errorcode>EACCES</errorcode> error code"> | ||
59 | @@ -334,6 +340,8 @@ | ||
60 | <!ENTITY sub-media-close SYSTEM "v4l/media-func-close.xml"> | ||
61 | <!ENTITY sub-media-ioctl SYSTEM "v4l/media-func-ioctl.xml"> | ||
62 | <!ENTITY sub-media-ioc-device-info SYSTEM "v4l/media-ioc-device-info.xml"> | ||
63 | +<!ENTITY sub-media-ioc-enum-entities SYSTEM "v4l/media-ioc-enum-entities.xml"> | ||
64 | +<!ENTITY sub-media-ioc-enum-links SYSTEM "v4l/media-ioc-enum-links.xml"> | ||
65 | |||
66 | <!-- Function Reference --> | ||
67 | <!ENTITY close SYSTEM "v4l/func-close.xml"> | ||
68 | diff --git a/Documentation/DocBook/v4l/media-controller.xml b/Documentation/DocBook/v4l/media-controller.xml | ||
69 | index a46b786..2c4fd2b 100644 | ||
70 | --- a/Documentation/DocBook/v4l/media-controller.xml | ||
71 | +++ b/Documentation/DocBook/v4l/media-controller.xml | ||
72 | @@ -83,4 +83,6 @@ | ||
73 | &sub-media-ioctl; | ||
74 | <!-- All ioctls go here. --> | ||
75 | &sub-media-ioc-device-info; | ||
76 | + &sub-media-ioc-enum-entities; | ||
77 | + &sub-media-ioc-enum-links; | ||
78 | </appendix> | ||
79 | diff --git a/Documentation/DocBook/v4l/media-ioc-device-info.xml b/Documentation/DocBook/v4l/media-ioc-device-info.xml | ||
80 | index 278a312..1f32373 100644 | ||
81 | --- a/Documentation/DocBook/v4l/media-ioc-device-info.xml | ||
82 | +++ b/Documentation/DocBook/v4l/media-ioc-device-info.xml | ||
83 | @@ -27,7 +27,8 @@ | ||
84 | <varlistentry> | ||
85 | <term><parameter>fd</parameter></term> | ||
86 | <listitem> | ||
87 | - <para>&fd;</para> | ||
88 | + <para>File descriptor returned by | ||
89 | + <link linkend='media-func-open'><function>open()</function></link>.</para> | ||
90 | </listitem> | ||
91 | </varlistentry> | ||
92 | <varlistentry> | ||
93 | diff --git a/Documentation/DocBook/v4l/media-ioc-enum-entities.xml b/Documentation/DocBook/v4l/media-ioc-enum-entities.xml | ||
94 | new file mode 100644 | ||
95 | index 0000000..13d0cc4 | ||
96 | --- /dev/null | ||
97 | +++ b/Documentation/DocBook/v4l/media-ioc-enum-entities.xml | ||
98 | @@ -0,0 +1,308 @@ | ||
99 | +<refentry id="media-ioc-enum-entities"> | ||
100 | + <refmeta> | ||
101 | + <refentrytitle>ioctl MEDIA_IOC_ENUM_ENTITIES</refentrytitle> | ||
102 | + &manvol; | ||
103 | + </refmeta> | ||
104 | + | ||
105 | + <refnamediv> | ||
106 | + <refname>MEDIA_IOC_ENUM_ENTITIES</refname> | ||
107 | + <refpurpose>Enumerate entities and their properties</refpurpose> | ||
108 | + </refnamediv> | ||
109 | + | ||
110 | + <refsynopsisdiv> | ||
111 | + <funcsynopsis> | ||
112 | + <funcprototype> | ||
113 | + <funcdef>int <function>ioctl</function></funcdef> | ||
114 | + <paramdef>int <parameter>fd</parameter></paramdef> | ||
115 | + <paramdef>int <parameter>request</parameter></paramdef> | ||
116 | + <paramdef>struct media_entity_desc *<parameter>argp</parameter></paramdef> | ||
117 | + </funcprototype> | ||
118 | + </funcsynopsis> | ||
119 | + </refsynopsisdiv> | ||
120 | + | ||
121 | + <refsect1> | ||
122 | + <title>Arguments</title> | ||
123 | + | ||
124 | + <variablelist> | ||
125 | + <varlistentry> | ||
126 | + <term><parameter>fd</parameter></term> | ||
127 | + <listitem> | ||
128 | + <para>File descriptor returned by | ||
129 | + <link linkend='media-func-open'><function>open()</function></link>.</para> | ||
130 | + </listitem> | ||
131 | + </varlistentry> | ||
132 | + <varlistentry> | ||
133 | + <term><parameter>request</parameter></term> | ||
134 | + <listitem> | ||
135 | + <para>MEDIA_IOC_ENUM_ENTITIES</para> | ||
136 | + </listitem> | ||
137 | + </varlistentry> | ||
138 | + <varlistentry> | ||
139 | + <term><parameter>argp</parameter></term> | ||
140 | + <listitem> | ||
141 | + <para></para> | ||
142 | + </listitem> | ||
143 | + </varlistentry> | ||
144 | + </variablelist> | ||
145 | + </refsect1> | ||
146 | + | ||
147 | + <refsect1> | ||
148 | + <title>Description</title> | ||
149 | + <para>To query the attributes of an entity, applications set the id field | ||
150 | + of a &media-entity-desc; structure and call the MEDIA_IOC_ENUM_ENTITIES | ||
151 | + ioctl with a pointer to this structure. The driver fills the rest of the | ||
152 | + structure or returns an &EINVAL; when the id is invalid.</para> | ||
153 | + <para>Entities can be enumerated by or'ing the id with the | ||
154 | + <constant>MEDIA_ENT_ID_FLAG_NEXT</constant> flag. The driver will return | ||
155 | + information about the entity with the smallest id strictly larger than the | ||
156 | + requested one ('next entity'), or the &EINVAL; if there is none.</para> | ||
157 | + <para>Entity IDs can be non-contiguous. Applications must | ||
158 | + <emphasis>not</emphasis> try to enumerate entities by calling | ||
159 | + MEDIA_IOC_ENUM_ENTITIES with increasing id's until they get an error.</para> | ||
160 | + <para>Two or more entities that share a common non-zero | ||
161 | + <structfield>group_id</structfield> value are considered as logically | ||
162 | + grouped. Groups are used to report | ||
163 | + <itemizedlist> | ||
164 | + <listitem>ALSA, VBI and video nodes that carry the same media | ||
165 | + stream</listitem> | ||
166 | + <listitem>lens and flash controllers associated with a sensor</listitem> | ||
167 | + </itemizedlist> | ||
168 | + </para> | ||
169 | + | ||
170 | + <table pgwide="1" frame="none" id="media-entity-desc"> | ||
171 | + <title>struct <structname>media_entity_desc</structname></title> | ||
172 | + <tgroup cols="5"> | ||
173 | + <colspec colname="c1" /> | ||
174 | + <colspec colname="c2" /> | ||
175 | + <colspec colname="c3" /> | ||
176 | + <colspec colname="c4" /> | ||
177 | + <colspec colname="c5" /> | ||
178 | + <tbody valign="top"> | ||
179 | + <row> | ||
180 | + <entry>__u32</entry> | ||
181 | + <entry><structfield>id</structfield></entry> | ||
182 | + <entry></entry> | ||
183 | + <entry></entry> | ||
184 | + <entry>Entity id, set by the application. When the id is or'ed with | ||
185 | + <constant>MEDIA_ENT_ID_FLAG_NEXT</constant>, the driver clears the | ||
186 | + flag and returns the first entity with a larger id.</entry> | ||
187 | + </row> | ||
188 | + <row> | ||
189 | + <entry>char</entry> | ||
190 | + <entry><structfield>name</structfield>[32]</entry> | ||
191 | + <entry></entry> | ||
192 | + <entry></entry> | ||
193 | + <entry>Entity name as an UTF-8 NULL-terminated string.</entry> | ||
194 | + </row> | ||
195 | + <row> | ||
196 | + <entry>__u32</entry> | ||
197 | + <entry><structfield>type</structfield></entry> | ||
198 | + <entry></entry> | ||
199 | + <entry></entry> | ||
200 | + <entry>Entity type, see <xref linkend="media-entity-type" /> for details.</entry> | ||
201 | + </row> | ||
202 | + <row> | ||
203 | + <entry>__u32</entry> | ||
204 | + <entry><structfield>revision</structfield></entry> | ||
205 | + <entry></entry> | ||
206 | + <entry></entry> | ||
207 | + <entry>Entity revision in a driver/hardware specific format.</entry> | ||
208 | + </row> | ||
209 | + <row> | ||
210 | + <entry>__u32</entry> | ||
211 | + <entry><structfield>flags</structfield></entry> | ||
212 | + <entry></entry> | ||
213 | + <entry></entry> | ||
214 | + <entry>Entity flags, see <xref linkend="media-entity-flag" /> for details.</entry> | ||
215 | + </row> | ||
216 | + <row> | ||
217 | + <entry>__u32</entry> | ||
218 | + <entry><structfield>group_id</structfield></entry> | ||
219 | + <entry></entry> | ||
220 | + <entry></entry> | ||
221 | + <entry>Entity group ID</entry> | ||
222 | + </row> | ||
223 | + <row> | ||
224 | + <entry>__u16</entry> | ||
225 | + <entry><structfield>pads</structfield></entry> | ||
226 | + <entry></entry> | ||
227 | + <entry></entry> | ||
228 | + <entry>Number of pads</entry> | ||
229 | + </row> | ||
230 | + <row> | ||
231 | + <entry>__u16</entry> | ||
232 | + <entry><structfield>links</structfield></entry> | ||
233 | + <entry></entry> | ||
234 | + <entry></entry> | ||
235 | + <entry>Total number of outbound links. Inbound links are not counted | ||
236 | + in this field.</entry> | ||
237 | + </row> | ||
238 | + <row> | ||
239 | + <entry>union</entry> | ||
240 | + </row> | ||
241 | + <row> | ||
242 | + <entry></entry> | ||
243 | + <entry>struct</entry> | ||
244 | + <entry><structfield>v4l</structfield></entry> | ||
245 | + <entry></entry> | ||
246 | + <entry>Valid for V4L sub-devices and nodes only.</entry> | ||
247 | + </row> | ||
248 | + <row> | ||
249 | + <entry></entry> | ||
250 | + <entry></entry> | ||
251 | + <entry>__u32</entry> | ||
252 | + <entry><structfield>major</structfield></entry> | ||
253 | + <entry>V4L device node major number. For V4L sub-devices with no | ||
254 | + device node, set by the driver to 0.</entry> | ||
255 | + </row> | ||
256 | + <row> | ||
257 | + <entry></entry> | ||
258 | + <entry></entry> | ||
259 | + <entry>__u32</entry> | ||
260 | + <entry><structfield>minor</structfield></entry> | ||
261 | + <entry>V4L device node minor number. For V4L sub-devices with no | ||
262 | + device node, set by the driver to 0.</entry> | ||
263 | + </row> | ||
264 | + <row> | ||
265 | + <entry></entry> | ||
266 | + <entry>struct</entry> | ||
267 | + <entry><structfield>fb</structfield></entry> | ||
268 | + <entry></entry> | ||
269 | + <entry>Valid for frame buffer nodes only.</entry> | ||
270 | + </row> | ||
271 | + <row> | ||
272 | + <entry></entry> | ||
273 | + <entry></entry> | ||
274 | + <entry>__u32</entry> | ||
275 | + <entry><structfield>major</structfield></entry> | ||
276 | + <entry>Frame buffer device node major number.</entry> | ||
277 | + </row> | ||
278 | + <row> | ||
279 | + <entry></entry> | ||
280 | + <entry></entry> | ||
281 | + <entry>__u32</entry> | ||
282 | + <entry><structfield>minor</structfield></entry> | ||
283 | + <entry>Frame buffer device node minor number.</entry> | ||
284 | + </row> | ||
285 | + <row> | ||
286 | + <entry></entry> | ||
287 | + <entry>struct</entry> | ||
288 | + <entry><structfield>alsa</structfield></entry> | ||
289 | + <entry></entry> | ||
290 | + <entry>Valid for ALSA devices only.</entry> | ||
291 | + </row> | ||
292 | + <row> | ||
293 | + <entry></entry> | ||
294 | + <entry></entry> | ||
295 | + <entry>__u32</entry> | ||
296 | + <entry><structfield>card</structfield></entry> | ||
297 | + <entry>ALSA card number</entry> | ||
298 | + </row> | ||
299 | + <row> | ||
300 | + <entry></entry> | ||
301 | + <entry></entry> | ||
302 | + <entry>__u32</entry> | ||
303 | + <entry><structfield>device</structfield></entry> | ||
304 | + <entry>ALSA device number</entry> | ||
305 | + </row> | ||
306 | + <row> | ||
307 | + <entry></entry> | ||
308 | + <entry></entry> | ||
309 | + <entry>__u32</entry> | ||
310 | + <entry><structfield>subdevice</structfield></entry> | ||
311 | + <entry>ALSA sub-device number</entry> | ||
312 | + </row> | ||
313 | + <row> | ||
314 | + <entry></entry> | ||
315 | + <entry>int</entry> | ||
316 | + <entry><structfield>dvb</structfield></entry> | ||
317 | + <entry></entry> | ||
318 | + <entry>DVB card number</entry> | ||
319 | + </row> | ||
320 | + <row> | ||
321 | + <entry></entry> | ||
322 | + <entry>__u8</entry> | ||
323 | + <entry><structfield>raw</structfield>[180]</entry> | ||
324 | + <entry></entry> | ||
325 | + <entry></entry> | ||
326 | + </row> | ||
327 | + </tbody> | ||
328 | + </tgroup> | ||
329 | + </table> | ||
330 | + | ||
331 | + <table frame="none" pgwide="1" id="media-entity-type"> | ||
332 | + <title>Media entity types</title> | ||
333 | + <tgroup cols="2"> | ||
334 | + <colspec colname="c1"/> | ||
335 | + <colspec colname="c2"/> | ||
336 | + <tbody valign="top"> | ||
337 | + <row> | ||
338 | + <entry><constant>MEDIA_ENT_T_DEVNODE</constant></entry> | ||
339 | + <entry>Unknown device node</entry> | ||
340 | + </row> | ||
341 | + <row> | ||
342 | + <entry><constant>MEDIA_ENT_T_DEVNODE_V4L</constant></entry> | ||
343 | + <entry>V4L video, radio or vbi device node</entry> | ||
344 | + </row> | ||
345 | + <row> | ||
346 | + <entry><constant>MEDIA_ENT_T_DEVNODE_FB</constant></entry> | ||
347 | + <entry>Frame buffer device node</entry> | ||
348 | + </row> | ||
349 | + <row> | ||
350 | + <entry><constant>MEDIA_ENT_T_DEVNODE_ALSA</constant></entry> | ||
351 | + <entry>ALSA card</entry> | ||
352 | + </row> | ||
353 | + <row> | ||
354 | + <entry><constant>MEDIA_ENT_T_DEVNODE_DVB</constant></entry> | ||
355 | + <entry>DVB card</entry> | ||
356 | + </row> | ||
357 | + <row> | ||
358 | + <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV</constant></entry> | ||
359 | + <entry>Unknown V4L sub-device</entry> | ||
360 | + </row> | ||
361 | + <row> | ||
362 | + <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_SENSOR</constant></entry> | ||
363 | + <entry>Video sensor</entry> | ||
364 | + </row> | ||
365 | + <row> | ||
366 | + <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_FLASH</constant></entry> | ||
367 | + <entry>Flash controller</entry> | ||
368 | + </row> | ||
369 | + <row> | ||
370 | + <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_LENS</constant></entry> | ||
371 | + <entry>Lens controller</entry> | ||
372 | + </row> | ||
373 | + </tbody> | ||
374 | + </tgroup> | ||
375 | + </table> | ||
376 | + | ||
377 | + <table frame="none" pgwide="1" id="media-entity-flag"> | ||
378 | + <title>Media entity flags</title> | ||
379 | + <tgroup cols="2"> | ||
380 | + <colspec colname="c1"/> | ||
381 | + <colspec colname="c2"/> | ||
382 | + <tbody valign="top"> | ||
383 | + <row> | ||
384 | + <entry><constant>MEDIA_ENT_FL_DEFAULT</constant></entry> | ||
385 | + <entry>Default entity for its type. Used to discover the default | ||
386 | + audio, VBI and video devices, the default camera sensor, ...</entry> | ||
387 | + </row> | ||
388 | + </tbody> | ||
389 | + </tgroup> | ||
390 | + </table> | ||
391 | + </refsect1> | ||
392 | + | ||
393 | + <refsect1> | ||
394 | + &return-value; | ||
395 | + | ||
396 | + <variablelist> | ||
397 | + <varlistentry> | ||
398 | + <term><errorcode>EINVAL</errorcode></term> | ||
399 | + <listitem> | ||
400 | + <para>The &media-entity-desc; <structfield>id</structfield> references | ||
401 | + a non-existing entity.</para> | ||
402 | + </listitem> | ||
403 | + </varlistentry> | ||
404 | + </variablelist> | ||
405 | + </refsect1> | ||
406 | +</refentry> | ||
407 | diff --git a/Documentation/DocBook/v4l/media-ioc-enum-links.xml b/Documentation/DocBook/v4l/media-ioc-enum-links.xml | ||
408 | new file mode 100644 | ||
409 | index 0000000..daf0360 | ||
410 | --- /dev/null | ||
411 | +++ b/Documentation/DocBook/v4l/media-ioc-enum-links.xml | ||
412 | @@ -0,0 +1,202 @@ | ||
413 | +<refentry id="media-ioc-enum-links"> | ||
414 | + <refmeta> | ||
415 | + <refentrytitle>ioctl MEDIA_IOC_ENUM_LINKS</refentrytitle> | ||
416 | + &manvol; | ||
417 | + </refmeta> | ||
418 | + | ||
419 | + <refnamediv> | ||
420 | + <refname>MEDIA_IOC_ENUM_LINKS</refname> | ||
421 | + <refpurpose>Enumerate all pads and links for a given entity</refpurpose> | ||
422 | + </refnamediv> | ||
423 | + | ||
424 | + <refsynopsisdiv> | ||
425 | + <funcsynopsis> | ||
426 | + <funcprototype> | ||
427 | + <funcdef>int <function>ioctl</function></funcdef> | ||
428 | + <paramdef>int <parameter>fd</parameter></paramdef> | ||
429 | + <paramdef>int <parameter>request</parameter></paramdef> | ||
430 | + <paramdef>struct media_links_enum *<parameter>argp</parameter></paramdef> | ||
431 | + </funcprototype> | ||
432 | + </funcsynopsis> | ||
433 | + </refsynopsisdiv> | ||
434 | + | ||
435 | + <refsect1> | ||
436 | + <title>Arguments</title> | ||
437 | + | ||
438 | + <variablelist> | ||
439 | + <varlistentry> | ||
440 | + <term><parameter>fd</parameter></term> | ||
441 | + <listitem> | ||
442 | + <para>File descriptor returned by | ||
443 | + <link linkend='media-func-open'><function>open()</function></link>.</para> | ||
444 | + </listitem> | ||
445 | + </varlistentry> | ||
446 | + <varlistentry> | ||
447 | + <term><parameter>request</parameter></term> | ||
448 | + <listitem> | ||
449 | + <para>MEDIA_IOC_ENUM_LINKS</para> | ||
450 | + </listitem> | ||
451 | + </varlistentry> | ||
452 | + <varlistentry> | ||
453 | + <term><parameter>argp</parameter></term> | ||
454 | + <listitem> | ||
455 | + <para></para> | ||
456 | + </listitem> | ||
457 | + </varlistentry> | ||
458 | + </variablelist> | ||
459 | + </refsect1> | ||
460 | + | ||
461 | + <refsect1> | ||
462 | + <title>Description</title> | ||
463 | + | ||
464 | + <para>To enumerate pads and/or links for a given entity, applications set | ||
465 | + the entity field of a &media-links-enum; structure and initialize the | ||
466 | + &media-pad-desc; and &media-link-desc; structure arrays pointed by the | ||
467 | + <structfield>pads</structfield> and <structfield>links</structfield> fields. | ||
468 | + They then call the MEDIA_IOC_ENUM_LINKS ioctl with a pointer to this | ||
469 | + structure.</para> | ||
470 | + <para>If the <structfield>pads</structfield> field is not NULL, the driver | ||
471 | + fills the <structfield>pads</structfield> array with information about the | ||
472 | + entity's pads. The array must have enough room to store all the entity's | ||
473 | + pads. The number of pads can be retrieved with the &MEDIA-IOC-ENUM-ENTITIES; | ||
474 | + ioctl.</para> | ||
475 | + <para>If the <structfield>links</structfield> field is not NULL, the driver | ||
476 | + fills the <structfield>links</structfield> array with information about the | ||
477 | + entity's outbound links. The array must have enough room to store all the | ||
478 | + entity's outbound links. The number of outbound links can be retrieved with | ||
479 | + the &MEDIA-IOC-ENUM-ENTITIES; ioctl.</para> | ||
480 | + <para>Only forward links that originate at one of the entity's source pads | ||
481 | + are returned during the enumeration process.</para> | ||
482 | + | ||
483 | + <table pgwide="1" frame="none" id="media-links-enum"> | ||
484 | + <title>struct <structname>media_links_enum</structname></title> | ||
485 | + <tgroup cols="3"> | ||
486 | + &cs-str; | ||
487 | + <tbody valign="top"> | ||
488 | + <row> | ||
489 | + <entry>__u32</entry> | ||
490 | + <entry><structfield>entity</structfield></entry> | ||
491 | + <entry>Entity id, set by the application.</entry> | ||
492 | + </row> | ||
493 | + <row> | ||
494 | + <entry>struct &media-pad-desc;</entry> | ||
495 | + <entry>*<structfield>pads</structfield></entry> | ||
496 | + <entry>Pointer to a pads array allocated by the application. Ignored | ||
497 | + if NULL.</entry> | ||
498 | + </row> | ||
499 | + <row> | ||
500 | + <entry>struct &media-link-desc;</entry> | ||
501 | + <entry>*<structfield>links</structfield></entry> | ||
502 | + <entry>Pointer to a links array allocated by the application. Ignored | ||
503 | + if NULL.</entry> | ||
504 | + </row> | ||
505 | + </tbody> | ||
506 | + </tgroup> | ||
507 | + </table> | ||
508 | + | ||
509 | + <table pgwide="1" frame="none" id="media-pad-desc"> | ||
510 | + <title>struct <structname>media_pad_desc</structname></title> | ||
511 | + <tgroup cols="3"> | ||
512 | + &cs-str; | ||
513 | + <tbody valign="top"> | ||
514 | + <row> | ||
515 | + <entry>__u32</entry> | ||
516 | + <entry><structfield>entity</structfield></entry> | ||
517 | + <entry>ID of the entity this pad belongs to.</entry> | ||
518 | + </row> | ||
519 | + <row> | ||
520 | + <entry>__u16</entry> | ||
521 | + <entry><structfield>index</structfield></entry> | ||
522 | + <entry>0-based pad index.</entry> | ||
523 | + </row> | ||
524 | + <row> | ||
525 | + <entry>__u32</entry> | ||
526 | + <entry><structfield>flags</structfield></entry> | ||
527 | + <entry>Pad flags, see <xref linkend="media-pad-flag" /> for more details.</entry> | ||
528 | + </row> | ||
529 | + </tbody> | ||
530 | + </tgroup> | ||
531 | + </table> | ||
532 | + | ||
533 | + <table frame="none" pgwide="1" id="media-pad-flag"> | ||
534 | + <title>Media pad flags</title> | ||
535 | + <tgroup cols="2"> | ||
536 | + <colspec colname="c1"/> | ||
537 | + <colspec colname="c2"/> | ||
538 | + <tbody valign="top"> | ||
539 | + <row> | ||
540 | + <entry><constant>MEDIA_PAD_FL_INPUT</constant></entry> | ||
541 | + <entry>Input pad, relative to the entity. Input pads sink data and | ||
542 | + are targets of links.</entry> | ||
543 | + </row> | ||
544 | + <row> | ||
545 | + <entry><constant>MEDIA_PAD_FL_OUTPUT</constant></entry> | ||
546 | + <entry>Output pad, relative to the entity. Output pads source data | ||
547 | + and are origins of links.</entry> | ||
548 | + </row> | ||
549 | + </tbody> | ||
550 | + </tgroup> | ||
551 | + </table> | ||
552 | + | ||
553 | + <table pgwide="1" frame="none" id="media-link-desc"> | ||
554 | + <title>struct <structname>media_links_enum</structname></title> | ||
555 | + <tgroup cols="3"> | ||
556 | + &cs-str; | ||
557 | + <tbody valign="top"> | ||
558 | + <row> | ||
559 | + <entry>struct &media-pad-desc;</entry> | ||
560 | + <entry><structfield>source</structfield></entry> | ||
561 | + <entry>Pad at the origin of this link.</entry> | ||
562 | + </row> | ||
563 | + <row> | ||
564 | + <entry>struct &media-pad-desc;</entry> | ||
565 | + <entry><structfield>sink</structfield></entry> | ||
566 | + <entry>Pad at the target of this link.</entry> | ||
567 | + </row> | ||
568 | + <row> | ||
569 | + <entry>__u32</entry> | ||
570 | + <entry><structfield>flags</structfield></entry> | ||
571 | + <entry>Link flags, see <xref linkend="media-link-flag" /> for more details.</entry> | ||
572 | + </row> | ||
573 | + </tbody> | ||
574 | + </tgroup> | ||
575 | + </table> | ||
576 | + | ||
577 | + <table frame="none" pgwide="1" id="media-link-flag"> | ||
578 | + <title>Media link flags</title> | ||
579 | + <tgroup cols="2"> | ||
580 | + <colspec colname="c1"/> | ||
581 | + <colspec colname="c2"/> | ||
582 | + <tbody valign="top"> | ||
583 | + <row> | ||
584 | + <entry><constant>MEDIA_LNK_FL_ENABLED</constant></entry> | ||
585 | + <entry>The link is enabled and can be used to transfer media data. | ||
586 | + When two or more links target a sink pad, only one of them can be | ||
587 | + enabled at a time.</entry> | ||
588 | + </row> | ||
589 | + <row> | ||
590 | + <entry><constant>MEDIA_LNK_FL_IMMUTABLE</constant></entry> | ||
591 | + <entry>The link enabled state can't be modified at runtime. An | ||
592 | + immutable link is always enabled.</entry> | ||
593 | + </row> | ||
594 | + </tbody> | ||
595 | + </tgroup> | ||
596 | + </table> | ||
597 | + <para>One and only one of <constant>MEDIA_PAD_FL_INPUT</constant> and | ||
598 | + <constant>MEDIA_PAD_FL_OUTPUT</constant> must be set for every pad.</para> | ||
599 | + </refsect1> | ||
600 | + | ||
601 | + <refsect1> | ||
602 | + &return-value; | ||
603 | + | ||
604 | + <variablelist> | ||
605 | + <varlistentry> | ||
606 | + <term><errorcode>EINVAL</errorcode></term> | ||
607 | + <listitem> | ||
608 | + <para>The &media-links-enum; <structfield>id</structfield> references | ||
609 | + a non-existing entity.</para> | ||
610 | + </listitem> | ||
611 | + </varlistentry> | ||
612 | + </variablelist> | ||
613 | + </refsect1> | ||
614 | +</refentry> | ||
615 | diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c | ||
616 | index 5c745be..1f46acb 100644 | ||
617 | --- a/drivers/media/media-device.c | ||
618 | +++ b/drivers/media/media-device.c | ||
619 | @@ -61,6 +61,117 @@ static int media_device_get_info(struct media_device *dev, | ||
620 | return copy_to_user(__info, &info, sizeof(*__info)); | ||
621 | } | ||
622 | |||
623 | +static struct media_entity *find_entity(struct media_device *mdev, u32 id) | ||
624 | +{ | ||
625 | + struct media_entity *entity; | ||
626 | + int next = id & MEDIA_ENT_ID_FLAG_NEXT; | ||
627 | + | ||
628 | + id &= ~MEDIA_ENT_ID_FLAG_NEXT; | ||
629 | + | ||
630 | + spin_lock(&mdev->lock); | ||
631 | + | ||
632 | + media_device_for_each_entity(entity, mdev) { | ||
633 | + if ((entity->id == id && !next) || | ||
634 | + (entity->id > id && next)) { | ||
635 | + spin_unlock(&mdev->lock); | ||
636 | + return entity; | ||
637 | + } | ||
638 | + } | ||
639 | + | ||
640 | + spin_unlock(&mdev->lock); | ||
641 | + | ||
642 | + return NULL; | ||
643 | +} | ||
644 | + | ||
645 | +static long media_device_enum_entities(struct media_device *mdev, | ||
646 | + struct media_entity_desc __user *uent) | ||
647 | +{ | ||
648 | + struct media_entity *ent; | ||
649 | + struct media_entity_desc u_ent; | ||
650 | + | ||
651 | + if (copy_from_user(&u_ent.id, &uent->id, sizeof(u_ent.id))) | ||
652 | + return -EFAULT; | ||
653 | + | ||
654 | + ent = find_entity(mdev, u_ent.id); | ||
655 | + | ||
656 | + if (ent == NULL) | ||
657 | + return -EINVAL; | ||
658 | + | ||
659 | + u_ent.id = ent->id; | ||
660 | + u_ent.name[0] = '\0'; | ||
661 | + if (ent->name) | ||
662 | + strlcpy(u_ent.name, ent->name, sizeof(u_ent.name)); | ||
663 | + u_ent.type = ent->type; | ||
664 | + u_ent.revision = ent->revision; | ||
665 | + u_ent.flags = ent->flags; | ||
666 | + u_ent.group_id = ent->group_id; | ||
667 | + u_ent.pads = ent->num_pads; | ||
668 | + u_ent.links = ent->num_links - ent->num_backlinks; | ||
669 | + u_ent.v4l.major = ent->v4l.major; | ||
670 | + u_ent.v4l.minor = ent->v4l.minor; | ||
671 | + if (copy_to_user(uent, &u_ent, sizeof(u_ent))) | ||
672 | + return -EFAULT; | ||
673 | + return 0; | ||
674 | +} | ||
675 | + | ||
676 | +static void media_device_kpad_to_upad(const struct media_pad *kpad, | ||
677 | + struct media_pad_desc *upad) | ||
678 | +{ | ||
679 | + upad->entity = kpad->entity->id; | ||
680 | + upad->index = kpad->index; | ||
681 | + upad->flags = kpad->flags; | ||
682 | +} | ||
683 | + | ||
684 | +static long media_device_enum_links(struct media_device *mdev, | ||
685 | + struct media_links_enum __user *ulinks) | ||
686 | +{ | ||
687 | + struct media_entity *entity; | ||
688 | + struct media_links_enum links; | ||
689 | + | ||
690 | + if (copy_from_user(&links, ulinks, sizeof(links))) | ||
691 | + return -EFAULT; | ||
692 | + | ||
693 | + entity = find_entity(mdev, links.entity); | ||
694 | + if (entity == NULL) | ||
695 | + return -EINVAL; | ||
696 | + | ||
697 | + if (links.pads) { | ||
698 | + unsigned int p; | ||
699 | + | ||
700 | + for (p = 0; p < entity->num_pads; p++) { | ||
701 | + struct media_pad_desc pad; | ||
702 | + media_device_kpad_to_upad(&entity->pads[p], &pad); | ||
703 | + if (copy_to_user(&links.pads[p], &pad, sizeof(pad))) | ||
704 | + return -EFAULT; | ||
705 | + } | ||
706 | + } | ||
707 | + | ||
708 | + if (links.links) { | ||
709 | + struct media_link_desc __user *ulink; | ||
710 | + unsigned int l; | ||
711 | + | ||
712 | + for (l = 0, ulink = links.links; l < entity->num_links; l++) { | ||
713 | + struct media_link_desc link; | ||
714 | + | ||
715 | + /* Ignore backlinks. */ | ||
716 | + if (entity->links[l].source->entity != entity) | ||
717 | + continue; | ||
718 | + | ||
719 | + media_device_kpad_to_upad(entity->links[l].source, | ||
720 | + &link.source); | ||
721 | + media_device_kpad_to_upad(entity->links[l].sink, | ||
722 | + &link.sink); | ||
723 | + link.flags = entity->links[l].flags; | ||
724 | + if (copy_to_user(ulink, &link, sizeof(*ulink))) | ||
725 | + return -EFAULT; | ||
726 | + ulink++; | ||
727 | + } | ||
728 | + } | ||
729 | + if (copy_to_user(ulinks, &links, sizeof(*ulinks))) | ||
730 | + return -EFAULT; | ||
731 | + return 0; | ||
732 | +} | ||
733 | + | ||
734 | static long media_device_ioctl(struct file *filp, unsigned int cmd, | ||
735 | unsigned long arg) | ||
736 | { | ||
737 | @@ -74,6 +185,18 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd, | ||
738 | (struct media_device_info __user *)arg); | ||
739 | break; | ||
740 | |||
741 | + case MEDIA_IOC_ENUM_ENTITIES: | ||
742 | + ret = media_device_enum_entities(dev, | ||
743 | + (struct media_entity_desc __user *)arg); | ||
744 | + break; | ||
745 | + | ||
746 | + case MEDIA_IOC_ENUM_LINKS: | ||
747 | + mutex_lock(&dev->graph_mutex); | ||
748 | + ret = media_device_enum_links(dev, | ||
749 | + (struct media_links_enum __user *)arg); | ||
750 | + mutex_unlock(&dev->graph_mutex); | ||
751 | + break; | ||
752 | + | ||
753 | default: | ||
754 | ret = -ENOIOCTLCMD; | ||
755 | } | ||
756 | diff --git a/include/linux/media.h b/include/linux/media.h | ||
757 | index 4c52f08..64c0313 100644 | ||
758 | --- a/include/linux/media.h | ||
759 | +++ b/include/linux/media.h | ||
760 | @@ -40,6 +40,91 @@ struct media_device_info { | ||
761 | __u32 reserved[31]; | ||
762 | }; | ||
763 | |||
764 | +#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) | ||
765 | + | ||
766 | +#define MEDIA_ENT_TYPE_SHIFT 16 | ||
767 | +#define MEDIA_ENT_TYPE_MASK 0x00ff0000 | ||
768 | +#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff | ||
769 | + | ||
770 | +#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT) | ||
771 | +#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1) | ||
772 | +#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) | ||
773 | +#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) | ||
774 | +#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) | ||
775 | + | ||
776 | +#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT) | ||
777 | +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1) | ||
778 | +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2) | ||
779 | +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3) | ||
780 | + | ||
781 | +#define MEDIA_ENT_FL_DEFAULT (1 << 0) | ||
782 | + | ||
783 | +struct media_entity_desc { | ||
784 | + __u32 id; | ||
785 | + char name[32]; | ||
786 | + __u32 type; | ||
787 | + __u32 revision; | ||
788 | + __u32 flags; | ||
789 | + __u32 group_id; | ||
790 | + __u16 pads; | ||
791 | + __u16 links; | ||
792 | + | ||
793 | + __u32 reserved[4]; | ||
794 | + | ||
795 | + union { | ||
796 | + /* Node specifications */ | ||
797 | + struct { | ||
798 | + __u32 major; | ||
799 | + __u32 minor; | ||
800 | + } v4l; | ||
801 | + struct { | ||
802 | + __u32 major; | ||
803 | + __u32 minor; | ||
804 | + } fb; | ||
805 | + struct { | ||
806 | + __u32 card; | ||
807 | + __u32 device; | ||
808 | + __u32 subdevice; | ||
809 | + } alsa; | ||
810 | + int dvb; | ||
811 | + | ||
812 | + /* Sub-device specifications */ | ||
813 | + /* Nothing needed yet */ | ||
814 | + __u8 raw[184]; | ||
815 | + }; | ||
816 | +}; | ||
817 | + | ||
818 | +#define MEDIA_PAD_FL_INPUT (1 << 0) | ||
819 | +#define MEDIA_PAD_FL_OUTPUT (1 << 1) | ||
820 | + | ||
821 | +struct media_pad_desc { | ||
822 | + __u32 entity; /* entity ID */ | ||
823 | + __u16 index; /* pad index */ | ||
824 | + __u32 flags; /* pad flags */ | ||
825 | + __u32 reserved[2]; | ||
826 | +}; | ||
827 | + | ||
828 | +#define MEDIA_LNK_FL_ENABLED (1 << 0) | ||
829 | +#define MEDIA_LNK_FL_IMMUTABLE (1 << 1) | ||
830 | + | ||
831 | +struct media_link_desc { | ||
832 | + struct media_pad_desc source; | ||
833 | + struct media_pad_desc sink; | ||
834 | + __u32 flags; | ||
835 | + __u32 reserved[2]; | ||
836 | +}; | ||
837 | + | ||
838 | +struct media_links_enum { | ||
839 | + __u32 entity; | ||
840 | + /* Should have enough room for pads elements */ | ||
841 | + struct media_pad_desc __user *pads; | ||
842 | + /* Should have enough room for links elements */ | ||
843 | + struct media_link_desc __user *links; | ||
844 | + __u32 reserved[4]; | ||
845 | +}; | ||
846 | + | ||
847 | #define MEDIA_IOC_DEVICE_INFO _IOWR('M', 1, struct media_device_info) | ||
848 | +#define MEDIA_IOC_ENUM_ENTITIES _IOWR('M', 2, struct media_entity_desc) | ||
849 | +#define MEDIA_IOC_ENUM_LINKS _IOWR('M', 3, struct media_links_enum) | ||
850 | |||
851 | #endif /* __LINUX_MEDIA_H */ | ||
852 | diff --git a/include/media/media-entity.h b/include/media/media-entity.h | ||
853 | index 114541a..0954490 100644 | ||
854 | --- a/include/media/media-entity.h | ||
855 | +++ b/include/media/media-entity.h | ||
856 | @@ -24,29 +24,7 @@ | ||
857 | #define _MEDIA_ENTITY_H | ||
858 | |||
859 | #include <linux/list.h> | ||
860 | - | ||
861 | -#define MEDIA_ENT_TYPE_SHIFT 16 | ||
862 | -#define MEDIA_ENT_TYPE_MASK 0x00ff0000 | ||
863 | -#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff | ||
864 | - | ||
865 | -#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENTITY_TYPE_SHIFT) | ||
866 | -#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENTITY_T_DEVNODE + 1) | ||
867 | -#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENTITY_T_DEVNODE + 2) | ||
868 | -#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENTITY_T_DEVNODE + 3) | ||
869 | -#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENTITY_T_DEVNODE + 4) | ||
870 | - | ||
871 | -#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENTITY_TYPE_SHIFT) | ||
872 | -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENTITY_T_V4L2_SUBDEV + 1) | ||
873 | -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENTITY_T_V4L2_SUBDEV + 2) | ||
874 | -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENTITY_T_V4L2_SUBDEV + 3) | ||
875 | - | ||
876 | -#define MEDIA_ENT_FL_DEFAULT (1 << 0) | ||
877 | - | ||
878 | -#define MEDIA_LNK_FL_ENABLED (1 << 0) | ||
879 | -#define MEDIA_LNK_FL_IMMUTABLE (1 << 1) | ||
880 | - | ||
881 | -#define MEDIA_PAD_FL_INPUT (1 << 0) | ||
882 | -#define MEDIA_PAD_FL_OUTPUT (1 << 1) | ||
883 | +#include <linux/media.h> | ||
884 | |||
885 | struct media_link { | ||
886 | struct media_pad *source; /* Source pad */ | ||
887 | -- | ||
888 | 1.6.6.1 | ||
889 | |||