diff options
-rw-r--r-- | Documentation/DocBook/media-entities.tmpl | 8 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/media-controller.xml | 2 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/media-ioc-device-info.xml | 3 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/media-ioc-enum-entities.xml | 308 | ||||
-rw-r--r-- | Documentation/DocBook/v4l/media-ioc-enum-links.xml | 202 | ||||
-rw-r--r-- | drivers/media/media-device.c | 123 | ||||
-rw-r--r-- | include/linux/media.h | 85 | ||||
-rw-r--r-- | include/media/media-entity.h | 24 |
8 files changed, 731 insertions, 24 deletions
diff --git a/Documentation/DocBook/media-entities.tmpl b/Documentation/DocBook/media-entities.tmpl index 034f891399ed..2bd7b27f8553 100644 --- a/Documentation/DocBook/media-entities.tmpl +++ b/Documentation/DocBook/media-entities.tmpl | |||
@@ -92,6 +92,8 @@ | |||
92 | <!ENTITY VIDIOC-UNSUBSCRIBE-EVENT "<link linkend='vidioc-subscribe-event'><constant>VIDIOC_UNSUBSCRIBE_EVENT</constant></link>"> | 92 | <!ENTITY VIDIOC-UNSUBSCRIBE-EVENT "<link linkend='vidioc-subscribe-event'><constant>VIDIOC_UNSUBSCRIBE_EVENT</constant></link>"> |
93 | 93 | ||
94 | <!ENTITY MEDIA-IOC-DEVICE-INFO "<link linkend='media-ioc-device-info'><constant>MEDIA_IOC_DEVICE_INFO</constant></link>"> | 94 | <!ENTITY MEDIA-IOC-DEVICE-INFO "<link linkend='media-ioc-device-info'><constant>MEDIA_IOC_DEVICE_INFO</constant></link>"> |
95 | <!ENTITY MEDIA-IOC-ENUM-ENTITIES "<link linkend='media-ioc-enum-entities'><constant>MEDIA_IOC_ENUM_ENTITIES</constant></link>"> | ||
96 | <!ENTITY MEDIA-IOC-ENUM-LINKS "<link linkend='media-ioc-enum-links'><constant>MEDIA_IOC_ENUM_LINKS</constant></link>"> | ||
95 | 97 | ||
96 | <!-- Types --> | 98 | <!-- Types --> |
97 | <!ENTITY v4l2-std-id "<link linkend='v4l2-std-id'>v4l2_std_id</link>"> | 99 | <!ENTITY v4l2-std-id "<link linkend='v4l2-std-id'>v4l2_std_id</link>"> |
@@ -191,6 +193,10 @@ | |||
191 | <!ENTITY v4l2-window "struct <link linkend='v4l2-window'>v4l2_window</link>"> | 193 | <!ENTITY v4l2-window "struct <link linkend='v4l2-window'>v4l2_window</link>"> |
192 | 194 | ||
193 | <!ENTITY media-device-info "struct <link linkend='media-device-info'>media_device_info</link>"> | 195 | <!ENTITY media-device-info "struct <link linkend='media-device-info'>media_device_info</link>"> |
196 | <!ENTITY media-entity-desc "struct <link linkend='media-entity-desc'>media_entity_desc</link>"> | ||
197 | <!ENTITY media-links-enum "struct <link linkend='media-links-enum'>media_links_enum</link>"> | ||
198 | <!ENTITY media-pad-desc "struct <link linkend='media-pad-desc'>media_pad_desc</link>"> | ||
199 | <!ENTITY media-link-desc "struct <link linkend='media-link-desc'>media_link_desc</link>"> | ||
194 | 200 | ||
195 | <!-- Error Codes --> | 201 | <!-- Error Codes --> |
196 | <!ENTITY EACCES "<errorcode>EACCES</errorcode> error code"> | 202 | <!ENTITY EACCES "<errorcode>EACCES</errorcode> error code"> |
@@ -340,6 +346,8 @@ | |||
340 | <!ENTITY sub-media-close SYSTEM "v4l/media-func-close.xml"> | 346 | <!ENTITY sub-media-close SYSTEM "v4l/media-func-close.xml"> |
341 | <!ENTITY sub-media-ioctl SYSTEM "v4l/media-func-ioctl.xml"> | 347 | <!ENTITY sub-media-ioctl SYSTEM "v4l/media-func-ioctl.xml"> |
342 | <!ENTITY sub-media-ioc-device-info SYSTEM "v4l/media-ioc-device-info.xml"> | 348 | <!ENTITY sub-media-ioc-device-info SYSTEM "v4l/media-ioc-device-info.xml"> |
349 | <!ENTITY sub-media-ioc-enum-entities SYSTEM "v4l/media-ioc-enum-entities.xml"> | ||
350 | <!ENTITY sub-media-ioc-enum-links SYSTEM "v4l/media-ioc-enum-links.xml"> | ||
343 | 351 | ||
344 | <!-- Function Reference --> | 352 | <!-- Function Reference --> |
345 | <!ENTITY close SYSTEM "v4l/func-close.xml"> | 353 | <!ENTITY close SYSTEM "v4l/func-close.xml"> |
diff --git a/Documentation/DocBook/v4l/media-controller.xml b/Documentation/DocBook/v4l/media-controller.xml index a46b786e9f2b..2c4fd2b27683 100644 --- a/Documentation/DocBook/v4l/media-controller.xml +++ b/Documentation/DocBook/v4l/media-controller.xml | |||
@@ -83,4 +83,6 @@ | |||
83 | &sub-media-ioctl; | 83 | &sub-media-ioctl; |
84 | <!-- All ioctls go here. --> | 84 | <!-- All ioctls go here. --> |
85 | &sub-media-ioc-device-info; | 85 | &sub-media-ioc-device-info; |
86 | &sub-media-ioc-enum-entities; | ||
87 | &sub-media-ioc-enum-links; | ||
86 | </appendix> | 88 | </appendix> |
diff --git a/Documentation/DocBook/v4l/media-ioc-device-info.xml b/Documentation/DocBook/v4l/media-ioc-device-info.xml index 278a3120ee2e..1f3237351bba 100644 --- a/Documentation/DocBook/v4l/media-ioc-device-info.xml +++ b/Documentation/DocBook/v4l/media-ioc-device-info.xml | |||
@@ -27,7 +27,8 @@ | |||
27 | <varlistentry> | 27 | <varlistentry> |
28 | <term><parameter>fd</parameter></term> | 28 | <term><parameter>fd</parameter></term> |
29 | <listitem> | 29 | <listitem> |
30 | <para>&fd;</para> | 30 | <para>File descriptor returned by |
31 | <link linkend='media-func-open'><function>open()</function></link>.</para> | ||
31 | </listitem> | 32 | </listitem> |
32 | </varlistentry> | 33 | </varlistentry> |
33 | <varlistentry> | 34 | <varlistentry> |
diff --git a/Documentation/DocBook/v4l/media-ioc-enum-entities.xml b/Documentation/DocBook/v4l/media-ioc-enum-entities.xml new file mode 100644 index 000000000000..13d0cc44865a --- /dev/null +++ b/Documentation/DocBook/v4l/media-ioc-enum-entities.xml | |||
@@ -0,0 +1,308 @@ | |||
1 | <refentry id="media-ioc-enum-entities"> | ||
2 | <refmeta> | ||
3 | <refentrytitle>ioctl MEDIA_IOC_ENUM_ENTITIES</refentrytitle> | ||
4 | &manvol; | ||
5 | </refmeta> | ||
6 | |||
7 | <refnamediv> | ||
8 | <refname>MEDIA_IOC_ENUM_ENTITIES</refname> | ||
9 | <refpurpose>Enumerate entities and their properties</refpurpose> | ||
10 | </refnamediv> | ||
11 | |||
12 | <refsynopsisdiv> | ||
13 | <funcsynopsis> | ||
14 | <funcprototype> | ||
15 | <funcdef>int <function>ioctl</function></funcdef> | ||
16 | <paramdef>int <parameter>fd</parameter></paramdef> | ||
17 | <paramdef>int <parameter>request</parameter></paramdef> | ||
18 | <paramdef>struct media_entity_desc *<parameter>argp</parameter></paramdef> | ||
19 | </funcprototype> | ||
20 | </funcsynopsis> | ||
21 | </refsynopsisdiv> | ||
22 | |||
23 | <refsect1> | ||
24 | <title>Arguments</title> | ||
25 | |||
26 | <variablelist> | ||
27 | <varlistentry> | ||
28 | <term><parameter>fd</parameter></term> | ||
29 | <listitem> | ||
30 | <para>File descriptor returned by | ||
31 | <link linkend='media-func-open'><function>open()</function></link>.</para> | ||
32 | </listitem> | ||
33 | </varlistentry> | ||
34 | <varlistentry> | ||
35 | <term><parameter>request</parameter></term> | ||
36 | <listitem> | ||
37 | <para>MEDIA_IOC_ENUM_ENTITIES</para> | ||
38 | </listitem> | ||
39 | </varlistentry> | ||
40 | <varlistentry> | ||
41 | <term><parameter>argp</parameter></term> | ||
42 | <listitem> | ||
43 | <para></para> | ||
44 | </listitem> | ||
45 | </varlistentry> | ||
46 | </variablelist> | ||
47 | </refsect1> | ||
48 | |||
49 | <refsect1> | ||
50 | <title>Description</title> | ||
51 | <para>To query the attributes of an entity, applications set the id field | ||
52 | of a &media-entity-desc; structure and call the MEDIA_IOC_ENUM_ENTITIES | ||
53 | ioctl with a pointer to this structure. The driver fills the rest of the | ||
54 | structure or returns an &EINVAL; when the id is invalid.</para> | ||
55 | <para>Entities can be enumerated by or'ing the id with the | ||
56 | <constant>MEDIA_ENT_ID_FLAG_NEXT</constant> flag. The driver will return | ||
57 | information about the entity with the smallest id strictly larger than the | ||
58 | requested one ('next entity'), or the &EINVAL; if there is none.</para> | ||
59 | <para>Entity IDs can be non-contiguous. Applications must | ||
60 | <emphasis>not</emphasis> try to enumerate entities by calling | ||
61 | MEDIA_IOC_ENUM_ENTITIES with increasing id's until they get an error.</para> | ||
62 | <para>Two or more entities that share a common non-zero | ||
63 | <structfield>group_id</structfield> value are considered as logically | ||
64 | grouped. Groups are used to report | ||
65 | <itemizedlist> | ||
66 | <listitem>ALSA, VBI and video nodes that carry the same media | ||
67 | stream</listitem> | ||
68 | <listitem>lens and flash controllers associated with a sensor</listitem> | ||
69 | </itemizedlist> | ||
70 | </para> | ||
71 | |||
72 | <table pgwide="1" frame="none" id="media-entity-desc"> | ||
73 | <title>struct <structname>media_entity_desc</structname></title> | ||
74 | <tgroup cols="5"> | ||
75 | <colspec colname="c1" /> | ||
76 | <colspec colname="c2" /> | ||
77 | <colspec colname="c3" /> | ||
78 | <colspec colname="c4" /> | ||
79 | <colspec colname="c5" /> | ||
80 | <tbody valign="top"> | ||
81 | <row> | ||
82 | <entry>__u32</entry> | ||
83 | <entry><structfield>id</structfield></entry> | ||
84 | <entry></entry> | ||
85 | <entry></entry> | ||
86 | <entry>Entity id, set by the application. When the id is or'ed with | ||
87 | <constant>MEDIA_ENT_ID_FLAG_NEXT</constant>, the driver clears the | ||
88 | flag and returns the first entity with a larger id.</entry> | ||
89 | </row> | ||
90 | <row> | ||
91 | <entry>char</entry> | ||
92 | <entry><structfield>name</structfield>[32]</entry> | ||
93 | <entry></entry> | ||
94 | <entry></entry> | ||
95 | <entry>Entity name as an UTF-8 NULL-terminated string.</entry> | ||
96 | </row> | ||
97 | <row> | ||
98 | <entry>__u32</entry> | ||
99 | <entry><structfield>type</structfield></entry> | ||
100 | <entry></entry> | ||
101 | <entry></entry> | ||
102 | <entry>Entity type, see <xref linkend="media-entity-type" /> for details.</entry> | ||
103 | </row> | ||
104 | <row> | ||
105 | <entry>__u32</entry> | ||
106 | <entry><structfield>revision</structfield></entry> | ||
107 | <entry></entry> | ||
108 | <entry></entry> | ||
109 | <entry>Entity revision in a driver/hardware specific format.</entry> | ||
110 | </row> | ||
111 | <row> | ||
112 | <entry>__u32</entry> | ||
113 | <entry><structfield>flags</structfield></entry> | ||
114 | <entry></entry> | ||
115 | <entry></entry> | ||
116 | <entry>Entity flags, see <xref linkend="media-entity-flag" /> for details.</entry> | ||
117 | </row> | ||
118 | <row> | ||
119 | <entry>__u32</entry> | ||
120 | <entry><structfield>group_id</structfield></entry> | ||
121 | <entry></entry> | ||
122 | <entry></entry> | ||
123 | <entry>Entity group ID</entry> | ||
124 | </row> | ||
125 | <row> | ||
126 | <entry>__u16</entry> | ||
127 | <entry><structfield>pads</structfield></entry> | ||
128 | <entry></entry> | ||
129 | <entry></entry> | ||
130 | <entry>Number of pads</entry> | ||
131 | </row> | ||
132 | <row> | ||
133 | <entry>__u16</entry> | ||
134 | <entry><structfield>links</structfield></entry> | ||
135 | <entry></entry> | ||
136 | <entry></entry> | ||
137 | <entry>Total number of outbound links. Inbound links are not counted | ||
138 | in this field.</entry> | ||
139 | </row> | ||
140 | <row> | ||
141 | <entry>union</entry> | ||
142 | </row> | ||
143 | <row> | ||
144 | <entry></entry> | ||
145 | <entry>struct</entry> | ||
146 | <entry><structfield>v4l</structfield></entry> | ||
147 | <entry></entry> | ||
148 | <entry>Valid for V4L sub-devices and nodes only.</entry> | ||
149 | </row> | ||
150 | <row> | ||
151 | <entry></entry> | ||
152 | <entry></entry> | ||
153 | <entry>__u32</entry> | ||
154 | <entry><structfield>major</structfield></entry> | ||
155 | <entry>V4L device node major number. For V4L sub-devices with no | ||
156 | device node, set by the driver to 0.</entry> | ||
157 | </row> | ||
158 | <row> | ||
159 | <entry></entry> | ||
160 | <entry></entry> | ||
161 | <entry>__u32</entry> | ||
162 | <entry><structfield>minor</structfield></entry> | ||
163 | <entry>V4L device node minor number. For V4L sub-devices with no | ||
164 | device node, set by the driver to 0.</entry> | ||
165 | </row> | ||
166 | <row> | ||
167 | <entry></entry> | ||
168 | <entry>struct</entry> | ||
169 | <entry><structfield>fb</structfield></entry> | ||
170 | <entry></entry> | ||
171 | <entry>Valid for frame buffer nodes only.</entry> | ||
172 | </row> | ||
173 | <row> | ||
174 | <entry></entry> | ||
175 | <entry></entry> | ||
176 | <entry>__u32</entry> | ||
177 | <entry><structfield>major</structfield></entry> | ||
178 | <entry>Frame buffer device node major number.</entry> | ||
179 | </row> | ||
180 | <row> | ||
181 | <entry></entry> | ||
182 | <entry></entry> | ||
183 | <entry>__u32</entry> | ||
184 | <entry><structfield>minor</structfield></entry> | ||
185 | <entry>Frame buffer device node minor number.</entry> | ||
186 | </row> | ||
187 | <row> | ||
188 | <entry></entry> | ||
189 | <entry>struct</entry> | ||
190 | <entry><structfield>alsa</structfield></entry> | ||
191 | <entry></entry> | ||
192 | <entry>Valid for ALSA devices only.</entry> | ||
193 | </row> | ||
194 | <row> | ||
195 | <entry></entry> | ||
196 | <entry></entry> | ||
197 | <entry>__u32</entry> | ||
198 | <entry><structfield>card</structfield></entry> | ||
199 | <entry>ALSA card number</entry> | ||
200 | </row> | ||
201 | <row> | ||
202 | <entry></entry> | ||
203 | <entry></entry> | ||
204 | <entry>__u32</entry> | ||
205 | <entry><structfield>device</structfield></entry> | ||
206 | <entry>ALSA device number</entry> | ||
207 | </row> | ||
208 | <row> | ||
209 | <entry></entry> | ||
210 | <entry></entry> | ||
211 | <entry>__u32</entry> | ||
212 | <entry><structfield>subdevice</structfield></entry> | ||
213 | <entry>ALSA sub-device number</entry> | ||
214 | </row> | ||
215 | <row> | ||
216 | <entry></entry> | ||
217 | <entry>int</entry> | ||
218 | <entry><structfield>dvb</structfield></entry> | ||
219 | <entry></entry> | ||
220 | <entry>DVB card number</entry> | ||
221 | </row> | ||
222 | <row> | ||
223 | <entry></entry> | ||
224 | <entry>__u8</entry> | ||
225 | <entry><structfield>raw</structfield>[180]</entry> | ||
226 | <entry></entry> | ||
227 | <entry></entry> | ||
228 | </row> | ||
229 | </tbody> | ||
230 | </tgroup> | ||
231 | </table> | ||
232 | |||
233 | <table frame="none" pgwide="1" id="media-entity-type"> | ||
234 | <title>Media entity types</title> | ||
235 | <tgroup cols="2"> | ||
236 | <colspec colname="c1"/> | ||
237 | <colspec colname="c2"/> | ||
238 | <tbody valign="top"> | ||
239 | <row> | ||
240 | <entry><constant>MEDIA_ENT_T_DEVNODE</constant></entry> | ||
241 | <entry>Unknown device node</entry> | ||
242 | </row> | ||
243 | <row> | ||
244 | <entry><constant>MEDIA_ENT_T_DEVNODE_V4L</constant></entry> | ||
245 | <entry>V4L video, radio or vbi device node</entry> | ||
246 | </row> | ||
247 | <row> | ||
248 | <entry><constant>MEDIA_ENT_T_DEVNODE_FB</constant></entry> | ||
249 | <entry>Frame buffer device node</entry> | ||
250 | </row> | ||
251 | <row> | ||
252 | <entry><constant>MEDIA_ENT_T_DEVNODE_ALSA</constant></entry> | ||
253 | <entry>ALSA card</entry> | ||
254 | </row> | ||
255 | <row> | ||
256 | <entry><constant>MEDIA_ENT_T_DEVNODE_DVB</constant></entry> | ||
257 | <entry>DVB card</entry> | ||
258 | </row> | ||
259 | <row> | ||
260 | <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV</constant></entry> | ||
261 | <entry>Unknown V4L sub-device</entry> | ||
262 | </row> | ||
263 | <row> | ||
264 | <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_SENSOR</constant></entry> | ||
265 | <entry>Video sensor</entry> | ||
266 | </row> | ||
267 | <row> | ||
268 | <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_FLASH</constant></entry> | ||
269 | <entry>Flash controller</entry> | ||
270 | </row> | ||
271 | <row> | ||
272 | <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_LENS</constant></entry> | ||
273 | <entry>Lens controller</entry> | ||
274 | </row> | ||
275 | </tbody> | ||
276 | </tgroup> | ||
277 | </table> | ||
278 | |||
279 | <table frame="none" pgwide="1" id="media-entity-flag"> | ||
280 | <title>Media entity flags</title> | ||
281 | <tgroup cols="2"> | ||
282 | <colspec colname="c1"/> | ||
283 | <colspec colname="c2"/> | ||
284 | <tbody valign="top"> | ||
285 | <row> | ||
286 | <entry><constant>MEDIA_ENT_FL_DEFAULT</constant></entry> | ||
287 | <entry>Default entity for its type. Used to discover the default | ||
288 | audio, VBI and video devices, the default camera sensor, ...</entry> | ||
289 | </row> | ||
290 | </tbody> | ||
291 | </tgroup> | ||
292 | </table> | ||
293 | </refsect1> | ||
294 | |||
295 | <refsect1> | ||
296 | &return-value; | ||
297 | |||
298 | <variablelist> | ||
299 | <varlistentry> | ||
300 | <term><errorcode>EINVAL</errorcode></term> | ||
301 | <listitem> | ||
302 | <para>The &media-entity-desc; <structfield>id</structfield> references | ||
303 | a non-existing entity.</para> | ||
304 | </listitem> | ||
305 | </varlistentry> | ||
306 | </variablelist> | ||
307 | </refsect1> | ||
308 | </refentry> | ||
diff --git a/Documentation/DocBook/v4l/media-ioc-enum-links.xml b/Documentation/DocBook/v4l/media-ioc-enum-links.xml new file mode 100644 index 000000000000..6da884159cab --- /dev/null +++ b/Documentation/DocBook/v4l/media-ioc-enum-links.xml | |||
@@ -0,0 +1,202 @@ | |||
1 | <refentry id="media-ioc-enum-links"> | ||
2 | <refmeta> | ||
3 | <refentrytitle>ioctl MEDIA_IOC_ENUM_LINKS</refentrytitle> | ||
4 | &manvol; | ||
5 | </refmeta> | ||
6 | |||
7 | <refnamediv> | ||
8 | <refname>MEDIA_IOC_ENUM_LINKS</refname> | ||
9 | <refpurpose>Enumerate all pads and links for a given entity</refpurpose> | ||
10 | </refnamediv> | ||
11 | |||
12 | <refsynopsisdiv> | ||
13 | <funcsynopsis> | ||
14 | <funcprototype> | ||
15 | <funcdef>int <function>ioctl</function></funcdef> | ||
16 | <paramdef>int <parameter>fd</parameter></paramdef> | ||
17 | <paramdef>int <parameter>request</parameter></paramdef> | ||
18 | <paramdef>struct media_links_enum *<parameter>argp</parameter></paramdef> | ||
19 | </funcprototype> | ||
20 | </funcsynopsis> | ||
21 | </refsynopsisdiv> | ||
22 | |||
23 | <refsect1> | ||
24 | <title>Arguments</title> | ||
25 | |||
26 | <variablelist> | ||
27 | <varlistentry> | ||
28 | <term><parameter>fd</parameter></term> | ||
29 | <listitem> | ||
30 | <para>File descriptor returned by | ||
31 | <link linkend='media-func-open'><function>open()</function></link>.</para> | ||
32 | </listitem> | ||
33 | </varlistentry> | ||
34 | <varlistentry> | ||
35 | <term><parameter>request</parameter></term> | ||
36 | <listitem> | ||
37 | <para>MEDIA_IOC_ENUM_LINKS</para> | ||
38 | </listitem> | ||
39 | </varlistentry> | ||
40 | <varlistentry> | ||
41 | <term><parameter>argp</parameter></term> | ||
42 | <listitem> | ||
43 | <para></para> | ||
44 | </listitem> | ||
45 | </varlistentry> | ||
46 | </variablelist> | ||
47 | </refsect1> | ||
48 | |||
49 | <refsect1> | ||
50 | <title>Description</title> | ||
51 | |||
52 | <para>To enumerate pads and/or links for a given entity, applications set | ||
53 | the entity field of a &media-links-enum; structure and initialize the | ||
54 | &media-pad-desc; and &media-link-desc; structure arrays pointed by the | ||
55 | <structfield>pads</structfield> and <structfield>links</structfield> fields. | ||
56 | They then call the MEDIA_IOC_ENUM_LINKS ioctl with a pointer to this | ||
57 | structure.</para> | ||
58 | <para>If the <structfield>pads</structfield> field is not NULL, the driver | ||
59 | fills the <structfield>pads</structfield> array with information about the | ||
60 | entity's pads. The array must have enough room to store all the entity's | ||
61 | pads. The number of pads can be retrieved with the &MEDIA-IOC-ENUM-ENTITIES; | ||
62 | ioctl.</para> | ||
63 | <para>If the <structfield>links</structfield> field is not NULL, the driver | ||
64 | fills the <structfield>links</structfield> array with information about the | ||
65 | entity's outbound links. The array must have enough room to store all the | ||
66 | entity's outbound links. The number of outbound links can be retrieved with | ||
67 | the &MEDIA-IOC-ENUM-ENTITIES; ioctl.</para> | ||
68 | <para>Only forward links that originate at one of the entity's source pads | ||
69 | are returned during the enumeration process.</para> | ||
70 | |||
71 | <table pgwide="1" frame="none" id="media-links-enum"> | ||
72 | <title>struct <structname>media_links_enum</structname></title> | ||
73 | <tgroup cols="3"> | ||
74 | &cs-str; | ||
75 | <tbody valign="top"> | ||
76 | <row> | ||
77 | <entry>__u32</entry> | ||
78 | <entry><structfield>entity</structfield></entry> | ||
79 | <entry>Entity id, set by the application.</entry> | ||
80 | </row> | ||
81 | <row> | ||
82 | <entry>struct &media-pad-desc;</entry> | ||
83 | <entry>*<structfield>pads</structfield></entry> | ||
84 | <entry>Pointer to a pads array allocated by the application. Ignored | ||
85 | if NULL.</entry> | ||
86 | </row> | ||
87 | <row> | ||
88 | <entry>struct &media-link-desc;</entry> | ||
89 | <entry>*<structfield>links</structfield></entry> | ||
90 | <entry>Pointer to a links array allocated by the application. Ignored | ||
91 | if NULL.</entry> | ||
92 | </row> | ||
93 | </tbody> | ||
94 | </tgroup> | ||
95 | </table> | ||
96 | |||
97 | <table pgwide="1" frame="none" id="media-pad-desc"> | ||
98 | <title>struct <structname>media_pad_desc</structname></title> | ||
99 | <tgroup cols="3"> | ||
100 | &cs-str; | ||
101 | <tbody valign="top"> | ||
102 | <row> | ||
103 | <entry>__u32</entry> | ||
104 | <entry><structfield>entity</structfield></entry> | ||
105 | <entry>ID of the entity this pad belongs to.</entry> | ||
106 | </row> | ||
107 | <row> | ||
108 | <entry>__u16</entry> | ||
109 | <entry><structfield>index</structfield></entry> | ||
110 | <entry>0-based pad index.</entry> | ||
111 | </row> | ||
112 | <row> | ||
113 | <entry>__u32</entry> | ||
114 | <entry><structfield>flags</structfield></entry> | ||
115 | <entry>Pad flags, see <xref linkend="media-pad-flag" /> for more details.</entry> | ||
116 | </row> | ||
117 | </tbody> | ||
118 | </tgroup> | ||
119 | </table> | ||
120 | |||
121 | <table frame="none" pgwide="1" id="media-pad-flag"> | ||
122 | <title>Media pad flags</title> | ||
123 | <tgroup cols="2"> | ||
124 | <colspec colname="c1"/> | ||
125 | <colspec colname="c2"/> | ||
126 | <tbody valign="top"> | ||
127 | <row> | ||
128 | <entry><constant>MEDIA_PAD_FL_SINK</constant></entry> | ||
129 | <entry>Input pad, relative to the entity. Input pads sink data and | ||
130 | are targets of links.</entry> | ||
131 | </row> | ||
132 | <row> | ||
133 | <entry><constant>MEDIA_PAD_FL_SOURCE</constant></entry> | ||
134 | <entry>Output pad, relative to the entity. Output pads source data | ||
135 | and are origins of links.</entry> | ||
136 | </row> | ||
137 | </tbody> | ||
138 | </tgroup> | ||
139 | </table> | ||
140 | |||
141 | <table pgwide="1" frame="none" id="media-link-desc"> | ||
142 | <title>struct <structname>media_links_desc</structname></title> | ||
143 | <tgroup cols="3"> | ||
144 | &cs-str; | ||
145 | <tbody valign="top"> | ||
146 | <row> | ||
147 | <entry>struct &media-pad-desc;</entry> | ||
148 | <entry><structfield>source</structfield></entry> | ||
149 | <entry>Pad at the origin of this link.</entry> | ||
150 | </row> | ||
151 | <row> | ||
152 | <entry>struct &media-pad-desc;</entry> | ||
153 | <entry><structfield>sink</structfield></entry> | ||
154 | <entry>Pad at the target of this link.</entry> | ||
155 | </row> | ||
156 | <row> | ||
157 | <entry>__u32</entry> | ||
158 | <entry><structfield>flags</structfield></entry> | ||
159 | <entry>Link flags, see <xref linkend="media-link-flag" /> for more details.</entry> | ||
160 | </row> | ||
161 | </tbody> | ||
162 | </tgroup> | ||
163 | </table> | ||
164 | |||
165 | <table frame="none" pgwide="1" id="media-link-flag"> | ||
166 | <title>Media link flags</title> | ||
167 | <tgroup cols="2"> | ||
168 | <colspec colname="c1"/> | ||
169 | <colspec colname="c2"/> | ||
170 | <tbody valign="top"> | ||
171 | <row> | ||
172 | <entry><constant>MEDIA_LNK_FL_ENABLED</constant></entry> | ||
173 | <entry>The link is enabled and can be used to transfer media data. | ||
174 | When two or more links target a sink pad, only one of them can be | ||
175 | enabled at a time.</entry> | ||
176 | </row> | ||
177 | <row> | ||
178 | <entry><constant>MEDIA_LNK_FL_IMMUTABLE</constant></entry> | ||
179 | <entry>The link enabled state can't be modified at runtime. An | ||
180 | immutable link is always enabled.</entry> | ||
181 | </row> | ||
182 | </tbody> | ||
183 | </tgroup> | ||
184 | </table> | ||
185 | <para>One and only one of <constant>MEDIA_PAD_FL_SINK</constant> and | ||
186 | <constant>MEDIA_PAD_FL_SOURCE</constant> must be set for every pad.</para> | ||
187 | </refsect1> | ||
188 | |||
189 | <refsect1> | ||
190 | &return-value; | ||
191 | |||
192 | <variablelist> | ||
193 | <varlistentry> | ||
194 | <term><errorcode>EINVAL</errorcode></term> | ||
195 | <listitem> | ||
196 | <para>The &media-links-enum; <structfield>id</structfield> references | ||
197 | a non-existing entity.</para> | ||
198 | </listitem> | ||
199 | </varlistentry> | ||
200 | </variablelist> | ||
201 | </refsect1> | ||
202 | </refentry> | ||
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 92e0d4eb84b8..648a9d892ac1 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c | |||
@@ -61,6 +61,117 @@ static int media_device_get_info(struct media_device *dev, | |||
61 | return copy_to_user(__info, &info, sizeof(*__info)); | 61 | return copy_to_user(__info, &info, sizeof(*__info)); |
62 | } | 62 | } |
63 | 63 | ||
64 | static struct media_entity *find_entity(struct media_device *mdev, u32 id) | ||
65 | { | ||
66 | struct media_entity *entity; | ||
67 | int next = id & MEDIA_ENT_ID_FLAG_NEXT; | ||
68 | |||
69 | id &= ~MEDIA_ENT_ID_FLAG_NEXT; | ||
70 | |||
71 | spin_lock(&mdev->lock); | ||
72 | |||
73 | media_device_for_each_entity(entity, mdev) { | ||
74 | if ((entity->id == id && !next) || | ||
75 | (entity->id > id && next)) { | ||
76 | spin_unlock(&mdev->lock); | ||
77 | return entity; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | spin_unlock(&mdev->lock); | ||
82 | |||
83 | return NULL; | ||
84 | } | ||
85 | |||
86 | static long media_device_enum_entities(struct media_device *mdev, | ||
87 | struct media_entity_desc __user *uent) | ||
88 | { | ||
89 | struct media_entity *ent; | ||
90 | struct media_entity_desc u_ent; | ||
91 | |||
92 | if (copy_from_user(&u_ent.id, &uent->id, sizeof(u_ent.id))) | ||
93 | return -EFAULT; | ||
94 | |||
95 | ent = find_entity(mdev, u_ent.id); | ||
96 | |||
97 | if (ent == NULL) | ||
98 | return -EINVAL; | ||
99 | |||
100 | u_ent.id = ent->id; | ||
101 | u_ent.name[0] = '\0'; | ||
102 | if (ent->name) | ||
103 | strlcpy(u_ent.name, ent->name, sizeof(u_ent.name)); | ||
104 | u_ent.type = ent->type; | ||
105 | u_ent.revision = ent->revision; | ||
106 | u_ent.flags = ent->flags; | ||
107 | u_ent.group_id = ent->group_id; | ||
108 | u_ent.pads = ent->num_pads; | ||
109 | u_ent.links = ent->num_links - ent->num_backlinks; | ||
110 | u_ent.v4l.major = ent->v4l.major; | ||
111 | u_ent.v4l.minor = ent->v4l.minor; | ||
112 | if (copy_to_user(uent, &u_ent, sizeof(u_ent))) | ||
113 | return -EFAULT; | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static void media_device_kpad_to_upad(const struct media_pad *kpad, | ||
118 | struct media_pad_desc *upad) | ||
119 | { | ||
120 | upad->entity = kpad->entity->id; | ||
121 | upad->index = kpad->index; | ||
122 | upad->flags = kpad->flags; | ||
123 | } | ||
124 | |||
125 | static long media_device_enum_links(struct media_device *mdev, | ||
126 | struct media_links_enum __user *ulinks) | ||
127 | { | ||
128 | struct media_entity *entity; | ||
129 | struct media_links_enum links; | ||
130 | |||
131 | if (copy_from_user(&links, ulinks, sizeof(links))) | ||
132 | return -EFAULT; | ||
133 | |||
134 | entity = find_entity(mdev, links.entity); | ||
135 | if (entity == NULL) | ||
136 | return -EINVAL; | ||
137 | |||
138 | if (links.pads) { | ||
139 | unsigned int p; | ||
140 | |||
141 | for (p = 0; p < entity->num_pads; p++) { | ||
142 | struct media_pad_desc pad; | ||
143 | media_device_kpad_to_upad(&entity->pads[p], &pad); | ||
144 | if (copy_to_user(&links.pads[p], &pad, sizeof(pad))) | ||
145 | return -EFAULT; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | if (links.links) { | ||
150 | struct media_link_desc __user *ulink; | ||
151 | unsigned int l; | ||
152 | |||
153 | for (l = 0, ulink = links.links; l < entity->num_links; l++) { | ||
154 | struct media_link_desc link; | ||
155 | |||
156 | /* Ignore backlinks. */ | ||
157 | if (entity->links[l].source->entity != entity) | ||
158 | continue; | ||
159 | |||
160 | media_device_kpad_to_upad(entity->links[l].source, | ||
161 | &link.source); | ||
162 | media_device_kpad_to_upad(entity->links[l].sink, | ||
163 | &link.sink); | ||
164 | link.flags = entity->links[l].flags; | ||
165 | if (copy_to_user(ulink, &link, sizeof(*ulink))) | ||
166 | return -EFAULT; | ||
167 | ulink++; | ||
168 | } | ||
169 | } | ||
170 | if (copy_to_user(ulinks, &links, sizeof(*ulinks))) | ||
171 | return -EFAULT; | ||
172 | return 0; | ||
173 | } | ||
174 | |||
64 | static long media_device_ioctl(struct file *filp, unsigned int cmd, | 175 | static long media_device_ioctl(struct file *filp, unsigned int cmd, |
65 | unsigned long arg) | 176 | unsigned long arg) |
66 | { | 177 | { |
@@ -74,6 +185,18 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd, | |||
74 | (struct media_device_info __user *)arg); | 185 | (struct media_device_info __user *)arg); |
75 | break; | 186 | break; |
76 | 187 | ||
188 | case MEDIA_IOC_ENUM_ENTITIES: | ||
189 | ret = media_device_enum_entities(dev, | ||
190 | (struct media_entity_desc __user *)arg); | ||
191 | break; | ||
192 | |||
193 | case MEDIA_IOC_ENUM_LINKS: | ||
194 | mutex_lock(&dev->graph_mutex); | ||
195 | ret = media_device_enum_links(dev, | ||
196 | (struct media_links_enum __user *)arg); | ||
197 | mutex_unlock(&dev->graph_mutex); | ||
198 | break; | ||
199 | |||
77 | default: | 200 | default: |
78 | ret = -ENOIOCTLCMD; | 201 | ret = -ENOIOCTLCMD; |
79 | } | 202 | } |
diff --git a/include/linux/media.h b/include/linux/media.h index 64090db3c1fc..17c93a413677 100644 --- a/include/linux/media.h +++ b/include/linux/media.h | |||
@@ -40,6 +40,91 @@ struct media_device_info { | |||
40 | __u32 reserved[31]; | 40 | __u32 reserved[31]; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) | ||
44 | |||
45 | #define MEDIA_ENT_TYPE_SHIFT 16 | ||
46 | #define MEDIA_ENT_TYPE_MASK 0x00ff0000 | ||
47 | #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff | ||
48 | |||
49 | #define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT) | ||
50 | #define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1) | ||
51 | #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) | ||
52 | #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) | ||
53 | #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) | ||
54 | |||
55 | #define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT) | ||
56 | #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1) | ||
57 | #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2) | ||
58 | #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3) | ||
59 | |||
60 | #define MEDIA_ENT_FL_DEFAULT (1 << 0) | ||
61 | |||
62 | struct media_entity_desc { | ||
63 | __u32 id; | ||
64 | char name[32]; | ||
65 | __u32 type; | ||
66 | __u32 revision; | ||
67 | __u32 flags; | ||
68 | __u32 group_id; | ||
69 | __u16 pads; | ||
70 | __u16 links; | ||
71 | |||
72 | __u32 reserved[4]; | ||
73 | |||
74 | union { | ||
75 | /* Node specifications */ | ||
76 | struct { | ||
77 | __u32 major; | ||
78 | __u32 minor; | ||
79 | } v4l; | ||
80 | struct { | ||
81 | __u32 major; | ||
82 | __u32 minor; | ||
83 | } fb; | ||
84 | struct { | ||
85 | __u32 card; | ||
86 | __u32 device; | ||
87 | __u32 subdevice; | ||
88 | } alsa; | ||
89 | int dvb; | ||
90 | |||
91 | /* Sub-device specifications */ | ||
92 | /* Nothing needed yet */ | ||
93 | __u8 raw[184]; | ||
94 | }; | ||
95 | }; | ||
96 | |||
97 | #define MEDIA_PAD_FL_SINK (1 << 0) | ||
98 | #define MEDIA_PAD_FL_SOURCE (1 << 1) | ||
99 | |||
100 | struct media_pad_desc { | ||
101 | __u32 entity; /* entity ID */ | ||
102 | __u16 index; /* pad index */ | ||
103 | __u32 flags; /* pad flags */ | ||
104 | __u32 reserved[2]; | ||
105 | }; | ||
106 | |||
107 | #define MEDIA_LNK_FL_ENABLED (1 << 0) | ||
108 | #define MEDIA_LNK_FL_IMMUTABLE (1 << 1) | ||
109 | |||
110 | struct media_link_desc { | ||
111 | struct media_pad_desc source; | ||
112 | struct media_pad_desc sink; | ||
113 | __u32 flags; | ||
114 | __u32 reserved[2]; | ||
115 | }; | ||
116 | |||
117 | struct media_links_enum { | ||
118 | __u32 entity; | ||
119 | /* Should have enough room for pads elements */ | ||
120 | struct media_pad_desc __user *pads; | ||
121 | /* Should have enough room for links elements */ | ||
122 | struct media_link_desc __user *links; | ||
123 | __u32 reserved[4]; | ||
124 | }; | ||
125 | |||
43 | #define MEDIA_IOC_DEVICE_INFO _IOWR('M', 1, struct media_device_info) | 126 | #define MEDIA_IOC_DEVICE_INFO _IOWR('M', 1, struct media_device_info) |
127 | #define MEDIA_IOC_ENUM_ENTITIES _IOWR('M', 2, struct media_entity_desc) | ||
128 | #define MEDIA_IOC_ENUM_LINKS _IOWR('M', 3, struct media_links_enum) | ||
44 | 129 | ||
45 | #endif /* __LINUX_MEDIA_H */ | 130 | #endif /* __LINUX_MEDIA_H */ |
diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a9b31d98e3c6..51bdafce72c7 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h | |||
@@ -24,29 +24,7 @@ | |||
24 | #define _MEDIA_ENTITY_H | 24 | #define _MEDIA_ENTITY_H |
25 | 25 | ||
26 | #include <linux/list.h> | 26 | #include <linux/list.h> |
27 | 27 | #include <linux/media.h> | |
28 | #define MEDIA_ENT_TYPE_SHIFT 16 | ||
29 | #define MEDIA_ENT_TYPE_MASK 0x00ff0000 | ||
30 | #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff | ||
31 | |||
32 | #define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT) | ||
33 | #define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1) | ||
34 | #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) | ||
35 | #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) | ||
36 | #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) | ||
37 | |||
38 | #define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT) | ||
39 | #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1) | ||
40 | #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2) | ||
41 | #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3) | ||
42 | |||
43 | #define MEDIA_ENT_FL_DEFAULT (1 << 0) | ||
44 | |||
45 | #define MEDIA_LNK_FL_ENABLED (1 << 0) | ||
46 | #define MEDIA_LNK_FL_IMMUTABLE (1 << 1) | ||
47 | |||
48 | #define MEDIA_PAD_FL_SINK (1 << 0) | ||
49 | #define MEDIA_PAD_FL_SOURCE (1 << 1) | ||
50 | 28 | ||
51 | struct media_link { | 29 | struct media_link { |
52 | struct media_pad *source; /* Source pad */ | 30 | struct media_pad *source; /* Source pad */ |