diff options
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap/media/0013-media-Media-device-information-query.patch')
-rw-r--r-- | extras/recipes-kernel/linux/linux-omap/media/0013-media-Media-device-information-query.patch | 659 |
1 files changed, 659 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap/media/0013-media-Media-device-information-query.patch b/extras/recipes-kernel/linux/linux-omap/media/0013-media-Media-device-information-query.patch new file mode 100644 index 00000000..bf9fcd97 --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap/media/0013-media-Media-device-information-query.patch | |||
@@ -0,0 +1,659 @@ | |||
1 | From cb6936ced565e168ac7f9be06dc3320733aac17f Mon Sep 17 00:00:00 2001 | ||
2 | From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
3 | Date: Wed, 18 Aug 2010 16:41:22 +0200 | ||
4 | Subject: [PATCH 13/43] media: Media device information query | ||
5 | |||
6 | Create the following ioctl and implement it at the media device level to | ||
7 | query device information. | ||
8 | |||
9 | - MEDIA_IOC_DEVICE_INFO: Query media device information | ||
10 | |||
11 | The ioctl and its data structure are defined in the new kernel header | ||
12 | linux/media.h available to userspace applications. | ||
13 | |||
14 | Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
15 | --- | ||
16 | Documentation/DocBook/media-entities.tmpl | 12 ++ | ||
17 | Documentation/DocBook/v4l/media-controller.xml | 10 ++ | ||
18 | Documentation/DocBook/v4l/media-func-close.xml | 59 +++++++++ | ||
19 | Documentation/DocBook/v4l/media-func-ioctl.xml | 116 +++++++++++++++++ | ||
20 | Documentation/DocBook/v4l/media-func-open.xml | 94 ++++++++++++++ | ||
21 | .../DocBook/v4l/media-ioc-device-info.xml | 132 ++++++++++++++++++++ | ||
22 | drivers/media/media-device.c | 57 +++++++++ | ||
23 | include/linux/Kbuild | 1 + | ||
24 | include/linux/media.h | 45 +++++++ | ||
25 | 9 files changed, 526 insertions(+), 0 deletions(-) | ||
26 | create mode 100644 Documentation/DocBook/v4l/media-func-close.xml | ||
27 | create mode 100644 Documentation/DocBook/v4l/media-func-ioctl.xml | ||
28 | create mode 100644 Documentation/DocBook/v4l/media-func-open.xml | ||
29 | create mode 100644 Documentation/DocBook/v4l/media-ioc-device-info.xml | ||
30 | create mode 100644 include/linux/media.h | ||
31 | |||
32 | diff --git a/Documentation/DocBook/media-entities.tmpl b/Documentation/DocBook/media-entities.tmpl | ||
33 | index 61d6f11..6af3375 100644 | ||
34 | --- a/Documentation/DocBook/media-entities.tmpl | ||
35 | +++ b/Documentation/DocBook/media-entities.tmpl | ||
36 | @@ -11,6 +11,10 @@ | ||
37 | <!ENTITY func-select "<link linkend='func-select'><function>select()</function></link>"> | ||
38 | <!ENTITY func-write "<link linkend='func-write'><function>write()</function></link>"> | ||
39 | |||
40 | +<!ENTITY media-func-close "<link linkend='media-func-close'><function>close()</function></link>"> | ||
41 | +<!ENTITY media-func-ioctl "<link linkend='media-func-ioctl'><function>ioctl()</function></link>"> | ||
42 | +<!ENTITY media-func-open "<link linkend='media-func-open'><function>open()</function></link>"> | ||
43 | + | ||
44 | <!-- Ioctls --> | ||
45 | <!ENTITY VIDIOC-CROPCAP "<link linkend='vidioc-cropcap'><constant>VIDIOC_CROPCAP</constant></link>"> | ||
46 | <!ENTITY VIDIOC-DBG-G-CHIP-IDENT "<link linkend='vidioc-dbg-g-chip-ident'><constant>VIDIOC_DBG_G_CHIP_IDENT</constant></link>"> | ||
47 | @@ -87,6 +91,8 @@ | ||
48 | <!ENTITY VIDIOC-TRY-FMT "<link linkend='vidioc-g-fmt'><constant>VIDIOC_TRY_FMT</constant></link>"> | ||
49 | <!ENTITY VIDIOC-UNSUBSCRIBE-EVENT "<link linkend='vidioc-subscribe-event'><constant>VIDIOC_UNSUBSCRIBE_EVENT</constant></link>"> | ||
50 | |||
51 | +<!ENTITY MEDIA-IOC-DEVICE-INFO "<link linkend='media-ioc-device-info'><constant>MEDIA_IOC_DEVICE_INFO</constant></link>"> | ||
52 | + | ||
53 | <!-- Types --> | ||
54 | <!ENTITY v4l2-std-id "<link linkend='v4l2-std-id'>v4l2_std_id</link>"> | ||
55 | |||
56 | @@ -181,6 +187,8 @@ | ||
57 | <!ENTITY v4l2-vbi-format "struct <link linkend='v4l2-vbi-format'>v4l2_vbi_format</link>"> | ||
58 | <!ENTITY v4l2-window "struct <link linkend='v4l2-window'>v4l2_window</link>"> | ||
59 | |||
60 | +<!ENTITY media-device-info "struct <link linkend='media-device-info'>media_device_info</link>"> | ||
61 | + | ||
62 | <!-- Error Codes --> | ||
63 | <!ENTITY EACCES "<errorcode>EACCES</errorcode> error code"> | ||
64 | <!ENTITY EAGAIN "<errorcode>EAGAIN</errorcode> error code"> | ||
65 | @@ -322,6 +330,10 @@ | ||
66 | <!ENTITY sub-media-indices SYSTEM "media-indices.tmpl"> | ||
67 | |||
68 | <!ENTITY sub-media-controller SYSTEM "v4l/media-controller.xml"> | ||
69 | +<!ENTITY sub-media-open SYSTEM "v4l/media-func-open.xml"> | ||
70 | +<!ENTITY sub-media-close SYSTEM "v4l/media-func-close.xml"> | ||
71 | +<!ENTITY sub-media-ioctl SYSTEM "v4l/media-func-ioctl.xml"> | ||
72 | +<!ENTITY sub-media-ioc-device-info SYSTEM "v4l/media-ioc-device-info.xml"> | ||
73 | |||
74 | <!-- Function Reference --> | ||
75 | <!ENTITY close SYSTEM "v4l/func-close.xml"> | ||
76 | diff --git a/Documentation/DocBook/v4l/media-controller.xml b/Documentation/DocBook/v4l/media-controller.xml | ||
77 | index f89228d..a46b786 100644 | ||
78 | --- a/Documentation/DocBook/v4l/media-controller.xml | ||
79 | +++ b/Documentation/DocBook/v4l/media-controller.xml | ||
80 | @@ -74,3 +74,13 @@ | ||
81 | pad to a sink pad.</para> | ||
82 | </section> | ||
83 | </chapter> | ||
84 | + | ||
85 | +<appendix id="media-user-func"> | ||
86 | + <title>Function Reference</title> | ||
87 | + <!-- Keep this alphabetically sorted. --> | ||
88 | + &sub-media-open; | ||
89 | + &sub-media-close; | ||
90 | + &sub-media-ioctl; | ||
91 | + <!-- All ioctls go here. --> | ||
92 | + &sub-media-ioc-device-info; | ||
93 | +</appendix> | ||
94 | diff --git a/Documentation/DocBook/v4l/media-func-close.xml b/Documentation/DocBook/v4l/media-func-close.xml | ||
95 | new file mode 100644 | ||
96 | index 0000000..be149c8 | ||
97 | --- /dev/null | ||
98 | +++ b/Documentation/DocBook/v4l/media-func-close.xml | ||
99 | @@ -0,0 +1,59 @@ | ||
100 | +<refentry id="media-func-close"> | ||
101 | + <refmeta> | ||
102 | + <refentrytitle>media close()</refentrytitle> | ||
103 | + &manvol; | ||
104 | + </refmeta> | ||
105 | + | ||
106 | + <refnamediv> | ||
107 | + <refname>media-close</refname> | ||
108 | + <refpurpose>Close a media device</refpurpose> | ||
109 | + </refnamediv> | ||
110 | + | ||
111 | + <refsynopsisdiv> | ||
112 | + <funcsynopsis> | ||
113 | + <funcsynopsisinfo>#include <unistd.h></funcsynopsisinfo> | ||
114 | + <funcprototype> | ||
115 | + <funcdef>int <function>close</function></funcdef> | ||
116 | + <paramdef>int <parameter>fd</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>&fd;</para> | ||
129 | + </listitem> | ||
130 | + </varlistentry> | ||
131 | + </variablelist> | ||
132 | + </refsect1> | ||
133 | + | ||
134 | + <refsect1> | ||
135 | + <title>Description</title> | ||
136 | + | ||
137 | + <para>Closes the media device. Resources associated with the file descriptor | ||
138 | + are freed. The device configuration remain unchanged.</para> | ||
139 | + </refsect1> | ||
140 | + | ||
141 | + <refsect1> | ||
142 | + <title>Return Value</title> | ||
143 | + | ||
144 | + <para><function>close</function> returns 0 on success. On error, -1 is | ||
145 | + returned, and <varname>errno</varname> is set appropriately. Possible error | ||
146 | + codes are:</para> | ||
147 | + | ||
148 | + <variablelist> | ||
149 | + <varlistentry> | ||
150 | + <term><errorcode>EBADF</errorcode></term> | ||
151 | + <listitem> | ||
152 | + <para><parameter>fd</parameter> is not a valid open file descriptor. | ||
153 | + </para> | ||
154 | + </listitem> | ||
155 | + </varlistentry> | ||
156 | + </variablelist> | ||
157 | + </refsect1> | ||
158 | +</refentry> | ||
159 | diff --git a/Documentation/DocBook/v4l/media-func-ioctl.xml b/Documentation/DocBook/v4l/media-func-ioctl.xml | ||
160 | new file mode 100644 | ||
161 | index 0000000..bda8604 | ||
162 | --- /dev/null | ||
163 | +++ b/Documentation/DocBook/v4l/media-func-ioctl.xml | ||
164 | @@ -0,0 +1,116 @@ | ||
165 | +<refentry id="media-func-ioctl"> | ||
166 | + <refmeta> | ||
167 | + <refentrytitle>media ioctl()</refentrytitle> | ||
168 | + &manvol; | ||
169 | + </refmeta> | ||
170 | + | ||
171 | + <refnamediv> | ||
172 | + <refname>media-ioctl</refname> | ||
173 | + <refpurpose>Control a media device</refpurpose> | ||
174 | + </refnamediv> | ||
175 | + | ||
176 | + <refsynopsisdiv> | ||
177 | + <funcsynopsis> | ||
178 | + <funcsynopsisinfo>#include <sys/ioctl.h></funcsynopsisinfo> | ||
179 | + <funcprototype> | ||
180 | + <funcdef>int <function>ioctl</function></funcdef> | ||
181 | + <paramdef>int <parameter>fd</parameter></paramdef> | ||
182 | + <paramdef>int <parameter>request</parameter></paramdef> | ||
183 | + <paramdef>void *<parameter>argp</parameter></paramdef> | ||
184 | + </funcprototype> | ||
185 | + </funcsynopsis> | ||
186 | + </refsynopsisdiv> | ||
187 | + | ||
188 | + <refsect1> | ||
189 | + <title>Arguments</title> | ||
190 | + | ||
191 | + <variablelist> | ||
192 | + <varlistentry> | ||
193 | + <term><parameter>fd</parameter></term> | ||
194 | + <listitem> | ||
195 | + <para>&fd;</para> | ||
196 | + </listitem> | ||
197 | + </varlistentry> | ||
198 | + <varlistentry> | ||
199 | + <term><parameter>request</parameter></term> | ||
200 | + <listitem> | ||
201 | + <para>Media ioctl request code as defined in the media.h header file, | ||
202 | + for example MEDIA_IOC_SETUP_LINK.</para> | ||
203 | + </listitem> | ||
204 | + </varlistentry> | ||
205 | + <varlistentry> | ||
206 | + <term><parameter>argp</parameter></term> | ||
207 | + <listitem> | ||
208 | + <para>Pointer to a request-specific structure.</para> | ||
209 | + </listitem> | ||
210 | + </varlistentry> | ||
211 | + </variablelist> | ||
212 | + </refsect1> | ||
213 | + | ||
214 | + <refsect1> | ||
215 | + <title>Description</title> | ||
216 | + <para>The <function>ioctl()</function> function manipulates media device | ||
217 | + parameters. The argument <parameter>fd</parameter> must be an open file | ||
218 | + descriptor.</para> | ||
219 | + <para>The ioctl <parameter>request</parameter> code specifies the media | ||
220 | + function to be called. It has encoded in it whether the argument is an | ||
221 | + input, output or read/write parameter, and the size of the argument | ||
222 | + <parameter>argp</parameter> in bytes.</para> | ||
223 | + <para>Macros and structures definitions specifying media ioctl requests and | ||
224 | + their parameters are located in the media.h header file. All media ioctl | ||
225 | + requests, their respective function and parameters are specified in | ||
226 | + <xref linkend="media-user-func" />.</para> | ||
227 | + </refsect1> | ||
228 | + | ||
229 | + <refsect1> | ||
230 | + <title>Return Value</title> | ||
231 | + | ||
232 | + <para><function>ioctl()</function> returns <returnvalue>0</returnvalue> on | ||
233 | + success. On failure, <returnvalue>-1</returnvalue> is returned, and the | ||
234 | + <varname>errno</varname> variable is set appropriately. Generic error codes | ||
235 | + are listed below, and request-specific error codes are listed in the | ||
236 | + individual requests descriptions.</para> | ||
237 | + <para>When an ioctl that takes an output or read/write parameter fails, | ||
238 | + the parameter remains unmodified.</para> | ||
239 | + | ||
240 | + <variablelist> | ||
241 | + <varlistentry> | ||
242 | + <term><errorcode>EBADF</errorcode></term> | ||
243 | + <listitem> | ||
244 | + <para><parameter>fd</parameter> is not a valid open file descriptor. | ||
245 | + </para> | ||
246 | + </listitem> | ||
247 | + </varlistentry> | ||
248 | + <varlistentry> | ||
249 | + <term><errorcode>EFAULT</errorcode></term> | ||
250 | + <listitem> | ||
251 | + <para><parameter>argp</parameter> references an inaccessible memory | ||
252 | + area.</para> | ||
253 | + </listitem> | ||
254 | + </varlistentry> | ||
255 | + <varlistentry> | ||
256 | + <term><errorcode>EINVAL</errorcode></term> | ||
257 | + <listitem> | ||
258 | + <para>The <parameter>request</parameter> or the data pointed to by | ||
259 | + <parameter>argp</parameter> is not valid. This is a very common error | ||
260 | + code, see the individual ioctl requests listed in | ||
261 | + <xref linkend="media-user-func" /> for actual causes.</para> | ||
262 | + </listitem> | ||
263 | + </varlistentry> | ||
264 | + <varlistentry> | ||
265 | + <term><errorcode>ENOMEM</errorcode></term> | ||
266 | + <listitem> | ||
267 | + <para>Insufficient kernel memory was available to complete the | ||
268 | + request.</para> | ||
269 | + </listitem> | ||
270 | + </varlistentry> | ||
271 | + <varlistentry> | ||
272 | + <term><errorcode>ENOTTY</errorcode></term> | ||
273 | + <listitem> | ||
274 | + <para><parameter>fd</parameter> is not associated with a character | ||
275 | + special device.</para> | ||
276 | + </listitem> | ||
277 | + </varlistentry> | ||
278 | + </variablelist> | ||
279 | + </refsect1> | ||
280 | +</refentry> | ||
281 | diff --git a/Documentation/DocBook/v4l/media-func-open.xml b/Documentation/DocBook/v4l/media-func-open.xml | ||
282 | new file mode 100644 | ||
283 | index 0000000..f7df034 | ||
284 | --- /dev/null | ||
285 | +++ b/Documentation/DocBook/v4l/media-func-open.xml | ||
286 | @@ -0,0 +1,94 @@ | ||
287 | +<refentry id="media-func-open"> | ||
288 | + <refmeta> | ||
289 | + <refentrytitle>media open()</refentrytitle> | ||
290 | + &manvol; | ||
291 | + </refmeta> | ||
292 | + | ||
293 | + <refnamediv> | ||
294 | + <refname>media-open</refname> | ||
295 | + <refpurpose>Open a media device</refpurpose> | ||
296 | + </refnamediv> | ||
297 | + | ||
298 | + <refsynopsisdiv> | ||
299 | + <funcsynopsis> | ||
300 | + <funcsynopsisinfo>#include <fcntl.h></funcsynopsisinfo> | ||
301 | + <funcprototype> | ||
302 | + <funcdef>int <function>open</function></funcdef> | ||
303 | + <paramdef>const char *<parameter>device_name</parameter></paramdef> | ||
304 | + <paramdef>int <parameter>flags</parameter></paramdef> | ||
305 | + </funcprototype> | ||
306 | + </funcsynopsis> | ||
307 | + </refsynopsisdiv> | ||
308 | + | ||
309 | + <refsect1> | ||
310 | + <title>Arguments</title> | ||
311 | + | ||
312 | + <variablelist> | ||
313 | + <varlistentry> | ||
314 | + <term><parameter>device_name</parameter></term> | ||
315 | + <listitem> | ||
316 | + <para>Device to be opened.</para> | ||
317 | + </listitem> | ||
318 | + </varlistentry> | ||
319 | + <varlistentry> | ||
320 | + <term><parameter>flags</parameter></term> | ||
321 | + <listitem> | ||
322 | + <para>Open flags. Access mode must be either <constant>O_RDONLY</constant> | ||
323 | + or <constant>O_RDWR</constant>. Other flags have no effect.</para> | ||
324 | + </listitem> | ||
325 | + </varlistentry> | ||
326 | + </variablelist> | ||
327 | + </refsect1> | ||
328 | + <refsect1> | ||
329 | + <title>Description</title> | ||
330 | + <para>To open a media device applications call <function>open()</function> | ||
331 | + with the desired device name. The function has no side effects; the device | ||
332 | + configuration remain unchanged.</para> | ||
333 | + <para>When the device is opened in read-only mode, attemps to modify its | ||
334 | + configuration will result in an error, and <varname>errno</varname> will be | ||
335 | + set to <errorcode>EBADF</errorcode>.</para> | ||
336 | + </refsect1> | ||
337 | + <refsect1> | ||
338 | + <title>Return Value</title> | ||
339 | + | ||
340 | + <para><function>open</function> returns the new file descriptor on success. | ||
341 | + On error, -1 is returned, and <varname>errno</varname> is set appropriately. | ||
342 | + Possible error codes are:</para> | ||
343 | + | ||
344 | + <variablelist> | ||
345 | + <varlistentry> | ||
346 | + <term><errorcode>EACCES</errorcode></term> | ||
347 | + <listitem> | ||
348 | + <para>The requested access to the file is not allowed.</para> | ||
349 | + </listitem> | ||
350 | + </varlistentry> | ||
351 | + <varlistentry> | ||
352 | + <term><errorcode>EMFILE</errorcode></term> | ||
353 | + <listitem> | ||
354 | + <para>The process already has the maximum number of files open. | ||
355 | + </para> | ||
356 | + </listitem> | ||
357 | + </varlistentry> | ||
358 | + <varlistentry> | ||
359 | + <term><errorcode>ENFILE</errorcode></term> | ||
360 | + <listitem> | ||
361 | + <para>The system limit on the total number of open files has been | ||
362 | + reached.</para> | ||
363 | + </listitem> | ||
364 | + </varlistentry> | ||
365 | + <varlistentry> | ||
366 | + <term><errorcode>ENOMEM</errorcode></term> | ||
367 | + <listitem> | ||
368 | + <para>Insufficient kernel memory was available.</para> | ||
369 | + </listitem> | ||
370 | + </varlistentry> | ||
371 | + <varlistentry> | ||
372 | + <term><errorcode>ENXIO</errorcode></term> | ||
373 | + <listitem> | ||
374 | + <para>No device corresponding to this device special file exists. | ||
375 | + </para> | ||
376 | + </listitem> | ||
377 | + </varlistentry> | ||
378 | + </variablelist> | ||
379 | + </refsect1> | ||
380 | +</refentry> | ||
381 | diff --git a/Documentation/DocBook/v4l/media-ioc-device-info.xml b/Documentation/DocBook/v4l/media-ioc-device-info.xml | ||
382 | new file mode 100644 | ||
383 | index 0000000..278a312 | ||
384 | --- /dev/null | ||
385 | +++ b/Documentation/DocBook/v4l/media-ioc-device-info.xml | ||
386 | @@ -0,0 +1,132 @@ | ||
387 | +<refentry id="media-ioc-device-info"> | ||
388 | + <refmeta> | ||
389 | + <refentrytitle>ioctl MEDIA_IOC_DEVICE_INFO</refentrytitle> | ||
390 | + &manvol; | ||
391 | + </refmeta> | ||
392 | + | ||
393 | + <refnamediv> | ||
394 | + <refname>MEDIA_IOC_DEVICE_INFO</refname> | ||
395 | + <refpurpose>Query device information</refpurpose> | ||
396 | + </refnamediv> | ||
397 | + | ||
398 | + <refsynopsisdiv> | ||
399 | + <funcsynopsis> | ||
400 | + <funcprototype> | ||
401 | + <funcdef>int <function>ioctl</function></funcdef> | ||
402 | + <paramdef>int <parameter>fd</parameter></paramdef> | ||
403 | + <paramdef>int <parameter>request</parameter></paramdef> | ||
404 | + <paramdef>struct media_device_info *<parameter>argp</parameter></paramdef> | ||
405 | + </funcprototype> | ||
406 | + </funcsynopsis> | ||
407 | + </refsynopsisdiv> | ||
408 | + | ||
409 | + <refsect1> | ||
410 | + <title>Arguments</title> | ||
411 | + | ||
412 | + <variablelist> | ||
413 | + <varlistentry> | ||
414 | + <term><parameter>fd</parameter></term> | ||
415 | + <listitem> | ||
416 | + <para>&fd;</para> | ||
417 | + </listitem> | ||
418 | + </varlistentry> | ||
419 | + <varlistentry> | ||
420 | + <term><parameter>request</parameter></term> | ||
421 | + <listitem> | ||
422 | + <para>MEDIA_IOC_DEVICE_INFO</para> | ||
423 | + </listitem> | ||
424 | + </varlistentry> | ||
425 | + <varlistentry> | ||
426 | + <term><parameter>argp</parameter></term> | ||
427 | + <listitem> | ||
428 | + <para></para> | ||
429 | + </listitem> | ||
430 | + </varlistentry> | ||
431 | + </variablelist> | ||
432 | + </refsect1> | ||
433 | + | ||
434 | + <refsect1> | ||
435 | + <title>Description</title> | ||
436 | + | ||
437 | + <para>All media devices must support the <constant>MEDIA_IOC_DEVICE_INFO</constant> | ||
438 | + ioctl. To query device information, applications call the ioctl with a | ||
439 | + pointer to a &media-device-info;. The driver fills the structure and returns | ||
440 | + the information to the application. | ||
441 | + The ioctl never fails.</para> | ||
442 | + | ||
443 | + <table pgwide="1" frame="none" id="media-device-info"> | ||
444 | + <title>struct <structname>media_device_info</structname></title> | ||
445 | + <tgroup cols="3"> | ||
446 | + &cs-str; | ||
447 | + <tbody valign="top"> | ||
448 | + <row> | ||
449 | + <entry>char</entry> | ||
450 | + <entry><structfield>driver</structfield>[16]</entry> | ||
451 | + <entry><para>Name of the driver implementing the media API as a | ||
452 | + NUL-terminated ASCII string. The driver version is stored in the | ||
453 | + <structfield>driver_version</structfield> field.</para> | ||
454 | + <para>Driver specific applications can use this information to | ||
455 | + verify the driver identity. It is also useful to work around | ||
456 | + known bugs, or to identify drivers in error reports.</para></entry> | ||
457 | + </row> | ||
458 | + <row> | ||
459 | + <entry>char</entry> | ||
460 | + <entry><structfield>model</structfield>[32]</entry> | ||
461 | + <entry>Device model name as a NUL-terminated UTF-8 string. The | ||
462 | + device version is stored in the <structfield>device_version</structfield> | ||
463 | + field and is not be appended to the model name.</entry> | ||
464 | + </row> | ||
465 | + <row> | ||
466 | + <entry>char</entry> | ||
467 | + <entry><structfield>serial</structfield>[40]</entry> | ||
468 | + <entry>Serial number as a NUL-terminated ASCII string.</entry> | ||
469 | + </row> | ||
470 | + <row> | ||
471 | + <entry>char</entry> | ||
472 | + <entry><structfield>bus_info</structfield>[32]</entry> | ||
473 | + <entry>Location of the device in the system as a NUL-terminated | ||
474 | + ASCII string. This includes the bus type name (PCI, USB, ...) and a | ||
475 | + bus-specific identifier.</entry> | ||
476 | + </row> | ||
477 | + <row> | ||
478 | + <entry>__u32</entry> | ||
479 | + <entry><structfield>media_version</structfield></entry> | ||
480 | + <entry>Media API version, formatted with the | ||
481 | + <constant>KERNEL_VERSION()</constant> macro.</entry> | ||
482 | + </row> | ||
483 | + <row> | ||
484 | + <entry>__u32</entry> | ||
485 | + <entry><structfield>hw_revision</structfield></entry> | ||
486 | + <entry>Hardware device revision in a driver-specific format.</entry> | ||
487 | + </row> | ||
488 | + <row> | ||
489 | + <entry>__u32</entry> | ||
490 | + <entry><structfield>media_version</structfield></entry> | ||
491 | + <entry>Media device driver version, formatted with the | ||
492 | + <constant>KERNEL_VERSION()</constant> macro. Together with the | ||
493 | + <structfield>driver</structfield> field this identifies a particular | ||
494 | + driver.</entry> | ||
495 | + </row> | ||
496 | + <row> | ||
497 | + <entry>__u32</entry> | ||
498 | + <entry><structfield>reserved</structfield>[31]</entry> | ||
499 | + <entry>Reserved for future extensions. Drivers and applications must | ||
500 | + set this array to zero.</entry> | ||
501 | + </row> | ||
502 | + </tbody> | ||
503 | + </tgroup> | ||
504 | + </table> | ||
505 | + <para>The <structfield>serial</structfield> and <structfield>bus_info</structfield> | ||
506 | + fields can be used to distinguish between multiple instances of otherwise | ||
507 | + identical hardware. The serial number takes precedence when provided and can | ||
508 | + be assumed to be unique. If the serial number is an empty string, the | ||
509 | + <structfield>bus_info</structfield> field can be used instead. The | ||
510 | + <structfield>bus_info</structfield> field is guaranteed to be unique, but | ||
511 | + can vary across reboots or device unplug/replug.</para> | ||
512 | + </refsect1> | ||
513 | + | ||
514 | + <refsect1> | ||
515 | + <title>Return value</title> | ||
516 | + <para>This function doesn't return specific error codes.</para> | ||
517 | + </refsect1> | ||
518 | +</refentry> | ||
519 | diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c | ||
520 | index e4c2157..5c745be 100644 | ||
521 | --- a/drivers/media/media-device.c | ||
522 | +++ b/drivers/media/media-device.c | ||
523 | @@ -22,13 +22,70 @@ | ||
524 | |||
525 | #include <linux/types.h> | ||
526 | #include <linux/ioctl.h> | ||
527 | +#include <linux/media.h> | ||
528 | |||
529 | #include <media/media-device.h> | ||
530 | #include <media/media-devnode.h> | ||
531 | #include <media/media-entity.h> | ||
532 | |||
533 | +/* ----------------------------------------------------------------------------- | ||
534 | + * Userspace API | ||
535 | + */ | ||
536 | + | ||
537 | +static int media_device_open(struct file *filp) | ||
538 | +{ | ||
539 | + return 0; | ||
540 | +} | ||
541 | + | ||
542 | +static int media_device_close(struct file *filp) | ||
543 | +{ | ||
544 | + return 0; | ||
545 | +} | ||
546 | + | ||
547 | +static int media_device_get_info(struct media_device *dev, | ||
548 | + struct media_device_info __user *__info) | ||
549 | +{ | ||
550 | + struct media_device_info info; | ||
551 | + | ||
552 | + memset(&info, 0, sizeof(info)); | ||
553 | + | ||
554 | + strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver)); | ||
555 | + strlcpy(info.model, dev->model, sizeof(info.model)); | ||
556 | + strlcpy(info.serial, dev->serial, sizeof(info.serial)); | ||
557 | + strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info)); | ||
558 | + | ||
559 | + info.media_version = MEDIA_API_VERSION; | ||
560 | + info.hw_revision = dev->hw_revision; | ||
561 | + info.driver_version = dev->driver_version; | ||
562 | + | ||
563 | + return copy_to_user(__info, &info, sizeof(*__info)); | ||
564 | +} | ||
565 | + | ||
566 | +static long media_device_ioctl(struct file *filp, unsigned int cmd, | ||
567 | + unsigned long arg) | ||
568 | +{ | ||
569 | + struct media_devnode *devnode = media_devnode_data(filp); | ||
570 | + struct media_device *dev = to_media_device(devnode); | ||
571 | + long ret; | ||
572 | + | ||
573 | + switch (cmd) { | ||
574 | + case MEDIA_IOC_DEVICE_INFO: | ||
575 | + ret = media_device_get_info(dev, | ||
576 | + (struct media_device_info __user *)arg); | ||
577 | + break; | ||
578 | + | ||
579 | + default: | ||
580 | + ret = -ENOIOCTLCMD; | ||
581 | + } | ||
582 | + | ||
583 | + return ret; | ||
584 | +} | ||
585 | + | ||
586 | static const struct media_file_operations media_device_fops = { | ||
587 | .owner = THIS_MODULE, | ||
588 | + .open = media_device_open, | ||
589 | + .ioctl = media_device_ioctl, | ||
590 | + .release = media_device_close, | ||
591 | }; | ||
592 | |||
593 | /* ----------------------------------------------------------------------------- | ||
594 | diff --git a/include/linux/Kbuild b/include/linux/Kbuild | ||
595 | index 97319a8..26e0a7f 100644 | ||
596 | --- a/include/linux/Kbuild | ||
597 | +++ b/include/linux/Kbuild | ||
598 | @@ -228,6 +228,7 @@ header-y += magic.h | ||
599 | header-y += major.h | ||
600 | header-y += map_to_7segment.h | ||
601 | header-y += matroxfb.h | ||
602 | +header-y += media.h | ||
603 | header-y += mempolicy.h | ||
604 | header-y += meye.h | ||
605 | header-y += mii.h | ||
606 | diff --git a/include/linux/media.h b/include/linux/media.h | ||
607 | new file mode 100644 | ||
608 | index 0000000..4c52f08 | ||
609 | --- /dev/null | ||
610 | +++ b/include/linux/media.h | ||
611 | @@ -0,0 +1,45 @@ | ||
612 | +/* | ||
613 | + * Multimedia device API | ||
614 | + * | ||
615 | + * Copyright (C) 2010 Nokia Corporation | ||
616 | + * | ||
617 | + * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
618 | + * Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> | ||
619 | + * | ||
620 | + * This program is free software; you can redistribute it and/or modify | ||
621 | + * it under the terms of the GNU General Public License version 2 as | ||
622 | + * published by the Free Software Foundation. | ||
623 | + * | ||
624 | + * This program is distributed in the hope that it will be useful, | ||
625 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
626 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
627 | + * GNU General Public License for more details. | ||
628 | + * | ||
629 | + * You should have received a copy of the GNU General Public License | ||
630 | + * along with this program; if not, write to the Free Software | ||
631 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
632 | + */ | ||
633 | + | ||
634 | +#ifndef __LINUX_MEDIA_H | ||
635 | +#define __LINUX_MEDIA_H | ||
636 | + | ||
637 | +#include <linux/ioctl.h> | ||
638 | +#include <linux/types.h> | ||
639 | +#include <linux/version.h> | ||
640 | + | ||
641 | +#define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0) | ||
642 | + | ||
643 | +struct media_device_info { | ||
644 | + char driver[16]; | ||
645 | + char model[32]; | ||
646 | + char serial[40]; | ||
647 | + char bus_info[32]; | ||
648 | + __u32 media_version; | ||
649 | + __u32 hw_revision; | ||
650 | + __u32 driver_version; | ||
651 | + __u32 reserved[31]; | ||
652 | +}; | ||
653 | + | ||
654 | +#define MEDIA_IOC_DEVICE_INFO _IOWR('M', 1, struct media_device_info) | ||
655 | + | ||
656 | +#endif /* __LINUX_MEDIA_H */ | ||
657 | -- | ||
658 | 1.6.6.1 | ||
659 | |||